--- /srv/rebuilderd/tmp/rebuilderds0CTT4/inputs/libtorrent-rasterbar-doc_2.1.0-2_all.deb +++ /srv/rebuilderd/tmp/rebuilderds0CTT4/out/libtorrent-rasterbar-doc_2.1.0-2_all.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2026-07-12 05:50:55.000000 debian-binary │ -rw-r--r-- 0 0 0 3700 2026-07-12 05:50:55.000000 control.tar.xz │ --rw-r--r-- 0 0 0 1714988 2026-07-12 05:50:55.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 1718856 2026-07-12 05:50:55.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./control │ │ │ @@ -1,13 +1,13 @@ │ │ │ Package: libtorrent-rasterbar-doc │ │ │ Source: libtorrent-rasterbar │ │ │ Version: 2.1.0-2 │ │ │ Architecture: all │ │ │ Maintainer: Christian Marillat │ │ │ -Installed-Size: 6074 │ │ │ +Installed-Size: 6245 │ │ │ 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) 23659 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/python_binding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 38189 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Add_Torrent.html │ │ │ -rw-r--r-- 0 root (0) root (0) 253520 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Alerts.html │ │ │ -rw-r--r-- 0 root (0) root (0) 27781 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bdecoding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25890 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bencoding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 94758 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Core.html │ │ │ -rw-r--r-- 0 root (0) root (0) 51641 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Create_Torrents.html │ │ │ --rw-r--r-- 0 root (0) root (0) 66108 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 153593 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ -rw-r--r-- 0 root (0) root (0) 27745 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html │ │ │ -rw-r--r-- 0 root (0) root (0) 49936 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Error_Codes.html │ │ │ -rw-r--r-- 0 root (0) root (0) 13278 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Filter.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12819 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-PeerClass.html │ │ │ -rw-r--r-- 0 root (0) root (0) 99978 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Plugins.html │ │ │ -rw-r--r-- 0 root (0) root (0) 10894 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Resume_Data.html │ │ │ -rw-r--r-- 0 root (0) root (0) 103442 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Session.html │ │ │ -rw-r--r-- 0 root (0) root (0) 176222 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Settings.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12839 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Stats.html │ │ │ --rw-r--r-- 0 root (0) root (0) 79643 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ --rw-r--r-- 0 root (0) root (0) 137177 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ --rw-r--r-- 0 root (0) root (0) 33234 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 79635 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 137169 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 33226 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ -rw-r--r-- 0 root (0) root (0) 49668 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Status.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16903 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Trackers.html │ │ │ -rw-r--r-- 0 root (0) root (0) 26549 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Utility.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9128 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-ed25519.html │ │ │ -rw-r--r-- 0 root (0) root (0) 35367 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference.html │ │ │ -rw-r--r-- 0 root (0) root (0) 29242 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/security-audit.html │ │ │ --rw-r--r-- 0 root (0) root (0) 1363573 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 1451034 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 10120 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/streaming.html │ │ │ -rw-r--r-- 0 root (0) root (0) 8807 2026-07-09 11:02:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/style.css │ │ │ --rw-r--r-- 0 root (0) root (0) 547475 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 547478 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ -rw-r--r-- 0 root (0) root (0) 3022 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/troubleshooting.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25164 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tuning-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 132629 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tutorial-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16383 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/udp_tracker_protocol.html │ │ │ -rw-r--r-- 0 root (0) root (0) 18162 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_1.2-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 34652 2026-07-12 05:50:55.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_2.0-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 20295 2026-07-12 05:50:55.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);
│ │ │ +
│ │ │ +

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

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

make_magnet_uri()

│ │ │

Declared in "libtorrent/magnet_uri.hpp"

│ │ │
│ │ │  std::string make_magnet_uri (add_torrent_params const& atp);
│ │ │  
│ │ │ @@ -840,31 +849,22 @@ │ │ │

For more information about magnet links, see magnet links.

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

parse_magnet_uri()

│ │ │

Declared in "libtorrent/magnet_uri.hpp"

│ │ │
│ │ │  add_torrent_params parse_magnet_uri (string_view uri);
│ │ │ -void parse_magnet_uri (string_view uri, add_torrent_params& p, error_code& ec);
│ │ │  add_torrent_params parse_magnet_uri (string_view uri, error_code& ec);
│ │ │ +void parse_magnet_uri (string_view uri, add_torrent_params& p, 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);
│ │ │ -
│ │ │ -

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

│ │ │ [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);
│ │ │ @@ -886,73 +886,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"

│ │ │ │ │ │ │ │ │ │ │ │ @@ -1104,14 +1045,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 │ │ │ @@ -1125,46 +1141,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
│ │ │ @@ -1184,14 +1168,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.0 │ │ │ │ _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_2_(_)_ _h_a_s_(_)_ _h_a_s___v_1_(_) │ │ │ │ - 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___b_u_f_f_e_r_(_)_ _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_(_) │ │ │ │ + * _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 │ │ │ │ +{ │ │ │ │ + web_seed_entry& ooppeerraattoorr== (web_seed_entry const&); │ │ │ │ + wweebb__sseeeedd__eennttrryy (web_seed_entry const&); │ │ │ │ + web_seed_entry& ooppeerraattoorr== (web_seed_entry&&) noexcept; │ │ │ │ + wweebb__sseeeedd__eennttrryy (web_seed_entry&&) noexcept; │ │ │ │ + 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 () noexcept = default; │ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ + iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) 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 () noexcept = default; │ │ │ │ +explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ +iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) 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,54 @@ │ │ │ │ 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 │ │ │ │ -{ │ │ │ │ - iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ - iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ - bool hhaass__vv22 () const; │ │ │ │ - bool hhaass (protocol_version v) 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 () noexcept = default; │ │ │ │ -explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ -iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ -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__vv22(()) hhaass(()) hhaass__vv11(()) ********** │ │ │ │ -bool hhaass__vv22 () const; │ │ │ │ -bool hhaass (protocol_version v) 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] │ │ │ │ -************ 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 const&); │ │ │ │ - wweebb__sseeeedd__eennttrryy (web_seed_entry const&); │ │ │ │ - web_seed_entry& ooppeerraattoorr== (web_seed_entry&&) noexcept; │ │ │ │ - wweebb__sseeeedd__eennttrryy (web_seed_entry&&) noexcept; │ │ │ │ - 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__bbuuffffeerr(()) llooaadd__ttoorrrreenntt__ppaarrsseedd(()) llooaadd__ttoorrrreenntt__ffiillee(()) ************ │ │ │ │ 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__ffiillee ( │ │ │ │ + std::string const& filename); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ - span buffer, error_code& ec, load_torrent_limits const& cfg); │ │ │ │ + span buffer); │ │ │ │ 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); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ span buffer, 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__ffiillee ( │ │ │ │ std::string const& filename, error_code& ec, load_torrent_limits const& │ │ │ │ cfg); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ - span buffer); │ │ │ │ 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); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ - std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ - bdecode_node const& torrent_file, 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); │ │ │ │ +Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ +specified save_path. │ │ │ │ +[_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: │ │ │ │ @@ -617,29 +624,22 @@ │ │ │ │ _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_), which will post a _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t containing an │ │ │ │ _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. This can then be passed to _m_a_k_e___m_a_g_n_e_t___u_r_i_(_). │ │ │ │ For more information about magnet links, see _m_a_g_n_e_t_ _l_i_n_k_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppaarrssee__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" │ │ │ │ add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri); │ │ │ │ -void ppaarrssee__mmaaggnneett__uurrii (string_view uri, add_torrent_params& p, error_code& ec); │ │ │ │ add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri, error_code& ec); │ │ │ │ +void ppaarrssee__mmaaggnneett__uurrii (string_view uri, add_torrent_params& p, 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); │ │ │ │ -Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ -specified save_path. │ │ │ │ -[_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(()) ************ │ │ │ │ @@ -653,29 +653,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_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ @@ -709,45 +694,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 │ │ │ │ @@ -755,14 +745,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,39 +167,39 @@ │ │ │ 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);
    │ │ │     void add_tracker (string_view url, int tier = 0);
    │ │ │     void set_root_cert (string_view cert);
    │ │ │ -   bool priv () const;
    │ │ │     void set_priv (bool p);
    │ │ │ +   bool priv () const;
    │ │ │     bool is_v1_only () const;
    │ │ │     bool is_v2_only () const;
    │ │ │     int num_pieces () const;
    │ │ │     piece_index_t end_piece () const;
    │ │ │     index_range<piece_index_t> piece_range () const noexcept;
    │ │ │     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_size (piece_index_t i) 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);
    │ │ │  
    │ │ │     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;
    │ │ │ @@ -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() generate_buf()

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

    generate_buf() generate()

    │ │ │
    │ │ │ -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,21 +381,21 @@ │ │ │

    │ │ │

    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);
    │ │ │ +bool priv () const;
    │ │ │  
    │ │ │

    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]
    │ │ │ @@ -467,29 +467,29 @@ │ │ │ [report issue] │ │ │
    │ │ │

    total_size()

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

    the total number of bytes of all files and pad files

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

    piece_size() piece_length()

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

    piece_length() piece_size()

    │ │ │
    │ │ │ -int piece_size (piece_index_t i) const;
    │ │ │  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_similar_torrent() add_collection()

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

    add_collection() add_similar_torrent()

    │ │ │
    │ │ │  void add_collection (string_view c);
    │ │ │  void add_similar_torrent (sha1_hash ih);
    │ │ │  
    │ │ │

    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 │ │ │ @@ -580,26 +580,26 @@ │ │ │

    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"

    │ │ │
    │ │ │ -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);
    │ │ │  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, 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
    │ │ │ +   , 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);
    │ │ │ +void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ +   , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │  void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │     , settings_pack const& settings
    │ │ │     , std::function<void(piece_index_t)> const& f, 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 │ │ │ ├── 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_(_)_ _g_e_n_e_r_a_t_e___b_u_f_(_) │ │ │ │ + o _g_e_n_e_r_a_t_e___b_u_f_(_)_ _g_e_n_e_r_a_t_e_(_) │ │ │ │ o _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 _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___s_i_m_i_l_a_r___t_o_r_r_e_n_t_(_)_ _a_d_d___c_o_l_l_e_c_t_i_o_n_(_) │ │ │ │ + o _p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ + 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_(_) │ │ │ │ * _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,40 +116,40 @@ │ │ │ │ _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); │ │ │ │ void aadddd__nnooddee (std::pair node); │ │ │ │ void aadddd__ttrraacckkeerr (string_view url, int tier = 0); │ │ │ │ void sseett__rroooott__cceerrtt (string_view cert); │ │ │ │ - bool pprriivv () const; │ │ │ │ void sseett__pprriivv (bool p); │ │ │ │ + bool pprriivv () const; │ │ │ │ bool iiss__vv11__oonnllyy () const; │ │ │ │ bool iiss__vv22__oonnllyy () const; │ │ │ │ int nnuumm__ppiieecceess () const; │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ file_index_t eenndd__ffiillee () const; │ │ │ │ index_range ffiillee__rraannggee () const noexcept; │ │ │ │ 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__ssiizzee (piece_index_t i) 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); │ │ │ │ │ │ │ │ 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; │ │ │ │ @@ -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(()) ggeenneerraattee__bbuuff(()) ********** │ │ │ │ -entry ggeenneerraattee () const; │ │ │ │ +********** ggeenneerraattee__bbuuff(()) ggeenneerraattee(()) ********** │ │ │ │ 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,17 +287,17 @@ │ │ │ │ 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(()) ********** │ │ │ │ -bool pprriivv () const; │ │ │ │ +********** pprriivv(()) sseett__pprriivv(()) ********** │ │ │ │ void sseett__pprriivv (bool p); │ │ │ │ +bool pprriivv () const; │ │ │ │ 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__vv11__oonnllyy(()) iiss__vv22__oonnllyy(()) ********** │ │ │ │ bool iiss__vv11__oonnllyy () const; │ │ │ │ bool iiss__vv22__oonnllyy () const; │ │ │ │ @@ -338,22 +338,22 @@ │ │ │ │ for v2 and hybrid torrents only, the pieces in the specified file, specified as │ │ │ │ delta from the first piece in the file. i.e. the first index is 0. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ttoottaall__ssiizzee(()) ********** │ │ │ │ std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ the total number of bytes of all files and pad files │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__ssiizzee(()) ppiieeccee__lleennggtthh(()) ********** │ │ │ │ -int ppiieeccee__ssiizzee (piece_index_t i) const; │ │ │ │ +********** ppiieeccee__lleennggtthh(()) ppiieeccee__ssiizzee(()) ********** │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ +int ppiieeccee__ssiizzee (piece_index_t i) const; │ │ │ │ piece_length() returns the piece size of all pieces but the last one. │ │ │ │ piece_size() returns the size of the specified piece. these functions are just │ │ │ │ forwarding to the associated _f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ssiimmiillaarr__ttoorrrreenntt(()) aadddd__ccoolllleeccttiioonn(()) ********** │ │ │ │ +********** aadddd__ccoolllleeccttiioonn(()) aadddd__ssiimmiillaarr__ttoorrrreenntt(()) ********** │ │ │ │ void aadddd__ccoolllleeccttiioonn (string_view c); │ │ │ │ void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih); │ │ │ │ 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. │ │ │ │ @@ -423,27 +423,27 @@ │ │ │ │ directories are traversed. │ │ │ │ The ".." directory is never traversed. │ │ │ │ The flags argument should be the same as the flags passed to the _c_r_e_a_t_e___t_o_r_r_e_n_t │ │ │ │ constructor. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseett__ppiieeccee__hhaasshheess(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ -void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ - , std::function const& f, error_code& ec); │ │ │ │ inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p); │ │ │ │ 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, │ │ │ │ +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 │ │ │ │ + , settings_pack const& settings │ │ │ │ , std::function const& f); │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p, │ │ │ │ -error_code& ec); │ │ │ │ +void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ + , std::function const& f, error_code& ec); │ │ │ │ void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ , settings_pack const& settings │ │ │ │ , std::function const& f, 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: │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ @@ -28,92 +28,418 @@ │ │ │ 2.1.0 │ │ │ │ │ │ │ │ │

    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_bool (int name, bool val) = 0;
    │ │ │ +   virtual void set_int (int name, int val) = 0;
    │ │ │ +   virtual void set_str (int name, std::string val) = 0;
    │ │ │ +   virtual bool has_val (int name) const = 0;
    │ │ │ +   virtual int get_int (int name) const = 0;
    │ │ │ +   virtual std::string const& get_str (int name) const = 0;
    │ │ │ +   virtual bool get_bool (int name) const = 0;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    set_str() set_int() set_bool()

    │ │ │ +
    │ │ │ +virtual void set_bool (int name, bool val) = 0;
    │ │ │ +virtual void set_int (int name, int val) = 0;
    │ │ │ +virtual void set_str (int name, std::string 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 int get_int (int name) const = 0;
    │ │ │ +virtual std::string const& get_str (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;
    │ │ │ @@ -227,21 +553,21 @@
    │ │ │  delete any files from disk, just to clean up any resources associated
    │ │ │  with the specified storage.

    │ │ │ │ │ │ [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 │ │ │ @@ -496,16 +822,16 @@ │ │ │ for a torrent to the lifetime of the internal torrent object. When a │ │ │ torrent is removed from the session, this holder is destructed and will │ │ │ inform the disk object.

    │ │ │
    │ │ │  struct storage_holder
    │ │ │  {
    │ │ │     storage_holder (storage_index_t idx, disk_interface& disk_io);
    │ │ │ -   ~storage_holder ();
    │ │ │     storage_holder () = default;
    │ │ │ +   ~storage_holder ();
    │ │ │     explicit operator bool () const;
    │ │ │     operator storage_index_t () const;
    │ │ │     void reset ();
    │ │ │     storage_holder (storage_holder const&) = delete;
    │ │ │     storage_holder& operator= (storage_holder const&) = delete;
    │ │ │     storage_holder (storage_holder&& rhs) noexcept;
    │ │ │     storage_holder& operator= (storage_holder&& rhs) noexcept;
    │ │ │ @@ -585,18 +911,18 @@
    │ │ │  

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

    │ │ │

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

    │ │ │
    │ │ │  struct disk_buffer_holder
    │ │ │  {
    │ │ │ -   disk_buffer_holder (disk_buffer_holder&&) noexcept;
    │ │ │     disk_buffer_holder& operator= (disk_buffer_holder&&) & noexcept;
    │ │ │ -   disk_buffer_holder& operator= (disk_buffer_holder const&) = delete;
    │ │ │ +   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 (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,21 +999,21 @@
    │ │ │  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& operator= (disk_buffer_ref const&) = delete;
    │ │ │ -   disk_buffer_ref (disk_buffer_ref const&) = delete;
    │ │ │     ~disk_buffer_ref ();
    │ │ │ +   disk_buffer_ref (disk_buffer_ref const&) = delete;
    │ │ │     disk_buffer_ref& operator= (disk_buffer_ref&&) noexcept;
    │ │ │     disk_buffer_ref (disk_buffer_ref&&) noexcept;
    │ │ │ -   char* data () const noexcept;
    │ │ │ +   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;
    │ │ │  
    │ │ │ @@ -696,16 +1022,16 @@ │ │ │ bulk_free_buffer for release; this type cannot free the │ │ │ buffer itself.

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

    data() bool()

    │ │ │
    │ │ │ -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]
    │ │ │
    │ │ │
    │ │ │ @@ -736,73 +1062,14 @@ │ │ │
    │ │ │

    add() ~bulk_free_buffer()

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

    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_int (int name, int val) = 0;
    │ │ │ -   virtual void set_str (int name, std::string 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_int (int name, int val) = 0;
    │ │ │ -virtual void set_str (int name, std::string 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_str() get_int() get_bool()

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

    status_t

    │ │ │

    Declared in "libtorrent/disk_interface.hpp"

    │ │ │
    │ │ │
    fatal_disk_error
    │ │ │ ├── html2text {} │ │ │ │ @@ -1,12 +1,16 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _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___s_t_r_(_)_ _s_e_t___i_n_t_(_)_ _s_e_t___b_o_o_l_(_) │ │ │ │ + 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___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_(_) │ │ │ │ @@ -41,32 +45,356 @@ │ │ │ │ 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_(_) │ │ │ │ * _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 _a_d_d_(_)_ _~_b_u_l_k___f_r_e_e___b_u_f_f_e_r_(_) │ │ │ │ - * _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___s_t_r_(_)_ _g_e_t___i_n_t_(_)_ _g_e_t___b_o_o_l_(_) │ │ │ │ * _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__bbooooll (int name, bool val) = 0; │ │ │ │ + virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ + virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ + virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ + virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ + virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ + virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sseett__ssttrr(()) sseett__iinntt(()) sseett__bbooooll(()) ********** │ │ │ │ +virtual void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ +virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ +virtual void sseett__ssttrr (int name, std::string 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 int ggeett__iinntt (int name) const = 0; │ │ │ │ +virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ +virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ +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 │ │ │ │ @@ -173,21 +501,21 @@ │ │ │ │ ********** rreemmoovvee__ttoorrrreenntt(()) ********** │ │ │ │ virtual void rreemmoovvee__ttoorrrreenntt (storage_index_t) = 0; │ │ │ │ remove the storage with the specified index. This is not expected to delete any │ │ │ │ files from disk, just to clean up any resources associated with the specified │ │ │ │ storage. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aassyynncc__wwrriittee(()) aassyynncc__rreeaadd(()) ********** │ │ │ │ -virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r │ │ │ │ - , std::function handler │ │ │ │ - , disk_job_flags_t flags = {}) = 0; │ │ │ │ virtual bool aassyynncc__wwrriittee (storage_index_t storage, peer_request const& r │ │ │ │ , char const* buf, std::shared_ptr o │ │ │ │ , std::function handler │ │ │ │ , disk_job_flags_t flags = {}) = 0; │ │ │ │ +virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r │ │ │ │ + , std::function handler │ │ │ │ + , disk_job_flags_t flags = {}) = 0; │ │ │ │ perform a read or write operation from/to the specified storage index and the │ │ │ │ specified request. When the operation completes, call handler possibly with a │ │ │ │ _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r, holding the buffer with the result. Flags may be set to │ │ │ │ affect the read operation. See disk_job_flags_t. │ │ │ │ The _d_i_s_k___o_b_s_e_r_v_e_r is a callback to indicate that the store buffer/disk write │ │ │ │ queue is below the watermark to let peers start writing buffers to disk again. │ │ │ │ When async_write() returns true, indicating the write queue is full, the peer │ │ │ │ @@ -378,16 +706,16 @@ │ │ │ │ (class that implements _d_i_s_k___i_n_t_e_r_f_a_c_e). This is held by the internal libtorrent │ │ │ │ torrent object to tie the storage object allocated for a torrent to the │ │ │ │ lifetime of the internal torrent object. When a torrent is removed from the │ │ │ │ _s_e_s_s_i_o_n, this holder is destructed and will inform the disk object. │ │ │ │ struct storage_holder │ │ │ │ { │ │ │ │ ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io); │ │ │ │ - ~~ssttoorraaggee__hhoollddeerr (); │ │ │ │ ssttoorraaggee__hhoollddeerr () = default; │ │ │ │ + ~~ssttoorraaggee__hhoollddeerr (); │ │ │ │ explicit operator bbooooll () const; │ │ │ │ operator ssttoorraaggee__iinnddeexx__tt () const; │ │ │ │ void rreesseett (); │ │ │ │ ssttoorraaggee__hhoollddeerr (storage_holder const&) = delete; │ │ │ │ storage_holder& ooppeerraattoorr== (storage_holder const&) = delete; │ │ │ │ ssttoorraaggee__hhoollddeerr (storage_holder&& rhs) noexcept; │ │ │ │ storage_holder& ooppeerraattoorr== (storage_holder&& rhs) noexcept; │ │ │ │ @@ -442,18 +770,18 @@ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p" │ │ │ │ The disk buffer holder acts like a unique_ptr that frees a disk buffer when │ │ │ │ it's destructed │ │ │ │ If this buffer holder is moved-from, default constructed or reset, data() will │ │ │ │ return nullptr. │ │ │ │ struct disk_buffer_holder │ │ │ │ { │ │ │ │ - ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder&&) noexcept; │ │ │ │ disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder&&) & noexcept; │ │ │ │ - disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder const&) = delete; │ │ │ │ + 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 (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,32 +829,32 @@ │ │ │ │ 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; │ │ │ │ - disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref const&) = delete; │ │ │ │ - ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref const&) = delete; │ │ │ │ ~~ddiisskk__bbuuffffeerr__rreeff (); │ │ │ │ + ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref const&) = delete; │ │ │ │ disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref&&) noexcept; │ │ │ │ ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref&&) noexcept; │ │ │ │ - char* ddaattaa () const noexcept; │ │ │ │ + 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; │ │ │ │ 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 │ │ │ │ @@ -545,53 +873,14 @@ │ │ │ │ destructor. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aadddd(()) ~~bbuullkk__ffrreeee__bbuuffffeerr(()) ********** │ │ │ │ ~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ void aadddd (disk_buffer_ref r); │ │ │ │ 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__iinntt (int name, int val) = 0; │ │ │ │ - virtual void sseett__ssttrr (int name, std::string 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__iinntt (int name, int val) = 0; │ │ │ │ -virtual void sseett__ssttrr (int name, std::string 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__ssttrr(()) ggeett__iinntt(()) ggeett__bbooooll(()) ********** │ │ │ │ -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] │ │ │ │ ************ 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;
    │ │ │ -   void file (file_index_t f);
    │ │ │     file_index_t file () const;
    │ │ │ +   void file (file_index_t f);
    │ │ │  
    │ │ │     error_code ec;
    │ │ │     operation_t operation;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    bool()

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

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

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

    file()

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

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

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

    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"

    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1007,423 +1416,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_unchoke() on_have_all() on_choke() on_interested() on_have() on_have_none() on_dont_have() on_request() on_bitfield() on_not_interested()

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

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

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

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

    │ │ │ [report issue]
    │ │ │ @@ -664,63 +997,63 @@ │ │ │ │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    on_cancel() on_reject() on_suggest()

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

    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_cancel() sent_suggest() sent_piece() sent_reject_request() sent_unchoke() sent_choke() sent_allow_fast() sent_have_none() sent_not_interested() sent_have() sent_request() sent_have_all() sent_interested()

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

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

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

    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]
    │ │ │ @@ -744,21 +1077,21 @@ │ │ │
    │ │ │

    on_unknown_message()

    │ │ │
    │ │ │  virtual bool on_unknown_message (int /*length*/, int /*msg*/,
    │ │ │        span<char const> /*body*/);
    │ │ │  
    │ │ │

    this is not called for web seeds

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

    on_piece_failed() on_piece_pass()

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

    on_piece_pass() on_piece_failed()

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

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

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

    tick()

    │ │ │
    │ │ │ @@ -783,26 +1116,26 @@
    │ │ │  encryption / decryption of a peer connection. Returned by
    │ │ │  peer_plugin::wrap_socket() to plug into the BitTorrent peer
    │ │ │  connection's send / receive path. Used by the built-in protocol
    │ │ │  encryption (MSE) implementation.

    │ │ │
    │ │ │  struct crypto_plugin
    │ │ │  {
    │ │ │ -   virtual void set_incoming_key (span<char const> key) = 0;
    │ │ │     virtual void set_outgoing_key (span<char const> key) = 0;
    │ │ │ +   virtual void set_incoming_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;
    │ │ │ +virtual void set_incoming_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 │ │ │ encrypting bytes sent to the peer. Both are called once │ │ │ during the handshake before any data flows through the │ │ │ plugin.

    │ │ │ @@ -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;
    │ │ │ -   void add_extension (std::shared_ptr<peer_plugin>);
    │ │ │ -   peer_plugin const* find_plugin (string_view type) const;
    │ │ │ -   bool is_seed () const;
    │ │ │ -   bool upload_only () const;
    │ │ │ -   bool has_piece (piece_index_t i) const;
    │ │ │ -   peer_id const& pid () const;
    │ │ │ -   bool is_interesting () const;
    │ │ │ -   bool is_choked () const;
    │ │ │ -   bool has_peer_choked () const;
    │ │ │ -   bool is_peer_interested () const;
    │ │ │ -   void maybe_unchoke_this_peer ();
    │ │ │ -   void choke_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_connecting () const;
    │ │ │ -   bool is_outgoing () const;
    │ │ │ -   void disconnect (error_code const& ec, operation_t op
    │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ -   bool is_disconnecting () const;
    │ │ │ -   bool ignore_unchoke_slots () const;
    │ │ │ -   bool on_local_network () 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);
    │ │ │ -   std::time_t last_seen_complete () const;
    │ │ │ -   time_point time_of_last_unchoke () 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]
    │ │ │ -
    │ │ │ -

    find_plugin() add_extension()

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

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

    has_piece() pid()

    │ │ │ -
    │ │ │ -bool has_piece (piece_index_t i) const;
    │ │ │ -peer_id const& pid () 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_choked() is_interesting()

    │ │ │ -
    │ │ │ -bool is_interesting () const;
    │ │ │ -bool is_choked () 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]
    │ │ │ -
    │ │ │ -

    has_peer_choked() is_peer_interested()

    │ │ │ -
    │ │ │ -bool has_peer_choked () const;
    │ │ │ -bool is_peer_interested () 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]
    │ │ │ -
    │ │ │ -

    choke_this_peer() maybe_unchoke_this_peer()

    │ │ │ -
    │ │ │ -void maybe_unchoke_this_peer ();
    │ │ │ -void choke_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() disconnect() is_connecting() is_disconnecting()

    │ │ │ -
    │ │ │ -bool is_connecting () const;
    │ │ │ -bool is_outgoing () const;
    │ │ │ -void disconnect (error_code const& ec, operation_t op
    │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ -bool is_disconnecting () 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]
    │ │ │ -
    │ │ │ -

    ignore_unchoke_slots() on_local_network()

    │ │ │ -
    │ │ │ -bool ignore_unchoke_slots () const;
    │ │ │ -bool on_local_network () 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]
    │ │ │ -
    │ │ │ -

    peer_log() should_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()

    │ │ │ -
    │ │ │ -std::time_t last_seen_complete () const;
    │ │ │ -time_point time_of_last_unchoke () 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_send_crypto() switch_recv_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,90 +2,90 @@
    │ │ │ │  _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
    │ │ │ │  VVeerrssiioonn:: 2.1.0
    │ │ │ │  _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 _f_i_n_d___p_l_u_g_i_n_(_)_ _a_d_d___e_x_t_e_n_s_i_o_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___i_n_t_e_r_e_s_t_i_n_g_(_)_ _i_s___c_h_o_k_e_d_(_)
    │ │ │ │ +          o _h_a_s___p_e_e_r___c_h_o_k_e_d_(_)_ _i_s___p_e_e_r___i_n_t_e_r_e_s_t_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 _r_e_m_o_t_e_(_)_ _l_o_c_a_l___e_n_d_p_o_i_n_t_(_)
    │ │ │ │ +          o _i_s___c_o_n_n_e_c_t_i_n_g_(_)_ _i_s___d_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_(_)
    │ │ │ │ +          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_(_)
    │ │ │ │            o _o_n___u_n_k_n_o_w_n___t_o_r_r_e_n_t_(_)
    │ │ │ │            o _o_n___t_i_c_k_(_)
    │ │ │ │            o _g_e_t___u_n_c_h_o_k_e___p_r_i_o_r_i_t_y_(_)
    │ │ │ │            o _s_a_v_e___s_t_a_t_e_(_)
    │ │ │ │            o _l_o_a_d___s_t_a_t_e_(_)
    │ │ │ │      * _t_o_r_r_e_n_t___p_l_u_g_i_n
    │ │ │ │            o _n_e_w___c_o_n_n_e_c_t_i_o_n_(_)
    │ │ │ │ -          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 _o_n___p_i_e_c_e___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_)
    │ │ │ │            o _t_i_c_k_(_)
    │ │ │ │ -          o _o_n___r_e_s_u_m_e_(_)_ _o_n___p_a_u_s_e_(_)
    │ │ │ │ +          o _o_n___p_a_u_s_e_(_)_ _o_n___r_e_s_u_m_e_(_)
    │ │ │ │            o _o_n___f_i_l_e_s___c_h_e_c_k_e_d_(_)
    │ │ │ │            o _o_n___s_t_a_t_e_(_)
    │ │ │ │            o _o_n___a_d_d___p_e_e_r_(_)
    │ │ │ │      * _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___u_n_c_h_o_k_e_(_)_ _o_n___h_a_v_e___a_l_l_(_)_ _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_(_)_ _o_n___h_a_v_e___n_o_n_e_(_)_ _o_n___d_o_n_t___h_a_v_e_(_)_ _o_n___r_e_q_u_e_s_t
    │ │ │ │ -            _(_)_ _o_n___b_i_t_f_i_e_l_d_(_)_ _o_n___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │ +          o _o_n___r_e_q_u_e_s_t_(_)_ _o_n___h_a_v_e___n_o_n_e_(_)_ _o_n___h_a_v_e_(_)_ _o_n___d_o_n_t___h_a_v_e_(_)
    │ │ │ │ +            _o_n___a_l_l_o_w_e_d___f_a_s_t_(_)_ _o_n___i_n_t_e_r_e_s_t_e_d_(_)_ _o_n___h_a_v_e___a_l_l_(_)_ _o_n___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │ +            _o_n___c_h_o_k_e_(_)_ _o_n___u_n_c_h_o_k_e_(_)_ _o_n___b_i_t_f_i_e_l_d_(_)
    │ │ │ │            o _o_n___p_i_e_c_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___c_a_n_c_e_l_(_)_ _s_e_n_t___s_u_g_g_e_s_t_(_)_ _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_(_)_ _s_e_n_t___a_l_l_o_w___f_a_s_t_(_)_ _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___h_a_v_e_(_)_ _s_e_n_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___h_a_v_e___a_l_l_(_)
    │ │ │ │ +          o _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___c_a_n_c_e_l_(_)_ _s_e_n_t___h_a_v_e_(_)
    │ │ │ │ +            _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___c_h_o_k_e_(_)_ _s_e_n_t___h_a_v_e___n_o_n_e_(_)
    │ │ │ │ +            _s_e_n_t___p_i_e_c_e_(_)_ _s_e_n_t___u_n_c_h_o_k_e_(_)_ _s_e_n_t___r_e_j_e_c_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___h_a_v_e___a_l_l_(_)
    │ │ │ │              _s_e_n_t___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │            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 _o_n___p_i_e_c_e___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_)
    │ │ │ │            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 _f_i_n_d___p_l_u_g_i_n_(_)_ _a_d_d___e_x_t_e_n_s_i_o_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 _h_a_s___p_e_e_r___c_h_o_k_e_d_(_)_ _i_s___p_e_e_r___i_n_t_e_r_e_s_t_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___o_u_t_g_o_i_n_g_(_)_ _d_i_s_c_o_n_n_e_c_t_(_)_ _i_s___c_o_n_n_e_c_t_i_n_g_(_)_ _i_s___d_i_s_c_o_n_n_e_c_t_i_n_g_(_)
    │ │ │ │ -          o _i_g_n_o_r_e___u_n_c_h_o_k_e___s_l_o_t_s_(_)_ _o_n___l_o_c_a_l___n_e_t_w_o_r_k_(_)
    │ │ │ │ -          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 _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___s_e_n_d___c_r_y_p_t_o_(_)_ _s_w_i_t_c_h___r_e_c_v___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;
    │ │ │ │ +   bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ +   peer_id const& ppiidd () const;
    │ │ │ │ +   bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ +   bool iiss__cchhookkeedd () const;
    │ │ │ │ +   bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ +   bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ +   void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +   void cchhookkee__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 llooccaall__eennddppooiinntt () const;
    │ │ │ │ +   _t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ +   void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ +   bool iiss__oouuttggooiinngg () const;
    │ │ │ │ +   bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ +   bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ +   bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ +   bool oonn__llooccaall__nneettwwoorrkk () 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]
    │ │ │ │ +********** ffiinndd__pplluuggiinn(()) aadddd__eexxtteennssiioonn(()) **********
    │ │ │ │ +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(()) **********
    │ │ │ │ +bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ +peer_id const& ppiidd () 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__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]
    │ │ │ │ +********** hhaass__ppeeeerr__cchhookkeedd(()) iiss__ppeeeerr__iinntteerreesstteedd(()) **********
    │ │ │ │ +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]
    │ │ │ │ +********** cchhookkee__tthhiiss__ppeeeerr(()) mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr(()) **********
    │ │ │ │ +void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +void cchhookkee__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]
    │ │ │ │ +********** rreemmoottee(()) llooccaall__eennddppooiinntt(()) **********
    │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () 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__ddiissccoonnnneeccttiinngg(()) iiss__oouuttggooiinngg(()) ddiissccoonnnneecctt(()) **********
    │ │ │ │ +void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ +bool iiss__oouuttggooiinngg () const;
    │ │ │ │ +bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ +bool iiss__ddiissccoonnnneeccttiinngg () 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 iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ +bool oonn__llooccaall__nneettwwoorrkk () 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 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]
    │ │ │ │ +********** ssuuppppoorrtt__eexxtteennssiioonnss(()) ppaacckkeett__ffiinniisshheedd(()) **********
    │ │ │ │ +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]
    │ │ │ │  ************ 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
    │ │ │ │  {
    │ │ │ │ @@ -295,16 +517,16 @@
    │ │ │ │  Torrent plugins are associated with a single torrent and have a number of
    │ │ │ │  functions called at certain events. Many of its functions have the ability to
    │ │ │ │  change or override the default libtorrent behavior.
    │ │ │ │  struct torrent_plugin
    │ │ │ │  {
    │ │ │ │     virtual std::shared_ptr nneeww__ccoonnnneeccttiioonn (peer_connection_handle
    │ │ │ │  const&);
    │ │ │ │ -   virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │     virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │ +   virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │     virtual void ttiicckk ();
    │ │ │ │     virtual bool oonn__rreessuummee ();
    │ │ │ │     virtual bool oonn__ppaauussee ();
    │ │ │ │     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);
    │ │ │ │ @@ -324,28 +546,28 @@
    │ │ │ │  have its hook functions called on event specific to that peer.
    │ │ │ │  The peer_connection_handle will be valid as long as the shared_ptr is being
    │ │ │ │  held by the torrent object. So, it is generally a good idea to not keep a
    │ │ │ │  shared_ptr to your own _p_e_e_r___p_l_u_g_i_n. If you want to keep references to it, use
    │ │ │ │  weak_ptr.
    │ │ │ │  If this function throws an exception, the connection will be closed.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__ppiieeccee__ffaaiilleedd(()) oonn__ppiieeccee__ppaassss(()) **********
    │ │ │ │ -virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │ +********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) **********
    │ │ │ │  virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │ +virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │  These hooks are called when a piece passes the hash check or fails the hash
    │ │ │ │  check, respectively. The index is the piece index that was downloaded. It is
    │ │ │ │  possible to access the list of peers that participated in sending the piece
    │ │ │ │  through the torrent and the piece_picker.
    │ │ │ │  [_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__rreessuummee(()) oonn__ppaauussee(()) **********
    │ │ │ │ +********** oonn__ppaauussee(()) oonn__rreessuummee(()) **********
    │ │ │ │  virtual bool oonn__rreessuummee ();
    │ │ │ │  virtual bool oonn__ppaauussee ();
    │ │ │ │  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
    │ │ │ │ @@ -393,51 +615,51 @@
    │ │ │ │  {
    │ │ │ │     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 (piece_index_t);
    │ │ │ │ -   virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │ -   virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │ -   virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │ +   virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │     virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ -   virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ -   virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ -   virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +   virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │     virtual bool oonn__uunncchhookkee ();
    │ │ │ │ -   virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │     virtual bool oonn__cchhookkee ();
    │ │ │ │ +   virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │ +   virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +   virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +   virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │ +   virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ +   virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │     virtual bool oonn__ppiieeccee (peer_request const& //**ppiieeccee**//
    │ │ │ │        , span //**bbuuff**//);
    │ │ │ │     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__aallll ();
    │ │ │ │ -   virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ +   virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │     virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ -   virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │     virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │ -   virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__uunncchhookkee ();
    │ │ │ │ +   virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │     virtual void sseenntt__ppiieeccee (peer_request const&);
    │ │ │ │ +   virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ +   virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ +   virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │     virtual void sseenntt__cchhookkee ();
    │ │ │ │ -   virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │ -   virtual void sseenntt__uunncchhookkee ();
    │ │ │ │     virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │     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);
    │ │ │ │     virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │ +   virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │     virtual void ttiicckk ();
    │ │ │ │     virtual bool wwrriittee__rreeqquueesstt (peer_request const&);
    │ │ │ │  };
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ttyyppee(()) **********
    │ │ │ │  virtual string_view ttyyppee () const;
    │ │ │ │  This function is expected to return the name of the _p_l_u_g_i_n.
    │ │ │ │ @@ -465,28 +687,28 @@
    │ │ │ │  ********** 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__uunncchhookkee(()) oonn__hhaavvee__aallll(()) oonn__cchhookkee(()) oonn__iinntteerreesstteedd(())
    │ │ │ │ -oonn__hhaavvee(()) oonn__hhaavvee__nnoonnee(()) oonn__ddoonntt__hhaavvee(()) oonn__rreeqquueesstt(()) oonn__bbiittffiieelldd(())
    │ │ │ │ -oonn__nnoott__iinntteerreesstteedd(()) **********
    │ │ │ │ -virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │ -virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │ -virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │ -virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │ +********** oonn__rreeqquueesstt(()) oonn__hhaavvee__nnoonnee(()) oonn__hhaavvee(()) oonn__ddoonntt__hhaavvee(()) oonn__aalllloowweedd__ffaasstt(())
    │ │ │ │ +oonn__iinntteerreesstteedd(()) oonn__hhaavvee__aallll(()) oonn__nnoott__iinntteerreesstteedd(()) oonn__cchhookkee(()) oonn__uunncchhookkee(())
    │ │ │ │ +oonn__bbiittffiieelldd(()) **********
    │ │ │ │ +virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │  virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ -virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ -virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ -virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │  virtual bool oonn__uunncchhookkee ();
    │ │ │ │ -virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │  virtual bool oonn__cchhookkee ();
    │ │ │ │ +virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │ +virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │ +virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ +virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │  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**//);
    │ │ │ │ @@ -494,37 +716,36 @@
    │ │ │ │  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__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&);
    │ │ │ │ +virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │  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__ccaanncceell(()) sseenntt__ssuuggggeesstt(()) sseenntt__ppiieeccee(()) sseenntt__rreejjeecctt__rreeqquueesstt(())
    │ │ │ │ -sseenntt__uunncchhookkee(()) sseenntt__cchhookkee(()) sseenntt__aallllooww__ffaasstt(()) sseenntt__hhaavvee__nnoonnee(())
    │ │ │ │ -sseenntt__nnoott__iinntteerreesstteedd(()) sseenntt__hhaavvee(()) sseenntt__rreeqquueesstt(()) sseenntt__hhaavvee__aallll(())
    │ │ │ │ -sseenntt__iinntteerreesstteedd(()) **********
    │ │ │ │ -virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │ -virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ -virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ +********** sseenntt__nnoott__iinntteerreesstteedd(()) sseenntt__aallllooww__ffaasstt(()) sseenntt__ccaanncceell(()) sseenntt__hhaavvee(())
    │ │ │ │ +sseenntt__rreeqquueesstt(()) sseenntt__ssuuggggeesstt(()) sseenntt__cchhookkee(()) sseenntt__hhaavvee__nnoonnee(()) sseenntt__ppiieeccee(())
    │ │ │ │ +sseenntt__uunncchhookkee(()) sseenntt__rreejjeecctt__rreeqquueesstt(()) sseenntt__hhaavvee__aallll(()) sseenntt__iinntteerreesstteedd(()) **********
    │ │ │ │  virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ -virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │  virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │ -virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__uunncchhookkee ();
    │ │ │ │ +virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │  virtual void sseenntt__ppiieeccee (peer_request const&);
    │ │ │ │ +virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ +virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ +virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │  virtual void sseenntt__cchhookkee ();
    │ │ │ │ -virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │ -virtual void sseenntt__uunncchhookkee ();
    │ │ │ │  virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │  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]
    │ │ │ │ @@ -547,17 +768,17 @@
    │ │ │ │  receiving large messages.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** oonn__uunnkknnoowwnn__mmeessssaaggee(()) **********
    │ │ │ │  virtual bool oonn__uunnkknnoowwnn__mmeessssaaggee (int //**lleennggtthh**//, int //**mmssgg**//,
    │ │ │ │        span //**bbooddyy**//);
    │ │ │ │  this is not called for web seeds
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__ppiieeccee__ffaaiilleedd(()) oonn__ppiieeccee__ppaassss(()) **********
    │ │ │ │ -virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │ +********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) **********
    │ │ │ │  virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │ +virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │  called when a piece that this peer participated in either fails or passes the
    │ │ │ │  hash_check
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ttiicckk(()) **********
    │ │ │ │  virtual void ttiicckk ();
    │ │ │ │  called approximately once every second
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ @@ -571,24 +792,24 @@
    │ │ │ │  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"
    │ │ │ │  interface implemented by a _p_l_u_g_i_n that wants to take over the encryption /
    │ │ │ │  decryption of a peer connection. Returned by peer_plugin::wrap_socket() to plug
    │ │ │ │  into the BitTorrent peer connection's send / receive path. Used by the built-in
    │ │ │ │  protocol encryption (MSE) implementation.
    │ │ │ │  struct crypto_plugin
    │ │ │ │  {
    │ │ │ │ -   virtual void sseett__iinnccoommiinngg__kkeeyy (span key) = 0;
    │ │ │ │     virtual void sseett__oouuttggooiinngg__kkeeyy (span key) = 0;
    │ │ │ │ +   virtual void sseett__iinnccoommiinngg__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(()) **********
    │ │ │ │ -virtual void sseett__iinnccoommiinngg__kkeeyy (span key) = 0;
    │ │ │ │ +********** sseett__oouuttggooiinngg__kkeeyy(()) sseett__iinnccoommiinngg__kkeeyy(()) **********
    │ │ │ │  virtual void sseett__oouuttggooiinngg__kkeeyy (span key) = 0;
    │ │ │ │ +virtual void sseett__iinnccoommiinngg__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]
    │ │ │ │  ********** eennccrryypptt(()) **********
    │ │ │ │  eennccrryypptt (span> //**sseenndd__vveecc**//) = 0;
    │ │ │ │ @@ -609,236 +830,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;
    │ │ │ │ -   void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ -   peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ -   bool iiss__sseeeedd () const;
    │ │ │ │ -   bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ -   bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ -   peer_id const& ppiidd () const;
    │ │ │ │ -   bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ -   bool iiss__cchhookkeedd () const;
    │ │ │ │ -   bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ -   bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ -   void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -   void cchhookkee__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__ccoonnnneeccttiinngg () const;
    │ │ │ │ -   bool iiss__oouuttggooiinngg () const;
    │ │ │ │ -   void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ -   bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ -   bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ -   bool oonn__llooccaall__nneettwwoorrkk () 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);
    │ │ │ │ -   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]
    │ │ │ │ -********** ffiinndd__pplluuggiinn(()) aadddd__eexxtteennssiioonn(()) **********
    │ │ │ │ -void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ -peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ -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(()) **********
    │ │ │ │ -bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ -peer_id const& ppiidd () 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]
    │ │ │ │ -********** hhaass__ppeeeerr__cchhookkeedd(()) iiss__ppeeeerr__iinntteerreesstteedd(()) **********
    │ │ │ │ -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 mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -void cchhookkee__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(()) ddiissccoonnnneecctt(()) iiss__ccoonnnneeccttiinngg(()) iiss__ddiissccoonnnneeccttiinngg(()) **********
    │ │ │ │ -bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ -bool iiss__oouuttggooiinngg () const;
    │ │ │ │ -void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ -bool iiss__ddiissccoonnnneeccttiinngg () 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]
    │ │ │ │ -********** iiggnnoorree__uunncchhookkee__sslloottss(()) oonn__llooccaall__nneettwwoorrkk(()) **********
    │ │ │ │ -bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ -bool oonn__llooccaall__nneettwwoorrkk () 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(()) **********
    │ │ │ │ -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(()) **********
    │ │ │ │ -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 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__sseenndd__ccrryyppttoo(()) sswwiittcchh__rreeccvv__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
    │ │ │ @@ -30,28 +30,28 @@
    │ │ │  
    │ │ │  

    home

    │ │ │
    │ │ │

    Table of contents

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

    read_resume_data()

    │ │ │

    Declared in "libtorrent/read_resume_data.hpp"

    │ │ │
    │ │ │  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 (bdecode_node const& rd
    │ │ │     , error_code& ec, int piece_limit = 0x200000);
    │ │ │ +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 = {});
    │ │ │  
    │ │ │

    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().

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

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

    write_torrent_file_buf() write_torrent_file()

    │ │ │

    Declared in "libtorrent/write_resume_data.hpp"

    │ │ │
    │ │ │ -entry write_torrent_file (add_torrent_params const& atp, write_torrent_flags_t flags);
    │ │ │ -entry write_torrent_file (add_torrent_params const& atp);
    │ │ │  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);
    │ │ │ +entry write_torrent_file (add_torrent_params const& atp, write_torrent_flags_t flags);
    │ │ │  
    │ │ │

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

    │ │ │
      │ │ │
    • The add_torrent_params object passed to this function does not contain the │ │ │ info dictionary (the ti field)
    • │ │ │
    • The piece layers are not complete for all files that need them
    • │ │ │ ├── html2text {} │ │ │ │ @@ -1,25 +1,25 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _r_e_a_d___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ * _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a___b_u_f_(_)_ _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ - * _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_)_ _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e___b_u_f_(_) │ │ │ │ + * _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e___b_u_f_(_)_ _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ * _w_r_i_t_e___t_o_r_r_e_n_t___f_l_a_g_s___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ rreeaadd__rreessuummee__ddaattaa(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_r_e_a_d___r_e_s_u_m_e___d_a_t_a_._h_p_p" │ │ │ │ add_torrent_params rreeaadd__rreessuummee__ddaattaa (span buffer │ │ │ │ , load_torrent_limits const& cfg = {}); │ │ │ │ add_torrent_params rreeaadd__rreessuummee__ddaattaa (bdecode_node const& rd │ │ │ │ - , int piece_limit = 0x200000); │ │ │ │ -add_torrent_params rreeaadd__rreessuummee__ddaattaa (bdecode_node const& rd │ │ │ │ , error_code& ec, int piece_limit = 0x200000); │ │ │ │ +add_torrent_params rreeaadd__rreessuummee__ddaattaa (bdecode_node const& rd │ │ │ │ + , int piece_limit = 0x200000); │ │ │ │ add_torrent_params rreeaadd__rreessuummee__ddaattaa (span buffer │ │ │ │ , error_code& ec, load_torrent_limits const& cfg = {}); │ │ │ │ these functions are used to parse resume data and populate the appropriate │ │ │ │ fields in an _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. This object can then be used to add the │ │ │ │ actual _t_o_r_r_e_n_t___i_n_f_o 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, │ │ │ │ @@ -47,26 +47,26 @@ │ │ │ │ the system from modifying them, and do not load resume data received from │ │ │ │ untrusted sources (e.g. downloaded, synced from a shared location, or supplied │ │ │ │ by a peer) without independently validating or overriding the security- │ │ │ │ sensitive fields after parsing. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ wwrriittee__rreessuummee__ddaattaa__bbuuff(()) wwrriittee__rreessuummee__ddaattaa(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_._h_p_p" │ │ │ │ -std::vector wwrriittee__rreessuummee__ddaattaa__bbuuff (add_torrent_params const& atp); │ │ │ │ entry wwrriittee__rreessuummee__ddaattaa (add_torrent_params const& atp); │ │ │ │ +std::vector wwrriittee__rreessuummee__ddaattaa__bbuuff (add_torrent_params const& atp); │ │ │ │ this function turns the resume data in an add_torrent_params object into a │ │ │ │ bencoded structure │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ wwrriittee__ttoorrrreenntt__ffiillee(()) wwrriittee__ttoorrrreenntt__ffiillee__bbuuff(()) ************ │ │ │ │ +************ wwrriittee__ttoorrrreenntt__ffiillee__bbuuff(()) wwrriittee__ttoorrrreenntt__ffiillee(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_._h_p_p" │ │ │ │ -entry wwrriittee__ttoorrrreenntt__ffiillee (add_torrent_params const& atp, write_torrent_flags_t │ │ │ │ -flags); │ │ │ │ -entry wwrriittee__ttoorrrreenntt__ffiillee (add_torrent_params const& atp); │ │ │ │ std::vector wwrriittee__ttoorrrreenntt__ffiillee__bbuuff (add_torrent_params const& atp │ │ │ │ , write_torrent_flags_t flags); │ │ │ │ +entry wwrriittee__ttoorrrreenntt__ffiillee (add_torrent_params const& atp); │ │ │ │ +entry wwrriittee__ttoorrrreenntt__ffiillee (add_torrent_params const& atp, write_torrent_flags_t │ │ │ │ +flags); │ │ │ │ writes only the fields to create a .torrent file. This function may fail with a │ │ │ │ std::system_error exception if: │ │ │ │ * The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object passed to this function does not contain │ │ │ │ the info dictionary (the ti field) │ │ │ │ * The piece layers are not complete for all files that need them │ │ │ │ The write_torrent_file_buf() overload returns the torrent file in bencoded │ │ │ │ buffer form. This overload may be faster at the expense of lost flexibility to │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Session.html │ │ │ @@ -34,77 +34,77 @@ │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    session_params

    │ │ │

    Declared in "libtorrent/session_params.hpp"

    │ │ │

    The session_params is a parameters pack for configuring the session │ │ │ before it's started.

    │ │ │
    │ │ │  struct session_params
    │ │ │  {
    │ │ │ +   session_params (settings_pack&& sp);
    │ │ │     session_params (settings_pack const& sp);
    │ │ │     session_params ();
    │ │ │ -   session_params (settings_pack&& sp);
    │ │ │     session_params (settings_pack&& sp
    │ │ │        , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │     session_params (settings_pack const& sp
    │ │ │        , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │  
    │ │ │     settings_pack settings;
    │ │ │     session_flags_t flags {};
    │ │ │ @@ -115,17 +115,17 @@
    │ │ │     std::map<std::string, std::string> ext_state;
    │ │ │     libtorrent::ip_filter ip_filter;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    session_params()

    │ │ │
    │ │ │ +session_params (settings_pack&& sp);
    │ │ │  session_params (settings_pack const& sp);
    │ │ │  session_params ();
    │ │ │ -session_params (settings_pack&& sp);
    │ │ │  
    │ │ │

    This constructor can be used to start with the default plugins │ │ │ (ut_metadata, ut_pex and smart_ban). Pass a settings_pack to set the │ │ │ initial settings when the session starts.

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

    session_params()

    │ │ │ @@ -197,33 +197,33 @@ │ │ │ synchronize the completion of the shutdown. The lifetime of this object │ │ │ may outlive session, causing the session destructor to not block. The │ │ │ session_proxy destructor will block however, until the underlying session │ │ │ is done shutting down.

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

    operator=() ~session_proxy() session_proxy()

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

    session_proxy() ~session_proxy() operator=()

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

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

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

    session

    │ │ │ @@ -237,28 +237,28 @@ │ │ │ session_handle::apply_settings() member function. To change one or more │ │ │ configuration options, create a settings_pack. object and fill it with │ │ │ the settings to be set and pass it in to session::apply_settings().

    │ │ │

    see apply_settings().

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

    session()

    │ │ │
    │ │ │ -explicit session (session_params&& params);
    │ │ │  explicit session (session_params const& params);
    │ │ │ +explicit session (session_params&& params);
    │ │ │  session ();
    │ │ │  
    │ │ │

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

    │ │ │ [report issue]
    │ │ │ @@ -317,15 +317,15 @@ │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │

    session_handle

    │ │ │

    Declared in "libtorrent/session_handle.hpp"

    │ │ │

    this class provides a non-owning handle to a session and a subset of the │ │ │ interface of the session class. If the underlying session is destructed │ │ │ -any handle to it will no longer be valid. is_valid() will return false and │ │ │ +any handle to it will no longer be valid. is_valid() will return false and │ │ │ any operation on it will throw a system_error exception, with error code │ │ │ invalid_session_handle.

    │ │ │
    │ │ │  struct session_handle
    │ │ │  {
    │ │ │     bool is_valid () const;
    │ │ │     session_params session_state (save_state_flags_t flags = save_state_flags_t::all()) const;
    │ │ │ @@ -336,65 +336,65 @@
    │ │ │        , status_flags_t flags = {}) const;
    │ │ │     void post_torrent_updates (status_flags_t flags = status_flags_t::all());
    │ │ │     void post_session_stats ();
    │ │ │     void post_dht_stats ();
    │ │ │     void set_dht_state (dht::dht_state&& st);
    │ │ │     void set_dht_state (dht::dht_state const& st);
    │ │ │     torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │ -   std::vector<torrent_handle> get_torrents () const;
    │ │ │     torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │ -   torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ -   torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │ -   void async_add_torrent (add_torrent_params&& params);
    │ │ │ +   std::vector<torrent_handle> get_torrents () const;
    │ │ │     torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │ +   torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │     void async_add_torrent (add_torrent_params const& params);
    │ │ │     torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │ -   bool is_paused () const;
    │ │ │ +   torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ +   void async_add_torrent (add_torrent_params&& params);
    │ │ │     void resume ();
    │ │ │     void pause ();
    │ │ │ +   bool is_paused () const;
    │ │ │     bool is_dht_running () const;
    │ │ │     void set_dht_storage (dht::dht_storage_constructor_type sc);
    │ │ │     void add_dht_node (std::pair<std::string, int> const& node);
    │ │ │     void dht_get_item (sha1_hash const& target);
    │ │ │     void dht_get_item (std::array<char, 32> key
    │ │ │        , std::string salt = std::string());
    │ │ │     sha1_hash dht_put_item (entry data);
    │ │ │     void dht_put_item (std::array<char, 32> key
    │ │ │        , std::function<void(entry&, std::array<char, 64>&
    │ │ │        , std::int64_t&, std::string const&)> cb
    │ │ │        , std::string salt = std::string());
    │ │ │ -   void dht_get_peers (sha1_hash const& info_hash);
    │ │ │     void dht_announce (sha1_hash const& info_hash, int port = 0, dht::announce_flags_t flags = {});
    │ │ │ +   void dht_get_peers (sha1_hash const& info_hash);
    │ │ │     void dht_live_nodes (sha1_hash const& nid);
    │ │ │     void dht_sample_infohashes (udp::endpoint const& ep, sha1_hash const& target);
    │ │ │     void dht_direct_request (udp::endpoint const& ep, entry const& e, client_data_t userdata = {});
    │ │ │ +   void add_extension (std::shared_ptr<plugin> ext);
    │ │ │     void add_extension (std::function<std::shared_ptr<torrent_plugin>(
    │ │ │        torrent_handle const&, client_data_t)> ext);
    │ │ │ -   void add_extension (std::shared_ptr<plugin> ext);
    │ │ │     void set_ip_filter (ip_filter f);
    │ │ │     ip_filter get_ip_filter () const;
    │ │ │     void set_port_filter (port_filter const& f);
    │ │ │ -   bool is_listening () const;
    │ │ │     unsigned short listen_port () const;
    │ │ │ +   bool is_listening () const;
    │ │ │     unsigned short ssl_listen_port () const;
    │ │ │     ip_filter get_peer_class_filter () const;
    │ │ │     void set_peer_class_filter (ip_filter const& f);
    │ │ │ -   void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │     peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │ +   void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │     peer_class_t create_peer_class (char const* name);
    │ │ │     void delete_peer_class (peer_class_t cid);
    │ │ │ -   void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │     peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │ +   void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │     void remove_torrent (const torrent_handle&, remove_flags_t = {});
    │ │ │ +   void apply_settings (settings_pack const&);
    │ │ │     void apply_settings (settings_pack&&);
    │ │ │     settings_pack get_settings () const;
    │ │ │ -   void apply_settings (settings_pack const&);
    │ │ │ -   bool wait_for_alert (time_duration max_wait);
    │ │ │     void set_alert_notify (std::function<void()> const& fun);
    │ │ │     void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ +   bool wait_for_alert (time_duration max_wait);
    │ │ │     void delete_port_mapping (port_mapping_t handle);
    │ │ │     std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │     void reopen_network_sockets (reopen_network_flags_t options = reopen_map_ports);
    │ │ │     std::shared_ptr<aux::session_impl> native_handle () const;
    │ │ │  
    │ │ │     static inline constexpr save_state_flags_t save_settings  = 0_bit;
    │ │ │     static inline constexpr save_state_flags_t save_dht_state  = 2_bit;
    │ │ │ @@ -428,18 +428,18 @@
    │ │ │  

    returns the current session state. This can be passed to │ │ │ write_session_params() to save the state to disk and restored using │ │ │ read_session_params() when constructing a new session. 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 │ │ │ session state

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

    get_torrent_status() refresh_torrent_status()

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

    refresh_torrent_status() get_torrent_status()

    │ │ │
    │ │ │  std::vector<torrent_status> get_torrent_status (
    │ │ │        std::function<bool(torrent_status const&)> const& pred
    │ │ │        , status_flags_t flags = {}) const;
    │ │ │  void refresh_torrent_status (std::vector<torrent_status>* ret
    │ │ │        , status_flags_t flags = {}) const;
    │ │ │  
    │ │ │ @@ -515,42 +515,42 @@ │ │ │
    │ │ │  void set_dht_state (dht::dht_state&& st);
    │ │ │  void set_dht_state (dht::dht_state const& st);
    │ │ │  
    │ │ │

    set the DHT state for the session. This will be taken into account the │ │ │ next time the DHT is started, as if it had been passed in via the │ │ │ session_params on startup.

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

    find_torrent() get_torrents()

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

    get_torrents() find_torrent()

    │ │ │
    │ │ │  torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │ -std::vector<torrent_handle> get_torrents () const;
    │ │ │  torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │ +std::vector<torrent_handle> get_torrents () const;
    │ │ │  
    │ │ │

    find_torrent() looks for a torrent with the given info-hash. In │ │ │ case there is such a torrent in the session, a torrent_handle to that │ │ │ torrent is returned. In case the torrent cannot be found, an invalid │ │ │ torrent_handle 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 session.

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

    add_torrent() async_add_torrent()

    │ │ │
    │ │ │ -torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ -torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │ -void async_add_torrent (add_torrent_params&& params);
    │ │ │  torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │ +torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │  void async_add_torrent (add_torrent_params const& params);
    │ │ │  torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │ +torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ +void async_add_torrent (add_torrent_params&& params);
    │ │ │  
    │ │ │

    You add torrents through the add_torrent() function where you give an │ │ │ object with all the parameters. The add_torrent() overloads will block │ │ │ until the torrent has been added (or failed to be added) and returns │ │ │ an error code and a torrent_handle. In order to add torrents more │ │ │ efficiently, consider using async_add_torrent() which returns │ │ │ immediately, without waiting for the torrent to add. Notification of │ │ │ @@ -575,23 +575,23 @@ │ │ │ want to control are torrent_flags::paused and │ │ │ torrent_flags::auto_managed. In order to add a magnet link that will │ │ │ just download the metadata, but no payload, set the │ │ │ torrent_flags::upload_mode flag.

    │ │ │

    Special consideration has to be taken when adding hybrid torrents │ │ │ (i.e. torrents that are BitTorrent v2 torrents that are backwards │ │ │ compatible with v1). For more details, see BitTorrent v2 torrents.

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

    pause() resume() is_paused()

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

    resume() is_paused() pause()

    │ │ │
    │ │ │ -bool is_paused () const;
    │ │ │  void resume ();
    │ │ │  void pause ();
    │ │ │ +bool is_paused () const;
    │ │ │  
    │ │ │

    Pausing the session 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 session pause state is separate from the torrent pause │ │ │ state. A torrent is inactive if it is paused or if the session is │ │ │ paused. is_paused() returns true if the session is currently │ │ │ @@ -705,16 +705,16 @@ │ │ │ the DHT works, it is natural to always do a lookup before storing and │ │ │ calling the callback in between is convenient.

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

    dht_get_peers() dht_announce()

    │ │ │
    │ │ │ -void dht_get_peers (sha1_hash const& info_hash);
    │ │ │  void dht_announce (sha1_hash const& info_hash, int port = 0, dht::announce_flags_t flags = {});
    │ │ │ +void dht_get_peers (sha1_hash const& info_hash);
    │ │ │  
    │ │ │

    dht_get_peers() will issue a DHT get_peer request to the DHT for the │ │ │ specified info-hash. The response (the peers) will be posted back in a │ │ │ dht_get_peers_reply_alert.

    │ │ │

    dht_announce() will issue a DHT announce request to the DHT to the │ │ │ specified info-hash, advertising the specified port. If the port is │ │ │ left at its default, 0, the port will be implied by the DHT message's │ │ │ @@ -759,17 +759,17 @@ │ │ │ with the response (if any) and the userdata pointer passed in here. │ │ │ Since this alert is a response to an explicit call, it will always be │ │ │ posted, regardless of the alert mask.

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

    add_extension()

    │ │ │
    │ │ │ +void add_extension (std::shared_ptr<plugin> ext);
    │ │ │  void add_extension (std::function<std::shared_ptr<torrent_plugin>(
    │ │ │        torrent_handle const&, client_data_t)> ext);
    │ │ │ -void add_extension (std::shared_ptr<plugin> ext);
    │ │ │  
    │ │ │

    This function adds an extension to this session. The argument is a │ │ │ function object that is called with a torrent_handle and which should │ │ │ return a std::shared_ptr<torrent_plugin>. To write custom │ │ │ plugins, see libtorrent plugins. For the typical bittorrent client │ │ │ all of these extensions should be added. The main plugins implemented │ │ │ in libtorrent are:

    │ │ │ @@ -797,18 +797,18 @@ │ │ │ that sends bad data with very high accuracy. Should │ │ │ eliminate most problems on poisoned torrents. │ │ │ │ │ │
    │ │ │  #include <libtorrent/extensions/smart_ban.hpp>
    │ │ │  ses.add_extension(&lt::create_smart_ban_plugin);
    │ │ │  
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_ip_filter() set_ip_filter()

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

    set_ip_filter() get_ip_filter()

    │ │ │
    │ │ │  void set_ip_filter (ip_filter f);
    │ │ │  ip_filter get_ip_filter () const;
    │ │ │  
    │ │ │

    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 │ │ │ @@ -828,16 +828,16 @@ │ │ │ anti-virus software by connecting to SMTP, FTP ports.

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

    listen_port() ssl_listen_port() is_listening()

    │ │ │
    │ │ │ -bool is_listening () const;
    │ │ │  unsigned short listen_port () const;
    │ │ │ +bool is_listening () const;
    │ │ │  unsigned short ssl_listen_port () const;
    │ │ │  
    │ │ │

    is_listening() will tell you whether or not the session has │ │ │ successfully opened a listening port. If it hasn't, this function will │ │ │ return false, and then you can set a new │ │ │ settings_pack::listen_interfaces to try another interface and port to │ │ │ bind to.

    │ │ │ @@ -874,21 +874,21 @@ │ │ │ 32 bits in the IP range mapping. Only the set bits matter; no peer │ │ │ class will be removed from a peer as a result of this call, peer │ │ │ classes are only added.

    │ │ │

    The peer_class argument cannot be greater than 31. The bitmasks │ │ │ representing peer classes in the peer_class_filter are 32 bits.

    │ │ │

    The get_peer_class_filter() function returns the current filter.

    │ │ │

    For more information, see peer classes.

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

    set_peer_class_type_filter() get_peer_class_type_filter()

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

    get_peer_class_type_filter() set_peer_class_type_filter()

    │ │ │
    │ │ │ -void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │  peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │ +void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │  
    │ │ │

    Sets and gets the peer class type filter. This is controls automatic │ │ │ peer class assignments to peers based on what kind of socket it is.

    │ │ │

    It does not only support assigning peer classes, it also supports │ │ │ removing peer classes based on socket type.

    │ │ │

    The order of these rules being applied are:

    │ │ │
      │ │ │ @@ -927,21 +927,21 @@ │ │ │ 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 session object │ │ │ destructs.

      │ │ │

      For more information on peer classes, see peer classes.

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

    set_peer_class() get_peer_class()

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

    get_peer_class() set_peer_class()

    │ │ │
    │ │ │ -void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │  peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │ +void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │  
    │ │ │

    These functions queries information from a peer class and updates the │ │ │ configuration of a peer class, respectively.

    │ │ │

    cid must refer to an existing peer class. If it does not, the │ │ │ return value of get_peer_class() is undefined.

    │ │ │

    set_peer_class() sets all the information in the │ │ │ peer_class_info object in the specified peer class. There is no │ │ │ @@ -986,30 +986,30 @@ │ │ │ advised to remove them from the back of the queue, to minimize the │ │ │ shifting.

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

    get_settings() apply_settings()

    │ │ │
    │ │ │ +void apply_settings (settings_pack const&);
    │ │ │  void apply_settings (settings_pack&&);
    │ │ │  settings_pack get_settings () const;
    │ │ │ -void apply_settings (settings_pack const&);
    │ │ │  
    │ │ │

    Applies the settings specified by the settings_pack s. This is an │ │ │ asynchronous operation that will return immediately and actually apply │ │ │ the settings to the main thread of libtorrent some time later.

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

    pop_alerts() wait_for_alert() set_alert_notify()

    │ │ │
    │ │ │ -bool wait_for_alert (time_duration max_wait);
    │ │ │  void set_alert_notify (std::function<void()> const& fun);
    │ │ │  void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ +bool wait_for_alert (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 session still owns these alerts and they will stay │ │ │ valid until the next time pop_alerts is called. You may not delete │ │ │ the alert objects.

    │ │ │

    It is safe to call pop_alerts from multiple different threads, as │ │ │ @@ -1057,18 +1057,18 @@ │ │ │ message to an HWND or some other main message pump. The actual │ │ │ retrieval of alerts should not be done in the callback. In fact, the │ │ │ callback should not block. It should not perform any expensive work. │ │ │ It really should just notify the main application thread.

    │ │ │

    The type of an alert 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.

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

    delete_port_mapping() add_port_mapping()

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

    add_port_mapping() delete_port_mapping()

    │ │ │
    │ │ │  void delete_port_mapping (port_mapping_t handle);
    │ │ │  std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │  
    │ │ │

    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 session. The return values are all handles referring to the │ │ │ @@ -1137,30 +1137,30 @@ │ │ │ [report issue]

    │ │ │
    reopen_map_ports
    │ │ │
    This option indicates if the ports are mapped using natpmp │ │ │ and upnp. If mapping was already made, they are deleted and added │ │ │ again. This only works if natpmp and/or upnp are configured to be │ │ │ enable.
    │ │ │
    │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │
    │ │ │ -
    │ │ │ -

    read_session_params() write_session_params() write_session_params_buf()

    │ │ │ +
    │ │ │ +

    write_session_params_buf() write_session_params() read_session_params()

    │ │ │

    Declared in "libtorrent/session_params.hpp"

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

    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 │ │ │ session's state. │ │ │ ├── html2text {} │ │ │ │ @@ -3,68 +3,68 @@ │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _s_e_s_s_i_o_n___p_a_r_a_m_s │ │ │ │ o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ * _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _~_s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _s_e_s_s_i_o_n___p_r_o_x_y_(_) │ │ │ │ + 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_=_(_) │ │ │ │ * _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 _f_i_n_d___t_o_r_r_e_n_t_(_)_ _g_e_t___t_o_r_r_e_n_t_s_(_) │ │ │ │ + o _g_e_t___t_o_r_r_e_n_t_s_(_)_ _f_i_n_d___t_o_r_r_e_n_t_(_) │ │ │ │ o _a_d_d___t_o_r_r_e_n_t_(_)_ _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ - o _p_a_u_s_e_(_)_ _r_e_s_u_m_e_(_)_ _i_s___p_a_u_s_e_d_(_) │ │ │ │ + o _r_e_s_u_m_e_(_)_ _i_s___p_a_u_s_e_d_(_)_ _p_a_u_s_e_(_) │ │ │ │ o _i_s___d_h_t___r_u_n_n_i_n_g_(_) │ │ │ │ o _s_e_t___d_h_t___s_t_o_r_a_g_e_(_) │ │ │ │ o _a_d_d___d_h_t___n_o_d_e_(_) │ │ │ │ o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___p_u_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___p_u_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___g_e_t___p_e_e_r_s_(_)_ _d_h_t___a_n_n_o_u_n_c_e_(_) │ │ │ │ o _d_h_t___l_i_v_e___n_o_d_e_s_(_) │ │ │ │ o _d_h_t___s_a_m_p_l_e___i_n_f_o_h_a_s_h_e_s_(_) │ │ │ │ o _d_h_t___d_i_r_e_c_t___r_e_q_u_e_s_t_(_) │ │ │ │ o _a_d_d___e_x_t_e_n_s_i_o_n_(_) │ │ │ │ - o _g_e_t___i_p___f_i_l_t_e_r_(_)_ _s_e_t___i_p___f_i_l_t_e_r_(_) │ │ │ │ + o _s_e_t___i_p___f_i_l_t_e_r_(_)_ _g_e_t___i_p___f_i_l_t_e_r_(_) │ │ │ │ o _s_e_t___p_o_r_t___f_i_l_t_e_r_(_) │ │ │ │ o _l_i_s_t_e_n___p_o_r_t_(_)_ _s_s_l___l_i_s_t_e_n___p_o_r_t_(_)_ _i_s___l_i_s_t_e_n_i_n_g_(_) │ │ │ │ o _g_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_) │ │ │ │ - o _s_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_)_ _g_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_) │ │ │ │ + o _g_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_)_ _s_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 _g_e_t___s_e_t_t_i_n_g_s_(_)_ _a_p_p_l_y___s_e_t_t_i_n_g_s_(_) │ │ │ │ o _p_o_p___a_l_e_r_t_s_(_)_ _w_a_i_t___f_o_r___a_l_e_r_t_(_)_ _s_e_t___a_l_e_r_t___n_o_t_i_f_y_(_) │ │ │ │ - o _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_)_ _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ + 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_(_)_ _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___b_u_f_(_)_ _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_)_ _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn__ppaarraammss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___p_a_r_a_m_s_._h_p_p" │ │ │ │ The _s_e_s_s_i_o_n___p_a_r_a_m_s is a parameters pack for configuring the _s_e_s_s_i_o_n before it's │ │ │ │ started. │ │ │ │ struct session_params │ │ │ │ { │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ sseessssiioonn__ppaarraammss (); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ , std::vector> exts); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ , std::vector> exts); │ │ │ │ │ │ │ │ settings_pack settings; │ │ │ │ session_flags_t ffllaaggss {}; │ │ │ │ @@ -73,17 +73,17 @@ │ │ │ │ dht::dht_storage_constructor_type dht_storage_constructor; │ │ │ │ disk_io_constructor_type disk_io_constructor; │ │ │ │ std::map ext_state; │ │ │ │ libtorrent::ip_filter ip_filter; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn__ppaarraammss(()) ********** │ │ │ │ +sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ sseessssiioonn__ppaarraammss (); │ │ │ │ -sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ This constructor can be used to start with the default plugins (ut_metadata, │ │ │ │ ut_pex and smart_ban). Pass a _s_e_t_t_i_n_g_s___p_a_c_k to set the initial settings when │ │ │ │ the _s_e_s_s_i_o_n starts. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn__ppaarraammss(()) ********** │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ , std::vector> exts); │ │ │ │ @@ -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 const&); │ │ │ │ - session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ - sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ sseessssiioonn__pprrooxxyy (); │ │ │ │ + session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) ~~sseessssiioonn__pprrooxxyy(()) sseessssiioonn__pprrooxxyy(()) ********** │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ -session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ +********** sseessssiioonn__pprrooxxyy(()) ~~sseessssiioonn__pprrooxxyy(()) ooppeerraattoorr==(()) ********** │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ sseessssiioonn__pprrooxxyy (); │ │ │ │ +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 │ │ │ │ { │ │ │ │ - explicit sseessssiioonn (session_params&& params); │ │ │ │ explicit sseessssiioonn (session_params const& params); │ │ │ │ + explicit sseessssiioonn (session_params&& params); │ │ │ │ sseessssiioonn (); │ │ │ │ sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ ~~sseessssiioonn (); │ │ │ │ session_proxy aabboorrtt (); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn(()) ********** │ │ │ │ -explicit sseessssiioonn (session_params&& params); │ │ │ │ explicit sseessssiioonn (session_params const& params); │ │ │ │ +explicit sseessssiioonn (session_params&& params); │ │ │ │ sseessssiioonn (); │ │ │ │ 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(()) ********** │ │ │ │ @@ -245,69 +245,69 @@ │ │ │ │ , 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; │ │ │ │ - std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ - void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ + std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ + 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 const& params, error_code& │ │ │ │ ec); │ │ │ │ - bool iiss__ppaauusseedd () const; │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ + void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ void rreessuummee (); │ │ │ │ void ppaauussee (); │ │ │ │ + bool iiss__ppaauusseedd () const; │ │ │ │ bool iiss__ddhhtt__rruunnnniinngg () const; │ │ │ │ void sseett__ddhhtt__ssttoorraaggee (dht::dht_storage_constructor_type sc); │ │ │ │ void aadddd__ddhhtt__nnooddee (std::pair const& node); │ │ │ │ void ddhhtt__ggeett__iitteemm (sha1_hash const& target); │ │ │ │ void ddhhtt__ggeett__iitteemm (std::array key │ │ │ │ , std::string salt = std::string()); │ │ │ │ sha1_hash ddhhtt__ppuutt__iitteemm (entry data); │ │ │ │ void ddhhtt__ppuutt__iitteemm (std::array key │ │ │ │ , std::function& │ │ │ │ , std::int64_t&, std::string const&)> cb │ │ │ │ , std::string salt = std::string()); │ │ │ │ - void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ void ddhhtt__aannnnoouunnccee (sha1_hash const& info_hash, int port = 0, dht:: │ │ │ │ announce_flags_t flags = {}); │ │ │ │ + void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ void ddhhtt__lliivvee__nnooddeess (sha1_hash const& nid); │ │ │ │ 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 aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ ip_filter ggeett__iipp__ffiilltteerr () const; │ │ │ │ void sseett__ppoorrtt__ffiilltteerr (port_filter const& f); │ │ │ │ - bool iiss__lliisstteenniinngg () const; │ │ │ │ unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ + bool iiss__lliisstteenniinngg () const; │ │ │ │ unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ - void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ + void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ peer_class_t ccrreeaattee__ppeeeerr__ccllaassss (char const* name); │ │ │ │ void ddeelleettee__ppeeeerr__ccllaassss (peer_class_t cid); │ │ │ │ - void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ + void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ void rreemmoovvee__ttoorrrreenntt (const torrent_handle&, remove_flags_t = {}); │ │ │ │ + void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ - void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ - bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ + bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ external_port, int local_port); │ │ │ │ void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ reopen_map_ports); │ │ │ │ std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ │ │ │ │ @@ -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] │ │ │ │ -********** ffiinndd__ttoorrrreenntt(()) ggeett__ttoorrrreennttss(()) ********** │ │ │ │ +********** ggeett__ttoorrrreennttss(()) ffiinndd__ttoorrrreenntt(()) ********** │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ -std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ +std::vector ggeett__ttoorrrreennttss () 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] │ │ │ │ ********** aadddd__ttoorrrreenntt(()) aassyynncc__aadddd__ttoorrrreenntt(()) ********** │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ -void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& ec); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ +void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ 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 │ │ │ │ @@ -446,18 +446,18 @@ │ │ │ │ torrent_flags::paused and torrent_flags::auto_managed. In order to add a magnet │ │ │ │ link that will just download the metadata, but no payload, set the │ │ │ │ torrent_flags::upload_mode flag. │ │ │ │ Special consideration has to be taken when adding hybrid torrents (i.e. │ │ │ │ torrents that are BitTorrent v2 torrents that are backwards compatible with │ │ │ │ v1). For more details, see _B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppaauussee(()) rreessuummee(()) iiss__ppaauusseedd(()) ********** │ │ │ │ -bool iiss__ppaauusseedd () const; │ │ │ │ +********** rreessuummee(()) iiss__ppaauusseedd(()) ppaauussee(()) ********** │ │ │ │ void rreessuummee (); │ │ │ │ void ppaauussee (); │ │ │ │ +bool iiss__ppaauusseedd () const; │ │ │ │ Pausing the _s_e_s_s_i_o_n has the same effect as pausing every torrent in it, except │ │ │ │ that torrents will not be resumed by the auto-manage mechanism. Resuming will │ │ │ │ restore the torrents to their previous paused state. i.e. the _s_e_s_s_i_o_n pause │ │ │ │ state is separate from the torrent pause state. A torrent is inactive if it is │ │ │ │ paused or if the _s_e_s_s_i_o_n is paused. 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] │ │ │ │ @@ -535,17 +535,17 @@ │ │ │ │ value is computed via a function instead of just passing in the new value is to │ │ │ │ avoid race conditions. If you want to uuppddaattee the value in the DHT, you must │ │ │ │ first retrieve it, then modify it, then write it back. The way the DHT works, │ │ │ │ it is natural to always do a lookup before storing and calling the callback in │ │ │ │ between is convenient. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ddhhtt__ggeett__ppeeeerrss(()) ddhhtt__aannnnoouunnccee(()) ********** │ │ │ │ -void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ void ddhhtt__aannnnoouunnccee (sha1_hash const& info_hash, int port = 0, dht:: │ │ │ │ announce_flags_t flags = {}); │ │ │ │ +void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ dht_get_peers() will issue a DHT get_peer request to the DHT for the specified │ │ │ │ info-hash. The response (the peers) will be posted back in a │ │ │ │ _d_h_t___g_e_t___p_e_e_r_s___r_e_p_l_y___a_l_e_r_t. │ │ │ │ dht_announce() will issue a DHT announce request to the DHT to the specified │ │ │ │ info-hash, advertising the specified port. If the port is left at its default, │ │ │ │ 0, the port will be implied by the DHT message's source port (which may improve │ │ │ │ connectivity through a NAT). dht_announce() is not affected by the │ │ │ │ @@ -577,17 +577,17 @@ │ │ │ │ Send an arbitrary DHT request directly to the specified endpoint. This function │ │ │ │ is intended for use by plugins. When a response is received or the request │ │ │ │ times out, a _d_h_t___d_i_r_e_c_t___r_e_s_p_o_n_s_e___a_l_e_r_t will be posted with the response (if │ │ │ │ any) and the userdata pointer passed in here. Since this _a_l_e_r_t is a response to │ │ │ │ an explicit call, it will always be posted, regardless of the _a_l_e_r_t mask. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aadddd__eexxtteennssiioonn(()) ********** │ │ │ │ +void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ void aadddd__eexxtteennssiioonn (std::function( │ │ │ │ torrent_handle const&, client_data_t)> ext); │ │ │ │ -void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ This function adds an extension to this _s_e_s_s_i_o_n. The argument is a function │ │ │ │ object that is called with a torrent_handle and which should return a std:: │ │ │ │ shared_ptr. To write custom plugins, see _l_i_b_t_o_r_r_e_n_t_ _p_l_u_g_i_n_s. │ │ │ │ For the typical bittorrent client all of these extensions should be added. The │ │ │ │ main plugins implemented in libtorrent are: │ │ │ │ uTorrent metadata │ │ │ │ Allows peers to download the metadata (.torrent files) from the swarm │ │ │ │ @@ -602,15 +602,15 @@ │ │ │ │ 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(()) ********** │ │ │ │ +********** sseett__iipp__ffiilltteerr(()) ggeett__iipp__ffiilltteerr(()) ********** │ │ │ │ void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ ip_filter ggeett__iipp__ffiilltteerr () const; │ │ │ │ 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 │ │ │ │ @@ -621,16 +621,16 @@ │ │ │ │ void sseett__ppoorrtt__ffiilltteerr (port_filter const& f); │ │ │ │ apply _p_o_r_t___f_i_l_t_e_r f to incoming and outgoing peers. a port filter will reject │ │ │ │ making outgoing peer connections to certain remote ports. The main intention is │ │ │ │ to be able to avoid triggering certain anti-virus software by connecting to │ │ │ │ SMTP, FTP ports. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** lliisstteenn__ppoorrtt(()) ssssll__lliisstteenn__ppoorrtt(()) iiss__lliisstteenniinngg(()) ********** │ │ │ │ -bool iiss__lliisstteenniinngg () const; │ │ │ │ unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ +bool iiss__lliisstteenniinngg () const; │ │ │ │ unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ is_listening() will tell you whether or not the _s_e_s_s_i_o_n has successfully opened │ │ │ │ a listening port. If it hasn't, this function will return false, and then you │ │ │ │ can set a new _s_e_t_t_i_n_g_s___p_a_c_k_:_:_l_i_s_t_e_n___i_n_t_e_r_f_a_c_e_s to try another interface and │ │ │ │ port to bind to. │ │ │ │ listen_port() returns the port we ended up listening on. │ │ │ │ ssl_listen_port() returns the port used for incoming SSL connections, or 0 if │ │ │ │ @@ -659,17 +659,17 @@ │ │ │ │ in the IP range mapping. Only the set bits matter; no peer class will be │ │ │ │ removed from a peer as a result of this call, peer classes are only added. │ │ │ │ The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ │ peer classes in the peer_class_filter are 32 bits. │ │ │ │ The get_peer_class_filter() function returns the current filter. │ │ │ │ For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ********** │ │ │ │ -void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ +********** ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ********** │ │ │ │ peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ +void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ Sets and gets the ppeeeerr ccllaassss ttyyppee ffiilltteerr. This is controls automatic peer class │ │ │ │ assignments to peers based on what kind of socket it is. │ │ │ │ It does not only support assigning peer classes, it also supports removing peer │ │ │ │ classes based on socket type. │ │ │ │ The order of these rules being applied are: │ │ │ │ 1. peer-class IP filter │ │ │ │ 2. peer-class type filter, removing classes │ │ │ │ @@ -697,17 +697,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(()) ********** │ │ │ │ -void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ +********** ggeett__ppeeeerr__ccllaassss(()) sseett__ppeeeerr__ccllaassss(()) ********** │ │ │ │ peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ +void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ These functions queries information from a peer class and updates the │ │ │ │ configuration of a peer class, respectively. │ │ │ │ cid must refer to an existing peer class. If it does not, the return value of │ │ │ │ get_peer_class() is undefined. │ │ │ │ set_peer_class() sets all the information in the _p_e_e_r___c_l_a_s_s___i_n_f_o object in the │ │ │ │ specified peer class. There is no option to only update a single property. │ │ │ │ A peer or torrent belonging to more than one class, the highest priority among │ │ │ │ @@ -738,25 +738,25 @@ │ │ │ │ Note that when a queued or downloading torrent is removed, its position in the │ │ │ │ download queue is vacated and every subsequent torrent in the queue has their │ │ │ │ queue positions updated. This can potentially cause a large state_update to be │ │ │ │ posted. When removing all torrents, it is advised to remove them from the back │ │ │ │ of the queue, to minimize the shifting. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ggeett__sseettttiinnggss(()) aappppllyy__sseettttiinnggss(()) ********** │ │ │ │ +void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ -void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ Applies the settings specified by the _s_e_t_t_i_n_g_s___p_a_c_k s. This is an asynchronous │ │ │ │ operation that will return immediately and actually apply the settings to the │ │ │ │ main thread of libtorrent some time later. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ppoopp__aalleerrttss(()) wwaaiitt__ffoorr__aalleerrtt(()) sseett__aalleerrtt__nnoottiiffyy(()) ********** │ │ │ │ -bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ 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. │ │ │ │ @@ -796,15 +796,15 @@ │ │ │ │ alerts should not be done in the callback. In fact, the callback should not │ │ │ │ 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] │ │ │ │ -********** ddeelleettee__ppoorrtt__mmaappppiinngg(()) aadddd__ppoorrtt__mmaappppiinngg(()) ********** │ │ │ │ +********** 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); │ │ │ │ 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. │ │ │ │ @@ -853,25 +853,25 @@ │ │ │ │ protocols used by _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ reopen_map_ports │ │ │ │ This option indicates if the ports are mapped using natpmp and upnp. If │ │ │ │ mapping was already made, they are deleted and added again. This only │ │ │ │ works if natpmp and/or upnp are configured to be enable. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ rreeaadd__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss__bbuuff(()) │ │ │ │ +************ wwrriittee__sseessssiioonn__ppaarraammss__bbuuff(()) wwrriittee__sseessssiioonn__ppaarraammss(()) rreeaadd__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" │ │ │ │ -session_params rreeaadd__sseessssiioonn__ppaarraammss (bdecode_node const& e │ │ │ │ - , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ session_params rreeaadd__sseessssiioonn__ppaarraammss (span buf │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ -entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ - , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ std::vector wwrriittee__sseessssiioonn__ppaarraammss__bbuuff (session_params const& sp │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ +session_params rreeaadd__sseessssiioonn__ppaarraammss (bdecode_node const& e │ │ │ │ + , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ +entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ + , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ 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 │ │ │ │ _s_e_s_s_i_o_n are not part of the _s_e_s_s_i_o_n___p_a_r_a_m_s state, they have to be restored │ │ ├── ./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 │ │ │ @@ -4826,17 +4826,17 @@ │ │ │ │ │ │ │ │ │ │ │ │

    the WebRTC connection timeout used by WebTorrent (in seconds)

    │ │ │
    │ │ │  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_int (int name, int 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;
    │ │ │  
    │ │ │ @@ -4911,22 +4911,22 @@
    │ │ │        socks5,
    │ │ │        socks5_pw,
    │ │ │        http,
    │ │ │        http_pw,
    │ │ │     };
    │ │ │  };
    │ │ │  
    │ │ │ + │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_int() set_bool() set_str()

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

    set_str() set_int() set_bool()

    │ │ │
    │ │ │ -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_int (int name, int 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()

    │ │ │ @@ -4946,19 +4946,19 @@ │ │ │ [report issue]
    │ │ │
    │ │ │

    clear()

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

    clear a specific setting from the pack

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

    get_str() get_int() get_bool()

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

    queries the current configuration option from the settings_pack. │ │ │ name is one of the enumeration values from string_types, int_types │ │ │ @@ -5322,16 +5322,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]
    │ │ │
    │ │ │ +
    │ │ │ +

    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

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

    high_performance_seed() min_memory_usage()

    │ │ │ +

    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);
    │ │ │  
    │ │ │ @@ -5380,62 +5428,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 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]
    │ │ │ -
    │ │ │ -

    setting_by_name() name_for_setting()

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

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

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

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

    default_settings()

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

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

    returns a settings_pack with every setting set to its default value

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

    session_stats_metrics()

    │ │ │

    Declared in "libtorrent/session_stats.hpp"

    │ │ │
    │ │ │  std::vector<stats_metric> session_stats_metrics ();
    │ │ │  
    │ │ │

    This free function returns the list of available metrics exposed by │ │ │ ├── html2text {} │ │ │ │ @@ -1,21 +1,40 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ + * _s_t_a_t_s___m_e_t_r_i_c │ │ │ │ * _c_o_u_n_t_e_r_s │ │ │ │ o _i_n_c___s_t_a_t_s___c_o_u_n_t_e_r_(_) │ │ │ │ o _o_p_e_r_a_t_o_r_[_]_(_) │ │ │ │ o _s_e_t___v_a_l_u_e_(_)_ _b_l_e_n_d___s_t_a_t_s___c_o_u_n_t_e_r_(_) │ │ │ │ - * _s_t_a_t_s___m_e_t_r_i_c │ │ │ │ * _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_) │ │ │ │ * _f_i_n_d___m_e_t_r_i_c___i_d_x_(_) │ │ │ │ * _e_n_u_m_ _m_e_t_r_i_c___t_y_p_e___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttaattss__mmeettrriicc ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ +describes one statistics metric from the _s_e_s_s_i_o_n. For more information, see the │ │ │ │ +_s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ +struct stats_metric │ │ │ │ +{ │ │ │ │ + char const* name; │ │ │ │ + int value_index; │ │ │ │ + metric_type_t type; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + name │ │ │ │ + the name of the counter or gauge │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + value_index type │ │ │ │ + the index into the _s_e_s_s_i_o_n stats array, where the underlying value of │ │ │ │ + this counter or gauge is found. The _s_e_s_s_i_o_n stats array is part of the │ │ │ │ + _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t object. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ccoouunntteerrss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_r_f_o_r_m_a_n_c_e___c_o_u_n_t_e_r_s_._h_p_p" │ │ │ │ holds the session-wide _c_o_u_n_t_e_r_s and gauges backing the session_stats_alert and │ │ │ │ session_status reporting paths. One instance lives on the _s_e_s_s_i_o_n and is │ │ │ │ incremented from the network thread; reads from other threads use the lock-free │ │ │ │ operator[] overload when ATOMIC_LLONG_LOCK_FREE is set, otherwise a single │ │ │ │ shared mutex guards the whole array. │ │ │ │ @@ -47,33 +66,14 @@ │ │ │ │ ********** sseett__vvaalluuee(()) bblleenndd__ssttaattss__ccoouunntteerr(()) ********** │ │ │ │ void sseett__vvaalluuee (int c, std::int64_t value) ; │ │ │ │ void bblleenndd__ssttaattss__ccoouunntteerr (int c, std::int64_t value, int ratio) ; │ │ │ │ overwrites the value of counter or gauge c (an index into the counter array). │ │ │ │ blend_stats_counter() adjusts the stat value toward the specified value, ratio │ │ │ │ specifies the percent of the new value should be influenced by value. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttaattss__mmeettrriicc ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ -describes one statistics metric from the _s_e_s_s_i_o_n. For more information, see the │ │ │ │ -_s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ -struct stats_metric │ │ │ │ -{ │ │ │ │ - char const* name; │ │ │ │ - int value_index; │ │ │ │ - metric_type_t type; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - name │ │ │ │ - the name of the counter or gauge │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - value_index type │ │ │ │ - the index into the _s_e_s_s_i_o_n stats array, where the underlying value of │ │ │ │ - this counter or gauge is found. The _s_e_s_s_i_o_n stats array is part of the │ │ │ │ - _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn__ssttaattss__mmeettrriiccss(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ std::vector sseessssiioonn__ssttaattss__mmeettrriiccss (); │ │ │ │ This free function returns the list of available metrics exposed by │ │ │ │ libtorrent's statistics API. Each metric has a name and a vvaalluuee iinnddeexx. The │ │ │ │ value index is the index into the array in _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t where this │ │ │ │ metric's value can be found when the _s_e_s_s_i_o_n stats is sampled (by calling │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ @@ -28,87 +28,166 @@ │ │ │ 2.1.0 │ │ │ │ │ │ │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

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

    storage_params

    │ │ │ +

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ +

    a parameter pack used to construct the storage for a torrent, used in │ │ │ +disk_interface

    │ │ │ +
    │ │ │ +struct storage_params
    │ │ │ +{
    │ │ │ +   storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ +      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ +      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ +      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ +
    │ │ │ +   file_storage const& files;
    │ │ │ +   lt::renamed_files const& renamed_files;
    │ │ │ +   string_view path;
    │ │ │ +   string_view part_file_dir;
    │ │ │ +   storage_mode_t mode {storage_mode_sparse};
    │ │ │ +   aux::vector<download_priority_t, file_index_t> const& priorities;
    │ │ │ +   sha1_hash info_hash;
    │ │ │ +   bool v1;
    │ │ │ +   bool v2;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    storage_params()

    │ │ │ +
    │ │ │ +storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ +      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ +      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ +      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ +
    │ │ │ +

    constructs a parameter pack from the layout, save path, mode, │ │ │ +per-file priorities, info-hash and protocol-version flags. │ │ │ +v1 indicates that the torrent has v1 metadata (a SHA-1 │ │ │ +info-hash); v2 that it has v2 metadata (BEP 52). A hybrid │ │ │ +torrent has both set.

    │ │ │ +[report issue]
    │ │ │ +
    files
    │ │ │ +
    the file layout (sizes, paths, flags) of the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    renamed_files
    │ │ │ +
    rename overlay applied on top of files; on-disk paths │ │ │ +resolved through this object take precedence over the │ │ │ +originals
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    path
    │ │ │ +
    the directory where the torrent's files are stored
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    part_file_dir
    │ │ │ +
    directory in which the part file is created. If empty, the │ │ │ +part file is placed under path.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    mode
    │ │ │ +
    the storage allocation mode (sparse vs. pre-allocated)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    priorities
    │ │ │ +
    per-file download priorities, indexed by file index
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    info_hash
    │ │ │ +
    the SHA-1 info-hash of the torrent (zero for v2-only │ │ │ +torrents)
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    v1 v2
    │ │ │ +
    indicates which BitTorrent protocol version(s) this storage │ │ │ +is for. v1 is true if the torrent has v1 metadata; │ │ │ +v2 is true if the torrent has v2 metadata (BEP 52). A │ │ │ +hybrid torrent has both flags set.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │

    file_slice

    │ │ │

    Declared in "libtorrent/file_storage.hpp"

    │ │ │

    represents a window of a file in a torrent.

    │ │ │

    The file_index refers to the index of the file (in the torrent_info). │ │ │ To get the path and filename, use file_path() and give the file_index │ │ │ as argument. The offset is the byte offset in the file where the range │ │ │ starts, and size is the number of bytes this range is. The size + offset │ │ │ @@ -172,47 +251,47 @@ │ │ │ std::int64_t total_size () const; │ │ │ std::int64_t size_on_disk () const; │ │ │ int num_pieces () const; │ │ │ void set_num_pieces (int n); │ │ │ piece_index_t end_piece () const; │ │ │ piece_index_t last_piece () const; │ │ │ index_range<piece_index_t> piece_range () const noexcept; │ │ │ - void set_piece_length (int l); │ │ │ int piece_length () const; │ │ │ + void set_piece_length (int l); │ │ │ int piece_size (piece_index_t index) const; │ │ │ int piece_size2 (piece_index_t index) const; │ │ │ int blocks_in_piece2 (piece_index_t index) const; │ │ │ int blocks_per_piece () const; │ │ │ std::string const& name () const; │ │ │ void set_name (std::string const& n); │ │ │ void swap (file_storage& ti) noexcept; │ │ │ std::int64_t file_size (file_index_t index) const; │ │ │ - std::string symlink (file_index_t index) const; │ │ │ - string_view file_name (file_index_t index) const; │ │ │ + char const* root_ptr (file_index_t const index) const; │ │ │ std::string file_path (file_index_t index, std::string const& save_path = "") const; │ │ │ - bool pad_file_at (file_index_t index) const; │ │ │ std::int64_t file_offset (file_index_t index) const; │ │ │ - char const* root_ptr (file_index_t const index) const; │ │ │ - std::time_t mtime (file_index_t index) const; │ │ │ sha256_hash root (file_index_t index) const; │ │ │ + string_view file_name (file_index_t index) const; │ │ │ + std::string symlink (file_index_t index) const; │ │ │ + bool pad_file_at (file_index_t index) const; │ │ │ + std::time_t mtime (file_index_t index) const; │ │ │ index_range<piece_index_t::diff_type> file_piece_range (file_index_t) const; │ │ │ int file_num_pieces (file_index_t index) const; │ │ │ int file_num_blocks (file_index_t index) const; │ │ │ - int file_first_piece_node (file_index_t index) const; │ │ │ int file_first_block_node (file_index_t index) const; │ │ │ + int file_first_piece_node (file_index_t index) const; │ │ │ std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const; │ │ │ void all_path_hashes (std::unordered_set<std::uint32_t>& table) const; │ │ │ file_flags_t file_flags (file_index_t index) const; │ │ │ bool file_absolute_path (file_index_t index) const; │ │ │ file_index_t file_index_at_piece (piece_index_t piece) const; │ │ │ file_index_t file_index_at_offset (std::int64_t offset) const; │ │ │ file_index_t last_file_index_at_piece (piece_index_t piece) const; │ │ │ file_index_t file_index_for_root (sha256_hash const& root_hash) const; │ │ │ - piece_index_t piece_index_at_file (file_index_t f) const; │ │ │ piece_index_t last_piece_index_at_file (file_index_t f) const; │ │ │ + piece_index_t piece_index_at_file (file_index_t f) const; │ │ │ void sanitize_symlinks (); │ │ │ bool v2 () const; │ │ │ │ │ │ static inline constexpr file_flags_t flag_pad_file = 0_bit; │ │ │ static inline constexpr file_flags_t flag_hidden = 1_bit; │ │ │ static inline constexpr file_flags_t flag_executable = 2_bit; │ │ │ static inline constexpr file_flags_t flag_symlink = 3_bit; │ │ │ @@ -411,26 +490,26 @@ │ │ │ container in a range-for loop. Where the values are the indices of all │ │ │ pieces in the file_storage.

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

    set_piece_length() piece_length()

    │ │ │
    │ │ │ -void set_piece_length (int l);
    │ │ │  int piece_length () const;
    │ │ │ +void set_piece_length (int l);
    │ │ │  
    │ │ │

    set and get the size of each piece in this torrent. It must be a power of two │ │ │ and at least 16 kiB.

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

    piece_size()

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

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

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

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

    piece_size2()

    │ │ │
    │ │ │  int piece_size2 (piece_index_t index) const;
    │ │ │  
    │ │ │ @@ -466,35 +545,35 @@ │ │ │ [report issue]
    │ │ │
    │ │ │

    swap()

    │ │ │
    │ │ │  void swap (file_storage& ti) noexcept;
    │ │ │  
    │ │ │

    swap all content of this with ti.

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

    file_first_piece_node() file_first_block_node()

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

    file_first_block_node() file_first_piece_node()

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

    index of first piece node in the merkle tree

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

    file_path_hash()

    │ │ │
    │ │ │  std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const;
    │ │ │ @@ -573,18 +652,18 @@
    │ │ │  
    │ │ │  bool file_absolute_path (file_index_t index) const;
    │ │ │  
    │ │ │

    returns true if the file at the specified index has been renamed to │ │ │ have an absolute path, i.e. is not anchored in the save path of the │ │ │ torrent.

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

    last_file_index_at_piece() file_index_at_piece() file_index_at_offset()

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

    last_file_index_at_piece() file_index_at_offset() file_index_at_piece()

    │ │ │
    │ │ │  file_index_t file_index_at_piece (piece_index_t piece) const;
    │ │ │  file_index_t file_index_at_offset (std::int64_t offset) const;
    │ │ │  file_index_t last_file_index_at_piece (piece_index_t piece) const;
    │ │ │  
    │ │ │

    returns the index of the file at the given offset or piece in the torrent

    │ │ │ [report issue]
    │ │ │ @@ -596,16 +675,16 @@ │ │ │

    finds the file with the given root hash and returns its index │ │ │ if there is no file with the root hash, file_index_t{-1} is returned

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

    last_piece_index_at_file() piece_index_at_file()

    │ │ │
    │ │ │ -piece_index_t piece_index_at_file (file_index_t f) const;
    │ │ │  piece_index_t last_piece_index_at_file (file_index_t f) const;
    │ │ │ +piece_index_t piece_index_at_file (file_index_t f) const;
    │ │ │  
    │ │ │

    returns the first or last piece index of the given file in the torrent

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

    pad_file_at()

    │ │ │
    │ │ │  bool pad_file_at (file_index_t const index) const;
    │ │ │  
    │ │ │

    returns true if the file at index is a pad file

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

    file_size() file_offset()

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

    file_offset() file_size()

    │ │ │
    │ │ │ -std::int64_t file_size (file_index_t const index) const;
    │ │ │  std::int64_t file_offset (file_index_t const index) const;
    │ │ │ +std::int64_t file_size (file_index_t const index) const;
    │ │ │  
    │ │ │

    returns the file size or file offset for the file at index. The │ │ │ file offset is in the torrent space, of all files in the torrent, in │ │ │ the order they are defined.

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

    file_path() file_absolute_path()

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

    file_absolute_path() file_path()

    │ │ │
    │ │ │ -std::string file_path (file_index_t const index, std::string const& save_path = "") const;
    │ │ │  bool file_absolute_path (file_index_t const index) const;
    │ │ │ +std::string file_path (file_index_t const index, std::string const& save_path = "") const;
    │ │ │  
    │ │ │

    returns the on-disk path for the file at index, applying │ │ │ any rename recorded in the underlying renamed_files. If │ │ │ save_path is non-empty it is prepended to relative │ │ │ paths. file_absolute_path() returns true if the recorded │ │ │ rename is an absolute path (in which case save_path is │ │ │ ignored).

    │ │ │ @@ -796,21 +875,21 @@ │ │ │

    file_range()

    │ │ │
    │ │ │  index_range<file_index_t> file_range () const noexcept;
    │ │ │  
    │ │ │

    all file indices in the underlying file_storage. Convenient in │ │ │ range-for loops.

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

    num_files() num_pieces() end_piece()

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

    num_files() end_piece() num_pieces()

    │ │ │
    │ │ │ -int num_pieces () const;
    │ │ │  piece_index_t end_piece () const;
    │ │ │ +int num_pieces () const;
    │ │ │  int num_files () const noexcept;
    │ │ │  
    │ │ │

    the number of files in the underlying file_storage, the │ │ │ number of pieces, and the one-past-the-end piece index.

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

    map_block()

    │ │ │ @@ -845,136 +924,57 @@ │ │ │
    │ │ │

    piece_length()

    │ │ │
    │ │ │  int piece_length () const;
    │ │ │  
    │ │ │

    the piece size, in bytes. All pieces have this size except │ │ │ the last, which may be shorter.

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

    storage_params

    │ │ │ -

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ -

    a parameter pack used to construct the storage for a torrent, used in │ │ │ -disk_interface

    │ │ │ +
    │ │ │ +

    mmap_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/mmap_disk_io.hpp"

    │ │ │
    │ │ │ -struct storage_params
    │ │ │ -{
    │ │ │ -   storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ -      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ -      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ -      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ -
    │ │ │ -   file_storage const& files;
    │ │ │ -   lt::renamed_files const& renamed_files;
    │ │ │ -   string_view path;
    │ │ │ -   string_view part_file_dir;
    │ │ │ -   storage_mode_t mode {storage_mode_sparse};
    │ │ │ -   aux::vector<download_priority_t, file_index_t> const& priorities;
    │ │ │ -   sha1_hash info_hash;
    │ │ │ -   bool v1;
    │ │ │ -   bool v2;
    │ │ │ -};
    │ │ │ +std::unique_ptr<disk_interface> mmap_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -

    storage_params()

    │ │ │ +

    constructs a memory mapped file disk I/O object.

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

    default_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/session.hpp"

    │ │ │
    │ │ │ -storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ -      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ -      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ -      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ +std::unique_ptr<disk_interface> default_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │  
    │ │ │ -

    constructs a parameter pack from the layout, save path, mode, │ │ │ -per-file priorities, info-hash and protocol-version flags. │ │ │ -v1 indicates that the torrent has v1 metadata (a SHA-1 │ │ │ -info-hash); v2 that it has v2 metadata (BEP 52). A hybrid │ │ │ -torrent has both set.

    │ │ │ -[report issue]
    │ │ │ -
    files
    │ │ │ -
    the file layout (sizes, paths, flags) of the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    renamed_files
    │ │ │ -
    rename overlay applied on top of files; on-disk paths │ │ │ -resolved through this object take precedence over the │ │ │ -originals
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    path
    │ │ │ -
    the directory where the torrent's files are stored
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    part_file_dir
    │ │ │ -
    directory in which the part file is created. If empty, the │ │ │ -part file is placed under path.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    mode
    │ │ │ -
    the storage allocation mode (sparse vs. pre-allocated)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    priorities
    │ │ │ -
    per-file download priorities, indexed by file index
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hash
    │ │ │ -
    the SHA-1 info-hash of the torrent (zero for v2-only │ │ │ -torrents)
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    v1 v2
    │ │ │ -
    indicates which BitTorrent protocol version(s) this storage │ │ │ -is for. v1 is true if the torrent has v1 metadata; │ │ │ -v2 is true if the torrent has v2 metadata (BEP 52). A │ │ │ -hybrid torrent has both flags set.
    │ │ │ -
    │ │ │ +

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

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

    disabled_disk_io_constructor()

    │ │ │

    Declared in "libtorrent/disabled_disk_io.hpp"

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

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

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

    mmap_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/mmap_disk_io.hpp"

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

    constructs a memory mapped file disk I/O object.

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

    posix_disk_io_constructor()

    │ │ │

    Declared in "libtorrent/posix_disk_io.hpp"

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

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

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

    default_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/session.hpp"

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

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

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

    enum storage_mode_t

    │ │ │

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ @@ -1,12 +1,14 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ + * _s_t_o_r_a_g_e___p_a_r_a_m_s │ │ │ │ + o _s_t_o_r_a_g_e___p_a_r_a_m_s_(_) │ │ │ │ * _f_i_l_e___s_l_i_c_e │ │ │ │ * _f_i_l_e___s_t_o_r_a_g_e │ │ │ │ o _i_s___v_a_l_i_d_(_) │ │ │ │ o _r_e_s_e_r_v_e_(_) │ │ │ │ o _a_d_d___f_i_l_e_(_)_ _a_d_d___f_i_l_e___b_o_r_r_o_w_(_) │ │ │ │ o _a_d_d___f_i_l_e_(_)_ _a_d_d___f_i_l_e___b_o_r_r_o_w_(_) │ │ │ │ o _m_a_p___b_l_o_c_k_(_) │ │ │ │ @@ -23,55 +25,113 @@ │ │ │ │ o _s_e_t___p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ o _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ o _p_i_e_c_e___s_i_z_e_2_(_) │ │ │ │ o _b_l_o_c_k_s___i_n___p_i_e_c_e_2_(_) │ │ │ │ o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ o _s_e_t___n_a_m_e_(_)_ _n_a_m_e_(_) │ │ │ │ o _s_w_a_p_(_) │ │ │ │ - o _f_i_l_e___n_a_m_e_(_)_ _s_y_m_l_i_n_k_(_)_ _r_o_o_t_(_)_ _p_a_d___f_i_l_e___a_t_(_)_ _f_i_l_e___s_i_z_e_(_)_ _r_o_o_t___p_t_r_(_) │ │ │ │ - _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___o_f_f_s_e_t_(_)_ _m_t_i_m_e_(_) │ │ │ │ + o _p_a_d___f_i_l_e___a_t_(_)_ _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___s_i_z_e_(_)_ _r_o_o_t___p_t_r_(_)_ _f_i_l_e___n_a_m_e_(_)_ _r_o_o_t_(_) │ │ │ │ + _s_y_m_l_i_n_k_(_)_ _f_i_l_e___o_f_f_s_e_t_(_)_ _m_t_i_m_e_(_) │ │ │ │ o _f_i_l_e___n_u_m___b_l_o_c_k_s_(_)_ _f_i_l_e___p_i_e_c_e___r_a_n_g_e_(_)_ _f_i_l_e___n_u_m___p_i_e_c_e_s_(_) │ │ │ │ - o _f_i_l_e___f_i_r_s_t___p_i_e_c_e___n_o_d_e_(_)_ _f_i_l_e___f_i_r_s_t___b_l_o_c_k___n_o_d_e_(_) │ │ │ │ + o _f_i_l_e___f_i_r_s_t___b_l_o_c_k___n_o_d_e_(_)_ _f_i_l_e___f_i_r_s_t___p_i_e_c_e___n_o_d_e_(_) │ │ │ │ o _f_i_l_e___p_a_t_h___h_a_s_h_(_) │ │ │ │ o _a_l_l___p_a_t_h___h_a_s_h_e_s_(_) │ │ │ │ o _f_i_l_e___f_l_a_g_s_(_) │ │ │ │ o _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ - o _l_a_s_t___f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_)_ _f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_) │ │ │ │ - _f_i_l_e___i_n_d_e_x___a_t___o_f_f_s_e_t_(_) │ │ │ │ + o _l_a_s_t___f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_)_ _f_i_l_e___i_n_d_e_x___a_t___o_f_f_s_e_t_(_) │ │ │ │ + _f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_) │ │ │ │ o _f_i_l_e___i_n_d_e_x___f_o_r___r_o_o_t_(_) │ │ │ │ o _l_a_s_t___p_i_e_c_e___i_n_d_e_x___a_t___f_i_l_e_(_)_ _p_i_e_c_e___i_n_d_e_x___a_t___f_i_l_e_(_) │ │ │ │ o _s_a_n_i_t_i_z_e___s_y_m_l_i_n_k_s_(_) │ │ │ │ o _v_2_(_) │ │ │ │ * _r_e_n_a_m_e_d___f_i_l_e_s │ │ │ │ o _f_i_l_e___n_a_m_e_(_)_ _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ o _r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ o _i_m_p_o_r_t___f_i_l_e_n_a_m_e_s_(_)_ _e_x_p_o_r_t___f_i_l_e_n_a_m_e_s_(_) │ │ │ │ * _f_i_l_e_n_a_m_e_s │ │ │ │ o _f_i_l_e_n_a_m_e_s_(_) │ │ │ │ o _f_i_l_e___f_l_a_g_s_(_) │ │ │ │ o _e_n_d___f_i_l_e_(_) │ │ │ │ o _p_a_d___f_i_l_e___a_t_(_) │ │ │ │ - o _f_i_l_e___s_i_z_e_(_)_ _f_i_l_e___o_f_f_s_e_t_(_) │ │ │ │ - o _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ + o _f_i_l_e___o_f_f_s_e_t_(_)_ _f_i_l_e___s_i_z_e_(_) │ │ │ │ + o _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_)_ _f_i_l_e___p_a_t_h_(_) │ │ │ │ o _s_y_m_l_i_n_k_(_) │ │ │ │ o _f_i_l_e___r_a_n_g_e_(_) │ │ │ │ - o _n_u_m___f_i_l_e_s_(_)_ _n_u_m___p_i_e_c_e_s_(_)_ _e_n_d___p_i_e_c_e_(_) │ │ │ │ + o _n_u_m___f_i_l_e_s_(_)_ _e_n_d___p_i_e_c_e_(_)_ _n_u_m___p_i_e_c_e_s_(_) │ │ │ │ o _m_a_p___b_l_o_c_k_(_) │ │ │ │ o _m_a_p___f_i_l_e_(_) │ │ │ │ o _r_o_o_t_(_) │ │ │ │ o _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ - * _s_t_o_r_a_g_e___p_a_r_a_m_s │ │ │ │ - o _s_t_o_r_a_g_e___p_a_r_a_m_s_(_) │ │ │ │ - * _d_i_s_a_b_l_e_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _m_m_a_p___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ - * _p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _d_e_f_a_u_l_t___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _d_i_s_a_b_l_e_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _e_n_u_m_ _s_t_o_r_a_g_e___m_o_d_e___t │ │ │ │ * _e_n_u_m_ _m_o_v_e___f_l_a_g_s___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttoorraaggee__ppaarraammss ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ +a parameter pack used to construct the storage for a torrent, used in │ │ │ │ +_d_i_s_k___i_n_t_e_r_f_a_c_e │ │ │ │ +struct storage_params │ │ │ │ +{ │ │ │ │ + ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ + , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ + , aux::vector const& prio │ │ │ │ + , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ + │ │ │ │ + file_storage const& files; │ │ │ │ + lt::renamed_files const& renamed_files; │ │ │ │ + string_view path; │ │ │ │ + string_view part_file_dir; │ │ │ │ + storage_mode_t mmooddee {storage_mode_sparse}; │ │ │ │ + aux::vector const& priorities; │ │ │ │ + sha1_hash info_hash; │ │ │ │ + bool v1; │ │ │ │ + bool v2; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ssttoorraaggee__ppaarraammss(()) ********** │ │ │ │ +ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ + , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ + , aux::vector const& prio │ │ │ │ + , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ +constructs a parameter pack from the layout, save path, mode, per-file │ │ │ │ +priorities, info-hash and protocol-version flags. v1 indicates that the torrent │ │ │ │ +has v1 metadata (a SHA-1 info-hash); v2 that it has v2 metadata (BEP 52). A │ │ │ │ +hybrid torrent has both set. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + files │ │ │ │ + the file layout (sizes, paths, flags) of the torrent │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + renamed_files │ │ │ │ + rename overlay applied on top of files; on-disk paths resolved through │ │ │ │ + this object take precedence over the originals │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + path │ │ │ │ + the directory where the torrent's files are stored │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + part_file_dir │ │ │ │ + directory in which the part file is created. If empty, the part file is │ │ │ │ + placed under path. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + mode │ │ │ │ + the storage allocation mode (sparse vs. pre-allocated) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + priorities │ │ │ │ + per-file download priorities, indexed by file index │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + info_hash │ │ │ │ + the SHA-1 info-hash of the torrent (zero for v2-only torrents) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + v1 v2 │ │ │ │ + indicates which BitTorrent protocol version(s) this storage is for. v1 is │ │ │ │ + true if the torrent has v1 metadata; v2 is true if the torrent has v2 │ │ │ │ + metadata (BEP 52). A hybrid torrent has both flags set. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ffiillee__sslliiccee ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ represents a window of a file in a torrent. │ │ │ │ The file_index refers to the index of the file (in the _t_o_r_r_e_n_t___i_n_f_o). To get │ │ │ │ the path and filename, use file_path() and give the file_index as argument. The │ │ │ │ offset is the byte offset in the file where the range starts, and size is the │ │ │ │ number of bytes this range is. The size + offset will never be greater than the │ │ │ │ @@ -129,49 +189,49 @@ │ │ │ │ std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ int nnuumm__ppiieecceess () const; │ │ │ │ void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ - void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ + void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ int ppiieeccee__ssiizzee22 (piece_index_t index) const; │ │ │ │ int bblloocckkss__iinn__ppiieeccee22 (piece_index_t index) const; │ │ │ │ int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ std::string const& nnaammee () const; │ │ │ │ void sseett__nnaammee (std::string const& n); │ │ │ │ void sswwaapp (file_storage& ti) noexcept; │ │ │ │ std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ - std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ - string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ + char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = │ │ │ │ "") const; │ │ │ │ - bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ - char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ - std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ sha256_hash rroooott (file_index_t index) const; │ │ │ │ + string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ + std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ + bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ + std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ index_range ffiillee__ppiieeccee__rraannggee (file_index_t) const; │ │ │ │ int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ - int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ + int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& │ │ │ │ save_path) const; │ │ │ │ void aallll__ppaatthh__hhaasshheess (std::unordered_set& table) const; │ │ │ │ file_flags_t ffiillee__ffllaaggss (file_index_t index) const; │ │ │ │ bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t index) const; │ │ │ │ file_index_t ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ file_index_t ffiillee__iinnddeexx__aatt__ooffffsseett (std::int64_t offset) const; │ │ │ │ file_index_t llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ file_index_t ffiillee__iinnddeexx__ffoorr__rroooott (sha256_hash const& root_hash) const; │ │ │ │ - piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ piece_index_t llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ + piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ void ssaanniittiizzee__ssyymmlliinnkkss (); │ │ │ │ bool vv22 () const; │ │ │ │ │ │ │ │ static inline constexpr file_flags_t ffllaagg__ppaadd__ffiillee = 0_bit; │ │ │ │ static inline constexpr file_flags_t ffllaagg__hhiiddddeenn = 1_bit; │ │ │ │ static inline constexpr file_flags_t ffllaagg__eexxeeccuuttaabbllee = 2_bit; │ │ │ │ static inline constexpr file_flags_t ffllaagg__ssyymmlliinnkk = 3_bit; │ │ │ │ @@ -309,16 +369,16 @@ │ │ │ │ ********** ppiieeccee__rraannggee(()) ********** │ │ │ │ index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ returns an implementation-defined type that can be used as the container in a │ │ │ │ range-for loop. Where the values are the indices of all pieces in the │ │ │ │ _f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseett__ppiieeccee__lleennggtthh(()) ppiieeccee__lleennggtthh(()) ********** │ │ │ │ -void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ +void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ set and get the size of each piece in this torrent. It must be a power of two │ │ │ │ and at least 16 kiB. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ppiieeccee__ssiizzee(()) ********** │ │ │ │ int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ returns the piece size of index. This will be the same as _p_i_e_c_e___l_e_n_g_t_h_(_), │ │ │ │ except for the last piece, which may be shorter. │ │ │ │ @@ -345,26 +405,26 @@ │ │ │ │ set and get the name of this torrent. For multi-file torrents, this is also the │ │ │ │ name of the root directory all the files are stored in. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sswwaapp(()) ********** │ │ │ │ void sswwaapp (file_storage& ti) noexcept; │ │ │ │ swap all content of tthhiiss with ttii. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__nnaammee(()) ssyymmlliinnkk(()) rroooott(()) ppaadd__ffiillee__aatt(()) ffiillee__ssiizzee(()) rroooott__ppttrr(()) │ │ │ │ -ffiillee__ppaatthh(()) ffiillee__ooffffsseett(()) mmttiimmee(()) ********** │ │ │ │ +********** ppaadd__ffiillee__aatt(()) ffiillee__ppaatthh(()) ffiillee__ssiizzee(()) rroooott__ppttrr(()) ffiillee__nnaammee(()) rroooott(()) │ │ │ │ +ssyymmlliinnkk(()) ffiillee__ooffffsseett(()) mmttiimmee(()) ********** │ │ │ │ std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ -std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ -string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ +char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = "") │ │ │ │ const; │ │ │ │ -bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ -char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ -std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ sha256_hash rroooott (file_index_t index) const; │ │ │ │ +string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ +std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ +bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ +std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ These functions are used to query attributes of files at a given index. │ │ │ │ root() returns the SHA-256 merkle tree root of the specified file, in case this │ │ │ │ is a v2 torrent. Otherwise returns zeros. root_ptr() returns a pointer to the │ │ │ │ SHA-256 merkle tree root hash for the specified file. The pointer points into │ │ │ │ storage referred to when the file was added, it is not owned by this object. │ │ │ │ Torrents that are not v2 torrents return nullptr. │ │ │ │ The mtime() is the modification time is the posix time when a file was last │ │ │ │ @@ -385,17 +445,17 @@ │ │ │ │ int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ Returns the number of pieces or blocks the file atindexspans, under the │ │ │ │ assumption that the file is aligned to the start of a piece. This is only │ │ │ │ meaningful for v2 torrents, where files are guaranteed such alignment. These │ │ │ │ numbers are used to size and navigate the merkle hash tree for each file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ffiirrsstt__ppiieeccee__nnooddee(()) ffiillee__ffiirrsstt__bblloocckk__nnooddee(()) ********** │ │ │ │ -int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ +********** ffiillee__ffiirrsstt__bblloocckk__nnooddee(()) ffiillee__ffiirrsstt__ppiieeccee__nnooddee(()) ********** │ │ │ │ int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ +int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ index of first piece node in the merkle tree │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__ppaatthh__hhaasshh(()) ********** │ │ │ │ std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& save_path) │ │ │ │ const; │ │ │ │ returns the crc32 hash of file_path(index) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ @@ -412,29 +472,29 @@ │ │ │ │ returns a bitmask of flags from file_flags_t that apply to file at index. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t index) const; │ │ │ │ returns true if the file at the specified index has been renamed to have an │ │ │ │ absolute path, i.e. is not anchored in the save path of the torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee(()) ffiillee__iinnddeexx__aatt__ppiieeccee(()) ffiillee__iinnddeexx__aatt__ooffffsseett(()) │ │ │ │ +********** llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee(()) ffiillee__iinnddeexx__aatt__ooffffsseett(()) ffiillee__iinnddeexx__aatt__ppiieeccee(()) │ │ │ │ ********** │ │ │ │ file_index_t ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ file_index_t ffiillee__iinnddeexx__aatt__ooffffsseett (std::int64_t offset) const; │ │ │ │ file_index_t llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ returns the index of the file at the given offset or piece in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__iinnddeexx__ffoorr__rroooott(()) ********** │ │ │ │ file_index_t ffiillee__iinnddeexx__ffoorr__rroooott (sha256_hash const& root_hash) const; │ │ │ │ finds the file with the given root hash and returns its index if there is no │ │ │ │ file with the root hash, file_index_t{-1} is returned │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee(()) ppiieeccee__iinnddeexx__aatt__ffiillee(()) ********** │ │ │ │ -piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ piece_index_t llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ +piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ returns the first or last piece index of the given file in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ssaanniittiizzee__ssyymmlliinnkkss(()) ********** │ │ │ │ void ssaanniittiizzee__ssyymmlliinnkkss (); │ │ │ │ validate any symlinks, to ensure they all point to other files or directories │ │ │ │ inside this storage. Any invalid symlinks are updated to point to themselves. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ @@ -511,23 +571,23 @@ │ │ │ │ through the rename layer. │ │ │ │ struct filenames │ │ │ │ { │ │ │ │ ffiilleennaammeess (file_storage const& fs, renamed_files const& rf); │ │ │ │ file_flags_t ffiillee__ffllaaggss (file_index_t const index) const; │ │ │ │ file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ bool ppaadd__ffiillee__aatt (file_index_t const index) const; │ │ │ │ - std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ std::int64_t ffiillee__ooffffsseett (file_index_t const index) const; │ │ │ │ + std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ + bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ std::string ffiillee__ppaatthh (file_index_t const index, std::string const& │ │ │ │ save_path = "") const; │ │ │ │ - bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ std::string ssyymmlliinnkk (file_index_t const index) const; │ │ │ │ index_range ffiillee__rraannggee () const noexcept; │ │ │ │ - int nnuumm__ppiieecceess () const; │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ + int nnuumm__ppiieecceess () const; │ │ │ │ int nnuumm__ffiilleess () const noexcept; │ │ │ │ std::vector mmaapp__bblloocckk (piece_index_t const piece, std::int64_t │ │ │ │ const offset │ │ │ │ , std::int64_t const size) const; │ │ │ │ peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t const offset, │ │ │ │ int const size) const; │ │ │ │ sha256_hash rroooott (file_index_t const index) const; │ │ │ │ @@ -547,42 +607,42 @@ │ │ │ │ file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ one past-the-end file index │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ppaadd__ffiillee__aatt(()) ********** │ │ │ │ bool ppaadd__ffiillee__aatt (file_index_t const index) const; │ │ │ │ returns true if the file at index is a pad file │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ssiizzee(()) ffiillee__ooffffsseett(()) ********** │ │ │ │ -std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ +********** ffiillee__ooffffsseett(()) ffiillee__ssiizzee(()) ********** │ │ │ │ std::int64_t ffiillee__ooffffsseett (file_index_t const index) const; │ │ │ │ +std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ returns the file size or file offset for the file at index. The file offset is │ │ │ │ in the torrent space, of all files in the torrent, in the order they are │ │ │ │ defined. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppaatthh(()) ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ +********** ffiillee__aabbssoolluuttee__ppaatthh(()) ffiillee__ppaatthh(()) ********** │ │ │ │ +bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ std::string ffiillee__ppaatthh (file_index_t const index, std::string const& save_path = │ │ │ │ "") const; │ │ │ │ -bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ returns the on-disk path for the file at index, applying any rename recorded in │ │ │ │ the underlying renamed_files. If save_path is non-empty it is prepended to │ │ │ │ relative paths. file_absolute_path() returns true if the recorded rename is an │ │ │ │ absolute path (in which case save_path is ignored). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ssyymmlliinnkk(()) ********** │ │ │ │ std::string ssyymmlliinnkk (file_index_t const index) const; │ │ │ │ If the file at index is a symbolic link, its link target is returned. otherwise │ │ │ │ an empty string. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__rraannggee(()) ********** │ │ │ │ index_range ffiillee__rraannggee () const noexcept; │ │ │ │ all file indices in the underlying _f_i_l_e___s_t_o_r_a_g_e. Convenient in range-for loops. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ffiilleess(()) nnuumm__ppiieecceess(()) eenndd__ppiieeccee(()) ********** │ │ │ │ -int nnuumm__ppiieecceess () const; │ │ │ │ +********** nnuumm__ffiilleess(()) eenndd__ppiieeccee(()) nnuumm__ppiieecceess(()) ********** │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ +int nnuumm__ppiieecceess () const; │ │ │ │ int nnuumm__ffiilleess () const noexcept; │ │ │ │ the number of files in the underlying _f_i_l_e___s_t_o_r_a_g_e, the number of pieces, and │ │ │ │ the one-past-the-end piece index. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** mmaapp__bblloocckk(()) ********** │ │ │ │ std::vector mmaapp__bblloocckk (piece_index_t const piece, std::int64_t │ │ │ │ const offset │ │ │ │ @@ -604,103 +664,43 @@ │ │ │ │ hash for v1-only torrents. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ppiieeccee__lleennggtthh(()) ********** │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ the piece size, in bytes. All pieces have this size except the last, which may │ │ │ │ be shorter. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttoorraaggee__ppaarraammss ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ -a parameter pack used to construct the storage for a torrent, used in │ │ │ │ -_d_i_s_k___i_n_t_e_r_f_a_c_e │ │ │ │ -struct storage_params │ │ │ │ -{ │ │ │ │ - ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ - , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ - , aux::vector const& prio │ │ │ │ - , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ - │ │ │ │ - file_storage const& files; │ │ │ │ - lt::renamed_files const& renamed_files; │ │ │ │ - string_view path; │ │ │ │ - string_view part_file_dir; │ │ │ │ - storage_mode_t mmooddee {storage_mode_sparse}; │ │ │ │ - aux::vector const& priorities; │ │ │ │ - sha1_hash info_hash; │ │ │ │ - bool v1; │ │ │ │ - bool v2; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssttoorraaggee__ppaarraammss(()) ********** │ │ │ │ -ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ - , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ - , aux::vector const& prio │ │ │ │ - , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ -constructs a parameter pack from the layout, save path, mode, per-file │ │ │ │ -priorities, info-hash and protocol-version flags. v1 indicates that the torrent │ │ │ │ -has v1 metadata (a SHA-1 info-hash); v2 that it has v2 metadata (BEP 52). A │ │ │ │ -hybrid torrent has both set. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - files │ │ │ │ - the file layout (sizes, paths, flags) of the torrent │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - renamed_files │ │ │ │ - rename overlay applied on top of files; on-disk paths resolved through │ │ │ │ - this object take precedence over the originals │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - path │ │ │ │ - the directory where the torrent's files are stored │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - part_file_dir │ │ │ │ - directory in which the part file is created. If empty, the part file is │ │ │ │ - placed under path. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - mode │ │ │ │ - the storage allocation mode (sparse vs. pre-allocated) │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - priorities │ │ │ │ - per-file download priorities, indexed by file index │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - info_hash │ │ │ │ - the SHA-1 info-hash of the torrent (zero for v2-only torrents) │ │ │ │ +************ mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_m_a_p___d_i_s_k___i_o_._h_p_p" │ │ │ │ +std::unique_ptr mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +constructs a memory mapped file disk I/O object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - v1 v2 │ │ │ │ - indicates which BitTorrent protocol version(s) this storage is for. v1 is │ │ │ │ - true if the torrent has v1 metadata; v2 is true if the torrent has v2 │ │ │ │ - metadata (BEP 52). A hybrid torrent has both flags set. │ │ │ │ +************ ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ +std::unique_ptr ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +the constructor function for the default storage. On systems that support │ │ │ │ +memory mapped files (and a 64 bit address space) the memory mapped storage will │ │ │ │ +be constructed, otherwise the portable posix storage. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_a_b_l_e_d___d_i_s_k___i_o_._h_p_p" │ │ │ │ std::unique_ptr ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ creates a disk io object that discards all data written to it, and only returns │ │ │ │ zero-buffers when read from. May be useful for testing and benchmarking. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_m_a_p___d_i_s_k___i_o_._h_p_p" │ │ │ │ -std::unique_ptr mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -constructs a memory mapped file disk I/O object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_s_i_x___d_i_s_k___i_o_._h_p_p" │ │ │ │ std::unique_ptr ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ this is a simple posix disk I/O back-end, used for systems that don't have a 64 │ │ │ │ bit virtual address space or don't support memory mapped files. It's │ │ │ │ implemented using portable C file functions and is single-threaded. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -std::unique_ptr ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -the constructor function for the default storage. On systems that support │ │ │ │ -memory mapped files (and a 64 bit address space) the memory mapped storage will │ │ │ │ -be constructed, otherwise the portable posix storage. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ eennuumm ssttoorraaggee__mmooddee__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ | | |All pieces will be written to their final | │ │ │ │ | | |position, all files will be allocated in full | │ │ │ │ |storage_mode_allocate|0 |when the torrent is first started. This mode | │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ @@ -41,53 +41,53 @@ │ │ │
  • torrent_handle │ │ │
  • │ │ │
  • hash_value()
  • │ │ │ @@ -257,125 +257,125 @@ │ │ │ Which means you cannot perform any operation on it, unless you first │ │ │ assign it a valid handle. If you try to perform any operation on an │ │ │ uninitialized handle, it will throw invalid_handle.

    │ │ │
    │ │ │

    Warning

    │ │ │

    All operations on a torrent_handle may throw system_error │ │ │ exception, in case the handle is no longer referring to a torrent. │ │ │ -There is one exception is_valid() will never throw. Since the torrents │ │ │ +There is one exception is_valid() will never throw. Since the torrents │ │ │ are processed by a background thread, there is no guarantee that a │ │ │ handle will remain valid between two calls.

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

    torrent_handle()

    │ │ │
    │ │ │  torrent_handle () noexcept = default;
    │ │ │  
    │ │ │

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

    │ │ │ +i.e. is_valid() will return false.

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

    add_piece()

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

    Note

    │ │ │

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

    │ │ │
    │ │ │
    │ │ │

    Note

    │ │ │

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

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

    set_sequential_range()

    │ │ │
    │ │ │ -void set_sequential_range (piece_index_t first_piece) const;
    │ │ │  void set_sequential_range (piece_index_t first_piece, piece_index_t last_piece) const;
    │ │ │ +void set_sequential_range (piece_index_t first_piece) const;
    │ │ │  
    │ │ │

    These functions set the first piece and the last piece of the range │ │ │ for the piece picker. They start downloading from the specified piece │ │ │ in sequential download mode, which is enabled. If the last piece is │ │ │ omitted then it is implicitly set to the end of the file the first │ │ │ piece is set to. If the torrent metadata has not been downloaded yet │ │ │ then the functions do nothing.

    │ │ │ @@ -487,36 +487,36 @@ │ │ │
    │ │ │

    have_piece()

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

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

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

    post_peer_info() get_peer_info()

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

    get_peer_info() post_peer_info()

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

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

    │ │ │

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

    │ │ │

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

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

    status() post_status()

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

    post_status() status()

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

    status() will return a structure with information about the status │ │ │ of this torrent. If the torrent_handle is invalid, it will throw │ │ │ system_error exception. See torrent_status. The flags │ │ │ @@ -534,16 +534,16 @@ │ │ │

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

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

    get_download_queue() post_download_queue()

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

    post_download_queue() triggers a download_queue_alert to be │ │ │ posted. │ │ │ get_download_queue() is a synchronous call and returns a vector │ │ │ with information about pieces that are partially downloaded or not │ │ │ downloaded but partially requested. See partial_piece_info for the │ │ │ @@ -553,23 +553,23 @@ │ │ │

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

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

    clear_piece_deadlines() set_piece_deadline() reset_piece_deadline()

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

    set_piece_deadline() clear_piece_deadlines() reset_piece_deadline()

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

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

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

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

    post_file_progress() file_progress()

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

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

    │ │ │

    This operation is not very cheap. Its complexity is O(n + mj). │ │ │ @@ -604,18 +604,18 @@ │ │ │ file progress. If left at the default value of 0, the progress will be │ │ │ as accurate as possible, but also more expensive to calculate. If │ │ │ torrent_handle::piece_granularity is specified, the progress will │ │ │ be specified in piece granularity. i.e. only pieces that have been │ │ │ fully downloaded and passed the hash check count. When specifying │ │ │ piece granularity, the operation is a lot cheaper, since libtorrent │ │ │ already keeps track of this internally and no calculation is required.

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

    file_status() post_file_status()

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

    post_file_status() file_status()

    │ │ │
    │ │ │  void post_file_status () const;
    │ │ │  std::vector<open_file_state> file_status () const;
    │ │ │  
    │ │ │

    file_status() returns a vector with status about files │ │ │ that are open for this torrent. Any file that is not open │ │ │ will not be reported in the vector, i.e. it's possible that │ │ │ @@ -628,25 +628,25 @@ │ │ │

    │ │ │

    clear_error()

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

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

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

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

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

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

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

    trackers() returns the list of trackers for this torrent. The │ │ │ announce entry contains both a string url which specify the │ │ │ announce url for the tracker as well as an int tier, which is │ │ │ specifies the order in which this tracker is tried. If you want │ │ │ libtorrent to use another list of trackers for this torrent, you can │ │ │ use replace_trackers() which takes a list of the same form as the │ │ │ @@ -658,23 +658,23 @@ │ │ │

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

    │ │ │

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

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

    remove_url_seed() url_seeds() add_url_seed()

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

    add_url_seed() remove_url_seed() url_seeds()

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

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

    Returns true if this handle refers to a valid torrent and false if it │ │ │ hasn't been initialized or if the torrent it refers to has been │ │ │ removed from the session AND destructed.

    │ │ │

    To tell if the torrent_handle is in the session, use │ │ │ torrent_handle::in_session(). This will return true before │ │ │ session_handle::remove_torrent() is called, and false │ │ │ afterward.

    │ │ │ -

    Clients should only use is_valid() to determine if the result of │ │ │ +

    Clients should only use is_valid() to determine if the result of │ │ │ session::find_torrent() was successful.

    │ │ │ -

    Unlike other member functions which return a value, is_valid() │ │ │ +

    Unlike other member functions which return a value, is_valid() │ │ │ completes immediately, without blocking on a result from the │ │ │ network thread. Also unlike other functions, it never throws │ │ │ the system_error exception.

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

    pause() resume()

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

    resume() pause()

    │ │ │
    │ │ │ -void resume () const;
    │ │ │  void pause (pause_flags_t flags = {}) const;
    │ │ │ +void resume () const;
    │ │ │  
    │ │ │

    pause(), and resume() will disconnect all peers and reconnect │ │ │ all peers respectively. When a torrent is paused, it will however │ │ │ remember all share ratios to all peers and remember all potential (not │ │ │ connected) peers. Torrents may be paused automatically if there is a │ │ │ file error (e.g. disk full) or something similar. See │ │ │ file_error_alert.

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

    unset_flags() set_flags() flags()

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

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

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

    save_resume_data() get_resume_data()

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

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

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

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

    need_save_resume_data()

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

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

    │ │ │

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

    │ │ │

    Note

    │ │ │

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

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

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

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

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

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

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

    │ │ │

    When a torrent is removed or turns into a seed, all torrents with │ │ │ greater queue positions have their positions decreased to fill in the │ │ │ @@ -969,21 +969,21 @@ │ │ │ of all other torrents remain intact but their numerical queue position │ │ │ shifts to make space for this torrent's new position

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

    set_ssl_certificate_buffer() set_ssl_certificate()

    │ │ │
    │ │ │ +void set_ssl_certificate_buffer (std::string const& certificate
    │ │ │ +      , std::string const& private_key
    │ │ │ +      , std::string const& dh_params);
    │ │ │  void set_ssl_certificate (std::string const& certificate
    │ │ │        , std::string const& private_key
    │ │ │        , std::string const& dh_params
    │ │ │        , std::string const& passphrase = "");
    │ │ │ -void set_ssl_certificate_buffer (std::string const& certificate
    │ │ │ -      , std::string const& private_key
    │ │ │ -      , std::string const& dh_params);
    │ │ │  
    │ │ │

    For SSL torrents, use this to specify a path to a .pem file to use as │ │ │ this client's certificate. The certificate must be signed by the │ │ │ certificate in the .torrent file to be valid.

    │ │ │

    The set_ssl_certificate_buffer() overload takes the actual certificate, │ │ │ private key and DH params as strings, rather than paths to files.

    │ │ │

    cert is a path to the (signed) certificate in .pem format │ │ │ @@ -1072,24 +1072,24 @@ │ │ │

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

    │ │ │

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

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

    get_piece_priorities() piece_priority() prioritize_pieces()

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

    get_piece_priorities() prioritize_pieces() piece_priority()

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

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

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

    prioritize_files() get_file_priorities() file_priority()

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

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

    │ │ │

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

    │ │ │

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

    │ │ │ @@ -1160,24 +1160,24 @@ │ │ │

    post_file_priorities()

    │ │ │
    │ │ │  void post_file_priorities () const;
    │ │ │  
    │ │ │

    post_file_priorities() will trigger a file_priorities_alert to be │ │ │ posted, containing the download priority of each file in the torrent.

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

    force_lsd_announce() force_reannounce() force_dht_announce()

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

    force_lsd_announce() force_dht_announce() force_reannounce()

    │ │ │
    │ │ │ -void force_reannounce (int seconds, std::string const& url, reannounce_flags_t = {}) const;
    │ │ │  void force_dht_announce () const;
    │ │ │ -void force_reannounce (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │ -void force_lsd_announce () const;
    │ │ │  void force_reannounce (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ +void force_lsd_announce () const;
    │ │ │ +void force_reannounce (int seconds, std::string const& url, reannounce_flags_t = {}) const;
    │ │ │ +void force_reannounce (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │  
    │ │ │

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

    │ │ │

    If the tracker's min_interval has not passed since the last │ │ │ announce, the forced announce will be scheduled to happen immediately │ │ │ as the min_interval expires. This is to honor trackers minimum │ │ │ @@ -1190,38 +1190,38 @@ │ │ │ immediately.

    │ │ │

    force_lsd_announce will announce the torrent on LSD │ │ │ immediately.

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

    scrape_tracker()

    │ │ │
    │ │ │ -void scrape_tracker (int idx) const;
    │ │ │  void scrape_tracker (std::string url) const;
    │ │ │  void scrape_tracker () const;
    │ │ │ +void scrape_tracker (int idx) const;
    │ │ │  
    │ │ │

    scrape_tracker() will send a scrape request to a tracker. By │ │ │ default (idx = -1) it will scrape the last working tracker. If │ │ │ idx is >= 0, the tracker with the specified index will scraped.

    │ │ │

    A scrape request queries the tracker for statistics such as total │ │ │ number of incomplete peers, complete peers, number of downloads etc.

    │ │ │

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

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

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

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

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

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

    set_upload_limit will limit the upload bandwidth used by this │ │ │ particular torrent to the limit you set. It is given as the number of │ │ │ bytes per second the torrent is allowed to upload. │ │ │ set_download_limit works the same way but for download bandwidth │ │ │ instead of upload bandwidth. Note that setting a higher limit on a │ │ │ torrent then the global limit │ │ │ @@ -1253,32 +1253,32 @@ │ │ │

    clear_peers()

    │ │ │
    │ │ │  void clear_peers ();
    │ │ │  
    │ │ │

    This will disconnect all peers and clear the peer list for this │ │ │ torrent. New peers will have to be acquired before resuming, from │ │ │ trackers, DHT or local service discovery, for example.

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

    set_max_uploads() max_uploads()

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

    max_uploads() set_max_uploads()

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

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

    │ │ │

    max_uploads() returns the current settings.

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

    set_max_connections() max_connections()

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

    max_connections() set_max_connections()

    │ │ │
    │ │ │  void set_max_connections (int max_connections) const;
    │ │ │  int max_connections () const;
    │ │ │  
    │ │ │

    set_max_connections() sets the maximum number of connection this │ │ │ torrent will open. If all connections are used up, incoming │ │ │ connections may be refused or poor connections may be closed. This │ │ │ @@ -1349,32 +1349,32 @@ │ │ │ operation is complete when either a file_renamed_alert or │ │ │ file_rename_failed_alert is posted.

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

    info_hash() info_hashes()

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

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

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

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

    │ │ │ +

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

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

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

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

    id()

    │ │ │
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -10,55 +10,55 @@
    │ │ │ │      * _t_o_r_r_e_n_t___h_a_n_d_l_e
    │ │ │ │            o _h_a_s_h___v_a_l_u_e_(_)
    │ │ │ │            o _t_o_r_r_e_n_t___h_a_n_d_l_e_(_)
    │ │ │ │            o _a_d_d___p_i_e_c_e_(_)
    │ │ │ │            o _r_e_a_d___p_i_e_c_e_(_)
    │ │ │ │            o _s_e_t___s_e_q_u_e_n_t_i_a_l___r_a_n_g_e_(_)
    │ │ │ │            o _h_a_v_e___p_i_e_c_e_(_)
    │ │ │ │ -          o _p_o_s_t___p_e_e_r___i_n_f_o_(_)_ _g_e_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ -          o _s_t_a_t_u_s_(_)_ _p_o_s_t___s_t_a_t_u_s_(_)
    │ │ │ │ +          o _g_e_t___p_e_e_r___i_n_f_o_(_)_ _p_o_s_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ +          o _p_o_s_t___s_t_a_t_u_s_(_)_ _s_t_a_t_u_s_(_)
    │ │ │ │            o _g_e_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)_ _p_o_s_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)
    │ │ │ │ -          o _c_l_e_a_r___p_i_e_c_e___d_e_a_d_l_i_n_e_s_(_)_ _s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)
    │ │ │ │ +          o _s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _c_l_e_a_r___p_i_e_c_e___d_e_a_d_l_i_n_e_s_(_)_ _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)
    │ │ │ │            o _p_o_s_t___f_i_l_e___p_r_o_g_r_e_s_s_(_)_ _f_i_l_e___p_r_o_g_r_e_s_s_(_)
    │ │ │ │ -          o _f_i_l_e___s_t_a_t_u_s_(_)_ _p_o_s_t___f_i_l_e___s_t_a_t_u_s_(_)
    │ │ │ │ +          o _p_o_s_t___f_i_l_e___s_t_a_t_u_s_(_)_ _f_i_l_e___s_t_a_t_u_s_(_)
    │ │ │ │            o _c_l_e_a_r___e_r_r_o_r_(_)
    │ │ │ │ -          o _r_e_p_l_a_c_e___t_r_a_c_k_e_r_s_(_)_ _t_r_a_c_k_e_r_s_(_)_ _p_o_s_t___t_r_a_c_k_e_r_s_(_)_ _a_d_d___t_r_a_c_k_e_r_(_)
    │ │ │ │ -          o _r_e_m_o_v_e___u_r_l___s_e_e_d_(_)_ _u_r_l___s_e_e_d_s_(_)_ _a_d_d___u_r_l___s_e_e_d_(_)
    │ │ │ │ +          o _a_d_d___t_r_a_c_k_e_r_(_)_ _t_r_a_c_k_e_r_s_(_)_ _p_o_s_t___t_r_a_c_k_e_r_s_(_)_ _r_e_p_l_a_c_e___t_r_a_c_k_e_r_s_(_)
    │ │ │ │ +          o _a_d_d___u_r_l___s_e_e_d_(_)_ _r_e_m_o_v_e___u_r_l___s_e_e_d_(_)_ _u_r_l___s_e_e_d_s_(_)
    │ │ │ │            o _a_d_d___e_x_t_e_n_s_i_o_n_(_)
    │ │ │ │            o _s_e_t___m_e_t_a_d_a_t_a_(_)
    │ │ │ │            o _i_s___v_a_l_i_d_(_)
    │ │ │ │ -          o _p_a_u_s_e_(_)_ _r_e_s_u_m_e_(_)
    │ │ │ │ +          o _r_e_s_u_m_e_(_)_ _p_a_u_s_e_(_)
    │ │ │ │            o _u_n_s_e_t___f_l_a_g_s_(_)_ _s_e_t___f_l_a_g_s_(_)_ _f_l_a_g_s_(_)
    │ │ │ │            o _f_l_u_s_h___c_a_c_h_e_(_)
    │ │ │ │            o _f_o_r_c_e___r_e_c_h_e_c_k_(_)
    │ │ │ │            o _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_)_ _g_e_t___r_e_s_u_m_e___d_a_t_a_(_)
    │ │ │ │            o _n_e_e_d___s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_)
    │ │ │ │ -          o _q_u_e_u_e___p_o_s_i_t_i_o_n_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___b_o_t_t_o_m_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___u_p_(_)
    │ │ │ │ -            _q_u_e_u_e___p_o_s_i_t_i_o_n___t_o_p_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___d_o_w_n_(_)
    │ │ │ │ +          o _q_u_e_u_e___p_o_s_i_t_i_o_n___d_o_w_n_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___t_o_p_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n_(_)
    │ │ │ │ +            _q_u_e_u_e___p_o_s_i_t_i_o_n___b_o_t_t_o_m_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___u_p_(_)
    │ │ │ │            o _q_u_e_u_e___p_o_s_i_t_i_o_n___s_e_t_(_)
    │ │ │ │            o _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e___b_u_f_f_e_r_(_)_ _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e_(_)
    │ │ │ │            o _t_o_r_r_e_n_t___f_i_l_e_(_)
    │ │ │ │            o _g_e_t___r_e_n_a_m_e_d___f_i_l_e_s_(_)
    │ │ │ │            o _p_i_e_c_e___l_a_y_e_r_s_(_)
    │ │ │ │            o _p_o_s_t___p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)_ _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)
    │ │ │ │ -          o _g_e_t___p_i_e_c_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_i_e_c_e___p_r_i_o_r_i_t_y_(_)_ _p_r_i_o_r_i_t_i_z_e___p_i_e_c_e_s_(_)
    │ │ │ │ +          o _g_e_t___p_i_e_c_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_r_i_o_r_i_t_i_z_e___p_i_e_c_e_s_(_)_ _p_i_e_c_e___p_r_i_o_r_i_t_y_(_)
    │ │ │ │            o _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_)_ _g_e_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_)_ _f_i_l_e___p_r_i_o_r_i_t_y_(_)
    │ │ │ │            o _p_o_s_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_)
    │ │ │ │ -          o _f_o_r_c_e___l_s_d___a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___d_h_t___a_n_n_o_u_n_c_e_(_)
    │ │ │ │ +          o _f_o_r_c_e___l_s_d___a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___d_h_t___a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_)
    │ │ │ │            o _s_c_r_a_p_e___t_r_a_c_k_e_r_(_)
    │ │ │ │ -          o _s_e_t___d_o_w_n_l_o_a_d___l_i_m_i_t_(_)_ _u_p_l_o_a_d___l_i_m_i_t_(_)_ _s_e_t___u_p_l_o_a_d___l_i_m_i_t_(_)
    │ │ │ │ +          o _u_p_l_o_a_d___l_i_m_i_t_(_)_ _s_e_t___d_o_w_n_l_o_a_d___l_i_m_i_t_(_)_ _s_e_t___u_p_l_o_a_d___l_i_m_i_t_(_)
    │ │ │ │              _d_o_w_n_l_o_a_d___l_i_m_i_t_(_)
    │ │ │ │            o _c_o_n_n_e_c_t___p_e_e_r_(_)
    │ │ │ │            o _c_l_e_a_r___p_e_e_r_s_(_)
    │ │ │ │ -          o _s_e_t___m_a_x___u_p_l_o_a_d_s_(_)_ _m_a_x___u_p_l_o_a_d_s_(_)
    │ │ │ │ -          o _s_e_t___m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)_ _m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)
    │ │ │ │ +          o _m_a_x___u_p_l_o_a_d_s_(_)_ _s_e_t___m_a_x___u_p_l_o_a_d_s_(_)
    │ │ │ │ +          o _m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)_ _s_e_t___m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)
    │ │ │ │            o _m_o_v_e___s_t_o_r_a_g_e_(_)
    │ │ │ │            o _r_e_n_a_m_e___f_i_l_e_(_)
    │ │ │ │            o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_)
    │ │ │ │ -          o _o_p_e_r_a_t_o_r_<_(_)_ _o_p_e_r_a_t_o_r_=_=_(_)_ _o_p_e_r_a_t_o_r_!_=_(_)
    │ │ │ │ +          o _o_p_e_r_a_t_o_r_=_=_(_)_ _o_p_e_r_a_t_o_r_<_(_)_ _o_p_e_r_a_t_o_r_!_=_(_)
    │ │ │ │            o _i_d_(_)
    │ │ │ │            o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │            o _u_s_e_r_d_a_t_a_(_)
    │ │ │ │            o _i_n___s_e_s_s_i_o_n_(_)
    │ │ │ │      * _h_a_s_h___v_a_l_u_e_(_)
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ bblloocckk__iinnffoo ************
    │ │ │ │ @@ -183,122 +183,122 @@
    │ │ │ │     friend std::size_t hhaasshh__vvaalluuee (torrent_handle const& th);
    │ │ │ │     ttoorrrreenntt__hhaannddllee () noexcept = default;
    │ │ │ │     void aadddd__ppiieeccee (piece_index_t piece, char const* data, add_piece_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │     void aadddd__ppiieeccee (piece_index_t piece, std::vector data,
    │ │ │ │  add_piece_flags_t flags = {}) const;
    │ │ │ │     void rreeaadd__ppiieeccee (piece_index_t piece) const;
    │ │ │ │ -   void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece) const;
    │ │ │ │     void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece, piece_index_t
    │ │ │ │  last_piece) const;
    │ │ │ │ +   void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece) const;
    │ │ │ │     bool hhaavvee__ppiieeccee (piece_index_t piece) const;
    │ │ │ │ -   void ppoosstt__ppeeeerr__iinnffoo () const;
    │ │ │ │     void ggeett__ppeeeerr__iinnffoo (std::vector& v) const;
    │ │ │ │ +   void ppoosstt__ppeeeerr__iinnffoo () const;
    │ │ │ │     torrent_status ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │     void ppoosstt__ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │ -   std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │     void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ +   std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │     void ggeett__ddoowwnnllooaadd__qquueeuuee (std::vector& queue) const;
    │ │ │ │ -   void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const;
    │ │ │ │     void sseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index, int deadline, deadline_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │     void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const;
    │ │ │ │ -   void ppoosstt__ffiillee__pprrooggrreessss (file_progress_flags_t flags) const;
    │ │ │ │ +   void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const;
    │ │ │ │     std::vector ffiillee__pprrooggrreessss (file_progress_flags_t flags = {})
    │ │ │ │  const;
    │ │ │ │ +   void ppoosstt__ffiillee__pprrooggrreessss (file_progress_flags_t flags) const;
    │ │ │ │     void ffiillee__pprrooggrreessss (std::vector& progress,
    │ │ │ │  file_progress_flags_t flags = {}) const;
    │ │ │ │     void ppoosstt__ffiillee__ssttaattuuss () const;
    │ │ │ │     std::vector ffiillee__ssttaattuuss () const;
    │ │ │ │     void cclleeaarr__eerrrroorr () const;
    │ │ │ │ -   void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │ +   void aadddd__ttrraacckkeerr (announce_entry const&) const;
    │ │ │ │     std::vector ttrraacckkeerrss () const;
    │ │ │ │     void ppoosstt__ttrraacckkeerrss () const;
    │ │ │ │ -   void aadddd__ttrraacckkeerr (announce_entry const&) const;
    │ │ │ │ -   void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ -   void aadddd__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +   void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │     std::set uurrll__sseeeeddss () const;
    │ │ │ │ +   void aadddd__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +   void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │     void aadddd__eexxtteennssiioonn (
    │ │ │ │        std::function(torrent_handle const&,
    │ │ │ │  client_data_t)> const& ext
    │ │ │ │        , client_data_t userdata = client_data_t{});
    │ │ │ │     bool sseett__mmeettaaddaattaa (span metadata) const;
    │ │ │ │     bool iiss__vvaalliidd () const;
    │ │ │ │ -   void rreessuummee () const;
    │ │ │ │     void ppaauussee (pause_flags_t flags = {}) const;
    │ │ │ │ -   void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │ +   void rreessuummee () const;
    │ │ │ │     void uunnsseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │ -   torrent_flags_t ffllaaggss () const;
    │ │ │ │     void sseett__ffllaaggss (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │ │ +   torrent_flags_t ffllaaggss () const;
    │ │ │ │ +   void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │     void fflluusshh__ccaacchhee () const;
    │ │ │ │     void ffoorrccee__rreecchheecckk () const;
    │ │ │ │ -   void ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │     add_torrent_params ggeett__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │ -   bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │ +   void ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │     bool nneeeedd__ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags) const;
    │ │ │ │ +   bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │ +   void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │     queue_position_t qquueeuuee__ppoossiittiioonn () const;
    │ │ │ │     void qquueeuuee__ppoossiittiioonn__bboottttoomm () const;
    │ │ │ │ -   void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │ -   void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │     void qquueeuuee__ppoossiittiioonn__ttoopp () const;
    │ │ │ │ +   void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │     void qquueeuuee__ppoossiittiioonn__sseett (queue_position_t p) const;
    │ │ │ │ +   void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate
    │ │ │ │ +      , std::string const& private_key
    │ │ │ │ +      , std::string const& dh_params);
    │ │ │ │     void sseett__ssssll__cceerrttiiffiiccaattee (std::string const& certificate
    │ │ │ │        , std::string const& private_key
    │ │ │ │        , std::string const& dh_params
    │ │ │ │        , std::string const& passphrase = "");
    │ │ │ │ -   void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate
    │ │ │ │ -      , std::string const& private_key
    │ │ │ │ -      , std::string const& dh_params);
    │ │ │ │     std::shared_ptr ttoorrrreenntt__ffiillee () const;
    │ │ │ │     renamed_files ggeett__rreennaammeedd__ffiilleess () const;
    │ │ │ │     std::vector> ppiieeccee__llaayyeerrss () const;
    │ │ │ │     void ppiieeccee__aavvaaiillaabbiilliittyy (std::vector& avail) const;
    │ │ │ │     void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const;
    │ │ │ │ +   void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const;
    │ │ │ │     void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority)
    │ │ │ │  const;
    │ │ │ │ +   std::vector ggeett__ppiieeccee__pprriioorriittiieess () const;
    │ │ │ │     download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const;
    │ │ │ │ -   void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const;
    │ │ │ │     void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces)
    │ │ │ │  const;
    │ │ │ │ -   std::vector ggeett__ppiieeccee__pprriioorriittiieess () const;
    │ │ │ │ -   std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │ -   void pprriioorriittiizzee__ffiilleess (std::vector const& files) const;
    │ │ │ │     void ffiillee__pprriioorriittyy (file_index_t index, download_priority_t priority) const;
    │ │ │ │ +   void pprriioorriittiizzee__ffiilleess (std::vector const& files) const;
    │ │ │ │     download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const;
    │ │ │ │ +   std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │     void ppoosstt__ffiillee__pprriioorriittiieess () const;
    │ │ │ │ +   void ffoorrccee__ddhhtt__aannnnoouunnccee () const;
    │ │ │ │ +   void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ │ +   void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │     void ffoorrccee__rreeaannnnoouunnccee (int seconds, std::string const& url,
    │ │ │ │  reannounce_flags_t = {}) const;
    │ │ │ │ -   void ffoorrccee__ddhhtt__aannnnoouunnccee () const;
    │ │ │ │     void ffoorrccee__rreeaannnnoouunnccee (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │ │ -   void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │ -   void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ │ -   void ssccrraappee__ttrraacckkeerr (int idx) const;
    │ │ │ │     void ssccrraappee__ttrraacckkeerr (std::string url) const;
    │ │ │ │     void ssccrraappee__ttrraacckkeerr () const;
    │ │ │ │ -   int ddoowwnnllooaadd__lliimmiitt () const;
    │ │ │ │ +   void ssccrraappee__ttrraacckkeerr (int idx) const;
    │ │ │ │     void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const;
    │ │ │ │ -   void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │ +   int ddoowwnnllooaadd__lliimmiitt () const;
    │ │ │ │     int uuppllooaadd__lliimmiitt () const;
    │ │ │ │ +   void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │     void ccoonnnneecctt__ppeeeerr (tcp::endpoint const& adr, peer_source_flags_t source = {}
    │ │ │ │        , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const;
    │ │ │ │     void cclleeaarr__ppeeeerrss ();
    │ │ │ │     void sseett__mmaaxx__uuppllooaaddss (int max_uploads) const;
    │ │ │ │     int mmaaxx__uuppllooaaddss () const;
    │ │ │ │     void sseett__mmaaxx__ccoonnnneeccttiioonnss (int max_connections) const;
    │ │ │ │     int mmaaxx__ccoonnnneeccttiioonnss () const;
    │ │ │ │     void mmoovvee__ssttoorraaggee (std::string const& save_path
    │ │ │ │        , move_flags_t flags = move_flags_t::always_replace_files
    │ │ │ │        ) const;
    │ │ │ │     void rreennaammee__ffiillee (file_index_t index, std::string const& new_name) const;
    │ │ │ │ -   sha1_hash iinnffoo__hhaasshh () const;
    │ │ │ │     info_hash_t iinnffoo__hhaasshheess () const;
    │ │ │ │ -   bool ooppeerraattoorr<< (const torrent_handle& h) const;
    │ │ │ │ +   sha1_hash iinnffoo__hhaasshh () const;
    │ │ │ │     bool ooppeerraattoorr==== (const torrent_handle& h) const;
    │ │ │ │     bool ooppeerraattoorr!!== (const torrent_handle& h) const;
    │ │ │ │ +   bool ooppeerraattoorr<< (const torrent_handle& h) const;
    │ │ │ │     std::uint32_t iidd () const;
    │ │ │ │     std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │     client_data_t uusseerrddaattaa () const;
    │ │ │ │     bool iinn__sseessssiioonn () const;
    │ │ │ │  
    │ │ │ │     static inline constexpr add_piece_flags_t oovveerrwwrriittee__eexxiissttiinngg  = 0_bit;
    │ │ │ │     static inline constexpr status_flags_t qquueerryy__ddiissttrriibbuutteedd__ccooppiieess  = 0_bit;
    │ │ │ │ @@ -376,42 +376,42 @@
    │ │ │ │  finish in the same order as you initiated them.
    │ │ │ │  Note
    │ │ │ │  the size of the buffer passed back in the _a_l_e_r_t is not necessarily _p_i_e_c_e___l_e_n_g_t_h
    │ │ │ │  _(_) long. The last piece or pieces at the end of files (in v2 and hybrid
    │ │ │ │  torrents) are not full size.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** sseett__sseeqquueennttiiaall__rraannggee(()) **********
    │ │ │ │ -void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece) const;
    │ │ │ │  void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece, piece_index_t last_piece)
    │ │ │ │  const;
    │ │ │ │ +void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece) const;
    │ │ │ │  These functions set the first piece and the last piece of the range for the
    │ │ │ │  piece picker. They start downloading from the specified piece in sequential
    │ │ │ │  download mode, which is enabled. If the last piece is omitted then it is
    │ │ │ │  implicitly set to the end of the file the first piece is set to. If the torrent
    │ │ │ │  metadata has not been downloaded yet then the functions do nothing.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** hhaavvee__ppiieeccee(()) **********
    │ │ │ │  bool hhaavvee__ppiieeccee (piece_index_t piece) const;
    │ │ │ │  Returns true if this piece has been completely downloaded and written to disk,
    │ │ │ │  and false otherwise.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppoosstt__ppeeeerr__iinnffoo(()) ggeett__ppeeeerr__iinnffoo(()) **********
    │ │ │ │ -void ppoosstt__ppeeeerr__iinnffoo () const;
    │ │ │ │ +********** ggeett__ppeeeerr__iinnffoo(()) ppoosstt__ppeeeerr__iinnffoo(()) **********
    │ │ │ │  void ggeett__ppeeeerr__iinnffoo (std::vector& v) const;
    │ │ │ │ +void ppoosstt__ppeeeerr__iinnffoo () const;
    │ │ │ │  Query information about connected peers for this torrent. If the _t_o_r_r_e_n_t___h_a_n_d_l_e
    │ │ │ │  is invalid, it will throw a system_error exception.
    │ │ │ │  post_peer_info() is asynchronous and will trigger the posting of a
    │ │ │ │  _p_e_e_r___i_n_f_o___a_l_e_r_t. The _a_l_e_r_t contain a list of _p_e_e_r___i_n_f_o objects, one for each
    │ │ │ │  connected peer.
    │ │ │ │  get_peer_info() is synchronous and takes a reference to a vector that will be
    │ │ │ │  cleared and filled with one _e_n_t_r_y for each peer connected to this torrent,
    │ │ │ │  given the handle is valid. Each _e_n_t_r_y in the vector contains information about
    │ │ │ │  that particular peer. See _p_e_e_r___i_n_f_o.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ssttaattuuss(()) ppoosstt__ssttaattuuss(()) **********
    │ │ │ │ +********** ppoosstt__ssttaattuuss(()) ssttaattuuss(()) **********
    │ │ │ │  torrent_status ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │  void ppoosstt__ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │  status() will return a structure with information about the status of this
    │ │ │ │  torrent. If the _t_o_r_r_e_n_t___h_a_n_d_l_e is invalid, it will throw system_error
    │ │ │ │  exception. See _t_o_r_r_e_n_t___s_t_a_t_u_s. The flags argument filters what information is
    │ │ │ │  returned in the _t_o_r_r_e_n_t___s_t_a_t_u_s. Some information in there is relatively
    │ │ │ │  expensive to calculate, and if you're not interested in it (and see performance
    │ │ │ │ @@ -422,34 +422,34 @@
    │ │ │ │  object for this torrent.
    │ │ │ │  In order to get regular updates for torrents whose status changes, consider
    │ │ │ │  calling session::post_torrent_updates()`` instead.
    │ │ │ │  By default everything is included. The flags you can use to decide what to
    │ │ │ │  iinncclluuddee are defined in this class.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ggeett__ddoowwnnllooaadd__qquueeuuee(()) ppoosstt__ddoowwnnllooaadd__qquueeuuee(()) **********
    │ │ │ │ -std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │  void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ +std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │  void ggeett__ddoowwnnllooaadd__qquueeuuee (std::vector& queue) const;
    │ │ │ │  post_download_queue() triggers a download_queue_alert to be posted.
    │ │ │ │  get_download_queue() is a synchronous call and returns a vector with
    │ │ │ │  information about pieces that are partially downloaded or not downloaded but
    │ │ │ │  partially requested. See _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o for the fields in the returned
    │ │ │ │  vector.
    │ │ │ │  Warning
    │ │ │ │  get_download_queue() is prone to threading errors. The _b_l_o_c_k___i_n_f_o pointers its
    │ │ │ │  return value points to are owned by the _s_e_s_s_i_o_n and will be cleared the next
    │ │ │ │  time get_download_queue() is called. Therefore it's not safe to call this
    │ │ │ │  function from multiple threads. Using post_download_queue() is a safe
    │ │ │ │  alternative.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** cclleeaarr__ppiieeccee__ddeeaaddlliinneess(()) sseett__ppiieeccee__ddeeaaddlliinnee(()) rreesseett__ppiieeccee__ddeeaaddlliinnee(()) **********
    │ │ │ │ -void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const;
    │ │ │ │ +********** sseett__ppiieeccee__ddeeaaddlliinnee(()) cclleeaarr__ppiieeccee__ddeeaaddlliinneess(()) rreesseett__ppiieeccee__ddeeaaddlliinnee(()) **********
    │ │ │ │  void sseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index, int deadline, deadline_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │  void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const;
    │ │ │ │ +void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const;
    │ │ │ │  This function sets or resets the deadline associated with a specific piece
    │ │ │ │  index (index). libtorrent will attempt to download this entire piece before the
    │ │ │ │  deadline expires. This is not necessarily possible, but pieces with a more
    │ │ │ │  recent deadline will always be prioritized over pieces with a deadline further
    │ │ │ │  ahead in time. The deadline (and flags) of a piece can be changed by calling
    │ │ │ │  this function again.
    │ │ │ │  If the piece is already downloaded when this call is made, nothing happens,
    │ │ │ │ @@ -458,17 +458,17 @@
    │ │ │ │  deadline is the number of milliseconds until this piece should be completed.
    │ │ │ │  reset_piece_deadline removes the deadline from the piece. If it hasn't already
    │ │ │ │  been downloaded, it will no longer be considered a priority.
    │ │ │ │  clear_piece_deadlines() removes deadlines on all pieces in the torrent. As if
    │ │ │ │  _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_) was called on all pieces.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ppoosstt__ffiillee__pprrooggrreessss(()) ffiillee__pprrooggrreessss(()) **********
    │ │ │ │ -void ppoosstt__ffiillee__pprrooggrreessss (file_progress_flags_t flags) const;
    │ │ │ │  std::vector ffiillee__pprrooggrreessss (file_progress_flags_t flags = {})
    │ │ │ │  const;
    │ │ │ │ +void ppoosstt__ffiillee__pprrooggrreessss (file_progress_flags_t flags) const;
    │ │ │ │  void ffiillee__pprrooggrreessss (std::vector& progress, file_progress_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │  This function fills in the supplied vector, or returns a vector, with the
    │ │ │ │  number of bytes downloaded of each file in this torrent. The progress values
    │ │ │ │  are ordered the same as the files in the _t_o_r_r_e_n_t___i_n_f_o.
    │ │ │ │  This operation is not very cheap. Its complexity is OO((nn ++ mmjj)). Where nn is the
    │ │ │ │  number of files, mm is the number of currently downloading pieces and jj is the
    │ │ │ │ @@ -478,15 +478,15 @@
    │ │ │ │  as possible, but also more expensive to calculate. If torrent_handle::
    │ │ │ │  piece_granularity is specified, the progress will be specified in piece
    │ │ │ │  granularity. i.e. only pieces that have been fully downloaded and passed the
    │ │ │ │  hash check count. When specifying piece granularity, the operation is a lot
    │ │ │ │  cheaper, since libtorrent already keeps track of this internally and no
    │ │ │ │  calculation is required.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ffiillee__ssttaattuuss(()) ppoosstt__ffiillee__ssttaattuuss(()) **********
    │ │ │ │ +********** ppoosstt__ffiillee__ssttaattuuss(()) ffiillee__ssttaattuuss(()) **********
    │ │ │ │  void ppoosstt__ffiillee__ssttaattuuss () const;
    │ │ │ │  std::vector ffiillee__ssttaattuuss () const;
    │ │ │ │  file_status() returns a vector with status about files that are open for this
    │ │ │ │  torrent. Any file that is not open will not be reported in the vector, i.e.
    │ │ │ │  it's possible that the vector is empty when returning, if none of the files in
    │ │ │ │  the torrent are currently open.
    │ │ │ │  post_file_status() will trigger a _f_i_l_e___s_t_a_t_u_s___a_l_e_r_t to be posted, containing
    │ │ │ │ @@ -494,19 +494,19 @@
    │ │ │ │  See _o_p_e_n___f_i_l_e___s_t_a_t_e
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** cclleeaarr__eerrrroorr(()) **********
    │ │ │ │  void cclleeaarr__eerrrroorr () const;
    │ │ │ │  If the torrent is in an error state (i.e. torrent_status::error is non-empty),
    │ │ │ │  this will clear the error and start the torrent again.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** rreeppllaaccee__ttrraacckkeerrss(()) ttrraacckkeerrss(()) ppoosstt__ttrraacckkeerrss(()) aadddd__ttrraacckkeerr(()) **********
    │ │ │ │ -void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │ +********** aadddd__ttrraacckkeerr(()) ttrraacckkeerrss(()) ppoosstt__ttrraacckkeerrss(()) rreeppllaaccee__ttrraacckkeerrss(()) **********
    │ │ │ │ +void aadddd__ttrraacckkeerr (announce_entry const&) const;
    │ │ │ │  std::vector ttrraacckkeerrss () const;
    │ │ │ │  void ppoosstt__ttrraacckkeerrss () const;
    │ │ │ │ -void aadddd__ttrraacckkeerr (announce_entry const&) const;
    │ │ │ │ +void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │  trackers() returns the list of trackers for this torrent. The announce _e_n_t_r_y
    │ │ │ │  contains both a string url which specify the announce url for the tracker as
    │ │ │ │  well as an _i_n_t tier, which is specifies the order in which this tracker is
    │ │ │ │  tried. If you want libtorrent to use another list of trackers for this torrent,
    │ │ │ │  you can use replace_trackers() which takes a list of the same form as the one
    │ │ │ │  returned from trackers() and will replace it. If you want an immediate effect,
    │ │ │ │  you have to call _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_). See _a_n_n_o_u_n_c_e___e_n_t_r_y.
    │ │ │ │ @@ -515,18 +515,18 @@
    │ │ │ │  add_tracker() will look if the specified tracker is already in the set. If it
    │ │ │ │  is, it doesn't do anything. If it's not in the current set of trackers, it will
    │ │ │ │  insert it in the tier specified in the _a_n_n_o_u_n_c_e___e_n_t_r_y.
    │ │ │ │  The updated set of trackers will be saved in the resume data, and when a
    │ │ │ │  torrent is started with resume data, the trackers from the resume data will
    │ │ │ │  replace the original ones.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** rreemmoovvee__uurrll__sseeeedd(()) uurrll__sseeeeddss(()) aadddd__uurrll__sseeeedd(()) **********
    │ │ │ │ -void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ -void aadddd__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +********** aadddd__uurrll__sseeeedd(()) rreemmoovvee__uurrll__sseeeedd(()) uurrll__sseeeeddss(()) **********
    │ │ │ │  std::set uurrll__sseeeeddss () const;
    │ │ │ │ +void aadddd__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │  add_url_seed() adds another url to the torrent's list of url seeds. If the
    │ │ │ │  given url already exists in that list, the call has no effect. The torrent will
    │ │ │ │  connect to the server and try to download pieces from it, unless it's paused,
    │ │ │ │  queued, checking or seeding. remove_url_seed() removes the given url if it
    │ │ │ │  exists already. url_seeds() return a set of the url seeds currently in this
    │ │ │ │  torrent. Note that URLs that fails may be removed automatically from the list.
    │ │ │ │  See _h_t_t_p_ _s_e_e_d_i_n_g for more information.
    │ │ │ │ @@ -561,17 +561,17 @@
    │ │ │ │  and false afterward.
    │ │ │ │  Clients should only use _i_s___v_a_l_i_d_(_) to determine if the result of session::
    │ │ │ │  find_torrent() was successful.
    │ │ │ │  Unlike other member functions which return a value, _i_s___v_a_l_i_d_(_) completes
    │ │ │ │  immediately, without blocking on a result from the network thread. Also unlike
    │ │ │ │  other functions, it never throws the system_error exception.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppaauussee(()) rreessuummee(()) **********
    │ │ │ │ -void rreessuummee () const;
    │ │ │ │ +********** rreessuummee(()) ppaauussee(()) **********
    │ │ │ │  void ppaauussee (pause_flags_t flags = {}) const;
    │ │ │ │ +void rreessuummee () const;
    │ │ │ │  pause(), and resume() will disconnect all peers and reconnect all peers
    │ │ │ │  respectively. When a torrent is paused, it will however remember all share
    │ │ │ │  ratios to all peers and remember all potential (not connected) peers. Torrents
    │ │ │ │  may be paused automatically if there is a file error (e.g. disk full) or
    │ │ │ │  something similar. See _f_i_l_e___e_r_r_o_r___a_l_e_r_t.
    │ │ │ │  For possible values of the flags parameter, see pause_flags_t.
    │ │ │ │  To know if a torrent is paused or not, call torrent_handle::flags() and check
    │ │ │ │ @@ -579,18 +579,18 @@
    │ │ │ │  Note
    │ │ │ │  Torrents that are auto-managed may be automatically resumed again. It does not
    │ │ │ │  make sense to pause an auto-managed torrent without making it not auto-managed
    │ │ │ │  first. Torrents are auto-managed by default when added to the _s_e_s_s_i_o_n. For more
    │ │ │ │  information, see _q_u_e_u_i_n_g.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** uunnsseett__ffllaaggss(()) sseett__ffllaaggss(()) ffllaaggss(()) **********
    │ │ │ │ -void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │  void uunnsseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │ -torrent_flags_t ffllaaggss () const;
    │ │ │ │  void sseett__ffllaaggss (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │ │ +torrent_flags_t ffllaaggss () const;
    │ │ │ │ +void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │  sets and gets the torrent state flags. See _t_o_r_r_e_n_t___f_l_a_g_s___t. The set_flags
    │ │ │ │  overload that take a mask will affect all flags part of the mask, and set their
    │ │ │ │  values to what the flags argument is set to. This allows clearing and setting
    │ │ │ │  flags in a single function call. The set_flags overload that just takes flags,
    │ │ │ │  sets all the specified flags and leave any other flags unchanged. unset_flags
    │ │ │ │  clears the specified flags, while leaving any other flags unchanged.
    │ │ │ │  Theseed_modeflag is special, it can only be cleared once the torrent has been
    │ │ │ │ @@ -614,16 +614,16 @@
    │ │ │ │  announcing to the tracker. The torrent will be added to the checking queue, and
    │ │ │ │  will be checked (all the files will be read and compared to the piece hashes).
    │ │ │ │  Once the check is complete, the torrent will start connecting to peers again,
    │ │ │ │  as normal. The torrent will be placed last in queue, i.e. its queue position
    │ │ │ │  will be the highest of all torrents in the _s_e_s_s_i_o_n.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ssaavvee__rreessuummee__ddaattaa(()) ggeett__rreessuummee__ddaattaa(()) **********
    │ │ │ │ -void ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │  add_torrent_params ggeett__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │ +void ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │  save_resume_data() and get_resume_data() asks libtorrent to generate fast-
    │ │ │ │  resume data for this torrent. The fast resume data (stored in an
    │ │ │ │  _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object) can be used to resume a torrent in the next _s_e_s_s_i_o_n
    │ │ │ │  without having to check all files for which pieces have been downloaded. It can
    │ │ │ │  also be used to save a .torrent file for a _t_o_r_r_e_n_t___h_a_n_d_l_e.
    │ │ │ │  `get_resume_data() is synchronous and will block the calling thread until the
    │ │ │ │  resume data is ready and returned from the libtorrent main thread. /
    │ │ │ │ @@ -701,35 +701,35 @@
    │ │ │ │  Note how outstanding_resume_data is a global counter in this example. This is
    │ │ │ │  deliberate, otherwise there is a race condition for torrents that was just
    │ │ │ │  asked to save their resume data, they posted the _a_l_e_r_t, but it has not been
    │ │ │ │  received yet. Those torrents would report that they don't need to save resume
    │ │ │ │  data again, and skipped by the initial loop, and thwart the counter otherwise.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** nneeeedd__ssaavvee__rreessuummee__ddaattaa(()) **********
    │ │ │ │ -bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │  bool nneeeedd__ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags) const;
    │ │ │ │ +bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │  This function returns true if anything that is stored in the resume data has
    │ │ │ │  changed since the last time resume data was saved. The overload that takes
    │ │ │ │  flags let you ask if specific categories of properties have changed. These
    │ │ │ │  flags have the same behavior as in the _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) call.
    │ │ │ │  This is a bblloocckkiinngg call. It will wait for a response from libtorrent's main
    │ │ │ │  thread. A way to avoid blocking is to instead call _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) directly,
    │ │ │ │  specifying the conditions under which resume data should be saved.
    │ │ │ │  Note
    │ │ │ │  A torrent's resume data is considered saved as soon as the
    │ │ │ │  _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t is posted. It is important to make sure this _a_l_e_r_t is
    │ │ │ │  received and handled in order for this function to be meaningful.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** qquueeuuee__ppoossiittiioonn(()) qquueeuuee__ppoossiittiioonn__bboottttoomm(()) qquueeuuee__ppoossiittiioonn__uupp(())
    │ │ │ │ -qquueeuuee__ppoossiittiioonn__ttoopp(()) qquueeuuee__ppoossiittiioonn__ddoowwnn(()) **********
    │ │ │ │ +********** qquueeuuee__ppoossiittiioonn__ddoowwnn(()) qquueeuuee__ppoossiittiioonn__ttoopp(()) qquueeuuee__ppoossiittiioonn(())
    │ │ │ │ +qquueeuuee__ppoossiittiioonn__bboottttoomm(()) qquueeuuee__ppoossiittiioonn__uupp(()) **********
    │ │ │ │ +void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │  queue_position_t qquueeuuee__ppoossiittiioonn () const;
    │ │ │ │  void qquueeuuee__ppoossiittiioonn__bboottttoomm () const;
    │ │ │ │ -void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │ -void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │  void qquueeuuee__ppoossiittiioonn__ttoopp () const;
    │ │ │ │ +void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │  Every torrent that is added is assigned a queue position exactly one greater
    │ │ │ │  than the greatest queue position of all existing torrents. Torrents that are
    │ │ │ │  being seeded have -1 as their queue position, since they're no longer in line
    │ │ │ │  to be downloaded.
    │ │ │ │  When a torrent is removed or turns into a seed, all torrents with greater queue
    │ │ │ │  positions have their positions decreased to fill in the space in the sequence.
    │ │ │ │  queue_position() returns the torrent's position in the download queue. The
    │ │ │ │ @@ -744,21 +744,21 @@
    │ │ │ │  ********** qquueeuuee__ppoossiittiioonn__sseett(()) **********
    │ │ │ │  void qquueeuuee__ppoossiittiioonn__sseett (queue_position_t p) const;
    │ │ │ │  updates the position in the queue for this torrent. The relative order of all
    │ │ │ │  other torrents remain intact but their numerical queue position shifts to make
    │ │ │ │  space for this torrent's new position
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr(()) sseett__ssssll__cceerrttiiffiiccaattee(()) **********
    │ │ │ │ +void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate
    │ │ │ │ +      , std::string const& private_key
    │ │ │ │ +      , std::string const& dh_params);
    │ │ │ │  void sseett__ssssll__cceerrttiiffiiccaattee (std::string const& certificate
    │ │ │ │        , std::string const& private_key
    │ │ │ │        , std::string const& dh_params
    │ │ │ │        , std::string const& passphrase = "");
    │ │ │ │ -void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate
    │ │ │ │ -      , std::string const& private_key
    │ │ │ │ -      , std::string const& dh_params);
    │ │ │ │  For SSL torrents, use this to specify a path to a .pem file to use as this
    │ │ │ │  client's certificate. The certificate must be signed by the certificate in the
    │ │ │ │  .torrent file to be valid.
    │ │ │ │  The _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e___b_u_f_f_e_r_(_) overload takes the actual certificate, private
    │ │ │ │  key and DH params as strings, rather than paths to files.
    │ │ │ │  cert is a path to the (signed) certificate in .pem format corresponding to this
    │ │ │ │  torrent.
    │ │ │ │ @@ -825,21 +825,21 @@
    │ │ │ │  uses in order to prefer picking rare pieces.
    │ │ │ │  post_piece_availability() will trigger a _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y___a_l_e_r_t to be posted.
    │ │ │ │  piece_availability() fills the specified std::vector with the availability
    │ │ │ │  for each piece in this torrent. libtorrent does not keep track of availability
    │ │ │ │  for seeds, so if the torrent is seeding the availability for all pieces is
    │ │ │ │  reported as 0.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ggeett__ppiieeccee__pprriioorriittiieess(()) ppiieeccee__pprriioorriittyy(()) pprriioorriittiizzee__ppiieecceess(()) **********
    │ │ │ │ -void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority) const;
    │ │ │ │ -download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const;
    │ │ │ │ +********** ggeett__ppiieeccee__pprriioorriittiieess(()) pprriioorriittiizzee__ppiieecceess(()) ppiieeccee__pprriioorriittyy(()) **********
    │ │ │ │  void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const;
    │ │ │ │ -void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces) const;
    │ │ │ │ +void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority) const;
    │ │ │ │  std::vector ggeett__ppiieeccee__pprriioorriittiieess () const;
    │ │ │ │ +download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const;
    │ │ │ │ +void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces) const;
    │ │ │ │  These functions are used to set and get the priority of individual pieces. By
    │ │ │ │  default all pieces have priority 4. That means that the random rarest first
    │ │ │ │  algorithm is effectively active for all pieces. You may however change the
    │ │ │ │  priority of individual pieces. There are 8 priority levels. 0 means not to
    │ │ │ │  download the piece at all. Otherwise, lower priority values means less likely
    │ │ │ │  to be picked. Piece priority takes precedence over piece availability. Every
    │ │ │ │  piece with priority 7 will be attempted to be picked before a priority 6 piece
    │ │ │ │ @@ -860,18 +860,18 @@
    │ │ │ │  get_piece_priorities returns a vector with one element for each piece in the
    │ │ │ │  torrent. Each element is the current priority of that piece.
    │ │ │ │  It's possible to cancel the effect of ffiillee priorities by setting the priorities
    │ │ │ │  for the affected pieces. Care has to be taken when mixing usage of file- and
    │ │ │ │  piece priorities.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** pprriioorriittiizzee__ffiilleess(()) ggeett__ffiillee__pprriioorriittiieess(()) ffiillee__pprriioorriittyy(()) **********
    │ │ │ │ -std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │ -void pprriioorriittiizzee__ffiilleess (std::vector const& files) const;
    │ │ │ │  void ffiillee__pprriioorriittyy (file_index_t index, download_priority_t priority) const;
    │ │ │ │ +void pprriioorriittiizzee__ffiilleess (std::vector const& files) const;
    │ │ │ │  download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const;
    │ │ │ │ +std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │  index must be in the range [0, number_of_files).
    │ │ │ │  file_priority() queries or sets the priority of file index.
    │ │ │ │  prioritize_files() takes a vector that has at as many elements as there are
    │ │ │ │  files in the torrent. Each _e_n_t_r_y is the priority of that file. The function
    │ │ │ │  sets the priorities of all the pieces in the torrent based on the vector.
    │ │ │ │  get_file_priorities() returns a vector with the priorities of all files.
    │ │ │ │  The priority values are the same as for _p_i_e_c_e___p_r_i_o_r_i_t_y_(_). See
    │ │ │ │ @@ -895,54 +895,54 @@
    │ │ │ │  be moved into the partfile.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ppoosstt__ffiillee__pprriioorriittiieess(()) **********
    │ │ │ │  void ppoosstt__ffiillee__pprriioorriittiieess () const;
    │ │ │ │  post_file_priorities() will trigger a _f_i_l_e___p_r_i_o_r_i_t_i_e_s___a_l_e_r_t to be posted,
    │ │ │ │  containing the download priority of each file in the torrent.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ffoorrccee__llssdd__aannnnoouunnccee(()) ffoorrccee__rreeaannnnoouunnccee(()) ffoorrccee__ddhhtt__aannnnoouunnccee(()) **********
    │ │ │ │ +********** ffoorrccee__llssdd__aannnnoouunnccee(()) ffoorrccee__ddhhtt__aannnnoouunnccee(()) ffoorrccee__rreeaannnnoouunnccee(()) **********
    │ │ │ │ +void ffoorrccee__ddhhtt__aannnnoouunnccee () const;
    │ │ │ │ +void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ │ +void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │  void ffoorrccee__rreeaannnnoouunnccee (int seconds, std::string const& url, reannounce_flags_t
    │ │ │ │  = {}) const;
    │ │ │ │ -void ffoorrccee__ddhhtt__aannnnoouunnccee () const;
    │ │ │ │  void ffoorrccee__rreeaannnnoouunnccee (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │ │ -void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │ -void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ │  force_reannounce() will force this torrent to do another tracker request, to
    │ │ │ │  receive new peers. The seconds argument specifies how many seconds from now to
    │ │ │ │  issue the tracker announces.
    │ │ │ │  If the tracker's min_interval has not passed since the last announce, the
    │ │ │ │  forced announce will be scheduled to happen immediately as the min_interval
    │ │ │ │  expires. This is to honor trackers minimum re-announce interval settings.
    │ │ │ │  The tracker_index argument specifies which tracker to re-announce. If set to -
    │ │ │ │  1 (which is the default), all trackers are re-announce.
    │ │ │ │  The flags argument can be used to affect the re-announce. See
    │ │ │ │  ignore_min_interval and high_priority.
    │ │ │ │  force_dht_announce will announce the torrent to the DHT immediately.
    │ │ │ │  force_lsd_announce will announce the torrent on LSD immediately.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ssccrraappee__ttrraacckkeerr(()) **********
    │ │ │ │ -void ssccrraappee__ttrraacckkeerr (int idx) const;
    │ │ │ │  void ssccrraappee__ttrraacckkeerr (std::string url) const;
    │ │ │ │  void ssccrraappee__ttrraacckkeerr () const;
    │ │ │ │ +void ssccrraappee__ttrraacckkeerr (int idx) const;
    │ │ │ │  scrape_tracker() will send a scrape request to a tracker. By default (idx = -1)
    │ │ │ │  it will scrape the last working tracker. If idx is >= 0, the tracker with the
    │ │ │ │  specified index will scraped.
    │ │ │ │  A scrape request queries the tracker for statistics such as total number of
    │ │ │ │  incomplete peers, complete peers, number of downloads etc.
    │ │ │ │  This request will specifically update the num_complete and num_incomplete
    │ │ │ │  fields in the _t_o_r_r_e_n_t___s_t_a_t_u_s struct once it completes. When it completes, it
    │ │ │ │  will generate a _s_c_r_a_p_e___r_e_p_l_y___a_l_e_r_t. If it fails, it will generate a
    │ │ │ │  _s_c_r_a_p_e___f_a_i_l_e_d___a_l_e_r_t.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__ddoowwnnllooaadd__lliimmiitt(()) uuppllooaadd__lliimmiitt(()) sseett__uuppllooaadd__lliimmiitt(()) ddoowwnnllooaadd__lliimmiitt(())
    │ │ │ │ +********** uuppllooaadd__lliimmiitt(()) sseett__ddoowwnnllooaadd__lliimmiitt(()) sseett__uuppllooaadd__lliimmiitt(()) ddoowwnnllooaadd__lliimmiitt(())
    │ │ │ │  **********
    │ │ │ │ -int ddoowwnnllooaadd__lliimmiitt () const;
    │ │ │ │  void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const;
    │ │ │ │ -void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │ +int ddoowwnnllooaadd__lliimmiitt () const;
    │ │ │ │  int uuppllooaadd__lliimmiitt () const;
    │ │ │ │ +void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │  set_upload_limit will limit the upload bandwidth used by this particular
    │ │ │ │  torrent to the limit you set. It is given as the number of bytes per second the
    │ │ │ │  torrent is allowed to upload. set_download_limit works the same way but for
    │ │ │ │  download bandwidth instead of upload bandwidth. Note that setting a higher
    │ │ │ │  limit on a torrent then the global limit (settings_pack::upload_rate_limit)
    │ │ │ │  will not override the global rate limit. The torrent can never upload more than
    │ │ │ │  the global rate limit.
    │ │ │ │ @@ -965,24 +965,24 @@
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** cclleeaarr__ppeeeerrss(()) **********
    │ │ │ │  void cclleeaarr__ppeeeerrss ();
    │ │ │ │  This will disconnect all peers and clear the peer list for this torrent. New
    │ │ │ │  peers will have to be acquired before resuming, from trackers, DHT or local
    │ │ │ │  service discovery, for example.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__mmaaxx__uuppllooaaddss(()) mmaaxx__uuppllooaaddss(()) **********
    │ │ │ │ +********** mmaaxx__uuppllooaaddss(()) sseett__mmaaxx__uuppllooaaddss(()) **********
    │ │ │ │  void sseett__mmaaxx__uuppllooaaddss (int max_uploads) const;
    │ │ │ │  int mmaaxx__uuppllooaaddss () const;
    │ │ │ │  set_max_uploads() sets the maximum number of peers that's unchoked at the same
    │ │ │ │  time on this torrent. If you set this to -1, there will be no limit. This
    │ │ │ │  defaults to infinite. The primary setting controlling this is the global
    │ │ │ │  unchoke slots limit, set by unchoke_slots_limit in _s_e_t_t_i_n_g_s___p_a_c_k.
    │ │ │ │  max_uploads() returns the current settings.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__mmaaxx__ccoonnnneeccttiioonnss(()) mmaaxx__ccoonnnneeccttiioonnss(()) **********
    │ │ │ │ +********** mmaaxx__ccoonnnneeccttiioonnss(()) sseett__mmaaxx__ccoonnnneeccttiioonnss(()) **********
    │ │ │ │  void sseett__mmaaxx__ccoonnnneeccttiioonnss (int max_connections) const;
    │ │ │ │  int mmaaxx__ccoonnnneeccttiioonnss () const;
    │ │ │ │  set_max_connections() sets the maximum number of connection this torrent will
    │ │ │ │  open. If all connections are used up, incoming connections may be refused or
    │ │ │ │  poor connections may be closed. This must be at least 2. The default is
    │ │ │ │  unlimited number of connections. If -1 is given to the function, it means
    │ │ │ │  unlimited. There is also a global limit of the number of connections, set by
    │ │ │ │ @@ -1035,26 +1035,26 @@
    │ │ │ │  ********** rreennaammee__ffiillee(()) **********
    │ │ │ │  void rreennaammee__ffiillee (file_index_t index, std::string const& new_name) const;
    │ │ │ │  Renames the file with the given index asynchronously. The rename operation is
    │ │ │ │  complete when either a _f_i_l_e___r_e_n_a_m_e_d___a_l_e_r_t or _f_i_l_e___r_e_n_a_m_e___f_a_i_l_e_d___a_l_e_r_t is
    │ │ │ │  posted.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) **********
    │ │ │ │ -sha1_hash iinnffoo__hhaasshh () const;
    │ │ │ │  info_hash_t iinnffoo__hhaasshheess () const;
    │ │ │ │ +sha1_hash iinnffoo__hhaasshh () const;
    │ │ │ │  returns the info-hash(es) of the torrent. If this handle is to a torrent that
    │ │ │ │  hasn't loaded yet (for instance by being added) by a URL, the returned value is
    │ │ │ │  undefined. The info_hash() returns the SHA-1 info-hash for v1 torrents and a
    │ │ │ │  truncated hash for v2 torrents. For the full v2 info-hash, use info_hashes()
    │ │ │ │  instead.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ooppeerraattoorr<<(()) ooppeerraattoorr====(()) ooppeerraattoorr!!==(()) **********
    │ │ │ │ -bool ooppeerraattoorr<< (const torrent_handle& h) const;
    │ │ │ │ +********** ooppeerraattoorr====(()) ooppeerraattoorr<<(()) ooppeerraattoorr!!==(()) **********
    │ │ │ │  bool ooppeerraattoorr==== (const torrent_handle& h) const;
    │ │ │ │  bool ooppeerraattoorr!!== (const torrent_handle& h) const;
    │ │ │ │ +bool ooppeerraattoorr<< (const torrent_handle& h) const;
    │ │ │ │  comparison operators. The order of the torrents is unspecified but stable.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** iidd(()) **********
    │ │ │ │  std::uint32_t iidd () const;
    │ │ │ │  returns a unique identifier for this torrent. It's not a dense index. It's not
    │ │ │ │  preserved across sessions.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html
    │ │ │ @@ -34,32 +34,32 @@
    │ │ │  
    │ │ │  
    │ │ │ @@ -120,28 +120,28 @@ │ │ │ explicit torrent_info (info_hash_t const& info_hash); │ │ │ torrent_info (torrent_info const& t); │ │ │ torrent_info (bdecode_node const& info_section, error_code& ec │ │ │ , load_torrent_limits const& cfg │ │ │ , from_info_section_t); │ │ │ ~torrent_info (); │ │ │ file_storage const& layout () const; │ │ │ - std::vector<std::string> collections () const; │ │ │ std::vector<sha1_hash> similar_torrents () const; │ │ │ + std::vector<std::string> collections () const; │ │ │ std::int64_t total_size () const; │ │ │ std::int64_t size_on_disk () const; │ │ │ - int num_pieces () const; │ │ │ int piece_length () const; │ │ │ + int num_pieces () const; │ │ │ int blocks_per_piece () const; │ │ │ piece_index_t end_piece () const; │ │ │ - piece_index_t last_piece () const; │ │ │ index_range<piece_index_t> piece_range () const; │ │ │ + piece_index_t last_piece () const; │ │ │ sha1_hash info_hash () const noexcept; │ │ │ info_hash_t const& info_hashes () const; │ │ │ - bool v1 () const; │ │ │ bool v2 () const; │ │ │ + bool v1 () const; │ │ │ int num_files () const; │ │ │ std::vector<file_slice> map_block (piece_index_t const piece │ │ │ , std::int64_t offset, int size) const; │ │ │ peer_request map_file (file_index_t const file, std::int64_t offset, int size) const; │ │ │ string_view ssl_cert () const; │ │ │ bool is_valid () const; │ │ │ bool priv () const; │ │ │ @@ -197,21 +197,21 @@ │ │ │ disk I/O subsystem only needs access to file names and sizes. │ │ │ The file_storage object is immutable, renamed files are recorded │ │ │ separately. layout() returns the original filenames, as found in │ │ │ the .torrent file. Files may be renamed to de-duplicate names, or to │ │ │ correct invalid filenames.

    │ │ │

    For more information on the file_storage object, see the separate │ │ │ document on how to create torrents.

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

    collections() similar_torrents()

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

    similar_torrents() collections()

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

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

    │ │ │ [report issue]
    │ │ │ @@ -229,21 +229,21 @@ │ │ │
    │ │ │

    size_on_disk()

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

    returns the sum of all non-pad file sizes. i.e. the files that will │ │ │ actually be saved to disk by this torrent.

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

    num_pieces() piece_length()

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

    piece_length() num_pieces()

    │ │ │
    │ │ │ -int num_pieces () const;
    │ │ │  int piece_length () const;
    │ │ │ +int num_pieces () const;
    │ │ │  
    │ │ │

    piece_length() and num_pieces() returns the number of byte │ │ │ for each piece and the total number of pieces, respectively. The │ │ │ difference between piece_size() and piece_length() is that │ │ │ piece_size() takes the piece index as argument and gives you the │ │ │ exact size of that piece. It will always be the same as │ │ │ piece_length() except in the case of the last piece, which may be │ │ │ @@ -252,23 +252,23 @@ │ │ │

    │ │ │

    blocks_per_piece()

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

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

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

    last_piece() piece_range() end_piece()

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

    end_piece() piece_range() last_piece()

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

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

    │ │ │ @@ -279,21 +279,21 @@ │ │ │
    │ │ │  sha1_hash info_hash () const noexcept;
    │ │ │  info_hash_t const& info_hashes () const;
    │ │ │  
    │ │ │

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

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

    v2() v1()

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

    v1() v2()

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

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

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

    num_files()

    │ │ │ @@ -366,15 +366,15 @@ │ │ │ magnet links. Prefer using torrent::is_i2p() instead.

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

    piece_size()

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

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

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

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

    piece_size_for_req()

    │ │ │
    │ │ │  int piece_size_for_req (piece_index_t index) const;
    │ │ │  
    │ │ │ @@ -384,18 +384,18 @@ │ │ │ full (except for the last piece) in order to correctly compute the │ │ │ piece hash. │ │ │ Note: this is not a trivial accessor. For v2-only torrents it calls │ │ │ file_storage::piece_size2(), which performs an O(log n) upper_bound │ │ │ over the file list to find the file boundary that may shorten the │ │ │ piece. Cache the result when calling it repeatedly for the same │ │ │ piece in a hot path.

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

    hash_for_piece_ptr() hash_for_piece()

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

    hash_for_piece() hash_for_piece_ptr()

    │ │ │
    │ │ │  sha1_hash hash_for_piece (piece_index_t index) const;
    │ │ │  char const* hash_for_piece_ptr (piece_index_t const index) const;
    │ │ │  
    │ │ │

    hash_for_piece() takes a piece-index and returns the 20-bytes │ │ │ sha1-hash for that piece. │ │ │ hash_for_piece_ptr() returns a pointer to the 20 byte sha1 digest │ │ │ ├── html2text {} │ │ │ │ @@ -5,32 +5,32 @@ │ │ │ │ Table of contents │ │ │ │ * _l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s │ │ │ │ * _t_o_r_r_e_n_t___i_n_f_o │ │ │ │ o _t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ o _t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ o _~_t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ o _l_a_y_o_u_t_(_) │ │ │ │ - o _c_o_l_l_e_c_t_i_o_n_s_(_)_ _s_i_m_i_l_a_r___t_o_r_r_e_n_t_s_(_) │ │ │ │ + o _s_i_m_i_l_a_r___t_o_r_r_e_n_t_s_(_)_ _c_o_l_l_e_c_t_i_o_n_s_(_) │ │ │ │ o _t_o_t_a_l___s_i_z_e_(_) │ │ │ │ o _s_i_z_e___o_n___d_i_s_k_(_) │ │ │ │ - o _n_u_m___p_i_e_c_e_s_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ + o _p_i_e_c_e___l_e_n_g_t_h_(_)_ _n_u_m___p_i_e_c_e_s_(_) │ │ │ │ o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ - o _l_a_s_t___p_i_e_c_e_(_)_ _p_i_e_c_e___r_a_n_g_e_(_)_ _e_n_d___p_i_e_c_e_(_) │ │ │ │ + o _e_n_d___p_i_e_c_e_(_)_ _p_i_e_c_e___r_a_n_g_e_(_)_ _l_a_s_t___p_i_e_c_e_(_) │ │ │ │ o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_) │ │ │ │ - o _v_2_(_)_ _v_1_(_) │ │ │ │ + o _v_1_(_)_ _v_2_(_) │ │ │ │ o _n_u_m___f_i_l_e_s_(_) │ │ │ │ o _m_a_p___b_l_o_c_k_(_) │ │ │ │ o _m_a_p___f_i_l_e_(_) │ │ │ │ o _s_s_l___c_e_r_t_(_) │ │ │ │ o _i_s___v_a_l_i_d_(_) │ │ │ │ o _p_r_i_v_(_) │ │ │ │ o _i_s___i_2_p_(_) │ │ │ │ o _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ o _p_i_e_c_e___s_i_z_e___f_o_r___r_e_q_(_) │ │ │ │ - o _h_a_s_h___f_o_r___p_i_e_c_e___p_t_r_(_)_ _h_a_s_h___f_o_r___p_i_e_c_e_(_) │ │ │ │ + o _h_a_s_h___f_o_r___p_i_e_c_e_(_)_ _h_a_s_h___f_o_r___p_i_e_c_e___p_t_r_(_) │ │ │ │ o _i_s___l_o_a_d_e_d_(_) │ │ │ │ o _n_a_m_e_(_) │ │ │ │ o _i_n_f_o___s_e_c_t_i_o_n_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ llooaadd__ttoorrrreenntt__lliimmiittss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___i_n_f_o_._h_p_p" │ │ │ │ this object holds configuration options for limits to use when loading │ │ │ │ @@ -77,28 +77,28 @@ │ │ │ │ explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ ttoorrrreenntt__iinnffoo (torrent_info const& t); │ │ │ │ ttoorrrreenntt__iinnffoo (bdecode_node const& info_section, error_code& ec │ │ │ │ , load_torrent_limits const& cfg │ │ │ │ , from_info_section_t); │ │ │ │ ~~ttoorrrreenntt__iinnffoo (); │ │ │ │ file_storage const& llaayyoouutt () const; │ │ │ │ - std::vector ccoolllleeccttiioonnss () const; │ │ │ │ std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ + std::vector ccoolllleeccttiioonnss () const; │ │ │ │ std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ - int nnuumm__ppiieecceess () const; │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ + int nnuumm__ppiieecceess () const; │ │ │ │ int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ - piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ index_range ppiieeccee__rraannggee () const; │ │ │ │ + piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ - bool vv11 () const; │ │ │ │ bool vv22 () const; │ │ │ │ + bool vv11 () const; │ │ │ │ int nnuumm__ffiilleess () const; │ │ │ │ std::vector mmaapp__bblloocckk (piece_index_t const piece │ │ │ │ , std::int64_t offset, int size) const; │ │ │ │ peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t offset, int │ │ │ │ size) const; │ │ │ │ string_view ssssll__cceerrtt () const; │ │ │ │ bool iiss__vvaalliidd () const; │ │ │ │ @@ -140,17 +140,17 @@ │ │ │ │ only needs access to file names and sizes. The _f_i_l_e___s_t_o_r_a_g_e object is │ │ │ │ immutable, renamed files are recorded separately. layout() returns the original │ │ │ │ _f_i_l_e_n_a_m_e_s, as found in the .torrent file. Files may be renamed to de-duplicate │ │ │ │ names, or to correct invalid _f_i_l_e_n_a_m_e_s. │ │ │ │ For more information on the _f_i_l_e___s_t_o_r_a_g_e object, see the separate document on │ │ │ │ how to create torrents. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccoolllleeccttiioonnss(()) ssiimmiillaarr__ttoorrrreennttss(()) ********** │ │ │ │ -std::vector ccoolllleeccttiioonnss () const; │ │ │ │ +********** ssiimmiillaarr__ttoorrrreennttss(()) ccoolllleeccttiioonnss(()) ********** │ │ │ │ std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ +std::vector ccoolllleeccttiioonnss () const; │ │ │ │ These two functions are related to _B_E_P_ _3_8 (mutable torrents). The vectors │ │ │ │ returned from these correspond to the "similar" and "collections" keys in the │ │ │ │ .torrent file. Both info-hashes and collections from within the info-dict and │ │ │ │ from outside of it are included. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ttoottaall__ssiizzee(()) ********** │ │ │ │ std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ @@ -160,47 +160,47 @@ │ │ │ │ than the sum of all (regular) file sizes. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ssiizzee__oonn__ddiisskk(()) ********** │ │ │ │ std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ returns the sum of all non-pad file sizes. i.e. the files that will actually be │ │ │ │ saved to disk by this torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ppiieecceess(()) ppiieeccee__lleennggtthh(()) ********** │ │ │ │ -int nnuumm__ppiieecceess () const; │ │ │ │ +********** ppiieeccee__lleennggtthh(()) nnuumm__ppiieecceess(()) ********** │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ +int nnuumm__ppiieecceess () const; │ │ │ │ piece_length() and num_pieces() returns the number of byte for each piece and │ │ │ │ the total number of pieces, respectively. The difference between piece_size() │ │ │ │ and piece_length() is that piece_size() takes the piece index as argument and │ │ │ │ gives you the exact size of that piece. It will always be the same as │ │ │ │ piece_length() except in the case of the last piece, which may be smaller. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** bblloocckkss__ppeerr__ppiieeccee(()) ********** │ │ │ │ int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ returns the number of blocks there are in the typical piece. There may be fewer │ │ │ │ in the last piece) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** llaasstt__ppiieeccee(()) ppiieeccee__rraannggee(()) eenndd__ppiieeccee(()) ********** │ │ │ │ +********** eenndd__ppiieeccee(()) ppiieeccee__rraannggee(()) llaasstt__ppiieeccee(()) ********** │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ -piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ index_range ppiieeccee__rraannggee () const; │ │ │ │ +piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ last_piece() returns the index to the last piece in the torrent and end_piece() │ │ │ │ returns the index to the one-past-end piece in the torrent piece_range() │ │ │ │ returns an implementation-defined type that can be used as the container in a │ │ │ │ range-for loop. Where the values are the indices of all pieces in the │ │ │ │ _f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) ********** │ │ │ │ sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ returns the info-hash of the torrent. For BitTorrent v2 support, use │ │ │ │ info_hashes() to get an object that may hold both a v1 and v2 info-hash │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** vv22(()) vv11(()) ********** │ │ │ │ -bool vv11 () const; │ │ │ │ +********** vv11(()) vv22(()) ********** │ │ │ │ bool vv22 () const; │ │ │ │ +bool vv11 () const; │ │ │ │ returns whether this torrent has v1 and/or v2 metadata, respectively. Hybrid │ │ │ │ torrents have both. These are shortcuts for info_hashes().has_v1() and │ │ │ │ info_hashes().has_v2() calls. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** nnuumm__ffiilleess(()) ********** │ │ │ │ int nnuumm__ffiilleess () const; │ │ │ │ If you need index-access to files you can use the num_files() along with the │ │ │ │ @@ -260,15 +260,15 @@ │ │ │ │ For v1 and hybrid torrents, piece sizes must be full (except for the last │ │ │ │ piece) in order to correctly compute the piece hash. Note: this is not a │ │ │ │ trivial accessor. For v2-only torrents it calls _f_i_l_e___s_t_o_r_a_g_e_:_:_p_i_e_c_e___s_i_z_e_2_(_), │ │ │ │ which performs an O(log n) upper_bound over the file list to find the file │ │ │ │ boundary that may shorten the piece. Cache the result when calling it │ │ │ │ repeatedly for the same piece in a hot path. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaasshh__ffoorr__ppiieeccee__ppttrr(()) hhaasshh__ffoorr__ppiieeccee(()) ********** │ │ │ │ +********** hhaasshh__ffoorr__ppiieeccee(()) hhaasshh__ffoorr__ppiieeccee__ppttrr(()) ********** │ │ │ │ sha1_hash hhaasshh__ffoorr__ppiieeccee (piece_index_t index) const; │ │ │ │ char const* hhaasshh__ffoorr__ppiieeccee__ppttrr (piece_index_t const index) const; │ │ │ │ hash_for_piece() takes a piece-index and returns the 20-bytes sha1-hash for │ │ │ │ that piece. hash_for_piece_ptr() returns a pointer to the 20 byte sha1 digest │ │ │ │ for the piece. Note that the string is not 0-terminated. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** iiss__llooaaddeedd(()) ********** │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Trackers.html │ │ │ @@ -31,15 +31,15 @@ │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

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

    announce_infohash

    │ │ │ @@ -137,19 +137,19 @@ │ │ │

    announce_entry

    │ │ │

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │

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

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

    ~announce_entry() announce_entry() operator=()

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

    announce_entry() ~announce_entry() operator=()

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

    constructs a tracker announce entry with u as the URL.

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

    enum tracker_source

    │ │ │

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │
    │ │ │ ├── html2text {} │ │ │ │ @@ -2,15 +2,15 @@ │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _a_n_n_o_u_n_c_e___i_n_f_o_h_a_s_h │ │ │ │ * _a_n_n_o_u_n_c_e___e_n_d_p_o_i_n_t │ │ │ │ * _a_n_n_o_u_n_c_e___e_n_t_r_y │ │ │ │ - o _~_a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ + o _a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _~_a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ o _e_n_u_m_ _t_r_a_c_k_e_r___s_o_u_r_c_e │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ aannnnoouunnccee__iinnffoohhaasshh ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ holds the per-info-hash state for a tracker, separately for the v1 and v2 info- │ │ │ │ hashes. Since a hybrid torrent has both info-hashes, the state for the two │ │ │ │ announces (the message returned by the tracker, the time of the next announce, │ │ │ │ @@ -83,19 +83,19 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ aannnnoouunnccee__eennttrryy ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ this class holds information about one bittorrent tracker, as it relates to a │ │ │ │ specific torrent. │ │ │ │ struct announce_entry │ │ │ │ { │ │ │ │ + announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ - aannnnoouunnccee__eennttrryy (); │ │ │ │ aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ + aannnnoouunnccee__eennttrryy (); │ │ │ │ ~~aannnnoouunnccee__eennttrryy (); │ │ │ │ - announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ │ │ │ │ enum tracker_source │ │ │ │ { │ │ │ │ source_torrent, │ │ │ │ source_client, │ │ │ │ source_magnet_link, │ │ │ │ source_tex, │ │ │ │ @@ -106,20 +106,20 @@ │ │ │ │ std::vector endpoints; │ │ │ │ std::uint8_t ttiieerr = 0; │ │ │ │ std::uint8_t ffaaiill__lliimmiitt = 0; │ │ │ │ std::uint8_t source:4; │ │ │ │ bool verified:1; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~aannnnoouunnccee__eennttrryy(()) aannnnoouunnccee__eennttrryy(()) ooppeerraattoorr==(()) ********** │ │ │ │ +********** aannnnoouunnccee__eennttrryy(()) ~~aannnnoouunnccee__eennttrryy(()) ooppeerraattoorr==(()) ********** │ │ │ │ +announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ -aannnnoouunnccee__eennttrryy (); │ │ │ │ aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ +aannnnoouunnccee__eennttrryy (); │ │ │ │ ~~aannnnoouunnccee__eennttrryy (); │ │ │ │ -announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ constructs a tracker announce _e_n_t_r_y with u as the URL. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** eennuumm ttrraacckkeerr__ssoouurrccee ********** │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_s_o_u_r_c_e___t_o_r_r_e_n_t_ _ _ _ _|_1_ _ _ _ _|_t_h_e_ _t_r_a_c_k_e_r_ _w_a_s_ _p_a_r_t_ _o_f_ _t_h_e_ _._t_o_r_r_e_n_t_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ | │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Utility.html │ │ │ @@ -28,65 +28,201 @@ │ │ │ │ │ │ │ │ │
    2.1.0
    │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

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

    hasher

    │ │ │ +

    Declared in "libtorrent/hasher.hpp"

    │ │ │ +

    this is a SHA-1 hash class.

    │ │ │ +

    You use it by first instantiating it, then call update() to feed it │ │ │ +with data. i.e. you don't have to keep the entire buffer of which you want to │ │ │ +create the hash in memory. You can feed the hasher parts of it at a time. When │ │ │ +You have fed the hasher with all the data, you call final() and it │ │ │ +will return the sha1-hash of the data.

    │ │ │ +

    The constructor that takes a char const* and an integer will construct the │ │ │ +sha1 context and feed it the data passed in.

    │ │ │ +

    If you want to reuse the hasher object once you have created a hash, you have to │ │ │ +call reset() to reinitialize it.

    │ │ │ +

    The built-in software version of sha1-algorithm was implemented │ │ │ +by Steve Reid and released as public domain. │ │ │ +For more info, see src/sha1.cpp.

    │ │ │ +
    │ │ │ +class hasher
    │ │ │ +{
    │ │ │ +   hasher ();
    │ │ │ +   hasher& operator= (hasher&&) & noexcept;
    │ │ │ +   hasher& operator= (hasher const&) &;
    │ │ │ +   hasher (char const* data, int len);
    │ │ │ +   hasher (hasher&&) noexcept;
    │ │ │ +   explicit hasher (span<char const> data);
    │ │ │ +   hasher (hasher const&);
    │ │ │ +   hasher& update (span<char const> data);
    │ │ │ +   hasher& update (char const* data, int len);
    │ │ │ +   sha1_hash final ();
    │ │ │ +   void reset ();
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    hasher() operator=()

    │ │ │ +
    │ │ │ +hasher& operator= (hasher&&) & noexcept;
    │ │ │ +hasher& operator= (hasher const&) &;
    │ │ │ +hasher (char const* data, int len);
    │ │ │ +hasher (hasher&&) noexcept;
    │ │ │ +explicit hasher (span<char const> data);
    │ │ │ +hasher (hasher const&);
    │ │ │ +
    │ │ │ +

    this is the same as default constructing followed by a call to │ │ │ +update(data, len).

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

    update()

    │ │ │ +
    │ │ │ +hasher& update (span<char const> data);
    │ │ │ +hasher& update (char const* data, int len);
    │ │ │ +
    │ │ │ +

    append the following bytes to what is being hashed

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

    final()

    │ │ │ +
    │ │ │ +sha1_hash final ();
    │ │ │ +
    │ │ │ +

    returns the SHA-1 digest of the buffers previously passed to │ │ │ +update() and the hasher constructor.

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

    reset()

    │ │ │ +
    │ │ │ +void reset ();
    │ │ │ +
    │ │ │ +

    restore the hasher state to be as if the hasher has just been │ │ │ +default constructed.

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

    hasher256

    │ │ │ +

    Declared in "libtorrent/hasher.hpp"

    │ │ │ +

    hasher256 computes a SHA-256 message digest. It is the │ │ │ +counterpart to hasher (which computes SHA-1) and is used for │ │ │ +BitTorrent v2 piece and merkle-tree hashes. It can be fed input │ │ │ +incrementally via update() and the digest is produced by │ │ │ +final(). Call reset() to reuse the object for another │ │ │ +digest.

    │ │ │ +
    │ │ │ +class hasher256
    │ │ │ +{
    │ │ │ +   hasher256 ();
    │ │ │ +   hasher256 (hasher256&&) noexcept;
    │ │ │ +   hasher256 (hasher256 const&);
    │ │ │ +   hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ +   hasher256 (char const* data, int len);
    │ │ │ +   hasher256& operator= (hasher256 const&) &;
    │ │ │ +   explicit hasher256 (span<char const> data);
    │ │ │ +   hasher256& update (span<char const> data);
    │ │ │ +   hasher256& update (char const* data, int len);
    │ │ │ +   sha256_hash final ();
    │ │ │ +   void reset ();
    │ │ │ +   ~hasher256 ();
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    hasher256() operator=()

    │ │ │ +
    │ │ │ +hasher256 (hasher256&&) noexcept;
    │ │ │ +hasher256 (hasher256 const&);
    │ │ │ +hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ +hasher256 (char const* data, int len);
    │ │ │ +hasher256& operator= (hasher256 const&) &;
    │ │ │ +explicit hasher256 (span<char const> data);
    │ │ │ +
    │ │ │ +

    this is the same as default constructing followed by a call to │ │ │ +update(data, len).

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

    update()

    │ │ │ +
    │ │ │ +hasher256& update (span<char const> data);
    │ │ │ +hasher256& update (char const* data, int len);
    │ │ │ +
    │ │ │ +

    append the following bytes to what is being hashed

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

    final()

    │ │ │ +
    │ │ │ +sha256_hash final ();
    │ │ │ +
    │ │ │ +

    returns the SHA-1 digest of the buffers previously passed to │ │ │ +update() and the hasher constructor.

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

    reset()

    │ │ │ +
    │ │ │ +void reset ();
    │ │ │ +
    │ │ │ +

    restore the hasher state to be as if the hasher has just been │ │ │ +default constructed.

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

    bitfield

    │ │ │

    Declared in "libtorrent/bitfield.hpp"

    │ │ │

    The bitfield type stores any number of bits as a bitfield │ │ │ in a heap allocated array.

    │ │ │
    │ │ │  struct bitfield
    │ │ │  {
    │ │ │ -   bitfield () noexcept = default;
    │ │ │     bitfield (char const* b, int bits);
    │ │ │ -   bitfield (int bits, bool val);
    │ │ │ +   explicit bitfield (int bits);
    │ │ │     bitfield (bitfield const& rhs);
    │ │ │     bitfield (bitfield&& rhs) noexcept = default;
    │ │ │ -   explicit bitfield (int bits);
    │ │ │ +   bitfield () noexcept = default;
    │ │ │ +   bitfield (int bits, bool val);
    │ │ │     void assign (char const* b, int const bits);
    │ │ │ -   bool get_bit (int index) const noexcept;
    │ │ │     bool operator[] (int index) const noexcept;
    │ │ │ +   bool get_bit (int index) const noexcept;
    │ │ │     void clear_bit (int index) noexcept;
    │ │ │     void set_bit (int index) noexcept;
    │ │ │     bool all_set () const noexcept;
    │ │ │     bool none_set () const noexcept;
    │ │ │     int size () const noexcept;
    │ │ │     int num_words () const noexcept;
    │ │ │     int num_bytes () const noexcept;
    │ │ │ @@ -99,20 +235,20 @@
    │ │ │     int find_last_clear () const noexcept;
    │ │ │     bool operator== (lt::bitfield const& rhs) const;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    bitfield()

    │ │ │
    │ │ │ -bitfield () noexcept = default;
    │ │ │  bitfield (char const* b, int bits);
    │ │ │ -bitfield (int bits, bool val);
    │ │ │ +explicit bitfield (int bits);
    │ │ │  bitfield (bitfield const& rhs);
    │ │ │  bitfield (bitfield&& rhs) noexcept = default;
    │ │ │ -explicit bitfield (int bits);
    │ │ │ +bitfield () noexcept = default;
    │ │ │ +bitfield (int bits, bool val);
    │ │ │  
    │ │ │

    constructs a new bitfield. The default constructor creates an empty │ │ │ bitfield. bits is the size of the bitfield (specified in bits). │ │ │ val is the value to initialize the bits to. If not specified │ │ │ all bits are initialized to 0.

    │ │ │

    The constructor taking a pointer b and bits copies a bitfield │ │ │ from the specified buffer, and bits number of bits (rounded up to │ │ │ @@ -121,21 +257,21 @@ │ │ │

    │ │ │

    assign()

    │ │ │
    │ │ │  void assign (char const* b, int const bits);
    │ │ │  
    │ │ │

    copy bitfield from buffer b of bits number of bits, rounded up to │ │ │ the nearest byte boundary.

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

    get_bit() operator[]()

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

    operator[]() get_bit()

    │ │ │
    │ │ │ -bool get_bit (int index) const noexcept;
    │ │ │  bool operator[] (int index) const noexcept;
    │ │ │ +bool get_bit (int index) const noexcept;
    │ │ │  
    │ │ │

    query bit at index. Returns true if bit is 1, otherwise false.

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

    set_bit() clear_bit()

    │ │ │
    │ │ │ @@ -220,150 +356,14 @@
    │ │ │  [report issue]
    │ │ │
    │ │ │

    find_last_clear()

    │ │ │
    │ │ │  int find_last_clear () const noexcept;
    │ │ │  
    │ │ │

    returns the index to the last cleared bit in the bitfield, i.e. 0 bit.

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

    hasher

    │ │ │ -

    Declared in "libtorrent/hasher.hpp"

    │ │ │ -

    this is a SHA-1 hash class.

    │ │ │ -

    You use it by first instantiating it, then call update() to feed it │ │ │ -with data. i.e. you don't have to keep the entire buffer of which you want to │ │ │ -create the hash in memory. You can feed the hasher parts of it at a time. When │ │ │ -You have fed the hasher with all the data, you call final() and it │ │ │ -will return the sha1-hash of the data.

    │ │ │ -

    The constructor that takes a char const* and an integer will construct the │ │ │ -sha1 context and feed it the data passed in.

    │ │ │ -

    If you want to reuse the hasher object once you have created a hash, you have to │ │ │ -call reset() to reinitialize it.

    │ │ │ -

    The built-in software version of sha1-algorithm was implemented │ │ │ -by Steve Reid and released as public domain. │ │ │ -For more info, see src/sha1.cpp.

    │ │ │ -
    │ │ │ -class hasher
    │ │ │ -{
    │ │ │ -   hasher ();
    │ │ │ -   hasher (char const* data, int len);
    │ │ │ -   hasher& operator= (hasher const&) &;
    │ │ │ -   hasher& operator= (hasher&&) & noexcept;
    │ │ │ -   hasher (hasher&&) noexcept;
    │ │ │ -   explicit hasher (span<char const> data);
    │ │ │ -   hasher (hasher const&);
    │ │ │ -   hasher& update (span<char const> data);
    │ │ │ -   hasher& update (char const* data, int len);
    │ │ │ -   sha1_hash final ();
    │ │ │ -   void reset ();
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    operator=() hasher()

    │ │ │ -
    │ │ │ -hasher (char const* data, int len);
    │ │ │ -hasher& operator= (hasher const&) &;
    │ │ │ -hasher& operator= (hasher&&) & noexcept;
    │ │ │ -hasher (hasher&&) noexcept;
    │ │ │ -explicit hasher (span<char const> data);
    │ │ │ -hasher (hasher const&);
    │ │ │ -
    │ │ │ -

    this is the same as default constructing followed by a call to │ │ │ -update(data, len).

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

    update()

    │ │ │ -
    │ │ │ -hasher& update (span<char const> data);
    │ │ │ -hasher& update (char const* data, int len);
    │ │ │ -
    │ │ │ -

    append the following bytes to what is being hashed

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

    final()

    │ │ │ -
    │ │ │ -sha1_hash final ();
    │ │ │ -
    │ │ │ -

    returns the SHA-1 digest of the buffers previously passed to │ │ │ -update() and the hasher constructor.

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

    reset()

    │ │ │ -
    │ │ │ -void reset ();
    │ │ │ -
    │ │ │ -

    restore the hasher state to be as if the hasher has just been │ │ │ -default constructed.

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

    hasher256

    │ │ │ -

    Declared in "libtorrent/hasher.hpp"

    │ │ │ -

    hasher256 computes a SHA-256 message digest. It is the │ │ │ -counterpart to hasher (which computes SHA-1) and is used for │ │ │ -BitTorrent v2 piece and merkle-tree hashes. It can be fed input │ │ │ -incrementally via update() and the digest is produced by │ │ │ -final(). Call reset() to reuse the object for another │ │ │ -digest.

    │ │ │ -
    │ │ │ -class hasher256
    │ │ │ -{
    │ │ │ -   hasher256 ();
    │ │ │ -   hasher256 (hasher256&&) noexcept;
    │ │ │ -   hasher256& operator= (hasher256 const&) &;
    │ │ │ -   explicit hasher256 (span<char const> data);
    │ │ │ -   hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ -   hasher256 (hasher256 const&);
    │ │ │ -   hasher256 (char const* data, int len);
    │ │ │ -   hasher256& update (char const* data, int len);
    │ │ │ -   hasher256& update (span<char const> data);
    │ │ │ -   sha256_hash final ();
    │ │ │ -   void reset ();
    │ │ │ -   ~hasher256 ();
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    operator=() hasher256()

    │ │ │ -
    │ │ │ -hasher256 (hasher256&&) noexcept;
    │ │ │ -hasher256& operator= (hasher256 const&) &;
    │ │ │ -explicit hasher256 (span<char const> data);
    │ │ │ -hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ -hasher256 (hasher256 const&);
    │ │ │ -hasher256 (char const* data, int len);
    │ │ │ -
    │ │ │ -

    this is the same as default constructing followed by a call to │ │ │ -update(data, len).

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

    update()

    │ │ │ -
    │ │ │ -hasher256& update (char const* data, int len);
    │ │ │ -hasher256& update (span<char const> data);
    │ │ │ -
    │ │ │ -

    append the following bytes to what is being hashed

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

    final()

    │ │ │ -
    │ │ │ -sha256_hash final ();
    │ │ │ -
    │ │ │ -

    returns the SHA-1 digest of the buffers previously passed to │ │ │ -update() and the hasher constructor.

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

    reset()

    │ │ │ -
    │ │ │ -void reset ();
    │ │ │ -
    │ │ │ -

    restore the hasher state to be as if the hasher has just been │ │ │ -default constructed.

    │ │ │
    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │
    │ │ │
    │ │ │ ├── html2text {} │ │ │ │ @@ -1,54 +1,155 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ + * _h_a_s_h_e_r │ │ │ │ + o _h_a_s_h_e_r_(_)_ _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ + o _u_p_d_a_t_e_(_) │ │ │ │ + o _f_i_n_a_l_(_) │ │ │ │ + o _r_e_s_e_t_(_) │ │ │ │ + * _h_a_s_h_e_r_2_5_6 │ │ │ │ + o _h_a_s_h_e_r_2_5_6_(_)_ _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ + o _u_p_d_a_t_e_(_) │ │ │ │ + o _f_i_n_a_l_(_) │ │ │ │ + o _r_e_s_e_t_(_) │ │ │ │ * _b_i_t_f_i_e_l_d │ │ │ │ o _b_i_t_f_i_e_l_d_(_) │ │ │ │ o _a_s_s_i_g_n_(_) │ │ │ │ - o _g_e_t___b_i_t_(_)_ _o_p_e_r_a_t_o_r_[_]_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_[_]_(_)_ _g_e_t___b_i_t_(_) │ │ │ │ o _s_e_t___b_i_t_(_)_ _c_l_e_a_r___b_i_t_(_) │ │ │ │ o _a_l_l___s_e_t_(_) │ │ │ │ o _n_o_n_e___s_e_t_(_) │ │ │ │ o _s_i_z_e_(_) │ │ │ │ o _n_u_m___w_o_r_d_s_(_) │ │ │ │ o _n_u_m___b_y_t_e_s_(_) │ │ │ │ o _e_m_p_t_y_(_) │ │ │ │ o _d_a_t_a_(_) │ │ │ │ o _s_w_a_p_(_) │ │ │ │ o _c_o_u_n_t_(_) │ │ │ │ o _f_i_n_d___f_i_r_s_t___s_e_t_(_) │ │ │ │ o _f_i_n_d___l_a_s_t___c_l_e_a_r_(_) │ │ │ │ - * _h_a_s_h_e_r │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _h_a_s_h_e_r_(_) │ │ │ │ - o _u_p_d_a_t_e_(_) │ │ │ │ - o _f_i_n_a_l_(_) │ │ │ │ - o _r_e_s_e_t_(_) │ │ │ │ - * _h_a_s_h_e_r_2_5_6 │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _h_a_s_h_e_r_2_5_6_(_) │ │ │ │ - o _u_p_d_a_t_e_(_) │ │ │ │ - o _f_i_n_a_l_(_) │ │ │ │ - o _r_e_s_e_t_(_) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ hhaasshheerr ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ +this is a SHA-1 hash class. │ │ │ │ +You use it by first instantiating it, then call update() to feed it with data. │ │ │ │ +i.e. you don't have to keep the entire buffer of which you want to create the │ │ │ │ +hash in memory. You can feed the _h_a_s_h_e_r parts of it at a time. When You have │ │ │ │ +fed the _h_a_s_h_e_r with all the data, you call final() and it will return the sha1- │ │ │ │ +hash of the data. │ │ │ │ +The constructor that takes a char const* and an integer will construct the sha1 │ │ │ │ +context and feed it the data passed in. │ │ │ │ +If you want to reuse the _h_a_s_h_e_r object once you have created a hash, you have │ │ │ │ +to call reset() to reinitialize it. │ │ │ │ +The built-in software version of sha1-algorithm was implemented by Steve Reid │ │ │ │ +and released as public domain. For more info, see src/sha1.cpp. │ │ │ │ +class hasher │ │ │ │ +{ │ │ │ │ + hhaasshheerr (); │ │ │ │ + hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ + hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ + hhaasshheerr (char const* data, int len); │ │ │ │ + hhaasshheerr (hasher&&) noexcept; │ │ │ │ + explicit hhaasshheerr (span data); │ │ │ │ + hhaasshheerr (hasher const&); │ │ │ │ + hasher& uuppddaattee (span data); │ │ │ │ + hasher& uuppddaattee (char const* data, int len); │ │ │ │ + sha1_hash ffiinnaall (); │ │ │ │ + void rreesseett (); │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaasshheerr(()) ooppeerraattoorr==(()) ********** │ │ │ │ +hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ +hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ +hhaasshheerr (char const* data, int len); │ │ │ │ +hhaasshheerr (hasher&&) noexcept; │ │ │ │ +explicit hhaasshheerr (span data); │ │ │ │ +hhaasshheerr (hasher const&); │ │ │ │ +this is the same as default constructing followed by a call to update(data, │ │ │ │ +len). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** uuppddaattee(()) ********** │ │ │ │ +hasher& uuppddaattee (span data); │ │ │ │ +hasher& uuppddaattee (char const* data, int len); │ │ │ │ +append the following bytes to what is being hashed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffiinnaall(()) ********** │ │ │ │ +sha1_hash ffiinnaall (); │ │ │ │ +returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ +_h_a_s_h_e_r constructor. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** rreesseett(()) ********** │ │ │ │ +void rreesseett (); │ │ │ │ +restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ +constructed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ hhaasshheerr225566 ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ +hasher256 computes a SHA-256 message digest. It is the counterpart to hasher │ │ │ │ +(which computes SHA-1) and is used for BitTorrent v2 piece and merkle-tree │ │ │ │ +hashes. It can be fed input incrementally via update() and the digest is │ │ │ │ +produced by final(). Call reset() to reuse the object for another digest. │ │ │ │ +class hasher256 │ │ │ │ +{ │ │ │ │ + hhaasshheerr225566 (); │ │ │ │ + hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ + hhaasshheerr225566 (hasher256 const&); │ │ │ │ + hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ + hhaasshheerr225566 (char const* data, int len); │ │ │ │ + hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ + explicit hhaasshheerr225566 (span data); │ │ │ │ + hasher256& uuppddaattee (span data); │ │ │ │ + hasher256& uuppddaattee (char const* data, int len); │ │ │ │ + sha256_hash ffiinnaall (); │ │ │ │ + void rreesseett (); │ │ │ │ + ~~hhaasshheerr225566 (); │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaasshheerr225566(()) ooppeerraattoorr==(()) ********** │ │ │ │ +hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ +hhaasshheerr225566 (hasher256 const&); │ │ │ │ +hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ +hhaasshheerr225566 (char const* data, int len); │ │ │ │ +hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ +explicit hhaasshheerr225566 (span data); │ │ │ │ +this is the same as default constructing followed by a call to update(data, │ │ │ │ +len). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** uuppddaattee(()) ********** │ │ │ │ +hasher256& uuppddaattee (span data); │ │ │ │ +hasher256& uuppddaattee (char const* data, int len); │ │ │ │ +append the following bytes to what is being hashed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffiinnaall(()) ********** │ │ │ │ +sha256_hash ffiinnaall (); │ │ │ │ +returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ +_h_a_s_h_e_r constructor. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** rreesseett(()) ********** │ │ │ │ +void rreesseett (); │ │ │ │ +restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ +constructed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ bbiittffiieelldd ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_i_t_f_i_e_l_d_._h_p_p" │ │ │ │ The _b_i_t_f_i_e_l_d type stores any number of bits as a _b_i_t_f_i_e_l_d in a heap allocated │ │ │ │ array. │ │ │ │ struct bitfield │ │ │ │ { │ │ │ │ - bbiittffiieelldd () noexcept = default; │ │ │ │ bbiittffiieelldd (char const* b, int bits); │ │ │ │ - bbiittffiieelldd (int bits, bool val); │ │ │ │ + explicit bbiittffiieelldd (int bits); │ │ │ │ bbiittffiieelldd (bitfield const& rhs); │ │ │ │ bbiittffiieelldd (bitfield&& rhs) noexcept = default; │ │ │ │ - explicit bbiittffiieelldd (int bits); │ │ │ │ + bbiittffiieelldd () noexcept = default; │ │ │ │ + bbiittffiieelldd (int bits, bool val); │ │ │ │ void aassssiiggnn (char const* b, int const bits); │ │ │ │ - bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ bool ooppeerraattoorr[[]] (int index) const noexcept; │ │ │ │ + bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ void cclleeaarr__bbiitt (int index) noexcept; │ │ │ │ void sseett__bbiitt (int index) noexcept; │ │ │ │ bool aallll__sseett () const noexcept; │ │ │ │ bool nnoonnee__sseett () const noexcept; │ │ │ │ int ssiizzee () const noexcept; │ │ │ │ int nnuumm__wwoorrddss () const noexcept; │ │ │ │ int nnuumm__bbyytteess () const noexcept; │ │ │ │ @@ -59,35 +160,35 @@ │ │ │ │ int ccoouunntt () const noexcept; │ │ │ │ int ffiinndd__ffiirrsstt__sseett () const noexcept; │ │ │ │ int ffiinndd__llaasstt__cclleeaarr () const noexcept; │ │ │ │ bool ooppeerraattoorr==== (lt::bitfield const& rhs) const; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** bbiittffiieelldd(()) ********** │ │ │ │ -bbiittffiieelldd () noexcept = default; │ │ │ │ bbiittffiieelldd (char const* b, int bits); │ │ │ │ -bbiittffiieelldd (int bits, bool val); │ │ │ │ +explicit bbiittffiieelldd (int bits); │ │ │ │ bbiittffiieelldd (bitfield const& rhs); │ │ │ │ bbiittffiieelldd (bitfield&& rhs) noexcept = default; │ │ │ │ -explicit bbiittffiieelldd (int bits); │ │ │ │ +bbiittffiieelldd () noexcept = default; │ │ │ │ +bbiittffiieelldd (int bits, bool val); │ │ │ │ constructs a new _b_i_t_f_i_e_l_d. The default constructor creates an empty _b_i_t_f_i_e_l_d. │ │ │ │ bits is the size of the _b_i_t_f_i_e_l_d (specified in bits). val is the value to │ │ │ │ initialize the bits to. If not specified all bits are initialized to 0. │ │ │ │ The constructor taking a pointer b and bits copies a _b_i_t_f_i_e_l_d from the │ │ │ │ specified buffer, and bits number of bits (rounded up to the nearest byte │ │ │ │ boundary). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aassssiiggnn(()) ********** │ │ │ │ void aassssiiggnn (char const* b, int const bits); │ │ │ │ copy _b_i_t_f_i_e_l_d from buffer b of bits number of bits, rounded up to the nearest │ │ │ │ byte boundary. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__bbiitt(()) ooppeerraattoorr[[]](()) ********** │ │ │ │ -bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ +********** ooppeerraattoorr[[]](()) ggeett__bbiitt(()) ********** │ │ │ │ bool ooppeerraattoorr[[]] (int index) const noexcept; │ │ │ │ +bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ query bit at index. Returns true if bit is 1, otherwise false. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseett__bbiitt(()) cclleeaarr__bbiitt(()) ********** │ │ │ │ void cclleeaarr__bbiitt (int index) noexcept; │ │ │ │ void sseett__bbiitt (int index) noexcept; │ │ │ │ set bit at index to 0 (clear_bit) or 1 (set_bit). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ @@ -133,115 +234,14 @@ │ │ │ │ ********** ffiinndd__ffiirrsstt__sseett(()) ********** │ │ │ │ int ffiinndd__ffiirrsstt__sseett () const noexcept; │ │ │ │ returns the index of the first set bit in the _b_i_t_f_i_e_l_d, i.e. 1 bit. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiinndd__llaasstt__cclleeaarr(()) ********** │ │ │ │ int ffiinndd__llaasstt__cclleeaarr () const noexcept; │ │ │ │ returns the index to the last cleared bit in the _b_i_t_f_i_e_l_d, i.e. 0 bit. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhaasshheerr ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ -this is a SHA-1 hash class. │ │ │ │ -You use it by first instantiating it, then call update() to feed it with data. │ │ │ │ -i.e. you don't have to keep the entire buffer of which you want to create the │ │ │ │ -hash in memory. You can feed the _h_a_s_h_e_r parts of it at a time. When You have │ │ │ │ -fed the _h_a_s_h_e_r with all the data, you call final() and it will return the sha1- │ │ │ │ -hash of the data. │ │ │ │ -The constructor that takes a char const* and an integer will construct the sha1 │ │ │ │ -context and feed it the data passed in. │ │ │ │ -If you want to reuse the _h_a_s_h_e_r object once you have created a hash, you have │ │ │ │ -to call reset() to reinitialize it. │ │ │ │ -The built-in software version of sha1-algorithm was implemented by Steve Reid │ │ │ │ -and released as public domain. For more info, see src/sha1.cpp. │ │ │ │ -class hasher │ │ │ │ -{ │ │ │ │ - hhaasshheerr (); │ │ │ │ - hhaasshheerr (char const* data, int len); │ │ │ │ - hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ - hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ - hhaasshheerr (hasher&&) noexcept; │ │ │ │ - explicit hhaasshheerr (span data); │ │ │ │ - hhaasshheerr (hasher const&); │ │ │ │ - hasher& uuppddaattee (span data); │ │ │ │ - hasher& uuppddaattee (char const* data, int len); │ │ │ │ - sha1_hash ffiinnaall (); │ │ │ │ - void rreesseett (); │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) hhaasshheerr(()) ********** │ │ │ │ -hhaasshheerr (char const* data, int len); │ │ │ │ -hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ -hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ -hhaasshheerr (hasher&&) noexcept; │ │ │ │ -explicit hhaasshheerr (span data); │ │ │ │ -hhaasshheerr (hasher const&); │ │ │ │ -this is the same as default constructing followed by a call to update(data, │ │ │ │ -len). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** uuppddaattee(()) ********** │ │ │ │ -hasher& uuppddaattee (span data); │ │ │ │ -hasher& uuppddaattee (char const* data, int len); │ │ │ │ -append the following bytes to what is being hashed │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinnaall(()) ********** │ │ │ │ -sha1_hash ffiinnaall (); │ │ │ │ -returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ -_h_a_s_h_e_r constructor. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseett(()) ********** │ │ │ │ -void rreesseett (); │ │ │ │ -restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ -constructed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhaasshheerr225566 ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ -hasher256 computes a SHA-256 message digest. It is the counterpart to hasher │ │ │ │ -(which computes SHA-1) and is used for BitTorrent v2 piece and merkle-tree │ │ │ │ -hashes. It can be fed input incrementally via update() and the digest is │ │ │ │ -produced by final(). Call reset() to reuse the object for another digest. │ │ │ │ -class hasher256 │ │ │ │ -{ │ │ │ │ - hhaasshheerr225566 (); │ │ │ │ - hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ - hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ - explicit hhaasshheerr225566 (span data); │ │ │ │ - hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ - hhaasshheerr225566 (hasher256 const&); │ │ │ │ - hhaasshheerr225566 (char const* data, int len); │ │ │ │ - hasher256& uuppddaattee (char const* data, int len); │ │ │ │ - hasher256& uuppddaattee (span data); │ │ │ │ - sha256_hash ffiinnaall (); │ │ │ │ - void rreesseett (); │ │ │ │ - ~~hhaasshheerr225566 (); │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) hhaasshheerr225566(()) ********** │ │ │ │ -hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ -hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ -explicit hhaasshheerr225566 (span data); │ │ │ │ -hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ -hhaasshheerr225566 (hasher256 const&); │ │ │ │ -hhaasshheerr225566 (char const* data, int len); │ │ │ │ -this is the same as default constructing followed by a call to update(data, │ │ │ │ -len). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** uuppddaattee(()) ********** │ │ │ │ -hasher256& uuppddaattee (char const* data, int len); │ │ │ │ -hasher256& uuppddaattee (span data); │ │ │ │ -append the following bytes to what is being hashed │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinnaall(()) ********** │ │ │ │ -sha256_hash ffiinnaall (); │ │ │ │ -returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ -_h_a_s_h_e_r constructor. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseett(()) ********** │ │ │ │ -void rreesseett (); │ │ │ │ -restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ -constructed. │ │ │ │ _h_o_m_e │ │ │ │ _b_l_o_g │ │ │ │ _u_T_P │ │ │ │ _d_o_w_n_l_o_a_d │ │ │ │ _d_o_c_u_m_e_n_t_a_t_i_o_n │ │ │ │ _D_H_T_ _p_u_t_ _e_x_t_e_n_s_i_o_n │ │ │ │ _p_y_t_h_o_n_ _b_i_n_d_i_n_g_s │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-ed25519.html │ │ │┄ Ordering differences only │ │ │ @@ -84,18 +84,18 @@ │ │ │ │ │ │

    Verifies the signature on the given message using pk

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

    ed25519_add_scalar()

    │ │ │

    Declared in "libtorrent/kademlia/ed25519.hpp"

    │ │ │
    │ │ │ -public_key ed25519_add_scalar (public_key const& pk
    │ │ │ -   , std::array<char, 32> const& scalar);
    │ │ │  secret_key ed25519_add_scalar (secret_key const& sk
    │ │ │     , std::array<char, 32> const& scalar);
    │ │ │ +public_key ed25519_add_scalar (public_key const& pk
    │ │ │ +   , std::array<char, 32> const& scalar);
    │ │ │  
    │ │ │

    Adds a scalar to the given key pair where scalar is a 32 byte buffer │ │ │ (possibly generated with ed25519_create_seed), generating a new key pair.

    │ │ │

    You can calculate the public key sum without knowing the private key and │ │ │ vice versa by passing in null for the key you don't know. This is useful │ │ │ when a third party (an authoritative server for example) needs to enforce │ │ │ randomness on a key pair while only knowing the public key of the other │ │ │ ├── html2text {} │ │ │ │ @@ -39,18 +39,18 @@ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_e_d_2_5_5_1_9_._h_p_p" │ │ │ │ bool eedd2255551199__vveerriiffyy (signature const& sig │ │ │ │ , span msg, public_key const& pk); │ │ │ │ Verifies the signature on the given message using pk │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ eedd2255551199__aadddd__ssccaallaarr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_e_d_2_5_5_1_9_._h_p_p" │ │ │ │ -public_key eedd2255551199__aadddd__ssccaallaarr (public_key const& pk │ │ │ │ - , std::array const& scalar); │ │ │ │ secret_key eedd2255551199__aadddd__ssccaallaarr (secret_key const& sk │ │ │ │ , std::array const& scalar); │ │ │ │ +public_key eedd2255551199__aadddd__ssccaallaarr (public_key const& pk │ │ │ │ + , std::array const& scalar); │ │ │ │ Adds a scalar to the given key pair where scalar is a 32 byte buffer (possibly │ │ │ │ generated withed25519_create_seed), generating a new key pair. │ │ │ │ You can calculate the public key sum without knowing the private key and vice │ │ │ │ versa by passing in null for the key you don't know. This is useful when a │ │ │ │ third party (an authoritative server for example) needs to enforce randomness │ │ │ │ on a key pair while only knowing the public key of the other side. │ │ │ │ Warning: the last bit of the scalar is ignored - if comparing scalars make sure │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference.html │ │ │┄ Ordering differences only │ │ │ @@ -19,219 +19,219 @@ │ │ │ libtorrent logo │ │ │ │ │ │

    │ │ │

    reference documentation

    │ │ │ │ │ │

    single-page version

    │ │ │
    │ │ │ -

    Session

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

    Torrent Info

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

    Core

    │ │ │
    │ │ │ - │ │ │ - │ │ │ │ │ │ │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ │ │ │
    │ │ │ -

    Add Torrent

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

    Torrent Handle

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

    Stats

    │ │ │
    │ │ │ - │ │ │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │ -

    Torrent Status

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

    Trackers

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

    Settings

    │ │ │
    │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Session

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Torrent Info

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Torrent Handle

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Add Torrent

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Torrent Status

    │ │ │ +
    │ │ │ + │ │ │
    │ │ │

    DHT

    │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ │ │ + │ │ │ │ │ │
    │ │ │

    Resume Data

    │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ │ │ + │ │ │ │ │ │
    │ │ │
    │ │ │
    │ │ │ +

    Create Torrents

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Filter

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Bdecoding

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    │ │ │

    Error Codes

    │ │ │
    │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ │ │ │ -
    │ │ │ -

    Filter

    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │
    │ │ │

    Bencoding

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

    Create Torrents

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

    Bdecoding

    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │
    │ │ │
    │ │ │
    │ │ │ -

    Plugins

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

    Storage

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

    PeerClass

    │ │ │ +

    Utility

    │ │ │
    │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │
    │ │ │

    Custom Storage

    │ │ │
    │ │ │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ │ │ │ │ │
    │ │ │ -

    Utility

    │ │ │ +

    PeerClass

    │ │ │
    │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Storage

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    │ │ │ +

    Plugins

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │
    │ │ │

    ed25519

    │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -239,15 +239,14 @@ │ │ │ │ │ │
    │ │ │
    │ │ │
    │ │ │

    Alerts

    │ │ │
    │ │ │ │ │ │ - │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -342,19 +341,20 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ + │ │ │ │ │ │ - │ │ │ │ │ │ + │ │ │
    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │
    │ │ │
    │ │ │ ├── html2text {} │ │ │ │ @@ -1,181 +1,180 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ ************ rreeffeerreennccee ddooccuummeennttaattiioonn ************ │ │ │ │ _s_i_n_g_l_e_-_p_a_g_e_ _v_e_r_s_i_o_n │ │ │ │ -Session │ │ │ │ -_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 │ │ │ │ -_s_e_s_s_i_o_n │ │ │ │ -_s_e_s_s_i_o_n___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_(_) │ │ │ │ -_w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s___b_u_f_(_) │ │ │ │ -Torrent Info │ │ │ │ -_l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s │ │ │ │ -_t_o_r_r_e_n_t___i_n_f_o │ │ │ │ Core │ │ │ │ -_p_e_e_r___i_n_f_o │ │ │ │ -_i_n_f_o___h_a_s_h___t │ │ │ │ _w_e_b___s_e_e_d___e_n_t_r_y │ │ │ │ _p_i_e_c_e___b_l_o_c_k │ │ │ │ +_i_n_f_o___h_a_s_h___t │ │ │ │ _p_e_e_r___r_e_q_u_e_s_t │ │ │ │ -_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_(_) │ │ │ │ +_p_e_e_r___i_n_f_o │ │ │ │ _l_o_a_d___t_o_r_r_e_n_t___b_u_f_f_e_r_(_) │ │ │ │ +_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_(_) │ │ │ │ +_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_(_) │ │ │ │ -_s_o_c_k_e_t___t_y_p_e___t │ │ │ │ _p_r_o_t_o_c_o_l___v_e_r_s_i_o_n │ │ │ │ _p_o_r_t_m_a_p___t_r_a_n_s_p_o_r_t │ │ │ │ _p_o_r_t_m_a_p___p_r_o_t_o_c_o_l │ │ │ │ _e_v_e_n_t___t │ │ │ │ _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 │ │ │ │ +_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 │ │ │ │ -Add Torrent │ │ │ │ -_c_l_i_e_n_t___d_a_t_a___t │ │ │ │ -_a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ -Torrent Handle │ │ │ │ -_b_l_o_c_k___i_n_f_o │ │ │ │ -_p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o │ │ │ │ -_t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ -_h_a_s_h___v_a_l_u_e_(_) │ │ │ │ Stats │ │ │ │ -_c_o_u_n_t_e_r_s │ │ │ │ _s_t_a_t_s___m_e_t_r_i_c │ │ │ │ +_c_o_u_n_t_e_r_s │ │ │ │ _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_) │ │ │ │ _f_i_n_d___m_e_t_r_i_c___i_d_x_(_) │ │ │ │ _m_e_t_r_i_c___t_y_p_e___t │ │ │ │ -Torrent Status │ │ │ │ -_t_o_r_r_e_n_t___s_t_a_t_u_s │ │ │ │ Trackers │ │ │ │ _a_n_n_o_u_n_c_e___i_n_f_o_h_a_s_h │ │ │ │ _a_n_n_o_u_n_c_e___e_n_d_p_o_i_n_t │ │ │ │ _a_n_n_o_u_n_c_e___e_n_t_r_y │ │ │ │ Settings │ │ │ │ _o_v_e_r_v_i_e_w │ │ │ │ _s_e_t_t_i_n_g_s___p_a_c_k │ │ │ │ -_g_e_n_e_r_a_t_e___f_i_n_g_e_r_p_r_i_n_t_(_) │ │ │ │ -_m_i_n___m_e_m_o_r_y___u_s_a_g_e_(_) │ │ │ │ -_h_i_g_h___p_e_r_f_o_r_m_a_n_c_e___s_e_e_d_(_) │ │ │ │ _s_e_t_t_i_n_g___b_y___n_a_m_e_(_) │ │ │ │ _n_a_m_e___f_o_r___s_e_t_t_i_n_g_(_) │ │ │ │ _d_e_f_a_u_l_t___s_e_t_t_i_n_g_s_(_) │ │ │ │ +_h_i_g_h___p_e_r_f_o_r_m_a_n_c_e___s_e_e_d_(_) │ │ │ │ +_m_i_n___m_e_m_o_r_y___u_s_a_g_e_(_) │ │ │ │ +_g_e_n_e_r_a_t_e___f_i_n_g_e_r_p_r_i_n_t_(_) │ │ │ │ +Session │ │ │ │ +_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 │ │ │ │ +_s_e_s_s_i_o_n │ │ │ │ +_s_e_s_s_i_o_n___h_a_n_d_l_e │ │ │ │ +_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_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ +Torrent Info │ │ │ │ +_l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s │ │ │ │ +_t_o_r_r_e_n_t___i_n_f_o │ │ │ │ +Torrent Handle │ │ │ │ +_b_l_o_c_k___i_n_f_o │ │ │ │ +_p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o │ │ │ │ +_t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ +_h_a_s_h___v_a_l_u_e_(_) │ │ │ │ +Add Torrent │ │ │ │ +_a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ +_c_l_i_e_n_t___d_a_t_a___t │ │ │ │ +Torrent Status │ │ │ │ +_t_o_r_r_e_n_t___s_t_a_t_u_s │ │ │ │ DHT │ │ │ │ _d_h_t___s_t_a_t_e │ │ │ │ _d_h_t___s_t_o_r_a_g_e___c_o_u_n_t_e_r_s │ │ │ │ _d_h_t___s_t_o_r_a_g_e___i_n_t_e_r_f_a_c_e │ │ │ │ -_s_i_g_n___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ _d_h_t___d_e_f_a_u_l_t___s_t_o_r_a_g_e___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ +_s_i_g_n___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ _a_n_n_o_u_n_c_e___f_l_a_g_s___t │ │ │ │ Resume Data │ │ │ │ _r_e_a_d___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a___b_u_f_(_) │ │ │ │ _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ -_w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e___b_u_f_(_) │ │ │ │ +_w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ _w_r_i_t_e___t_o_r_r_e_n_t___f_l_a_g_s___t │ │ │ │ +Create Torrents │ │ │ │ +_o_v_e_r_v_i_e_w │ │ │ │ +_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 │ │ │ │ +_l_i_s_t___f_i_l_e_s_(_) │ │ │ │ +_s_e_t___p_i_e_c_e___h_a_s_h_e_s_(_) │ │ │ │ +Filter │ │ │ │ +_i_p___f_i_l_t_e_r │ │ │ │ +_p_o_r_t___f_i_l_t_e_r │ │ │ │ +Bdecoding │ │ │ │ +_b_d_e_c_o_d_e___n_o_d_e │ │ │ │ +_p_r_i_n_t___e_n_t_r_y_(_) │ │ │ │ +_b_d_e_c_o_d_e_(_) │ │ │ │ Error Codes │ │ │ │ _s_t_o_r_a_g_e___e_r_r_o_r │ │ │ │ -_l_i_b_t_o_r_r_e_n_t___c_a_t_e_g_o_r_y_(_) │ │ │ │ -_h_t_t_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ -_g_z_i_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ +_p_c_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ _u_p_n_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ -_i_2_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ _s_o_c_k_s___c_a_t_e_g_o_r_y_(_) │ │ │ │ -_p_c_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ +_g_z_i_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ +_i_2_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ _b_d_e_c_o_d_e___c_a_t_e_g_o_r_y_(_) │ │ │ │ +_l_i_b_t_o_r_r_e_n_t___c_a_t_e_g_o_r_y_(_) │ │ │ │ +_h_t_t_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ +_p_c_p___e_r_r_o_r_s │ │ │ │ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ -_h_t_t_p___e_r_r_o_r_s │ │ │ │ -_e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ +_s_o_c_k_s___e_r_r_o_r___c_o_d_e │ │ │ │ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ _i_2_p___e_r_r_o_r___c_o_d_e │ │ │ │ -_s_o_c_k_s___e_r_r_o_r___c_o_d_e │ │ │ │ -_p_c_p___e_r_r_o_r_s │ │ │ │ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ -Filter │ │ │ │ -_i_p___f_i_l_t_e_r │ │ │ │ -_p_o_r_t___f_i_l_t_e_r │ │ │ │ +_e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ +_h_t_t_p___e_r_r_o_r_s │ │ │ │ Bencoding │ │ │ │ _o_v_e_r_v_i_e_w │ │ │ │ _e_n_t_r_y │ │ │ │ -_o_p_e_r_a_t_o_r_<_<_(_) │ │ │ │ _b_e_n_c_o_d_e_(_) │ │ │ │ -Create Torrents │ │ │ │ -_o_v_e_r_v_i_e_w │ │ │ │ -_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 │ │ │ │ -_l_i_s_t___f_i_l_e_s_(_) │ │ │ │ -_s_e_t___p_i_e_c_e___h_a_s_h_e_s_(_) │ │ │ │ -Bdecoding │ │ │ │ -_b_d_e_c_o_d_e___n_o_d_e │ │ │ │ -_p_r_i_n_t___e_n_t_r_y_(_) │ │ │ │ -_b_d_e_c_o_d_e_(_) │ │ │ │ -Plugins │ │ │ │ -_o_v_e_r_v_i_e_w │ │ │ │ -_p_l_u_g_i_n │ │ │ │ -_t_o_r_r_e_n_t___p_l_u_g_i_n │ │ │ │ -_p_e_e_r___p_l_u_g_i_n │ │ │ │ -_c_r_y_p_t_o___p_l_u_g_i_n │ │ │ │ -_p_e_e_r___c_o_n_n_e_c_t_i_o_n___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 │ │ │ │ -_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_(_) │ │ │ │ -Storage │ │ │ │ -_f_i_l_e___s_l_i_c_e │ │ │ │ -_f_i_l_e___s_t_o_r_a_g_e │ │ │ │ -_r_e_n_a_m_e_d___f_i_l_e_s │ │ │ │ -_f_i_l_e_n_a_m_e_s │ │ │ │ -_s_t_o_r_a_g_e___p_a_r_a_m_s │ │ │ │ -_d_i_s_a_b_l_e_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ -_m_m_a_p___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ -_p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ -_d_e_f_a_u_l_t___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ -_s_t_o_r_a_g_e___m_o_d_e___t │ │ │ │ -_m_o_v_e___f_l_a_g_s___t │ │ │ │ -PeerClass │ │ │ │ -_p_e_e_r___c_l_a_s_s___i_n_f_o │ │ │ │ -_p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r │ │ │ │ +_o_p_e_r_a_t_o_r_<_<_(_) │ │ │ │ +Utility │ │ │ │ +_h_a_s_h_e_r │ │ │ │ +_h_a_s_h_e_r_2_5_6 │ │ │ │ +_b_i_t_f_i_e_l_d │ │ │ │ Custom Storage │ │ │ │ _o_v_e_r_v_i_e_w │ │ │ │ +_s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ _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 │ │ │ │ _s_t_o_r_a_g_e___h_o_l_d_e_r │ │ │ │ _d_i_s_k___o_b_s_e_r_v_e_r │ │ │ │ _b_u_f_f_e_r___a_l_l_o_c_a_t_o_r___i_n_t_e_r_f_a_c_e │ │ │ │ _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r │ │ │ │ _d_i_s_k___b_u_f_f_e_r___r_e_f │ │ │ │ _b_u_l_k___f_r_e_e___b_u_f_f_e_r │ │ │ │ -_s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ _s_t_a_t_u_s___t │ │ │ │ _f_i_l_e___o_p_e_n___m_o_d_e___t │ │ │ │ -Utility │ │ │ │ -_b_i_t_f_i_e_l_d │ │ │ │ -_h_a_s_h_e_r │ │ │ │ -_h_a_s_h_e_r_2_5_6 │ │ │ │ +PeerClass │ │ │ │ +_p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r │ │ │ │ +_p_e_e_r___c_l_a_s_s___i_n_f_o │ │ │ │ +Storage │ │ │ │ +_s_t_o_r_a_g_e___p_a_r_a_m_s │ │ │ │ +_f_i_l_e___s_l_i_c_e │ │ │ │ +_f_i_l_e___s_t_o_r_a_g_e │ │ │ │ +_r_e_n_a_m_e_d___f_i_l_e_s │ │ │ │ +_f_i_l_e_n_a_m_e_s │ │ │ │ +_m_m_a_p___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ +_d_e_f_a_u_l_t___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ +_d_i_s_a_b_l_e_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ +_p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ +_s_t_o_r_a_g_e___m_o_d_e___t │ │ │ │ +_m_o_v_e___f_l_a_g_s___t │ │ │ │ +Plugins │ │ │ │ +_o_v_e_r_v_i_e_w │ │ │ │ +_p_e_e_r___c_o_n_n_e_c_t_i_o_n___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 │ │ │ │ +_p_l_u_g_i_n │ │ │ │ +_t_o_r_r_e_n_t___p_l_u_g_i_n │ │ │ │ +_p_e_e_r___p_l_u_g_i_n │ │ │ │ +_c_r_y_p_t_o___p_l_u_g_i_n │ │ │ │ +_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_(_) │ │ │ │ ed25519 │ │ │ │ _e_d_2_5_5_1_9___c_r_e_a_t_e___s_e_e_d_(_) │ │ │ │ _e_d_2_5_5_1_9___c_r_e_a_t_e___k_e_y_p_a_i_r_(_) │ │ │ │ _e_d_2_5_5_1_9___s_i_g_n_(_) │ │ │ │ _e_d_2_5_5_1_9___v_e_r_i_f_y_(_) │ │ │ │ _e_d_2_5_5_1_9___a_d_d___s_c_a_l_a_r_(_) │ │ │ │ _e_d_2_5_5_1_9___k_e_y___e_x_c_h_a_n_g_e_(_) │ │ │ │ Alerts │ │ │ │ _o_v_e_r_v_i_e_w │ │ │ │ -_a_l_e_r_t │ │ │ │ _d_h_t___r_o_u_t_i_n_g___b_u_c_k_e_t │ │ │ │ _t_o_r_r_e_n_t___a_l_e_r_t │ │ │ │ _p_e_e_r___a_l_e_r_t │ │ │ │ _t_r_a_c_k_e_r___a_l_e_r_t │ │ │ │ _t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t │ │ │ │ _r_e_a_d___p_i_e_c_e___a_l_e_r_t │ │ │ │ _f_i_l_e___c_o_m_p_l_e_t_e_d___a_l_e_r_t │ │ │ │ @@ -270,19 +269,20 @@ │ │ │ │ _p_e_e_r___i_n_f_o___a_l_e_r_t │ │ │ │ _f_i_l_e___p_r_o_g_r_e_s_s___a_l_e_r_t │ │ │ │ _p_i_e_c_e___i_n_f_o___a_l_e_r_t │ │ │ │ _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y___a_l_e_r_t │ │ │ │ _t_r_a_c_k_e_r___l_i_s_t___a_l_e_r_t │ │ │ │ _f_i_l_e___p_r_i_o_r_i_t_i_e_s___a_l_e_r_t │ │ │ │ _f_i_l_e___s_t_a_t_u_s___a_l_e_r_t │ │ │ │ -_a_l_e_r_t___c_a_s_t_(_) │ │ │ │ +_a_l_e_r_t │ │ │ │ _o_p_e_r_a_t_i_o_n___n_a_m_e_(_) │ │ │ │ +_a_l_e_r_t___c_a_s_t_(_) │ │ │ │ _o_p_e_r_a_t_i_o_n___t │ │ │ │ -_a_l_e_r_t___c_a_t_e_g_o_r_y___t │ │ │ │ _i_n_t │ │ │ │ +_a_l_e_r_t___c_a_t_e_g_o_r_y___t │ │ │ │ _h_o_m_e │ │ │ │ _b_l_o_g │ │ │ │ _u_T_P │ │ │ │ _d_o_w_n_l_o_a_d │ │ │ │ _d_o_c_u_m_e_n_t_a_t_i_o_n │ │ │ │ _D_H_T_ _p_u_t_ _e_x_t_e_n_s_i_o_n │ │ │ │ _p_y_t_h_o_n_ _b_i_n_d_i_n_g_s │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ @@ -28,822 +28,822 @@ │ │ │ 2.1.0 │ │ │ │ │ │ │ │ │

    home

    │ │ │
    │ │ │

    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

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

    web_seed_entry

    │ │ │ +

    Declared in "libtorrent/web_seed_entry.hpp"

    │ │ │ +

    the web_seed_entry 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 BEP 17 and BEP 19.

    │ │ │
    │ │ │ -struct storage_error
    │ │ │ +struct web_seed_entry
    │ │ │  {
    │ │ │ -   explicit operator bool () const;
    │ │ │ -   void file (file_index_t f);
    │ │ │ -   file_index_t file () const;
    │ │ │ +   web_seed_entry (web_seed_entry&&) noexcept;
    │ │ │ +   web_seed_entry& operator= (web_seed_entry const&);
    │ │ │ +   web_seed_entry& operator= (web_seed_entry&&) noexcept;
    │ │ │ +   web_seed_entry (web_seed_entry const&);
    │ │ │ +   bool operator== (web_seed_entry const& e) const;
    │ │ │ +   bool operator< (web_seed_entry const& e) const;
    │ │ │  
    │ │ │ -   error_code ec;
    │ │ │ -   operation_t operation;
    │ │ │ +   std::string url;
    │ │ │ +   std::string auth;
    │ │ │ +   headers_t extra_headers;
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -

    bool()

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

    operator==()

    │ │ │
    │ │ │ -explicit operator bool () const;
    │ │ │ +bool operator== (web_seed_entry const& e) const;
    │ │ │  
    │ │ │ -

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

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

    file()

    │ │ │ +

    URL and type comparison

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

    operator<()

    │ │ │
    │ │ │ -void file (file_index_t f);
    │ │ │ -file_index_t file () const;
    │ │ │ +bool operator< (web_seed_entry const& e) 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
    │ │ │ +

    URL and type less-than comparison

    │ │ │ +[report issue]
    │ │ │ +
    url
    │ │ │ +
    The URL of the web seed
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    operation
    │ │ │ -
    A code from operation_t enum, indicating what │ │ │ -kind of operation failed.
    │ │ │ +[report issue]
    │ │ │ +
    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 not forwarded to │ │ │ +the new origin.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │ +
    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.
    │ │ │ +
    │ │ │ +[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"

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

    get the error_category for zip errors

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

    │ │ │ -
    │ │ │ -boost::system::error_category& pcp_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.

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

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/error_code.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0Not an error
    file_collision1Two torrents has files which end up overwriting each other
    failed_hash_check2A piece did not match its piece hash
    torrent_is_no_dict3The .torrent file does not contain a bencoded dictionary at │ │ │ -its top level
    torrent_missing_info4The .torrent file does not have an info dictionary
    torrent_info_no_dict5The .torrent file's info entry is not a dictionary
    torrent_missing_piece_length6The .torrent file does not have a piece length entry
    torrent_missing_name7The .torrent file does not have a name entry
    torrent_invalid_name8The .torrent file's name entry is invalid
    torrent_invalid_length9The length of a file, or of the whole .torrent file is invalid. │ │ │ -Either negative or not an integer
    torrent_file_parse_failed10Failed to parse a file entry in the .torrent
    torrent_missing_pieces11The pieces field is missing or invalid in the .torrent file
    torrent_invalid_hashes12The pieces string has incorrect length
    too_many_pieces_in_torrent13The .torrent file has more pieces than is supported by libtorrent
    invalid_swarm_metadata14The metadata (.torrent file) that was received from the swarm │ │ │ -matched the info-hash, but failed to be parsed
    invalid_bencoding15The file or buffer is not correctly bencoded
    no_files_in_torrent16The .torrent file does not contain any files
    invalid_escaped_string17The string was not properly url-encoded as expected
    session_is_closing18Operation is not permitted since the session is shutting down
    duplicate_torrent19There's already a torrent with that info-hash added to the │ │ │ -session
    invalid_torrent_handle20The supplied torrent_handle is not referring to a valid torrent
    invalid_entry_type21The type requested from the entry did not match its type
    missing_info_hash_in_uri22The specified URI does not contain a valid info-hash
    file_too_short23One of the files in the torrent was unexpectedly small. This │ │ │ -might be caused by files being changed by an external process
    unsupported_url_protocol24The URL used an unknown protocol. Currently http and │ │ │ -https (if built with openssl support) are recognized. For │ │ │ -trackers udp is recognized as well.
    url_parse_error25The URL did not conform to URL syntax and failed to be parsed
    peer_sent_empty_piece26The peer sent a piece message of length 0
    parse_failed27A bencoded structure was corrupt and failed to be parsed
    invalid_file_tag28The fast resume file was missing or had an invalid file version │ │ │ -tag
    missing_info_hash29The fast resume file was missing or had an invalid info-hash
    mismatching_info_hash30The info-hash did not match the torrent
    invalid_hostname31The URL contained an invalid hostname
    invalid_port32The URL had an invalid port
    port_blocked33The port is blocked by the port-filter, and prevented the │ │ │ -connection
    expected_close_bracket_in_address34The IPv6 address was expected to end with "]"
    destructing_torrent35The torrent is being destructed, preventing the operation to │ │ │ -succeed
    timed_out36The connection timed out
    upload_upload_connection37The peer is upload only, and we are upload only. There's no point │ │ │ -in keeping the connection
    uninteresting_upload_peer38The peer is upload only, and we're not interested in it. There's │ │ │ -no point in keeping the connection
    invalid_info_hash39The peer sent an unknown info-hash
    torrent_paused40The torrent is paused, preventing the operation from succeeding
    invalid_have41The peer sent an invalid have message, either wrong size or │ │ │ -referring to a piece that doesn't exist in the torrent
    invalid_bitfield_size42The bitfield message had the incorrect size
    too_many_requests_when_choked43The peer kept requesting pieces after it was choked, possible │ │ │ -abuse attempt.
    invalid_piece44The peer sent a piece message that does not correspond to a │ │ │ -piece request sent by the client
    no_memory45memory allocation failed
    torrent_aborted46The torrent is aborted, preventing the operation to succeed
    self_connection47The peer is a connection to ourself, no point in keeping it
    invalid_piece_size48The peer sent a piece message with invalid size, either negative │ │ │ -or greater than one block
    timed_out_no_interest49The peer has not been interesting or interested in us for too │ │ │ -long, no point in keeping it around
    timed_out_inactivity50The peer has not said anything in a long time, possibly dead
    timed_out_no_handshake51The peer did not send a handshake within a reasonable amount of │ │ │ -time, it might not be a bittorrent peer
    timed_out_no_request52The peer has been unchoked for too long without requesting any │ │ │ -data. It might be lying about its interest in us
    invalid_choke53The peer sent an invalid choke message
    invalid_unchoke54The peer send an invalid unchoke message
    invalid_interested55The peer sent an invalid interested message
    invalid_not_interested56The peer sent an invalid not-interested message
    invalid_request57The peer sent an invalid piece request message
    invalid_hash_list58The peer sent an invalid hash-list message (this is part of the │ │ │ -merkle-torrent extension)
    invalid_hash_piece59The peer sent an invalid hash-piece message (this is part of the │ │ │ -merkle-torrent extension)
    invalid_cancel60The peer sent an invalid cancel message
    invalid_dht_port61The peer sent an invalid DHT port-message
    invalid_suggest62The peer sent an invalid suggest piece-message
    invalid_have_all63The peer sent an invalid have all-message
    invalid_have_none64The peer sent an invalid have none-message
    invalid_reject65The peer sent an invalid reject message
    invalid_allow_fast66The peer sent an invalid allow fast-message
    invalid_extended67The peer sent an invalid extension message ID
    invalid_message68The peer sent an invalid message ID
    sync_hash_not_found69The synchronization hash was not found in the encrypted handshake
    invalid_encryption_constant70The encryption constant in the handshake is invalid
    no_plaintext_mode71The peer does not support plain text, which is the selected mode
    no_rc4_mode72The peer does not support RC4, which is the selected mode
    unsupported_encryption_mode73The peer does not support any of the encryption modes that the │ │ │ -client supports
    unsupported_encryption_mode_selected74The peer selected an encryption mode that the client did not │ │ │ -advertise and does not support
    invalid_pad_size75The pad size used in the encryption handshake is of invalid size
    invalid_encrypt_handshake76The encryption handshake is invalid
    no_incoming_encrypted77The client is set to not support incoming encrypted connections │ │ │ -and this is an encrypted connection
    no_incoming_regular78The client is set to not support incoming regular bittorrent │ │ │ -connections, and this is a regular connection
    duplicate_peer_id79The client is already connected to this peer-ID
    torrent_removed80Torrent was removed
    packet_too_large81The packet size exceeded the upper sanity check-limit
    reserved82 
    http_error83The web server responded with an error
    missing_location84The web server response is missing a location header
    invalid_redirection85The web seed redirected to a path that no longer matches the │ │ │ -.torrent directory structure
    redirecting86The connection was closed because it redirected to a different │ │ │ -URL
    invalid_range87The HTTP range header is invalid
    no_content_length88The HTTP response did not have a content length
    banned_by_ip_filter89The IP is blocked by the IP filter
    too_many_connections90At the connection limit
    peer_banned91The peer is marked as banned
    stopping_torrent92The torrent is stopping, causing the operation to fail
    too_many_corrupt_pieces93The peer has sent too many corrupt pieces and is banned
    torrent_not_ready94The torrent is not ready to receive peers
    peer_not_constructed95The peer is not completely constructed yet
    session_closing96The session is closing, causing the operation to fail
    optimistic_disconnect97The peer was disconnected in order to leave room for a │ │ │ -potentially better peer
    torrent_finished98The torrent is finished
    no_router99No UPnP router found
    metadata_too_large100The metadata message says the metadata exceeds the limit
    invalid_metadata_request101The peer sent an invalid metadata request message
    invalid_metadata_size102The peer advertised an invalid metadata size
    invalid_metadata_offset103The peer sent a message with an invalid metadata offset
    invalid_metadata_message104The peer sent an invalid metadata message
    pex_message_too_large105The peer sent a peer exchange message that was too large
    invalid_pex_message106The peer sent an invalid peer exchange message
    invalid_lt_tracker_message107The peer sent an invalid tracker exchange message
    too_frequent_pex108The peer sent an pex messages too often. This is a possible │ │ │ -attempt of and attack
    no_metadata109The operation failed because it requires the torrent to have │ │ │ -the metadata (.torrent file) and it doesn't have it yet. │ │ │ -This happens for magnet links before they have downloaded the │ │ │ -metadata, and also torrents added by URL.
    invalid_dont_have110The peer sent an invalid dont_have message. The don't have │ │ │ -message is an extension to allow peers to advertise that the │ │ │ -no longer has a piece they previously had.
    requires_ssl_connection111The peer tried to connect to an SSL torrent without connecting │ │ │ -over SSL.
    invalid_ssl_cert112The peer tried to connect to a torrent with a certificate │ │ │ -for a different torrent.
    not_an_ssl_torrent113the torrent is not an SSL torrent, and the operation requires │ │ │ -an SSL torrent
    banned_by_port_filter114peer was banned because its listen port is within a banned port │ │ │ -range, as specified by the port_filter.
    invalid_session_handle115The session_handle is not referring to a valid session_impl
    invalid_listen_socket116the listen socket associated with this request was closed
    invalid_hash_request117 
    invalid_hashes118 
    invalid_hash_reject119 
    deprecated_120120 
    deprecated_121121 
    deprecated_122122 
    deprecated_123123 
    deprecated_124124 
    missing_file_sizes130The resume data file is missing the file sizes entry
    no_files_in_resume_data131The resume data file file sizes entry is empty
    missing_pieces132The resume data file is missing the pieces and slots entry
    mismatching_number_of_files133The number of files in the resume data does not match the number │ │ │ -of files in the torrent
    mismatching_file_size134One of the files on disk has a different size than in the fast │ │ │ -resume file
    mismatching_file_timestamp135One of the files on disk has a different timestamp than in the │ │ │ -fast resume file
    not_a_dictionary136The resume data file is not a dictionary
    invalid_blocks_per_piece137The blocks per piece entry is invalid in the resume data file
    missing_slots138The resume file is missing the slots entry, which is required │ │ │ -for torrents with compact allocation. DEPRECATED
    too_many_slots139The resume file contains more slots than the torrent
    invalid_slot_list140The slot entry is invalid in the resume data
    invalid_piece_index141One index in the slot list is invalid
    pieces_need_reorder142The pieces on disk needs to be re-ordered for the specified │ │ │ -allocation mode. This happens if you specify sparse allocation │ │ │ -and the files on disk are using compact storage. The pieces needs │ │ │ -to be moved to their right position. DEPRECATED
    resume_data_not_modified143this error is returned when asking to save resume data and │ │ │ -specifying the flag to only save when there's anything new to save │ │ │ -(torrent_handle::only_if_modified) and there wasn't anything changed.
    invalid_save_path144the save_path in add_torrent_params is not valid
    too_many_duplicate_filenames145The torrent contained too many duplicate filenames, exceeding the │ │ │ -configured limit.
    http_parse_error150The HTTP header was not correctly formatted
    http_missing_location151The HTTP response was in the 300-399 range but lacked a location │ │ │ -header
    http_failed_decompress152The HTTP response was encoded with gzip or deflate but │ │ │ -decompressing it failed
    no_i2p_router160The URL specified an i2p address, but no i2p router is configured
    no_i2p_endpoint161i2p acceptor is not available yet, can't announce without endpoint
    scrape_not_available170The tracker URL doesn't support transforming it into a scrape │ │ │ -URL. i.e. it doesn't contain "announce.
    invalid_tracker_response171invalid tracker response
    invalid_peer_dict172invalid peer dictionary entry. Not a dictionary
    tracker_failure173tracker sent a failure message
    invalid_files_entry174missing or invalid files entry
    invalid_hash_entry175missing or invalid hash entry
    invalid_peers_entry176missing or invalid peers and peers6 entry
    invalid_tracker_response_length177UDP tracker response packet has invalid size
    invalid_tracker_transaction_id178invalid transaction id in UDP tracker response
    invalid_tracker_action179invalid action field in UDP tracker response
    announce_skipped180skipped announce (because it's assumed to be unreachable over the │ │ │ -given source network interface)
    no_entropy200random number generation failed
    ssrf_mitigation201blocked by SSRF mitigation
    blocked_by_idna202blocked because IDNA host names are banned
    torrent_unknown_version210the torrent file has an unknown meta version
    torrent_missing_file_tree211the v2 torrent file has no file tree
    torrent_missing_meta_version212the torrent contains v2 keys but does not specify meta version 2
    torrent_inconsistent_files213the v1 and v2 file metadata does not match
    torrent_missing_piece_layer214one or more files are missing piece layer hashes
    torrent_invalid_piece_layer215a piece layer has the wrong size or failed hash check
    torrent_missing_pieces_root216a v2 file entry has no root hash
    torrent_inconsistent_hashes217the v1 and v2 hashes do not describe the same data
    torrent_invalid_pad_file218a file in the v2 metadata has the pad attribute set
    torrent_directory_too_deep219the directory structure of files in the torrent exceeds the │ │ │ -configured maximum depth (see load_torrent_limits)
    error_code_max220the number of error codes
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum http_errors

    │ │ │ -

    Declared in "libtorrent/error_code.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    cont100 
    ok200 
    created201 
    accepted202 
    no_content204 
    multiple_choices300 
    moved_permanently301 
    moved_temporarily302 
    not_modified304 
    bad_request400 
    unauthorized401 
    forbidden403 
    not_found404 
    internal_server_error500 
    not_implemented501 
    bad_gateway502 
    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
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    session_params

    │ │ │ -

    Declared in "libtorrent/session_params.hpp"

    │ │ │ -

    The session_params is a parameters pack for configuring the session │ │ │ -before it's started.

    │ │ │ +
    │ │ │ +

    piece_block

    │ │ │ +

    Declared in "libtorrent/piece_block.hpp"

    │ │ │ +

    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 session_params
    │ │ │ +struct piece_block
    │ │ │  {
    │ │ │ -   session_params ();
    │ │ │ -   session_params (settings_pack const& sp);
    │ │ │ -   session_params (settings_pack&& sp);
    │ │ │ -   session_params (settings_pack&& sp
    │ │ │ -      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ -   session_params (settings_pack const& sp
    │ │ │ -      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ +   piece_block (piece_index_t p_index, int b_index);
    │ │ │ +   piece_block () = default;
    │ │ │ +   bool operator< (piece_block const& b) const;
    │ │ │ +   bool operator== (piece_block const& b) const;
    │ │ │ +   bool operator!= (piece_block const& b) const;
    │ │ │  
    │ │ │ -   settings_pack settings;
    │ │ │ -   session_flags_t flags {};
    │ │ │ -   std::vector<std::shared_ptr<plugin>> extensions;
    │ │ │ -   dht::dht_state dht_state;
    │ │ │ -   dht::dht_storage_constructor_type dht_storage_constructor;
    │ │ │ -   disk_io_constructor_type disk_io_constructor;
    │ │ │ -   std::map<std::string, std::string> ext_state;
    │ │ │ -   libtorrent::ip_filter ip_filter;
    │ │ │ +   static const piece_block invalid;
    │ │ │ +   piece_index_t piece_index {0};
    │ │ │ +   int block_index  = 0;
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -

    session_params()

    │ │ │ -
    │ │ │ -session_params ();
    │ │ │ -session_params (settings_pack const& sp);
    │ │ │ -session_params (settings_pack&& sp);
    │ │ │ -
    │ │ │ -

    This constructor can be used to start with the default plugins │ │ │ -(ut_metadata, ut_pex and smart_ban). Pass a settings_pack to set the │ │ │ -initial settings when the session starts.

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

    session_params()

    │ │ │ -
    │ │ │ -session_params (settings_pack&& sp
    │ │ │ -      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ -session_params (settings_pack const& sp
    │ │ │ -      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ -
    │ │ │ -

    This constructor helps to configure the set of initial plugins │ │ │ -to be added to the session before it's started.

    │ │ │ -[report issue]
    │ │ │ -
    settings
    │ │ │ -
    The settings to configure the session with
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flags
    │ │ │ -
    specifies flags affecting the session construction. E.g. they can be used │ │ │ -to start a session in paused mode (by passing in session::paused).
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    extensions
    │ │ │ -
    the plugins to add to the session as it is constructed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    dht_state
    │ │ │ -
    DHT node ID and node addresses to bootstrap the DHT with.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    dht_storage_constructor
    │ │ │ -
    function object to construct the storage object for DHT items.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    disk_io_constructor
    │ │ │ -

    function object to create the disk I/O subsystem. Defaults to │ │ │ -default_disk_io_constructor, which is implied by leaving the field default │ │ │ -initialized. Built-in options are:

    │ │ │ -
      │ │ │ -
    • mmap_disk_io_constructor. Multi-threaded disk I/O using memory mapped files
    • │ │ │ -
    • posix_disk_io_constructor. Single-threaded simple portable disk I/O
    • │ │ │ -
    • │ │ │ -
      disabled_disk_io_constructor. Throws away all data and reads garbage.
      │ │ │ -
      Useful for testing and benchmarking.
      │ │ │ -
      │ │ │ -
    • │ │ │ -
    • pread_disk_io_constructor (experimental). Multi-threaded disk I/O │ │ │ -using preadv/pwritev with a write cache.
    • │ │ │ -
    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    ext_state
    │ │ │ -
    this container can be used by extensions/plugins to store settings. It's │ │ │ -primarily here to make it convenient to save and restore state across │ │ │ -sessions, using read_session_params() and write_session_params().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    ip_filter
    │ │ │ -
    the IP filter to use for the session. This restricts which peers are allowed │ │ │ -to connect. As if passed to set_ip_filter().
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    invalid piece_index block_index
    │ │ │ +
    sentinel value representing "no block". Compares unequal to any │ │ │ +real block.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    session_proxy

    │ │ │ -

    Declared in "libtorrent/session.hpp"

    │ │ │ -

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

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

    operator=() session_proxy() ~session_proxy()

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

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

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

    info_hash_t

    │ │ │ +

    Declared in "libtorrent/info_hash.hpp"

    │ │ │ +

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

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

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

    │ │ │
    │ │ │ -
    │ │ │ -

    session

    │ │ │ -

    Declared in "libtorrent/session.hpp"

    │ │ │ -

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

    │ │ │ -

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

    │ │ │ -

    see apply_settings().

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

    session()

    │ │ │ -
    │ │ │ -session ();
    │ │ │ -explicit session (session_params&& params);
    │ │ │ -explicit session (session_params const& params);
    │ │ │ -
    │ │ │ -

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

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

    session()

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

    info_hash_t()

    │ │ │
    │ │ │ -session (session_params&& params, io_context& ios);
    │ │ │ -session (session_params const& params, io_context& ios);
    │ │ │ +info_hash_t () noexcept = default;
    │ │ │ +explicit info_hash_t (sha256_hash h2) noexcept;
    │ │ │ +info_hash_t (sha1_hash h1, sha256_hash h2) noexcept;
    │ │ │ +explicit info_hash_t (sha1_hash h1) noexcept;
    │ │ │  
    │ │ │ -

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

    │ │ │ -
    │ │ │ -

    Warning

    │ │ │ -

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

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

    ~session()

    │ │ │ +

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

    │ │ │ +

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

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

    has_v1() has() has_v2()

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

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

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

    abort()

    │ │ │ +

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

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

    get()

    │ │ │
    │ │ │ -session_proxy abort ();
    │ │ │ +sha1_hash get (protocol_version v) const;
    │ │ │  
    │ │ │ -

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

    │ │ │ +

    returns the has for the specified protocol version

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

    get_best()

    │ │ │
    │ │ │ -struct session_proxy {};
    │ │ │ +sha1_hash get_best () const;
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ +

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

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

    session_handle

    │ │ │ -

    Declared in "libtorrent/session_handle.hpp"

    │ │ │ -

    this class provides a non-owning handle to a session and a subset of the │ │ │ -interface of the session class. If the underlying session is destructed │ │ │ -any handle to it will no longer be valid. is_valid() will return false and │ │ │ -any operation on it will throw a system_error exception, with error code │ │ │ -invalid_session_handle.

    │ │ │ +
    │ │ │ +

    peer_request

    │ │ │ +

    Declared in "libtorrent/peer_request.hpp"

    │ │ │ +

    represents a byte range within a piece. Internally this is is used for │ │ │ +incoming piece requests.

    │ │ │
    │ │ │ -struct session_handle
    │ │ │ +struct peer_request
    │ │ │  {
    │ │ │ -   bool is_valid () const;
    │ │ │ -   session_params session_state (save_state_flags_t flags = save_state_flags_t::all()) const;
    │ │ │ -   void refresh_torrent_status (std::vector<torrent_status>* ret
    │ │ │ -      , status_flags_t flags = {}) const;
    │ │ │ -   std::vector<torrent_status> get_torrent_status (
    │ │ │ -      std::function<bool(torrent_status const&)> const& pred
    │ │ │ -      , status_flags_t flags = {}) const;
    │ │ │ -   void post_torrent_updates (status_flags_t flags = status_flags_t::all());
    │ │ │ -   void post_session_stats ();
    │ │ │ -   void post_dht_stats ();
    │ │ │ -   void set_dht_state (dht::dht_state&& st);
    │ │ │ -   void set_dht_state (dht::dht_state const& st);
    │ │ │ -   std::vector<torrent_handle> get_torrents () const;
    │ │ │ -   torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │ -   torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │ -   torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │ -   torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ -   torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │ -   void async_add_torrent (add_torrent_params&& params);
    │ │ │ -   void async_add_torrent (add_torrent_params const& params);
    │ │ │ -   torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │ -   void pause ();
    │ │ │ -   void resume ();
    │ │ │ -   bool is_paused () const;
    │ │ │ -   bool is_dht_running () const;
    │ │ │ -   void set_dht_storage (dht::dht_storage_constructor_type sc);
    │ │ │ -   void add_dht_node (std::pair<std::string, int> const& node);
    │ │ │ -   void dht_get_item (sha1_hash const& target);
    │ │ │ -   void dht_get_item (std::array<char, 32> key
    │ │ │ -      , std::string salt = std::string());
    │ │ │ -   sha1_hash dht_put_item (entry data);
    │ │ │ -   void dht_put_item (std::array<char, 32> key
    │ │ │ -      , std::function<void(entry&, std::array<char, 64>&
    │ │ │ -      , std::int64_t&, std::string const&)> cb
    │ │ │ -      , std::string salt = std::string());
    │ │ │ -   void dht_get_peers (sha1_hash const& info_hash);
    │ │ │ -   void dht_announce (sha1_hash const& info_hash, int port = 0, dht::announce_flags_t flags = {});
    │ │ │ -   void dht_live_nodes (sha1_hash const& nid);
    │ │ │ -   void dht_sample_infohashes (udp::endpoint const& ep, sha1_hash const& target);
    │ │ │ -   void dht_direct_request (udp::endpoint const& ep, entry const& e, client_data_t userdata = {});
    │ │ │ -   void add_extension (std::function<std::shared_ptr<torrent_plugin>(
    │ │ │ -      torrent_handle const&, client_data_t)> ext);
    │ │ │ -   void add_extension (std::shared_ptr<plugin> ext);
    │ │ │ -   ip_filter get_ip_filter () const;
    │ │ │ -   void set_ip_filter (ip_filter f);
    │ │ │ -   void set_port_filter (port_filter const& f);
    │ │ │ -   bool is_listening () const;
    │ │ │ -   unsigned short listen_port () const;
    │ │ │ -   unsigned short ssl_listen_port () const;
    │ │ │ -   void set_peer_class_filter (ip_filter const& f);
    │ │ │ -   ip_filter get_peer_class_filter () const;
    │ │ │ -   peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │ -   void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │ -   peer_class_t create_peer_class (char const* name);
    │ │ │ -   void delete_peer_class (peer_class_t cid);
    │ │ │ -   void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │ -   peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │ -   void remove_torrent (const torrent_handle&, remove_flags_t = {});
    │ │ │ -   void apply_settings (settings_pack&&);
    │ │ │ -   settings_pack get_settings () const;
    │ │ │ -   void apply_settings (settings_pack const&);
    │ │ │ -   bool wait_for_alert (time_duration max_wait);
    │ │ │ -   void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ -   void set_alert_notify (std::function<void()> const& fun);
    │ │ │ -   void delete_port_mapping (port_mapping_t handle);
    │ │ │ -   std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │ -   void reopen_network_sockets (reopen_network_flags_t options = reopen_map_ports);
    │ │ │ -   std::shared_ptr<aux::session_impl> native_handle () const;
    │ │ │ +   bool operator== (peer_request const& r) const;
    │ │ │  
    │ │ │ -   static inline constexpr save_state_flags_t save_settings  = 0_bit;
    │ │ │ -   static inline constexpr save_state_flags_t save_dht_state  = 2_bit;
    │ │ │ -   static inline constexpr save_state_flags_t save_extension_state  = 11_bit;
    │ │ │ -   static inline constexpr save_state_flags_t save_ip_filter  = 12_bit;
    │ │ │ -   static inline constexpr peer_class_t global_peer_class_id {0};
    │ │ │ -   static inline constexpr peer_class_t tcp_peer_class_id {1};
    │ │ │ -   static inline constexpr peer_class_t local_peer_class_id {2};
    │ │ │ -   static inline constexpr remove_flags_t delete_files  = 0_bit;
    │ │ │ -   static inline constexpr remove_flags_t delete_partfile  = 1_bit;
    │ │ │ -   static inline constexpr session_flags_t paused  = 2_bit;
    │ │ │ -   static constexpr portmap_protocol udp  = portmap_protocol::udp;
    │ │ │ -   static constexpr portmap_protocol tcp  = portmap_protocol::tcp;
    │ │ │ -   static inline constexpr reopen_network_flags_t reopen_map_ports  = 0_bit;
    │ │ │ +   piece_index_t piece;
    │ │ │ +   int start;
    │ │ │ +   int length;
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -

    is_valid()

    │ │ │ -
    │ │ │ -bool is_valid () const;
    │ │ │ -
    │ │ │ -

    returns true if this handle refers to a valid session object. If the │ │ │ -session has been destroyed, all session_handle objects will expire and │ │ │ -not be valid.

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

    session_state()

    │ │ │ -
    │ │ │ -session_params session_state (save_state_flags_t flags = save_state_flags_t::all()) const;
    │ │ │ -
    │ │ │ -

    returns the current session state. This can be passed to │ │ │ -write_session_params() to save the state to disk and restored using │ │ │ -read_session_params() when constructing a new session. 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 │ │ │ -session state

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

    get_torrent_status() refresh_torrent_status()

    │ │ │ -
    │ │ │ -void refresh_torrent_status (std::vector<torrent_status>* ret
    │ │ │ -      , status_flags_t flags = {}) const;
    │ │ │ -std::vector<torrent_status> get_torrent_status (
    │ │ │ -      std::function<bool(torrent_status const&)> const& pred
    │ │ │ -      , status_flags_t flags = {}) const;
    │ │ │ -
    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    these calls are potentially expensive and won't scale well with │ │ │ -lots of torrents. If you're concerned about performance, consider │ │ │ -using post_torrent_updates() instead.

    │ │ │ -
    │ │ │ -

    get_torrent_status returns a vector of the torrent_status for │ │ │ -every torrent which satisfies pred, which is a predicate function │ │ │ -which determines if a torrent should be included in the returned set │ │ │ -or not. Returning true means it should be included and false means │ │ │ -excluded. The flags argument is the same as to │ │ │ -torrent_handle::status(). Since pred is guaranteed to be │ │ │ -called for every torrent, it may be used to count the number of │ │ │ -torrents of different categories as well.

    │ │ │ -

    refresh_torrent_status takes a vector of torrent_status structs │ │ │ -(for instance the same vector that was returned by │ │ │ -get_torrent_status() ) and refreshes the status based on the │ │ │ -handle member. It is possible to use this function by first │ │ │ -setting up a vector of default constructed torrent_status objects, │ │ │ -only initializing the handle member, in order to request the │ │ │ -torrent status for multiple torrents in a single call. This can save a │ │ │ -significant amount of time if you have a lot of torrents.

    │ │ │ -

    Any torrent_status object whose handle member is not referring to │ │ │ -a valid torrent are ignored.

    │ │ │ -

    The intended use of these functions is to start off by calling │ │ │ -get_torrent_status() to get a list of all torrents that match your │ │ │ -criteria. Then call refresh_torrent_status() on that list. This │ │ │ -will only refresh the status for the torrents in your list, and thus │ │ │ -ignore all other torrents you might be running. This may save a │ │ │ -significant amount of time, especially if the number of torrents you're │ │ │ -interested in is small. In order to keep your list of interested │ │ │ -torrents up to date, you can either call get_torrent_status() from │ │ │ -time to time, to include torrents you might have become interested in │ │ │ -since the last time. In order to stop refreshing a certain torrent, │ │ │ -simply remove it from the list.

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

    post_torrent_updates()

    │ │ │ -
    │ │ │ -void post_torrent_updates (status_flags_t flags = status_flags_t::all());
    │ │ │ -
    │ │ │ -

    This functions instructs the session to post the state_update_alert, │ │ │ -containing the status of all torrents whose state changed since the │ │ │ -last time this function was called.

    │ │ │ -

    Only torrents who have the state subscription flag set will be │ │ │ -included. This flag is on by default. See add_torrent_params. │ │ │ -the flags argument is the same as for torrent_handle::status(). │ │ │ -see status_flags_t in torrent_handle.

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

    post_session_stats()

    │ │ │ -
    │ │ │ -void post_session_stats ();
    │ │ │ -
    │ │ │ -

    This function will post a session_stats_alert object, containing a │ │ │ -snapshot of the performance counters from the internals of libtorrent. │ │ │ -To interpret these counters, query the session via │ │ │ -session_stats_metrics().

    │ │ │ -

    For more information, see the session statistics section.

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

    post_dht_stats()

    │ │ │ -
    │ │ │ -void post_dht_stats ();
    │ │ │ -
    │ │ │ -

    This will cause a dht_stats_alert to be posted.

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

    set_dht_state()

    │ │ │ -
    │ │ │ -void set_dht_state (dht::dht_state&& st);
    │ │ │ -void set_dht_state (dht::dht_state const& st);
    │ │ │ -
    │ │ │ -

    set the DHT state for the session. This will be taken into account the │ │ │ -next time the DHT is started, as if it had been passed in via the │ │ │ -session_params on startup.

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

    get_torrents() find_torrent()

    │ │ │ -
    │ │ │ -std::vector<torrent_handle> get_torrents () const;
    │ │ │ -torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │ -torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │ -
    │ │ │ -

    find_torrent() looks for a torrent with the given info-hash. In │ │ │ -case there is such a torrent in the session, a torrent_handle to that │ │ │ -torrent is returned. In case the torrent cannot be found, an invalid │ │ │ -torrent_handle 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 session.

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

    add_torrent() async_add_torrent()

    │ │ │ -
    │ │ │ -torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │ -torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ -torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │ -void async_add_torrent (add_torrent_params&& params);
    │ │ │ -void async_add_torrent (add_torrent_params const& params);
    │ │ │ -torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │ -
    │ │ │ -

    You add torrents through the add_torrent() function where you give an │ │ │ -object with all the parameters. The add_torrent() overloads will block │ │ │ -until the torrent has been added (or failed to be added) and returns │ │ │ -an error code and a torrent_handle. In order to add torrents more │ │ │ -efficiently, consider using async_add_torrent() which returns │ │ │ -immediately, without waiting for the torrent to add. Notification of │ │ │ -the torrent being added is sent as add_torrent_alert.

    │ │ │ -

    The save_path field in add_torrent_params must be set to a valid │ │ │ -path where the files for the torrent will be saved. Even when using a │ │ │ -custom storage, this needs to be set to something. If the save_path │ │ │ -is empty, the call to add_torrent() will throw a system_error │ │ │ -exception.

    │ │ │ -

    The overload that does not take an error_code throws an exception on │ │ │ -error and is not available when building without exception support. │ │ │ -The torrent_handle returned by add_torrent() can be used to retrieve │ │ │ -information about the torrent's progress, its peers etc. It is also │ │ │ -used to abort a torrent.

    │ │ │ -

    If the torrent you are trying to add already exists in the session (is │ │ │ -either queued for checking, being checked or downloading) │ │ │ -add_torrent() will throw system_error which derives from │ │ │ -std::exception unless duplicate_is_error is set to false. In that │ │ │ -case, add_torrent() will return the handle to the existing torrent.

    │ │ │ -

    The add_torrent_params class has a flags field. It can be used to │ │ │ -control what state the new torrent will be added in. Common flags to │ │ │ -want to control are torrent_flags::paused and │ │ │ -torrent_flags::auto_managed. In order to add a magnet link that will │ │ │ -just download the metadata, but no payload, set the │ │ │ -torrent_flags::upload_mode flag.

    │ │ │ -

    Special consideration has to be taken when adding hybrid torrents │ │ │ -(i.e. torrents that are BitTorrent v2 torrents that are backwards │ │ │ -compatible with v1). For more details, see BitTorrent v2 torrents.

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

    resume() is_paused() pause()

    │ │ │ -
    │ │ │ -void pause ();
    │ │ │ -void resume ();
    │ │ │ -bool is_paused () const;
    │ │ │ -
    │ │ │ -

    Pausing the session 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 session pause state is separate from the torrent pause │ │ │ -state. A torrent is inactive if it is paused or if the session is │ │ │ -paused. is_paused() returns true if the session is currently │ │ │ -paused.

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

    is_dht_running()

    │ │ │ -
    │ │ │ -bool is_dht_running () const;
    │ │ │ -
    │ │ │ -

    is_dht_running() returns true if the DHT support has been started │ │ │ -and false otherwise.

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

    set_dht_storage()

    │ │ │ -
    │ │ │ -void set_dht_storage (dht::dht_storage_constructor_type sc);
    │ │ │ -
    │ │ │ -

    set_dht_storage set a dht custom storage constructor function │ │ │ -to be used internally when the dht is created.

    │ │ │ -

    Since the dht storage is a critical component for the dht behavior, │ │ │ -this function will only be effective the next time the dht is started. │ │ │ -If you never touch this feature, a default map-memory based storage │ │ │ -is used.

    │ │ │ -

    If you want to make sure the dht is initially created with your │ │ │ -custom storage, create a session with the setting │ │ │ -settings_pack::enable_dht to false, set your constructor function │ │ │ -and call apply_settings with settings_pack::enable_dht to true.

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

    add_dht_node()

    │ │ │ -
    │ │ │ -void add_dht_node (std::pair<std::string, int> const& node);
    │ │ │ -
    │ │ │ -

    add_dht_node takes a host name and port pair. That endpoint will be │ │ │ -pinged, and if a valid DHT reply is received, the node will be added to │ │ │ -the routing table.

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

    dht_get_item()

    │ │ │ -
    │ │ │ -void dht_get_item (sha1_hash const& target);
    │ │ │ -
    │ │ │ -

    query the DHT for an immutable item at the target hash. │ │ │ -the result is posted as a dht_immutable_item_alert.

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

    dht_get_item()

    │ │ │ -
    │ │ │ -void dht_get_item (std::array<char, 32> key
    │ │ │ -      , std::string salt = std::string());
    │ │ │ -
    │ │ │ -

    query the DHT for a mutable item under the public key key. │ │ │ -this is an ed25519 key. salt is optional and may be left │ │ │ -as an empty string if no salt is to be used. │ │ │ -if the item is found in the DHT, a dht_mutable_item_alert is │ │ │ -posted.

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

    dht_put_item()

    │ │ │ -
    │ │ │ -sha1_hash dht_put_item (entry data);
    │ │ │ -
    │ │ │ -

    store the given bencoded data as an immutable item in the DHT. │ │ │ -the returned hash is the key that is to be used to look the item │ │ │ -up again. It's just the SHA-1 hash of the bencoded form of the │ │ │ -structure.

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

    dht_put_item()

    │ │ │ -
    │ │ │ -void dht_put_item (std::array<char, 32> key
    │ │ │ -      , std::function<void(entry&, std::array<char, 64>&
    │ │ │ -      , std::int64_t&, std::string const&)> cb
    │ │ │ -      , std::string salt = std::string());
    │ │ │ -
    │ │ │ -

    store a mutable item. The key is the public key the blob is │ │ │ -to be stored under. The optional salt argument is a string that │ │ │ -is to be mixed in with the key when determining where in the DHT │ │ │ -the value is to be stored. The callback function is called from within │ │ │ -the libtorrent network thread once we've found where to store the blob, │ │ │ -possibly with the current value stored under the key. │ │ │ -The values passed to the callback functions are:

    │ │ │ -
    │ │ │ -
    entry& value
    │ │ │ -
    the current value stored under the key (may be empty). Also expected │ │ │ -to be set to the value to be stored by the function.
    │ │ │ -
    std::array<char,64>& signature
    │ │ │ -
    the signature authenticating the current value. This may be zeros │ │ │ -if there is currently no value stored. The function is expected to │ │ │ -fill in this buffer with the signature of the new value to store. │ │ │ -To generate the signature, you may want to use the │ │ │ -sign_mutable_item function.
    │ │ │ -
    std::int64_t& seq
    │ │ │ -
    current sequence number. May be zero if there is no current value. │ │ │ -The function is expected to set this to the new sequence number of │ │ │ -the value that is to be stored. Sequence numbers must be monotonically │ │ │ -increasing. Attempting to overwrite a value with a lower or equal │ │ │ -sequence number will fail, even if the signature is correct.
    │ │ │ -
    std::string const& salt
    │ │ │ -
    this is the salt that was used for this put call.
    │ │ │ -
    │ │ │ -

    Since the callback function cb is called from within libtorrent, │ │ │ -it is critical to not perform any blocking operations. Ideally not │ │ │ -even locking a mutex. Pass any data required for this function along │ │ │ -with the function object's context and make the function entirely │ │ │ -self-contained. The only reason data blob's value is computed │ │ │ -via a function instead of just passing in the new value is to avoid │ │ │ -race conditions. If you want to update the value in the DHT, you │ │ │ -must first retrieve it, then modify it, then write it back. The way │ │ │ -the DHT works, it is natural to always do a lookup before storing and │ │ │ -calling the callback in between is convenient.

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

    dht_get_peers() dht_announce()

    │ │ │ -
    │ │ │ -void dht_get_peers (sha1_hash const& info_hash);
    │ │ │ -void dht_announce (sha1_hash const& info_hash, int port = 0, dht::announce_flags_t flags = {});
    │ │ │ -
    │ │ │ -

    dht_get_peers() will issue a DHT get_peer request to the DHT for the │ │ │ -specified info-hash. The response (the peers) will be posted back in a │ │ │ -dht_get_peers_reply_alert.

    │ │ │ -

    dht_announce() will issue a DHT announce request to the DHT to the │ │ │ -specified info-hash, advertising the specified port. If the port is │ │ │ -left at its default, 0, the port will be implied by the DHT message's │ │ │ -source port (which may improve connectivity through a NAT). │ │ │ -dht_announce() is not affected by the announce_port override setting.

    │ │ │ -

    Both these functions are exposed for advanced custom use of the DHT. │ │ │ -All torrents eligible to be announce to the DHT will be automatically, │ │ │ -by libtorrent.

    │ │ │ -

    For possible flags, see announce_flags_t.

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

    dht_live_nodes()

    │ │ │ -
    │ │ │ -void dht_live_nodes (sha1_hash const& nid);
    │ │ │ -
    │ │ │ -

    Retrieve all the live DHT (identified by nid) nodes. All the │ │ │ -nodes id and endpoint will be returned in the list of nodes in the │ │ │ -alert dht_live_nodes_alert. │ │ │ -Since this alert is a response to an explicit call, it will always be │ │ │ -posted, regardless of the alert mask.

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

    dht_sample_infohashes()

    │ │ │ -
    │ │ │ -void dht_sample_infohashes (udp::endpoint const& ep, sha1_hash const& target);
    │ │ │ -
    │ │ │ -

    Query the DHT node specified by ep to retrieve a sample of the │ │ │ -info-hashes that the node currently have in their storage. │ │ │ -The target is included for iterative lookups so that indexing nodes │ │ │ -can perform a key space traversal with a single RPC per node by adjusting │ │ │ -the target value for each RPC. It has no effect on the returned sample value. │ │ │ -The result is posted as a dht_sample_infohashes_alert.

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

    dht_direct_request()

    │ │ │ -
    │ │ │ -void dht_direct_request (udp::endpoint const& ep, entry const& e, client_data_t userdata = {});
    │ │ │ -
    │ │ │ -

    Send an arbitrary DHT request directly to the specified endpoint. This │ │ │ -function is intended for use by plugins. When a response is received │ │ │ -or the request times out, a dht_direct_response_alert will be posted │ │ │ -with the response (if any) and the userdata pointer passed in here. │ │ │ -Since this alert is a response to an explicit call, it will always be │ │ │ -posted, regardless of the alert mask.

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

    add_extension()

    │ │ │ -
    │ │ │ -void add_extension (std::function<std::shared_ptr<torrent_plugin>(
    │ │ │ -      torrent_handle const&, client_data_t)> ext);
    │ │ │ -void add_extension (std::shared_ptr<plugin> ext);
    │ │ │ -
    │ │ │ -

    This function adds an extension to this session. The argument is a │ │ │ -function object that is called with a torrent_handle and which should │ │ │ -return a std::shared_ptr<torrent_plugin>. To write custom │ │ │ -plugins, see libtorrent plugins. For the typical bittorrent client │ │ │ -all of these extensions should be added. The main plugins implemented │ │ │ -in libtorrent are:

    │ │ │ -
    │ │ │ -
    uTorrent metadata
    │ │ │ -
    Allows peers to download the metadata (.torrent files) from the swarm │ │ │ -directly. Makes it possible to join a swarm with just a tracker and │ │ │ -info-hash.
    │ │ │ -
    │ │ │ -
    │ │ │ -#include <libtorrent/extensions/ut_metadata.hpp>
    │ │ │ -ses.add_extension(&lt::create_ut_metadata_plugin);
    │ │ │ -
    │ │ │ -
    │ │ │ -
    uTorrent peer exchange
    │ │ │ -
    Exchanges peers between clients.
    │ │ │ -
    │ │ │ -
    │ │ │ -#include <libtorrent/extensions/ut_pex.hpp>
    │ │ │ -ses.add_extension(&lt::create_ut_pex_plugin);
    │ │ │ -
    │ │ │ -
    │ │ │ -
    smart ban plugin
    │ │ │ -
    A plugin that, with a small overhead, can ban peers │ │ │ -that sends bad data with very high accuracy. Should │ │ │ -eliminate most problems on poisoned torrents.
    │ │ │ -
    │ │ │ -
    │ │ │ -#include <libtorrent/extensions/smart_ban.hpp>
    │ │ │ -ses.add_extension(&lt::create_smart_ban_plugin);
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_ip_filter() set_ip_filter()

    │ │ │ -
    │ │ │ -ip_filter get_ip_filter () const;
    │ │ │ -void set_ip_filter (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 ip_filter.

    │ │ │ -

    Each time a peer is blocked because of the IP filter, a │ │ │ -peer_blocked_alert is generated. get_ip_filter() Returns the │ │ │ -ip_filter currently in the session. See ip_filter.

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

    set_port_filter()

    │ │ │ -
    │ │ │ -void set_port_filter (port_filter const& f);
    │ │ │ -
    │ │ │ -

    apply port_filter 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.

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

    ssl_listen_port() listen_port() is_listening()

    │ │ │ -
    │ │ │ -bool is_listening () const;
    │ │ │ -unsigned short listen_port () const;
    │ │ │ -unsigned short ssl_listen_port () const;
    │ │ │ -
    │ │ │ -

    is_listening() will tell you whether or not the session has │ │ │ -successfully opened a listening port. If it hasn't, this function will │ │ │ -return false, and then you can set a new │ │ │ -settings_pack::listen_interfaces 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.

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

    get_peer_class_filter() set_peer_class_filter()

    │ │ │ -
    │ │ │ -void set_peer_class_filter (ip_filter const& f);
    │ │ │ -ip_filter get_peer_class_filter () const;
    │ │ │ -
    │ │ │ -

    Sets the peer class filter for this session. 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 ip_filter.

    │ │ │ -

    For example, to make all peers in the range 200.1.1.0 - 200.1.255.255 │ │ │ -belong to their own peer class, apply the following filter:

    │ │ │ -
    │ │ │ -ip_filter f = ses.get_peer_class_filter();
    │ │ │ -peer_class_t my_class = ses.create_peer_class("200.1.x.x IP range");
    │ │ │ -f.add_rule(make_address("200.1.1.0"), make_address("200.1.255.255")
    │ │ │ -        , 1 << static_cast<std::uint32_t>(my_class));
    │ │ │ -ses.set_peer_class_filter(f);
    │ │ │ -
    │ │ │ -

    This setting only applies to new connections, it won't affect existing │ │ │ -peer connections.

    │ │ │ -

    This function is limited to only peer class 0-31, since there are only │ │ │ -32 bits in the IP range mapping. Only the set bits matter; no peer │ │ │ -class will be removed from a peer as a result of this call, peer │ │ │ -classes are only added.

    │ │ │ -

    The peer_class argument cannot be greater than 31. The bitmasks │ │ │ -representing peer classes in the peer_class_filter are 32 bits.

    │ │ │ -

    The get_peer_class_filter() function returns the current filter.

    │ │ │ -

    For more information, see peer classes.

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

    set_peer_class_type_filter() get_peer_class_type_filter()

    │ │ │ -
    │ │ │ -peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │ -void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │ -
    │ │ │ -

    Sets and gets the peer class type filter. This is controls automatic │ │ │ -peer class assignments to peers based on what kind of socket it is.

    │ │ │ -

    It does not only support assigning peer classes, it also supports │ │ │ -removing peer classes based on socket type.

    │ │ │ -

    The order of these rules being applied are:

    │ │ │ -
      │ │ │ -
    1. peer-class IP filter
    2. │ │ │ -
    3. peer-class type filter, removing classes
    4. │ │ │ -
    5. peer-class type filter, adding classes
    6. │ │ │ -
    │ │ │ -

    For more information, see peer classes.

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

    create_peer_class()

    │ │ │ -
    │ │ │ -peer_class_t create_peer_class (char const* name);
    │ │ │ -
    │ │ │ -

    Creates a new peer class (see peer classes) with the given name. The │ │ │ -returned integer is the new peer class identifier. Peer classes may │ │ │ -have the same name, so each invocation of this function creates a new │ │ │ -class and returns a unique identifier.

    │ │ │ -

    Identifiers are assigned from low numbers to higher. So if you plan on │ │ │ -using certain peer classes in a call to set_peer_class_filter(), │ │ │ -make sure to create those early on, to get low identifiers.

    │ │ │ -

    For more information on peer classes, see peer classes.

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

    delete_peer_class()

    │ │ │ -
    │ │ │ -void delete_peer_class (peer_class_t cid);
    │ │ │ -
    │ │ │ -

    This call dereferences the reference count of the specified peer │ │ │ -class. When creating a peer class it's automatically referenced by 1. │ │ │ -If you want to recycle a peer class, you may call this function. You │ │ │ -may only call this function once per peer class you create. │ │ │ -Calling it more than once for the same class will lead to memory │ │ │ -corruption.

    │ │ │ -

    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 session object │ │ │ -destructs.

    │ │ │ -

    For more information on peer classes, see peer classes.

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

    get_peer_class() set_peer_class()

    │ │ │ -
    │ │ │ -void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │ -peer_class_info get_peer_class (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 │ │ │ -peer_class_info object in the specified peer class. There is no │ │ │ -option to only update a single property.

    │ │ │ -

    A peer or torrent belonging to more than one class, the highest │ │ │ -priority among any of its classes is the one that is taken into │ │ │ -account.

    │ │ │ -

    For more information, see peer classes.

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

    remove_torrent()

    │ │ │ -
    │ │ │ -void remove_torrent (const torrent_handle&, remove_flags_t = {});
    │ │ │ -
    │ │ │ -

    remove_torrent() will close all peer connections associated with │ │ │ -the torrent and tell the tracker that we've stopped participating in │ │ │ -the swarm. This operation cannot fail. When it completes, you will │ │ │ -receive a torrent_removed_alert.

    │ │ │ -

    remove_torrent() is non-blocking, but will remove the torrent from the │ │ │ -session synchronously. Calling session_handle::add_torrent() immediately │ │ │ -afterward with the same torrent will succeed. Note that this creates a │ │ │ -new handle which is not equal to the removed one.

    │ │ │ -

    The optional second argument options can be used to delete all the │ │ │ -files downloaded by this torrent. To do so, pass in the value │ │ │ -session_handle::delete_files. Once the torrent is deleted, a │ │ │ -torrent_deleted_alert is posted.

    │ │ │ -

    The torrent_handle remains valid for some time after remove_torrent() is │ │ │ -called. It will become invalid only after all libtorrent tasks (such as │ │ │ -I/O tasks) release their references to the torrent. Until this happens, │ │ │ -torrent_handle::is_valid() will return true, and other calls such │ │ │ -as torrent_handle::status() will succeed. Because of this, and because │ │ │ -remove_torrent() is non-blocking, the following sequence usually │ │ │ -succeeds (does not throw system_error): │ │ │ -.. code:: c++

    │ │ │ -
    │ │ │ -session.remove_handle(handle); │ │ │ -handle.save_resume_data();
    │ │ │ -

    Note that when a queued or downloading torrent is removed, its position │ │ │ -in the download queue is vacated and every subsequent torrent in the │ │ │ -queue has their queue positions updated. This can potentially cause a │ │ │ -large state_update to be posted. When removing all torrents, it is │ │ │ -advised to remove them from the back of the queue, to minimize the │ │ │ -shifting.

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

    get_settings() apply_settings()

    │ │ │ -
    │ │ │ -void apply_settings (settings_pack&&);
    │ │ │ -settings_pack get_settings () const;
    │ │ │ -void apply_settings (settings_pack const&);
    │ │ │ -
    │ │ │ -

    Applies the settings specified by the settings_pack s. This is an │ │ │ -asynchronous operation that will return immediately and actually apply │ │ │ -the settings to the main thread of libtorrent some time later.

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

    pop_alerts() wait_for_alert() set_alert_notify()

    │ │ │ -
    │ │ │ -bool wait_for_alert (time_duration max_wait);
    │ │ │ -void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ -void set_alert_notify (std::function<void()> const& fun);
    │ │ │ -
    │ │ │ -

    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 session still owns these alerts and they will stay │ │ │ -valid until the next time pop_alerts is called. You may not delete │ │ │ -the alert 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.

    │ │ │ -

    wait_for_alert will block the current thread for max_wait time │ │ │ -duration, or until another alert is posted. If an alert is already │ │ │ -available at the time of the call, it returns immediately. It returns │ │ │ -true if an alert is pending (i.e. a subsequent pop_alerts │ │ │ -call would return at least one alert), and false if the timeout │ │ │ -expired with no alert available.

    │ │ │ -

    In TORRENT_ABI_VERSION < 4 the return type is alert* for │ │ │ -backwards compatibility; the returned pointer is non-null when an │ │ │ -alert is pending and null on timeout, but it does not point at any │ │ │ -real alert (it is a placeholder) and must not be dereferenced. Use │ │ │ -pop_alerts to retrieve the actual alerts.

    │ │ │ -

    In the python binding, wait_for_alert takes the number of │ │ │ -milliseconds to wait as an integer and returns a bool.

    │ │ │ -

    The alert queue in the session will not grow indefinitely. Make sure │ │ │ -to pop periodically to not miss notifications. To control the max │ │ │ -number of alerts that's queued by the session, see │ │ │ -settings_pack::alert_queue_size.

    │ │ │ -

    Some alerts are considered so important that they are posted even when │ │ │ -the alert queue is full. Some alerts are considered mandatory and cannot │ │ │ -be disabled by the alert_mask. For instance, │ │ │ -save_resume_data_alert and save_resume_data_failed_alert are always │ │ │ -posted, regardless of the alert mask.

    │ │ │ -

    To control which alerts are posted, set the alert_mask │ │ │ -(settings_pack::alert_mask).

    │ │ │ -

    If the alert queue fills up to the point where alerts are dropped, this │ │ │ -will be indicated by a alerts_dropped_alert, which contains a bitmask │ │ │ -of which types of alerts were dropped. Generally it is a good idea to │ │ │ -make sure the alert queue is large enough, the alert_mask doesn't have │ │ │ -unnecessary categories enabled and to call pop_alert() frequently, to │ │ │ -avoid alerts being dropped.

    │ │ │ -

    the set_alert_notify function lets the client set a function object │ │ │ -to be invoked every time the alert queue goes from having 0 alerts to │ │ │ -1 alert. This function is called from within libtorrent, it may be the │ │ │ -main thread, or it may be from within a user call. The intention of │ │ │ -of the function is that the client wakes up its main thread, to poll │ │ │ -for more alerts using pop_alerts(). If the notify function fails │ │ │ -to do so, it won't be called again, until pop_alerts is called for │ │ │ -some other reason. For instance, it could signal an eventfd, post a │ │ │ -message to an HWND or some other main message pump. The actual │ │ │ -retrieval of alerts should not be done in the callback. In fact, the │ │ │ -callback should not block. It should not perform any expensive work. │ │ │ -It really should just notify the main application thread.

    │ │ │ -

    The type of an alert 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.

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

    delete_port_mapping() add_port_mapping()

    │ │ │ -
    │ │ │ -void delete_port_mapping (port_mapping_t handle);
    │ │ │ -std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │ -
    │ │ │ -

    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 session. The return values are all handles referring to the │ │ │ -port mappings that were just created. Pass them to delete_port_mapping() │ │ │ -to remove them.

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

    reopen_network_sockets()

    │ │ │ -
    │ │ │ -void reopen_network_sockets (reopen_network_flags_t options = reopen_map_ports);
    │ │ │ -
    │ │ │ -

    Instructs the session to reopen all listen and outgoing sockets.

    │ │ │ -

    It's useful in the case your platform doesn't support the built in │ │ │ -IP notifier mechanism, or if you have a better more reliable way to │ │ │ -detect changes in the IP routing table.

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

    native_handle()

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

    This function is intended only for use by plugins. This type does │ │ │ -not have a stable API and should be relied on as little as possible.

    │ │ │ -[report issue]
    │ │ │ -
    save_settings
    │ │ │ -
    saves settings (i.e. the settings_pack)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    save_dht_state
    │ │ │ -
    saves dht state such as nodes and node-id, possibly accelerating │ │ │ -joining the DHT if provided at next session startup.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    save_extension_state
    │ │ │ -
    load or save state from plugins
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    save_ip_filter
    │ │ │ -
    load or save the IP filter set on the session
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    global_peer_class_id tcp_peer_class_id local_peer_class_id
    │ │ │ -
    built-in peer classes
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    delete_files
    │ │ │ -
    delete the files belonging to the torrent from disk. │ │ │ -including the part-file, if there is one
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    delete_partfile
    │ │ │ -
    delete just the part-file associated with this torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    paused
    │ │ │ -
    when set, the session will start paused. Call │ │ │ -session_handle::resume() to start
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    udp tcp
    │ │ │ -
    protocols used by add_port_mapping()
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    reopen_map_ports
    │ │ │ -
    This option indicates if the ports are mapped using natpmp │ │ │ -and upnp. If mapping was already made, they are deleted and added │ │ │ -again. This only works if natpmp and/or upnp are configured to be │ │ │ -enable.
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    write_session_params() read_session_params() write_session_params_buf()

    │ │ │ -

    Declared in "libtorrent/session_params.hpp"

    │ │ │ -
    │ │ │ -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
    │ │ │ -   , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │ -entry write_session_params (session_params const& sp
    │ │ │ -   , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │ -session_params read_session_params (bdecode_node const& e
    │ │ │ -   , 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 │ │ │ -session's state. │ │ │ -The _buf suffix indicates the function operates on buffer rather than the │ │ │ -bencoded structure. │ │ │ -The torrents in a session are not part of the session_params state, they have │ │ │ -to be restored separately.

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

    load_torrent_limits

    │ │ │ -

    Declared in "libtorrent/torrent_info.hpp"

    │ │ │ -

    this object holds configuration options for limits to use when loading │ │ │ -torrents. They are meant to prevent loading potentially malicious torrents │ │ │ -that cause excessive memory allocations.

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

    operator==()

    │ │ │
    │ │ │ -struct load_torrent_limits
    │ │ │ -{
    │ │ │ -   int max_buffer_size  = 10000000;
    │ │ │ -   int max_pieces  = 0x200000;
    │ │ │ -   int max_decode_depth  = 100;
    │ │ │ -   int max_decode_tokens  = 3000000;
    │ │ │ -   int max_duplicate_filenames  = 500;
    │ │ │ -   int max_directory_depth  = 100;
    │ │ │ -};
    │ │ │ +bool operator== (peer_request const& r) const;
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -
    max_buffer_size
    │ │ │ -
    the max size of a .torrent file to load into RAM
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    max_pieces
    │ │ │ -
    the max number of pieces allowed in the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    max_decode_depth
    │ │ │ -
    the max recursion depth in the bdecoded structure
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    max_decode_tokens
    │ │ │ -
    the max number of bdecode tokens
    │ │ │ +

    returns true if the right hand side peer_request refers to the same │ │ │ +range as this does.

    │ │ │ +[report issue]
    │ │ │ +
    piece
    │ │ │ +
    The index of the piece in which the range starts.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    max_duplicate_filenames
    │ │ │ -
    the max number of files with same filename allowed in the torrent. │ │ │ -Files with the same filename are disambiguated by appending a │ │ │ -counter. This operation is not cheap and a malicious torrent may pose │ │ │ -a DoS attack, stalling torrent parsing.
    │ │ │ +[report issue]
    │ │ │ +
    start
    │ │ │ +
    The byte offset within that piece where the range starts.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    max_directory_depth
    │ │ │ -
    the max depth of the directory structure of files in the torrent. It │ │ │ -protects against malicious torrents with a deeply nested directory │ │ │ -structure.
    │ │ │ +[report issue]
    │ │ │ +
    length
    │ │ │ +
    The size of the range, in bytes.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_info

    │ │ │ -

    Declared in "libtorrent/torrent_info.hpp"

    │ │ │ -

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

    │ │ │ -
    │ │ │ -class torrent_info
    │ │ │ -{
    │ │ │ -   explicit torrent_info (info_hash_t const& info_hash);
    │ │ │ -   torrent_info (torrent_info const& t);
    │ │ │ -   torrent_info (bdecode_node const& info_section, error_code& ec
    │ │ │ -      , load_torrent_limits const& cfg
    │ │ │ -      , from_info_section_t);
    │ │ │ -   ~torrent_info ();
    │ │ │ -   file_storage const& layout () const;
    │ │ │ -   std::vector<sha1_hash> similar_torrents () const;
    │ │ │ -   std::vector<std::string> collections () const;
    │ │ │ -   std::int64_t total_size () const;
    │ │ │ -   std::int64_t size_on_disk () const;
    │ │ │ -   int piece_length () const;
    │ │ │ -   int num_pieces () const;
    │ │ │ -   int blocks_per_piece () const;
    │ │ │ -   index_range<piece_index_t> piece_range () const;
    │ │ │ -   piece_index_t last_piece () const;
    │ │ │ -   piece_index_t end_piece () const;
    │ │ │ -   sha1_hash info_hash () const noexcept;
    │ │ │ -   info_hash_t const& info_hashes () const;
    │ │ │ -   bool v2 () const;
    │ │ │ -   bool v1 () const;
    │ │ │ -   int num_files () const;
    │ │ │ -   std::vector<file_slice> map_block (piece_index_t const piece
    │ │ │ -      , std::int64_t offset, int size) const;
    │ │ │ -   peer_request map_file (file_index_t const file, std::int64_t offset, int size) const;
    │ │ │ -   string_view ssl_cert () const;
    │ │ │ -   bool is_valid () const;
    │ │ │ -   bool priv () const;
    │ │ │ -   bool is_i2p () const;
    │ │ │ -   int piece_size (piece_index_t index) const;
    │ │ │ -   int piece_size_for_req (piece_index_t index) const;
    │ │ │ -   char const* hash_for_piece_ptr (piece_index_t const index) const;
    │ │ │ -   sha1_hash hash_for_piece (piece_index_t index) const;
    │ │ │ -   bool is_loaded () const;
    │ │ │ -   const std::string& name () const;
    │ │ │ -   span<char const> info_section () const;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    torrent_info()

    │ │ │ -
    │ │ │ -explicit torrent_info (info_hash_t const& info_hash);
    │ │ │ -
    │ │ │ -

    constructs an empty torrent_info containing only an │ │ │ -info-hash. Useful for magnet links: the resulting object has │ │ │ -no metadata (no file list, no piece hashes) but the info-hash │ │ │ -is set so it can be passed to session::add_torrent().

    │ │ │ -

    This object is not filled in once metadata is received from │ │ │ -peers. The torrent installs a new torrent_info instance │ │ │ -internally rather than updating this one. Retrieve the populated │ │ │ -metadata via torrent_handle::torrent_file().

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

    torrent_info()

    │ │ │ -
    │ │ │ -torrent_info (bdecode_node const& info_section, error_code& ec
    │ │ │ -      , load_torrent_limits const& cfg
    │ │ │ -      , from_info_section_t);
    │ │ │ -
    │ │ │ -

    Construct a torrent_info object from the parsed info-section │ │ │ -pointed to by info_section. The info-section buffer will be copied │ │ │ -into torrent_info.

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

    ~torrent_info()

    │ │ │ -
    │ │ │ -~torrent_info ();
    │ │ │ -
    │ │ │ -

    frees all storage associated with this torrent_info object

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

    layout()

    │ │ │ -
    │ │ │ -file_storage const& layout () const;
    │ │ │ -
    │ │ │ -

    The file_storage object contains the information on how to map the │ │ │ -pieces to files. It is separated from the torrent_info object as the │ │ │ -disk I/O subsystem only needs access to file names and sizes. │ │ │ -The file_storage object is immutable, renamed files are recorded │ │ │ -separately. layout() returns the original filenames, as found in │ │ │ -the .torrent file. Files may be renamed to de-duplicate names, or to │ │ │ -correct invalid filenames.

    │ │ │ -

    For more information on the file_storage object, see the separate │ │ │ -document on how to create torrents.

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

    similar_torrents() collections()

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

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

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

    total_size()

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

    total_size() returns the total number of bytes the torrent-file │ │ │ -represents. Note that this is the number of pieces times the piece │ │ │ -size (modulo the last piece possibly being smaller). With pad files, │ │ │ -the total size will be larger than the sum of all (regular) file │ │ │ -sizes.

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

    size_on_disk()

    │ │ │ -
    │ │ │ -std::int64_t size_on_disk () const;
    │ │ │ -
    │ │ │ -

    returns the sum of all non-pad file sizes. i.e. the files that will │ │ │ -actually be saved to disk by this torrent.

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

    num_pieces() piece_length()

    │ │ │ -
    │ │ │ -int piece_length () const;
    │ │ │ -int num_pieces () const;
    │ │ │ -
    │ │ │ -

    piece_length() and num_pieces() returns the number of byte │ │ │ -for each piece and the total number of pieces, respectively. The │ │ │ -difference between piece_size() and piece_length() is that │ │ │ -piece_size() takes the piece index as argument and gives you the │ │ │ -exact size of that piece. It will always be the same as │ │ │ -piece_length() except in the case of the last piece, which may be │ │ │ -smaller.

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

    blocks_per_piece()

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

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

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

    piece_range() end_piece() last_piece()

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

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

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

    info_hash() info_hashes()

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

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

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

    v1() v2()

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

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

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

    num_files()

    │ │ │ -
    │ │ │ -int num_files () const;
    │ │ │ -
    │ │ │ -

    If you need index-access to files you can use the num_files() along │ │ │ -with the file_path(), file_size()-family of functions to access │ │ │ -files using indices.

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

    map_block()

    │ │ │ -
    │ │ │ -std::vector<file_slice> map_block (piece_index_t const piece
    │ │ │ -      , std::int64_t offset, int size) const;
    │ │ │ -
    │ │ │ -

    This function will map a piece index, a byte offset within that piece │ │ │ -and a size (in bytes) into the corresponding files with offsets where │ │ │ -that data for that piece is supposed to be stored. See file_slice.

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

    map_file()

    │ │ │ -
    │ │ │ -peer_request map_file (file_index_t const file, std::int64_t offset, int size) const;
    │ │ │ -
    │ │ │ -

    This function will map a range in a specific file into a range in the │ │ │ -torrent. The file_offset parameter is the offset in the file, │ │ │ -given in bytes, where 0 is the start of the file. See peer_request.

    │ │ │ -

    The input range is assumed to be valid within the torrent. │ │ │ -file_offset + size is not allowed to be greater than the file │ │ │ -size. file_index must refer to a valid file, i.e. it cannot be >= │ │ │ -num_files().

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

    ssl_cert()

    │ │ │ -
    │ │ │ -string_view ssl_cert () const;
    │ │ │ -
    │ │ │ -

    Returns the SSL root certificate for the torrent, if it is an SSL │ │ │ -torrent. Otherwise returns an empty string. The certificate is │ │ │ -the public certificate in x509 format.

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

    is_valid()

    │ │ │ -
    │ │ │ -bool is_valid () const;
    │ │ │ -
    │ │ │ -

    returns true if this torrent_info object has a torrent loaded. │ │ │ -This is primarily used to determine if a magnet link has had its │ │ │ -metadata resolved yet or not.

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

    priv()

    │ │ │ -
    │ │ │ -bool priv () const;
    │ │ │ -
    │ │ │ -

    returns true if this torrent is private. i.e., the client should not │ │ │ -advertise itself on the trackerless network (the Kademlia DHT) for this torrent.

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

    is_i2p()

    │ │ │ -
    │ │ │ -bool is_i2p () const;
    │ │ │ -
    │ │ │ -

    returns true if this is an i2p torrent. This is determined by whether │ │ │ -or not it has a tracker whose URL domain name ends with ".i2p". i2p │ │ │ -torrents disable the DHT and local peer discovery as well as talking │ │ │ -to peers over anything other than the i2p network. │ │ │ -This is not reliably set for torrents created via resume data or │ │ │ -magnet links. Prefer using torrent::is_i2p() instead.

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

    piece_size()

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

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

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

    piece_size_for_req()

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

    returns the piece size appropriate for computing request lengths. │ │ │ -for v2-only torrents, pieces at the end of files may be shorter than │ │ │ -the main piece size. For v1 and hybrid torrents, piece sizes must be │ │ │ -full (except for the last piece) in order to correctly compute the │ │ │ -piece hash. │ │ │ -Note: this is not a trivial accessor. For v2-only torrents it calls │ │ │ -file_storage::piece_size2(), which performs an O(log n) upper_bound │ │ │ -over the file list to find the file boundary that may shorten the │ │ │ -piece. Cache the result when calling it repeatedly for the same │ │ │ -piece in a hot path.

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

    hash_for_piece_ptr() hash_for_piece()

    │ │ │ -
    │ │ │ -char const* hash_for_piece_ptr (piece_index_t const index) const;
    │ │ │ -sha1_hash hash_for_piece (piece_index_t index) const;
    │ │ │ -
    │ │ │ -

    hash_for_piece() takes a piece-index and returns the 20-bytes │ │ │ -sha1-hash for that piece. │ │ │ -hash_for_piece_ptr() returns a pointer to the 20 byte sha1 digest │ │ │ -for the piece. Note that the string is not 0-terminated.

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

    is_loaded()

    │ │ │ -
    │ │ │ -bool is_loaded () const;
    │ │ │ -
    │ │ │ -

    returns true if the metadata for this torrent has been loaded │ │ │ -(i.e. the file list is populated). For a torrent_info │ │ │ -constructed from just an info-hash this returns false.

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

    name()

    │ │ │ -
    │ │ │ -const std::string& name () const;
    │ │ │ -
    │ │ │ -

    name() returns the name of the torrent. │ │ │ -name contains UTF-8 encoded string.

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

    info_section()

    │ │ │ -
    │ │ │ -span<char const> info_section () const;
    │ │ │ -
    │ │ │ -

    returns a the raw info section of the torrent file. │ │ │ -The underlying buffer is still owned by the torrent_info object

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

    peer_info

    │ │ │

    Declared in "libtorrent/peer_info.hpp"

    │ │ │

    holds information and statistics about one peer │ │ │ that libtorrent is connected to

    │ │ │ @@ -4168,247 +1566,40 @@ │ │ │ [report issue]
    │ │ │
    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.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    info_hash_t

    │ │ │ -

    Declared in "libtorrent/info_hash.hpp"

    │ │ │ -

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

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

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

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

    info_hash_t()

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

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

    │ │ │ -

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

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

    has() has_v1() has_v2()

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

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

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

    get()

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

    returns the has for the specified protocol version

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

    get_best()

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

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

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

    web_seed_entry

    │ │ │ -

    Declared in "libtorrent/web_seed_entry.hpp"

    │ │ │ -

    the web_seed_entry 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 BEP 17 and BEP 19.

    │ │ │ -
    │ │ │ -struct web_seed_entry
    │ │ │ -{
    │ │ │ -   web_seed_entry& operator= (web_seed_entry&&) noexcept;
    │ │ │ -   web_seed_entry& operator= (web_seed_entry const&);
    │ │ │ -   web_seed_entry (web_seed_entry&&) noexcept;
    │ │ │ -   web_seed_entry (web_seed_entry const&);
    │ │ │ -   bool operator== (web_seed_entry const& e) const;
    │ │ │ -   bool operator< (web_seed_entry const& e) const;
    │ │ │ -
    │ │ │ -   std::string url;
    │ │ │ -   std::string auth;
    │ │ │ -   headers_t extra_headers;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    operator==()

    │ │ │ -
    │ │ │ -bool operator== (web_seed_entry const& e) const;
    │ │ │ -
    │ │ │ -

    URL and type comparison

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

    operator<()

    │ │ │ -
    │ │ │ -bool operator< (web_seed_entry const& e) const;
    │ │ │ -
    │ │ │ -

    URL and type less-than comparison

    │ │ │ -[report issue]
    │ │ │ -
    url
    │ │ │ -
    The URL of the web seed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    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 not forwarded to │ │ │ -the new origin.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    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.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    piece_block

    │ │ │ -

    Declared in "libtorrent/piece_block.hpp"

    │ │ │ -

    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
    │ │ │ -{
    │ │ │ -   piece_block (piece_index_t p_index, int b_index);
    │ │ │ -   piece_block () = default;
    │ │ │ -   bool operator< (piece_block const& b) const;
    │ │ │ -   bool operator== (piece_block const& b) const;
    │ │ │ -   bool operator!= (piece_block const& b) const;
    │ │ │ -
    │ │ │ -   static const piece_block invalid;
    │ │ │ -   piece_index_t piece_index {0};
    │ │ │ -   int block_index  = 0;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    invalid piece_index block_index
    │ │ │ -
    sentinel value representing "no block". Compares unequal to any │ │ │ -real block.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_request

    │ │ │ -

    Declared in "libtorrent/peer_request.hpp"

    │ │ │ -

    represents a byte range within a piece. Internally this is is used for │ │ │ -incoming piece requests.

    │ │ │ -
    │ │ │ -struct peer_request
    │ │ │ -{
    │ │ │ -   bool operator== (peer_request const& r) const;
    │ │ │ -
    │ │ │ -   piece_index_t piece;
    │ │ │ -   int start;
    │ │ │ -   int length;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    operator==()

    │ │ │ -
    │ │ │ -bool operator== (peer_request const& r) const;
    │ │ │ -
    │ │ │ -

    returns true if the right hand side peer_request refers to the same │ │ │ -range as this does.

    │ │ │ -[report issue]
    │ │ │ -
    piece
    │ │ │ -
    The index of the piece in which the range starts.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    start
    │ │ │ -
    The byte offset within that piece where the range starts.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    length
    │ │ │ -
    The size of the range, in bytes.
    │ │ │ -
    │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │
    │ │ │ -
    │ │ │ -

    load_torrent_buffer() load_torrent_parsed() load_torrent_file()

    │ │ │ +
    │ │ │ +

    load_torrent_file() load_torrent_parsed() load_torrent_buffer()

    │ │ │

    Declared in "libtorrent/load_torrent.hpp"

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

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

    │ │ │ @@ -4419,14 +1610,23 @@ │ │ │
  • turned into a magnet link via make_magnet_uri()
  • │ │ │ │ │ │ │ │ │

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

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

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

    make_magnet_uri()

    │ │ │

    Declared in "libtorrent/magnet_uri.hpp"

    │ │ │
    │ │ │  std::string make_magnet_uri (add_torrent_params const& atp);
    │ │ │  
    │ │ │ @@ -4449,32 +1649,23 @@ │ │ │ make_magnet_uri().

    │ │ │

    For more information about magnet links, see magnet links.

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

    parse_magnet_uri()

    │ │ │

    Declared in "libtorrent/magnet_uri.hpp"

    │ │ │
    │ │ │ -void parse_magnet_uri (string_view uri, add_torrent_params& p, error_code& ec);
    │ │ │  add_torrent_params parse_magnet_uri (string_view uri, error_code& ec);
    │ │ │  add_torrent_params parse_magnet_uri (string_view uri);
    │ │ │ +void parse_magnet_uri (string_view uri, add_torrent_params& p, 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);
    │ │ │ -
    │ │ │ -

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

    │ │ │ [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);
    │ │ │ @@ -4496,73 +1687,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"

    │ │ │ │ │ │ │ │ │ │ │ │ @@ -4714,14 +1846,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 │ │ │ @@ -4735,46 +1942,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
    │ │ │ @@ -4794,14 +1969,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 │ │ │ @@ -5010,4138 +2201,982 @@ │ │ │ torrents. Cannot be changed after the torrent is added.

    │ │ │
    │ │ │
    │ │ │
    all
    │ │ │
    all torrent flags combined. Can conveniently be used when creating masks │ │ │ for flags
    │ │ │
    │ │ │ -

    libtorrent has a plugin 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.

    │ │ │ -

    In short, the plugin interface makes it possible to:

    │ │ │ -
      │ │ │ -
    • register extension messages (sent in the extension handshake), see │ │ │ -extensions.
    • │ │ │ -
    • add data and parse data from the extension handshake.
    • │ │ │ -
    • send extension messages and standard bittorrent messages.
    • │ │ │ -
    • override or block the handling of standard bittorrent messages.
    • │ │ │ -
    • save and restore state via the session state
    • │ │ │ -
    • see all alerts that are posted
    • │ │ │ -
    │ │ │ -
    │ │ │ -
    │ │ │ -

    a word of caution

    │ │ │ -

    Writing your own plugin is a very easy way to introduce serious bugs such as │ │ │ -dead locks and race conditions. Since a plugin has access to internal │ │ │ -structures it is also quite easy to sabotage libtorrent's operation.

    │ │ │ -

    All the callbacks are always called from the libtorrent network thread. In │ │ │ -case portions of your plugin are called from other threads, typically the main │ │ │ -thread, you cannot use any of the member functions on the internal structures │ │ │ -in libtorrent, since those require being called from the libtorrent network │ │ │ -thread . Furthermore, you also need to synchronize your own shared data │ │ │ -within the plugin, to make sure it is not accessed at the same time from the │ │ │ -libtorrent thread (through a callback). If you need to send out a message │ │ │ -from another thread, it is advised to use an internal queue, and do the │ │ │ -actual sending in tick().

    │ │ │ -

    Since the plugin interface gives you easy access to internal structures, it │ │ │ -is not supported as a stable API. Plugins should be considered specific to a │ │ │ -specific version of libtorrent. Although, in practice the internals mostly │ │ │ -don't change that dramatically.

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

    plugin-interface

    │ │ │ -

    The plugin interface consists of three base classes that the plugin may │ │ │ -implement. These are called plugin, torrent_plugin and peer_plugin. │ │ │ -They are found in the <libtorrent/extensions.hpp> header.

    │ │ │ -

    These plugins are instantiated for each session, torrent and possibly each peer, │ │ │ -respectively.

    │ │ │ -

    For plugins that only need per torrent state, it is enough to only implement │ │ │ -torrent_plugin and pass a constructor function or function object to │ │ │ -session::add_extension() or torrent_handle::add_extension() (if the │ │ │ -torrent has already been started and you want to hook in the extension at │ │ │ -run-time).

    │ │ │ -

    The signature of the function is:

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

    The second argument is the userdata passed to session::add_torrent() or │ │ │ -torrent_handle::add_extension().

    │ │ │ -

    The function should return a std::shared_ptr<torrent_plugin> which │ │ │ -may or may not be 0. If it is a nullptr, the extension is simply ignored │ │ │ -for this torrent. If it is a valid pointer (to a class inheriting │ │ │ -torrent_plugin), it will be associated with this torrent and callbacks │ │ │ -will be made on torrent events.

    │ │ │ -

    For more elaborate plugins which require session wide state, you would │ │ │ -implement plugin, construct an object (in a std::shared_ptr) and pass │ │ │ -it in to session::add_extension().

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

    custom alerts

    │ │ │ -

    Since plugins are running within internal libtorrent threads, one convenient │ │ │ -way to communicate with the client is to post custom alerts.

    │ │ │ -

    The expected interface of any alert, apart from deriving from the alert │ │ │ -base class, looks like this:

    │ │ │ -
    │ │ │ -static const int alert_type = <unique alert ID>;
    │ │ │ -virtual int type() const { return alert_type; }
    │ │ │ -
    │ │ │ -virtual std::string message() const;
    │ │ │ -
    │ │ │ -static const alert_category_t static_category = <bitmask of alert::category_t flags>;
    │ │ │ -virtual alert_category_t category() const { return static_category; }
    │ │ │ -
    │ │ │ -virtual char const* what() const { return <string literal of the name of this alert>; }
    │ │ │ -
    │ │ │ -

    The alert_type is used for the type-checking in alert_cast. It must │ │ │ -not collide with any other alert. The built-in alerts in libtorrent will │ │ │ -not use alert type IDs greater than user_alert_id. When defining your │ │ │ -own alert, make sure it's greater than this constant.

    │ │ │ -

    type() is the run-time equivalence of the alert_type.

    │ │ │ -

    The message() virtual function is expected to construct a useful │ │ │ -string representation of the alert and the event or data it represents. │ │ │ -Something convenient to put in a log file for instance.

    │ │ │ -

    clone() is used internally to copy alerts. The suggested implementation │ │ │ -of simply allocating a new instance as a copy of *this is all that's │ │ │ -expected.

    │ │ │ -

    The static category is required for checking whether or not the category │ │ │ -for a specific alert is enabled or not, without instantiating the alert. │ │ │ -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 alert.

    │ │ │ -

    For more information, see the alert section.

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

    plugin

    │ │ │ -

    Declared in "libtorrent/extensions.hpp"

    │ │ │ -

    this is the base class for a session plugin. One primary feature │ │ │ -is that it is notified of all torrents that are added to the session, │ │ │ -and can add its own torrent_plugins.

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

    hasher

    │ │ │ +

    Declared in "libtorrent/hasher.hpp"

    │ │ │ +

    this is a SHA-1 hash class.

    │ │ │ +

    You use it by first instantiating it, then call update() to feed it │ │ │ +with data. i.e. you don't have to keep the entire buffer of which you want to │ │ │ +create the hash in memory. You can feed the hasher parts of it at a time. When │ │ │ +You have fed the hasher with all the data, you call final() and it │ │ │ +will return the sha1-hash of the data.

    │ │ │ +

    The constructor that takes a char const* and an integer will construct the │ │ │ +sha1 context and feed it the data passed in.

    │ │ │ +

    If you want to reuse the hasher object once you have created a hash, you have to │ │ │ +call reset() to reinitialize it.

    │ │ │ +

    The built-in software version of sha1-algorithm was implemented │ │ │ +by Steve Reid and released as public domain. │ │ │ +For more info, see src/sha1.cpp.

    │ │ │
    │ │ │ -struct plugin
    │ │ │ +class hasher
    │ │ │  {
    │ │ │ -   virtual feature_flags_t implemented_features ();
    │ │ │ -   virtual std::shared_ptr<torrent_plugin> new_torrent (torrent_handle const&, client_data_t);
    │ │ │ -   virtual void added (session_handle const&);
    │ │ │ -   virtual void abort ();
    │ │ │ -   virtual bool on_dht_request (string_view /* query */
    │ │ │ -      , udp::endpoint const& /* source */, bdecode_node const& /* message */
    │ │ │ -      , entry& /* response */);
    │ │ │ -   virtual void on_alert (alert const*);
    │ │ │ -   virtual bool on_unknown_torrent (info_hash_t const& /* info_hash */
    │ │ │ -      , peer_connection_handle const& /* pc */, add_torrent_params& /* p */);
    │ │ │ -   virtual void on_tick ();
    │ │ │ -   virtual uint64_t get_unchoke_priority (peer_connection_handle const& /* peer */);
    │ │ │ -   virtual std::map<std::string, std::string> save_state () const;
    │ │ │ -   virtual void load_state (std::map<std::string, std::string> const&);
    │ │ │ -
    │ │ │ -   static inline constexpr feature_flags_t optimistic_unchoke_feature  = 1_bit;
    │ │ │ -   static inline constexpr feature_flags_t tick_feature  = 2_bit;
    │ │ │ -   static inline constexpr feature_flags_t dht_request_feature  = 3_bit;
    │ │ │ -   static inline constexpr feature_flags_t alert_feature  = 4_bit;
    │ │ │ -   static inline constexpr feature_flags_t unknown_torrent_feature  = 5_bit;
    │ │ │ +   hasher ();
    │ │ │ +   hasher (char const* data, int len);
    │ │ │ +   explicit hasher (span<char const> data);
    │ │ │ +   hasher (hasher const&);
    │ │ │ +   hasher& operator= (hasher&&) & noexcept;
    │ │ │ +   hasher& operator= (hasher const&) &;
    │ │ │ +   hasher (hasher&&) noexcept;
    │ │ │ +   hasher& update (char const* data, int len);
    │ │ │ +   hasher& update (span<char const> data);
    │ │ │ +   sha1_hash final ();
    │ │ │ +   void reset ();
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -

    implemented_features()

    │ │ │ -
    │ │ │ -virtual feature_flags_t implemented_features ();
    │ │ │ -
    │ │ │ -

    This function is expected to return a bitmask indicating which features │ │ │ -this plugin implements. Some callbacks on this object may not be called │ │ │ -unless the corresponding feature flag is returned here. Note that │ │ │ -callbacks may still be called even if the corresponding feature is not │ │ │ -specified in the return value here. See feature_flags_t for possible │ │ │ -flags to return.

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

    new_torrent()

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

    this is called by the session every time a new torrent is added. │ │ │ -The torrent* points to the internal torrent object created │ │ │ -for the new torrent. The client_data_t is the userdata pointer as │ │ │ -passed in via add_torrent_params.

    │ │ │ -

    If the plugin returns a torrent_plugin instance, it will be added │ │ │ -to the new torrent. Otherwise, return an empty shared_ptr to a │ │ │ -torrent_plugin (the default).

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

    added()

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

    operator=() hasher()

    │ │ │
    │ │ │ -virtual void added (session_handle const&);
    │ │ │ +hasher (char const* data, int len);
    │ │ │ +explicit hasher (span<char const> data);
    │ │ │ +hasher (hasher const&);
    │ │ │ +hasher& operator= (hasher&&) & noexcept;
    │ │ │ +hasher& operator= (hasher const&) &;
    │ │ │ +hasher (hasher&&) noexcept;
    │ │ │  
    │ │ │ -

    called when plugin is added to a session

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

    abort()

    │ │ │ +

    this is the same as default constructing followed by a call to │ │ │ +update(data, len).

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

    update()

    │ │ │
    │ │ │ -virtual void abort ();
    │ │ │ +hasher& update (char const* data, int len);
    │ │ │ +hasher& update (span<char const> data);
    │ │ │  
    │ │ │ -

    called when the session is aborted │ │ │ -the plugin should perform any cleanup necessary to allow the session's │ │ │ -destruction (e.g. cancel outstanding async operations)

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

    on_dht_request()

    │ │ │ +

    append the following bytes to what is being hashed

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

    final()

    │ │ │
    │ │ │ -virtual bool on_dht_request (string_view /* query */
    │ │ │ -      , udp::endpoint const& /* source */, bdecode_node const& /* message */
    │ │ │ -      , entry& /* response */);
    │ │ │ +sha1_hash final ();
    │ │ │  
    │ │ │ -

    called when a dht request is received. │ │ │ -If your plugin expects this to be called, make sure to include the flag │ │ │ -dht_request_feature in the return value from implemented_features().

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

    on_alert()

    │ │ │ +

    returns the SHA-1 digest of the buffers previously passed to │ │ │ +update() and the hasher constructor.

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

    reset()

    │ │ │
    │ │ │ -virtual void on_alert (alert const*);
    │ │ │ +void reset ();
    │ │ │  
    │ │ │ -

    called when an alert is posted alerts that are filtered are not posted. │ │ │ -If your plugin expects this to be called, make sure to include the flag │ │ │ -alert_feature in the return value from implemented_features().

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

    on_unknown_torrent()

    │ │ │ +

    restore the hasher state to be as if the hasher has just been │ │ │ +default constructed.

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

    hasher256

    │ │ │ +

    Declared in "libtorrent/hasher.hpp"

    │ │ │ +

    hasher256 computes a SHA-256 message digest. It is the │ │ │ +counterpart to hasher (which computes SHA-1) and is used for │ │ │ +BitTorrent v2 piece and merkle-tree hashes. It can be fed input │ │ │ +incrementally via update() and the digest is produced by │ │ │ +final(). Call reset() to reuse the object for another │ │ │ +digest.

    │ │ │
    │ │ │ -virtual bool on_unknown_torrent (info_hash_t const& /* info_hash */
    │ │ │ -      , peer_connection_handle const& /* pc */, add_torrent_params& /* p */);
    │ │ │ +class hasher256
    │ │ │ +{
    │ │ │ +   hasher256 ();
    │ │ │ +   hasher256 (hasher256&&) noexcept;
    │ │ │ +   hasher256 (hasher256 const&);
    │ │ │ +   explicit hasher256 (span<char const> data);
    │ │ │ +   hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ +   hasher256 (char const* data, int len);
    │ │ │ +   hasher256& operator= (hasher256 const&) &;
    │ │ │ +   hasher256& update (char const* data, int len);
    │ │ │ +   hasher256& update (span<char const> data);
    │ │ │ +   sha256_hash final ();
    │ │ │ +   void reset ();
    │ │ │ +   ~hasher256 ();
    │ │ │ +};
    │ │ │  
    │ │ │ -

    return true if the add_torrent_params should be added

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

    on_tick()

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

    operator=() hasher256()

    │ │ │
    │ │ │ -virtual void on_tick ();
    │ │ │ +hasher256 (hasher256&&) noexcept;
    │ │ │ +hasher256 (hasher256 const&);
    │ │ │ +explicit hasher256 (span<char const> data);
    │ │ │ +hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ +hasher256 (char const* data, int len);
    │ │ │ +hasher256& operator= (hasher256 const&) &;
    │ │ │  
    │ │ │ -

    called once per second. │ │ │ -If your plugin expects this to be called, make sure to include the flag │ │ │ -tick_feature in the return value from implemented_features().

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

    get_unchoke_priority()

    │ │ │ +

    this is the same as default constructing followed by a call to │ │ │ +update(data, len).

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

    update()

    │ │ │
    │ │ │ -virtual uint64_t get_unchoke_priority (peer_connection_handle const& /* peer */);
    │ │ │ +hasher256& update (char const* data, int len);
    │ │ │ +hasher256& update (span<char const> data);
    │ │ │  
    │ │ │ -

    called when choosing peers to optimistically unchoke. The return value │ │ │ -indicates the peer's priority for unchoking. Lower return values │ │ │ -correspond to higher priority. Priorities above 2^63-1 are reserved. │ │ │ -If your plugin has no priority to assign a peer it should return 2^64-1. │ │ │ -If your plugin expects this to be called, make sure to include the flag │ │ │ -optimistic_unchoke_feature in the return value from implemented_features(). │ │ │ -If multiple plugins implement this function the lowest return value │ │ │ -(i.e. the highest priority) is used.

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

    save_state()

    │ │ │ +

    append the following bytes to what is being hashed

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

    final()

    │ │ │
    │ │ │ -virtual std::map<std::string, std::string> save_state () const;
    │ │ │ +sha256_hash final ();
    │ │ │  
    │ │ │ -

    called when serializing session state. The returned map of │ │ │ -key/value strings is stored alongside the session state and │ │ │ -passed back to load_state() on the next session.

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

    load_state()

    │ │ │ +

    returns the SHA-1 digest of the buffers previously passed to │ │ │ +update() and the hasher constructor.

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

    reset()

    │ │ │
    │ │ │ -virtual void load_state (std::map<std::string, std::string> const&);
    │ │ │ +void reset ();
    │ │ │  
    │ │ │ -

    called on startup while loading settings state from the session_params

    │ │ │ -[report issue]
    │ │ │ -
    optimistic_unchoke_feature
    │ │ │ -
    include this bit if your plugin needs to alter the order of the │ │ │ -optimistic unchoke of peers. i.e. have the on_optimistic_unchoke() │ │ │ -callback be called.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    tick_feature
    │ │ │ -
    include this bit if your plugin needs to have on_tick() called
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    dht_request_feature
    │ │ │ -
    include this bit if your plugin needs to have on_dht_request() │ │ │ -called
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    alert_feature
    │ │ │ -
    include this bit if your plugin needs to have on_alert() │ │ │ -called
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    unknown_torrent_feature
    │ │ │ -
    include this bit if your plugin needs to have on_unknown_torrent() │ │ │ -called even if there is no active torrent in the session
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ +

    restore the hasher state to be as if the hasher has just been │ │ │ +default constructed.

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

    torrent_plugin

    │ │ │ -

    Declared in "libtorrent/extensions.hpp"

    │ │ │ -

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

    │ │ │ +
    │ │ │ +

    bitfield

    │ │ │ +

    Declared in "libtorrent/bitfield.hpp"

    │ │ │ +

    The bitfield type stores any number of bits as a bitfield │ │ │ +in a heap allocated array.

    │ │ │
    │ │ │ -struct torrent_plugin
    │ │ │ +struct bitfield
    │ │ │  {
    │ │ │ -   virtual std::shared_ptr<peer_plugin> new_connection (peer_connection_handle const&);
    │ │ │ -   virtual void on_piece_failed (piece_index_t);
    │ │ │ -   virtual void on_piece_pass (piece_index_t);
    │ │ │ -   virtual void tick ();
    │ │ │ -   virtual bool on_resume ();
    │ │ │ -   virtual bool on_pause ();
    │ │ │ -   virtual void on_files_checked ();
    │ │ │ -   virtual void on_state (torrent_status::state_t);
    │ │ │ -   virtual void on_add_peer (tcp::endpoint const&,
    │ │ │ -      peer_source_flags_t, add_peer_flags_t);
    │ │ │ -
    │ │ │ -   static inline constexpr add_peer_flags_t first_time  = 1_bit;
    │ │ │ -   static inline constexpr add_peer_flags_t filtered  = 2_bit;
    │ │ │ +   bitfield (bitfield&& rhs) noexcept = default;
    │ │ │ +   bitfield (char const* b, int bits);
    │ │ │ +   bitfield (bitfield const& rhs);
    │ │ │ +   bitfield (int bits, bool val);
    │ │ │ +   explicit bitfield (int bits);
    │ │ │ +   bitfield () noexcept = default;
    │ │ │ +   void assign (char const* b, int const bits);
    │ │ │ +   bool get_bit (int index) const noexcept;
    │ │ │ +   bool operator[] (int index) const noexcept;
    │ │ │ +   void set_bit (int index) noexcept;
    │ │ │ +   void clear_bit (int index) noexcept;
    │ │ │ +   bool all_set () const noexcept;
    │ │ │ +   bool none_set () const noexcept;
    │ │ │ +   int size () const noexcept;
    │ │ │ +   int num_words () const noexcept;
    │ │ │ +   int num_bytes () const noexcept;
    │ │ │ +   bool empty () const noexcept;
    │ │ │ +   char* data () noexcept;
    │ │ │ +   char const* data () const noexcept;
    │ │ │ +   void swap (bitfield& rhs) noexcept;
    │ │ │ +   int count () const noexcept;
    │ │ │ +   int find_first_set () const noexcept;
    │ │ │ +   int find_last_clear () const noexcept;
    │ │ │ +   bool operator== (lt::bitfield const& rhs) const;
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -

    new_connection()

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

    bitfield()

    │ │ │
    │ │ │ -virtual std::shared_ptr<peer_plugin> new_connection (peer_connection_handle const&);
    │ │ │ +bitfield (bitfield&& rhs) noexcept = default;
    │ │ │ +bitfield (char const* b, int bits);
    │ │ │ +bitfield (bitfield const& rhs);
    │ │ │ +bitfield (int bits, bool val);
    │ │ │ +explicit bitfield (int bits);
    │ │ │ +bitfield () noexcept = default;
    │ │ │  
    │ │ │ -

    This function is called each time a new peer is connected to the torrent. You │ │ │ -may choose to ignore this by just returning a default constructed │ │ │ -shared_ptr (in which case you don't need to override this member │ │ │ -function).

    │ │ │ -

    If you need an extension to the peer connection (which most plugins do) you │ │ │ -are supposed to return an instance of your peer_plugin class. Which in │ │ │ -turn will have its hook functions called on event specific to that peer.

    │ │ │ -

    The peer_connection_handle will be valid as long as the shared_ptr │ │ │ -is being held by the torrent object. So, it is generally a good idea to not │ │ │ -keep a shared_ptr to your own peer_plugin. If you want to keep references │ │ │ -to it, use weak_ptr.

    │ │ │ -

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

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

    on_piece_pass() on_piece_failed()

    │ │ │ +

    constructs a new bitfield. The default constructor creates an empty │ │ │ +bitfield. bits is the size of the bitfield (specified in bits). │ │ │ +val is the value to initialize the bits to. If not specified │ │ │ +all bits are initialized to 0.

    │ │ │ +

    The constructor taking a pointer b and bits copies a bitfield │ │ │ +from the specified buffer, and bits number of bits (rounded up to │ │ │ +the nearest byte boundary).

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

    assign()

    │ │ │
    │ │ │ -virtual void on_piece_failed (piece_index_t);
    │ │ │ -virtual void on_piece_pass (piece_index_t);
    │ │ │ +void assign (char const* b, int const bits);
    │ │ │  
    │ │ │ -

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

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

    tick()

    │ │ │ +

    copy bitfield from buffer b of bits number of bits, rounded up to │ │ │ +the nearest byte boundary.

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

    operator[]() get_bit()

    │ │ │
    │ │ │ -virtual void tick ();
    │ │ │ +bool get_bit (int index) const noexcept;
    │ │ │ +bool operator[] (int index) const noexcept;
    │ │ │  
    │ │ │ -

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

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

    on_pause() on_resume()

    │ │ │ +

    query bit at index. Returns true if bit is 1, otherwise false.

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

    clear_bit() set_bit()

    │ │ │
    │ │ │ -virtual bool on_resume ();
    │ │ │ -virtual bool on_pause ();
    │ │ │ +void set_bit (int index) noexcept;
    │ │ │ +void clear_bit (int index) noexcept;
    │ │ │  
    │ │ │ -

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

    │ │ │ -

    Note that if you call pause() or resume() on the torrent from your │ │ │ -handler it will recurse back into your handler, so in order to invoke the │ │ │ -standard handler, you have to keep your own state on whether you want standard │ │ │ -behavior or overridden behavior.

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

    on_files_checked()

    │ │ │ +

    set bit at index to 0 (clear_bit) or 1 (set_bit).

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

    all_set()

    │ │ │
    │ │ │ -virtual void on_files_checked ();
    │ │ │ +bool all_set () const noexcept;
    │ │ │  
    │ │ │ -

    This function is called when the initial files of the torrent have been │ │ │ -checked. If there are no files to check, this function is called immediately.

    │ │ │ -

    i.e. This function is always called when the torrent is in a state where it │ │ │ -can start downloading.

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

    on_state()

    │ │ │ +

    returns true if all bits in the bitfield are set

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

    none_set()

    │ │ │
    │ │ │ -virtual void on_state (torrent_status::state_t);
    │ │ │ +bool none_set () const noexcept;
    │ │ │  
    │ │ │ -

    called when the torrent changes state │ │ │ -the state is one of torrent_status::state_t │ │ │ -enum members

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

    on_add_peer()

    │ │ │ +

    returns true if no bit in the bitfield is set

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

    size()

    │ │ │
    │ │ │ -virtual void on_add_peer (tcp::endpoint const&,
    │ │ │ -      peer_source_flags_t, add_peer_flags_t);
    │ │ │ +int size () const noexcept;
    │ │ │  
    │ │ │ -

    called every time a new peer is added to the peer list. │ │ │ -This is before the peer is connected to. For flags, see │ │ │ -torrent_plugin::flags_t. The source argument refers to │ │ │ -the source where we learned about this peer from. It's a │ │ │ -bitmask, because many sources may have told us about the same │ │ │ -peer. For peer source flags, see peer_info::peer_source_flags.

    │ │ │ -[report issue]
    │ │ │ -
    first_time
    │ │ │ -
    this is the first time we see this peer
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    filtered
    │ │ │ -
    this peer was not added because it was │ │ │ -filtered by the IP filter
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    peer_plugin

    │ │ │ -

    Declared in "libtorrent/extensions.hpp"

    │ │ │ -

    peer plugins are associated with a specific peer. A peer could be │ │ │ -both a regular bittorrent peer (bt_peer_connection) or one of the │ │ │ -web seed connections (web_peer_connection). │ │ │ -In order to only attach to certain peers, make your │ │ │ -torrent_plugin::new_connection only return a plugin for certain peer │ │ │ -connection types

    │ │ │ +

    returns the size of the bitfield in bits.

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

    num_words()

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

    type()

    │ │ │ +

    returns the number of 32 bit words are needed to represent all bits in │ │ │ +this bitfield.

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

    num_bytes()

    │ │ │
    │ │ │ -virtual string_view type () const;
    │ │ │ +int num_bytes () const noexcept;
    │ │ │  
    │ │ │ -

    This function is expected to return the name of │ │ │ -the plugin.

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

    add_handshake()

    │ │ │ +

    returns the number of bytes needed to represent all bits in this │ │ │ +bitfield

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

    empty()

    │ │ │
    │ │ │ -virtual void add_handshake (entry&);
    │ │ │ +bool empty () const noexcept;
    │ │ │  
    │ │ │ -

    can add entries to the extension handshake │ │ │ -this is not called for web seeds

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

    on_disconnect()

    │ │ │ +

    returns true if the bitfield has zero size.

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

    data()

    │ │ │
    │ │ │ -virtual void on_disconnect (error_code const&);
    │ │ │ +char* data () noexcept;
    │ │ │ +char const* data () const noexcept;
    │ │ │  
    │ │ │ -

    called when the peer is being disconnected.

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

    on_connected()

    │ │ │ +

    returns a pointer to the internal buffer of the bitfield, or │ │ │ +nullptr if it's empty.

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

    swap()

    │ │ │
    │ │ │ -virtual void on_connected ();
    │ │ │ +void swap (bitfield& rhs) noexcept;
    │ │ │  
    │ │ │ -

    called when the peer is successfully connected. Note that │ │ │ -incoming connections will have been connected by the time │ │ │ -the peer plugin is attached to it, and won't have this hook │ │ │ -called.

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

    on_handshake()

    │ │ │ +

    swaps the bit-fields two variables refer to

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

    count()

    │ │ │
    │ │ │ -virtual bool on_handshake (span<char const>);
    │ │ │ +int count () const noexcept;
    │ │ │  
    │ │ │ -

    this is called when the initial bittorrent handshake is received. │ │ │ -Returning false means that the other end doesn't support this extension │ │ │ -and will remove it from the list of plugins. this is not called for web │ │ │ -seeds

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

    on_extension_handshake()

    │ │ │ +

    count the number of bits in the bitfield that are set to 1.

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

    find_first_set()

    │ │ │
    │ │ │ -virtual bool on_extension_handshake (bdecode_node const&);
    │ │ │ +int find_first_set () const noexcept;
    │ │ │  
    │ │ │ -

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

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

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

    │ │ │ +

    returns the index of the first set bit in the bitfield, i.e. 1 bit.

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

    find_last_clear()

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

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

    on_piece()

    │ │ │ +

    returns the index to the last cleared bit in the bitfield, i.e. 0 bit.

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

    stats_metric

    │ │ │ +

    Declared in "libtorrent/session_stats.hpp"

    │ │ │ +

    describes one statistics metric from the session. For more information, │ │ │ +see the session statistics section.

    │ │ │
    │ │ │ -virtual bool on_piece (peer_request const& /*piece*/
    │ │ │ -      , span<char const> /*buf*/);
    │ │ │ +struct stats_metric
    │ │ │ +{
    │ │ │ +   char const* name;
    │ │ │ +   int value_index;
    │ │ │ +   metric_type_t type;
    │ │ │ +};
    │ │ │  
    │ │ │ -

    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_cancel() on_reject() on_suggest()

    │ │ │ +[report issue]
    │ │ │ +
    name
    │ │ │ +
    the name of the counter or gauge
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    value_index type
    │ │ │ +
    the index into the session stats array, where the underlying value of │ │ │ +this counter or gauge is found. The session stats array is part of the │ │ │ +session_stats_alert object.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    counters

    │ │ │ +

    Declared in "libtorrent/performance_counters.hpp"

    │ │ │ +

    holds the session-wide counters and gauges backing the │ │ │ +session_stats_alert and session_status reporting paths. │ │ │ +One instance lives on the session and is incremented from the │ │ │ +network thread; reads from other threads use the lock-free │ │ │ +operator[] overload when ATOMIC_LLONG_LOCK_FREE is set, │ │ │ +otherwise a single shared mutex guards the whole array.

    │ │ │ +

    A reference to this object is passed to custom disk I/O │ │ │ +implementations (see disk_interface and the disk_io_constructor │ │ │ +passed via session_params), which update the disk related metrics │ │ │ +through it. The specific counters and gauges are documented under │ │ │ +the session statistics section.

    │ │ │
    │ │ │ -virtual bool on_suggest (piece_index_t);
    │ │ │ -virtual bool on_cancel (peer_request const&);
    │ │ │ -virtual bool on_reject (peer_request const&);
    │ │ │ +struct counters
    │ │ │ +{
    │ │ │ +   counters () ;
    │ │ │ +   counters& operator= (counters const&) & ;
    │ │ │ +   counters (counters const&) ;
    │ │ │ +   std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
    │ │ │ +   std::int64_t operator[] (int i) const ;
    │ │ │ +   void set_value (int c, std::int64_t value) ;
    │ │ │ +   void blend_stats_counter (int c, std::int64_t value, int ratio) ;
    │ │ │ +};
    │ │ │  
    │ │ │ -

    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_suggest() sent_have_all() sent_have_none() sent_unchoke() sent_interested() sent_not_interested() sent_cancel() sent_request() sent_reject_request() sent_piece() sent_choke() sent_allow_fast() sent_have()

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

    inc_stats_counter()

    │ │ │
    │ │ │ -virtual void sent_allow_fast (piece_index_t);
    │ │ │ -virtual void sent_piece (peer_request const&);
    │ │ │ -virtual void sent_have (piece_index_t);
    │ │ │ -virtual void sent_suggest (piece_index_t);
    │ │ │ -virtual void sent_unchoke ();
    │ │ │ -virtual void sent_not_interested ();
    │ │ │ -virtual void sent_reject_request (peer_request const&);
    │ │ │ -virtual void sent_have_none ();
    │ │ │ -virtual void sent_have_all ();
    │ │ │ -virtual void sent_interested ();
    │ │ │ -virtual void sent_cancel (peer_request const&);
    │ │ │ -virtual void sent_choke ();
    │ │ │ -virtual void sent_request (peer_request const&);
    │ │ │ +std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
    │ │ │  
    │ │ │ -

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

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

    sent_payload()

    │ │ │ +

    increments the counter or gauge c (an index into the counter │ │ │ +array) by value and returns the new value.

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

    operator[]()

    │ │ │
    │ │ │ -virtual void sent_payload (int /* bytes */);
    │ │ │ +std::int64_t operator[] (int i) const ;
    │ │ │  
    │ │ │ -

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

    on_extended()

    │ │ │ -
    │ │ │ -virtual bool on_extended (int /*length*/, int /*msg*/,
    │ │ │ -      span<char const> /*body*/);
    │ │ │ -
    │ │ │ -

    called when an extended message is received. If returning true, │ │ │ -the message is not processed by any other plugin and if false │ │ │ -is returned the next plugin in the chain will receive it to │ │ │ -be able to handle it. This is not called for web seeds. │ │ │ -thus function may be called more than once per incoming message, but │ │ │ -only the last of the calls will the body size equal the length. │ │ │ -i.e. Every time another fragment of the message is received, this │ │ │ -function will be called, until finally the whole message has been │ │ │ -received. The purpose of this is to allow early disconnects for invalid │ │ │ -messages and for reporting progress of receiving large messages.

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

    on_unknown_message()

    │ │ │ -
    │ │ │ -virtual bool on_unknown_message (int /*length*/, int /*msg*/,
    │ │ │ -      span<char const> /*body*/);
    │ │ │ -
    │ │ │ -

    this is not called for web seeds

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

    on_piece_pass() on_piece_failed()

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

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

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

    tick()

    │ │ │ -
    │ │ │ -virtual void tick ();
    │ │ │ -
    │ │ │ -

    called approximately once every second

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

    write_request()

    │ │ │ -
    │ │ │ -virtual bool write_request (peer_request const&);
    │ │ │ -
    │ │ │ -

    called each time a request message is to be sent. If true │ │ │ -is returned, the original request message won't be sent and │ │ │ -no other plugin will have this function called.

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

    crypto_plugin

    │ │ │ -

    Declared in "libtorrent/extensions.hpp"

    │ │ │ -

    interface implemented by a plugin that wants to take over the │ │ │ -encryption / decryption of a peer connection. Returned by │ │ │ -peer_plugin::wrap_socket() to plug into the BitTorrent peer │ │ │ -connection's send / receive path. Used by the built-in protocol │ │ │ -encryption (MSE) implementation.

    │ │ │ -
    │ │ │ -struct crypto_plugin
    │ │ │ -{
    │ │ │ -   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()

    │ │ │ -
    │ │ │ -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 │ │ │ -encrypting bytes sent to the peer. Both are called once │ │ │ -during the handshake before any data flows through the │ │ │ -plugin.

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

    encrypt()

    │ │ │ -
    │ │ │ -encrypt (span<span<char>> /*send_vec*/) = 0;
    │ │ │ -
    │ │ │ -

    encrypted the provided buffers and returns the number of bytes which │ │ │ -are now ready to be sent to the lower layer. This must be at least │ │ │ -as large as the number of bytes passed in and may be larger if there │ │ │ -is additional data to be inserted at the head of the send buffer. │ │ │ -The additional data is returned as the second tuple value. Any │ │ │ -returned buffer as well as the iovec itself, to be prepended to the │ │ │ -send buffer, must be owned by the crypto plugin and guaranteed to stay │ │ │ -alive until the crypto_plugin is destructed or this function is called │ │ │ -again.

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

    decrypt()

    │ │ │ -
    │ │ │ -virtual std::tuple<int, int, int> decrypt (span<span<char>> /*receive_vec*/) = 0;
    │ │ │ -
    │ │ │ -

    decrypt the provided buffers. │ │ │ -returns is a tuple representing the values │ │ │ -(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 maybe_unchoke_this_peer ();
    │ │ │ -   void choke_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;
    │ │ │ -   bool is_outgoing () const;
    │ │ │ -   bool is_connecting () const;
    │ │ │ -   void disconnect (error_code const& ec, operation_t op
    │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ -   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);
    │ │ │ -   std::time_t last_seen_complete () const;
    │ │ │ -   time_point time_of_last_unchoke () 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]
    │ │ │ -
    │ │ │ -

    has_peer_choked() is_peer_interested()

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

    choke_this_peer() maybe_unchoke_this_peer()

    │ │ │ -
    │ │ │ -void maybe_unchoke_this_peer ();
    │ │ │ -void choke_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]
    │ │ │ -
    │ │ │ -

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

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

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

    peer_log() should_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]
    │ │ │ -
    │ │ │ -

    time_of_last_unchoke() last_seen_complete()

    │ │ │ -
    │ │ │ -std::time_t last_seen_complete () const;
    │ │ │ -time_point time_of_last_unchoke () 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]
    │ │ │ -
    │ │ │ -

    support_extensions() packet_finished()

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

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

    │ │ │ -

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

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

    create_smart_ban_plugin()

    │ │ │ -

    Declared in "libtorrent/extensions/smart_ban.hpp"

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

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

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

    create_ut_metadata_plugin()

    │ │ │ -

    Declared in "libtorrent/extensions/ut_metadata.hpp"

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

    constructor function for the ut_metadata extension. The ut_metadata │ │ │ -extension allows peers to request the .torrent file (or more │ │ │ -specifically the info-dictionary of the .torrent file) from each │ │ │ -other. This is the main building block in making magnet links work. │ │ │ -This extension is enabled by default unless explicitly disabled in │ │ │ -the session constructor.

    │ │ │ -

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

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

    file_slice

    │ │ │ -

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ -

    represents a window of a file in a torrent.

    │ │ │ -

    The file_index refers to the index of the file (in the torrent_info). │ │ │ -To get the path and filename, use file_path() and give the file_index │ │ │ -as argument. The offset is the byte offset in the file where the range │ │ │ -starts, and size is the number of bytes this range is. The size + offset │ │ │ -will never be greater than the file size.

    │ │ │ -
    │ │ │ -struct file_slice
    │ │ │ -{
    │ │ │ -   file_index_t file_index;
    │ │ │ -   std::int64_t offset;
    │ │ │ -   std::int64_t size;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    file_index
    │ │ │ -
    the index of the file
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    offset
    │ │ │ -
    the offset from the start of the file, in bytes
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    size
    │ │ │ -
    the size of the window, in bytes
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_storage

    │ │ │ -

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ -

    The file_storage class represents a file list and the piece │ │ │ -size. Everything necessary to interpret a regular bittorrent storage │ │ │ -file structure.

    │ │ │ -
    │ │ │ -class file_storage
    │ │ │ -{
    │ │ │ -   bool is_valid () const;
    │ │ │ -   void reserve (int num_files);
    │ │ │ -   void add_file_borrow (string_view filename
    │ │ │ -      , std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}, std::int64_t mtime = 0
    │ │ │ -      , string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │ -   void add_file (std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}
    │ │ │ -      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │ -   void add_file_borrow (error_code& ec, string_view filename
    │ │ │ -      , std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}, std::int64_t mtime = 0
    │ │ │ -      , string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │ -   void add_file (error_code& ec, std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}
    │ │ │ -      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │ -   std::vector<file_slice> map_block (piece_index_t piece, std::int64_t offset
    │ │ │ -      , std::int64_t size) const;
    │ │ │ -   peer_request map_file (file_index_t file, std::int64_t offset, int size) const;
    │ │ │ -   int num_files () const noexcept;
    │ │ │ -   file_index_t end_file () const noexcept;
    │ │ │ -   index_range<file_index_t> file_range () const noexcept;
    │ │ │ -   std::int64_t total_size () const;
    │ │ │ -   std::int64_t size_on_disk () const;
    │ │ │ -   void set_num_pieces (int n);
    │ │ │ -   int num_pieces () const;
    │ │ │ -   piece_index_t end_piece () const;
    │ │ │ -   piece_index_t last_piece () const;
    │ │ │ -   index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ -   int piece_length () const;
    │ │ │ -   void set_piece_length (int l);
    │ │ │ -   int piece_size (piece_index_t index) const;
    │ │ │ -   int piece_size2 (piece_index_t index) const;
    │ │ │ -   int blocks_in_piece2 (piece_index_t index) const;
    │ │ │ -   int blocks_per_piece () const;
    │ │ │ -   void set_name (std::string const& n);
    │ │ │ -   std::string const& name () const;
    │ │ │ -   void swap (file_storage& ti) noexcept;
    │ │ │ -   bool pad_file_at (file_index_t index) const;
    │ │ │ -   string_view file_name (file_index_t index) const;
    │ │ │ -   char const* root_ptr (file_index_t const index) const;
    │ │ │ -   std::string file_path (file_index_t index, std::string const& save_path = "") const;
    │ │ │ -   std::int64_t file_size (file_index_t index) const;
    │ │ │ -   std::string symlink (file_index_t index) const;
    │ │ │ -   sha256_hash root (file_index_t index) const;
    │ │ │ -   std::int64_t file_offset (file_index_t index) const;
    │ │ │ -   std::time_t mtime (file_index_t index) const;
    │ │ │ -   int file_num_blocks (file_index_t index) const;
    │ │ │ -   index_range<piece_index_t::diff_type> file_piece_range (file_index_t) const;
    │ │ │ -   int file_num_pieces (file_index_t index) const;
    │ │ │ -   int file_first_block_node (file_index_t index) const;
    │ │ │ -   int file_first_piece_node (file_index_t index) const;
    │ │ │ -   std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const;
    │ │ │ -   void all_path_hashes (std::unordered_set<std::uint32_t>& table) const;
    │ │ │ -   file_flags_t file_flags (file_index_t index) const;
    │ │ │ -   bool file_absolute_path (file_index_t index) const;
    │ │ │ -   file_index_t file_index_at_piece (piece_index_t piece) const;
    │ │ │ -   file_index_t last_file_index_at_piece (piece_index_t piece) const;
    │ │ │ -   file_index_t file_index_at_offset (std::int64_t offset) const;
    │ │ │ -   file_index_t file_index_for_root (sha256_hash const& root_hash) const;
    │ │ │ -   piece_index_t last_piece_index_at_file (file_index_t f) const;
    │ │ │ -   piece_index_t piece_index_at_file (file_index_t f) const;
    │ │ │ -   void sanitize_symlinks ();
    │ │ │ -   bool v2 () const;
    │ │ │ -
    │ │ │ -   static inline constexpr file_flags_t flag_pad_file  = 0_bit;
    │ │ │ -   static inline constexpr file_flags_t flag_hidden  = 1_bit;
    │ │ │ -   static inline constexpr file_flags_t flag_executable  = 2_bit;
    │ │ │ -   static inline constexpr file_flags_t flag_symlink  = 3_bit;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    is_valid()

    │ │ │ -
    │ │ │ -bool is_valid () const;
    │ │ │ -
    │ │ │ -

    returns true if the piece length has been initialized │ │ │ -on the file_storage. This is typically taken as a proxy │ │ │ -of whether the file_storage as a whole is initialized or │ │ │ -not.

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

    reserve()

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

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

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

    add_file_borrow() add_file()

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

    Adds a file to the file storage. The add_file_borrow version │ │ │ -expects that filename is the file name (without a path) of │ │ │ -the file that's being added. │ │ │ -This memory is borrowed, i.e. it is the caller's │ │ │ -responsibility to make sure it stays valid throughout the lifetime │ │ │ -of this file_storage object or any copy of it. The same thing applies │ │ │ -to filehash, which is an optional pointer to a 20 byte binary │ │ │ -SHA-1 hash of the file.

    │ │ │ -

    if filename is empty, the filename from path is used and not │ │ │ -borrowed.

    │ │ │ -

    The path argument is the full path (in the torrent file) to │ │ │ -the file to add. Note that this is not supposed to be an absolute │ │ │ -path, but it is expected to include the name of the torrent as the │ │ │ -first path element.

    │ │ │ -

    file_size is the size of the file in bytes.

    │ │ │ -

    The file_flags argument sets attributes on the file. The file │ │ │ -attributes is an extension and may not work in all bittorrent clients.

    │ │ │ -

    For possible file attributes, see file_storage::flags_t.

    │ │ │ -

    The mtime argument is optional and can be set to 0. If non-zero, │ │ │ -it is the posix time of the last modification time of this file.

    │ │ │ -

    symlink_path is the path the file is a symlink to. To make this a │ │ │ -symlink you also need to set the file_storage::flag_symlink file flag.

    │ │ │ -

    root_hash is an optional pointer to a 32 byte SHA-256 hash, being │ │ │ -the merkle tree root hash for this file. This is only used for v2 │ │ │ -torrents. If the root hash is specified for one file, it has to │ │ │ -be specified for all, otherwise this function will fail. │ │ │ -Note that the buffer root_hash points to must out-live the │ │ │ -file_storage object, it will not be copied. This parameter is only │ │ │ -used when loading torrents, that already have their file hashes │ │ │ -computed. When creating torrents, the file hashes will be computed by │ │ │ -the piece hashes.

    │ │ │ -

    If more files than one are added, certain restrictions to their paths │ │ │ -apply. In a multi-file file storage (torrent), all files must share │ │ │ -the same root directory.

    │ │ │ -

    That is, the first path element of all files must be the same. │ │ │ -This shared path element is also set to the name of the torrent. It │ │ │ -can be changed by calling set_name.

    │ │ │ -

    The overloads that take an error_code reference will report failures │ │ │ -via that variable, otherwise system_error is thrown.

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

    add_file_borrow() add_file()

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

    these overloads report failures through the ec reference │ │ │ -rather than throwing. add_file_borrow() does not copy the │ │ │ -filename string; it is borrowed by reference and the caller │ │ │ -must keep it alive for the lifetime of this file_storage │ │ │ -object. This is useful when constructing the file list from a │ │ │ -memory-mapped .torrent file.

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

    map_block()

    │ │ │ -
    │ │ │ -std::vector<file_slice> map_block (piece_index_t piece, std::int64_t offset
    │ │ │ -      , std::int64_t size) const;
    │ │ │ -
    │ │ │ -

    returns a list of file_slice objects representing the portions of │ │ │ -files the specified piece index, byte offset and size range overlaps. │ │ │ -this is the inverse mapping of map_file().

    │ │ │ -

    Preconditions of this function is that the input range is within the │ │ │ -torrents address space. piece may not be negative and

    │ │ │ -
    │ │ │ -piece * piece_size + offset + size
    │ │ │ -

    may not exceed the total size of the torrent.

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

    map_file()

    │ │ │ -
    │ │ │ -peer_request map_file (file_index_t file, std::int64_t offset, int size) const;
    │ │ │ -
    │ │ │ -

    returns a peer_request representing the piece index, byte offset │ │ │ -and size the specified file range overlaps. This is the inverse │ │ │ -mapping over map_block(). Note that the peer_request return type │ │ │ -is meant to hold bittorrent block requests, which may not be larger │ │ │ -than 16 kiB. Mapping a range larger than that may return an overflown │ │ │ -integer.

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

    num_files()

    │ │ │ -
    │ │ │ -int num_files () const noexcept;
    │ │ │ -
    │ │ │ -

    returns the number of files in the file_storage

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

    end_file()

    │ │ │ -
    │ │ │ -file_index_t end_file () const noexcept;
    │ │ │ -
    │ │ │ -

    returns the index of the one-past-end file in the file storage

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

    file_range()

    │ │ │ -
    │ │ │ -index_range<file_index_t> file_range () const noexcept;
    │ │ │ -
    │ │ │ -

    returns an implementation-defined type that can be used as the │ │ │ -container in a range-for loop. Where the values are the indices of all │ │ │ -files in the file_storage.

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

    total_size()

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

    returns the total number of bytes all the files in this torrent spans │ │ │ -including pad files

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

    size_on_disk()

    │ │ │ -
    │ │ │ -std::int64_t size_on_disk () const;
    │ │ │ -
    │ │ │ -

    returns the sum of all non pad file sizes

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

    set_num_pieces() num_pieces()

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

    set and get the number of pieces in the torrent

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

    end_piece()

    │ │ │ -
    │ │ │ -piece_index_t end_piece () const;
    │ │ │ -
    │ │ │ -

    returns the index of the one-past-end piece in the file storage

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

    last_piece()

    │ │ │ -
    │ │ │ -piece_index_t last_piece () const;
    │ │ │ -
    │ │ │ -

    returns the index of the last piece in the torrent. The last piece is │ │ │ -special in that it may be smaller than the other pieces (and the other │ │ │ -pieces are all the same size).

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

    piece_range()

    │ │ │ -
    │ │ │ -index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ -
    │ │ │ -

    returns an implementation-defined type that can be used as the │ │ │ -container in a range-for loop. Where the values are the indices of all │ │ │ -pieces in the file_storage.

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

    set_piece_length() piece_length()

    │ │ │ -
    │ │ │ -int piece_length () const;
    │ │ │ -void set_piece_length (int l);
    │ │ │ -
    │ │ │ -

    set and get the size of each piece in this torrent. It must be a power of two │ │ │ -and at least 16 kiB.

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

    piece_size()

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

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

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

    piece_size2()

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

    Returns the size of the given piece. If the piece spans multiple files, │ │ │ -only the first file is considered part of the piece. This is used for │ │ │ -v2 torrents, where all files are piece aligned and padded. i.e. The pad │ │ │ -files are not considered part of the piece for this purpose.

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

    blocks_in_piece2()

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

    returns the number of blocks in the specified piece, for v2 torrents.

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

    blocks_per_piece()

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

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

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

    set_name() name()

    │ │ │ -
    │ │ │ -void set_name (std::string const& n);
    │ │ │ -std::string const& name () const;
    │ │ │ -
    │ │ │ -

    set and get the name of this torrent. For multi-file torrents, this is also │ │ │ -the name of the root directory all the files are stored in.

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

    swap()

    │ │ │ -
    │ │ │ -void swap (file_storage& ti) noexcept;
    │ │ │ -
    │ │ │ -

    swap all content of this with ti.

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

    file_piece_range() file_num_pieces() file_num_blocks()

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

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

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

    file_first_piece_node() file_first_block_node()

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

    index of first piece node in the merkle tree

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

    file_path_hash()

    │ │ │ -
    │ │ │ -std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const;
    │ │ │ -
    │ │ │ -

    returns the crc32 hash of file_path(index)

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

    all_path_hashes()

    │ │ │ -
    │ │ │ -void all_path_hashes (std::unordered_set<std::uint32_t>& table) const;
    │ │ │ -
    │ │ │ -

    this will add the CRC32 hash of all directory entries to the table. No │ │ │ -filename will be included, just directories. Every depth of directories │ │ │ -are added separately to allow test for collisions with files at all │ │ │ -levels. i.e. if one path in the torrent is foo/bar/baz, the CRC32 │ │ │ -hashes for foo, foo/bar and foo/bar/baz will be added to │ │ │ -the set.

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

    file_flags()

    │ │ │ -
    │ │ │ -file_flags_t file_flags (file_index_t index) const;
    │ │ │ -
    │ │ │ -

    returns a bitmask of flags from file_flags_t that apply │ │ │ -to file at index.

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

    file_absolute_path()

    │ │ │ -
    │ │ │ -bool file_absolute_path (file_index_t index) const;
    │ │ │ -
    │ │ │ -

    returns true if the file at the specified index has been renamed to │ │ │ -have an absolute path, i.e. is not anchored in the save path of the │ │ │ -torrent.

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

    last_file_index_at_piece() file_index_at_offset() file_index_at_piece()

    │ │ │ -
    │ │ │ -file_index_t file_index_at_piece (piece_index_t piece) const;
    │ │ │ -file_index_t last_file_index_at_piece (piece_index_t piece) const;
    │ │ │ -file_index_t file_index_at_offset (std::int64_t offset) const;
    │ │ │ -
    │ │ │ -

    returns the index of the file at the given offset or piece in the torrent

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

    file_index_for_root()

    │ │ │ -
    │ │ │ -file_index_t file_index_for_root (sha256_hash const& root_hash) const;
    │ │ │ -
    │ │ │ -

    finds the file with the given root hash and returns its index │ │ │ -if there is no file with the root hash, file_index_t{-1} is returned

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

    piece_index_at_file() last_piece_index_at_file()

    │ │ │ -
    │ │ │ -piece_index_t last_piece_index_at_file (file_index_t f) const;
    │ │ │ -piece_index_t piece_index_at_file (file_index_t f) const;
    │ │ │ -
    │ │ │ -

    returns the first or last piece index of the given file in the torrent

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

    v2()

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

    returns true if this torrent contains v2 metadata.

    │ │ │ -[report issue]
    │ │ │ -
    flag_pad_file
    │ │ │ -
    the file is a pad file. It's required to contain zeros │ │ │ -at it will not be saved to disk. Its purpose is to make │ │ │ -the following file start on a piece boundary.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flag_hidden
    │ │ │ -
    this file has the hidden attribute set. This is primarily │ │ │ -a windows attribute
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flag_executable
    │ │ │ -
    this file has the executable attribute set.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flag_symlink
    │ │ │ -
    this file is a symbolic link. It should have a link │ │ │ -target string associated with it.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    renamed_files

    │ │ │ -

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ -

    this is a wrapper around file_storage for renaming files without having │ │ │ -to mutate the file_storage object itself.

    │ │ │ -
    │ │ │ -struct renamed_files
    │ │ │ -{
    │ │ │ -   std::string file_path (file_storage const& fs, file_index_t index, std::string const& save_path = "") const;
    │ │ │ -   bool file_absolute_path (file_storage const& fs, file_index_t index) const;
    │ │ │ -   string_view file_name (file_storage const& fs, file_index_t index) const;
    │ │ │ -   void rename_file (file_storage const& fs, file_index_t index, std::string const& new_filename);
    │ │ │ -   void import_filenames (file_storage const& fs, std::map<file_index_t, std::string> const& renamed_files);
    │ │ │ -   std::map<file_index_t, std::string> export_filenames (file_storage const& fs) const;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    file_path() file_name() file_absolute_path()

    │ │ │ -
    │ │ │ -std::string file_path (file_storage const& fs, file_index_t index, std::string const& save_path = "") const;
    │ │ │ -bool file_absolute_path (file_storage const& fs, file_index_t index) const;
    │ │ │ -string_view file_name (file_storage const& fs, file_index_t index) const;
    │ │ │ -
    │ │ │ -

    returns information about the file at index in fs, │ │ │ -honoring any rename recorded in this object. │ │ │ -file_path() returns the full on-disk path (prepending │ │ │ -save_path to relative paths). file_name() returns │ │ │ -just the leaf filename. file_absolute_path() returns │ │ │ -true if the recorded rename is an absolute path (in which │ │ │ -case save_path is ignored).

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

    rename_file()

    │ │ │ -
    │ │ │ -void rename_file (file_storage const& fs, file_index_t index, std::string const& new_filename);
    │ │ │ -
    │ │ │ -

    records that the file at index in fs should be │ │ │ -renamed to new_filename on disk. The underlying │ │ │ -file_storage is not modified.

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

    export_filenames() import_filenames()

    │ │ │ -
    │ │ │ -void import_filenames (file_storage const& fs, std::map<file_index_t, std::string> const& renamed_files);
    │ │ │ -std::map<file_index_t, std::string> export_filenames (file_storage const& fs) const;
    │ │ │ -
    │ │ │ -

    bulk import or export the set of file renames recorded in │ │ │ -this object. import_filenames() adds the given renames │ │ │ -(dropping entries whose file index is out of range). │ │ │ -export_filenames() returns the current renames as a map │ │ │ -suitable for serializing and later passing back to │ │ │ -import_filenames().

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

    filenames

    │ │ │ -

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ -

    a lightweight view that pairs a file_storage with the rename │ │ │ -overrides in a renamed_files. It exposes the read-only subset │ │ │ -of file_storage that downstream code (e.g. the disk I/O │ │ │ -backends) needs, with file paths automatically resolved through │ │ │ -the rename layer.

    │ │ │ -
    │ │ │ -struct filenames
    │ │ │ -{
    │ │ │ -   filenames (file_storage const& fs, renamed_files const& rf);
    │ │ │ -   file_flags_t file_flags (file_index_t const index) const;
    │ │ │ -   file_index_t end_file () const noexcept;
    │ │ │ -   bool pad_file_at (file_index_t const index) const;
    │ │ │ -   std::int64_t file_size (file_index_t const index) const;
    │ │ │ -   std::int64_t file_offset (file_index_t const index) const;
    │ │ │ -   bool file_absolute_path (file_index_t const index) const;
    │ │ │ -   std::string file_path (file_index_t const index, std::string const& save_path = "") const;
    │ │ │ -   std::string symlink (file_index_t const index) const;
    │ │ │ -   index_range<file_index_t> file_range () const noexcept;
    │ │ │ -   int num_pieces () const;
    │ │ │ -   piece_index_t end_piece () const;
    │ │ │ -   int num_files () const noexcept;
    │ │ │ -   std::vector<file_slice> map_block (piece_index_t const piece, std::int64_t const offset
    │ │ │ -      , std::int64_t const size) const;
    │ │ │ -   peer_request map_file (file_index_t const file, std::int64_t const offset, int const size) const;
    │ │ │ -   sha256_hash root (file_index_t const index) const;
    │ │ │ -   int piece_length () const;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    filenames()

    │ │ │ -
    │ │ │ -filenames (file_storage const& fs, renamed_files const& rf);
    │ │ │ -
    │ │ │ -

    construct a view over fs with the renames recorded in │ │ │ -rf applied. Both references must outlive the view.

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

    file_flags()

    │ │ │ -
    │ │ │ -file_flags_t file_flags (file_index_t const index) const;
    │ │ │ -
    │ │ │ -

    returns the file flags for the file at index

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

    end_file()

    │ │ │ -
    │ │ │ -file_index_t end_file () const noexcept;
    │ │ │ -
    │ │ │ -

    one past-the-end file index

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

    pad_file_at()

    │ │ │ -
    │ │ │ -bool pad_file_at (file_index_t const index) const;
    │ │ │ -
    │ │ │ -

    returns true if the file at index is a pad file

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

    file_size() file_offset()

    │ │ │ -
    │ │ │ -std::int64_t file_size (file_index_t const index) const;
    │ │ │ -std::int64_t file_offset (file_index_t const index) const;
    │ │ │ -
    │ │ │ -

    returns the file size or file offset for the file at index. The │ │ │ -file offset is in the torrent space, of all files in the torrent, in │ │ │ -the order they are defined.

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

    file_path() file_absolute_path()

    │ │ │ -
    │ │ │ -bool file_absolute_path (file_index_t const index) const;
    │ │ │ -std::string file_path (file_index_t const index, std::string const& save_path = "") const;
    │ │ │ -
    │ │ │ -

    returns the on-disk path for the file at index, applying │ │ │ -any rename recorded in the underlying renamed_files. If │ │ │ -save_path is non-empty it is prepended to relative │ │ │ -paths. file_absolute_path() returns true if the recorded │ │ │ -rename is an absolute path (in which case save_path is │ │ │ -ignored).

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

    file_range()

    │ │ │ -
    │ │ │ -index_range<file_index_t> file_range () const noexcept;
    │ │ │ -
    │ │ │ -

    all file indices in the underlying file_storage. Convenient in │ │ │ -range-for loops.

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

    num_files() end_piece() num_pieces()

    │ │ │ -
    │ │ │ -int num_pieces () const;
    │ │ │ -piece_index_t end_piece () const;
    │ │ │ -int num_files () const noexcept;
    │ │ │ -
    │ │ │ -

    the number of files in the underlying file_storage, the │ │ │ -number of pieces, and the one-past-the-end piece index.

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

    map_block()

    │ │ │ -
    │ │ │ -std::vector<file_slice> map_block (piece_index_t const piece, std::int64_t const offset
    │ │ │ -      , std::int64_t const size) const;
    │ │ │ -
    │ │ │ -

    returns the list of file slices that make up the piece at │ │ │ -piece, starting at offset into the piece and │ │ │ -covering size bytes. Each entry identifies one file and │ │ │ -the byte range within it that contributes to the requested │ │ │ -block.

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

    map_file()

    │ │ │ -
    │ │ │ -peer_request map_file (file_index_t const file, std::int64_t const offset, int const size) const;
    │ │ │ -
    │ │ │ -

    inverse of map_block(): maps a byte range within the │ │ │ -file at file (starting at offset, of length │ │ │ -size) to a peer_request identifying the piece, │ │ │ -piece-offset and length in torrent space.

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

    root()

    │ │ │ -
    │ │ │ -sha256_hash root (file_index_t const index) const;
    │ │ │ -
    │ │ │ -

    returns the v2 merkle root (pieces root) for the file │ │ │ -at index. Returns a zero hash for v1-only torrents.

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

    piece_length()

    │ │ │ -
    │ │ │ -int piece_length () const;
    │ │ │ -
    │ │ │ -

    the piece size, in bytes. All pieces have this size except │ │ │ -the last, which may be shorter.

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

    storage_params

    │ │ │ -

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ -

    a parameter pack used to construct the storage for a torrent, used in │ │ │ -disk_interface

    │ │ │ -
    │ │ │ -struct storage_params
    │ │ │ -{
    │ │ │ -   storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ -      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ -      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ -      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ -
    │ │ │ -   file_storage const& files;
    │ │ │ -   lt::renamed_files const& renamed_files;
    │ │ │ -   string_view path;
    │ │ │ -   string_view part_file_dir;
    │ │ │ -   storage_mode_t mode {storage_mode_sparse};
    │ │ │ -   aux::vector<download_priority_t, file_index_t> const& priorities;
    │ │ │ -   sha1_hash info_hash;
    │ │ │ -   bool v1;
    │ │ │ -   bool v2;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    storage_params()

    │ │ │ +

    returns the current value of counter or gauge i (an index into │ │ │ +the counter array).

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

    blend_stats_counter() set_value()

    │ │ │
    │ │ │ -storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ -      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ -      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ -      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ +void set_value (int c, std::int64_t value) ;
    │ │ │ +void blend_stats_counter (int c, std::int64_t value, int ratio) ;
    │ │ │  
    │ │ │ -

    constructs a parameter pack from the layout, save path, mode, │ │ │ -per-file priorities, info-hash and protocol-version flags. │ │ │ -v1 indicates that the torrent has v1 metadata (a SHA-1 │ │ │ -info-hash); v2 that it has v2 metadata (BEP 52). A hybrid │ │ │ -torrent has both set.

    │ │ │ -[report issue]
    │ │ │ -
    files
    │ │ │ -
    the file layout (sizes, paths, flags) of the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    renamed_files
    │ │ │ -
    rename overlay applied on top of files; on-disk paths │ │ │ -resolved through this object take precedence over the │ │ │ -originals
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    path
    │ │ │ -
    the directory where the torrent's files are stored
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    part_file_dir
    │ │ │ -
    directory in which the part file is created. If empty, the │ │ │ -part file is placed under path.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    mode
    │ │ │ -
    the storage allocation mode (sparse vs. pre-allocated)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    priorities
    │ │ │ -
    per-file download priorities, indexed by file index
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hash
    │ │ │ -
    the SHA-1 info-hash of the torrent (zero for v2-only │ │ │ -torrents)
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    v1 v2
    │ │ │ -
    indicates which BitTorrent protocol version(s) this storage │ │ │ -is for. v1 is true if the torrent has v1 metadata; │ │ │ -v2 is true if the torrent has v2 metadata (BEP 52). A │ │ │ -hybrid torrent has both flags set.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ +

    overwrites the value of counter or gauge c (an index into │ │ │ +the counter array). blend_stats_counter() adjusts the stat value │ │ │ +toward the specified value, ratio specifies the percent of │ │ │ +the new value should be influenced by value.

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

    disabled_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/disabled_disk_io.hpp"

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

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

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

    mmap_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/mmap_disk_io.hpp"

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

    constructs a memory mapped file disk I/O object.

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

    posix_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/posix_disk_io.hpp"

    │ │ │ +
    │ │ │ +

    session_stats_metrics()

    │ │ │ +

    Declared in "libtorrent/session_stats.hpp"

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

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

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

    default_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/session.hpp"

    │ │ │ +

    This free function returns the list of available metrics exposed by │ │ │ +libtorrent's statistics API. Each metric has a name and a value index. │ │ │ +The value index is the index into the array in session_stats_alert where │ │ │ +this metric's value can be found when the session stats is sampled (by │ │ │ +calling post_session_stats()).

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

    find_metric_idx()

    │ │ │ +

    Declared in "libtorrent/session_stats.hpp"

    │ │ │
    │ │ │ -std::unique_ptr<disk_interface> default_disk_io_constructor (
    │ │ │ -   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ +int find_metric_idx (string_view name);
    │ │ │  
    │ │ │ -

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

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

    enum storage_mode_t

    │ │ │ -

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    storage_mode_allocate0All pieces will be written to their final position, all files will be │ │ │ -allocated in full when the torrent is first started. This mode minimizes │ │ │ -fragmentation but could be a costly operation.
    storage_mode_sparse1All pieces will be written to the place where they belong and sparse files │ │ │ -will be used. This is the recommended, and default mode.
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum move_flags_t

    │ │ │ -

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ +

    given a name of a metric, this function returns the counter index of it, │ │ │ +or -1 if it could not be found. The counter index is the index into the │ │ │ +values array returned by session_stats_alert.

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

    enum metric_type_t

    │ │ │ +

    Declared in "libtorrent/session_stats.hpp"

    │ │ │ │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescription
    always_replace_files
    counter0replace any files in the destination when copying │ │ │ -or moving the storage 
    fail_if_exist
    gauge1if any files that we want to copy exist in the destination │ │ │ -exist, fail the whole operation and don't perform │ │ │ -any copy or move. There is an inherent race condition │ │ │ -in this mode. The files are checked for existence before │ │ │ -the operation starts. In between the check and performing │ │ │ -the copy, the destination files may be created, in which │ │ │ -case they are replaced.
    dont_replace2if any file exist in the target, take those files instead │ │ │ -of the ones we may have in the source.
    reset_save_path3don't move any source files, just forget about them │ │ │ -and begin checking files at new save path
    reset_save_path_unchecked4don't move any source files, just change save path │ │ │ -and continue working without any checks 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    client_data_t

    │ │ │ -

    Declared in "libtorrent/client_data.hpp"

    │ │ │ -

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

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

    client_data_t()

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

    construct a nullptr client data

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

    client_data_t()

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

    initialize the client data with the specified pointer

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

    operator=()

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

    assigns a new pointer to the client data

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

    T() get()

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

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

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

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

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

    we don't allow type-unsafe operations

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

    add_torrent_params

    │ │ │ -

    Declared in "libtorrent/add_torrent_params.hpp"

    │ │ │ -

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

    │ │ │ -
      │ │ │ -
    • ti - the immutable info-dict part of the torrent
    • │ │ │ -
    • info_hash - when you don't have the metadata (.torrent file). This │ │ │ -uniquely identifies the torrent and can validate the info-dict when │ │ │ -received from the swarm.
    • │ │ │ -
    │ │ │ -

    In order to add a torrent to a session, one of those fields must be set │ │ │ -in addition to save_path. The add_torrent_params object can then be │ │ │ -passed into one of the session::add_torrent() overloads or │ │ │ -session::async_add_torrent().

    │ │ │ -

    If you only specify the info-hash, the torrent file will be downloaded │ │ │ -from peers, which requires them to support the metadata extension. For │ │ │ -the metadata extension to work, libtorrent must be built with extensions │ │ │ -enabled (TORRENT_DISABLE_EXTENSIONS must not be defined). It also │ │ │ -takes an optional name argument. This may be left empty in case no │ │ │ -name should be assigned to the torrent. In case it's not, the name is │ │ │ -used for the torrent as long as it doesn't have metadata. See │ │ │ -torrent_handle::name.

    │ │ │ -

    The add_torrent_params is also used when requesting resume data for a │ │ │ -torrent. It can be saved to and restored from a file and added back to a │ │ │ -new session. For serialization and de-serialization of │ │ │ -add_torrent_params objects, see read_resume_data() and │ │ │ -write_resume_data().

    │ │ │ -

    The add_torrent_params is also used to represent a parsed .torrent │ │ │ -file. It can be loaded via load_torrent_file(), load_torrent_buffer() and │ │ │ -load_torrent_parsed(). It can be saved via write_torrent_file().

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

    announce_infohash

    │ │ │ +

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ +

    holds the per-info-hash state for a tracker, separately for the v1 │ │ │ +and v2 info-hashes. Since a hybrid torrent has both info-hashes, the │ │ │ +state for the two announces (the message returned by the tracker, the │ │ │ +time of the next announce, the most recent scrape numbers, etc.) are │ │ │ +kept independently. announce_endpoint owns one announce_infohash │ │ │ +for each protocol version.

    │ │ │
    │ │ │ -struct add_torrent_params
    │ │ │ +struct announce_infohash
    │ │ │  {
    │ │ │ -   int version  = LIBTORRENT_VERSION_NUM;
    │ │ │ -   std::shared_ptr<torrent_info const> ti;
    │ │ │ -   std::vector<std::string> trackers;
    │ │ │ -   std::vector<int> tracker_tiers;
    │ │ │ -   std::vector<std::pair<std::string, int>> dht_nodes;
    │ │ │ -   std::string name;
    │ │ │ -   std::string save_path;
    │ │ │ -   std::string part_file_dir;
    │ │ │ -   storage_mode_t storage_mode  = storage_mode_sparse;
    │ │ │ -   client_data_t userdata;
    │ │ │ -   std::vector<download_priority_t> file_priorities;
    │ │ │ -   std::string trackerid;
    │ │ │ -   torrent_flags_t flags  = torrent_flags::default_flags;
    │ │ │ -   info_hash_t info_hashes;
    │ │ │ -   int max_uploads  = -1;
    │ │ │ -   int max_connections  = -1;
    │ │ │ -   int upload_limit  = -1;
    │ │ │ -   int download_limit  = -1;
    │ │ │ -   std::int64_t total_uploaded  = 0;
    │ │ │ -   std::int64_t total_downloaded  = 0;
    │ │ │ -   int active_time  = 0;
    │ │ │ -   int finished_time  = 0;
    │ │ │ -   int seeding_time  = 0;
    │ │ │ -   std::time_t added_time  = 0;
    │ │ │ -   std::time_t completed_time  = 0;
    │ │ │ -   std::time_t last_seen_complete  = 0;
    │ │ │ -   int num_complete  = -1;
    │ │ │ -   int num_incomplete  = -1;
    │ │ │ -   int num_downloaded  = -1;
    │ │ │ -   std::vector<std::string> url_seeds;
    │ │ │ -   std::vector<tcp::endpoint> peers;
    │ │ │ -   std::vector<tcp::endpoint> banned_peers;
    │ │ │ -   aux::noexcept_movable<std::map<piece_index_t, bitfield>> unfinished_pieces;
    │ │ │ -   typed_bitfield<piece_index_t> have_pieces;
    │ │ │ -   typed_bitfield<piece_index_t> verified_pieces;
    │ │ │ -   std::vector<download_priority_t> piece_priorities;
    │ │ │ -   aux::vector<std::vector<sha256_hash>, file_index_t> merkle_trees;
    │ │ │ -   aux::vector<bitfield, file_index_t> merkle_tree_mask;
    │ │ │ -   aux::vector<bitfield, file_index_t> verified_leaf_hashes;
    │ │ │ -   aux::noexcept_movable<std::map<file_index_t, std::string>> renamed_files;
    │ │ │ -   std::time_t last_download  = 0;
    │ │ │ -   std::time_t last_upload  = 0;
    │ │ │ -   std::string comment;
    │ │ │ -   std::string created_by;
    │ │ │ -   std::time_t creation_date  = 0;
    │ │ │ -   std::string root_certificate;
    │ │ │ +   std::string message;
    │ │ │ +   error_code last_error;
    │ │ │ +   int scrape_incomplete  = -1;
    │ │ │ +   int scrape_complete  = -1;
    │ │ │ +   int scrape_downloaded  = -1;
    │ │ │ +   std::uint8_t fails : 7;
    │ │ │ +   bool updating : 1;
    │ │ │ +   bool start_sent : 1;
    │ │ │ +   bool complete_sent : 1;
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -
    version
    │ │ │ -
    filled in by the constructor and should be left untouched. It is used │ │ │ -for forward binary compatibility.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    ti
    │ │ │ -
    torrent_info object with the torrent to add. Unless the │ │ │ -info_hash is set, this is required to be initialized.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    trackers
    │ │ │ -
    If the torrent doesn't have a tracker, but relies on the DHT to find │ │ │ -peers, the trackers can specify tracker URLs for the torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    tracker_tiers
    │ │ │ -
    the tiers the URLs in trackers belong to. Trackers belonging to │ │ │ -different tiers may be treated differently, as defined by the multi │ │ │ -tracker extension. This is optional, if not specified trackers are │ │ │ -assumed to be part of tier 0, or whichever the last tier was as │ │ │ -iterating over the trackers.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    dht_nodes
    │ │ │ -
    a list of hostname and port pairs, representing DHT nodes to be added │ │ │ -to the session (if DHT is enabled). The hostname may be an IP address.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    name
    │ │ │ -
    in case there's no other name in this torrent, this name will be used. │ │ │ -The name out of the torrent_info object takes precedence if available.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    save_path
    │ │ │ -

    The path to the directory where the torrent is or will be stored.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    On windows this path (and other paths) are interpreted as UNC │ │ │ -paths. This means they must use backslashes as directory separators │ │ │ -and may not contain the special directories "." or "..".

    │ │ │ -
    │ │ │ -

    Setting this to an absolute path performs slightly better than a │ │ │ -relative path.

    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    part_file_dir
    │ │ │ -
    This is an optional field. If set, the part-file for this torrent │ │ │ -will be stored in the specified subdirectory, still inside its │ │ │ -download directory. i.e. part_file_dir is a relative directory. │ │ │ -The part file name is disambiguated by including the info-hash, in │ │ │ -hexadecimal form. By default it's stored directly in the download │ │ │ -directory. If the storage for a torrent is moved, the part file is │ │ │ -also moved along with it, to the new download directory. │ │ │ -A part file contains partial pieces that need to be downloaded in │ │ │ -order to verify hashes and seeding, but are part of files whose │ │ │ -priority is zero.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    storage_mode
    │ │ │ -
    One of the values from storage_mode_t. For more information, see │ │ │ -storage allocation.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    userdata
    │ │ │ -
    The userdata parameter is optional and will be passed on to the │ │ │ -extension constructor functions, if any │ │ │ -(see torrent_handle::add_extension()). It will also be stored in the │ │ │ -torrent object and can be retrieved by calling userdata().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    file_priorities
    │ │ │ -
    can be set to control the initial file priorities when adding a │ │ │ -torrent. The semantics are the same as for │ │ │ -torrent_handle::prioritize_files(). The file priorities specified │ │ │ -in here take precedence over those specified in the resume data, if │ │ │ -any. │ │ │ -If this vector of file priorities is shorter than the number of files │ │ │ -in the torrent, the remaining files (not covered by this) will still │ │ │ -have the default download priority. This default can be changed by │ │ │ -setting the default_dont_download torrent_flag.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    trackerid
    │ │ │ -
    the default tracker id to be used when announcing to trackers. By │ │ │ -default this is empty, and no tracker ID is used, since this is an │ │ │ -optional argument. If a tracker returns a tracker ID, that ID is used │ │ │ -instead of this.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flags
    │ │ │ -

    flags controlling aspects of this torrent and how it's added. See │ │ │ -torrent_flags_t for details.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    The flags field is initialized with default flags by the │ │ │ -constructor. In order to preserve default behavior when clearing or │ │ │ -setting other flags, make sure to bitwise OR or in a flag or bitwise │ │ │ -AND the inverse of a flag to clear it.

    │ │ │ -
    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hashes
    │ │ │ -
    set this to the info hash of the torrent to add in case the info-hash │ │ │ -is the only known property of the torrent. i.e. you don't have a │ │ │ -.torrent file nor a magnet link. │ │ │ -To add a magnet link, use parse_magnet_uri() to populate fields in the │ │ │ -add_torrent_params object.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    max_uploads max_connections
    │ │ │ -

    max_uploads, max_connections, upload_limit, │ │ │ -download_limit correspond to the set_max_uploads(), │ │ │ -set_max_connections(), set_upload_limit() and │ │ │ -set_download_limit() functions on torrent_handle. These values let │ │ │ -you initialize these settings when the torrent is added, instead of │ │ │ -calling these functions immediately following adding it.

    │ │ │ -

    -1 means unlimited on these settings just like their counterpart │ │ │ -functions on torrent_handle

    │ │ │ -

    For fine grained control over rate limits, including making them apply │ │ │ -to local peers, see peer classes.

    │ │ │ -
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    upload_limit download_limit
    │ │ │ -
    the upload and download rate limits for this torrent, specified in │ │ │ -bytes per second. -1 means unlimited.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    total_uploaded total_downloaded
    │ │ │ -
    the total number of bytes uploaded and downloaded by this torrent so │ │ │ -far.
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    active_time finished_time seeding_time
    │ │ │ -
    the number of seconds this torrent has spent in started, finished and │ │ │ -seeding state so far, respectively.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    added_time completed_time
    │ │ │ -
    if set to a non-zero value, this is the posix time of when this torrent │ │ │ -was first added, including previous runs/sessions. If set to zero, the │ │ │ -internal added_time will be set to the time of when add_torrent() is │ │ │ -called.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    last_seen_complete
    │ │ │ -
    if set to non-zero, initializes the time (expressed in posix time) when │ │ │ -we last saw a seed or peers that together formed a complete copy of the │ │ │ -torrent. If left set to zero, the internal counterpart to this field │ │ │ -will be updated when we see a seed or a distributed copies >= 1.0.
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    num_complete num_incomplete num_downloaded
    │ │ │ -

    these field can be used to initialize the torrent's cached scrape data. │ │ │ -The scrape data is high level metadata about the current state of the │ │ │ -swarm, as returned by the tracker (either when announcing to it or by │ │ │ -sending a specific scrape request). num_complete is the number of │ │ │ -peers in the swarm that are seeds, or have every piece in the torrent. │ │ │ -num_incomplete is the number of peers in the swarm that do not have │ │ │ -every piece. num_downloaded is the number of times the torrent has │ │ │ -been downloaded (not initiated, but the number of times a download has │ │ │ -completed).

    │ │ │ -

    Leaving any of these values set to -1 indicates we don't know, or we │ │ │ -have not received any scrape data.

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

    URLs can be added to these two lists to specify additional web │ │ │ -seeds to be used by the torrent. If the override_web_seeds flag │ │ │ -is set, these will be the _only_ ones to be used. i.e. any web seeds │ │ │ -found in the .torrent file will be overridden.

    │ │ │ -

    URLs are expected to be regular web servers, aka "get right" style, │ │ │ -specified in BEP 19.

    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    peers
    │ │ │ -
    peers to add to the torrent, to be tried to be connected to as │ │ │ -bittorrent peers.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    banned_peers
    │ │ │ -
    peers banned from this torrent. They will not be connected to
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    unfinished_pieces
    │ │ │ -
    this is a map of partially downloaded piece. The key is the piece index │ │ │ -and the value is a bitfield where each bit represents a 16 kiB block. │ │ │ -A set bit means we have that block.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    have_pieces
    │ │ │ -
    this is a bitfield indicating which pieces we already have of this │ │ │ -torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    verified_pieces
    │ │ │ -
    when in seed_mode, pieces with a set bit in this bitfield have been │ │ │ -verified to be valid. Other pieces will be verified the first time a │ │ │ -peer requests it.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    piece_priorities
    │ │ │ -
    this sets the priorities for each individual piece in the torrent. Each │ │ │ -element in the vector represent the piece with the same index. If you │ │ │ -set both file- and piece priorities, file priorities will take │ │ │ -precedence.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    merkle_trees
    │ │ │ -
    v2 hashes, if known
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    merkle_tree_mask
    │ │ │ -
    if set, indicates which hashes are included in the corresponding │ │ │ -vector of merkle_trees. These bitmasks always cover the full │ │ │ -tree, a cleared bit means the hash is all zeros (i.e. not set) and │ │ │ -set bit means the next hash in the corresponding vector in │ │ │ -merkle_trees is the hash for that node. This is an optimization │ │ │ -to avoid storing a lot of zeros.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    verified_leaf_hashes
    │ │ │ -
    bit-fields indicating which v2 leaf hashes have been verified │ │ │ -against the root hash. If this vector is empty and merkle_trees is │ │ │ -non-empty it implies that all hashes in merkle_trees are verified.
    │ │ │ +[report issue]
    │ │ │ +
    message
    │ │ │ +
    if this tracker has returned an error or warning message │ │ │ +that message is stored here
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    renamed_files
    │ │ │ -
    this is a map of file indices in the torrent and new filenames to be │ │ │ -applied before the torrent is added.
    │ │ │ +[report issue]
    │ │ │ +
    last_error
    │ │ │ +
    if this tracker failed the last time it was contacted │ │ │ +this error code specifies what error occurred
    │ │ │
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    last_download last_upload
    │ │ │ -
    the posix time of the last time payload was received or sent for this │ │ │ -torrent, respectively. A value of 0 means we don't know when we last │ │ │ -uploaded or downloaded, or we have never uploaded or downloaded any │ │ │ -payload for this torrent.
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    scrape_incomplete scrape_complete scrape_downloaded
    │ │ │ +
    if this tracker has returned scrape data, these fields are filled in │ │ │ +with valid numbers. Otherwise they are set to -1. incomplete counts │ │ │ +the number of current downloaders. complete counts the number of │ │ │ +current peers completed the download, or "seeds". downloaded is the │ │ │ +cumulative number of completed downloads.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    comment
    │ │ │ -
    if a comment is found in the torrent file │ │ │ -this will be set to that comment
    │ │ │ +[report issue]
    │ │ │ +
    fails
    │ │ │ +
    the number of times in a row we have failed to announce to this │ │ │ +tracker.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    created_by
    │ │ │ -
    an optional string naming the software used │ │ │ -to create the torrent file
    │ │ │ +[report issue]
    │ │ │ +
    updating
    │ │ │ +
    true while we're waiting for a response from the tracker.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    creation_date
    │ │ │ -
    if a creation date is found in the torrent file │ │ │ -this will be set to that, otherwise it'll be │ │ │ -1970, Jan 1
    │ │ │ +[report issue]
    │ │ │ +
    start_sent
    │ │ │ +
    set to true when we get a valid response from an announce │ │ │ +with event=started. If it is set, we won't send start in the subsequent │ │ │ +announces.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    root_certificate
    │ │ │ -
    If this torrent is an infohash only SSL torrent, specify the root │ │ │ -certificate here. │ │ │ -If a peer does not have a matching certificate during metadata │ │ │ -exchange it will be rejected and the download will not proceed.
    │ │ │ +[report issue]
    │ │ │ +
    complete_sent
    │ │ │ +
    set to true when we send a event=completed.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_class_info

    │ │ │ -

    Declared in "libtorrent/peer_class.hpp"

    │ │ │ -

    holds settings for a peer class. Used in set_peer_class() and │ │ │ -get_peer_class() calls.

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

    announce_endpoint

    │ │ │ +

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ +

    announces are sent to each tracker using every listen socket │ │ │ +this class holds information about one listen socket for one tracker

    │ │ │
    │ │ │ -struct peer_class_info
    │ │ │ +struct announce_endpoint
    │ │ │  {
    │ │ │ -   bool ignore_unchoke_slots;
    │ │ │ -   int connection_limit_factor;
    │ │ │ -   std::string label;
    │ │ │ -   int upload_limit;
    │ │ │ -   int download_limit;
    │ │ │ -   int upload_priority;
    │ │ │ -   int download_priority;
    │ │ │ +   announce_endpoint ();
    │ │ │ +
    │ │ │ +   tcp::endpoint local_endpoint;
    │ │ │ +   aux::array<announce_infohash, num_protocols, protocol_version> info_hashes;
    │ │ │ +   bool enabled  = true;
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -
    ignore_unchoke_slots
    │ │ │ -
    ignore_unchoke_slots determines whether peers should always │ │ │ -unchoke a peer, regardless of the choking algorithm, or if it should │ │ │ -honor the unchoke slot limits. It's used for local peers by default. │ │ │ -If any of the peer classes a peer belongs to has this set to true, │ │ │ -that peer will be unchoked at all times.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    connection_limit_factor
    │ │ │ -
    adjusts the connection limit (global and per torrent) that applies to │ │ │ -this peer class. By default, local peers are allowed to exceed the │ │ │ -normal connection limit for instance. This is specified as a percent │ │ │ -factor. 100 makes the peer class apply normally to the limit. 200 │ │ │ -means as long as there are fewer connections than twice the limit, we │ │ │ -accept this peer. This factor applies both to the global connection │ │ │ -limit and the per-torrent limit. Note that if not used carefully one │ │ │ -peer class can potentially completely starve out all other over time.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    label
    │ │ │ -
    not used by libtorrent. It's intended as a potentially user-facing │ │ │ -identifier of this peer class.
    │ │ │ +[report issue]
    │ │ │ +
    local_endpoint
    │ │ │ +
    the local endpoint of the listen interface associated with this endpoint
    │ │ │
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    upload_limit download_limit
    │ │ │ -
    transfer rates limits for the whole peer class. They are specified in │ │ │ -bytes per second and apply to the sum of all peers that are members of │ │ │ -this class.
    │ │ │ +[report issue]
    │ │ │ +
    info_hashes
    │ │ │ +
    info_hashes[0] is the v1 info hash (SHA1) │ │ │ +info_hashes[1] is the v2 info hash (truncated SHA-256)
    │ │ │
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    upload_priority download_priority
    │ │ │ -
    relative priorities used by the bandwidth allocator in the rate │ │ │ -limiter. If no rate limits are in use, the priority is not used │ │ │ -either. Priorities start at 1 (0 is not a valid priority) and may not │ │ │ -exceed 255.
    │ │ │ +[report issue]
    │ │ │ +
    enabled
    │ │ │ +
    set to false to not announce from this endpoint
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_class_type_filter

    │ │ │ -

    Declared in "libtorrent/peer_class_type_filter.hpp"

    │ │ │ -

    peer_class_type_filter is a simple container for rules for adding and subtracting │ │ │ -peer-classes from peers. It is applied after the peer class filter is applied (which │ │ │ -is based on the peer's IP address).

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

    announce_entry

    │ │ │ +

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ +

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

    │ │ │
    │ │ │ -struct peer_class_type_filter
    │ │ │ +struct announce_entry
    │ │ │  {
    │ │ │ -   void remove (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -   void add (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -   void allow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -   void disallow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -   std::uint32_t apply (socket_type_t const st, std::uint32_t peer_class_mask);
    │ │ │ -   friend bool operator== (peer_class_type_filter const& lhs
    │ │ │ -      , peer_class_type_filter const& rhs);
    │ │ │ +   explicit announce_entry (string_view u);
    │ │ │ +   announce_entry& operator= (announce_entry const&) &;
    │ │ │ +   announce_entry ();
    │ │ │ +   announce_entry (announce_entry const&);
    │ │ │ +   ~announce_entry ();
    │ │ │  
    │ │ │ -   enum socket_type_t
    │ │ │ +   enum tracker_source
    │ │ │     {
    │ │ │ -      tcp_socket,
    │ │ │ -      utp_socket,
    │ │ │ -      ssl_tcp_socket,
    │ │ │ -      ssl_utp_socket,
    │ │ │ -      i2p_socket,
    │ │ │ -      rtc_socket,
    │ │ │ -      num_socket_types,
    │ │ │ +      source_torrent,
    │ │ │ +      source_client,
    │ │ │ +      source_magnet_link,
    │ │ │ +      source_tex,
    │ │ │     };
    │ │ │ +
    │ │ │ +   std::string url;
    │ │ │ +   std::string trackerid;
    │ │ │ +   std::vector<announce_endpoint> endpoints;
    │ │ │ +   std::uint8_t tier  = 0;
    │ │ │ +   std::uint8_t fail_limit  = 0;
    │ │ │ +   std::uint8_t source:4;
    │ │ │ +   bool verified:1;
    │ │ │  };
    │ │ │  
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    remove() add()

    │ │ │ -
    │ │ │ -void remove (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -void add (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -
    │ │ │ -

    add() and remove() adds and removes a peer class to be added │ │ │ -to new peers based on socket type.

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

    allow() disallow()

    │ │ │ -
    │ │ │ -void allow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -void disallow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ -
    │ │ │ -

    disallow() and allow() adds and removes a peer class to be │ │ │ -removed from new peers based on socket type.

    │ │ │ -

    The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ -peer classes in the peer_class_type_filter are 32 bits.

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

    apply()

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

    operator=() announce_entry() ~announce_entry()

    │ │ │
    │ │ │ -std::uint32_t apply (socket_type_t const st, std::uint32_t peer_class_mask);
    │ │ │ +explicit announce_entry (string_view u);
    │ │ │ +announce_entry& operator= (announce_entry const&) &;
    │ │ │ +announce_entry ();
    │ │ │ +announce_entry (announce_entry const&);
    │ │ │ +~announce_entry ();
    │ │ │  
    │ │ │ -

    takes a bitmask of peer classes and returns a new bitmask of │ │ │ -peer classes after the rules have been applied, based on the socket type argument │ │ │ -(st).

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

    enum socket_type_t

    │ │ │ -

    Declared in "libtorrent/peer_class_type_filter.hpp"

    │ │ │ +

    constructs a tracker announce entry with u as the URL.

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

    enum tracker_source

    │ │ │ +

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    tcp_socket0 
    utp_socket
    source_torrent1 the tracker was part of the .torrent file
    ssl_tcp_socket
    source_client2 
    ssl_utp_socket3 the tracker was added programmatically via the add_tracker() function
    i2p_socket
    source_magnet_link4 
    rtc_socket5 
    num_socket_types6 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    block_info

    │ │ │ -

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ -

    holds the state of a block in a piece. Who we requested │ │ │ -it from and how far along we are at downloading it.

    │ │ │ -
    │ │ │ -struct block_info
    │ │ │ -{
    │ │ │ -   tcp::endpoint peer () const;
    │ │ │ -   void set_peer (tcp::endpoint const& ep);
    │ │ │ -
    │ │ │ -   enum block_state_t
    │ │ │ -   {
    │ │ │ -      none,
    │ │ │ -      requested,
    │ │ │ -      writing,
    │ │ │ -      finished,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   std::uint16_t num_peers:15;
    │ │ │ -   std::uint32_t bytes_progress:15;
    │ │ │ -   std::uint32_t block_size:15;
    │ │ │ -   std::uint32_t state:2;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_peer() peer()

    │ │ │ -
    │ │ │ -tcp::endpoint peer () const;
    │ │ │ -void set_peer (tcp::endpoint const& ep);
    │ │ │ -
    │ │ │ -

    The peer is the ip address of the peer this block was downloaded from.

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

    enum block_state_t

    │ │ │ -

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescription
    none0This block has not been downloaded or requested form any peer.
    requested1The block has been requested, but not completely downloaded yet.
    writing2The block has been downloaded and is currently queued for being │ │ │ -written to disk.the tracker was part of a magnet link
    finished3The block has been written to disk.
    source_tex8the tracker was received from the swarm via tracker exchange
    │ │ │ -[report issue]
    │ │ │ -
    num_peers
    │ │ │ -
    the number of peers that is currently requesting this block. Typically │ │ │ -this is 0 or 1, but at the end of the torrent blocks may be requested │ │ │ -by more peers in parallel to speed things up.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    bytes_progress
    │ │ │ -
    the number of bytes that have been received for this block
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    block_size
    │ │ │ -
    the total number of bytes in this block.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    state
    │ │ │ -
    the state this block is in (see block_state_t)
    │ │ │ +[report issue]
    │ │ │ +
    url
    │ │ │ +
    tracker URL as it appeared in the torrent file
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    partial_piece_info

    │ │ │ -

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ -

    This class holds information about pieces that have outstanding requests │ │ │ -or outstanding writes

    │ │ │ -
    │ │ │ -struct partial_piece_info
    │ │ │ -{
    │ │ │ -   piece_index_t piece_index;
    │ │ │ -   int blocks_in_piece;
    │ │ │ -   int finished;
    │ │ │ -   int writing;
    │ │ │ -   int requested;
    │ │ │ -   block_info const* blocks;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    piece_index
    │ │ │ -
    the index of the piece in question. blocks_in_piece is the number │ │ │ -of blocks in this particular piece. This number will be the same for │ │ │ -most pieces, but │ │ │ -the last piece may have fewer blocks than the standard pieces.
    │ │ │ +[report issue]
    │ │ │ +
    trackerid
    │ │ │ +
    the current &trackerid= argument passed to the tracker. │ │ │ +this is optional and is normally empty (in which case no │ │ │ +trackerid is sent).
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    blocks_in_piece
    │ │ │ -
    the number of blocks in this piece
    │ │ │ +[report issue]
    │ │ │ +
    endpoints
    │ │ │ +
    each local listen socket (endpoint) will announce to the tracker. This │ │ │ +list contains state per endpoint.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    finished
    │ │ │ -
    the number of blocks that are in the finished state
    │ │ │ +[report issue]
    │ │ │ +
    tier
    │ │ │ +
    the tier this tracker belongs to
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    writing
    │ │ │ -
    the number of blocks that are in the writing state
    │ │ │ +[report issue]
    │ │ │ +
    fail_limit
    │ │ │ +
    the max number of failures to announce to this tracker in │ │ │ +a row, before this tracker is not used anymore. 0 means unlimited
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    requested
    │ │ │ -
    the number of blocks that are in the requested state
    │ │ │ +[report issue]
    │ │ │ +
    source
    │ │ │ +
    a bitmask specifying which sources we got this tracker from.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    blocks
    │ │ │ -

    this is an array of blocks_in_piece number of │ │ │ -items. One for each block in the piece.

    │ │ │ -
    │ │ │ -

    Warning

    │ │ │ -

    This is a pointer that points to an array │ │ │ -that's owned by the session object. The next time │ │ │ -get_download_queue() is called, it will be invalidated. │ │ │ -In the case of piece_info_alert, these pointers point into the alert │ │ │ -object itself, and will be invalidated when the alert destruct.

    │ │ │ -
    │ │ │ -
    │ │ │ +[report issue]
    │ │ │ +
    verified
    │ │ │ +
    set to true the first time we receive a valid response │ │ │ +from this tracker.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_handle

    │ │ │ -

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ -

    You will usually have to store your torrent handles somewhere, since it's │ │ │ -the object through which you retrieve information about the torrent and │ │ │ -aborts the torrent.

    │ │ │ -
    │ │ │ -

    Warning

    │ │ │ -

    Any member function that returns a value or fills in a value has to be │ │ │ -made synchronously. This means it has to wait for the main thread to │ │ │ -complete the query before it can return. This might potentially be │ │ │ -expensive if done from within a GUI thread that needs to stay │ │ │ -responsive. Try to avoid querying for information you don't need, and │ │ │ -try to do it in as few calls as possible. You can get most of the │ │ │ -interesting information about a torrent from the │ │ │ -torrent_handle::status() call.

    │ │ │ -
    │ │ │ -

    The default constructor will initialize the handle to an invalid state. │ │ │ -Which means you cannot perform any operation on it, unless you first │ │ │ -assign it a valid handle. If you try to perform any operation on an │ │ │ -uninitialized handle, it will throw invalid_handle.

    │ │ │ -
    │ │ │ -

    Warning

    │ │ │ -

    All operations on a torrent_handle may throw system_error │ │ │ -exception, in case the handle is no longer referring to a torrent. │ │ │ -There is one exception is_valid() will never throw. Since the torrents │ │ │ -are processed by a background thread, there is no guarantee that a │ │ │ -handle will remain valid between two calls.

    │ │ │ -
    │ │ │ -
    │ │ │ -struct torrent_handle
    │ │ │ -{
    │ │ │ -   friend std::size_t hash_value (torrent_handle const& th);
    │ │ │ -   torrent_handle () noexcept = default;
    │ │ │ -   void add_piece (piece_index_t piece, char const* data, add_piece_flags_t flags = {}) const;
    │ │ │ -   void add_piece (piece_index_t piece, std::vector<char> data, add_piece_flags_t flags = {}) const;
    │ │ │ -   void read_piece (piece_index_t piece) const;
    │ │ │ -   void set_sequential_range (piece_index_t first_piece) const;
    │ │ │ -   void set_sequential_range (piece_index_t first_piece, piece_index_t last_piece) const;
    │ │ │ -   bool have_piece (piece_index_t piece) const;
    │ │ │ -   void post_peer_info () const;
    │ │ │ -   void get_peer_info (std::vector<peer_info>& v) const;
    │ │ │ -   void post_status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ -   torrent_status status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ -   std::vector<partial_piece_info> get_download_queue () const;
    │ │ │ -   void post_download_queue () const;
    │ │ │ -   void get_download_queue (std::vector<partial_piece_info>& queue) const;
    │ │ │ -   void reset_piece_deadline (piece_index_t index) const;
    │ │ │ -   void clear_piece_deadlines () const;
    │ │ │ -   void set_piece_deadline (piece_index_t index, int deadline, deadline_flags_t flags = {}) const;
    │ │ │ -   void post_file_progress (file_progress_flags_t flags) const;
    │ │ │ -   std::vector<std::int64_t> file_progress (file_progress_flags_t flags = {}) const;
    │ │ │ -   void file_progress (std::vector<std::int64_t>& progress, file_progress_flags_t flags = {}) const;
    │ │ │ -   void post_file_status () const;
    │ │ │ -   std::vector<open_file_state> file_status () const;
    │ │ │ -   void clear_error () const;
    │ │ │ -   void add_tracker (announce_entry const&) const;
    │ │ │ -   void replace_trackers (std::vector<announce_entry> const&) const;
    │ │ │ -   void post_trackers () const;
    │ │ │ -   std::vector<announce_entry> trackers () const;
    │ │ │ -   void add_url_seed (std::string const& url) const;
    │ │ │ -   void remove_url_seed (std::string const& url) const;
    │ │ │ -   std::set<std::string> url_seeds () const;
    │ │ │ -   void add_extension (
    │ │ │ -      std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, client_data_t)> const& ext
    │ │ │ -      , client_data_t userdata = client_data_t{});
    │ │ │ -   bool set_metadata (span<char const> metadata) const;
    │ │ │ -   bool is_valid () const;
    │ │ │ -   void pause (pause_flags_t flags = {}) const;
    │ │ │ -   void resume () const;
    │ │ │ -   void set_flags (torrent_flags_t flags) const;
    │ │ │ -   torrent_flags_t flags () const;
    │ │ │ -   void unset_flags (torrent_flags_t flags) const;
    │ │ │ -   void set_flags (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │ -   void flush_cache () const;
    │ │ │ -   void force_recheck () const;
    │ │ │ -   add_torrent_params get_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ -   void save_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ -   bool need_save_resume_data () const;
    │ │ │ -   bool need_save_resume_data (resume_data_flags_t flags) const;
    │ │ │ -   void queue_position_top () const;
    │ │ │ -   void queue_position_bottom () const;
    │ │ │ -   void queue_position_down () const;
    │ │ │ -   queue_position_t queue_position () const;
    │ │ │ -   void queue_position_up () const;
    │ │ │ -   void queue_position_set (queue_position_t p) const;
    │ │ │ -   void set_ssl_certificate_buffer (std::string const& certificate
    │ │ │ -      , std::string const& private_key
    │ │ │ -      , std::string const& dh_params);
    │ │ │ -   void set_ssl_certificate (std::string const& certificate
    │ │ │ -      , std::string const& private_key
    │ │ │ -      , std::string const& dh_params
    │ │ │ -      , std::string const& passphrase = "");
    │ │ │ -   std::shared_ptr<const torrent_info> torrent_file () const;
    │ │ │ -   renamed_files get_renamed_files () const;
    │ │ │ -   std::vector<std::vector<sha256_hash>> piece_layers () const;
    │ │ │ -   void post_piece_availability () const;
    │ │ │ -   void piece_availability (std::vector<int>& avail) const;
    │ │ │ -   void piece_priority (piece_index_t index, download_priority_t priority) const;
    │ │ │ -   std::vector<download_priority_t> get_piece_priorities () const;
    │ │ │ -   void prioritize_pieces (std::vector<download_priority_t> const& pieces) const;
    │ │ │ -   void prioritize_pieces (std::vector<std::pair<piece_index_t, download_priority_t>> const& pieces) const;
    │ │ │ -   download_priority_t piece_priority (piece_index_t index) const;
    │ │ │ -   void prioritize_files (std::vector<download_priority_t> const& files) const;
    │ │ │ -   void file_priority (file_index_t index, download_priority_t priority) const;
    │ │ │ -   std::vector<download_priority_t> get_file_priorities () const;
    │ │ │ -   download_priority_t file_priority (file_index_t index) const;
    │ │ │ -   void post_file_priorities () const;
    │ │ │ -   void force_reannounce (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │ -   void force_lsd_announce () const;
    │ │ │ -   void force_reannounce (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ -   void force_reannounce (int seconds, std::string const& url, reannounce_flags_t = {}) const;
    │ │ │ -   void force_dht_announce () const;
    │ │ │ -   void scrape_tracker () const;
    │ │ │ -   void scrape_tracker (int idx) const;
    │ │ │ -   void scrape_tracker (std::string url) const;
    │ │ │ -   int upload_limit () const;
    │ │ │ -   int download_limit () const;
    │ │ │ -   void set_upload_limit (int limit) const;
    │ │ │ -   void set_download_limit (int limit) const;
    │ │ │ -   void connect_peer (tcp::endpoint const& adr, peer_source_flags_t source = {}
    │ │ │ -      , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const;
    │ │ │ -   void clear_peers ();
    │ │ │ -   void set_max_uploads (int max_uploads) const;
    │ │ │ -   int max_uploads () const;
    │ │ │ -   void set_max_connections (int max_connections) const;
    │ │ │ -   int max_connections () const;
    │ │ │ -   void move_storage (std::string const& save_path
    │ │ │ -      , move_flags_t flags = move_flags_t::always_replace_files
    │ │ │ -      ) const;
    │ │ │ -   void rename_file (file_index_t index, std::string const& new_name) const;
    │ │ │ -   info_hash_t info_hashes () const;
    │ │ │ -   sha1_hash info_hash () const;
    │ │ │ -   bool operator!= (const torrent_handle& h) const;
    │ │ │ -   bool operator== (const torrent_handle& h) const;
    │ │ │ -   bool operator< (const torrent_handle& h) const;
    │ │ │ -   std::uint32_t id () const;
    │ │ │ -   std::shared_ptr<aux::torrent> native_handle () const;
    │ │ │ -   client_data_t userdata () const;
    │ │ │ -   bool in_session () const;
    │ │ │ -
    │ │ │ -   static inline constexpr add_piece_flags_t overwrite_existing  = 0_bit;
    │ │ │ -   static inline constexpr status_flags_t query_distributed_copies  = 0_bit;
    │ │ │ -   static inline constexpr status_flags_t query_accurate_download_counters  = 1_bit;
    │ │ │ -   static inline constexpr status_flags_t query_last_seen_complete  = 2_bit;
    │ │ │ -   static inline constexpr status_flags_t query_pieces  = 3_bit;
    │ │ │ -   static inline constexpr status_flags_t query_verified_pieces  = 4_bit;
    │ │ │ -   static inline constexpr status_flags_t query_torrent_file  = 5_bit;
    │ │ │ -   static inline constexpr status_flags_t query_name  = 6_bit;
    │ │ │ -   static inline constexpr status_flags_t query_save_path  = 7_bit;
    │ │ │ -   static inline constexpr status_flags_t query_renamed_files  = 8_bit;
    │ │ │ -   static inline constexpr deadline_flags_t alert_when_available  = 0_bit;
    │ │ │ -   static constexpr file_progress_flags_t piece_granularity  = 0_bit;
    │ │ │ -   static inline constexpr pause_flags_t graceful_pause  = 0_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t flush_disk_cache  = 0_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t save_info_dict  = 1_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t if_counters_changed  = 3_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t if_download_progress  = 4_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t if_config_changed  = 5_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t if_state_changed  = 6_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t if_metadata_changed  = 7_bit;
    │ │ │ -   static inline constexpr resume_data_flags_t only_if_modified  = if_metadata_changed
    │ │ │ -   | if_counters_changed;
    │ │ │ -   static inline constexpr reannounce_flags_t ignore_min_interval  = 0_bit;
    │ │ │ -   static constexpr reannounce_flags_t high_priority  = 1_bit;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    hash_value()

    │ │ │ -
    │ │ │ -friend std::size_t hash_value (torrent_handle const& th);
    │ │ │ -
    │ │ │ -

    ADL hook for boost::hash and the hash specialization for │ │ │ -torrent_handle. Two handles that refer to the same torrent │ │ │ -hash to the same value.

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

    torrent_handle()

    │ │ │ -
    │ │ │ -torrent_handle () noexcept = default;
    │ │ │ -
    │ │ │ -

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

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

    add_piece()

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

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

    │ │ │ -

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

    │ │ │ -

    Since the data is written asynchronously, you may know that is passed │ │ │ -or failed the hash check by waiting for piece_finished_alert or │ │ │ -hash_failed_alert.

    │ │ │ -

    Adding pieces while the torrent is being checked (i.e. in │ │ │ -torrent_status::checking_files state) is not supported.

    │ │ │ -

    The overload taking a raw pointer to the data is a blocking call. It │ │ │ -won't return until the libtorrent thread has copied the data into its │ │ │ -disk write buffer. data is expected to point to a buffer of as │ │ │ -many bytes as the size of the specified piece. │ │ │ -For v2-only torrents, pieces at the end of files may not be full sized.

    │ │ │ -

    The data in the buffer is copied and passed on to the disk IO thread │ │ │ -to be written at some later point in time.

    │ │ │ -

    The overload taking a std::vector<char> is not blocking, it will │ │ │ -send the buffer to the main thread and return immediately.

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

    read_piece()

    │ │ │ -
    │ │ │ -void read_piece (piece_index_t piece) const;
    │ │ │ -
    │ │ │ -

    This function starts an asynchronous read operation of the specified │ │ │ -piece from this torrent. You must have completed the download of the │ │ │ -specified piece before calling this function.

    │ │ │ -

    When the read operation is completed, it is passed back through an │ │ │ -alert, read_piece_alert. Since this alert is a response to an explicit │ │ │ -call, it will always be posted, regardless of the alert mask.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

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

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

    Note

    │ │ │ -

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

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

    set_sequential_range()

    │ │ │ -
    │ │ │ -void set_sequential_range (piece_index_t first_piece) const;
    │ │ │ -void set_sequential_range (piece_index_t first_piece, piece_index_t last_piece) const;
    │ │ │ -
    │ │ │ -

    These functions set the first piece and the last piece of the range │ │ │ -for the piece picker. They start downloading from the specified piece │ │ │ -in sequential download mode, which is enabled. If the last piece is │ │ │ -omitted then it is implicitly set to the end of the file the first │ │ │ -piece is set to. If the torrent metadata has not been downloaded yet │ │ │ -then the functions do nothing.

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

    have_piece()

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

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

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

    post_peer_info() get_peer_info()

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

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

    │ │ │ -

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

    │ │ │ -

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

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

    status() post_status()

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

    status() will return a structure with information about the status │ │ │ -of this torrent. If the torrent_handle is invalid, it will throw │ │ │ -system_error exception. See torrent_status. The flags │ │ │ -argument filters what information is returned in the torrent_status. │ │ │ -Some information in there is relatively expensive to calculate, and if │ │ │ -you're not interested in it (and see performance issues), you can │ │ │ -filter them out.

    │ │ │ -

    The status() function will block until the internal libtorrent │ │ │ -thread responds with the torrent_status object. To avoid blocking, │ │ │ -instead call post_status(). It will trigger posting of a │ │ │ -state_update_alert with a single torrent_status object for this │ │ │ -torrent.

    │ │ │ -

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

    │ │ │ -

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

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

    post_download_queue() get_download_queue()

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

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

    │ │ │ -
    │ │ │ -

    Warning

    │ │ │ -

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

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

    clear_piece_deadlines() reset_piece_deadline() set_piece_deadline()

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

    This function sets or resets the deadline associated with a specific │ │ │ -piece index (index). libtorrent will attempt to download this │ │ │ -entire piece before the deadline expires. This is not necessarily │ │ │ -possible, but pieces with a more recent deadline will always be │ │ │ -prioritized over pieces with a deadline further ahead in time. The │ │ │ -deadline (and flags) of a piece can be changed by calling this │ │ │ -function again.

    │ │ │ -

    If the piece is already downloaded when this call is made, nothing │ │ │ -happens, unless the alert_when_available flag is set, in which case it │ │ │ -will have the same effect as calling read_piece() for index.

    │ │ │ -

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

    │ │ │ -

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

    │ │ │ -

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

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

    file_progress() post_file_progress()

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

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

    │ │ │ -

    This operation is not very cheap. Its complexity is O(n + mj). │ │ │ -Where n is the number of files, m is the number of currently │ │ │ -downloading pieces and j is the number of blocks in a piece.

    │ │ │ -

    The flags parameter can be used to specify the granularity of the │ │ │ -file progress. If left at the default value of 0, the progress will be │ │ │ -as accurate as possible, but also more expensive to calculate. If │ │ │ -torrent_handle::piece_granularity is specified, the progress will │ │ │ -be specified in piece granularity. i.e. only pieces that have been │ │ │ -fully downloaded and passed the hash check count. When specifying │ │ │ -piece granularity, the operation is a lot cheaper, since libtorrent │ │ │ -already keeps track of this internally and no calculation is required.

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

    file_status() post_file_status()

    │ │ │ -
    │ │ │ -void post_file_status () const;
    │ │ │ -std::vector<open_file_state> file_status () const;
    │ │ │ -
    │ │ │ -

    file_status() returns a vector with status about files │ │ │ -that are open for this torrent. Any file that is not open │ │ │ -will not be reported in the vector, i.e. it's possible that │ │ │ -the vector is empty when returning, if none of the files in the │ │ │ -torrent are currently open.

    │ │ │ -

    post_file_status() will trigger a file_status_alert to be posted, │ │ │ -containing the open-file state of all currently open files in the torrent.

    │ │ │ -

    See open_file_state

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

    clear_error()

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

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

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

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

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

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

    │ │ │ -

    post_trackers() is the asynchronous version of trackers(). It │ │ │ -will trigger a tracker_list_alert to be posted.

    │ │ │ -

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

    │ │ │ -

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

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

    url_seeds() remove_url_seed() add_url_seed()

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

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

    │ │ │ -

    See http seeding for more information.

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

    add_extension()

    │ │ │ -
    │ │ │ -void add_extension (
    │ │ │ -      std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, client_data_t)> const& ext
    │ │ │ -      , client_data_t userdata = client_data_t{});
    │ │ │ -
    │ │ │ -

    add the specified extension to this torrent. The ext argument is │ │ │ -a function that will be called from within libtorrent's context │ │ │ -passing in the internal torrent object and the specified userdata │ │ │ -pointer. The function is expected to return a shared pointer to │ │ │ -a torrent_plugin instance.

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

    set_metadata()

    │ │ │ -
    │ │ │ -bool set_metadata (span<char const> metadata) const;
    │ │ │ -
    │ │ │ -

    set_metadata expects the info section of metadata. i.e. The │ │ │ -buffer passed in will be hashed and verified against the info-hash. If │ │ │ -it fails, a metadata_failed_alert will be generated. If it passes, │ │ │ -a metadata_received_alert is generated. The function returns true │ │ │ -if the metadata is successfully set on the torrent, and false │ │ │ -otherwise. If the torrent already has metadata, this function will not │ │ │ -affect the torrent, and false will be returned.

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

    is_valid()

    │ │ │ -
    │ │ │ -bool is_valid () const;
    │ │ │ -
    │ │ │ -

    Returns true if this handle refers to a valid torrent and false if it │ │ │ -hasn't been initialized or if the torrent it refers to has been │ │ │ -removed from the session AND destructed.

    │ │ │ -

    To tell if the torrent_handle is in the session, use │ │ │ -torrent_handle::in_session(). This will return true before │ │ │ -session_handle::remove_torrent() is called, and false │ │ │ -afterward.

    │ │ │ -

    Clients should only use is_valid() to determine if the result of │ │ │ -session::find_torrent() was successful.

    │ │ │ -

    Unlike other member functions which return a value, is_valid() │ │ │ -completes immediately, without blocking on a result from the │ │ │ -network thread. Also unlike other functions, it never throws │ │ │ -the system_error exception.

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

    resume() pause()

    │ │ │ -
    │ │ │ -void pause (pause_flags_t flags = {}) const;
    │ │ │ -void resume () const;
    │ │ │ -
    │ │ │ -

    pause(), and resume() will disconnect all peers and reconnect │ │ │ -all peers respectively. When a torrent is paused, it will however │ │ │ -remember all share ratios to all peers and remember all potential (not │ │ │ -connected) peers. Torrents may be paused automatically if there is a │ │ │ -file error (e.g. disk full) or something similar. See │ │ │ -file_error_alert.

    │ │ │ -

    For possible values of the flags parameter, see pause_flags_t.

    │ │ │ -

    To know if a torrent is paused or not, call │ │ │ -torrent_handle::flags() and check for the │ │ │ -torrent_status::paused flag.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    Torrents that are auto-managed may be automatically resumed again. It │ │ │ -does not make sense to pause an auto-managed torrent without making it │ │ │ -not auto-managed first. Torrents are auto-managed by default when added │ │ │ -to the session. For more information, see queuing.

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

    flags() set_flags() unset_flags()

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

    sets and gets the torrent state flags. See torrent_flags_t. │ │ │ -The set_flags overload that take a mask will affect all │ │ │ -flags part of the mask, and set their values to what the │ │ │ -flags argument is set to. This allows clearing and │ │ │ -setting flags in a single function call. │ │ │ -The set_flags overload that just takes flags, sets all │ │ │ -the specified flags and leave any other flags unchanged. │ │ │ -unset_flags clears the specified flags, while leaving │ │ │ -any other flags unchanged.

    │ │ │ -

    The seed_mode flag is special, it can only be cleared once the │ │ │ -torrent has been added, and it can only be set as part of the │ │ │ -add_torrent_params flags, when adding the torrent.

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

    flush_cache()

    │ │ │ -
    │ │ │ -void flush_cache () const;
    │ │ │ -
    │ │ │ -

    Instructs libtorrent to flush all the disk caches for this torrent and │ │ │ -close all file handles. This is done asynchronously and you will be │ │ │ -notified that it's complete through cache_flushed_alert.

    │ │ │ -

    Note that by the time you get the alert, libtorrent may have cached │ │ │ -more data for the torrent, but you are guaranteed that whatever cached │ │ │ -data libtorrent had by the time you called │ │ │ -torrent_handle::flush_cache() has been written to disk.

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

    force_recheck()

    │ │ │ -
    │ │ │ -void force_recheck () const;
    │ │ │ -
    │ │ │ -

    force_recheck puts the torrent back in a state where it assumes to │ │ │ -have no resume data. All peers will be disconnected and the torrent │ │ │ -will stop announcing to the tracker. The torrent will be added to the │ │ │ -checking queue, and will be checked (all the files will be read and │ │ │ -compared to the piece hashes). Once the check is complete, the torrent │ │ │ -will start connecting to peers again, as normal. │ │ │ -The torrent will be placed last in queue, i.e. its queue position │ │ │ -will be the highest of all torrents in the session.

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

    save_resume_data() get_resume_data()

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

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

    │ │ │ -

    `get_resume_data() is synchronous and will block the calling │ │ │ -thread until the resume data is ready and returned from the │ │ │ -libtorrent main thread. │ │ │ -/ │ │ │ -save_resume_data() is asynchronous. It will return immediately │ │ │ -and deliver the resume data is when it's done through a │ │ │ -save_resume_data_alert.

    │ │ │ -

    The operation will fail, and post a save_resume_data_failed_alert │ │ │ -instead, in the following cases:

    │ │ │ -
    │ │ │ -
      │ │ │ -
    1. The torrent is in the process of being removed.
    2. │ │ │ -
    3. No torrent state has changed since the last saving of resume │ │ │ -data, and the only_if_modified flag is set. │ │ │ -metadata (see libtorrent's metadata from peers extension)
    4. │ │ │ -
    │ │ │ -
    │ │ │ -

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

    │ │ │ -

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

    │ │ │ -

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

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    It is typically a good idea to save resume data whenever a torrent │ │ │ -is completed or paused. If you save resume data for torrents when they are │ │ │ -paused, you can accelerate the shutdown process by not saving resume │ │ │ -data again for those torrents. Completed torrents should have their │ │ │ -resume data saved when they complete and on exit, since their │ │ │ -statistics might be updated.

    │ │ │ -
    │ │ │ -

    Example code to pause and save resume data for all torrents and wait │ │ │ -for the alerts:

    │ │ │ +

    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:

    │ │ │
    │ │ │ -extern int outstanding_resume_data; // global counter of outstanding resume data
    │ │ │ -std::vector<torrent_handle> handles = ses.get_torrents();
    │ │ │ -for (torrent_handle const& h : handles) try
    │ │ │ +struct temp_storage
    │ │ │  {
    │ │ │ -        h.save_resume_data(torrent_handle::only_if_modified);
    │ │ │ -        ++outstanding_resume_data;
    │ │ │ -}
    │ │ │ -catch (lt::system_error const& e)
    │ │ │ +  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)
    │ │ │  {
    │ │ │ -        // the handle was invalid, ignore this one and move to the next
    │ │ │ +  TORRENT_ASSERT(!q.empty());
    │ │ │ +  lt::storage_index_t const ret = q.back();
    │ │ │ +  q.pop_back();
    │ │ │ +  return ret;
    │ │ │  }
    │ │ │  
    │ │ │ -while (outstanding_resume_data > 0)
    │ │ │ +struct temp_disk_io final : lt::disk_interface
    │ │ │ +  , lt::buffer_allocator_interface
    │ │ │  {
    │ │ │ -        // if we don't get an alert within 30 seconds, abort
    │ │ │ -        if (!ses.wait_for_alert(seconds(30))) break;
    │ │ │ +  explicit temp_disk_io(lt::io_context& ioc): m_ioc(ioc) {}
    │ │ │  
    │ │ │ -        std::vector<alert*> alerts;
    │ │ │ -        ses.pop_alerts(&alerts);
    │ │ │ +  void settings_updated() override {}
    │ │ │  
    │ │ │ -        for (alert* i : alerts)
    │ │ │ -        {
    │ │ │ -                if (alert_cast<save_resume_data_failed_alert>(i))
    │ │ │ -                {
    │ │ │ -                        process_alert(i);
    │ │ │ -                        --outstanding_resume_data;
    │ │ │ -                        continue;
    │ │ │ -                }
    │ │ │ +  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 {}
    │ │ │  
    │ │ │ -                save_resume_data_alert const* rd = alert_cast<save_resume_data_alert>(i);
    │ │ │ -                if (rd == nullptr)
    │ │ │ -                {
    │ │ │ -                        process_alert(i);
    │ │ │ -                        continue;
    │ │ │ -                }
    │ │ │ +  std::vector<lt::open_file_state> get_status(lt::storage_index_t) const override
    │ │ │ +  { return {}; }
    │ │ │  
    │ │ │ -                std::ofstream out((rd->params.save_path
    │ │ │ -                        + "/" + rd->params.name + ".fastresume").c_str()
    │ │ │ -                        , std::ios_base::binary);
    │ │ │ -                std::vector<char> buf = write_resume_data_buf(rd->params);
    │ │ │ -                out.write(buf.data(), buf.size());
    │ │ │ -                --outstanding_resume_data;
    │ │ │ -        }
    │ │ │ +  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);
    │ │ │  }
    │ │ │  
    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    Note how outstanding_resume_data is a global counter in this │ │ │ -example. This is deliberate, otherwise there is a race condition for │ │ │ -torrents that was just asked to save their resume data, they posted │ │ │ -the alert, but it has not been received yet. Those torrents would │ │ │ -report that they don't need to save resume data again, and skipped by │ │ │ -the initial loop, and thwart the counter otherwise.

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

    need_save_resume_data()

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

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

    │ │ │ -

    This is a blocking call. It will wait for a response from │ │ │ -libtorrent's main thread. A way to avoid blocking is to instead │ │ │ -call save_resume_data() directly, specifying the conditions under │ │ │ -which resume data should be saved.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

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

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

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

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

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

    │ │ │ -

    When a torrent is removed or turns into a seed, all torrents with │ │ │ -greater queue positions have their positions decreased to fill in the │ │ │ -space in the sequence.

    │ │ │ -

    queue_position() returns the torrent's position in the download │ │ │ -queue. The torrents with the smallest numbers are the ones that are │ │ │ -being downloaded. The smaller number, the closer the torrent is to the │ │ │ -front of the line to be started.

    │ │ │ -

    The queue position is also available in the torrent_status.

    │ │ │ -

    The queue_position_*() functions adjust the torrents position in │ │ │ -the queue. Up means closer to the front and down means closer to the │ │ │ -back of the queue. Top and bottom refers to the front and the back of │ │ │ -the queue respectively.

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

    queue_position_set()

    │ │ │ -
    │ │ │ -void queue_position_set (queue_position_t p) const;
    │ │ │ -
    │ │ │ -

    updates the position in the queue for this torrent. The relative order │ │ │ -of all other torrents remain intact but their numerical queue position │ │ │ -shifts to make space for this torrent's new position

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

    set_ssl_certificate_buffer() set_ssl_certificate()

    │ │ │ -
    │ │ │ -void set_ssl_certificate_buffer (std::string const& certificate
    │ │ │ -      , std::string const& private_key
    │ │ │ -      , std::string const& dh_params);
    │ │ │ -void set_ssl_certificate (std::string const& certificate
    │ │ │ -      , std::string const& private_key
    │ │ │ -      , std::string const& dh_params
    │ │ │ -      , std::string const& passphrase = "");
    │ │ │ -
    │ │ │ -

    For SSL torrents, use this to specify a path to a .pem file to use as │ │ │ -this client's certificate. The certificate must be signed by the │ │ │ -certificate in the .torrent file to be valid.

    │ │ │ -

    The set_ssl_certificate_buffer() overload takes the actual certificate, │ │ │ -private key and DH params as strings, rather than paths to files.

    │ │ │ -

    cert is a path to the (signed) certificate in .pem format │ │ │ -corresponding to this torrent.

    │ │ │ -

    private_key is a path to the private key for the specified │ │ │ -certificate. This must be in .pem format.

    │ │ │ -

    dh_params is a path to the Diffie-Hellman parameter file, which │ │ │ -needs to be in .pem format. You can generate this file using the │ │ │ -openssl command like this: openssl dhparam -outform PEM -out │ │ │ -dhparams.pem 512.

    │ │ │ -

    passphrase may be specified if the private key is encrypted and │ │ │ -requires a passphrase to be decrypted.

    │ │ │ -

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

    │ │ │ -

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

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

    torrent_file()

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

    torrent_file() returns a pointer to the torrent_info object │ │ │ -associated with this torrent. The torrent_info object may be a copy │ │ │ -of the internal object. If the torrent doesn't have metadata, the │ │ │ -pointer will not be initialized (i.e. a nullptr). The torrent may be │ │ │ -in a state without metadata only if it was started without a .torrent │ │ │ -file, e.g. by being added by magnet link.

    │ │ │ -

    Note that the torrent_info object returned here may be a different │ │ │ -instance than the one added to the session, with different attributes │ │ │ -like piece layers, dht nodes and trackers. A torrent_info object does │ │ │ -not round-trip cleanly when added to a session.

    │ │ │ -

    If you want to save a .torrent file from the torrent_handle, instead │ │ │ -call save_resume_data() and write_torrent_file() the │ │ │ -add_torrent_params object passed back in the alert.

    │ │ │ -

    Note that a torrent added from a magnet link may not have the full │ │ │ -merkle trees for all files, and hence not have the complete piece │ │ │ -layers. In that state, you cannot create a .torrent file from the │ │ │ -torrent_info returned. Once the torrent completes downloading all │ │ │ -files, becoming a seed, you can make a .torrent file from it.

    │ │ │ -

    If any files in the torrent have been renamed, using │ │ │ -torrent_handle::rename_file(), the new names will not be reflected │ │ │ -in the returned torrent_info object.

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

    get_renamed_files()

    │ │ │ -
    │ │ │ -renamed_files get_renamed_files () const;
    │ │ │ -
    │ │ │ -

    Returns a copy of the renamed_files object for this torrent. This │ │ │ -records all file renames applied via torrent_handle::rename_file(). │ │ │ -To get a complete view of the current file layout (original names │ │ │ -plus any renames), combine this with the file_storage from │ │ │ -torrent_file()->layout():

    │ │ │ -
    │ │ │ -auto tf = handle.torrent_file();
    │ │ │ -auto renames = handle.get_renamed_files();
    │ │ │ -lt::filenames fn(tf->layout(), renames);
    │ │ │ -for (auto i : fn.file_range())
    │ │ │ -        std::cout << fn.file_path(i) << "\n";
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_layers()

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

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

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

    piece_availability() post_piece_availability()

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

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

    │ │ │ -

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

    │ │ │ -

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

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

    piece_priority() get_piece_priorities() prioritize_pieces()

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

    These functions are used to set and get the priority of individual │ │ │ -pieces. By default all pieces have priority 4. That means that the │ │ │ -random rarest first algorithm is effectively active for all pieces. │ │ │ -You may however change the priority of individual pieces. There are 8 │ │ │ -priority levels. 0 means not to download the piece at all. Otherwise, │ │ │ -lower priority values means less likely to be picked. Piece priority │ │ │ -takes precedence over piece availability. Every piece with priority 7 │ │ │ -will be attempted to be picked before a priority 6 piece and so on.

    │ │ │ -

    The default priority of pieces is 4.

    │ │ │ -

    Piece priorities can not be changed for torrents that have not │ │ │ -downloaded the metadata yet. Magnet links won't have metadata │ │ │ -immediately. see the metadata_received_alert.

    │ │ │ -

    piece_priority sets or gets the priority for an individual piece, │ │ │ -specified by index.

    │ │ │ -

    prioritize_pieces takes a vector of integers, one integer per │ │ │ -piece in the torrent. All the piece priorities will be updated with │ │ │ -the priorities in the vector. │ │ │ -The second overload of prioritize_pieces that takes a vector of pairs │ │ │ -will update the priorities of only select pieces, and leave all other │ │ │ -unaffected. Each pair is (piece, priority). That is, the first item is │ │ │ -the piece index and the second item is the priority of that piece. │ │ │ -Invalid entries, where the piece index or priority is out of range, are │ │ │ -not allowed.

    │ │ │ -

    get_piece_priorities returns a vector with one element for each piece │ │ │ -in the torrent. Each element is the current priority of that piece.

    │ │ │ -

    It's possible to cancel the effect of file priorities by setting the │ │ │ -priorities for the affected pieces. Care has to be taken when mixing │ │ │ -usage of file- and piece priorities.

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

    file_priority() get_file_priorities() prioritize_files()

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

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

    │ │ │ -

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

    │ │ │ -

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

    │ │ │ -

    get_file_priorities() returns a vector with the priorities of all │ │ │ -files.

    │ │ │ -

    The priority values are the same as for piece_priority(). See │ │ │ -download_priority_t.

    │ │ │ -

    Whenever a file priority is changed, all other piece priorities are │ │ │ -reset to match the file priorities. In order to maintain special │ │ │ -priorities for particular pieces, piece_priority() has to be called │ │ │ -again for those pieces.

    │ │ │ -

    You cannot set the file priorities on a torrent that does not yet have │ │ │ -metadata or a torrent that is a seed. file_priority(int, int) and │ │ │ -prioritize_files() are both no-ops for such torrents.

    │ │ │ -

    Since changing file priorities may involve disk operations (of moving │ │ │ -files in- and out of the part file), the internal accounting of file │ │ │ -priorities happen asynchronously. i.e. setting file priorities and then │ │ │ -immediately querying them may not yield the same priorities just set. │ │ │ -To synchronize with the priorities taking effect, wait for the │ │ │ -file_prio_alert.

    │ │ │ -

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

    │ │ │ -

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

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

    post_file_priorities()

    │ │ │ -
    │ │ │ -void post_file_priorities () const;
    │ │ │ -
    │ │ │ -

    post_file_priorities() will trigger a file_priorities_alert to be │ │ │ -posted, containing the download priority of each file in the torrent.

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

    force_reannounce() force_lsd_announce() force_dht_announce()

    │ │ │ -
    │ │ │ -void force_reannounce (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │ -void force_lsd_announce () const;
    │ │ │ -void force_reannounce (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ -void force_reannounce (int seconds, std::string const& url, reannounce_flags_t = {}) const;
    │ │ │ -void force_dht_announce () const;
    │ │ │ -
    │ │ │ -

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

    │ │ │ -

    If the tracker's min_interval has not passed since the last │ │ │ -announce, the forced announce will be scheduled to happen immediately │ │ │ -as the min_interval expires. This is to honor trackers minimum │ │ │ -re-announce interval settings.

    │ │ │ -

    The tracker_index argument specifies which tracker to re-announce. │ │ │ -If set to -1 (which is the default), all trackers are re-announce.

    │ │ │ -

    The flags argument can be used to affect the re-announce. See │ │ │ -ignore_min_interval and high_priority.

    │ │ │ -

    force_dht_announce will announce the torrent to the DHT │ │ │ -immediately.

    │ │ │ -

    force_lsd_announce will announce the torrent on LSD │ │ │ -immediately.

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

    scrape_tracker()

    │ │ │ -
    │ │ │ -void scrape_tracker () const;
    │ │ │ -void scrape_tracker (int idx) const;
    │ │ │ -void scrape_tracker (std::string url) const;
    │ │ │ -
    │ │ │ -

    scrape_tracker() will send a scrape request to a tracker. By │ │ │ -default (idx = -1) it will scrape the last working tracker. If │ │ │ -idx is >= 0, the tracker with the specified index will scraped.

    │ │ │ -

    A scrape request queries the tracker for statistics such as total │ │ │ -number of incomplete peers, complete peers, number of downloads etc.

    │ │ │ -

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

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

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

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

    set_upload_limit will limit the upload bandwidth used by this │ │ │ -particular torrent to the limit you set. It is given as the number of │ │ │ -bytes per second the torrent is allowed to upload. │ │ │ -set_download_limit works the same way but for download bandwidth │ │ │ -instead of upload bandwidth. Note that setting a higher limit on a │ │ │ -torrent then the global limit │ │ │ -(settings_pack::upload_rate_limit) will not override the global │ │ │ -rate limit. The torrent can never upload more than the global rate │ │ │ -limit.

    │ │ │ -

    upload_limit and download_limit will return the current limit │ │ │ -setting, for upload and download, respectively.

    │ │ │ -

    Local peers are not rate limited by default. see peer classes.

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

    connect_peer()

    │ │ │ -
    │ │ │ -void connect_peer (tcp::endpoint const& adr, peer_source_flags_t source = {}
    │ │ │ -      , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const;
    │ │ │ -
    │ │ │ -

    connect_peer() is a way to manually connect to peers that one │ │ │ -believe is a part of the torrent. If the peer does not respond, or is │ │ │ -not a member of this torrent, it will simply be disconnected. No harm │ │ │ -can be done by using this other than an unnecessary connection attempt │ │ │ -is made. If the torrent is uninitialized or in queued or checking │ │ │ -mode, this will throw system_error. The second (optional) │ │ │ -argument will be bitwise ORed into the source mask of this peer. │ │ │ -Typically this is one of the source flags in peer_info. i.e. │ │ │ -tracker, pex, dht etc.

    │ │ │ -

    For possible values of flags, see pex_flags_t.

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

    clear_peers()

    │ │ │ -
    │ │ │ -void clear_peers ();
    │ │ │ -
    │ │ │ -

    This will disconnect all peers and clear the peer list for this │ │ │ -torrent. New peers will have to be acquired before resuming, from │ │ │ -trackers, DHT or local service discovery, for example.

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

    max_uploads() set_max_uploads()

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

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

    │ │ │ -

    max_uploads() returns the current settings.

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

    set_max_connections() max_connections()

    │ │ │ -
    │ │ │ -void set_max_connections (int max_connections) const;
    │ │ │ -int max_connections () const;
    │ │ │ -
    │ │ │ -

    set_max_connections() sets the maximum number of connection this │ │ │ -torrent will open. If all connections are used up, incoming │ │ │ -connections may be refused or poor connections may be closed. This │ │ │ -must be at least 2. The default is unlimited number of connections. If │ │ │ --1 is given to the function, it means unlimited. There is also a │ │ │ -global limit of the number of connections, set by │ │ │ -connections_limit in settings_pack.

    │ │ │ -

    max_connections() returns the current settings.

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

    move_storage()

    │ │ │ -
    │ │ │ -void move_storage (std::string const& save_path
    │ │ │ -      , move_flags_t flags = move_flags_t::always_replace_files
    │ │ │ -      ) const;
    │ │ │ -
    │ │ │ -

    Moves the file(s) that this torrent are currently seeding from or │ │ │ -downloading to. If the given save_path is not located on the same │ │ │ -drive as the original save path, the files will be copied to the new │ │ │ -drive and removed from their original location. This will block all │ │ │ -other disk IO, and other torrents download and upload rates may drop │ │ │ -while copying the file.

    │ │ │ -

    Since disk IO is performed in a separate thread, this operation is │ │ │ -also asynchronous. Once the operation completes, the │ │ │ -storage_moved_alert is generated, with the new path as the │ │ │ -message. If the move fails for some reason, │ │ │ -storage_moved_failed_alert is generated instead, containing the │ │ │ -error message.

    │ │ │ -

    The flags argument determines the behavior of the copying/moving │ │ │ -of the files in the torrent. see move_flags_t.

    │ │ │ -

    always_replace_files is the default and replaces any file that │ │ │ -exist in both the source directory and the target directory.

    │ │ │ -

    fail_if_exist first check to see that none of the copy operations │ │ │ -would cause an overwrite. If it would, it will fail. Otherwise it will │ │ │ -proceed as if it was in always_replace_files mode. Note that there │ │ │ -is an inherent race condition here. If the files in the target │ │ │ -directory appear after the check but before the copy or move │ │ │ -completes, they will be overwritten. When failing because of files │ │ │ -already existing in the target path, the error of │ │ │ -move_storage_failed_alert is set to │ │ │ -boost::system::errc::file_exists.

    │ │ │ -

    The intention is that a client may use this as a probe, and if it │ │ │ -fails, ask the user which mode to use. The client may then re-issue │ │ │ -the move_storage call with one of the other modes.

    │ │ │ -

    dont_replace always keeps the existing file in the target │ │ │ -directory, if there is one. The source files will still be removed in │ │ │ -that case. Note that it won't automatically re-check files. If an │ │ │ -incomplete torrent is moved into a directory with the complete files, │ │ │ -pause, move, force-recheck and resume. Without the re-checking, the │ │ │ -torrent will keep downloading and files in the new download directory │ │ │ -will be overwritten.

    │ │ │ -

    Files that have been renamed to have absolute paths are not moved by │ │ │ -this function. Keep in mind that files that don't belong to the │ │ │ -torrent but are stored in the torrent's directory may be moved as │ │ │ -well. This goes for files that have been renamed to absolute paths │ │ │ -that still end up inside the save path.

    │ │ │ -

    When copying files, sparse regions are not likely to be preserved. │ │ │ -This makes it proportionally more expensive to move a large torrent │ │ │ -when only few pieces have been downloaded, since the files are then │ │ │ -allocated with zeros in the destination directory.

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

    rename_file()

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

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

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

    info_hash() info_hashes()

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

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

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

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

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

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

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

    id()

    │ │ │ -
    │ │ │ -std::uint32_t id () const;
    │ │ │ -
    │ │ │ -

    returns a unique identifier for this torrent. It's not a dense index. │ │ │ -It's not preserved across sessions.

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

    native_handle()

    │ │ │ +
    │ │ │ +

    settings_interface

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +

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

    │ │ │
    │ │ │ -std::shared_ptr<aux::torrent> native_handle () const;
    │ │ │ +struct settings_interface
    │ │ │ +{
    │ │ │ +   virtual void set_str (int name, std::string val) = 0;
    │ │ │ +   virtual void set_bool (int name, bool 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 std::string const& get_str (int name) const = 0;
    │ │ │ +   virtual int get_int (int name) const = 0;
    │ │ │ +};
    │ │ │  
    │ │ │ -

    This function is intended only for use by plugins and the alert │ │ │ -dispatch function. This type does not have a stable ABI and should │ │ │ -be relied on as little as possible. Accessing the handle returned by │ │ │ -this function is not thread safe outside of libtorrent's internal │ │ │ -thread (which is used to invoke plugin callbacks).

    │ │ │ -

    The aux::torrent class is not only eligible for changing ABI across │ │ │ -minor versions of libtorrent, its layout is also dependent on build │ │ │ -configuration. This adds additional requirements on a client to be │ │ │ -built with the exact same build configuration as libtorrent itself. │ │ │ -i.e. the TORRENT_ macros must match between libtorrent and the │ │ │ -client builds.

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

    userdata()

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

    set_bool() set_str() set_int()

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

    returns the userdata pointer as set in add_torrent_params

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

    in_session()

    │ │ │ +

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

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

    Returns true if the torrent is in the session. It returns true before │ │ │ -session::remove_torrent() is called, and false afterward.

    │ │ │ -

    Note that this is a blocking function, unlike torrent_handle::is_valid() │ │ │ -which returns immediately.

    │ │ │ -[report issue]
    │ │ │ -
    overwrite_existing
    │ │ │ -
    instruct libtorrent to overwrite any data that may already have been │ │ │ -downloaded with the data of the new piece being added. Using this │ │ │ -flag when adding a piece that is actively being downloaded from other │ │ │ -peers may have some unexpected consequences, as blocks currently │ │ │ -being downloaded from peers may not be replaced.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_distributed_copies
    │ │ │ -
    calculates distributed_copies, distributed_full_copies and │ │ │ -distributed_fraction.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_accurate_download_counters
    │ │ │ -
    includes partial downloaded blocks in total_done and │ │ │ -total_wanted_done.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_last_seen_complete
    │ │ │ -
    includes last_seen_complete.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_pieces
    │ │ │ -
    populate the pieces field in torrent_status.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_verified_pieces
    │ │ │ -
    includes verified_pieces (only applies to torrents in seed │ │ │ -mode).
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_torrent_file
    │ │ │ -
    includes torrent_file, which is all the static information from │ │ │ -the .torrent file.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_name
    │ │ │ -
    includes name, the name of the torrent. This is either derived │ │ │ -from the .torrent file, or from the &dn= magnet link argument │ │ │ -or possibly some other source. If the name of the torrent is not │ │ │ -known, this is an empty string.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_save_path
    │ │ │ -
    includes save_path, the path to the directory the files of the │ │ │ -torrent are saved to.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    query_renamed_files
    │ │ │ -
    includes renamed_files, a map of files that have been renamed in this torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    alert_when_available
    │ │ │ -
    used to ask libtorrent to send an alert once the piece has been │ │ │ -downloaded, by passing alert_when_available. When set, the │ │ │ -read_piece_alert alert will be delivered, with the piece data, when │ │ │ -it's downloaded.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    piece_granularity
    │ │ │ -
    only calculate file progress at piece granularity. This makes │ │ │ -the file_progress() call cheaper and also only takes bytes that │ │ │ -have passed the hash check into account, so progress cannot │ │ │ -regress in this mode.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    graceful_pause
    │ │ │ -
    will delay the disconnect of peers that we're still downloading │ │ │ -outstanding requests from. The torrent will not accept any more │ │ │ -requests and will disconnect all idle peers. As soon as a peer is done │ │ │ -transferring the blocks that were requested from it, it is │ │ │ -disconnected. This is a graceful shut down of the torrent in the sense │ │ │ -that no downloaded bytes are wasted.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flush_disk_cache
    │ │ │ -
    the disk cache will be flushed before creating the resume data. │ │ │ -This avoids a problem with file timestamps in the resume data in │ │ │ -case the cache hasn't been flushed yet.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    save_info_dict
    │ │ │ -
    the resume data will contain the metadata from the torrent file as │ │ │ -well. This is useful for clients that don't keep .torrent files │ │ │ -around separately, or for torrents that were added via a magnet link.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    if_counters_changed
    │ │ │ -
    save resume data if any counters has changed since the last time │ │ │ -resume data was saved. This includes upload/download counters, active │ │ │ -time counters and scrape data. A torrent that is not paused will have │ │ │ -its active time counters incremented continuously.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    if_download_progress
    │ │ │ -
    save the resume data if any blocks have been downloaded since the │ │ │ -last time resume data was saved. This includes: │ │ │ -* checking existing files on disk │ │ │ -* downloading a block from a peer
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    if_config_changed
    │ │ │ -
    save the resume data if configuration options changed since last time │ │ │ -the resume data was saved. This includes: │ │ │ -* file- or piece priorities │ │ │ -* upload- and download rate limits │ │ │ -* change max-uploads (unchoke slots) │ │ │ -* change max connection limit │ │ │ -* enable/disable peer-exchange, local service discovery or DHT │ │ │ -* enable/disable apply IP-filter │ │ │ -* enable/disable auto-managed │ │ │ -* enable/disable share-mode │ │ │ -* enable/disable sequential-mode │ │ │ -* files renamed │ │ │ -* storage moved (save_path changed)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    if_state_changed
    │ │ │ -
    save the resume data if torrent state has changed since last time the │ │ │ -resume data was saved. This includes: │ │ │ -* upload mode │ │ │ -* paused state │ │ │ -* super-seeding │ │ │ -* seed-mode
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    if_metadata_changed
    │ │ │ -
    save the resume data if any metadata changed since the last time │ │ │ -resume data was saved. This includes: │ │ │ -* add/remove web seeds │ │ │ -* add/remove trackers │ │ │ -* receiving metadata for a magnet link
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    only_if_modified if_counters_changed
    │ │ │ -
    this flag has the same behavior as the combination of: │ │ │ -if_counters_changed | if_download_progress | if_config_changed | │ │ │ -if_state_changed | if_metadata_changed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    ignore_min_interval
    │ │ │ -
    by default, force-reannounce will still honor the min-interval │ │ │ -published by the tracker. If this flag is set, it will be ignored │ │ │ -and the tracker is announced immediately.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    high_priority
    │ │ │ -
    by default, force-reannounce will queue the announce normally. │ │ │ -If this flag is set, the announce will be put at the front of the │ │ │ -tracker queue for immediate processing.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    hash_value()

    │ │ │ -

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ +

    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_str() get_int() get_bool()

    │ │ │
    │ │ │ -std::size_t hash_value (torrent_handle const& h);
    │ │ │ +virtual bool get_bool (int name) const = 0;
    │ │ │ +virtual std::string const& get_str (int name) const = 0;
    │ │ │ +virtual int get_int (int name) const = 0;
    │ │ │  
    │ │ │ -

    for std::hash (and to support using this type in unordered_map etc.)

    │ │ │ -

    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:

    │ │ │ +

    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
    │ │ │ @@ -9231,27 +3266,27 @@
    │ │ │     static inline constexpr disk_job_flags_t force_copy  = 0_bit;
    │ │ │     static inline constexpr disk_job_flags_t sequential_access  = 3_bit;
    │ │ │     static inline constexpr disk_job_flags_t volatile_read  = 4_bit;
    │ │ │     static inline constexpr disk_job_flags_t v1_hash  = 5_bit;
    │ │ │     static constexpr disk_job_flags_t flush_piece  = 7_bit;
    │ │ │  };
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │

    new_torrent()

    │ │ │
    │ │ │  virtual storage_holder new_torrent (storage_params const& p
    │ │ │        , std::shared_ptr<void> const& torrent) = 0;
    │ │ │  
    │ │ │

    this is called when a new torrent is added. The shared_ptr can be │ │ │ used to hold the internal torrent object alive as long as there are │ │ │ outstanding disk operations on the storage. │ │ │ The returned storage_holder is an owning reference to the underlying │ │ │ storage that was just created. It is fundamentally a storage_index_t

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

    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.

    │ │ │ @@ -9446,15 +3481,15 @@ │ │ │ virtual std::vector<open_file_state> get_status (storage_index_t) const = 0; │ │ │ │ │ │

    Return a list of all the files that are currently open for the │ │ │ specified storage/torrent. This is is just used for the client to │ │ │ query the currently open files, and which modes those files are open │ │ │ in.

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

    abort()

    │ │ │
    │ │ │  virtual void abort (bool wait) = 0;
    │ │ │  
    │ │ │

    this is called when the session is starting to shut down. The disk │ │ │ I/O object is expected to flush any outstanding write jobs, cancel │ │ │ hash jobs and initiate tearing down of any internal threads. If │ │ │ @@ -9545,15 +3580,15 @@ │ │ │

    │ │ │  storage_holder (storage_index_t idx, disk_interface& disk_io);
    │ │ │  
    │ │ │

    constructs a storage holder, for storage idx held at disk │ │ │ interface disk_io. When the holder is destructed or reset, │ │ │ disk_io will be notified that the storage can be removed.

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

    reset()

    │ │ │
    │ │ │  void reset ();
    │ │ │  
    │ │ │

    release ownership of the storage, removing the torrent from │ │ │ the disk subsystem. After this call the holder is empty and │ │ │ operator bool() returns false.

    │ │ │ @@ -9587,24 +3622,24 @@ │ │ │

    Declared in "libtorrent/disk_buffer_holder.hpp"

    │ │ │

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

    │ │ │
    │ │ │  struct buffer_allocator_interface
    │ │ │  {
    │ │ │ -   virtual void free_disk_buffer (char* b) = 0;
    │ │ │     virtual void free_multiple_buffers (span<char*> bufs) = 0;
    │ │ │ +   virtual void free_disk_buffer (char* b) = 0;
    │ │ │  };
    │ │ │  
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    free_multiple_buffers() free_disk_buffer()

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

    free_disk_buffer() free_multiple_buffers()

    │ │ │
    │ │ │ -virtual void free_disk_buffer (char* b) = 0;
    │ │ │  virtual void free_multiple_buffers (span<char*> bufs) = 0;
    │ │ │ +virtual void free_disk_buffer (char* b) = 0;
    │ │ │  
    │ │ │

    returns one or more disk buffers (previously handed out by │ │ │ the disk subsystem) back to the allocator. The bulk │ │ │ overload, free_multiple_buffers(), lets callers free a │ │ │ batch of buffers under a single mutex acquisition.

    │ │ │ [report issue]
    │ │ │
    │ │ │ @@ -9614,16 +3649,16 @@ │ │ │

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

    │ │ │

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

    │ │ │
    │ │ │  struct disk_buffer_holder
    │ │ │  {
    │ │ │ -   disk_buffer_holder& operator= (disk_buffer_holder&&) & noexcept;
    │ │ │     disk_buffer_holder (disk_buffer_holder&&) noexcept;
    │ │ │ +   disk_buffer_holder& operator= (disk_buffer_holder&&) & noexcept;
    │ │ │     disk_buffer_holder& operator= (disk_buffer_holder const&) = delete;
    │ │ │     disk_buffer_holder (disk_buffer_holder const&) = delete;
    │ │ │     disk_buffer_holder (buffer_allocator_interface& alloc, char* buf) noexcept;
    │ │ │     disk_buffer_holder () noexcept = default;
    │ │ │     ~disk_buffer_holder ();
    │ │ │     char* data () const noexcept;
    │ │ │     void reset ();
    │ │ │ @@ -9651,22 +3686,22 @@
    │ │ │  
    │ │ │

    ~disk_buffer_holder()

    │ │ │
    │ │ │  ~disk_buffer_holder ();
    │ │ │  
    │ │ │

    frees disk buffer held by this object

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

    data()

    │ │ │
    │ │ │  char* data () const noexcept;
    │ │ │  
    │ │ │

    return a pointer to the held buffer, if any. Otherwise returns nullptr.

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

    reset()

    │ │ │
    │ │ │  void reset ();
    │ │ │  
    │ │ │

    free the held disk buffer, if any, and clear the holder. This sets the │ │ │ holder object to a default-constructed state

    │ │ │ [report issue]
    │ │ │ @@ -9680,15 +3715,15 @@ │ │ │
    │ │ │

    is_mutable()

    │ │ │
    │ │ │  bool is_mutable () const noexcept;
    │ │ │  
    │ │ │

    if this returns true, the buffer may not be modified in place

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

    bool()

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

    implicitly convertible to true if the object is currently holding a │ │ │ buffer

    │ │ │ [report issue]
    │ │ │ @@ -9702,36 +3737,36 @@ │ │ │ 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 const&) = delete;
    │ │ │     disk_buffer_ref (disk_buffer_ref&&) noexcept;
    │ │ │ +   disk_buffer_ref (disk_buffer_ref const&) = delete;
    │ │ │     ~disk_buffer_ref ();
    │ │ │ -   disk_buffer_ref& operator= (disk_buffer_ref&&) noexcept;
    │ │ │     disk_buffer_ref& operator= (disk_buffer_ref const&) = delete;
    │ │ │ +   disk_buffer_ref& operator= (disk_buffer_ref&&) noexcept;
    │ │ │     char* data () const noexcept;
    │ │ │     explicit operator bool () 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;
    │ │ │  
    │ │ │

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

    │ │ │ @@ -9744,16 +3779,16 @@ │ │ │ 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);
    │ │ │  
    │ │ │ @@ -9761,77 +3796,18 @@ │ │ │ buffers added via add() must have come from this same │ │ │ allocator. The batch is freed in the destructor.

    │ │ │ │ │ │ [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_int (int name, int val) = 0;
    │ │ │ -   virtual void set_str (int name, std::string 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_bool() set_str() set_int()

    │ │ │ -
    │ │ │ -virtual void set_int (int name, int val) = 0;
    │ │ │ -virtual void set_str (int name, std::string 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_str() get_bool() get_int()

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

    status_t

    │ │ │

    Declared in "libtorrent/disk_interface.hpp"

    │ │ │
    │ │ │
    fatal_disk_error
    │ │ │ @@ -9898,6882 +3874,1177 @@ │ │ │
    When this is not set, the kernel is hinted that access to this file will │ │ │ be made sequentially.
    │ │ │
    │ │ │
    │ │ │
    mmapped
    │ │ │
    the file is memory mapped
    │ │ │
    │ │ │ -

    The pop_alerts() function on session is the main interface for retrieving │ │ │ -alerts (warnings, messages and errors from libtorrent). If no alerts have │ │ │ -been posted by libtorrent pop_alerts() will return an empty list.

    │ │ │ -

    By default, only errors are reported. settings_pack::alert_mask can be │ │ │ -used to specify which kinds of events should be reported. The alert mask is │ │ │ -a combination of the alert_category_t flags in the alert class.

    │ │ │ -

    Every alert belongs to one or more category. There is a cost associated with │ │ │ -posting alerts. Only alerts that belong to an enabled category are │ │ │ -posted. Setting the alert bitmask to 0 will disable all alerts (except those │ │ │ -that are non-discardable). Alerts that are responses to API calls such as │ │ │ -save_resume_data() and post_session_stats() are non-discardable and will be │ │ │ -posted even if their category is disabled.

    │ │ │ -

    There are other alert base classes that some alerts derive from, all the │ │ │ -alerts that are generated for a specific torrent are derived from │ │ │ -torrent_alert, and tracker events derive from tracker_alert.

    │ │ │ -

    Alerts returned by pop_alerts() are only valid until the next call to │ │ │ -pop_alerts(). You may not copy an alert object to access it after the next │ │ │ -call to pop_alerts(). Internal members of alerts also become invalid once │ │ │ -pop_alerts() is called again.

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

    alert

    │ │ │ -

    Declared in "libtorrent/alert.hpp"

    │ │ │ -

    The alert class is the base class that specific messages are derived from. │ │ │ -alert types are not copyable, and cannot be constructed by the client. The │ │ │ -pointers returned by libtorrent are short lived (the details are described │ │ │ -under session_handle::pop_alerts())

    │ │ │ -
    │ │ │ -struct alert
    │ │ │ -{
    │ │ │ -   time_point timestamp () const;
    │ │ │ -   virtual int type () const noexcept = 0;
    │ │ │ -   virtual char const* what () const noexcept = 0;
    │ │ │ -   virtual std::string message () const = 0;
    │ │ │ -   virtual alert_category_t category () const noexcept = 0;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    timestamp()

    │ │ │ -
    │ │ │ -time_point timestamp () const;
    │ │ │ -
    │ │ │ -

    a timestamp is automatically created in the constructor

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

    type()

    │ │ │ -
    │ │ │ -virtual int type () const noexcept = 0;
    │ │ │ -
    │ │ │ -

    returns an integer that is unique to this alert type. It can be │ │ │ -compared against a specific alert by querying a static constant called alert_type │ │ │ -in the alert. It can be used to determine the run-time type of an alert* in │ │ │ -order to cast to that alert type and access specific members.

    │ │ │ -

    e.g:

    │ │ │ -
    │ │ │ -std::vector<alert*> alerts;
    │ │ │ -ses.pop_alerts(&alerts);
    │ │ │ -for (alert* a : alerts) {
    │ │ │ -        switch (a->type()) {
    │ │ │ -
    │ │ │ -                case read_piece_alert::alert_type:
    │ │ │ -                {
    │ │ │ -                        auto* p = static_cast<read_piece_alert*>(a);
    │ │ │ -                        if (p->ec) {
    │ │ │ -                                // read_piece failed
    │ │ │ -                                break;
    │ │ │ -                        }
    │ │ │ -                        // use p
    │ │ │ -                        break;
    │ │ │ -                }
    │ │ │ -                case file_renamed_alert::alert_type:
    │ │ │ -                {
    │ │ │ -                        // etc...
    │ │ │ -                }
    │ │ │ -        }
    │ │ │ -}
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    what()

    │ │ │ -
    │ │ │ -virtual char const* what () const noexcept = 0;
    │ │ │ -
    │ │ │ -

    returns a string literal describing the type of the alert. It does │ │ │ -not include any information that might be bundled with the alert.

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

    message()

    │ │ │ -
    │ │ │ -virtual std::string message () const = 0;
    │ │ │ -
    │ │ │ -

    generate a string describing the alert and the information bundled │ │ │ -with it. This is mainly intended for debug and development use. It is not suitable │ │ │ -to use this for applications that may be localized. Instead, handle each alert │ │ │ -type individually and extract and render the information from the alert depending │ │ │ -on the locale.

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

    category()

    │ │ │ -
    │ │ │ -virtual alert_category_t category () const noexcept = 0;
    │ │ │ -
    │ │ │ -

    returns a bitmask specifying which categories this alert belong to.

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

    dht_routing_bucket

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    struct to hold information about a single DHT routing table bucket

    │ │ │ -
    │ │ │ -struct dht_routing_bucket
    │ │ │ -{
    │ │ │ -   int num_nodes  = 0;
    │ │ │ -   int num_replacements  = 0;
    │ │ │ -   int last_active  = 0;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    num_nodes num_replacements
    │ │ │ -
    the total number of nodes and replacement nodes │ │ │ -in the routing table
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    last_active
    │ │ │ -
    number of seconds since last activity
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This is a base class for alerts that are associated with a │ │ │ -specific torrent. It contains a handle to the torrent.

    │ │ │ -

    Note that by the time the client receives a torrent_alert, its │ │ │ -handle member may be invalid.

    │ │ │ -
    │ │ │ -struct torrent_alert : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   torrent_handle handle;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    message()

    │ │ │ -
    │ │ │ -std::string message () const override;
    │ │ │ -
    │ │ │ -

    returns the message associated with this alert

    │ │ │ -[report issue]
    │ │ │ -
    handle
    │ │ │ -
    The torrent_handle pointing to the torrent this │ │ │ -alert is associated with.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    peer_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    The peer alert is a base class for alerts that refer to a specific peer. It includes all │ │ │ -the information to identify the peer. i.e. ip and peer-id.

    │ │ │ -
    │ │ │ -struct peer_alert : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   enum endpoint_type_t
    │ │ │ -   {
    │ │ │ -      ip_endpoint,
    │ │ │ -      i2p_endpoint,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   peer_endpoint_t ep;
    │ │ │ -   peer_id pid;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    enum endpoint_type_t

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ - │ │ │ +

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

    settings_pack

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +

    The settings_pack struct, contains the names of all settings as │ │ │ +enum values. These values are passed in to the set_str(), │ │ │ +set_int(), set_bool() functions, to specify the setting to │ │ │ +change.

    │ │ │ +

    The settings_pack only stores values for settings that have been │ │ │ +explicitly set on this object. However, it can still be queried for │ │ │ +settings that have not been set and returns the default value for those │ │ │ +settings.

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescriptiontypedefault
    ip_endpoint0 
    i2p_endpoint1 
    user_agentstringlibtorrent/
    │ │ │ -[report issue]
    │ │ │ -
    ep
    │ │ │ -
    The peer's endpoint, either IP address and port or i2p destination │ │ │ -hash.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    pid
    │ │ │ -
    the peer ID, if known.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    tracker_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This is a base class used for alerts that are associated with a │ │ │ -specific tracker. It derives from torrent_alert since a tracker │ │ │ -is also associated with a specific torrent.

    │ │ │ -
    │ │ │ -struct tracker_alert : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* tracker_url () const;
    │ │ │ -
    │ │ │ -   aux::noexcept_movable<tcp::endpoint> local_endpoint;
    │ │ │ -   protocol_version version;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    tracker_url()

    │ │ │ -
    │ │ │ -char const* tracker_url () const;
    │ │ │ -
    │ │ │ -

    returns a 0-terminated string of the tracker's URL

    │ │ │ -[report issue]
    │ │ │ -
    local_endpoint
    │ │ │ -
    endpoint of the listen interface being announced
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    version
    │ │ │ -
    the bittorrent protocol version that was announced
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    torrent_removed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    The torrent_removed_alert is posted whenever a torrent is removed. Since │ │ │ -the torrent handle in its base class will usually be invalid (since the torrent │ │ │ -is already removed) it has the info hash as a member, to identify it. │ │ │ -It's posted when the alert_category::status bit is set in the alert_mask.

    │ │ │ -

    Note that the handle remains valid for some time after │ │ │ -torrent_removed_alert is posted, as long as some internal libtorrent │ │ │ -task (such as an I/O task) refers to it. Additionally, other alerts like │ │ │ -save_resume_data_alert may be posted after torrent_removed_alert. │ │ │ -To synchronize on whether the torrent has been removed or not, call │ │ │ -torrent_handle::in_session(). This will return true before │ │ │ -torrent_removed_alert is posted, and false afterward.

    │ │ │ -

    Even though the handle member doesn't point to an existing torrent anymore, │ │ │ -it is still useful for comparing to other handles, which may also no │ │ │ -longer point to existing torrents, but to the same non-existing torrents.

    │ │ │ -

    The torrent_handle acts as a weak_ptr, even though its object no │ │ │ -longer exists, it can still compare equal to another weak pointer which │ │ │ -points to the same non-existent object.

    │ │ │ -
    │ │ │ -struct torrent_removed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   info_hash_t info_hashes;
    │ │ │ -   client_data_t userdata;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    userdata
    │ │ │ -
    'userdata` as set in add_torrent_params at torrent creation. │ │ │ -This can be used to associate this torrent with related data │ │ │ -in the client application more efficiently than info_hashes.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    read_piece_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when the asynchronous read operation initiated by │ │ │ -a call to torrent_handle::read_piece() is completed. If the read failed, the torrent │ │ │ -is paused and an error state is set and the buffer member of the alert │ │ │ -is 0. If successful, buffer points to a buffer containing all the data │ │ │ -of the piece. piece is the piece index that was read. size is the │ │ │ -number of bytes that was read.

    │ │ │ -

    If the operation fails, error will indicate what went wrong.

    │ │ │ -
    │ │ │ -struct read_piece_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -   error_code const error;
    │ │ │ -   boost::shared_array<char> const buffer;
    │ │ │ -   piece_index_t const piece;
    │ │ │ -   int const size;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_completed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This is posted whenever an individual file completes its download. i.e. │ │ │ -All pieces overlapping this file have passed their hash check.

    │ │ │ -
    │ │ │ -struct file_completed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   file_index_t const index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    index
    │ │ │ -
    refers to the index of the file that completed.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_renamed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

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

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

    new_name() old_name()

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

    returns the new and previous file name, respectively.

    │ │ │ -[report issue]
    │ │ │ -
    index
    │ │ │ -
    refers to the index of the file that was renamed,
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    file_rename_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

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

    │ │ │ -
    │ │ │ -struct file_rename_failed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -   file_index_t const index;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    index error
    │ │ │ -
    refers to the index of the file that was supposed to be renamed, │ │ │ -error is the error code returned from the filesystem.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    performance_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a limit is reached that might have a negative impact on │ │ │ -upload or download rate performance.

    │ │ │ -
    │ │ │ -struct performance_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   enum performance_warning_t
    │ │ │ -   {
    │ │ │ -      outstanding_disk_buffer_limit_reached,
    │ │ │ -      outstanding_request_limit_reached,
    │ │ │ -      upload_limit_too_low,
    │ │ │ -      download_limit_too_low,
    │ │ │ -      send_buffer_watermark_too_low,
    │ │ │ -      too_many_optimistic_unchoke_slots,
    │ │ │ -      too_high_disk_queue_limit,
    │ │ │ -      aio_limit_reached,
    │ │ │ -      deprecated_bittyrant_with_no_uplimit,
    │ │ │ -      too_few_outgoing_ports,
    │ │ │ -      too_few_file_descriptors,
    │ │ │ -      num_warnings,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::performance_warning;
    │ │ │ -   performance_warning_t const warning_code;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    enum performance_warning_t

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ - │ │ │ +

    this is the client identification to the tracker. The recommended │ │ │ +format of this string is: "client-name/client-version │ │ │ +libtorrent/libtorrent-version". This name will not only be used when │ │ │ +making HTTP requests, but also when sending extended headers to │ │ │ +peers that support that extension. It may not contain r or n

    │ │ │ +
    │ │ │ │ │ │ +│ │ │ │ │ │ -│ │ │ -│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    namevaluedescriptiontypedefault
    outstanding_disk_buffer_limit_reached0This warning means that the number of bytes queued to be written to disk │ │ │ -exceeds the max disk byte queue setting (settings_pack::max_queued_disk_bytes). │ │ │ -This might restrict the download rate, by not queuing up enough write jobs │ │ │ -to the disk I/O thread. When this alert is posted, peer connections are │ │ │ -temporarily stopped from downloading, until the queued disk bytes have fallen │ │ │ -below the limit again. Unless your max_queued_disk_bytes setting is already │ │ │ -high, you might want to increase it to get better performance.
    announce_ipstring 
    outstanding_request_limit_reached1This is posted when libtorrent would like to send more requests to a peer, │ │ │ -but it's limited by settings_pack::max_out_request_queue. The queue length │ │ │ -libtorrent is trying to achieve is determined by the download rate and the │ │ │ -assumed round-trip-time (settings_pack::request_queue_time). The assumed │ │ │ -round-trip-time is not limited to just the network RTT, but also the remote disk │ │ │ -access time and message handling time. It defaults to 3 seconds. The target number │ │ │ -of outstanding requests is set to fill the bandwidth-delay product (assumed RTT │ │ │ -times download rate divided by number of bytes per request). When this alert │ │ │ -is posted, there is a risk that the number of outstanding requests is too low │ │ │ -and limits the download rate. You might want to increase the max_out_request_queue │ │ │ -setting.
    upload_limit_too_low2This warning is posted when the amount of TCP/IP overhead is greater than the │ │ │ -upload rate limit. When this happens, the TCP/IP overhead is caused by a much │ │ │ -faster download rate, triggering TCP ACK packets. These packets eat into the │ │ │ -rate limit specified to libtorrent. When the overhead traffic is greater than │ │ │ -the rate limit, libtorrent will not be able to send any actual payload, such │ │ │ -as piece requests. This means the download rate will suffer, and new requests │ │ │ -can be sent again. There will be an equilibrium where the download rate, on │ │ │ -average, is about 20 times the upload rate limit. If you want to maximize the │ │ │ -download rate, increase the upload rate limit above 5% of your download capacity.
    download_limit_too_low3This is the same warning as upload_limit_too_low but referring to the download │ │ │ -limit instead of upload. This suggests that your download rate limit is much lower │ │ │ -than your upload capacity. Your upload rate will suffer. To maximize upload rate, │ │ │ -make sure your download rate limit is above 5% of your upload capacity.
    send_buffer_watermark_too_low4

    We're stalled on the disk. We want to write to the socket, and we can write │ │ │ -but our send buffer is empty, waiting to be refilled from the disk. │ │ │ -This either means the disk is slower than the network connection │ │ │ -or that our send buffer watermark is too small, because we can │ │ │ -send it all before the disk gets back to us. │ │ │ -The number of bytes that we keep outstanding, requested from the disk, is calculated │ │ │ -as follows:

    │ │ │ -
    │ │ │ -min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark))
    │ │ │ -
    │ │ │ -

    If you receive this alert, you might want to either increase your send_buffer_watermark │ │ │ -or send_buffer_watermark_factor.

    │ │ │ -
    │ │ │ +

    announce_ip is the ip address passed along to trackers as the │ │ │ +&ip= parameter. If left as the default, that parameter is │ │ │ +omitted.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    This setting is only meant for very special cases where a seed is │ │ │ +running on the same host as the tracker, and the tracker accepts │ │ │ +the IP parameter (which normal trackers don't). Do not set this │ │ │ +option unless you also control the tracker.

    │ │ │ +
    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    too_many_optimistic_unchoke_slots5If the half (or more) of all upload slots are set as optimistic unchoke slots, this │ │ │ -warning is issued. You probably want more regular (rate based) unchoke slots.
    handshake_client_versionstring 
    too_high_disk_queue_limit6If the disk write queue ever grows larger than half of the cache size, this warning │ │ │ -is posted. The disk write queue eats into the total disk cache and leaves very little │ │ │ -left for the actual cache. This causes the disk cache to oscillate in evicting large │ │ │ -portions of the cache before allowing peers to download any more, onto the disk write │ │ │ -queue. Either lower max_queued_disk_bytes or increase cache_size.
    │ │ │ +

    this is the client name and version identifier sent to peers in the │ │ │ +handshake message. If this is an empty string, the user_agent is │ │ │ +used instead. This string must be a UTF-8 encoded unicode string.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    aio_limit_reached7
    outgoing_interfacesstring 
    deprecated_bittyrant_with_no_uplimit8 
    │ │ │ +

    This controls which IP address outgoing TCP peer connections are bound │ │ │ +to, in addition to controlling whether such connections are also │ │ │ +bound to a specific network interface/adapter (bind-to-device).

    │ │ │ +

    This string is a comma-separated list of IP addresses and │ │ │ +interface names. An empty string will not bind TCP sockets to a │ │ │ +device, and let the network stack assign the local address.

    │ │ │ +

    A list of names will be used to bind outgoing TCP sockets in a │ │ │ +round-robin fashion. An IP address will simply be used to bind() │ │ │ +the socket. An interface name will attempt to bind the socket to │ │ │ +that interface. If that fails, or is unsupported, one of the IP │ │ │ +addresses configured for that interface is used to bind() the │ │ │ +socket to. If the interface or adapter doesn't exist, the │ │ │ +outgoing peer connection will fail with an error message suggesting │ │ │ +the device cannot be found. Adapter names on Unix systems are of │ │ │ +the form "eth0", "eth1", "tun0", etc. This may be useful for │ │ │ +clients that are multi-homed. Binding an outgoing connection to a │ │ │ +local IP does not necessarily make the connection via the │ │ │ +associated NIC/Adapter.

    │ │ │ +

    When outgoing interfaces are specified, incoming connections or │ │ │ +packets sent to a local interface or IP that's not in this list │ │ │ +will be rejected with a peer_blocked_alert with │ │ │ +invalid_local_interface as the reason.

    │ │ │ +

    Note that these are just interface/adapter names or IP addresses. │ │ │ +There are no ports specified in this list. IPv6 addresses without │ │ │ +port should be specified without enclosing [, ].

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    too_few_outgoing_ports9This is generated if outgoing peer connections are failing because of address in use │ │ │ -errors, indicating that settings_pack::outgoing_ports is set and is too small of │ │ │ -a range. Consider not using the outgoing_ports setting at all, or widen the range to │ │ │ -include more ports.
    listen_interfacesstring0.0.0.0:6881,[::]:6881
    too_few_file_descriptors10 
    │ │ │ +

    a comma-separated list of (IP or device name, port) pairs. These are │ │ │ +the listen ports that will be opened for accepting incoming uTP and │ │ │ +TCP peer connections. These are also used for outgoing uTP and UDP │ │ │ +tracker connections and DHT nodes.

    │ │ │ +

    It is possible to listen on multiple interfaces and │ │ │ +multiple ports. Binding to port 0 will make the operating system │ │ │ +pick the port.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    There are reasons to stick to the same port across sessions, │ │ │ +which would mean only using port 0 on the first start, and │ │ │ +recording the port that was picked for subsequent startups. │ │ │ +Trackers, the DHT and other peers will remember the port they see │ │ │ +you use and hand that port out to other peers trying to connect │ │ │ +to you, as well as trying to connect to you themselves.

    │ │ │ +
    │ │ │ +

    A port that has an "s" suffix will accept SSL peer connections. (note │ │ │ +that SSL sockets are only available in builds with SSL support)

    │ │ │ +

    A port that has an "l" suffix will be considered a local network. │ │ │ +i.e. it's assumed to only be able to reach hosts in the same local │ │ │ +network as the IP address (based on the netmask associated with the │ │ │ +IP, queried from the operating system).

    │ │ │ +

    if binding fails, the listen_failed_alert is posted. Once a │ │ │ +socket binding succeeds (if it does), the listen_succeeded_alert │ │ │ +is posted. There may be multiple failures before a success.

    │ │ │ +

    If a device name that does not exist is configured, no listen │ │ │ +socket will be opened for that interface. If this is the only │ │ │ +interface configured, it will be as if no listen ports are │ │ │ +configured.

    │ │ │ +

    If no listen ports are configured (e.g. listen_interfaces is an │ │ │ +empty string), networking will be disabled. No DHT will start, no │ │ │ +outgoing uTP or tracker connections will be made. No incoming TCP │ │ │ +or uTP connections will be accepted. (outgoing TCP connections │ │ │ +will still be possible, depending on │ │ │ +settings_pack::outgoing_interfaces).

    │ │ │ +

    For example: │ │ │ +[::1]:8888 - will only accept connections on the IPv6 loopback │ │ │ +address on port 8888.

    │ │ │ +

    eth0:4444,eth1:4444 - will accept connections on port 4444 on │ │ │ +any IP address bound to device eth0 or eth1.

    │ │ │ +

    [::]:0s - will accept SSL connections on a port chosen by the │ │ │ +OS. And not accept non-SSL connections at all.

    │ │ │ +

    0.0.0.0:6881,[::]:6881 - binds to all interfaces on port 6881.

    │ │ │ +

    10.0.1.13:6881l - binds to the local IP address, port 6881, but │ │ │ +only allow talking to peers on the same local network. The netmask │ │ │ +is queried from the operating system. Interfaces marked l are │ │ │ +not announced to trackers, unless the tracker is also on the same │ │ │ +local network.

    │ │ │ +

    Windows OS network adapter device name must be specified with GUID. │ │ │ +It can be obtained from "netsh lan show interfaces" command output. │ │ │ +GUID must be uppercased string embraced in curly brackets. │ │ │ +{E4F0B674-0DFC-48BB-98A5-2AA730BDB6D6}:7777 - will accept │ │ │ +connections on port 7777 on adapter with this GUID.

    │ │ │ +

    For more information, see the Multi-homed hosts section.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │
    nametypedefault
    num_warnings11
    proxy_hostnamestring 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    state_changed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    Generated whenever a torrent changes its state.

    │ │ │ -
    │ │ │ -struct state_changed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   torrent_status::state_t const state;
    │ │ │ -   torrent_status::state_t const prev_state;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    state
    │ │ │ -
    the new state of the torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    prev_state
    │ │ │ -
    the previous state.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    tracker_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated on tracker time outs, premature disconnects, │ │ │ -invalid response or a HTTP response other than "200 OK". From the alert │ │ │ -you can get the handle to the torrent the tracker belongs to.

    │ │ │ -
    │ │ │ -struct tracker_error_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* failure_reason () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::tracker | alert_category::error;
    │ │ │ -   int const times_in_row;
    │ │ │ -   error_code const error;
    │ │ │ -   operation_t op;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    failure_reason()

    │ │ │ -
    │ │ │ -char const* failure_reason () const;
    │ │ │ -
    │ │ │ -

    if the tracker sent a "failure reason" string, it will be returned │ │ │ -here.

    │ │ │ -[report issue]
    │ │ │ -
    times_in_row
    │ │ │ -
    This member says how many times in a row this tracker has failed.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error code indicating why the tracker announce failed. If it is │ │ │ -is lt::errors::tracker_failure the failure_reason() might contain │ │ │ -a more detailed description of why the tracker rejected the request. │ │ │ -HTTP status codes indicating errors are also set in this field.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    tracker_warning_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is triggered if the tracker reply contains a warning field. │ │ │ -Usually this means that the tracker announce was successful, but the │ │ │ -tracker has a message to the client.

    │ │ │ -
    │ │ │ -struct tracker_warning_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* warning_message () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::tracker | alert_category::error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    warning_message()

    │ │ │ -
    │ │ │ -char const* warning_message () const;
    │ │ │ -
    │ │ │ -

    the message associated with this warning

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

    scrape_reply_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a scrape request succeeds.

    │ │ │ -
    │ │ │ -struct scrape_reply_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::tracker;
    │ │ │ -   int const incomplete;
    │ │ │ -   int const complete;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    incomplete complete
    │ │ │ -
    the data returned in the scrape response. These numbers │ │ │ -may be -1 if the response was malformed.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    scrape_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    If a scrape request fails, this alert is generated. This might be due │ │ │ -to the tracker timing out, refusing connection or returning an http response │ │ │ -code indicating an error.

    │ │ │ -
    │ │ │ -struct scrape_failed_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* error_message () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::tracker | alert_category::error;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    error_message()

    │ │ │ -
    │ │ │ -char const* error_message () const;
    │ │ │ -
    │ │ │ -

    if the error indicates there is an associated message, this returns │ │ │ -that message. Otherwise and empty string.

    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error itself. This may indicate that the tracker sent an error │ │ │ -message (error::tracker_failure), in which case it can be │ │ │ -retrieved by calling error_message().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    tracker_reply_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is only for informational purpose. It is generated when a tracker announce │ │ │ -succeeds. It is generated regardless what kind of tracker was used, be it UDP, HTTP or │ │ │ -the DHT.

    │ │ │ -
    │ │ │ -struct tracker_reply_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::tracker;
    │ │ │ -   int const num_peers;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_peers
    │ │ │ -
    tells how many peers the tracker returned in this response. This is │ │ │ -not expected to be greater than the num_want settings. These are not necessarily │ │ │ -all new peers, some of them may already be connected.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_reply_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated each time the DHT receives peers from a node. num_peers │ │ │ -is the number of peers we received in this packet. Typically these packets are │ │ │ -received from multiple DHT nodes, and so the alerts are typically generated │ │ │ -a few at a time.

    │ │ │ -
    │ │ │ -struct dht_reply_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht | alert_category::tracker;
    │ │ │ -   int const num_peers;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    tracker_announce_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated each time a tracker announce is sent (or attempted to be sent). │ │ │ -There are no extra data members in this alert. The url can be found in the base class │ │ │ -however.

    │ │ │ -
    │ │ │ -struct tracker_announce_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::tracker;
    │ │ │ -   event_t const event;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    event
    │ │ │ -
    specifies what event was sent to the tracker. See event_t.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    hash_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a finished piece fails its hash check. You can get the handle │ │ │ -to the torrent which got the failed piece and the index of the piece itself from the alert.

    │ │ │ -
    │ │ │ -struct hash_failed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_ban_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a peer is banned because it has sent too many corrupt pieces │ │ │ -to us. ip is the endpoint to the peer that was banned.

    │ │ │ -
    │ │ │ -struct peer_ban_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_unsnubbed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a peer is un-snubbed. Essentially when it was snubbed for stalling │ │ │ -sending data, and now it started sending data again.

    │ │ │ -
    │ │ │ -struct peer_unsnubbed_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_snubbed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a peer is snubbed, when it stops sending data when we request │ │ │ -it.

    │ │ │ -
    │ │ │ -struct peer_snubbed_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer │ │ │ -will be disconnected, but you get its ip address from the alert, to identify it.

    │ │ │ -
    │ │ │ -struct peer_error_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -   operation_t op;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    a 0-terminated string of the low-level operation that failed, or nullptr if │ │ │ -there was no low level disk operation.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    tells you what error caused this alert.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_connect_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted every time an incoming peer connection both │ │ │ -successfully passes the protocol handshake and is associated with a │ │ │ -torrent, or an outgoing peer connection attempt succeeds. For arbitrary │ │ │ -incoming connections, see incoming_connection_alert.

    │ │ │ -
    │ │ │ -struct peer_connect_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   enum direction_t
    │ │ │ -   {
    │ │ │ -      in,
    │ │ │ -      out,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::connect;
    │ │ │ -   direction_t direction;
    │ │ │ -   socket_type_t socket_type;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    enum direction_t

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ - │ │ │ +

    when using a proxy, this is the hostname where the proxy is running │ │ │ +see proxy_type. Note that when using a proxy, the │ │ │ +settings_pack::listen_interfaces setting is overridden and only a │ │ │ +single interface is created, just to contact the proxy. This │ │ │ +means a proxy cannot be combined with SSL torrents or multiple │ │ │ +listen interfaces. This proxy listen interface will not accept │ │ │ +incoming TCP connections, will not map ports with any gateway and │ │ │ +will not enable local service discovery. All traffic is supposed │ │ │ +to be channeled through the proxy.

    │ │ │ + │ │ │ +
    │ │ │ │ │ │ -│ │ │ +│ │ │ +│ │ │ │ │ │ -│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │
    namevaluedescriptiontypedefault
    in0
    proxy_usernamestring 
    out1
    proxy_passwordstring 
    │ │ │ -[report issue]
    │ │ │ -
    direction
    │ │ │ -
    Tells you if the peer was incoming or outgoing
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    peer_disconnected_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a peer is disconnected for any reason (other than the ones │ │ │ -covered by peer_error_alert ).

    │ │ │ -
    │ │ │ -struct peer_disconnected_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::connect;
    │ │ │ -   socket_type_t const socket_type;
    │ │ │ -   operation_t const op;
    │ │ │ -   error_code const error;
    │ │ │ -   close_reason_t const reason;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    socket_type
    │ │ │ -
    the kind of socket this peer was connected over
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    the operation or level where the error occurred. Specified as an │ │ │ -value from the operation_t enum. Defined in operations.hpp.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    tells you what error caused peer to disconnect.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    reason
    │ │ │ -
    the reason the peer disconnected (if specified)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    invalid_request_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This is a debug alert that is generated by an incoming invalid piece request. │ │ │ -ip is the address of the peer and the request is the actual incoming │ │ │ -request from the peer. See peer_request for more info.

    │ │ │ -
    │ │ │ -struct invalid_request_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -   peer_request const request;
    │ │ │ -   bool const we_have;
    │ │ │ -   bool const peer_interested;
    │ │ │ -   bool const withheld;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    request
    │ │ │ -
    the request we received from the peer
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    we_have
    │ │ │ -
    true if we have this piece
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    peer_interested
    │ │ │ -
    true if the peer indicated that it was interested to download before │ │ │ -sending the request
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    withheld
    │ │ │ -
    if this is true, the peer is not allowed to download this piece because │ │ │ -of super-seeding rules.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_finished_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a torrent switches from being a downloader to a seed. │ │ │ -It will only be generated once per torrent. It contains a torrent_handle to the │ │ │ -torrent in question.

    │ │ │ -
    │ │ │ -struct torrent_finished_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_finished_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert is posted every time a piece completes downloading │ │ │ -and passes the hash check. This alert derives from torrent_alert │ │ │ -which contains the torrent_handle to the torrent the piece belongs to. │ │ │ -Note that being downloaded and passing the hash check may happen before │ │ │ -the piece is also fully flushed to disk. So torrent_handle::have_piece() │ │ │ -may still return false

    │ │ │ -
    │ │ │ -struct piece_finished_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    piece_index
    │ │ │ -
    the index of the piece that finished
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    request_dropped_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a peer rejects or ignores a piece request.

    │ │ │ -
    │ │ │ -struct request_dropped_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   int const block_index;
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    block_timeout_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a block request times out.

    │ │ │ -
    │ │ │ -struct block_timeout_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   int const block_index;
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    block_finished_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a block request receives a response.

    │ │ │ -
    │ │ │ -struct block_finished_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   int const block_index;
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    block_downloading_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a block request is sent to a peer.

    │ │ │ -
    │ │ │ -struct block_downloading_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   int const block_index;
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    unwanted_block_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a block is received that was not requested or │ │ │ -whose request timed out.

    │ │ │ -
    │ │ │ -struct unwanted_block_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -   int const block_index;
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    storage_moved_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    The storage_moved_alert is generated when all the disk IO has │ │ │ -completed and the files have been moved, as an effect of a call to │ │ │ -torrent_handle::move_storage. This is useful to synchronize with the │ │ │ -actual disk. The storage_path() member return the new path of the │ │ │ -storage.

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

    storage_path() old_path()

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

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

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

    storage_moved_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    The storage_moved_failed_alert is generated when an attempt to move the storage, │ │ │ -via torrent_handle::move_storage(), fails.

    │ │ │ -
    │ │ │ -struct storage_moved_failed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* file_path () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -   error_code const error;
    │ │ │ -   operation_t op;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    file_path()

    │ │ │ -
    │ │ │ -char const* file_path () const;
    │ │ │ -
    │ │ │ -

    If the error happened for a specific file, this returns its path.

    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    this indicates what underlying operation caused the error
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    torrent_deleted_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a request to delete the files of a torrent complete.

    │ │ │ -

    This alert is posted in the alert_category::storage category, and that bit │ │ │ -needs to be set in the alert_mask.

    │ │ │ -
    │ │ │ -struct torrent_deleted_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -   info_hash_t info_hashes;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hashes
    │ │ │ -
    The info-hash of the torrent that was just deleted. Most of │ │ │ -the time the torrent_handle in the torrent_alert will be invalid by the time │ │ │ -this alert arrives, since the torrent is being deleted. The info_hashes member │ │ │ -is hence the main way of identifying which torrent just completed the delete.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_delete_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a request to delete the files of a torrent fails. │ │ │ -Just removing a torrent from the session cannot fail

    │ │ │ -
    │ │ │ -struct torrent_delete_failed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage
    │ │ │ -   | alert_category::error;
    │ │ │ -   error_code const error;
    │ │ │ -   info_hash_t info_hashes;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    tells you why it failed.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hashes
    │ │ │ -
    the info hash of the torrent whose files failed to be deleted
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    save_resume_data_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated as a response to a torrent_handle::save_resume_data request. │ │ │ -It is generated once the disk IO thread is done writing the state for this torrent.

    │ │ │ -
    │ │ │ -struct save_resume_data_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -   add_torrent_params params;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    params
    │ │ │ -

    the params object is populated with the torrent file whose resume │ │ │ -data was saved. It is suitable to be:

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

    save_resume_data_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated instead of save_resume_data_alert if there was an error │ │ │ -generating the resume data. error describes what went wrong.

    │ │ │ -
    │ │ │ -struct save_resume_data_failed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage
    │ │ │ -   | alert_category::error;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error code from the resume_data failure
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_paused_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated as a response to a torrent_handle::pause request. It is │ │ │ -generated once all disk IO is complete and the files in the torrent have been closed. │ │ │ -This is useful for synchronizing with the disk.

    │ │ │ -
    │ │ │ -struct torrent_paused_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_resumed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated as a response to a torrent_handle::resume() request. It is │ │ │ -generated when a torrent goes from a paused state to an active state.

    │ │ │ -
    │ │ │ -struct torrent_resumed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_checked_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when a torrent completes checking. i.e. when it transitions │ │ │ -out of the checking files state into a state where it is ready to start downloading

    │ │ │ -
    │ │ │ -struct torrent_checked_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    url_seed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a HTTP seed name lookup fails.

    │ │ │ -
    │ │ │ -struct url_seed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* server_url () const;
    │ │ │ -   char const* error_message () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer | alert_category::error;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    server_url()

    │ │ │ -
    │ │ │ -char const* server_url () const;
    │ │ │ -
    │ │ │ -

    the URL the error is associated with

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

    error_message()

    │ │ │ -
    │ │ │ -char const* error_message () const;
    │ │ │ -
    │ │ │ -

    in case the web server sent an error message, this function returns │ │ │ -it.

    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error the web seed encountered. If this is not set, the server │ │ │ -sent an error message, call error_message().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    file_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    If the storage fails to read or write files that it needs access to, this alert is │ │ │ -generated and the torrent is paused.

    │ │ │ -
    │ │ │ -struct file_error_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* filename () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status
    │ │ │ -   | alert_category::storage;
    │ │ │ -   error_code const error;
    │ │ │ -   operation_t op;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    filename()

    │ │ │ -
    │ │ │ -char const* filename () const;
    │ │ │ -
    │ │ │ -

    the file that experienced the error

    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error code describing the error.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    indicates which underlying operation caused the error
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    metadata_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when the metadata has been completely received and the info-hash │ │ │ -failed to match it. i.e. the metadata that was received was corrupt. libtorrent will │ │ │ -automatically retry to fetch it in this case. This is only relevant when running a │ │ │ -torrent-less download, with the metadata extension provided by libtorrent.

    │ │ │ -
    │ │ │ -struct metadata_failed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    indicates what failed when parsing the metadata. This error is │ │ │ -what's returned from lazy_bdecode().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    metadata_received_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when the metadata has been completely received and the torrent │ │ │ -can start downloading. It is not generated on torrents that are started with metadata, but │ │ │ -only those that needs to download it from peers (via ut_metadata).

    │ │ │ -

    There are no additional data members in this alert.

    │ │ │ -

    Typically, when receiving this alert, you would want to trigger saving │ │ │ -its resume data. You do that by calling save_resume_data() on the torrent │ │ │ -handle, like this: │ │ │ -.. code:: c++

    │ │ │ -
    │ │ │ -torrent_handle h = alert->handle; │ │ │ -h.save_resume_data(torrent_handle::save_info_dict);
    │ │ │ -

    In the handler for the save_resume_alert, you can save the resume data │ │ │ -but also a copy of torrent file: │ │ │ -.. code:: c++

    │ │ │ -
    │ │ │ -save_resume_data_alert* alert = ...; │ │ │ -std::vector<char> buf = write_resume_data_buf(alert->params); │ │ │ -std::ofstream f("resume-data"); │ │ │ -f.write(buf.data(), buf.size());
    │ │ │ -

    If writing a .torrent file that may be a v2 torrent and may not yet have │ │ │ -downloaded the piece layers from its peers, you need to specify the │ │ │ -allow_missing_piece_layer flag.

    │ │ │ - │ │ │ -
    │ │ │ -struct metadata_received_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    udp_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when there is an error on a UDP socket. The │ │ │ -UDP sockets are used for all uTP, DHT and UDP tracker traffic. They are │ │ │ -global to the session.

    │ │ │ -
    │ │ │ -struct udp_error_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │ -   operation_t operation;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    endpoint
    │ │ │ -
    the source address associated with the error (if any)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    operation
    │ │ │ -
    the operation that failed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error code describing the error
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    external_ip_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    Whenever libtorrent learns about the machines external IP, this alert is │ │ │ -generated. The external IP address can be acquired from the tracker (if it │ │ │ -supports that) or from peers that supports the extension protocol. │ │ │ -The address can be accessed through the external_address member.

    │ │ │ -
    │ │ │ -struct external_ip_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   aux::noexcept_movable<address> external_address;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    external_address
    │ │ │ -
    the IP address that is believed to be our external IP
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    listen_failed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when none of the ports, given in the port range, to │ │ │ -session can be opened for listening. The listen_interface member is the │ │ │ -interface that failed, error is the error code describing the failure.

    │ │ │ -

    In the case an endpoint was created before generating the alert, it is │ │ │ -represented by address and port. The combinations of socket type │ │ │ -and operation in which such address and port are not valid are: │ │ │ -accept - i2p │ │ │ -accept - socks5 │ │ │ -enum_if - tcp

    │ │ │ -

    libtorrent may sometimes try to listen on port 0, if all other ports failed. │ │ │ -Port 0 asks the operating system to pick a port that's free). If that fails │ │ │ -you may see a listen_failed_alert with port 0 even if you didn't ask to │ │ │ -listen on it.

    │ │ │ -
    │ │ │ -struct listen_failed_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* listen_interface () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status | alert_category::error;
    │ │ │ -   error_code const error;
    │ │ │ -   operation_t op;
    │ │ │ -   lt::socket_type_t const socket_type;
    │ │ │ -   aux::noexcept_movable<lt::address> address;
    │ │ │ -   int const port;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    listen_interface()

    │ │ │ -
    │ │ │ -char const* listen_interface () const;
    │ │ │ -
    │ │ │ -

    the network device libtorrent attempted to listen on, or the IP address

    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error the system returned
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    the underlying operation that failed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    socket_type
    │ │ │ -
    the type of listen socket this alert refers to.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    address
    │ │ │ -
    the address libtorrent attempted to listen on │ │ │ -see alert documentation for validity of this value
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    port
    │ │ │ -
    the port libtorrent attempted to listen on │ │ │ -see alert documentation for validity of this value
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    listen_succeeded_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when the listen port succeeds to be opened on a │ │ │ -particular interface. address and port is the endpoint that │ │ │ -successfully was opened for listening.

    │ │ │ -
    │ │ │ -struct listen_succeeded_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   aux::noexcept_movable<lt::address> address;
    │ │ │ -   int const port;
    │ │ │ -   lt::socket_type_t const socket_type;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    address
    │ │ │ -
    the address libtorrent ended up listening on. This address │ │ │ -refers to the local interface.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    port
    │ │ │ -
    the port libtorrent ended up listening on.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    socket_type
    │ │ │ -
    the type of listen socket this alert refers to.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    portmap_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a NAT router was successfully found but some │ │ │ -part of the port mapping request failed. It contains a text message that │ │ │ -may help the user figure out what is wrong. This alert is not generated in │ │ │ -case it appears the client is not running on a NAT:ed network or if it │ │ │ -appears there is no NAT router that can be remote controlled to add port │ │ │ -mappings.

    │ │ │ -
    │ │ │ -struct portmap_error_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::port_mapping
    │ │ │ -   | alert_category::error;
    │ │ │ -   port_mapping_t const mapping;
    │ │ │ -   portmap_transport map_transport;
    │ │ │ -   aux::noexcept_movable<address> local_address;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    mapping
    │ │ │ -
    refers to the mapping index of the port map that failed, i.e. │ │ │ -the index returned from add_mapping().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    map_transport
    │ │ │ -
    UPnP or NAT-PMP
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    local_address
    │ │ │ -
    the local network the port mapper is running on
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    tells you what failed.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    portmap_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a NAT router was successfully found and │ │ │ -a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP │ │ │ -capable router, this is typically generated once when mapping the TCP │ │ │ -port and, if DHT is enabled, when the UDP port is mapped.

    │ │ │ -
    │ │ │ -struct portmap_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::port_mapping;
    │ │ │ -   port_mapping_t const mapping;
    │ │ │ -   int const external_port;
    │ │ │ -   portmap_protocol const map_protocol;
    │ │ │ -   portmap_transport const map_transport;
    │ │ │ -   aux::noexcept_movable<address> local_address;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    mapping
    │ │ │ -
    refers to the mapping index of the port map that failed, i.e. │ │ │ -the index returned from add_mapping().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    external_port
    │ │ │ -
    the external port allocated for the mapping.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    local_address
    │ │ │ -
    the local network the port mapper is running on
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    portmap_log_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated to log informational events related to either │ │ │ -UPnP or NAT-PMP. They contain a log line and the type (0 = NAT-PMP │ │ │ -and 1 = UPnP). Displaying these messages to an end user is only useful │ │ │ -for debugging the UPnP or NAT-PMP implementation. This alert is only │ │ │ -posted if the alert_category::port_mapping_log flag is enabled in │ │ │ -the alert mask.

    │ │ │ -
    │ │ │ -struct portmap_log_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* log_message () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::port_mapping_log;
    │ │ │ -   portmap_transport const map_transport;
    │ │ │ -   aux::noexcept_movable<address> local_address;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    log_message()

    │ │ │ -
    │ │ │ -char const* log_message () const;
    │ │ │ -
    │ │ │ -

    the message associated with this log line

    │ │ │ -[report issue]
    │ │ │ -
    local_address
    │ │ │ -
    the local network the port mapper is running on
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    fastresume_rejected_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a fast resume file has been passed to │ │ │ -add_torrent() but the files on disk did not match the fast resume file. │ │ │ -The error_code explains the reason why the resume file was rejected.

    │ │ │ -
    │ │ │ -struct fastresume_rejected_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* file_path () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status
    │ │ │ -   | alert_category::error;
    │ │ │ -   error_code error;
    │ │ │ -   operation_t op;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    file_path()

    │ │ │ -
    │ │ │ -char const* file_path () const;
    │ │ │ -
    │ │ │ -

    If the error happened to a specific file, this returns the path to it.

    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    the underlying operation that failed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    peer_blocked_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when an incoming peer connection, or a peer that's about to be added │ │ │ -to our peer list, is blocked for some reason. This could be any of:

    │ │ │ -
      │ │ │ -
    • the IP filter
    • │ │ │ -
    • i2p mixed mode restrictions (a normal peer is not allowed on an i2p swarm)
    • │ │ │ -
    • the port filter
    • │ │ │ -
    • the peer has a low port and no_connect_privileged_ports is enabled
    • │ │ │ -
    • the protocol of the peer is blocked (uTP/TCP blocking)
    • │ │ │ -
    │ │ │ -
    │ │ │ -struct peer_blocked_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   enum reason_t
    │ │ │ -   {
    │ │ │ -      ip_filter,
    │ │ │ -      port_filter,
    │ │ │ -      i2p_mixed,
    │ │ │ -      privileged_ports,
    │ │ │ -      utp_disabled,
    │ │ │ -      tcp_disabled,
    │ │ │ -      invalid_local_interface,
    │ │ │ -      ssrf_mitigation,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::ip_block;
    │ │ │ -   int const reason;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    enum reason_t

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ - │ │ │ +

    when using a proxy, these are the credentials (if any) to use when │ │ │ +connecting to it. see proxy_type

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    namevaluedescriptiontypedefault
    ip_filter0
    i2p_hostnamestring 
    port_filter1 
    │ │ │ +

    sets the i2p SAM bridge to connect to. set the port with the │ │ │ +i2p_port setting. Unless this is set, i2p torrents are not │ │ │ +supported. This setting is separate from the other proxy settings │ │ │ +since i2p torrents and their peers are orthogonal. You can have │ │ │ +i2p peers as well as regular peers via a proxy.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    i2p_mixed2 
    peer_fingerprintstring-LT2100-
    privileged_ports3 
    │ │ │ +

    this is the fingerprint for the client. It will be used as the │ │ │ +prefix to the peer_id. If this is 20 bytes (or longer) it will be │ │ │ +truncated to 20 bytes and used as the entire peer-id

    │ │ │ +

    There is a utility function, generate_fingerprint() that can be used │ │ │ +to generate a standard client peer ID fingerprint prefix.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    utp_disabled4 
    dht_bootstrap_nodesstringdht.libtorrent.org:25401
    tcp_disabled5 
    │ │ │ +

    This is a comma-separated list of IP port-pairs. They will be added │ │ │ +to the DHT node (if it's enabled) as back-up nodes in case we don't │ │ │ +know of any.

    │ │ │ +

    Changing these after the DHT has been started may not have any │ │ │ +effect until the DHT is restarted. │ │ │ +Here are some other bootstrap nodes that may work: │ │ │ +router.bittorrent.com:6881, │ │ │ +dht.transmissionbt.com:6881 │ │ │ +router.bt.ouinet.work:6881,

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    invalid_local_interface6
    natpmp_gatewaystring 
    ssrf_mitigation7 
    │ │ │ +

    Overrides the NAT-PMP service gateway. When set, libtorrent won't try │ │ │ +to resolve the default gateway and instead will send the requests to │ │ │ +the address specified. This only takes affect when NAT-PMP first │ │ │ +starts. If you change this setting after NAT-PMP has been │ │ │ +enabled, you need to disable it and re-enable it.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    nametypedefault
    webtorrent_stun_serverstringstun.l.google.com:19302
    │ │ │ -[report issue]
    │ │ │ -
    reason
    │ │ │ -
    the reason for the peer being blocked. Is one of the values from the │ │ │ -reason_t enum.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    dht_announce_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a DHT node announces to an info-hash on our │ │ │ -DHT node. It belongs to the alert_category::dht category.

    │ │ │ -
    │ │ │ -struct dht_announce_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -   aux::noexcept_movable<address> ip;
    │ │ │ -   int port;
    │ │ │ -   sha1_hash info_hash;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_get_peers_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when a DHT node sends a get_peers message to │ │ │ -our DHT node. It belongs to the alert_category::dht category.

    │ │ │ -
    │ │ │ -struct dht_get_peers_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -   sha1_hash info_hash;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    cache_flushed_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when the disk cache has been flushed for a specific │ │ │ -torrent as a result of a call to torrent_handle::flush_cache(). This │ │ │ -alert belongs to the alert_category::storage category, which must be │ │ │ -enabled to let this alert through. The alert is also posted when removing │ │ │ -a torrent from the session, once the outstanding cache flush is complete │ │ │ -and the torrent does no longer have any files open.

    │ │ │ -
    │ │ │ -struct cache_flushed_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    lsd_peer_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when we receive a local service discovery message │ │ │ -from a peer for a torrent we're currently participating in.

    │ │ │ -
    │ │ │ -struct lsd_peer_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    trackerid_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted whenever a tracker responds with a trackerid. │ │ │ -The tracker ID is like a cookie. libtorrent will store the tracker ID │ │ │ -for this tracker and repeat it in subsequent announces.

    │ │ │ -
    │ │ │ -struct trackerid_alert final : tracker_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* tracker_id () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    tracker_id()

    │ │ │ -
    │ │ │ -char const* tracker_id () const;
    │ │ │ -
    │ │ │ -

    The tracker ID returned by the tracker

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

    dht_bootstrap_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when the initial DHT bootstrap is done.

    │ │ │ -
    │ │ │ -struct dht_bootstrap_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This is posted whenever a torrent is transitioned into the error state. │ │ │ -If the error code is duplicate_torrent (error_code_enum) error, it suggests two magnet │ │ │ -links ended up resolving to the same hybrid torrent. For more details, │ │ │ -see BitTorrent v2 torrents.

    │ │ │ -
    │ │ │ -struct torrent_error_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* filename () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error | alert_category::status;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    filename()

    │ │ │ -
    │ │ │ -char const* filename () const;
    │ │ │ -
    │ │ │ -

    the filename (or object) the error occurred on.

    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    specifies which error the torrent encountered.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    torrent_need_cert_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This is always posted for SSL torrents. This is a reminder to the client that │ │ │ -the torrent won't work unless torrent_handle::set_ssl_certificate() is called with │ │ │ -a valid certificate. Valid certificates MUST be signed by the SSL certificate │ │ │ -in the .torrent file.

    │ │ │ -
    │ │ │ -struct torrent_need_cert_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    incoming_connection_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    The incoming connection alert is posted every time we successfully accept │ │ │ -an incoming connection, through any mean. The most straight-forward ways │ │ │ -of accepting incoming connections are through the TCP listen socket and │ │ │ -the UDP listen socket for uTP sockets. However, connections may also be │ │ │ -accepted through a Socks5 or i2p listen socket, or via an SSL listen │ │ │ -socket.

    │ │ │ -
    │ │ │ -struct incoming_connection_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ -   socket_type_t socket_type;
    │ │ │ -   aux::noexcept_movable<tcp::endpoint> endpoint;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    socket_type
    │ │ │ -
    tells you what kind of socket the connection was accepted
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    endpoint
    │ │ │ -
    is the IP address and port the connection came from.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_torrent_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is always posted when a torrent was attempted to be added │ │ │ -and contains the return status of the add operation. The torrent handle of the new │ │ │ -torrent can be found as the handle member in the base class. If adding │ │ │ -the torrent failed, error contains the error code.

    │ │ │ -
    │ │ │ -struct add_torrent_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   add_torrent_params params;
    │ │ │ -   error_code error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    params
    │ │ │ -

    This contains copies of the most important fields from the original │ │ │ -add_torrent_params object, passed to add_torrent() or │ │ │ -async_add_torrent(). Specifically, these fields are copied:

    │ │ │ -
      │ │ │ -
    • version
    • │ │ │ -
    • ti
    • │ │ │ -
    • name
    • │ │ │ -
    • save_path
    • │ │ │ -
    • userdata
    • │ │ │ -
    • tracker_id
    • │ │ │ -
    • flags
    • │ │ │ -
    • info_hash
    • │ │ │ -
    │ │ │ -

    the info_hash field will be updated with the info-hash of the torrent │ │ │ -specified by ti.

    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    set to the error, if one occurred while adding the torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    state_update_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is only posted when requested by the user, by calling │ │ │ -session::post_torrent_updates() on the session. It contains the torrent │ │ │ -status of all torrents that changed since last time this message was │ │ │ -posted. Its category is alert_category::status, but it's not subject to │ │ │ -filtering, since it's only manually posted anyway.

    │ │ │ -
    │ │ │ -struct state_update_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   std::vector<torrent_status> status;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    status
    │ │ │ -
    contains the torrent status of all torrents that changed since last │ │ │ -time this message was posted. Note that you can map a torrent status │ │ │ -to a specific torrent via its handle member. The receiving end is │ │ │ -suggested to have all torrents sorted by the torrent_handle or hashed │ │ │ -by it, for efficient updates.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    session_stats_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    The session_stats_alert is posted when the user requests session statistics by │ │ │ -calling post_session_stats() on the session object. This alert does not │ │ │ -have a category, since it's only posted in response to an API call. It │ │ │ -is not subject to the alert_mask filter.

    │ │ │ -

    the message() member function returns a string representation of the values that │ │ │ -properly match the line returned in session_stats_header_alert::message().

    │ │ │ -

    this specific output is parsed by tools/parse_session_stats.py │ │ │ -if this is changed, that parser should also be changed

    │ │ │ -
    │ │ │ -struct session_stats_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   span<std::int64_t const> counters () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = {};
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    counters()

    │ │ │ -
    │ │ │ -span<std::int64_t const> counters () const;
    │ │ │ -
    │ │ │ -

    An array are a mix of counters and gauges, which meanings can be │ │ │ -queries via the session_stats_metrics() function on the session. The │ │ │ -mapping from a specific metric to an index into this array is constant │ │ │ -for a specific version of libtorrent, but may differ for other │ │ │ -versions. The intended usage is to request the mapping, i.e. call │ │ │ -session_stats_metrics(), once on startup, and then use that mapping to │ │ │ -interpret these values throughout the process' runtime.

    │ │ │ -

    For more information, see the session statistics section.

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

    dht_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when something fails in the DHT. This is not necessarily a fatal │ │ │ -error, but it could prevent proper operation

    │ │ │ -
    │ │ │ -struct dht_error_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error | alert_category::dht;
    │ │ │ -   error_code error;
    │ │ │ -   operation_t op;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error code
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    the operation that failed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_immutable_item_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert is posted as a response to a call to session::get_item(), │ │ │ -specifically the overload for looking up immutable items in the DHT.

    │ │ │ -
    │ │ │ -struct dht_immutable_item_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -   sha1_hash target;
    │ │ │ -   entry item;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    target
    │ │ │ -
    the target hash of the immutable item. This must │ │ │ -match the SHA-1 hash of the bencoded form of item.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    item
    │ │ │ -
    the data for this item
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_mutable_item_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert is posted as a response to a call to session::get_item(), │ │ │ -specifically the overload for looking up mutable items in the DHT.

    │ │ │ -
    │ │ │ -struct dht_mutable_item_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -   std::array<char, 32> key;
    │ │ │ -   std::array<char, 64> signature;
    │ │ │ -   std::int64_t seq;
    │ │ │ -   std::string salt;
    │ │ │ -   entry item;
    │ │ │ -   bool authoritative;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    key
    │ │ │ -
    the public key that was looked up
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    signature
    │ │ │ -
    the signature of the data. This is not the signature of the │ │ │ -plain encoded form of the item, but it includes the sequence number │ │ │ -and possibly the hash as well. See the dht_store document for more │ │ │ -information. This is primarily useful for echoing back in a store │ │ │ -request.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    seq
    │ │ │ -
    the sequence number of this item
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    salt
    │ │ │ -
    the salt, if any, used to lookup and store this item. If no │ │ │ -salt was used, this is an empty string
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    item
    │ │ │ -
    the data for this item
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    authoritative
    │ │ │ -
    the last response for mutable data is authoritative.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_put_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this is posted when a DHT put operation completes. This is useful if the │ │ │ -client is waiting for a put to complete before shutting down for instance.

    │ │ │ -
    │ │ │ -struct dht_put_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -   sha1_hash target;
    │ │ │ -   std::array<char, 32> public_key;
    │ │ │ -   std::array<char, 64> signature;
    │ │ │ -   std::string salt;
    │ │ │ -   std::int64_t seq;
    │ │ │ -   int num_success;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    target
    │ │ │ -
    the target hash the item was stored under if this was an immutable │ │ │ -item.
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    public_key signature salt seq
    │ │ │ -
    if a mutable item was stored, these are the public key, signature, │ │ │ -salt and sequence number the item was stored under.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_success
    │ │ │ -
    DHT put operation usually writes item to k nodes, maybe the node │ │ │ -is stale so no response, or the node doesn't support 'put', or the │ │ │ -token for write is out of date, etc. num_success is the number of │ │ │ -successful responses we got from the puts.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    i2p_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert is used to report errors in the i2p SAM connection

    │ │ │ -
    │ │ │ -struct i2p_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   error_code error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error that occurred in the i2p SAM connection
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_outgoing_get_peers_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is generated when we send a get_peers request │ │ │ -It belongs to the alert_category::dht category.

    │ │ │ -
    │ │ │ -struct dht_outgoing_get_peers_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -   sha1_hash info_hash;
    │ │ │ -   sha1_hash obfuscated_info_hash;
    │ │ │ -   aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hash
    │ │ │ -
    the info_hash of the torrent we're looking for peers for.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    obfuscated_info_hash
    │ │ │ -
    if this was an obfuscated lookup, this is the info-hash target │ │ │ -actually sent to the node.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    endpoint
    │ │ │ -
    the endpoint we're sending this query to
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    log_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted by some session wide event. Its main purpose is │ │ │ -trouble shooting and debugging. It's not enabled by the default alert │ │ │ -mask and is enabled by the alert_category::session_log bit. │ │ │ -Furthermore, it's by default disabled as a build configuration.

    │ │ │ -
    │ │ │ -struct log_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* log_message () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::session_log;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    log_message()

    │ │ │ -
    │ │ │ -char const* log_message () const;
    │ │ │ -
    │ │ │ -

    returns the log message

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

    torrent_log_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted by torrent wide events. It's meant to be used for │ │ │ -trouble shooting and debugging. It's not enabled by the default alert │ │ │ -mask and is enabled by the alert_category::torrent_log bit. By │ │ │ -default it is disabled as a build configuration.

    │ │ │ -
    │ │ │ -struct torrent_log_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* log_message () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::torrent_log;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    log_message()

    │ │ │ -
    │ │ │ -char const* log_message () const;
    │ │ │ -
    │ │ │ -

    returns the log message

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

    peer_log_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted by events specific to a peer. It's meant to be used │ │ │ -for trouble shooting and debugging. It's not enabled by the default alert │ │ │ -mask and is enabled by the alert_category::peer_log bit. By │ │ │ -default it is disabled as a build configuration.

    │ │ │ -
    │ │ │ -struct peer_log_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* log_message () const;
    │ │ │ -
    │ │ │ -   enum direction_t
    │ │ │ -   {
    │ │ │ -      incoming_message,
    │ │ │ -      outgoing_message,
    │ │ │ -      incoming,
    │ │ │ -      outgoing,
    │ │ │ -      info,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::peer_log;
    │ │ │ -   event_t event_type;
    │ │ │ -   direction_t direction;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    log_message()

    │ │ │ -
    │ │ │ -char const* log_message () const;
    │ │ │ -
    │ │ │ -

    returns the log message

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

    enum direction_t

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ - │ │ │ +

    This is the STUN server used by WebTorrent to enable ICE NAT │ │ │ +traversal for WebRTC. It must have the format hostname:port.

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ +│ │ │ +│ │ │ │ │ │ -│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    namevaluedescriptiontypedefault
    incoming_message0 
    allow_multiple_connections_per_ipboolfalse
    outgoing_message1 
    │ │ │ +

    determines if connections from the same IP address as existing │ │ │ +connections should be rejected or not. Rejecting multiple connections │ │ │ +from the same IP address will prevent abusive │ │ │ +behavior by peers. The logic for determining whether connections are │ │ │ +to the same peer is more complicated with this enabled, and more │ │ │ +likely to fail in some edge cases. It is not recommended to enable │ │ │ +this feature.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    incoming2 
    send_redundant_havebooltrue
    outgoing3 
    │ │ │ +

    send_redundant_have controls if have messages will be sent to │ │ │ +peers that already have the piece. This is typically not necessary, │ │ │ +but it might be necessary for collecting statistics in some cases.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    nametypedefault
    info4 
    use_dht_as_fallbackboolfalse
    │ │ │ -[report issue]
    │ │ │ -
    event_type
    │ │ │ -
    enum indicating the kind of event. For messages, this is the │ │ │ -message name.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    lsd_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted if the local service discovery socket fails to start properly. │ │ │ -it's categorized as alert_category::error.

    │ │ │ -
    │ │ │ -struct lsd_error_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   aux::noexcept_movable<address> local_address;
    │ │ │ -   error_code error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    local_address
    │ │ │ -
    the local network the corresponding local service discovery is running │ │ │ -on
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    The error code
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_lookup

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    holds statistics about a current dht_lookup operation. │ │ │ -a DHT lookup is the traversal of nodes, looking up a │ │ │ -set of target nodes in the DHT for retrieving and possibly │ │ │ -storing information in the DHT

    │ │ │ -
    │ │ │ -struct dht_lookup
    │ │ │ -{
    │ │ │ -   char const* type;
    │ │ │ -   int outstanding_requests;
    │ │ │ -   int timeouts;
    │ │ │ -   int responses;
    │ │ │ -   int branch_factor;
    │ │ │ -   int nodes_left;
    │ │ │ -   int last_sent;
    │ │ │ -   int first_timeout;
    │ │ │ -   sha1_hash target;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    type
    │ │ │ -
    string literal indicating which kind of lookup this is
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    outstanding_requests
    │ │ │ -
    the number of outstanding request to individual nodes │ │ │ -this lookup has right now
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    timeouts
    │ │ │ -
    the total number of requests that have timed out so far │ │ │ -for this lookup
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    responses
    │ │ │ -
    the total number of responses we have received for this │ │ │ -lookup so far for this lookup
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    branch_factor
    │ │ │ -
    the branch factor for this lookup. This is the number of │ │ │ -nodes we keep outstanding requests to in parallel by default. │ │ │ -when nodes time out we may increase this.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    nodes_left
    │ │ │ -
    the number of nodes left that could be queries for this │ │ │ -lookup. Many of these are likely to be part of the trail │ │ │ -while performing the lookup and would never end up actually │ │ │ -being queried.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    last_sent
    │ │ │ -
    the number of seconds ago the │ │ │ -last message was sent that's still │ │ │ -outstanding
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    first_timeout
    │ │ │ -
    the number of outstanding requests │ │ │ -that have exceeded the short timeout │ │ │ -and are considered timed out in the │ │ │ -sense that they increased the branch │ │ │ -factor
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    target
    │ │ │ -
    the node-id or info-hash target for this lookup
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_stats_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    contains current DHT state. Posted in response to session::post_dht_stats().

    │ │ │ -
    │ │ │ -struct dht_stats_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = {};
    │ │ │ -   std::vector<dht_lookup> active_requests;
    │ │ │ -   std::vector<dht_routing_bucket> routing_table;
    │ │ │ -   sha1_hash nid;
    │ │ │ -   aux::noexcept_movable<udp::endpoint> local_endpoint;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    active_requests
    │ │ │ -
    a vector of the currently running DHT lookups.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    routing_table
    │ │ │ -
    contains information about every bucket in the DHT routing │ │ │ -table.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    nid
    │ │ │ -
    the node ID of the DHT node instance
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    local_endpoint
    │ │ │ -
    the local socket this DHT node is running on
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    incoming_request_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted every time an incoming request from a peer is accepted and queued │ │ │ -up for being serviced. This alert is only posted if │ │ │ -the alert_category::incoming_request flag is enabled in the alert │ │ │ -mask.

    │ │ │ -
    │ │ │ -struct incoming_request_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::incoming_request;
    │ │ │ -   peer_request req;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    req
    │ │ │ -
    the request this peer sent to us
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_log_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    debug logging of the DHT when alert_category::dht_log is set in the alert │ │ │ -mask.

    │ │ │ -
    │ │ │ -struct dht_log_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   char const* log_message () const;
    │ │ │ -
    │ │ │ -   enum dht_module_t
    │ │ │ -   {
    │ │ │ -      tracker,
    │ │ │ -      node,
    │ │ │ -      routing_table,
    │ │ │ -      rpc_manager,
    │ │ │ -      traversal,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht_log;
    │ │ │ -   dht_module_t module;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    log_message()

    │ │ │ -
    │ │ │ -char const* log_message () const;
    │ │ │ -
    │ │ │ -

    the log message

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

    enum dht_module_t

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ - │ │ │ +

    use_dht_as_fallback determines how the DHT is used. If this is │ │ │ +true, the DHT will only be used for torrents where all trackers in │ │ │ +its tracker list has failed. Either by an explicit error message or │ │ │ +a time out. If this is false, the DHT is used regardless of if the │ │ │ +trackers fail or not.

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    namevaluedescriptiontypedefault
    tracker0 
    upnp_ignore_nonroutersboolfalse
    node1 
    │ │ │ +

    upnp_ignore_nonrouters indicates whether or not the UPnP │ │ │ +implementation should ignore any broadcast response from a device │ │ │ +whose address is not on our subnet. i.e. │ │ │ +it's a way to not talk to other people's routers by mistake.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    routing_table2 
    use_parole_modebooltrue
    rpc_manager3 
    │ │ │ +

    use_parole_mode specifies if parole mode should be used. Parole │ │ │ +mode means that peers that participate in pieces that fail the hash │ │ │ +check are put in a mode where they are only allowed to download │ │ │ +whole pieces. If the whole piece a peer in parole mode fails the │ │ │ +hash check, it is banned. If a peer participates in a piece that │ │ │ +passes the hash check, it is taken out of parole mode.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    nametypedefault
    traversal4 
    auto_manage_prefer_seedsboolfalse
    │ │ │ -[report issue]
    │ │ │ -
    module
    │ │ │ -
    the module, or part, of the DHT that produced this log message.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    dht_pkt_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted every time a DHT message is sent or received. It is │ │ │ -only posted if the alert_category::dht_log alert category is │ │ │ -enabled. It contains a verbatim copy of the message.

    │ │ │ -
    │ │ │ -struct dht_pkt_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   span<char const> pkt_buf () const;
    │ │ │ -
    │ │ │ -   enum direction_t
    │ │ │ -   {
    │ │ │ -      incoming,
    │ │ │ -      outgoing,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht_log;
    │ │ │ -   direction_t direction;
    │ │ │ -   aux::noexcept_movable<udp::endpoint> node;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    pkt_buf()

    │ │ │ -
    │ │ │ -span<char const> pkt_buf () const;
    │ │ │ -
    │ │ │ -

    returns a pointer to the packet buffer and size of the packet, │ │ │ -respectively. This buffer is only valid for as long as the alert itself │ │ │ -is valid, which is owned by libtorrent and reclaimed whenever │ │ │ -pop_alerts() is called on the session.

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

    enum direction_t

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ - │ │ │ +

    if true, prefer seeding torrents when determining which torrents to give │ │ │ +active slots to. If false, give preference to downloading torrents

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescriptiontypedefault
    incoming0 
    outgoing1 
    dont_count_slow_torrentsbooltrue
    │ │ │ -[report issue]
    │ │ │ -
    direction
    │ │ │ -
    whether this is an incoming or outgoing packet.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    node
    │ │ │ -
    the DHT node we received this packet from, or sent this packet to │ │ │ -(depending on direction).
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    dht_get_peers_reply_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    Posted when we receive a response to a DHT get_peers request.

    │ │ │ -
    │ │ │ -struct dht_get_peers_reply_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   int num_peers () const;
    │ │ │ -   std::vector<tcp::endpoint> peers () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht_operation;
    │ │ │ -   sha1_hash info_hash;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_direct_response_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This is posted exactly once for every call to session_handle::dht_direct_request. │ │ │ -If the request failed, response() will return a default constructed bdecode_node.

    │ │ │ -
    │ │ │ -struct dht_direct_response_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   bdecode_node response () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ -   client_data_t userdata;
    │ │ │ -   aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    picker_log_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this is posted when one or more blocks are picked by the piece picker, │ │ │ -assuming the verbose piece picker logging is enabled (see │ │ │ -alert_category::picker_log).

    │ │ │ -
    │ │ │ -struct picker_log_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -   std::vector<piece_block> blocks () const;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::picker_log;
    │ │ │ -   static inline constexpr picker_flags_t partial_ratio  = 0_bit;
    │ │ │ -   static inline constexpr picker_flags_t prioritize_partials  = 1_bit;
    │ │ │ -   static inline constexpr picker_flags_t rarest_first_partials  = 2_bit;
    │ │ │ -   static inline constexpr picker_flags_t rarest_first  = 3_bit;
    │ │ │ -   static inline constexpr picker_flags_t reverse_rarest_first  = 4_bit;
    │ │ │ -   static inline constexpr picker_flags_t suggested_pieces  = 5_bit;
    │ │ │ -   static inline constexpr picker_flags_t prio_sequential_pieces  = 6_bit;
    │ │ │ -   static inline constexpr picker_flags_t sequential_pieces  = 7_bit;
    │ │ │ -   static inline constexpr picker_flags_t reverse_pieces  = 8_bit;
    │ │ │ -   static inline constexpr picker_flags_t time_critical  = 9_bit;
    │ │ │ -   static inline constexpr picker_flags_t random_pieces  = 10_bit;
    │ │ │ -   static inline constexpr picker_flags_t prefer_contiguous  = 11_bit;
    │ │ │ -   static inline constexpr picker_flags_t reverse_sequential  = 12_bit;
    │ │ │ -   static inline constexpr picker_flags_t backup1  = 13_bit;
    │ │ │ -   static inline constexpr picker_flags_t backup2  = 14_bit;
    │ │ │ -   static inline constexpr picker_flags_t end_game  = 15_bit;
    │ │ │ -   static inline constexpr picker_flags_t extent_affinity  = 16_bit;
    │ │ │ -   picker_flags_t picker_flags;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    picker_flags
    │ │ │ -
    this is a bitmask of which features were enabled for this particular │ │ │ -pick. The bits are defined in the picker_flags_t enum.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    session_error_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert is posted when the session encounters a serious error, │ │ │ -potentially fatal

    │ │ │ -
    │ │ │ -struct session_error_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   error_code const error;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    The error code, if one is associated with this error
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_live_nodes_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

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

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

    num_nodes() nodes()

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

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

    │ │ │ -[report issue]
    │ │ │ -
    node_id
    │ │ │ -
    the local DHT node's node-ID this routing table belongs to
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    session_stats_header_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    The session_stats_header alert is posted the first time │ │ │ -post_session_stats() is called

    │ │ │ -

    the message() member function returns a string representation of the │ │ │ -header that properly match the stats values string returned in │ │ │ -session_stats_alert::message().

    │ │ │ -

    this specific output is parsed by tools/parse_session_stats.py │ │ │ -if this is changed, that parser should also be changed

    │ │ │ -
    │ │ │ -struct session_stats_header_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = {};
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_sample_infohashes_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

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

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

    num_samples() samples()

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

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

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

    num_nodes()

    │ │ │ -
    │ │ │ -int num_nodes () const;
    │ │ │ -
    │ │ │ -

    The total number of nodes returned by nodes().

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

    nodes()

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

    This is the set of more DHT nodes returned by the request.

    │ │ │ -

    The information is included so that indexing nodes can perform a key │ │ │ -space traversal with a single RPC per node by adjusting the target │ │ │ -value for each RPC.

    │ │ │ -[report issue]
    │ │ │ -
    node_id
    │ │ │ -
    id of the node the request was sent to (and this response was received from)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    endpoint
    │ │ │ -
    the node the request was sent to (and this response was received from)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    interval
    │ │ │ -
    the interval to wait before making another request to this node
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_infohashes
    │ │ │ -
    This field indicates how many info-hash keys are currently in the node's storage. │ │ │ -If the value is larger than the number of returned samples it indicates that the │ │ │ -indexer may obtain additional samples after waiting out the interval.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    block_uploaded_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    This alert is posted when a block intended to be sent to a peer is placed in the │ │ │ -send buffer. Note that if the connection is closed before the send buffer is sent, │ │ │ -the alert may be posted without the bytes having been sent to the peer. │ │ │ -It belongs to the alert_category::upload category.

    │ │ │ -
    │ │ │ -struct block_uploaded_alert final : peer_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   int const block_index;
    │ │ │ -   piece_index_t const piece_index;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    alerts_dropped_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

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

    │ │ │ -
    │ │ │ -struct alerts_dropped_alert final : alert
    │ │ │ -{
    │ │ │ -   static_assert (num_alert_types <= abi_alert_count, "need to increase bitset. This is an ABI break");
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   std::bitset<abi_alert_count> dropped_alerts;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    dropped_alerts
    │ │ │ -
    a bitmask indicating which alerts were dropped. Each bit represents the │ │ │ -alert type ID, where bit 0 represents whether any alert of type 0 has │ │ │ -been dropped, and so on.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    socks5_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert is posted with SOCKS5 related errors, when a SOCKS5 proxy is │ │ │ -configured. It's enabled with the alert_category::error alert category.

    │ │ │ -
    │ │ │ -struct socks5_alert final : alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   error_code error;
    │ │ │ -   operation_t op;
    │ │ │ -   aux::noexcept_movable<tcp::endpoint> ip;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    the operation that failed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    ip
    │ │ │ -
    the endpoint configured as the proxy
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_prio_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when a prioritize_files() or file_priority() update of the file │ │ │ -priorities complete, which requires a round-trip to the disk thread.

    │ │ │ -

    If the disk operation fails this alert won't be posted, but a │ │ │ -file_error_alert is posted instead, and the torrent is stopped.

    │ │ │ -
    │ │ │ -struct file_prio_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -   error_code error;
    │ │ │ -   operation_t op;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error
    │ │ │ -
    the error
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    op
    │ │ │ -
    the operation that failed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    oversized_file_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert may be posted when the initial checking of resume data and files │ │ │ -on disk (just existence, not piece hashes) completes. If a file belonging │ │ │ -to the torrent is found on disk, but is larger than the file in the │ │ │ -torrent, that's when this alert is posted. │ │ │ -the client may want to call truncate_files() in that case, or perhaps │ │ │ -interpret it as a sign that some other file is in the way, that shouldn't │ │ │ -be overwritten.

    │ │ │ -
    │ │ │ -struct oversized_file_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_conflict_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    this alert is posted when two separate torrents (magnet links) resolve to │ │ │ -the same torrent, thus causing the same torrent being added twice. In │ │ │ -that case, both torrents enter an error state with duplicate_torrent │ │ │ -as the error code. This alert is posted containing the metadata. For more │ │ │ -information, see BitTorrent v2 torrents. │ │ │ -The torrent this alert originated from was the one that downloaded the │ │ │ -metadata (i.e. the handle member from the torrent_alert base class).

    │ │ │ -
    │ │ │ -struct torrent_conflict_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ -   torrent_handle conflicting_torrent;
    │ │ │ -   std::shared_ptr<torrent_info> metadata;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    conflicting_torrent
    │ │ │ -
    the handle to the torrent in conflict. The swarm associated with this │ │ │ -torrent handle did not download the metadata, but the downloaded │ │ │ -metadata collided with this swarm's info-hash.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    metadata
    │ │ │ -
    the metadata that was received by one of the torrents in conflict. │ │ │ -One way to resolve the conflict is to remove both failing torrents │ │ │ -and re-add it using this metadata
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_info_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when torrent_handle::post_peer_info() is called

    │ │ │ -
    │ │ │ -struct peer_info_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   std::vector<lt::peer_info> peer_info;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    peer_info
    │ │ │ -
    the list of the currently connected peers
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_progress_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when torrent_handle::post_file_progress() is called

    │ │ │ -
    │ │ │ -struct file_progress_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::file_progress;
    │ │ │ -   aux::vector<std::int64_t, file_index_t> files;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    files
    │ │ │ -
    the list of the files in the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_info_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when torrent_handle::post_download_queue() is called

    │ │ │ -
    │ │ │ -struct piece_info_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::piece_progress;
    │ │ │ -   std::vector<partial_piece_info> piece_info;
    │ │ │ -   std::vector<block_info> block_data;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    piece_info
    │ │ │ -
    info about pieces being downloaded for the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    block_data
    │ │ │ -
    storage for block_info pointers in partial_piece_info objects
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_availability_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when torrent_handle::post_piece_availability() is called

    │ │ │ -
    │ │ │ -struct piece_availability_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   std::vector<int> piece_availability;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    piece_availability
    │ │ │ -
    info about pieces being downloaded for the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    tracker_list_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when torrent_handle::post_trackers() is called

    │ │ │ -
    │ │ │ -struct tracker_list_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   std::vector<announce_entry> trackers;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    trackers
    │ │ │ -
    list of trackers and their status for the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_priorities_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when torrent_handle::post_file_priorities() is called

    │ │ │ -
    │ │ │ -struct file_priorities_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   std::vector<download_priority_t> priorities;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    priorities
    │ │ │ -
    the download priority of each file in the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_status_alert

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -

    posted when torrent_handle::post_file_status() is called

    │ │ │ -
    │ │ │ -struct file_status_alert final : torrent_alert
    │ │ │ -{
    │ │ │ -   std::string message () const override;
    │ │ │ -
    │ │ │ -   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ -   std::vector<open_file_state> state;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    state
    │ │ │ -
    the open-file state of each currently open file in the torrent. │ │ │ -Files that are not open are not included. Each entry's file_index │ │ │ -field identifies which file it refers to.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    alert_cast()

    │ │ │ -

    Declared in "libtorrent/alert.hpp"

    │ │ │ -
    │ │ │ -template <typename T> T* alert_cast (alert* a);
    │ │ │ -template <typename T> T const* alert_cast (alert const* a);
    │ │ │ -
    │ │ │ -

    When you get an alert, you can use alert_cast<> to attempt to cast the │ │ │ -pointer to a specific alert type, in order to query it for more │ │ │ -information.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    alert_cast<> can only cast to an exact alert type, not a base class

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

    operation_name()

    │ │ │ -

    Declared in "libtorrent/operations.hpp"

    │ │ │ -
    │ │ │ -char const* operation_name (operation_t op);
    │ │ │ -
    │ │ │ -

    maps an operation id (from peer_error_alert and peer_disconnected_alert) │ │ │ -to its name. See operation_t for the constants

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

    enum operation_t

    │ │ │ -

    Declared in "libtorrent/operations.hpp"

    │ │ │ - │ │ │ +

    if dont_count_slow_torrents is true, torrents without any │ │ │ +payload transfers are not subject to the active_seeds and │ │ │ +active_downloads limits. This is intended to make it more │ │ │ +likely to utilize all available bandwidth, and avoid having │ │ │ +torrents that don't transfer anything block the active slots.

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    namevaluedescriptiontypedefault
    unknown0the error was unexpected and it is unknown which operation caused it
    close_redundant_connectionsbooltrue
    bittorrent1this is used when the bittorrent logic │ │ │ -determines to disconnect
    │ │ │ +

    close_redundant_connections specifies whether libtorrent should │ │ │ +close connections where both ends have no utility in keeping the │ │ │ +connection open. For instance if both ends have completed their │ │ │ +downloads, there's no point in keeping it open.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    iocontrol2a call to iocontrol failed
    prioritize_partial_piecesboolfalse
    getpeername3a call to getpeername() failed (querying the remote IP of a │ │ │ -connection)
    │ │ │ +

    If prioritize_partial_pieces is true, partial pieces are picked │ │ │ +before pieces that are more rare. If false, rare pieces are always │ │ │ +prioritized, unless the number of partial pieces is growing out of │ │ │ +proportion.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    getname4a call to getname failed (querying the local IP of a │ │ │ -connection)
    rate_limit_ip_overheadbooltrue
    alloc_recvbuf5an attempt to allocate a receive buffer failed
    │ │ │ +

    if set to true, the estimated TCP/IP overhead is drained from the │ │ │ +rate limiters, to avoid exceeding the limits with the total traffic

    │ │ │ + │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    alloc_sndbuf6an attempt to allocate a send buffer failed
    announce_to_all_tiersboolfalse
    file_write7writing to a file failed
    announce_to_all_trackersboolfalse
    file_read8reading from a file failed
    │ │ │ +

    announce_to_all_trackers controls how multi tracker torrents │ │ │ +are treated. If this is set to true, all trackers in the same tier │ │ │ +are announced to in parallel. If all trackers in tier 0 fails, all │ │ │ +trackers in tier 1 are announced as well. If it's set to false, the │ │ │ +behavior is as defined by the multi tracker specification.

    │ │ │ +

    announce_to_all_tiers also controls how multi tracker torrents │ │ │ +are treated. When this is set to true, one tracker from each tier │ │ │ +is announced to. This is the uTorrent behavior. To be compliant │ │ │ +with the Multi-tracker specification, set it to false.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    file9a non-read and non-write file operation failed
    prefer_udp_trackersbooltrue
    sock_write10a socket write operation failed
    │ │ │ +

    prefer_udp_trackers: true means that trackers │ │ │ +may be rearranged in a way that udp trackers are always tried │ │ │ +before http trackers for the same hostname. Setting this to false │ │ │ +means that the tracker's tier is respected and there's no │ │ │ +preference of one protocol over another.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    sock_read11a socket read operation failed
    disable_hash_checksboolfalse
    sock_open12a call to open(), to create a socket socket failed
    │ │ │ +

    when set to true, all data downloaded from peers will be assumed to │ │ │ +be correct, and not tested to match the hashes in the torrent this │ │ │ +is only useful for simulation and testing purposes (typically │ │ │ +combined with disabled_storage)

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    sock_bind13a call to bind() on a socket failed
    allow_i2p_mixedboolfalse
    available14an attempt to query the number of bytes available to read from a socket │ │ │ -failed
    │ │ │ +

    if this is true, i2p torrents are allowed to also get peers from │ │ │ +other sources than the tracker, and connect to regular IPs, not │ │ │ +providing any anonymization. This may be useful if the user is not │ │ │ +interested in the anonymization of i2p, but still wants to be able │ │ │ +to connect to i2p peers.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    encryption15a call related to bittorrent protocol encryption failed
    no_atime_storagebooltrue
    connect16an attempt to connect a socket failed
    │ │ │ +

    no_atime_storage this is a Linux-only option and passes in the │ │ │ +O_NOATIME to open() when opening files. This may lead to │ │ │ +some disk performance improvements.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    ssl_handshake17establishing an SSL connection failed
    incoming_starts_queued_torrentsboolfalse
    get_interface18a connection failed to satisfy the bind interface setting
    │ │ │ +

    incoming_starts_queued_torrents. If a torrent │ │ │ +has been paused by the auto managed feature in libtorrent, i.e. the │ │ │ +torrent is paused and auto managed, this feature affects whether or │ │ │ +not it is automatically started on an incoming connection. The main │ │ │ +reason to queue torrents, is not to make them unavailable, but to │ │ │ +save on the overhead of announcing to the trackers, the DHT and to │ │ │ +avoid spreading one's unchoke slots too thin. If a peer managed to │ │ │ +find us, even though we're no in the torrent anymore, this setting │ │ │ +can make us start the torrent and serve it.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    sock_listen19a call to listen() on a socket
    report_true_downloadedboolfalse
    sock_bind_to_device20a call to the ioctl to bind a socket to a specific network device or │ │ │ -adapter
    │ │ │ +

    when set to true, the downloaded counter sent to trackers will │ │ │ +include the actual number of payload bytes downloaded including │ │ │ +redundant bytes. If set to false, it will not include any redundancy │ │ │ +bytes

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    sock_accept21a call to accept() on a socket
    strict_end_game_modebooltrue
    parse_address22convert a string into a valid network address
    │ │ │ +

    strict_end_game_mode controls when a │ │ │ +block may be requested twice. If this is true, a block may only │ │ │ +be requested twice when there's at least one request to every piece │ │ │ +that's left to download in the torrent. This may slow down progress │ │ │ +on some pieces sometimes, but it may also avoid downloading a lot │ │ │ +of redundant bytes. If this is false, libtorrent attempts to │ │ │ +use each peer connection to its max, by always requesting │ │ │ +something, even if it means requesting something that has been │ │ │ +requested from another peer already.

    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    enum_if23enumeration network devices or adapters
    enable_outgoing_utpbooltrue
    file_stat24invoking stat() on a file
    enable_incoming_utpbooltrue
    file_copy25copying a file
    enable_outgoing_tcpbooltrue
    file_fallocate26allocating storage for a file
    enable_incoming_tcpbooltrue
    file_hard_link27creating a hard link
    │ │ │ +

    Enables incoming and outgoing, TCP and uTP peer connections. │ │ │ +false is disabled and true is enabled. When outgoing │ │ │ +connections are disabled, libtorrent will simply not make │ │ │ +outgoing peer connections with the specific transport protocol. │ │ │ +Disabled incoming peer connections will simply be rejected. │ │ │ +These options only apply to peer connections, not tracker- or any │ │ │ +other kinds of connections.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    file_remove28removing a file
    no_recheck_incomplete_resumeboolfalse
    file_rename29renaming a file
    │ │ │ +

    no_recheck_incomplete_resume determines if the storage should │ │ │ +check the whole files when resume data is incomplete or missing or │ │ │ +whether it should simply assume we don't have any of the data. If │ │ │ +false, any existing files will be checked. │ │ │ +By setting this setting to true, the files won't be checked, but │ │ │ +will go straight to download mode.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    file_open30opening a file
    anonymous_modeboolfalse
    mkdir31creating a directory
    │ │ │ +

    anonymous_mode: When set to true, the client tries to hide │ │ │ +its identity to a certain degree.

    │ │ │ +
      │ │ │ +
    • A generic user-agent will be │ │ │ +used for trackers (except for private torrents).
    • │ │ │ +
    • Your local IPv4 and IPv6 address won't be sent as query string │ │ │ +parameters to private trackers.
    • │ │ │ +
    • If announce_ip is configured, it will not be sent to trackers
    • │ │ │ +
    • The client version will not be sent to peers in the extension │ │ │ +handshake.
    • │ │ │ +
    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    check_resume32check fast resume data against files on disk
    report_web_seed_downloadsbooltrue
    exception33an unknown exception
    │ │ │ +

    specifies whether downloads from web seeds is reported to the │ │ │ +tracker or not. Turning it off also excludes web │ │ │ +seed traffic from other stats and download rate reporting via the │ │ │ +libtorrent API.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    alloc_cache_piece34allocate space for a piece in the cache
    seeding_outgoing_connectionsbooltrue
    partfile_move35move a part-file
    │ │ │ +

    seeding_outgoing_connections determines if seeding (and │ │ │ +finished) torrents should attempt to make outgoing connections or │ │ │ +not. It may be set to false in very │ │ │ +specific applications where the cost of making outgoing connections │ │ │ +is high, and there are no or small benefits of doing so. For │ │ │ +instance, if no nodes are behind a firewall or a NAT, seeds don't │ │ │ +need to make outgoing connections.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    partfile_read36read from a part file
    no_connect_privileged_portsboolfalse
    partfile_write37write to a part-file
    │ │ │ +

    when this is true, libtorrent will not attempt to make outgoing │ │ │ +connections to peers whose port is < 1024. This is a safety │ │ │ +precaution to avoid being part of a DDoS attack

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    hostname_lookup38a hostname lookup
    smooth_connectsbooltrue
    symlink39create or read a symlink
    │ │ │ +

    smooth_connects means the number of │ │ │ +connection attempts per second may be limited to below the │ │ │ +connection_speed, in case we're close to bump up against the │ │ │ +limit of number of connections. The intention of this setting is to │ │ │ +more evenly distribute our connection attempts over time, instead │ │ │ +of attempting to connect in batches, and timing them out in │ │ │ +batches.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    handshake40handshake with a peer or server
    always_send_user_agentboolfalse
    sock_option41set socket option
    │ │ │ +

    always send user-agent in every web seed request. If false, only │ │ │ +the first request per http connection will include the user agent

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    enum_route42enumeration of network routes
    apply_ip_filter_to_trackersbooltrue
    file_seek43moving read/write position in a file
    │ │ │ +

    apply_ip_filter_to_trackers determines │ │ │ +whether the IP filter applies to trackers as well as peers. If this │ │ │ +is set to false, trackers are exempt from the IP filter (if there │ │ │ +is one). If no IP filter is set, this setting is irrelevant.

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ +
    nametypedefault
    timer44an async wait operation on a timer
    ban_web_seedsbooltrue
    file_mmap45call to mmap() (or windows counterpart)
    │ │ │ +

    when true, web seeds sending bad data will be banned

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    nametypedefault
    file_truncate46call to ftruncate() (or SetEndOfFile() on windows)
    support_share_modebooltrue
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    alert_category_t

    │ │ │ -

    Declared in "libtorrent/alert.hpp"

    │ │ │ -
    │ │ │ -
    error
    │ │ │ -

    Enables alerts that report an error. This includes:

    │ │ │ -
      │ │ │ -
    • tracker errors
    • │ │ │ -
    • tracker warnings
    • │ │ │ -
    • file errors
    • │ │ │ -
    • resume data failures
    • │ │ │ -
    • web seed errors
    • │ │ │ -
    • .torrent files errors
    • │ │ │ -
    • listen socket errors
    • │ │ │ -
    • port mapping errors
    • │ │ │ -
    │ │ │ -
    │ │ │ -
    │ │ │ -
    │ │ │ -
    peer
    │ │ │ -
    Enables alerts when peers send invalid requests, get banned or │ │ │ -snubbed.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    port_mapping
    │ │ │ -
    Enables alerts for port mapping events. For NAT-PMP and UPnP.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    storage
    │ │ │ -
    Enables alerts for events related to the storage. File errors and │ │ │ -synchronization events for moving the storage, renaming files etc.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    tracker
    │ │ │ -
    Enables all tracker events. Includes announcing to trackers, │ │ │ -receiving responses, warnings and errors.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    connect
    │ │ │ -
    Low level alerts for when peers are connected and disconnected.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    status
    │ │ │ -
    Enables alerts for when a torrent or the session changes state.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    ip_block
    │ │ │ -
    Alerts when a peer is blocked by the ip blocker or port blocker.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    performance_warning
    │ │ │ -
    Alerts when some limit is reached that might limit the download │ │ │ -or upload rate.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    dht
    │ │ │ -
    Alerts on events in the DHT node. For incoming searches or │ │ │ -bootstrapping being done etc.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    stats
    │ │ │ -
    If you enable these alerts, you will receive a stats_alert │ │ │ -approximately once every second, for every active torrent. │ │ │ -These alerts contain all statistics counters for the interval since │ │ │ -the lasts stats alert.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    session_log
    │ │ │ -
    Enables debug logging alerts. These are available unless libtorrent │ │ │ -was built with logging disabled (TORRENT_DISABLE_LOGGING). The │ │ │ -alerts being posted are log_alert and are session wide.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    torrent_log
    │ │ │ -
    Enables debug logging alerts for torrents. These are available │ │ │ -unless libtorrent was built with logging disabled │ │ │ -(TORRENT_DISABLE_LOGGING). The alerts being posted are │ │ │ -torrent_log_alert and are torrent wide debug events.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    peer_log
    │ │ │ -
    Enables debug logging alerts for peers. These are available unless │ │ │ -libtorrent was built with logging disabled │ │ │ -(TORRENT_DISABLE_LOGGING). The alerts being posted are │ │ │ -peer_log_alert and low-level peer events and messages.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    incoming_request
    │ │ │ -
    enables the incoming_request_alert.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    dht_log
    │ │ │ -
    enables dht_log_alert, debug logging for the DHT
    │ │ │ -
    │ │ │ -
    │ │ │ -
    dht_operation
    │ │ │ -
    enable events from pure dht operations not related to torrents
    │ │ │ -
    │ │ │ -
    │ │ │ -
    port_mapping_log
    │ │ │ -
    enables port mapping log events. This log is useful │ │ │ -for debugging the UPnP or NAT-PMP implementation
    │ │ │ -
    │ │ │ -
    │ │ │ -
    picker_log
    │ │ │ -
    enables verbose logging from the piece picker.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    file_progress
    │ │ │ -
    alerts when files complete downloading
    │ │ │ -
    │ │ │ -
    │ │ │ -
    piece_progress
    │ │ │ -
    alerts when pieces complete downloading or fail hash check
    │ │ │ -
    │ │ │ -
    │ │ │ -
    upload
    │ │ │ -
    alerts when we upload blocks to other peers
    │ │ │ -
    │ │ │ -
    │ │ │ -
    block_progress
    │ │ │ -
    alerts on individual blocks being requested, downloading, finished, │ │ │ -rejected, time-out and cancelled. This is likely to post alerts at a │ │ │ -high rate.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    all
    │ │ │ -

    The full bitmask, representing all available categories.

    │ │ │ -

    since the enum is signed, make sure this isn't │ │ │ -interpreted as -1. For instance, boost.python │ │ │ -does that and fails when assigning it to an │ │ │ -unsigned parameter.

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

    int

    │ │ │ -

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ -
    │ │ │ -
    user_alert_id
    │ │ │ -
    user defined alerts should use IDs greater than this
    │ │ │ -
    │ │ │ -
    │ │ │ -
    num_alert_types
    │ │ │ -
    this constant represents "max_alert_index" + 1
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    counters

    │ │ │ -

    Declared in "libtorrent/performance_counters.hpp"

    │ │ │ -

    holds the session-wide counters and gauges backing the │ │ │ -session_stats_alert and session_status reporting paths. │ │ │ -One instance lives on the session and is incremented from the │ │ │ -network thread; reads from other threads use the lock-free │ │ │ -operator[] overload when ATOMIC_LLONG_LOCK_FREE is set, │ │ │ -otherwise a single shared mutex guards the whole array.

    │ │ │ -

    A reference to this object is passed to custom disk I/O │ │ │ -implementations (see disk_interface and the disk_io_constructor │ │ │ -passed via session_params), which update the disk related metrics │ │ │ -through it. The specific counters and gauges are documented under │ │ │ -the session statistics section.

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

    inc_stats_counter()

    │ │ │ -
    │ │ │ -std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
    │ │ │ -
    │ │ │ -

    increments the counter or gauge c (an index into the counter │ │ │ -array) by value and returns the new value.

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

    operator[]()

    │ │ │ -
    │ │ │ -std::int64_t operator[] (int i) const ;
    │ │ │ -
    │ │ │ -

    returns the current value of counter or gauge i (an index into │ │ │ -the counter array).

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

    blend_stats_counter() set_value()

    │ │ │ -
    │ │ │ -void blend_stats_counter (int c, std::int64_t value, int ratio) ;
    │ │ │ -void set_value (int c, std::int64_t value) ;
    │ │ │ -
    │ │ │ -

    overwrites the value of counter or gauge c (an index into │ │ │ -the counter array). blend_stats_counter() adjusts the stat value │ │ │ -toward the specified value, ratio specifies the percent of │ │ │ -the new value should be influenced by value.

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

    stats_metric

    │ │ │ -

    Declared in "libtorrent/session_stats.hpp"

    │ │ │ -

    describes one statistics metric from the session. For more information, │ │ │ -see the session statistics section.

    │ │ │ -
    │ │ │ -struct stats_metric
    │ │ │ -{
    │ │ │ -   char const* name;
    │ │ │ -   int value_index;
    │ │ │ -   metric_type_t type;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    name
    │ │ │ -
    the name of the counter or gauge
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    value_index type
    │ │ │ -
    the index into the session stats array, where the underlying value of │ │ │ -this counter or gauge is found. The session stats array is part of the │ │ │ -session_stats_alert object.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    session_stats_metrics()

    │ │ │ -

    Declared in "libtorrent/session_stats.hpp"

    │ │ │ -
    │ │ │ -std::vector<stats_metric> session_stats_metrics ();
    │ │ │ -
    │ │ │ -

    This free function returns the list of available metrics exposed by │ │ │ -libtorrent's statistics API. Each metric has a name and a value index. │ │ │ -The value index is the index into the array in session_stats_alert where │ │ │ -this metric's value can be found when the session stats is sampled (by │ │ │ -calling post_session_stats()).

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

    find_metric_idx()

    │ │ │ -

    Declared in "libtorrent/session_stats.hpp"

    │ │ │ -
    │ │ │ -int find_metric_idx (string_view name);
    │ │ │ -
    │ │ │ -

    given a name of a metric, this function returns the counter index of it, │ │ │ -or -1 if it could not be found. The counter index is the index into the │ │ │ -values array returned by session_stats_alert.

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

    enum metric_type_t

    │ │ │ -

    Declared in "libtorrent/session_stats.hpp"

    │ │ │ - │ │ │ +

    if false, prevents libtorrent to advertise share-mode support

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescriptiontypedefault
    counter0 
    gauge1 
    report_redundant_bytesbooltrue
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    ip_filter

    │ │ │ -

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ -

    The ip_filter class is a set of rules that uniquely categorizes all │ │ │ -ip addresses as allowed or disallowed. The default constructor creates │ │ │ -a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for │ │ │ -the IPv4 range, and the equivalent range covering all addresses for the │ │ │ -IPv6 range).

    │ │ │ -

    A default constructed ip_filter does not filter any address.

    │ │ │ -
    │ │ │ -struct ip_filter
    │ │ │ -{
    │ │ │ -   ip_filter (ip_filter&&) noexcept;
    │ │ │ -   ip_filter& operator= (ip_filter&&) noexcept;
    │ │ │ -   ip_filter ();
    │ │ │ -   ip_filter (ip_filter const&);
    │ │ │ -   ~ip_filter ();
    │ │ │ -   ip_filter& operator= (ip_filter const&);
    │ │ │ -   bool empty () const;
    │ │ │ -   void add_rule (address const& first, address const& last, std::uint32_t flags);
    │ │ │ -   std::uint32_t access (address const& addr) const;
    │ │ │ -   filter_tuple_t export_filter () const;
    │ │ │ -
    │ │ │ -   enum access_flags
    │ │ │ -   {
    │ │ │ -      blocked,
    │ │ │ -   };
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    empty()

    │ │ │ -
    │ │ │ -bool empty () const;
    │ │ │ -
    │ │ │ -

    returns true if the filter does not contain any rules

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

    add_rule()

    │ │ │ -
    │ │ │ -void add_rule (address const& first, address const& last, std::uint32_t flags);
    │ │ │ -
    │ │ │ -

    Adds a rule to the filter. first and last defines a range of │ │ │ -ip addresses that will be marked with the given flags. The flags │ │ │ -can currently be 0, which means allowed, or ip_filter::blocked, which │ │ │ -means disallowed.

    │ │ │ -

    precondition: │ │ │ -first.is_v4() == last.is_v4() && first.is_v6() == last.is_v6()

    │ │ │ -

    postcondition: │ │ │ -access(x) == flags for every x in the range [first, last]

    │ │ │ -

    This means that in a case of overlapping ranges, the last one applied takes │ │ │ -precedence.

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

    access()

    │ │ │ -
    │ │ │ -std::uint32_t access (address const& addr) const;
    │ │ │ -
    │ │ │ -

    Returns the access permissions for the given address (addr). The permission │ │ │ -can currently be 0 or ip_filter::blocked. The complexity of this operation │ │ │ -is O(log n), where n is the minimum number of non-overlapping ranges to describe │ │ │ -the current filter.

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

    export_filter()

    │ │ │ -
    │ │ │ -filter_tuple_t export_filter () const;
    │ │ │ -
    │ │ │ -

    This function will return the current state of the filter in the minimum number of │ │ │ -ranges possible. They are sorted from ranges in low addresses to high addresses. Each │ │ │ -entry in the returned vector is a range with the access control specified in its │ │ │ -flags field.

    │ │ │ -

    The return value is a tuple containing two range-lists. One for IPv4 addresses │ │ │ -and one for IPv6 addresses.

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

    enum access_flags

    │ │ │ -

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ - │ │ │ +

    if this is true, the number of redundant bytes is sent to the │ │ │ +tracker

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescriptiontypedefault
    blocked1indicates that IPs in this range should not be connected │ │ │ -to nor accepted as incoming connections
    listen_system_port_fallbackbooltrue
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    port_filter

    │ │ │ -

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ -

    the port filter maps non-overlapping port ranges to flags. This │ │ │ -is primarily used to indicate whether a range of ports should │ │ │ -be connected to or not. The default is to have the full port │ │ │ -range (0-65535) set to flag 0.

    │ │ │ -
    │ │ │ -class port_filter
    │ │ │ -{
    │ │ │ -   port_filter& operator= (port_filter&&);
    │ │ │ -   port_filter ();
    │ │ │ -   port_filter (port_filter const&);
    │ │ │ -   port_filter (port_filter&&);
    │ │ │ -   port_filter& operator= (port_filter const&);
    │ │ │ -   ~port_filter ();
    │ │ │ -   void add_rule (std::uint16_t first, std::uint16_t last, std::uint32_t flags);
    │ │ │ -   std::uint32_t access (std::uint16_t port) const;
    │ │ │ -
    │ │ │ -   enum access_flags
    │ │ │ -   {
    │ │ │ -      blocked,
    │ │ │ -   };
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    add_rule()

    │ │ │ -
    │ │ │ -void add_rule (std::uint16_t first, std::uint16_t last, std::uint32_t flags);
    │ │ │ -
    │ │ │ -

    set the flags for the specified port range (first, last) to │ │ │ -flags overwriting any existing rule for those ports. The range │ │ │ -is inclusive, i.e. the port last also has the flag set on it.

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

    access()

    │ │ │ -
    │ │ │ -std::uint32_t access (std::uint16_t port) const;
    │ │ │ -
    │ │ │ -

    test the specified port (port) for whether it is blocked │ │ │ -or not. The returned value is the flags set for this port. │ │ │ -see access_flags.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum access_flags

    │ │ │ -

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ - │ │ │ +

    if this is true, libtorrent will fall back to listening on a port │ │ │ +chosen by the operating system (i.e. binding to port 0). If a │ │ │ +failure is preferred, set this to false.

    │ │ │ +
    │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescriptiontypedefault
    blocked1this flag indicates that destination ports in the │ │ │ -range should not be connected to
    │ │ │ -

    Bencoding is a common representation in bittorrent used for dictionary, │ │ │ -list, int and string hierarchies. It's used to encode .torrent files and │ │ │ -some messages in the network protocol. libtorrent also uses it to store │ │ │ -settings, resume data and other session state.

    │ │ │ -

    Strings in bencoded structures do not necessarily represent text. │ │ │ -Strings are raw byte buffers of a certain length. If a string is meant to be │ │ │ -interpreted as text, it is required to be UTF-8 encoded. See BEP 3.

    │ │ │ -

    The function for decoding bencoded data bdecode(), returning a bdecode_node. │ │ │ -This function builds a tree that points back into the original buffer. The │ │ │ -returned bdecode_node will not be valid once the buffer it was parsed out of │ │ │ -is discarded.

    │ │ │ -

    It's possible to construct an entry from a bdecode_node, if a structure needs │ │ │ -to be altered and re-encoded.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    entry

    │ │ │ -

    Declared in "libtorrent/entry.hpp"

    │ │ │ -

    The entry class represents one node in a bencoded hierarchy. It works as a │ │ │ -variant type, it can be either a list, a dictionary (std::map), an integer │ │ │ -or a string.

    │ │ │ -
    │ │ │ -struct entry : entry_types::variant_type
    │ │ │ -{
    │ │ │ -   data_type type () const;
    │ │ │ -   entry (preformatted_type);
    │ │ │ -   entry (integer_type);
    │ │ │ -   entry (span<char const>);
    │ │ │ -   entry (dictionary_type);
    │ │ │ -   entry (string_view);
    │ │ │ -   entry (list_type);
    │ │ │ -   entry (string_type);
    │ │ │ -   entry (data_type t);
    │ │ │ -   entry (bdecode_node const& n);
    │ │ │ -   entry& operator= (integer_type) &;
    │ │ │ -   entry& operator= (dictionary_type) &;
    │ │ │ -   entry& operator= (entry&&) & ;
    │ │ │ -   entry& operator= (string_type) &;
    │ │ │ -   entry& operator= (preformatted_type) &;
    │ │ │ -   entry& operator= (bdecode_node const&) &;
    │ │ │ -   entry& operator= (span<char const>) &;
    │ │ │ -   entry& operator= (list_type) &;
    │ │ │ -   entry& operator= (entry const&) &;
    │ │ │ -   entry& operator= (string_view) &;
    │ │ │ -   list_type const& list () const;
    │ │ │ -   preformatted_type const& preformatted () const;
    │ │ │ -   string_type const& string () const;
    │ │ │ -   integer_type const& integer () const;
    │ │ │ -   string_type& string ();
    │ │ │ -   list_type& list ();
    │ │ │ -   dictionary_type const& dict () const;
    │ │ │ -   integer_type& integer ();
    │ │ │ -   preformatted_type& preformatted ();
    │ │ │ -   dictionary_type& dict ();
    │ │ │ -   entry const& operator[] (string_view key) const;
    │ │ │ -   entry& operator[] (string_view key);
    │ │ │ -   entry* find_key (string_view key);
    │ │ │ -   entry const* find_key (string_view key) const;
    │ │ │ -   std::string to_string (bool single_line = false) const;
    │ │ │ -
    │ │ │ -   enum data_type
    │ │ │ -   {
    │ │ │ -      int_t,
    │ │ │ -      string_t,
    │ │ │ -      list_t,
    │ │ │ -      dictionary_t,
    │ │ │ -      preformatted_t,
    │ │ │ -      undefined_t,
    │ │ │ -   };
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    type()

    │ │ │ -
    │ │ │ -data_type type () const;
    │ │ │ -
    │ │ │ -

    returns the concrete type of the entry

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    entry()

    │ │ │ -
    │ │ │ -entry (preformatted_type);
    │ │ │ -entry (integer_type);
    │ │ │ -entry (span<char const>);
    │ │ │ -entry (dictionary_type);
    │ │ │ -entry (string_view);
    │ │ │ -entry (list_type);
    │ │ │ -entry (string_type);
    │ │ │ -
    │ │ │ -

    constructors directly from a specific type. │ │ │ -The content of the argument is copied into the │ │ │ -newly constructed entry

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    entry()

    │ │ │ -
    │ │ │ -entry (data_type t);
    │ │ │ -
    │ │ │ -

    construct an empty entry of the specified type. │ │ │ -see data_type enum.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    entry()

    │ │ │ -
    │ │ │ -entry (bdecode_node const& n);
    │ │ │ -
    │ │ │ -

    construct from bdecode_node parsed form (see bdecode())

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    operator=()

    │ │ │ -
    │ │ │ -entry& operator= (integer_type) &;
    │ │ │ -entry& operator= (dictionary_type) &;
    │ │ │ -entry& operator= (entry&&) & ;
    │ │ │ -entry& operator= (string_type) &;
    │ │ │ -entry& operator= (preformatted_type) &;
    │ │ │ -entry& operator= (bdecode_node const&) &;
    │ │ │ -entry& operator= (span<char const>) &;
    │ │ │ -entry& operator= (list_type) &;
    │ │ │ -entry& operator= (entry const&) &;
    │ │ │ -entry& operator= (string_view) &;
    │ │ │ -
    │ │ │ -

    copies the structure of the right hand side into this │ │ │ -entry.

    │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dict() integer() string() preformatted() list()

    │ │ │ -
    │ │ │ -list_type const& list () const;
    │ │ │ -preformatted_type const& preformatted () const;
    │ │ │ -string_type const& string () const;
    │ │ │ -integer_type const& integer () const;
    │ │ │ -string_type& string ();
    │ │ │ -list_type& list ();
    │ │ │ -dictionary_type const& dict () const;
    │ │ │ -integer_type& integer ();
    │ │ │ -preformatted_type& preformatted ();
    │ │ │ -dictionary_type& dict ();
    │ │ │ -
    │ │ │ -

    The integer(), string(), list(), dict() and │ │ │ -preformatted() functions are accessors that return the │ │ │ -respective type. If the entry object │ │ │ -isn't of the type you request, the accessor will throw │ │ │ -system_error. You can ask an entry for its type through the │ │ │ -type() function.

    │ │ │ -

    If you want to create an entry you give it the type you want it to │ │ │ -have in its constructor, and then use one of the non-const accessors │ │ │ -to get a reference which you then can assign the value you want it to │ │ │ -have.

    │ │ │ -

    The typical code to get info from a torrent file will then look like │ │ │ -this:

    │ │ │ -
    │ │ │ -entry torrent_file;
    │ │ │ -// ...
    │ │ │ -
    │ │ │ -// throws if this is not a dictionary
    │ │ │ -entry::dictionary_type const& dict = torrent_file.dict();
    │ │ │ -entry::dictionary_type::const_iterator i;
    │ │ │ -i = dict.find("announce");
    │ │ │ -if (i != dict.end())
    │ │ │ -{
    │ │ │ -        std::string tracker_url = i->second.string();
    │ │ │ -        std::cout << tracker_url << "\n";
    │ │ │ -}
    │ │ │ -
    │ │ │ -

    The following code is equivalent, but a little bit shorter:

    │ │ │ -
    │ │ │ -entry torrent_file;
    │ │ │ -// ...
    │ │ │ -
    │ │ │ -// throws if this is not a dictionary
    │ │ │ -if (entry* i = torrent_file.find_key("announce"))
    │ │ │ -{
    │ │ │ -        std::string tracker_url = i->string();
    │ │ │ -        std::cout << tracker_url << "\n";
    │ │ │ -}
    │ │ │ -
    │ │ │ -

    To make it easier to extract information from a torrent file, the │ │ │ -class torrent_info exists.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    operator[]()

    │ │ │ -
    │ │ │ -entry const& operator[] (string_view key) const;
    │ │ │ -entry& operator[] (string_view key);
    │ │ │ -
    │ │ │ -

    All of these functions requires the entry to be a dictionary, if it │ │ │ -isn't they will throw system_error.

    │ │ │ -

    The non-const versions of the operator[] will return a reference │ │ │ -to either the existing element at the given key or, if there is no │ │ │ -element with the given key, a reference to a newly inserted element at │ │ │ -that key.

    │ │ │ -

    The const version of operator[] will only return a reference to an │ │ │ -existing element at the given key. If the key is not found, it will │ │ │ -throw system_error.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    find_key()

    │ │ │ -
    │ │ │ -entry* find_key (string_view key);
    │ │ │ -entry const* find_key (string_view key) const;
    │ │ │ -
    │ │ │ -

    These functions requires the entry to be a dictionary, if it isn't │ │ │ -they will throw system_error.

    │ │ │ -

    They will look for an element at the given key in the dictionary, if │ │ │ -the element cannot be found, they will return nullptr. If an element │ │ │ -with the given key is found, the return a pointer to it.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    to_string()

    │ │ │ -
    │ │ │ -std::string to_string (bool single_line = false) const;
    │ │ │ -
    │ │ │ -

    returns a pretty-printed string representation │ │ │ -of the bencoded structure, with JSON-style syntax

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum data_type

    │ │ │ -

    Declared in "libtorrent/entry.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    int_t0 
    string_t1 
    list_t2 
    dictionary_t3 
    preformatted_t4 
    undefined_t5 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    operator<<()

    │ │ │ -

    Declared in "libtorrent/entry.hpp"

    │ │ │ -
    │ │ │ -inline std::ostream& operator<< (std::ostream& os, const entry& e);
    │ │ │ -
    │ │ │ -

    prints the bencoded structure to the ostream as a JSON-style structure.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    bencode()

    │ │ │ -

    Declared in "libtorrent/bencode.hpp"

    │ │ │ -
    │ │ │ -template<class OutIt> int bencode (OutIt out, const entry& e);
    │ │ │ -std::vector<char> bencode (entry const& e);
    │ │ │ -
    │ │ │ -

    The bencode() function has two overloads that serializes a tree │ │ │ -structure of entry objects into a bencoded, flat, buffer. │ │ │ -The entry class is the internal representation of the bencoded data.

    │ │ │ -

    The simplest overload simply takes an entry object and returns a vector │ │ │ -with the serialized data.

    │ │ │ -

    The second overload encode it into the OutIt iterator.

    │ │ │ -

    OutIt is an OutputIterator. It's a template and usually │ │ │ -instantiated as ostream_iterator or back_insert_iterator. This │ │ │ -function assumes the value_type of the iterator is a char. │ │ │ -In order to encode entry e into a buffer, do:

    │ │ │ -
    │ │ │ -std::vector<char> buf;
    │ │ │ -bencode(std::back_inserter(buf), e);
    │ │ │ -
    │ │ │ -

    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. │ │ │ -
    3. the torrent properties are set, such as tracker url, web seeds, │ │ │ -DHT nodes etc.
    4. │ │ │ -
    5. Read through all the files in the torrent, SHA-1 all the data │ │ │ -and set the piece hashes.
    6. │ │ │ -
    7. The torrent is bencoded into a file or buffer.
    8. │ │ │ -
    │ │ │ -

    If there are a lot of files and or deep directory hierarchies to │ │ │ -traverse, step one can be time consuming.

    │ │ │ -

    Typically step 3 is by far the most time consuming step, since it │ │ │ -requires to read all the bytes from all the files in the torrent.

    │ │ │ -

    All of these classes and functions are declared by including │ │ │ -libtorrent/create_torrent.hpp.

    │ │ │ -

    example:

    │ │ │ -
    │ │ │ -// recursively create a list of all files in the directory
    │ │ │ -auto fs = list_files("./my_torrent");
    │ │ │ -
    │ │ │ -create_torrent t(std::move(fs));
    │ │ │ -t.add_tracker("http://my.tracker.com/announce");
    │ │ │ -t.set_creator("libtorrent example");
    │ │ │ -
    │ │ │ -// reads the files and calculates the hashes
    │ │ │ -set_piece_hashes(t, ".");
    │ │ │ -
    │ │ │ -ofstream out("my_torrent.torrent", std::ios_base::binary);
    │ │ │ -std::vector<char> buf = t.generate_buf();
    │ │ │ -out.write(buf.data(), buf.size());
    │ │ │ -
    │ │ │ -// alternatively, generate an entry and encode it directly to an ostream
    │ │ │ -// iterator
    │ │ │ -bencode(std::ostream_iterator<char>(out), t.generate());
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    create_file_entry

    │ │ │ -

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │ -

    This represents one file in the torrent file to be created

    │ │ │ -
    │ │ │ -struct create_file_entry
    │ │ │ -{
    │ │ │ -   create_file_entry (std::string fn, std::int64_t const sz
    │ │ │ -      , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = {});
    │ │ │ -
    │ │ │ -   std::string filename;
    │ │ │ -   std::int64_t size;
    │ │ │ -   file_flags_t flags;
    │ │ │ -   std::time_t mtime;
    │ │ │ -   std::string symlink;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    create_file_entry()

    │ │ │ -
    │ │ │ -create_file_entry (std::string fn, std::int64_t const sz
    │ │ │ -      , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = {});
    │ │ │ -
    │ │ │ -

    construct a file entry for the file at relative path fn │ │ │ -with size sz. │ │ │ -f is the set of file flags that applies to the file, see file_flags_t. │ │ │ -ts is an optional modification time (0 to omit). │ │ │ -sl is the symlink target, only used when f includes the symlink │ │ │ -flag. Symlinks are only allowed to target other files or directories │ │ │ -in the torrent.

    │ │ │ -[report issue]
    │ │ │ -
    filename
    │ │ │ -
    the path and name of the file. The path is relative to the root of │ │ │ -the torrent file.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    size
    │ │ │ -
    the size of the file
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flags
    │ │ │ -
    bitmask of file_flags_t (pad-file, hidden, executable, │ │ │ -symlink) for this file.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    mtime
    │ │ │ -
    optional modification time of the file. 0 means "do not record".
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    symlink
    │ │ │ -
    the link target, only considered if the symlink flag is set
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    create_torrent

    │ │ │ -

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │ -

    This class holds state for creating a torrent. After having added │ │ │ -all information to it, call create_torrent::generate() to generate │ │ │ -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;
    │ │ │ -   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);
    │ │ │ -   void add_tracker (string_view url, int tier = 0);
    │ │ │ -   void set_root_cert (string_view cert);
    │ │ │ -   void set_priv (bool p);
    │ │ │ -   bool priv () const;
    │ │ │ -   bool is_v1_only () const;
    │ │ │ -   bool is_v2_only () const;
    │ │ │ -   int num_pieces () const;
    │ │ │ -   piece_index_t end_piece () const;
    │ │ │ -   index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ -   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);
    │ │ │ -
    │ │ │ -   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;
    │ │ │ -   static inline constexpr create_flags_t canonical_files_no_tail_padding  = 9_bit;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    create_torrent()

    │ │ │ -
    │ │ │ -explicit create_torrent (std::vector<create_file_entry> files, int piece_size = 0
    │ │ │ -      , create_flags_t flags = {});
    │ │ │ -
    │ │ │ -

    The piece_size is the size of each piece in bytes. It must be a │ │ │ -power of 2 and a minimum of 16 kiB. If a piece size of 0 is │ │ │ -specified, a piece_size will be set automatically. │ │ │ -Piece sizes greater than 128 MiB are considered unreasonable and will │ │ │ -be rejected (with an lt::system_error exception).

    │ │ │ -

    The flags arguments specifies options for the torrent creation. It can │ │ │ -be any combination of the flags defined by create_flags_t.

    │ │ │ -

    The files argument is a list of all files to be included in the │ │ │ -torrent file. If it has more than one file in it, all files must │ │ │ -share a common root directory (which will be the name of the │ │ │ -torrent).

    │ │ │ -

    If files has a single file without any directory component (i.e. │ │ │ -just a filename) it will create a single file torrent. If it has a │ │ │ -directory path, it will create a multi-file torrent with a single │ │ │ -file. This is in order to preserve the directory path.

    │ │ │ -
    │ │ │ -
    │ │ │ -

    deprecated overloads

    │ │ │ -

    There are two deprecated constructors that take a file_storage object │ │ │ -and a torrent_info object respectively.

    │ │ │ -

    The file_storage (fs) parameter defines the files, sizes and │ │ │ -their properties for the torrent to be created. Set this up first, │ │ │ -before passing it to the create_torrent constructor. Instead of using │ │ │ -this overload, consider using the overload taking a vector of │ │ │ -create_file_entry objects instead. It is more efficient.

    │ │ │ -

    The overload that takes a torrent_info object will make a verbatim │ │ │ -copy of its info dictionary (to preserve the info-hash). The copy of │ │ │ -the info dictionary will be used by create_torrent::generate(). This means │ │ │ -that none of the member functions of create_torrent that affects │ │ │ -the content of the info dictionary (such as set_hash()), will │ │ │ -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()

    │ │ │ -
    │ │ │ -entry generate () const;
    │ │ │ -std::vector<char> generate_buf () 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 │ │ │ -whether any of the v1_only or v2_only flags were set on the │ │ │ -constructor. If neither were set, the resulting torrent depends on │ │ │ -which hashes were set. If both v1 and v2 hashes were set, a hybrid │ │ │ -torrent is created.

    │ │ │ -

    Any failure will cause this function to throw system_error, with an │ │ │ -appropriate error message. These are the reasons this call may throw:

    │ │ │ -
      │ │ │ -
    • the file storage has 0 files
    • │ │ │ -
    • the total size of the file storage is 0 bytes (i.e. it only has │ │ │ -empty files)
    • │ │ │ -
    • not all v1 hashes (set_hash()) and not all v2 hashes (set_hash2()) │ │ │ -were set
    • │ │ │ -
    • for v2 torrents, you may not have a directory with the same name as │ │ │ -a file. If that's encountered in the file storage, generate() │ │ │ -fails.
    • │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_comment()

    │ │ │ -
    │ │ │ -void set_comment (char const* str);
    │ │ │ -
    │ │ │ -

    Sets the comment for the torrent. The string str should be utf-8 encoded. │ │ │ -The comment in a torrent file is optional.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_creator()

    │ │ │ -
    │ │ │ -void set_creator (char const* str);
    │ │ │ -
    │ │ │ -

    Sets the creator of the torrent. The string str should be utf-8 encoded. │ │ │ -This is optional.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_creation_date()

    │ │ │ -
    │ │ │ -void set_creation_date (std::time_t timestamp);
    │ │ │ -
    │ │ │ -

    sets the "creation time" field. Defaults to the system clock at the │ │ │ -time of construction of the create_torrent object. The timestamp is │ │ │ -specified in seconds, posix time. If the creation date is set to 0, │ │ │ -the "creation date" field will be omitted from the generated torrent.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_hash()

    │ │ │ -
    │ │ │ -void set_hash (piece_index_t index, sha1_hash const& h);
    │ │ │ -
    │ │ │ -

    This sets the SHA-1 hash for the specified piece (index). You are required │ │ │ -to set the hash for every piece in the torrent before generating it. If you have │ │ │ -the files on disk, you can use the high level convenience function to do this. │ │ │ -See set_piece_hashes(). │ │ │ -A SHA-1 hash of all zeros is internally used to indicate a hash that │ │ │ -has not been set. Setting such hash will not be considered set when │ │ │ -calling generate(). │ │ │ -This function will throw std::system_error if it is called on an │ │ │ -object constructed with the v2_only flag.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_hash2()

    │ │ │ -
    │ │ │ -void set_hash2 (file_index_t file, piece_index_t::diff_type piece, sha256_hash const& h);
    │ │ │ -
    │ │ │ -

    sets the bittorrent v2 hash for file file of the piece piece. │ │ │ -piece is relative to the first piece of the file, starting at 0. The │ │ │ -first piece in the file can be computed with │ │ │ -file_storage::file_index_at_piece(). │ │ │ -The hash, h, is the root of the merkle tree formed by the piece's │ │ │ -16 kiB blocks. Note that piece sizes must be powers-of-2, so all │ │ │ -per-piece merkle trees are complete. │ │ │ -A SHA-256 hash of all zeros is internally used to indicate a hash │ │ │ -that has not been set. Setting such hash will not be considered set │ │ │ -when calling generate(). │ │ │ -This function will throw std::system_error if it is called on an │ │ │ -object constructed with the v1_only flag.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_url_seed()

    │ │ │ -
    │ │ │ -void add_url_seed (string_view url);
    │ │ │ -
    │ │ │ -

    This adds a url seed to the torrent. You can have any number of url seeds. For a │ │ │ -single file torrent, this should be an HTTP url, pointing to a file with identical │ │ │ -content as the file of the torrent. For a multi-file torrent, it should point to │ │ │ -a directory containing a directory with the same name as this torrent, and all the │ │ │ -files of the torrent in it.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_node()

    │ │ │ -
    │ │ │ -void add_node (std::pair<std::string, int> node);
    │ │ │ -
    │ │ │ -

    This adds a DHT node to the torrent. This especially useful if you're creating a │ │ │ -tracker less torrent. It can be used by clients to bootstrap their DHT node from. │ │ │ -The node is a hostname and a port number where there is a DHT node running. │ │ │ -You can have any number of DHT nodes in a torrent.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_tracker()

    │ │ │ -
    │ │ │ -void add_tracker (string_view url, int tier = 0);
    │ │ │ -
    │ │ │ -

    Adds a tracker to the torrent. This is not strictly required, but most torrents │ │ │ -use a tracker as their main source of peers. The url should be an http:// or udp:// │ │ │ -url to a machine running a bittorrent tracker that accepts announces for this torrent's │ │ │ -info-hash. The tier is the fallback priority of the tracker. All trackers with tier 0 are │ │ │ -tried first (in any order). If all fail, trackers with tier 1 are tried. If all of those │ │ │ -fail, trackers with tier 2 are tried, and so on.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_root_cert()

    │ │ │ -
    │ │ │ -void set_root_cert (string_view cert);
    │ │ │ -
    │ │ │ -

    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()

    │ │ │ -
    │ │ │ -void set_priv (bool p);
    │ │ │ -bool priv () const;
    │ │ │ -
    │ │ │ -

    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()

    │ │ │ -
    │ │ │ -bool is_v1_only () const;
    │ │ │ -bool is_v2_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 │ │ │ -file tree will be written. A torrent that is neither │ │ │ -v1-only nor v2-only is a hybrid v1+v2 torrent.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    num_pieces()

    │ │ │ -
    │ │ │ -int num_pieces () const;
    │ │ │ -
    │ │ │ -

    returns the number of pieces in the associated file_storage object.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    end_piece()

    │ │ │ -
    │ │ │ -piece_index_t end_piece () const;
    │ │ │ -
    │ │ │ -

    one past-the-end piece index

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_range()

    │ │ │ -
    │ │ │ -index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ -
    │ │ │ -

    all piece indices in the torrent to be created

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    end_file()

    │ │ │ -
    │ │ │ -file_index_t end_file () const;
    │ │ │ -
    │ │ │ -

    one past-the-end file index

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_range()

    │ │ │ -
    │ │ │ -index_range<file_index_t> file_range () const noexcept;
    │ │ │ -
    │ │ │ -

    all file indices in the torrent to be created

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_at()

    │ │ │ -
    │ │ │ -create_file_entry const& file_at (file_index_t f) const;
    │ │ │ -
    │ │ │ -

    returns a reference to the create_file_entry at the given file index. │ │ │ -Note that this is not necessarily the same entries passed into the │ │ │ -constructor, since the layout may have been canonicalized. e.g. file │ │ │ -order and padding may have changed.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    file_piece_range()

    │ │ │ -
    │ │ │ -index_range<piece_index_t::diff_type> file_piece_range (file_index_t f);
    │ │ │ -
    │ │ │ -

    for v2 and hybrid torrents only, the pieces in the │ │ │ -specified file, specified as delta from the first piece in the file. │ │ │ -i.e. the first index is 0.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    total_size()

    │ │ │ -
    │ │ │ -std::int64_t total_size () const;
    │ │ │ -
    │ │ │ -

    the total number of bytes of all files and pad files

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_size() piece_length()

    │ │ │ -
    │ │ │ -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()

    │ │ │ -
    │ │ │ -void add_collection (string_view c);
    │ │ │ -void add_similar_torrent (sha1_hash ih);
    │ │ │ -
    │ │ │ -

    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.

    │ │ │ -[report issue]
    │ │ │ -
    modification_time
    │ │ │ -
    This will include the file modification time as part of the torrent. │ │ │ -This is not enabled by default, as it might cause problems when you │ │ │ -create a torrent from separate files with the same content, hoping to │ │ │ -yield the same info-hash. If the files have different modification times, │ │ │ -with this option enabled, you would get different info-hashes for the │ │ │ -files.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    symlinks
    │ │ │ -
    If this flag is set, files that are symlinks get a symlink attribute │ │ │ -set on them and their data will not be included in the torrent. This │ │ │ -is useful if you need to reconstruct a file hierarchy which contains │ │ │ -symlinks.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    v2_only
    │ │ │ -
    Do not generate v1 metadata. The resulting torrent will only be usable by │ │ │ -clients which support v2. This requires setting all v2 hashes, with │ │ │ -set_hash2() before calling generate(). Setting v1 hashes (with │ │ │ -set_hash()) is an error with this flag set.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    v1_only
    │ │ │ -
    do not generate v2 metadata or enforce v2 alignment and padding rules │ │ │ -this is mainly for tests, not recommended for production use. This │ │ │ -requires setting all v1 hashes, with set_hash(), before calling │ │ │ -generate(). Setting v2 hashes (with set_hash2()) is an error with │ │ │ -this flag set.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    canonical_files
    │ │ │ -
    This flag only affects v1-only torrents, and is only relevant │ │ │ -together with the v1_only_flag. This flag will force the │ │ │ -same file order and padding as a v2 (or hybrid) torrent would have. │ │ │ -It has the effect of ordering files and inserting pad files to align │ │ │ -them with piece boundaries.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    no_attributes
    │ │ │ -
    passing this flag to list_files() will ignore file attributes (such as │ │ │ -executable or hidden) when adding the files to the file storage. │ │ │ -Since not all filesystems and operating systems support all file │ │ │ -attributes the resulting torrent may differ depending on where it's │ │ │ -created. If it's important for torrents to be created consistently │ │ │ -across systems, this flag should be set.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    canonical_files_no_tail_padding
    │ │ │ -
    this flag enforces the file layout to be canonical according to the │ │ │ -bittorrent v2 specification (just like the canonical_files flag) │ │ │ -with the one exception that tail padding is not added to the last │ │ │ -file. │ │ │ -This 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.
    │ │ │ -
    │ │ │ -[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 = {});
    │ │ │ -
    │ │ │ -

    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:

    │ │ │ -
    │ │ │ -bool Pred(std::string const& p);
    │ │ │ -
    │ │ │ -

    The path that is passed in to the predicate is the full path of the file or │ │ │ -directory. If no predicate is specified, all files are added, and all directories │ │ │ -are traversed.

    │ │ │ -

    The ".." directory is never traversed.

    │ │ │ -

    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"

    │ │ │ -
    │ │ │ -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
    │ │ │ -   , settings_pack const& settings
    │ │ │ -   , std::function<void(piece_index_t)> const& f);
    │ │ │ -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);
    │ │ │ -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, 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
    │ │ │ -   , 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);
    │ │ │ -
    │ │ │ -

    The overloads taking a settings_pack may be used to configure the │ │ │ -underlying disk access. Such as settings_pack::aio_threads.

    │ │ │ -

    The overloads that don't take an error_code& may throw an exception in case of a │ │ │ -file error, the other overloads sets the error code to reflect the error, if any.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    bitfield

    │ │ │ -

    Declared in "libtorrent/bitfield.hpp"

    │ │ │ -

    The bitfield type stores any number of bits as a bitfield │ │ │ -in a heap allocated array.

    │ │ │ -
    │ │ │ -struct bitfield
    │ │ │ -{
    │ │ │ -   bitfield (char const* b, int bits);
    │ │ │ -   bitfield (int bits, bool val);
    │ │ │ -   explicit bitfield (int bits);
    │ │ │ -   bitfield (bitfield const& rhs);
    │ │ │ -   bitfield () noexcept = default;
    │ │ │ -   bitfield (bitfield&& rhs) noexcept = default;
    │ │ │ -   void assign (char const* b, int const bits);
    │ │ │ -   bool operator[] (int index) const noexcept;
    │ │ │ -   bool get_bit (int index) const noexcept;
    │ │ │ -   void set_bit (int index) noexcept;
    │ │ │ -   void clear_bit (int index) noexcept;
    │ │ │ -   bool all_set () const noexcept;
    │ │ │ -   bool none_set () const noexcept;
    │ │ │ -   int size () const noexcept;
    │ │ │ -   int num_words () const noexcept;
    │ │ │ -   int num_bytes () const noexcept;
    │ │ │ -   bool empty () const noexcept;
    │ │ │ -   char* data () noexcept;
    │ │ │ -   char const* data () const noexcept;
    │ │ │ -   void swap (bitfield& rhs) noexcept;
    │ │ │ -   int count () const noexcept;
    │ │ │ -   int find_first_set () const noexcept;
    │ │ │ -   int find_last_clear () const noexcept;
    │ │ │ -   bool operator== (lt::bitfield const& rhs) const;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    bitfield()

    │ │ │ -
    │ │ │ -bitfield (char const* b, int bits);
    │ │ │ -bitfield (int bits, bool val);
    │ │ │ -explicit bitfield (int bits);
    │ │ │ -bitfield (bitfield const& rhs);
    │ │ │ -bitfield () noexcept = default;
    │ │ │ -bitfield (bitfield&& rhs) noexcept = default;
    │ │ │ -
    │ │ │ -

    constructs a new bitfield. The default constructor creates an empty │ │ │ -bitfield. bits is the size of the bitfield (specified in bits). │ │ │ -val is the value to initialize the bits to. If not specified │ │ │ -all bits are initialized to 0.

    │ │ │ -

    The constructor taking a pointer b and bits copies a bitfield │ │ │ -from the specified buffer, and bits number of bits (rounded up to │ │ │ -the nearest byte boundary).

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    assign()

    │ │ │ -
    │ │ │ -void assign (char const* b, int const bits);
    │ │ │ -
    │ │ │ -

    copy bitfield from buffer b of bits number of bits, rounded up to │ │ │ -the nearest byte boundary.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_bit() operator[]()

    │ │ │ -
    │ │ │ -bool operator[] (int index) const noexcept;
    │ │ │ -bool get_bit (int index) const noexcept;
    │ │ │ -
    │ │ │ -

    query bit at index. Returns true if bit is 1, otherwise false.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_bit() clear_bit()

    │ │ │ -
    │ │ │ -void set_bit (int index) noexcept;
    │ │ │ -void clear_bit (int index) noexcept;
    │ │ │ -
    │ │ │ -

    set bit at index to 0 (clear_bit) or 1 (set_bit).

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    all_set()

    │ │ │ -
    │ │ │ -bool all_set () const noexcept;
    │ │ │ -
    │ │ │ -

    returns true if all bits in the bitfield are set

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    none_set()

    │ │ │ -
    │ │ │ -bool none_set () const noexcept;
    │ │ │ -
    │ │ │ -

    returns true if no bit in the bitfield is set

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    size()

    │ │ │ -
    │ │ │ -int size () const noexcept;
    │ │ │ -
    │ │ │ -

    returns the size of the bitfield in bits.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    num_words()

    │ │ │ -
    │ │ │ -int num_words () const noexcept;
    │ │ │ -
    │ │ │ -

    returns the number of 32 bit words are needed to represent all bits in │ │ │ -this bitfield.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    num_bytes()

    │ │ │ -
    │ │ │ -int num_bytes () const noexcept;
    │ │ │ -
    │ │ │ -

    returns the number of bytes needed to represent all bits in this │ │ │ -bitfield

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    empty()

    │ │ │ -
    │ │ │ -bool empty () const noexcept;
    │ │ │ -
    │ │ │ -

    returns true if the bitfield has zero size.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    data()

    │ │ │ -
    │ │ │ -char* data () noexcept;
    │ │ │ -char const* data () const noexcept;
    │ │ │ -
    │ │ │ -

    returns a pointer to the internal buffer of the bitfield, or │ │ │ -nullptr if it's empty.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    swap()

    │ │ │ -
    │ │ │ -void swap (bitfield& rhs) noexcept;
    │ │ │ -
    │ │ │ -

    swaps the bit-fields two variables refer to

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    count()

    │ │ │ -
    │ │ │ -int count () const noexcept;
    │ │ │ -
    │ │ │ -

    count the number of bits in the bitfield that are set to 1.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    find_first_set()

    │ │ │ -
    │ │ │ -int find_first_set () const noexcept;
    │ │ │ -
    │ │ │ -

    returns the index of the first set bit in the bitfield, i.e. 1 bit.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    find_last_clear()

    │ │ │ -
    │ │ │ -int find_last_clear () const noexcept;
    │ │ │ -
    │ │ │ -

    returns the index to the last cleared bit in the bitfield, i.e. 0 bit.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    hasher

    │ │ │ -

    Declared in "libtorrent/hasher.hpp"

    │ │ │ -

    this is a SHA-1 hash class.

    │ │ │ -

    You use it by first instantiating it, then call update() to feed it │ │ │ -with data. i.e. you don't have to keep the entire buffer of which you want to │ │ │ -create the hash in memory. You can feed the hasher parts of it at a time. When │ │ │ -You have fed the hasher with all the data, you call final() and it │ │ │ -will return the sha1-hash of the data.

    │ │ │ -

    The constructor that takes a char const* and an integer will construct the │ │ │ -sha1 context and feed it the data passed in.

    │ │ │ -

    If you want to reuse the hasher object once you have created a hash, you have to │ │ │ -call reset() to reinitialize it.

    │ │ │ -

    The built-in software version of sha1-algorithm was implemented │ │ │ -by Steve Reid and released as public domain. │ │ │ -For more info, see src/sha1.cpp.

    │ │ │ -
    │ │ │ -class hasher
    │ │ │ -{
    │ │ │ -   hasher ();
    │ │ │ -   hasher (char const* data, int len);
    │ │ │ -   explicit hasher (span<char const> data);
    │ │ │ -   hasher& operator= (hasher const&) &;
    │ │ │ -   hasher (hasher&&) noexcept;
    │ │ │ -   hasher (hasher const&);
    │ │ │ -   hasher& operator= (hasher&&) & noexcept;
    │ │ │ -   hasher& update (span<char const> data);
    │ │ │ -   hasher& update (char const* data, int len);
    │ │ │ -   sha1_hash final ();
    │ │ │ -   void reset ();
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    operator=() hasher()

    │ │ │ -
    │ │ │ -hasher (char const* data, int len);
    │ │ │ -explicit hasher (span<char const> data);
    │ │ │ -hasher& operator= (hasher const&) &;
    │ │ │ -hasher (hasher&&) noexcept;
    │ │ │ -hasher (hasher const&);
    │ │ │ -hasher& operator= (hasher&&) & noexcept;
    │ │ │ -
    │ │ │ -

    this is the same as default constructing followed by a call to │ │ │ -update(data, len).

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    update()

    │ │ │ -
    │ │ │ -hasher& update (span<char const> data);
    │ │ │ -hasher& update (char const* data, int len);
    │ │ │ -
    │ │ │ -

    append the following bytes to what is being hashed

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    final()

    │ │ │ -
    │ │ │ -sha1_hash final ();
    │ │ │ -
    │ │ │ -

    returns the SHA-1 digest of the buffers previously passed to │ │ │ -update() and the hasher constructor.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    reset()

    │ │ │ -
    │ │ │ -void reset ();
    │ │ │ -
    │ │ │ -

    restore the hasher state to be as if the hasher has just been │ │ │ -default constructed.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    hasher256

    │ │ │ -

    Declared in "libtorrent/hasher.hpp"

    │ │ │ -

    hasher256 computes a SHA-256 message digest. It is the │ │ │ -counterpart to hasher (which computes SHA-1) and is used for │ │ │ -BitTorrent v2 piece and merkle-tree hashes. It can be fed input │ │ │ -incrementally via update() and the digest is produced by │ │ │ -final(). Call reset() to reuse the object for another │ │ │ -digest.

    │ │ │ -
    │ │ │ -class hasher256
    │ │ │ -{
    │ │ │ -   hasher256 ();
    │ │ │ -   hasher256 (char const* data, int len);
    │ │ │ -   hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ -   hasher256 (hasher256&&) noexcept;
    │ │ │ -   explicit hasher256 (span<char const> data);
    │ │ │ -   hasher256 (hasher256 const&);
    │ │ │ -   hasher256& operator= (hasher256 const&) &;
    │ │ │ -   hasher256& update (span<char const> data);
    │ │ │ -   hasher256& update (char const* data, int len);
    │ │ │ -   sha256_hash final ();
    │ │ │ -   void reset ();
    │ │ │ -   ~hasher256 ();
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    operator=() hasher256()

    │ │ │ -
    │ │ │ -hasher256 (char const* data, int len);
    │ │ │ -hasher256& operator= (hasher256&&) & noexcept;
    │ │ │ -hasher256 (hasher256&&) noexcept;
    │ │ │ -explicit hasher256 (span<char const> data);
    │ │ │ -hasher256 (hasher256 const&);
    │ │ │ -hasher256& operator= (hasher256 const&) &;
    │ │ │ -
    │ │ │ -

    this is the same as default constructing followed by a call to │ │ │ -update(data, len).

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    update()

    │ │ │ -
    │ │ │ -hasher256& update (span<char const> data);
    │ │ │ -hasher256& update (char const* data, int len);
    │ │ │ -
    │ │ │ -

    append the following bytes to what is being hashed

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    final()

    │ │ │ -
    │ │ │ -sha256_hash final ();
    │ │ │ -
    │ │ │ -

    returns the SHA-1 digest of the buffers previously passed to │ │ │ -update() and the hasher constructor.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    reset()

    │ │ │ -
    │ │ │ -void reset ();
    │ │ │ -
    │ │ │ -

    restore the hasher state to be as if the hasher has just been │ │ │ -default constructed.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    torrent_status

    │ │ │ -

    Declared in "libtorrent/torrent_status.hpp"

    │ │ │ -

    holds a snapshot of the status of a torrent, as queried by │ │ │ -torrent_handle::status().

    │ │ │ -
    │ │ │ -struct torrent_status
    │ │ │ -{
    │ │ │ -   bool operator== (torrent_status const& st) const;
    │ │ │ -
    │ │ │ -   enum state_t
    │ │ │ -   {
    │ │ │ -      checking_files,
    │ │ │ -      downloading_metadata,
    │ │ │ -      downloading,
    │ │ │ -      finished,
    │ │ │ -      seeding,
    │ │ │ -      checking_resume_data,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   torrent_handle handle;
    │ │ │ -   error_code errc;
    │ │ │ -   file_index_t error_file  = torrent_status::error_file_none;
    │ │ │ -   static inline constexpr file_index_t error_file_none {-1};
    │ │ │ -   static inline constexpr file_index_t error_file_ssl_ctx {-3};
    │ │ │ -   static inline constexpr file_index_t error_file_metadata {-4};
    │ │ │ -   static inline constexpr file_index_t error_file_exception {-5};
    │ │ │ -   static inline constexpr file_index_t error_file_partfile {-6};
    │ │ │ -   std::string save_path;
    │ │ │ -   std::string name;
    │ │ │ -   std::weak_ptr<const torrent_info> torrent_file;
    │ │ │ -   time_duration next_announce  = seconds{0};
    │ │ │ -   std::string current_tracker;
    │ │ │ -   std::int64_t total_download  = 0;
    │ │ │ -   std::int64_t total_upload  = 0;
    │ │ │ -   std::int64_t total_payload_download  = 0;
    │ │ │ -   std::int64_t total_payload_upload  = 0;
    │ │ │ -   std::int64_t total_failed_bytes  = 0;
    │ │ │ -   std::int64_t total_redundant_bytes  = 0;
    │ │ │ -   typed_bitfield<piece_index_t> pieces;
    │ │ │ -   typed_bitfield<piece_index_t> verified_pieces;
    │ │ │ -   std::int64_t total_done  = 0;
    │ │ │ -   std::int64_t total  = 0;
    │ │ │ -   std::int64_t total_wanted_done  = 0;
    │ │ │ -   std::int64_t total_wanted  = 0;
    │ │ │ -   std::int64_t all_time_upload  = 0;
    │ │ │ -   std::int64_t all_time_download  = 0;
    │ │ │ -   std::time_t added_time  = 0;
    │ │ │ -   std::time_t completed_time  = 0;
    │ │ │ -   std::time_t last_seen_complete  = 0;
    │ │ │ -   storage_mode_t storage_mode  = storage_mode_sparse;
    │ │ │ -   float progress  = 0.f;
    │ │ │ -   int progress_ppm  = 0;
    │ │ │ -   queue_position_t queue_position {};
    │ │ │ -   int download_rate  = 0;
    │ │ │ -   int upload_rate  = 0;
    │ │ │ -   int download_payload_rate  = 0;
    │ │ │ -   int upload_payload_rate  = 0;
    │ │ │ -   int num_seeds  = 0;
    │ │ │ -   int num_peers  = 0;
    │ │ │ -   int num_complete  = -1;
    │ │ │ -   int num_incomplete  = -1;
    │ │ │ -   int list_seeds  = 0;
    │ │ │ -   int list_peers  = 0;
    │ │ │ -   int connect_candidates  = 0;
    │ │ │ -   int num_pieces  = 0;
    │ │ │ -   int distributed_full_copies  = 0;
    │ │ │ -   int distributed_fraction  = 0;
    │ │ │ -   float distributed_copies  = 0.f;
    │ │ │ -   int block_size  = 0;
    │ │ │ -   int num_uploads  = 0;
    │ │ │ -   int num_connections  = 0;
    │ │ │ -   int uploads_limit  = 0;
    │ │ │ -   int connections_limit  = 0;
    │ │ │ -   int upload_limit  = -1;
    │ │ │ -   int download_limit  = -1;
    │ │ │ -   int up_bandwidth_queue  = 0;
    │ │ │ -   int down_bandwidth_queue  = 0;
    │ │ │ -   int seed_rank  = 0;
    │ │ │ -   state_t state  = checking_resume_data;
    │ │ │ -   resume_data_flags_t need_save_resume_data;
    │ │ │ -   bool is_seeding  = false;
    │ │ │ -   bool is_finished  = false;
    │ │ │ -   bool has_metadata  = false;
    │ │ │ -   bool has_incoming  = false;
    │ │ │ -   bool moving_storage  = false;
    │ │ │ -   bool announcing_to_trackers  = false;
    │ │ │ -   bool announcing_to_lsd  = false;
    │ │ │ -   bool announcing_to_dht  = false;
    │ │ │ -   info_hash_t info_hashes;
    │ │ │ -   time_point last_upload;
    │ │ │ -   time_point last_download;
    │ │ │ -   seconds active_duration;
    │ │ │ -   seconds finished_duration;
    │ │ │ -   seconds seeding_duration;
    │ │ │ -   torrent_flags_t flags {};
    │ │ │ -   struct renamed_files renamed_files;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    operator==()

    │ │ │ -
    │ │ │ -bool operator== (torrent_status const& st) const;
    │ │ │ -
    │ │ │ -

    compares if the torrent status objects come from the same torrent. i.e. │ │ │ -only the torrent_handle field is compared.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum state_t

    │ │ │ -

    Declared in "libtorrent/torrent_status.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    checking_files1The torrent has not started its download yet, and is │ │ │ -currently checking existing files.
    downloading_metadata2The torrent is trying to download metadata from peers. │ │ │ -This implies the ut_metadata extension is in use.
    downloading3The torrent is being downloaded. This is the state │ │ │ -most torrents will be in most of the time. The progress │ │ │ -meter will tell how much of the files that has been │ │ │ -downloaded.
    finished4In this state the torrent has finished downloading but │ │ │ -still doesn't have the entire torrent. i.e. some pieces │ │ │ -are filtered and won't get downloaded.
    seeding5In this state the torrent has finished downloading and │ │ │ -is a pure seeder.
    checking_resume_data7If the torrent was started in full allocation mode, this │ │ │ -indicates that the (disk) storage for the torrent is │ │ │ -allocated. │ │ │ -The torrent is currently checking the fast resume data and │ │ │ -comparing it to the files on disk. This is typically │ │ │ -completed in a fraction of a second, but if you add a │ │ │ -large number of torrents at once, they will queue up.
    │ │ │ -[report issue]
    │ │ │ -
    handle
    │ │ │ -
    a handle to the torrent whose status the object represents.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    errc
    │ │ │ -
    may be set to an error code describing why the torrent was paused, in │ │ │ -case it was paused by an error. If the torrent is not paused or if it's │ │ │ -paused but not because of an error, this error_code is not set. │ │ │ -if the error is attributed specifically to a file, error_file is set to │ │ │ -the index of that file in the .torrent file.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error_file
    │ │ │ -
    if the torrent is stopped because of an disk I/O error, this field │ │ │ -contains the index of the file in the torrent that encountered the │ │ │ -error. If the error did not originate in a file in the torrent, there │ │ │ -are a few special values this can be set to: error_file_none, │ │ │ -error_file_ssl_ctx, error_file_exception, error_file_partfile or │ │ │ -error_file_metadata;
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error_file_none
    │ │ │ -
    special values for error_file to describe which file or component │ │ │ -encountered the error (errc). │ │ │ -the error did not occur on a file
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error_file_ssl_ctx
    │ │ │ -
    the error occurred setting up the SSL context
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error_file_metadata
    │ │ │ -
    the error occurred while loading the metadata for the torrent
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error_file_exception
    │ │ │ -
    there was a serious error reported in this torrent. The error code │ │ │ -or a torrent log alert may provide more information.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    error_file_partfile
    │ │ │ -
    the error occurred with the partfile
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    save_path
    │ │ │ -
    the path to the directory where this torrent's files are stored. │ │ │ -It's typically the path as was given to async_add_torrent() or │ │ │ -add_torrent() when this torrent was started. This field is only │ │ │ -included if the torrent status is queried with │ │ │ -torrent_handle::query_save_path.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    name
    │ │ │ -
    the name of the torrent. Typically this is derived from the │ │ │ -.torrent file. In case the torrent was started without metadata, │ │ │ -and hasn't completely received it yet, it returns the name given │ │ │ -to it when added to the session. See session::add_torrent. │ │ │ -This field is only included if the torrent status is queried │ │ │ -with torrent_handle::query_name.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    torrent_file
    │ │ │ -
    set to point to the torrent_info object for this torrent. It's │ │ │ -only included if the torrent status is queried with │ │ │ -torrent_handle::query_torrent_file.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    next_announce
    │ │ │ -
    the time until the torrent will announce itself to the tracker.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    current_tracker
    │ │ │ -
    the URL of the last working tracker. If no tracker request has │ │ │ -been successful yet, it's set to an empty string.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    total_download total_upload
    │ │ │ -
    the number of bytes downloaded and uploaded to all peers, accumulated, │ │ │ -this session only. The session is considered to restart when a │ │ │ -torrent is paused and restarted again. When a torrent is paused, these │ │ │ -counters are reset to 0. If you want complete, persistent, stats, see │ │ │ -all_time_upload and all_time_download.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    total_payload_download total_payload_upload
    │ │ │ -
    counts the amount of bytes send and received this session, but only │ │ │ -the actual payload data (i.e the interesting data), these counters │ │ │ -ignore any protocol overhead. The session is considered to restart │ │ │ -when a torrent is paused and restarted again. When a torrent is │ │ │ -paused, these counters are reset to 0.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    total_failed_bytes
    │ │ │ -
    the number of bytes that has been downloaded and that has failed the │ │ │ -piece hash test. In other words, this is just how much crap that has │ │ │ -been downloaded since the torrent was last started. If a torrent is │ │ │ -paused and then restarted again, this counter will be reset.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    total_redundant_bytes
    │ │ │ -
    the number of bytes that has been downloaded even though that data │ │ │ -already was downloaded. The reason for this is that in some situations │ │ │ -the same data can be downloaded by mistake. When libtorrent sends │ │ │ -requests to a peer, and the peer doesn't send a response within a │ │ │ -certain timeout, libtorrent will re-request that block. Another │ │ │ -situation when libtorrent may re-request blocks is when the requests │ │ │ -it sends out are not replied in FIFO-order (it will re-request blocks │ │ │ -that are skipped by an out of order block). This is supposed to be as │ │ │ -low as possible. This only counts bytes since the torrent was last │ │ │ -started. If a torrent is paused and then restarted again, this counter │ │ │ -will be reset.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    pieces
    │ │ │ -
    a bitmask that represents which pieces we have (set to true) and the │ │ │ -pieces we don't have. It's a pointer and may be set to 0 if the │ │ │ -torrent isn't downloading or seeding.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    verified_pieces
    │ │ │ -
    a bitmask representing which pieces has had their hash checked. This │ │ │ -only applies to torrents in seed mode. If the torrent is not in seed │ │ │ -mode, this bitmask may be empty.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    total_done
    │ │ │ -
    the total number of bytes of the file(s) that we have. All this does │ │ │ -not necessarily has to be downloaded during this session (that's │ │ │ -total_payload_download).
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    total
    │ │ │ -
    the total number of bytes to download for this torrent. This │ │ │ -may be less than the size of the torrent in case there are │ │ │ -pad files. This number only counts bytes that will actually │ │ │ -be requested from peers.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    total_wanted_done
    │ │ │ -
    the number of bytes we have downloaded, only counting the pieces that │ │ │ -we actually want to download. i.e. excluding any pieces that we have │ │ │ -but have priority 0 (i.e. not wanted). │ │ │ -Once a torrent becomes seed, any piece- and file priorities are │ │ │ -forgotten and all bytes are considered "wanted".
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    total_wanted
    │ │ │ -
    The total number of bytes we want to download. This may be smaller │ │ │ -than the total torrent size in case any pieces are prioritized to 0, │ │ │ -i.e. not wanted. │ │ │ -Once a torrent becomes seed, any piece- and file priorities are │ │ │ -forgotten and all bytes are considered "wanted".
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    all_time_upload all_time_download
    │ │ │ -
    are accumulated upload and download payload byte counters. They are │ │ │ -saved in and restored from resume data to keep totals across sessions.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    added_time
    │ │ │ -
    the posix-time when this torrent was added. i.e. what time(nullptr) │ │ │ -returned at the time.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    completed_time
    │ │ │ -
    the posix-time when this torrent was finished. If the torrent is not │ │ │ -yet finished, this is 0.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    last_seen_complete
    │ │ │ -
    the time when we, or one of our peers, last saw a complete copy of │ │ │ -this torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    storage_mode
    │ │ │ -
    The allocation mode for the torrent. See storage_mode_t for the │ │ │ -options. For more information, see storage allocation.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    progress
    │ │ │ -
    a value in the range [0, 1], that represents the progress of the │ │ │ -torrent's current task. It may be checking files or downloading.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    progress_ppm
    │ │ │ -

    progress parts per million (progress * 1000000) when disabling │ │ │ -floating point operations, this is the only option to query progress

    │ │ │ -

    reflects the same value as progress, but instead in a range [0, │ │ │ -1000000] (ppm = parts per million). When floating point operations are │ │ │ -disabled, this is the only alternative to the floating point value in │ │ │ -progress.

    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    queue_position
    │ │ │ -
    the position this torrent has in the download │ │ │ -queue. If the torrent is a seed or finished, this is -1.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    download_rate upload_rate
    │ │ │ -
    the total rates for all peers for this torrent. These will usually │ │ │ -have better precision than summing the rates from all peers. The rates │ │ │ -are given as the number of bytes per second.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    download_payload_rate upload_payload_rate
    │ │ │ -
    the total transfer rate of payload only, not counting protocol │ │ │ -chatter. This might be slightly smaller than the other rates, but if │ │ │ -projected over a long time (e.g. when calculating ETA:s) the │ │ │ -difference may be noticeable.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_seeds
    │ │ │ -
    the number of peers that are seeding that this client is │ │ │ -currently connected to.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_peers
    │ │ │ -
    the number of peers this torrent currently is connected to. Peer │ │ │ -connections that are in the half-open state (is attempting to connect) │ │ │ -or are queued for later connection attempt do not count. Although they │ │ │ -are visible in the peer list when you call get_peer_info().
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    num_complete num_incomplete
    │ │ │ -
    if the tracker sends scrape info in its announce reply, these fields │ │ │ -will be set to the total number of peers that have the whole file and │ │ │ -the total number of peers that are still downloading. set to -1 if the │ │ │ -tracker did not send any scrape data in its announce reply.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    list_seeds list_peers
    │ │ │ -
    the number of seeds in our peer list and the total number of peers │ │ │ -(including seeds). We are not necessarily connected to all the peers │ │ │ -in our peer list. This is the number of peers we know of in total, │ │ │ -including banned peers and peers that we have failed to connect to.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    connect_candidates
    │ │ │ -
    the number of peers in this torrent's peer list that is a candidate to │ │ │ -be connected to. i.e. It has fewer connect attempts than the max fail │ │ │ -count, it is not a seed if we are a seed, it is not banned etc. If │ │ │ -this is 0, it means we don't know of any more peers that we can try.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_pieces
    │ │ │ -
    the number of pieces that has been downloaded. It is equivalent to: │ │ │ -std::accumulate(pieces->begin(), pieces->end()). So you don't have │ │ │ -to count yourself. This can be used to see if anything has updated │ │ │ -since last time if you want to keep a graph of the pieces up to date. │ │ │ -Note that these pieces have not necessarily been written to disk yet, │ │ │ -and there is a risk the write to disk will fail.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    distributed_full_copies
    │ │ │ -
    the number of distributed copies of the torrent. Note that one copy │ │ │ -may be spread out among many peers. It tells how many copies there are │ │ │ -currently of the rarest piece(s) among the peers this client is │ │ │ -connected to.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    distributed_fraction
    │ │ │ -

    tells the share of pieces that have more copies than the rarest │ │ │ -piece(s). Divide this number by 1000 to get the fraction.

    │ │ │ -

    For example, if distributed_full_copies is 2 and │ │ │ -distributed_fraction is 500, it means that the rarest pieces have │ │ │ -only 2 copies among the peers this torrent is connected to, and that │ │ │ -50% of all the pieces have more than two copies.

    │ │ │ -

    If we are a seed, the piece picker is deallocated as an optimization, │ │ │ -and piece availability is no longer tracked. In this case the │ │ │ -distributed copies members are set to -1.

    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    distributed_copies
    │ │ │ -

    the number of distributed copies of the file. note that one copy may │ │ │ -be spread out among many peers. This is a floating point │ │ │ -representation of the distributed copies.

    │ │ │ -
    │ │ │ -
    the integer part tells how many copies
    │ │ │ -
    there are of the rarest piece(s)
    │ │ │ -
    the fractional part tells the fraction of pieces that
    │ │ │ -
    have more copies than the rarest piece(s).
    │ │ │ -
    │ │ │ -
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    block_size
    │ │ │ -
    the size of a block, in bytes. A block is a sub piece, it is the │ │ │ -number of bytes that each piece request asks for and the number of │ │ │ -bytes that each bit in the partial_piece_info's bitset represents, │ │ │ -see get_download_queue(). This is typically 16 kB, but it may be │ │ │ -smaller, if the pieces are smaller.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_uploads
    │ │ │ -
    the number of unchoked peers in this torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    num_connections
    │ │ │ -
    the number of peer connections this torrent has, including half-open │ │ │ -connections that hasn't completed the bittorrent handshake yet. This │ │ │ -is always >= num_peers.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    uploads_limit
    │ │ │ -
    the set limit of upload slots (unchoked peers) for this torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    connections_limit
    │ │ │ -
    the set limit of number of connections for this torrent.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    upload_limit download_limit
    │ │ │ -
    the upload and download rate limits for this torrent, in bytes per │ │ │ -second. A value of -1 means unlimited.
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    up_bandwidth_queue down_bandwidth_queue
    │ │ │ -
    the number of peers in this torrent that are waiting for more │ │ │ -bandwidth quota from the torrent rate limiter. This can determine if │ │ │ -the rate you get from this torrent is bound by the torrents limit or │ │ │ -not. If there is no limit set on this torrent, the peers might still │ │ │ -be waiting for bandwidth quota from the global limiter, but then they │ │ │ -are counted in the session_status object.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    seed_rank
    │ │ │ -
    A rank of how important it is to seed the torrent, it is used to │ │ │ -determine which torrents to seed and which to queue. It is based on │ │ │ -the peer to seed ratio from the tracker scrape. For more information, │ │ │ -see queuing. Higher value means more important to seed
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    state
    │ │ │ -
    the main state the torrent is in. See torrent_status::state_t.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    need_save_resume_data
    │ │ │ -
    These are the flags indicating which aspects of this torrent have │ │ │ -changed since the last time resume data was saved. See │ │ │ -torrent_handle::save_resume_data().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    is_seeding
    │ │ │ -
    true if all pieces have been downloaded.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    is_finished
    │ │ │ -
    true if all pieces that have a priority > 0 are downloaded. There is │ │ │ -only a distinction between finished and seeding if some pieces or │ │ │ -files have been set to priority 0, i.e. are not downloaded.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    has_metadata
    │ │ │ -
    true if this torrent has metadata (either it was started from a │ │ │ -.torrent file or the metadata has been downloaded). The only scenario │ │ │ -where this can be false is when the torrent was started torrent-less │ │ │ -(i.e. with just an info-hash and tracker ip, a magnet link for │ │ │ -instance).
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    has_incoming
    │ │ │ -
    true if there has ever been an incoming connection attempt to this │ │ │ -torrent.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    moving_storage
    │ │ │ -
    this is true if this torrent's storage is currently being moved from │ │ │ -one location to another. This may potentially be a long operation │ │ │ -if a large file ends up being copied from one drive to another.
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    announcing_to_trackers announcing_to_lsd announcing_to_dht
    │ │ │ -
    these are set to true if this torrent is allowed to announce to the │ │ │ -respective peer source. Whether they are true or false is determined by │ │ │ -the queue logic/auto manager. Torrents that are not auto managed will │ │ │ -always be allowed to announce to all peer sources.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hashes
    │ │ │ -
    the info-hash for this torrent
    │ │ │ -
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    last_upload last_download
    │ │ │ -
    the timestamps of the last time this torrent uploaded or downloaded │ │ │ -payload to any peer.
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    active_duration finished_duration seeding_duration
    │ │ │ -
    these are cumulative counters of for how long the torrent has been in │ │ │ -different states. active means not paused and added to session. Whether │ │ │ -it has found any peers or not is not relevant. │ │ │ -finished means all selected files/pieces were downloaded and available │ │ │ -to other peers (this is always a subset of active time). │ │ │ -seeding means all files/pieces were downloaded and available to │ │ │ -peers. Being available to peers does not imply there are other peers │ │ │ -asking for the payload.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    flags
    │ │ │ -
    reflects several of the torrent's flags. For more │ │ │ -information, see torrent_handle::flags().
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    renamed_files
    │ │ │ -
    contains a mapping of any files that have been renamed in this │ │ │ -torrent. It can act as an overlay over file_storage (which is │ │ │ -immutable).
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    announce_infohash

    │ │ │ -

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ -

    holds the per-info-hash state for a tracker, separately for the v1 │ │ │ -and v2 info-hashes. Since a hybrid torrent has both info-hashes, the │ │ │ -state for the two announces (the message returned by the tracker, the │ │ │ -time of the next announce, the most recent scrape numbers, etc.) are │ │ │ -kept independently. announce_endpoint owns one announce_infohash │ │ │ -for each protocol version.

    │ │ │ -
    │ │ │ -struct announce_infohash
    │ │ │ -{
    │ │ │ -   std::string message;
    │ │ │ -   error_code last_error;
    │ │ │ -   int scrape_incomplete  = -1;
    │ │ │ -   int scrape_complete  = -1;
    │ │ │ -   int scrape_downloaded  = -1;
    │ │ │ -   std::uint8_t fails : 7;
    │ │ │ -   bool updating : 1;
    │ │ │ -   bool start_sent : 1;
    │ │ │ -   bool complete_sent : 1;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    message
    │ │ │ -
    if this tracker has returned an error or warning message │ │ │ -that message is stored here
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    last_error
    │ │ │ -
    if this tracker failed the last time it was contacted │ │ │ -this error code specifies what error occurred
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    scrape_incomplete scrape_complete scrape_downloaded
    │ │ │ -
    if this tracker has returned scrape data, these fields are filled in │ │ │ -with valid numbers. Otherwise they are set to -1. incomplete counts │ │ │ -the number of current downloaders. complete counts the number of │ │ │ -current peers completed the download, or "seeds". downloaded is the │ │ │ -cumulative number of completed downloads.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    fails
    │ │ │ -
    the number of times in a row we have failed to announce to this │ │ │ -tracker.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    updating
    │ │ │ -
    true while we're waiting for a response from the tracker.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    start_sent
    │ │ │ -
    set to true when we get a valid response from an announce │ │ │ -with event=started. If it is set, we won't send start in the subsequent │ │ │ -announces.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    complete_sent
    │ │ │ -
    set to true when we send a event=completed.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    announce_endpoint

    │ │ │ -

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ -

    announces are sent to each tracker using every listen socket │ │ │ -this class holds information about one listen socket for one tracker

    │ │ │ -
    │ │ │ -struct announce_endpoint
    │ │ │ -{
    │ │ │ -   announce_endpoint ();
    │ │ │ -
    │ │ │ -   tcp::endpoint local_endpoint;
    │ │ │ -   aux::array<announce_infohash, num_protocols, protocol_version> info_hashes;
    │ │ │ -   bool enabled  = true;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    local_endpoint
    │ │ │ -
    the local endpoint of the listen interface associated with this endpoint
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    info_hashes
    │ │ │ -
    info_hashes[0] is the v1 info hash (SHA1) │ │ │ -info_hashes[1] is the v2 info hash (truncated SHA-256)
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    enabled
    │ │ │ -
    set to false to not announce from this endpoint
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    announce_entry

    │ │ │ -

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ -

    this class holds information about one bittorrent tracker, as it │ │ │ -relates to a specific torrent.

    │ │ │ -
    │ │ │ -struct announce_entry
    │ │ │ -{
    │ │ │ -   announce_entry& operator= (announce_entry const&) &;
    │ │ │ -   ~announce_entry ();
    │ │ │ -   announce_entry (announce_entry const&);
    │ │ │ -   announce_entry ();
    │ │ │ -   explicit announce_entry (string_view u);
    │ │ │ -
    │ │ │ -   enum tracker_source
    │ │ │ -   {
    │ │ │ -      source_torrent,
    │ │ │ -      source_client,
    │ │ │ -      source_magnet_link,
    │ │ │ -      source_tex,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   std::string url;
    │ │ │ -   std::string trackerid;
    │ │ │ -   std::vector<announce_endpoint> endpoints;
    │ │ │ -   std::uint8_t tier  = 0;
    │ │ │ -   std::uint8_t fail_limit  = 0;
    │ │ │ -   std::uint8_t source:4;
    │ │ │ -   bool verified:1;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    ~announce_entry() operator=() announce_entry()

    │ │ │ -
    │ │ │ -announce_entry& operator= (announce_entry const&) &;
    │ │ │ -~announce_entry ();
    │ │ │ -announce_entry (announce_entry const&);
    │ │ │ -announce_entry ();
    │ │ │ -explicit announce_entry (string_view u);
    │ │ │ -
    │ │ │ -

    constructs a tracker announce entry with u as the URL.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum tracker_source

    │ │ │ -

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    source_torrent1the tracker was part of the .torrent file
    source_client2the tracker was added programmatically via the add_tracker() function
    source_magnet_link4the tracker was part of a magnet link
    source_tex8the tracker was received from the swarm via tracker exchange
    │ │ │ -[report issue]
    │ │ │ -
    url
    │ │ │ -
    tracker URL as it appeared in the torrent file
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    trackerid
    │ │ │ -
    the current &trackerid= argument passed to the tracker. │ │ │ -this is optional and is normally empty (in which case no │ │ │ -trackerid is sent).
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    endpoints
    │ │ │ -
    each local listen socket (endpoint) will announce to the tracker. This │ │ │ -list contains state per endpoint.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    tier
    │ │ │ -
    the tier this tracker belongs to
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    fail_limit
    │ │ │ -
    the max number of failures to announce to this tracker in │ │ │ -a row, before this tracker is not used anymore. 0 means unlimited
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    source
    │ │ │ -
    a bitmask specifying which sources we got this tracker from.
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    verified
    │ │ │ -
    set to true the first time we receive a valid response │ │ │ -from this tracker.
    │ │ │ -
    │ │ │ -

    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]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    settings_pack

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ -

    The settings_pack struct, contains the names of all settings as │ │ │ -enum values. These values are passed in to the set_str(), │ │ │ -set_int(), set_bool() functions, to specify the setting to │ │ │ -change.

    │ │ │ -

    The settings_pack only stores values for settings that have been │ │ │ -explicitly set on this object. However, it can still be queried for │ │ │ -settings that have not been set and returns the default value for those │ │ │ -settings.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    user_agentstringlibtorrent/
    │ │ │ -

    this is the client identification to the tracker. The recommended │ │ │ -format of this string is: "client-name/client-version │ │ │ -libtorrent/libtorrent-version". This name will not only be used when │ │ │ -making HTTP requests, but also when sending extended headers to │ │ │ -peers that support that extension. It may not contain r or n

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    announce_ipstring 
    │ │ │ -

    announce_ip is the ip address passed along to trackers as the │ │ │ -&ip= parameter. If left as the default, that parameter is │ │ │ -omitted.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    This setting is only meant for very special cases where a seed is │ │ │ -running on the same host as the tracker, and the tracker accepts │ │ │ -the IP parameter (which normal trackers don't). Do not set this │ │ │ -option unless you also control the tracker.

    │ │ │ -
    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    handshake_client_versionstring 
    │ │ │ -

    this is the client name and version identifier sent to peers in the │ │ │ -handshake message. If this is an empty string, the user_agent is │ │ │ -used instead. This string must be a UTF-8 encoded unicode string.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    outgoing_interfacesstring 
    │ │ │ -

    This controls which IP address outgoing TCP peer connections are bound │ │ │ -to, in addition to controlling whether such connections are also │ │ │ -bound to a specific network interface/adapter (bind-to-device).

    │ │ │ -

    This string is a comma-separated list of IP addresses and │ │ │ -interface names. An empty string will not bind TCP sockets to a │ │ │ -device, and let the network stack assign the local address.

    │ │ │ -

    A list of names will be used to bind outgoing TCP sockets in a │ │ │ -round-robin fashion. An IP address will simply be used to bind() │ │ │ -the socket. An interface name will attempt to bind the socket to │ │ │ -that interface. If that fails, or is unsupported, one of the IP │ │ │ -addresses configured for that interface is used to bind() the │ │ │ -socket to. If the interface or adapter doesn't exist, the │ │ │ -outgoing peer connection will fail with an error message suggesting │ │ │ -the device cannot be found. Adapter names on Unix systems are of │ │ │ -the form "eth0", "eth1", "tun0", etc. This may be useful for │ │ │ -clients that are multi-homed. Binding an outgoing connection to a │ │ │ -local IP does not necessarily make the connection via the │ │ │ -associated NIC/Adapter.

    │ │ │ -

    When outgoing interfaces are specified, incoming connections or │ │ │ -packets sent to a local interface or IP that's not in this list │ │ │ -will be rejected with a peer_blocked_alert with │ │ │ -invalid_local_interface as the reason.

    │ │ │ -

    Note that these are just interface/adapter names or IP addresses. │ │ │ -There are no ports specified in this list. IPv6 addresses without │ │ │ -port should be specified without enclosing [, ].

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    listen_interfacesstring0.0.0.0:6881,[::]:6881
    │ │ │ -

    a comma-separated list of (IP or device name, port) pairs. These are │ │ │ -the listen ports that will be opened for accepting incoming uTP and │ │ │ -TCP peer connections. These are also used for outgoing uTP and UDP │ │ │ -tracker connections and DHT nodes.

    │ │ │ -

    It is possible to listen on multiple interfaces and │ │ │ -multiple ports. Binding to port 0 will make the operating system │ │ │ -pick the port.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    There are reasons to stick to the same port across sessions, │ │ │ -which would mean only using port 0 on the first start, and │ │ │ -recording the port that was picked for subsequent startups. │ │ │ -Trackers, the DHT and other peers will remember the port they see │ │ │ -you use and hand that port out to other peers trying to connect │ │ │ -to you, as well as trying to connect to you themselves.

    │ │ │ -
    │ │ │ -

    A port that has an "s" suffix will accept SSL peer connections. (note │ │ │ -that SSL sockets are only available in builds with SSL support)

    │ │ │ -

    A port that has an "l" suffix will be considered a local network. │ │ │ -i.e. it's assumed to only be able to reach hosts in the same local │ │ │ -network as the IP address (based on the netmask associated with the │ │ │ -IP, queried from the operating system).

    │ │ │ -

    if binding fails, the listen_failed_alert is posted. Once a │ │ │ -socket binding succeeds (if it does), the listen_succeeded_alert │ │ │ -is posted. There may be multiple failures before a success.

    │ │ │ -

    If a device name that does not exist is configured, no listen │ │ │ -socket will be opened for that interface. If this is the only │ │ │ -interface configured, it will be as if no listen ports are │ │ │ -configured.

    │ │ │ -

    If no listen ports are configured (e.g. listen_interfaces is an │ │ │ -empty string), networking will be disabled. No DHT will start, no │ │ │ -outgoing uTP or tracker connections will be made. No incoming TCP │ │ │ -or uTP connections will be accepted. (outgoing TCP connections │ │ │ -will still be possible, depending on │ │ │ -settings_pack::outgoing_interfaces).

    │ │ │ -

    For example: │ │ │ -[::1]:8888 - will only accept connections on the IPv6 loopback │ │ │ -address on port 8888.

    │ │ │ -

    eth0:4444,eth1:4444 - will accept connections on port 4444 on │ │ │ -any IP address bound to device eth0 or eth1.

    │ │ │ -

    [::]:0s - will accept SSL connections on a port chosen by the │ │ │ -OS. And not accept non-SSL connections at all.

    │ │ │ -

    0.0.0.0:6881,[::]:6881 - binds to all interfaces on port 6881.

    │ │ │ -

    10.0.1.13:6881l - binds to the local IP address, port 6881, but │ │ │ -only allow talking to peers on the same local network. The netmask │ │ │ -is queried from the operating system. Interfaces marked l are │ │ │ -not announced to trackers, unless the tracker is also on the same │ │ │ -local network.

    │ │ │ -

    Windows OS network adapter device name must be specified with GUID. │ │ │ -It can be obtained from "netsh lan show interfaces" command output. │ │ │ -GUID must be uppercased string embraced in curly brackets. │ │ │ -{E4F0B674-0DFC-48BB-98A5-2AA730BDB6D6}:7777 - will accept │ │ │ -connections on port 7777 on adapter with this GUID.

    │ │ │ -

    For more information, see the Multi-homed hosts section.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    proxy_hostnamestring 
    │ │ │ -

    when using a proxy, this is the hostname where the proxy is running │ │ │ -see proxy_type. Note that when using a proxy, the │ │ │ -settings_pack::listen_interfaces setting is overridden and only a │ │ │ -single interface is created, just to contact the proxy. This │ │ │ -means a proxy cannot be combined with SSL torrents or multiple │ │ │ -listen interfaces. This proxy listen interface will not accept │ │ │ -incoming TCP connections, will not map ports with any gateway and │ │ │ -will not enable local service discovery. All traffic is supposed │ │ │ -to be channeled through the proxy.

    │ │ │ - │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    proxy_usernamestring 
    proxy_passwordstring 
    │ │ │ -

    when using a proxy, these are the credentials (if any) to use when │ │ │ -connecting to it. see proxy_type

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    i2p_hostnamestring 
    │ │ │ -

    sets the i2p SAM bridge to connect to. set the port with the │ │ │ -i2p_port setting. Unless this is set, i2p torrents are not │ │ │ -supported. This setting is separate from the other proxy settings │ │ │ -since i2p torrents and their peers are orthogonal. You can have │ │ │ -i2p peers as well as regular peers via a proxy.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    peer_fingerprintstring-LT2100-
    │ │ │ -

    this is the fingerprint for the client. It will be used as the │ │ │ -prefix to the peer_id. If this is 20 bytes (or longer) it will be │ │ │ -truncated to 20 bytes and used as the entire peer-id

    │ │ │ -

    There is a utility function, generate_fingerprint() that can be used │ │ │ -to generate a standard client peer ID fingerprint prefix.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    dht_bootstrap_nodesstringdht.libtorrent.org:25401
    │ │ │ -

    This is a comma-separated list of IP port-pairs. They will be added │ │ │ -to the DHT node (if it's enabled) as back-up nodes in case we don't │ │ │ -know of any.

    │ │ │ -

    Changing these after the DHT has been started may not have any │ │ │ -effect until the DHT is restarted. │ │ │ -Here are some other bootstrap nodes that may work: │ │ │ -router.bittorrent.com:6881, │ │ │ -dht.transmissionbt.com:6881 │ │ │ -router.bt.ouinet.work:6881,

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    natpmp_gatewaystring 
    │ │ │ -

    Overrides the NAT-PMP service gateway. When set, libtorrent won't try │ │ │ -to resolve the default gateway and instead will send the requests to │ │ │ -the address specified. This only takes affect when NAT-PMP first │ │ │ -starts. If you change this setting after NAT-PMP has been │ │ │ -enabled, you need to disable it and re-enable it.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    webtorrent_stun_serverstringstun.l.google.com:19302
    │ │ │ -

    This is the STUN server used by WebTorrent to enable ICE NAT │ │ │ -traversal for WebRTC. It must have the format hostname:port.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    allow_multiple_connections_per_ipboolfalse
    │ │ │ -

    determines if connections from the same IP address as existing │ │ │ -connections should be rejected or not. Rejecting multiple connections │ │ │ -from the same IP address will prevent abusive │ │ │ -behavior by peers. The logic for determining whether connections are │ │ │ -to the same peer is more complicated with this enabled, and more │ │ │ -likely to fail in some edge cases. It is not recommended to enable │ │ │ -this feature.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    send_redundant_havebooltrue
    │ │ │ -

    send_redundant_have controls if have messages will be sent to │ │ │ -peers that already have the piece. This is typically not necessary, │ │ │ -but it might be necessary for collecting statistics in some cases.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    use_dht_as_fallbackboolfalse
    │ │ │ -

    use_dht_as_fallback determines how the DHT is used. If this is │ │ │ -true, the DHT will only be used for torrents where all trackers in │ │ │ -its tracker list has failed. Either by an explicit error message or │ │ │ -a time out. If this is false, the DHT is used regardless of if the │ │ │ -trackers fail or not.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    upnp_ignore_nonroutersboolfalse
    │ │ │ -

    upnp_ignore_nonrouters indicates whether or not the UPnP │ │ │ -implementation should ignore any broadcast response from a device │ │ │ -whose address is not on our subnet. i.e. │ │ │ -it's a way to not talk to other people's routers by mistake.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    use_parole_modebooltrue
    │ │ │ -

    use_parole_mode specifies if parole mode should be used. Parole │ │ │ -mode means that peers that participate in pieces that fail the hash │ │ │ -check are put in a mode where they are only allowed to download │ │ │ -whole pieces. If the whole piece a peer in parole mode fails the │ │ │ -hash check, it is banned. If a peer participates in a piece that │ │ │ -passes the hash check, it is taken out of parole mode.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    auto_manage_prefer_seedsboolfalse
    │ │ │ -

    if true, prefer seeding torrents when determining which torrents to give │ │ │ -active slots to. If false, give preference to downloading torrents

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    dont_count_slow_torrentsbooltrue
    │ │ │ -

    if dont_count_slow_torrents is true, torrents without any │ │ │ -payload transfers are not subject to the active_seeds and │ │ │ -active_downloads limits. This is intended to make it more │ │ │ -likely to utilize all available bandwidth, and avoid having │ │ │ -torrents that don't transfer anything block the active slots.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    close_redundant_connectionsbooltrue
    │ │ │ -

    close_redundant_connections specifies whether libtorrent should │ │ │ -close connections where both ends have no utility in keeping the │ │ │ -connection open. For instance if both ends have completed their │ │ │ -downloads, there's no point in keeping it open.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    prioritize_partial_piecesboolfalse
    │ │ │ -

    If prioritize_partial_pieces is true, partial pieces are picked │ │ │ -before pieces that are more rare. If false, rare pieces are always │ │ │ -prioritized, unless the number of partial pieces is growing out of │ │ │ -proportion.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    rate_limit_ip_overheadbooltrue
    │ │ │ -

    if set to true, the estimated TCP/IP overhead is drained from the │ │ │ -rate limiters, to avoid exceeding the limits with the total traffic

    │ │ │ - │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    announce_to_all_tiersboolfalse
    announce_to_all_trackersboolfalse
    │ │ │ -

    announce_to_all_trackers controls how multi tracker torrents │ │ │ -are treated. If this is set to true, all trackers in the same tier │ │ │ -are announced to in parallel. If all trackers in tier 0 fails, all │ │ │ -trackers in tier 1 are announced as well. If it's set to false, the │ │ │ -behavior is as defined by the multi tracker specification.

    │ │ │ -

    announce_to_all_tiers also controls how multi tracker torrents │ │ │ -are treated. When this is set to true, one tracker from each tier │ │ │ -is announced to. This is the uTorrent behavior. To be compliant │ │ │ -with the Multi-tracker specification, set it to false.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    prefer_udp_trackersbooltrue
    │ │ │ -

    prefer_udp_trackers: true means that trackers │ │ │ -may be rearranged in a way that udp trackers are always tried │ │ │ -before http trackers for the same hostname. Setting this to false │ │ │ -means that the tracker's tier is respected and there's no │ │ │ -preference of one protocol over another.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    disable_hash_checksboolfalse
    │ │ │ -

    when set to true, all data downloaded from peers will be assumed to │ │ │ -be correct, and not tested to match the hashes in the torrent this │ │ │ -is only useful for simulation and testing purposes (typically │ │ │ -combined with disabled_storage)

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    allow_i2p_mixedboolfalse
    │ │ │ -

    if this is true, i2p torrents are allowed to also get peers from │ │ │ -other sources than the tracker, and connect to regular IPs, not │ │ │ -providing any anonymization. This may be useful if the user is not │ │ │ -interested in the anonymization of i2p, but still wants to be able │ │ │ -to connect to i2p peers.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    no_atime_storagebooltrue
    │ │ │ -

    no_atime_storage this is a Linux-only option and passes in the │ │ │ -O_NOATIME to open() when opening files. This may lead to │ │ │ -some disk performance improvements.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    incoming_starts_queued_torrentsboolfalse
    │ │ │ -

    incoming_starts_queued_torrents. If a torrent │ │ │ -has been paused by the auto managed feature in libtorrent, i.e. the │ │ │ -torrent is paused and auto managed, this feature affects whether or │ │ │ -not it is automatically started on an incoming connection. The main │ │ │ -reason to queue torrents, is not to make them unavailable, but to │ │ │ -save on the overhead of announcing to the trackers, the DHT and to │ │ │ -avoid spreading one's unchoke slots too thin. If a peer managed to │ │ │ -find us, even though we're no in the torrent anymore, this setting │ │ │ -can make us start the torrent and serve it.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    report_true_downloadedboolfalse
    │ │ │ -

    when set to true, the downloaded counter sent to trackers will │ │ │ -include the actual number of payload bytes downloaded including │ │ │ -redundant bytes. If set to false, it will not include any redundancy │ │ │ -bytes

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    strict_end_game_modebooltrue
    │ │ │ -

    strict_end_game_mode controls when a │ │ │ -block may be requested twice. If this is true, a block may only │ │ │ -be requested twice when there's at least one request to every piece │ │ │ -that's left to download in the torrent. This may slow down progress │ │ │ -on some pieces sometimes, but it may also avoid downloading a lot │ │ │ -of redundant bytes. If this is false, libtorrent attempts to │ │ │ -use each peer connection to its max, by always requesting │ │ │ -something, even if it means requesting something that has been │ │ │ -requested from another peer already.

    │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    enable_outgoing_utpbooltrue
    enable_incoming_utpbooltrue
    enable_outgoing_tcpbooltrue
    enable_incoming_tcpbooltrue
    │ │ │ -

    Enables incoming and outgoing, TCP and uTP peer connections. │ │ │ -false is disabled and true is enabled. When outgoing │ │ │ -connections are disabled, libtorrent will simply not make │ │ │ -outgoing peer connections with the specific transport protocol. │ │ │ -Disabled incoming peer connections will simply be rejected. │ │ │ -These options only apply to peer connections, not tracker- or any │ │ │ -other kinds of connections.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    no_recheck_incomplete_resumeboolfalse
    │ │ │ -

    no_recheck_incomplete_resume determines if the storage should │ │ │ -check the whole files when resume data is incomplete or missing or │ │ │ -whether it should simply assume we don't have any of the data. If │ │ │ -false, any existing files will be checked. │ │ │ -By setting this setting to true, the files won't be checked, but │ │ │ -will go straight to download mode.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    anonymous_modeboolfalse
    │ │ │ -

    anonymous_mode: When set to true, the client tries to hide │ │ │ -its identity to a certain degree.

    │ │ │ -
      │ │ │ -
    • A generic user-agent will be │ │ │ -used for trackers (except for private torrents).
    • │ │ │ -
    • Your local IPv4 and IPv6 address won't be sent as query string │ │ │ -parameters to private trackers.
    • │ │ │ -
    • If announce_ip is configured, it will not be sent to trackers
    • │ │ │ -
    • The client version will not be sent to peers in the extension │ │ │ -handshake.
    • │ │ │ -
    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    report_web_seed_downloadsbooltrue
    │ │ │ -

    specifies whether downloads from web seeds is reported to the │ │ │ -tracker or not. Turning it off also excludes web │ │ │ -seed traffic from other stats and download rate reporting via the │ │ │ -libtorrent API.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    seeding_outgoing_connectionsbooltrue
    │ │ │ -

    seeding_outgoing_connections determines if seeding (and │ │ │ -finished) torrents should attempt to make outgoing connections or │ │ │ -not. It may be set to false in very │ │ │ -specific applications where the cost of making outgoing connections │ │ │ -is high, and there are no or small benefits of doing so. For │ │ │ -instance, if no nodes are behind a firewall or a NAT, seeds don't │ │ │ -need to make outgoing connections.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    no_connect_privileged_portsboolfalse
    │ │ │ -

    when this is true, libtorrent will not attempt to make outgoing │ │ │ -connections to peers whose port is < 1024. This is a safety │ │ │ -precaution to avoid being part of a DDoS attack

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    smooth_connectsbooltrue
    │ │ │ -

    smooth_connects means the number of │ │ │ -connection attempts per second may be limited to below the │ │ │ -connection_speed, in case we're close to bump up against the │ │ │ -limit of number of connections. The intention of this setting is to │ │ │ -more evenly distribute our connection attempts over time, instead │ │ │ -of attempting to connect in batches, and timing them out in │ │ │ -batches.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    always_send_user_agentboolfalse
    │ │ │ -

    always send user-agent in every web seed request. If false, only │ │ │ -the first request per http connection will include the user agent

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    apply_ip_filter_to_trackersbooltrue
    │ │ │ -

    apply_ip_filter_to_trackers determines │ │ │ -whether the IP filter applies to trackers as well as peers. If this │ │ │ -is set to false, trackers are exempt from the IP filter (if there │ │ │ -is one). If no IP filter is set, this setting is irrelevant.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    ban_web_seedsbooltrue
    │ │ │ -

    when true, web seeds sending bad data will be banned

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    support_share_modebooltrue
    │ │ │ -

    if false, prevents libtorrent to advertise share-mode support

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    report_redundant_bytesbooltrue
    │ │ │ -

    if this is true, the number of redundant bytes is sent to the │ │ │ -tracker

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    nametypedefault
    listen_system_port_fallbackbooltrue
    │ │ │ -

    if this is true, libtorrent will fall back to listening on a port │ │ │ -chosen by the operating system (i.e. binding to port 0). If a │ │ │ -failure is preferred, set this to false.

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    nametypedefault
    announce_crypto_supportbooltrue
    announce_crypto_supportbooltrue
    │ │ │

    when this is true, and incoming encrypted connections are enabled, │ │ │ &supportcrypt=1 is included in http tracker announces

    │ │ │ │ │ │ │ │ │ @@ -20376,662 +8647,9986 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    int2 * 60
    │ │ │

    the WebRTC connection timeout used by WebTorrent (in seconds)

    │ │ │
    │ │ │ -struct settings_pack final : settings_interface
    │ │ │ +struct settings_pack final : settings_interface
    │ │ │ +{
    │ │ │ +   void set_str (int name, std::string val) override;
    │ │ │ +   void set_bool (int name, bool val) override;
    │ │ │ +   void set_int (int name, int val) override;
    │ │ │ +   bool has_val (int name) const override;
    │ │ │ +   void clear ();
    │ │ │ +   void clear (int name);
    │ │ │ +   std::string const& get_str (int name) const override;
    │ │ │ +   int get_int (int name) const override;
    │ │ │ +   bool get_bool (int name) const override;
    │ │ │ +
    │ │ │ +   enum type_bases
    │ │ │ +   {
    │ │ │ +      string_type_base,
    │ │ │ +      int_type_base,
    │ │ │ +      bool_type_base,
    │ │ │ +      type_mask,
    │ │ │ +      index_mask,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum mmap_write_mode_t
    │ │ │ +   {
    │ │ │ +      always_pwrite,
    │ │ │ +      always_mmap_write,
    │ │ │ +      auto_mmap_write,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum suggest_mode_t
    │ │ │ +   {
    │ │ │ +      no_piece_suggestions,
    │ │ │ +      suggest_read_cache,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum choking_algorithm_t
    │ │ │ +   {
    │ │ │ +      fixed_slots_choker,
    │ │ │ +      rate_based_choker,
    │ │ │ +      deprecated_bittyrant_choker,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum seed_choking_algorithm_t
    │ │ │ +   {
    │ │ │ +      round_robin,
    │ │ │ +      fastest_upload,
    │ │ │ +      anti_leech,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum io_buffer_mode_t
    │ │ │ +   {
    │ │ │ +      enable_os_cache,
    │ │ │ +      deprecated_disable_os_cache_for_aligned_files,
    │ │ │ +      disable_os_cache,
    │ │ │ +      write_through,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum bandwidth_mixed_algo_t
    │ │ │ +   {
    │ │ │ +      prefer_tcp,
    │ │ │ +      peer_proportional,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum enc_policy
    │ │ │ +   {
    │ │ │ +      pe_forced,
    │ │ │ +      pe_enabled,
    │ │ │ +      pe_disabled,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum enc_level
    │ │ │ +   {
    │ │ │ +      pe_plaintext,
    │ │ │ +      pe_rc4,
    │ │ │ +      pe_both,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   enum proxy_type_t
    │ │ │ +   {
    │ │ │ +      none,
    │ │ │ +      socks4,
    │ │ │ +      socks5,
    │ │ │ +      socks5_pw,
    │ │ │ +      http,
    │ │ │ +      http_pw,
    │ │ │ +   };
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    set_bool() set_str() set_int()

    │ │ │ +
    │ │ │ +void set_str (int name, std::string val) override;
    │ │ │ +void set_bool (int name, bool val) override;
    │ │ │ +void set_int (int name, int val) override;
    │ │ │ +
    │ │ │ +

    set a configuration option in the settings_pack. name is one of │ │ │ +the enum values from string_types, int_types or bool_types. They must │ │ │ +match the respective type of the set_* function.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    has_val()

    │ │ │ +
    │ │ │ +bool has_val (int name) const override;
    │ │ │ +
    │ │ │ +

    queries whether the specified configuration option has a value set in │ │ │ +this pack. name can be any enumeration value from string_types, │ │ │ +int_types or bool_types.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    clear()

    │ │ │ +
    │ │ │ +void clear ();
    │ │ │ +
    │ │ │ +

    clear the settings pack from all settings

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    clear()

    │ │ │ +
    │ │ │ +void clear (int name);
    │ │ │ +
    │ │ │ +

    clear a specific setting from the pack

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_str() get_int() get_bool()

    │ │ │ +
    │ │ │ +std::string const& get_str (int name) const override;
    │ │ │ +int get_int (int name) const override;
    │ │ │ +bool get_bool (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]
    │ │ │ +
    │ │ │ +

    enum type_bases

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    string_type_base0 
    int_type_base16384 
    bool_type_base32768 
    type_mask49152 
    index_mask16383 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum mmap_write_mode_t

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    always_pwrite0disable writing to disk via mmap, always use normal write calls
    always_mmap_write1prefer using memory mapped files for disk writes (at least for │ │ │ +large files where it might make sense)
    auto_mmap_write2determine whether to use pwrite or memory mapped files for disk │ │ │ +writes depending on the kind of storage behind the save path
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum suggest_mode_t

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_piece_suggestions0disables suggestion messages
    suggest_read_cache1sends suggest messages for the pieces currently in the read │ │ │ +cache, as a hint to peers about cache-friendly piece selection
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum choking_algorithm_t

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    fixed_slots_choker0This is the traditional choker with a fixed number of unchoke │ │ │ +slots (as specified by settings_pack::unchoke_slots_limit).
    rate_based_choker2

    This opens up unchoke slots based on the upload rate achieved to │ │ │ +peers. The more slots that are opened, the marginal upload rate │ │ │ +required to open up another slot increases. Configure the initial │ │ │ +threshold with settings_pack::rate_choker_initial_threshold.

    │ │ │ +

    For more information, see rate based choking.

    │ │ │ +
    deprecated_bittyrant_choker3 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum seed_choking_algorithm_t

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    round_robin0which round-robins the peers that are unchoked │ │ │ +when seeding. This distributes the upload bandwidth uniformly and │ │ │ +fairly. It minimizes the ability for a peer to download everything │ │ │ +without redistributing it.
    fastest_upload1unchokes the peers we can send to the fastest. This might be a │ │ │ +bit more reliable in utilizing all available capacity.
    anti_leech2prioritizes peers who have just started or are │ │ │ +just about to finish the download. The intention is to force │ │ │ +peers in the middle of the download to trade with each other. │ │ │ +This does not just take into account the pieces a peer is │ │ │ +reporting having downloaded, but also the pieces we have sent │ │ │ +to it.
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum io_buffer_mode_t

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    enable_os_cache0 
    deprecated_disable_os_cache_for_aligned_files1 
    disable_os_cache2 
    write_through3 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum bandwidth_mixed_algo_t

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    prefer_tcp0disables the mixed mode bandwidth balancing
    peer_proportional1does not throttle uTP, throttles TCP to the same proportion │ │ │ +of throughput as there are TCP connections
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum enc_policy

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    pe_forced0Only encrypted connections are allowed. Incoming connections that │ │ │ +are not encrypted are closed and if the encrypted outgoing │ │ │ +connection fails, a non-encrypted retry will not be made.
    pe_enabled1encrypted connections are enabled, but non-encrypted connections │ │ │ +are allowed. An incoming non-encrypted connection will be accepted, │ │ │ +and if an outgoing encrypted connection fails, a non- encrypted │ │ │ +connection will be tried.
    pe_disabled2only non-encrypted connections are allowed.
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum enc_level

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    pe_plaintext1use only plain text encryption
    pe_rc42use only RC4 encryption
    pe_both3allow both
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum proxy_type_t

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    none0No proxy server is used and all other fields are ignored.
    socks41The server is assumed to be a SOCKS4 server that requires a │ │ │ +username.
    socks52The server is assumed to be a SOCKS5 server (RFC 1928) that does │ │ │ +not require any authentication. The username and password are │ │ │ +ignored.
    socks5_pw3The server is assumed to be a SOCKS5 server that supports plain │ │ │ +text username and password authentication (RFC 1929). The │ │ │ +username and password specified may be sent to the proxy if it │ │ │ +requires.
    http4The server is assumed to be an HTTP proxy. If the transport used │ │ │ +for the connection is non-HTTP, the server is assumed to support │ │ │ +the CONNECT method. i.e. for web seeds and HTTP trackers, a plain │ │ │ +proxy will suffice. The proxy is assumed to not require │ │ │ +authorization. The username and password will not be used.
    http_pw5The server is assumed to be an HTTP proxy that requires user │ │ │ +authorization. The username and password will be sent to the proxy.
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    name_for_setting() setting_by_name()

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +
    │ │ │ +int setting_by_name (string_view name);
    │ │ │ +char const* name_for_setting (int s);
    │ │ │ +
    │ │ │ +

    converts a setting integer (from the enums string_types, int_types or │ │ │ +bool_types) to a string, and vice versa.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    default_settings()

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +
    │ │ │ +settings_pack default_settings ();
    │ │ │ +
    │ │ │ +

    returns a settings_pack with every setting set to its default value

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    high_performance_seed() min_memory_usage()

    │ │ │ +

    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);
    │ │ │ +
    │ │ │ +

    This is a utility function to produce a client ID fingerprint formatted to │ │ │ +the most common convention. The fingerprint can be set via the │ │ │ +peer_fingerprint setting, in settings_pack.

    │ │ │ +

    The name string should contain exactly two characters. These are the │ │ │ +characters unique to your client, used to identify it. Make sure not to │ │ │ +clash with anybody else. Here are some taken id's:

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    id charsclient
    LTlibtorrent (default)
    UTuTorrent
    UMuTorrent Mac
    qBqBittorrent
    BPBitTorrent Pro
    BTBitTorrent
    DEDeluge
    AZAzureus
    TLTribler
    │ │ │ +

    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]
    │ │ │ +
    │ │ │ +

    peer_class_type_filter

    │ │ │ +

    Declared in "libtorrent/peer_class_type_filter.hpp"

    │ │ │ +

    peer_class_type_filter is a simple container for rules for adding and subtracting │ │ │ +peer-classes from peers. It is applied after the peer class filter is applied (which │ │ │ +is based on the peer's IP address).

    │ │ │ +
    │ │ │ +struct peer_class_type_filter
    │ │ │ +{
    │ │ │ +   void remove (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +   void add (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +   void disallow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +   void allow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +   std::uint32_t apply (socket_type_t const st, std::uint32_t peer_class_mask);
    │ │ │ +   friend bool operator== (peer_class_type_filter const& lhs
    │ │ │ +      , peer_class_type_filter const& rhs);
    │ │ │ +
    │ │ │ +   enum socket_type_t
    │ │ │ +   {
    │ │ │ +      tcp_socket,
    │ │ │ +      utp_socket,
    │ │ │ +      ssl_tcp_socket,
    │ │ │ +      ssl_utp_socket,
    │ │ │ +      i2p_socket,
    │ │ │ +      rtc_socket,
    │ │ │ +      num_socket_types,
    │ │ │ +   };
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    remove() add()

    │ │ │ +
    │ │ │ +void remove (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +void add (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +
    │ │ │ +

    add() and remove() adds and removes a peer class to be added │ │ │ +to new peers based on socket type.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    disallow() allow()

    │ │ │ +
    │ │ │ +void disallow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +void allow (socket_type_t const st, peer_class_t const peer_class);
    │ │ │ +
    │ │ │ +

    disallow() and allow() adds and removes a peer class to be │ │ │ +removed from new peers based on socket type.

    │ │ │ +

    The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ +peer classes in the peer_class_type_filter are 32 bits.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    apply()

    │ │ │ +
    │ │ │ +std::uint32_t apply (socket_type_t const st, std::uint32_t peer_class_mask);
    │ │ │ +
    │ │ │ +

    takes a bitmask of peer classes and returns a new bitmask of │ │ │ +peer classes after the rules have been applied, based on the socket type argument │ │ │ +(st).

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum socket_type_t

    │ │ │ +

    Declared in "libtorrent/peer_class_type_filter.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    tcp_socket0 
    utp_socket1 
    ssl_tcp_socket2 
    ssl_utp_socket3 
    i2p_socket4 
    rtc_socket5 
    num_socket_types6 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    peer_class_info

    │ │ │ +

    Declared in "libtorrent/peer_class.hpp"

    │ │ │ +

    holds settings for a peer class. Used in set_peer_class() and │ │ │ +get_peer_class() calls.

    │ │ │ +
    │ │ │ +struct peer_class_info
    │ │ │ +{
    │ │ │ +   bool ignore_unchoke_slots;
    │ │ │ +   int connection_limit_factor;
    │ │ │ +   std::string label;
    │ │ │ +   int upload_limit;
    │ │ │ +   int download_limit;
    │ │ │ +   int upload_priority;
    │ │ │ +   int download_priority;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    ignore_unchoke_slots
    │ │ │ +
    ignore_unchoke_slots determines whether peers should always │ │ │ +unchoke a peer, regardless of the choking algorithm, or if it should │ │ │ +honor the unchoke slot limits. It's used for local peers by default. │ │ │ +If any of the peer classes a peer belongs to has this set to true, │ │ │ +that peer will be unchoked at all times.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    connection_limit_factor
    │ │ │ +
    adjusts the connection limit (global and per torrent) that applies to │ │ │ +this peer class. By default, local peers are allowed to exceed the │ │ │ +normal connection limit for instance. This is specified as a percent │ │ │ +factor. 100 makes the peer class apply normally to the limit. 200 │ │ │ +means as long as there are fewer connections than twice the limit, we │ │ │ +accept this peer. This factor applies both to the global connection │ │ │ +limit and the per-torrent limit. Note that if not used carefully one │ │ │ +peer class can potentially completely starve out all other over time.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    label
    │ │ │ +
    not used by libtorrent. It's intended as a potentially user-facing │ │ │ +identifier of this peer class.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    upload_limit download_limit
    │ │ │ +
    transfer rates limits for the whole peer class. They are specified in │ │ │ +bytes per second and apply to the sum of all peers that are members of │ │ │ +this class.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    upload_priority download_priority
    │ │ │ +
    relative priorities used by the bandwidth allocator in the rate │ │ │ +limiter. If no rate limits are in use, the priority is not used │ │ │ +either. Priorities start at 1 (0 is not a valid priority) and may not │ │ │ +exceed 255.
    │ │ │ +
    │ │ │ +

    The pop_alerts() function on session is the main interface for retrieving │ │ │ +alerts (warnings, messages and errors from libtorrent). If no alerts have │ │ │ +been posted by libtorrent pop_alerts() will return an empty list.

    │ │ │ +

    By default, only errors are reported. settings_pack::alert_mask can be │ │ │ +used to specify which kinds of events should be reported. The alert mask is │ │ │ +a combination of the alert_category_t flags in the alert class.

    │ │ │ +

    Every alert belongs to one or more category. There is a cost associated with │ │ │ +posting alerts. Only alerts that belong to an enabled category are │ │ │ +posted. Setting the alert bitmask to 0 will disable all alerts (except those │ │ │ +that are non-discardable). Alerts that are responses to API calls such as │ │ │ +save_resume_data() and post_session_stats() are non-discardable and will be │ │ │ +posted even if their category is disabled.

    │ │ │ +

    There are other alert base classes that some alerts derive from, all the │ │ │ +alerts that are generated for a specific torrent are derived from │ │ │ +torrent_alert, and tracker events derive from tracker_alert.

    │ │ │ +

    Alerts returned by pop_alerts() are only valid until the next call to │ │ │ +pop_alerts(). You may not copy an alert object to access it after the next │ │ │ +call to pop_alerts(). Internal members of alerts also become invalid once │ │ │ +pop_alerts() is called again.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_routing_bucket

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    struct to hold information about a single DHT routing table bucket

    │ │ │ +
    │ │ │ +struct dht_routing_bucket
    │ │ │ +{
    │ │ │ +   int num_nodes  = 0;
    │ │ │ +   int num_replacements  = 0;
    │ │ │ +   int last_active  = 0;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    num_nodes num_replacements
    │ │ │ +
    the total number of nodes and replacement nodes │ │ │ +in the routing table
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    last_active
    │ │ │ +
    number of seconds since last activity
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is a base class for alerts that are associated with a │ │ │ +specific torrent. It contains a handle to the torrent.

    │ │ │ +

    Note that by the time the client receives a torrent_alert, its │ │ │ +handle member may be invalid.

    │ │ │ +
    │ │ │ +struct torrent_alert : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   torrent_handle handle;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    message()

    │ │ │ +
    │ │ │ +std::string message () const override;
    │ │ │ +
    │ │ │ +

    returns the message associated with this alert

    │ │ │ +[report issue]
    │ │ │ +
    handle
    │ │ │ +
    The torrent_handle pointing to the torrent this │ │ │ +alert is associated with.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    peer_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    The peer alert is a base class for alerts that refer to a specific peer. It includes all │ │ │ +the information to identify the peer. i.e. ip and peer-id.

    │ │ │ +
    │ │ │ +struct peer_alert : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   enum endpoint_type_t
    │ │ │ +   {
    │ │ │ +      ip_endpoint,
    │ │ │ +      i2p_endpoint,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   peer_endpoint_t ep;
    │ │ │ +   peer_id pid;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    enum endpoint_type_t

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    ip_endpoint0 
    i2p_endpoint1 
    │ │ │ +[report issue]
    │ │ │ +
    ep
    │ │ │ +
    The peer's endpoint, either IP address and port or i2p destination │ │ │ +hash.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    pid
    │ │ │ +
    the peer ID, if known.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    tracker_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is a base class used for alerts that are associated with a │ │ │ +specific tracker. It derives from torrent_alert since a tracker │ │ │ +is also associated with a specific torrent.

    │ │ │ +
    │ │ │ +struct tracker_alert : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* tracker_url () const;
    │ │ │ +
    │ │ │ +   aux::noexcept_movable<tcp::endpoint> local_endpoint;
    │ │ │ +   protocol_version version;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    tracker_url()

    │ │ │ +
    │ │ │ +char const* tracker_url () const;
    │ │ │ +
    │ │ │ +

    returns a 0-terminated string of the tracker's URL

    │ │ │ +[report issue]
    │ │ │ +
    local_endpoint
    │ │ │ +
    endpoint of the listen interface being announced
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    version
    │ │ │ +
    the bittorrent protocol version that was announced
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    torrent_removed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    The torrent_removed_alert is posted whenever a torrent is removed. Since │ │ │ +the torrent handle in its base class will usually be invalid (since the torrent │ │ │ +is already removed) it has the info hash as a member, to identify it. │ │ │ +It's posted when the alert_category::status bit is set in the alert_mask.

    │ │ │ +

    Note that the handle remains valid for some time after │ │ │ +torrent_removed_alert is posted, as long as some internal libtorrent │ │ │ +task (such as an I/O task) refers to it. Additionally, other alerts like │ │ │ +save_resume_data_alert may be posted after torrent_removed_alert. │ │ │ +To synchronize on whether the torrent has been removed or not, call │ │ │ +torrent_handle::in_session(). This will return true before │ │ │ +torrent_removed_alert is posted, and false afterward.

    │ │ │ +

    Even though the handle member doesn't point to an existing torrent anymore, │ │ │ +it is still useful for comparing to other handles, which may also no │ │ │ +longer point to existing torrents, but to the same non-existing torrents.

    │ │ │ +

    The torrent_handle acts as a weak_ptr, even though its object no │ │ │ +longer exists, it can still compare equal to another weak pointer which │ │ │ +points to the same non-existent object.

    │ │ │ +
    │ │ │ +struct torrent_removed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   info_hash_t info_hashes;
    │ │ │ +   client_data_t userdata;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    userdata
    │ │ │ +
    'userdata` as set in add_torrent_params at torrent creation. │ │ │ +This can be used to associate this torrent with related data │ │ │ +in the client application more efficiently than info_hashes.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    read_piece_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when the asynchronous read operation initiated by │ │ │ +a call to torrent_handle::read_piece() is completed. If the read failed, the torrent │ │ │ +is paused and an error state is set and the buffer member of the alert │ │ │ +is 0. If successful, buffer points to a buffer containing all the data │ │ │ +of the piece. piece is the piece index that was read. size is the │ │ │ +number of bytes that was read.

    │ │ │ +

    If the operation fails, error will indicate what went wrong.

    │ │ │ +
    │ │ │ +struct read_piece_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +   error_code const error;
    │ │ │ +   boost::shared_array<char> const buffer;
    │ │ │ +   piece_index_t const piece;
    │ │ │ +   int const size;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_completed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is posted whenever an individual file completes its download. i.e. │ │ │ +All pieces overlapping this file have passed their hash check.

    │ │ │ +
    │ │ │ +struct file_completed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   file_index_t const index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    index
    │ │ │ +
    refers to the index of the file that completed.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_renamed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is posted as a response to a torrent_handle::rename_file() call, if the rename │ │ │ +operation succeeds.

    │ │ │ +
    │ │ │ +struct file_renamed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* old_name () const;
    │ │ │ +   char const* new_name () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +   file_index_t const index;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    old_name() new_name()

    │ │ │ +
    │ │ │ +char const* old_name () const;
    │ │ │ +char const* new_name () const;
    │ │ │ +
    │ │ │ +

    returns the new and previous file name, respectively.

    │ │ │ +[report issue]
    │ │ │ +
    index
    │ │ │ +
    refers to the index of the file that was renamed,
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    file_rename_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is posted as a response to a torrent_handle::rename_file() call, if the rename │ │ │ +operation failed.

    │ │ │ +
    │ │ │ +struct file_rename_failed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +   file_index_t const index;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    index error
    │ │ │ +
    refers to the index of the file that was supposed to be renamed, │ │ │ +error is the error code returned from the filesystem.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    performance_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a limit is reached that might have a negative impact on │ │ │ +upload or download rate performance.

    │ │ │ +
    │ │ │ +struct performance_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   enum performance_warning_t
    │ │ │ +   {
    │ │ │ +      outstanding_disk_buffer_limit_reached,
    │ │ │ +      outstanding_request_limit_reached,
    │ │ │ +      upload_limit_too_low,
    │ │ │ +      download_limit_too_low,
    │ │ │ +      send_buffer_watermark_too_low,
    │ │ │ +      too_many_optimistic_unchoke_slots,
    │ │ │ +      too_high_disk_queue_limit,
    │ │ │ +      aio_limit_reached,
    │ │ │ +      deprecated_bittyrant_with_no_uplimit,
    │ │ │ +      too_few_outgoing_ports,
    │ │ │ +      too_few_file_descriptors,
    │ │ │ +      num_warnings,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::performance_warning;
    │ │ │ +   performance_warning_t const warning_code;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    enum performance_warning_t

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    outstanding_disk_buffer_limit_reached0This warning means that the number of bytes queued to be written to disk │ │ │ +exceeds the max disk byte queue setting (settings_pack::max_queued_disk_bytes). │ │ │ +This might restrict the download rate, by not queuing up enough write jobs │ │ │ +to the disk I/O thread. When this alert is posted, peer connections are │ │ │ +temporarily stopped from downloading, until the queued disk bytes have fallen │ │ │ +below the limit again. Unless your max_queued_disk_bytes setting is already │ │ │ +high, you might want to increase it to get better performance.
    outstanding_request_limit_reached1This is posted when libtorrent would like to send more requests to a peer, │ │ │ +but it's limited by settings_pack::max_out_request_queue. The queue length │ │ │ +libtorrent is trying to achieve is determined by the download rate and the │ │ │ +assumed round-trip-time (settings_pack::request_queue_time). The assumed │ │ │ +round-trip-time is not limited to just the network RTT, but also the remote disk │ │ │ +access time and message handling time. It defaults to 3 seconds. The target number │ │ │ +of outstanding requests is set to fill the bandwidth-delay product (assumed RTT │ │ │ +times download rate divided by number of bytes per request). When this alert │ │ │ +is posted, there is a risk that the number of outstanding requests is too low │ │ │ +and limits the download rate. You might want to increase the max_out_request_queue │ │ │ +setting.
    upload_limit_too_low2This warning is posted when the amount of TCP/IP overhead is greater than the │ │ │ +upload rate limit. When this happens, the TCP/IP overhead is caused by a much │ │ │ +faster download rate, triggering TCP ACK packets. These packets eat into the │ │ │ +rate limit specified to libtorrent. When the overhead traffic is greater than │ │ │ +the rate limit, libtorrent will not be able to send any actual payload, such │ │ │ +as piece requests. This means the download rate will suffer, and new requests │ │ │ +can be sent again. There will be an equilibrium where the download rate, on │ │ │ +average, is about 20 times the upload rate limit. If you want to maximize the │ │ │ +download rate, increase the upload rate limit above 5% of your download capacity.
    download_limit_too_low3This is the same warning as upload_limit_too_low but referring to the download │ │ │ +limit instead of upload. This suggests that your download rate limit is much lower │ │ │ +than your upload capacity. Your upload rate will suffer. To maximize upload rate, │ │ │ +make sure your download rate limit is above 5% of your upload capacity.
    send_buffer_watermark_too_low4

    We're stalled on the disk. We want to write to the socket, and we can write │ │ │ +but our send buffer is empty, waiting to be refilled from the disk. │ │ │ +This either means the disk is slower than the network connection │ │ │ +or that our send buffer watermark is too small, because we can │ │ │ +send it all before the disk gets back to us. │ │ │ +The number of bytes that we keep outstanding, requested from the disk, is calculated │ │ │ +as follows:

    │ │ │ +
    │ │ │ +min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark))
    │ │ │ +
    │ │ │ +

    If you receive this alert, you might want to either increase your send_buffer_watermark │ │ │ +or send_buffer_watermark_factor.

    │ │ │ +
    too_many_optimistic_unchoke_slots5If the half (or more) of all upload slots are set as optimistic unchoke slots, this │ │ │ +warning is issued. You probably want more regular (rate based) unchoke slots.
    too_high_disk_queue_limit6If the disk write queue ever grows larger than half of the cache size, this warning │ │ │ +is posted. The disk write queue eats into the total disk cache and leaves very little │ │ │ +left for the actual cache. This causes the disk cache to oscillate in evicting large │ │ │ +portions of the cache before allowing peers to download any more, onto the disk write │ │ │ +queue. Either lower max_queued_disk_bytes or increase cache_size.
    aio_limit_reached7 
    deprecated_bittyrant_with_no_uplimit8 
    too_few_outgoing_ports9This is generated if outgoing peer connections are failing because of address in use │ │ │ +errors, indicating that settings_pack::outgoing_ports is set and is too small of │ │ │ +a range. Consider not using the outgoing_ports setting at all, or widen the range to │ │ │ +include more ports.
    too_few_file_descriptors10 
    num_warnings11 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    state_changed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    Generated whenever a torrent changes its state.

    │ │ │ +
    │ │ │ +struct state_changed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   torrent_status::state_t const state;
    │ │ │ +   torrent_status::state_t const prev_state;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    state
    │ │ │ +
    the new state of the torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    prev_state
    │ │ │ +
    the previous state.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    tracker_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated on tracker time outs, premature disconnects, │ │ │ +invalid response or a HTTP response other than "200 OK". From the alert │ │ │ +you can get the handle to the torrent the tracker belongs to.

    │ │ │ +
    │ │ │ +struct tracker_error_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* failure_reason () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::tracker | alert_category::error;
    │ │ │ +   int const times_in_row;
    │ │ │ +   error_code const error;
    │ │ │ +   operation_t op;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    failure_reason()

    │ │ │ +
    │ │ │ +char const* failure_reason () const;
    │ │ │ +
    │ │ │ +

    if the tracker sent a "failure reason" string, it will be returned │ │ │ +here.

    │ │ │ +[report issue]
    │ │ │ +
    times_in_row
    │ │ │ +
    This member says how many times in a row this tracker has failed.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error code indicating why the tracker announce failed. If it is │ │ │ +is lt::errors::tracker_failure the failure_reason() might contain │ │ │ +a more detailed description of why the tracker rejected the request. │ │ │ +HTTP status codes indicating errors are also set in this field.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    tracker_warning_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is triggered if the tracker reply contains a warning field. │ │ │ +Usually this means that the tracker announce was successful, but the │ │ │ +tracker has a message to the client.

    │ │ │ +
    │ │ │ +struct tracker_warning_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* warning_message () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::tracker | alert_category::error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    warning_message()

    │ │ │ +
    │ │ │ +char const* warning_message () const;
    │ │ │ +
    │ │ │ +

    the message associated with this warning

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    scrape_reply_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a scrape request succeeds.

    │ │ │ +
    │ │ │ +struct scrape_reply_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::tracker;
    │ │ │ +   int const incomplete;
    │ │ │ +   int const complete;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    incomplete complete
    │ │ │ +
    the data returned in the scrape response. These numbers │ │ │ +may be -1 if the response was malformed.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    scrape_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    If a scrape request fails, this alert is generated. This might be due │ │ │ +to the tracker timing out, refusing connection or returning an http response │ │ │ +code indicating an error.

    │ │ │ +
    │ │ │ +struct scrape_failed_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* error_message () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::tracker | alert_category::error;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    error_message()

    │ │ │ +
    │ │ │ +char const* error_message () const;
    │ │ │ +
    │ │ │ +

    if the error indicates there is an associated message, this returns │ │ │ +that message. Otherwise and empty string.

    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error itself. This may indicate that the tracker sent an error │ │ │ +message (error::tracker_failure), in which case it can be │ │ │ +retrieved by calling error_message().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    tracker_reply_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is only for informational purpose. It is generated when a tracker announce │ │ │ +succeeds. It is generated regardless what kind of tracker was used, be it UDP, HTTP or │ │ │ +the DHT.

    │ │ │ +
    │ │ │ +struct tracker_reply_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::tracker;
    │ │ │ +   int const num_peers;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_peers
    │ │ │ +
    tells how many peers the tracker returned in this response. This is │ │ │ +not expected to be greater than the num_want settings. These are not necessarily │ │ │ +all new peers, some of them may already be connected.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_reply_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated each time the DHT receives peers from a node. num_peers │ │ │ +is the number of peers we received in this packet. Typically these packets are │ │ │ +received from multiple DHT nodes, and so the alerts are typically generated │ │ │ +a few at a time.

    │ │ │ +
    │ │ │ +struct dht_reply_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht | alert_category::tracker;
    │ │ │ +   int const num_peers;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    tracker_announce_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated each time a tracker announce is sent (or attempted to be sent). │ │ │ +There are no extra data members in this alert. The url can be found in the base class │ │ │ +however.

    │ │ │ +
    │ │ │ +struct tracker_announce_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::tracker;
    │ │ │ +   event_t const event;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    event
    │ │ │ +
    specifies what event was sent to the tracker. See event_t.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    hash_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a finished piece fails its hash check. You can get the handle │ │ │ +to the torrent which got the failed piece and the index of the piece itself from the alert.

    │ │ │ +
    │ │ │ +struct hash_failed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    peer_ban_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a peer is banned because it has sent too many corrupt pieces │ │ │ +to us. ip is the endpoint to the peer that was banned.

    │ │ │ +
    │ │ │ +struct peer_ban_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    peer_unsnubbed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a peer is un-snubbed. Essentially when it was snubbed for stalling │ │ │ +sending data, and now it started sending data again.

    │ │ │ +
    │ │ │ +struct peer_unsnubbed_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    peer_snubbed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a peer is snubbed, when it stops sending data when we request │ │ │ +it.

    │ │ │ +
    │ │ │ +struct peer_snubbed_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    peer_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer │ │ │ +will be disconnected, but you get its ip address from the alert, to identify it.

    │ │ │ +
    │ │ │ +struct peer_error_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +   operation_t op;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    a 0-terminated string of the low-level operation that failed, or nullptr if │ │ │ +there was no low level disk operation.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    tells you what error caused this alert.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    peer_connect_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted every time an incoming peer connection both │ │ │ +successfully passes the protocol handshake and is associated with a │ │ │ +torrent, or an outgoing peer connection attempt succeeds. For arbitrary │ │ │ +incoming connections, see incoming_connection_alert.

    │ │ │ +
    │ │ │ +struct peer_connect_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   enum direction_t
    │ │ │ +   {
    │ │ │ +      in,
    │ │ │ +      out,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::connect;
    │ │ │ +   direction_t direction;
    │ │ │ +   socket_type_t socket_type;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    enum direction_t

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    in0 
    out1 
    │ │ │ +[report issue]
    │ │ │ +
    direction
    │ │ │ +
    Tells you if the peer was incoming or outgoing
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    peer_disconnected_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a peer is disconnected for any reason (other than the ones │ │ │ +covered by peer_error_alert ).

    │ │ │ +
    │ │ │ +struct peer_disconnected_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::connect;
    │ │ │ +   socket_type_t const socket_type;
    │ │ │ +   operation_t const op;
    │ │ │ +   error_code const error;
    │ │ │ +   close_reason_t const reason;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    socket_type
    │ │ │ +
    the kind of socket this peer was connected over
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    the operation or level where the error occurred. Specified as an │ │ │ +value from the operation_t enum. Defined in operations.hpp.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    tells you what error caused peer to disconnect.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    reason
    │ │ │ +
    the reason the peer disconnected (if specified)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    invalid_request_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is a debug alert that is generated by an incoming invalid piece request. │ │ │ +ip is the address of the peer and the request is the actual incoming │ │ │ +request from the peer. See peer_request for more info.

    │ │ │ +
    │ │ │ +struct invalid_request_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +   peer_request const request;
    │ │ │ +   bool const we_have;
    │ │ │ +   bool const peer_interested;
    │ │ │ +   bool const withheld;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    request
    │ │ │ +
    the request we received from the peer
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    we_have
    │ │ │ +
    true if we have this piece
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    peer_interested
    │ │ │ +
    true if the peer indicated that it was interested to download before │ │ │ +sending the request
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    withheld
    │ │ │ +
    if this is true, the peer is not allowed to download this piece because │ │ │ +of super-seeding rules.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_finished_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a torrent switches from being a downloader to a seed. │ │ │ +It will only be generated once per torrent. It contains a torrent_handle to the │ │ │ +torrent in question.

    │ │ │ +
    │ │ │ +struct torrent_finished_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_finished_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is posted every time a piece completes downloading │ │ │ +and passes the hash check. This alert derives from torrent_alert │ │ │ +which contains the torrent_handle to the torrent the piece belongs to. │ │ │ +Note that being downloaded and passing the hash check may happen before │ │ │ +the piece is also fully flushed to disk. So torrent_handle::have_piece() │ │ │ +may still return false

    │ │ │ +
    │ │ │ +struct piece_finished_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    piece_index
    │ │ │ +
    the index of the piece that finished
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    request_dropped_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a peer rejects or ignores a piece request.

    │ │ │ +
    │ │ │ +struct request_dropped_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   int const block_index;
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    block_timeout_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a block request times out.

    │ │ │ +
    │ │ │ +struct block_timeout_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   int const block_index;
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    block_finished_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a block request receives a response.

    │ │ │ +
    │ │ │ +struct block_finished_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   int const block_index;
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    block_downloading_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a block request is sent to a peer.

    │ │ │ +
    │ │ │ +struct block_downloading_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   int const block_index;
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    unwanted_block_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a block is received that was not requested or │ │ │ +whose request timed out.

    │ │ │ +
    │ │ │ +struct unwanted_block_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +   int const block_index;
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    storage_moved_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    The storage_moved_alert is generated when all the disk IO has │ │ │ +completed and the files have been moved, as an effect of a call to │ │ │ +torrent_handle::move_storage. This is useful to synchronize with the │ │ │ +actual disk. The storage_path() member return the new path of the │ │ │ +storage.

    │ │ │ +
    │ │ │ +struct storage_moved_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* storage_path () const;
    │ │ │ +   char const* old_path () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    storage_path() old_path()

    │ │ │ +
    │ │ │ +char const* storage_path () const;
    │ │ │ +char const* old_path () const;
    │ │ │ +
    │ │ │ +

    the path the torrent was moved to and from, respectively.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    storage_moved_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    The storage_moved_failed_alert is generated when an attempt to move the storage, │ │ │ +via torrent_handle::move_storage(), fails.

    │ │ │ +
    │ │ │ +struct storage_moved_failed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* file_path () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +   error_code const error;
    │ │ │ +   operation_t op;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    file_path()

    │ │ │ +
    │ │ │ +char const* file_path () const;
    │ │ │ +
    │ │ │ +

    If the error happened for a specific file, this returns its path.

    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    this indicates what underlying operation caused the error
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    torrent_deleted_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a request to delete the files of a torrent complete.

    │ │ │ +

    This alert is posted in the alert_category::storage category, and that bit │ │ │ +needs to be set in the alert_mask.

    │ │ │ +
    │ │ │ +struct torrent_deleted_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +   info_hash_t info_hashes;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    info_hashes
    │ │ │ +
    The info-hash of the torrent that was just deleted. Most of │ │ │ +the time the torrent_handle in the torrent_alert will be invalid by the time │ │ │ +this alert arrives, since the torrent is being deleted. The info_hashes member │ │ │ +is hence the main way of identifying which torrent just completed the delete.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_delete_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a request to delete the files of a torrent fails. │ │ │ +Just removing a torrent from the session cannot fail

    │ │ │ +
    │ │ │ +struct torrent_delete_failed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage
    │ │ │ +   | alert_category::error;
    │ │ │ +   error_code const error;
    │ │ │ +   info_hash_t info_hashes;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    tells you why it failed.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    info_hashes
    │ │ │ +
    the info hash of the torrent whose files failed to be deleted
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    save_resume_data_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated as a response to a torrent_handle::save_resume_data request. │ │ │ +It is generated once the disk IO thread is done writing the state for this torrent.

    │ │ │ +
    │ │ │ +struct save_resume_data_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +   add_torrent_params params;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    params
    │ │ │ +

    the params object is populated with the torrent file whose resume │ │ │ +data was saved. It is suitable to be:

    │ │ │ + │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    save_resume_data_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated instead of save_resume_data_alert if there was an error │ │ │ +generating the resume data. error describes what went wrong.

    │ │ │ +
    │ │ │ +struct save_resume_data_failed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage
    │ │ │ +   | alert_category::error;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error code from the resume_data failure
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_paused_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated as a response to a torrent_handle::pause request. It is │ │ │ +generated once all disk IO is complete and the files in the torrent have been closed. │ │ │ +This is useful for synchronizing with the disk.

    │ │ │ +
    │ │ │ +struct torrent_paused_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_resumed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated as a response to a torrent_handle::resume() request. It is │ │ │ +generated when a torrent goes from a paused state to an active state.

    │ │ │ +
    │ │ │ +struct torrent_resumed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_checked_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when a torrent completes checking. i.e. when it transitions │ │ │ +out of the checking files state into a state where it is ready to start downloading

    │ │ │ +
    │ │ │ +struct torrent_checked_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    url_seed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a HTTP seed name lookup fails.

    │ │ │ +
    │ │ │ +struct url_seed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* server_url () const;
    │ │ │ +   char const* error_message () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer | alert_category::error;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    server_url()

    │ │ │ +
    │ │ │ +char const* server_url () const;
    │ │ │ +
    │ │ │ +

    the URL the error is associated with

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    error_message()

    │ │ │ +
    │ │ │ +char const* error_message () const;
    │ │ │ +
    │ │ │ +

    in case the web server sent an error message, this function returns │ │ │ +it.

    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error the web seed encountered. If this is not set, the server │ │ │ +sent an error message, call error_message().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    file_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    If the storage fails to read or write files that it needs access to, this alert is │ │ │ +generated and the torrent is paused.

    │ │ │ +
    │ │ │ +struct file_error_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* filename () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status
    │ │ │ +   | alert_category::storage;
    │ │ │ +   error_code const error;
    │ │ │ +   operation_t op;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    filename()

    │ │ │ +
    │ │ │ +char const* filename () const;
    │ │ │ +
    │ │ │ +

    the file that experienced the error

    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error code describing the error.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    indicates which underlying operation caused the error
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    metadata_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when the metadata has been completely received and the info-hash │ │ │ +failed to match it. i.e. the metadata that was received was corrupt. libtorrent will │ │ │ +automatically retry to fetch it in this case. This is only relevant when running a │ │ │ +torrent-less download, with the metadata extension provided by libtorrent.

    │ │ │ +
    │ │ │ +struct metadata_failed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    indicates what failed when parsing the metadata. This error is │ │ │ +what's returned from lazy_bdecode().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    metadata_received_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when the metadata has been completely received and the torrent │ │ │ +can start downloading. It is not generated on torrents that are started with metadata, but │ │ │ +only those that needs to download it from peers (via ut_metadata).

    │ │ │ +

    There are no additional data members in this alert.

    │ │ │ +

    Typically, when receiving this alert, you would want to trigger saving │ │ │ +its resume data. You do that by calling save_resume_data() on the torrent │ │ │ +handle, like this: │ │ │ +.. code:: c++

    │ │ │ +
    │ │ │ +torrent_handle h = alert->handle; │ │ │ +h.save_resume_data(torrent_handle::save_info_dict);
    │ │ │ +

    In the handler for the save_resume_alert, you can save the resume data │ │ │ +but also a copy of torrent file: │ │ │ +.. code:: c++

    │ │ │ +
    │ │ │ +save_resume_data_alert* alert = ...; │ │ │ +std::vector<char> buf = write_resume_data_buf(alert->params); │ │ │ +std::ofstream f("resume-data"); │ │ │ +f.write(buf.data(), buf.size());
    │ │ │ +

    If writing a .torrent file that may be a v2 torrent and may not yet have │ │ │ +downloaded the piece layers from its peers, you need to specify the │ │ │ +allow_missing_piece_layer flag.

    │ │ │ + │ │ │ +
    │ │ │ +struct metadata_received_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    udp_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when there is an error on a UDP socket. The │ │ │ +UDP sockets are used for all uTP, DHT and UDP tracker traffic. They are │ │ │ +global to the session.

    │ │ │ +
    │ │ │ +struct udp_error_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │ +   operation_t operation;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    endpoint
    │ │ │ +
    the source address associated with the error (if any)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    operation
    │ │ │ +
    the operation that failed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error code describing the error
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    external_ip_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    Whenever libtorrent learns about the machines external IP, this alert is │ │ │ +generated. The external IP address can be acquired from the tracker (if it │ │ │ +supports that) or from peers that supports the extension protocol. │ │ │ +The address can be accessed through the external_address member.

    │ │ │ +
    │ │ │ +struct external_ip_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   aux::noexcept_movable<address> external_address;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    external_address
    │ │ │ +
    the IP address that is believed to be our external IP
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    listen_failed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when none of the ports, given in the port range, to │ │ │ +session can be opened for listening. The listen_interface member is the │ │ │ +interface that failed, error is the error code describing the failure.

    │ │ │ +

    In the case an endpoint was created before generating the alert, it is │ │ │ +represented by address and port. The combinations of socket type │ │ │ +and operation in which such address and port are not valid are: │ │ │ +accept - i2p │ │ │ +accept - socks5 │ │ │ +enum_if - tcp

    │ │ │ +

    libtorrent may sometimes try to listen on port 0, if all other ports failed. │ │ │ +Port 0 asks the operating system to pick a port that's free). If that fails │ │ │ +you may see a listen_failed_alert with port 0 even if you didn't ask to │ │ │ +listen on it.

    │ │ │ +
    │ │ │ +struct listen_failed_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* listen_interface () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status | alert_category::error;
    │ │ │ +   error_code const error;
    │ │ │ +   operation_t op;
    │ │ │ +   lt::socket_type_t const socket_type;
    │ │ │ +   aux::noexcept_movable<lt::address> address;
    │ │ │ +   int const port;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    listen_interface()

    │ │ │ +
    │ │ │ +char const* listen_interface () const;
    │ │ │ +
    │ │ │ +

    the network device libtorrent attempted to listen on, or the IP address

    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error the system returned
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    the underlying operation that failed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    socket_type
    │ │ │ +
    the type of listen socket this alert refers to.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    address
    │ │ │ +
    the address libtorrent attempted to listen on │ │ │ +see alert documentation for validity of this value
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    port
    │ │ │ +
    the port libtorrent attempted to listen on │ │ │ +see alert documentation for validity of this value
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    listen_succeeded_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when the listen port succeeds to be opened on a │ │ │ +particular interface. address and port is the endpoint that │ │ │ +successfully was opened for listening.

    │ │ │ +
    │ │ │ +struct listen_succeeded_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   aux::noexcept_movable<lt::address> address;
    │ │ │ +   int const port;
    │ │ │ +   lt::socket_type_t const socket_type;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    address
    │ │ │ +
    the address libtorrent ended up listening on. This address │ │ │ +refers to the local interface.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    port
    │ │ │ +
    the port libtorrent ended up listening on.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    socket_type
    │ │ │ +
    the type of listen socket this alert refers to.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    portmap_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a NAT router was successfully found but some │ │ │ +part of the port mapping request failed. It contains a text message that │ │ │ +may help the user figure out what is wrong. This alert is not generated in │ │ │ +case it appears the client is not running on a NAT:ed network or if it │ │ │ +appears there is no NAT router that can be remote controlled to add port │ │ │ +mappings.

    │ │ │ +
    │ │ │ +struct portmap_error_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::port_mapping
    │ │ │ +   | alert_category::error;
    │ │ │ +   port_mapping_t const mapping;
    │ │ │ +   portmap_transport map_transport;
    │ │ │ +   aux::noexcept_movable<address> local_address;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    mapping
    │ │ │ +
    refers to the mapping index of the port map that failed, i.e. │ │ │ +the index returned from add_mapping().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    map_transport
    │ │ │ +
    UPnP or NAT-PMP
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    local_address
    │ │ │ +
    the local network the port mapper is running on
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    tells you what failed.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    portmap_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a NAT router was successfully found and │ │ │ +a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP │ │ │ +capable router, this is typically generated once when mapping the TCP │ │ │ +port and, if DHT is enabled, when the UDP port is mapped.

    │ │ │ +
    │ │ │ +struct portmap_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::port_mapping;
    │ │ │ +   port_mapping_t const mapping;
    │ │ │ +   int const external_port;
    │ │ │ +   portmap_protocol const map_protocol;
    │ │ │ +   portmap_transport const map_transport;
    │ │ │ +   aux::noexcept_movable<address> local_address;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    mapping
    │ │ │ +
    refers to the mapping index of the port map that failed, i.e. │ │ │ +the index returned from add_mapping().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    external_port
    │ │ │ +
    the external port allocated for the mapping.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    local_address
    │ │ │ +
    the local network the port mapper is running on
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    portmap_log_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated to log informational events related to either │ │ │ +UPnP or NAT-PMP. They contain a log line and the type (0 = NAT-PMP │ │ │ +and 1 = UPnP). Displaying these messages to an end user is only useful │ │ │ +for debugging the UPnP or NAT-PMP implementation. This alert is only │ │ │ +posted if the alert_category::port_mapping_log flag is enabled in │ │ │ +the alert mask.

    │ │ │ +
    │ │ │ +struct portmap_log_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* log_message () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::port_mapping_log;
    │ │ │ +   portmap_transport const map_transport;
    │ │ │ +   aux::noexcept_movable<address> local_address;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    log_message()

    │ │ │ +
    │ │ │ +char const* log_message () const;
    │ │ │ +
    │ │ │ +

    the message associated with this log line

    │ │ │ +[report issue]
    │ │ │ +
    local_address
    │ │ │ +
    the local network the port mapper is running on
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    fastresume_rejected_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a fast resume file has been passed to │ │ │ +add_torrent() but the files on disk did not match the fast resume file. │ │ │ +The error_code explains the reason why the resume file was rejected.

    │ │ │ +
    │ │ │ +struct fastresume_rejected_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* file_path () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status
    │ │ │ +   | alert_category::error;
    │ │ │ +   error_code error;
    │ │ │ +   operation_t op;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    file_path()

    │ │ │ +
    │ │ │ +char const* file_path () const;
    │ │ │ +
    │ │ │ +

    If the error happened to a specific file, this returns the path to it.

    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    the underlying operation that failed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    peer_blocked_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when an incoming peer connection, or a peer that's about to be added │ │ │ +to our peer list, is blocked for some reason. This could be any of:

    │ │ │ +
      │ │ │ +
    • the IP filter
    • │ │ │ +
    • i2p mixed mode restrictions (a normal peer is not allowed on an i2p swarm)
    • │ │ │ +
    • the port filter
    • │ │ │ +
    • the peer has a low port and no_connect_privileged_ports is enabled
    • │ │ │ +
    • the protocol of the peer is blocked (uTP/TCP blocking)
    • │ │ │ +
    │ │ │ +
    │ │ │ +struct peer_blocked_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   enum reason_t
    │ │ │ +   {
    │ │ │ +      ip_filter,
    │ │ │ +      port_filter,
    │ │ │ +      i2p_mixed,
    │ │ │ +      privileged_ports,
    │ │ │ +      utp_disabled,
    │ │ │ +      tcp_disabled,
    │ │ │ +      invalid_local_interface,
    │ │ │ +      ssrf_mitigation,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::ip_block;
    │ │ │ +   int const reason;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    enum reason_t

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    ip_filter0 
    port_filter1 
    i2p_mixed2 
    privileged_ports3 
    utp_disabled4 
    tcp_disabled5 
    invalid_local_interface6 
    ssrf_mitigation7 
    │ │ │ +[report issue]
    │ │ │ +
    reason
    │ │ │ +
    the reason for the peer being blocked. Is one of the values from the │ │ │ +reason_t enum.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    dht_announce_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a DHT node announces to an info-hash on our │ │ │ +DHT node. It belongs to the alert_category::dht category.

    │ │ │ +
    │ │ │ +struct dht_announce_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   aux::noexcept_movable<address> ip;
    │ │ │ +   int port;
    │ │ │ +   sha1_hash info_hash;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_get_peers_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when a DHT node sends a get_peers message to │ │ │ +our DHT node. It belongs to the alert_category::dht category.

    │ │ │ +
    │ │ │ +struct dht_get_peers_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   sha1_hash info_hash;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    cache_flushed_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when the disk cache has been flushed for a specific │ │ │ +torrent as a result of a call to torrent_handle::flush_cache(). This │ │ │ +alert belongs to the alert_category::storage category, which must be │ │ │ +enabled to let this alert through. The alert is also posted when removing │ │ │ +a torrent from the session, once the outstanding cache flush is complete │ │ │ +and the torrent does no longer have any files open.

    │ │ │ +
    │ │ │ +struct cache_flushed_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    lsd_peer_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when we receive a local service discovery message │ │ │ +from a peer for a torrent we're currently participating in.

    │ │ │ +
    │ │ │ +struct lsd_peer_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    trackerid_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted whenever a tracker responds with a trackerid. │ │ │ +The tracker ID is like a cookie. libtorrent will store the tracker ID │ │ │ +for this tracker and repeat it in subsequent announces.

    │ │ │ +
    │ │ │ +struct trackerid_alert final : tracker_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* tracker_id () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    tracker_id()

    │ │ │ +
    │ │ │ +char const* tracker_id () const;
    │ │ │ +
    │ │ │ +

    The tracker ID returned by the tracker

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    dht_bootstrap_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when the initial DHT bootstrap is done.

    │ │ │ +
    │ │ │ +struct dht_bootstrap_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is posted whenever a torrent is transitioned into the error state. │ │ │ +If the error code is duplicate_torrent (error_code_enum) error, it suggests two magnet │ │ │ +links ended up resolving to the same hybrid torrent. For more details, │ │ │ +see BitTorrent v2 torrents.

    │ │ │ +
    │ │ │ +struct torrent_error_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* filename () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error | alert_category::status;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    filename()

    │ │ │ +
    │ │ │ +char const* filename () const;
    │ │ │ +
    │ │ │ +

    the filename (or object) the error occurred on.

    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    specifies which error the torrent encountered.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    torrent_need_cert_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is always posted for SSL torrents. This is a reminder to the client that │ │ │ +the torrent won't work unless torrent_handle::set_ssl_certificate() is called with │ │ │ +a valid certificate. Valid certificates MUST be signed by the SSL certificate │ │ │ +in the .torrent file.

    │ │ │ +
    │ │ │ +struct torrent_need_cert_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    incoming_connection_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    The incoming connection alert is posted every time we successfully accept │ │ │ +an incoming connection, through any mean. The most straight-forward ways │ │ │ +of accepting incoming connections are through the TCP listen socket and │ │ │ +the UDP listen socket for uTP sockets. However, connections may also be │ │ │ +accepted through a Socks5 or i2p listen socket, or via an SSL listen │ │ │ +socket.

    │ │ │ +
    │ │ │ +struct incoming_connection_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer;
    │ │ │ +   socket_type_t socket_type;
    │ │ │ +   aux::noexcept_movable<tcp::endpoint> endpoint;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    socket_type
    │ │ │ +
    tells you what kind of socket the connection was accepted
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    endpoint
    │ │ │ +
    is the IP address and port the connection came from.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_torrent_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is always posted when a torrent was attempted to be added │ │ │ +and contains the return status of the add operation. The torrent handle of the new │ │ │ +torrent can be found as the handle member in the base class. If adding │ │ │ +the torrent failed, error contains the error code.

    │ │ │ +
    │ │ │ +struct add_torrent_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   add_torrent_params params;
    │ │ │ +   error_code error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    params
    │ │ │ +

    This contains copies of the most important fields from the original │ │ │ +add_torrent_params object, passed to add_torrent() or │ │ │ +async_add_torrent(). Specifically, these fields are copied:

    │ │ │ +
      │ │ │ +
    • version
    • │ │ │ +
    • ti
    • │ │ │ +
    • name
    • │ │ │ +
    • save_path
    • │ │ │ +
    • userdata
    • │ │ │ +
    • tracker_id
    • │ │ │ +
    • flags
    • │ │ │ +
    • info_hash
    • │ │ │ +
    │ │ │ +

    the info_hash field will be updated with the info-hash of the torrent │ │ │ +specified by ti.

    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    set to the error, if one occurred while adding the torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    state_update_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is only posted when requested by the user, by calling │ │ │ +session::post_torrent_updates() on the session. It contains the torrent │ │ │ +status of all torrents that changed since last time this message was │ │ │ +posted. Its category is alert_category::status, but it's not subject to │ │ │ +filtering, since it's only manually posted anyway.

    │ │ │ +
    │ │ │ +struct state_update_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   std::vector<torrent_status> status;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    status
    │ │ │ +
    contains the torrent status of all torrents that changed since last │ │ │ +time this message was posted. Note that you can map a torrent status │ │ │ +to a specific torrent via its handle member. The receiving end is │ │ │ +suggested to have all torrents sorted by the torrent_handle or hashed │ │ │ +by it, for efficient updates.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    session_stats_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    The session_stats_alert is posted when the user requests session statistics by │ │ │ +calling post_session_stats() on the session object. This alert does not │ │ │ +have a category, since it's only posted in response to an API call. It │ │ │ +is not subject to the alert_mask filter.

    │ │ │ +

    the message() member function returns a string representation of the values that │ │ │ +properly match the line returned in session_stats_header_alert::message().

    │ │ │ +

    this specific output is parsed by tools/parse_session_stats.py │ │ │ +if this is changed, that parser should also be changed

    │ │ │ +
    │ │ │ +struct session_stats_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   span<std::int64_t const> counters () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = {};
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    counters()

    │ │ │ +
    │ │ │ +span<std::int64_t const> counters () const;
    │ │ │ +
    │ │ │ +

    An array are a mix of counters and gauges, which meanings can be │ │ │ +queries via the session_stats_metrics() function on the session. The │ │ │ +mapping from a specific metric to an index into this array is constant │ │ │ +for a specific version of libtorrent, but may differ for other │ │ │ +versions. The intended usage is to request the mapping, i.e. call │ │ │ +session_stats_metrics(), once on startup, and then use that mapping to │ │ │ +interpret these values throughout the process' runtime.

    │ │ │ +

    For more information, see the session statistics section.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    dht_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when something fails in the DHT. This is not necessarily a fatal │ │ │ +error, but it could prevent proper operation

    │ │ │ +
    │ │ │ +struct dht_error_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error | alert_category::dht;
    │ │ │ +   error_code error;
    │ │ │ +   operation_t op;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error code
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    the operation that failed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_immutable_item_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is posted as a response to a call to session::get_item(), │ │ │ +specifically the overload for looking up immutable items in the DHT.

    │ │ │ +
    │ │ │ +struct dht_immutable_item_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   sha1_hash target;
    │ │ │ +   entry item;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    target
    │ │ │ +
    the target hash of the immutable item. This must │ │ │ +match the SHA-1 hash of the bencoded form of item.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    item
    │ │ │ +
    the data for this item
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_mutable_item_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is posted as a response to a call to session::get_item(), │ │ │ +specifically the overload for looking up mutable items in the DHT.

    │ │ │ +
    │ │ │ +struct dht_mutable_item_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   std::array<char, 32> key;
    │ │ │ +   std::array<char, 64> signature;
    │ │ │ +   std::int64_t seq;
    │ │ │ +   std::string salt;
    │ │ │ +   entry item;
    │ │ │ +   bool authoritative;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    key
    │ │ │ +
    the public key that was looked up
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    signature
    │ │ │ +
    the signature of the data. This is not the signature of the │ │ │ +plain encoded form of the item, but it includes the sequence number │ │ │ +and possibly the hash as well. See the dht_store document for more │ │ │ +information. This is primarily useful for echoing back in a store │ │ │ +request.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    seq
    │ │ │ +
    the sequence number of this item
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    salt
    │ │ │ +
    the salt, if any, used to lookup and store this item. If no │ │ │ +salt was used, this is an empty string
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    item
    │ │ │ +
    the data for this item
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    authoritative
    │ │ │ +
    the last response for mutable data is authoritative.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_put_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this is posted when a DHT put operation completes. This is useful if the │ │ │ +client is waiting for a put to complete before shutting down for instance.

    │ │ │ +
    │ │ │ +struct dht_put_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   sha1_hash target;
    │ │ │ +   std::array<char, 32> public_key;
    │ │ │ +   std::array<char, 64> signature;
    │ │ │ +   std::string salt;
    │ │ │ +   std::int64_t seq;
    │ │ │ +   int num_success;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    target
    │ │ │ +
    the target hash the item was stored under if this was an immutable │ │ │ +item.
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    public_key signature salt seq
    │ │ │ +
    if a mutable item was stored, these are the public key, signature, │ │ │ +salt and sequence number the item was stored under.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_success
    │ │ │ +
    DHT put operation usually writes item to k nodes, maybe the node │ │ │ +is stale so no response, or the node doesn't support 'put', or the │ │ │ +token for write is out of date, etc. num_success is the number of │ │ │ +successful responses we got from the puts.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    i2p_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is used to report errors in the i2p SAM connection

    │ │ │ +
    │ │ │ +struct i2p_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   error_code error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error that occurred in the i2p SAM connection
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_outgoing_get_peers_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is generated when we send a get_peers request │ │ │ +It belongs to the alert_category::dht category.

    │ │ │ +
    │ │ │ +struct dht_outgoing_get_peers_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   sha1_hash info_hash;
    │ │ │ +   sha1_hash obfuscated_info_hash;
    │ │ │ +   aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    info_hash
    │ │ │ +
    the info_hash of the torrent we're looking for peers for.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    obfuscated_info_hash
    │ │ │ +
    if this was an obfuscated lookup, this is the info-hash target │ │ │ +actually sent to the node.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    endpoint
    │ │ │ +
    the endpoint we're sending this query to
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    log_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted by some session wide event. Its main purpose is │ │ │ +trouble shooting and debugging. It's not enabled by the default alert │ │ │ +mask and is enabled by the alert_category::session_log bit. │ │ │ +Furthermore, it's by default disabled as a build configuration.

    │ │ │ +
    │ │ │ +struct log_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* log_message () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::session_log;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    log_message()

    │ │ │ +
    │ │ │ +char const* log_message () const;
    │ │ │ +
    │ │ │ +

    returns the log message

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    torrent_log_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted by torrent wide events. It's meant to be used for │ │ │ +trouble shooting and debugging. It's not enabled by the default alert │ │ │ +mask and is enabled by the alert_category::torrent_log bit. By │ │ │ +default it is disabled as a build configuration.

    │ │ │ +
    │ │ │ +struct torrent_log_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* log_message () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::torrent_log;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    log_message()

    │ │ │ +
    │ │ │ +char const* log_message () const;
    │ │ │ +
    │ │ │ +

    returns the log message

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    peer_log_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted by events specific to a peer. It's meant to be used │ │ │ +for trouble shooting and debugging. It's not enabled by the default alert │ │ │ +mask and is enabled by the alert_category::peer_log bit. By │ │ │ +default it is disabled as a build configuration.

    │ │ │ +
    │ │ │ +struct peer_log_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* log_message () const;
    │ │ │ +
    │ │ │ +   enum direction_t
    │ │ │ +   {
    │ │ │ +      incoming_message,
    │ │ │ +      outgoing_message,
    │ │ │ +      incoming,
    │ │ │ +      outgoing,
    │ │ │ +      info,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::peer_log;
    │ │ │ +   event_t event_type;
    │ │ │ +   direction_t direction;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    log_message()

    │ │ │ +
    │ │ │ +char const* log_message () const;
    │ │ │ +
    │ │ │ +

    returns the log message

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum direction_t

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    incoming_message0 
    outgoing_message1 
    incoming2 
    outgoing3 
    info4 
    │ │ │ +[report issue]
    │ │ │ +
    event_type
    │ │ │ +
    enum indicating the kind of event. For messages, this is the │ │ │ +message name.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    lsd_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted if the local service discovery socket fails to start properly. │ │ │ +it's categorized as alert_category::error.

    │ │ │ +
    │ │ │ +struct lsd_error_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   aux::noexcept_movable<address> local_address;
    │ │ │ +   error_code error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    local_address
    │ │ │ +
    the local network the corresponding local service discovery is running │ │ │ +on
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    The error code
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_lookup

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    holds statistics about a current dht_lookup operation. │ │ │ +a DHT lookup is the traversal of nodes, looking up a │ │ │ +set of target nodes in the DHT for retrieving and possibly │ │ │ +storing information in the DHT

    │ │ │ +
    │ │ │ +struct dht_lookup
    │ │ │ +{
    │ │ │ +   char const* type;
    │ │ │ +   int outstanding_requests;
    │ │ │ +   int timeouts;
    │ │ │ +   int responses;
    │ │ │ +   int branch_factor;
    │ │ │ +   int nodes_left;
    │ │ │ +   int last_sent;
    │ │ │ +   int first_timeout;
    │ │ │ +   sha1_hash target;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    type
    │ │ │ +
    string literal indicating which kind of lookup this is
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    outstanding_requests
    │ │ │ +
    the number of outstanding request to individual nodes │ │ │ +this lookup has right now
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    timeouts
    │ │ │ +
    the total number of requests that have timed out so far │ │ │ +for this lookup
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    responses
    │ │ │ +
    the total number of responses we have received for this │ │ │ +lookup so far for this lookup
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    branch_factor
    │ │ │ +
    the branch factor for this lookup. This is the number of │ │ │ +nodes we keep outstanding requests to in parallel by default. │ │ │ +when nodes time out we may increase this.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    nodes_left
    │ │ │ +
    the number of nodes left that could be queries for this │ │ │ +lookup. Many of these are likely to be part of the trail │ │ │ +while performing the lookup and would never end up actually │ │ │ +being queried.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    last_sent
    │ │ │ +
    the number of seconds ago the │ │ │ +last message was sent that's still │ │ │ +outstanding
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    first_timeout
    │ │ │ +
    the number of outstanding requests │ │ │ +that have exceeded the short timeout │ │ │ +and are considered timed out in the │ │ │ +sense that they increased the branch │ │ │ +factor
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    target
    │ │ │ +
    the node-id or info-hash target for this lookup
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_stats_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    contains current DHT state. Posted in response to session::post_dht_stats().

    │ │ │ +
    │ │ │ +struct dht_stats_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = {};
    │ │ │ +   std::vector<dht_lookup> active_requests;
    │ │ │ +   std::vector<dht_routing_bucket> routing_table;
    │ │ │ +   sha1_hash nid;
    │ │ │ +   aux::noexcept_movable<udp::endpoint> local_endpoint;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    active_requests
    │ │ │ +
    a vector of the currently running DHT lookups.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    routing_table
    │ │ │ +
    contains information about every bucket in the DHT routing │ │ │ +table.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    nid
    │ │ │ +
    the node ID of the DHT node instance
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    local_endpoint
    │ │ │ +
    the local socket this DHT node is running on
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    incoming_request_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted every time an incoming request from a peer is accepted and queued │ │ │ +up for being serviced. This alert is only posted if │ │ │ +the alert_category::incoming_request flag is enabled in the alert │ │ │ +mask.

    │ │ │ +
    │ │ │ +struct incoming_request_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::incoming_request;
    │ │ │ +   peer_request req;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    req
    │ │ │ +
    the request this peer sent to us
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_log_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    debug logging of the DHT when alert_category::dht_log is set in the alert │ │ │ +mask.

    │ │ │ +
    │ │ │ +struct dht_log_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   char const* log_message () const;
    │ │ │ +
    │ │ │ +   enum dht_module_t
    │ │ │ +   {
    │ │ │ +      tracker,
    │ │ │ +      node,
    │ │ │ +      routing_table,
    │ │ │ +      rpc_manager,
    │ │ │ +      traversal,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht_log;
    │ │ │ +   dht_module_t module;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    log_message()

    │ │ │ +
    │ │ │ +char const* log_message () const;
    │ │ │ +
    │ │ │ +

    the log message

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum dht_module_t

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    tracker0 
    node1 
    routing_table2 
    rpc_manager3 
    traversal4 
    │ │ │ +[report issue]
    │ │ │ +
    module
    │ │ │ +
    the module, or part, of the DHT that produced this log message.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    dht_pkt_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted every time a DHT message is sent or received. It is │ │ │ +only posted if the alert_category::dht_log alert category is │ │ │ +enabled. It contains a verbatim copy of the message.

    │ │ │ +
    │ │ │ +struct dht_pkt_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   span<char const> pkt_buf () const;
    │ │ │ +
    │ │ │ +   enum direction_t
    │ │ │ +   {
    │ │ │ +      incoming,
    │ │ │ +      outgoing,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht_log;
    │ │ │ +   direction_t direction;
    │ │ │ +   aux::noexcept_movable<udp::endpoint> node;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    pkt_buf()

    │ │ │ +
    │ │ │ +span<char const> pkt_buf () const;
    │ │ │ +
    │ │ │ +

    returns a pointer to the packet buffer and size of the packet, │ │ │ +respectively. This buffer is only valid for as long as the alert itself │ │ │ +is valid, which is owned by libtorrent and reclaimed whenever │ │ │ +pop_alerts() is called on the session.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum direction_t

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    incoming0 
    outgoing1 
    │ │ │ +[report issue]
    │ │ │ +
    direction
    │ │ │ +
    whether this is an incoming or outgoing packet.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    node
    │ │ │ +
    the DHT node we received this packet from, or sent this packet to │ │ │ +(depending on direction).
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    dht_get_peers_reply_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    Posted when we receive a response to a DHT get_peers request.

    │ │ │ +
    │ │ │ +struct dht_get_peers_reply_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   int num_peers () const;
    │ │ │ +   std::vector<tcp::endpoint> peers () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht_operation;
    │ │ │ +   sha1_hash info_hash;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_direct_response_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This is posted exactly once for every call to session_handle::dht_direct_request. │ │ │ +If the request failed, response() will return a default constructed bdecode_node.

    │ │ │ +
    │ │ │ +struct dht_direct_response_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   bdecode_node response () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   client_data_t userdata;
    │ │ │ +   aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    picker_log_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this is posted when one or more blocks are picked by the piece picker, │ │ │ +assuming the verbose piece picker logging is enabled (see │ │ │ +alert_category::picker_log).

    │ │ │ +
    │ │ │ +struct picker_log_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   std::vector<piece_block> blocks () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::picker_log;
    │ │ │ +   static inline constexpr picker_flags_t partial_ratio  = 0_bit;
    │ │ │ +   static inline constexpr picker_flags_t prioritize_partials  = 1_bit;
    │ │ │ +   static inline constexpr picker_flags_t rarest_first_partials  = 2_bit;
    │ │ │ +   static inline constexpr picker_flags_t rarest_first  = 3_bit;
    │ │ │ +   static inline constexpr picker_flags_t reverse_rarest_first  = 4_bit;
    │ │ │ +   static inline constexpr picker_flags_t suggested_pieces  = 5_bit;
    │ │ │ +   static inline constexpr picker_flags_t prio_sequential_pieces  = 6_bit;
    │ │ │ +   static inline constexpr picker_flags_t sequential_pieces  = 7_bit;
    │ │ │ +   static inline constexpr picker_flags_t reverse_pieces  = 8_bit;
    │ │ │ +   static inline constexpr picker_flags_t time_critical  = 9_bit;
    │ │ │ +   static inline constexpr picker_flags_t random_pieces  = 10_bit;
    │ │ │ +   static inline constexpr picker_flags_t prefer_contiguous  = 11_bit;
    │ │ │ +   static inline constexpr picker_flags_t reverse_sequential  = 12_bit;
    │ │ │ +   static inline constexpr picker_flags_t backup1  = 13_bit;
    │ │ │ +   static inline constexpr picker_flags_t backup2  = 14_bit;
    │ │ │ +   static inline constexpr picker_flags_t end_game  = 15_bit;
    │ │ │ +   static inline constexpr picker_flags_t extent_affinity  = 16_bit;
    │ │ │ +   picker_flags_t picker_flags;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    picker_flags
    │ │ │ +
    this is a bitmask of which features were enabled for this particular │ │ │ +pick. The bits are defined in the picker_flags_t enum.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    session_error_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is posted when the session encounters a serious error, │ │ │ +potentially fatal

    │ │ │ +
    │ │ │ +struct session_error_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   error_code const error;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    The error code, if one is associated with this error
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_live_nodes_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted in response to a call to session::dht_live_nodes(). It contains the │ │ │ +live nodes from the DHT routing table of one of the DHT nodes running │ │ │ +locally.

    │ │ │ +
    │ │ │ +struct dht_live_nodes_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   int num_nodes () const;
    │ │ │ +   std::vector<std::pair<sha1_hash, udp::endpoint>> nodes () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │ +   sha1_hash node_id;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    nodes() num_nodes()

    │ │ │ +
    │ │ │ +int num_nodes () const;
    │ │ │ +std::vector<std::pair<sha1_hash, udp::endpoint>> nodes () const;
    │ │ │ +
    │ │ │ +

    the number of nodes in the routing table and the actual nodes.

    │ │ │ +[report issue]
    │ │ │ +
    node_id
    │ │ │ +
    the local DHT node's node-ID this routing table belongs to
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    session_stats_header_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    The session_stats_header alert is posted the first time │ │ │ +post_session_stats() is called

    │ │ │ +

    the message() member function returns a string representation of the │ │ │ +header that properly match the stats values string returned in │ │ │ +session_stats_alert::message().

    │ │ │ +

    this specific output is parsed by tools/parse_session_stats.py │ │ │ +if this is changed, that parser should also be changed

    │ │ │ +
    │ │ │ +struct session_stats_header_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = {};
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_sample_infohashes_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted as a response to a call to session::dht_sample_infohashes() with │ │ │ +the information from the DHT response message.

    │ │ │ +
    │ │ │ +struct dht_sample_infohashes_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   std::vector<sha1_hash> samples () const;
    │ │ │ +   int num_samples () const;
    │ │ │ +   int num_nodes () const;
    │ │ │ +   std::vector<std::pair<sha1_hash, udp::endpoint>> nodes () const;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::dht_operation;
    │ │ │ +   sha1_hash node_id;
    │ │ │ +   aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │ +   time_duration const interval;
    │ │ │ +   int const num_infohashes;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    num_samples() samples()

    │ │ │ +
    │ │ │ +std::vector<sha1_hash> samples () const;
    │ │ │ +int num_samples () const;
    │ │ │ +
    │ │ │ +

    returns the number of info-hashes returned by the node, as well as the │ │ │ +actual info-hashes. num_samples() is more efficient than │ │ │ +samples().size().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    num_nodes()

    │ │ │ +
    │ │ │ +int num_nodes () const;
    │ │ │ +
    │ │ │ +

    The total number of nodes returned by nodes().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    nodes()

    │ │ │ +
    │ │ │ +std::vector<std::pair<sha1_hash, udp::endpoint>> nodes () const;
    │ │ │ +
    │ │ │ +

    This is the set of more DHT nodes returned by the request.

    │ │ │ +

    The information is included so that indexing nodes can perform a key │ │ │ +space traversal with a single RPC per node by adjusting the target │ │ │ +value for each RPC.

    │ │ │ +[report issue]
    │ │ │ +
    node_id
    │ │ │ +
    id of the node the request was sent to (and this response was received from)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    endpoint
    │ │ │ +
    the node the request was sent to (and this response was received from)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    interval
    │ │ │ +
    the interval to wait before making another request to this node
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_infohashes
    │ │ │ +
    This field indicates how many info-hash keys are currently in the node's storage. │ │ │ +If the value is larger than the number of returned samples it indicates that the │ │ │ +indexer may obtain additional samples after waiting out the interval.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    block_uploaded_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    This alert is posted when a block intended to be sent to a peer is placed in the │ │ │ +send buffer. Note that if the connection is closed before the send buffer is sent, │ │ │ +the alert may be posted without the bytes having been sent to the peer. │ │ │ +It belongs to the alert_category::upload category.

    │ │ │ +
    │ │ │ +struct block_uploaded_alert final : peer_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   int const block_index;
    │ │ │ +   piece_index_t const piece_index;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    alerts_dropped_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is posted to indicate to the client that some alerts were │ │ │ +dropped. Dropped meaning that the alert failed to be delivered to the │ │ │ +client. The most common cause of such failure is that the internal alert │ │ │ +queue grew too big (controlled by alert_queue_size).

    │ │ │ +
    │ │ │ +struct alerts_dropped_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +   static_assert (num_alert_types <= abi_alert_count, "need to increase bitset. This is an ABI break");
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   std::bitset<abi_alert_count> dropped_alerts;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    dropped_alerts
    │ │ │ +
    a bitmask indicating which alerts were dropped. Each bit represents the │ │ │ +alert type ID, where bit 0 represents whether any alert of type 0 has │ │ │ +been dropped, and so on.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    socks5_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is posted with SOCKS5 related errors, when a SOCKS5 proxy is │ │ │ +configured. It's enabled with the alert_category::error alert category.

    │ │ │ +
    │ │ │ +struct socks5_alert final : alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static inline constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   error_code error;
    │ │ │ +   operation_t op;
    │ │ │ +   aux::noexcept_movable<tcp::endpoint> ip;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    the operation that failed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    ip
    │ │ │ +
    the endpoint configured as the proxy
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_prio_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when a prioritize_files() or file_priority() update of the file │ │ │ +priorities complete, which requires a round-trip to the disk thread.

    │ │ │ +

    If the disk operation fails this alert won't be posted, but a │ │ │ +file_error_alert is posted instead, and the torrent is stopped.

    │ │ │ +
    │ │ │ +struct file_prio_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +   error_code error;
    │ │ │ +   operation_t op;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error
    │ │ │ +
    the error
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    op
    │ │ │ +
    the operation that failed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    oversized_file_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert may be posted when the initial checking of resume data and files │ │ │ +on disk (just existence, not piece hashes) completes. If a file belonging │ │ │ +to the torrent is found on disk, but is larger than the file in the │ │ │ +torrent, that's when this alert is posted. │ │ │ +the client may want to call truncate_files() in that case, or perhaps │ │ │ +interpret it as a sign that some other file is in the way, that shouldn't │ │ │ +be overwritten.

    │ │ │ +
    │ │ │ +struct oversized_file_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_conflict_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    this alert is posted when two separate torrents (magnet links) resolve to │ │ │ +the same torrent, thus causing the same torrent being added twice. In │ │ │ +that case, both torrents enter an error state with duplicate_torrent │ │ │ +as the error code. This alert is posted containing the metadata. For more │ │ │ +information, see BitTorrent v2 torrents. │ │ │ +The torrent this alert originated from was the one that downloaded the │ │ │ +metadata (i.e. the handle member from the torrent_alert base class).

    │ │ │ +
    │ │ │ +struct torrent_conflict_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::error;
    │ │ │ +   torrent_handle conflicting_torrent;
    │ │ │ +   std::shared_ptr<torrent_info> metadata;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    conflicting_torrent
    │ │ │ +
    the handle to the torrent in conflict. The swarm associated with this │ │ │ +torrent handle did not download the metadata, but the downloaded │ │ │ +metadata collided with this swarm's info-hash.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    metadata
    │ │ │ +
    the metadata that was received by one of the torrents in conflict. │ │ │ +One way to resolve the conflict is to remove both failing torrents │ │ │ +and re-add it using this metadata
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    peer_info_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when torrent_handle::post_peer_info() is called

    │ │ │ +
    │ │ │ +struct peer_info_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   std::vector<lt::peer_info> peer_info;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    peer_info
    │ │ │ +
    the list of the currently connected peers
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_progress_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when torrent_handle::post_file_progress() is called

    │ │ │ +
    │ │ │ +struct file_progress_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::file_progress;
    │ │ │ +   aux::vector<std::int64_t, file_index_t> files;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    files
    │ │ │ +
    the list of the files in the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_info_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when torrent_handle::post_download_queue() is called

    │ │ │ +
    │ │ │ +struct piece_info_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::piece_progress;
    │ │ │ +   std::vector<partial_piece_info> piece_info;
    │ │ │ +   std::vector<block_info> block_data;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    piece_info
    │ │ │ +
    info about pieces being downloaded for the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    block_data
    │ │ │ +
    storage for block_info pointers in partial_piece_info objects
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_availability_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when torrent_handle::post_piece_availability() is called

    │ │ │ +
    │ │ │ +struct piece_availability_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   std::vector<int> piece_availability;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    piece_availability
    │ │ │ +
    info about pieces being downloaded for the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    tracker_list_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when torrent_handle::post_trackers() is called

    │ │ │ +
    │ │ │ +struct tracker_list_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   std::vector<announce_entry> trackers;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    trackers
    │ │ │ +
    list of trackers and their status for the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_priorities_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when torrent_handle::post_file_priorities() is called

    │ │ │ +
    │ │ │ +struct file_priorities_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   std::vector<download_priority_t> priorities;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    priorities
    │ │ │ +
    the download priority of each file in the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_status_alert

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +

    posted when torrent_handle::post_file_status() is called

    │ │ │ +
    │ │ │ +struct file_status_alert final : torrent_alert
    │ │ │ +{
    │ │ │ +   std::string message () const override;
    │ │ │ +
    │ │ │ +   static constexpr alert_category_t static_category  = alert_category::status;
    │ │ │ +   std::vector<open_file_state> state;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    state
    │ │ │ +
    the open-file state of each currently open file in the torrent. │ │ │ +Files that are not open are not included. Each entry's file_index │ │ │ +field identifies which file it refers to.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    alert

    │ │ │ +

    Declared in "libtorrent/alert.hpp"

    │ │ │ +

    The alert class is the base class that specific messages are derived from. │ │ │ +alert types are not copyable, and cannot be constructed by the client. The │ │ │ +pointers returned by libtorrent are short lived (the details are described │ │ │ +under session_handle::pop_alerts())

    │ │ │ +
    │ │ │ +struct alert
    │ │ │ +{
    │ │ │ +   time_point timestamp () const;
    │ │ │ +   virtual int type () const noexcept = 0;
    │ │ │ +   virtual char const* what () const noexcept = 0;
    │ │ │ +   virtual std::string message () const = 0;
    │ │ │ +   virtual alert_category_t category () const noexcept = 0;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    timestamp()

    │ │ │ +
    │ │ │ +time_point timestamp () const;
    │ │ │ +
    │ │ │ +

    a timestamp is automatically created in the constructor

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    type()

    │ │ │ +
    │ │ │ +virtual int type () const noexcept = 0;
    │ │ │ +
    │ │ │ +

    returns an integer that is unique to this alert type. It can be │ │ │ +compared against a specific alert by querying a static constant called alert_type │ │ │ +in the alert. It can be used to determine the run-time type of an alert* in │ │ │ +order to cast to that alert type and access specific members.

    │ │ │ +

    e.g:

    │ │ │ +
    │ │ │ +std::vector<alert*> alerts;
    │ │ │ +ses.pop_alerts(&alerts);
    │ │ │ +for (alert* a : alerts) {
    │ │ │ +        switch (a->type()) {
    │ │ │ +
    │ │ │ +                case read_piece_alert::alert_type:
    │ │ │ +                {
    │ │ │ +                        auto* p = static_cast<read_piece_alert*>(a);
    │ │ │ +                        if (p->ec) {
    │ │ │ +                                // read_piece failed
    │ │ │ +                                break;
    │ │ │ +                        }
    │ │ │ +                        // use p
    │ │ │ +                        break;
    │ │ │ +                }
    │ │ │ +                case file_renamed_alert::alert_type:
    │ │ │ +                {
    │ │ │ +                        // etc...
    │ │ │ +                }
    │ │ │ +        }
    │ │ │ +}
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    what()

    │ │ │ +
    │ │ │ +virtual char const* what () const noexcept = 0;
    │ │ │ +
    │ │ │ +

    returns a string literal describing the type of the alert. It does │ │ │ +not include any information that might be bundled with the alert.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    message()

    │ │ │ +
    │ │ │ +virtual std::string message () const = 0;
    │ │ │ +
    │ │ │ +

    generate a string describing the alert and the information bundled │ │ │ +with it. This is mainly intended for debug and development use. It is not suitable │ │ │ +to use this for applications that may be localized. Instead, handle each alert │ │ │ +type individually and extract and render the information from the alert depending │ │ │ +on the locale.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    category()

    │ │ │ +
    │ │ │ +virtual alert_category_t category () const noexcept = 0;
    │ │ │ +
    │ │ │ +

    returns a bitmask specifying which categories this alert belong to.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    operation_name()

    │ │ │ +

    Declared in "libtorrent/operations.hpp"

    │ │ │ +
    │ │ │ +char const* operation_name (operation_t op);
    │ │ │ +
    │ │ │ +

    maps an operation id (from peer_error_alert and peer_disconnected_alert) │ │ │ +to its name. See operation_t for the constants

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    alert_cast()

    │ │ │ +

    Declared in "libtorrent/alert.hpp"

    │ │ │ +
    │ │ │ +template <typename T> T const* alert_cast (alert const* a);
    │ │ │ +template <typename T> T* alert_cast (alert* a);
    │ │ │ +
    │ │ │ +

    When you get an alert, you can use alert_cast<> to attempt to cast the │ │ │ +pointer to a specific alert type, in order to query it for more │ │ │ +information.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    alert_cast<> can only cast to an exact alert type, not a base class

    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum operation_t

    │ │ │ +

    Declared in "libtorrent/operations.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    unknown0the error was unexpected and it is unknown which operation caused it
    bittorrent1this is used when the bittorrent logic │ │ │ +determines to disconnect
    iocontrol2a call to iocontrol failed
    getpeername3a call to getpeername() failed (querying the remote IP of a │ │ │ +connection)
    getname4a call to getname failed (querying the local IP of a │ │ │ +connection)
    alloc_recvbuf5an attempt to allocate a receive buffer failed
    alloc_sndbuf6an attempt to allocate a send buffer failed
    file_write7writing to a file failed
    file_read8reading from a file failed
    file9a non-read and non-write file operation failed
    sock_write10a socket write operation failed
    sock_read11a socket read operation failed
    sock_open12a call to open(), to create a socket socket failed
    sock_bind13a call to bind() on a socket failed
    available14an attempt to query the number of bytes available to read from a socket │ │ │ +failed
    encryption15a call related to bittorrent protocol encryption failed
    connect16an attempt to connect a socket failed
    ssl_handshake17establishing an SSL connection failed
    get_interface18a connection failed to satisfy the bind interface setting
    sock_listen19a call to listen() on a socket
    sock_bind_to_device20a call to the ioctl to bind a socket to a specific network device or │ │ │ +adapter
    sock_accept21a call to accept() on a socket
    parse_address22convert a string into a valid network address
    enum_if23enumeration network devices or adapters
    file_stat24invoking stat() on a file
    file_copy25copying a file
    file_fallocate26allocating storage for a file
    file_hard_link27creating a hard link
    file_remove28removing a file
    file_rename29renaming a file
    file_open30opening a file
    mkdir31creating a directory
    check_resume32check fast resume data against files on disk
    exception33an unknown exception
    alloc_cache_piece34allocate space for a piece in the cache
    partfile_move35move a part-file
    partfile_read36read from a part file
    partfile_write37write to a part-file
    hostname_lookup38a hostname lookup
    symlink39create or read a symlink
    handshake40handshake with a peer or server
    sock_option41set socket option
    enum_route42enumeration of network routes
    file_seek43moving read/write position in a file
    timer44an async wait operation on a timer
    file_mmap45call to mmap() (or windows counterpart)
    file_truncate46call to ftruncate() (or SetEndOfFile() on windows)
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    int

    │ │ │ +

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ +
    │ │ │ +
    user_alert_id
    │ │ │ +
    user defined alerts should use IDs greater than this
    │ │ │ +
    │ │ │ +
    │ │ │ +
    num_alert_types
    │ │ │ +
    this constant represents "max_alert_index" + 1
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    alert_category_t

    │ │ │ +

    Declared in "libtorrent/alert.hpp"

    │ │ │ +
    │ │ │ +
    error
    │ │ │ +

    Enables alerts that report an error. This includes:

    │ │ │ +
      │ │ │ +
    • tracker errors
    • │ │ │ +
    • tracker warnings
    • │ │ │ +
    • file errors
    • │ │ │ +
    • resume data failures
    • │ │ │ +
    • web seed errors
    • │ │ │ +
    • .torrent files errors
    • │ │ │ +
    • listen socket errors
    • │ │ │ +
    • port mapping errors
    • │ │ │ +
    │ │ │ +
    │ │ │ +
    │ │ │ +
    │ │ │ +
    peer
    │ │ │ +
    Enables alerts when peers send invalid requests, get banned or │ │ │ +snubbed.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    port_mapping
    │ │ │ +
    Enables alerts for port mapping events. For NAT-PMP and UPnP.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    storage
    │ │ │ +
    Enables alerts for events related to the storage. File errors and │ │ │ +synchronization events for moving the storage, renaming files etc.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    tracker
    │ │ │ +
    Enables all tracker events. Includes announcing to trackers, │ │ │ +receiving responses, warnings and errors.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    connect
    │ │ │ +
    Low level alerts for when peers are connected and disconnected.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    status
    │ │ │ +
    Enables alerts for when a torrent or the session changes state.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    ip_block
    │ │ │ +
    Alerts when a peer is blocked by the ip blocker or port blocker.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    performance_warning
    │ │ │ +
    Alerts when some limit is reached that might limit the download │ │ │ +or upload rate.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    dht
    │ │ │ +
    Alerts on events in the DHT node. For incoming searches or │ │ │ +bootstrapping being done etc.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    stats
    │ │ │ +
    If you enable these alerts, you will receive a stats_alert │ │ │ +approximately once every second, for every active torrent. │ │ │ +These alerts contain all statistics counters for the interval since │ │ │ +the lasts stats alert.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    session_log
    │ │ │ +
    Enables debug logging alerts. These are available unless libtorrent │ │ │ +was built with logging disabled (TORRENT_DISABLE_LOGGING). The │ │ │ +alerts being posted are log_alert and are session wide.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    torrent_log
    │ │ │ +
    Enables debug logging alerts for torrents. These are available │ │ │ +unless libtorrent was built with logging disabled │ │ │ +(TORRENT_DISABLE_LOGGING). The alerts being posted are │ │ │ +torrent_log_alert and are torrent wide debug events.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    peer_log
    │ │ │ +
    Enables debug logging alerts for peers. These are available unless │ │ │ +libtorrent was built with logging disabled │ │ │ +(TORRENT_DISABLE_LOGGING). The alerts being posted are │ │ │ +peer_log_alert and low-level peer events and messages.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    incoming_request
    │ │ │ +
    enables the incoming_request_alert.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    dht_log
    │ │ │ +
    enables dht_log_alert, debug logging for the DHT
    │ │ │ +
    │ │ │ +
    │ │ │ +
    dht_operation
    │ │ │ +
    enable events from pure dht operations not related to torrents
    │ │ │ +
    │ │ │ +
    │ │ │ +
    port_mapping_log
    │ │ │ +
    enables port mapping log events. This log is useful │ │ │ +for debugging the UPnP or NAT-PMP implementation
    │ │ │ +
    │ │ │ +
    │ │ │ +
    picker_log
    │ │ │ +
    enables verbose logging from the piece picker.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    file_progress
    │ │ │ +
    alerts when files complete downloading
    │ │ │ +
    │ │ │ +
    │ │ │ +
    piece_progress
    │ │ │ +
    alerts when pieces complete downloading or fail hash check
    │ │ │ +
    │ │ │ +
    │ │ │ +
    upload
    │ │ │ +
    alerts when we upload blocks to other peers
    │ │ │ +
    │ │ │ +
    │ │ │ +
    block_progress
    │ │ │ +
    alerts on individual blocks being requested, downloading, finished, │ │ │ +rejected, time-out and cancelled. This is likely to post alerts at a │ │ │ +high rate.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    all
    │ │ │ +

    The full bitmask, representing all available categories.

    │ │ │ +

    since the enum is signed, make sure this isn't │ │ │ +interpreted as -1. For instance, boost.python │ │ │ +does that and fails when assigning it to an │ │ │ +unsigned parameter.

    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    session_params

    │ │ │ +

    Declared in "libtorrent/session_params.hpp"

    │ │ │ +

    The session_params is a parameters pack for configuring the session │ │ │ +before it's started.

    │ │ │ +
    │ │ │ +struct session_params
    │ │ │ +{
    │ │ │ +   session_params (settings_pack&& sp);
    │ │ │ +   session_params (settings_pack const& sp);
    │ │ │ +   session_params ();
    │ │ │ +   session_params (settings_pack const& sp
    │ │ │ +      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ +   session_params (settings_pack&& sp
    │ │ │ +      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ +
    │ │ │ +   settings_pack settings;
    │ │ │ +   session_flags_t flags {};
    │ │ │ +   std::vector<std::shared_ptr<plugin>> extensions;
    │ │ │ +   dht::dht_state dht_state;
    │ │ │ +   dht::dht_storage_constructor_type dht_storage_constructor;
    │ │ │ +   disk_io_constructor_type disk_io_constructor;
    │ │ │ +   std::map<std::string, std::string> ext_state;
    │ │ │ +   libtorrent::ip_filter ip_filter;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    session_params()

    │ │ │ +
    │ │ │ +session_params (settings_pack&& sp);
    │ │ │ +session_params (settings_pack const& sp);
    │ │ │ +session_params ();
    │ │ │ +
    │ │ │ +

    This constructor can be used to start with the default plugins │ │ │ +(ut_metadata, ut_pex and smart_ban). Pass a settings_pack to set the │ │ │ +initial settings when the session starts.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    session_params()

    │ │ │ +
    │ │ │ +session_params (settings_pack const& sp
    │ │ │ +      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ +session_params (settings_pack&& sp
    │ │ │ +      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ +
    │ │ │ +

    This constructor helps to configure the set of initial plugins │ │ │ +to be added to the session before it's started.

    │ │ │ +[report issue]
    │ │ │ +
    settings
    │ │ │ +
    The settings to configure the session with
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flags
    │ │ │ +
    specifies flags affecting the session construction. E.g. they can be used │ │ │ +to start a session in paused mode (by passing in session::paused).
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    extensions
    │ │ │ +
    the plugins to add to the session as it is constructed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    dht_state
    │ │ │ +
    DHT node ID and node addresses to bootstrap the DHT with.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    dht_storage_constructor
    │ │ │ +
    function object to construct the storage object for DHT items.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    disk_io_constructor
    │ │ │ +

    function object to create the disk I/O subsystem. Defaults to │ │ │ +default_disk_io_constructor, which is implied by leaving the field default │ │ │ +initialized. Built-in options are:

    │ │ │ +
      │ │ │ +
    • mmap_disk_io_constructor. Multi-threaded disk I/O using memory mapped files
    • │ │ │ +
    • posix_disk_io_constructor. Single-threaded simple portable disk I/O
    • │ │ │ +
    • │ │ │ +
      disabled_disk_io_constructor. Throws away all data and reads garbage.
      │ │ │ +
      Useful for testing and benchmarking.
      │ │ │ +
      │ │ │ +
    • │ │ │ +
    • pread_disk_io_constructor (experimental). Multi-threaded disk I/O │ │ │ +using preadv/pwritev with a write cache.
    • │ │ │ +
    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    ext_state
    │ │ │ +
    this container can be used by extensions/plugins to store settings. It's │ │ │ +primarily here to make it convenient to save and restore state across │ │ │ +sessions, using read_session_params() and write_session_params().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    ip_filter
    │ │ │ +
    the IP filter to use for the session. This restricts which peers are allowed │ │ │ +to connect. As if passed to set_ip_filter().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    session_proxy

    │ │ │ +

    Declared in "libtorrent/session.hpp"

    │ │ │ +

    this is a holder for the internal session implementation object. Once the │ │ │ +session destruction is explicitly initiated, this holder is used to │ │ │ +synchronize the completion of the shutdown. The lifetime of this object │ │ │ +may outlive session, causing the session destructor to not block. The │ │ │ +session_proxy destructor will block however, until the underlying session │ │ │ +is done shutting down.

    │ │ │ +
    │ │ │ +struct session_proxy
    │ │ │ +{
    │ │ │ +   session_proxy (session_proxy const&);
    │ │ │ +   ~session_proxy ();
    │ │ │ +   session_proxy& operator= (session_proxy const&) &;
    │ │ │ +   session_proxy (session_proxy&&) noexcept;
    │ │ │ +   session_proxy ();
    │ │ │ +   session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    session_proxy() ~session_proxy() operator=()

    │ │ │ +
    │ │ │ +session_proxy (session_proxy const&);
    │ │ │ +~session_proxy ();
    │ │ │ +session_proxy& operator= (session_proxy const&) &;
    │ │ │ +session_proxy (session_proxy&&) noexcept;
    │ │ │ +session_proxy ();
    │ │ │ +session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │ +
    │ │ │ +

    default constructor, does not refer to any session │ │ │ +implementation object.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    session

    │ │ │ +

    Declared in "libtorrent/session.hpp"

    │ │ │ +

    The session holds all state that spans multiple torrents. Among other │ │ │ +things it runs the network loop and manages all torrents. Once it's │ │ │ +created, the session object will spawn the main thread that will do all │ │ │ +the work. The main thread will be idle as long it doesn't have any │ │ │ +torrents to participate in.

    │ │ │ +

    You have some control over session configuration through the │ │ │ +session_handle::apply_settings() member function. To change one or more │ │ │ +configuration options, create a settings_pack. object and fill it with │ │ │ +the settings to be set and pass it in to session::apply_settings().

    │ │ │ +

    see apply_settings().

    │ │ │ +
    │ │ │ +struct session : session_handle
    │ │ │ +{
    │ │ │ +   explicit session (session_params const& params);
    │ │ │ +   session ();
    │ │ │ +   explicit session (session_params&& params);
    │ │ │ +   session (session_params&& params, io_context& ios);
    │ │ │ +   session (session_params const& params, io_context& ios);
    │ │ │ +   ~session ();
    │ │ │ +   session_proxy abort ();
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    session()

    │ │ │ +
    │ │ │ +explicit session (session_params const& params);
    │ │ │ +session ();
    │ │ │ +explicit session (session_params&& params);
    │ │ │ +
    │ │ │ +

    Constructs the session objects which acts as the container of torrents. │ │ │ +In order to avoid a race condition between starting the session and │ │ │ +configuring it, you can pass in a session_params object. Its settings │ │ │ +will take effect before the session starts up.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    session()

    │ │ │ +
    │ │ │ +session (session_params&& params, io_context& ios);
    │ │ │ +session (session_params const& params, io_context& ios);
    │ │ │ +
    │ │ │ +

    Overload of the constructor that takes an external io_context to run │ │ │ +the session object on. This is primarily useful for tests that may want │ │ │ +to run multiple sessions on a single io_context, or low resource │ │ │ +systems where additional threads are expensive and sharing an │ │ │ +io_context with other events is fine.

    │ │ │ +
    │ │ │ +

    Warning

    │ │ │ +

    The session object does not cleanly terminate with an external │ │ │ +io_context. The io_context::run() call must have returned │ │ │ +before it's safe to destruct the session. Which means you MUST │ │ │ +call session::abort() and save the session_proxy first, then │ │ │ +destruct the session object, then sync with the io_context, then │ │ │ +destruct the session_proxy object.

    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    ~session()

    │ │ │ +
    │ │ │ +~session ();
    │ │ │ +
    │ │ │ +

    The destructor of session will notify all trackers that our torrents │ │ │ +have been shut down. If some trackers are down, they will time out. │ │ │ +All this before the destructor of session returns. So, it's advised │ │ │ +that any kind of interface (such as windows) are closed before │ │ │ +destructing the session object. Because it can take a few second for │ │ │ +it to finish. The timeout can be set with apply_settings().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    abort()

    │ │ │ +
    │ │ │ +session_proxy abort ();
    │ │ │ +
    │ │ │ +

    In case you want to destruct the session asynchronously, you can │ │ │ +request a session destruction proxy. If you don't do this, the │ │ │ +destructor of the session object will block while the trackers are │ │ │ +contacted. If you keep one session_proxy to the session when │ │ │ +destructing it, the destructor will not block, but start to close down │ │ │ +the session, the destructor of the proxy will then synchronize the │ │ │ +threads. So, the destruction of the session is performed from the │ │ │ +session destructor call until the session_proxy destructor │ │ │ +call. The session_proxy does not have any operations on it (since │ │ │ +the session is being closed down, no operations are allowed on it). │ │ │ +The only valid operation is calling the destructor:

    │ │ │ +
    │ │ │ +struct session_proxy {};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    session_handle

    │ │ │ +

    Declared in "libtorrent/session_handle.hpp"

    │ │ │ +

    this class provides a non-owning handle to a session and a subset of the │ │ │ +interface of the session class. If the underlying session is destructed │ │ │ +any handle to it will no longer be valid. is_valid() will return false and │ │ │ +any operation on it will throw a system_error exception, with error code │ │ │ +invalid_session_handle.

    │ │ │ +
    │ │ │ +struct session_handle
    │ │ │ +{
    │ │ │ +   bool is_valid () const;
    │ │ │ +   session_params session_state (save_state_flags_t flags = save_state_flags_t::all()) const;
    │ │ │ +   std::vector<torrent_status> get_torrent_status (
    │ │ │ +      std::function<bool(torrent_status const&)> const& pred
    │ │ │ +      , status_flags_t flags = {}) const;
    │ │ │ +   void refresh_torrent_status (std::vector<torrent_status>* ret
    │ │ │ +      , status_flags_t flags = {}) const;
    │ │ │ +   void post_torrent_updates (status_flags_t flags = status_flags_t::all());
    │ │ │ +   void post_session_stats ();
    │ │ │ +   void post_dht_stats ();
    │ │ │ +   void set_dht_state (dht::dht_state const& st);
    │ │ │ +   void set_dht_state (dht::dht_state&& st);
    │ │ │ +   torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │ +   torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │ +   std::vector<torrent_handle> get_torrents () const;
    │ │ │ +   torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │ +   torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ +   torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │ +   void async_add_torrent (add_torrent_params const& params);
    │ │ │ +   torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │ +   void async_add_torrent (add_torrent_params&& params);
    │ │ │ +   bool is_paused () const;
    │ │ │ +   void resume ();
    │ │ │ +   void pause ();
    │ │ │ +   bool is_dht_running () const;
    │ │ │ +   void set_dht_storage (dht::dht_storage_constructor_type sc);
    │ │ │ +   void add_dht_node (std::pair<std::string, int> const& node);
    │ │ │ +   void dht_get_item (sha1_hash const& target);
    │ │ │ +   void dht_get_item (std::array<char, 32> key
    │ │ │ +      , std::string salt = std::string());
    │ │ │ +   sha1_hash dht_put_item (entry data);
    │ │ │ +   void dht_put_item (std::array<char, 32> key
    │ │ │ +      , std::function<void(entry&, std::array<char, 64>&
    │ │ │ +      , std::int64_t&, std::string const&)> cb
    │ │ │ +      , std::string salt = std::string());
    │ │ │ +   void dht_announce (sha1_hash const& info_hash, int port = 0, dht::announce_flags_t flags = {});
    │ │ │ +   void dht_get_peers (sha1_hash const& info_hash);
    │ │ │ +   void dht_live_nodes (sha1_hash const& nid);
    │ │ │ +   void dht_sample_infohashes (udp::endpoint const& ep, sha1_hash const& target);
    │ │ │ +   void dht_direct_request (udp::endpoint const& ep, entry const& e, client_data_t userdata = {});
    │ │ │ +   void add_extension (std::function<std::shared_ptr<torrent_plugin>(
    │ │ │ +      torrent_handle const&, client_data_t)> ext);
    │ │ │ +   void add_extension (std::shared_ptr<plugin> ext);
    │ │ │ +   ip_filter get_ip_filter () const;
    │ │ │ +   void set_ip_filter (ip_filter f);
    │ │ │ +   void set_port_filter (port_filter const& f);
    │ │ │ +   unsigned short listen_port () const;
    │ │ │ +   bool is_listening () const;
    │ │ │ +   unsigned short ssl_listen_port () const;
    │ │ │ +   ip_filter get_peer_class_filter () const;
    │ │ │ +   void set_peer_class_filter (ip_filter const& f);
    │ │ │ +   void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │ +   peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │ +   peer_class_t create_peer_class (char const* name);
    │ │ │ +   void delete_peer_class (peer_class_t cid);
    │ │ │ +   void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │ +   peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │ +   void remove_torrent (const torrent_handle&, remove_flags_t = {});
    │ │ │ +   settings_pack get_settings () const;
    │ │ │ +   void apply_settings (settings_pack const&);
    │ │ │ +   void apply_settings (settings_pack&&);
    │ │ │ +   bool wait_for_alert (time_duration max_wait);
    │ │ │ +   void set_alert_notify (std::function<void()> const& fun);
    │ │ │ +   void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ +   std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │ +   void delete_port_mapping (port_mapping_t handle);
    │ │ │ +   void reopen_network_sockets (reopen_network_flags_t options = reopen_map_ports);
    │ │ │ +   std::shared_ptr<aux::session_impl> native_handle () const;
    │ │ │ +
    │ │ │ +   static inline constexpr save_state_flags_t save_settings  = 0_bit;
    │ │ │ +   static inline constexpr save_state_flags_t save_dht_state  = 2_bit;
    │ │ │ +   static inline constexpr save_state_flags_t save_extension_state  = 11_bit;
    │ │ │ +   static inline constexpr save_state_flags_t save_ip_filter  = 12_bit;
    │ │ │ +   static inline constexpr peer_class_t global_peer_class_id {0};
    │ │ │ +   static inline constexpr peer_class_t tcp_peer_class_id {1};
    │ │ │ +   static inline constexpr peer_class_t local_peer_class_id {2};
    │ │ │ +   static inline constexpr remove_flags_t delete_files  = 0_bit;
    │ │ │ +   static inline constexpr remove_flags_t delete_partfile  = 1_bit;
    │ │ │ +   static inline constexpr session_flags_t paused  = 2_bit;
    │ │ │ +   static constexpr portmap_protocol udp  = portmap_protocol::udp;
    │ │ │ +   static constexpr portmap_protocol tcp  = portmap_protocol::tcp;
    │ │ │ +   static inline constexpr reopen_network_flags_t reopen_map_ports  = 0_bit;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    is_valid()

    │ │ │ +
    │ │ │ +bool is_valid () const;
    │ │ │ +
    │ │ │ +

    returns true if this handle refers to a valid session object. If the │ │ │ +session has been destroyed, all session_handle objects will expire and │ │ │ +not be valid.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    session_state()

    │ │ │ +
    │ │ │ +session_params session_state (save_state_flags_t flags = save_state_flags_t::all()) const;
    │ │ │ +
    │ │ │ +

    returns the current session state. This can be passed to │ │ │ +write_session_params() to save the state to disk and restored using │ │ │ +read_session_params() when constructing a new session. 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 │ │ │ +session state

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_torrent_status() refresh_torrent_status()

    │ │ │ +
    │ │ │ +std::vector<torrent_status> get_torrent_status (
    │ │ │ +      std::function<bool(torrent_status const&)> const& pred
    │ │ │ +      , status_flags_t flags = {}) const;
    │ │ │ +void refresh_torrent_status (std::vector<torrent_status>* ret
    │ │ │ +      , status_flags_t flags = {}) const;
    │ │ │ +
    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    these calls are potentially expensive and won't scale well with │ │ │ +lots of torrents. If you're concerned about performance, consider │ │ │ +using post_torrent_updates() instead.

    │ │ │ +
    │ │ │ +

    get_torrent_status returns a vector of the torrent_status for │ │ │ +every torrent which satisfies pred, which is a predicate function │ │ │ +which determines if a torrent should be included in the returned set │ │ │ +or not. Returning true means it should be included and false means │ │ │ +excluded. The flags argument is the same as to │ │ │ +torrent_handle::status(). Since pred is guaranteed to be │ │ │ +called for every torrent, it may be used to count the number of │ │ │ +torrents of different categories as well.

    │ │ │ +

    refresh_torrent_status takes a vector of torrent_status structs │ │ │ +(for instance the same vector that was returned by │ │ │ +get_torrent_status() ) and refreshes the status based on the │ │ │ +handle member. It is possible to use this function by first │ │ │ +setting up a vector of default constructed torrent_status objects, │ │ │ +only initializing the handle member, in order to request the │ │ │ +torrent status for multiple torrents in a single call. This can save a │ │ │ +significant amount of time if you have a lot of torrents.

    │ │ │ +

    Any torrent_status object whose handle member is not referring to │ │ │ +a valid torrent are ignored.

    │ │ │ +

    The intended use of these functions is to start off by calling │ │ │ +get_torrent_status() to get a list of all torrents that match your │ │ │ +criteria. Then call refresh_torrent_status() on that list. This │ │ │ +will only refresh the status for the torrents in your list, and thus │ │ │ +ignore all other torrents you might be running. This may save a │ │ │ +significant amount of time, especially if the number of torrents you're │ │ │ +interested in is small. In order to keep your list of interested │ │ │ +torrents up to date, you can either call get_torrent_status() from │ │ │ +time to time, to include torrents you might have become interested in │ │ │ +since the last time. In order to stop refreshing a certain torrent, │ │ │ +simply remove it from the list.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_torrent_updates()

    │ │ │ +
    │ │ │ +void post_torrent_updates (status_flags_t flags = status_flags_t::all());
    │ │ │ +
    │ │ │ +

    This functions instructs the session to post the state_update_alert, │ │ │ +containing the status of all torrents whose state changed since the │ │ │ +last time this function was called.

    │ │ │ +

    Only torrents who have the state subscription flag set will be │ │ │ +included. This flag is on by default. See add_torrent_params. │ │ │ +the flags argument is the same as for torrent_handle::status(). │ │ │ +see status_flags_t in torrent_handle.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_session_stats()

    │ │ │ +
    │ │ │ +void post_session_stats ();
    │ │ │ +
    │ │ │ +

    This function will post a session_stats_alert object, containing a │ │ │ +snapshot of the performance counters from the internals of libtorrent. │ │ │ +To interpret these counters, query the session via │ │ │ +session_stats_metrics().

    │ │ │ +

    For more information, see the session statistics section.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_dht_stats()

    │ │ │ +
    │ │ │ +void post_dht_stats ();
    │ │ │ +
    │ │ │ +

    This will cause a dht_stats_alert to be posted.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_dht_state()

    │ │ │ +
    │ │ │ +void set_dht_state (dht::dht_state const& st);
    │ │ │ +void set_dht_state (dht::dht_state&& st);
    │ │ │ +
    │ │ │ +

    set the DHT state for the session. This will be taken into account the │ │ │ +next time the DHT is started, as if it had been passed in via the │ │ │ +session_params on startup.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    find_torrent() get_torrents()

    │ │ │ +
    │ │ │ +torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │ +torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │ +std::vector<torrent_handle> get_torrents () const;
    │ │ │ +
    │ │ │ +

    find_torrent() looks for a torrent with the given info-hash. In │ │ │ +case there is such a torrent in the session, a torrent_handle to that │ │ │ +torrent is returned. In case the torrent cannot be found, an invalid │ │ │ +torrent_handle 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 session.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    async_add_torrent() add_torrent()

    │ │ │ +
    │ │ │ +torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │ +torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ +torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │ +void async_add_torrent (add_torrent_params const& params);
    │ │ │ +torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │ +void async_add_torrent (add_torrent_params&& params);
    │ │ │ +
    │ │ │ +

    You add torrents through the add_torrent() function where you give an │ │ │ +object with all the parameters. The add_torrent() overloads will block │ │ │ +until the torrent has been added (or failed to be added) and returns │ │ │ +an error code and a torrent_handle. In order to add torrents more │ │ │ +efficiently, consider using async_add_torrent() which returns │ │ │ +immediately, without waiting for the torrent to add. Notification of │ │ │ +the torrent being added is sent as add_torrent_alert.

    │ │ │ +

    The save_path field in add_torrent_params must be set to a valid │ │ │ +path where the files for the torrent will be saved. Even when using a │ │ │ +custom storage, this needs to be set to something. If the save_path │ │ │ +is empty, the call to add_torrent() will throw a system_error │ │ │ +exception.

    │ │ │ +

    The overload that does not take an error_code throws an exception on │ │ │ +error and is not available when building without exception support. │ │ │ +The torrent_handle returned by add_torrent() can be used to retrieve │ │ │ +information about the torrent's progress, its peers etc. It is also │ │ │ +used to abort a torrent.

    │ │ │ +

    If the torrent you are trying to add already exists in the session (is │ │ │ +either queued for checking, being checked or downloading) │ │ │ +add_torrent() will throw system_error which derives from │ │ │ +std::exception unless duplicate_is_error is set to false. In that │ │ │ +case, add_torrent() will return the handle to the existing torrent.

    │ │ │ +

    The add_torrent_params class has a flags field. It can be used to │ │ │ +control what state the new torrent will be added in. Common flags to │ │ │ +want to control are torrent_flags::paused and │ │ │ +torrent_flags::auto_managed. In order to add a magnet link that will │ │ │ +just download the metadata, but no payload, set the │ │ │ +torrent_flags::upload_mode flag.

    │ │ │ +

    Special consideration has to be taken when adding hybrid torrents │ │ │ +(i.e. torrents that are BitTorrent v2 torrents that are backwards │ │ │ +compatible with v1). For more details, see BitTorrent v2 torrents.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    pause() is_paused() resume()

    │ │ │ +
    │ │ │ +bool is_paused () const;
    │ │ │ +void resume ();
    │ │ │ +void pause ();
    │ │ │ +
    │ │ │ +

    Pausing the session 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 session pause state is separate from the torrent pause │ │ │ +state. A torrent is inactive if it is paused or if the session is │ │ │ +paused. is_paused() returns true if the session is currently │ │ │ +paused.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    is_dht_running()

    │ │ │ +
    │ │ │ +bool is_dht_running () const;
    │ │ │ +
    │ │ │ +

    is_dht_running() returns true if the DHT support has been started │ │ │ +and false otherwise.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_dht_storage()

    │ │ │ +
    │ │ │ +void set_dht_storage (dht::dht_storage_constructor_type sc);
    │ │ │ +
    │ │ │ +

    set_dht_storage set a dht custom storage constructor function │ │ │ +to be used internally when the dht is created.

    │ │ │ +

    Since the dht storage is a critical component for the dht behavior, │ │ │ +this function will only be effective the next time the dht is started. │ │ │ +If you never touch this feature, a default map-memory based storage │ │ │ +is used.

    │ │ │ +

    If you want to make sure the dht is initially created with your │ │ │ +custom storage, create a session with the setting │ │ │ +settings_pack::enable_dht to false, set your constructor function │ │ │ +and call apply_settings with settings_pack::enable_dht to true.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_dht_node()

    │ │ │ +
    │ │ │ +void add_dht_node (std::pair<std::string, int> const& node);
    │ │ │ +
    │ │ │ +

    add_dht_node takes a host name and port pair. That endpoint will be │ │ │ +pinged, and if a valid DHT reply is received, the node will be added to │ │ │ +the routing table.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_get_item()

    │ │ │ +
    │ │ │ +void dht_get_item (sha1_hash const& target);
    │ │ │ +
    │ │ │ +

    query the DHT for an immutable item at the target hash. │ │ │ +the result is posted as a dht_immutable_item_alert.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_get_item()

    │ │ │ +
    │ │ │ +void dht_get_item (std::array<char, 32> key
    │ │ │ +      , std::string salt = std::string());
    │ │ │ +
    │ │ │ +

    query the DHT for a mutable item under the public key key. │ │ │ +this is an ed25519 key. salt is optional and may be left │ │ │ +as an empty string if no salt is to be used. │ │ │ +if the item is found in the DHT, a dht_mutable_item_alert is │ │ │ +posted.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_put_item()

    │ │ │ +
    │ │ │ +sha1_hash dht_put_item (entry data);
    │ │ │ +
    │ │ │ +

    store the given bencoded data as an immutable item in the DHT. │ │ │ +the returned hash is the key that is to be used to look the item │ │ │ +up again. It's just the SHA-1 hash of the bencoded form of the │ │ │ +structure.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_put_item()

    │ │ │ +
    │ │ │ +void dht_put_item (std::array<char, 32> key
    │ │ │ +      , std::function<void(entry&, std::array<char, 64>&
    │ │ │ +      , std::int64_t&, std::string const&)> cb
    │ │ │ +      , std::string salt = std::string());
    │ │ │ +
    │ │ │ +

    store a mutable item. The key is the public key the blob is │ │ │ +to be stored under. The optional salt argument is a string that │ │ │ +is to be mixed in with the key when determining where in the DHT │ │ │ +the value is to be stored. The callback function is called from within │ │ │ +the libtorrent network thread once we've found where to store the blob, │ │ │ +possibly with the current value stored under the key. │ │ │ +The values passed to the callback functions are:

    │ │ │ +
    │ │ │ +
    entry& value
    │ │ │ +
    the current value stored under the key (may be empty). Also expected │ │ │ +to be set to the value to be stored by the function.
    │ │ │ +
    std::array<char,64>& signature
    │ │ │ +
    the signature authenticating the current value. This may be zeros │ │ │ +if there is currently no value stored. The function is expected to │ │ │ +fill in this buffer with the signature of the new value to store. │ │ │ +To generate the signature, you may want to use the │ │ │ +sign_mutable_item function.
    │ │ │ +
    std::int64_t& seq
    │ │ │ +
    current sequence number. May be zero if there is no current value. │ │ │ +The function is expected to set this to the new sequence number of │ │ │ +the value that is to be stored. Sequence numbers must be monotonically │ │ │ +increasing. Attempting to overwrite a value with a lower or equal │ │ │ +sequence number will fail, even if the signature is correct.
    │ │ │ +
    std::string const& salt
    │ │ │ +
    this is the salt that was used for this put call.
    │ │ │ +
    │ │ │ +

    Since the callback function cb is called from within libtorrent, │ │ │ +it is critical to not perform any blocking operations. Ideally not │ │ │ +even locking a mutex. Pass any data required for this function along │ │ │ +with the function object's context and make the function entirely │ │ │ +self-contained. The only reason data blob's value is computed │ │ │ +via a function instead of just passing in the new value is to avoid │ │ │ +race conditions. If you want to update the value in the DHT, you │ │ │ +must first retrieve it, then modify it, then write it back. The way │ │ │ +the DHT works, it is natural to always do a lookup before storing and │ │ │ +calling the callback in between is convenient.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_get_peers() dht_announce()

    │ │ │ +
    │ │ │ +void dht_announce (sha1_hash const& info_hash, int port = 0, dht::announce_flags_t flags = {});
    │ │ │ +void dht_get_peers (sha1_hash const& info_hash);
    │ │ │ +
    │ │ │ +

    dht_get_peers() will issue a DHT get_peer request to the DHT for the │ │ │ +specified info-hash. The response (the peers) will be posted back in a │ │ │ +dht_get_peers_reply_alert.

    │ │ │ +

    dht_announce() will issue a DHT announce request to the DHT to the │ │ │ +specified info-hash, advertising the specified port. If the port is │ │ │ +left at its default, 0, the port will be implied by the DHT message's │ │ │ +source port (which may improve connectivity through a NAT). │ │ │ +dht_announce() is not affected by the announce_port override setting.

    │ │ │ +

    Both these functions are exposed for advanced custom use of the DHT. │ │ │ +All torrents eligible to be announce to the DHT will be automatically, │ │ │ +by libtorrent.

    │ │ │ +

    For possible flags, see announce_flags_t.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_live_nodes()

    │ │ │ +
    │ │ │ +void dht_live_nodes (sha1_hash const& nid);
    │ │ │ +
    │ │ │ +

    Retrieve all the live DHT (identified by nid) nodes. All the │ │ │ +nodes id and endpoint will be returned in the list of nodes in the │ │ │ +alert dht_live_nodes_alert. │ │ │ +Since this alert is a response to an explicit call, it will always be │ │ │ +posted, regardless of the alert mask.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_sample_infohashes()

    │ │ │ +
    │ │ │ +void dht_sample_infohashes (udp::endpoint const& ep, sha1_hash const& target);
    │ │ │ +
    │ │ │ +

    Query the DHT node specified by ep to retrieve a sample of the │ │ │ +info-hashes that the node currently have in their storage. │ │ │ +The target is included for iterative lookups so that indexing nodes │ │ │ +can perform a key space traversal with a single RPC per node by adjusting │ │ │ +the target value for each RPC. It has no effect on the returned sample value. │ │ │ +The result is posted as a dht_sample_infohashes_alert.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dht_direct_request()

    │ │ │ +
    │ │ │ +void dht_direct_request (udp::endpoint const& ep, entry const& e, client_data_t userdata = {});
    │ │ │ +
    │ │ │ +

    Send an arbitrary DHT request directly to the specified endpoint. This │ │ │ +function is intended for use by plugins. When a response is received │ │ │ +or the request times out, a dht_direct_response_alert will be posted │ │ │ +with the response (if any) and the userdata pointer passed in here. │ │ │ +Since this alert is a response to an explicit call, it will always be │ │ │ +posted, regardless of the alert mask.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_extension()

    │ │ │ +
    │ │ │ +void add_extension (std::function<std::shared_ptr<torrent_plugin>(
    │ │ │ +      torrent_handle const&, client_data_t)> ext);
    │ │ │ +void add_extension (std::shared_ptr<plugin> ext);
    │ │ │ +
    │ │ │ +

    This function adds an extension to this session. The argument is a │ │ │ +function object that is called with a torrent_handle and which should │ │ │ +return a std::shared_ptr<torrent_plugin>. To write custom │ │ │ +plugins, see libtorrent plugins. For the typical bittorrent client │ │ │ +all of these extensions should be added. The main plugins implemented │ │ │ +in libtorrent are:

    │ │ │ +
    │ │ │ +
    uTorrent metadata
    │ │ │ +
    Allows peers to download the metadata (.torrent files) from the swarm │ │ │ +directly. Makes it possible to join a swarm with just a tracker and │ │ │ +info-hash.
    │ │ │ +
    │ │ │ +
    │ │ │ +#include <libtorrent/extensions/ut_metadata.hpp>
    │ │ │ +ses.add_extension(&lt::create_ut_metadata_plugin);
    │ │ │ +
    │ │ │ +
    │ │ │ +
    uTorrent peer exchange
    │ │ │ +
    Exchanges peers between clients.
    │ │ │ +
    │ │ │ +
    │ │ │ +#include <libtorrent/extensions/ut_pex.hpp>
    │ │ │ +ses.add_extension(&lt::create_ut_pex_plugin);
    │ │ │ +
    │ │ │ +
    │ │ │ +
    smart ban plugin
    │ │ │ +
    A plugin that, with a small overhead, can ban peers │ │ │ +that sends bad data with very high accuracy. Should │ │ │ +eliminate most problems on poisoned torrents.
    │ │ │ +
    │ │ │ +
    │ │ │ +#include <libtorrent/extensions/smart_ban.hpp>
    │ │ │ +ses.add_extension(&lt::create_smart_ban_plugin);
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_ip_filter() get_ip_filter()

    │ │ │ +
    │ │ │ +ip_filter get_ip_filter () const;
    │ │ │ +void set_ip_filter (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 ip_filter.

    │ │ │ +

    Each time a peer is blocked because of the IP filter, a │ │ │ +peer_blocked_alert is generated. get_ip_filter() Returns the │ │ │ +ip_filter currently in the session. See ip_filter.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_port_filter()

    │ │ │ +
    │ │ │ +void set_port_filter (port_filter const& f);
    │ │ │ +
    │ │ │ +

    apply port_filter 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.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    is_listening() listen_port() ssl_listen_port()

    │ │ │ +
    │ │ │ +unsigned short listen_port () const;
    │ │ │ +bool is_listening () const;
    │ │ │ +unsigned short ssl_listen_port () const;
    │ │ │ +
    │ │ │ +

    is_listening() will tell you whether or not the session has │ │ │ +successfully opened a listening port. If it hasn't, this function will │ │ │ +return false, and then you can set a new │ │ │ +settings_pack::listen_interfaces 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.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_peer_class_filter() get_peer_class_filter()

    │ │ │ +
    │ │ │ +ip_filter get_peer_class_filter () const;
    │ │ │ +void set_peer_class_filter (ip_filter const& f);
    │ │ │ +
    │ │ │ +

    Sets the peer class filter for this session. 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 ip_filter.

    │ │ │ +

    For example, to make all peers in the range 200.1.1.0 - 200.1.255.255 │ │ │ +belong to their own peer class, apply the following filter:

    │ │ │ +
    │ │ │ +ip_filter f = ses.get_peer_class_filter();
    │ │ │ +peer_class_t my_class = ses.create_peer_class("200.1.x.x IP range");
    │ │ │ +f.add_rule(make_address("200.1.1.0"), make_address("200.1.255.255")
    │ │ │ +        , 1 << static_cast<std::uint32_t>(my_class));
    │ │ │ +ses.set_peer_class_filter(f);
    │ │ │ +
    │ │ │ +

    This setting only applies to new connections, it won't affect existing │ │ │ +peer connections.

    │ │ │ +

    This function is limited to only peer class 0-31, since there are only │ │ │ +32 bits in the IP range mapping. Only the set bits matter; no peer │ │ │ +class will be removed from a peer as a result of this call, peer │ │ │ +classes are only added.

    │ │ │ +

    The peer_class argument cannot be greater than 31. The bitmasks │ │ │ +representing peer classes in the peer_class_filter are 32 bits.

    │ │ │ +

    The get_peer_class_filter() function returns the current filter.

    │ │ │ +

    For more information, see peer classes.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_peer_class_type_filter() set_peer_class_type_filter()

    │ │ │ +
    │ │ │ +void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │ +peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │ +
    │ │ │ +

    Sets and gets the peer class type filter. This is controls automatic │ │ │ +peer class assignments to peers based on what kind of socket it is.

    │ │ │ +

    It does not only support assigning peer classes, it also supports │ │ │ +removing peer classes based on socket type.

    │ │ │ +

    The order of these rules being applied are:

    │ │ │ +
      │ │ │ +
    1. peer-class IP filter
    2. │ │ │ +
    3. peer-class type filter, removing classes
    4. │ │ │ +
    5. peer-class type filter, adding classes
    6. │ │ │ +
    │ │ │ +

    For more information, see peer classes.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    create_peer_class()

    │ │ │ +
    │ │ │ +peer_class_t create_peer_class (char const* name);
    │ │ │ +
    │ │ │ +

    Creates a new peer class (see peer classes) with the given name. The │ │ │ +returned integer is the new peer class identifier. Peer classes may │ │ │ +have the same name, so each invocation of this function creates a new │ │ │ +class and returns a unique identifier.

    │ │ │ +

    Identifiers are assigned from low numbers to higher. So if you plan on │ │ │ +using certain peer classes in a call to set_peer_class_filter(), │ │ │ +make sure to create those early on, to get low identifiers.

    │ │ │ +

    For more information on peer classes, see peer classes.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    delete_peer_class()

    │ │ │ +
    │ │ │ +void delete_peer_class (peer_class_t cid);
    │ │ │ +
    │ │ │ +

    This call dereferences the reference count of the specified peer │ │ │ +class. When creating a peer class it's automatically referenced by 1. │ │ │ +If you want to recycle a peer class, you may call this function. You │ │ │ +may only call this function once per peer class you create. │ │ │ +Calling it more than once for the same class will lead to memory │ │ │ +corruption.

    │ │ │ +

    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 session object │ │ │ +destructs.

    │ │ │ +

    For more information on peer classes, see peer classes.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_peer_class() get_peer_class()

    │ │ │ +
    │ │ │ +void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │ +peer_class_info get_peer_class (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 │ │ │ +peer_class_info object in the specified peer class. There is no │ │ │ +option to only update a single property.

    │ │ │ +

    A peer or torrent belonging to more than one class, the highest │ │ │ +priority among any of its classes is the one that is taken into │ │ │ +account.

    │ │ │ +

    For more information, see peer classes.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    remove_torrent()

    │ │ │ +
    │ │ │ +void remove_torrent (const torrent_handle&, remove_flags_t = {});
    │ │ │ +
    │ │ │ +

    remove_torrent() will close all peer connections associated with │ │ │ +the torrent and tell the tracker that we've stopped participating in │ │ │ +the swarm. This operation cannot fail. When it completes, you will │ │ │ +receive a torrent_removed_alert.

    │ │ │ +

    remove_torrent() is non-blocking, but will remove the torrent from the │ │ │ +session synchronously. Calling session_handle::add_torrent() immediately │ │ │ +afterward with the same torrent will succeed. Note that this creates a │ │ │ +new handle which is not equal to the removed one.

    │ │ │ +

    The optional second argument options can be used to delete all the │ │ │ +files downloaded by this torrent. To do so, pass in the value │ │ │ +session_handle::delete_files. Once the torrent is deleted, a │ │ │ +torrent_deleted_alert is posted.

    │ │ │ +

    The torrent_handle remains valid for some time after remove_torrent() is │ │ │ +called. It will become invalid only after all libtorrent tasks (such as │ │ │ +I/O tasks) release their references to the torrent. Until this happens, │ │ │ +torrent_handle::is_valid() will return true, and other calls such │ │ │ +as torrent_handle::status() will succeed. Because of this, and because │ │ │ +remove_torrent() is non-blocking, the following sequence usually │ │ │ +succeeds (does not throw system_error): │ │ │ +.. code:: c++

    │ │ │ +
    │ │ │ +session.remove_handle(handle); │ │ │ +handle.save_resume_data();
    │ │ │ +

    Note that when a queued or downloading torrent is removed, its position │ │ │ +in the download queue is vacated and every subsequent torrent in the │ │ │ +queue has their queue positions updated. This can potentially cause a │ │ │ +large state_update to be posted. When removing all torrents, it is │ │ │ +advised to remove them from the back of the queue, to minimize the │ │ │ +shifting.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_settings() apply_settings()

    │ │ │ +
    │ │ │ +settings_pack get_settings () const;
    │ │ │ +void apply_settings (settings_pack const&);
    │ │ │ +void apply_settings (settings_pack&&);
    │ │ │ +
    │ │ │ +

    Applies the settings specified by the settings_pack s. This is an │ │ │ +asynchronous operation that will return immediately and actually apply │ │ │ +the settings to the main thread of libtorrent some time later.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    pop_alerts() wait_for_alert() set_alert_notify()

    │ │ │ +
    │ │ │ +bool wait_for_alert (time_duration max_wait);
    │ │ │ +void set_alert_notify (std::function<void()> const& fun);
    │ │ │ +void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ +
    │ │ │ +

    Alerts is the main mechanism for libtorrent to report errors and │ │ │ +events. pop_alerts fills in the vector passed to it with pointers │ │ │ +to new alerts. The session still owns these alerts and they will stay │ │ │ +valid until the next time pop_alerts is called. You may not delete │ │ │ +the alert 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.

    │ │ │ +

    wait_for_alert will block the current thread for max_wait time │ │ │ +duration, or until another alert is posted. If an alert is already │ │ │ +available at the time of the call, it returns immediately. It returns │ │ │ +true if an alert is pending (i.e. a subsequent pop_alerts │ │ │ +call would return at least one alert), and false if the timeout │ │ │ +expired with no alert available.

    │ │ │ +

    In TORRENT_ABI_VERSION < 4 the return type is alert* for │ │ │ +backwards compatibility; the returned pointer is non-null when an │ │ │ +alert is pending and null on timeout, but it does not point at any │ │ │ +real alert (it is a placeholder) and must not be dereferenced. Use │ │ │ +pop_alerts to retrieve the actual alerts.

    │ │ │ +

    In the python binding, wait_for_alert takes the number of │ │ │ +milliseconds to wait as an integer and returns a bool.

    │ │ │ +

    The alert queue in the session will not grow indefinitely. Make sure │ │ │ +to pop periodically to not miss notifications. To control the max │ │ │ +number of alerts that's queued by the session, see │ │ │ +settings_pack::alert_queue_size.

    │ │ │ +

    Some alerts are considered so important that they are posted even when │ │ │ +the alert queue is full. Some alerts are considered mandatory and cannot │ │ │ +be disabled by the alert_mask. For instance, │ │ │ +save_resume_data_alert and save_resume_data_failed_alert are always │ │ │ +posted, regardless of the alert mask.

    │ │ │ +

    To control which alerts are posted, set the alert_mask │ │ │ +(settings_pack::alert_mask).

    │ │ │ +

    If the alert queue fills up to the point where alerts are dropped, this │ │ │ +will be indicated by a alerts_dropped_alert, which contains a bitmask │ │ │ +of which types of alerts were dropped. Generally it is a good idea to │ │ │ +make sure the alert queue is large enough, the alert_mask doesn't have │ │ │ +unnecessary categories enabled and to call pop_alert() frequently, to │ │ │ +avoid alerts being dropped.

    │ │ │ +

    the set_alert_notify function lets the client set a function object │ │ │ +to be invoked every time the alert queue goes from having 0 alerts to │ │ │ +1 alert. This function is called from within libtorrent, it may be the │ │ │ +main thread, or it may be from within a user call. The intention of │ │ │ +of the function is that the client wakes up its main thread, to poll │ │ │ +for more alerts using pop_alerts(). If the notify function fails │ │ │ +to do so, it won't be called again, until pop_alerts is called for │ │ │ +some other reason. For instance, it could signal an eventfd, post a │ │ │ +message to an HWND or some other main message pump. The actual │ │ │ +retrieval of alerts should not be done in the callback. In fact, the │ │ │ +callback should not block. It should not perform any expensive work. │ │ │ +It really should just notify the main application thread.

    │ │ │ +

    The type of an alert 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.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_port_mapping() delete_port_mapping()

    │ │ │ +
    │ │ │ +std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │ +void delete_port_mapping (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 session. The return values are all handles referring to the │ │ │ +port mappings that were just created. Pass them to delete_port_mapping() │ │ │ +to remove them.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    reopen_network_sockets()

    │ │ │ +
    │ │ │ +void reopen_network_sockets (reopen_network_flags_t options = reopen_map_ports);
    │ │ │ +
    │ │ │ +

    Instructs the session to reopen all listen and outgoing sockets.

    │ │ │ +

    It's useful in the case your platform doesn't support the built in │ │ │ +IP notifier mechanism, or if you have a better more reliable way to │ │ │ +detect changes in the IP routing table.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    native_handle()

    │ │ │ +
    │ │ │ +std::shared_ptr<aux::session_impl> native_handle () const;
    │ │ │ +
    │ │ │ +

    This function is intended only for use by plugins. This type does │ │ │ +not have a stable API and should be relied on as little as possible.

    │ │ │ +[report issue]
    │ │ │ +
    save_settings
    │ │ │ +
    saves settings (i.e. the settings_pack)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    save_dht_state
    │ │ │ +
    saves dht state such as nodes and node-id, possibly accelerating │ │ │ +joining the DHT if provided at next session startup.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    save_extension_state
    │ │ │ +
    load or save state from plugins
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    save_ip_filter
    │ │ │ +
    load or save the IP filter set on the session
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    global_peer_class_id tcp_peer_class_id local_peer_class_id
    │ │ │ +
    built-in peer classes
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    delete_files
    │ │ │ +
    delete the files belonging to the torrent from disk. │ │ │ +including the part-file, if there is one
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    delete_partfile
    │ │ │ +
    delete just the part-file associated with this torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    paused
    │ │ │ +
    when set, the session will start paused. Call │ │ │ +session_handle::resume() to start
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    udp tcp
    │ │ │ +
    protocols used by add_port_mapping()
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    reopen_map_ports
    │ │ │ +
    This option indicates if the ports are mapped using natpmp │ │ │ +and upnp. If mapping was already made, they are deleted and added │ │ │ +again. This only works if natpmp and/or upnp are configured to be │ │ │ +enable.
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    write_session_params() write_session_params_buf() read_session_params()

    │ │ │ +

    Declared in "libtorrent/session_params.hpp"

    │ │ │ +
    │ │ │ +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
    │ │ │ +   , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │ +entry write_session_params (session_params const& sp
    │ │ │ +   , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │ +
    │ │ │ +

    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 │ │ │ +session's state. │ │ │ +The _buf suffix indicates the function operates on buffer rather than the │ │ │ +bencoded structure. │ │ │ +The torrents in a session are not part of the session_params state, they have │ │ │ +to be restored separately.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    load_torrent_limits

    │ │ │ +

    Declared in "libtorrent/torrent_info.hpp"

    │ │ │ +

    this object holds configuration options for limits to use when loading │ │ │ +torrents. They are meant to prevent loading potentially malicious torrents │ │ │ +that cause excessive memory allocations.

    │ │ │ +
    │ │ │ +struct load_torrent_limits
    │ │ │ +{
    │ │ │ +   int max_buffer_size  = 10000000;
    │ │ │ +   int max_pieces  = 0x200000;
    │ │ │ +   int max_decode_depth  = 100;
    │ │ │ +   int max_decode_tokens  = 3000000;
    │ │ │ +   int max_duplicate_filenames  = 500;
    │ │ │ +   int max_directory_depth  = 100;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    max_buffer_size
    │ │ │ +
    the max size of a .torrent file to load into RAM
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    max_pieces
    │ │ │ +
    the max number of pieces allowed in the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    max_decode_depth
    │ │ │ +
    the max recursion depth in the bdecoded structure
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    max_decode_tokens
    │ │ │ +
    the max number of bdecode tokens
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    max_duplicate_filenames
    │ │ │ +
    the max number of files with same filename allowed in the torrent. │ │ │ +Files with the same filename are disambiguated by appending a │ │ │ +counter. This operation is not cheap and a malicious torrent may pose │ │ │ +a DoS attack, stalling torrent parsing.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    max_directory_depth
    │ │ │ +
    the max depth of the directory structure of files in the torrent. It │ │ │ +protects against malicious torrents with a deeply nested directory │ │ │ +structure.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_info

    │ │ │ +

    Declared in "libtorrent/torrent_info.hpp"

    │ │ │ +

    the torrent_info class holds the information found in a .torrent file.

    │ │ │ +
    │ │ │ +class torrent_info
    │ │ │ +{
    │ │ │ +   explicit torrent_info (info_hash_t const& info_hash);
    │ │ │ +   torrent_info (torrent_info const& t);
    │ │ │ +   torrent_info (bdecode_node const& info_section, error_code& ec
    │ │ │ +      , load_torrent_limits const& cfg
    │ │ │ +      , from_info_section_t);
    │ │ │ +   ~torrent_info ();
    │ │ │ +   file_storage const& layout () const;
    │ │ │ +   std::vector<sha1_hash> similar_torrents () const;
    │ │ │ +   std::vector<std::string> collections () const;
    │ │ │ +   std::int64_t total_size () const;
    │ │ │ +   std::int64_t size_on_disk () const;
    │ │ │ +   int piece_length () const;
    │ │ │ +   int num_pieces () const;
    │ │ │ +   int blocks_per_piece () const;
    │ │ │ +   piece_index_t last_piece () const;
    │ │ │ +   index_range<piece_index_t> piece_range () const;
    │ │ │ +   piece_index_t end_piece () const;
    │ │ │ +   sha1_hash info_hash () const noexcept;
    │ │ │ +   info_hash_t const& info_hashes () const;
    │ │ │ +   bool v1 () const;
    │ │ │ +   bool v2 () const;
    │ │ │ +   int num_files () const;
    │ │ │ +   std::vector<file_slice> map_block (piece_index_t const piece
    │ │ │ +      , std::int64_t offset, int size) const;
    │ │ │ +   peer_request map_file (file_index_t const file, std::int64_t offset, int size) const;
    │ │ │ +   string_view ssl_cert () const;
    │ │ │ +   bool is_valid () const;
    │ │ │ +   bool priv () const;
    │ │ │ +   bool is_i2p () const;
    │ │ │ +   int piece_size (piece_index_t index) const;
    │ │ │ +   int piece_size_for_req (piece_index_t index) const;
    │ │ │ +   sha1_hash hash_for_piece (piece_index_t index) const;
    │ │ │ +   char const* hash_for_piece_ptr (piece_index_t const index) const;
    │ │ │ +   bool is_loaded () const;
    │ │ │ +   const std::string& name () const;
    │ │ │ +   span<char const> info_section () const;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    torrent_info()

    │ │ │ +
    │ │ │ +explicit torrent_info (info_hash_t const& info_hash);
    │ │ │ +
    │ │ │ +

    constructs an empty torrent_info containing only an │ │ │ +info-hash. Useful for magnet links: the resulting object has │ │ │ +no metadata (no file list, no piece hashes) but the info-hash │ │ │ +is set so it can be passed to session::add_torrent().

    │ │ │ +

    This object is not filled in once metadata is received from │ │ │ +peers. The torrent installs a new torrent_info instance │ │ │ +internally rather than updating this one. Retrieve the populated │ │ │ +metadata via torrent_handle::torrent_file().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_info()

    │ │ │ +
    │ │ │ +torrent_info (bdecode_node const& info_section, error_code& ec
    │ │ │ +      , load_torrent_limits const& cfg
    │ │ │ +      , from_info_section_t);
    │ │ │ +
    │ │ │ +

    Construct a torrent_info object from the parsed info-section │ │ │ +pointed to by info_section. The info-section buffer will be copied │ │ │ +into torrent_info.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    ~torrent_info()

    │ │ │ +
    │ │ │ +~torrent_info ();
    │ │ │ +
    │ │ │ +

    frees all storage associated with this torrent_info object

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    layout()

    │ │ │ +
    │ │ │ +file_storage const& layout () const;
    │ │ │ +
    │ │ │ +

    The file_storage object contains the information on how to map the │ │ │ +pieces to files. It is separated from the torrent_info object as the │ │ │ +disk I/O subsystem only needs access to file names and sizes. │ │ │ +The file_storage object is immutable, renamed files are recorded │ │ │ +separately. layout() returns the original filenames, as found in │ │ │ +the .torrent file. Files may be renamed to de-duplicate names, or to │ │ │ +correct invalid filenames.

    │ │ │ +

    For more information on the file_storage object, see the separate │ │ │ +document on how to create torrents.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    collections() similar_torrents()

    │ │ │ +
    │ │ │ +std::vector<sha1_hash> similar_torrents () const;
    │ │ │ +std::vector<std::string> collections () const;
    │ │ │ +
    │ │ │ +

    These two functions are related to BEP 38 (mutable torrents). The │ │ │ +vectors returned from these correspond to the "similar" and │ │ │ +"collections" keys in the .torrent file. Both info-hashes and │ │ │ +collections from within the info-dict and from outside of it are │ │ │ +included.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    total_size()

    │ │ │ +
    │ │ │ +std::int64_t total_size () const;
    │ │ │ +
    │ │ │ +

    total_size() returns the total number of bytes the torrent-file │ │ │ +represents. Note that this is the number of pieces times the piece │ │ │ +size (modulo the last piece possibly being smaller). With pad files, │ │ │ +the total size will be larger than the sum of all (regular) file │ │ │ +sizes.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    size_on_disk()

    │ │ │ +
    │ │ │ +std::int64_t size_on_disk () const;
    │ │ │ +
    │ │ │ +

    returns the sum of all non-pad file sizes. i.e. the files that will │ │ │ +actually be saved to disk by this torrent.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    num_pieces() piece_length()

    │ │ │ +
    │ │ │ +int piece_length () const;
    │ │ │ +int num_pieces () const;
    │ │ │ +
    │ │ │ +

    piece_length() and num_pieces() returns the number of byte │ │ │ +for each piece and the total number of pieces, respectively. The │ │ │ +difference between piece_size() and piece_length() is that │ │ │ +piece_size() takes the piece index as argument and gives you the │ │ │ +exact size of that piece. It will always be the same as │ │ │ +piece_length() except in the case of the last piece, which may be │ │ │ +smaller.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    blocks_per_piece()

    │ │ │ +
    │ │ │ +int blocks_per_piece () const;
    │ │ │ +
    │ │ │ +

    returns the number of blocks there are in the typical piece. There │ │ │ +may be fewer in the last piece)

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    last_piece() end_piece() piece_range()

    │ │ │ +
    │ │ │ +piece_index_t last_piece () const;
    │ │ │ +index_range<piece_index_t> piece_range () const;
    │ │ │ +piece_index_t end_piece () const;
    │ │ │ +
    │ │ │ +

    last_piece() returns the index to the last piece in the torrent and │ │ │ +end_piece() returns the index to the one-past-end piece in the │ │ │ +torrent │ │ │ +piece_range() returns an implementation-defined type that can be │ │ │ +used as the container in a range-for loop. Where the values are the │ │ │ +indices of all pieces in the file_storage.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    info_hash() info_hashes()

    │ │ │ +
    │ │ │ +sha1_hash info_hash () const noexcept;
    │ │ │ +info_hash_t const& info_hashes () const;
    │ │ │ +
    │ │ │ +

    returns the info-hash of the torrent. For BitTorrent v2 support, use │ │ │ +info_hashes() to get an object that may hold both a v1 and v2 │ │ │ +info-hash

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    v1() v2()

    │ │ │ +
    │ │ │ +bool v1 () const;
    │ │ │ +bool v2 () const;
    │ │ │ +
    │ │ │ +

    returns whether this torrent has v1 and/or v2 metadata, respectively. │ │ │ +Hybrid torrents have both. These are shortcuts for │ │ │ +info_hashes().has_v1() and info_hashes().has_v2() calls.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    num_files()

    │ │ │ +
    │ │ │ +int num_files () const;
    │ │ │ +
    │ │ │ +

    If you need index-access to files you can use the num_files() along │ │ │ +with the file_path(), file_size()-family of functions to access │ │ │ +files using indices.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    map_block()

    │ │ │ +
    │ │ │ +std::vector<file_slice> map_block (piece_index_t const piece
    │ │ │ +      , std::int64_t offset, int size) const;
    │ │ │ +
    │ │ │ +

    This function will map a piece index, a byte offset within that piece │ │ │ +and a size (in bytes) into the corresponding files with offsets where │ │ │ +that data for that piece is supposed to be stored. See file_slice.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    map_file()

    │ │ │ +
    │ │ │ +peer_request map_file (file_index_t const file, std::int64_t offset, int size) const;
    │ │ │ +
    │ │ │ +

    This function will map a range in a specific file into a range in the │ │ │ +torrent. The file_offset parameter is the offset in the file, │ │ │ +given in bytes, where 0 is the start of the file. See peer_request.

    │ │ │ +

    The input range is assumed to be valid within the torrent. │ │ │ +file_offset + size is not allowed to be greater than the file │ │ │ +size. file_index must refer to a valid file, i.e. it cannot be >= │ │ │ +num_files().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    ssl_cert()

    │ │ │ +
    │ │ │ +string_view ssl_cert () const;
    │ │ │ +
    │ │ │ +

    Returns the SSL root certificate for the torrent, if it is an SSL │ │ │ +torrent. Otherwise returns an empty string. The certificate is │ │ │ +the public certificate in x509 format.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    is_valid()

    │ │ │ +
    │ │ │ +bool is_valid () const;
    │ │ │ +
    │ │ │ +

    returns true if this torrent_info object has a torrent loaded. │ │ │ +This is primarily used to determine if a magnet link has had its │ │ │ +metadata resolved yet or not.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    priv()

    │ │ │ +
    │ │ │ +bool priv () const;
    │ │ │ +
    │ │ │ +

    returns true if this torrent is private. i.e., the client should not │ │ │ +advertise itself on the trackerless network (the Kademlia DHT) for this torrent.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    is_i2p()

    │ │ │ +
    │ │ │ +bool is_i2p () const;
    │ │ │ +
    │ │ │ +

    returns true if this is an i2p torrent. This is determined by whether │ │ │ +or not it has a tracker whose URL domain name ends with ".i2p". i2p │ │ │ +torrents disable the DHT and local peer discovery as well as talking │ │ │ +to peers over anything other than the i2p network. │ │ │ +This is not reliably set for torrents created via resume data or │ │ │ +magnet links. Prefer using torrent::is_i2p() instead.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_size()

    │ │ │ +
    │ │ │ +int piece_size (piece_index_t index) const;
    │ │ │ +
    │ │ │ +

    returns the piece size of file with index. This will be the same as piece_length(), │ │ │ +except for the last piece, which may be shorter.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_size_for_req()

    │ │ │ +
    │ │ │ +int piece_size_for_req (piece_index_t index) const;
    │ │ │ +
    │ │ │ +

    returns the piece size appropriate for computing request lengths. │ │ │ +for v2-only torrents, pieces at the end of files may be shorter than │ │ │ +the main piece size. For v1 and hybrid torrents, piece sizes must be │ │ │ +full (except for the last piece) in order to correctly compute the │ │ │ +piece hash. │ │ │ +Note: this is not a trivial accessor. For v2-only torrents it calls │ │ │ +file_storage::piece_size2(), which performs an O(log n) upper_bound │ │ │ +over the file list to find the file boundary that may shorten the │ │ │ +piece. Cache the result when calling it repeatedly for the same │ │ │ +piece in a hot path.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    hash_for_piece() hash_for_piece_ptr()

    │ │ │ +
    │ │ │ +sha1_hash hash_for_piece (piece_index_t index) const;
    │ │ │ +char const* hash_for_piece_ptr (piece_index_t const index) const;
    │ │ │ +
    │ │ │ +

    hash_for_piece() takes a piece-index and returns the 20-bytes │ │ │ +sha1-hash for that piece. │ │ │ +hash_for_piece_ptr() returns a pointer to the 20 byte sha1 digest │ │ │ +for the piece. Note that the string is not 0-terminated.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    is_loaded()

    │ │ │ +
    │ │ │ +bool is_loaded () const;
    │ │ │ +
    │ │ │ +

    returns true if the metadata for this torrent has been loaded │ │ │ +(i.e. the file list is populated). For a torrent_info │ │ │ +constructed from just an info-hash this returns false.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    name()

    │ │ │ +
    │ │ │ +const std::string& name () const;
    │ │ │ +
    │ │ │ +

    name() returns the name of the torrent. │ │ │ +name contains UTF-8 encoded string.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    info_section()

    │ │ │ +
    │ │ │ +span<char const> info_section () const;
    │ │ │ +
    │ │ │ +

    returns a the raw info section of the torrent file. │ │ │ +The underlying buffer is still owned by the torrent_info object

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    block_info

    │ │ │ +

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ +

    holds the state of a block in a piece. Who we requested │ │ │ +it from and how far along we are at downloading it.

    │ │ │ +
    │ │ │ +struct block_info
    │ │ │ +{
    │ │ │ +   tcp::endpoint peer () const;
    │ │ │ +   void set_peer (tcp::endpoint const& ep);
    │ │ │ +
    │ │ │ +   enum block_state_t
    │ │ │ +   {
    │ │ │ +      none,
    │ │ │ +      requested,
    │ │ │ +      writing,
    │ │ │ +      finished,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   std::uint16_t num_peers:15;
    │ │ │ +   std::uint32_t bytes_progress:15;
    │ │ │ +   std::uint32_t block_size:15;
    │ │ │ +   std::uint32_t state:2;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    peer() set_peer()

    │ │ │ +
    │ │ │ +tcp::endpoint peer () const;
    │ │ │ +void set_peer (tcp::endpoint const& ep);
    │ │ │ +
    │ │ │ +

    The peer is the ip address of the peer this block was downloaded from.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum block_state_t

    │ │ │ +

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    none0This block has not been downloaded or requested form any peer.
    requested1The block has been requested, but not completely downloaded yet.
    writing2The block has been downloaded and is currently queued for being │ │ │ +written to disk.
    finished3The block has been written to disk.
    │ │ │ +[report issue]
    │ │ │ +
    num_peers
    │ │ │ +
    the number of peers that is currently requesting this block. Typically │ │ │ +this is 0 or 1, but at the end of the torrent blocks may be requested │ │ │ +by more peers in parallel to speed things up.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    bytes_progress
    │ │ │ +
    the number of bytes that have been received for this block
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    block_size
    │ │ │ +
    the total number of bytes in this block.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    state
    │ │ │ +
    the state this block is in (see block_state_t)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    partial_piece_info

    │ │ │ +

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ +

    This class holds information about pieces that have outstanding requests │ │ │ +or outstanding writes

    │ │ │ +
    │ │ │ +struct partial_piece_info
    │ │ │ +{
    │ │ │ +   piece_index_t piece_index;
    │ │ │ +   int blocks_in_piece;
    │ │ │ +   int finished;
    │ │ │ +   int writing;
    │ │ │ +   int requested;
    │ │ │ +   block_info const* blocks;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    piece_index
    │ │ │ +
    the index of the piece in question. blocks_in_piece is the number │ │ │ +of blocks in this particular piece. This number will be the same for │ │ │ +most pieces, but │ │ │ +the last piece may have fewer blocks than the standard pieces.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    blocks_in_piece
    │ │ │ +
    the number of blocks in this piece
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    finished
    │ │ │ +
    the number of blocks that are in the finished state
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    writing
    │ │ │ +
    the number of blocks that are in the writing state
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    requested
    │ │ │ +
    the number of blocks that are in the requested state
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    blocks
    │ │ │ +

    this is an array of blocks_in_piece number of │ │ │ +items. One for each block in the piece.

    │ │ │ +
    │ │ │ +

    Warning

    │ │ │ +

    This is a pointer that points to an array │ │ │ +that's owned by the session object. The next time │ │ │ +get_download_queue() is called, it will be invalidated. │ │ │ +In the case of piece_info_alert, these pointers point into the alert │ │ │ +object itself, and will be invalidated when the alert destruct.

    │ │ │ +
    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_handle

    │ │ │ +

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ +

    You will usually have to store your torrent handles somewhere, since it's │ │ │ +the object through which you retrieve information about the torrent and │ │ │ +aborts the torrent.

    │ │ │ +
    │ │ │ +

    Warning

    │ │ │ +

    Any member function that returns a value or fills in a value has to be │ │ │ +made synchronously. This means it has to wait for the main thread to │ │ │ +complete the query before it can return. This might potentially be │ │ │ +expensive if done from within a GUI thread that needs to stay │ │ │ +responsive. Try to avoid querying for information you don't need, and │ │ │ +try to do it in as few calls as possible. You can get most of the │ │ │ +interesting information about a torrent from the │ │ │ +torrent_handle::status() call.

    │ │ │ +
    │ │ │ +

    The default constructor will initialize the handle to an invalid state. │ │ │ +Which means you cannot perform any operation on it, unless you first │ │ │ +assign it a valid handle. If you try to perform any operation on an │ │ │ +uninitialized handle, it will throw invalid_handle.

    │ │ │ +
    │ │ │ +

    Warning

    │ │ │ +

    All operations on a torrent_handle may throw system_error │ │ │ +exception, in case the handle is no longer referring to a torrent. │ │ │ +There is one exception is_valid() will never throw. Since the torrents │ │ │ +are processed by a background thread, there is no guarantee that a │ │ │ +handle will remain valid between two calls.

    │ │ │ +
    │ │ │ +
    │ │ │ +struct torrent_handle
    │ │ │ +{
    │ │ │ +   friend std::size_t hash_value (torrent_handle const& th);
    │ │ │ +   torrent_handle () noexcept = default;
    │ │ │ +   void add_piece (piece_index_t piece, std::vector<char> data, add_piece_flags_t flags = {}) const;
    │ │ │ +   void add_piece (piece_index_t piece, char const* data, add_piece_flags_t flags = {}) const;
    │ │ │ +   void read_piece (piece_index_t piece) const;
    │ │ │ +   void set_sequential_range (piece_index_t first_piece) const;
    │ │ │ +   void set_sequential_range (piece_index_t first_piece, piece_index_t last_piece) const;
    │ │ │ +   bool have_piece (piece_index_t piece) const;
    │ │ │ +   void get_peer_info (std::vector<peer_info>& v) const;
    │ │ │ +   void post_peer_info () const;
    │ │ │ +   void post_status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ +   torrent_status status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ +   void post_download_queue () const;
    │ │ │ +   void get_download_queue (std::vector<partial_piece_info>& queue) const;
    │ │ │ +   std::vector<partial_piece_info> get_download_queue () const;
    │ │ │ +   void set_piece_deadline (piece_index_t index, int deadline, deadline_flags_t flags = {}) const;
    │ │ │ +   void clear_piece_deadlines () const;
    │ │ │ +   void reset_piece_deadline (piece_index_t index) const;
    │ │ │ +   void post_file_progress (file_progress_flags_t flags) const;
    │ │ │ +   std::vector<std::int64_t> file_progress (file_progress_flags_t flags = {}) const;
    │ │ │ +   void file_progress (std::vector<std::int64_t>& progress, file_progress_flags_t flags = {}) const;
    │ │ │ +   std::vector<open_file_state> file_status () const;
    │ │ │ +   void post_file_status () const;
    │ │ │ +   void clear_error () const;
    │ │ │ +   void post_trackers () const;
    │ │ │ +   std::vector<announce_entry> trackers () const;
    │ │ │ +   void replace_trackers (std::vector<announce_entry> const&) const;
    │ │ │ +   void add_tracker (announce_entry const&) const;
    │ │ │ +   std::set<std::string> url_seeds () const;
    │ │ │ +   void add_url_seed (std::string const& url) const;
    │ │ │ +   void remove_url_seed (std::string const& url) const;
    │ │ │ +   void add_extension (
    │ │ │ +      std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, client_data_t)> const& ext
    │ │ │ +      , client_data_t userdata = client_data_t{});
    │ │ │ +   bool set_metadata (span<char const> metadata) const;
    │ │ │ +   bool is_valid () const;
    │ │ │ +   void resume () const;
    │ │ │ +   void pause (pause_flags_t flags = {}) const;
    │ │ │ +   torrent_flags_t flags () const;
    │ │ │ +   void unset_flags (torrent_flags_t flags) const;
    │ │ │ +   void set_flags (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │ +   void set_flags (torrent_flags_t flags) const;
    │ │ │ +   void flush_cache () const;
    │ │ │ +   void force_recheck () const;
    │ │ │ +   add_torrent_params get_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ +   void save_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ +   bool need_save_resume_data () const;
    │ │ │ +   bool need_save_resume_data (resume_data_flags_t flags) const;
    │ │ │ +   queue_position_t queue_position () const;
    │ │ │ +   void queue_position_down () const;
    │ │ │ +   void queue_position_bottom () const;
    │ │ │ +   void queue_position_up () const;
    │ │ │ +   void queue_position_top () const;
    │ │ │ +   void queue_position_set (queue_position_t p) const;
    │ │ │ +   void set_ssl_certificate (std::string const& certificate
    │ │ │ +      , std::string const& private_key
    │ │ │ +      , std::string const& dh_params
    │ │ │ +      , std::string const& passphrase = "");
    │ │ │ +   void set_ssl_certificate_buffer (std::string const& certificate
    │ │ │ +      , std::string const& private_key
    │ │ │ +      , std::string const& dh_params);
    │ │ │ +   std::shared_ptr<const torrent_info> torrent_file () const;
    │ │ │ +   renamed_files get_renamed_files () const;
    │ │ │ +   std::vector<std::vector<sha256_hash>> piece_layers () const;
    │ │ │ +   void post_piece_availability () const;
    │ │ │ +   void piece_availability (std::vector<int>& avail) const;
    │ │ │ +   std::vector<download_priority_t> get_piece_priorities () const;
    │ │ │ +   void prioritize_pieces (std::vector<download_priority_t> const& pieces) const;
    │ │ │ +   download_priority_t piece_priority (piece_index_t index) const;
    │ │ │ +   void prioritize_pieces (std::vector<std::pair<piece_index_t, download_priority_t>> const& pieces) const;
    │ │ │ +   void piece_priority (piece_index_t index, download_priority_t priority) const;
    │ │ │ +   std::vector<download_priority_t> get_file_priorities () const;
    │ │ │ +   void prioritize_files (std::vector<download_priority_t> const& files) const;
    │ │ │ +   void file_priority (file_index_t index, download_priority_t priority) const;
    │ │ │ +   download_priority_t file_priority (file_index_t index) const;
    │ │ │ +   void post_file_priorities () const;
    │ │ │ +   void force_reannounce (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ +   void force_reannounce (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │ +   void force_lsd_announce () const;
    │ │ │ +   void force_dht_announce () const;
    │ │ │ +   void force_reannounce (int seconds, std::string const& url, reannounce_flags_t = {}) const;
    │ │ │ +   void scrape_tracker (int idx) const;
    │ │ │ +   void scrape_tracker () const;
    │ │ │ +   void scrape_tracker (std::string url) const;
    │ │ │ +   int upload_limit () const;
    │ │ │ +   void set_upload_limit (int limit) const;
    │ │ │ +   int download_limit () const;
    │ │ │ +   void set_download_limit (int limit) const;
    │ │ │ +   void connect_peer (tcp::endpoint const& adr, peer_source_flags_t source = {}
    │ │ │ +      , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const;
    │ │ │ +   void clear_peers ();
    │ │ │ +   void set_max_uploads (int max_uploads) const;
    │ │ │ +   int max_uploads () const;
    │ │ │ +   void set_max_connections (int max_connections) const;
    │ │ │ +   int max_connections () const;
    │ │ │ +   void move_storage (std::string const& save_path
    │ │ │ +      , move_flags_t flags = move_flags_t::always_replace_files
    │ │ │ +      ) const;
    │ │ │ +   void rename_file (file_index_t index, std::string const& new_name) const;
    │ │ │ +   sha1_hash info_hash () const;
    │ │ │ +   info_hash_t info_hashes () const;
    │ │ │ +   bool operator!= (const torrent_handle& h) const;
    │ │ │ +   bool operator< (const torrent_handle& h) const;
    │ │ │ +   bool operator== (const torrent_handle& h) const;
    │ │ │ +   std::uint32_t id () const;
    │ │ │ +   std::shared_ptr<aux::torrent> native_handle () const;
    │ │ │ +   client_data_t userdata () const;
    │ │ │ +   bool in_session () const;
    │ │ │ +
    │ │ │ +   static inline constexpr add_piece_flags_t overwrite_existing  = 0_bit;
    │ │ │ +   static inline constexpr status_flags_t query_distributed_copies  = 0_bit;
    │ │ │ +   static inline constexpr status_flags_t query_accurate_download_counters  = 1_bit;
    │ │ │ +   static inline constexpr status_flags_t query_last_seen_complete  = 2_bit;
    │ │ │ +   static inline constexpr status_flags_t query_pieces  = 3_bit;
    │ │ │ +   static inline constexpr status_flags_t query_verified_pieces  = 4_bit;
    │ │ │ +   static inline constexpr status_flags_t query_torrent_file  = 5_bit;
    │ │ │ +   static inline constexpr status_flags_t query_name  = 6_bit;
    │ │ │ +   static inline constexpr status_flags_t query_save_path  = 7_bit;
    │ │ │ +   static inline constexpr status_flags_t query_renamed_files  = 8_bit;
    │ │ │ +   static inline constexpr deadline_flags_t alert_when_available  = 0_bit;
    │ │ │ +   static constexpr file_progress_flags_t piece_granularity  = 0_bit;
    │ │ │ +   static inline constexpr pause_flags_t graceful_pause  = 0_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t flush_disk_cache  = 0_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t save_info_dict  = 1_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t if_counters_changed  = 3_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t if_download_progress  = 4_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t if_config_changed  = 5_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t if_state_changed  = 6_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t if_metadata_changed  = 7_bit;
    │ │ │ +   static inline constexpr resume_data_flags_t only_if_modified  = if_metadata_changed
    │ │ │ +   | if_counters_changed;
    │ │ │ +   static inline constexpr reannounce_flags_t ignore_min_interval  = 0_bit;
    │ │ │ +   static constexpr reannounce_flags_t high_priority  = 1_bit;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    hash_value()

    │ │ │ +
    │ │ │ +friend std::size_t hash_value (torrent_handle const& th);
    │ │ │ +
    │ │ │ +

    ADL hook for boost::hash and the hash specialization for │ │ │ +torrent_handle. Two handles that refer to the same torrent │ │ │ +hash to the same value.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_handle()

    │ │ │ +
    │ │ │ +torrent_handle () noexcept = default;
    │ │ │ +
    │ │ │ +

    constructs a torrent handle that does not refer to a torrent. │ │ │ +i.e. is_valid() will return false.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_piece()

    │ │ │ +
    │ │ │ +void add_piece (piece_index_t piece, std::vector<char> data, add_piece_flags_t flags = {}) const;
    │ │ │ +void add_piece (piece_index_t piece, char const* data, add_piece_flags_t flags = {}) const;
    │ │ │ +
    │ │ │ +

    This function will write data to the storage as piece piece, │ │ │ +as if it had been downloaded from a peer.

    │ │ │ +

    By default, data that's already been downloaded is not overwritten by │ │ │ +this buffer. If you trust this data to be correct (and pass the piece │ │ │ +hash check) you may pass the overwrite_existing flag. This will │ │ │ +instruct libtorrent to overwrite any data that may already have been │ │ │ +downloaded with this data.

    │ │ │ +

    Since the data is written asynchronously, you may know that is passed │ │ │ +or failed the hash check by waiting for piece_finished_alert or │ │ │ +hash_failed_alert.

    │ │ │ +

    Adding pieces while the torrent is being checked (i.e. in │ │ │ +torrent_status::checking_files state) is not supported.

    │ │ │ +

    The overload taking a raw pointer to the data is a blocking call. It │ │ │ +won't return until the libtorrent thread has copied the data into its │ │ │ +disk write buffer. data is expected to point to a buffer of as │ │ │ +many bytes as the size of the specified piece. │ │ │ +For v2-only torrents, pieces at the end of files may not be full sized.

    │ │ │ +

    The data in the buffer is copied and passed on to the disk IO thread │ │ │ +to be written at some later point in time.

    │ │ │ +

    The overload taking a std::vector<char> is not blocking, it will │ │ │ +send the buffer to the main thread and return immediately.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    read_piece()

    │ │ │ +
    │ │ │ +void read_piece (piece_index_t piece) const;
    │ │ │ +
    │ │ │ +

    This function starts an asynchronous read operation of the specified │ │ │ +piece from this torrent. You must have completed the download of the │ │ │ +specified piece before calling this function.

    │ │ │ +

    When the read operation is completed, it is passed back through an │ │ │ +alert, read_piece_alert. Since this alert is a response to an explicit │ │ │ +call, it will always be posted, regardless of the alert mask.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    that if you read multiple pieces, the read operations are not │ │ │ +guaranteed to finish in the same order as you initiated them.

    │ │ │ +
    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    the size of the buffer passed back in the alert is not │ │ │ +necessarily piece_length() long. The last piece or pieces at the end │ │ │ +of files (in v2 and hybrid torrents) are not full size.

    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_sequential_range()

    │ │ │ +
    │ │ │ +void set_sequential_range (piece_index_t first_piece) const;
    │ │ │ +void set_sequential_range (piece_index_t first_piece, piece_index_t last_piece) const;
    │ │ │ +
    │ │ │ +

    These functions set the first piece and the last piece of the range │ │ │ +for the piece picker. They start downloading from the specified piece │ │ │ +in sequential download mode, which is enabled. If the last piece is │ │ │ +omitted then it is implicitly set to the end of the file the first │ │ │ +piece is set to. If the torrent metadata has not been downloaded yet │ │ │ +then the functions do nothing.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    have_piece()

    │ │ │ +
    │ │ │ +bool have_piece (piece_index_t piece) const;
    │ │ │ +
    │ │ │ +

    Returns true if this piece has been completely downloaded and written │ │ │ +to disk, and false otherwise.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_peer_info() post_peer_info()

    │ │ │ +
    │ │ │ +void get_peer_info (std::vector<peer_info>& v) const;
    │ │ │ +void post_peer_info () const;
    │ │ │ +
    │ │ │ +

    Query information about connected peers for this torrent. If the │ │ │ +torrent_handle is invalid, it will throw a system_error exception.

    │ │ │ +

    post_peer_info() is asynchronous and will trigger the posting of │ │ │ +a peer_info_alert. The alert contain a list of peer_info objects, one │ │ │ +for each connected peer.

    │ │ │ +

    get_peer_info() is synchronous and takes a reference to a vector │ │ │ +that will be cleared and filled with one entry for each peer │ │ │ +connected to this torrent, given the handle is valid. Each entry in │ │ │ +the vector contains information about that particular peer. See │ │ │ +peer_info.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    status() post_status()

    │ │ │ +
    │ │ │ +void post_status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ +torrent_status status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ +
    │ │ │ +

    status() will return a structure with information about the status │ │ │ +of this torrent. If the torrent_handle is invalid, it will throw │ │ │ +system_error exception. See torrent_status. The flags │ │ │ +argument filters what information is returned in the torrent_status. │ │ │ +Some information in there is relatively expensive to calculate, and if │ │ │ +you're not interested in it (and see performance issues), you can │ │ │ +filter them out.

    │ │ │ +

    The status() function will block until the internal libtorrent │ │ │ +thread responds with the torrent_status object. To avoid blocking, │ │ │ +instead call post_status(). It will trigger posting of a │ │ │ +state_update_alert with a single torrent_status object for this │ │ │ +torrent.

    │ │ │ +

    In order to get regular updates for torrents whose status changes, │ │ │ +consider calling session::post_torrent_updates()`` instead.

    │ │ │ +

    By default everything is included. The flags you can use to decide │ │ │ +what to include are defined in this class.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_download_queue() get_download_queue()

    │ │ │ +
    │ │ │ +void post_download_queue () const;
    │ │ │ +void get_download_queue (std::vector<partial_piece_info>& queue) const;
    │ │ │ +std::vector<partial_piece_info> get_download_queue () const;
    │ │ │ +
    │ │ │ +

    post_download_queue() triggers a download_queue_alert to be │ │ │ +posted. │ │ │ +get_download_queue() is a synchronous call and returns a vector │ │ │ +with information about pieces that are partially downloaded or not │ │ │ +downloaded but partially requested. See partial_piece_info for the │ │ │ +fields in the returned vector.

    │ │ │ +
    │ │ │ +

    Warning

    │ │ │ +

    get_download_queue() is prone to threading errors. The │ │ │ +block_info pointers its return value points to are owned by the │ │ │ +session and will be cleared the next time get_download_queue() │ │ │ +is called. Therefore it's not safe to call this function from │ │ │ +multiple threads. Using post_download_queue() is a safe │ │ │ +alternative.

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    clear_piece_deadlines() set_piece_deadline() reset_piece_deadline()

    │ │ │ +
    │ │ │ +void set_piece_deadline (piece_index_t index, int deadline, deadline_flags_t flags = {}) const;
    │ │ │ +void clear_piece_deadlines () const;
    │ │ │ +void reset_piece_deadline (piece_index_t index) const;
    │ │ │ +
    │ │ │ +

    This function sets or resets the deadline associated with a specific │ │ │ +piece index (index). libtorrent will attempt to download this │ │ │ +entire piece before the deadline expires. This is not necessarily │ │ │ +possible, but pieces with a more recent deadline will always be │ │ │ +prioritized over pieces with a deadline further ahead in time. The │ │ │ +deadline (and flags) of a piece can be changed by calling this │ │ │ +function again.

    │ │ │ +

    If the piece is already downloaded when this call is made, nothing │ │ │ +happens, unless the alert_when_available flag is set, in which case it │ │ │ +will have the same effect as calling read_piece() for index.

    │ │ │ +

    deadline is the number of milliseconds until this piece should be │ │ │ +completed.

    │ │ │ +

    reset_piece_deadline removes the deadline from the piece. If it │ │ │ +hasn't already been downloaded, it will no longer be considered a │ │ │ +priority.

    │ │ │ +

    clear_piece_deadlines() removes deadlines on all pieces in │ │ │ +the torrent. As if reset_piece_deadline() was called on all pieces.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_progress() post_file_progress()

    │ │ │ +
    │ │ │ +void post_file_progress (file_progress_flags_t flags) const;
    │ │ │ +std::vector<std::int64_t> file_progress (file_progress_flags_t flags = {}) const;
    │ │ │ +void file_progress (std::vector<std::int64_t>& progress, file_progress_flags_t flags = {}) const;
    │ │ │ +
    │ │ │ +

    This function fills in the supplied vector, or returns a vector, with │ │ │ +the number of bytes downloaded of each file in this torrent. The │ │ │ +progress values are ordered the same as the files in the │ │ │ +torrent_info.

    │ │ │ +

    This operation is not very cheap. Its complexity is O(n + mj). │ │ │ +Where n is the number of files, m is the number of currently │ │ │ +downloading pieces and j is the number of blocks in a piece.

    │ │ │ +

    The flags parameter can be used to specify the granularity of the │ │ │ +file progress. If left at the default value of 0, the progress will be │ │ │ +as accurate as possible, but also more expensive to calculate. If │ │ │ +torrent_handle::piece_granularity is specified, the progress will │ │ │ +be specified in piece granularity. i.e. only pieces that have been │ │ │ +fully downloaded and passed the hash check count. When specifying │ │ │ +piece granularity, the operation is a lot cheaper, since libtorrent │ │ │ +already keeps track of this internally and no calculation is required.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_status() post_file_status()

    │ │ │ +
    │ │ │ +std::vector<open_file_state> file_status () const;
    │ │ │ +void post_file_status () const;
    │ │ │ +
    │ │ │ +

    file_status() returns a vector with status about files │ │ │ +that are open for this torrent. Any file that is not open │ │ │ +will not be reported in the vector, i.e. it's possible that │ │ │ +the vector is empty when returning, if none of the files in the │ │ │ +torrent are currently open.

    │ │ │ +

    post_file_status() will trigger a file_status_alert to be posted, │ │ │ +containing the open-file state of all currently open files in the torrent.

    │ │ │ +

    See open_file_state

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    clear_error()

    │ │ │ +
    │ │ │ +void clear_error () const;
    │ │ │ +
    │ │ │ +

    If the torrent is in an error state (i.e. torrent_status::error is │ │ │ +non-empty), this will clear the error and start the torrent again.

    │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_trackers() replace_trackers() trackers() add_tracker()

    │ │ │ +
    │ │ │ +void post_trackers () const;
    │ │ │ +std::vector<announce_entry> trackers () const;
    │ │ │ +void replace_trackers (std::vector<announce_entry> const&) const;
    │ │ │ +void add_tracker (announce_entry const&) const;
    │ │ │ +
    │ │ │ +

    trackers() returns the list of trackers for this torrent. The │ │ │ +announce entry contains both a string url which specify the │ │ │ +announce url for the tracker as well as an int tier, which is │ │ │ +specifies the order in which this tracker is tried. If you want │ │ │ +libtorrent to use another list of trackers for this torrent, you can │ │ │ +use replace_trackers() which takes a list of the same form as the │ │ │ +one returned from trackers() and will replace it. If you want an │ │ │ +immediate effect, you have to call force_reannounce(). See │ │ │ +announce_entry.

    │ │ │ +

    post_trackers() is the asynchronous version of trackers(). It │ │ │ +will trigger a tracker_list_alert to be posted.

    │ │ │ +

    add_tracker() will look if the specified tracker is already in the │ │ │ +set. If it is, it doesn't do anything. If it's not in the current set │ │ │ +of trackers, it will insert it in the tier specified in the │ │ │ +announce_entry.

    │ │ │ +

    The updated set of trackers will be saved in the resume data, and when │ │ │ +a torrent is started with resume data, the trackers from the resume │ │ │ +data will replace the original ones.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_url_seed() remove_url_seed() url_seeds()

    │ │ │ +
    │ │ │ +std::set<std::string> url_seeds () const;
    │ │ │ +void add_url_seed (std::string const& url) const;
    │ │ │ +void remove_url_seed (std::string const& url) const;
    │ │ │ +
    │ │ │ +

    add_url_seed() adds another url to the torrent's list of url │ │ │ +seeds. If the given url already exists in that list, the call has no │ │ │ +effect. The torrent will connect to the server and try to download │ │ │ +pieces from it, unless it's paused, queued, checking or seeding. │ │ │ +remove_url_seed() removes the given url if it exists already. │ │ │ +url_seeds() return a set of the url seeds currently in this │ │ │ +torrent. Note that URLs that fails may be removed automatically from │ │ │ +the list.

    │ │ │ +

    See http seeding for more information.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_extension()

    │ │ │ +
    │ │ │ +void add_extension (
    │ │ │ +      std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, client_data_t)> const& ext
    │ │ │ +      , client_data_t userdata = client_data_t{});
    │ │ │ +
    │ │ │ +

    add the specified extension to this torrent. The ext argument is │ │ │ +a function that will be called from within libtorrent's context │ │ │ +passing in the internal torrent object and the specified userdata │ │ │ +pointer. The function is expected to return a shared pointer to │ │ │ +a torrent_plugin instance.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_metadata()

    │ │ │ +
    │ │ │ +bool set_metadata (span<char const> metadata) const;
    │ │ │ +
    │ │ │ +

    set_metadata expects the info section of metadata. i.e. The │ │ │ +buffer passed in will be hashed and verified against the info-hash. If │ │ │ +it fails, a metadata_failed_alert will be generated. If it passes, │ │ │ +a metadata_received_alert is generated. The function returns true │ │ │ +if the metadata is successfully set on the torrent, and false │ │ │ +otherwise. If the torrent already has metadata, this function will not │ │ │ +affect the torrent, and false will be returned.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    is_valid()

    │ │ │ +
    │ │ │ +bool is_valid () const;
    │ │ │ +
    │ │ │ +

    Returns true if this handle refers to a valid torrent and false if it │ │ │ +hasn't been initialized or if the torrent it refers to has been │ │ │ +removed from the session AND destructed.

    │ │ │ +

    To tell if the torrent_handle is in the session, use │ │ │ +torrent_handle::in_session(). This will return true before │ │ │ +session_handle::remove_torrent() is called, and false │ │ │ +afterward.

    │ │ │ +

    Clients should only use is_valid() to determine if the result of │ │ │ +session::find_torrent() was successful.

    │ │ │ +

    Unlike other member functions which return a value, is_valid() │ │ │ +completes immediately, without blocking on a result from the │ │ │ +network thread. Also unlike other functions, it never throws │ │ │ +the system_error exception.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    pause() resume()

    │ │ │ +
    │ │ │ +void resume () const;
    │ │ │ +void pause (pause_flags_t flags = {}) const;
    │ │ │ +
    │ │ │ +

    pause(), and resume() will disconnect all peers and reconnect │ │ │ +all peers respectively. When a torrent is paused, it will however │ │ │ +remember all share ratios to all peers and remember all potential (not │ │ │ +connected) peers. Torrents may be paused automatically if there is a │ │ │ +file error (e.g. disk full) or something similar. See │ │ │ +file_error_alert.

    │ │ │ +

    For possible values of the flags parameter, see pause_flags_t.

    │ │ │ +

    To know if a torrent is paused or not, call │ │ │ +torrent_handle::flags() and check for the │ │ │ +torrent_status::paused flag.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    Torrents that are auto-managed may be automatically resumed again. It │ │ │ +does not make sense to pause an auto-managed torrent without making it │ │ │ +not auto-managed first. Torrents are auto-managed by default when added │ │ │ +to the session. For more information, see queuing.

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    unset_flags() flags() set_flags()

    │ │ │ +
    │ │ │ +torrent_flags_t flags () const;
    │ │ │ +void unset_flags (torrent_flags_t flags) const;
    │ │ │ +void set_flags (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │ +void set_flags (torrent_flags_t flags) const;
    │ │ │ +
    │ │ │ +

    sets and gets the torrent state flags. See torrent_flags_t. │ │ │ +The set_flags overload that take a mask will affect all │ │ │ +flags part of the mask, and set their values to what the │ │ │ +flags argument is set to. This allows clearing and │ │ │ +setting flags in a single function call. │ │ │ +The set_flags overload that just takes flags, sets all │ │ │ +the specified flags and leave any other flags unchanged. │ │ │ +unset_flags clears the specified flags, while leaving │ │ │ +any other flags unchanged.

    │ │ │ +

    The seed_mode flag is special, it can only be cleared once the │ │ │ +torrent has been added, and it can only be set as part of the │ │ │ +add_torrent_params flags, when adding the torrent.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    flush_cache()

    │ │ │ +
    │ │ │ +void flush_cache () const;
    │ │ │ +
    │ │ │ +

    Instructs libtorrent to flush all the disk caches for this torrent and │ │ │ +close all file handles. This is done asynchronously and you will be │ │ │ +notified that it's complete through cache_flushed_alert.

    │ │ │ +

    Note that by the time you get the alert, libtorrent may have cached │ │ │ +more data for the torrent, but you are guaranteed that whatever cached │ │ │ +data libtorrent had by the time you called │ │ │ +torrent_handle::flush_cache() has been written to disk.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    force_recheck()

    │ │ │ +
    │ │ │ +void force_recheck () const;
    │ │ │ +
    │ │ │ +

    force_recheck puts the torrent back in a state where it assumes to │ │ │ +have no resume data. All peers will be disconnected and the torrent │ │ │ +will stop announcing to the tracker. The torrent will be added to the │ │ │ +checking queue, and will be checked (all the files will be read and │ │ │ +compared to the piece hashes). Once the check is complete, the torrent │ │ │ +will start connecting to peers again, as normal. │ │ │ +The torrent will be placed last in queue, i.e. its queue position │ │ │ +will be the highest of all torrents in the session.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    save_resume_data() get_resume_data()

    │ │ │ +
    │ │ │ +add_torrent_params get_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ +void save_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ +
    │ │ │ +

    save_resume_data() and get_resume_data() asks libtorrent to │ │ │ +generate fast-resume data for this torrent. The fast resume data │ │ │ +(stored in an add_torrent_params object) can be used to resume a │ │ │ +torrent in the next session without having to check all files for │ │ │ +which pieces have been downloaded. It can also be used to save a │ │ │ +.torrent file for a torrent_handle.

    │ │ │ +

    `get_resume_data() is synchronous and will block the calling │ │ │ +thread until the resume data is ready and returned from the │ │ │ +libtorrent main thread. │ │ │ +/ │ │ │ +save_resume_data() is asynchronous. It will return immediately │ │ │ +and deliver the resume data is when it's done through a │ │ │ +save_resume_data_alert.

    │ │ │ +

    The operation will fail, and post a save_resume_data_failed_alert │ │ │ +instead, in the following cases:

    │ │ │ +
    │ │ │ +
      │ │ │ +
    1. The torrent is in the process of being removed.
    2. │ │ │ +
    3. No torrent state has changed since the last saving of resume │ │ │ +data, and the only_if_modified flag is set. │ │ │ +metadata (see libtorrent's metadata from peers extension)
    4. │ │ │ +
    │ │ │ +
    │ │ │ +

    Note that some counters may be outdated by the time you receive the fast resume data

    │ │ │ +

    When saving resume data because of shutting down, make sure not to │ │ │ +remove_torrent() before you receive the save_resume_data_alert. │ │ │ +There's no need to pause the session or torrent when saving resume │ │ │ +data.

    │ │ │ +

    The paused state of a torrent is saved in the resume data, so pausing │ │ │ +all torrents before saving resume data will all torrents be restored │ │ │ +in a paused state.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    It is typically a good idea to save resume data whenever a torrent │ │ │ +is completed or paused. If you save resume data for torrents when they are │ │ │ +paused, you can accelerate the shutdown process by not saving resume │ │ │ +data again for those torrents. Completed torrents should have their │ │ │ +resume data saved when they complete and on exit, since their │ │ │ +statistics might be updated.

    │ │ │ +
    │ │ │ +

    Example code to pause and save resume data for all torrents and wait │ │ │ +for the alerts:

    │ │ │ +
    │ │ │ +extern int outstanding_resume_data; // global counter of outstanding resume data
    │ │ │ +std::vector<torrent_handle> handles = ses.get_torrents();
    │ │ │ +for (torrent_handle const& h : handles) try
    │ │ │ +{
    │ │ │ +        h.save_resume_data(torrent_handle::only_if_modified);
    │ │ │ +        ++outstanding_resume_data;
    │ │ │ +}
    │ │ │ +catch (lt::system_error const& e)
    │ │ │ +{
    │ │ │ +        // the handle was invalid, ignore this one and move to the next
    │ │ │ +}
    │ │ │ +
    │ │ │ +while (outstanding_resume_data > 0)
    │ │ │ +{
    │ │ │ +        // if we don't get an alert within 30 seconds, abort
    │ │ │ +        if (!ses.wait_for_alert(seconds(30))) break;
    │ │ │ +
    │ │ │ +        std::vector<alert*> alerts;
    │ │ │ +        ses.pop_alerts(&alerts);
    │ │ │ +
    │ │ │ +        for (alert* i : alerts)
    │ │ │ +        {
    │ │ │ +                if (alert_cast<save_resume_data_failed_alert>(i))
    │ │ │ +                {
    │ │ │ +                        process_alert(i);
    │ │ │ +                        --outstanding_resume_data;
    │ │ │ +                        continue;
    │ │ │ +                }
    │ │ │ +
    │ │ │ +                save_resume_data_alert const* rd = alert_cast<save_resume_data_alert>(i);
    │ │ │ +                if (rd == nullptr)
    │ │ │ +                {
    │ │ │ +                        process_alert(i);
    │ │ │ +                        continue;
    │ │ │ +                }
    │ │ │ +
    │ │ │ +                std::ofstream out((rd->params.save_path
    │ │ │ +                        + "/" + rd->params.name + ".fastresume").c_str()
    │ │ │ +                        , std::ios_base::binary);
    │ │ │ +                std::vector<char> buf = write_resume_data_buf(rd->params);
    │ │ │ +                out.write(buf.data(), buf.size());
    │ │ │ +                --outstanding_resume_data;
    │ │ │ +        }
    │ │ │ +}
    │ │ │ +
    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    Note how outstanding_resume_data is a global counter in this │ │ │ +example. This is deliberate, otherwise there is a race condition for │ │ │ +torrents that was just asked to save their resume data, they posted │ │ │ +the alert, but it has not been received yet. Those torrents would │ │ │ +report that they don't need to save resume data again, and skipped by │ │ │ +the initial loop, and thwart the counter otherwise.

    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    need_save_resume_data()

    │ │ │ +
    │ │ │ +bool need_save_resume_data () const;
    │ │ │ +bool need_save_resume_data (resume_data_flags_t flags) const;
    │ │ │ +
    │ │ │ +

    This function returns true if anything that is stored in the resume │ │ │ +data has changed since the last time resume data was saved. │ │ │ +The overload that takes flags let you ask if specific categories │ │ │ +of properties have changed. These flags have the same behavior as in │ │ │ +the save_resume_data() call.

    │ │ │ +

    This is a blocking call. It will wait for a response from │ │ │ +libtorrent's main thread. A way to avoid blocking is to instead │ │ │ +call save_resume_data() directly, specifying the conditions under │ │ │ +which resume data should be saved.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    A torrent's resume data is considered saved as soon as the │ │ │ +save_resume_data_alert is posted. It is important to make sure this │ │ │ +alert is received and handled in order for this function to be │ │ │ +meaningful.

    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    queue_position_down() queue_position_up() queue_position_top() queue_position_bottom() queue_position()

    │ │ │ +
    │ │ │ +queue_position_t queue_position () const;
    │ │ │ +void queue_position_down () const;
    │ │ │ +void queue_position_bottom () const;
    │ │ │ +void queue_position_up () const;
    │ │ │ +void queue_position_top () const;
    │ │ │ +
    │ │ │ +

    Every torrent that is added is assigned a queue position exactly one │ │ │ +greater than the greatest queue position of all existing torrents. │ │ │ +Torrents that are being seeded have -1 as their queue position, since │ │ │ +they're no longer in line to be downloaded.

    │ │ │ +

    When a torrent is removed or turns into a seed, all torrents with │ │ │ +greater queue positions have their positions decreased to fill in the │ │ │ +space in the sequence.

    │ │ │ +

    queue_position() returns the torrent's position in the download │ │ │ +queue. The torrents with the smallest numbers are the ones that are │ │ │ +being downloaded. The smaller number, the closer the torrent is to the │ │ │ +front of the line to be started.

    │ │ │ +

    The queue position is also available in the torrent_status.

    │ │ │ +

    The queue_position_*() functions adjust the torrents position in │ │ │ +the queue. Up means closer to the front and down means closer to the │ │ │ +back of the queue. Top and bottom refers to the front and the back of │ │ │ +the queue respectively.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    queue_position_set()

    │ │ │ +
    │ │ │ +void queue_position_set (queue_position_t p) const;
    │ │ │ +
    │ │ │ +

    updates the position in the queue for this torrent. The relative order │ │ │ +of all other torrents remain intact but their numerical queue position │ │ │ +shifts to make space for this torrent's new position

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_ssl_certificate_buffer() set_ssl_certificate()

    │ │ │ +
    │ │ │ +void set_ssl_certificate (std::string const& certificate
    │ │ │ +      , std::string const& private_key
    │ │ │ +      , std::string const& dh_params
    │ │ │ +      , std::string const& passphrase = "");
    │ │ │ +void set_ssl_certificate_buffer (std::string const& certificate
    │ │ │ +      , std::string const& private_key
    │ │ │ +      , std::string const& dh_params);
    │ │ │ +
    │ │ │ +

    For SSL torrents, use this to specify a path to a .pem file to use as │ │ │ +this client's certificate. The certificate must be signed by the │ │ │ +certificate in the .torrent file to be valid.

    │ │ │ +

    The set_ssl_certificate_buffer() overload takes the actual certificate, │ │ │ +private key and DH params as strings, rather than paths to files.

    │ │ │ +

    cert is a path to the (signed) certificate in .pem format │ │ │ +corresponding to this torrent.

    │ │ │ +

    private_key is a path to the private key for the specified │ │ │ +certificate. This must be in .pem format.

    │ │ │ +

    dh_params is a path to the Diffie-Hellman parameter file, which │ │ │ +needs to be in .pem format. You can generate this file using the │ │ │ +openssl command like this: openssl dhparam -outform PEM -out │ │ │ +dhparams.pem 512.

    │ │ │ +

    passphrase may be specified if the private key is encrypted and │ │ │ +requires a passphrase to be decrypted.

    │ │ │ +

    Note that when a torrent first starts up, and it needs a certificate, │ │ │ +it will suspend connecting to any peers until it has one. It's │ │ │ +typically desirable to resume the torrent after setting the SSL │ │ │ +certificate.

    │ │ │ +

    If you receive a torrent_need_cert_alert, you need to call this to │ │ │ +provide a valid cert. If you don't have a cert you won't be allowed to │ │ │ +connect to any peers.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_file()

    │ │ │ +
    │ │ │ +std::shared_ptr<const torrent_info> torrent_file () const;
    │ │ │ +
    │ │ │ +

    torrent_file() returns a pointer to the torrent_info object │ │ │ +associated with this torrent. The torrent_info object may be a copy │ │ │ +of the internal object. If the torrent doesn't have metadata, the │ │ │ +pointer will not be initialized (i.e. a nullptr). The torrent may be │ │ │ +in a state without metadata only if it was started without a .torrent │ │ │ +file, e.g. by being added by magnet link.

    │ │ │ +

    Note that the torrent_info object returned here may be a different │ │ │ +instance than the one added to the session, with different attributes │ │ │ +like piece layers, dht nodes and trackers. A torrent_info object does │ │ │ +not round-trip cleanly when added to a session.

    │ │ │ +

    If you want to save a .torrent file from the torrent_handle, instead │ │ │ +call save_resume_data() and write_torrent_file() the │ │ │ +add_torrent_params object passed back in the alert.

    │ │ │ +

    Note that a torrent added from a magnet link may not have the full │ │ │ +merkle trees for all files, and hence not have the complete piece │ │ │ +layers. In that state, you cannot create a .torrent file from the │ │ │ +torrent_info returned. Once the torrent completes downloading all │ │ │ +files, becoming a seed, you can make a .torrent file from it.

    │ │ │ +

    If any files in the torrent have been renamed, using │ │ │ +torrent_handle::rename_file(), the new names will not be reflected │ │ │ +in the returned torrent_info object.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_renamed_files()

    │ │ │ +
    │ │ │ +renamed_files get_renamed_files () const;
    │ │ │ +
    │ │ │ +

    Returns a copy of the renamed_files object for this torrent. This │ │ │ +records all file renames applied via torrent_handle::rename_file(). │ │ │ +To get a complete view of the current file layout (original names │ │ │ +plus any renames), combine this with the file_storage from │ │ │ +torrent_file()->layout():

    │ │ │ +
    │ │ │ +auto tf = handle.torrent_file();
    │ │ │ +auto renames = handle.get_renamed_files();
    │ │ │ +lt::filenames fn(tf->layout(), renames);
    │ │ │ +for (auto i : fn.file_range())
    │ │ │ +        std::cout << fn.file_path(i) << "\n";
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_layers()

    │ │ │ +
    │ │ │ +std::vector<std::vector<sha256_hash>> piece_layers () const;
    │ │ │ +
    │ │ │ +

    returns the piece layers for all files in the torrent. If this is a │ │ │ +v1 torrent (and doesn't have any piece layers) it returns an empty │ │ │ +vector. This is a blocking call that will synchronize with the │ │ │ +libtorrent network thread.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_piece_availability() piece_availability()

    │ │ │ +
    │ │ │ +void post_piece_availability () const;
    │ │ │ +void piece_availability (std::vector<int>& avail) const;
    │ │ │ +
    │ │ │ +

    The piece availability is the number of peers that we are connected │ │ │ +that has advertised having a particular piece. This is the information │ │ │ +that libtorrent uses in order to prefer picking rare pieces.

    │ │ │ +

    post_piece_availability() will trigger a piece_availability_alert │ │ │ +to be posted.

    │ │ │ +

    piece_availability() fills the specified std::vector<int> │ │ │ +with the availability for each piece in this torrent. libtorrent does │ │ │ +not keep track of availability for seeds, so if the torrent is │ │ │ +seeding the availability for all pieces is reported as 0.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_piece_priorities() prioritize_pieces() piece_priority()

    │ │ │ +
    │ │ │ +std::vector<download_priority_t> get_piece_priorities () const;
    │ │ │ +void prioritize_pieces (std::vector<download_priority_t> const& pieces) const;
    │ │ │ +download_priority_t piece_priority (piece_index_t index) const;
    │ │ │ +void prioritize_pieces (std::vector<std::pair<piece_index_t, download_priority_t>> const& pieces) const;
    │ │ │ +void piece_priority (piece_index_t index, download_priority_t priority) const;
    │ │ │ +
    │ │ │ +

    These functions are used to set and get the priority of individual │ │ │ +pieces. By default all pieces have priority 4. That means that the │ │ │ +random rarest first algorithm is effectively active for all pieces. │ │ │ +You may however change the priority of individual pieces. There are 8 │ │ │ +priority levels. 0 means not to download the piece at all. Otherwise, │ │ │ +lower priority values means less likely to be picked. Piece priority │ │ │ +takes precedence over piece availability. Every piece with priority 7 │ │ │ +will be attempted to be picked before a priority 6 piece and so on.

    │ │ │ +

    The default priority of pieces is 4.

    │ │ │ +

    Piece priorities can not be changed for torrents that have not │ │ │ +downloaded the metadata yet. Magnet links won't have metadata │ │ │ +immediately. see the metadata_received_alert.

    │ │ │ +

    piece_priority sets or gets the priority for an individual piece, │ │ │ +specified by index.

    │ │ │ +

    prioritize_pieces takes a vector of integers, one integer per │ │ │ +piece in the torrent. All the piece priorities will be updated with │ │ │ +the priorities in the vector. │ │ │ +The second overload of prioritize_pieces that takes a vector of pairs │ │ │ +will update the priorities of only select pieces, and leave all other │ │ │ +unaffected. Each pair is (piece, priority). That is, the first item is │ │ │ +the piece index and the second item is the priority of that piece. │ │ │ +Invalid entries, where the piece index or priority is out of range, are │ │ │ +not allowed.

    │ │ │ +

    get_piece_priorities returns a vector with one element for each piece │ │ │ +in the torrent. Each element is the current priority of that piece.

    │ │ │ +

    It's possible to cancel the effect of file priorities by setting the │ │ │ +priorities for the affected pieces. Care has to be taken when mixing │ │ │ +usage of file- and piece priorities.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_file_priorities() prioritize_files() file_priority()

    │ │ │ +
    │ │ │ +std::vector<download_priority_t> get_file_priorities () const;
    │ │ │ +void prioritize_files (std::vector<download_priority_t> const& files) const;
    │ │ │ +void file_priority (file_index_t index, download_priority_t priority) const;
    │ │ │ +download_priority_t file_priority (file_index_t index) const;
    │ │ │ +
    │ │ │ +

    index must be in the range [0, number_of_files).

    │ │ │ +

    file_priority() queries or sets the priority of file index.

    │ │ │ +

    prioritize_files() takes a vector that has at as many elements as │ │ │ +there are files in the torrent. Each entry is the priority of that │ │ │ +file. The function sets the priorities of all the pieces in the │ │ │ +torrent based on the vector.

    │ │ │ +

    get_file_priorities() returns a vector with the priorities of all │ │ │ +files.

    │ │ │ +

    The priority values are the same as for piece_priority(). See │ │ │ +download_priority_t.

    │ │ │ +

    Whenever a file priority is changed, all other piece priorities are │ │ │ +reset to match the file priorities. In order to maintain special │ │ │ +priorities for particular pieces, piece_priority() has to be called │ │ │ +again for those pieces.

    │ │ │ +

    You cannot set the file priorities on a torrent that does not yet have │ │ │ +metadata or a torrent that is a seed. file_priority(int, int) and │ │ │ +prioritize_files() are both no-ops for such torrents.

    │ │ │ +

    Since changing file priorities may involve disk operations (of moving │ │ │ +files in- and out of the part file), the internal accounting of file │ │ │ +priorities happen asynchronously. i.e. setting file priorities and then │ │ │ +immediately querying them may not yield the same priorities just set. │ │ │ +To synchronize with the priorities taking effect, wait for the │ │ │ +file_prio_alert.

    │ │ │ +

    When combining file- and piece priorities, the resume file will record │ │ │ +both. When loading the resume data, the file priorities will be applied │ │ │ +first, then the piece priorities.

    │ │ │ +

    Moving data from a file into the part file is currently not │ │ │ +supported. If a file has its priority set to 0 after it has already │ │ │ +been created, it will not be moved into the partfile.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_file_priorities()

    │ │ │ +
    │ │ │ +void post_file_priorities () const;
    │ │ │ +
    │ │ │ +

    post_file_priorities() will trigger a file_priorities_alert to be │ │ │ +posted, containing the download priority of each file in the torrent.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    force_reannounce() force_lsd_announce() force_dht_announce()

    │ │ │ +
    │ │ │ +void force_reannounce (int seconds, int idx, reannounce_flags_t = {}) const;
    │ │ │ +void force_reannounce (int seconds = 0, reannounce_flags_t = {}) const;
    │ │ │ +void force_lsd_announce () const;
    │ │ │ +void force_dht_announce () const;
    │ │ │ +void force_reannounce (int seconds, std::string const& url, reannounce_flags_t = {}) const;
    │ │ │ +
    │ │ │ +

    force_reannounce() will force this torrent to do another tracker │ │ │ +request, to receive new peers. The seconds argument specifies how │ │ │ +many seconds from now to issue the tracker announces.

    │ │ │ +

    If the tracker's min_interval has not passed since the last │ │ │ +announce, the forced announce will be scheduled to happen immediately │ │ │ +as the min_interval expires. This is to honor trackers minimum │ │ │ +re-announce interval settings.

    │ │ │ +

    The tracker_index argument specifies which tracker to re-announce. │ │ │ +If set to -1 (which is the default), all trackers are re-announce.

    │ │ │ +

    The flags argument can be used to affect the re-announce. See │ │ │ +ignore_min_interval and high_priority.

    │ │ │ +

    force_dht_announce will announce the torrent to the DHT │ │ │ +immediately.

    │ │ │ +

    force_lsd_announce will announce the torrent on LSD │ │ │ +immediately.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    scrape_tracker()

    │ │ │ +
    │ │ │ +void scrape_tracker (int idx) const;
    │ │ │ +void scrape_tracker () const;
    │ │ │ +void scrape_tracker (std::string url) const;
    │ │ │ +
    │ │ │ +

    scrape_tracker() will send a scrape request to a tracker. By │ │ │ +default (idx = -1) it will scrape the last working tracker. If │ │ │ +idx is >= 0, the tracker with the specified index will scraped.

    │ │ │ +

    A scrape request queries the tracker for statistics such as total │ │ │ +number of incomplete peers, complete peers, number of downloads etc.

    │ │ │ +

    This request will specifically update the num_complete and │ │ │ +num_incomplete fields in the torrent_status struct once it │ │ │ +completes. When it completes, it will generate a scrape_reply_alert. │ │ │ +If it fails, it will generate a scrape_failed_alert.

    │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    upload_limit() set_upload_limit() set_download_limit() download_limit()

    │ │ │ +
    │ │ │ +int upload_limit () const;
    │ │ │ +void set_upload_limit (int limit) const;
    │ │ │ +int download_limit () const;
    │ │ │ +void set_download_limit (int limit) const;
    │ │ │ +
    │ │ │ +

    set_upload_limit will limit the upload bandwidth used by this │ │ │ +particular torrent to the limit you set. It is given as the number of │ │ │ +bytes per second the torrent is allowed to upload. │ │ │ +set_download_limit works the same way but for download bandwidth │ │ │ +instead of upload bandwidth. Note that setting a higher limit on a │ │ │ +torrent then the global limit │ │ │ +(settings_pack::upload_rate_limit) will not override the global │ │ │ +rate limit. The torrent can never upload more than the global rate │ │ │ +limit.

    │ │ │ +

    upload_limit and download_limit will return the current limit │ │ │ +setting, for upload and download, respectively.

    │ │ │ +

    Local peers are not rate limited by default. see peer classes.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    connect_peer()

    │ │ │ +
    │ │ │ +void connect_peer (tcp::endpoint const& adr, peer_source_flags_t source = {}
    │ │ │ +      , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const;
    │ │ │ +
    │ │ │ +

    connect_peer() is a way to manually connect to peers that one │ │ │ +believe is a part of the torrent. If the peer does not respond, or is │ │ │ +not a member of this torrent, it will simply be disconnected. No harm │ │ │ +can be done by using this other than an unnecessary connection attempt │ │ │ +is made. If the torrent is uninitialized or in queued or checking │ │ │ +mode, this will throw system_error. The second (optional) │ │ │ +argument will be bitwise ORed into the source mask of this peer. │ │ │ +Typically this is one of the source flags in peer_info. i.e. │ │ │ +tracker, pex, dht etc.

    │ │ │ +

    For possible values of flags, see pex_flags_t.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    clear_peers()

    │ │ │ +
    │ │ │ +void clear_peers ();
    │ │ │ +
    │ │ │ +

    This will disconnect all peers and clear the peer list for this │ │ │ +torrent. New peers will have to be acquired before resuming, from │ │ │ +trackers, DHT or local service discovery, for example.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_max_uploads() max_uploads()

    │ │ │ +
    │ │ │ +void set_max_uploads (int max_uploads) const;
    │ │ │ +int max_uploads () const;
    │ │ │ +
    │ │ │ +

    set_max_uploads() sets the maximum number of peers that's unchoked │ │ │ +at the same time on this torrent. If you set this to -1, there will be │ │ │ +no limit. This defaults to infinite. The primary setting controlling │ │ │ +this is the global unchoke slots limit, set by unchoke_slots_limit in │ │ │ +settings_pack.

    │ │ │ +

    max_uploads() returns the current settings.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_max_connections() max_connections()

    │ │ │ +
    │ │ │ +void set_max_connections (int max_connections) const;
    │ │ │ +int max_connections () const;
    │ │ │ +
    │ │ │ +

    set_max_connections() sets the maximum number of connection this │ │ │ +torrent will open. If all connections are used up, incoming │ │ │ +connections may be refused or poor connections may be closed. This │ │ │ +must be at least 2. The default is unlimited number of connections. If │ │ │ +-1 is given to the function, it means unlimited. There is also a │ │ │ +global limit of the number of connections, set by │ │ │ +connections_limit in settings_pack.

    │ │ │ +

    max_connections() returns the current settings.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    move_storage()

    │ │ │ +
    │ │ │ +void move_storage (std::string const& save_path
    │ │ │ +      , move_flags_t flags = move_flags_t::always_replace_files
    │ │ │ +      ) const;
    │ │ │ +
    │ │ │ +

    Moves the file(s) that this torrent are currently seeding from or │ │ │ +downloading to. If the given save_path is not located on the same │ │ │ +drive as the original save path, the files will be copied to the new │ │ │ +drive and removed from their original location. This will block all │ │ │ +other disk IO, and other torrents download and upload rates may drop │ │ │ +while copying the file.

    │ │ │ +

    Since disk IO is performed in a separate thread, this operation is │ │ │ +also asynchronous. Once the operation completes, the │ │ │ +storage_moved_alert is generated, with the new path as the │ │ │ +message. If the move fails for some reason, │ │ │ +storage_moved_failed_alert is generated instead, containing the │ │ │ +error message.

    │ │ │ +

    The flags argument determines the behavior of the copying/moving │ │ │ +of the files in the torrent. see move_flags_t.

    │ │ │ +

    always_replace_files is the default and replaces any file that │ │ │ +exist in both the source directory and the target directory.

    │ │ │ +

    fail_if_exist first check to see that none of the copy operations │ │ │ +would cause an overwrite. If it would, it will fail. Otherwise it will │ │ │ +proceed as if it was in always_replace_files mode. Note that there │ │ │ +is an inherent race condition here. If the files in the target │ │ │ +directory appear after the check but before the copy or move │ │ │ +completes, they will be overwritten. When failing because of files │ │ │ +already existing in the target path, the error of │ │ │ +move_storage_failed_alert is set to │ │ │ +boost::system::errc::file_exists.

    │ │ │ +

    The intention is that a client may use this as a probe, and if it │ │ │ +fails, ask the user which mode to use. The client may then re-issue │ │ │ +the move_storage call with one of the other modes.

    │ │ │ +

    dont_replace always keeps the existing file in the target │ │ │ +directory, if there is one. The source files will still be removed in │ │ │ +that case. Note that it won't automatically re-check files. If an │ │ │ +incomplete torrent is moved into a directory with the complete files, │ │ │ +pause, move, force-recheck and resume. Without the re-checking, the │ │ │ +torrent will keep downloading and files in the new download directory │ │ │ +will be overwritten.

    │ │ │ +

    Files that have been renamed to have absolute paths are not moved by │ │ │ +this function. Keep in mind that files that don't belong to the │ │ │ +torrent but are stored in the torrent's directory may be moved as │ │ │ +well. This goes for files that have been renamed to absolute paths │ │ │ +that still end up inside the save path.

    │ │ │ +

    When copying files, sparse regions are not likely to be preserved. │ │ │ +This makes it proportionally more expensive to move a large torrent │ │ │ +when only few pieces have been downloaded, since the files are then │ │ │ +allocated with zeros in the destination directory.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    rename_file()

    │ │ │ +
    │ │ │ +void rename_file (file_index_t index, std::string const& new_name) const;
    │ │ │ +
    │ │ │ +

    Renames the file with the given index asynchronously. The rename │ │ │ +operation is complete when either a file_renamed_alert or │ │ │ +file_rename_failed_alert is posted.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    info_hash() info_hashes()

    │ │ │ +
    │ │ │ +sha1_hash info_hash () const;
    │ │ │ +info_hash_t info_hashes () const;
    │ │ │ +
    │ │ │ +

    returns the info-hash(es) of the torrent. If this handle is to a │ │ │ +torrent that hasn't loaded yet (for instance by being added) by a │ │ │ +URL, the returned value is undefined. │ │ │ +The info_hash() returns the SHA-1 info-hash for v1 torrents and a │ │ │ +truncated hash for v2 torrents. For the full v2 info-hash, use │ │ │ +info_hashes() instead.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator<() operator!=() operator==()

    │ │ │ +
    │ │ │ +bool operator!= (const torrent_handle& h) const;
    │ │ │ +bool operator< (const torrent_handle& h) const;
    │ │ │ +bool operator== (const torrent_handle& h) const;
    │ │ │ +
    │ │ │ +

    comparison operators. The order of the torrents is unspecified │ │ │ +but stable.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    id()

    │ │ │ +
    │ │ │ +std::uint32_t id () const;
    │ │ │ +
    │ │ │ +

    returns a unique identifier for this torrent. It's not a dense index. │ │ │ +It's not preserved across sessions.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    native_handle()

    │ │ │ +
    │ │ │ +std::shared_ptr<aux::torrent> native_handle () const;
    │ │ │ +
    │ │ │ +

    This function is intended only for use by plugins and the alert │ │ │ +dispatch function. This type does not have a stable ABI and should │ │ │ +be relied on as little as possible. Accessing the handle returned by │ │ │ +this function is not thread safe outside of libtorrent's internal │ │ │ +thread (which is used to invoke plugin callbacks).

    │ │ │ +

    The aux::torrent class is not only eligible for changing ABI across │ │ │ +minor versions of libtorrent, its layout is also dependent on build │ │ │ +configuration. This adds additional requirements on a client to be │ │ │ +built with the exact same build configuration as libtorrent itself. │ │ │ +i.e. the TORRENT_ macros must match between libtorrent and the │ │ │ +client builds.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    userdata()

    │ │ │ +
    │ │ │ +client_data_t userdata () const;
    │ │ │ +
    │ │ │ +

    returns the userdata pointer as set in add_torrent_params

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    in_session()

    │ │ │ +
    │ │ │ +bool in_session () const;
    │ │ │ +
    │ │ │ +

    Returns true if the torrent is in the session. It returns true before │ │ │ +session::remove_torrent() is called, and false afterward.

    │ │ │ +

    Note that this is a blocking function, unlike torrent_handle::is_valid() │ │ │ +which returns immediately.

    │ │ │ +[report issue]
    │ │ │ +
    overwrite_existing
    │ │ │ +
    instruct libtorrent to overwrite any data that may already have been │ │ │ +downloaded with the data of the new piece being added. Using this │ │ │ +flag when adding a piece that is actively being downloaded from other │ │ │ +peers may have some unexpected consequences, as blocks currently │ │ │ +being downloaded from peers may not be replaced.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_distributed_copies
    │ │ │ +
    calculates distributed_copies, distributed_full_copies and │ │ │ +distributed_fraction.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_accurate_download_counters
    │ │ │ +
    includes partial downloaded blocks in total_done and │ │ │ +total_wanted_done.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_last_seen_complete
    │ │ │ +
    includes last_seen_complete.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_pieces
    │ │ │ +
    populate the pieces field in torrent_status.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_verified_pieces
    │ │ │ +
    includes verified_pieces (only applies to torrents in seed │ │ │ +mode).
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_torrent_file
    │ │ │ +
    includes torrent_file, which is all the static information from │ │ │ +the .torrent file.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_name
    │ │ │ +
    includes name, the name of the torrent. This is either derived │ │ │ +from the .torrent file, or from the &dn= magnet link argument │ │ │ +or possibly some other source. If the name of the torrent is not │ │ │ +known, this is an empty string.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_save_path
    │ │ │ +
    includes save_path, the path to the directory the files of the │ │ │ +torrent are saved to.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    query_renamed_files
    │ │ │ +
    includes renamed_files, a map of files that have been renamed in this torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    alert_when_available
    │ │ │ +
    used to ask libtorrent to send an alert once the piece has been │ │ │ +downloaded, by passing alert_when_available. When set, the │ │ │ +read_piece_alert alert will be delivered, with the piece data, when │ │ │ +it's downloaded.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    piece_granularity
    │ │ │ +
    only calculate file progress at piece granularity. This makes │ │ │ +the file_progress() call cheaper and also only takes bytes that │ │ │ +have passed the hash check into account, so progress cannot │ │ │ +regress in this mode.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    graceful_pause
    │ │ │ +
    will delay the disconnect of peers that we're still downloading │ │ │ +outstanding requests from. The torrent will not accept any more │ │ │ +requests and will disconnect all idle peers. As soon as a peer is done │ │ │ +transferring the blocks that were requested from it, it is │ │ │ +disconnected. This is a graceful shut down of the torrent in the sense │ │ │ +that no downloaded bytes are wasted.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flush_disk_cache
    │ │ │ +
    the disk cache will be flushed before creating the resume data. │ │ │ +This avoids a problem with file timestamps in the resume data in │ │ │ +case the cache hasn't been flushed yet.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    save_info_dict
    │ │ │ +
    the resume data will contain the metadata from the torrent file as │ │ │ +well. This is useful for clients that don't keep .torrent files │ │ │ +around separately, or for torrents that were added via a magnet link.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    if_counters_changed
    │ │ │ +
    save resume data if any counters has changed since the last time │ │ │ +resume data was saved. This includes upload/download counters, active │ │ │ +time counters and scrape data. A torrent that is not paused will have │ │ │ +its active time counters incremented continuously.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    if_download_progress
    │ │ │ +
    save the resume data if any blocks have been downloaded since the │ │ │ +last time resume data was saved. This includes: │ │ │ +* checking existing files on disk │ │ │ +* downloading a block from a peer
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    if_config_changed
    │ │ │ +
    save the resume data if configuration options changed since last time │ │ │ +the resume data was saved. This includes: │ │ │ +* file- or piece priorities │ │ │ +* upload- and download rate limits │ │ │ +* change max-uploads (unchoke slots) │ │ │ +* change max connection limit │ │ │ +* enable/disable peer-exchange, local service discovery or DHT │ │ │ +* enable/disable apply IP-filter │ │ │ +* enable/disable auto-managed │ │ │ +* enable/disable share-mode │ │ │ +* enable/disable sequential-mode │ │ │ +* files renamed │ │ │ +* storage moved (save_path changed)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    if_state_changed
    │ │ │ +
    save the resume data if torrent state has changed since last time the │ │ │ +resume data was saved. This includes: │ │ │ +* upload mode │ │ │ +* paused state │ │ │ +* super-seeding │ │ │ +* seed-mode
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    if_metadata_changed
    │ │ │ +
    save the resume data if any metadata changed since the last time │ │ │ +resume data was saved. This includes: │ │ │ +* add/remove web seeds │ │ │ +* add/remove trackers │ │ │ +* receiving metadata for a magnet link
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    only_if_modified if_counters_changed
    │ │ │ +
    this flag has the same behavior as the combination of: │ │ │ +if_counters_changed | if_download_progress | if_config_changed | │ │ │ +if_state_changed | if_metadata_changed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    ignore_min_interval
    │ │ │ +
    by default, force-reannounce will still honor the min-interval │ │ │ +published by the tracker. If this flag is set, it will be ignored │ │ │ +and the tracker is announced immediately.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    high_priority
    │ │ │ +
    by default, force-reannounce will queue the announce normally. │ │ │ +If this flag is set, the announce will be put at the front of the │ │ │ +tracker queue for immediate processing.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    hash_value()

    │ │ │ +

    Declared in "libtorrent/torrent_handle.hpp"

    │ │ │ +
    │ │ │ +std::size_t hash_value (torrent_handle const& h);
    │ │ │ +
    │ │ │ +

    for std::hash (and to support using this type in unordered_map etc.)

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    storage_params

    │ │ │ +

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ +

    a parameter pack used to construct the storage for a torrent, used in │ │ │ +disk_interface

    │ │ │ +
    │ │ │ +struct storage_params
    │ │ │ +{
    │ │ │ +   storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ +      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ +      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ +      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ +
    │ │ │ +   file_storage const& files;
    │ │ │ +   lt::renamed_files const& renamed_files;
    │ │ │ +   string_view path;
    │ │ │ +   string_view part_file_dir;
    │ │ │ +   storage_mode_t mode {storage_mode_sparse};
    │ │ │ +   aux::vector<download_priority_t, file_index_t> const& priorities;
    │ │ │ +   sha1_hash info_hash;
    │ │ │ +   bool v1;
    │ │ │ +   bool v2;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    storage_params()

    │ │ │ +
    │ │ │ +storage_params (file_storage const& f, lt::renamed_files const& mf
    │ │ │ +      , string_view sp, string_view pfd, storage_mode_t const sm
    │ │ │ +      , aux::vector<download_priority_t, file_index_t> const& prio
    │ │ │ +      , sha1_hash const& ih, bool v1_torrent, bool v2_torrent);
    │ │ │ +
    │ │ │ +

    constructs a parameter pack from the layout, save path, mode, │ │ │ +per-file priorities, info-hash and protocol-version flags. │ │ │ +v1 indicates that the torrent has v1 metadata (a SHA-1 │ │ │ +info-hash); v2 that it has v2 metadata (BEP 52). A hybrid │ │ │ +torrent has both set.

    │ │ │ +[report issue]
    │ │ │ +
    files
    │ │ │ +
    the file layout (sizes, paths, flags) of the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    renamed_files
    │ │ │ +
    rename overlay applied on top of files; on-disk paths │ │ │ +resolved through this object take precedence over the │ │ │ +originals
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    path
    │ │ │ +
    the directory where the torrent's files are stored
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    part_file_dir
    │ │ │ +
    directory in which the part file is created. If empty, the │ │ │ +part file is placed under path.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    mode
    │ │ │ +
    the storage allocation mode (sparse vs. pre-allocated)
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    priorities
    │ │ │ +
    per-file download priorities, indexed by file index
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    info_hash
    │ │ │ +
    the SHA-1 info-hash of the torrent (zero for v2-only │ │ │ +torrents)
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    v1 v2
    │ │ │ +
    indicates which BitTorrent protocol version(s) this storage │ │ │ +is for. v1 is true if the torrent has v1 metadata; │ │ │ +v2 is true if the torrent has v2 metadata (BEP 52). A │ │ │ +hybrid torrent has both flags set.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    file_slice

    │ │ │ +

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ +

    represents a window of a file in a torrent.

    │ │ │ +

    The file_index refers to the index of the file (in the torrent_info). │ │ │ +To get the path and filename, use file_path() and give the file_index │ │ │ +as argument. The offset is the byte offset in the file where the range │ │ │ +starts, and size is the number of bytes this range is. The size + offset │ │ │ +will never be greater than the file size.

    │ │ │ +
    │ │ │ +struct file_slice
    │ │ │ +{
    │ │ │ +   file_index_t file_index;
    │ │ │ +   std::int64_t offset;
    │ │ │ +   std::int64_t size;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    file_index
    │ │ │ +
    the index of the file
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    offset
    │ │ │ +
    the offset from the start of the file, in bytes
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    size
    │ │ │ +
    the size of the window, in bytes
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_storage

    │ │ │ +

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ +

    The file_storage class represents a file list and the piece │ │ │ +size. Everything necessary to interpret a regular bittorrent storage │ │ │ +file structure.

    │ │ │ +
    │ │ │ +class file_storage
    │ │ │ +{
    │ │ │ +   bool is_valid () const;
    │ │ │ +   void reserve (int num_files);
    │ │ │ +   void add_file (std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +   void add_file_borrow (string_view filename
    │ │ │ +      , std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}, std::int64_t mtime = 0
    │ │ │ +      , string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +   void add_file (error_code& ec, std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +   void add_file_borrow (error_code& ec, string_view filename
    │ │ │ +      , std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}, std::int64_t mtime = 0
    │ │ │ +      , string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +   std::vector<file_slice> map_block (piece_index_t piece, std::int64_t offset
    │ │ │ +      , std::int64_t size) const;
    │ │ │ +   peer_request map_file (file_index_t file, std::int64_t offset, int size) const;
    │ │ │ +   int num_files () const noexcept;
    │ │ │ +   file_index_t end_file () const noexcept;
    │ │ │ +   index_range<file_index_t> file_range () const noexcept;
    │ │ │ +   std::int64_t total_size () const;
    │ │ │ +   std::int64_t size_on_disk () const;
    │ │ │ +   int num_pieces () const;
    │ │ │ +   void set_num_pieces (int n);
    │ │ │ +   piece_index_t end_piece () const;
    │ │ │ +   piece_index_t last_piece () const;
    │ │ │ +   index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ +   int piece_length () const;
    │ │ │ +   void set_piece_length (int l);
    │ │ │ +   int piece_size (piece_index_t index) const;
    │ │ │ +   int piece_size2 (piece_index_t index) const;
    │ │ │ +   int blocks_in_piece2 (piece_index_t index) const;
    │ │ │ +   int blocks_per_piece () const;
    │ │ │ +   std::string const& name () const;
    │ │ │ +   void set_name (std::string const& n);
    │ │ │ +   void swap (file_storage& ti) noexcept;
    │ │ │ +   std::int64_t file_offset (file_index_t index) const;
    │ │ │ +   string_view file_name (file_index_t index) const;
    │ │ │ +   std::string file_path (file_index_t index, std::string const& save_path = "") const;
    │ │ │ +   char const* root_ptr (file_index_t const index) const;
    │ │ │ +   bool pad_file_at (file_index_t index) const;
    │ │ │ +   std::time_t mtime (file_index_t index) const;
    │ │ │ +   std::string symlink (file_index_t index) const;
    │ │ │ +   sha256_hash root (file_index_t index) const;
    │ │ │ +   std::int64_t file_size (file_index_t index) const;
    │ │ │ +   int file_num_blocks (file_index_t index) const;
    │ │ │ +   int file_num_pieces (file_index_t index) const;
    │ │ │ +   index_range<piece_index_t::diff_type> file_piece_range (file_index_t) const;
    │ │ │ +   int file_first_piece_node (file_index_t index) const;
    │ │ │ +   int file_first_block_node (file_index_t index) const;
    │ │ │ +   std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const;
    │ │ │ +   void all_path_hashes (std::unordered_set<std::uint32_t>& table) const;
    │ │ │ +   file_flags_t file_flags (file_index_t index) const;
    │ │ │ +   bool file_absolute_path (file_index_t index) const;
    │ │ │ +   file_index_t file_index_at_piece (piece_index_t piece) const;
    │ │ │ +   file_index_t last_file_index_at_piece (piece_index_t piece) const;
    │ │ │ +   file_index_t file_index_at_offset (std::int64_t offset) const;
    │ │ │ +   file_index_t file_index_for_root (sha256_hash const& root_hash) const;
    │ │ │ +   piece_index_t piece_index_at_file (file_index_t f) const;
    │ │ │ +   piece_index_t last_piece_index_at_file (file_index_t f) const;
    │ │ │ +   void sanitize_symlinks ();
    │ │ │ +   bool v2 () const;
    │ │ │ +
    │ │ │ +   static inline constexpr file_flags_t flag_pad_file  = 0_bit;
    │ │ │ +   static inline constexpr file_flags_t flag_hidden  = 1_bit;
    │ │ │ +   static inline constexpr file_flags_t flag_executable  = 2_bit;
    │ │ │ +   static inline constexpr file_flags_t flag_symlink  = 3_bit;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    is_valid()

    │ │ │ +
    │ │ │ +bool is_valid () const;
    │ │ │ +
    │ │ │ +

    returns true if the piece length has been initialized │ │ │ +on the file_storage. This is typically taken as a proxy │ │ │ +of whether the file_storage as a whole is initialized or │ │ │ +not.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    reserve()

    │ │ │ +
    │ │ │ +void reserve (int num_files);
    │ │ │ +
    │ │ │ +

    allocates space for num_files in the internal file list. This can │ │ │ +be used to avoid reallocating the internal file list when the number │ │ │ +of files to be added is known up-front.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_file_borrow() add_file()

    │ │ │ +
    │ │ │ +void add_file (std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +void add_file_borrow (string_view filename
    │ │ │ +      , std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}, std::int64_t mtime = 0
    │ │ │ +      , string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +
    │ │ │ +

    Adds a file to the file storage. The add_file_borrow version │ │ │ +expects that filename is the file name (without a path) of │ │ │ +the file that's being added. │ │ │ +This memory is borrowed, i.e. it is the caller's │ │ │ +responsibility to make sure it stays valid throughout the lifetime │ │ │ +of this file_storage object or any copy of it. The same thing applies │ │ │ +to filehash, which is an optional pointer to a 20 byte binary │ │ │ +SHA-1 hash of the file.

    │ │ │ +

    if filename is empty, the filename from path is used and not │ │ │ +borrowed.

    │ │ │ +

    The path argument is the full path (in the torrent file) to │ │ │ +the file to add. Note that this is not supposed to be an absolute │ │ │ +path, but it is expected to include the name of the torrent as the │ │ │ +first path element.

    │ │ │ +

    file_size is the size of the file in bytes.

    │ │ │ +

    The file_flags argument sets attributes on the file. The file │ │ │ +attributes is an extension and may not work in all bittorrent clients.

    │ │ │ +

    For possible file attributes, see file_storage::flags_t.

    │ │ │ +

    The mtime argument is optional and can be set to 0. If non-zero, │ │ │ +it is the posix time of the last modification time of this file.

    │ │ │ +

    symlink_path is the path the file is a symlink to. To make this a │ │ │ +symlink you also need to set the file_storage::flag_symlink file flag.

    │ │ │ +

    root_hash is an optional pointer to a 32 byte SHA-256 hash, being │ │ │ +the merkle tree root hash for this file. This is only used for v2 │ │ │ +torrents. If the root hash is specified for one file, it has to │ │ │ +be specified for all, otherwise this function will fail. │ │ │ +Note that the buffer root_hash points to must out-live the │ │ │ +file_storage object, it will not be copied. This parameter is only │ │ │ +used when loading torrents, that already have their file hashes │ │ │ +computed. When creating torrents, the file hashes will be computed by │ │ │ +the piece hashes.

    │ │ │ +

    If more files than one are added, certain restrictions to their paths │ │ │ +apply. In a multi-file file storage (torrent), all files must share │ │ │ +the same root directory.

    │ │ │ +

    That is, the first path element of all files must be the same. │ │ │ +This shared path element is also set to the name of the torrent. It │ │ │ +can be changed by calling set_name.

    │ │ │ +

    The overloads that take an error_code reference will report failures │ │ │ +via that variable, otherwise system_error is thrown.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_file_borrow() add_file()

    │ │ │ +
    │ │ │ +void add_file (error_code& ec, std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +void add_file_borrow (error_code& ec, string_view filename
    │ │ │ +      , std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}, std::int64_t mtime = 0
    │ │ │ +      , string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +
    │ │ │ +

    these overloads report failures through the ec reference │ │ │ +rather than throwing. add_file_borrow() does not copy the │ │ │ +filename string; it is borrowed by reference and the caller │ │ │ +must keep it alive for the lifetime of this file_storage │ │ │ +object. This is useful when constructing the file list from a │ │ │ +memory-mapped .torrent file.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    map_block()

    │ │ │ +
    │ │ │ +std::vector<file_slice> map_block (piece_index_t piece, std::int64_t offset
    │ │ │ +      , std::int64_t size) const;
    │ │ │ +
    │ │ │ +

    returns a list of file_slice objects representing the portions of │ │ │ +files the specified piece index, byte offset and size range overlaps. │ │ │ +this is the inverse mapping of map_file().

    │ │ │ +

    Preconditions of this function is that the input range is within the │ │ │ +torrents address space. piece may not be negative and

    │ │ │ +
    │ │ │ +piece * piece_size + offset + size
    │ │ │ +

    may not exceed the total size of the torrent.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    map_file()

    │ │ │ +
    │ │ │ +peer_request map_file (file_index_t file, std::int64_t offset, int size) const;
    │ │ │ +
    │ │ │ +

    returns a peer_request representing the piece index, byte offset │ │ │ +and size the specified file range overlaps. This is the inverse │ │ │ +mapping over map_block(). Note that the peer_request return type │ │ │ +is meant to hold bittorrent block requests, which may not be larger │ │ │ +than 16 kiB. Mapping a range larger than that may return an overflown │ │ │ +integer.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    num_files()

    │ │ │ +
    │ │ │ +int num_files () const noexcept;
    │ │ │ +
    │ │ │ +

    returns the number of files in the file_storage

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    end_file()

    │ │ │ +
    │ │ │ +file_index_t end_file () const noexcept;
    │ │ │ +
    │ │ │ +

    returns the index of the one-past-end file in the file storage

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_range()

    │ │ │ +
    │ │ │ +index_range<file_index_t> file_range () const noexcept;
    │ │ │ +
    │ │ │ +

    returns an implementation-defined type that can be used as the │ │ │ +container in a range-for loop. Where the values are the indices of all │ │ │ +files in the file_storage.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    total_size()

    │ │ │ +
    │ │ │ +std::int64_t total_size () const;
    │ │ │ +
    │ │ │ +

    returns the total number of bytes all the files in this torrent spans │ │ │ +including pad files

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    size_on_disk()

    │ │ │ +
    │ │ │ +std::int64_t size_on_disk () const;
    │ │ │ +
    │ │ │ +

    returns the sum of all non pad file sizes

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_num_pieces() num_pieces()

    │ │ │ +
    │ │ │ +int num_pieces () const;
    │ │ │ +void set_num_pieces (int n);
    │ │ │ +
    │ │ │ +

    set and get the number of pieces in the torrent

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    end_piece()

    │ │ │ +
    │ │ │ +piece_index_t end_piece () const;
    │ │ │ +
    │ │ │ +

    returns the index of the one-past-end piece in the file storage

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    last_piece()

    │ │ │ +
    │ │ │ +piece_index_t last_piece () const;
    │ │ │ +
    │ │ │ +

    returns the index of the last piece in the torrent. The last piece is │ │ │ +special in that it may be smaller than the other pieces (and the other │ │ │ +pieces are all the same size).

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_range()

    │ │ │ +
    │ │ │ +index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ +
    │ │ │ +

    returns an implementation-defined type that can be used as the │ │ │ +container in a range-for loop. Where the values are the indices of all │ │ │ +pieces in the file_storage.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_piece_length() piece_length()

    │ │ │ +
    │ │ │ +int piece_length () const;
    │ │ │ +void set_piece_length (int l);
    │ │ │ +
    │ │ │ +

    set and get the size of each piece in this torrent. It must be a power of two │ │ │ +and at least 16 kiB.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_size()

    │ │ │ +
    │ │ │ +int piece_size (piece_index_t index) const;
    │ │ │ +
    │ │ │ +

    returns the piece size of index. This will be the same as piece_length(), except │ │ │ +for the last piece, which may be shorter.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_size2()

    │ │ │ +
    │ │ │ +int piece_size2 (piece_index_t index) const;
    │ │ │ +
    │ │ │ +

    Returns the size of the given piece. If the piece spans multiple files, │ │ │ +only the first file is considered part of the piece. This is used for │ │ │ +v2 torrents, where all files are piece aligned and padded. i.e. The pad │ │ │ +files are not considered part of the piece for this purpose.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    blocks_in_piece2()

    │ │ │ +
    │ │ │ +int blocks_in_piece2 (piece_index_t index) const;
    │ │ │ +
    │ │ │ +

    returns the number of blocks in the specified piece, for v2 torrents.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    blocks_per_piece()

    │ │ │ +
    │ │ │ +int blocks_per_piece () const;
    │ │ │ +
    │ │ │ +

    returns the number of blocks there are in the typical piece. There │ │ │ +may be fewer in the last piece)

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    name() set_name()

    │ │ │ +
    │ │ │ +std::string const& name () const;
    │ │ │ +void set_name (std::string const& n);
    │ │ │ +
    │ │ │ +

    set and get the name of this torrent. For multi-file torrents, this is also │ │ │ +the name of the root directory all the files are stored in.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    swap()

    │ │ │ +
    │ │ │ +void swap (file_storage& ti) noexcept;
    │ │ │ +
    │ │ │ +

    swap all content of this with ti.

    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ + │ │ │ +
    │ │ │ +

    file_num_pieces() file_num_blocks() file_piece_range()

    │ │ │ +
    │ │ │ +int file_num_blocks (file_index_t index) const;
    │ │ │ +int file_num_pieces (file_index_t index) const;
    │ │ │ +index_range<piece_index_t::diff_type> file_piece_range (file_index_t) const;
    │ │ │ +
    │ │ │ +

    Returns the number of pieces or blocks the file at index spans, │ │ │ +under the assumption that the file is aligned to the start of a piece. │ │ │ +This is only meaningful for v2 torrents, where files are guaranteed │ │ │ +such alignment. │ │ │ +These numbers are used to size and navigate the merkle hash tree for │ │ │ +each file.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_first_block_node() file_first_piece_node()

    │ │ │ +
    │ │ │ +int file_first_piece_node (file_index_t index) const;
    │ │ │ +int file_first_block_node (file_index_t index) const;
    │ │ │ +
    │ │ │ +

    index of first piece node in the merkle tree

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_path_hash()

    │ │ │ +
    │ │ │ +std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const;
    │ │ │ +
    │ │ │ +

    returns the crc32 hash of file_path(index)

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    all_path_hashes()

    │ │ │ +
    │ │ │ +void all_path_hashes (std::unordered_set<std::uint32_t>& table) const;
    │ │ │ +
    │ │ │ +

    this will add the CRC32 hash of all directory entries to the table. No │ │ │ +filename will be included, just directories. Every depth of directories │ │ │ +are added separately to allow test for collisions with files at all │ │ │ +levels. i.e. if one path in the torrent is foo/bar/baz, the CRC32 │ │ │ +hashes for foo, foo/bar and foo/bar/baz will be added to │ │ │ +the set.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_flags()

    │ │ │ +
    │ │ │ +file_flags_t file_flags (file_index_t index) const;
    │ │ │ +
    │ │ │ +

    returns a bitmask of flags from file_flags_t that apply │ │ │ +to file at index.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_absolute_path()

    │ │ │ +
    │ │ │ +bool file_absolute_path (file_index_t index) const;
    │ │ │ +
    │ │ │ +

    returns true if the file at the specified index has been renamed to │ │ │ +have an absolute path, i.e. is not anchored in the save path of the │ │ │ +torrent.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    last_file_index_at_piece() file_index_at_offset() file_index_at_piece()

    │ │ │ +
    │ │ │ +file_index_t file_index_at_piece (piece_index_t piece) const;
    │ │ │ +file_index_t last_file_index_at_piece (piece_index_t piece) const;
    │ │ │ +file_index_t file_index_at_offset (std::int64_t offset) const;
    │ │ │ +
    │ │ │ +

    returns the index of the file at the given offset or piece in the torrent

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_index_for_root()

    │ │ │ +
    │ │ │ +file_index_t file_index_for_root (sha256_hash const& root_hash) const;
    │ │ │ +
    │ │ │ +

    finds the file with the given root hash and returns its index │ │ │ +if there is no file with the root hash, file_index_t{-1} is returned

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_index_at_file() last_piece_index_at_file()

    │ │ │ +
    │ │ │ +piece_index_t piece_index_at_file (file_index_t f) const;
    │ │ │ +piece_index_t last_piece_index_at_file (file_index_t f) const;
    │ │ │ +
    │ │ │ +

    returns the first or last piece index of the given file in the torrent

    │ │ │ +[report issue]
    │ │ │ + │ │ │ +
    │ │ │ +

    v2()

    │ │ │ +
    │ │ │ +bool v2 () const;
    │ │ │ +
    │ │ │ +

    returns true if this torrent contains v2 metadata.

    │ │ │ +[report issue]
    │ │ │ +
    flag_pad_file
    │ │ │ +
    the file is a pad file. It's required to contain zeros │ │ │ +at it will not be saved to disk. Its purpose is to make │ │ │ +the following file start on a piece boundary.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flag_hidden
    │ │ │ +
    this file has the hidden attribute set. This is primarily │ │ │ +a windows attribute
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flag_executable
    │ │ │ +
    this file has the executable attribute set.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flag_symlink
    │ │ │ +
    this file is a symbolic link. It should have a link │ │ │ +target string associated with it.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    renamed_files

    │ │ │ +

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ +

    this is a wrapper around file_storage for renaming files without having │ │ │ +to mutate the file_storage object itself.

    │ │ │ +
    │ │ │ +struct renamed_files
    │ │ │ +{
    │ │ │ +   bool file_absolute_path (file_storage const& fs, file_index_t index) const;
    │ │ │ +   string_view file_name (file_storage const& fs, file_index_t index) const;
    │ │ │ +   std::string file_path (file_storage const& fs, file_index_t index, std::string const& save_path = "") const;
    │ │ │ +   void rename_file (file_storage const& fs, file_index_t index, std::string const& new_filename);
    │ │ │ +   void import_filenames (file_storage const& fs, std::map<file_index_t, std::string> const& renamed_files);
    │ │ │ +   std::map<file_index_t, std::string> export_filenames (file_storage const& fs) const;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    file_path() file_name() file_absolute_path()

    │ │ │ +
    │ │ │ +bool file_absolute_path (file_storage const& fs, file_index_t index) const;
    │ │ │ +string_view file_name (file_storage const& fs, file_index_t index) const;
    │ │ │ +std::string file_path (file_storage const& fs, file_index_t index, std::string const& save_path = "") const;
    │ │ │ +
    │ │ │ +

    returns information about the file at index in fs, │ │ │ +honoring any rename recorded in this object. │ │ │ +file_path() returns the full on-disk path (prepending │ │ │ +save_path to relative paths). file_name() returns │ │ │ +just the leaf filename. file_absolute_path() returns │ │ │ +true if the recorded rename is an absolute path (in which │ │ │ +case save_path is ignored).

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    rename_file()

    │ │ │ +
    │ │ │ +void rename_file (file_storage const& fs, file_index_t index, std::string const& new_filename);
    │ │ │ +
    │ │ │ +

    records that the file at index in fs should be │ │ │ +renamed to new_filename on disk. The underlying │ │ │ +file_storage is not modified.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    export_filenames() import_filenames()

    │ │ │ +
    │ │ │ +void import_filenames (file_storage const& fs, std::map<file_index_t, std::string> const& renamed_files);
    │ │ │ +std::map<file_index_t, std::string> export_filenames (file_storage const& fs) const;
    │ │ │ +
    │ │ │ +

    bulk import or export the set of file renames recorded in │ │ │ +this object. import_filenames() adds the given renames │ │ │ +(dropping entries whose file index is out of range). │ │ │ +export_filenames() returns the current renames as a map │ │ │ +suitable for serializing and later passing back to │ │ │ +import_filenames().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    filenames

    │ │ │ +

    Declared in "libtorrent/file_storage.hpp"

    │ │ │ +

    a lightweight view that pairs a file_storage with the rename │ │ │ +overrides in a renamed_files. It exposes the read-only subset │ │ │ +of file_storage that downstream code (e.g. the disk I/O │ │ │ +backends) needs, with file paths automatically resolved through │ │ │ +the rename layer.

    │ │ │ +
    │ │ │ +struct filenames
    │ │ │ +{
    │ │ │ +   filenames (file_storage const& fs, renamed_files const& rf);
    │ │ │ +   file_flags_t file_flags (file_index_t const index) const;
    │ │ │ +   file_index_t end_file () const noexcept;
    │ │ │ +   bool pad_file_at (file_index_t const index) const;
    │ │ │ +   std::int64_t file_size (file_index_t const index) const;
    │ │ │ +   std::int64_t file_offset (file_index_t const index) const;
    │ │ │ +   bool file_absolute_path (file_index_t const index) const;
    │ │ │ +   std::string file_path (file_index_t const index, std::string const& save_path = "") const;
    │ │ │ +   std::string symlink (file_index_t const index) const;
    │ │ │ +   index_range<file_index_t> file_range () const noexcept;
    │ │ │ +   int num_pieces () const;
    │ │ │ +   piece_index_t end_piece () const;
    │ │ │ +   int num_files () const noexcept;
    │ │ │ +   std::vector<file_slice> map_block (piece_index_t const piece, std::int64_t const offset
    │ │ │ +      , std::int64_t const size) const;
    │ │ │ +   peer_request map_file (file_index_t const file, std::int64_t const offset, int const size) const;
    │ │ │ +   sha256_hash root (file_index_t const index) const;
    │ │ │ +   int piece_length () const;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    filenames()

    │ │ │ +
    │ │ │ +filenames (file_storage const& fs, renamed_files const& rf);
    │ │ │ +
    │ │ │ +

    construct a view over fs with the renames recorded in │ │ │ +rf applied. Both references must outlive the view.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_flags()

    │ │ │ +
    │ │ │ +file_flags_t file_flags (file_index_t const index) const;
    │ │ │ +
    │ │ │ +

    returns the file flags for the file at index

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    end_file()

    │ │ │ +
    │ │ │ +file_index_t end_file () const noexcept;
    │ │ │ +
    │ │ │ +

    one past-the-end file index

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    pad_file_at()

    │ │ │ +
    │ │ │ +bool pad_file_at (file_index_t const index) const;
    │ │ │ +
    │ │ │ +

    returns true if the file at index is a pad file

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_size() file_offset()

    │ │ │ +
    │ │ │ +std::int64_t file_size (file_index_t const index) const;
    │ │ │ +std::int64_t file_offset (file_index_t const index) const;
    │ │ │ +
    │ │ │ +

    returns the file size or file offset for the file at index. The │ │ │ +file offset is in the torrent space, of all files in the torrent, in │ │ │ +the order they are defined.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_path() file_absolute_path()

    │ │ │ +
    │ │ │ +bool file_absolute_path (file_index_t const index) const;
    │ │ │ +std::string file_path (file_index_t const index, std::string const& save_path = "") const;
    │ │ │ +
    │ │ │ +

    returns the on-disk path for the file at index, applying │ │ │ +any rename recorded in the underlying renamed_files. If │ │ │ +save_path is non-empty it is prepended to relative │ │ │ +paths. file_absolute_path() returns true if the recorded │ │ │ +rename is an absolute path (in which case save_path is │ │ │ +ignored).

    │ │ │ +[report issue]
    │ │ │ + │ │ │ +
    │ │ │ +

    file_range()

    │ │ │ +
    │ │ │ +index_range<file_index_t> file_range () const noexcept;
    │ │ │ +
    │ │ │ +

    all file indices in the underlying file_storage. Convenient in │ │ │ +range-for loops.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    num_pieces() end_piece() num_files()

    │ │ │ +
    │ │ │ +int num_pieces () const;
    │ │ │ +piece_index_t end_piece () const;
    │ │ │ +int num_files () const noexcept;
    │ │ │ +
    │ │ │ +

    the number of files in the underlying file_storage, the │ │ │ +number of pieces, and the one-past-the-end piece index.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    map_block()

    │ │ │ +
    │ │ │ +std::vector<file_slice> map_block (piece_index_t const piece, std::int64_t const offset
    │ │ │ +      , std::int64_t const size) const;
    │ │ │ +
    │ │ │ +

    returns the list of file slices that make up the piece at │ │ │ +piece, starting at offset into the piece and │ │ │ +covering size bytes. Each entry identifies one file and │ │ │ +the byte range within it that contributes to the requested │ │ │ +block.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    map_file()

    │ │ │ +
    │ │ │ +peer_request map_file (file_index_t const file, std::int64_t const offset, int const size) const;
    │ │ │ +
    │ │ │ +

    inverse of map_block(): maps a byte range within the │ │ │ +file at file (starting at offset, of length │ │ │ +size) to a peer_request identifying the piece, │ │ │ +piece-offset and length in torrent space.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    root()

    │ │ │ +
    │ │ │ +sha256_hash root (file_index_t const index) const;
    │ │ │ +
    │ │ │ +

    returns the v2 merkle root (pieces root) for the file │ │ │ +at index. Returns a zero hash for v1-only torrents.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_length()

    │ │ │ +
    │ │ │ +int piece_length () const;
    │ │ │ +
    │ │ │ +

    the piece size, in bytes. All pieces have this size except │ │ │ +the last, which may be shorter.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    mmap_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/mmap_disk_io.hpp"

    │ │ │ +
    │ │ │ +std::unique_ptr<disk_interface> mmap_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ +
    │ │ │ +

    constructs a memory mapped file disk I/O object.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    default_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/session.hpp"

    │ │ │ +
    │ │ │ +std::unique_ptr<disk_interface> default_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ +
    │ │ │ +

    the constructor function for the default storage. On systems that support │ │ │ +memory mapped files (and a 64 bit address space) the memory mapped storage │ │ │ +will be constructed, otherwise the portable posix storage.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    disabled_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/disabled_disk_io.hpp"

    │ │ │ +
    │ │ │ +std::unique_ptr<disk_interface> disabled_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ +
    │ │ │ +

    creates a disk io object that discards all data written to it, and only │ │ │ +returns zero-buffers when read from. May be useful for testing and │ │ │ +benchmarking.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    posix_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/posix_disk_io.hpp"

    │ │ │ +
    │ │ │ +std::unique_ptr<disk_interface> posix_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ +
    │ │ │ +

    this is a simple posix disk I/O back-end, used for systems that don't │ │ │ +have a 64 bit virtual address space or don't support memory mapped files. │ │ │ +It's implemented using portable C file functions and is single-threaded.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum storage_mode_t

    │ │ │ +

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    storage_mode_allocate0All pieces will be written to their final position, all files will be │ │ │ +allocated in full when the torrent is first started. This mode minimizes │ │ │ +fragmentation but could be a costly operation.
    storage_mode_sparse1All pieces will be written to the place where they belong and sparse files │ │ │ +will be used. This is the recommended, and default mode.
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum move_flags_t

    │ │ │ +

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    always_replace_files0replace any files in the destination when copying │ │ │ +or moving the storage
    fail_if_exist1if any files that we want to copy exist in the destination │ │ │ +exist, fail the whole operation and don't perform │ │ │ +any copy or move. There is an inherent race condition │ │ │ +in this mode. The files are checked for existence before │ │ │ +the operation starts. In between the check and performing │ │ │ +the copy, the destination files may be created, in which │ │ │ +case they are replaced.
    dont_replace2if any file exist in the target, take those files instead │ │ │ +of the ones we may have in the source.
    reset_save_path3don't move any source files, just forget about them │ │ │ +and begin checking files at new save path
    reset_save_path_unchecked4don't move any source files, just change save path │ │ │ +and continue working without any checks
    │ │ │ +

    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. │ │ │ +
    3. the torrent properties are set, such as tracker url, web seeds, │ │ │ +DHT nodes etc.
    4. │ │ │ +
    5. Read through all the files in the torrent, SHA-1 all the data │ │ │ +and set the piece hashes.
    6. │ │ │ +
    7. The torrent is bencoded into a file or buffer.
    8. │ │ │ +
    │ │ │ +

    If there are a lot of files and or deep directory hierarchies to │ │ │ +traverse, step one can be time consuming.

    │ │ │ +

    Typically step 3 is by far the most time consuming step, since it │ │ │ +requires to read all the bytes from all the files in the torrent.

    │ │ │ +

    All of these classes and functions are declared by including │ │ │ +libtorrent/create_torrent.hpp.

    │ │ │ +

    example:

    │ │ │ +
    │ │ │ +// recursively create a list of all files in the directory
    │ │ │ +auto fs = list_files("./my_torrent");
    │ │ │ +
    │ │ │ +create_torrent t(std::move(fs));
    │ │ │ +t.add_tracker("http://my.tracker.com/announce");
    │ │ │ +t.set_creator("libtorrent example");
    │ │ │ +
    │ │ │ +// reads the files and calculates the hashes
    │ │ │ +set_piece_hashes(t, ".");
    │ │ │ +
    │ │ │ +ofstream out("my_torrent.torrent", std::ios_base::binary);
    │ │ │ +std::vector<char> buf = t.generate_buf();
    │ │ │ +out.write(buf.data(), buf.size());
    │ │ │ +
    │ │ │ +// alternatively, generate an entry and encode it directly to an ostream
    │ │ │ +// iterator
    │ │ │ +bencode(std::ostream_iterator<char>(out), t.generate());
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    create_file_entry

    │ │ │ +

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │ +

    This represents one file in the torrent file to be created

    │ │ │ +
    │ │ │ +struct create_file_entry
    │ │ │ +{
    │ │ │ +   create_file_entry (std::string fn, std::int64_t const sz
    │ │ │ +      , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = {});
    │ │ │ +
    │ │ │ +   std::string filename;
    │ │ │ +   std::int64_t size;
    │ │ │ +   file_flags_t flags;
    │ │ │ +   std::time_t mtime;
    │ │ │ +   std::string symlink;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    create_file_entry()

    │ │ │ +
    │ │ │ +create_file_entry (std::string fn, std::int64_t const sz
    │ │ │ +      , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = {});
    │ │ │ +
    │ │ │ +

    construct a file entry for the file at relative path fn │ │ │ +with size sz. │ │ │ +f is the set of file flags that applies to the file, see file_flags_t. │ │ │ +ts is an optional modification time (0 to omit). │ │ │ +sl is the symlink target, only used when f includes the symlink │ │ │ +flag. Symlinks are only allowed to target other files or directories │ │ │ +in the torrent.

    │ │ │ +[report issue]
    │ │ │ +
    filename
    │ │ │ +
    the path and name of the file. The path is relative to the root of │ │ │ +the torrent file.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    size
    │ │ │ +
    the size of the file
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flags
    │ │ │ +
    bitmask of file_flags_t (pad-file, hidden, executable, │ │ │ +symlink) for this file.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    mtime
    │ │ │ +
    optional modification time of the file. 0 means "do not record".
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    symlink
    │ │ │ +
    the link target, only considered if the symlink flag is set
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    create_torrent

    │ │ │ +

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │ +

    This class holds state for creating a torrent. After having added │ │ │ +all information to it, call create_torrent::generate() to generate │ │ │ +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 = {});
    │ │ │ +   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);
    │ │ │ +   void add_tracker (string_view url, int tier = 0);
    │ │ │ +   void set_root_cert (string_view cert);
    │ │ │ +   void set_priv (bool p);
    │ │ │ +   bool priv () const;
    │ │ │ +   bool is_v2_only () const;
    │ │ │ +   bool is_v1_only () const;
    │ │ │ +   int num_pieces () const;
    │ │ │ +   piece_index_t end_piece () const;
    │ │ │ +   index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ +   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);
    │ │ │ +
    │ │ │ +   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;
    │ │ │ +   static inline constexpr create_flags_t canonical_files_no_tail_padding  = 9_bit;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    create_torrent()

    │ │ │ +
    │ │ │ +explicit create_torrent (std::vector<create_file_entry> files, int piece_size = 0
    │ │ │ +      , create_flags_t flags = {});
    │ │ │ +
    │ │ │ +

    The piece_size is the size of each piece in bytes. It must be a │ │ │ +power of 2 and a minimum of 16 kiB. If a piece size of 0 is │ │ │ +specified, a piece_size will be set automatically. │ │ │ +Piece sizes greater than 128 MiB are considered unreasonable and will │ │ │ +be rejected (with an lt::system_error exception).

    │ │ │ +

    The flags arguments specifies options for the torrent creation. It can │ │ │ +be any combination of the flags defined by create_flags_t.

    │ │ │ +

    The files argument is a list of all files to be included in the │ │ │ +torrent file. If it has more than one file in it, all files must │ │ │ +share a common root directory (which will be the name of the │ │ │ +torrent).

    │ │ │ +

    If files has a single file without any directory component (i.e. │ │ │ +just a filename) it will create a single file torrent. If it has a │ │ │ +directory path, it will create a multi-file torrent with a single │ │ │ +file. This is in order to preserve the directory path.

    │ │ │ +
    │ │ │ +
    │ │ │ +

    deprecated overloads

    │ │ │ +

    There are two deprecated constructors that take a file_storage object │ │ │ +and a torrent_info object respectively.

    │ │ │ +

    The file_storage (fs) parameter defines the files, sizes and │ │ │ +their properties for the torrent to be created. Set this up first, │ │ │ +before passing it to the create_torrent constructor. Instead of using │ │ │ +this overload, consider using the overload taking a vector of │ │ │ +create_file_entry objects instead. It is more efficient.

    │ │ │ +

    The overload that takes a torrent_info object will make a verbatim │ │ │ +copy of its info dictionary (to preserve the info-hash). The copy of │ │ │ +the info dictionary will be used by create_torrent::generate(). This means │ │ │ +that none of the member functions of create_torrent that affects │ │ │ +the content of the info dictionary (such as set_hash()), will │ │ │ +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() generate_buf()

    │ │ │ +
    │ │ │ +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 │ │ │ +whether any of the v1_only or v2_only flags were set on the │ │ │ +constructor. If neither were set, the resulting torrent depends on │ │ │ +which hashes were set. If both v1 and v2 hashes were set, a hybrid │ │ │ +torrent is created.

    │ │ │ +

    Any failure will cause this function to throw system_error, with an │ │ │ +appropriate error message. These are the reasons this call may throw:

    │ │ │ +
      │ │ │ +
    • the file storage has 0 files
    • │ │ │ +
    • the total size of the file storage is 0 bytes (i.e. it only has │ │ │ +empty files)
    • │ │ │ +
    • not all v1 hashes (set_hash()) and not all v2 hashes (set_hash2()) │ │ │ +were set
    • │ │ │ +
    • for v2 torrents, you may not have a directory with the same name as │ │ │ +a file. If that's encountered in the file storage, generate() │ │ │ +fails.
    • │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_comment()

    │ │ │ +
    │ │ │ +void set_comment (char const* str);
    │ │ │ +
    │ │ │ +

    Sets the comment for the torrent. The string str should be utf-8 encoded. │ │ │ +The comment in a torrent file is optional.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_creator()

    │ │ │ +
    │ │ │ +void set_creator (char const* str);
    │ │ │ +
    │ │ │ +

    Sets the creator of the torrent. The string str should be utf-8 encoded. │ │ │ +This is optional.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_creation_date()

    │ │ │ +
    │ │ │ +void set_creation_date (std::time_t timestamp);
    │ │ │ +
    │ │ │ +

    sets the "creation time" field. Defaults to the system clock at the │ │ │ +time of construction of the create_torrent object. The timestamp is │ │ │ +specified in seconds, posix time. If the creation date is set to 0, │ │ │ +the "creation date" field will be omitted from the generated torrent.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_hash()

    │ │ │ +
    │ │ │ +void set_hash (piece_index_t index, sha1_hash const& h);
    │ │ │ +
    │ │ │ +

    This sets the SHA-1 hash for the specified piece (index). You are required │ │ │ +to set the hash for every piece in the torrent before generating it. If you have │ │ │ +the files on disk, you can use the high level convenience function to do this. │ │ │ +See set_piece_hashes(). │ │ │ +A SHA-1 hash of all zeros is internally used to indicate a hash that │ │ │ +has not been set. Setting such hash will not be considered set when │ │ │ +calling generate(). │ │ │ +This function will throw std::system_error if it is called on an │ │ │ +object constructed with the v2_only flag.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_hash2()

    │ │ │ +
    │ │ │ +void set_hash2 (file_index_t file, piece_index_t::diff_type piece, sha256_hash const& h);
    │ │ │ +
    │ │ │ +

    sets the bittorrent v2 hash for file file of the piece piece. │ │ │ +piece is relative to the first piece of the file, starting at 0. The │ │ │ +first piece in the file can be computed with │ │ │ +file_storage::file_index_at_piece(). │ │ │ +The hash, h, is the root of the merkle tree formed by the piece's │ │ │ +16 kiB blocks. Note that piece sizes must be powers-of-2, so all │ │ │ +per-piece merkle trees are complete. │ │ │ +A SHA-256 hash of all zeros is internally used to indicate a hash │ │ │ +that has not been set. Setting such hash will not be considered set │ │ │ +when calling generate(). │ │ │ +This function will throw std::system_error if it is called on an │ │ │ +object constructed with the v1_only flag.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_url_seed()

    │ │ │ +
    │ │ │ +void add_url_seed (string_view url);
    │ │ │ +
    │ │ │ +

    This adds a url seed to the torrent. You can have any number of url seeds. For a │ │ │ +single file torrent, this should be an HTTP url, pointing to a file with identical │ │ │ +content as the file of the torrent. For a multi-file torrent, it should point to │ │ │ +a directory containing a directory with the same name as this torrent, and all the │ │ │ +files of the torrent in it.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_node()

    │ │ │ +
    │ │ │ +void add_node (std::pair<std::string, int> node);
    │ │ │ +
    │ │ │ +

    This adds a DHT node to the torrent. This especially useful if you're creating a │ │ │ +tracker less torrent. It can be used by clients to bootstrap their DHT node from. │ │ │ +The node is a hostname and a port number where there is a DHT node running. │ │ │ +You can have any number of DHT nodes in a torrent.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_tracker()

    │ │ │ +
    │ │ │ +void add_tracker (string_view url, int tier = 0);
    │ │ │ +
    │ │ │ +

    Adds a tracker to the torrent. This is not strictly required, but most torrents │ │ │ +use a tracker as their main source of peers. The url should be an http:// or udp:// │ │ │ +url to a machine running a bittorrent tracker that accepts announces for this torrent's │ │ │ +info-hash. The tier is the fallback priority of the tracker. All trackers with tier 0 are │ │ │ +tried first (in any order). If all fail, trackers with tier 1 are tried. If all of those │ │ │ +fail, trackers with tier 2 are tried, and so on.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_root_cert()

    │ │ │ +
    │ │ │ +void set_root_cert (string_view cert);
    │ │ │ +
    │ │ │ +

    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()

    │ │ │ +
    │ │ │ +void set_priv (bool p);
    │ │ │ +bool priv () const;
    │ │ │ +
    │ │ │ +

    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()

    │ │ │ +
    │ │ │ +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 │ │ │ +file tree will be written. A torrent that is neither │ │ │ +v1-only nor v2-only is a hybrid v1+v2 torrent.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    num_pieces()

    │ │ │ +
    │ │ │ +int num_pieces () const;
    │ │ │ +
    │ │ │ +

    returns the number of pieces in the associated file_storage object.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    end_piece()

    │ │ │ +
    │ │ │ +piece_index_t end_piece () const;
    │ │ │ +
    │ │ │ +

    one past-the-end piece index

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_range()

    │ │ │ +
    │ │ │ +index_range<piece_index_t> piece_range () const noexcept;
    │ │ │ +
    │ │ │ +

    all piece indices in the torrent to be created

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    end_file()

    │ │ │ +
    │ │ │ +file_index_t end_file () const;
    │ │ │ +
    │ │ │ +

    one past-the-end file index

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_range()

    │ │ │ +
    │ │ │ +index_range<file_index_t> file_range () const noexcept;
    │ │ │ +
    │ │ │ +

    all file indices in the torrent to be created

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_at()

    │ │ │ +
    │ │ │ +create_file_entry const& file_at (file_index_t f) const;
    │ │ │ +
    │ │ │ +

    returns a reference to the create_file_entry at the given file index. │ │ │ +Note that this is not necessarily the same entries passed into the │ │ │ +constructor, since the layout may have been canonicalized. e.g. file │ │ │ +order and padding may have changed.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_piece_range()

    │ │ │ +
    │ │ │ +index_range<piece_index_t::diff_type> file_piece_range (file_index_t f);
    │ │ │ +
    │ │ │ +

    for v2 and hybrid torrents only, the pieces in the │ │ │ +specified file, specified as delta from the first piece in the file. │ │ │ +i.e. the first index is 0.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    total_size()

    │ │ │ +
    │ │ │ +std::int64_t total_size () const;
    │ │ │ +
    │ │ │ +

    the total number of bytes of all files and pad files

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    piece_size() piece_length()

    │ │ │ +
    │ │ │ +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_similar_torrent() add_collection()

    │ │ │ +
    │ │ │ +void add_collection (string_view c);
    │ │ │ +void add_similar_torrent (sha1_hash ih);
    │ │ │ +
    │ │ │ +

    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.

    │ │ │ +[report issue]
    │ │ │ +
    modification_time
    │ │ │ +
    This will include the file modification time as part of the torrent. │ │ │ +This is not enabled by default, as it might cause problems when you │ │ │ +create a torrent from separate files with the same content, hoping to │ │ │ +yield the same info-hash. If the files have different modification times, │ │ │ +with this option enabled, you would get different info-hashes for the │ │ │ +files.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    symlinks
    │ │ │ +
    If this flag is set, files that are symlinks get a symlink attribute │ │ │ +set on them and their data will not be included in the torrent. This │ │ │ +is useful if you need to reconstruct a file hierarchy which contains │ │ │ +symlinks.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    v2_only
    │ │ │ +
    Do not generate v1 metadata. The resulting torrent will only be usable by │ │ │ +clients which support v2. This requires setting all v2 hashes, with │ │ │ +set_hash2() before calling generate(). Setting v1 hashes (with │ │ │ +set_hash()) is an error with this flag set.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    v1_only
    │ │ │ +
    do not generate v2 metadata or enforce v2 alignment and padding rules │ │ │ +this is mainly for tests, not recommended for production use. This │ │ │ +requires setting all v1 hashes, with set_hash(), before calling │ │ │ +generate(). Setting v2 hashes (with set_hash2()) is an error with │ │ │ +this flag set.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    canonical_files
    │ │ │ +
    This flag only affects v1-only torrents, and is only relevant │ │ │ +together with the v1_only_flag. This flag will force the │ │ │ +same file order and padding as a v2 (or hybrid) torrent would have. │ │ │ +It has the effect of ordering files and inserting pad files to align │ │ │ +them with piece boundaries.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    no_attributes
    │ │ │ +
    passing this flag to list_files() will ignore file attributes (such as │ │ │ +executable or hidden) when adding the files to the file storage. │ │ │ +Since not all filesystems and operating systems support all file │ │ │ +attributes the resulting torrent may differ depending on where it's │ │ │ +created. If it's important for torrents to be created consistently │ │ │ +across systems, this flag should be set.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    canonical_files_no_tail_padding
    │ │ │ +
    this flag enforces the file layout to be canonical according to the │ │ │ +bittorrent v2 specification (just like the canonical_files flag) │ │ │ +with the one exception that tail padding is not added to the last │ │ │ +file. │ │ │ +This 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.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    list_files()

    │ │ │ +

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │ +
    │ │ │ +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:

    │ │ │ +
    │ │ │ +bool Pred(std::string const& p);
    │ │ │ +
    │ │ │ +

    The path that is passed in to the predicate is the full path of the file or │ │ │ +directory. If no predicate is specified, all files are added, and all directories │ │ │ +are traversed.

    │ │ │ +

    The ".." directory is never traversed.

    │ │ │ +

    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
    │ │ │ +   , std::function<void(piece_index_t)> const& f);
    │ │ │ +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);
    │ │ │ +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);
    │ │ │ +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);
    │ │ │ +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);
    │ │ │ +
    │ │ │ +

    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 settings_pack may be used to configure the │ │ │ +underlying disk access. Such as settings_pack::aio_threads.

    │ │ │ +

    The overloads that don't take an error_code& may throw an exception in case of a │ │ │ +file error, the other overloads sets the error code to reflect the error, if any.

    │ │ │ +

    libtorrent has a plugin 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.

    │ │ │ +

    In short, the plugin interface makes it possible to:

    │ │ │ +
      │ │ │ +
    • register extension messages (sent in the extension handshake), see │ │ │ +extensions.
    • │ │ │ +
    • add data and parse data from the extension handshake.
    • │ │ │ +
    • send extension messages and standard bittorrent messages.
    • │ │ │ +
    • override or block the handling of standard bittorrent messages.
    • │ │ │ +
    • save and restore state via the session state
    • │ │ │ +
    • see all alerts that are posted
    • │ │ │ +
    │ │ │ +
    │ │ │ +
    │ │ │ +

    a word of caution

    │ │ │ +

    Writing your own plugin is a very easy way to introduce serious bugs such as │ │ │ +dead locks and race conditions. Since a plugin has access to internal │ │ │ +structures it is also quite easy to sabotage libtorrent's operation.

    │ │ │ +

    All the callbacks are always called from the libtorrent network thread. In │ │ │ +case portions of your plugin are called from other threads, typically the main │ │ │ +thread, you cannot use any of the member functions on the internal structures │ │ │ +in libtorrent, since those require being called from the libtorrent network │ │ │ +thread . Furthermore, you also need to synchronize your own shared data │ │ │ +within the plugin, to make sure it is not accessed at the same time from the │ │ │ +libtorrent thread (through a callback). If you need to send out a message │ │ │ +from another thread, it is advised to use an internal queue, and do the │ │ │ +actual sending in tick().

    │ │ │ +

    Since the plugin interface gives you easy access to internal structures, it │ │ │ +is not supported as a stable API. Plugins should be considered specific to a │ │ │ +specific version of libtorrent. Although, in practice the internals mostly │ │ │ +don't change that dramatically.

    │ │ │ +
    │ │ │ +
    │ │ │ +

    plugin-interface

    │ │ │ +

    The plugin interface consists of three base classes that the plugin may │ │ │ +implement. These are called plugin, torrent_plugin and peer_plugin. │ │ │ +They are found in the <libtorrent/extensions.hpp> header.

    │ │ │ +

    These plugins are instantiated for each session, torrent and possibly each peer, │ │ │ +respectively.

    │ │ │ +

    For plugins that only need per torrent state, it is enough to only implement │ │ │ +torrent_plugin and pass a constructor function or function object to │ │ │ +session::add_extension() or torrent_handle::add_extension() (if the │ │ │ +torrent has already been started and you want to hook in the extension at │ │ │ +run-time).

    │ │ │ +

    The signature of the function is:

    │ │ │ +
    │ │ │ +std::shared_ptr<torrent_plugin> (*)(torrent_handle const&, client_data_t);
    │ │ │ +
    │ │ │ +

    The second argument is the userdata passed to session::add_torrent() or │ │ │ +torrent_handle::add_extension().

    │ │ │ +

    The function should return a std::shared_ptr<torrent_plugin> which │ │ │ +may or may not be 0. If it is a nullptr, the extension is simply ignored │ │ │ +for this torrent. If it is a valid pointer (to a class inheriting │ │ │ +torrent_plugin), it will be associated with this torrent and callbacks │ │ │ +will be made on torrent events.

    │ │ │ +

    For more elaborate plugins which require session wide state, you would │ │ │ +implement plugin, construct an object (in a std::shared_ptr) and pass │ │ │ +it in to session::add_extension().

    │ │ │ +
    │ │ │ +
    │ │ │ +

    custom alerts

    │ │ │ +

    Since plugins are running within internal libtorrent threads, one convenient │ │ │ +way to communicate with the client is to post custom alerts.

    │ │ │ +

    The expected interface of any alert, apart from deriving from the alert │ │ │ +base class, looks like this:

    │ │ │ +
    │ │ │ +static const int alert_type = <unique alert ID>;
    │ │ │ +virtual int type() const { return alert_type; }
    │ │ │ +
    │ │ │ +virtual std::string message() const;
    │ │ │ +
    │ │ │ +static const alert_category_t static_category = <bitmask of alert::category_t flags>;
    │ │ │ +virtual alert_category_t category() const { return static_category; }
    │ │ │ +
    │ │ │ +virtual char const* what() const { return <string literal of the name of this alert>; }
    │ │ │ +
    │ │ │ +

    The alert_type is used for the type-checking in alert_cast. It must │ │ │ +not collide with any other alert. The built-in alerts in libtorrent will │ │ │ +not use alert type IDs greater than user_alert_id. When defining your │ │ │ +own alert, make sure it's greater than this constant.

    │ │ │ +

    type() is the run-time equivalence of the alert_type.

    │ │ │ +

    The message() virtual function is expected to construct a useful │ │ │ +string representation of the alert and the event or data it represents. │ │ │ +Something convenient to put in a log file for instance.

    │ │ │ +

    clone() is used internally to copy alerts. The suggested implementation │ │ │ +of simply allocating a new instance as a copy of *this is all that's │ │ │ +expected.

    │ │ │ +

    The static category is required for checking whether or not the category │ │ │ +for a specific alert is enabled or not, without instantiating the alert. │ │ │ +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 alert.

    │ │ │ +

    For more information, see the alert section.

    │ │ │ +[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 maybe_unchoke_this_peer ();
    │ │ │ +   void choke_this_peer ();
    │ │ │ +   void get_peer_info (peer_info& p) const;
    │ │ │ +   torrent_handle associated_torrent () const;
    │ │ │ +   tcp::endpoint local_endpoint () const;
    │ │ │ +   tcp::endpoint const& remote () const;
    │ │ │ +   bool is_connecting () const;
    │ │ │ +   void disconnect (error_code const& ec, operation_t op
    │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ +   bool is_outgoing () const;
    │ │ │ +   bool is_disconnecting () const;
    │ │ │ +   bool on_local_network () const;
    │ │ │ +   bool ignore_unchoke_slots () const;
    │ │ │ +   bool failed () const;
    │ │ │ +   bool should_log (peer_log_alert::direction_t direction) 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 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]
    │ │ │ +
    │ │ │ +

    find_plugin() add_extension()

    │ │ │ +
    │ │ │ +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]
    │ │ │ +
    │ │ │ +

    has_piece() pid()

    │ │ │ +
    │ │ │ +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_choked() is_interesting()

    │ │ │ +
    │ │ │ +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 maybe_unchoke_this_peer ();
    │ │ │ +void choke_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 local_endpoint () const;
    │ │ │ +tcp::endpoint const& remote () const;
    │ │ │ +
    │ │ │ +

    the remote peer's address and port, and the local endpoint of │ │ │ +the socket on our side.

    │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    is_connecting() is_disconnecting() disconnect() is_outgoing()

    │ │ │ +
    │ │ │ +bool is_connecting () const;
    │ │ │ +void disconnect (error_code const& ec, operation_t op
    │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ +bool is_outgoing () const;
    │ │ │ +bool is_disconnecting () 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]
    │ │ │ +
    │ │ │ +

    ignore_unchoke_slots() on_local_network()

    │ │ │ +
    │ │ │ +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]
    │ │ │ +
    │ │ │ +

    peer_log() should_log()

    │ │ │ +
    │ │ │ +bool should_log (peer_log_alert::direction_t direction) const;
    │ │ │ +void peer_log (peer_log_alert::direction_t direction
    │ │ │ +      , peer_log_alert::event_t event, char const* fmt = "", ...) const TORRENT_FORMAT(4,5);
    │ │ │ +
    │ │ │ +

    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]
    │ │ │ +
    │ │ │ +

    time_of_last_unchoke() last_seen_complete()

    │ │ │ +
    │ │ │ +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 support_extensions () const;
    │ │ │ +   bool packet_finished () const;
    │ │ │ +   bool supports_encryption () const;
    │ │ │ +   void switch_send_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ +   void switch_recv_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]
    │ │ │ +
    │ │ │ +

    support_extensions() packet_finished()

    │ │ │ +
    │ │ │ +bool support_extensions () const;
    │ │ │ +bool packet_finished () 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_send_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ +void switch_recv_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]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    plugin

    │ │ │ +

    Declared in "libtorrent/extensions.hpp"

    │ │ │ +

    this is the base class for a session plugin. One primary feature │ │ │ +is that it is notified of all torrents that are added to the session, │ │ │ +and can add its own torrent_plugins.

    │ │ │ +
    │ │ │ +struct plugin
    │ │ │  {
    │ │ │ -   void set_bool (int name, bool val) override;
    │ │ │ -   void set_int (int name, int 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;
    │ │ │ -
    │ │ │ -   enum type_bases
    │ │ │ -   {
    │ │ │ -      string_type_base,
    │ │ │ -      int_type_base,
    │ │ │ -      bool_type_base,
    │ │ │ -      type_mask,
    │ │ │ -      index_mask,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   enum mmap_write_mode_t
    │ │ │ -   {
    │ │ │ -      always_pwrite,
    │ │ │ -      always_mmap_write,
    │ │ │ -      auto_mmap_write,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   enum suggest_mode_t
    │ │ │ -   {
    │ │ │ -      no_piece_suggestions,
    │ │ │ -      suggest_read_cache,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   enum choking_algorithm_t
    │ │ │ -   {
    │ │ │ -      fixed_slots_choker,
    │ │ │ -      rate_based_choker,
    │ │ │ -      deprecated_bittyrant_choker,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   enum seed_choking_algorithm_t
    │ │ │ -   {
    │ │ │ -      round_robin,
    │ │ │ -      fastest_upload,
    │ │ │ -      anti_leech,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   enum io_buffer_mode_t
    │ │ │ -   {
    │ │ │ -      enable_os_cache,
    │ │ │ -      deprecated_disable_os_cache_for_aligned_files,
    │ │ │ -      disable_os_cache,
    │ │ │ -      write_through,
    │ │ │ -   };
    │ │ │ -
    │ │ │ -   enum bandwidth_mixed_algo_t
    │ │ │ -   {
    │ │ │ -      prefer_tcp,
    │ │ │ -      peer_proportional,
    │ │ │ -   };
    │ │ │ +   virtual feature_flags_t implemented_features ();
    │ │ │ +   virtual std::shared_ptr<torrent_plugin> new_torrent (torrent_handle const&, client_data_t);
    │ │ │ +   virtual void added (session_handle const&);
    │ │ │ +   virtual void abort ();
    │ │ │ +   virtual bool on_dht_request (string_view /* query */
    │ │ │ +      , udp::endpoint const& /* source */, bdecode_node const& /* message */
    │ │ │ +      , entry& /* response */);
    │ │ │ +   virtual void on_alert (alert const*);
    │ │ │ +   virtual bool on_unknown_torrent (info_hash_t const& /* info_hash */
    │ │ │ +      , peer_connection_handle const& /* pc */, add_torrent_params& /* p */);
    │ │ │ +   virtual void on_tick ();
    │ │ │ +   virtual uint64_t get_unchoke_priority (peer_connection_handle const& /* peer */);
    │ │ │ +   virtual std::map<std::string, std::string> save_state () const;
    │ │ │ +   virtual void load_state (std::map<std::string, std::string> const&);
    │ │ │  
    │ │ │ -   enum enc_policy
    │ │ │ -   {
    │ │ │ -      pe_forced,
    │ │ │ -      pe_enabled,
    │ │ │ -      pe_disabled,
    │ │ │ -   };
    │ │ │ +   static inline constexpr feature_flags_t optimistic_unchoke_feature  = 1_bit;
    │ │ │ +   static inline constexpr feature_flags_t tick_feature  = 2_bit;
    │ │ │ +   static inline constexpr feature_flags_t dht_request_feature  = 3_bit;
    │ │ │ +   static inline constexpr feature_flags_t alert_feature  = 4_bit;
    │ │ │ +   static inline constexpr feature_flags_t unknown_torrent_feature  = 5_bit;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    implemented_features()

    │ │ │ +
    │ │ │ +virtual feature_flags_t implemented_features ();
    │ │ │ +
    │ │ │ +

    This function is expected to return a bitmask indicating which features │ │ │ +this plugin implements. Some callbacks on this object may not be called │ │ │ +unless the corresponding feature flag is returned here. Note that │ │ │ +callbacks may still be called even if the corresponding feature is not │ │ │ +specified in the return value here. See feature_flags_t for possible │ │ │ +flags to return.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    new_torrent()

    │ │ │ +
    │ │ │ +virtual std::shared_ptr<torrent_plugin> new_torrent (torrent_handle const&, client_data_t);
    │ │ │ +
    │ │ │ +

    this is called by the session every time a new torrent is added. │ │ │ +The torrent* points to the internal torrent object created │ │ │ +for the new torrent. The client_data_t is the userdata pointer as │ │ │ +passed in via add_torrent_params.

    │ │ │ +

    If the plugin returns a torrent_plugin instance, it will be added │ │ │ +to the new torrent. Otherwise, return an empty shared_ptr to a │ │ │ +torrent_plugin (the default).

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    added()

    │ │ │ +
    │ │ │ +virtual void added (session_handle const&);
    │ │ │ +
    │ │ │ +

    called when plugin is added to a session

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    abort()

    │ │ │ +
    │ │ │ +virtual void abort ();
    │ │ │ +
    │ │ │ +

    called when the session is aborted │ │ │ +the plugin should perform any cleanup necessary to allow the session's │ │ │ +destruction (e.g. cancel outstanding async operations)

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_dht_request()

    │ │ │ +
    │ │ │ +virtual bool on_dht_request (string_view /* query */
    │ │ │ +      , udp::endpoint const& /* source */, bdecode_node const& /* message */
    │ │ │ +      , entry& /* response */);
    │ │ │ +
    │ │ │ +

    called when a dht request is received. │ │ │ +If your plugin expects this to be called, make sure to include the flag │ │ │ +dht_request_feature in the return value from implemented_features().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_alert()

    │ │ │ +
    │ │ │ +virtual void on_alert (alert const*);
    │ │ │ +
    │ │ │ +

    called when an alert is posted alerts that are filtered are not posted. │ │ │ +If your plugin expects this to be called, make sure to include the flag │ │ │ +alert_feature in the return value from implemented_features().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_unknown_torrent()

    │ │ │ +
    │ │ │ +virtual bool on_unknown_torrent (info_hash_t const& /* info_hash */
    │ │ │ +      , peer_connection_handle const& /* pc */, add_torrent_params& /* p */);
    │ │ │ +
    │ │ │ +

    return true if the add_torrent_params should be added

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_tick()

    │ │ │ +
    │ │ │ +virtual void on_tick ();
    │ │ │ +
    │ │ │ +

    called once per second. │ │ │ +If your plugin expects this to be called, make sure to include the flag │ │ │ +tick_feature in the return value from implemented_features().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_unchoke_priority()

    │ │ │ +
    │ │ │ +virtual uint64_t get_unchoke_priority (peer_connection_handle const& /* peer */);
    │ │ │ +
    │ │ │ +

    called when choosing peers to optimistically unchoke. The return value │ │ │ +indicates the peer's priority for unchoking. Lower return values │ │ │ +correspond to higher priority. Priorities above 2^63-1 are reserved. │ │ │ +If your plugin has no priority to assign a peer it should return 2^64-1. │ │ │ +If your plugin expects this to be called, make sure to include the flag │ │ │ +optimistic_unchoke_feature in the return value from implemented_features(). │ │ │ +If multiple plugins implement this function the lowest return value │ │ │ +(i.e. the highest priority) is used.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    save_state()

    │ │ │ +
    │ │ │ +virtual std::map<std::string, std::string> save_state () const;
    │ │ │ +
    │ │ │ +

    called when serializing session state. The returned map of │ │ │ +key/value strings is stored alongside the session state and │ │ │ +passed back to load_state() on the next session.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    load_state()

    │ │ │ +
    │ │ │ +virtual void load_state (std::map<std::string, std::string> const&);
    │ │ │ +
    │ │ │ +

    called on startup while loading settings state from the session_params

    │ │ │ +[report issue]
    │ │ │ +
    optimistic_unchoke_feature
    │ │ │ +
    include this bit if your plugin needs to alter the order of the │ │ │ +optimistic unchoke of peers. i.e. have the on_optimistic_unchoke() │ │ │ +callback be called.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    tick_feature
    │ │ │ +
    include this bit if your plugin needs to have on_tick() called
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    dht_request_feature
    │ │ │ +
    include this bit if your plugin needs to have on_dht_request() │ │ │ +called
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    alert_feature
    │ │ │ +
    include this bit if your plugin needs to have on_alert() │ │ │ +called
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    unknown_torrent_feature
    │ │ │ +
    include this bit if your plugin needs to have on_unknown_torrent() │ │ │ +called even if there is no active torrent in the session
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    torrent_plugin

    │ │ │ +

    Declared in "libtorrent/extensions.hpp"

    │ │ │ +

    Torrent plugins are associated with a single torrent and have a number │ │ │ +of functions called at certain events. Many of its functions have the │ │ │ +ability to change or override the default libtorrent behavior.

    │ │ │ +
    │ │ │ +struct torrent_plugin
    │ │ │ +{
    │ │ │ +   virtual std::shared_ptr<peer_plugin> new_connection (peer_connection_handle const&);
    │ │ │ +   virtual void on_piece_pass (piece_index_t);
    │ │ │ +   virtual void on_piece_failed (piece_index_t);
    │ │ │ +   virtual void tick ();
    │ │ │ +   virtual bool on_pause ();
    │ │ │ +   virtual bool on_resume ();
    │ │ │ +   virtual void on_files_checked ();
    │ │ │ +   virtual void on_state (torrent_status::state_t);
    │ │ │ +   virtual void on_add_peer (tcp::endpoint const&,
    │ │ │ +      peer_source_flags_t, add_peer_flags_t);
    │ │ │  
    │ │ │ -   enum enc_level
    │ │ │ -   {
    │ │ │ -      pe_plaintext,
    │ │ │ -      pe_rc4,
    │ │ │ -      pe_both,
    │ │ │ -   };
    │ │ │ +   static inline constexpr add_peer_flags_t first_time  = 1_bit;
    │ │ │ +   static inline constexpr add_peer_flags_t filtered  = 2_bit;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    new_connection()

    │ │ │ +
    │ │ │ +virtual std::shared_ptr<peer_plugin> new_connection (peer_connection_handle const&);
    │ │ │ +
    │ │ │ +

    This function is called each time a new peer is connected to the torrent. You │ │ │ +may choose to ignore this by just returning a default constructed │ │ │ +shared_ptr (in which case you don't need to override this member │ │ │ +function).

    │ │ │ +

    If you need an extension to the peer connection (which most plugins do) you │ │ │ +are supposed to return an instance of your peer_plugin class. Which in │ │ │ +turn will have its hook functions called on event specific to that peer.

    │ │ │ +

    The peer_connection_handle will be valid as long as the shared_ptr │ │ │ +is being held by the torrent object. So, it is generally a good idea to not │ │ │ +keep a shared_ptr to your own peer_plugin. If you want to keep references │ │ │ +to it, use weak_ptr.

    │ │ │ +

    If this function throws an exception, the connection will be closed.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_piece_pass() on_piece_failed()

    │ │ │ +
    │ │ │ +virtual void on_piece_pass (piece_index_t);
    │ │ │ +virtual void on_piece_failed (piece_index_t);
    │ │ │ +
    │ │ │ +

    These hooks are called when a piece passes the hash check or fails the hash │ │ │ +check, respectively. The index is the piece index that was downloaded. │ │ │ +It is possible to access the list of peers that participated in sending the │ │ │ +piece through the torrent and the piece_picker.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    tick()

    │ │ │ +
    │ │ │ +virtual void tick ();
    │ │ │ +
    │ │ │ +

    This hook is called approximately once per second. It is a way of making it │ │ │ +easy for plugins to do timed events, for sending messages or whatever.

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_pause() on_resume()

    │ │ │ +
    │ │ │ +virtual bool on_pause ();
    │ │ │ +virtual bool on_resume ();
    │ │ │ +
    │ │ │ +

    These hooks are called when the torrent is paused and resumed respectively. │ │ │ +The return value indicates if the event was handled. A return value of │ │ │ +true indicates that it was handled, and no other plugin after this one │ │ │ +will have this hook function called, and the standard handler will also not be │ │ │ +invoked. So, returning true effectively overrides the standard behavior of │ │ │ +pause or resume.

    │ │ │ +

    Note that if you call pause() or resume() on the torrent from your │ │ │ +handler it will recurse back into your handler, so in order to invoke the │ │ │ +standard handler, you have to keep your own state on whether you want standard │ │ │ +behavior or overridden behavior.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_files_checked()

    │ │ │ +
    │ │ │ +virtual void on_files_checked ();
    │ │ │ +
    │ │ │ +

    This function is called when the initial files of the torrent have been │ │ │ +checked. If there are no files to check, this function is called immediately.

    │ │ │ +

    i.e. This function is always called when the torrent is in a state where it │ │ │ +can start downloading.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_state()

    │ │ │ +
    │ │ │ +virtual void on_state (torrent_status::state_t);
    │ │ │ +
    │ │ │ +

    called when the torrent changes state │ │ │ +the state is one of torrent_status::state_t │ │ │ +enum members

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_add_peer()

    │ │ │ +
    │ │ │ +virtual void on_add_peer (tcp::endpoint const&,
    │ │ │ +      peer_source_flags_t, add_peer_flags_t);
    │ │ │ +
    │ │ │ +

    called every time a new peer is added to the peer list. │ │ │ +This is before the peer is connected to. For flags, see │ │ │ +torrent_plugin::flags_t. The source argument refers to │ │ │ +the source where we learned about this peer from. It's a │ │ │ +bitmask, because many sources may have told us about the same │ │ │ +peer. For peer source flags, see peer_info::peer_source_flags.

    │ │ │ +[report issue]
    │ │ │ +
    first_time
    │ │ │ +
    this is the first time we see this peer
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    filtered
    │ │ │ +
    this peer was not added because it was │ │ │ +filtered by the IP filter
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    peer_plugin

    │ │ │ +

    Declared in "libtorrent/extensions.hpp"

    │ │ │ +

    peer plugins are associated with a specific peer. A peer could be │ │ │ +both a regular bittorrent peer (bt_peer_connection) or one of the │ │ │ +web seed connections (web_peer_connection). │ │ │ +In order to only attach to certain peers, make your │ │ │ +torrent_plugin::new_connection only return a plugin for certain peer │ │ │ +connection types

    │ │ │ +
    │ │ │ +struct peer_plugin
    │ │ │ +{
    │ │ │ +   virtual string_view type () const;
    │ │ │ +   virtual void add_handshake (entry&);
    │ │ │ +   virtual void on_disconnect (error_code const&);
    │ │ │ +   virtual void on_connected ();
    │ │ │ +   virtual bool on_handshake (span<char const>);
    │ │ │ +   virtual bool on_extension_handshake (bdecode_node const&);
    │ │ │ +   virtual bool on_have (piece_index_t);
    │ │ │ +   virtual bool on_dont_have (piece_index_t);
    │ │ │ +   virtual bool on_request (peer_request const&);
    │ │ │ +   virtual bool on_bitfield (bitfield const& /*bitfield*/);
    │ │ │ +   virtual bool on_interested ();
    │ │ │ +   virtual bool on_not_interested ();
    │ │ │ +   virtual bool on_have_all ();
    │ │ │ +   virtual bool on_unchoke ();
    │ │ │ +   virtual bool on_have_none ();
    │ │ │ +   virtual bool on_allowed_fast (piece_index_t);
    │ │ │ +   virtual bool on_choke ();
    │ │ │ +   virtual bool on_piece (peer_request const& /*piece*/
    │ │ │ +      , span<char const> /*buf*/);
    │ │ │ +   virtual bool on_cancel (peer_request const&);
    │ │ │ +   virtual bool on_reject (peer_request const&);
    │ │ │ +   virtual bool on_suggest (piece_index_t);
    │ │ │ +   virtual void sent_cancel (peer_request const&);
    │ │ │ +   virtual void sent_have_all ();
    │ │ │ +   virtual void sent_request (peer_request const&);
    │ │ │ +   virtual void sent_choke ();
    │ │ │ +   virtual void sent_suggest (piece_index_t);
    │ │ │ +   virtual void sent_reject_request (peer_request const&);
    │ │ │ +   virtual void sent_not_interested ();
    │ │ │ +   virtual void sent_have (piece_index_t);
    │ │ │ +   virtual void sent_piece (peer_request const&);
    │ │ │ +   virtual void sent_interested ();
    │ │ │ +   virtual void sent_have_none ();
    │ │ │ +   virtual void sent_unchoke ();
    │ │ │ +   virtual void sent_allow_fast (piece_index_t);
    │ │ │ +   virtual void sent_payload (int /* bytes */);
    │ │ │ +   virtual bool can_disconnect (error_code const& /*ec*/);
    │ │ │ +   virtual bool on_extended (int /*length*/, int /*msg*/,
    │ │ │ +      span<char const> /*body*/);
    │ │ │ +   virtual bool on_unknown_message (int /*length*/, int /*msg*/,
    │ │ │ +      span<char const> /*body*/);
    │ │ │ +   virtual void on_piece_pass (piece_index_t);
    │ │ │ +   virtual void on_piece_failed (piece_index_t);
    │ │ │ +   virtual void tick ();
    │ │ │ +   virtual bool write_request (peer_request const&);
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    type()

    │ │ │ +
    │ │ │ +virtual string_view type () const;
    │ │ │ +
    │ │ │ +

    This function is expected to return the name of │ │ │ +the plugin.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_handshake()

    │ │ │ +
    │ │ │ +virtual void add_handshake (entry&);
    │ │ │ +
    │ │ │ +

    can add entries to the extension handshake │ │ │ +this is not called for web seeds

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_disconnect()

    │ │ │ +
    │ │ │ +virtual void on_disconnect (error_code const&);
    │ │ │ +
    │ │ │ +

    called when the peer is being disconnected.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_connected()

    │ │ │ +
    │ │ │ +virtual void on_connected ();
    │ │ │ +
    │ │ │ +

    called when the peer is successfully connected. Note that │ │ │ +incoming connections will have been connected by the time │ │ │ +the peer plugin is attached to it, and won't have this hook │ │ │ +called.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_handshake()

    │ │ │ +
    │ │ │ +virtual bool on_handshake (span<char const>);
    │ │ │ +
    │ │ │ +

    this is called when the initial bittorrent handshake is received. │ │ │ +Returning false means that the other end doesn't support this extension │ │ │ +and will remove it from the list of plugins. this is not called for web │ │ │ +seeds

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_extension_handshake()

    │ │ │ +
    │ │ │ +virtual bool on_extension_handshake (bdecode_node const&);
    │ │ │ +
    │ │ │ +

    called when the extension handshake from the other end is received │ │ │ +if this returns false, it means that this extension isn't │ │ │ +supported by this peer. It will result in this peer_plugin │ │ │ +being removed from the peer_connection and destructed. │ │ │ +this is not called for web seeds

    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_unchoke() on_not_interested() on_dont_have() on_request() on_interested() on_allowed_fast() on_have() on_choke() on_have_all() on_bitfield() on_have_none()

    │ │ │ +
    │ │ │ +virtual bool on_have (piece_index_t);
    │ │ │ +virtual bool on_dont_have (piece_index_t);
    │ │ │ +virtual bool on_request (peer_request const&);
    │ │ │ +virtual bool on_bitfield (bitfield const& /*bitfield*/);
    │ │ │ +virtual bool on_interested ();
    │ │ │ +virtual bool on_not_interested ();
    │ │ │ +virtual bool on_have_all ();
    │ │ │ +virtual bool on_unchoke ();
    │ │ │ +virtual bool on_have_none ();
    │ │ │ +virtual bool on_allowed_fast (piece_index_t);
    │ │ │ +virtual bool on_choke ();
    │ │ │ +
    │ │ │ +

    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]
    │ │ │ +
    │ │ │ +

    on_piece()

    │ │ │ +
    │ │ │ +virtual bool on_piece (peer_request const& /*piece*/
    │ │ │ +      , span<char const> /*buf*/);
    │ │ │ +
    │ │ │ +

    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_cancel() on_reject() on_suggest()

    │ │ │ +
    │ │ │ +virtual bool on_cancel (peer_request const&);
    │ │ │ +virtual bool on_reject (peer_request const&);
    │ │ │ +virtual bool on_suggest (piece_index_t);
    │ │ │ +
    │ │ │ +

    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_piece() sent_have_all() sent_interested() sent_cancel() sent_have() sent_unchoke() sent_have_none() sent_suggest() sent_reject_request() sent_request() sent_choke() sent_not_interested() sent_allow_fast()

    │ │ │ +
    │ │ │ +virtual void sent_cancel (peer_request const&);
    │ │ │ +virtual void sent_have_all ();
    │ │ │ +virtual void sent_request (peer_request const&);
    │ │ │ +virtual void sent_choke ();
    │ │ │ +virtual void sent_suggest (piece_index_t);
    │ │ │ +virtual void sent_reject_request (peer_request const&);
    │ │ │ +virtual void sent_not_interested ();
    │ │ │ +virtual void sent_have (piece_index_t);
    │ │ │ +virtual void sent_piece (peer_request const&);
    │ │ │ +virtual void sent_interested ();
    │ │ │ +virtual void sent_have_none ();
    │ │ │ +virtual void sent_unchoke ();
    │ │ │ +virtual void sent_allow_fast (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]
    │ │ │ +
    │ │ │ +

    on_extended()

    │ │ │ +
    │ │ │ +virtual bool on_extended (int /*length*/, int /*msg*/,
    │ │ │ +      span<char const> /*body*/);
    │ │ │ +
    │ │ │ +

    called when an extended message is received. If returning true, │ │ │ +the message is not processed by any other plugin and if false │ │ │ +is returned the next plugin in the chain will receive it to │ │ │ +be able to handle it. This is not called for web seeds. │ │ │ +thus function may be called more than once per incoming message, but │ │ │ +only the last of the calls will the body size equal the length. │ │ │ +i.e. Every time another fragment of the message is received, this │ │ │ +function will be called, until finally the whole message has been │ │ │ +received. The purpose of this is to allow early disconnects for invalid │ │ │ +messages and for reporting progress of receiving large messages.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_unknown_message()

    │ │ │ +
    │ │ │ +virtual bool on_unknown_message (int /*length*/, int /*msg*/,
    │ │ │ +      span<char const> /*body*/);
    │ │ │ +
    │ │ │ +

    this is not called for web seeds

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_piece_pass() on_piece_failed()

    │ │ │ +
    │ │ │ +virtual void on_piece_pass (piece_index_t);
    │ │ │ +virtual void on_piece_failed (piece_index_t);
    │ │ │ +
    │ │ │ +

    called when a piece that this peer participated in either │ │ │ +fails or passes the hash_check

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    tick()

    │ │ │ +
    │ │ │ +virtual void tick ();
    │ │ │ +
    │ │ │ +

    called approximately once every second

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    write_request()

    │ │ │ +
    │ │ │ +virtual bool write_request (peer_request const&);
    │ │ │ +
    │ │ │ +

    called each time a request message is to be sent. If true │ │ │ +is returned, the original request message won't be sent and │ │ │ +no other plugin will have this function called.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    crypto_plugin

    │ │ │ +

    Declared in "libtorrent/extensions.hpp"

    │ │ │ +

    interface implemented by a plugin that wants to take over the │ │ │ +encryption / decryption of a peer connection. Returned by │ │ │ +peer_plugin::wrap_socket() to plug into the BitTorrent peer │ │ │ +connection's send / receive path. Used by the built-in protocol │ │ │ +encryption (MSE) implementation.

    │ │ │ +
    │ │ │ +struct crypto_plugin
    │ │ │ +{
    │ │ │ +   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()

    │ │ │ +
    │ │ │ +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 │ │ │ +encrypting bytes sent to the peer. Both are called once │ │ │ +during the handshake before any data flows through the │ │ │ +plugin.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    encrypt()

    │ │ │ +
    │ │ │ +encrypt (span<span<char>> /*send_vec*/) = 0;
    │ │ │ +
    │ │ │ +

    encrypted the provided buffers and returns the number of bytes which │ │ │ +are now ready to be sent to the lower layer. This must be at least │ │ │ +as large as the number of bytes passed in and may be larger if there │ │ │ +is additional data to be inserted at the head of the send buffer. │ │ │ +The additional data is returned as the second tuple value. Any │ │ │ +returned buffer as well as the iovec itself, to be prepended to the │ │ │ +send buffer, must be owned by the crypto plugin and guaranteed to stay │ │ │ +alive until the crypto_plugin is destructed or this function is called │ │ │ +again.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    decrypt()

    │ │ │ +
    │ │ │ +virtual std::tuple<int, int, int> decrypt (span<span<char>> /*receive_vec*/) = 0;
    │ │ │ +
    │ │ │ +

    decrypt the provided buffers. │ │ │ +returns is a tuple representing the values │ │ │ +(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]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    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);
    │ │ │ +
    │ │ │ +

    constructor function for the ut_pex extension. The ut_pex │ │ │ +extension allows peers to gossip about their connections, allowing │ │ │ +the swarm stay well connected and peers aware of more peers in the │ │ │ +swarm. This extension is enabled by default unless explicitly disabled in │ │ │ +the session constructor.

    │ │ │ +

    This can either be passed in the add_torrent_params::extensions field, or │ │ │ +via torrent_handle::add_extension().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    create_smart_ban_plugin()

    │ │ │ +

    Declared in "libtorrent/extensions/smart_ban.hpp"

    │ │ │ +
    │ │ │ +std::shared_ptr<torrent_plugin> create_smart_ban_plugin (torrent_handle const&, client_data_t);
    │ │ │ +
    │ │ │ +

    constructor function for the smart ban extension. The extension keeps │ │ │ +track of the data peers have sent us for failing pieces and once the │ │ │ +piece completes and passes the hash check bans the peers that turned │ │ │ +out to have sent corrupt data. │ │ │ +This function can either be passed in the add_torrent_params::extensions │ │ │ +field, or via torrent_handle::add_extension().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    create_ut_metadata_plugin()

    │ │ │ +

    Declared in "libtorrent/extensions/ut_metadata.hpp"

    │ │ │ +
    │ │ │ +std::shared_ptr<torrent_plugin> create_ut_metadata_plugin (torrent_handle const&, client_data_t);
    │ │ │ +
    │ │ │ +

    constructor function for the ut_metadata extension. The ut_metadata │ │ │ +extension allows peers to request the .torrent file (or more │ │ │ +specifically the info-dictionary of the .torrent file) from each │ │ │ +other. This is the main building block in making magnet links work. │ │ │ +This extension is enabled by default unless explicitly disabled in │ │ │ +the session constructor.

    │ │ │ +

    This can either be passed in the add_torrent_params::extensions field, or │ │ │ +via torrent_handle::add_extension().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    ip_filter

    │ │ │ +

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ +

    The ip_filter class is a set of rules that uniquely categorizes all │ │ │ +ip addresses as allowed or disallowed. The default constructor creates │ │ │ +a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for │ │ │ +the IPv4 range, and the equivalent range covering all addresses for the │ │ │ +IPv6 range).

    │ │ │ +

    A default constructed ip_filter does not filter any address.

    │ │ │ +
    │ │ │ +struct ip_filter
    │ │ │ +{
    │ │ │ +   ip_filter ();
    │ │ │ +   ip_filter& operator= (ip_filter const&);
    │ │ │ +   ip_filter (ip_filter&&) noexcept;
    │ │ │ +   ip_filter (ip_filter const&);
    │ │ │ +   ~ip_filter ();
    │ │ │ +   ip_filter& operator= (ip_filter&&) noexcept;
    │ │ │ +   bool empty () const;
    │ │ │ +   void add_rule (address const& first, address const& last, std::uint32_t flags);
    │ │ │ +   std::uint32_t access (address const& addr) const;
    │ │ │ +   filter_tuple_t export_filter () const;
    │ │ │  
    │ │ │ -   enum proxy_type_t
    │ │ │ +   enum access_flags
    │ │ │     {
    │ │ │ -      none,
    │ │ │ -      socks4,
    │ │ │ -      socks5,
    │ │ │ -      socks5_pw,
    │ │ │ -      http,
    │ │ │ -      http_pw,
    │ │ │ +      blocked,
    │ │ │     };
    │ │ │  };
    │ │ │  
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_bool() set_str() set_int()

    │ │ │ -
    │ │ │ -void set_bool (int name, bool val) override;
    │ │ │ -void set_int (int name, int 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()

    │ │ │ +[report issue]
    │ │ │ +

    empty()

    │ │ │
    │ │ │ -bool has_val (int name) const override;
    │ │ │ +bool empty () const;
    │ │ │  
    │ │ │ -

    queries whether the specified configuration option has a value set in │ │ │ -this pack. name can be any enumeration value from string_types, │ │ │ -int_types or bool_types.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    clear()

    │ │ │ +

    returns true if the filter does not contain any rules

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_rule()

    │ │ │
    │ │ │ -void clear ();
    │ │ │ +void add_rule (address const& first, address const& last, std::uint32_t flags);
    │ │ │  
    │ │ │ -

    clear the settings pack from all settings

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    clear()

    │ │ │ +

    Adds a rule to the filter. first and last defines a range of │ │ │ +ip addresses that will be marked with the given flags. The flags │ │ │ +can currently be 0, which means allowed, or ip_filter::blocked, which │ │ │ +means disallowed.

    │ │ │ +

    precondition: │ │ │ +first.is_v4() == last.is_v4() && first.is_v6() == last.is_v6()

    │ │ │ +

    postcondition: │ │ │ +access(x) == flags for every x in the range [first, last]

    │ │ │ +

    This means that in a case of overlapping ranges, the last one applied takes │ │ │ +precedence.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    access()

    │ │ │
    │ │ │ -void clear (int name);
    │ │ │ +std::uint32_t access (address const& addr) const;
    │ │ │  
    │ │ │ -

    clear a specific setting from the pack

    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_str() get_bool() get_int()

    │ │ │ +

    Returns the access permissions for the given address (addr). The permission │ │ │ +can currently be 0 or ip_filter::blocked. The complexity of this operation │ │ │ +is O(log n), where n is the minimum number of non-overlapping ranges to describe │ │ │ +the current filter.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    export_filter()

    │ │ │
    │ │ │ -int get_int (int name) const override;
    │ │ │ -bool get_bool (int name) const override;
    │ │ │ -std::string const& get_str (int name) const override;
    │ │ │ +filter_tuple_t export_filter () const;
    │ │ │  
    │ │ │ -

    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]
    │ │ │ -
    │ │ │ -

    enum type_bases

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    string_type_base0 
    int_type_base16384 
    bool_type_base32768 
    type_mask49152 
    index_mask16383 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum mmap_write_mode_t

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    always_pwrite0disable writing to disk via mmap, always use normal write calls
    always_mmap_write1prefer using memory mapped files for disk writes (at least for │ │ │ -large files where it might make sense)
    auto_mmap_write2determine whether to use pwrite or memory mapped files for disk │ │ │ -writes depending on the kind of storage behind the save path
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum suggest_mode_t

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_piece_suggestions0disables suggestion messages
    suggest_read_cache1sends suggest messages for the pieces currently in the read │ │ │ -cache, as a hint to peers about cache-friendly piece selection
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum choking_algorithm_t

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    fixed_slots_choker0This is the traditional choker with a fixed number of unchoke │ │ │ -slots (as specified by settings_pack::unchoke_slots_limit).
    rate_based_choker2

    This opens up unchoke slots based on the upload rate achieved to │ │ │ -peers. The more slots that are opened, the marginal upload rate │ │ │ -required to open up another slot increases. Configure the initial │ │ │ -threshold with settings_pack::rate_choker_initial_threshold.

    │ │ │ -

    For more information, see rate based choking.

    │ │ │ -
    deprecated_bittyrant_choker3 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum seed_choking_algorithm_t

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    round_robin0which round-robins the peers that are unchoked │ │ │ -when seeding. This distributes the upload bandwidth uniformly and │ │ │ -fairly. It minimizes the ability for a peer to download everything │ │ │ -without redistributing it.
    fastest_upload1unchokes the peers we can send to the fastest. This might be a │ │ │ -bit more reliable in utilizing all available capacity.
    anti_leech2prioritizes peers who have just started or are │ │ │ -just about to finish the download. The intention is to force │ │ │ -peers in the middle of the download to trade with each other. │ │ │ -This does not just take into account the pieces a peer is │ │ │ -reporting having downloaded, but also the pieces we have sent │ │ │ -to it.
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum io_buffer_mode_t

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    enable_os_cache0 
    deprecated_disable_os_cache_for_aligned_files1 
    disable_os_cache2 
    write_through3 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum bandwidth_mixed_algo_t

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    prefer_tcp0disables the mixed mode bandwidth balancing
    peer_proportional1does not throttle uTP, throttles TCP to the same proportion │ │ │ -of throughput as there are TCP connections
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum enc_policy

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +

    This function will return the current state of the filter in the minimum number of │ │ │ +ranges possible. They are sorted from ranges in low addresses to high addresses. Each │ │ │ +entry in the returned vector is a range with the access control specified in its │ │ │ +flags field.

    │ │ │ +

    The return value is a tuple containing two range-lists. One for IPv4 addresses │ │ │ +and one for IPv6 addresses.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum access_flags

    │ │ │ +

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ │ │ │ │ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescription
    pe_forced0Only encrypted connections are allowed. Incoming connections that │ │ │ -are not encrypted are closed and if the encrypted outgoing │ │ │ -connection fails, a non-encrypted retry will not be made.
    pe_enabled
    blocked1encrypted connections are enabled, but non-encrypted connections │ │ │ -are allowed. An incoming non-encrypted connection will be accepted, │ │ │ -and if an outgoing encrypted connection fails, a non- encrypted │ │ │ -connection will be tried.
    pe_disabled2only non-encrypted connections are allowed.indicates that IPs in this range should not be connected │ │ │ +to nor accepted as incoming connections
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum enc_level

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    port_filter

    │ │ │ +

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ +

    the port filter maps non-overlapping port ranges to flags. This │ │ │ +is primarily used to indicate whether a range of ports should │ │ │ +be connected to or not. The default is to have the full port │ │ │ +range (0-65535) set to flag 0.

    │ │ │ +
    │ │ │ +class port_filter
    │ │ │ +{
    │ │ │ +   port_filter (port_filter const&);
    │ │ │ +   port_filter& operator= (port_filter const&);
    │ │ │ +   ~port_filter ();
    │ │ │ +   port_filter (port_filter&&);
    │ │ │ +   port_filter ();
    │ │ │ +   port_filter& operator= (port_filter&&);
    │ │ │ +   void add_rule (std::uint16_t first, std::uint16_t last, std::uint32_t flags);
    │ │ │ +   std::uint32_t access (std::uint16_t port) const;
    │ │ │ +
    │ │ │ +   enum access_flags
    │ │ │ +   {
    │ │ │ +      blocked,
    │ │ │ +   };
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    add_rule()

    │ │ │ +
    │ │ │ +void add_rule (std::uint16_t first, std::uint16_t last, std::uint32_t flags);
    │ │ │ +
    │ │ │ +

    set the flags for the specified port range (first, last) to │ │ │ +flags overwriting any existing rule for those ports. The range │ │ │ +is inclusive, i.e. the port last also has the flag set on it.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    access()

    │ │ │ +
    │ │ │ +std::uint32_t access (std::uint16_t port) const;
    │ │ │ +
    │ │ │ +

    test the specified port (port) for whether it is blocked │ │ │ +or not. The returned value is the flags set for this port. │ │ │ +see access_flags.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum access_flags

    │ │ │ +

    Declared in "libtorrent/ip_filter.hpp"

    │ │ │ │ │ │ │ │ │ -│ │ │ │ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    pe_plaintext1use only plain text encryption
    pe_rc42use only RC4 encryption
    pe_both3allow both
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum proxy_type_t

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    none0No proxy server is used and all other fields are ignored.
    socks4
    blocked1The server is assumed to be a SOCKS4 server that requires a │ │ │ -username.
    socks52The server is assumed to be a SOCKS5 server (RFC 1928) that does │ │ │ -not require any authentication. The username and password are │ │ │ -ignored.
    socks5_pw3The server is assumed to be a SOCKS5 server that supports plain │ │ │ -text username and password authentication (RFC 1929). The │ │ │ -username and password specified may be sent to the proxy if it │ │ │ -requires.
    http4The server is assumed to be an HTTP proxy. If the transport used │ │ │ -for the connection is non-HTTP, the server is assumed to support │ │ │ -the CONNECT method. i.e. for web seeds and HTTP trackers, a plain │ │ │ -proxy will suffice. The proxy is assumed to not require │ │ │ -authorization. The username and password will not be used.
    http_pw5The server is assumed to be an HTTP proxy that requires user │ │ │ -authorization. The username and password will be sent to the proxy.
    │ │ │ -[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);
    │ │ │ -
    │ │ │ -

    This is a utility function to produce a client ID fingerprint formatted to │ │ │ -the most common convention. The fingerprint can be set via the │ │ │ -peer_fingerprint setting, in settings_pack.

    │ │ │ -

    The name string should contain exactly two characters. These are the │ │ │ -characters unique to your client, used to identify it. Make sure not to │ │ │ -clash with anybody else. Here are some taken id's:

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │
    id charsclient
    LTlibtorrent (default)
    UTuTorrent
    UMuTorrent Mac
    qBqBittorrent
    BPBitTorrent Pro
    BTBitTorrent
    DEDeluge
    AZAzureus
    TLTriblerthis flag indicates that destination ports in the │ │ │ +range should not be connected to
    │ │ │ -

    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]
    │ │ │ -
    │ │ │ -

    high_performance_seed() min_memory_usage()

    │ │ │ -

    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

    │ │ │ [report issue]
    │ │ │ +
    │ │ │
    │ │ │

    bdecode_node

    │ │ │

    Declared in "libtorrent/bdecode.hpp"

    │ │ │

    Sometimes it's important to get a non-owning reference to the root node ( │ │ │ to be able to copy it as a reference for instance). For that, use the │ │ │ non_owning() member function.

    │ │ │

    There are 5 different types of nodes, see type_t.

    │ │ │
    │ │ │  struct bdecode_node
    │ │ │  {
    │ │ │     bdecode_node () = default;
    │ │ │ -   bdecode_node& operator= (bdecode_node&&) & = default;
    │ │ │     bdecode_node (bdecode_node const&);
    │ │ │     bdecode_node& operator= (bdecode_node const&) &;
    │ │ │     bdecode_node (bdecode_node&&) noexcept;
    │ │ │ +   bdecode_node& operator= (bdecode_node&&) & = default;
    │ │ │     type_t type () const noexcept;
    │ │ │     explicit operator bool () const noexcept;
    │ │ │     bdecode_node non_owning () const;
    │ │ │ -   span<char const> data_section () const noexcept;
    │ │ │     std::ptrdiff_t data_offset () const noexcept;
    │ │ │ +   span<char const> data_section () const noexcept;
    │ │ │ +   std::int64_t list_int_value_at (int i
    │ │ │ +      , std::int64_t default_val = 0) const;
    │ │ │ +   bdecode_node list_at (int i) const;
    │ │ │     string_view list_string_value_at (int i
    │ │ │        , string_view default_val = string_view()) const;
    │ │ │     int list_size () const;
    │ │ │ -   bdecode_node list_at (int i) const;
    │ │ │ -   std::int64_t list_int_value_at (int i
    │ │ │ -      , std::int64_t default_val = 0) const;
    │ │ │ -   bdecode_node dict_find_int (string_view key) const;
    │ │ │ -   string_view dict_find_string_value (string_view key
    │ │ │ -      , string_view default_value = string_view()) const;
    │ │ │ -   std::pair<string_view, bdecode_node> dict_at (int i) const;
    │ │ │     bdecode_node dict_find (string_view key) const;
    │ │ │     std::int64_t dict_find_int_value (string_view key
    │ │ │        , std::int64_t default_val = 0) const;
    │ │ │ -   int dict_size () const;
    │ │ │     bdecode_node dict_find_dict (string_view key) const;
    │ │ │ +   bdecode_node dict_find_string (string_view key) const;
    │ │ │     std::pair<bdecode_node, bdecode_node> dict_at_node (int i) const;
    │ │ │ +   int dict_size () const;
    │ │ │ +   bdecode_node dict_find_int (string_view key) const;
    │ │ │ +   std::pair<string_view, bdecode_node> dict_at (int i) const;
    │ │ │ +   string_view dict_find_string_value (string_view key
    │ │ │ +      , string_view default_value = string_view()) const;
    │ │ │     bdecode_node dict_find_list (string_view key) const;
    │ │ │ -   bdecode_node dict_find_string (string_view key) const;
    │ │ │     std::int64_t int_value () const;
    │ │ │ -   char const* string_ptr () const;
    │ │ │     string_view string_value () const;
    │ │ │     int string_length () const;
    │ │ │     std::ptrdiff_t string_offset () const;
    │ │ │ +   char const* string_ptr () const;
    │ │ │     void clear ();
    │ │ │     void swap (bdecode_node& n);
    │ │ │     void reserve (int tokens);
    │ │ │     void switch_underlying_buffer (char const* buf) noexcept;
    │ │ │     bool has_soft_error (span<char> error) const;
    │ │ │  
    │ │ │     enum type_t
    │ │ │ @@ -21051,104 +18646,104 @@
    │ │ │  
    │ │ │

    creates a default constructed node, it will have the type none_t.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    operator=() bdecode_node()

    │ │ │
    │ │ │ -bdecode_node& operator= (bdecode_node&&) & = default;
    │ │ │  bdecode_node (bdecode_node const&);
    │ │ │  bdecode_node& operator= (bdecode_node const&) &;
    │ │ │  bdecode_node (bdecode_node&&) noexcept;
    │ │ │ +bdecode_node& operator= (bdecode_node&&) & = default;
    │ │ │  
    │ │ │

    For owning nodes, the copy will create a copy of the tree, but the │ │ │ underlying buffer remains the same.

    │ │ │ [report issue]
    │ │ │ -
    │ │ │ +
    │ │ │

    type()

    │ │ │
    │ │ │  type_t type () const noexcept;
    │ │ │  
    │ │ │

    the type of this node. See type_t.

    │ │ │ [report issue]
    │ │ │ -
    │ │ │ +
    │ │ │

    bool()

    │ │ │
    │ │ │  explicit operator bool () const noexcept;
    │ │ │  
    │ │ │ -

    returns true if type() != none_t.

    │ │ │ +

    returns true if type() != none_t.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    non_owning()

    │ │ │
    │ │ │  bdecode_node non_owning () const;
    │ │ │  
    │ │ │

    return a non-owning reference to this node. This is useful to refer to │ │ │ the root node without copying it in assignments.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    data_offset() data_section()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    data_section() data_offset()

    │ │ │
    │ │ │ -span<char const> data_section () const noexcept;
    │ │ │  std::ptrdiff_t data_offset () const noexcept;
    │ │ │ +span<char const> data_section () const noexcept;
    │ │ │  
    │ │ │

    returns the buffer and length of the section in the original bencoded │ │ │ buffer where this node is defined. For a dictionary for instance, this │ │ │ starts with d and ends with e, and has all the content of the │ │ │ dictionary in between. │ │ │ the data_offset() function returns the byte-offset to this node in, │ │ │ starting from the beginning of the buffer that was parsed.

    │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    list_size() list_string_value_at() list_at() list_int_value_at()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    list_int_value_at() list_at() list_string_value_at() list_size()

    │ │ │
    │ │ │ +std::int64_t list_int_value_at (int i
    │ │ │ +      , std::int64_t default_val = 0) const;
    │ │ │ +bdecode_node list_at (int i) const;
    │ │ │  string_view list_string_value_at (int i
    │ │ │        , string_view default_val = string_view()) const;
    │ │ │  int list_size () const;
    │ │ │ -bdecode_node list_at (int i) const;
    │ │ │ -std::int64_t list_int_value_at (int i
    │ │ │ -      , std::int64_t default_val = 0) const;
    │ │ │  
    │ │ │

    functions with the list_ prefix operate on lists. These functions are │ │ │ only valid if type() == list_t. list_at() returns the item │ │ │ in the list at index i. i may not be greater than or equal to the │ │ │ size of the list. list_size() returns the size of the list. │ │ │ list_int_value_at() and list_string_value_at() return the │ │ │ integer or string value of the item at index i directly. If that │ │ │ item is not of the requested type, the provided default_val is │ │ │ returned instead.

    │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dict_at() dict_size() dict_find_int() dict_find_string_value() dict_find_int_value() dict_find_dict() dict_at_node() dict_find() dict_find_string() dict_find_list()

    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    dict_at() dict_find_dict() dict_size() dict_find() dict_find_string() dict_at_node() dict_find_int() dict_find_int_value() dict_find_string_value() dict_find_list()

    │ │ │
    │ │ │ -bdecode_node dict_find_int (string_view key) const;
    │ │ │ -string_view dict_find_string_value (string_view key
    │ │ │ -      , string_view default_value = string_view()) const;
    │ │ │ -std::pair<string_view, bdecode_node> dict_at (int i) const;
    │ │ │  bdecode_node dict_find (string_view key) const;
    │ │ │  std::int64_t dict_find_int_value (string_view key
    │ │ │        , std::int64_t default_val = 0) const;
    │ │ │ -int dict_size () const;
    │ │ │  bdecode_node dict_find_dict (string_view key) const;
    │ │ │ +bdecode_node dict_find_string (string_view key) const;
    │ │ │  std::pair<bdecode_node, bdecode_node> dict_at_node (int i) const;
    │ │ │ +int dict_size () const;
    │ │ │ +bdecode_node dict_find_int (string_view key) const;
    │ │ │ +std::pair<string_view, bdecode_node> dict_at (int i) const;
    │ │ │ +string_view dict_find_string_value (string_view key
    │ │ │ +      , string_view default_value = string_view()) const;
    │ │ │  bdecode_node dict_find_list (string_view key) const;
    │ │ │ -bdecode_node dict_find_string (string_view key) const;
    │ │ │  
    │ │ │

    Functions with the dict_ prefix operates on dictionaries. They are │ │ │ only valid if type() == dict_t. In case a key you're looking up │ │ │ contains a 0 byte, you cannot use the 0-terminated string overloads, │ │ │ but have to use string_view instead. dict_find_list will return a │ │ │ valid bdecode_node if the key is found _and_ it is a list. Otherwise │ │ │ it will return a default-constructed bdecode_node.

    │ │ │ @@ -21165,23 +18760,23 @@ │ │ │
    │ │ │  std::int64_t int_value () const;
    │ │ │  
    │ │ │

    this function is only valid if type() == int_t. It returns the │ │ │ value of the integer.

    │ │ │ │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    string_offset() string_value() string_ptr() string_length()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    string_offset() string_value() string_length() string_ptr()

    │ │ │
    │ │ │ -char const* string_ptr () const;
    │ │ │  string_view string_value () const;
    │ │ │  int string_length () const;
    │ │ │  std::ptrdiff_t string_offset () const;
    │ │ │ +char const* string_ptr () const;
    │ │ │  
    │ │ │

    these functions are only valid if type() == string_t. They return │ │ │ the string values. Note that string_ptr() is not 0-terminated. │ │ │ string_length() returns the number of bytes in the string. │ │ │ string_offset() returns the byte offset from the start of the parsed │ │ │ bencoded buffer this string can be found.

    │ │ │ [report issue]
    │ │ │ @@ -21283,18 +18878,18 @@ │ │ │

    bdecode()

    │ │ │

    Declared in "libtorrent/bdecode.hpp"

    │ │ │
    │ │ │  int bdecode (char const* start, char const* end, bdecode_node& ret
    │ │ │     , error_code& ec, int* error_pos = nullptr, int depth_limit = 100
    │ │ │     , int token_limit = 2000000);
    │ │ │  bdecode_node bdecode (span<char const> buffer
    │ │ │ -   , int depth_limit = 100, int token_limit = 2000000);
    │ │ │ -bdecode_node bdecode (span<char const> buffer
    │ │ │     , error_code& ec, int* error_pos = nullptr, int depth_limit = 100
    │ │ │     , int token_limit = 2000000);
    │ │ │ +bdecode_node bdecode (span<char const> buffer
    │ │ │ +   , int depth_limit = 100, int token_limit = 2000000);
    │ │ │  
    │ │ │

    This function decodes/parses bdecoded data (for example a .torrent file). │ │ │ The data structure is returned in the ret argument. the buffer to parse │ │ │ is specified by the start of the buffer as well as the end, i.e. one │ │ │ byte past the end. If the buffer fails to parse, the function returns a │ │ │ non-zero value and fills in ec with the error code. The optional │ │ │ argument error_pos, if set to non-nullptr, will be set to the byte offset │ │ │ @@ -21309,14 +18904,2686 @@ │ │ │ those bdecode_node objects will simply have references to the root or │ │ │ owning bdecode_node. If the root node is destructed, all other nodes │ │ │ that refer to anything in that tree become invalid.

    │ │ │

    However, the underlying buffer passed in to this function (start, end) │ │ │ must also remain valid while the bdecoded tree is used. The parsed tree │ │ │ produced by this function does not copy any data out of the buffer, but │ │ │ simply produces references back into it.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    storage_error

    │ │ │ +

    Declared in "libtorrent/error_code.hpp"

    │ │ │ +

    used by storage to return errors │ │ │ +also includes which underlying file the │ │ │ +error happened on

    │ │ │ +
    │ │ │ +struct storage_error
    │ │ │ +{
    │ │ │ +   explicit operator bool () const;
    │ │ │ +   void file (file_index_t f);
    │ │ │ +   file_index_t file () const;
    │ │ │ +
    │ │ │ +   error_code ec;
    │ │ │ +   operation_t operation;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    bool()

    │ │ │ +
    │ │ │ +explicit operator bool () const;
    │ │ │ +
    │ │ │ +

    explicitly converts to true if this object represents an error, and │ │ │ +false if it does not.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file()

    │ │ │ +
    │ │ │ +void file (file_index_t f);
    │ │ │ +file_index_t file () const;
    │ │ │ +
    │ │ │ +

    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]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    pcp_category()

    │ │ │ +

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& pcp_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.

    │ │ │ +[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]
    │ │ │ +
    │ │ │ +

    socks_category()

    │ │ │ +

    Declared in "libtorrent/socks5_stream.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& socks_category ();
    │ │ │ +
    │ │ │ +

    returns the error_category for SOCKS5 errors

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    gzip_category()

    │ │ │ +

    Declared in "libtorrent/gzip.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& gzip_category ();
    │ │ │ +
    │ │ │ +

    get the error_category for zip errors

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    i2p_category()

    │ │ │ +

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& i2p_category ();
    │ │ │ +
    │ │ │ +

    returns the error category for I2P errors

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    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"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0Not an error
    file_collision1Two torrents has files which end up overwriting each other
    failed_hash_check2A piece did not match its piece hash
    torrent_is_no_dict3The .torrent file does not contain a bencoded dictionary at │ │ │ +its top level
    torrent_missing_info4The .torrent file does not have an info dictionary
    torrent_info_no_dict5The .torrent file's info entry is not a dictionary
    torrent_missing_piece_length6The .torrent file does not have a piece length entry
    torrent_missing_name7The .torrent file does not have a name entry
    torrent_invalid_name8The .torrent file's name entry is invalid
    torrent_invalid_length9The length of a file, or of the whole .torrent file is invalid. │ │ │ +Either negative or not an integer
    torrent_file_parse_failed10Failed to parse a file entry in the .torrent
    torrent_missing_pieces11The pieces field is missing or invalid in the .torrent file
    torrent_invalid_hashes12The pieces string has incorrect length
    too_many_pieces_in_torrent13The .torrent file has more pieces than is supported by libtorrent
    invalid_swarm_metadata14The metadata (.torrent file) that was received from the swarm │ │ │ +matched the info-hash, but failed to be parsed
    invalid_bencoding15The file or buffer is not correctly bencoded
    no_files_in_torrent16The .torrent file does not contain any files
    invalid_escaped_string17The string was not properly url-encoded as expected
    session_is_closing18Operation is not permitted since the session is shutting down
    duplicate_torrent19There's already a torrent with that info-hash added to the │ │ │ +session
    invalid_torrent_handle20The supplied torrent_handle is not referring to a valid torrent
    invalid_entry_type21The type requested from the entry did not match its type
    missing_info_hash_in_uri22The specified URI does not contain a valid info-hash
    file_too_short23One of the files in the torrent was unexpectedly small. This │ │ │ +might be caused by files being changed by an external process
    unsupported_url_protocol24The URL used an unknown protocol. Currently http and │ │ │ +https (if built with openssl support) are recognized. For │ │ │ +trackers udp is recognized as well.
    url_parse_error25The URL did not conform to URL syntax and failed to be parsed
    peer_sent_empty_piece26The peer sent a piece message of length 0
    parse_failed27A bencoded structure was corrupt and failed to be parsed
    invalid_file_tag28The fast resume file was missing or had an invalid file version │ │ │ +tag
    missing_info_hash29The fast resume file was missing or had an invalid info-hash
    mismatching_info_hash30The info-hash did not match the torrent
    invalid_hostname31The URL contained an invalid hostname
    invalid_port32The URL had an invalid port
    port_blocked33The port is blocked by the port-filter, and prevented the │ │ │ +connection
    expected_close_bracket_in_address34The IPv6 address was expected to end with "]"
    destructing_torrent35The torrent is being destructed, preventing the operation to │ │ │ +succeed
    timed_out36The connection timed out
    upload_upload_connection37The peer is upload only, and we are upload only. There's no point │ │ │ +in keeping the connection
    uninteresting_upload_peer38The peer is upload only, and we're not interested in it. There's │ │ │ +no point in keeping the connection
    invalid_info_hash39The peer sent an unknown info-hash
    torrent_paused40The torrent is paused, preventing the operation from succeeding
    invalid_have41The peer sent an invalid have message, either wrong size or │ │ │ +referring to a piece that doesn't exist in the torrent
    invalid_bitfield_size42The bitfield message had the incorrect size
    too_many_requests_when_choked43The peer kept requesting pieces after it was choked, possible │ │ │ +abuse attempt.
    invalid_piece44The peer sent a piece message that does not correspond to a │ │ │ +piece request sent by the client
    no_memory45memory allocation failed
    torrent_aborted46The torrent is aborted, preventing the operation to succeed
    self_connection47The peer is a connection to ourself, no point in keeping it
    invalid_piece_size48The peer sent a piece message with invalid size, either negative │ │ │ +or greater than one block
    timed_out_no_interest49The peer has not been interesting or interested in us for too │ │ │ +long, no point in keeping it around
    timed_out_inactivity50The peer has not said anything in a long time, possibly dead
    timed_out_no_handshake51The peer did not send a handshake within a reasonable amount of │ │ │ +time, it might not be a bittorrent peer
    timed_out_no_request52The peer has been unchoked for too long without requesting any │ │ │ +data. It might be lying about its interest in us
    invalid_choke53The peer sent an invalid choke message
    invalid_unchoke54The peer send an invalid unchoke message
    invalid_interested55The peer sent an invalid interested message
    invalid_not_interested56The peer sent an invalid not-interested message
    invalid_request57The peer sent an invalid piece request message
    invalid_hash_list58The peer sent an invalid hash-list message (this is part of the │ │ │ +merkle-torrent extension)
    invalid_hash_piece59The peer sent an invalid hash-piece message (this is part of the │ │ │ +merkle-torrent extension)
    invalid_cancel60The peer sent an invalid cancel message
    invalid_dht_port61The peer sent an invalid DHT port-message
    invalid_suggest62The peer sent an invalid suggest piece-message
    invalid_have_all63The peer sent an invalid have all-message
    invalid_have_none64The peer sent an invalid have none-message
    invalid_reject65The peer sent an invalid reject message
    invalid_allow_fast66The peer sent an invalid allow fast-message
    invalid_extended67The peer sent an invalid extension message ID
    invalid_message68The peer sent an invalid message ID
    sync_hash_not_found69The synchronization hash was not found in the encrypted handshake
    invalid_encryption_constant70The encryption constant in the handshake is invalid
    no_plaintext_mode71The peer does not support plain text, which is the selected mode
    no_rc4_mode72The peer does not support RC4, which is the selected mode
    unsupported_encryption_mode73The peer does not support any of the encryption modes that the │ │ │ +client supports
    unsupported_encryption_mode_selected74The peer selected an encryption mode that the client did not │ │ │ +advertise and does not support
    invalid_pad_size75The pad size used in the encryption handshake is of invalid size
    invalid_encrypt_handshake76The encryption handshake is invalid
    no_incoming_encrypted77The client is set to not support incoming encrypted connections │ │ │ +and this is an encrypted connection
    no_incoming_regular78The client is set to not support incoming regular bittorrent │ │ │ +connections, and this is a regular connection
    duplicate_peer_id79The client is already connected to this peer-ID
    torrent_removed80Torrent was removed
    packet_too_large81The packet size exceeded the upper sanity check-limit
    reserved82 
    http_error83The web server responded with an error
    missing_location84The web server response is missing a location header
    invalid_redirection85The web seed redirected to a path that no longer matches the │ │ │ +.torrent directory structure
    redirecting86The connection was closed because it redirected to a different │ │ │ +URL
    invalid_range87The HTTP range header is invalid
    no_content_length88The HTTP response did not have a content length
    banned_by_ip_filter89The IP is blocked by the IP filter
    too_many_connections90At the connection limit
    peer_banned91The peer is marked as banned
    stopping_torrent92The torrent is stopping, causing the operation to fail
    too_many_corrupt_pieces93The peer has sent too many corrupt pieces and is banned
    torrent_not_ready94The torrent is not ready to receive peers
    peer_not_constructed95The peer is not completely constructed yet
    session_closing96The session is closing, causing the operation to fail
    optimistic_disconnect97The peer was disconnected in order to leave room for a │ │ │ +potentially better peer
    torrent_finished98The torrent is finished
    no_router99No UPnP router found
    metadata_too_large100The metadata message says the metadata exceeds the limit
    invalid_metadata_request101The peer sent an invalid metadata request message
    invalid_metadata_size102The peer advertised an invalid metadata size
    invalid_metadata_offset103The peer sent a message with an invalid metadata offset
    invalid_metadata_message104The peer sent an invalid metadata message
    pex_message_too_large105The peer sent a peer exchange message that was too large
    invalid_pex_message106The peer sent an invalid peer exchange message
    invalid_lt_tracker_message107The peer sent an invalid tracker exchange message
    too_frequent_pex108The peer sent an pex messages too often. This is a possible │ │ │ +attempt of and attack
    no_metadata109The operation failed because it requires the torrent to have │ │ │ +the metadata (.torrent file) and it doesn't have it yet. │ │ │ +This happens for magnet links before they have downloaded the │ │ │ +metadata, and also torrents added by URL.
    invalid_dont_have110The peer sent an invalid dont_have message. The don't have │ │ │ +message is an extension to allow peers to advertise that the │ │ │ +no longer has a piece they previously had.
    requires_ssl_connection111The peer tried to connect to an SSL torrent without connecting │ │ │ +over SSL.
    invalid_ssl_cert112The peer tried to connect to a torrent with a certificate │ │ │ +for a different torrent.
    not_an_ssl_torrent113the torrent is not an SSL torrent, and the operation requires │ │ │ +an SSL torrent
    banned_by_port_filter114peer was banned because its listen port is within a banned port │ │ │ +range, as specified by the port_filter.
    invalid_session_handle115The session_handle is not referring to a valid session_impl
    invalid_listen_socket116the listen socket associated with this request was closed
    invalid_hash_request117 
    invalid_hashes118 
    invalid_hash_reject119 
    deprecated_120120 
    deprecated_121121 
    deprecated_122122 
    deprecated_123123 
    deprecated_124124 
    missing_file_sizes130The resume data file is missing the file sizes entry
    no_files_in_resume_data131The resume data file file sizes entry is empty
    missing_pieces132The resume data file is missing the pieces and slots entry
    mismatching_number_of_files133The number of files in the resume data does not match the number │ │ │ +of files in the torrent
    mismatching_file_size134One of the files on disk has a different size than in the fast │ │ │ +resume file
    mismatching_file_timestamp135One of the files on disk has a different timestamp than in the │ │ │ +fast resume file
    not_a_dictionary136The resume data file is not a dictionary
    invalid_blocks_per_piece137The blocks per piece entry is invalid in the resume data file
    missing_slots138The resume file is missing the slots entry, which is required │ │ │ +for torrents with compact allocation. DEPRECATED
    too_many_slots139The resume file contains more slots than the torrent
    invalid_slot_list140The slot entry is invalid in the resume data
    invalid_piece_index141One index in the slot list is invalid
    pieces_need_reorder142The pieces on disk needs to be re-ordered for the specified │ │ │ +allocation mode. This happens if you specify sparse allocation │ │ │ +and the files on disk are using compact storage. The pieces needs │ │ │ +to be moved to their right position. DEPRECATED
    resume_data_not_modified143this error is returned when asking to save resume data and │ │ │ +specifying the flag to only save when there's anything new to save │ │ │ +(torrent_handle::only_if_modified) and there wasn't anything changed.
    invalid_save_path144the save_path in add_torrent_params is not valid
    too_many_duplicate_filenames145The torrent contained too many duplicate filenames, exceeding the │ │ │ +configured limit.
    http_parse_error150The HTTP header was not correctly formatted
    http_missing_location151The HTTP response was in the 300-399 range but lacked a location │ │ │ +header
    http_failed_decompress152The HTTP response was encoded with gzip or deflate but │ │ │ +decompressing it failed
    no_i2p_router160The URL specified an i2p address, but no i2p router is configured
    no_i2p_endpoint161i2p acceptor is not available yet, can't announce without endpoint
    scrape_not_available170The tracker URL doesn't support transforming it into a scrape │ │ │ +URL. i.e. it doesn't contain "announce.
    invalid_tracker_response171invalid tracker response
    invalid_peer_dict172invalid peer dictionary entry. Not a dictionary
    tracker_failure173tracker sent a failure message
    invalid_files_entry174missing or invalid files entry
    invalid_hash_entry175missing or invalid hash entry
    invalid_peers_entry176missing or invalid peers and peers6 entry
    invalid_tracker_response_length177UDP tracker response packet has invalid size
    invalid_tracker_transaction_id178invalid transaction id in UDP tracker response
    invalid_tracker_action179invalid action field in UDP tracker response
    announce_skipped180skipped announce (because it's assumed to be unreachable over the │ │ │ +given source network interface)
    no_entropy200random number generation failed
    ssrf_mitigation201blocked by SSRF mitigation
    blocked_by_idna202blocked because IDNA host names are banned
    torrent_unknown_version210the torrent file has an unknown meta version
    torrent_missing_file_tree211the v2 torrent file has no file tree
    torrent_missing_meta_version212the torrent contains v2 keys but does not specify meta version 2
    torrent_inconsistent_files213the v1 and v2 file metadata does not match
    torrent_missing_piece_layer214one or more files are missing piece layer hashes
    torrent_invalid_piece_layer215a piece layer has the wrong size or failed hash check
    torrent_missing_pieces_root216a v2 file entry has no root hash
    torrent_inconsistent_hashes217the v1 and v2 hashes do not describe the same data
    torrent_invalid_pad_file218a file in the v2 metadata has the pad attribute set
    torrent_directory_too_deep219the directory structure of files in the torrent exceeds the │ │ │ +configured maximum depth (see load_torrent_limits)
    error_code_max220the number of error codes
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum http_errors

    │ │ │ +

    Declared in "libtorrent/error_code.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    cont100 
    ok200 
    created201 
    accepted202 
    no_content204 
    multiple_choices300 
    moved_permanently301 
    moved_temporarily302 
    not_modified304 
    bad_request400 
    unauthorized401 
    forbidden403 
    not_found404 
    internal_server_error500 
    not_implemented501 
    bad_gateway502 
    service_unavailable503 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_torrent_params

    │ │ │ +

    Declared in "libtorrent/add_torrent_params.hpp"

    │ │ │ +

    The add_torrent_params contains all the information in a .torrent file │ │ │ +along with all information necessary to add that torrent to a session. │ │ │ +The key fields when adding a torrent are:

    │ │ │ +
      │ │ │ +
    • ti - the immutable info-dict part of the torrent
    • │ │ │ +
    • info_hash - when you don't have the metadata (.torrent file). This │ │ │ +uniquely identifies the torrent and can validate the info-dict when │ │ │ +received from the swarm.
    • │ │ │ +
    │ │ │ +

    In order to add a torrent to a session, one of those fields must be set │ │ │ +in addition to save_path. The add_torrent_params object can then be │ │ │ +passed into one of the session::add_torrent() overloads or │ │ │ +session::async_add_torrent().

    │ │ │ +

    If you only specify the info-hash, the torrent file will be downloaded │ │ │ +from peers, which requires them to support the metadata extension. For │ │ │ +the metadata extension to work, libtorrent must be built with extensions │ │ │ +enabled (TORRENT_DISABLE_EXTENSIONS must not be defined). It also │ │ │ +takes an optional name argument. This may be left empty in case no │ │ │ +name should be assigned to the torrent. In case it's not, the name is │ │ │ +used for the torrent as long as it doesn't have metadata. See │ │ │ +torrent_handle::name.

    │ │ │ +

    The add_torrent_params is also used when requesting resume data for a │ │ │ +torrent. It can be saved to and restored from a file and added back to a │ │ │ +new session. For serialization and de-serialization of │ │ │ +add_torrent_params objects, see read_resume_data() and │ │ │ +write_resume_data().

    │ │ │ +

    The add_torrent_params is also used to represent a parsed .torrent │ │ │ +file. It can be loaded via load_torrent_file(), load_torrent_buffer() and │ │ │ +load_torrent_parsed(). It can be saved via write_torrent_file().

    │ │ │ +
    │ │ │ +struct add_torrent_params
    │ │ │ +{
    │ │ │ +   int version  = LIBTORRENT_VERSION_NUM;
    │ │ │ +   std::shared_ptr<torrent_info const> ti;
    │ │ │ +   std::vector<std::string> trackers;
    │ │ │ +   std::vector<int> tracker_tiers;
    │ │ │ +   std::vector<std::pair<std::string, int>> dht_nodes;
    │ │ │ +   std::string name;
    │ │ │ +   std::string save_path;
    │ │ │ +   std::string part_file_dir;
    │ │ │ +   storage_mode_t storage_mode  = storage_mode_sparse;
    │ │ │ +   client_data_t userdata;
    │ │ │ +   std::vector<download_priority_t> file_priorities;
    │ │ │ +   std::string trackerid;
    │ │ │ +   torrent_flags_t flags  = torrent_flags::default_flags;
    │ │ │ +   info_hash_t info_hashes;
    │ │ │ +   int max_uploads  = -1;
    │ │ │ +   int max_connections  = -1;
    │ │ │ +   int upload_limit  = -1;
    │ │ │ +   int download_limit  = -1;
    │ │ │ +   std::int64_t total_uploaded  = 0;
    │ │ │ +   std::int64_t total_downloaded  = 0;
    │ │ │ +   int active_time  = 0;
    │ │ │ +   int finished_time  = 0;
    │ │ │ +   int seeding_time  = 0;
    │ │ │ +   std::time_t added_time  = 0;
    │ │ │ +   std::time_t completed_time  = 0;
    │ │ │ +   std::time_t last_seen_complete  = 0;
    │ │ │ +   int num_complete  = -1;
    │ │ │ +   int num_incomplete  = -1;
    │ │ │ +   int num_downloaded  = -1;
    │ │ │ +   std::vector<std::string> url_seeds;
    │ │ │ +   std::vector<tcp::endpoint> peers;
    │ │ │ +   std::vector<tcp::endpoint> banned_peers;
    │ │ │ +   aux::noexcept_movable<std::map<piece_index_t, bitfield>> unfinished_pieces;
    │ │ │ +   typed_bitfield<piece_index_t> have_pieces;
    │ │ │ +   typed_bitfield<piece_index_t> verified_pieces;
    │ │ │ +   std::vector<download_priority_t> piece_priorities;
    │ │ │ +   aux::vector<std::vector<sha256_hash>, file_index_t> merkle_trees;
    │ │ │ +   aux::vector<bitfield, file_index_t> merkle_tree_mask;
    │ │ │ +   aux::vector<bitfield, file_index_t> verified_leaf_hashes;
    │ │ │ +   aux::noexcept_movable<std::map<file_index_t, std::string>> renamed_files;
    │ │ │ +   std::time_t last_download  = 0;
    │ │ │ +   std::time_t last_upload  = 0;
    │ │ │ +   std::string comment;
    │ │ │ +   std::string created_by;
    │ │ │ +   std::time_t creation_date  = 0;
    │ │ │ +   std::string root_certificate;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    version
    │ │ │ +
    filled in by the constructor and should be left untouched. It is used │ │ │ +for forward binary compatibility.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    ti
    │ │ │ +
    torrent_info object with the torrent to add. Unless the │ │ │ +info_hash is set, this is required to be initialized.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    trackers
    │ │ │ +
    If the torrent doesn't have a tracker, but relies on the DHT to find │ │ │ +peers, the trackers can specify tracker URLs for the torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    tracker_tiers
    │ │ │ +
    the tiers the URLs in trackers belong to. Trackers belonging to │ │ │ +different tiers may be treated differently, as defined by the multi │ │ │ +tracker extension. This is optional, if not specified trackers are │ │ │ +assumed to be part of tier 0, or whichever the last tier was as │ │ │ +iterating over the trackers.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    dht_nodes
    │ │ │ +
    a list of hostname and port pairs, representing DHT nodes to be added │ │ │ +to the session (if DHT is enabled). The hostname may be an IP address.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    name
    │ │ │ +
    in case there's no other name in this torrent, this name will be used. │ │ │ +The name out of the torrent_info object takes precedence if available.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    save_path
    │ │ │ +

    The path to the directory where the torrent is or will be stored.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    On windows this path (and other paths) are interpreted as UNC │ │ │ +paths. This means they must use backslashes as directory separators │ │ │ +and may not contain the special directories "." or "..".

    │ │ │ +
    │ │ │ +

    Setting this to an absolute path performs slightly better than a │ │ │ +relative path.

    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    part_file_dir
    │ │ │ +
    This is an optional field. If set, the part-file for this torrent │ │ │ +will be stored in the specified subdirectory, still inside its │ │ │ +download directory. i.e. part_file_dir is a relative directory. │ │ │ +The part file name is disambiguated by including the info-hash, in │ │ │ +hexadecimal form. By default it's stored directly in the download │ │ │ +directory. If the storage for a torrent is moved, the part file is │ │ │ +also moved along with it, to the new download directory. │ │ │ +A part file contains partial pieces that need to be downloaded in │ │ │ +order to verify hashes and seeding, but are part of files whose │ │ │ +priority is zero.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    storage_mode
    │ │ │ +
    One of the values from storage_mode_t. For more information, see │ │ │ +storage allocation.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    userdata
    │ │ │ +
    The userdata parameter is optional and will be passed on to the │ │ │ +extension constructor functions, if any │ │ │ +(see torrent_handle::add_extension()). It will also be stored in the │ │ │ +torrent object and can be retrieved by calling userdata().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    file_priorities
    │ │ │ +
    can be set to control the initial file priorities when adding a │ │ │ +torrent. The semantics are the same as for │ │ │ +torrent_handle::prioritize_files(). The file priorities specified │ │ │ +in here take precedence over those specified in the resume data, if │ │ │ +any. │ │ │ +If this vector of file priorities is shorter than the number of files │ │ │ +in the torrent, the remaining files (not covered by this) will still │ │ │ +have the default download priority. This default can be changed by │ │ │ +setting the default_dont_download torrent_flag.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    trackerid
    │ │ │ +
    the default tracker id to be used when announcing to trackers. By │ │ │ +default this is empty, and no tracker ID is used, since this is an │ │ │ +optional argument. If a tracker returns a tracker ID, that ID is used │ │ │ +instead of this.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flags
    │ │ │ +

    flags controlling aspects of this torrent and how it's added. See │ │ │ +torrent_flags_t for details.

    │ │ │ +
    │ │ │ +

    Note

    │ │ │ +

    The flags field is initialized with default flags by the │ │ │ +constructor. In order to preserve default behavior when clearing or │ │ │ +setting other flags, make sure to bitwise OR or in a flag or bitwise │ │ │ +AND the inverse of a flag to clear it.

    │ │ │ +
    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    info_hashes
    │ │ │ +
    set this to the info hash of the torrent to add in case the info-hash │ │ │ +is the only known property of the torrent. i.e. you don't have a │ │ │ +.torrent file nor a magnet link. │ │ │ +To add a magnet link, use parse_magnet_uri() to populate fields in the │ │ │ +add_torrent_params object.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    max_uploads max_connections
    │ │ │ +

    max_uploads, max_connections, upload_limit, │ │ │ +download_limit correspond to the set_max_uploads(), │ │ │ +set_max_connections(), set_upload_limit() and │ │ │ +set_download_limit() functions on torrent_handle. These values let │ │ │ +you initialize these settings when the torrent is added, instead of │ │ │ +calling these functions immediately following adding it.

    │ │ │ +

    -1 means unlimited on these settings just like their counterpart │ │ │ +functions on torrent_handle

    │ │ │ +

    For fine grained control over rate limits, including making them apply │ │ │ +to local peers, see peer classes.

    │ │ │ +
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    upload_limit download_limit
    │ │ │ +
    the upload and download rate limits for this torrent, specified in │ │ │ +bytes per second. -1 means unlimited.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    total_uploaded total_downloaded
    │ │ │ +
    the total number of bytes uploaded and downloaded by this torrent so │ │ │ +far.
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    active_time finished_time seeding_time
    │ │ │ +
    the number of seconds this torrent has spent in started, finished and │ │ │ +seeding state so far, respectively.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    added_time completed_time
    │ │ │ +
    if set to a non-zero value, this is the posix time of when this torrent │ │ │ +was first added, including previous runs/sessions. If set to zero, the │ │ │ +internal added_time will be set to the time of when add_torrent() is │ │ │ +called.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    last_seen_complete
    │ │ │ +
    if set to non-zero, initializes the time (expressed in posix time) when │ │ │ +we last saw a seed or peers that together formed a complete copy of the │ │ │ +torrent. If left set to zero, the internal counterpart to this field │ │ │ +will be updated when we see a seed or a distributed copies >= 1.0.
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    num_complete num_incomplete num_downloaded
    │ │ │ +

    these field can be used to initialize the torrent's cached scrape data. │ │ │ +The scrape data is high level metadata about the current state of the │ │ │ +swarm, as returned by the tracker (either when announcing to it or by │ │ │ +sending a specific scrape request). num_complete is the number of │ │ │ +peers in the swarm that are seeds, or have every piece in the torrent. │ │ │ +num_incomplete is the number of peers in the swarm that do not have │ │ │ +every piece. num_downloaded is the number of times the torrent has │ │ │ +been downloaded (not initiated, but the number of times a download has │ │ │ +completed).

    │ │ │ +

    Leaving any of these values set to -1 indicates we don't know, or we │ │ │ +have not received any scrape data.

    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    url_seeds
    │ │ │ +

    URLs can be added to these two lists to specify additional web │ │ │ +seeds to be used by the torrent. If the override_web_seeds flag │ │ │ +is set, these will be the _only_ ones to be used. i.e. any web seeds │ │ │ +found in the .torrent file will be overridden.

    │ │ │ +

    URLs are expected to be regular web servers, aka "get right" style, │ │ │ +specified in BEP 19.

    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    peers
    │ │ │ +
    peers to add to the torrent, to be tried to be connected to as │ │ │ +bittorrent peers.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    banned_peers
    │ │ │ +
    peers banned from this torrent. They will not be connected to
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    unfinished_pieces
    │ │ │ +
    this is a map of partially downloaded piece. The key is the piece index │ │ │ +and the value is a bitfield where each bit represents a 16 kiB block. │ │ │ +A set bit means we have that block.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    have_pieces
    │ │ │ +
    this is a bitfield indicating which pieces we already have of this │ │ │ +torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    verified_pieces
    │ │ │ +
    when in seed_mode, pieces with a set bit in this bitfield have been │ │ │ +verified to be valid. Other pieces will be verified the first time a │ │ │ +peer requests it.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    piece_priorities
    │ │ │ +
    this sets the priorities for each individual piece in the torrent. Each │ │ │ +element in the vector represent the piece with the same index. If you │ │ │ +set both file- and piece priorities, file priorities will take │ │ │ +precedence.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    merkle_trees
    │ │ │ +
    v2 hashes, if known
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    merkle_tree_mask
    │ │ │ +
    if set, indicates which hashes are included in the corresponding │ │ │ +vector of merkle_trees. These bitmasks always cover the full │ │ │ +tree, a cleared bit means the hash is all zeros (i.e. not set) and │ │ │ +set bit means the next hash in the corresponding vector in │ │ │ +merkle_trees is the hash for that node. This is an optimization │ │ │ +to avoid storing a lot of zeros.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    verified_leaf_hashes
    │ │ │ +
    bit-fields indicating which v2 leaf hashes have been verified │ │ │ +against the root hash. If this vector is empty and merkle_trees is │ │ │ +non-empty it implies that all hashes in merkle_trees are verified.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    renamed_files
    │ │ │ +
    this is a map of file indices in the torrent and new filenames to be │ │ │ +applied before the torrent is added.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    last_download last_upload
    │ │ │ +
    the posix time of the last time payload was received or sent for this │ │ │ +torrent, respectively. A value of 0 means we don't know when we last │ │ │ +uploaded or downloaded, or we have never uploaded or downloaded any │ │ │ +payload for this torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    comment
    │ │ │ +
    if a comment is found in the torrent file │ │ │ +this will be set to that comment
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    created_by
    │ │ │ +
    an optional string naming the software used │ │ │ +to create the torrent file
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    creation_date
    │ │ │ +
    if a creation date is found in the torrent file │ │ │ +this will be set to that, otherwise it'll be │ │ │ +1970, Jan 1
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    root_certificate
    │ │ │ +
    If this torrent is an infohash only SSL torrent, specify the root │ │ │ +certificate here. │ │ │ +If a peer does not have a matching certificate during metadata │ │ │ +exchange it will be rejected and the download will not proceed.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    client_data_t

    │ │ │ +

    Declared in "libtorrent/client_data.hpp"

    │ │ │ +

    A thin wrapper around a void pointer used as "user data". i.e. an opaque │ │ │ +cookie passed in to libtorrent and returned on demand. It adds type-safety by │ │ │ +requiring the same type be requested out of it as was assigned to it.

    │ │ │ +
    │ │ │ +struct client_data_t
    │ │ │ +{
    │ │ │ +   client_data_t () = default;
    │ │ │ +   explicit client_data_t (T* v);
    │ │ │ +   client_data_t& operator= (T* v);
    │ │ │ +   explicit operator T () const;
    │ │ │ +   T* get () const;
    │ │ │ +   operator void const* () const = delete;
    │ │ │ +   operator void* () const = delete;
    │ │ │ +   client_data_t& operator= (void const*) = delete;
    │ │ │ +   client_data_t& operator= (void*) = delete;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    client_data_t()

    │ │ │ +
    │ │ │ +client_data_t () = default;
    │ │ │ +
    │ │ │ +

    construct a nullptr client data

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    client_data_t()

    │ │ │ +
    │ │ │ +explicit client_data_t (T* v);
    │ │ │ +
    │ │ │ +

    initialize the client data with the specified pointer

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator=()

    │ │ │ +
    │ │ │ +client_data_t& operator= (T* v);
    │ │ │ +
    │ │ │ +

    assigns a new pointer to the client data

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    T() get()

    │ │ │ +
    │ │ │ +explicit operator T () const;
    │ │ │ +T* get () const;
    │ │ │ +
    │ │ │ +

    request to retrieve the pointer back again. The type T must be │ │ │ +identical to the type of the pointer assigned earlier, including │ │ │ +const & volatile qualifiers.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    const*() operator=() void*()

    │ │ │ +
    │ │ │ +operator void const* () const = delete;
    │ │ │ +operator void* () const = delete;
    │ │ │ +client_data_t& operator= (void const*) = delete;
    │ │ │ +client_data_t& operator= (void*) = delete;
    │ │ │ +
    │ │ │ +

    we don't allow type-unsafe operations

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    torrent_status

    │ │ │ +

    Declared in "libtorrent/torrent_status.hpp"

    │ │ │ +

    holds a snapshot of the status of a torrent, as queried by │ │ │ +torrent_handle::status().

    │ │ │ +
    │ │ │ +struct torrent_status
    │ │ │ +{
    │ │ │ +   bool operator== (torrent_status const& st) const;
    │ │ │ +
    │ │ │ +   enum state_t
    │ │ │ +   {
    │ │ │ +      checking_files,
    │ │ │ +      downloading_metadata,
    │ │ │ +      downloading,
    │ │ │ +      finished,
    │ │ │ +      seeding,
    │ │ │ +      checking_resume_data,
    │ │ │ +   };
    │ │ │ +
    │ │ │ +   torrent_handle handle;
    │ │ │ +   error_code errc;
    │ │ │ +   file_index_t error_file  = torrent_status::error_file_none;
    │ │ │ +   static inline constexpr file_index_t error_file_none {-1};
    │ │ │ +   static inline constexpr file_index_t error_file_ssl_ctx {-3};
    │ │ │ +   static inline constexpr file_index_t error_file_metadata {-4};
    │ │ │ +   static inline constexpr file_index_t error_file_exception {-5};
    │ │ │ +   static inline constexpr file_index_t error_file_partfile {-6};
    │ │ │ +   std::string save_path;
    │ │ │ +   std::string name;
    │ │ │ +   std::weak_ptr<const torrent_info> torrent_file;
    │ │ │ +   time_duration next_announce  = seconds{0};
    │ │ │ +   std::string current_tracker;
    │ │ │ +   std::int64_t total_download  = 0;
    │ │ │ +   std::int64_t total_upload  = 0;
    │ │ │ +   std::int64_t total_payload_download  = 0;
    │ │ │ +   std::int64_t total_payload_upload  = 0;
    │ │ │ +   std::int64_t total_failed_bytes  = 0;
    │ │ │ +   std::int64_t total_redundant_bytes  = 0;
    │ │ │ +   typed_bitfield<piece_index_t> pieces;
    │ │ │ +   typed_bitfield<piece_index_t> verified_pieces;
    │ │ │ +   std::int64_t total_done  = 0;
    │ │ │ +   std::int64_t total  = 0;
    │ │ │ +   std::int64_t total_wanted_done  = 0;
    │ │ │ +   std::int64_t total_wanted  = 0;
    │ │ │ +   std::int64_t all_time_upload  = 0;
    │ │ │ +   std::int64_t all_time_download  = 0;
    │ │ │ +   std::time_t added_time  = 0;
    │ │ │ +   std::time_t completed_time  = 0;
    │ │ │ +   std::time_t last_seen_complete  = 0;
    │ │ │ +   storage_mode_t storage_mode  = storage_mode_sparse;
    │ │ │ +   float progress  = 0.f;
    │ │ │ +   int progress_ppm  = 0;
    │ │ │ +   queue_position_t queue_position {};
    │ │ │ +   int download_rate  = 0;
    │ │ │ +   int upload_rate  = 0;
    │ │ │ +   int download_payload_rate  = 0;
    │ │ │ +   int upload_payload_rate  = 0;
    │ │ │ +   int num_seeds  = 0;
    │ │ │ +   int num_peers  = 0;
    │ │ │ +   int num_complete  = -1;
    │ │ │ +   int num_incomplete  = -1;
    │ │ │ +   int list_seeds  = 0;
    │ │ │ +   int list_peers  = 0;
    │ │ │ +   int connect_candidates  = 0;
    │ │ │ +   int num_pieces  = 0;
    │ │ │ +   int distributed_full_copies  = 0;
    │ │ │ +   int distributed_fraction  = 0;
    │ │ │ +   float distributed_copies  = 0.f;
    │ │ │ +   int block_size  = 0;
    │ │ │ +   int num_uploads  = 0;
    │ │ │ +   int num_connections  = 0;
    │ │ │ +   int uploads_limit  = 0;
    │ │ │ +   int connections_limit  = 0;
    │ │ │ +   int upload_limit  = -1;
    │ │ │ +   int download_limit  = -1;
    │ │ │ +   int up_bandwidth_queue  = 0;
    │ │ │ +   int down_bandwidth_queue  = 0;
    │ │ │ +   int seed_rank  = 0;
    │ │ │ +   state_t state  = checking_resume_data;
    │ │ │ +   resume_data_flags_t need_save_resume_data;
    │ │ │ +   bool is_seeding  = false;
    │ │ │ +   bool is_finished  = false;
    │ │ │ +   bool has_metadata  = false;
    │ │ │ +   bool has_incoming  = false;
    │ │ │ +   bool moving_storage  = false;
    │ │ │ +   bool announcing_to_trackers  = false;
    │ │ │ +   bool announcing_to_lsd  = false;
    │ │ │ +   bool announcing_to_dht  = false;
    │ │ │ +   info_hash_t info_hashes;
    │ │ │ +   time_point last_upload;
    │ │ │ +   time_point last_download;
    │ │ │ +   seconds active_duration;
    │ │ │ +   seconds finished_duration;
    │ │ │ +   seconds seeding_duration;
    │ │ │ +   torrent_flags_t flags {};
    │ │ │ +   struct renamed_files renamed_files;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    operator==()

    │ │ │ +
    │ │ │ +bool operator== (torrent_status const& st) const;
    │ │ │ +
    │ │ │ +

    compares if the torrent status objects come from the same torrent. i.e. │ │ │ +only the torrent_handle field is compared.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum state_t

    │ │ │ +

    Declared in "libtorrent/torrent_status.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    checking_files1The torrent has not started its download yet, and is │ │ │ +currently checking existing files.
    downloading_metadata2The torrent is trying to download metadata from peers. │ │ │ +This implies the ut_metadata extension is in use.
    downloading3The torrent is being downloaded. This is the state │ │ │ +most torrents will be in most of the time. The progress │ │ │ +meter will tell how much of the files that has been │ │ │ +downloaded.
    finished4In this state the torrent has finished downloading but │ │ │ +still doesn't have the entire torrent. i.e. some pieces │ │ │ +are filtered and won't get downloaded.
    seeding5In this state the torrent has finished downloading and │ │ │ +is a pure seeder.
    checking_resume_data7If the torrent was started in full allocation mode, this │ │ │ +indicates that the (disk) storage for the torrent is │ │ │ +allocated. │ │ │ +The torrent is currently checking the fast resume data and │ │ │ +comparing it to the files on disk. This is typically │ │ │ +completed in a fraction of a second, but if you add a │ │ │ +large number of torrents at once, they will queue up.
    │ │ │ +[report issue]
    │ │ │ +
    handle
    │ │ │ +
    a handle to the torrent whose status the object represents.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    errc
    │ │ │ +
    may be set to an error code describing why the torrent was paused, in │ │ │ +case it was paused by an error. If the torrent is not paused or if it's │ │ │ +paused but not because of an error, this error_code is not set. │ │ │ +if the error is attributed specifically to a file, error_file is set to │ │ │ +the index of that file in the .torrent file.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error_file
    │ │ │ +
    if the torrent is stopped because of an disk I/O error, this field │ │ │ +contains the index of the file in the torrent that encountered the │ │ │ +error. If the error did not originate in a file in the torrent, there │ │ │ +are a few special values this can be set to: error_file_none, │ │ │ +error_file_ssl_ctx, error_file_exception, error_file_partfile or │ │ │ +error_file_metadata;
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error_file_none
    │ │ │ +
    special values for error_file to describe which file or component │ │ │ +encountered the error (errc). │ │ │ +the error did not occur on a file
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error_file_ssl_ctx
    │ │ │ +
    the error occurred setting up the SSL context
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error_file_metadata
    │ │ │ +
    the error occurred while loading the metadata for the torrent
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error_file_exception
    │ │ │ +
    there was a serious error reported in this torrent. The error code │ │ │ +or a torrent log alert may provide more information.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    error_file_partfile
    │ │ │ +
    the error occurred with the partfile
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    save_path
    │ │ │ +
    the path to the directory where this torrent's files are stored. │ │ │ +It's typically the path as was given to async_add_torrent() or │ │ │ +add_torrent() when this torrent was started. This field is only │ │ │ +included if the torrent status is queried with │ │ │ +torrent_handle::query_save_path.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    name
    │ │ │ +
    the name of the torrent. Typically this is derived from the │ │ │ +.torrent file. In case the torrent was started without metadata, │ │ │ +and hasn't completely received it yet, it returns the name given │ │ │ +to it when added to the session. See session::add_torrent. │ │ │ +This field is only included if the torrent status is queried │ │ │ +with torrent_handle::query_name.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    torrent_file
    │ │ │ +
    set to point to the torrent_info object for this torrent. It's │ │ │ +only included if the torrent status is queried with │ │ │ +torrent_handle::query_torrent_file.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    next_announce
    │ │ │ +
    the time until the torrent will announce itself to the tracker.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    current_tracker
    │ │ │ +
    the URL of the last working tracker. If no tracker request has │ │ │ +been successful yet, it's set to an empty string.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    total_download total_upload
    │ │ │ +
    the number of bytes downloaded and uploaded to all peers, accumulated, │ │ │ +this session only. The session is considered to restart when a │ │ │ +torrent is paused and restarted again. When a torrent is paused, these │ │ │ +counters are reset to 0. If you want complete, persistent, stats, see │ │ │ +all_time_upload and all_time_download.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    total_payload_download total_payload_upload
    │ │ │ +
    counts the amount of bytes send and received this session, but only │ │ │ +the actual payload data (i.e the interesting data), these counters │ │ │ +ignore any protocol overhead. The session is considered to restart │ │ │ +when a torrent is paused and restarted again. When a torrent is │ │ │ +paused, these counters are reset to 0.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    total_failed_bytes
    │ │ │ +
    the number of bytes that has been downloaded and that has failed the │ │ │ +piece hash test. In other words, this is just how much crap that has │ │ │ +been downloaded since the torrent was last started. If a torrent is │ │ │ +paused and then restarted again, this counter will be reset.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    total_redundant_bytes
    │ │ │ +
    the number of bytes that has been downloaded even though that data │ │ │ +already was downloaded. The reason for this is that in some situations │ │ │ +the same data can be downloaded by mistake. When libtorrent sends │ │ │ +requests to a peer, and the peer doesn't send a response within a │ │ │ +certain timeout, libtorrent will re-request that block. Another │ │ │ +situation when libtorrent may re-request blocks is when the requests │ │ │ +it sends out are not replied in FIFO-order (it will re-request blocks │ │ │ +that are skipped by an out of order block). This is supposed to be as │ │ │ +low as possible. This only counts bytes since the torrent was last │ │ │ +started. If a torrent is paused and then restarted again, this counter │ │ │ +will be reset.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    pieces
    │ │ │ +
    a bitmask that represents which pieces we have (set to true) and the │ │ │ +pieces we don't have. It's a pointer and may be set to 0 if the │ │ │ +torrent isn't downloading or seeding.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    verified_pieces
    │ │ │ +
    a bitmask representing which pieces has had their hash checked. This │ │ │ +only applies to torrents in seed mode. If the torrent is not in seed │ │ │ +mode, this bitmask may be empty.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    total_done
    │ │ │ +
    the total number of bytes of the file(s) that we have. All this does │ │ │ +not necessarily has to be downloaded during this session (that's │ │ │ +total_payload_download).
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    total
    │ │ │ +
    the total number of bytes to download for this torrent. This │ │ │ +may be less than the size of the torrent in case there are │ │ │ +pad files. This number only counts bytes that will actually │ │ │ +be requested from peers.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    total_wanted_done
    │ │ │ +
    the number of bytes we have downloaded, only counting the pieces that │ │ │ +we actually want to download. i.e. excluding any pieces that we have │ │ │ +but have priority 0 (i.e. not wanted). │ │ │ +Once a torrent becomes seed, any piece- and file priorities are │ │ │ +forgotten and all bytes are considered "wanted".
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    total_wanted
    │ │ │ +
    The total number of bytes we want to download. This may be smaller │ │ │ +than the total torrent size in case any pieces are prioritized to 0, │ │ │ +i.e. not wanted. │ │ │ +Once a torrent becomes seed, any piece- and file priorities are │ │ │ +forgotten and all bytes are considered "wanted".
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    all_time_upload all_time_download
    │ │ │ +
    are accumulated upload and download payload byte counters. They are │ │ │ +saved in and restored from resume data to keep totals across sessions.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    added_time
    │ │ │ +
    the posix-time when this torrent was added. i.e. what time(nullptr) │ │ │ +returned at the time.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    completed_time
    │ │ │ +
    the posix-time when this torrent was finished. If the torrent is not │ │ │ +yet finished, this is 0.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    last_seen_complete
    │ │ │ +
    the time when we, or one of our peers, last saw a complete copy of │ │ │ +this torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    storage_mode
    │ │ │ +
    The allocation mode for the torrent. See storage_mode_t for the │ │ │ +options. For more information, see storage allocation.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    progress
    │ │ │ +
    a value in the range [0, 1], that represents the progress of the │ │ │ +torrent's current task. It may be checking files or downloading.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    progress_ppm
    │ │ │ +

    progress parts per million (progress * 1000000) when disabling │ │ │ +floating point operations, this is the only option to query progress

    │ │ │ +

    reflects the same value as progress, but instead in a range [0, │ │ │ +1000000] (ppm = parts per million). When floating point operations are │ │ │ +disabled, this is the only alternative to the floating point value in │ │ │ +progress.

    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    queue_position
    │ │ │ +
    the position this torrent has in the download │ │ │ +queue. If the torrent is a seed or finished, this is -1.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    download_rate upload_rate
    │ │ │ +
    the total rates for all peers for this torrent. These will usually │ │ │ +have better precision than summing the rates from all peers. The rates │ │ │ +are given as the number of bytes per second.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    download_payload_rate upload_payload_rate
    │ │ │ +
    the total transfer rate of payload only, not counting protocol │ │ │ +chatter. This might be slightly smaller than the other rates, but if │ │ │ +projected over a long time (e.g. when calculating ETA:s) the │ │ │ +difference may be noticeable.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_seeds
    │ │ │ +
    the number of peers that are seeding that this client is │ │ │ +currently connected to.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_peers
    │ │ │ +
    the number of peers this torrent currently is connected to. Peer │ │ │ +connections that are in the half-open state (is attempting to connect) │ │ │ +or are queued for later connection attempt do not count. Although they │ │ │ +are visible in the peer list when you call get_peer_info().
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    num_complete num_incomplete
    │ │ │ +
    if the tracker sends scrape info in its announce reply, these fields │ │ │ +will be set to the total number of peers that have the whole file and │ │ │ +the total number of peers that are still downloading. set to -1 if the │ │ │ +tracker did not send any scrape data in its announce reply.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    list_seeds list_peers
    │ │ │ +
    the number of seeds in our peer list and the total number of peers │ │ │ +(including seeds). We are not necessarily connected to all the peers │ │ │ +in our peer list. This is the number of peers we know of in total, │ │ │ +including banned peers and peers that we have failed to connect to.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    connect_candidates
    │ │ │ +
    the number of peers in this torrent's peer list that is a candidate to │ │ │ +be connected to. i.e. It has fewer connect attempts than the max fail │ │ │ +count, it is not a seed if we are a seed, it is not banned etc. If │ │ │ +this is 0, it means we don't know of any more peers that we can try.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_pieces
    │ │ │ +
    the number of pieces that has been downloaded. It is equivalent to: │ │ │ +std::accumulate(pieces->begin(), pieces->end()). So you don't have │ │ │ +to count yourself. This can be used to see if anything has updated │ │ │ +since last time if you want to keep a graph of the pieces up to date. │ │ │ +Note that these pieces have not necessarily been written to disk yet, │ │ │ +and there is a risk the write to disk will fail.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    distributed_full_copies
    │ │ │ +
    the number of distributed copies of the torrent. Note that one copy │ │ │ +may be spread out among many peers. It tells how many copies there are │ │ │ +currently of the rarest piece(s) among the peers this client is │ │ │ +connected to.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    distributed_fraction
    │ │ │ +

    tells the share of pieces that have more copies than the rarest │ │ │ +piece(s). Divide this number by 1000 to get the fraction.

    │ │ │ +

    For example, if distributed_full_copies is 2 and │ │ │ +distributed_fraction is 500, it means that the rarest pieces have │ │ │ +only 2 copies among the peers this torrent is connected to, and that │ │ │ +50% of all the pieces have more than two copies.

    │ │ │ +

    If we are a seed, the piece picker is deallocated as an optimization, │ │ │ +and piece availability is no longer tracked. In this case the │ │ │ +distributed copies members are set to -1.

    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    distributed_copies
    │ │ │ +

    the number of distributed copies of the file. note that one copy may │ │ │ +be spread out among many peers. This is a floating point │ │ │ +representation of the distributed copies.

    │ │ │ +
    │ │ │ +
    the integer part tells how many copies
    │ │ │ +
    there are of the rarest piece(s)
    │ │ │ +
    the fractional part tells the fraction of pieces that
    │ │ │ +
    have more copies than the rarest piece(s).
    │ │ │ +
    │ │ │ +
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    block_size
    │ │ │ +
    the size of a block, in bytes. A block is a sub piece, it is the │ │ │ +number of bytes that each piece request asks for and the number of │ │ │ +bytes that each bit in the partial_piece_info's bitset represents, │ │ │ +see get_download_queue(). This is typically 16 kB, but it may be │ │ │ +smaller, if the pieces are smaller.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_uploads
    │ │ │ +
    the number of unchoked peers in this torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    num_connections
    │ │ │ +
    the number of peer connections this torrent has, including half-open │ │ │ +connections that hasn't completed the bittorrent handshake yet. This │ │ │ +is always >= num_peers.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    uploads_limit
    │ │ │ +
    the set limit of upload slots (unchoked peers) for this torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    connections_limit
    │ │ │ +
    the set limit of number of connections for this torrent.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    upload_limit download_limit
    │ │ │ +
    the upload and download rate limits for this torrent, in bytes per │ │ │ +second. A value of -1 means unlimited.
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    up_bandwidth_queue down_bandwidth_queue
    │ │ │ +
    the number of peers in this torrent that are waiting for more │ │ │ +bandwidth quota from the torrent rate limiter. This can determine if │ │ │ +the rate you get from this torrent is bound by the torrents limit or │ │ │ +not. If there is no limit set on this torrent, the peers might still │ │ │ +be waiting for bandwidth quota from the global limiter, but then they │ │ │ +are counted in the session_status object.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    seed_rank
    │ │ │ +
    A rank of how important it is to seed the torrent, it is used to │ │ │ +determine which torrents to seed and which to queue. It is based on │ │ │ +the peer to seed ratio from the tracker scrape. For more information, │ │ │ +see queuing. Higher value means more important to seed
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    state
    │ │ │ +
    the main state the torrent is in. See torrent_status::state_t.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    need_save_resume_data
    │ │ │ +
    These are the flags indicating which aspects of this torrent have │ │ │ +changed since the last time resume data was saved. See │ │ │ +torrent_handle::save_resume_data().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    is_seeding
    │ │ │ +
    true if all pieces have been downloaded.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    is_finished
    │ │ │ +
    true if all pieces that have a priority > 0 are downloaded. There is │ │ │ +only a distinction between finished and seeding if some pieces or │ │ │ +files have been set to priority 0, i.e. are not downloaded.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    has_metadata
    │ │ │ +
    true if this torrent has metadata (either it was started from a │ │ │ +.torrent file or the metadata has been downloaded). The only scenario │ │ │ +where this can be false is when the torrent was started torrent-less │ │ │ +(i.e. with just an info-hash and tracker ip, a magnet link for │ │ │ +instance).
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    has_incoming
    │ │ │ +
    true if there has ever been an incoming connection attempt to this │ │ │ +torrent.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    moving_storage
    │ │ │ +
    this is true if this torrent's storage is currently being moved from │ │ │ +one location to another. This may potentially be a long operation │ │ │ +if a large file ends up being copied from one drive to another.
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    announcing_to_trackers announcing_to_lsd announcing_to_dht
    │ │ │ +
    these are set to true if this torrent is allowed to announce to the │ │ │ +respective peer source. Whether they are true or false is determined by │ │ │ +the queue logic/auto manager. Torrents that are not auto managed will │ │ │ +always be allowed to announce to all peer sources.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    info_hashes
    │ │ │ +
    the info-hash for this torrent
    │ │ │ +
    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    last_upload last_download
    │ │ │ +
    the timestamps of the last time this torrent uploaded or downloaded │ │ │ +payload to any peer.
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    active_duration finished_duration seeding_duration
    │ │ │ +
    these are cumulative counters of for how long the torrent has been in │ │ │ +different states. active means not paused and added to session. Whether │ │ │ +it has found any peers or not is not relevant. │ │ │ +finished means all selected files/pieces were downloaded and available │ │ │ +to other peers (this is always a subset of active time). │ │ │ +seeding means all files/pieces were downloaded and available to │ │ │ +peers. Being available to peers does not imply there are other peers │ │ │ +asking for the payload.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    flags
    │ │ │ +
    reflects several of the torrent's flags. For more │ │ │ +information, see torrent_handle::flags().
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    renamed_files
    │ │ │ +
    contains a mapping of any files that have been renamed in this │ │ │ +torrent. It can act as an overlay over file_storage (which is │ │ │ +immutable).
    │ │ │ +
    │ │ │ +

    Bencoding is a common representation in bittorrent used for dictionary, │ │ │ +list, int and string hierarchies. It's used to encode .torrent files and │ │ │ +some messages in the network protocol. libtorrent also uses it to store │ │ │ +settings, resume data and other session state.

    │ │ │ +

    Strings in bencoded structures do not necessarily represent text. │ │ │ +Strings are raw byte buffers of a certain length. If a string is meant to be │ │ │ +interpreted as text, it is required to be UTF-8 encoded. See BEP 3.

    │ │ │ +

    The function for decoding bencoded data bdecode(), returning a bdecode_node. │ │ │ +This function builds a tree that points back into the original buffer. The │ │ │ +returned bdecode_node will not be valid once the buffer it was parsed out of │ │ │ +is discarded.

    │ │ │ +

    It's possible to construct an entry from a bdecode_node, if a structure needs │ │ │ +to be altered and re-encoded.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    entry

    │ │ │ +

    Declared in "libtorrent/entry.hpp"

    │ │ │ +

    The entry class represents one node in a bencoded hierarchy. It works as a │ │ │ +variant type, it can be either a list, a dictionary (std::map), an integer │ │ │ +or a string.

    │ │ │ +
    │ │ │ +struct entry : entry_types::variant_type
    │ │ │ +{
    │ │ │ +   data_type type () const;
    │ │ │ +   entry (span<char const>);
    │ │ │ +   entry (dictionary_type);
    │ │ │ +   entry (string_view);
    │ │ │ +   entry (string_type);
    │ │ │ +   entry (list_type);
    │ │ │ +   entry (preformatted_type);
    │ │ │ +   entry (integer_type);
    │ │ │ +   entry (data_type t);
    │ │ │ +   entry (bdecode_node const& n);
    │ │ │ +   entry& operator= (dictionary_type) &;
    │ │ │ +   entry& operator= (bdecode_node const&) &;
    │ │ │ +   entry& operator= (integer_type) &;
    │ │ │ +   entry& operator= (entry const&) &;
    │ │ │ +   entry& operator= (entry&&) & ;
    │ │ │ +   entry& operator= (span<char const>) &;
    │ │ │ +   entry& operator= (preformatted_type) &;
    │ │ │ +   entry& operator= (string_view) &;
    │ │ │ +   entry& operator= (string_type) &;
    │ │ │ +   entry& operator= (list_type) &;
    │ │ │ +   preformatted_type const& preformatted () const;
    │ │ │ +   integer_type const& integer () const;
    │ │ │ +   preformatted_type& preformatted ();
    │ │ │ +   dictionary_type& dict ();
    │ │ │ +   dictionary_type const& dict () const;
    │ │ │ +   integer_type& integer ();
    │ │ │ +   string_type& string ();
    │ │ │ +   string_type const& string () const;
    │ │ │ +   list_type const& list () const;
    │ │ │ +   list_type& list ();
    │ │ │ +   entry const& operator[] (string_view key) const;
    │ │ │ +   entry& operator[] (string_view key);
    │ │ │ +   entry* find_key (string_view key);
    │ │ │ +   entry const* find_key (string_view key) const;
    │ │ │ +   std::string to_string (bool single_line = false) const;
    │ │ │ +
    │ │ │ +   enum data_type
    │ │ │ +   {
    │ │ │ +      int_t,
    │ │ │ +      string_t,
    │ │ │ +      list_t,
    │ │ │ +      dictionary_t,
    │ │ │ +      preformatted_t,
    │ │ │ +      undefined_t,
    │ │ │ +   };
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    type()

    │ │ │ +
    │ │ │ +data_type type () const;
    │ │ │ +
    │ │ │ +

    returns the concrete type of the entry

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    entry()

    │ │ │ +
    │ │ │ +entry (span<char const>);
    │ │ │ +entry (dictionary_type);
    │ │ │ +entry (string_view);
    │ │ │ +entry (string_type);
    │ │ │ +entry (list_type);
    │ │ │ +entry (preformatted_type);
    │ │ │ +entry (integer_type);
    │ │ │ +
    │ │ │ +

    constructors directly from a specific type. │ │ │ +The content of the argument is copied into the │ │ │ +newly constructed entry

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    entry()

    │ │ │ +
    │ │ │ +entry (data_type t);
    │ │ │ +
    │ │ │ +

    construct an empty entry of the specified type. │ │ │ +see data_type enum.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    entry()

    │ │ │ +
    │ │ │ +entry (bdecode_node const& n);
    │ │ │ +
    │ │ │ +

    construct from bdecode_node parsed form (see bdecode())

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator=()

    │ │ │ +
    │ │ │ +entry& operator= (dictionary_type) &;
    │ │ │ +entry& operator= (bdecode_node const&) &;
    │ │ │ +entry& operator= (integer_type) &;
    │ │ │ +entry& operator= (entry const&) &;
    │ │ │ +entry& operator= (entry&&) & ;
    │ │ │ +entry& operator= (span<char const>) &;
    │ │ │ +entry& operator= (preformatted_type) &;
    │ │ │ +entry& operator= (string_view) &;
    │ │ │ +entry& operator= (string_type) &;
    │ │ │ +entry& operator= (list_type) &;
    │ │ │ +
    │ │ │ +

    copies the structure of the right hand side into this │ │ │ +entry.

    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    integer() string() list() preformatted() dict()

    │ │ │ +
    │ │ │ +preformatted_type const& preformatted () const;
    │ │ │ +integer_type const& integer () const;
    │ │ │ +preformatted_type& preformatted ();
    │ │ │ +dictionary_type& dict ();
    │ │ │ +dictionary_type const& dict () const;
    │ │ │ +integer_type& integer ();
    │ │ │ +string_type& string ();
    │ │ │ +string_type const& string () const;
    │ │ │ +list_type const& list () const;
    │ │ │ +list_type& list ();
    │ │ │ +
    │ │ │ +

    The integer(), string(), list(), dict() and │ │ │ +preformatted() functions are accessors that return the │ │ │ +respective type. If the entry object │ │ │ +isn't of the type you request, the accessor will throw │ │ │ +system_error. You can ask an entry for its type through the │ │ │ +type() function.

    │ │ │ +

    If you want to create an entry you give it the type you want it to │ │ │ +have in its constructor, and then use one of the non-const accessors │ │ │ +to get a reference which you then can assign the value you want it to │ │ │ +have.

    │ │ │ +

    The typical code to get info from a torrent file will then look like │ │ │ +this:

    │ │ │ +
    │ │ │ +entry torrent_file;
    │ │ │ +// ...
    │ │ │ +
    │ │ │ +// throws if this is not a dictionary
    │ │ │ +entry::dictionary_type const& dict = torrent_file.dict();
    │ │ │ +entry::dictionary_type::const_iterator i;
    │ │ │ +i = dict.find("announce");
    │ │ │ +if (i != dict.end())
    │ │ │ +{
    │ │ │ +        std::string tracker_url = i->second.string();
    │ │ │ +        std::cout << tracker_url << "\n";
    │ │ │ +}
    │ │ │ +
    │ │ │ +

    The following code is equivalent, but a little bit shorter:

    │ │ │ +
    │ │ │ +entry torrent_file;
    │ │ │ +// ...
    │ │ │ +
    │ │ │ +// throws if this is not a dictionary
    │ │ │ +if (entry* i = torrent_file.find_key("announce"))
    │ │ │ +{
    │ │ │ +        std::string tracker_url = i->string();
    │ │ │ +        std::cout << tracker_url << "\n";
    │ │ │ +}
    │ │ │ +
    │ │ │ +

    To make it easier to extract information from a torrent file, the │ │ │ +class torrent_info exists.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator[]()

    │ │ │ +
    │ │ │ +entry const& operator[] (string_view key) const;
    │ │ │ +entry& operator[] (string_view key);
    │ │ │ +
    │ │ │ +

    All of these functions requires the entry to be a dictionary, if it │ │ │ +isn't they will throw system_error.

    │ │ │ +

    The non-const versions of the operator[] will return a reference │ │ │ +to either the existing element at the given key or, if there is no │ │ │ +element with the given key, a reference to a newly inserted element at │ │ │ +that key.

    │ │ │ +

    The const version of operator[] will only return a reference to an │ │ │ +existing element at the given key. If the key is not found, it will │ │ │ +throw system_error.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    find_key()

    │ │ │ +
    │ │ │ +entry* find_key (string_view key);
    │ │ │ +entry const* find_key (string_view key) const;
    │ │ │ +
    │ │ │ +

    These functions requires the entry to be a dictionary, if it isn't │ │ │ +they will throw system_error.

    │ │ │ +

    They will look for an element at the given key in the dictionary, if │ │ │ +the element cannot be found, they will return nullptr. If an element │ │ │ +with the given key is found, the return a pointer to it.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    to_string()

    │ │ │ +
    │ │ │ +std::string to_string (bool single_line = false) const;
    │ │ │ +
    │ │ │ +

    returns a pretty-printed string representation │ │ │ +of the bencoded structure, with JSON-style syntax

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum data_type

    │ │ │ +

    Declared in "libtorrent/entry.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    int_t0 
    string_t1 
    list_t2 
    dictionary_t3 
    preformatted_t4 
    undefined_t5 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │ +

    bencode()

    │ │ │ +

    Declared in "libtorrent/bencode.hpp"

    │ │ │ +
    │ │ │ +template<class OutIt> int bencode (OutIt out, const entry& e);
    │ │ │ +std::vector<char> bencode (entry const& e);
    │ │ │ +
    │ │ │ +

    The bencode() function has two overloads that serializes a tree │ │ │ +structure of entry objects into a bencoded, flat, buffer. │ │ │ +The entry class is the internal representation of the bencoded data.

    │ │ │ +

    The simplest overload simply takes an entry object and returns a vector │ │ │ +with the serialized data.

    │ │ │ +

    The second overload encode it into the OutIt iterator.

    │ │ │ +

    OutIt is an OutputIterator. It's a template and usually │ │ │ +instantiated as ostream_iterator or back_insert_iterator. This │ │ │ +function assumes the value_type of the iterator is a char. │ │ │ +In order to encode entry e into a buffer, do:

    │ │ │ +
    │ │ │ +std::vector<char> buf;
    │ │ │ +bencode(std::back_inserter(buf), e);
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator<<()

    │ │ │ +

    Declared in "libtorrent/entry.hpp"

    │ │ │ +
    │ │ │ +inline std::ostream& operator<< (std::ostream& os, const entry& e);
    │ │ │ +
    │ │ │ +

    prints the bencoded structure to the ostream as a JSON-style structure.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    dht_state

    │ │ │

    Declared in "libtorrent/kademlia/dht_state.hpp"

    │ │ │

    This structure helps to store and load the state │ │ │ of the dht_tracker. │ │ │ At this moment the library is only a dual stack │ │ │ @@ -21596,16 +21863,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
    │ │ │ @@ -21615,25 +21893,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
    │ │ │ @@ -21649,18 +21916,18 @@ │ │ │
    Specify the port number for the SSL listen socket in the DHT announce.
    │ │ │
    │ │ │ [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
    │ │ │ +   , error_code& ec, 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
    │ │ │     , 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 │ │ │ @@ -21708,17 +21975,17 @@ │ │ │ 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, 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, 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:

    │ │ │
      │ │ │
    • The add_torrent_params object passed to this function does not contain the │ │ │ info dictionary (the ti field)
    • │ │ │ ├── html2text {} │ │ │ │ @@ -1,356 +1,89 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.0 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ - * _s_t_o_r_a_g_e___e_r_r_o_r │ │ │ │ - o _b_o_o_l_(_) │ │ │ │ - o _f_i_l_e_(_) │ │ │ │ - * _l_i_b_t_o_r_r_e_n_t___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _h_t_t_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _g_z_i_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _u_p_n_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _i_2_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _s_o_c_k_s___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _p_c_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _b_d_e_c_o_d_e___c_a_t_e_g_o_r_y_(_) │ │ │ │ - * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ - * _e_n_u_m_ _h_t_t_p___e_r_r_o_r_s │ │ │ │ - * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ - * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ - * _e_n_u_m_ _i_2_p___e_r_r_o_r___c_o_d_e │ │ │ │ - * _e_n_u_m_ _s_o_c_k_s___e_r_r_o_r___c_o_d_e │ │ │ │ - * _e_n_u_m_ _p_c_p___e_r_r_o_r_s │ │ │ │ - * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ - * _s_e_s_s_i_o_n___p_a_r_a_m_s │ │ │ │ - o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ - o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ - * _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _~_s_e_s_s_i_o_n___p_r_o_x_y_(_) │ │ │ │ - * _s_e_s_s_i_o_n │ │ │ │ - o _s_e_s_s_i_o_n_(_) │ │ │ │ - o _s_e_s_s_i_o_n_(_) │ │ │ │ - o _~_s_e_s_s_i_o_n_(_) │ │ │ │ - o _a_b_o_r_t_(_) │ │ │ │ - * _s_e_s_s_i_o_n___h_a_n_d_l_e │ │ │ │ - o _i_s___v_a_l_i_d_(_) │ │ │ │ - o _s_e_s_s_i_o_n___s_t_a_t_e_(_) │ │ │ │ - o _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 _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_d_d___t_o_r_r_e_n_t_(_)_ _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ - o _r_e_s_u_m_e_(_)_ _i_s___p_a_u_s_e_d_(_)_ _p_a_u_s_e_(_) │ │ │ │ - o _i_s___d_h_t___r_u_n_n_i_n_g_(_) │ │ │ │ - o _s_e_t___d_h_t___s_t_o_r_a_g_e_(_) │ │ │ │ - o _a_d_d___d_h_t___n_o_d_e_(_) │ │ │ │ - o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ - o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ - o _d_h_t___p_u_t___i_t_e_m_(_) │ │ │ │ - o _d_h_t___p_u_t___i_t_e_m_(_) │ │ │ │ - o _d_h_t___g_e_t___p_e_e_r_s_(_)_ _d_h_t___a_n_n_o_u_n_c_e_(_) │ │ │ │ - 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___p_o_r_t___f_i_l_t_e_r_(_) │ │ │ │ - o _s_s_l___l_i_s_t_e_n___p_o_r_t_(_)_ _l_i_s_t_e_n___p_o_r_t_(_)_ _i_s___l_i_s_t_e_n_i_n_g_(_) │ │ │ │ - o _g_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_) │ │ │ │ - o _s_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_)_ _g_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_) │ │ │ │ - o _c_r_e_a_t_e___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ - o _d_e_l_e_t_e___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ - o _g_e_t___p_e_e_r___c_l_a_s_s_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ - o _r_e_m_o_v_e___t_o_r_r_e_n_t_(_) │ │ │ │ - o _g_e_t___s_e_t_t_i_n_g_s_(_)_ _a_p_p_l_y___s_e_t_t_i_n_g_s_(_) │ │ │ │ - o _p_o_p___a_l_e_r_t_s_(_)_ _w_a_i_t___f_o_r___a_l_e_r_t_(_)_ _s_e_t___a_l_e_r_t___n_o_t_i_f_y_(_) │ │ │ │ - o _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_)_ _a_d_d___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_(_) │ │ │ │ - * _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_)_ _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_(_) │ │ │ │ - * _l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s │ │ │ │ - * _t_o_r_r_e_n_t___i_n_f_o │ │ │ │ - o _t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ - o _t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ - o _~_t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ - o _l_a_y_o_u_t_(_) │ │ │ │ - o _s_i_m_i_l_a_r___t_o_r_r_e_n_t_s_(_)_ _c_o_l_l_e_c_t_i_o_n_s_(_) │ │ │ │ - o _t_o_t_a_l___s_i_z_e_(_) │ │ │ │ - o _s_i_z_e___o_n___d_i_s_k_(_) │ │ │ │ - o _n_u_m___p_i_e_c_e_s_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ - o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ - o _p_i_e_c_e___r_a_n_g_e_(_)_ _e_n_d___p_i_e_c_e_(_)_ _l_a_s_t___p_i_e_c_e_(_) │ │ │ │ - o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_) │ │ │ │ - o _v_1_(_)_ _v_2_(_) │ │ │ │ - o _n_u_m___f_i_l_e_s_(_) │ │ │ │ - o _m_a_p___b_l_o_c_k_(_) │ │ │ │ - o _m_a_p___f_i_l_e_(_) │ │ │ │ - o _s_s_l___c_e_r_t_(_) │ │ │ │ - o _i_s___v_a_l_i_d_(_) │ │ │ │ - o _p_r_i_v_(_) │ │ │ │ - o _i_s___i_2_p_(_) │ │ │ │ - o _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ - o _p_i_e_c_e___s_i_z_e___f_o_r___r_e_q_(_) │ │ │ │ - o _h_a_s_h___f_o_r___p_i_e_c_e___p_t_r_(_)_ _h_a_s_h___f_o_r___p_i_e_c_e_(_) │ │ │ │ - o _i_s___l_o_a_d_e_d_(_) │ │ │ │ - o _n_a_m_e_(_) │ │ │ │ - o _i_n_f_o___s_e_c_t_i_o_n_(_) │ │ │ │ - * _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_(_)_ _h_a_s___v_1_(_)_ _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_(_)_ _h_a_s___v_2_(_) │ │ │ │ + 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___b_u_f_f_e_r_(_)_ _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_(_) │ │ │ │ + * _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___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_(_) │ │ │ │ + * _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 │ │ │ │ - * _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_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_(_) │ │ │ │ - o _o_n___u_n_k_n_o_w_n___t_o_r_r_e_n_t_(_) │ │ │ │ - o _o_n___t_i_c_k_(_) │ │ │ │ - o _g_e_t___u_n_c_h_o_k_e___p_r_i_o_r_i_t_y_(_) │ │ │ │ - o _s_a_v_e___s_t_a_t_e_(_) │ │ │ │ - o _l_o_a_d___s_t_a_t_e_(_) │ │ │ │ - * _t_o_r_r_e_n_t___p_l_u_g_i_n │ │ │ │ - o _n_e_w___c_o_n_n_e_c_t_i_o_n_(_) │ │ │ │ - o _o_n___p_i_e_c_e___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_) │ │ │ │ - o _t_i_c_k_(_) │ │ │ │ - o _o_n___p_a_u_s_e_(_)_ _o_n___r_e_s_u_m_e_(_) │ │ │ │ - o _o_n___f_i_l_e_s___c_h_e_c_k_e_d_(_) │ │ │ │ - o _o_n___s_t_a_t_e_(_) │ │ │ │ - o _o_n___a_d_d___p_e_e_r_(_) │ │ │ │ - * _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___d_o_n_t___h_a_v_e_(_)_ _o_n___h_a_v_e___n_o_n_e_(_)_ _o_n___r_e_q_u_e_s_t_(_)_ _o_n___i_n_t_e_r_e_s_t_e_d_(_) │ │ │ │ - _o_n___n_o_t___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_n___a_l_l_o_w_e_d___f_a_s_t_(_) │ │ │ │ - _o_n___c_h_o_k_e_(_)_ _o_n___u_n_c_h_o_k_e_(_)_ _o_n___h_a_v_e_(_) │ │ │ │ - o _o_n___p_i_e_c_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___s_u_g_g_e_s_t_(_)_ _s_e_n_t___h_a_v_e___a_l_l_(_)_ _s_e_n_t___h_a_v_e___n_o_n_e_(_)_ _s_e_n_t___u_n_c_h_o_k_e_(_) │ │ │ │ - _s_e_n_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___c_a_n_c_e_l_(_)_ _s_e_n_t___r_e_q_u_e_s_t │ │ │ │ - _(_)_ _s_e_n_t___r_e_j_e_c_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___p_i_e_c_e_(_)_ _s_e_n_t___c_h_o_k_e_(_)_ _s_e_n_t___a_l_l_o_w___f_a_s_t │ │ │ │ - _(_)_ _s_e_n_t___h_a_v_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___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_) │ │ │ │ - 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 _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 _h_a_s___p_e_e_r___c_h_o_k_e_d_(_)_ _i_s___p_e_e_r___i_n_t_e_r_e_s_t_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 _d_i_s_c_o_n_n_e_c_t_(_)_ _i_s___o_u_t_g_o_i_n_g_(_)_ _i_s___d_i_s_c_o_n_n_e_c_t_i_n_g_(_)_ _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_(_) │ │ │ │ - * _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_(_) │ │ │ │ - * _f_i_l_e___s_l_i_c_e │ │ │ │ - * _f_i_l_e___s_t_o_r_a_g_e │ │ │ │ - o _i_s___v_a_l_i_d_(_) │ │ │ │ - o _r_e_s_e_r_v_e_(_) │ │ │ │ - o _a_d_d___f_i_l_e___b_o_r_r_o_w_(_)_ _a_d_d___f_i_l_e_(_) │ │ │ │ - o _a_d_d___f_i_l_e___b_o_r_r_o_w_(_)_ _a_d_d___f_i_l_e_(_) │ │ │ │ - o _m_a_p___b_l_o_c_k_(_) │ │ │ │ - o _m_a_p___f_i_l_e_(_) │ │ │ │ - o _n_u_m___f_i_l_e_s_(_) │ │ │ │ - o _e_n_d___f_i_l_e_(_) │ │ │ │ - o _f_i_l_e___r_a_n_g_e_(_) │ │ │ │ - o _t_o_t_a_l___s_i_z_e_(_) │ │ │ │ - o _s_i_z_e___o_n___d_i_s_k_(_) │ │ │ │ - o _s_e_t___n_u_m___p_i_e_c_e_s_(_)_ _n_u_m___p_i_e_c_e_s_(_) │ │ │ │ - o _e_n_d___p_i_e_c_e_(_) │ │ │ │ - o _l_a_s_t___p_i_e_c_e_(_) │ │ │ │ - o _p_i_e_c_e___r_a_n_g_e_(_) │ │ │ │ - o _s_e_t___p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ - o _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ - o _p_i_e_c_e___s_i_z_e_2_(_) │ │ │ │ - o _b_l_o_c_k_s___i_n___p_i_e_c_e_2_(_) │ │ │ │ - o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ - o _s_e_t___n_a_m_e_(_)_ _n_a_m_e_(_) │ │ │ │ + * _h_a_s_h_e_r │ │ │ │ + o _o_p_e_r_a_t_o_r_=_(_)_ _h_a_s_h_e_r_(_) │ │ │ │ + o _u_p_d_a_t_e_(_) │ │ │ │ + o _f_i_n_a_l_(_) │ │ │ │ + o _r_e_s_e_t_(_) │ │ │ │ + * _h_a_s_h_e_r_2_5_6 │ │ │ │ + o _o_p_e_r_a_t_o_r_=_(_)_ _h_a_s_h_e_r_2_5_6_(_) │ │ │ │ + o _u_p_d_a_t_e_(_) │ │ │ │ + o _f_i_n_a_l_(_) │ │ │ │ + o _r_e_s_e_t_(_) │ │ │ │ + * _b_i_t_f_i_e_l_d │ │ │ │ + o _b_i_t_f_i_e_l_d_(_) │ │ │ │ + o _a_s_s_i_g_n_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_[_]_(_)_ _g_e_t___b_i_t_(_) │ │ │ │ + o _c_l_e_a_r___b_i_t_(_)_ _s_e_t___b_i_t_(_) │ │ │ │ + o _a_l_l___s_e_t_(_) │ │ │ │ + o _n_o_n_e___s_e_t_(_) │ │ │ │ + o _s_i_z_e_(_) │ │ │ │ + o _n_u_m___w_o_r_d_s_(_) │ │ │ │ + o _n_u_m___b_y_t_e_s_(_) │ │ │ │ + o _e_m_p_t_y_(_) │ │ │ │ + o _d_a_t_a_(_) │ │ │ │ o _s_w_a_p_(_) │ │ │ │ - o _p_a_d___f_i_l_e___a_t_(_)_ _r_o_o_t_(_)_ _f_i_l_e___o_f_f_s_e_t_(_)_ _f_i_l_e___p_a_t_h_(_)_ _r_o_o_t___p_t_r_(_)_ _f_i_l_e___n_a_m_e │ │ │ │ - _(_)_ _m_t_i_m_e_(_)_ _s_y_m_l_i_n_k_(_)_ _f_i_l_e___s_i_z_e_(_) │ │ │ │ - o _f_i_l_e___p_i_e_c_e___r_a_n_g_e_(_)_ _f_i_l_e___n_u_m___p_i_e_c_e_s_(_)_ _f_i_l_e___n_u_m___b_l_o_c_k_s_(_) │ │ │ │ - o _f_i_l_e___f_i_r_s_t___p_i_e_c_e___n_o_d_e_(_)_ _f_i_l_e___f_i_r_s_t___b_l_o_c_k___n_o_d_e_(_) │ │ │ │ - o _f_i_l_e___p_a_t_h___h_a_s_h_(_) │ │ │ │ - o _a_l_l___p_a_t_h___h_a_s_h_e_s_(_) │ │ │ │ - o _f_i_l_e___f_l_a_g_s_(_) │ │ │ │ - o _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ - o _l_a_s_t___f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_)_ _f_i_l_e___i_n_d_e_x___a_t___o_f_f_s_e_t_(_) │ │ │ │ - _f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_) │ │ │ │ - o _f_i_l_e___i_n_d_e_x___f_o_r___r_o_o_t_(_) │ │ │ │ - o _p_i_e_c_e___i_n_d_e_x___a_t___f_i_l_e_(_)_ _l_a_s_t___p_i_e_c_e___i_n_d_e_x___a_t___f_i_l_e_(_) │ │ │ │ - o _s_a_n_i_t_i_z_e___s_y_m_l_i_n_k_s_(_) │ │ │ │ - o _v_2_(_) │ │ │ │ - * _r_e_n_a_m_e_d___f_i_l_e_s │ │ │ │ - o _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___n_a_m_e_(_)_ _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ - o _r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ - o _e_x_p_o_r_t___f_i_l_e_n_a_m_e_s_(_)_ _i_m_p_o_r_t___f_i_l_e_n_a_m_e_s_(_) │ │ │ │ - * _f_i_l_e_n_a_m_e_s │ │ │ │ - o _f_i_l_e_n_a_m_e_s_(_) │ │ │ │ - o _f_i_l_e___f_l_a_g_s_(_) │ │ │ │ - o _e_n_d___f_i_l_e_(_) │ │ │ │ - o _p_a_d___f_i_l_e___a_t_(_) │ │ │ │ - o _f_i_l_e___s_i_z_e_(_)_ _f_i_l_e___o_f_f_s_e_t_(_) │ │ │ │ - o _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ - o _s_y_m_l_i_n_k_(_) │ │ │ │ - o _f_i_l_e___r_a_n_g_e_(_) │ │ │ │ - o _n_u_m___f_i_l_e_s_(_)_ _e_n_d___p_i_e_c_e_(_)_ _n_u_m___p_i_e_c_e_s_(_) │ │ │ │ - o _m_a_p___b_l_o_c_k_(_) │ │ │ │ - o _m_a_p___f_i_l_e_(_) │ │ │ │ - o _r_o_o_t_(_) │ │ │ │ - o _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ - * _s_t_o_r_a_g_e___p_a_r_a_m_s │ │ │ │ - o _s_t_o_r_a_g_e___p_a_r_a_m_s_(_) │ │ │ │ - * _d_i_s_a_b_l_e_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ - * _m_m_a_p___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ - * _p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ - * _d_e_f_a_u_l_t___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ - * _e_n_u_m_ _s_t_o_r_a_g_e___m_o_d_e___t │ │ │ │ - * _e_n_u_m_ _m_o_v_e___f_l_a_g_s___t │ │ │ │ - * _c_l_i_e_n_t___d_a_t_a___t │ │ │ │ - o _c_l_i_e_n_t___d_a_t_a___t_(_) │ │ │ │ - o _c_l_i_e_n_t___d_a_t_a___t_(_) │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ - o _T_(_)_ _g_e_t_(_) │ │ │ │ - o _v_o_i_d_*_(_)_ _o_p_e_r_a_t_o_r_=_(_)_ _c_o_n_s_t_*_(_) │ │ │ │ - * _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ - * _p_e_e_r___c_l_a_s_s___i_n_f_o │ │ │ │ - * _p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r │ │ │ │ - o _r_e_m_o_v_e_(_)_ _a_d_d_(_) │ │ │ │ - o _a_l_l_o_w_(_)_ _d_i_s_a_l_l_o_w_(_) │ │ │ │ - o _a_p_p_l_y_(_) │ │ │ │ - o _e_n_u_m_ _s_o_c_k_e_t___t_y_p_e___t │ │ │ │ - * _b_l_o_c_k___i_n_f_o │ │ │ │ - o _s_e_t___p_e_e_r_(_)_ _p_e_e_r_(_) │ │ │ │ - o _e_n_u_m_ _b_l_o_c_k___s_t_a_t_e___t │ │ │ │ - * _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o │ │ │ │ - * _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ - o _h_a_s_h___v_a_l_u_e_(_) │ │ │ │ - o _t_o_r_r_e_n_t___h_a_n_d_l_e_(_) │ │ │ │ - o _a_d_d___p_i_e_c_e_(_) │ │ │ │ - o _r_e_a_d___p_i_e_c_e_(_) │ │ │ │ - o _s_e_t___s_e_q_u_e_n_t_i_a_l___r_a_n_g_e_(_) │ │ │ │ - o _h_a_v_e___p_i_e_c_e_(_) │ │ │ │ - o _p_o_s_t___p_e_e_r___i_n_f_o_(_)_ _g_e_t___p_e_e_r___i_n_f_o_(_) │ │ │ │ - o _s_t_a_t_u_s_(_)_ _p_o_s_t___s_t_a_t_u_s_(_) │ │ │ │ - o _p_o_s_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)_ _g_e_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_) │ │ │ │ - o _c_l_e_a_r___p_i_e_c_e___d_e_a_d_l_i_n_e_s_(_)_ _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_) │ │ │ │ - o _f_i_l_e___p_r_o_g_r_e_s_s_(_)_ _p_o_s_t___f_i_l_e___p_r_o_g_r_e_s_s_(_) │ │ │ │ - o _f_i_l_e___s_t_a_t_u_s_(_)_ _p_o_s_t___f_i_l_e___s_t_a_t_u_s_(_) │ │ │ │ - o _c_l_e_a_r___e_r_r_o_r_(_) │ │ │ │ - o _a_d_d___t_r_a_c_k_e_r_(_)_ _t_r_a_c_k_e_r_s_(_)_ _p_o_s_t___t_r_a_c_k_e_r_s_(_)_ _r_e_p_l_a_c_e___t_r_a_c_k_e_r_s_(_) │ │ │ │ - o _u_r_l___s_e_e_d_s_(_)_ _r_e_m_o_v_e___u_r_l___s_e_e_d_(_)_ _a_d_d___u_r_l___s_e_e_d_(_) │ │ │ │ - o _a_d_d___e_x_t_e_n_s_i_o_n_(_) │ │ │ │ - o _s_e_t___m_e_t_a_d_a_t_a_(_) │ │ │ │ - o _i_s___v_a_l_i_d_(_) │ │ │ │ - o _r_e_s_u_m_e_(_)_ _p_a_u_s_e_(_) │ │ │ │ - o _f_l_a_g_s_(_)_ _s_e_t___f_l_a_g_s_(_)_ _u_n_s_e_t___f_l_a_g_s_(_) │ │ │ │ - o _f_l_u_s_h___c_a_c_h_e_(_) │ │ │ │ - o _f_o_r_c_e___r_e_c_h_e_c_k_(_) │ │ │ │ - o _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_)_ _g_e_t___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ - o _n_e_e_d___s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ - o _q_u_e_u_e___p_o_s_i_t_i_o_n___u_p_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___t_o_p_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n_(_) │ │ │ │ - _q_u_e_u_e___p_o_s_i_t_i_o_n___d_o_w_n_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___b_o_t_t_o_m_(_) │ │ │ │ - o _q_u_e_u_e___p_o_s_i_t_i_o_n___s_e_t_(_) │ │ │ │ - o _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e___b_u_f_f_e_r_(_)_ _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e_(_) │ │ │ │ - o _t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ - o _g_e_t___r_e_n_a_m_e_d___f_i_l_e_s_(_) │ │ │ │ - o _p_i_e_c_e___l_a_y_e_r_s_(_) │ │ │ │ - o _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)_ _p_o_s_t___p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_) │ │ │ │ - o _p_i_e_c_e___p_r_i_o_r_i_t_y_(_)_ _g_e_t___p_i_e_c_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_r_i_o_r_i_t_i_z_e___p_i_e_c_e_s_(_) │ │ │ │ - o _f_i_l_e___p_r_i_o_r_i_t_y_(_)_ _g_e_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_) │ │ │ │ - o _p_o_s_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_) │ │ │ │ - o _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___l_s_d___a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___d_h_t___a_n_n_o_u_n_c_e_(_) │ │ │ │ - o _s_c_r_a_p_e___t_r_a_c_k_e_r_(_) │ │ │ │ - o _s_e_t___d_o_w_n_l_o_a_d___l_i_m_i_t_(_)_ _d_o_w_n_l_o_a_d___l_i_m_i_t_(_)_ _u_p_l_o_a_d___l_i_m_i_t_(_) │ │ │ │ - _s_e_t___u_p_l_o_a_d___l_i_m_i_t_(_) │ │ │ │ - o _c_o_n_n_e_c_t___p_e_e_r_(_) │ │ │ │ - o _c_l_e_a_r___p_e_e_r_s_(_) │ │ │ │ - o _m_a_x___u_p_l_o_a_d_s_(_)_ _s_e_t___m_a_x___u_p_l_o_a_d_s_(_) │ │ │ │ - o _s_e_t___m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)_ _m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_) │ │ │ │ - o _m_o_v_e___s_t_o_r_a_g_e_(_) │ │ │ │ - o _r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ - o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_) │ │ │ │ - o _o_p_e_r_a_t_o_r_!_=_(_)_ _o_p_e_r_a_t_o_r_<_(_)_ _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ - o _i_d_(_) │ │ │ │ - o _n_a_t_i_v_e___h_a_n_d_l_e_(_) │ │ │ │ - o _u_s_e_r_d_a_t_a_(_) │ │ │ │ - o _i_n___s_e_s_s_i_o_n_(_) │ │ │ │ - * _h_a_s_h___v_a_l_u_e_(_) │ │ │ │ + o _c_o_u_n_t_(_) │ │ │ │ + o _f_i_n_d___f_i_r_s_t___s_e_t_(_) │ │ │ │ + o _f_i_n_d___l_a_s_t___c_l_e_a_r_(_) │ │ │ │ + * _s_t_a_t_s___m_e_t_r_i_c │ │ │ │ + * _c_o_u_n_t_e_r_s │ │ │ │ + o _i_n_c___s_t_a_t_s___c_o_u_n_t_e_r_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_[_]_(_) │ │ │ │ + o _b_l_e_n_d___s_t_a_t_s___c_o_u_n_t_e_r_(_)_ _s_e_t___v_a_l_u_e_(_) │ │ │ │ + * _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_) │ │ │ │ + * _f_i_n_d___m_e_t_r_i_c___i_d_x_(_) │ │ │ │ + * _e_n_u_m_ _m_e_t_r_i_c___t_y_p_e___t │ │ │ │ + * _a_n_n_o_u_n_c_e___i_n_f_o_h_a_s_h │ │ │ │ + * _a_n_n_o_u_n_c_e___e_n_d_p_o_i_n_t │ │ │ │ + * _a_n_n_o_u_n_c_e___e_n_t_r_y │ │ │ │ + o _o_p_e_r_a_t_o_r_=_(_)_ _a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _~_a_n_n_o_u_n_c_e___e_n_t_r_y_(_) │ │ │ │ + o _e_n_u_m_ _t_r_a_c_k_e_r___s_o_u_r_c_e │ │ │ │ + * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ + o _s_e_t___b_o_o_l_(_)_ _s_e_t___s_t_r_(_)_ _s_e_t___i_n_t_(_) │ │ │ │ + o _h_a_s___v_a_l_(_) │ │ │ │ + o _g_e_t___s_t_r_(_)_ _g_e_t___i_n_t_(_)_ _g_e_t___b_o_o_l_(_) │ │ │ │ * _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___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_(_) │ │ │ │ @@ -369,54 +102,70 @@ │ │ │ │ o _s_e_t_t_i_n_g_s___u_p_d_a_t_e_d_(_) │ │ │ │ * _s_t_o_r_a_g_e___h_o_l_d_e_r │ │ │ │ o _s_t_o_r_a_g_e___h_o_l_d_e_r_(_) │ │ │ │ o _r_e_s_e_t_(_) │ │ │ │ * _d_i_s_k___o_b_s_e_r_v_e_r │ │ │ │ o _o_n___d_i_s_k_(_) │ │ │ │ * _b_u_f_f_e_r___a_l_l_o_c_a_t_o_r___i_n_t_e_r_f_a_c_e │ │ │ │ - o _f_r_e_e___m_u_l_t_i_p_l_e___b_u_f_f_e_r_s_(_)_ _f_r_e_e___d_i_s_k___b_u_f_f_e_r_(_) │ │ │ │ + o _f_r_e_e___d_i_s_k___b_u_f_f_e_r_(_)_ _f_r_e_e___m_u_l_t_i_p_l_e___b_u_f_f_e_r_s_(_) │ │ │ │ * _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r │ │ │ │ o _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_(_) │ │ │ │ o _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_(_) │ │ │ │ o _~_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_(_) │ │ │ │ o _d_a_t_a_(_) │ │ │ │ o _r_e_s_e_t_(_) │ │ │ │ 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 _a_d_d_(_)_ _~_b_u_l_k___f_r_e_e___b_u_f_f_e_r_(_) │ │ │ │ - * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ - o _s_e_t___b_o_o_l_(_)_ _s_e_t___s_t_r_(_)_ _s_e_t___i_n_t_(_) │ │ │ │ - o _h_a_s___v_a_l_(_) │ │ │ │ - o _g_e_t___s_t_r_(_)_ _g_e_t___b_o_o_l_(_)_ _g_e_t___i_n_t_(_) │ │ │ │ * _s_t_a_t_u_s___t │ │ │ │ * _f_i_l_e___o_p_e_n___m_o_d_e___t │ │ │ │ - * _a_l_e_r_t │ │ │ │ - o _t_i_m_e_s_t_a_m_p_(_) │ │ │ │ - o _t_y_p_e_(_) │ │ │ │ - o _w_h_a_t_(_) │ │ │ │ - o _m_e_s_s_a_g_e_(_) │ │ │ │ - o _c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _s_e_t_t_i_n_g_s___p_a_c_k │ │ │ │ + o _s_e_t___b_o_o_l_(_)_ _s_e_t___s_t_r_(_)_ _s_e_t___i_n_t_(_) │ │ │ │ + o _h_a_s___v_a_l_(_) │ │ │ │ + o _c_l_e_a_r_(_) │ │ │ │ + o _c_l_e_a_r_(_) │ │ │ │ + o _g_e_t___s_t_r_(_)_ _g_e_t___i_n_t_(_)_ _g_e_t___b_o_o_l_(_) │ │ │ │ + o _e_n_u_m_ _t_y_p_e___b_a_s_e_s │ │ │ │ + o _e_n_u_m_ _m_m_a_p___w_r_i_t_e___m_o_d_e___t │ │ │ │ + o _e_n_u_m_ _s_u_g_g_e_s_t___m_o_d_e___t │ │ │ │ + o _e_n_u_m_ _c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t │ │ │ │ + o _e_n_u_m_ _s_e_e_d___c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t │ │ │ │ + o _e_n_u_m_ _i_o___b_u_f_f_e_r___m_o_d_e___t │ │ │ │ + o _e_n_u_m_ _b_a_n_d_w_i_d_t_h___m_i_x_e_d___a_l_g_o___t │ │ │ │ + o _e_n_u_m_ _e_n_c___p_o_l_i_c_y │ │ │ │ + o _e_n_u_m_ _e_n_c___l_e_v_e_l │ │ │ │ + o _e_n_u_m_ _p_r_o_x_y___t_y_p_e___t │ │ │ │ + * _n_a_m_e___f_o_r___s_e_t_t_i_n_g_(_)_ _s_e_t_t_i_n_g___b_y___n_a_m_e_(_) │ │ │ │ + * _d_e_f_a_u_l_t___s_e_t_t_i_n_g_s_(_) │ │ │ │ + * _h_i_g_h___p_e_r_f_o_r_m_a_n_c_e___s_e_e_d_(_)_ _m_i_n___m_e_m_o_r_y___u_s_a_g_e_(_) │ │ │ │ + * _g_e_n_e_r_a_t_e___f_i_n_g_e_r_p_r_i_n_t_(_) │ │ │ │ + * _p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r │ │ │ │ + o _r_e_m_o_v_e_(_)_ _a_d_d_(_) │ │ │ │ + o _d_i_s_a_l_l_o_w_(_)_ _a_l_l_o_w_(_) │ │ │ │ + o _a_p_p_l_y_(_) │ │ │ │ + o _e_n_u_m_ _s_o_c_k_e_t___t_y_p_e___t │ │ │ │ + * _p_e_e_r___c_l_a_s_s___i_n_f_o │ │ │ │ * _d_h_t___r_o_u_t_i_n_g___b_u_c_k_e_t │ │ │ │ * _t_o_r_r_e_n_t___a_l_e_r_t │ │ │ │ o _m_e_s_s_a_g_e_(_) │ │ │ │ * _p_e_e_r___a_l_e_r_t │ │ │ │ o _e_n_u_m_ _e_n_d_p_o_i_n_t___t_y_p_e___t │ │ │ │ * _t_r_a_c_k_e_r___a_l_e_r_t │ │ │ │ o _t_r_a_c_k_e_r___u_r_l_(_) │ │ │ │ * _t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t │ │ │ │ * _r_e_a_d___p_i_e_c_e___a_l_e_r_t │ │ │ │ * _f_i_l_e___c_o_m_p_l_e_t_e_d___a_l_e_r_t │ │ │ │ * _f_i_l_e___r_e_n_a_m_e_d___a_l_e_r_t │ │ │ │ - o _n_e_w___n_a_m_e_(_)_ _o_l_d___n_a_m_e_(_) │ │ │ │ + o _o_l_d___n_a_m_e_(_)_ _n_e_w___n_a_m_e_(_) │ │ │ │ * _f_i_l_e___r_e_n_a_m_e___f_a_i_l_e_d___a_l_e_r_t │ │ │ │ * _p_e_r_f_o_r_m_a_n_c_e___a_l_e_r_t │ │ │ │ o _e_n_u_m_ _p_e_r_f_o_r_m_a_n_c_e___w_a_r_n_i_n_g___t │ │ │ │ * _s_t_a_t_e___c_h_a_n_g_e_d___a_l_e_r_t │ │ │ │ * _t_r_a_c_k_e_r___e_r_r_o_r___a_l_e_r_t │ │ │ │ o _f_a_i_l_u_r_e___r_e_a_s_o_n_(_) │ │ │ │ * _t_r_a_c_k_e_r___w_a_r_n_i_n_g___a_l_e_r_t │ │ │ │ @@ -513,15 +262,15 @@ │ │ │ │ o _p_k_t___b_u_f_(_) │ │ │ │ o _e_n_u_m_ _d_i_r_e_c_t_i_o_n___t │ │ │ │ * _d_h_t___g_e_t___p_e_e_r_s___r_e_p_l_y___a_l_e_r_t │ │ │ │ * _d_h_t___d_i_r_e_c_t___r_e_s_p_o_n_s_e___a_l_e_r_t │ │ │ │ * _p_i_c_k_e_r___l_o_g___a_l_e_r_t │ │ │ │ * _s_e_s_s_i_o_n___e_r_r_o_r___a_l_e_r_t │ │ │ │ * _d_h_t___l_i_v_e___n_o_d_e_s___a_l_e_r_t │ │ │ │ - o _n_u_m___n_o_d_e_s_(_)_ _n_o_d_e_s_(_) │ │ │ │ + o _n_o_d_e_s_(_)_ _n_u_m___n_o_d_e_s_(_) │ │ │ │ * _s_e_s_s_i_o_n___s_t_a_t_s___h_e_a_d_e_r___a_l_e_r_t │ │ │ │ * _d_h_t___s_a_m_p_l_e___i_n_f_o_h_a_s_h_e_s___a_l_e_r_t │ │ │ │ o _n_u_m___s_a_m_p_l_e_s_(_)_ _s_a_m_p_l_e_s_(_) │ │ │ │ o _n_u_m___n_o_d_e_s_(_) │ │ │ │ o _n_o_d_e_s_(_) │ │ │ │ * _b_l_o_c_k___u_p_l_o_a_d_e_d___a_l_e_r_t │ │ │ │ * _a_l_e_r_t_s___d_r_o_p_p_e_d___a_l_e_r_t │ │ │ │ @@ -532,56 +281,227 @@ │ │ │ │ * _p_e_e_r___i_n_f_o___a_l_e_r_t │ │ │ │ * _f_i_l_e___p_r_o_g_r_e_s_s___a_l_e_r_t │ │ │ │ * _p_i_e_c_e___i_n_f_o___a_l_e_r_t │ │ │ │ * _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y___a_l_e_r_t │ │ │ │ * _t_r_a_c_k_e_r___l_i_s_t___a_l_e_r_t │ │ │ │ * _f_i_l_e___p_r_i_o_r_i_t_i_e_s___a_l_e_r_t │ │ │ │ * _f_i_l_e___s_t_a_t_u_s___a_l_e_r_t │ │ │ │ - * _a_l_e_r_t___c_a_s_t_(_) │ │ │ │ + * _a_l_e_r_t │ │ │ │ + o _t_i_m_e_s_t_a_m_p_(_) │ │ │ │ + o _t_y_p_e_(_) │ │ │ │ + o _w_h_a_t_(_) │ │ │ │ + o _m_e_s_s_a_g_e_(_) │ │ │ │ + o _c_a_t_e_g_o_r_y_(_) │ │ │ │ * _o_p_e_r_a_t_i_o_n___n_a_m_e_(_) │ │ │ │ + * _a_l_e_r_t___c_a_s_t_(_) │ │ │ │ * _e_n_u_m_ _o_p_e_r_a_t_i_o_n___t │ │ │ │ - * _a_l_e_r_t___c_a_t_e_g_o_r_y___t │ │ │ │ * _i_n_t │ │ │ │ - * _c_o_u_n_t_e_r_s │ │ │ │ - o _i_n_c___s_t_a_t_s___c_o_u_n_t_e_r_(_) │ │ │ │ - o _o_p_e_r_a_t_o_r_[_]_(_) │ │ │ │ - o _b_l_e_n_d___s_t_a_t_s___c_o_u_n_t_e_r_(_)_ _s_e_t___v_a_l_u_e_(_) │ │ │ │ - * _s_t_a_t_s___m_e_t_r_i_c │ │ │ │ - * _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_) │ │ │ │ - * _f_i_n_d___m_e_t_r_i_c___i_d_x_(_) │ │ │ │ - * _e_n_u_m_ _m_e_t_r_i_c___t_y_p_e___t │ │ │ │ - * _i_p___f_i_l_t_e_r │ │ │ │ - o _e_m_p_t_y_(_) │ │ │ │ - o _a_d_d___r_u_l_e_(_) │ │ │ │ - o _a_c_c_e_s_s_(_) │ │ │ │ - o _e_x_p_o_r_t___f_i_l_t_e_r_(_) │ │ │ │ - o _e_n_u_m_ _a_c_c_e_s_s___f_l_a_g_s │ │ │ │ - * _p_o_r_t___f_i_l_t_e_r │ │ │ │ - o _a_d_d___r_u_l_e_(_) │ │ │ │ - o _a_c_c_e_s_s_(_) │ │ │ │ - o _e_n_u_m_ _a_c_c_e_s_s___f_l_a_g_s │ │ │ │ - * _e_n_t_r_y │ │ │ │ - o _t_y_p_e_(_) │ │ │ │ - o _e_n_t_r_y_(_) │ │ │ │ - o _e_n_t_r_y_(_) │ │ │ │ - o _e_n_t_r_y_(_) │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ - o _d_i_c_t_(_)_ _i_n_t_e_g_e_r_(_)_ _s_t_r_i_n_g_(_)_ _p_r_e_f_o_r_m_a_t_t_e_d_(_)_ _l_i_s_t_(_) │ │ │ │ - o _o_p_e_r_a_t_o_r_[_]_(_) │ │ │ │ - o _f_i_n_d___k_e_y_(_) │ │ │ │ - o _t_o___s_t_r_i_n_g_(_) │ │ │ │ - o _e_n_u_m_ _d_a_t_a___t_y_p_e │ │ │ │ - * _o_p_e_r_a_t_o_r_<_<_(_) │ │ │ │ - * _b_e_n_c_o_d_e_(_) │ │ │ │ + * _a_l_e_r_t___c_a_t_e_g_o_r_y___t │ │ │ │ + * _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_=_(_) │ │ │ │ + * _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 _p_o_s_t___t_o_r_r_e_n_t___u_p_d_a_t_e_s_(_) │ │ │ │ + o _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) │ │ │ │ + o _p_o_s_t___d_h_t___s_t_a_t_s_(_) │ │ │ │ + o _s_e_t___d_h_t___s_t_a_t_e_(_) │ │ │ │ + o _f_i_n_d___t_o_r_r_e_n_t_(_)_ _g_e_t___t_o_r_r_e_n_t_s_(_) │ │ │ │ + o _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_)_ _a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ + o _p_a_u_s_e_(_)_ _i_s___p_a_u_s_e_d_(_)_ _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___g_e_t___p_e_e_r_s_(_)_ _d_h_t___a_n_n_o_u_n_c_e_(_) │ │ │ │ + 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 _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 _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 _g_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_)_ _s_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 _r_e_m_o_v_e___t_o_r_r_e_n_t_(_) │ │ │ │ + o _g_e_t___s_e_t_t_i_n_g_s_(_)_ _a_p_p_l_y___s_e_t_t_i_n_g_s_(_) │ │ │ │ + o _p_o_p___a_l_e_r_t_s_(_)_ _w_a_i_t___f_o_r___a_l_e_r_t_(_)_ _s_e_t___a_l_e_r_t___n_o_t_i_f_y_(_) │ │ │ │ + o _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_)_ _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ + o _r_e_o_p_e_n___n_e_t_w_o_r_k___s_o_c_k_e_t_s_(_) │ │ │ │ + o _n_a_t_i_v_e___h_a_n_d_l_e_(_) │ │ │ │ + * _w_r_i_t_e___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_(_)_ _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ + * _l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s │ │ │ │ + * _t_o_r_r_e_n_t___i_n_f_o │ │ │ │ + o _t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ + o _t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ + o _~_t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ + o _l_a_y_o_u_t_(_) │ │ │ │ + o _c_o_l_l_e_c_t_i_o_n_s_(_)_ _s_i_m_i_l_a_r___t_o_r_r_e_n_t_s_(_) │ │ │ │ + o _t_o_t_a_l___s_i_z_e_(_) │ │ │ │ + o _s_i_z_e___o_n___d_i_s_k_(_) │ │ │ │ + o _n_u_m___p_i_e_c_e_s_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ + o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ + o _l_a_s_t___p_i_e_c_e_(_)_ _e_n_d___p_i_e_c_e_(_)_ _p_i_e_c_e___r_a_n_g_e_(_) │ │ │ │ + o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_) │ │ │ │ + o _v_1_(_)_ _v_2_(_) │ │ │ │ + o _n_u_m___f_i_l_e_s_(_) │ │ │ │ + o _m_a_p___b_l_o_c_k_(_) │ │ │ │ + o _m_a_p___f_i_l_e_(_) │ │ │ │ + o _s_s_l___c_e_r_t_(_) │ │ │ │ + o _i_s___v_a_l_i_d_(_) │ │ │ │ + o _p_r_i_v_(_) │ │ │ │ + o _i_s___i_2_p_(_) │ │ │ │ + o _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ + o _p_i_e_c_e___s_i_z_e___f_o_r___r_e_q_(_) │ │ │ │ + o _h_a_s_h___f_o_r___p_i_e_c_e_(_)_ _h_a_s_h___f_o_r___p_i_e_c_e___p_t_r_(_) │ │ │ │ + o _i_s___l_o_a_d_e_d_(_) │ │ │ │ + o _n_a_m_e_(_) │ │ │ │ + o _i_n_f_o___s_e_c_t_i_o_n_(_) │ │ │ │ + * _b_l_o_c_k___i_n_f_o │ │ │ │ + o _p_e_e_r_(_)_ _s_e_t___p_e_e_r_(_) │ │ │ │ + o _e_n_u_m_ _b_l_o_c_k___s_t_a_t_e___t │ │ │ │ + * _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o │ │ │ │ + * _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ + o _h_a_s_h___v_a_l_u_e_(_) │ │ │ │ + o _t_o_r_r_e_n_t___h_a_n_d_l_e_(_) │ │ │ │ + o _a_d_d___p_i_e_c_e_(_) │ │ │ │ + o _r_e_a_d___p_i_e_c_e_(_) │ │ │ │ + o _s_e_t___s_e_q_u_e_n_t_i_a_l___r_a_n_g_e_(_) │ │ │ │ + o _h_a_v_e___p_i_e_c_e_(_) │ │ │ │ + o _g_e_t___p_e_e_r___i_n_f_o_(_)_ _p_o_s_t___p_e_e_r___i_n_f_o_(_) │ │ │ │ + o _s_t_a_t_u_s_(_)_ _p_o_s_t___s_t_a_t_u_s_(_) │ │ │ │ + o _p_o_s_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)_ _g_e_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_) │ │ │ │ + o _c_l_e_a_r___p_i_e_c_e___d_e_a_d_l_i_n_e_s_(_)_ _s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_) │ │ │ │ + o _f_i_l_e___p_r_o_g_r_e_s_s_(_)_ _p_o_s_t___f_i_l_e___p_r_o_g_r_e_s_s_(_) │ │ │ │ + o _f_i_l_e___s_t_a_t_u_s_(_)_ _p_o_s_t___f_i_l_e___s_t_a_t_u_s_(_) │ │ │ │ + o _c_l_e_a_r___e_r_r_o_r_(_) │ │ │ │ + o _p_o_s_t___t_r_a_c_k_e_r_s_(_)_ _r_e_p_l_a_c_e___t_r_a_c_k_e_r_s_(_)_ _t_r_a_c_k_e_r_s_(_)_ _a_d_d___t_r_a_c_k_e_r_(_) │ │ │ │ + o _a_d_d___u_r_l___s_e_e_d_(_)_ _r_e_m_o_v_e___u_r_l___s_e_e_d_(_)_ _u_r_l___s_e_e_d_s_(_) │ │ │ │ + o _a_d_d___e_x_t_e_n_s_i_o_n_(_) │ │ │ │ + o _s_e_t___m_e_t_a_d_a_t_a_(_) │ │ │ │ + o _i_s___v_a_l_i_d_(_) │ │ │ │ + o _p_a_u_s_e_(_)_ _r_e_s_u_m_e_(_) │ │ │ │ + o _u_n_s_e_t___f_l_a_g_s_(_)_ _f_l_a_g_s_(_)_ _s_e_t___f_l_a_g_s_(_) │ │ │ │ + o _f_l_u_s_h___c_a_c_h_e_(_) │ │ │ │ + o _f_o_r_c_e___r_e_c_h_e_c_k_(_) │ │ │ │ + o _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_)_ _g_e_t___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ + o _n_e_e_d___s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ + o _q_u_e_u_e___p_o_s_i_t_i_o_n___d_o_w_n_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___u_p_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___t_o_p_(_) │ │ │ │ + _q_u_e_u_e___p_o_s_i_t_i_o_n___b_o_t_t_o_m_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n_(_) │ │ │ │ + o _q_u_e_u_e___p_o_s_i_t_i_o_n___s_e_t_(_) │ │ │ │ + o _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e___b_u_f_f_e_r_(_)_ _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e_(_) │ │ │ │ + o _t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ + o _g_e_t___r_e_n_a_m_e_d___f_i_l_e_s_(_) │ │ │ │ + o _p_i_e_c_e___l_a_y_e_r_s_(_) │ │ │ │ + o _p_o_s_t___p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)_ _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_) │ │ │ │ + o _g_e_t___p_i_e_c_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_r_i_o_r_i_t_i_z_e___p_i_e_c_e_s_(_)_ _p_i_e_c_e___p_r_i_o_r_i_t_y_(_) │ │ │ │ + o _g_e_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_)_ _f_i_l_e___p_r_i_o_r_i_t_y_(_) │ │ │ │ + o _p_o_s_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_) │ │ │ │ + o _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___l_s_d___a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___d_h_t___a_n_n_o_u_n_c_e_(_) │ │ │ │ + o _s_c_r_a_p_e___t_r_a_c_k_e_r_(_) │ │ │ │ + o _u_p_l_o_a_d___l_i_m_i_t_(_)_ _s_e_t___u_p_l_o_a_d___l_i_m_i_t_(_)_ _s_e_t___d_o_w_n_l_o_a_d___l_i_m_i_t_(_) │ │ │ │ + _d_o_w_n_l_o_a_d___l_i_m_i_t_(_) │ │ │ │ + o _c_o_n_n_e_c_t___p_e_e_r_(_) │ │ │ │ + o _c_l_e_a_r___p_e_e_r_s_(_) │ │ │ │ + o _s_e_t___m_a_x___u_p_l_o_a_d_s_(_)_ _m_a_x___u_p_l_o_a_d_s_(_) │ │ │ │ + o _s_e_t___m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)_ _m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_) │ │ │ │ + o _m_o_v_e___s_t_o_r_a_g_e_(_) │ │ │ │ + o _r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ + o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_<_(_)_ _o_p_e_r_a_t_o_r_!_=_(_)_ _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ + o _i_d_(_) │ │ │ │ + o _n_a_t_i_v_e___h_a_n_d_l_e_(_) │ │ │ │ + o _u_s_e_r_d_a_t_a_(_) │ │ │ │ + o _i_n___s_e_s_s_i_o_n_(_) │ │ │ │ + * _h_a_s_h___v_a_l_u_e_(_) │ │ │ │ + * _s_t_o_r_a_g_e___p_a_r_a_m_s │ │ │ │ + o _s_t_o_r_a_g_e___p_a_r_a_m_s_(_) │ │ │ │ + * _f_i_l_e___s_l_i_c_e │ │ │ │ + * _f_i_l_e___s_t_o_r_a_g_e │ │ │ │ + o _i_s___v_a_l_i_d_(_) │ │ │ │ + o _r_e_s_e_r_v_e_(_) │ │ │ │ + o _a_d_d___f_i_l_e___b_o_r_r_o_w_(_)_ _a_d_d___f_i_l_e_(_) │ │ │ │ + o _a_d_d___f_i_l_e___b_o_r_r_o_w_(_)_ _a_d_d___f_i_l_e_(_) │ │ │ │ + o _m_a_p___b_l_o_c_k_(_) │ │ │ │ + o _m_a_p___f_i_l_e_(_) │ │ │ │ + o _n_u_m___f_i_l_e_s_(_) │ │ │ │ + o _e_n_d___f_i_l_e_(_) │ │ │ │ + o _f_i_l_e___r_a_n_g_e_(_) │ │ │ │ + o _t_o_t_a_l___s_i_z_e_(_) │ │ │ │ + o _s_i_z_e___o_n___d_i_s_k_(_) │ │ │ │ + o _s_e_t___n_u_m___p_i_e_c_e_s_(_)_ _n_u_m___p_i_e_c_e_s_(_) │ │ │ │ + o _e_n_d___p_i_e_c_e_(_) │ │ │ │ + o _l_a_s_t___p_i_e_c_e_(_) │ │ │ │ + o _p_i_e_c_e___r_a_n_g_e_(_) │ │ │ │ + o _s_e_t___p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ + o _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ + o _p_i_e_c_e___s_i_z_e_2_(_) │ │ │ │ + o _b_l_o_c_k_s___i_n___p_i_e_c_e_2_(_) │ │ │ │ + o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ + o _n_a_m_e_(_)_ _s_e_t___n_a_m_e_(_) │ │ │ │ + o _s_w_a_p_(_) │ │ │ │ + o _f_i_l_e___o_f_f_s_e_t_(_)_ _r_o_o_t___p_t_r_(_)_ _p_a_d___f_i_l_e___a_t_(_)_ _f_i_l_e___n_a_m_e_(_)_ _f_i_l_e___p_a_t_h_(_)_ _r_o_o_t │ │ │ │ + _(_)_ _f_i_l_e___s_i_z_e_(_)_ _m_t_i_m_e_(_)_ _s_y_m_l_i_n_k_(_) │ │ │ │ + o _f_i_l_e___n_u_m___p_i_e_c_e_s_(_)_ _f_i_l_e___n_u_m___b_l_o_c_k_s_(_)_ _f_i_l_e___p_i_e_c_e___r_a_n_g_e_(_) │ │ │ │ + o _f_i_l_e___f_i_r_s_t___b_l_o_c_k___n_o_d_e_(_)_ _f_i_l_e___f_i_r_s_t___p_i_e_c_e___n_o_d_e_(_) │ │ │ │ + o _f_i_l_e___p_a_t_h___h_a_s_h_(_) │ │ │ │ + o _a_l_l___p_a_t_h___h_a_s_h_e_s_(_) │ │ │ │ + o _f_i_l_e___f_l_a_g_s_(_) │ │ │ │ + o _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ + o _l_a_s_t___f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_)_ _f_i_l_e___i_n_d_e_x___a_t___o_f_f_s_e_t_(_) │ │ │ │ + _f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_) │ │ │ │ + o _f_i_l_e___i_n_d_e_x___f_o_r___r_o_o_t_(_) │ │ │ │ + o _p_i_e_c_e___i_n_d_e_x___a_t___f_i_l_e_(_)_ _l_a_s_t___p_i_e_c_e___i_n_d_e_x___a_t___f_i_l_e_(_) │ │ │ │ + o _s_a_n_i_t_i_z_e___s_y_m_l_i_n_k_s_(_) │ │ │ │ + o _v_2_(_) │ │ │ │ + * _r_e_n_a_m_e_d___f_i_l_e_s │ │ │ │ + o _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___n_a_m_e_(_)_ _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ + o _r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ + o _e_x_p_o_r_t___f_i_l_e_n_a_m_e_s_(_)_ _i_m_p_o_r_t___f_i_l_e_n_a_m_e_s_(_) │ │ │ │ + * _f_i_l_e_n_a_m_e_s │ │ │ │ + o _f_i_l_e_n_a_m_e_s_(_) │ │ │ │ + o _f_i_l_e___f_l_a_g_s_(_) │ │ │ │ + o _e_n_d___f_i_l_e_(_) │ │ │ │ + o _p_a_d___f_i_l_e___a_t_(_) │ │ │ │ + o _f_i_l_e___s_i_z_e_(_)_ _f_i_l_e___o_f_f_s_e_t_(_) │ │ │ │ + o _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ + o _s_y_m_l_i_n_k_(_) │ │ │ │ + o _f_i_l_e___r_a_n_g_e_(_) │ │ │ │ + o _n_u_m___p_i_e_c_e_s_(_)_ _e_n_d___p_i_e_c_e_(_)_ _n_u_m___f_i_l_e_s_(_) │ │ │ │ + o _m_a_p___b_l_o_c_k_(_) │ │ │ │ + o _m_a_p___f_i_l_e_(_) │ │ │ │ + o _r_o_o_t_(_) │ │ │ │ + o _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ + * _m_m_a_p___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _d_e_f_a_u_l_t___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _d_i_s_a_b_l_e_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _e_n_u_m_ _s_t_o_r_a_g_e___m_o_d_e___t │ │ │ │ + * _e_n_u_m_ _m_o_v_e___f_l_a_g_s___t │ │ │ │ * _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_(_) │ │ │ │ @@ -594,92 +514,172 @@ │ │ │ │ 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_(_) │ │ │ │ - * _b_i_t_f_i_e_l_d │ │ │ │ - o _b_i_t_f_i_e_l_d_(_) │ │ │ │ - o _a_s_s_i_g_n_(_) │ │ │ │ - o _g_e_t___b_i_t_(_)_ _o_p_e_r_a_t_o_r_[_]_(_) │ │ │ │ - o _s_e_t___b_i_t_(_)_ _c_l_e_a_r___b_i_t_(_) │ │ │ │ - o _a_l_l___s_e_t_(_) │ │ │ │ - o _n_o_n_e___s_e_t_(_) │ │ │ │ - o _s_i_z_e_(_) │ │ │ │ - o _n_u_m___w_o_r_d_s_(_) │ │ │ │ - o _n_u_m___b_y_t_e_s_(_) │ │ │ │ + * _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 _f_i_n_d___p_l_u_g_i_n_(_)_ _a_d_d___e_x_t_e_n_s_i_o_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 _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___c_o_n_n_e_c_t_i_n_g_(_)_ _i_s___d_i_s_c_o_n_n_e_c_t_i_n_g_(_)_ _d_i_s_c_o_n_n_e_c_t_(_)_ _i_s___o_u_t_g_o_i_n_g_(_) │ │ │ │ + o _i_g_n_o_r_e___u_n_c_h_o_k_e___s_l_o_t_s_(_)_ _o_n___l_o_c_a_l___n_e_t_w_o_r_k_(_) │ │ │ │ + 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_(_) │ │ │ │ + o _o_n___u_n_k_n_o_w_n___t_o_r_r_e_n_t_(_) │ │ │ │ + o _o_n___t_i_c_k_(_) │ │ │ │ + o _g_e_t___u_n_c_h_o_k_e___p_r_i_o_r_i_t_y_(_) │ │ │ │ + o _s_a_v_e___s_t_a_t_e_(_) │ │ │ │ + o _l_o_a_d___s_t_a_t_e_(_) │ │ │ │ + * _t_o_r_r_e_n_t___p_l_u_g_i_n │ │ │ │ + o _n_e_w___c_o_n_n_e_c_t_i_o_n_(_) │ │ │ │ + o _o_n___p_i_e_c_e___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_) │ │ │ │ + o _t_i_c_k_(_) │ │ │ │ + o _o_n___p_a_u_s_e_(_)_ _o_n___r_e_s_u_m_e_(_) │ │ │ │ + o _o_n___f_i_l_e_s___c_h_e_c_k_e_d_(_) │ │ │ │ + o _o_n___s_t_a_t_e_(_) │ │ │ │ + o _o_n___a_d_d___p_e_e_r_(_) │ │ │ │ + * _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___u_n_c_h_o_k_e_(_)_ _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___r_e_q_u_e_s_t_(_) │ │ │ │ + _o_n___i_n_t_e_r_e_s_t_e_d_(_)_ _o_n___a_l_l_o_w_e_d___f_a_s_t_(_)_ _o_n___h_a_v_e_(_)_ _o_n___c_h_o_k_e_(_)_ _o_n___h_a_v_e___a_l_l │ │ │ │ + _(_)_ _o_n___b_i_t_f_i_e_l_d_(_)_ _o_n___h_a_v_e___n_o_n_e_(_) │ │ │ │ + o _o_n___p_i_e_c_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___p_i_e_c_e_(_)_ _s_e_n_t___h_a_v_e___a_l_l_(_)_ _s_e_n_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___c_a_n_c_e_l_(_) │ │ │ │ + _s_e_n_t___h_a_v_e_(_)_ _s_e_n_t___u_n_c_h_o_k_e_(_)_ _s_e_n_t___h_a_v_e___n_o_n_e_(_)_ _s_e_n_t___s_u_g_g_e_s_t_(_) │ │ │ │ + _s_e_n_t___r_e_j_e_c_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___c_h_o_k_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_(_) │ │ │ │ + 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___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_) │ │ │ │ + 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 _e_n_c_r_y_p_t_(_) │ │ │ │ + o _d_e_c_r_y_p_t_(_) │ │ │ │ + * _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_(_) │ │ │ │ + * _i_p___f_i_l_t_e_r │ │ │ │ o _e_m_p_t_y_(_) │ │ │ │ - o _d_a_t_a_(_) │ │ │ │ - o _s_w_a_p_(_) │ │ │ │ - o _c_o_u_n_t_(_) │ │ │ │ - o _f_i_n_d___f_i_r_s_t___s_e_t_(_) │ │ │ │ - o _f_i_n_d___l_a_s_t___c_l_e_a_r_(_) │ │ │ │ - * _h_a_s_h_e_r │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _h_a_s_h_e_r_(_) │ │ │ │ - o _u_p_d_a_t_e_(_) │ │ │ │ - o _f_i_n_a_l_(_) │ │ │ │ - o _r_e_s_e_t_(_) │ │ │ │ - * _h_a_s_h_e_r_2_5_6 │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _h_a_s_h_e_r_2_5_6_(_) │ │ │ │ - o _u_p_d_a_t_e_(_) │ │ │ │ - o _f_i_n_a_l_(_) │ │ │ │ - o _r_e_s_e_t_(_) │ │ │ │ - * _t_o_r_r_e_n_t___s_t_a_t_u_s │ │ │ │ - o _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ - o _e_n_u_m_ _s_t_a_t_e___t │ │ │ │ - * _a_n_n_o_u_n_c_e___i_n_f_o_h_a_s_h │ │ │ │ - * _a_n_n_o_u_n_c_e___e_n_d_p_o_i_n_t │ │ │ │ - * _a_n_n_o_u_n_c_e___e_n_t_r_y │ │ │ │ - o _~_a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _o_p_e_r_a_t_o_r_=_(_)_ _a_n_n_o_u_n_c_e___e_n_t_r_y_(_) │ │ │ │ - o _e_n_u_m_ _t_r_a_c_k_e_r___s_o_u_r_c_e │ │ │ │ - * _s_e_t_t_i_n_g_s___p_a_c_k │ │ │ │ - o _s_e_t___b_o_o_l_(_)_ _s_e_t___s_t_r_(_)_ _s_e_t___i_n_t_(_) │ │ │ │ - o _h_a_s___v_a_l_(_) │ │ │ │ - o _c_l_e_a_r_(_) │ │ │ │ - o _c_l_e_a_r_(_) │ │ │ │ - o _g_e_t___s_t_r_(_)_ _g_e_t___b_o_o_l_(_)_ _g_e_t___i_n_t_(_) │ │ │ │ - o _e_n_u_m_ _t_y_p_e___b_a_s_e_s │ │ │ │ - o _e_n_u_m_ _m_m_a_p___w_r_i_t_e___m_o_d_e___t │ │ │ │ - o _e_n_u_m_ _s_u_g_g_e_s_t___m_o_d_e___t │ │ │ │ - o _e_n_u_m_ _c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t │ │ │ │ - o _e_n_u_m_ _s_e_e_d___c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t │ │ │ │ - o _e_n_u_m_ _i_o___b_u_f_f_e_r___m_o_d_e___t │ │ │ │ - o _e_n_u_m_ _b_a_n_d_w_i_d_t_h___m_i_x_e_d___a_l_g_o___t │ │ │ │ - o _e_n_u_m_ _e_n_c___p_o_l_i_c_y │ │ │ │ - o _e_n_u_m_ _e_n_c___l_e_v_e_l │ │ │ │ - o _e_n_u_m_ _p_r_o_x_y___t_y_p_e___t │ │ │ │ - * _g_e_n_e_r_a_t_e___f_i_n_g_e_r_p_r_i_n_t_(_) │ │ │ │ - * _h_i_g_h___p_e_r_f_o_r_m_a_n_c_e___s_e_e_d_(_)_ _m_i_n___m_e_m_o_r_y___u_s_a_g_e_(_) │ │ │ │ - * _s_e_t_t_i_n_g___b_y___n_a_m_e_(_)_ _n_a_m_e___f_o_r___s_e_t_t_i_n_g_(_) │ │ │ │ - * _d_e_f_a_u_l_t___s_e_t_t_i_n_g_s_(_) │ │ │ │ + o _a_d_d___r_u_l_e_(_) │ │ │ │ + o _a_c_c_e_s_s_(_) │ │ │ │ + o _e_x_p_o_r_t___f_i_l_t_e_r_(_) │ │ │ │ + o _e_n_u_m_ _a_c_c_e_s_s___f_l_a_g_s │ │ │ │ + * _p_o_r_t___f_i_l_t_e_r │ │ │ │ + o _a_d_d___r_u_l_e_(_) │ │ │ │ + o _a_c_c_e_s_s_(_) │ │ │ │ + o _e_n_u_m_ _a_c_c_e_s_s___f_l_a_g_s │ │ │ │ * _b_d_e_c_o_d_e___n_o_d_e │ │ │ │ o _b_d_e_c_o_d_e___n_o_d_e_(_) │ │ │ │ o _o_p_e_r_a_t_o_r_=_(_)_ _b_d_e_c_o_d_e___n_o_d_e_(_) │ │ │ │ o _t_y_p_e_(_) │ │ │ │ o _b_o_o_l_(_) │ │ │ │ o _n_o_n___o_w_n_i_n_g_(_) │ │ │ │ - o _d_a_t_a___o_f_f_s_e_t_(_)_ _d_a_t_a___s_e_c_t_i_o_n_(_) │ │ │ │ - o _l_i_s_t___s_i_z_e_(_)_ _l_i_s_t___s_t_r_i_n_g___v_a_l_u_e___a_t_(_)_ _l_i_s_t___a_t_(_)_ _l_i_s_t___i_n_t___v_a_l_u_e___a_t_(_) │ │ │ │ - o _d_i_c_t___a_t_(_)_ _d_i_c_t___s_i_z_e_(_)_ _d_i_c_t___f_i_n_d___i_n_t_(_)_ _d_i_c_t___f_i_n_d___s_t_r_i_n_g___v_a_l_u_e_(_) │ │ │ │ - _d_i_c_t___f_i_n_d___i_n_t___v_a_l_u_e_(_)_ _d_i_c_t___f_i_n_d___d_i_c_t_(_)_ _d_i_c_t___a_t___n_o_d_e_(_)_ _d_i_c_t___f_i_n_d_(_) │ │ │ │ - _d_i_c_t___f_i_n_d___s_t_r_i_n_g_(_)_ _d_i_c_t___f_i_n_d___l_i_s_t_(_) │ │ │ │ + o _d_a_t_a___s_e_c_t_i_o_n_(_)_ _d_a_t_a___o_f_f_s_e_t_(_) │ │ │ │ + o _l_i_s_t___i_n_t___v_a_l_u_e___a_t_(_)_ _l_i_s_t___a_t_(_)_ _l_i_s_t___s_t_r_i_n_g___v_a_l_u_e___a_t_(_)_ _l_i_s_t___s_i_z_e_(_) │ │ │ │ + o _d_i_c_t___a_t_(_)_ _d_i_c_t___f_i_n_d___d_i_c_t_(_)_ _d_i_c_t___s_i_z_e_(_)_ _d_i_c_t___f_i_n_d_(_)_ _d_i_c_t___f_i_n_d___s_t_r_i_n_g │ │ │ │ + _(_)_ _d_i_c_t___a_t___n_o_d_e_(_)_ _d_i_c_t___f_i_n_d___i_n_t_(_)_ _d_i_c_t___f_i_n_d___i_n_t___v_a_l_u_e_(_) │ │ │ │ + _d_i_c_t___f_i_n_d___s_t_r_i_n_g___v_a_l_u_e_(_)_ _d_i_c_t___f_i_n_d___l_i_s_t_(_) │ │ │ │ o _i_n_t___v_a_l_u_e_(_) │ │ │ │ - o _s_t_r_i_n_g___o_f_f_s_e_t_(_)_ _s_t_r_i_n_g___v_a_l_u_e_(_)_ _s_t_r_i_n_g___p_t_r_(_)_ _s_t_r_i_n_g___l_e_n_g_t_h_(_) │ │ │ │ + o _s_t_r_i_n_g___o_f_f_s_e_t_(_)_ _s_t_r_i_n_g___v_a_l_u_e_(_)_ _s_t_r_i_n_g___l_e_n_g_t_h_(_)_ _s_t_r_i_n_g___p_t_r_(_) │ │ │ │ o _c_l_e_a_r_(_) │ │ │ │ o _s_w_a_p_(_) │ │ │ │ o _r_e_s_e_r_v_e_(_) │ │ │ │ o _s_w_i_t_c_h___u_n_d_e_r_l_y_i_n_g___b_u_f_f_e_r_(_) │ │ │ │ o _h_a_s___s_o_f_t___e_r_r_o_r_(_) │ │ │ │ o _e_n_u_m_ _t_y_p_e___t │ │ │ │ * _p_r_i_n_t___e_n_t_r_y_(_) │ │ │ │ * _b_d_e_c_o_d_e_(_) │ │ │ │ + * _s_t_o_r_a_g_e___e_r_r_o_r │ │ │ │ + o _b_o_o_l_(_) │ │ │ │ + o _f_i_l_e_(_) │ │ │ │ + * _p_c_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _u_p_n_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _s_o_c_k_s___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _g_z_i_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _i_2_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _b_d_e_c_o_d_e___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _l_i_b_t_o_r_r_e_n_t___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _h_t_t_p___c_a_t_e_g_o_r_y_(_) │ │ │ │ + * _e_n_u_m_ _p_c_p___e_r_r_o_r_s │ │ │ │ + * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ + * _e_n_u_m_ _s_o_c_k_s___e_r_r_o_r___c_o_d_e │ │ │ │ + * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ + * _e_n_u_m_ _i_2_p___e_r_r_o_r___c_o_d_e │ │ │ │ + * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ + * _e_n_u_m_ _e_r_r_o_r___c_o_d_e___e_n_u_m │ │ │ │ + * _e_n_u_m_ _h_t_t_p___e_r_r_o_r_s │ │ │ │ + * _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ + * _c_l_i_e_n_t___d_a_t_a___t │ │ │ │ + o _c_l_i_e_n_t___d_a_t_a___t_(_) │ │ │ │ + o _c_l_i_e_n_t___d_a_t_a___t_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ + o _T_(_)_ _g_e_t_(_) │ │ │ │ + o _c_o_n_s_t_*_(_)_ _o_p_e_r_a_t_o_r_=_(_)_ _v_o_i_d_*_(_) │ │ │ │ + * _t_o_r_r_e_n_t___s_t_a_t_u_s │ │ │ │ + o _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ + o _e_n_u_m_ _s_t_a_t_e___t │ │ │ │ + * _e_n_t_r_y │ │ │ │ + o _t_y_p_e_(_) │ │ │ │ + o _e_n_t_r_y_(_) │ │ │ │ + o _e_n_t_r_y_(_) │ │ │ │ + o _e_n_t_r_y_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ + o _i_n_t_e_g_e_r_(_)_ _s_t_r_i_n_g_(_)_ _l_i_s_t_(_)_ _p_r_e_f_o_r_m_a_t_t_e_d_(_)_ _d_i_c_t_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_[_]_(_) │ │ │ │ + o _f_i_n_d___k_e_y_(_) │ │ │ │ + o _t_o___s_t_r_i_n_g_(_) │ │ │ │ + o _e_n_u_m_ _d_a_t_a___t_y_p_e │ │ │ │ + * _b_e_n_c_o_d_e_(_) │ │ │ │ + * _o_p_e_r_a_t_o_r_<_<_(_) │ │ │ │ * _d_h_t___s_t_a_t_e │ │ │ │ o _c_l_e_a_r_(_) │ │ │ │ * _d_h_t___s_t_o_r_a_g_e___c_o_u_n_t_e_r_s │ │ │ │ o _r_e_s_e_t_(_) │ │ │ │ * _d_h_t___s_t_o_r_a_g_e___i_n_t_e_r_f_a_c_e │ │ │ │ o _u_p_d_a_t_e___n_o_d_e___i_d_s_(_) │ │ │ │ o _g_e_t___p_e_e_r_s_(_) │ │ │ │ @@ -688,1724 +688,181 @@ │ │ │ │ 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_a_d___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ * _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a___b_u_f_(_)_ _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ * _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_)_ _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e___b_u_f_(_) │ │ │ │ * _w_r_i_t_e___t_o_r_r_e_n_t___f_l_a_g_s___t │ │ │ │ * _e_d_2_5_5_1_9___c_r_e_a_t_e___s_e_e_d_(_) │ │ │ │ * _e_d_2_5_5_1_9___c_r_e_a_t_e___k_e_y_p_a_i_r_(_) │ │ │ │ * _e_d_2_5_5_1_9___s_i_g_n_(_) │ │ │ │ * _e_d_2_5_5_1_9___v_e_r_i_f_y_(_) │ │ │ │ * _e_d_2_5_5_1_9___a_d_d___s_c_a_l_a_r_(_) │ │ │ │ * _e_d_2_5_5_1_9___k_e_y___e_x_c_h_a_n_g_e_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttoorraaggee__eerrrroorr ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ -used by storage to return errors also includes which underlying file the error │ │ │ │ -happened on │ │ │ │ -struct storage_error │ │ │ │ -{ │ │ │ │ - explicit operator bbooooll () const; │ │ │ │ - void ffiillee (file_index_t f); │ │ │ │ - file_index_t ffiillee () const; │ │ │ │ - │ │ │ │ - error_code ec; │ │ │ │ - operation_t operation; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bbooooll(()) ********** │ │ │ │ -explicit operator bbooooll () const; │ │ │ │ -explicitly converts to true if this object represents an error, and false if it │ │ │ │ -does not. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee(()) ********** │ │ │ │ -void ffiillee (file_index_t f); │ │ │ │ -file_index_t ffiillee () const; │ │ │ │ -set and query the index (in the torrent) of the file this error occurred on. │ │ │ │ -This may also have special values defined in _t_o_r_r_e_n_t___s_t_a_t_u_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - ec │ │ │ │ - the error that occurred │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - operation │ │ │ │ - A code from _o_p_e_r_a_t_i_o_n___t enum, indicating what kind of operation failed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ lliibbttoorrrreenntt__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ -boost::system::error_category& lliibbttoorrrreenntt__ccaatteeggoorryy (); │ │ │ │ -return the instance of the libtorrent_error_category which maps libtorrent │ │ │ │ -error codes to human readable error messages. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhttttpp__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ -boost::system::error_category& hhttttpp__ccaatteeggoorryy (); │ │ │ │ -returns the error_category for HTTP errors │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ggzziipp__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_g_z_i_p_._h_p_p" │ │ │ │ -boost::system::error_category& ggzziipp__ccaatteeggoorryy (); │ │ │ │ -get the error_category for zip errors │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ uuppnnpp__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_u_p_n_p_._h_p_p" │ │ │ │ -boost::system::error_category& uuppnnpp__ccaatteeggoorryy (); │ │ │ │ -the boost.system error category for UPnP errors │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ii22pp__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_2_p___s_t_r_e_a_m_._h_p_p" │ │ │ │ -boost::system::error_category& ii22pp__ccaatteeggoorryy (); │ │ │ │ -returns the error category for I2P errors │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssoocckkss__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_s_5___s_t_r_e_a_m_._h_p_p" │ │ │ │ -boost::system::error_category& ssoocckkss__ccaatteeggoorryy (); │ │ │ │ -returns the error_category for SOCKS5 errors │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppccpp__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_n_a_t_p_m_p_._h_p_p" │ │ │ │ -boost::system::error_category& ppccpp__ccaatteeggoorryy (); │ │ │ │ -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. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bbddeeccooddee__ccaatteeggoorryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ -boost::system::error_category& bbddeeccooddee__ccaatteeggoorryy (); │ │ │ │ -returns the boost::system::error_category used for the bdecode_errors:: │ │ │ │ -error_code_enum errors. error_code objects produced by bdecode() use this │ │ │ │ -category. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_t_ _a_n_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|file_collision |1 |Two torrents has files which end | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_u_p_ _o_v_e_r_w_r_i_t_i_n_g_ _e_a_c_h_ _o_t_h_e_r_ _ _ _ _ _ _ _ _ | │ │ │ │ -|failed_hash_check |2 |A piece did not match its piece | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_a_s_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The .torrent file does not contain| │ │ │ │ -|torrent_is_no_dict |3 |a bencoded dictionary at its top | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_v_e_l_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_missing_info |4 |The .torrent file does not have an| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_f_o_ _d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_info_no_dict |5 |The .torrent file's info _e_n_t_r_y is | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_t_ _a_ _d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_missing_piece_length |6 |The .torrent file does not have a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_ _l_e_n_g_t_h_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_missing_name |7 |The .torrent file does not have a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_a_m_e_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_invalid_name |8 |The .torrent file's name _e_n_t_r_y is | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The length of a file, or of the | │ │ │ │ -|torrent_invalid_length |9 |whole .torrent file is invalid. | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_E_i_t_h_e_r_ _n_e_g_a_t_i_v_e_ _o_r_ _n_o_t_ _a_n_ _i_n_t_e_g_e_r_ | │ │ │ │ -|torrent_file_parse_failed |10 |Failed to parse a file _e_n_t_r_y in | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _._t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_missing_pieces |11 |The pieces field is missing or | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _i_n_ _t_h_e_ _._t_o_r_r_e_n_t_ _f_i_l_e_ _ _ _ _ _ | │ │ │ │ -|torrent_invalid_hashes |12 |The pieces string has incorrect | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_n_g_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|too_many_pieces_in_torrent |13 |The .torrent file has more pieces | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_a_n_ _i_s_ _s_u_p_p_o_r_t_e_d_ _b_y_ _l_i_b_t_o_r_r_e_n_t_ _ _ | │ │ │ │ -| | |The metadata (.torrent file) that | │ │ │ │ -|invalid_swarm_metadata |14 |was received from the swarm | │ │ │ │ -| | |matched the info-hash, but failed | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_ _b_e_ _p_a_r_s_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_bencoding |15 |The file or buffer is not | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_r_r_e_c_t_l_y_ _b_e_n_c_o_d_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|no_files_in_torrent |16 |The .torrent file does not contain| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_n_y_ _f_i_l_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_escaped_string |17 |The string was not properly url- | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_n_c_o_d_e_d_ _a_s_ _e_x_p_e_c_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|session_is_closing |18 |Operation is not permitted since | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _s_e_s_s_i_o_n_ _i_s_ _s_h_u_t_t_i_n_g_ _d_o_w_n_ _ _ _ _ _ | │ │ │ │ -| | |There's already a torrent with | │ │ │ │ -|duplicate_torrent |19 |that info-hash added to the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_s_s_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_torrent_handle |20 |The supplied _t_o_r_r_e_n_t___h_a_n_d_l_e is not| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_f_e_r_r_i_n_g_ _t_o_ _a_ _v_a_l_i_d_ _t_o_r_r_e_n_t_ _ _ _ _ _ | │ │ │ │ -|invalid_entry_type |21 |The type requested from the _e_n_t_r_y | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_i_d_ _n_o_t_ _m_a_t_c_h_ _i_t_s_ _t_y_p_e_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|missing_info_hash_in_uri |22 |The specified URI does not contain| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _v_a_l_i_d_ _i_n_f_o_-_h_a_s_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |One of the files in the torrent | │ │ │ │ -|file_too_short |23 |was unexpectedly small. This might| │ │ │ │ -| | |be caused by files being changed | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_y_ _a_n_ _e_x_t_e_r_n_a_l_ _p_r_o_c_e_s_s_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The URL used an unknown protocol. | │ │ │ │ -| | |Currently http and https (if built| │ │ │ │ -|unsupported_url_protocol |24 |with openssl support) are | │ │ │ │ -| | |recognized. For trackers udp is | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_c_o_g_n_i_z_e_d_ _a_s_ _w_e_l_l_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|url_parse_error |25 |The URL did not conform to URL | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_y_n_t_a_x_ _a_n_d_ _f_a_i_l_e_d_ _t_o_ _b_e_ _p_a_r_s_e_d_ _ _ _ | │ │ │ │ -|peer_sent_empty_piece |26 |The peer sent a piece message of | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_n_g_t_h_ _0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|parse_failed |27 |A bencoded structure was corrupt | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_n_d_ _f_a_i_l_e_d_ _t_o_ _b_e_ _p_a_r_s_e_d_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_file_tag |28 |The fast resume file was missing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _h_a_d_ _a_n_ _i_n_v_a_l_i_d_ _f_i_l_e_ _v_e_r_s_i_o_n_ _t_a_g| │ │ │ │ -|missing_info_hash |29 |The fast resume file was missing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _h_a_d_ _a_n_ _i_n_v_a_l_i_d_ _i_n_f_o_-_h_a_s_h_ _ _ _ _ _ _ | │ │ │ │ -|mismatching_info_hash |30 |The info-hash did not match the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_hostname |31 |The URL contained an invalid | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_o_s_t_n_a_m_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___p_o_r_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_2_ _ _ _|_T_h_e_ _U_R_L_ _h_a_d_ _a_n_ _i_n_v_a_l_i_d_ _p_o_r_t_ _ _ _ _ _ _ | │ │ │ │ -| | |The port is blocked by the port- | │ │ │ │ -|port_blocked |33 |filter, and prevented the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_n_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|expected_close_bracket_in_address |34 |The IPv6 address was expected to | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_n_d_ _w_i_t_h_ _"_]_"_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The torrent is being destructed, | │ │ │ │ -|destructing_torrent |35 |preventing the operation to | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_u_c_c_e_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_i_m_e_d___o_u_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_6_ _ _ _|_T_h_e_ _c_o_n_n_e_c_t_i_o_n_ _t_i_m_e_d_ _o_u_t_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer is upload only, and we | │ │ │ │ -|upload_upload_connection |37 |are upload only. There's no point | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_ _k_e_e_p_i_n_g_ _t_h_e_ _c_o_n_n_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer is upload only, and we're| │ │ │ │ -|uninteresting_upload_peer |38 |not interested in it. There's no | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_o_i_n_t_ _i_n_ _k_e_e_p_i_n_g_ _t_h_e_ _c_o_n_n_e_c_t_i_o_n_ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___i_n_f_o___h_a_s_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_9_ _ _ _|_T_h_e_ _p_e_e_r_ _s_e_n_t_ _a_n_ _u_n_k_n_o_w_n_ _i_n_f_o_-_h_a_s_h| │ │ │ │ -|torrent_paused |40 |The torrent is paused, preventing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _f_r_o_m_ _s_u_c_c_e_e_d_i_n_g_ _ _ _ _ | │ │ │ │ -| | |The peer sent an invalid have | │ │ │ │ -|invalid_have |41 |message, either wrong size or | │ │ │ │ -| | |referring to a piece that doesn't | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_i_s_t_ _i_n_ _t_h_e_ _t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_bitfield_size |42 |The _b_i_t_f_i_e_l_d message had the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_c_o_r_r_e_c_t_ _s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer kept requesting pieces | │ │ │ │ -|too_many_requests_when_choked |43 |after it was choked, possible | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_b_u_s_e_ _a_t_t_e_m_p_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer sent a piece message that| │ │ │ │ -|invalid_piece |44 |does not correspond to a piece | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_q_u_e_s_t_ _s_e_n_t_ _b_y_ _t_h_e_ _c_l_i_e_n_t_ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___m_e_m_o_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_4_5_ _ _ _|_m_e_m_o_r_y_ _a_l_l_o_c_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_aborted |46 |The torrent is aborted, preventing| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _t_o_ _s_u_c_c_e_e_d_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|self_connection |47 |The peer is a connection to | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_u_r_s_e_l_f_,_ _n_o_ _p_o_i_n_t_ _i_n_ _k_e_e_p_i_n_g_ _i_t_ _ _ | │ │ │ │ -| | |The peer sent a piece message with| │ │ │ │ -|invalid_piece_size |48 |invalid size, either negative or | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_g_r_e_a_t_e_r_ _t_h_a_n_ _o_n_e_ _b_l_o_c_k_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer has not been interesting | │ │ │ │ -|timed_out_no_interest |49 |or interested in us for too long, | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_ _p_o_i_n_t_ _i_n_ _k_e_e_p_i_n_g_ _i_t_ _a_r_o_u_n_d_ _ _ _ _ | │ │ │ │ -|timed_out_inactivity |50 |The peer has not said anything in | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _l_o_n_g_ _t_i_m_e_,_ _p_o_s_s_i_b_l_y_ _d_e_a_d_ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer did not send a handshake | │ │ │ │ -|timed_out_no_handshake |51 |within a reasonable amount of | │ │ │ │ -| | |time, it might not be a bittorrent| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_e_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer has been unchoked for too| │ │ │ │ -|timed_out_no_request |52 |long without requesting any data. | │ │ │ │ -| | |It might be lying about its | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_t_e_r_e_s_t_ _i_n_ _u_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_choke |53 |The peer sent an invalid choke | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_unchoke |54 |The peer send an invalid unchoke | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_interested |55 |The peer sent an invalid | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_t_e_r_e_s_t_e_d_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_not_interested |56 |The peer sent an invalid not- | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_t_e_r_e_s_t_e_d_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_request |57 |The peer sent an invalid piece | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_q_u_e_s_t_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer sent an invalid hash-list| │ │ │ │ -|invalid_hash_list |58 |message (this is part of the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_r_k_l_e_-_t_o_r_r_e_n_t_ _e_x_t_e_n_s_i_o_n_)_ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer sent an invalid hash- | │ │ │ │ -|invalid_hash_piece |59 |piece message (this is part of the| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_r_k_l_e_-_t_o_r_r_e_n_t_ _e_x_t_e_n_s_i_o_n_)_ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_cancel |60 |The peer sent an invalid cancel | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_dht_port |61 |The peer sent an invalid DHT port-| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_suggest |62 |The peer sent an invalid suggest | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_-_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_have_all |63 |The peer sent an invalid have all-| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_have_none |64 |The peer sent an invalid have | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_n_e_-_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_reject |65 |The peer sent an invalid reject | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_allow_fast |66 |The peer sent an invalid allow | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_a_s_t_-_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_extended |67 |The peer sent an invalid extension| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _I_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_message |68 |The peer sent an invalid message | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_I_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|sync_hash_not_found |69 |The synchronization hash was not | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_o_u_n_d_ _i_n_ _t_h_e_ _e_n_c_r_y_p_t_e_d_ _h_a_n_d_s_h_a_k_e_ _ | │ │ │ │ -|invalid_encryption_constant |70 |The encryption constant in the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_a_n_d_s_h_a_k_e_ _i_s_ _i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|no_plaintext_mode |71 |The peer does not support plain | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_e_x_t_,_ _w_h_i_c_h_ _i_s_ _t_h_e_ _s_e_l_e_c_t_e_d_ _m_o_d_e_ _ | │ │ │ │ -|no_rc4_mode |72 |The peer does not support RC4, | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_h_i_c_h_ _i_s_ _t_h_e_ _s_e_l_e_c_t_e_d_ _m_o_d_e_ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer does not support any of | │ │ │ │ -|unsupported_encryption_mode |73 |the encryption modes that the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_l_i_e_n_t_ _s_u_p_p_o_r_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer selected an encryption | │ │ │ │ -|unsupported_encryption_mode_selected|74 |mode that the client did not | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_d_v_e_r_t_i_s_e_ _a_n_d_ _d_o_e_s_ _n_o_t_ _s_u_p_p_o_r_t_ _ _ _ | │ │ │ │ -| | |The pad size used in the | │ │ │ │ -|invalid_pad_size |75 |encryption handshake is of invalid| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_encrypt_handshake |76 |The encryption handshake is | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The client is set to not support | │ │ │ │ -|no_incoming_encrypted |77 |incoming encrypted connections and| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_i_s_ _i_s_ _a_n_ _e_n_c_r_y_p_t_e_d_ _c_o_n_n_e_c_t_i_o_n_ _ _ | │ │ │ │ -| | |The client is set to not support | │ │ │ │ -|no_incoming_regular |78 |incoming regular bittorrent | │ │ │ │ -| | |connections, and this is a regular| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_n_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|duplicate_peer_id |79 |The client is already connected to| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_i_s_ _p_e_e_r_-_I_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_o_r_r_e_n_t___r_e_m_o_v_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_0_ _ _ _|_T_o_r_r_e_n_t_ _w_a_s_ _r_e_m_o_v_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|packet_too_large |81 |The packet size exceeded the upper| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_a_n_i_t_y_ _c_h_e_c_k_-_l_i_m_i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_s_e_r_v_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_2_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|http_error |83 |The web server responded with an | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|missing_location |84 |The web server response is missing| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _l_o_c_a_t_i_o_n_ _h_e_a_d_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The web seed redirected to a path | │ │ │ │ -|invalid_redirection |85 |that no longer matches the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_._t_o_r_r_e_n_t_ _d_i_r_e_c_t_o_r_y_ _s_t_r_u_c_t_u_r_e_ _ _ _ _ _ | │ │ │ │ -|redirecting |86 |The connection was closed because | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_t_ _r_e_d_i_r_e_c_t_e_d_ _t_o_ _a_ _d_i_f_f_e_r_e_n_t_ _U_R_L_ _ | │ │ │ │ -|_i_n_v_a_l_i_d___r_a_n_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_7_ _ _ _|_T_h_e_ _H_T_T_P_ _r_a_n_g_e_ _h_e_a_d_e_r_ _i_s_ _i_n_v_a_l_i_d_ _ | │ │ │ │ -|no_content_length |88 |The HTTP response did not have a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_t_e_n_t_ _l_e_n_g_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_b_a_n_n_e_d___b_y___i_p___f_i_l_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_9_ _ _ _|_T_h_e_ _I_P_ _i_s_ _b_l_o_c_k_e_d_ _b_y_ _t_h_e_ _I_P_ _f_i_l_t_e_r| │ │ │ │ -|_t_o_o___m_a_n_y___c_o_n_n_e_c_t_i_o_n_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_0_ _ _ _|_A_t_ _t_h_e_ _c_o_n_n_e_c_t_i_o_n_ _l_i_m_i_t_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_e_e_r___b_a_n_n_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_1_ _ _ _|_T_h_e_ _p_e_e_r_ _i_s_ _m_a_r_k_e_d_ _a_s_ _b_a_n_n_e_d_ _ _ _ _ _ | │ │ │ │ -|stopping_torrent |92 |The torrent is stopping, causing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _t_o_ _f_a_i_l_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|too_many_corrupt_pieces |93 |The peer has sent too many corrupt| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_s_ _a_n_d_ _i_s_ _b_a_n_n_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_not_ready |94 |The torrent is not ready to | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_c_e_i_v_e_ _p_e_e_r_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|peer_not_constructed |95 |The peer is not completely | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_s_t_r_u_c_t_e_d_ _y_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|session_closing |96 |The _s_e_s_s_i_o_n is closing, causing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _t_o_ _f_a_i_l_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer was disconnected in order| │ │ │ │ -|optimistic_disconnect |97 |to leave room for a potentially | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_e_t_t_e_r_ _p_e_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_o_r_r_e_n_t___f_i_n_i_s_h_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_8_ _ _ _|_T_h_e_ _t_o_r_r_e_n_t_ _i_s_ _f_i_n_i_s_h_e_d_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___r_o_u_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_9_ _ _ _|_N_o_ _U_P_n_P_ _r_o_u_t_e_r_ _f_o_u_n_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|metadata_too_large |100 |The metadata message says the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_t_a_d_a_t_a_ _e_x_c_e_e_d_s_ _t_h_e_ _l_i_m_i_t_ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_metadata_request |101 |The peer sent an invalid metadata | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_q_u_e_s_t_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_metadata_size |102 |The peer advertised an invalid | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_t_a_d_a_t_a_ _s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_metadata_offset |103 |The peer sent a message with an | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _m_e_t_a_d_a_t_a_ _o_f_f_s_e_t_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_metadata_message |104 |The peer sent an invalid metadata | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|pex_message_too_large |105 |The peer sent a peer exchange | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _t_h_a_t_ _w_a_s_ _t_o_o_ _l_a_r_g_e_ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_pex_message |106 |The peer sent an invalid peer | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_c_h_a_n_g_e_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_lt_tracker_message |107 |The peer sent an invalid tracker | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_c_h_a_n_g_e_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer sent an pex messages too | │ │ │ │ -|too_frequent_pex |108 |often. This is a possible attempt | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_f_ _a_n_d_ _a_t_t_a_c_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The operation failed because it | │ │ │ │ -| | |requires the torrent to have the | │ │ │ │ -| | |metadata (.torrent file) and it | │ │ │ │ -|no_metadata |109 |doesn't have it yet. This happens | │ │ │ │ -| | |for magnet links before they have | │ │ │ │ -| | |downloaded the metadata, and also | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_r_r_e_n_t_s_ _a_d_d_e_d_ _b_y_ _U_R_L_._ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer sent an invalid dont_have| │ │ │ │ -| | |message. The don't have message is| │ │ │ │ -|invalid_dont_have |110 |an extension to allow peers to | │ │ │ │ -| | |advertise that the no longer has a| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_ _t_h_e_y_ _p_r_e_v_i_o_u_s_l_y_ _h_a_d_._ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer tried to connect to an | │ │ │ │ -|requires_ssl_connection |111 |SSL torrent without connecting | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_v_e_r_ _S_S_L_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The peer tried to connect to a | │ │ │ │ -|invalid_ssl_cert |112 |torrent with a certificate for a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_i_f_f_e_r_e_n_t_ _t_o_r_r_e_n_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |the torrent is not an SSL torrent,| │ │ │ │ -|not_an_ssl_torrent |113 |and the operation requires an SSL | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |peer was banned because its listen| │ │ │ │ -|banned_by_port_filter |114 |port is within a banned port | │ │ │ │ -| | |range, as specified by the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_o_r_t___f_i_l_t_e_r_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_session_handle |115 |The _s_e_s_s_i_o_n___h_a_n_d_l_e is not | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_f_e_r_r_i_n_g_ _t_o_ _a_ _v_a_l_i_d_ _s_e_s_s_i_o_n___i_m_p_l_ | │ │ │ │ -|invalid_listen_socket |116 |the listen socket associated with | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_i_s_ _r_e_q_u_e_s_t_ _w_a_s_ _c_l_o_s_e_d_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___h_a_s_h___r_e_q_u_e_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_7_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___h_a_s_h_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_8_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___h_a_s_h___r_e_j_e_c_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_9_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___1_2_0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___1_2_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___1_2_2_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___1_2_3_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_3_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___1_2_4_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|missing_file_sizes |130 |The resume data file is missing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _f_i_l_e_ _s_i_z_e_s_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|no_files_in_resume_data |131 |The resume data file file sizes | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_n_t_r_y_ _i_s_ _e_m_p_t_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|missing_pieces |132 |The resume data file is missing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _p_i_e_c_e_s_ _a_n_d_ _s_l_o_t_s_ _e_n_t_r_y_ _ _ _ _ _ _ _ | │ │ │ │ -| | |The number of files in the resume | │ │ │ │ -|mismatching_number_of_files |133 |data does not match the number of | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_i_l_e_s_ _i_n_ _t_h_e_ _t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |One of the files on disk has a | │ │ │ │ -|mismatching_file_size |134 |different size than in the fast | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_s_u_m_e_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |One of the files on disk has a | │ │ │ │ -|mismatching_file_timestamp |135 |different timestamp than in the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_a_s_t_ _r_e_s_u_m_e_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|not_a_dictionary |136 |The resume data file is not a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_blocks_per_piece |137 |The blocks per piece _e_n_t_r_y is | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _i_n_ _t_h_e_ _r_e_s_u_m_e_ _d_a_t_a_ _f_i_l_e_ _ _ | │ │ │ │ -| | |The resume file is missing the | │ │ │ │ -|missing_slots |138 |slots _e_n_t_r_y, which is required for| │ │ │ │ -| | |torrents with compact allocation. | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_DD_EE_PP_RR_EE_CC_AA_TT_EE_DD_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|too_many_slots |139 |The resume file contains more | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_l_o_t_s_ _t_h_a_n_ _t_h_e_ _t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_slot_list |140 |The slot _e_n_t_r_y is invalid in the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_s_u_m_e_ _d_a_t_a_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_piece_index |141 |One index in the slot list is | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The pieces on disk needs to be re-| │ │ │ │ -| | |ordered for the specified | │ │ │ │ -| | |allocation mode. This happens if | │ │ │ │ -|pieces_need_reorder |142 |you specify sparse allocation and | │ │ │ │ -| | |the files on disk are using | │ │ │ │ -| | |compact storage. The pieces needs | │ │ │ │ -| | |to be moved to their right | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_o_s_i_t_i_o_n_._ _DD_EE_PP_RR_EE_CC_AA_TT_EE_DD_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |this error is returned when asking| │ │ │ │ -| | |to save resume data and specifying| │ │ │ │ -|resume_data_not_modified |143 |the flag to only save when there's| │ │ │ │ -| | |anything new to save | │ │ │ │ -| | |(_t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_o_n_l_y___i_f___m_o_d_i_f_i_e_d)| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_n_d_ _t_h_e_r_e_ _w_a_s_n_'_t_ _a_n_y_t_h_i_n_g_ _c_h_a_n_g_e_d_.| │ │ │ │ -|invalid_save_path |144 |the save_path in | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s_ _i_s_ _n_o_t_ _v_a_l_i_d_ _ _ | │ │ │ │ -| | |The torrent contained too many | │ │ │ │ -|too_many_duplicate_filenames |145 |duplicate _f_i_l_e_n_a_m_e_s, exceeding the| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_f_i_g_u_r_e_d_ _l_i_m_i_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|http_parse_error |150 |The HTTP header was not correctly | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_o_r_m_a_t_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The HTTP response was in the 300- | │ │ │ │ -|http_missing_location |151 |399 range but lacked a location | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_e_a_d_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The HTTP response was encoded with| │ │ │ │ -|http_failed_decompress |152 |gzip or deflate but decompressing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|no_i2p_router |160 |The URL specified an i2p address, | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_u_t_ _n_o_ _i_2_p_ _r_o_u_t_e_r_ _i_s_ _c_o_n_f_i_g_u_r_e_d_ _ _ | │ │ │ │ -|no_i2p_endpoint |161 |i2p acceptor is not available yet,| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_n_'_t_ _a_n_n_o_u_n_c_e_ _w_i_t_h_o_u_t_ _e_n_d_p_o_i_n_t_ _ _ | │ │ │ │ -| | |The tracker URL doesn't support | │ │ │ │ -|scrape_not_available |170 |transforming it into a scrape URL.| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_._e_._ _i_t_ _d_o_e_s_n_'_t_ _c_o_n_t_a_i_n_ _"_a_n_n_o_u_n_c_e_.| │ │ │ │ -|_i_n_v_a_l_i_d___t_r_a_c_k_e_r___r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_1_ _ _|_i_n_v_a_l_i_d_ _t_r_a_c_k_e_r_ _r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_peer_dict |172 |invalid peer dictionary _e_n_t_r_y. Not| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_r_a_c_k_e_r___f_a_i_l_u_r_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_3_ _ _|_t_r_a_c_k_e_r_ _s_e_n_t_ _a_ _f_a_i_l_u_r_e_ _m_e_s_s_a_g_e_ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___f_i_l_e_s___e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_4_ _ _|_m_i_s_s_i_n_g_ _o_r_ _i_n_v_a_l_i_d_ _f_i_l_e_s_ _e_n_t_r_y_ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___h_a_s_h___e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_5_ _ _|_m_i_s_s_i_n_g_ _o_r_ _i_n_v_a_l_i_d_ _h_a_s_h_ _e_n_t_r_y_ _ _ _ _ | │ │ │ │ -|invalid_peers_entry |176 |missing or invalid peers and | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_e_e_r_s_6_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_tracker_response_length |177 |UDP tracker response packet has | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_tracker_transaction_id |178 |invalid transaction id in UDP | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_a_c_k_e_r_ _r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_tracker_action |179 |invalid action field in UDP | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_a_c_k_e_r_ _r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |skipped announce (because it's | │ │ │ │ -|announce_skipped |180 |assumed to be unreachable over the| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_g_i_v_e_n_ _s_o_u_r_c_e_ _n_e_t_w_o_r_k_ _i_n_t_e_r_f_a_c_e_)_ _ _ | │ │ │ │ -|_n_o___e_n_t_r_o_p_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_0_ _ _|_r_a_n_d_o_m_ _n_u_m_b_e_r_ _g_e_n_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ | │ │ │ │ -|_s_s_r_f___m_i_t_i_g_a_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_1_ _ _|_b_l_o_c_k_e_d_ _b_y_ _S_S_R_F_ _m_i_t_i_g_a_t_i_o_n_ _ _ _ _ _ _ _ | │ │ │ │ -|blocked_by_idna |202 |blocked because IDNA host names | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_r_e_ _b_a_n_n_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_unknown_version |210 |the torrent file has an unknown | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_t_a_ _v_e_r_s_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_missing_file_tree |211 |the v2 torrent file has no file | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_e_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_missing_meta_version |212 |the torrent contains v2 keys but | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_o_e_s_ _n_o_t_ _s_p_e_c_i_f_y_ _m_e_t_a_ _v_e_r_s_i_o_n_ _2_ _ _ | │ │ │ │ -|torrent_inconsistent_files |213 |the v1 and v2 file metadata does | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_t_ _m_a_t_c_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_missing_piece_layer |214 |one or more files are missing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_ _l_a_y_e_r_ _h_a_s_h_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_invalid_piece_layer |215 |a piece layer has the wrong size | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _f_a_i_l_e_d_ _h_a_s_h_ _c_h_e_c_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_o_r_r_e_n_t___m_i_s_s_i_n_g___p_i_e_c_e_s___r_o_o_t_ _ _ _ _ _ _ _ _ _|_2_1_6_ _ _|_a_ _v_2_ _f_i_l_e_ _e_n_t_r_y_ _h_a_s_ _n_o_ _r_o_o_t_ _h_a_s_h_ _ | │ │ │ │ -|torrent_inconsistent_hashes |217 |the v1 and v2 hashes do not | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_e_s_c_r_i_b_e_ _t_h_e_ _s_a_m_e_ _d_a_t_a_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|torrent_invalid_pad_file |218 |a file in the v2 metadata has the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_a_d_ _a_t_t_r_i_b_u_t_e_ _s_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |the directory structure of files | │ │ │ │ -|torrent_directory_too_deep |219 |in the torrent exceeds the | │ │ │ │ -| | |configured maximum depth (see | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_e_r_r_o_r___c_o_d_e___m_a_x_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_2_0_ _ _|_t_h_e_ _n_u_m_b_e_r_ _o_f_ _e_r_r_o_r_ _c_o_d_e_s_ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm hhttttpp__eerrrroorrss ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_c_o_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_o_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_c_r_e_a_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_a_c_c_e_p_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___c_o_n_t_e_n_t_ _ _ _ _ _ _ _ _ _ _ _|_2_0_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_m_u_l_t_i_p_l_e___c_h_o_i_c_e_s_ _ _ _ _ _|_3_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_m_o_v_e_d___p_e_r_m_a_n_e_n_t_l_y_ _ _ _ _|_3_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_m_o_v_e_d___t_e_m_p_o_r_a_r_i_l_y_ _ _ _ _|_3_0_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o_t___m_o_d_i_f_i_e_d_ _ _ _ _ _ _ _ _ _|_3_0_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_b_a_d___r_e_q_u_e_s_t_ _ _ _ _ _ _ _ _ _ _|_4_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_n_a_u_t_h_o_r_i_z_e_d_ _ _ _ _ _ _ _ _ _|_4_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_o_r_b_i_d_d_e_n_ _ _ _ _ _ _ _ _ _ _ _ _|_4_0_3_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o_t___f_o_u_n_d_ _ _ _ _ _ _ _ _ _ _ _ _|_4_0_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_t_e_r_n_a_l___s_e_r_v_e_r___e_r_r_o_r_|_5_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o_t___i_m_p_l_e_m_e_n_t_e_d_ _ _ _ _ _ _|_5_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_b_a_d___g_a_t_e_w_a_y_ _ _ _ _ _ _ _ _ _ _|_5_0_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_e_r_v_i_c_e___u_n_a_v_a_i_l_a_b_l_e_ _ _|_5_0_3_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_g_z_i_p_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_t_ _a_n_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_gzip_header |1 |the supplied gzip buffer has | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _h_e_a_d_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |the gzip buffer would inflate to | │ │ │ │ -|inflated_data_too_large |2 |more bytes than the specified | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_x_i_m_u_m_ _s_i_z_e_,_ _a_n_d_ _w_a_s_ _r_e_j_e_c_t_e_d_._ _ _ _ | │ │ │ │ -|data_did_not_terminate |3 |available inflate data did not | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_e_r_m_i_n_a_t_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|space_exhausted |4 |output space exhausted before | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_m_p_l_e_t_i_n_g_ _i_n_f_l_a_t_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___b_l_o_c_k___t_y_p_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_i_n_v_a_l_i_d_ _b_l_o_c_k_ _t_y_p_e_ _(_t_y_p_e_ _=_=_ _3_)_ _ _ _ _ | │ │ │ │ -|invalid_stored_block_length |6 |stored block length did not match | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_n_e_'_s_ _c_o_m_p_l_e_m_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|too_many_length_or_distance_codes |7 |dynamic block code description: too| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_n_y_ _l_e_n_g_t_h_ _o_r_ _d_i_s_t_a_n_c_e_ _c_o_d_e_s_ _ _ _ _ _ | │ │ │ │ -|code_lengths_codes_incomplete |8 |dynamic block code description: | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_d_e_ _l_e_n_g_t_h_s_ _c_o_d_e_s_ _i_n_c_o_m_p_l_e_t_e_ _ _ _ _ _ | │ │ │ │ -|repeat_lengths_with_no_first_length|9 |dynamic block code description: | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_p_e_a_t_ _l_e_n_g_t_h_s_ _w_i_t_h_ _n_o_ _f_i_r_s_t_ _l_e_n_g_t_h| │ │ │ │ -|repeat_more_than_specified_lengths |10 |dynamic block code description: | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_p_e_a_t_ _m_o_r_e_ _t_h_a_n_ _s_p_e_c_i_f_i_e_d_ _l_e_n_g_t_h_s_ | │ │ │ │ -|invalid_literal_length_code_lengths|11 |dynamic block code description: | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _l_i_t_e_r_a_l_/_l_e_n_g_t_h_ _c_o_d_e_ _l_e_n_g_t_h_s| │ │ │ │ -|invalid_distance_code_lengths |12 |dynamic block code description: | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _d_i_s_t_a_n_c_e_ _c_o_d_e_ _l_e_n_g_t_h_s_ _ _ _ _ _ | │ │ │ │ -|invalid_literal_code_in_block |13 |invalid literal/length or distance | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_d_e_ _i_n_ _f_i_x_e_d_ _o_r_ _d_y_n_a_m_i_c_ _b_l_o_c_k_ _ _ _ _ | │ │ │ │ -|distance_too_far_back_in_block |14 |distance is too far back in fixed | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _d_y_n_a_m_i_c_ _b_l_o_c_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|unknown_gzip_error |15 |an unknown error occurred during | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_g_z_i_p_ _i_n_f_l_a_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_e_r_r_o_r___c_o_d_e___m_a_x_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_6_ _ _ _|_t_h_e_ _n_u_m_b_e_r_ _o_f_ _e_r_r_o_r_ _c_o_d_e_s_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_u_p_n_p_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|invalid_argument |402 |One of the arguments in the request | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_s_ _i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_a_c_t_i_o_n___f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_5_0_1_ _ _|_T_h_e_ _r_e_q_u_e_s_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|value_not_in_array |714 |The specified value does not exist | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_ _t_h_e_ _a_r_r_a_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The source IP address cannot be | │ │ │ │ -|source_ip_cannot_be_wildcarded |715 |wild-carded, but must be fully | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_p_e_c_i_f_i_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|external_port_cannot_be_wildcarded|716 |The external port cannot be a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_i_l_d_c_a_r_d_,_ _b_u_t_ _m_u_s_t_ _b_e_ _s_p_e_c_i_f_i_e_d_ _ _ _ _ | │ │ │ │ -| | |The port mapping _e_n_t_r_y specified | │ │ │ │ -|port_mapping_conflict |718 |conflicts with a mapping assigned | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_r_e_v_i_o_u_s_l_y_ _t_o_ _a_n_o_t_h_e_r_ _c_l_i_e_n_t_ _ _ _ _ _ _ _ | │ │ │ │ -|internal_port_must_match_external |724 |Internal and external port value | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_u_s_t_ _b_e_ _t_h_e_ _s_a_m_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The NAT implementation only supports| │ │ │ │ -|only_permanent_leases_supported |725 |permanent lease times on port | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_p_p_i_n_g_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |RemoteHost must be a wildcard and | │ │ │ │ -|remote_host_must_be_wildcard |726 |cannot be a specific IP address or | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_D_N_S_ _n_a_m_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|external_port_must_be_wildcard |727 |ExternalPort must be a wildcard and | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_n_n_o_t_ _b_e_ _a_ _s_p_e_c_i_f_i_c_ _p_o_r_t_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm ii22pp__eerrrroorr__ccooddee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_2_p___s_t_r_e_a_m_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_a_r_s_e___f_a_i_l_e_d_ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_c_a_n_t___r_e_a_c_h___p_e_e_r_|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_2_p___e_r_r_o_r_ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___k_e_y_ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___i_d_ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_i_m_e_o_u_t_ _ _ _ _ _ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_k_e_y___n_o_t___f_o_u_n_d_ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_u_p_l_i_c_a_t_e_d___i_d_ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_u_m___e_r_r_o_r_s_ _ _ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm ssoocckkss__eerrrroorr__ccooddee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_s_5___s_t_r_e_a_m_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_n_s_u_p_p_o_r_t_e_d___v_e_r_s_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_n_s_u_p_p_o_r_t_e_d___a_u_t_h_e_n_t_i_c_a_t_i_o_n___m_e_t_h_o_d_ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_n_s_u_p_p_o_r_t_e_d___a_u_t_h_e_n_t_i_c_a_t_i_o_n___v_e_r_s_i_o_n_|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_a_u_t_h_e_n_t_i_c_a_t_i_o_n___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_s_e_r_n_a_m_e___r_e_q_u_i_r_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_g_e_n_e_r_a_l___f_a_i_l_u_r_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_c_o_m_m_a_n_d___n_o_t___s_u_p_p_o_r_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___i_d_e_n_t_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_d_e_n_t_d___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_u_m___e_r_r_o_r_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm ppccpp__eerrrroorrss ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_n_a_t_p_m_p_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_p_c_p___s_u_c_c_e_s_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___u_n_s_u_p_p___v_e_r_s_i_o_n_ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___n_o_t___a_u_t_h_o_r_i_z_e_d_ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___m_a_l_f_o_r_m_e_d___r_e_q_u_e_s_t_ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___u_n_s_u_p_p___o_p_c_o_d_e_ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___u_n_s_u_p_p___o_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___m_a_l_f_o_r_m_e_d___o_p_t_i_o_n_ _ _ _ _ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___n_e_t_w_o_r_k___f_a_i_l_u_r_e_ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___n_o___r_e_s_o_u_r_c_e_s_ _ _ _ _ _ _ _ _ _ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___u_n_s_u_p_p___p_r_o_t_o_c_o_l_ _ _ _ _ _ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___u_s_e_r___e_x___q_u_o_t_a_ _ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___c_a_n_n_o_t___p_r_o_v_i_d_e___e_x_t_e_r_n_a_l_|_1_1_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___a_d_d_r_e_s_s___m_i_s_m_a_t_c_h_ _ _ _ _ _ _ _|_1_2_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_c_p___e_x_c_e_s_s_i_v_e___r_e_m_o_t_e___p_e_e_r_s_ _|_1_3_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___e_r_r_o_r_ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_t_ _a_n_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_e_x_p_e_c_t_e_d___d_i_g_i_t_|_1_ _ _ _ _|_e_x_p_e_c_t_e_d_ _d_i_g_i_t_ _i_n_ _b_e_n_c_o_d_e_d_ _s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_e_x_p_e_c_t_e_d___c_o_l_o_n_|_2_ _ _ _ _|_e_x_p_e_c_t_e_d_ _c_o_l_o_n_ _i_n_ _b_e_n_c_o_d_e_d_ _s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_n_e_x_p_e_c_t_e_d___e_o_f_|_3_ _ _ _ _|_u_n_e_x_p_e_c_t_e_d_ _e_n_d_ _o_f_ _f_i_l_e_ _i_n_ _b_e_n_c_o_d_e_d_ _s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|expected_value|4 |expected value (list, dict, _i_n_t or string) in bencoded| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_t_h___e_x_c_e_e_d_e_d_|_5_ _ _ _ _|_b_e_n_c_o_d_e_d_ _r_e_c_u_r_s_i_o_n_ _d_e_p_t_h_ _l_i_m_i_t_ _e_x_c_e_e_d_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_l_i_m_i_t___e_x_c_e_e_d_e_d_|_6_ _ _ _ _|_b_e_n_c_o_d_e_d_ _i_t_e_m_ _c_o_u_n_t_ _l_i_m_i_t_ _e_x_c_e_e_d_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_o_v_e_r_f_l_o_w_ _ _ _ _ _ _|_7_ _ _ _ _|_i_n_t_e_g_e_r_ _o_v_e_r_f_l_o_w_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_e_r_r_o_r___c_o_d_e___m_a_x_|_8_ _ _ _ _|_t_h_e_ _n_u_m_b_e_r_ _o_f_ _e_r_r_o_r_ _c_o_d_e_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 │ │ │ │ +************ 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 │ │ │ │ { │ │ │ │ - sseessssiioonn__ppaarraammss (); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ - , std::vector> exts); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ - , std::vector> exts); │ │ │ │ + wweebb__sseeeedd__eennttrryy (web_seed_entry&&) noexcept; │ │ │ │ + web_seed_entry& ooppeerraattoorr== (web_seed_entry const&); │ │ │ │ + web_seed_entry& ooppeerraattoorr== (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; │ │ │ │ │ │ │ │ - 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 const& sp); │ │ │ │ -sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ -This constructor can be used to start with the default plugins (ut_metadata, │ │ │ │ -ut_pex and smart_ban). Pass a _s_e_t_t_i_n_g_s___p_a_c_k to set the initial settings when │ │ │ │ -the _s_e_s_s_i_o_n starts. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseessssiioonn__ppaarraammss(()) ********** │ │ │ │ -sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ - , std::vector> exts); │ │ │ │ -sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ - , std::vector> exts); │ │ │ │ -This constructor helps to configure the set of initial plugins to be added to │ │ │ │ -the _s_e_s_s_i_o_n before it's started. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - settings │ │ │ │ - The settings to configure the _s_e_s_s_i_o_n with │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flags │ │ │ │ - specifies flags affecting the _s_e_s_s_i_o_n construction. E.g. they can be used │ │ │ │ - to start a _s_e_s_s_i_o_n in paused mode (by passing in session::paused). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - extensions │ │ │ │ - the plugins to add to the _s_e_s_s_i_o_n as it is constructed │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - dht_state │ │ │ │ - DHT node ID and node addresses to bootstrap the DHT with. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - dht_storage_constructor │ │ │ │ - function object to construct the storage object for DHT items. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - disk_io_constructor │ │ │ │ - function object to create the disk I/O subsystem. Defaults to │ │ │ │ - default_disk_io_constructor, which is implied by leaving the field │ │ │ │ - default initialized. Built-in options are: │ │ │ │ - * mmap_disk_io_constructor. Multi-threaded disk I/O using memory │ │ │ │ - mapped files │ │ │ │ - * posix_disk_io_constructor. Single-threaded simple portable disk I/O │ │ │ │ - * disabled_disk_io_constructor. Throws away all data and reads │ │ │ │ - garbage. │ │ │ │ - Useful for testing and benchmarking. │ │ │ │ - * pread_disk_io_constructor (experimental). Multi-threaded disk I/ │ │ │ │ - O using preadv/pwritev with a write cache. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - ext_state │ │ │ │ - this container can be used by extensions/plugins to store settings. It's │ │ │ │ - primarily here to make it convenient to save and restore state across │ │ │ │ - sessions, using _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) and _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - ip_filter │ │ │ │ - the IP filter to use for the _s_e_s_s_i_o_n. This restricts which peers are │ │ │ │ - allowed to connect. As if passed to _s_e_t___i_p___f_i_l_t_e_r_(_). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseessssiioonn__pprrooxxyy ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -this is a holder for the internal _s_e_s_s_i_o_n implementation object. Once the │ │ │ │ -_s_e_s_s_i_o_n destruction is explicitly initiated, this holder is used to synchronize │ │ │ │ -the completion of the shutdown. The lifetime of this object may outlive │ │ │ │ -_s_e_s_s_i_o_n, causing the _s_e_s_s_i_o_n destructor to not block. The _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ -destructor will block however, until the underlying _s_e_s_s_i_o_n is done shutting │ │ │ │ -down. │ │ │ │ -struct session_proxy │ │ │ │ -{ │ │ │ │ - ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ - session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ - session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ - sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ - sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ - sseessssiioonn__pprrooxxyy (); │ │ │ │ + std::string url; │ │ │ │ + std::string auth; │ │ │ │ + headers_t extra_headers; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) sseessssiioonn__pprrooxxyy(()) ~~sseessssiioonn__pprrooxxyy(()) ********** │ │ │ │ -~~sseessssiioonn__pprrooxxyy (); │ │ │ │ -session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ -session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ -sseessssiioonn__pprrooxxyy (); │ │ │ │ -default constructor, does not refer to any _s_e_s_s_i_o_n implementation object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseessssiioonn ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -The _s_e_s_s_i_o_n holds all state that spans multiple torrents. Among other things it │ │ │ │ -runs the network loop and manages all torrents. Once it's created, the _s_e_s_s_i_o_n │ │ │ │ -object will spawn the main thread that will do all the work. The main thread │ │ │ │ -will be idle as long it doesn't have any torrents to participate in. │ │ │ │ -You have some control over _s_e_s_s_i_o_n configuration through the session_handle:: │ │ │ │ -apply_settings() member function. To change one or more configuration options, │ │ │ │ -create a _s_e_t_t_i_n_g_s___p_a_c_k. object and fill it with the settings to be set and pass │ │ │ │ -it in to session::apply_settings(). │ │ │ │ -see _a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ -struct session : session_handle │ │ │ │ -{ │ │ │ │ - sseessssiioonn (); │ │ │ │ - explicit sseessssiioonn (session_params&& params); │ │ │ │ - explicit sseessssiioonn (session_params const& params); │ │ │ │ - sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ - sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ - ~~sseessssiioonn (); │ │ │ │ - session_proxy aabboorrtt (); │ │ │ │ -}; │ │ │ │ +********** ooppeerraattoorr====(()) ********** │ │ │ │ +bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ +URL and type comparison │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseessssiioonn(()) ********** │ │ │ │ -sseessssiioonn (); │ │ │ │ -explicit sseessssiioonn (session_params&& params); │ │ │ │ -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. │ │ │ │ +********** 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] │ │ │ │ -********** sseessssiioonn(()) ********** │ │ │ │ -sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ -sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ -Overload of the constructor that takes an external io_context to run the │ │ │ │ -_s_e_s_s_i_o_n object on. This is primarily useful for tests that may want to run │ │ │ │ -multiple sessions on a single io_context, or low resource systems where │ │ │ │ -additional threads are expensive and sharing an io_context with other events is │ │ │ │ -fine. │ │ │ │ -Warning │ │ │ │ -The _s_e_s_s_i_o_n object does not cleanly terminate with an external io_context. The │ │ │ │ -io_context::run() call mmuusstt have returned before it's safe to destruct the │ │ │ │ -_s_e_s_s_i_o_n. Which means you MMUUSSTT call _s_e_s_s_i_o_n_:_:_a_b_o_r_t_(_) and save the _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ -first, then destruct the _s_e_s_s_i_o_n object, then sync with the io_context, then │ │ │ │ -destruct the _s_e_s_s_i_o_n___p_r_o_x_y object. │ │ │ │ + url │ │ │ │ + The URL of the web seed │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~sseessssiioonn(()) ********** │ │ │ │ -~~sseessssiioonn (); │ │ │ │ -The destructor of _s_e_s_s_i_o_n will notify all trackers that our torrents have been │ │ │ │ -shut down. If some trackers are down, they will time out. All this before the │ │ │ │ -destructor of _s_e_s_s_i_o_n returns. So, it's advised that any kind of interface │ │ │ │ -(such as windows) are closed before destructing the _s_e_s_s_i_o_n object. Because it │ │ │ │ -can take a few second for it to finish. The timeout can be set with │ │ │ │ -_a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ + 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] │ │ │ │ -********** aabboorrtt(()) ********** │ │ │ │ -session_proxy aabboorrtt (); │ │ │ │ -In case you want to destruct the _s_e_s_s_i_o_n asynchronously, you can request a │ │ │ │ -_s_e_s_s_i_o_n destruction proxy. If you don't do this, the destructor of the _s_e_s_s_i_o_n │ │ │ │ -object will block while the trackers are contacted. If you keep one │ │ │ │ -session_proxy to the _s_e_s_s_i_o_n when destructing it, the destructor will not │ │ │ │ -block, but start to close down the _s_e_s_s_i_o_n, the destructor of the proxy will │ │ │ │ -then synchronize the threads. So, the destruction of the _s_e_s_s_i_o_n is performed │ │ │ │ -from the session destructor call until the session_proxy destructor call. The │ │ │ │ -session_proxy does not have any operations on it (since the _s_e_s_s_i_o_n is being │ │ │ │ -closed down, no operations are allowed on it). The only valid operation is │ │ │ │ -calling the destructor: │ │ │ │ -struct session_proxy {}; │ │ │ │ + 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] │ │ │ │ -************ sseessssiioonn__hhaannddllee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___h_a_n_d_l_e_._h_p_p" │ │ │ │ -this class provides a non-owning handle to a _s_e_s_s_i_o_n and a subset of the │ │ │ │ -interface of the _s_e_s_s_i_o_n class. If the underlying _s_e_s_s_i_o_n is destructed any │ │ │ │ -handle to it will no longer be valid. _i_s___v_a_l_i_d_(_) will return false and any │ │ │ │ -operation on it will throw a system_error exception, with error code │ │ │ │ -invalid_session_handle. │ │ │ │ -struct session_handle │ │ │ │ +************ 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 │ │ │ │ { │ │ │ │ - bool iiss__vvaalliidd () const; │ │ │ │ - session_params sseessssiioonn__ssttaattee (save_state_flags_t flags = │ │ │ │ -save_state_flags_t::all()) const; │ │ │ │ - void rreeffrreesshh__ttoorrrreenntt__ssttaattuuss (std::vector* ret │ │ │ │ - , status_flags_t flags = {}) const; │ │ │ │ - std::vector ggeett__ttoorrrreenntt__ssttaattuuss ( │ │ │ │ - std::function const& pred │ │ │ │ - , status_flags_t flags = {}) const; │ │ │ │ - void ppoosstt__ttoorrrreenntt__uuppddaatteess (status_flags_t flags = status_flags_t::all()); │ │ │ │ - void ppoosstt__sseessssiioonn__ssttaattss (); │ │ │ │ - void ppoosstt__ddhhtt__ssttaattss (); │ │ │ │ - void sseett__ddhhtt__ssttaattee (dht::dht_state&& st); │ │ │ │ - void sseett__ddhhtt__ssttaattee (dht::dht_state const& st); │ │ │ │ - std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ - torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ - torrent_handle ffiinndd__ttoorrrreenntt (sha1_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); │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ - void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ - void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ - void ppaauussee (); │ │ │ │ - void rreessuummee (); │ │ │ │ - bool iiss__ppaauusseedd () const; │ │ │ │ - bool iiss__ddhhtt__rruunnnniinngg () const; │ │ │ │ - void sseett__ddhhtt__ssttoorraaggee (dht::dht_storage_constructor_type sc); │ │ │ │ - void aadddd__ddhhtt__nnooddee (std::pair const& node); │ │ │ │ - void ddhhtt__ggeett__iitteemm (sha1_hash const& target); │ │ │ │ - void ddhhtt__ggeett__iitteemm (std::array key │ │ │ │ - , std::string salt = std::string()); │ │ │ │ - sha1_hash ddhhtt__ppuutt__iitteemm (entry data); │ │ │ │ - void ddhhtt__ppuutt__iitteemm (std::array key │ │ │ │ - , std::function& │ │ │ │ - , std::int64_t&, std::string const&)> cb │ │ │ │ - , std::string salt = std::string()); │ │ │ │ - void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ - void ddhhtt__aannnnoouunnccee (sha1_hash const& info_hash, int port = 0, dht:: │ │ │ │ -announce_flags_t flags = {}); │ │ │ │ - void ddhhtt__lliivvee__nnooddeess (sha1_hash const& nid); │ │ │ │ - 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::function( │ │ │ │ - torrent_handle const&, client_data_t)> ext); │ │ │ │ - void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ - 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 lliisstteenn__ppoorrtt () const; │ │ │ │ - unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ - void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ - ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ - peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ - void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ - peer_class_t ccrreeaattee__ppeeeerr__ccllaassss (char const* name); │ │ │ │ - void ddeelleettee__ppeeeerr__ccllaassss (peer_class_t cid); │ │ │ │ - void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ - peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ - void rreemmoovvee__ttoorrrreenntt (const torrent_handle&, remove_flags_t = {}); │ │ │ │ - void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ - settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ - void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ - bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ - void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ - void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ - void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ - std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ -external_port, int local_port); │ │ │ │ - void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ -reopen_map_ports); │ │ │ │ - std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ + 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 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; │ │ │ │ - static inline constexpr save_state_flags_t ssaavvee__iipp__ffiilltteerr = 12_bit; │ │ │ │ - static inline constexpr peer_class_t gglloobbaall__ppeeeerr__ccllaassss__iidd {0}; │ │ │ │ - static inline constexpr peer_class_t ttccpp__ppeeeerr__ccllaassss__iidd {1}; │ │ │ │ - static inline constexpr peer_class_t llooccaall__ppeeeerr__ccllaassss__iidd {2}; │ │ │ │ - static inline constexpr remove_flags_t ddeelleettee__ffiilleess = 0_bit; │ │ │ │ - static inline constexpr remove_flags_t ddeelleettee__ppaarrttffiillee = 1_bit; │ │ │ │ - static inline constexpr session_flags_t ppaauusseedd = 2_bit; │ │ │ │ - static constexpr portmap_protocol uuddpp = portmap_protocol::udp; │ │ │ │ - static constexpr portmap_protocol ttccpp = portmap_protocol::tcp; │ │ │ │ - static inline constexpr reopen_network_flags_t rreeooppeenn__mmaapp__ppoorrttss = 0_bit; │ │ │ │ + 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] │ │ │ │ -********** iiss__vvaalliidd(()) ********** │ │ │ │ -bool iiss__vvaalliidd () const; │ │ │ │ -returns true if this handle refers to a valid _s_e_s_s_i_o_n object. If the _s_e_s_s_i_o_n │ │ │ │ -has been destroyed, all _s_e_s_s_i_o_n___h_a_n_d_l_e objects will expire and not be valid. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseessssiioonn__ssttaattee(()) ********** │ │ │ │ -session_params sseessssiioonn__ssttaattee (save_state_flags_t flags = save_state_flags_t:: │ │ │ │ -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 │ │ │ │ + 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] │ │ │ │ -********** ggeett__ttoorrrreenntt__ssttaattuuss(()) rreeffrreesshh__ttoorrrreenntt__ssttaattuuss(()) ********** │ │ │ │ -void rreeffrreesshh__ttoorrrreenntt__ssttaattuuss (std::vector* ret │ │ │ │ - , status_flags_t flags = {}) const; │ │ │ │ -std::vector ggeett__ttoorrrreenntt__ssttaattuuss ( │ │ │ │ - std::function const& pred │ │ │ │ - , status_flags_t flags = {}) const; │ │ │ │ +************ 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 │ │ │ │ -these calls are potentially expensive and won't scale well with lots of │ │ │ │ -torrents. If you're concerned about performance, consider using │ │ │ │ -post_torrent_updates() instead. │ │ │ │ -get_torrent_status returns a vector of the _t_o_r_r_e_n_t___s_t_a_t_u_s for every torrent │ │ │ │ -which satisfies pred, which is a predicate function which determines if a │ │ │ │ -torrent should be included in the returned set or not. Returning true means it │ │ │ │ -should be included and false means excluded. The flags argument is the same as │ │ │ │ -to _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_t_a_t_u_s_(_). Since pred is guaranteed to be called for every │ │ │ │ -torrent, it may be used to count the number of torrents of different categories │ │ │ │ -as well. │ │ │ │ -refresh_torrent_status takes a vector of _t_o_r_r_e_n_t___s_t_a_t_u_s structs (for instance │ │ │ │ -the same vector that was returned by _g_e_t___t_o_r_r_e_n_t___s_t_a_t_u_s_(_) ) and refreshes the │ │ │ │ -status based on the handle member. It is possible to use this function by first │ │ │ │ -setting up a vector of default constructed torrent_status objects, only │ │ │ │ -initializing the handle member, in order to request the torrent status for │ │ │ │ -multiple torrents in a single call. This can save a significant amount of time │ │ │ │ -if you have a lot of torrents. │ │ │ │ -Any _t_o_r_r_e_n_t___s_t_a_t_u_s object whose handle member is not referring to a valid │ │ │ │ -torrent are ignored. │ │ │ │ -The intended use of these functions is to start off by calling │ │ │ │ -get_torrent_status() to get a list of all torrents that match your criteria. │ │ │ │ -Then call refresh_torrent_status() on that list. This will only refresh the │ │ │ │ -status for the torrents in your list, and thus ignore all other torrents you │ │ │ │ -might be running. This may save a significant amount of time, especially if the │ │ │ │ -number of torrents you're interested in is small. In order to keep your list of │ │ │ │ -interested torrents up to date, you can either call get_torrent_status() from │ │ │ │ -time to time, to include torrents you might have become interested in since the │ │ │ │ -last time. In order to stop refreshing a certain torrent, simply remove it from │ │ │ │ -the list. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppoosstt__ttoorrrreenntt__uuppddaatteess(()) ********** │ │ │ │ -void ppoosstt__ttoorrrreenntt__uuppddaatteess (status_flags_t flags = status_flags_t::all()); │ │ │ │ -This functions instructs the _s_e_s_s_i_o_n to post the _s_t_a_t_e___u_p_d_a_t_e___a_l_e_r_t, containing │ │ │ │ -the status of all torrents whose state changed since the last time this │ │ │ │ -function was called. │ │ │ │ -Only torrents who have the state subscription flag set will be included. This │ │ │ │ -flag is on by default. See _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s. the flags argument is the same │ │ │ │ -as for _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_t_a_t_u_s_(_). see status_flags_t in _t_o_r_r_e_n_t___h_a_n_d_l_e. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppoosstt__sseessssiioonn__ssttaattss(()) ********** │ │ │ │ -void ppoosstt__sseessssiioonn__ssttaattss (); │ │ │ │ -This function will post a _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t object, containing a snapshot of │ │ │ │ -the performance _c_o_u_n_t_e_r_s from the internals of libtorrent. To interpret these │ │ │ │ -_c_o_u_n_t_e_r_s, query the _s_e_s_s_i_o_n via _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_). │ │ │ │ -For more information, see the _s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppoosstt__ddhhtt__ssttaattss(()) ********** │ │ │ │ -void ppoosstt__ddhhtt__ssttaattss (); │ │ │ │ -This will cause a _d_h_t___s_t_a_t_s___a_l_e_r_t to be posted. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** 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(()) ********** │ │ │ │ -std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ -torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ -torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ -find_torrent() looks for a torrent with the given info-hash. In case there is │ │ │ │ -such a torrent in the _s_e_s_s_i_o_n, a _t_o_r_r_e_n_t___h_a_n_d_l_e to that torrent is returned. In │ │ │ │ -case the torrent cannot be found, an invalid _t_o_r_r_e_n_t___h_a_n_d_l_e is returned. │ │ │ │ -See torrent_handle::is_valid() to know if the torrent was found or not. │ │ │ │ -get_torrents() returns a vector of torrent_handles to all the torrents │ │ │ │ -currently in the _s_e_s_s_i_o_n. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** 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); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ -void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ -void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, 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 │ │ │ │ -files for the torrent will be saved. Even when using a custom storage, this │ │ │ │ -needs to be set to something. If the save_path is empty, the call to │ │ │ │ -_a_d_d___t_o_r_r_e_n_t_(_) will throw a system_error exception. │ │ │ │ -The overload that does not take an error_code throws an exception on error and │ │ │ │ -is not available when building without exception support. The _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ -returned by _a_d_d___t_o_r_r_e_n_t_(_) can be used to retrieve information about the │ │ │ │ -torrent's progress, its peers etc. It is also used to abort a torrent. │ │ │ │ -If the torrent you are trying to add already exists in the _s_e_s_s_i_o_n (is either │ │ │ │ -queued for checking, being checked or downloading) add_torrent() will throw │ │ │ │ -system_error which derives from std::exception unless duplicate_is_error is set │ │ │ │ -to false. In that case, _a_d_d___t_o_r_r_e_n_t_(_) will return the handle to the existing │ │ │ │ -torrent. │ │ │ │ -The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s class has a flags field. It can be used to control what │ │ │ │ -state the new torrent will be added in. Common flags to want to control are │ │ │ │ -torrent_flags::paused and torrent_flags::auto_managed. In order to add a magnet │ │ │ │ -link that will just download the metadata, but no payload, set the │ │ │ │ -torrent_flags::upload_mode flag. │ │ │ │ -Special consideration has to be taken when adding hybrid torrents (i.e. │ │ │ │ -torrents that are BitTorrent v2 torrents that are backwards compatible with │ │ │ │ -v1). For more details, see _B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreessuummee(()) iiss__ppaauusseedd(()) ppaauussee(()) ********** │ │ │ │ -void ppaauussee (); │ │ │ │ -void rreessuummee (); │ │ │ │ -bool iiss__ppaauusseedd () const; │ │ │ │ -Pausing the _s_e_s_s_i_o_n has the same effect as pausing every torrent in it, except │ │ │ │ -that torrents will not be resumed by the auto-manage mechanism. Resuming will │ │ │ │ -restore the torrents to their previous paused state. i.e. the _s_e_s_s_i_o_n pause │ │ │ │ -state is separate from the torrent pause state. A torrent is inactive if it is │ │ │ │ -paused or if the _s_e_s_s_i_o_n is paused. 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] │ │ │ │ -********** iiss__ddhhtt__rruunnnniinngg(()) ********** │ │ │ │ -bool iiss__ddhhtt__rruunnnniinngg () const; │ │ │ │ -is_dht_running() returns true if the DHT support has been started and false │ │ │ │ -otherwise. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ddhhtt__ssttoorraaggee(()) ********** │ │ │ │ -void sseett__ddhhtt__ssttoorraaggee (dht::dht_storage_constructor_type sc); │ │ │ │ -set_dht_storage set a dht custom storage constructor function to be used │ │ │ │ -internally when the dht is created. │ │ │ │ -Since the dht storage is a critical component for the dht behavior, this │ │ │ │ -function will only be effective the next time the dht is started. If you never │ │ │ │ -touch this feature, a default map-memory based storage is used. │ │ │ │ -If you want to make sure the dht is initially created with your custom storage, │ │ │ │ -create a _s_e_s_s_i_o_n with the setting settings_pack::enable_dht to false, set your │ │ │ │ -constructor function and call apply_settings with settings_pack::enable_dht to │ │ │ │ -true. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ddhhtt__nnooddee(()) ********** │ │ │ │ -void aadddd__ddhhtt__nnooddee (std::pair const& node); │ │ │ │ -add_dht_node takes a host name and port pair. That endpoint will be pinged, and │ │ │ │ -if a valid DHT reply is received, the node will be added to the routing table. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddhhtt__ggeett__iitteemm(()) ********** │ │ │ │ -void ddhhtt__ggeett__iitteemm (sha1_hash const& target); │ │ │ │ -query the DHT for an immutable item at the target hash. the result is posted as │ │ │ │ -a _d_h_t___i_m_m_u_t_a_b_l_e___i_t_e_m___a_l_e_r_t. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddhhtt__ggeett__iitteemm(()) ********** │ │ │ │ -void ddhhtt__ggeett__iitteemm (std::array key │ │ │ │ - , std::string salt = std::string()); │ │ │ │ -query the DHT for a mutable item under the public key key. this is an ed25519 │ │ │ │ -key. salt is optional and may be left as an empty string if no salt is to be │ │ │ │ -used. if the item is found in the DHT, a _d_h_t___m_u_t_a_b_l_e___i_t_e_m___a_l_e_r_t is posted. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddhhtt__ppuutt__iitteemm(()) ********** │ │ │ │ -sha1_hash ddhhtt__ppuutt__iitteemm (entry data); │ │ │ │ -store the given bencoded data as an immutable item in the DHT. the returned │ │ │ │ -hash is the key that is to be used to look the item up again. It's just the │ │ │ │ -SHA-1 hash of the bencoded form of the structure. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddhhtt__ppuutt__iitteemm(()) ********** │ │ │ │ -void ddhhtt__ppuutt__iitteemm (std::array key │ │ │ │ - , std::function& │ │ │ │ - , std::int64_t&, std::string const&)> cb │ │ │ │ - , std::string salt = std::string()); │ │ │ │ -store a mutable item. The key is the public key the blob is to be stored under. │ │ │ │ -The optional salt argument is a string that is to be mixed in with the key when │ │ │ │ -determining where in the DHT the value is to be stored. The callback function │ │ │ │ -is called from within the libtorrent network thread once we've found where to │ │ │ │ -store the blob, possibly with the current value stored under the key. The │ │ │ │ -values passed to the callback functions are: │ │ │ │ - entry& value │ │ │ │ - the current value stored under the key (may be empty). Also expected to │ │ │ │ - be set to the value to be stored by the function. │ │ │ │ - std::array& signature │ │ │ │ - the signature authenticating the current value. This may be zeros if │ │ │ │ - there is currently no value stored. The function is expected to fill in │ │ │ │ - this buffer with the signature of the new value to store. To generate the │ │ │ │ - signature, you may want to use the sign_mutable_item function. │ │ │ │ - std::int64_t& seq │ │ │ │ - current sequence number. May be zero if there is no current value. The │ │ │ │ - function is expected to set this to the new sequence number of the value │ │ │ │ - that is to be stored. Sequence numbers must be monotonically increasing. │ │ │ │ - Attempting to overwrite a value with a lower or equal sequence number │ │ │ │ - will fail, even if the signature is correct. │ │ │ │ - std::string const& salt │ │ │ │ - this is the salt that was used for this put call. │ │ │ │ -Since the callback function cb is called from within libtorrent, it is critical │ │ │ │ -to not perform any blocking operations. Ideally not even locking a mutex. Pass │ │ │ │ -any data required for this function along with the function object's context │ │ │ │ -and make the function entirely self-contained. The only reason data blob's │ │ │ │ -value is computed via a function instead of just passing in the new value is to │ │ │ │ -avoid race conditions. If you want to uuppddaattee the value in the DHT, you must │ │ │ │ -first retrieve it, then modify it, then write it back. The way the DHT works, │ │ │ │ -it is natural to always do a lookup before storing and calling the callback in │ │ │ │ -between is convenient. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddhhtt__ggeett__ppeeeerrss(()) ddhhtt__aannnnoouunnccee(()) ********** │ │ │ │ -void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ -void ddhhtt__aannnnoouunnccee (sha1_hash const& info_hash, int port = 0, dht:: │ │ │ │ -announce_flags_t flags = {}); │ │ │ │ -dht_get_peers() will issue a DHT get_peer request to the DHT for the specified │ │ │ │ -info-hash. The response (the peers) will be posted back in a │ │ │ │ -_d_h_t___g_e_t___p_e_e_r_s___r_e_p_l_y___a_l_e_r_t. │ │ │ │ -dht_announce() will issue a DHT announce request to the DHT to the specified │ │ │ │ -info-hash, advertising the specified port. If the port is left at its default, │ │ │ │ -0, the port will be implied by the DHT message's source port (which may improve │ │ │ │ -connectivity through a NAT). dht_announce() is not affected by the │ │ │ │ -announce_port override setting. │ │ │ │ -Both these functions are exposed for advanced custom use of the DHT. All │ │ │ │ -torrents eligible to be announce to the DHT will be automatically, by │ │ │ │ -libtorrent. │ │ │ │ -For possible flags, see _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__lliivvee__nnooddeess(()) ********** │ │ │ │ -void ddhhtt__lliivvee__nnooddeess (sha1_hash const& nid); │ │ │ │ -Retrieve all the live DHT (identified by nid) nodes. All the nodes id and │ │ │ │ -endpoint will be returned in the list of nodes in the _a_l_e_r_t │ │ │ │ -dht_live_nodes_alert. Since this _a_l_e_r_t is a response to an explicit call, it │ │ │ │ -will always be posted, regardless of the _a_l_e_r_t mask. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddhhtt__ssaammppllee__iinnffoohhaasshheess(()) ********** │ │ │ │ -void ddhhtt__ssaammppllee__iinnffoohhaasshheess (udp::endpoint const& ep, sha1_hash const& target); │ │ │ │ -Query the DHT node specified by ep to retrieve a sample of the info-hashes that │ │ │ │ -the node currently have in their storage. The target is included for iterative │ │ │ │ -lookups so that indexing nodes can perform a key space traversal with a single │ │ │ │ -RPC per node by adjusting the target value for each RPC. It has no effect on │ │ │ │ -the returned sample value. The result is posted as a │ │ │ │ -dht_sample_infohashes_alert. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddhhtt__ddiirreecctt__rreeqquueesstt(()) ********** │ │ │ │ -void ddhhtt__ddiirreecctt__rreeqquueesstt (udp::endpoint const& ep, entry const& e, client_data_t │ │ │ │ -userdata = {}); │ │ │ │ -Send an arbitrary DHT request directly to the specified endpoint. This function │ │ │ │ -is intended for use by plugins. When a response is received or the request │ │ │ │ -times out, a _d_h_t___d_i_r_e_c_t___r_e_s_p_o_n_s_e___a_l_e_r_t will be posted with the response (if │ │ │ │ -any) and the userdata pointer passed in here. Since this _a_l_e_r_t is a response to │ │ │ │ -an explicit call, it will always be posted, regardless of the _a_l_e_r_t mask. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__eexxtteennssiioonn(()) ********** │ │ │ │ -void aadddd__eexxtteennssiioonn (std::function( │ │ │ │ - torrent_handle const&, client_data_t)> ext); │ │ │ │ -void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ -This function adds an extension to this _s_e_s_s_i_o_n. The argument is a function │ │ │ │ -object that is called with a torrent_handle and which should return a std:: │ │ │ │ -shared_ptr. To write custom plugins, see _l_i_b_t_o_r_r_e_n_t_ _p_l_u_g_i_n_s. │ │ │ │ -For the typical bittorrent client all of these extensions should be added. The │ │ │ │ -main plugins implemented in libtorrent are: │ │ │ │ - uTorrent metadata │ │ │ │ - Allows peers to download the metadata (.torrent files) from the swarm │ │ │ │ - directly. Makes it possible to join a swarm with just a tracker and info- │ │ │ │ - hash. │ │ │ │ -#include │ │ │ │ -ses.add_extension(<::create_ut_metadata_plugin); │ │ │ │ - uTorrent peer exchange │ │ │ │ - Exchanges peers between clients. │ │ │ │ -#include │ │ │ │ -ses.add_extension(<::create_ut_pex_plugin); │ │ │ │ - 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(()) ********** │ │ │ │ -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. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** 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] │ │ │ │ -********** ssssll__lliisstteenn__ppoorrtt(()) lliisstteenn__ppoorrtt(()) iiss__lliisstteenniinngg(()) ********** │ │ │ │ -bool iiss__lliisstteenniinngg () const; │ │ │ │ -unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ -unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ -is_listening() will tell you whether or not the _s_e_s_s_i_o_n has successfully opened │ │ │ │ -a listening port. If it hasn't, this function will return false, and then you │ │ │ │ -can set a new _s_e_t_t_i_n_g_s___p_a_c_k_:_:_l_i_s_t_e_n___i_n_t_e_r_f_a_c_e_s to try another interface and │ │ │ │ -port to bind to. │ │ │ │ -listen_port() returns the port we ended up listening on. │ │ │ │ -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); │ │ │ │ -ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ -Sets the peer class filter for this _s_e_s_s_i_o_n. All new peer connections will take │ │ │ │ -this into account and be added to the peer classes specified by this filter, │ │ │ │ -based on the peer's IP address. │ │ │ │ -The ip-filter essentially maps an IP -> uint32. Each bit in that 32 bit integer │ │ │ │ -represents a peer class. The least significant bit represents class 0, the next │ │ │ │ -bit class 1 and so on. │ │ │ │ -For more info, see _i_p___f_i_l_t_e_r. │ │ │ │ -For example, to make all peers in the range 200.1.1.0 - 200.1.255.255 belong to │ │ │ │ -their own peer class, apply the following filter: │ │ │ │ -ip_filter f = ses.get_peer_class_filter(); │ │ │ │ -peer_class_t my_class = ses.create_peer_class("200.1.x.x IP range"); │ │ │ │ -f.add_rule(make_address("200.1.1.0"), make_address("200.1.255.255") │ │ │ │ - , 1 << static_cast(my_class)); │ │ │ │ -ses.set_peer_class_filter(f); │ │ │ │ -This setting only applies to new connections, it won't affect existing peer │ │ │ │ -connections. │ │ │ │ -This function is limited to only peer class 0-31, since there are only 32 bits │ │ │ │ -in the IP range mapping. Only the set bits matter; no peer class will be │ │ │ │ -removed from a peer as a result of this call, peer classes are only added. │ │ │ │ -The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ │ -peer classes in the peer_class_filter are 32 bits. │ │ │ │ -The get_peer_class_filter() function returns the current filter. │ │ │ │ -For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ********** │ │ │ │ -peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ -void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ -Sets and gets the ppeeeerr ccllaassss ttyyppee ffiilltteerr. This is controls automatic peer class │ │ │ │ -assignments to peers based on what kind of socket it is. │ │ │ │ -It does not only support assigning peer classes, it also supports removing peer │ │ │ │ -classes based on socket type. │ │ │ │ -The order of these rules being applied are: │ │ │ │ - 1. peer-class IP filter │ │ │ │ - 2. peer-class type filter, removing classes │ │ │ │ - 3. peer-class type filter, adding classes │ │ │ │ -For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccrreeaattee__ppeeeerr__ccllaassss(()) ********** │ │ │ │ -peer_class_t ccrreeaattee__ppeeeerr__ccllaassss (char const* name); │ │ │ │ -Creates a new peer class (see _p_e_e_r_ _c_l_a_s_s_e_s) with the given name. The returned │ │ │ │ -integer is the new peer class identifier. Peer classes may have the same name, │ │ │ │ -so each invocation of this function creates a new class and returns a unique │ │ │ │ -identifier. │ │ │ │ -Identifiers are assigned from low numbers to higher. So if you plan on using │ │ │ │ -certain peer classes in a call to _s_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_), make sure to create │ │ │ │ -those early on, to get low identifiers. │ │ │ │ -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] │ │ │ │ -********** ddeelleettee__ppeeeerr__ccllaassss(()) ********** │ │ │ │ -void ddeelleettee__ppeeeerr__ccllaassss (peer_class_t cid); │ │ │ │ -This call dereferences the reference count of the specified peer class. When │ │ │ │ -creating a peer class it's automatically referenced by 1. If you want to │ │ │ │ -recycle a peer class, you may call this function. You may only call this │ │ │ │ -function oonnccee per peer class you create. Calling it more than once for the same │ │ │ │ -class will lead to memory corruption. │ │ │ │ -Since peer classes are reference counted, this function will not remove the │ │ │ │ -peer class if it's still assigned to torrents or peers. It will however remove │ │ │ │ -it once the last peer and torrent drops their references to it. │ │ │ │ -There is no need to call this function for custom peer classes. All peer │ │ │ │ -classes will be properly destructed when the _s_e_s_s_i_o_n object destructs. │ │ │ │ -For more information on peer classes, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__ppeeeerr__ccllaassss(()) sseett__ppeeeerr__ccllaassss(()) ********** │ │ │ │ -void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ -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 │ │ │ │ -any of its classes is the one that is taken into account. │ │ │ │ -For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreemmoovvee__ttoorrrreenntt(()) ********** │ │ │ │ -void rreemmoovvee__ttoorrrreenntt (const torrent_handle&, remove_flags_t = {}); │ │ │ │ -remove_torrent() will close all peer connections associated with the torrent │ │ │ │ -and tell the tracker that we've stopped participating in the swarm. This │ │ │ │ -operation cannot fail. When it completes, you will receive a │ │ │ │ -_t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t. │ │ │ │ -_r_e_m_o_v_e___t_o_r_r_e_n_t_(_) is non-blocking, but will remove the torrent from the _s_e_s_s_i_o_n │ │ │ │ -synchronously. Calling _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_a_d_d___t_o_r_r_e_n_t_(_) immediately afterward with │ │ │ │ -the same torrent will succeed. Note that this creates a new handle which is not │ │ │ │ -equal to the removed one. │ │ │ │ -The optional second argument options can be used to delete all the files │ │ │ │ -downloaded by this torrent. To do so, pass in the value session_handle:: │ │ │ │ -delete_files. Once the torrent is deleted, a _t_o_r_r_e_n_t___d_e_l_e_t_e_d___a_l_e_r_t is posted. │ │ │ │ -The _t_o_r_r_e_n_t___h_a_n_d_l_e remains valid for some time after _r_e_m_o_v_e___t_o_r_r_e_n_t_(_) is │ │ │ │ -called. It will become invalid only after all libtorrent tasks (such as I/ │ │ │ │ -O tasks) release their references to the torrent. Until this happens, │ │ │ │ -_t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_i_s___v_a_l_i_d_(_) will return true, and other calls such as │ │ │ │ -_t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_t_a_t_u_s_(_) will succeed. Because of this, and because │ │ │ │ -_r_e_m_o_v_e___t_o_r_r_e_n_t_(_) is non-blocking, the following sequence usually succeeds (does │ │ │ │ -not throw system_error): .. code:: c++ │ │ │ │ - session.remove_handle(handle); handle.save_resume_data(); │ │ │ │ -Note that when a queued or downloading torrent is removed, its position in the │ │ │ │ -download queue is vacated and every subsequent torrent in the queue has their │ │ │ │ -queue positions updated. This can potentially cause a large state_update to be │ │ │ │ -posted. When removing all torrents, it is advised to remove them from the back │ │ │ │ -of the queue, to minimize the shifting. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__sseettttiinnggss(()) aappppllyy__sseettttiinnggss(()) ********** │ │ │ │ -void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ -settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ -void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ -Applies the settings specified by the _s_e_t_t_i_n_g_s___p_a_c_k s. This is an asynchronous │ │ │ │ -operation that will return immediately and actually apply the settings to the │ │ │ │ -main thread of libtorrent some time later. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppoopp__aalleerrttss(()) wwaaiitt__ffoorr__aalleerrtt(()) sseett__aalleerrtt__nnoottiiffyy(()) ********** │ │ │ │ -bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ -void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ -void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ -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. │ │ │ │ -wait_for_alert will block the current thread for max_wait time duration, or │ │ │ │ -until another _a_l_e_r_t is posted. If an _a_l_e_r_t is already available at the time of │ │ │ │ -the call, it returns immediately. It returns true if an _a_l_e_r_t is pending (i.e. │ │ │ │ -a subsequent pop_alerts call would return at least one _a_l_e_r_t), and false if the │ │ │ │ -timeout expired with no _a_l_e_r_t available. │ │ │ │ -In TORRENT_ABI_VERSION < 4 the return type is alert* for backwards │ │ │ │ -compatibility; the returned pointer is non-null when an _a_l_e_r_t is pending and │ │ │ │ -null on timeout, but it does not point at any real _a_l_e_r_t (it is a placeholder) │ │ │ │ -and must not be dereferenced. Use pop_alerts to retrieve the actual alerts. │ │ │ │ -In the python binding, wait_for_alert takes the number of milliseconds to wait │ │ │ │ -as an integer and returns a bool. │ │ │ │ -The _a_l_e_r_t queue in the _s_e_s_s_i_o_n will not grow indefinitely. Make sure to pop │ │ │ │ -periodically to not miss notifications. To control the max number of alerts │ │ │ │ -that's queued by the _s_e_s_s_i_o_n, see settings_pack::alert_queue_size. │ │ │ │ -Some alerts are considered so important that they are posted even when the │ │ │ │ -_a_l_e_r_t queue is full. Some alerts are considered mandatory and cannot be │ │ │ │ -disabled by the alert_mask. For instance, _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t and │ │ │ │ -_s_a_v_e___r_e_s_u_m_e___d_a_t_a___f_a_i_l_e_d___a_l_e_r_t are always posted, regardless of the _a_l_e_r_t mask. │ │ │ │ -To control which alerts are posted, set the alert_mask (_s_e_t_t_i_n_g_s___p_a_c_k_:_: │ │ │ │ -_a_l_e_r_t___m_a_s_k). │ │ │ │ -If the _a_l_e_r_t queue fills up to the point where alerts are dropped, this will be │ │ │ │ -indicated by a _a_l_e_r_t_s___d_r_o_p_p_e_d___a_l_e_r_t, which contains a bitmask of which types of │ │ │ │ -alerts were dropped. Generally it is a good idea to make sure the _a_l_e_r_t queue │ │ │ │ -is large enough, the alert_mask doesn't have unnecessary categories enabled and │ │ │ │ -to call pop_alert() frequently, to avoid alerts being dropped. │ │ │ │ -the set_alert_notify function lets the client set a function object to be │ │ │ │ -invoked every time the _a_l_e_r_t queue goes from having 0 alerts to 1 _a_l_e_r_t. This │ │ │ │ -function is called from within libtorrent, it may be the main thread, or it may │ │ │ │ -be from within a user call. The intention of of the function is that the client │ │ │ │ -wakes up its main thread, to poll for more alerts using pop_alerts(). If the │ │ │ │ -notify function fails to do so, it won't be called again, until pop_alerts is │ │ │ │ -called for some other reason. For instance, it could signal an eventfd, post a │ │ │ │ -message to an HWND or some other main message pump. The actual retrieval of │ │ │ │ -alerts should not be done in the callback. In fact, the callback should not │ │ │ │ -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] │ │ │ │ -********** ddeelleettee__ppoorrtt__mmaappppiinngg(()) aadddd__ppoorrtt__mmaappppiinngg(()) ********** │ │ │ │ -void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ -std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ -external_port, int local_port); │ │ │ │ -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 = │ │ │ │ -reopen_map_ports); │ │ │ │ -Instructs the _s_e_s_s_i_o_n to reopen all listen and outgoing sockets. │ │ │ │ -It's useful in the case your platform doesn't support the built in IP notifier │ │ │ │ -mechanism, or if you have a better more reliable way to detect changes in the │ │ │ │ -IP routing table. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnaattiivvee__hhaannddllee(()) ********** │ │ │ │ -std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ -This function is intended only for use by plugins. This type does not have a │ │ │ │ -stable API and should be relied on as little as possible. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - save_settings │ │ │ │ - saves settings (i.e. the _s_e_t_t_i_n_g_s___p_a_c_k) │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - save_dht_state │ │ │ │ - saves dht state such as nodes and node-id, possibly accelerating joining │ │ │ │ - the DHT if provided at next _s_e_s_s_i_o_n startup. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - save_extension_state │ │ │ │ - load or save state from plugins │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - save_ip_filter │ │ │ │ - load or save the IP filter set on the _s_e_s_s_i_o_n │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - global_peer_class_id tcp_peer_class_id local_peer_class_id │ │ │ │ - built-in peer classes │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - delete_files │ │ │ │ - delete the files belonging to the torrent from disk. including the part- │ │ │ │ - file, if there is one │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - delete_partfile │ │ │ │ - delete just the part-file associated with this torrent │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - paused │ │ │ │ - when set, the _s_e_s_s_i_o_n will start paused. Call _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_r_e_s_u_m_e_(_) to │ │ │ │ - start │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - udp tcp │ │ │ │ - protocols used by _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - reopen_map_ports │ │ │ │ - This option indicates if the ports are mapped using natpmp and upnp. If │ │ │ │ - mapping was already made, they are deleted and added again. This only │ │ │ │ - works if natpmp and/or upnp are configured to be enable. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ wwrriittee__sseessssiioonn__ppaarraammss(()) rreeaadd__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss__bbuuff(()) │ │ │ │ -************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___p_a_r_a_m_s_._h_p_p" │ │ │ │ -std::vector wwrriittee__sseessssiioonn__ppaarraammss__bbuuff (session_params const& sp │ │ │ │ - , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ -session_params rreeaadd__sseessssiioonn__ppaarraammss (span buf │ │ │ │ - , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ -entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ - , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ -session_params rreeaadd__sseessssiioonn__ppaarraammss (bdecode_node const& e │ │ │ │ - , 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 │ │ │ │ -_s_e_s_s_i_o_n are not part of the _s_e_s_s_i_o_n___p_a_r_a_m_s state, they have to be restored │ │ │ │ -separately. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ llooaadd__ttoorrrreenntt__lliimmiittss ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___i_n_f_o_._h_p_p" │ │ │ │ -this object holds configuration options for limits to use when loading │ │ │ │ -torrents. They are meant to prevent loading potentially malicious torrents that │ │ │ │ -cause excessive memory allocations. │ │ │ │ -struct load_torrent_limits │ │ │ │ +If has_v2() is false then the v1 hash might actually be a truncated v2 hash │ │ │ │ +struct info_hash_t │ │ │ │ { │ │ │ │ - int mmaaxx__bbuuffffeerr__ssiizzee = 10000000; │ │ │ │ - int mmaaxx__ppiieecceess = 0x200000; │ │ │ │ - int mmaaxx__ddeeccooddee__ddeepptthh = 100; │ │ │ │ - int mmaaxx__ddeeccooddee__ttookkeennss = 3000000; │ │ │ │ - int mmaaxx__dduupplliiccaattee__ffiilleennaammeess = 500; │ │ │ │ - int mmaaxx__ddiirreeccttoorryy__ddeepptthh = 100; │ │ │ │ + iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ + iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ + bool hhaass__vv11 () const; │ │ │ │ + bool hhaass (protocol_version v) 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] │ │ │ │ - max_buffer_size │ │ │ │ - the max size of a .torrent file to load into RAM │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - max_pieces │ │ │ │ - the max number of pieces allowed in the torrent │ │ │ │ +********** iinnffoo__hhaasshh__tt(()) ********** │ │ │ │ +iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ +explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ +iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ +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] │ │ │ │ - max_decode_depth │ │ │ │ - the max recursion depth in the bdecoded structure │ │ │ │ +********** hhaass__vv11(()) hhaass(()) hhaass__vv22(()) ********** │ │ │ │ +bool hhaass__vv11 () const; │ │ │ │ +bool hhaass (protocol_version v) 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] │ │ │ │ - max_decode_tokens │ │ │ │ - the max number of bdecode tokens │ │ │ │ +********** 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] │ │ │ │ - max_duplicate_filenames │ │ │ │ - the max number of files with same filename allowed in the torrent. Files │ │ │ │ - with the same filename are disambiguated by appending a counter. This │ │ │ │ - operation is not cheap and a malicious torrent may pose a DoS attack, │ │ │ │ - stalling torrent parsing. │ │ │ │ +********** 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] │ │ │ │ - max_directory_depth │ │ │ │ - the max depth of the directory structure of files in the torrent. It │ │ │ │ - protects against malicious torrents with a deeply nested directory │ │ │ │ - structure. │ │ │ │ + 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] │ │ │ │ -************ ttoorrrreenntt__iinnffoo ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___i_n_f_o_._h_p_p" │ │ │ │ -the _t_o_r_r_e_n_t___i_n_f_o class holds the information found in a .torrent file. │ │ │ │ -class torrent_info │ │ │ │ +************ 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 │ │ │ │ { │ │ │ │ - explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ - ttoorrrreenntt__iinnffoo (torrent_info const& t); │ │ │ │ - ttoorrrreenntt__iinnffoo (bdecode_node const& info_section, error_code& ec │ │ │ │ - , load_torrent_limits const& cfg │ │ │ │ - , from_info_section_t); │ │ │ │ - ~~ttoorrrreenntt__iinnffoo (); │ │ │ │ - file_storage const& llaayyoouutt () const; │ │ │ │ - std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ - std::vector ccoolllleeccttiioonnss () const; │ │ │ │ - std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ - std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ - int ppiieeccee__lleennggtthh () const; │ │ │ │ - int nnuumm__ppiieecceess () const; │ │ │ │ - int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ - index_range ppiieeccee__rraannggee () const; │ │ │ │ - piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ - piece_index_t eenndd__ppiieeccee () const; │ │ │ │ - sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ - info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ - bool vv22 () const; │ │ │ │ - bool vv11 () const; │ │ │ │ - int nnuumm__ffiilleess () const; │ │ │ │ - std::vector mmaapp__bblloocckk (piece_index_t const piece │ │ │ │ - , std::int64_t offset, int size) const; │ │ │ │ - peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t offset, int │ │ │ │ -size) const; │ │ │ │ - string_view ssssll__cceerrtt () const; │ │ │ │ - bool iiss__vvaalliidd () const; │ │ │ │ - bool pprriivv () const; │ │ │ │ - bool iiss__ii22pp () const; │ │ │ │ - int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ - int ppiieeccee__ssiizzee__ffoorr__rreeqq (piece_index_t index) const; │ │ │ │ - char const* hhaasshh__ffoorr__ppiieeccee__ppttrr (piece_index_t const index) const; │ │ │ │ - sha1_hash hhaasshh__ffoorr__ppiieeccee (piece_index_t index) const; │ │ │ │ - bool iiss__llooaaddeedd () const; │ │ │ │ - const std::string& nnaammee () const; │ │ │ │ - span iinnffoo__sseeccttiioonn () const; │ │ │ │ + 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] │ │ │ │ -********** ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ -explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ -constructs an empty torrent_info containing only an info-hash. Useful for │ │ │ │ -magnet links: the resulting object has no metadata (no file list, no piece │ │ │ │ -hashes) but the info-hash is set so it can be passed to session::add_torrent(). │ │ │ │ -This object is not filled in once metadata is received from peers. The torrent │ │ │ │ -installs a new torrent_info instance internally rather than updating this one. │ │ │ │ -Retrieve the populated metadata via torrent_handle::torrent_file(). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ -ttoorrrreenntt__iinnffoo (bdecode_node const& info_section, error_code& ec │ │ │ │ - , load_torrent_limits const& cfg │ │ │ │ - , from_info_section_t); │ │ │ │ -Construct a _t_o_r_r_e_n_t___i_n_f_o object from the parsed info-section pointed to │ │ │ │ -byinfo_section. The info-section buffer will be copied into _t_o_r_r_e_n_t___i_n_f_o. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ -~~ttoorrrreenntt__iinnffoo (); │ │ │ │ -frees all storage associated with this _t_o_r_r_e_n_t___i_n_f_o object │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** llaayyoouutt(()) ********** │ │ │ │ -file_storage const& llaayyoouutt () const; │ │ │ │ -The _f_i_l_e___s_t_o_r_a_g_e object contains the information on how to map the pieces to │ │ │ │ -files. It is separated from the _t_o_r_r_e_n_t___i_n_f_o object as the disk I/O subsystem │ │ │ │ -only needs access to file names and sizes. The _f_i_l_e___s_t_o_r_a_g_e object is │ │ │ │ -immutable, renamed files are recorded separately. layout() returns the original │ │ │ │ -_f_i_l_e_n_a_m_e_s, as found in the .torrent file. Files may be renamed to de-duplicate │ │ │ │ -names, or to correct invalid _f_i_l_e_n_a_m_e_s. │ │ │ │ -For more information on the _f_i_l_e___s_t_o_r_a_g_e object, see the separate document on │ │ │ │ -how to create torrents. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssiimmiillaarr__ttoorrrreennttss(()) ccoolllleeccttiioonnss(()) ********** │ │ │ │ -std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ -std::vector ccoolllleeccttiioonnss () const; │ │ │ │ -These two functions are related to _B_E_P_ _3_8 (mutable torrents). The vectors │ │ │ │ -returned from these correspond to the "similar" and "collections" keys in the │ │ │ │ -.torrent file. Both info-hashes and collections from within the info-dict and │ │ │ │ -from outside of it are included. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttoottaall__ssiizzee(()) ********** │ │ │ │ -std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ -total_size() returns the total number of bytes the torrent-file represents. │ │ │ │ -Note that this is the number of pieces times the piece size (modulo the last │ │ │ │ -piece possibly being smaller). With pad files, the total size will be larger │ │ │ │ -than the sum of all (regular) file sizes. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssiizzee__oonn__ddiisskk(()) ********** │ │ │ │ -std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ -returns the sum of all non-pad file sizes. i.e. the files that will actually be │ │ │ │ -saved to disk by this torrent. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ppiieecceess(()) ppiieeccee__lleennggtthh(()) ********** │ │ │ │ -int ppiieeccee__lleennggtthh () const; │ │ │ │ -int nnuumm__ppiieecceess () const; │ │ │ │ -piece_length() and num_pieces() returns the number of byte for each piece and │ │ │ │ -the total number of pieces, respectively. The difference between piece_size() │ │ │ │ -and piece_length() is that piece_size() takes the piece index as argument and │ │ │ │ -gives you the exact size of that piece. It will always be the same as │ │ │ │ -piece_length() except in the case of the last piece, which may be smaller. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bblloocckkss__ppeerr__ppiieeccee(()) ********** │ │ │ │ -int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ -returns the number of blocks there are in the typical piece. There may be fewer │ │ │ │ -in the last piece) │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__rraannggee(()) eenndd__ppiieeccee(()) llaasstt__ppiieeccee(()) ********** │ │ │ │ -index_range ppiieeccee__rraannggee () const; │ │ │ │ -piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ -piece_index_t eenndd__ppiieeccee () const; │ │ │ │ -last_piece() returns the index to the last piece in the torrent and end_piece() │ │ │ │ -returns the index to the one-past-end piece in the torrent piece_range() │ │ │ │ -returns an implementation-defined type that can be used as the container in a │ │ │ │ -range-for loop. Where the values are the indices of all pieces in the │ │ │ │ -_f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) ********** │ │ │ │ -sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ -info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ -returns the info-hash of the torrent. For BitTorrent v2 support, use │ │ │ │ -info_hashes() to get an object that may hold both a v1 and v2 info-hash │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** vv11(()) vv22(()) ********** │ │ │ │ -bool vv22 () const; │ │ │ │ -bool vv11 () const; │ │ │ │ -returns whether this torrent has v1 and/or v2 metadata, respectively. Hybrid │ │ │ │ -torrents have both. These are shortcuts for info_hashes().has_v1() and │ │ │ │ -info_hashes().has_v2() calls. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ffiilleess(()) ********** │ │ │ │ -int nnuumm__ffiilleess () const; │ │ │ │ -If you need index-access to files you can use the num_files() along with the │ │ │ │ -file_path(), file_size()-family of functions to access files using indices. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmaapp__bblloocckk(()) ********** │ │ │ │ -std::vector mmaapp__bblloocckk (piece_index_t const piece │ │ │ │ - , std::int64_t offset, int size) const; │ │ │ │ -This function will map a piece index, a byte offset within that piece and a │ │ │ │ -size (in bytes) into the corresponding files with offsets where that data for │ │ │ │ -that piece is supposed to be stored. See _f_i_l_e___s_l_i_c_e. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmaapp__ffiillee(()) ********** │ │ │ │ -peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t offset, int size) │ │ │ │ -const; │ │ │ │ -This function will map a range in a specific file into a range in the torrent. │ │ │ │ -The file_offset parameter is the offset in the file, given in bytes, where 0 is │ │ │ │ -the start of the file. See _p_e_e_r___r_e_q_u_e_s_t. │ │ │ │ -The input range is assumed to be valid within the torrent. file_offset + size │ │ │ │ -is not allowed to be greater than the file size. file_index must refer to a │ │ │ │ -valid file, i.e. it cannot be >= num_files(). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssssll__cceerrtt(()) ********** │ │ │ │ -string_view ssssll__cceerrtt () const; │ │ │ │ -Returns the SSL root certificate for the torrent, if it is an SSL torrent. │ │ │ │ -Otherwise returns an empty string. The certificate is the public certificate in │ │ │ │ -x509 format. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iiss__vvaalliidd(()) ********** │ │ │ │ -bool iiss__vvaalliidd () const; │ │ │ │ -returns true if this _t_o_r_r_e_n_t___i_n_f_o object has a torrent loaded. This is │ │ │ │ -primarily used to determine if a magnet link has had its metadata resolved yet │ │ │ │ -or not. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** pprriivv(()) ********** │ │ │ │ -bool pprriivv () const; │ │ │ │ -returns true if this torrent is private. i.e., the client should not advertise │ │ │ │ -itself on the trackerless network (the Kademlia DHT) for this torrent. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iiss__ii22pp(()) ********** │ │ │ │ -bool iiss__ii22pp () const; │ │ │ │ -returns true if this is an i2p torrent. This is determined by whether or not it │ │ │ │ -has a tracker whose URL domain name ends with ".i2p". i2p torrents disable the │ │ │ │ -DHT and local peer discovery as well as talking to peers over anything other │ │ │ │ -than the i2p network. This is not reliably set for torrents created via resume │ │ │ │ -data or magnet links. Prefer using torrent::is_i2p() instead. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__ssiizzee(()) ********** │ │ │ │ -int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ -returns the piece size of file with index. This will be the same as │ │ │ │ -_p_i_e_c_e___l_e_n_g_t_h_(_), except for the last piece, which may be shorter. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__ssiizzee__ffoorr__rreeqq(()) ********** │ │ │ │ -int ppiieeccee__ssiizzee__ffoorr__rreeqq (piece_index_t index) const; │ │ │ │ -returns the piece size appropriate for computing request lengths. for v2-only │ │ │ │ -torrents, pieces at the end of files may be shorter than the main piece size. │ │ │ │ -For v1 and hybrid torrents, piece sizes must be full (except for the last │ │ │ │ -piece) in order to correctly compute the piece hash. Note: this is not a │ │ │ │ -trivial accessor. For v2-only torrents it calls _f_i_l_e___s_t_o_r_a_g_e_:_:_p_i_e_c_e___s_i_z_e_2_(_), │ │ │ │ -which performs an O(log n) upper_bound over the file list to find the file │ │ │ │ -boundary that may shorten the piece. Cache the result when calling it │ │ │ │ -repeatedly for the same piece in a hot path. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaasshh__ffoorr__ppiieeccee__ppttrr(()) hhaasshh__ffoorr__ppiieeccee(()) ********** │ │ │ │ -char const* hhaasshh__ffoorr__ppiieeccee__ppttrr (piece_index_t const index) const; │ │ │ │ -sha1_hash hhaasshh__ffoorr__ppiieeccee (piece_index_t index) const; │ │ │ │ -hash_for_piece() takes a piece-index and returns the 20-bytes sha1-hash for │ │ │ │ -that piece. hash_for_piece_ptr() returns a pointer to the 20 byte sha1 digest │ │ │ │ -for the piece. Note that the string is not 0-terminated. │ │ │ │ +********** 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] │ │ │ │ -********** iiss__llooaaddeedd(()) ********** │ │ │ │ -bool iiss__llooaaddeedd () const; │ │ │ │ -returns true if the metadata for this torrent has been loaded (i.e. the file │ │ │ │ -list is populated). For a torrent_info constructed from just an info-hash this │ │ │ │ -returns false. │ │ │ │ + piece │ │ │ │ + The index of the piece in which the range starts. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnaammee(()) ********** │ │ │ │ -const std::string& nnaammee () const; │ │ │ │ -name() returns the name of the torrent. name contains UTF-8 encoded string. │ │ │ │ + start │ │ │ │ + The byte offset within that piece where the range starts. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinnffoo__sseeccttiioonn(()) ********** │ │ │ │ -span iinnffoo__sseeccttiioonn () const; │ │ │ │ -returns a the raw info section of the torrent file. The underlying buffer is │ │ │ │ -still owned by the _t_o_r_r_e_n_t___i_n_f_o object │ │ │ │ + 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; │ │ │ │ @@ -2772,201 +1229,54 @@ │ │ │ │ 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 │ │ │ │ -{ │ │ │ │ - iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ - iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ - bool hhaass__vv22 () const; │ │ │ │ - bool hhaass__vv11 () const; │ │ │ │ - bool hhaass (protocol_version v) 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 () noexcept = default; │ │ │ │ -iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ -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(()) hhaass__vv11(()) hhaass__vv22(()) ********** │ │ │ │ -bool hhaass__vv22 () const; │ │ │ │ -bool hhaass__vv11 () const; │ │ │ │ -bool hhaass (protocol_version v) 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__bbuuffffeerr(()) llooaadd__ttoorrrreenntt__ppaarrsseedd(()) llooaadd__ttoorrrreenntt__ffiillee(()) ************ │ │ │ │ +************ llooaadd__ttoorrrreenntt__ffiillee(()) llooaadd__ttoorrrreenntt__ppaarrsseedd(()) 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__bbuuffffeerr ( │ │ │ │ - span buffer, 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__bbuuffffeerr ( │ │ │ │ - span buffer); │ │ │ │ + std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ std::string const& filename, error_code& ec, load_torrent_limits const& │ │ │ │ cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ + span buffer); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ bdecode_node const& torrent_file, load_torrent_limits const& cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ + span buffer, load_torrent_limits const& cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ + std::string const& filename); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ + bdecode_node const& torrent_file); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ bdecode_node const& torrent_file, error_code& ec, 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); │ │ │ │ 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); │ │ │ │ +Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ +specified save_path. │ │ │ │ +[_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: │ │ │ │ @@ -2981,30 +1291,23 @@ │ │ │ │ The recommended way to generate a magnet link from a _t_o_r_r_e_n_t___h_a_n_d_l_e is to call │ │ │ │ _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_), which will post a _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t containing an │ │ │ │ _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. This can then be passed to _m_a_k_e___m_a_g_n_e_t___u_r_i_(_). │ │ │ │ For more information about magnet links, see _m_a_g_n_e_t_ _l_i_n_k_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppaarrssee__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" │ │ │ │ -void ppaarrssee__mmaaggnneett__uurrii (string_view uri, add_torrent_params& p, error_code& ec); │ │ │ │ add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri, error_code& ec); │ │ │ │ add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri); │ │ │ │ +void ppaarrssee__mmaaggnneett__uurrii (string_view uri, add_torrent_params& p, 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); │ │ │ │ -Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ -specified save_path. │ │ │ │ -[_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(()) ************ │ │ │ │ @@ -3018,29 +1321,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_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ @@ -3074,45 +1362,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 │ │ │ │ @@ -3120,14 +1413,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, │ │ │ │ @@ -3281,1894 +1584,6924 @@ │ │ │ │ only verify SHA-256 (v2) hashes. Saves CPU and disk I/O by avoiding the │ │ │ │ read-back required to compute v1 hashes for incomplete pieces, when v2 │ │ │ │ validation alone is sufficient. Has no effect on v1-only or v2-only │ │ │ │ torrents. Cannot be changed after the torrent is added. │ │ │ │ all │ │ │ │ all torrent flags combined. Can conveniently be used when creating masks │ │ │ │ for flags │ │ │ │ -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. │ │ │ │ -In short, the _p_l_u_g_i_n interface makes it possible to: │ │ │ │ - * register extension messages (sent in the extension handshake), see │ │ │ │ - _e_x_t_e_n_s_i_o_n_s. │ │ │ │ - * add data and parse data from the extension handshake. │ │ │ │ - * send extension messages and standard bittorrent messages. │ │ │ │ - * override or block the handling of standard bittorrent messages. │ │ │ │ - * save and restore state via the _s_e_s_s_i_o_n state │ │ │ │ - * see all alerts that are posted │ │ │ │ -************ aa wwoorrdd ooff ccaauuttiioonn ************ │ │ │ │ -Writing your own _p_l_u_g_i_n is a very easy way to introduce serious bugs such as │ │ │ │ -dead locks and race conditions. Since a _p_l_u_g_i_n has access to internal │ │ │ │ -structures it is also quite easy to sabotage libtorrent's operation. │ │ │ │ -All the callbacks are always called from the libtorrent network thread. In case │ │ │ │ -portions of your _p_l_u_g_i_n are called from other threads, typically the main │ │ │ │ -thread, you cannot use any of the member functions on the internal structures │ │ │ │ -in libtorrent, since those require being called from the libtorrent network │ │ │ │ -thread . Furthermore, you also need to synchronize your own shared data within │ │ │ │ -the _p_l_u_g_i_n, to make sure it is not accessed at the same time from the │ │ │ │ -libtorrent thread (through a callback). If you need to send out a message from │ │ │ │ -another thread, it is advised to use an internal queue, and do the actual │ │ │ │ -sending in tick(). │ │ │ │ -Since the _p_l_u_g_i_n interface gives you easy access to internal structures, it is │ │ │ │ -not supported as a stable API. Plugins should be considered specific to a │ │ │ │ -specific version of libtorrent. Although, in practice the internals mostly │ │ │ │ -don't change that dramatically. │ │ │ │ -************ pplluuggiinn--iinntteerrffaaccee ************ │ │ │ │ -The _p_l_u_g_i_n interface consists of three base classes that the _p_l_u_g_i_n may │ │ │ │ -implement. These are called _p_l_u_g_i_n, _t_o_r_r_e_n_t___p_l_u_g_i_n and _p_e_e_r___p_l_u_g_i_n. They are │ │ │ │ -found in the header. │ │ │ │ -These plugins are instantiated for each _s_e_s_s_i_o_n, torrent and possibly each │ │ │ │ -peer, respectively. │ │ │ │ -For plugins that only need per torrent state, it is enough to only implement │ │ │ │ -torrent_plugin and pass a constructor function or function object to session:: │ │ │ │ -add_extension() or torrent_handle::add_extension() (if the torrent has already │ │ │ │ -been started and you want to hook in the extension at run-time). │ │ │ │ -The signature of the function is: │ │ │ │ -std::shared_ptr (*)(torrent_handle const&, client_data_t); │ │ │ │ -The second argument is the userdata passed to session::add_torrent() or │ │ │ │ -torrent_handle::add_extension(). │ │ │ │ -The function should return a std::shared_ptr which may or may │ │ │ │ -not be 0. If it is a nullptr, the extension is simply ignored for this torrent. │ │ │ │ -If it is a valid pointer (to a class inheriting torrent_plugin), it will be │ │ │ │ -associated with this torrent and callbacks will be made on torrent events. │ │ │ │ -For more elaborate plugins which require _s_e_s_s_i_o_n wide state, you would │ │ │ │ -implement plugin, construct an object (in a std::shared_ptr) and pass it in to │ │ │ │ -session::add_extension(). │ │ │ │ -************ ccuussttoomm aalleerrttss ************ │ │ │ │ -Since plugins are running within internal libtorrent threads, one convenient │ │ │ │ -way to communicate with the client is to post custom alerts. │ │ │ │ -The expected interface of any _a_l_e_r_t, apart from deriving from the _a_l_e_r_t base │ │ │ │ -class, looks like this: │ │ │ │ -static const int alert_type = <>; │ │ │ │ -virtual int type() const { return alert_type; } │ │ │ │ - │ │ │ │ -virtual std::string message() const; │ │ │ │ - │ │ │ │ -static const alert_category_t static_category = <>; │ │ │ │ -virtual alert_category_t category() const { return static_category; } │ │ │ │ - │ │ │ │ -virtual char const* what() const { return <>; } │ │ │ │ -The alert_type is used for the type-checking in alert_cast. It must not collide │ │ │ │ -with any other _a_l_e_r_t. The built-in alerts in libtorrent will not use _a_l_e_r_t type │ │ │ │ -IDs greater than user_alert_id. When defining your own _a_l_e_r_t, make sure it's │ │ │ │ -greater than this constant. │ │ │ │ -type() is the run-time equivalence of the alert_type. │ │ │ │ -The message() virtual function is expected to construct a useful string │ │ │ │ -representation of the _a_l_e_r_t and the event or data it represents. Something │ │ │ │ -convenient to put in a log file for instance. │ │ │ │ -clone() is used internally to copy alerts. The suggested implementation of │ │ │ │ -simply allocating a new instance as a copy of *this is all that's expected. │ │ │ │ -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] │ │ │ │ -************ 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 │ │ │ │ +************ hhaasshheerr ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ +this is a SHA-1 hash class. │ │ │ │ +You use it by first instantiating it, then call update() to feed it with data. │ │ │ │ +i.e. you don't have to keep the entire buffer of which you want to create the │ │ │ │ +hash in memory. You can feed the _h_a_s_h_e_r parts of it at a time. When You have │ │ │ │ +fed the _h_a_s_h_e_r with all the data, you call final() and it will return the sha1- │ │ │ │ +hash of the data. │ │ │ │ +The constructor that takes a char const* and an integer will construct the sha1 │ │ │ │ +context and feed it the data passed in. │ │ │ │ +If you want to reuse the _h_a_s_h_e_r object once you have created a hash, you have │ │ │ │ +to call reset() to reinitialize it. │ │ │ │ +The built-in software version of sha1-algorithm was implemented by Steve Reid │ │ │ │ +and released as public domain. For more info, see src/sha1.cpp. │ │ │ │ +class hasher │ │ │ │ { │ │ │ │ - virtual feature_flags_t iimmpplleemmeenntteedd__ffeeaattuurreess (); │ │ │ │ - virtual std::shared_ptr nneeww__ttoorrrreenntt (torrent_handle const&, │ │ │ │ -client_data_t); │ │ │ │ - virtual void aaddddeedd (session_handle const&); │ │ │ │ - virtual void aabboorrtt (); │ │ │ │ - virtual bool oonn__ddhhtt__rreeqquueesstt (string_view //** qquueerryy **// │ │ │ │ - , udp::endpoint const& //** ssoouurrccee **//, bdecode_node const& //** mmeessssaaggee **// │ │ │ │ - , entry& //** rreessppoonnssee **//); │ │ │ │ - virtual void oonn__aalleerrtt (alert const*); │ │ │ │ - virtual bool oonn__uunnkknnoowwnn__ttoorrrreenntt (info_hash_t const& //** iinnffoo__hhaasshh **// │ │ │ │ - , peer_connection_handle const& //** ppcc **//, add_torrent_params& //** pp **//); │ │ │ │ - virtual void oonn__ttiicckk (); │ │ │ │ - virtual uint64_t ggeett__uunncchhookkee__pprriioorriittyy (peer_connection_handle const& //** ppeeeerr │ │ │ │ -**//); │ │ │ │ - virtual std::map ssaavvee__ssttaattee () const; │ │ │ │ - virtual void llooaadd__ssttaattee (std::map const&); │ │ │ │ - │ │ │ │ - static inline constexpr feature_flags_t ooppttiimmiissttiicc__uunncchhookkee__ffeeaattuurree = 1_bit; │ │ │ │ - static inline constexpr feature_flags_t ttiicckk__ffeeaattuurree = 2_bit; │ │ │ │ - static inline constexpr feature_flags_t ddhhtt__rreeqquueesstt__ffeeaattuurree = 3_bit; │ │ │ │ - static inline constexpr feature_flags_t aalleerrtt__ffeeaattuurree = 4_bit; │ │ │ │ - static inline constexpr feature_flags_t uunnkknnoowwnn__ttoorrrreenntt__ffeeaattuurree = 5_bit; │ │ │ │ + hhaasshheerr (); │ │ │ │ + hhaasshheerr (char const* data, int len); │ │ │ │ + explicit hhaasshheerr (span data); │ │ │ │ + hhaasshheerr (hasher const&); │ │ │ │ + hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ + hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ + hhaasshheerr (hasher&&) noexcept; │ │ │ │ + hasher& uuppddaattee (char const* data, int len); │ │ │ │ + hasher& uuppddaattee (span data); │ │ │ │ + sha1_hash ffiinnaall (); │ │ │ │ + void rreesseett (); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iimmpplleemmeenntteedd__ffeeaattuurreess(()) ********** │ │ │ │ -virtual feature_flags_t iimmpplleemmeenntteedd__ffeeaattuurreess (); │ │ │ │ -This function is expected to return a bitmask indicating which features this │ │ │ │ -_p_l_u_g_i_n implements. Some callbacks on this object may not be called unless the │ │ │ │ -corresponding feature flag is returned here. Note that callbacks may still be │ │ │ │ -called even if the corresponding feature is not specified in the return value │ │ │ │ -here. See feature_flags_t for possible flags to return. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nneeww__ttoorrrreenntt(()) ********** │ │ │ │ -virtual std::shared_ptr nneeww__ttoorrrreenntt (torrent_handle const&, │ │ │ │ -client_data_t); │ │ │ │ -this is called by the _s_e_s_s_i_o_n every time a new torrent is added. The torrent* │ │ │ │ -points to the internal torrent object created for the new torrent. The │ │ │ │ -_c_l_i_e_n_t___d_a_t_a___t is the userdata pointer as passed in via _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s. │ │ │ │ -If the _p_l_u_g_i_n returns a _t_o_r_r_e_n_t___p_l_u_g_i_n instance, it will be added to the new │ │ │ │ -torrent. Otherwise, return an empty shared_ptr to a _t_o_r_r_e_n_t___p_l_u_g_i_n (the │ │ │ │ -default). │ │ │ │ +********** ooppeerraattoorr==(()) hhaasshheerr(()) ********** │ │ │ │ +hhaasshheerr (char const* data, int len); │ │ │ │ +explicit hhaasshheerr (span data); │ │ │ │ +hhaasshheerr (hasher const&); │ │ │ │ +hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ +hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ +hhaasshheerr (hasher&&) noexcept; │ │ │ │ +this is the same as default constructing followed by a call to update(data, │ │ │ │ +len). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aaddddeedd(()) ********** │ │ │ │ -virtual void aaddddeedd (session_handle const&); │ │ │ │ -called when _p_l_u_g_i_n is added to a _s_e_s_s_i_o_n │ │ │ │ +********** uuppddaattee(()) ********** │ │ │ │ +hasher& uuppddaattee (char const* data, int len); │ │ │ │ +hasher& uuppddaattee (span data); │ │ │ │ +append the following bytes to what is being hashed │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aabboorrtt(()) ********** │ │ │ │ -virtual void aabboorrtt (); │ │ │ │ -called when the _s_e_s_s_i_o_n is aborted the _p_l_u_g_i_n should perform any cleanup │ │ │ │ -necessary to allow the session's destruction (e.g. cancel outstanding async │ │ │ │ -operations) │ │ │ │ +********** ffiinnaall(()) ********** │ │ │ │ +sha1_hash ffiinnaall (); │ │ │ │ +returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ +_h_a_s_h_e_r constructor. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ddhhtt__rreeqquueesstt(()) ********** │ │ │ │ -virtual bool oonn__ddhhtt__rreeqquueesstt (string_view //** qquueerryy **// │ │ │ │ - , udp::endpoint const& //** ssoouurrccee **//, bdecode_node const& //** mmeessssaaggee **// │ │ │ │ - , entry& //** rreessppoonnssee **//); │ │ │ │ -called when a dht request is received. If your _p_l_u_g_i_n expects this to be │ │ │ │ -called, make sure to include the flag dht_request_feature in the return value │ │ │ │ -from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). │ │ │ │ +********** rreesseett(()) ********** │ │ │ │ +void rreesseett (); │ │ │ │ +restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ +constructed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__aalleerrtt(()) ********** │ │ │ │ -virtual void oonn__aalleerrtt (alert const*); │ │ │ │ -called when an _a_l_e_r_t is posted alerts that are filtered are not posted. If your │ │ │ │ -_p_l_u_g_i_n expects this to be called, make sure to include the flag alert_feature │ │ │ │ -in the return value from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). │ │ │ │ +************ hhaasshheerr225566 ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ +hasher256 computes a SHA-256 message digest. It is the counterpart to hasher │ │ │ │ +(which computes SHA-1) and is used for BitTorrent v2 piece and merkle-tree │ │ │ │ +hashes. It can be fed input incrementally via update() and the digest is │ │ │ │ +produced by final(). Call reset() to reuse the object for another digest. │ │ │ │ +class hasher256 │ │ │ │ +{ │ │ │ │ + hhaasshheerr225566 (); │ │ │ │ + hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ + hhaasshheerr225566 (hasher256 const&); │ │ │ │ + explicit hhaasshheerr225566 (span data); │ │ │ │ + hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ + hhaasshheerr225566 (char const* data, int len); │ │ │ │ + hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ + hasher256& uuppddaattee (char const* data, int len); │ │ │ │ + hasher256& uuppddaattee (span data); │ │ │ │ + sha256_hash ffiinnaall (); │ │ │ │ + void rreesseett (); │ │ │ │ + ~~hhaasshheerr225566 (); │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__uunnkknnoowwnn__ttoorrrreenntt(()) ********** │ │ │ │ -virtual bool oonn__uunnkknnoowwnn__ttoorrrreenntt (info_hash_t const& //** iinnffoo__hhaasshh **// │ │ │ │ - , peer_connection_handle const& //** ppcc **//, add_torrent_params& //** pp **//); │ │ │ │ -return true if the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s should be added │ │ │ │ +********** ooppeerraattoorr==(()) hhaasshheerr225566(()) ********** │ │ │ │ +hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ +hhaasshheerr225566 (hasher256 const&); │ │ │ │ +explicit hhaasshheerr225566 (span data); │ │ │ │ +hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ +hhaasshheerr225566 (char const* data, int len); │ │ │ │ +hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ +this is the same as default constructing followed by a call to update(data, │ │ │ │ +len). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ttiicckk(()) ********** │ │ │ │ -virtual void oonn__ttiicckk (); │ │ │ │ -called once per second. If your _p_l_u_g_i_n expects this to be called, make sure to │ │ │ │ -include the flag tick_feature in the return value from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). │ │ │ │ +********** uuppddaattee(()) ********** │ │ │ │ +hasher256& uuppddaattee (char const* data, int len); │ │ │ │ +hasher256& uuppddaattee (span data); │ │ │ │ +append the following bytes to what is being hashed │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__uunncchhookkee__pprriioorriittyy(()) ********** │ │ │ │ -virtual uint64_t ggeett__uunncchhookkee__pprriioorriittyy (peer_connection_handle const& //** ppeeeerr **// │ │ │ │ -); │ │ │ │ -called when choosing peers to optimistically unchoke. The return value │ │ │ │ -indicates the peer's priority for unchoking. Lower return values correspond to │ │ │ │ -higher priority. Priorities above 2^63-1 are reserved. If your _p_l_u_g_i_n has no │ │ │ │ -priority to assign a peer it should return 2^64-1. If your _p_l_u_g_i_n expects this │ │ │ │ -to be called, make sure to include the flag optimistic_unchoke_feature in the │ │ │ │ -return value from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). If multiple plugins implement this │ │ │ │ -function the lowest return value (i.e. the highest priority) is used. │ │ │ │ +********** ffiinnaall(()) ********** │ │ │ │ +sha256_hash ffiinnaall (); │ │ │ │ +returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ +_h_a_s_h_e_r constructor. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssaavvee__ssttaattee(()) ********** │ │ │ │ -virtual std::map ssaavvee__ssttaattee () const; │ │ │ │ -called when serializing _s_e_s_s_i_o_n state. The returned map of key/value strings is │ │ │ │ -stored alongside the _s_e_s_s_i_o_n state and passed back to load_state() on the next │ │ │ │ -_s_e_s_s_i_o_n. │ │ │ │ +********** rreesseett(()) ********** │ │ │ │ +void rreesseett (); │ │ │ │ +restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ +constructed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** llooaadd__ssttaattee(()) ********** │ │ │ │ -virtual void llooaadd__ssttaattee (std::map const&); │ │ │ │ -called on startup while loading settings state from the _s_e_s_s_i_o_n___p_a_r_a_m_s │ │ │ │ +************ bbiittffiieelldd ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_i_t_f_i_e_l_d_._h_p_p" │ │ │ │ +The _b_i_t_f_i_e_l_d type stores any number of bits as a _b_i_t_f_i_e_l_d in a heap allocated │ │ │ │ +array. │ │ │ │ +struct bitfield │ │ │ │ +{ │ │ │ │ + bbiittffiieelldd (bitfield&& rhs) noexcept = default; │ │ │ │ + bbiittffiieelldd (char const* b, int bits); │ │ │ │ + bbiittffiieelldd (bitfield const& rhs); │ │ │ │ + bbiittffiieelldd (int bits, bool val); │ │ │ │ + explicit bbiittffiieelldd (int bits); │ │ │ │ + bbiittffiieelldd () noexcept = default; │ │ │ │ + void aassssiiggnn (char const* b, int const bits); │ │ │ │ + bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ + bool ooppeerraattoorr[[]] (int index) const noexcept; │ │ │ │ + void sseett__bbiitt (int index) noexcept; │ │ │ │ + void cclleeaarr__bbiitt (int index) noexcept; │ │ │ │ + bool aallll__sseett () const noexcept; │ │ │ │ + bool nnoonnee__sseett () const noexcept; │ │ │ │ + int ssiizzee () const noexcept; │ │ │ │ + int nnuumm__wwoorrddss () const noexcept; │ │ │ │ + int nnuumm__bbyytteess () const noexcept; │ │ │ │ + bool eemmppttyy () const noexcept; │ │ │ │ + char* ddaattaa () noexcept; │ │ │ │ + char const* ddaattaa () const noexcept; │ │ │ │ + void sswwaapp (bitfield& rhs) noexcept; │ │ │ │ + int ccoouunntt () const noexcept; │ │ │ │ + int ffiinndd__ffiirrsstt__sseett () const noexcept; │ │ │ │ + int ffiinndd__llaasstt__cclleeaarr () const noexcept; │ │ │ │ + bool ooppeerraattoorr==== (lt::bitfield const& rhs) const; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - optimistic_unchoke_feature │ │ │ │ - include this bit if your _p_l_u_g_i_n needs to alter the order of the │ │ │ │ - optimistic unchoke of peers. i.e. have the on_optimistic_unchoke() │ │ │ │ - callback be called. │ │ │ │ +********** bbiittffiieelldd(()) ********** │ │ │ │ +bbiittffiieelldd (bitfield&& rhs) noexcept = default; │ │ │ │ +bbiittffiieelldd (char const* b, int bits); │ │ │ │ +bbiittffiieelldd (bitfield const& rhs); │ │ │ │ +bbiittffiieelldd (int bits, bool val); │ │ │ │ +explicit bbiittffiieelldd (int bits); │ │ │ │ +bbiittffiieelldd () noexcept = default; │ │ │ │ +constructs a new _b_i_t_f_i_e_l_d. The default constructor creates an empty _b_i_t_f_i_e_l_d. │ │ │ │ +bits is the size of the _b_i_t_f_i_e_l_d (specified in bits). val is the value to │ │ │ │ +initialize the bits to. If not specified all bits are initialized to 0. │ │ │ │ +The constructor taking a pointer b and bits copies a _b_i_t_f_i_e_l_d from the │ │ │ │ +specified buffer, and bits number of bits (rounded up to the nearest byte │ │ │ │ +boundary). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - tick_feature │ │ │ │ - include this bit if your _p_l_u_g_i_n needs to have _o_n___t_i_c_k_(_) called │ │ │ │ +********** aassssiiggnn(()) ********** │ │ │ │ +void aassssiiggnn (char const* b, int const bits); │ │ │ │ +copy _b_i_t_f_i_e_l_d from buffer b of bits number of bits, rounded up to the nearest │ │ │ │ +byte boundary. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - dht_request_feature │ │ │ │ - include this bit if your _p_l_u_g_i_n needs to have _o_n___d_h_t___r_e_q_u_e_s_t_(_) called │ │ │ │ +********** ooppeerraattoorr[[]](()) ggeett__bbiitt(()) ********** │ │ │ │ +bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ +bool ooppeerraattoorr[[]] (int index) const noexcept; │ │ │ │ +query bit at index. Returns true if bit is 1, otherwise false. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - alert_feature │ │ │ │ - include this bit if your _p_l_u_g_i_n needs to have _o_n___a_l_e_r_t_(_) called │ │ │ │ +********** cclleeaarr__bbiitt(()) sseett__bbiitt(()) ********** │ │ │ │ +void sseett__bbiitt (int index) noexcept; │ │ │ │ +void cclleeaarr__bbiitt (int index) noexcept; │ │ │ │ +set bit at index to 0 (clear_bit) or 1 (set_bit). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - unknown_torrent_feature │ │ │ │ - include this bit if your _p_l_u_g_i_n needs to have _o_n___u_n_k_n_o_w_n___t_o_r_r_e_n_t_(_) called │ │ │ │ - even if there is no active torrent in the _s_e_s_s_i_o_n │ │ │ │ +********** aallll__sseett(()) ********** │ │ │ │ +bool aallll__sseett () const noexcept; │ │ │ │ +returns true if all bits in the _b_i_t_f_i_e_l_d are set │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__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" │ │ │ │ -Torrent plugins are associated with a single torrent and have a number of │ │ │ │ -functions called at certain events. Many of its functions have the ability to │ │ │ │ -change or override the default libtorrent behavior. │ │ │ │ -struct torrent_plugin │ │ │ │ -{ │ │ │ │ - virtual std::shared_ptr nneeww__ccoonnnneeccttiioonn (peer_connection_handle │ │ │ │ -const&); │ │ │ │ - virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t); │ │ │ │ - virtual void oonn__ppiieeccee__ppaassss (piece_index_t); │ │ │ │ - virtual void ttiicckk (); │ │ │ │ - virtual bool oonn__rreessuummee (); │ │ │ │ - virtual bool oonn__ppaauussee (); │ │ │ │ - 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; │ │ │ │ -}; │ │ │ │ +********** nnoonnee__sseett(()) ********** │ │ │ │ +bool nnoonnee__sseett () const noexcept; │ │ │ │ +returns true if no bit in the _b_i_t_f_i_e_l_d is set │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nneeww__ccoonnnneeccttiioonn(()) ********** │ │ │ │ -virtual std::shared_ptr nneeww__ccoonnnneeccttiioonn (peer_connection_handle │ │ │ │ -const&); │ │ │ │ -This function is called each time a new peer is connected to the torrent. You │ │ │ │ -may choose to ignore this by just returning a default constructed shared_ptr │ │ │ │ -(in which case you don't need to override this member function). │ │ │ │ -If you need an extension to the peer connection (which most plugins do) you are │ │ │ │ -supposed to return an instance of your _p_e_e_r___p_l_u_g_i_n class. Which in turn will │ │ │ │ -have its hook functions called on event specific to that peer. │ │ │ │ -The peer_connection_handle will be valid as long as the shared_ptr is being │ │ │ │ -held by the torrent object. So, it is generally a good idea to not keep a │ │ │ │ -shared_ptr to your own _p_e_e_r___p_l_u_g_i_n. If you want to keep references to it, use │ │ │ │ -weak_ptr. │ │ │ │ -If this function throws an exception, the connection will be closed. │ │ │ │ +********** ssiizzee(()) ********** │ │ │ │ +int ssiizzee () const noexcept; │ │ │ │ +returns the size of the _b_i_t_f_i_e_l_d in bits. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) ********** │ │ │ │ -virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t); │ │ │ │ -virtual void oonn__ppiieeccee__ppaassss (piece_index_t); │ │ │ │ -These hooks are called when a piece passes the hash check or fails the hash │ │ │ │ -check, respectively. The index is the piece index that was downloaded. It is │ │ │ │ -possible to access the list of peers that participated in sending the piece │ │ │ │ -through the torrent and the piece_picker. │ │ │ │ +********** nnuumm__wwoorrddss(()) ********** │ │ │ │ +int nnuumm__wwoorrddss () const noexcept; │ │ │ │ +returns the number of 32 bit words are needed to represent all bits in this │ │ │ │ +_b_i_t_f_i_e_l_d. │ │ │ │ [_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. │ │ │ │ +********** nnuumm__bbyytteess(()) ********** │ │ │ │ +int nnuumm__bbyytteess () const noexcept; │ │ │ │ +returns the number of bytes needed to represent all bits in this _b_i_t_f_i_e_l_d │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ppaauussee(()) oonn__rreessuummee(()) ********** │ │ │ │ -virtual bool oonn__rreessuummee (); │ │ │ │ -virtual bool oonn__ppaauussee (); │ │ │ │ -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 │ │ │ │ -will recurse back into your handler, so in order to invoke the standard │ │ │ │ -handler, you have to keep your own state on whether you want standard behavior │ │ │ │ -or overridden behavior. │ │ │ │ +********** eemmppttyy(()) ********** │ │ │ │ +bool eemmppttyy () const noexcept; │ │ │ │ +returns true if the _b_i_t_f_i_e_l_d has zero size. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ffiilleess__cchheecckkeedd(()) ********** │ │ │ │ -virtual void oonn__ffiilleess__cchheecckkeedd (); │ │ │ │ -This function is called when the initial files of the torrent have been │ │ │ │ -checked. If there are no files to check, this function is called immediately. │ │ │ │ -i.e. This function is always called when the torrent is in a state where it can │ │ │ │ -start downloading. │ │ │ │ +********** ddaattaa(()) ********** │ │ │ │ +char* ddaattaa () noexcept; │ │ │ │ +char const* ddaattaa () const noexcept; │ │ │ │ +returns a pointer to the internal buffer of the _b_i_t_f_i_e_l_d, or nullptr if it's │ │ │ │ +empty. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ssttaattee(()) ********** │ │ │ │ -virtual void oonn__ssttaattee (torrent_status::state_t); │ │ │ │ -called when the torrent changes state the state is one of _t_o_r_r_e_n_t___s_t_a_t_u_s_:_: │ │ │ │ -_s_t_a_t_e___t enum members │ │ │ │ +********** sswwaapp(()) ********** │ │ │ │ +void sswwaapp (bitfield& rhs) noexcept; │ │ │ │ +swaps the bit-fields two variables refer to │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__aadddd__ppeeeerr(()) ********** │ │ │ │ -virtual void oonn__aadddd__ppeeeerr (tcp::endpoint const&, │ │ │ │ - peer_source_flags_t, add_peer_flags_t); │ │ │ │ -called every time a new peer is added to the peer list. This is before the peer │ │ │ │ -is connected to. For flags, see torrent_plugin::flags_t. The source argument │ │ │ │ -refers to the source where we learned about this peer from. It's a bitmask, │ │ │ │ -because many sources may have told us about the same peer. For peer source │ │ │ │ -flags, see peer_info::peer_source_flags. │ │ │ │ +********** ccoouunntt(()) ********** │ │ │ │ +int ccoouunntt () const noexcept; │ │ │ │ +count the number of bits in the _b_i_t_f_i_e_l_d that are set to 1. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - first_time │ │ │ │ - this is the first time we see this peer │ │ │ │ +********** ffiinndd__ffiirrsstt__sseett(()) ********** │ │ │ │ +int ffiinndd__ffiirrsstt__sseett () const noexcept; │ │ │ │ +returns the index of the first set bit in the _b_i_t_f_i_e_l_d, i.e. 1 bit. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - filtered │ │ │ │ - this peer was not added because it was filtered by the IP filter │ │ │ │ +********** ffiinndd__llaasstt__cclleeaarr(()) ********** │ │ │ │ +int ffiinndd__llaasstt__cclleeaarr () const noexcept; │ │ │ │ +returns the index to the last cleared bit in the _b_i_t_f_i_e_l_d, i.e. 0 bit. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__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" │ │ │ │ -peer plugins are associated with a specific peer. A peer could be both a │ │ │ │ -regular bittorrent peer (bt_peer_connection) or one of the web seed connections │ │ │ │ -(web_peer_connection). In order to only attach to certain peers, make your │ │ │ │ -torrent_plugin::new_connection only return a _p_l_u_g_i_n for certain peer connection │ │ │ │ -types │ │ │ │ -struct peer_plugin │ │ │ │ +************ ssttaattss__mmeettrriicc ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ +describes one statistics metric from the _s_e_s_s_i_o_n. For more information, see the │ │ │ │ +_s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ +struct stats_metric │ │ │ │ { │ │ │ │ - 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__rreeqquueesstt (peer_request const&); │ │ │ │ - virtual bool oonn__hhaavvee (piece_index_t); │ │ │ │ - virtual bool oonn__hhaavvee__aallll (); │ │ │ │ - virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t); │ │ │ │ - virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//); │ │ │ │ - virtual bool oonn__ddoonntt__hhaavvee (piece_index_t); │ │ │ │ - virtual bool oonn__nnoott__iinntteerreesstteedd (); │ │ │ │ - virtual bool oonn__uunncchhookkee (); │ │ │ │ - virtual bool oonn__hhaavvee__nnoonnee (); │ │ │ │ - virtual bool oonn__iinntteerreesstteedd (); │ │ │ │ - virtual bool oonn__cchhookkee (); │ │ │ │ - virtual bool oonn__ppiieeccee (peer_request const& //**ppiieeccee**// │ │ │ │ - , span //**bbuuff**//); │ │ │ │ - virtual bool oonn__ssuuggggeesstt (piece_index_t); │ │ │ │ - virtual bool oonn__ccaanncceell (peer_request const&); │ │ │ │ - virtual bool oonn__rreejjeecctt (peer_request const&); │ │ │ │ - virtual void sseenntt__aallllooww__ffaasstt (piece_index_t); │ │ │ │ - virtual void sseenntt__ppiieeccee (peer_request const&); │ │ │ │ - virtual void sseenntt__hhaavvee (piece_index_t); │ │ │ │ - virtual void sseenntt__ssuuggggeesstt (piece_index_t); │ │ │ │ - virtual void sseenntt__uunncchhookkee (); │ │ │ │ - virtual void sseenntt__nnoott__iinntteerreesstteedd (); │ │ │ │ - virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&); │ │ │ │ - virtual void sseenntt__hhaavvee__nnoonnee (); │ │ │ │ - virtual void sseenntt__hhaavvee__aallll (); │ │ │ │ - virtual void sseenntt__iinntteerreesstteedd (); │ │ │ │ - virtual void sseenntt__ccaanncceell (peer_request const&); │ │ │ │ - virtual void sseenntt__cchhookkee (); │ │ │ │ - virtual void sseenntt__rreeqquueesstt (peer_request const&); │ │ │ │ - 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__ffaaiilleedd (piece_index_t); │ │ │ │ - virtual void oonn__ppiieeccee__ppaassss (piece_index_t); │ │ │ │ - virtual void ttiicckk (); │ │ │ │ - virtual bool wwrriittee__rreeqquueesstt (peer_request const&); │ │ │ │ + char const* name; │ │ │ │ + int value_index; │ │ │ │ + metric_type_t type; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttyyppee(()) ********** │ │ │ │ -virtual string_view ttyyppee () const; │ │ │ │ -This function is expected to return the name of the _p_l_u_g_i_n. │ │ │ │ + name │ │ │ │ + the name of the counter or gauge │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__hhaannddsshhaakkee(()) ********** │ │ │ │ -virtual void aadddd__hhaannddsshhaakkee (entry&); │ │ │ │ -can add entries to the extension handshake this is not called for web seeds │ │ │ │ + value_index type │ │ │ │ + the index into the _s_e_s_s_i_o_n stats array, where the underlying value of │ │ │ │ + this counter or gauge is found. The _s_e_s_s_i_o_n stats array is part of the │ │ │ │ + _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ddiissccoonnnneecctt(()) ********** │ │ │ │ -virtual void oonn__ddiissccoonnnneecctt (error_code const&); │ │ │ │ -called when the peer is being disconnected. │ │ │ │ +************ ccoouunntteerrss ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_r_f_o_r_m_a_n_c_e___c_o_u_n_t_e_r_s_._h_p_p" │ │ │ │ +holds the session-wide _c_o_u_n_t_e_r_s and gauges backing the session_stats_alert and │ │ │ │ +session_status reporting paths. One instance lives on the _s_e_s_s_i_o_n and is │ │ │ │ +incremented from the network thread; reads from other threads use the lock-free │ │ │ │ +operator[] overload when ATOMIC_LLONG_LOCK_FREE is set, otherwise a single │ │ │ │ +shared mutex guards the whole array. │ │ │ │ +A reference to this object is passed to custom disk I/O implementations (see │ │ │ │ +_d_i_s_k___i_n_t_e_r_f_a_c_e and the disk_io_constructor passed via _s_e_s_s_i_o_n___p_a_r_a_m_s), which │ │ │ │ +update the disk related metrics through it. The specific _c_o_u_n_t_e_r_s and gauges │ │ │ │ +are documented under the _s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ +struct counters │ │ │ │ +{ │ │ │ │ + ccoouunntteerrss () ; │ │ │ │ + counters& ooppeerraattoorr== (counters const&) & ; │ │ │ │ + ccoouunntteerrss (counters const&) ; │ │ │ │ + std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ + std::int64_t ooppeerraattoorr[[]] (int i) const ; │ │ │ │ + void sseett__vvaalluuee (int c, std::int64_t value) ; │ │ │ │ + void bblleenndd__ssttaattss__ccoouunntteerr (int c, std::int64_t value, int ratio) ; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ccoonnnneecctteedd(()) ********** │ │ │ │ -virtual void oonn__ccoonnnneecctteedd (); │ │ │ │ -called when the peer is successfully connected. Note that incoming connections │ │ │ │ -will have been connected by the time the peer _p_l_u_g_i_n is attached to it, and │ │ │ │ -won't have this hook called. │ │ │ │ +********** iinncc__ssttaattss__ccoouunntteerr(()) ********** │ │ │ │ +std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ +increments the counter or gauge c (an index into the counter array) by value │ │ │ │ +and returns the new value. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__hhaannddsshhaakkee(()) ********** │ │ │ │ -virtual bool oonn__hhaannddsshhaakkee (span); │ │ │ │ -this is called when the initial bittorrent handshake is received. Returning │ │ │ │ -false means that the other end doesn't support this extension and will remove │ │ │ │ -it from the list of plugins. this is not called for web seeds │ │ │ │ +********** ooppeerraattoorr[[]](()) ********** │ │ │ │ +std::int64_t ooppeerraattoorr[[]] (int i) const ; │ │ │ │ +returns the current value of counter or gauge i (an index into the counter │ │ │ │ +array). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** 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 │ │ │ │ +********** bblleenndd__ssttaattss__ccoouunntteerr(()) sseett__vvaalluuee(()) ********** │ │ │ │ +void sseett__vvaalluuee (int c, std::int64_t value) ; │ │ │ │ +void bblleenndd__ssttaattss__ccoouunntteerr (int c, std::int64_t value, int ratio) ; │ │ │ │ +overwrites the value of counter or gauge c (an index into the counter array). │ │ │ │ +blend_stats_counter() adjusts the stat value toward the specified value, ratio │ │ │ │ +specifies the percent of the new value should be influenced by value. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ddoonntt__hhaavvee(()) oonn__hhaavvee__nnoonnee(()) oonn__rreeqquueesstt(()) oonn__iinntteerreesstteedd(()) │ │ │ │ -oonn__nnoott__iinntteerreesstteedd(()) oonn__hhaavvee__aallll(()) oonn__bbiittffiieelldd(()) oonn__aalllloowweedd__ffaasstt(()) oonn__cchhookkee(()) │ │ │ │ -oonn__uunncchhookkee(()) oonn__hhaavvee(()) ********** │ │ │ │ -virtual bool oonn__rreeqquueesstt (peer_request const&); │ │ │ │ -virtual bool oonn__hhaavvee (piece_index_t); │ │ │ │ -virtual bool oonn__hhaavvee__aallll (); │ │ │ │ -virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t); │ │ │ │ -virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//); │ │ │ │ -virtual bool oonn__ddoonntt__hhaavvee (piece_index_t); │ │ │ │ -virtual bool oonn__nnoott__iinntteerreesstteedd (); │ │ │ │ -virtual bool oonn__uunncchhookkee (); │ │ │ │ -virtual bool oonn__hhaavvee__nnoonnee (); │ │ │ │ -virtual bool oonn__iinntteerreesstteedd (); │ │ │ │ -virtual bool oonn__cchhookkee (); │ │ │ │ -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. │ │ │ │ +************ sseessssiioonn__ssttaattss__mmeettrriiccss(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ +std::vector sseessssiioonn__ssttaattss__mmeettrriiccss (); │ │ │ │ +This free function returns the list of available metrics exposed by │ │ │ │ +libtorrent's statistics API. Each metric has a name and a vvaalluuee iinnddeexx. The │ │ │ │ +value index is the index into the array in _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t where this │ │ │ │ +metric's value can be found when the _s_e_s_s_i_o_n stats is sampled (by calling │ │ │ │ +_p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_)). │ │ │ │ [_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. │ │ │ │ +************ ffiinndd__mmeettrriicc__iiddxx(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ +int ffiinndd__mmeettrriicc__iiddxx (string_view name); │ │ │ │ +given a name of a metric, this function returns the counter index of it, or - │ │ │ │ +1 if it could not be found. The counter index is the index into the values │ │ │ │ +array returned by _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ccaanncceell(()) oonn__rreejjeecctt(()) oonn__ssuuggggeesstt(()) ********** │ │ │ │ -virtual bool oonn__ssuuggggeesstt (piece_index_t); │ │ │ │ -virtual bool oonn__ccaanncceell (peer_request const&); │ │ │ │ -virtual bool oonn__rreejjeecctt (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. │ │ │ │ +************ eennuumm mmeettrriicc__ttyyppee__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_c_o_u_n_t_e_r_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_g_a_u_g_e_ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseenntt__ssuuggggeesstt(()) sseenntt__hhaavvee__aallll(()) sseenntt__hhaavvee__nnoonnee(()) sseenntt__uunncchhookkee(()) │ │ │ │ -sseenntt__iinntteerreesstteedd(()) sseenntt__nnoott__iinntteerreesstteedd(()) sseenntt__ccaanncceell(()) sseenntt__rreeqquueesstt(()) │ │ │ │ -sseenntt__rreejjeecctt__rreeqquueesstt(()) sseenntt__ppiieeccee(()) sseenntt__cchhookkee(()) sseenntt__aallllooww__ffaasstt(()) sseenntt__hhaavvee(()) │ │ │ │ -********** │ │ │ │ -virtual void sseenntt__aallllooww__ffaasstt (piece_index_t); │ │ │ │ -virtual void sseenntt__ppiieeccee (peer_request const&); │ │ │ │ -virtual void sseenntt__hhaavvee (piece_index_t); │ │ │ │ -virtual void sseenntt__ssuuggggeesstt (piece_index_t); │ │ │ │ -virtual void sseenntt__uunncchhookkee (); │ │ │ │ -virtual void sseenntt__nnoott__iinntteerreesstteedd (); │ │ │ │ -virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&); │ │ │ │ -virtual void sseenntt__hhaavvee__nnoonnee (); │ │ │ │ -virtual void sseenntt__hhaavvee__aallll (); │ │ │ │ -virtual void sseenntt__iinntteerreesstteedd (); │ │ │ │ -virtual void sseenntt__ccaanncceell (peer_request const&); │ │ │ │ -virtual void sseenntt__cchhookkee (); │ │ │ │ -virtual void sseenntt__rreeqquueesstt (peer_request const&); │ │ │ │ -called after the corresponding message has been sent to the peer. │ │ │ │ +************ aannnnoouunnccee__iinnffoohhaasshh ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ +holds the per-info-hash state for a tracker, separately for the v1 and v2 info- │ │ │ │ +hashes. Since a hybrid torrent has both info-hashes, the state for the two │ │ │ │ +announces (the message returned by the tracker, the time of the next announce, │ │ │ │ +the most recent scrape numbers, etc.) are kept independently. announce_endpoint │ │ │ │ +owns one announce_infohash for each protocol version. │ │ │ │ +struct announce_infohash │ │ │ │ +{ │ │ │ │ + std::string message; │ │ │ │ + error_code last_error; │ │ │ │ + int ssccrraappee__iinnccoommpplleettee = -1; │ │ │ │ + int ssccrraappee__ccoommpplleettee = -1; │ │ │ │ + int ssccrraappee__ddoowwnnllooaaddeedd = -1; │ │ │ │ + std::uint8_t fails : 7; │ │ │ │ + bool updating : 1; │ │ │ │ + bool start_sent : 1; │ │ │ │ + bool complete_sent : 1; │ │ │ │ +}; │ │ │ │ [_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 │ │ │ │ + message │ │ │ │ + if this tracker has returned an error or warning message that message is │ │ │ │ + stored here │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccaann__ddiissccoonnnneecctt(()) ********** │ │ │ │ -virtual bool ccaann__ddiissccoonnnneecctt (error_code const& //**eecc**//); │ │ │ │ -called when libtorrent think this peer should be disconnected. if the _p_l_u_g_i_n │ │ │ │ -returns false, the peer will not be disconnected. │ │ │ │ + last_error │ │ │ │ + if this tracker failed the last time it was contacted this error code │ │ │ │ + specifies what error occurred │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__eexxtteennddeedd(()) ********** │ │ │ │ -virtual bool oonn__eexxtteennddeedd (int //**lleennggtthh**//, int //**mmssgg**//, │ │ │ │ - span //**bbooddyy**//); │ │ │ │ -called when an extended message is received. If returning true, the message is │ │ │ │ -not processed by any other _p_l_u_g_i_n and if false is returned the next _p_l_u_g_i_n in │ │ │ │ -the chain will receive it to be able to handle it. This is not called for web │ │ │ │ -seeds. thus function may be called more than once per incoming message, but │ │ │ │ -only the last of the calls will the body size equal the length. i.e. Every time │ │ │ │ -another fragment of the message is received, this function will be called, │ │ │ │ -until finally the whole message has been received. The purpose of this is to │ │ │ │ -allow early disconnects for invalid messages and for reporting progress of │ │ │ │ -receiving large messages. │ │ │ │ + scrape_incomplete scrape_complete scrape_downloaded │ │ │ │ + if this tracker has returned scrape data, these fields are filled in with │ │ │ │ + valid numbers. Otherwise they are set to -1. incomplete counts the number │ │ │ │ + of current downloaders. complete counts the number of current peers │ │ │ │ + completed the download, or "seeds". downloaded is the cumulative number │ │ │ │ + of completed downloads. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__uunnkknnoowwnn__mmeessssaaggee(()) ********** │ │ │ │ -virtual bool oonn__uunnkknnoowwnn__mmeessssaaggee (int //**lleennggtthh**//, int //**mmssgg**//, │ │ │ │ - span //**bbooddyy**//); │ │ │ │ -this is not called for web seeds │ │ │ │ + fails │ │ │ │ + the number of times in a row we have failed to announce to this tracker. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) ********** │ │ │ │ -virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t); │ │ │ │ -virtual void oonn__ppiieeccee__ppaassss (piece_index_t); │ │ │ │ -called when a piece that this peer participated in either fails or passes the │ │ │ │ -hash_check │ │ │ │ + updating │ │ │ │ + true while we're waiting for a response from the tracker. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttiicckk(()) ********** │ │ │ │ -virtual void ttiicckk (); │ │ │ │ -called approximately once every second │ │ │ │ + start_sent │ │ │ │ + set to true when we get a valid response from an announce with │ │ │ │ + event=started. If it is set, we won't send start in the subsequent │ │ │ │ + announces. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** wwrriittee__rreeqquueesstt(()) ********** │ │ │ │ -virtual bool wwrriittee__rreeqquueesstt (peer_request const&); │ │ │ │ -called each time a request message is to be sent. If true is returned, the │ │ │ │ -original request message won't be sent and no other _p_l_u_g_i_n will have this │ │ │ │ -function called. │ │ │ │ + complete_sent │ │ │ │ + set to true when we send a event=completed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ccrryyppttoo__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" │ │ │ │ -interface implemented by a _p_l_u_g_i_n that wants to take over the encryption / │ │ │ │ -decryption of a peer connection. Returned by peer_plugin::wrap_socket() to plug │ │ │ │ -into the BitTorrent peer connection's send / receive path. Used by the built-in │ │ │ │ -protocol encryption (MSE) implementation. │ │ │ │ -struct crypto_plugin │ │ │ │ +************ aannnnoouunnccee__eennddppooiinntt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ +announces are sent to each tracker using every listen socket this class holds │ │ │ │ +information about one listen socket for one tracker │ │ │ │ +struct announce_endpoint │ │ │ │ { │ │ │ │ - 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; │ │ │ │ + aannnnoouunnccee__eennddppooiinntt (); │ │ │ │ + │ │ │ │ + _t_c_p_:_:_e_n_d_p_o_i_n_t local_endpoint; │ │ │ │ + aux::array info_hashes; │ │ │ │ + bool eennaabblleedd = true; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__iinnccoommiinngg__kkeeyy(()) sseett__oouuttggooiinngg__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. │ │ │ │ + local_endpoint │ │ │ │ + the local endpoint of the listen interface associated with this endpoint │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennccrryypptt(()) ********** │ │ │ │ -eennccrryypptt (span> //**sseenndd__vveecc**//) = 0; │ │ │ │ -encrypted the provided buffers and returns the number of bytes which are now │ │ │ │ -ready to be sent to the lower layer. This must be at least as large as the │ │ │ │ -number of bytes passed in and may be larger if there is additional data to be │ │ │ │ -inserted at the head of the send buffer. The additional data is returned as the │ │ │ │ -second tuple value. Any returned buffer as well as the iovec itself, to be │ │ │ │ -prepended to the send buffer, must be owned by the crypto _p_l_u_g_i_n and guaranteed │ │ │ │ -to stay alive until the _c_r_y_p_t_o___p_l_u_g_i_n is destructed or this function is called │ │ │ │ -again. │ │ │ │ + info_hashes │ │ │ │ + info_hashes[0] is the v1 info hash (SHA1) info_hashes[1] is the v2 info │ │ │ │ + hash (truncated SHA-256) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddeeccrryypptt(()) ********** │ │ │ │ -virtual std::tuple ddeeccrryypptt (span> //**rreecceeiivvee__vveecc**//) = │ │ │ │ -0; │ │ │ │ -decrypt the provided buffers. returns is a tuple representing the values │ │ │ │ -(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 │ │ │ │ + enabled │ │ │ │ + set to false to not announce from this endpoint │ │ │ │ [_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 │ │ │ │ +************ aannnnoouunnccee__eennttrryy ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ +this class holds information about one bittorrent tracker, as it relates to a │ │ │ │ +specific torrent. │ │ │ │ +struct announce_entry │ │ │ │ { │ │ │ │ - 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 mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr (); │ │ │ │ - void cchhookkee__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; │ │ │ │ - bool iiss__oouuttggooiinngg () const; │ │ │ │ - bool iiss__ccoonnnneeccttiinngg () const; │ │ │ │ - void ddiissccoonnnneecctt (error_code const& ec, operation_t op │ │ │ │ - , disconnect_severity_t = peer_connection_interface::normal); │ │ │ │ - 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); │ │ │ │ - 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; │ │ │ │ + explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ + announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ + aannnnoouunnccee__eennttrryy (); │ │ │ │ + aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ + ~~aannnnoouunnccee__eennttrryy (); │ │ │ │ + │ │ │ │ + enum tracker_source │ │ │ │ + { │ │ │ │ + source_torrent, │ │ │ │ + source_client, │ │ │ │ + source_magnet_link, │ │ │ │ + source_tex, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + std::string url; │ │ │ │ + std::string trackerid; │ │ │ │ + std::vector endpoints; │ │ │ │ + std::uint8_t ttiieerr = 0; │ │ │ │ + std::uint8_t ffaaiill__lliimmiitt = 0; │ │ │ │ + std::uint8_t source:4; │ │ │ │ + bool verified:1; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** 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. │ │ │ │ +********** ooppeerraattoorr==(()) aannnnoouunnccee__eennttrryy(()) ~~aannnnoouunnccee__eennttrryy(()) ********** │ │ │ │ +explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ +announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ +aannnnoouunnccee__eennttrryy (); │ │ │ │ +aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ +~~aannnnoouunnccee__eennttrryy (); │ │ │ │ +constructs a tracker announce _e_n_t_r_y with u as the URL. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttyyppee(()) ********** │ │ │ │ -connection_type ttyyppee () const; │ │ │ │ -the protocol type of this connection (bittorrent, url_seed, http_seed) │ │ │ │ +********** eennuumm ttrraacckkeerr__ssoouurrccee ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_u_r_c_e___t_o_r_r_e_n_t_ _ _ _ _|_1_ _ _ _ _|_t_h_e_ _t_r_a_c_k_e_r_ _w_a_s_ _p_a_r_t_ _o_f_ _t_h_e_ _._t_o_r_r_e_n_t_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|source_client |2 |the tracker was added programmatically via the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_d_d___t_r_a_c_k_e_r_(_)_ _f_u_n_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_u_r_c_e___m_a_g_n_e_t___l_i_n_k_|_4_ _ _ _ _|_t_h_e_ _t_r_a_c_k_e_r_ _w_a_s_ _p_a_r_t_ _o_f_ _a_ _m_a_g_n_e_t_ _l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|source_tex |8 |the tracker was received from the swarm via tracker| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_c_h_a_n_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_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. │ │ │ │ + url │ │ │ │ + tracker URL as it appeared in the torrent file │ │ │ │ [_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 │ │ │ │ + trackerid │ │ │ │ + the current &trackerid= argument passed to the tracker. this is optional │ │ │ │ + and is normally empty (in which case no trackerid is sent). │ │ │ │ [_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) │ │ │ │ + endpoints │ │ │ │ + each local listen socket (endpoint) will announce to the tracker. This │ │ │ │ + list contains state per endpoint. │ │ │ │ [_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. │ │ │ │ + tier │ │ │ │ + the tier this tracker belongs to │ │ │ │ [_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). │ │ │ │ + fail_limit │ │ │ │ + the max number of failures to announce to this tracker in a row, before │ │ │ │ + this tracker is not used anymore. 0 means unlimited │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaass__ppeeeerr__cchhookkeedd(()) iiss__ppeeeerr__iinntteerreesstteedd(()) ********** │ │ │ │ -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. │ │ │ │ + source │ │ │ │ + a bitmask specifying which sources we got this tracker from. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cchhookkee__tthhiiss__ppeeeerr(()) mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr(()) ********** │ │ │ │ -void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr (); │ │ │ │ -void cchhookkee__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. │ │ │ │ + verified │ │ │ │ + set to true the first time we receive a valid response from this tracker. │ │ │ │ +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] │ │ │ │ -********** 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_(_). │ │ │ │ +************ 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__bbooooll (int name, bool 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 std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ + virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ +}; │ │ │ │ [_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. │ │ │ │ +********** sseett__bbooooll(()) sseett__ssttrr(()) sseett__iinntt(()) ********** │ │ │ │ +virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ +virtual void sseett__bbooooll (int name, bool 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] │ │ │ │ -********** 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. │ │ │ │ +********** 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] │ │ │ │ -********** ddiissccoonnnneecctt(()) iiss__oouuttggooiinngg(()) iiss__ddiissccoonnnneeccttiinngg(()) iiss__ccoonnnneeccttiinngg(()) ********** │ │ │ │ -bool iiss__ddiissccoonnnneeccttiinngg () const; │ │ │ │ -bool iiss__oouuttggooiinngg () const; │ │ │ │ -bool iiss__ccoonnnneeccttiinngg () const; │ │ │ │ -void ddiissccoonnnneecctt (error_code const& ec, operation_t op │ │ │ │ - , disconnect_severity_t = peer_connection_interface::normal); │ │ │ │ -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. │ │ │ │ +********** ggeett__ssttrr(()) ggeett__iinntt(()) ggeett__bbooooll(()) ********** │ │ │ │ +virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ +virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ +virtual int ggeett__iinntt (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] │ │ │ │ -********** 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. │ │ │ │ +************ ooppeenn__ffiillee__ssttaattee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___i_n_t_e_r_f_a_c_e_._h_p_p" │ │ │ │ +this contains information about a file that's currently open by the libtorrent │ │ │ │ +disk I/O subsystem. It's associated with a single torrent. │ │ │ │ +struct open_file_state │ │ │ │ +{ │ │ │ │ + file_index_t file_index; │ │ │ │ + file_open_mode_t open_mode; │ │ │ │ + time_point last_use; │ │ │ │ +}; │ │ │ │ [_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) │ │ │ │ + file_index │ │ │ │ + the index of the file this _e_n_t_r_y refers to into the file_storage file │ │ │ │ + list of this torrent. This starts indexing at 0. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppeeeerr__lloogg(()) sshhoouulldd__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. │ │ │ │ + open_mode │ │ │ │ + open_mode is a bitmask of the file flags this file is currently opened │ │ │ │ + with. For possible flags, see _f_i_l_e___o_p_e_n___m_o_d_e___t. │ │ │ │ + Note that the read/write mode is not a bitmask. The two least significant │ │ │ │ + bits are used to represent the read/write mode. Those bits can be masked │ │ │ │ + out using the rw_mask constant. │ │ │ │ [_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). │ │ │ │ + last_use │ │ │ │ + a (high precision) timestamp of when the file was last used. │ │ │ │ [_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 │ │ │ │ +************ ddiisskk__iinntteerrffaaccee ************ │ │ │ │ +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" │ │ │ │ +The _d_i_s_k___i_n_t_e_r_f_a_c_e is the customization point for disk I/O in libtorrent. │ │ │ │ +implement this interface and provide a factory function to the _s_e_s_s_i_o_n │ │ │ │ +constructor use custom disk I/O. All functions on the disk subsystem │ │ │ │ +(implementing _d_i_s_k___i_n_t_e_r_f_a_c_e) are called from within libtorrent's network │ │ │ │ +thread. For disk I/O to be performed in a separate thread, the disk subsystem │ │ │ │ +has to manage that itself. │ │ │ │ +Although the functions are called async_*, they do not technically hhaavvee to be │ │ │ │ +asynchronous, but they support being asynchronous, by expecting the result │ │ │ │ +passed back into a callback. The callbacks must be posted back onto the network │ │ │ │ +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 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 │ │ │ │ + , std::function handler) = 0; │ │ │ │ + virtual void aassyynncc__mmoovvee__ssttoorraaggee (storage_index_t storage, std::string p, │ │ │ │ +move_flags_t flags │ │ │ │ + , std::function │ │ │ │ +handler) = 0; │ │ │ │ + virtual void aassyynncc__rreelleeaassee__ffiilleess (storage_index_t storage │ │ │ │ + , std::function handler = std::function()) = 0; │ │ │ │ + virtual void aassyynncc__cchheecckk__ffiilleess (storage_index_t storage │ │ │ │ + , add_torrent_params const* resume_data │ │ │ │ + , aux::vector links │ │ │ │ + , std::function handler) = 0; │ │ │ │ + virtual void aassyynncc__ssttoopp__ttoorrrreenntt (storage_index_t storage │ │ │ │ + , std::function handler = std::function()) = 0; │ │ │ │ + virtual void aassyynncc__rreennaammee__ffiillee (storage_index_t storage │ │ │ │ + , file_index_t index, std::string name │ │ │ │ + , std::function handler) = 0; │ │ │ │ + virtual void aassyynncc__ddeelleettee__ffiilleess (storage_index_t storage, remove_flags_t │ │ │ │ +options │ │ │ │ + , std::function handler) = 0; │ │ │ │ + virtual void aassyynncc__sseett__ffiillee__pprriioorriittyy (storage_index_t storage │ │ │ │ + , aux::vector prio │ │ │ │ + , std::function)> handler) = 0; │ │ │ │ + virtual void aassyynncc__cclleeaarr__ppiieeccee (storage_index_t storage, piece_index_t index │ │ │ │ + , std::function handler) = 0; │ │ │ │ + virtual void uuppddaattee__ssttaattss__ccoouunntteerrss (counters& c) const = 0; │ │ │ │ + virtual std::vector ggeett__ssttaattuuss (storage_index_t) const = 0; │ │ │ │ + virtual void aabboorrtt (bool wait) = 0; │ │ │ │ + virtual void ssuubbmmiitt__jjoobbss () = 0; │ │ │ │ + virtual void sseettttiinnggss__uuppddaatteedd () = 0; │ │ │ │ + │ │ │ │ + static inline constexpr disk_job_flags_t ffoorrccee__ccooppyy = 0_bit; │ │ │ │ + static inline constexpr disk_job_flags_t sseeqquueennttiiaall__aacccceessss = 3_bit; │ │ │ │ + static inline constexpr disk_job_flags_t vvoollaattiillee__rreeaadd = 4_bit; │ │ │ │ + static inline constexpr disk_job_flags_t vv11__hhaasshh = 5_bit; │ │ │ │ + static constexpr disk_job_flags_t fflluusshh__ppiieeccee = 7_bit; │ │ │ │ +}; │ │ │ │ [_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 │ │ │ │ +********** nneeww__ttoorrrreenntt(()) ********** │ │ │ │ +virtual storage_holder nneeww__ttoorrrreenntt (storage_params const& p │ │ │ │ + , std::shared_ptr const& torrent) = 0; │ │ │ │ +this is called when a new torrent is added. The shared_ptr can be used to hold │ │ │ │ +the internal torrent object alive as long as there are outstanding disk │ │ │ │ +operations on the storage. The returned _s_t_o_r_a_g_e___h_o_l_d_e_r is an owning reference │ │ │ │ +to the underlying storage that was just created. It is fundamentally a │ │ │ │ +storage_index_t │ │ │ │ [_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. │ │ │ │ +********** 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] │ │ │ │ -********** 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. │ │ │ │ +********** 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 │ │ │ │ +will stop further writes and wait for the passed-in disk_observer to be │ │ │ │ +notified before resuming. │ │ │ │ +Note that for async_read, the _p_e_e_r___r_e_q_u_e_s_t (r) is not necessarily aligned to │ │ │ │ +blocks (but it is most of the time). However, all writes (passed to │ │ │ │ +async_write) are guaranteed to be block aligned. │ │ │ │ [_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. │ │ │ │ +********** aassyynncc__hhaasshh(()) ********** │ │ │ │ +virtual void aassyynncc__hhaasshh (storage_index_t storage, piece_index_t piece, │ │ │ │ +span v2 │ │ │ │ + , disk_job_flags_t flags │ │ │ │ + , std::function handler) = 0; │ │ │ │ +Compute hash(es) for the specified piece. Unless the v1_hash flag is set (in │ │ │ │ +flags), the SHA-1 hash of the whole piece does not need to be computed. │ │ │ │ +Thev2span is optional and can be empty, which means v2 hashes should not be │ │ │ │ +computed. If v2 is non-empty it must be at least large enough to hold all v2 │ │ │ │ +blocks in the piece, and this function will fill in the span with the SHA-256 │ │ │ │ +block hashes of the piece. │ │ │ │ +The contents of thev2span on _e_n_t_r_y are not read by the implementation; it is │ │ │ │ +treated as output only. Callers may safely reuse the same buffer across pieces │ │ │ │ +without clearing it. │ │ │ │ [_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; │ │ │ │ -}; │ │ │ │ +********** aassyynncc__hhaasshh22(()) ********** │ │ │ │ +virtual void aassyynncc__hhaasshh22 (storage_index_t storage, piece_index_t piece, int │ │ │ │ +offset, disk_job_flags_t flags │ │ │ │ + , std::function handler) = 0; │ │ │ │ +computes the v2 hash (SHA-256) of a single block. The block at offset in piece │ │ │ │ +piece. │ │ │ │ [_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. │ │ │ │ +********** aassyynncc__mmoovvee__ssttoorraaggee(()) ********** │ │ │ │ +virtual void aassyynncc__mmoovvee__ssttoorraaggee (storage_index_t storage, std::string p, │ │ │ │ +move_flags_t flags │ │ │ │ + , std::function │ │ │ │ +handler) = 0; │ │ │ │ +called to request the files for the specified storage/torrent be moved to a new │ │ │ │ +location. It is the disk I/O object's responsibility to synchronize this with │ │ │ │ +any currently outstanding disk operations to the storage. Whether files are │ │ │ │ +replaced at the destination path or not is controlled by flags (see │ │ │ │ +_m_o_v_e___f_l_a_g_s___t). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssuuppppoorrtt__eexxtteennssiioonnss(()) ppaacckkeett__ffiinniisshheedd(()) ********** │ │ │ │ -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). │ │ │ │ +********** aassyynncc__rreelleeaassee__ffiilleess(()) ********** │ │ │ │ +virtual void aassyynncc__rreelleeaassee__ffiilleess (storage_index_t storage │ │ │ │ + , std::function handler = std::function()) = 0; │ │ │ │ +This is called on disk I/O objects to request they close all open files for the │ │ │ │ +specified storage/torrent. If file handles are not pooled/cached, it can be a │ │ │ │ +no-op. For truly asynchronous disk I/O, this should provide at least one point │ │ │ │ +in time when all files are closed. It is possible that later asynchronous │ │ │ │ +operations will re-open some of the files, by the time this completion handler │ │ │ │ +is called, that's fine. │ │ │ │ [_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 │ │ │ │ +********** aassyynncc__cchheecckk__ffiilleess(()) ********** │ │ │ │ +virtual void aassyynncc__cchheecckk__ffiilleess (storage_index_t storage │ │ │ │ + , add_torrent_params const* resume_data │ │ │ │ + , aux::vector links │ │ │ │ + , std::function handler) = 0; │ │ │ │ +this is called when torrents are added to validate their resume data against │ │ │ │ +the files on disk. This function is expected to do a few things: │ │ │ │ +if links is non-empty, it contains a string for each file in the torrent. The │ │ │ │ +string being a path to an existing identical file. The default behavior is to │ │ │ │ +create hard links of those files into the storage of the new torrent (specified │ │ │ │ +by storage). An empty string indicates that there is no known identical file. │ │ │ │ +This is part of the "mutable torrent" feature, where files can be reused from │ │ │ │ +other torrents. │ │ │ │ +The resume_data points the resume data passed in by the client. │ │ │ │ +If the resume_data->flags field has the seed_mode flag set, all files/pieces │ │ │ │ +are expected to be on disk already. This should be verified. Not just the │ │ │ │ +existence of the file, but also that it has the correct size. │ │ │ │ +Any file with a piece set in the resume_data->have_pieces bitmask should exist │ │ │ │ +on disk, this should be verified. Pad files and files with zero priority may be │ │ │ │ +skipped. │ │ │ │ [_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. │ │ │ │ +********** aassyynncc__ssttoopp__ttoorrrreenntt(()) ********** │ │ │ │ +virtual void aassyynncc__ssttoopp__ttoorrrreenntt (storage_index_t storage │ │ │ │ + , std::function handler = std::function()) = 0; │ │ │ │ +This is called when a torrent is stopped. It gives the disk I/O object an │ │ │ │ +opportunity to flush any data to disk that's currently kept cached. This │ │ │ │ +function should at least do the same thing as _a_s_y_n_c___r_e_l_e_a_s_e___f_i_l_e_s_(_). │ │ │ │ [_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. │ │ │ │ +********** aassyynncc__rreennaammee__ffiillee(()) ********** │ │ │ │ +virtual void aassyynncc__rreennaammee__ffiillee (storage_index_t storage │ │ │ │ + , file_index_t index, std::string name │ │ │ │ + , std::function handler) = 0; │ │ │ │ +This function is called when the name of a file in the specified storage has │ │ │ │ +been requested to be renamed. The disk I/O object is responsible for renaming │ │ │ │ +the file without racing with other potentially outstanding operations against │ │ │ │ +the file (such as read, write, move, etc.). │ │ │ │ [_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 │ │ │ │ -default unless explicitly disabled in the _s_e_s_s_i_o_n constructor. │ │ │ │ -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_(_). │ │ │ │ +********** aassyynncc__ddeelleettee__ffiilleess(()) ********** │ │ │ │ +virtual void aassyynncc__ddeelleettee__ffiilleess (storage_index_t storage, remove_flags_t │ │ │ │ +options │ │ │ │ + , std::function handler) = 0; │ │ │ │ +This function is called when some file(s) on disk have been requested to be │ │ │ │ +removed by the client. storage indicates which torrent is referred to. See │ │ │ │ +_s_e_s_s_i_o_n___h_a_n_d_l_e for remove_flags_t flags indicating which files are to be │ │ │ │ +removed. e.g. _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_d_e_l_e_t_e___f_i_l_e_s - delete all files _s_e_s_s_i_o_n___h_a_n_d_l_e_:_: │ │ │ │ +_d_e_l_e_t_e___p_a_r_t_f_i_l_e - only delete part file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ccrreeaattee__ssmmaarrtt__bbaann__pplluuggiinn(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_x_t_e_n_s_i_o_n_s_/_s_m_a_r_t___b_a_n_._h_p_p" │ │ │ │ -std::shared_ptr ccrreeaattee__ssmmaarrtt__bbaann__pplluuggiinn (torrent_handle const&, │ │ │ │ -client_data_t); │ │ │ │ -constructor function for the smart ban extension. The extension keeps track of │ │ │ │ -the data peers have sent us for failing pieces and once the piece completes and │ │ │ │ -passes the hash check bans the peers that turned out to have sent corrupt data. │ │ │ │ -This function can either be passed in the add_torrent_params::extensions field, │ │ │ │ -or via _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_(_). │ │ │ │ +********** aassyynncc__sseett__ffiillee__pprriioorriittyy(()) ********** │ │ │ │ +virtual void aassyynncc__sseett__ffiillee__pprriioorriittyy (storage_index_t storage │ │ │ │ + , aux::vector prio │ │ │ │ + , std::function)> handler) = 0; │ │ │ │ +This is called to set the priority of some or all files. Changing the priority │ │ │ │ +from or to 0 may involve moving data to and from the partfile. The disk I/ │ │ │ │ +O object is responsible for correctly synchronizing this work to not race with │ │ │ │ +any potentially outstanding asynchronous operations affecting these files. │ │ │ │ +prio is a vector of the file priority for all files. If it's shorter than the │ │ │ │ +total number of files in the torrent, they are assumed to be set to the default │ │ │ │ +priority. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ccrreeaattee__uutt__mmeettaaddaattaa__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___m_e_t_a_d_a_t_a_._h_p_p" │ │ │ │ -std::shared_ptr ccrreeaattee__uutt__mmeettaaddaattaa__pplluuggiinn (torrent_handle │ │ │ │ -const&, client_data_t); │ │ │ │ -constructor function for the ut_metadata extension. The ut_metadata extension │ │ │ │ -allows peers to request the .torrent file (or more specifically the info- │ │ │ │ -dictionary of the .torrent file) from each other. This is the main building │ │ │ │ -block in making magnet links work. This extension is enabled by default unless │ │ │ │ -explicitly disabled in the _s_e_s_s_i_o_n constructor. │ │ │ │ -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_(_). │ │ │ │ +********** aassyynncc__cclleeaarr__ppiieeccee(()) ********** │ │ │ │ +virtual void aassyynncc__cclleeaarr__ppiieeccee (storage_index_t storage, piece_index_t index │ │ │ │ + , std::function handler) = 0; │ │ │ │ +This is called when a piece fails the hash check, to ensure there are no │ │ │ │ +outstanding disk operations to the piece before blocks are re-requested from │ │ │ │ +peers to overwrite the existing blocks. The disk I/O object does not need to │ │ │ │ +perform any action other than synchronize with all outstanding disk operations │ │ │ │ +to the specified piece before posting the result back. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__sslliiccee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ -represents a window of a file in a torrent. │ │ │ │ -The file_index refers to the index of the file (in the _t_o_r_r_e_n_t___i_n_f_o). To get │ │ │ │ -the path and filename, use file_path() and give the file_index as argument. The │ │ │ │ -offset is the byte offset in the file where the range starts, and size is the │ │ │ │ -number of bytes this range is. The size + offset will never be greater than the │ │ │ │ -file size. │ │ │ │ -struct file_slice │ │ │ │ -{ │ │ │ │ - file_index_t file_index; │ │ │ │ - std::int64_t offset; │ │ │ │ - std::int64_t size; │ │ │ │ -}; │ │ │ │ +********** uuppddaattee__ssttaattss__ccoouunntteerrss(()) ********** │ │ │ │ +virtual void uuppddaattee__ssttaattss__ccoouunntteerrss (counters& c) const = 0; │ │ │ │ +_u_p_d_a_t_e___s_t_a_t_s___c_o_u_n_t_e_r_s_(_) is called to give the disk storage an opportunity to │ │ │ │ +update gauges in the c stats _c_o_u_n_t_e_r_s, that aren't updated continuously as │ │ │ │ +operations are performed. This is called before a snapshot of the _c_o_u_n_t_e_r_s are │ │ │ │ +passed to the client. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - file_index │ │ │ │ - the index of the file │ │ │ │ +********** ggeett__ssttaattuuss(()) ********** │ │ │ │ +virtual std::vector ggeett__ssttaattuuss (storage_index_t) const = 0; │ │ │ │ +Return a list of all the files that are currently open for the specified │ │ │ │ +storage/torrent. This is is just used for the client to query the currently │ │ │ │ +open files, and which modes those files are open in. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - offset │ │ │ │ - the offset from the start of the file, in bytes │ │ │ │ +********** aabboorrtt(()) ********** │ │ │ │ +virtual void aabboorrtt (bool wait) = 0; │ │ │ │ +this is called when the _s_e_s_s_i_o_n is starting to shut down. The disk I/O object │ │ │ │ +is expected to flush any outstanding write jobs, cancel hash jobs and initiate │ │ │ │ +tearing down of any internal threads. If wait is true, this should be │ │ │ │ +asynchronous. i.e. this call should not return until all threads have stopped │ │ │ │ +and all jobs have either been aborted or completed and the disk I/O object is │ │ │ │ +ready to be destructed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - size │ │ │ │ - the size of the window, in bytes │ │ │ │ +********** ssuubbmmiitt__jjoobbss(()) ********** │ │ │ │ +virtual void ssuubbmmiitt__jjoobbss () = 0; │ │ │ │ +This will be called after a batch of disk jobs has been issues (via the async_* │ │ │ │ +). It gives the disk I/O object an opportunity to notify any potential │ │ │ │ +condition variables to wake up the disk thread(s). The async_* calls can of │ │ │ │ +course also notify condition variables, but doing it in this call allows for │ │ │ │ +batching jobs, by issuing the notification once for a collection of jobs. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__ssttoorraaggee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ -The file_storage class represents a file list and the piece size. Everything │ │ │ │ -necessary to interpret a regular bittorrent storage file structure. │ │ │ │ -class file_storage │ │ │ │ +********** sseettttiinnggss__uuppddaatteedd(()) ********** │ │ │ │ +virtual void sseettttiinnggss__uuppddaatteedd () = 0; │ │ │ │ +This is called to notify the disk I/O object that the settings have been │ │ │ │ +updated. In the disk io constructor, a _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e reference is passed │ │ │ │ +in. Whenever these settings are updated, this function is called to allow the │ │ │ │ +disk I/O object to react to any changed settings relevant to its operations. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + force_copy │ │ │ │ + force making a copy of the cached block, rather than getting a reference │ │ │ │ + to a block already in the cache. This is used the block is expected to be │ │ │ │ + overwritten very soon, by _a_s_y_n_c___w_r_i_t_e_(_), and we need access to the │ │ │ │ + previous content. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + sequential_access │ │ │ │ + hint that there may be more disk operations with sequential access to the │ │ │ │ + file │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + volatile_read │ │ │ │ + don't keep the read block in cache. This is a hint that this block is │ │ │ │ + unlikely to be read again anytime soon, and caching it would be wasteful. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + v1_hash │ │ │ │ + compute a v1 piece hash. This is only used by the _a_s_y_n_c___h_a_s_h_(_) call. If │ │ │ │ + this flag is not set in the _a_s_y_n_c___h_a_s_h_(_) call, the SHA-1 piece hash does │ │ │ │ + not need to be computed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + flush_piece │ │ │ │ + this flag instructs a hash job that we just completed this piece, and it │ │ │ │ + should be flushed to disk │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttoorraaggee__hhoollddeerr ************ │ │ │ │ +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" │ │ │ │ +a unique, owning, reference to the storage of a torrent in a disk io subsystem │ │ │ │ +(class that implements _d_i_s_k___i_n_t_e_r_f_a_c_e). This is held by the internal libtorrent │ │ │ │ +torrent object to tie the storage object allocated for a torrent to the │ │ │ │ +lifetime of the internal torrent object. When a torrent is removed from the │ │ │ │ +_s_e_s_s_i_o_n, this holder is destructed and will inform the disk object. │ │ │ │ +struct storage_holder │ │ │ │ { │ │ │ │ - bool iiss__vvaalliidd () const; │ │ │ │ - void rreesseerrvvee (int num_files); │ │ │ │ - void aadddd__ffiillee__bboorrrrooww (string_view filename │ │ │ │ - , std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ - , string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ - void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ - void aadddd__ffiillee__bboorrrrooww (error_code& ec, string_view filename │ │ │ │ - , std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ - , string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ - void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t │ │ │ │ -file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ - std::vector mmaapp__bblloocckk (piece_index_t piece, std::int64_t offset │ │ │ │ - , std::int64_t size) const; │ │ │ │ - peer_request mmaapp__ffiillee (file_index_t file, std::int64_t offset, int size) │ │ │ │ -const; │ │ │ │ - int nnuumm__ffiilleess () const noexcept; │ │ │ │ - file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ - index_range ffiillee__rraannggee () const noexcept; │ │ │ │ - std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ - std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ - void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ - int nnuumm__ppiieecceess () const; │ │ │ │ - piece_index_t eenndd__ppiieeccee () const; │ │ │ │ - piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ - index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ - int ppiieeccee__lleennggtthh () const; │ │ │ │ - void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ - int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ - int ppiieeccee__ssiizzee22 (piece_index_t index) const; │ │ │ │ - int bblloocckkss__iinn__ppiieeccee22 (piece_index_t index) const; │ │ │ │ - int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ - void sseett__nnaammee (std::string const& n); │ │ │ │ - std::string const& nnaammee () const; │ │ │ │ - void sswwaapp (file_storage& ti) noexcept; │ │ │ │ - bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ - string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ - char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ - std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = │ │ │ │ -"") const; │ │ │ │ - std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ - std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ - sha256_hash rroooott (file_index_t index) const; │ │ │ │ - std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ - std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ - int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ - index_range ffiillee__ppiieeccee__rraannggee (file_index_t) const; │ │ │ │ - int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ - int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ - int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ - std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& │ │ │ │ -save_path) const; │ │ │ │ - void aallll__ppaatthh__hhaasshheess (std::unordered_set& table) const; │ │ │ │ - file_flags_t ffiillee__ffllaaggss (file_index_t index) const; │ │ │ │ - bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t index) const; │ │ │ │ - file_index_t ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ - file_index_t llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ - file_index_t ffiillee__iinnddeexx__aatt__ooffffsseett (std::int64_t offset) const; │ │ │ │ - file_index_t ffiillee__iinnddeexx__ffoorr__rroooott (sha256_hash const& root_hash) const; │ │ │ │ - piece_index_t llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ - piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ - void ssaanniittiizzee__ssyymmlliinnkkss (); │ │ │ │ - bool vv22 () const; │ │ │ │ + ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io); │ │ │ │ + ~~ssttoorraaggee__hhoollddeerr (); │ │ │ │ + ssttoorraaggee__hhoollddeerr () = default; │ │ │ │ + explicit operator bbooooll () const; │ │ │ │ + operator ssttoorraaggee__iinnddeexx__tt () const; │ │ │ │ + void rreesseett (); │ │ │ │ + storage_holder& ooppeerraattoorr== (storage_holder const&) = delete; │ │ │ │ + ssttoorraaggee__hhoollddeerr (storage_holder const&) = delete; │ │ │ │ + ssttoorraaggee__hhoollddeerr (storage_holder&& rhs) noexcept; │ │ │ │ + storage_holder& ooppeerraattoorr== (storage_holder&& rhs) noexcept; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ssttoorraaggee__hhoollddeerr(()) ********** │ │ │ │ +ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io); │ │ │ │ +constructs a storage holder, for storage idx held at disk interface disk_io. │ │ │ │ +When the holder is destructed or reset, disk_io will be notified that the │ │ │ │ +storage can be removed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** rreesseett(()) ********** │ │ │ │ +void rreesseett (); │ │ │ │ +release ownership of the storage, removing the torrent from the disk subsystem. │ │ │ │ +After this call the holder is empty and operator bool() returns false. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddiisskk__oobbsseerrvveerr ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___o_b_s_e_r_v_e_r_._h_p_p" │ │ │ │ +callback interface used to be notified when the disk write queue has drained │ │ │ │ +below the low watermark. When the disk subsystem applies back-pressure, peers │ │ │ │ +wanting to upload are paused; once the queue drains, on_disk() is invoked so │ │ │ │ +that those peers can resume. │ │ │ │ +struct disk_observer │ │ │ │ +{ │ │ │ │ + virtual void oonn__ddiisskk () = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** oonn__ddiisskk(()) ********** │ │ │ │ +virtual void oonn__ddiisskk () = 0; │ │ │ │ +called when the disk cache size has dropped below the low watermark again and │ │ │ │ +we can resume downloading from peers │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ bbuuffffeerr__aallllooccaattoorr__iinntteerrffaaccee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p" │ │ │ │ +the interface for freeing disk buffers, used by the _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r. when │ │ │ │ +implementing _d_i_s_k___i_n_t_e_r_f_a_c_e, this must also be implemented in order to return │ │ │ │ +disk buffers back to libtorrent │ │ │ │ +struct buffer_allocator_interface │ │ │ │ +{ │ │ │ │ + virtual void ffrreeee__mmuullttiippllee__bbuuffffeerrss (span bufs) = 0; │ │ │ │ + virtual void ffrreeee__ddiisskk__bbuuffffeerr (char* b) = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffrreeee__ddiisskk__bbuuffffeerr(()) ffrreeee__mmuullttiippllee__bbuuffffeerrss(()) ********** │ │ │ │ +virtual void ffrreeee__mmuullttiippllee__bbuuffffeerrss (span bufs) = 0; │ │ │ │ +virtual void ffrreeee__ddiisskk__bbuuffffeerr (char* b) = 0; │ │ │ │ +returns one or more disk buffers (previously handed out by the disk subsystem) │ │ │ │ +back to the allocator. The bulk overload, free_multiple_buffers(), lets callers │ │ │ │ +free a batch of buffers under a single mutex acquisition. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddiisskk__bbuuffffeerr__hhoollddeerr ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p" │ │ │ │ +The disk buffer holder acts like a unique_ptr that frees a disk buffer when │ │ │ │ +it's destructed │ │ │ │ +If this buffer holder is moved-from, default constructed or reset, data() will │ │ │ │ +return nullptr. │ │ │ │ +struct disk_buffer_holder │ │ │ │ +{ │ │ │ │ + ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder&&) noexcept; │ │ │ │ + disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder&&) & noexcept; │ │ │ │ + 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; │ │ │ │ + explicit operator bbooooll () const noexcept; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ddiisskk__bbuuffffeerr__hhoollddeerr(()) ********** │ │ │ │ +ddiisskk__bbuuffffeerr__hhoollddeerr (buffer_allocator_interface& alloc, char* buf) noexcept; │ │ │ │ +construct a buffer holder that will free the held buffer using a disk buffer │ │ │ │ +pool directly (there's only one disk_buffer_pool per _s_e_s_s_i_o_n) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ddiisskk__bbuuffffeerr__hhoollddeerr(()) ********** │ │ │ │ +ddiisskk__bbuuffffeerr__hhoollddeerr () noexcept = default; │ │ │ │ +default construct a holder that does not own any buffer │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ~~ddiisskk__bbuuffffeerr__hhoollddeerr(()) ********** │ │ │ │ +~~ddiisskk__bbuuffffeerr__hhoollddeerr (); │ │ │ │ +frees disk buffer held by this object │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ddaattaa(()) ********** │ │ │ │ +char* ddaattaa () const noexcept; │ │ │ │ +return a pointer to the held buffer, if any. Otherwise returns nullptr. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** rreesseett(()) ********** │ │ │ │ +void rreesseett (); │ │ │ │ +free the held disk buffer, if any, and clear the holder. This sets the holder │ │ │ │ +object to a default-constructed state │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sswwaapp(()) ********** │ │ │ │ +void sswwaapp (disk_buffer_holder& h) noexcept; │ │ │ │ +swap pointers of two disk buffer holders. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iiss__mmuuttaabbllee(()) ********** │ │ │ │ +bool iiss__mmuuttaabbllee () const noexcept; │ │ │ │ +if this returns true, the buffer may not be modified in place │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** bbooooll(()) ********** │ │ │ │ +explicit operator bbooooll () const noexcept; │ │ │ │ +implicitly convertible to true if the object is currently holding a buffer │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddiisskk__bbuuffffeerr__rreeff ************ │ │ │ │ +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" │ │ │ │ +Pointer-only disk buffer reference. Holds a char* but neither the allocator nor │ │ │ │ +the size. Has unique_ptr-like move semantics. The destructor asserts that the │ │ │ │ +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 (disk_buffer_ref&&) noexcept; │ │ │ │ + ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref const&) = delete; │ │ │ │ + ~~ddiisskk__bbuuffffeerr__rreeff (); │ │ │ │ + disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref const&) = delete; │ │ │ │ + disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref&&) noexcept; │ │ │ │ + char* ddaattaa () const noexcept; │ │ │ │ + explicit operator bbooooll () 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] │ │ │ │ +********** bbooooll(()) ddaattaa(()) ********** │ │ │ │ +char* ddaattaa () const noexcept; │ │ │ │ +explicit operator bbooooll () 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); │ │ │ │ + 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] │ │ │ │ +********** 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] │ │ │ │ +************ 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 │ │ │ │ + returned from check_fastresume to indicate that resume data failed │ │ │ │ + validation and a full piece-hash check is required. │ │ │ │ + file_exist │ │ │ │ + returned from move_storage when the destination already exists and the │ │ │ │ + dont_replace flag was set. │ │ │ │ + oversized_file │ │ │ │ + returned from check_fastresume when a file on disk is larger than the │ │ │ │ + size recorded in the .torrent metadata. This triggers an _a_l_e_r_t to let the │ │ │ │ + user decide whether to truncate the file or save the torrent in another │ │ │ │ + directory. │ │ │ │ + job_deferred │ │ │ │ + Returned by do_job(hash) when the job was hung on a cache piece. │ │ │ │ + kick_hasher will post it to completed_jobs once hashing finishes. │ │ │ │ + perform_job() checks this flag before writing j->ret. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffiillee__ooppeenn__mmooddee__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" │ │ │ │ + read_only │ │ │ │ + open the file for reading only │ │ │ │ + write_only │ │ │ │ + open the file for writing only │ │ │ │ + read_write │ │ │ │ + open the file for reading and writing │ │ │ │ + rw_mask │ │ │ │ + the mask for the bits determining read or write mode │ │ │ │ + sparse │ │ │ │ + open the file in sparse mode (if supported by the filesystem). │ │ │ │ + no_atime │ │ │ │ + don't update the access timestamps on the file (if supported by the │ │ │ │ + operating system and filesystem). this generally improves disk │ │ │ │ + performance. │ │ │ │ + random_access │ │ │ │ + When this is not set, the kernel is hinted that access to this file will │ │ │ │ + be made sequentially. │ │ │ │ + mmapped │ │ │ │ + the file is memory mapped │ │ │ │ +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: │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ sseettttiinnggss__ppaacckk ************ │ │ │ │ +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 settings_pack struct, contains the names of all settings as enum values. │ │ │ │ +These values are passed in to the set_str(), set_int(), set_bool() functions, │ │ │ │ +to specify the setting to change. │ │ │ │ +The settings_pack only stores values for settings that have been explicitly set │ │ │ │ +on this object. However, it can still be queried for settings that have not │ │ │ │ +been set and returns the default value for those settings. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ | │ │ │ │ +|_u_s_e_r___a_g_e_n_t_|_s_t_r_i_n_g_|_l_i_b_t_o_r_r_e_n_t_/| │ │ │ │ +this is the client identification to the tracker. The recommended format of │ │ │ │ +this string is: "client-name/client-version libtorrent/libtorrent-version". │ │ │ │ +This name will not only be used when making HTTP requests, but also when │ │ │ │ +sending extended headers to peers that support that extension. It may not │ │ │ │ +contain r or n │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_n_n_o_u_n_c_e___i_p_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +announce_ip is the ip address passed along to trackers as the &ip= parameter. │ │ │ │ +If left as the default, that parameter is omitted. │ │ │ │ +Note │ │ │ │ +This setting is only meant for very special cases where a seed is running on │ │ │ │ +the same host as the tracker, and the tracker accepts the IP parameter (which │ │ │ │ +normal trackers don't). Do not set this option unless you also control the │ │ │ │ +tracker. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_h_a_n_d_s_h_a_k_e___c_l_i_e_n_t___v_e_r_s_i_o_n_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +this is the client name and version identifier sent to peers in the handshake │ │ │ │ +message. If this is an empty string, the user_agent is used instead. This │ │ │ │ +string must be a UTF-8 encoded unicode string. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_o_u_t_g_o_i_n_g___i_n_t_e_r_f_a_c_e_s_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +This controls which IP address outgoing TCP peer connections are bound to, in │ │ │ │ +addition to controlling whether such connections are also bound to a specific │ │ │ │ +network interface/adapter (bbiinndd--ttoo--ddeevviiccee). │ │ │ │ +This string is a comma-separated list of IP addresses and interface names. An │ │ │ │ +empty string will not bind TCP sockets to a device, and let the network stack │ │ │ │ +assign the local address. │ │ │ │ +A list of names will be used to bind outgoing TCP sockets in a round-robin │ │ │ │ +fashion. An IP address will simply be used tobind()the socket. An interface │ │ │ │ +name will attempt to bind the socket to that interface. If that fails, or is │ │ │ │ +unsupported, one of the IP addresses configured for that interface is used │ │ │ │ +tobind()the socket to. If the interface or adapter doesn't exist, the outgoing │ │ │ │ +peer connection will fail with an error message suggesting the device cannot be │ │ │ │ +found. Adapter names on Unix systems are of the form "eth0", "eth1", "tun0", │ │ │ │ +etc. This may be useful for clients that are multi-homed. Binding an outgoing │ │ │ │ +connection to a local IP does not necessarily make the connection via the │ │ │ │ +associated NIC/Adapter. │ │ │ │ +When outgoing interfaces are specified, incoming connections or packets sent to │ │ │ │ +a local interface or IP that's nnoott in this list will be rejected with a │ │ │ │ +_p_e_e_r___b_l_o_c_k_e_d___a_l_e_r_t with invalid_local_interface as the reason. │ │ │ │ +Note that these are just interface/adapter names or IP addresses. There are no │ │ │ │ +ports specified in this list. IPv6 addresses without port should be specified │ │ │ │ +without enclosing [, ]. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_l_i_s_t_e_n___i_n_t_e_r_f_a_c_e_s_|_s_t_r_i_n_g_|_0_._0_._0_._0_:_6_8_8_1_,_[_:_:_]_:_6_8_8_1| │ │ │ │ +a comma-separated list of (IP or device name, port) pairs. These are the listen │ │ │ │ +ports that will be opened for accepting incoming uTP and TCP peer connections. │ │ │ │ +These are also used for oouuttggooiinngg uTP and UDP tracker connections and DHT nodes. │ │ │ │ +It is possible to listen on multiple interfaces and multiple ports. Binding to │ │ │ │ +port 0 will make the operating system pick the port. │ │ │ │ +Note │ │ │ │ +There are reasons to stick to the same port across sessions, which would mean │ │ │ │ +only using port 0 on the first start, and recording the port that was picked │ │ │ │ +for subsequent startups. Trackers, the DHT and other peers will remember the │ │ │ │ +port they see you use and hand that port out to other peers trying to connect │ │ │ │ +to you, as well as trying to connect to you themselves. │ │ │ │ +A port that has an "s" suffix will accept SSL peer connections. (note that SSL │ │ │ │ +sockets are only available in builds with SSL support) │ │ │ │ +A port that has an "l" suffix will be considered a local network. i.e. it's │ │ │ │ +assumed to only be able to reach hosts in the same local network as the IP │ │ │ │ +address (based on the netmask associated with the IP, queried from the │ │ │ │ +operating system). │ │ │ │ +if binding fails, the _l_i_s_t_e_n___f_a_i_l_e_d___a_l_e_r_t is posted. Once a socket binding │ │ │ │ +succeeds (if it does), the _l_i_s_t_e_n___s_u_c_c_e_e_d_e_d___a_l_e_r_t is posted. There may be │ │ │ │ +multiple failures before a success. │ │ │ │ +If a device name that does not exist is configured, no listen socket will be │ │ │ │ +opened for that interface. If this is the only interface configured, it will be │ │ │ │ +as if no listen ports are configured. │ │ │ │ +If no listen ports are configured (e.g. listen_interfaces is an empty string), │ │ │ │ +networking will be disabled. No DHT will start, no outgoing uTP or tracker │ │ │ │ +connections will be made. No incoming TCP or uTP connections will be accepted. │ │ │ │ +(outgoing TCP connections will still be possible, depending on _s_e_t_t_i_n_g_s___p_a_c_k_:_: │ │ │ │ +_o_u_t_g_o_i_n_g___i_n_t_e_r_f_a_c_e_s). │ │ │ │ +For example: [::1]:8888 - will only accept connections on the IPv6 loopback │ │ │ │ +address on port 8888. │ │ │ │ +eth0:4444,eth1:4444 - will accept connections on port 4444 on any IP address │ │ │ │ +bound to device eth0 or eth1. │ │ │ │ +[::]:0s - will accept SSL connections on a port chosen by the OS. And not │ │ │ │ +accept non-SSL connections at all. │ │ │ │ +0.0.0.0:6881,[::]:6881 - binds to all interfaces on port 6881. │ │ │ │ +10.0.1.13:6881l - binds to the local IP address, port 6881, but only allow │ │ │ │ +talking to peers on the same local network. The netmask is queried from the │ │ │ │ +operating system. Interfaces marked l are not announced to trackers, unless the │ │ │ │ +tracker is also on the same local network. │ │ │ │ +Windows OS network adapter device name must be specified with GUID. It can be │ │ │ │ +obtained from "netsh lan show interfaces" command output. GUID must be │ │ │ │ +uppercased string embraced in curly brackets. {E4F0B674-0DFC-48BB-98A5- │ │ │ │ +2AA730BDB6D6}:7777 - will accept connections on port 7777 on adapter with this │ │ │ │ +GUID. │ │ │ │ +For more information, see the _M_u_l_t_i_-_h_o_m_e_d_ _h_o_s_t_s section. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_o_x_y___h_o_s_t_n_a_m_e_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +when using a proxy, this is the hostname where the proxy is running see │ │ │ │ +proxy_type. Note that when using a proxy, the _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 │ │ │ │ +setting is overridden and only a single interface is created, just to contact │ │ │ │ +the proxy. This means a proxy cannot be combined with SSL torrents or multiple │ │ │ │ +listen interfaces. This proxy listen interface will not accept incoming TCP │ │ │ │ +connections, will not map ports with any gateway and will not enable local │ │ │ │ +service discovery. All traffic is supposed to be channeled through the proxy. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_o_x_y___u_s_e_r_n_a_m_e_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +|_p_r_o_x_y___p_a_s_s_w_o_r_d_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +when using a proxy, these are the credentials (if any) to use when connecting │ │ │ │ +to it. see proxy_type │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_2_p___h_o_s_t_n_a_m_e_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +sets the _i_2_p SAM bridge to connect to. set the port with the i2p_port setting. │ │ │ │ +Unless this is set, i2p torrents are not supported. This setting is separate │ │ │ │ +from the other proxy settings since i2p torrents and their peers are │ │ │ │ +orthogonal. You can have i2p peers as well as regular peers via a proxy. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ | │ │ │ │ +|_p_e_e_r___f_i_n_g_e_r_p_r_i_n_t_|_s_t_r_i_n_g_|_-_L_T_2_1_0_0_-| │ │ │ │ +this is the fingerprint for the client. It will be used as the prefix to the │ │ │ │ +peer_id. If this is 20 bytes (or longer) it will be truncated to 20 bytes and │ │ │ │ +used as the entire peer-id │ │ │ │ +There is a utility function, _g_e_n_e_r_a_t_e___f_i_n_g_e_r_p_r_i_n_t_(_) that can be used to │ │ │ │ +generate a standard client peer ID fingerprint prefix. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_h_t___b_o_o_t_s_t_r_a_p___n_o_d_e_s_|_s_t_r_i_n_g_|_d_h_t_._l_i_b_t_o_r_r_e_n_t_._o_r_g_:_2_5_4_0_1| │ │ │ │ +This is a comma-separated list of IP port-pairs. They will be added to the DHT │ │ │ │ +node (if it's enabled) as back-up nodes in case we don't know of any. │ │ │ │ +Changing these after the DHT has been started may not have any effect until the │ │ │ │ +DHT is restarted. Here are some other bootstrap nodes that may work: │ │ │ │ +router.bittorrent.com:6881, dht.transmissionbt.com:6881 router.bt.ouinet.work: │ │ │ │ +6881, │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_n_a_t_p_m_p___g_a_t_e_w_a_y_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ +Overrides the NAT-PMP service gateway. When set, libtorrent won't try to │ │ │ │ +resolve the default gateway and instead will send the requests to the address │ │ │ │ +specified. This only takes affect when NAT-PMP first starts. If you change this │ │ │ │ +setting after NAT-PMP has been enabled, you need to disable it and re-enable │ │ │ │ +it. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_w_e_b_t_o_r_r_e_n_t___s_t_u_n___s_e_r_v_e_r_|_s_t_r_i_n_g_|_s_t_u_n_._l_._g_o_o_g_l_e_._c_o_m_:_1_9_3_0_2| │ │ │ │ +This is the STUN server used by WebTorrent to enable ICE NAT traversal for │ │ │ │ +WebRTC. It must have the format hostname:port. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_l_o_w___m_u_l_t_i_p_l_e___c_o_n_n_e_c_t_i_o_n_s___p_e_r___i_p_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +determines if connections from the same IP address as existing connections │ │ │ │ +should be rejected or not. Rejecting multiple connections from the same IP │ │ │ │ +address will prevent abusive behavior by peers. The logic for determining │ │ │ │ +whether connections are to the same peer is more complicated with this enabled, │ │ │ │ +and more likely to fail in some edge cases. It is not recommended to enable │ │ │ │ +this feature. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_e_n_d___r_e_d_u_n_d_a_n_t___h_a_v_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +send_redundant_have controls if have messages will be sent to peers that │ │ │ │ +already have the piece. This is typically not necessary, but it might be │ │ │ │ +necessary for collecting statistics in some cases. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_s_e___d_h_t___a_s___f_a_l_l_b_a_c_k_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +use_dht_as_fallback determines how the DHT is used. If this is true, the DHT │ │ │ │ +will only be used for torrents where all trackers in its tracker list has │ │ │ │ +failed. Either by an explicit error message or a time out. If this is false, │ │ │ │ +the DHT is used regardless of if the trackers fail or not. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_p_n_p___i_g_n_o_r_e___n_o_n_r_o_u_t_e_r_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +upnp_ignore_nonrouters indicates whether or not the UPnP implementation should │ │ │ │ +ignore any broadcast response from a device whose address is not on our subnet. │ │ │ │ +i.e. it's a way to not talk to other people's routers by mistake. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_s_e___p_a_r_o_l_e___m_o_d_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +use_parole_mode specifies if parole mode should be used. Parole mode means that │ │ │ │ +peers that participate in pieces that fail the hash check are put in a mode │ │ │ │ +where they are only allowed to download whole pieces. If the whole piece a peer │ │ │ │ +in parole mode fails the hash check, it is banned. If a peer participates in a │ │ │ │ +piece that passes the hash check, it is taken out of parole mode. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_u_t_o___m_a_n_a_g_e___p_r_e_f_e_r___s_e_e_d_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +if true, prefer seeding torrents when determining which torrents to give active │ │ │ │ +slots to. If false, give preference to downloading torrents │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_o_n_t___c_o_u_n_t___s_l_o_w___t_o_r_r_e_n_t_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if dont_count_slow_torrents is true, torrents without any payload transfers are │ │ │ │ +not subject to the active_seeds and active_downloads limits. This is intended │ │ │ │ +to make it more likely to utilize all available bandwidth, and avoid having │ │ │ │ +torrents that don't transfer anything block the active slots. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_c_l_o_s_e___r_e_d_u_n_d_a_n_t___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +close_redundant_connections specifies whether libtorrent should close │ │ │ │ +connections where both ends have no utility in keeping the connection open. For │ │ │ │ +instance if both ends have completed their downloads, there's no point in │ │ │ │ +keeping it open. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_i_o_r_i_t_i_z_e___p_a_r_t_i_a_l___p_i_e_c_e_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +If prioritize_partial_pieces is true, partial pieces are picked before pieces │ │ │ │ +that are more rare. If false, rare pieces are always prioritized, unless the │ │ │ │ +number of partial pieces is growing out of proportion. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_a_t_e___l_i_m_i_t___i_p___o_v_e_r_h_e_a_d_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if set to true, the estimated TCP/IP overhead is drained from the rate │ │ │ │ +limiters, to avoid exceeding the limits with the total traffic │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_n_n_o_u_n_c_e___t_o___a_l_l___t_i_e_r_s_ _ _ _|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +|_a_n_n_o_u_n_c_e___t_o___a_l_l___t_r_a_c_k_e_r_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +announce_to_all_trackers controls how multi tracker torrents are treated. If │ │ │ │ +this is set to true, all trackers in the same tier are announced to in │ │ │ │ +parallel. If all trackers in tier 0 fails, all trackers in tier 1 are announced │ │ │ │ +as well. If it's set to false, the behavior is as defined by the multi tracker │ │ │ │ +specification. │ │ │ │ +announce_to_all_tiers also controls how multi tracker torrents are treated. │ │ │ │ +When this is set to true, one tracker from each tier is announced to. This is │ │ │ │ +the uTorrent behavior. To be compliant with the Multi-tracker specification, │ │ │ │ +set it to false. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_e_f_e_r___u_d_p___t_r_a_c_k_e_r_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +prefer_udp_trackers: true means that trackers may be rearranged in a way that │ │ │ │ +udp trackers are always tried before http trackers for the same hostname. │ │ │ │ +Setting this to false means that the tracker's tier is respected and there's no │ │ │ │ +preference of one protocol over another. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_i_s_a_b_l_e___h_a_s_h___c_h_e_c_k_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when set to true, all data downloaded from peers will be assumed to be correct, │ │ │ │ +and not tested to match the hashes in the torrent this is only useful for │ │ │ │ +simulation and testing purposes (typically combined with disabled_storage) │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_l_o_w___i_2_p___m_i_x_e_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +if this is true, i2p torrents are allowed to also get peers from other sources │ │ │ │ +than the tracker, and connect to regular IPs, not providing any anonymization. │ │ │ │ +This may be useful if the user is not interested in the anonymization of i2p, │ │ │ │ +but still wants to be able to connect to i2p peers. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_n_o___a_t_i_m_e___s_t_o_r_a_g_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +no_atime_storage this is a Linux-only option and passes in the O_NOATIME to │ │ │ │ +open() when opening files. This may lead to some disk performance improvements. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_n_c_o_m_i_n_g___s_t_a_r_t_s___q_u_e_u_e_d___t_o_r_r_e_n_t_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +incoming_starts_queued_torrents. If a torrent has been paused by the auto │ │ │ │ +managed feature in libtorrent, i.e. the torrent is paused and auto managed, │ │ │ │ +this feature affects whether or not it is automatically started on an incoming │ │ │ │ +connection. The main reason to queue torrents, is not to make them unavailable, │ │ │ │ +but to save on the overhead of announcing to the trackers, the DHT and to avoid │ │ │ │ +spreading one's unchoke slots too thin. If a peer managed to find us, even │ │ │ │ +though we're no in the torrent anymore, this setting can make us start the │ │ │ │ +torrent and serve it. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_e_p_o_r_t___t_r_u_e___d_o_w_n_l_o_a_d_e_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when set to true, the downloaded counter sent to trackers will include the │ │ │ │ +actual number of payload bytes downloaded including redundant bytes. If set to │ │ │ │ +false, it will not include any redundancy bytes │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_t_r_i_c_t___e_n_d___g_a_m_e___m_o_d_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +strict_end_game_mode controls when a block may be requested twice. If this is │ │ │ │ +true, a block may only be requested twice when there's at least one request to │ │ │ │ +every piece that's left to download in the torrent. This may slow down progress │ │ │ │ +on some pieces sometimes, but it may also avoid downloading a lot of redundant │ │ │ │ +bytes. If this is false, libtorrent attempts to use each peer connection to its │ │ │ │ +max, by always requesting something, even if it means requesting something that │ │ │ │ +has been requested from another peer already. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_e_n_a_b_l_e___o_u_t_g_o_i_n_g___u_t_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +|_e_n_a_b_l_e___i_n_c_o_m_i_n_g___u_t_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +|_e_n_a_b_l_e___o_u_t_g_o_i_n_g___t_c_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +|_e_n_a_b_l_e___i_n_c_o_m_i_n_g___t_c_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +Enables incoming and outgoing, TCP and uTP peer connections. false is disabled │ │ │ │ +and true is enabled. When outgoing connections are disabled, libtorrent will │ │ │ │ +simply not make outgoing peer connections with the specific transport protocol. │ │ │ │ +Disabled incoming peer connections will simply be rejected. These options only │ │ │ │ +apply to peer connections, not tracker- or any other kinds of connections. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_n_o___r_e_c_h_e_c_k___i_n_c_o_m_p_l_e_t_e___r_e_s_u_m_e_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +no_recheck_incomplete_resume determines if the storage should check the whole │ │ │ │ +files when resume data is incomplete or missing or whether it should simply │ │ │ │ +assume we don't have any of the data. If false, any existing files will be │ │ │ │ +checked. By setting this setting to true, the files won't be checked, but will │ │ │ │ +go straight to download mode. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_n_o_n_y_m_o_u_s___m_o_d_e_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +anonymous_mode: When set to true, the client tries to hide its identity to a │ │ │ │ +certain degree. │ │ │ │ + * A generic user-agent will be used for trackers (except for private │ │ │ │ + torrents). │ │ │ │ + * Your local IPv4 and IPv6 address won't be sent as query string parameters │ │ │ │ + to private trackers. │ │ │ │ + * If announce_ip is configured, it will not be sent to trackers │ │ │ │ + * The client version will not be sent to peers in the extension handshake. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_e_p_o_r_t___w_e_b___s_e_e_d___d_o_w_n_l_o_a_d_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +specifies whether downloads from web seeds is reported to the tracker or not. │ │ │ │ +Turning it off also excludes web seed traffic from other stats and download │ │ │ │ +rate reporting via the libtorrent API. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_e_e_d_i_n_g___o_u_t_g_o_i_n_g___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +seeding_outgoing_connections determines if seeding (and finished) torrents │ │ │ │ +should attempt to make outgoing connections or not. It may be set to false in │ │ │ │ +very specific applications where the cost of making outgoing connections is │ │ │ │ +high, and there are no or small benefits of doing so. For instance, if no nodes │ │ │ │ +are behind a firewall or a NAT, seeds don't need to make outgoing connections. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_n_o___c_o_n_n_e_c_t___p_r_i_v_i_l_e_g_e_d___p_o_r_t_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when this is true, libtorrent will not attempt to make outgoing connections to │ │ │ │ +peers whose port is < 1024. This is a safety precaution to avoid being part of │ │ │ │ +a DDoS attack │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_m_o_o_t_h___c_o_n_n_e_c_t_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +smooth_connects means the number of connection attempts per second may be │ │ │ │ +limited to below the connection_speed, in case we're close to bump up against │ │ │ │ +the limit of number of connections. The intention of this setting is to more │ │ │ │ +evenly distribute our connection attempts over time, instead of attempting to │ │ │ │ +connect in batches, and timing them out in batches. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_w_a_y_s___s_e_n_d___u_s_e_r___a_g_e_n_t_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +always send user-agent in every web seed request. If false, only the first │ │ │ │ +request per http connection will include the user agent │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_p_p_l_y___i_p___f_i_l_t_e_r___t_o___t_r_a_c_k_e_r_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +apply_ip_filter_to_trackers determines whether the IP filter applies to │ │ │ │ +trackers as well as peers. If this is set to false, trackers are exempt from │ │ │ │ +the IP filter (if there is one). If no IP filter is set, this setting is │ │ │ │ +irrelevant. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_b_a_n___w_e_b___s_e_e_d_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +when true, web seeds sending bad data will be banned │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_u_p_p_o_r_t___s_h_a_r_e___m_o_d_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if false, prevents libtorrent to advertise share-mode support │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_e_p_o_r_t___r_e_d_u_n_d_a_n_t___b_y_t_e_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if this is true, the number of redundant bytes is sent to the tracker │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_l_i_s_t_e_n___s_y_s_t_e_m___p_o_r_t___f_a_l_l_b_a_c_k_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if this is true, libtorrent will fall back to listening on a port chosen by the │ │ │ │ +operating system (i.e. binding to port 0). If a failure is preferred, set this │ │ │ │ +to false. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_n_n_o_u_n_c_e___c_r_y_p_t_o___s_u_p_p_o_r_t_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +when this is true, and incoming encrypted connections are enabled, │ │ │ │ +&supportcrypt=1 is included in http tracker announces │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_e_n_a_b_l_e___u_p_n_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +Starts and stops the UPnP service. When started, the listen port and the DHT │ │ │ │ +port are attempted to be forwarded on local UPnP router devices. │ │ │ │ +The upnp object returned by start_upnp() can be used to add and remove │ │ │ │ +arbitrary port mappings. Mapping status is returned through the _p_o_r_t_m_a_p___a_l_e_r_t │ │ │ │ +and the _p_o_r_t_m_a_p___e_r_r_o_r___a_l_e_r_t. The object will be valid until stop_upnp() is │ │ │ │ +called. See _u_p_n_p_ _a_n_d_ _n_a_t_ _p_m_p. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_e_n_a_b_l_e___n_a_t_p_m_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +Starts and stops the NAT-PMP service. When started, the listen port and the DHT │ │ │ │ +port are attempted to be forwarded on the router through NAT-PMP. │ │ │ │ +The natpmp object returned by start_natpmp() can be used to add and remove │ │ │ │ +arbitrary port mappings. Mapping status is returned through the _p_o_r_t_m_a_p___a_l_e_r_t │ │ │ │ +and the _p_o_r_t_m_a_p___e_r_r_o_r___a_l_e_r_t. The object will be valid until stop_natpmp() is │ │ │ │ +called. See _u_p_n_p_ _a_n_d_ _n_a_t_ _p_m_p. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_e_n_a_b_l_e___l_s_d_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +Starts and stops Local Service Discovery. This service will broadcast the info- │ │ │ │ +hashes of all the non-private torrents on the local network to look for peers │ │ │ │ +on the same swarm within multicast reach. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_e_n_a_b_l_e___d_h_t_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +starts the dht node and makes the trackerless service available to torrents. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_e_f_e_r___r_c_4_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +if the allowed encryption level is both, setting this to true will prefer RC4 │ │ │ │ +if both methods are offered, plain text otherwise │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_o_x_y___h_o_s_t_n_a_m_e_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if true, hostname lookups are done via the configured proxy (if any). This is │ │ │ │ +only supported by SOCKS5 and HTTP. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_o_x_y___p_e_e_r___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if true, peer connections are made (and accepted) over the configured proxy, if │ │ │ │ +any. Web seeds as well as regular bittorrent peer connections are considered │ │ │ │ +"peer connections". Anything transporting actual torrent payload (trackers and │ │ │ │ +DHT traffic are not considered peer connections). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_u_t_o___s_e_q_u_e_n_t_i_a_l_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if this setting is true, torrents with a very high availability of pieces (and │ │ │ │ +seeds) are downloaded sequentially. This is more efficient for the disk I/O. │ │ │ │ +With many seeds, the download order is unlikely to matter anyway │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_o_x_y___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +if true, tracker connections are made over the configured proxy, if any. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_e_n_a_b_l_e___i_p___n_o_t_i_f_i_e_r_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +Starts and stops the internal IP table route changes notifier. │ │ │ │ +The current implementation supports multiple platforms, and it is recommended │ │ │ │ +to have it enable, but you may want to disable it if it's supported but │ │ │ │ +unreliable, or if you have a better way to detect the changes. In the later │ │ │ │ +case, you should manually call session_handle::reopen_network_sockets to ensure │ │ │ │ +network changes are taken in consideration. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___p_r_e_f_e_r___v_e_r_i_f_i_e_d___n_o_d_e___i_d_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +when this is true, nodes whose IDs are derived from their source IP according │ │ │ │ +to _B_E_P_ _4_2 are preferred in the routing table. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___r_e_s_t_r_i_c_t___r_o_u_t_i_n_g___i_p_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +determines if the routing table entries should restrict entries to one per IP. │ │ │ │ +This defaults to true, which helps mitigate some attacks on the DHT. It │ │ │ │ +prevents adding multiple nodes with IPs with a very close CIDR distance. │ │ │ │ +when set, nodes whose IP address that's in the same /24 (or /64 for IPv6) range │ │ │ │ +in the same routing table bucket. This is an attempt to mitigate node ID │ │ │ │ +spoofing attacks also restrict any IP to only have a single _e_n_t_r_y in the whole │ │ │ │ +routing table │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___r_e_s_t_r_i_c_t___s_e_a_r_c_h___i_p_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +determines if DHT searches should prevent adding nodes with IPs with very close │ │ │ │ +CIDR distance. This also defaults to true and helps mitigate certain attacks on │ │ │ │ +the DHT. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___e_x_t_e_n_d_e_d___r_o_u_t_i_n_g___t_a_b_l_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +makes the first buckets in the DHT routing table fit 128, 64, 32 and 16 nodes │ │ │ │ +respectively, as opposed to the standard size of 8. All other buckets have size │ │ │ │ +8 still. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___a_g_g_r_e_s_s_i_v_e___l_o_o_k_u_p_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +slightly changes the lookup behavior in terms of how many outstanding requests │ │ │ │ +we keep. Instead of having branch factor be a hard limit, we always keep bbrraanncchh │ │ │ │ +ffaaccttoorr outstanding requests to the closest nodes. i.e. every time we get │ │ │ │ +results back with closer nodes, we query them right away. It lowers the lookup │ │ │ │ +times at the cost of more outstanding queries. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___p_r_i_v_a_c_y___l_o_o_k_u_p_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when set, perform lookups in a way that is slightly more expensive, but which │ │ │ │ +minimizes the amount of information leaked about you. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___e_n_f_o_r_c_e___n_o_d_e___i_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when set, node's whose IDs that are not correctly generated based on its │ │ │ │ +external IP are ignored. When a query arrives from such node, an error message │ │ │ │ +is returned with a message saying "invalid node ID". │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___i_g_n_o_r_e___d_a_r_k___i_n_t_e_r_n_e_t_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +ignore DHT messages from parts of the internet we wouldn't expect to see any │ │ │ │ +traffic from │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___r_e_a_d___o_n_l_y_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when set, the other nodes won't keep this node in their routing tables, it's │ │ │ │ +meant for low-power and/or ephemeral devices that cannot support the DHT, it is │ │ │ │ +also useful for mobile devices which are sensitive to network traffic and │ │ │ │ +battery life. this node no longer responds to 'query' messages, and will place │ │ │ │ +a 'ro' key (value = 1) in the top-level message dictionary of outgoing query │ │ │ │ +messages. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_i_e_c_e___e_x_t_e_n_t___a_f_f_i_n_i_t_y_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when this is true, create an affinity for downloading 4 MiB extents of adjacent │ │ │ │ +pieces. This is an attempt to achieve better disk I/O throughput by downloading │ │ │ │ +larger extents of bytes, for torrents with small piece sizes │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_v_a_l_i_d_a_t_e___h_t_t_p_s___t_r_a_c_k_e_r_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +when set to true, the certificate of HTTPS trackers, HTTPS web seeds and │ │ │ │ +WebTorrent (wss://) trackers will be validated against the system's certificate │ │ │ │ +store (as defined by OpenSSL/GnuTLS). If the system does not have a certificate │ │ │ │ +store, this option may have to be disabled in order to get trackers and web │ │ │ │ +seeds to work). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_s_r_f___m_i_t_i_g_a_t_i_o_n_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ +when enabled, tracker and web seed requests are subject to certain │ │ │ │ +restrictions. │ │ │ │ +An HTTP(s) tracker requests to localhost (loopback) must have the request path │ │ │ │ +start with "/announce". This is the conventional bittorrent tracker request. │ │ │ │ +Any other HTTP(S) tracker request to loopback will be rejected. This applies to │ │ │ │ +trackers that redirect to loopback as well. │ │ │ │ +Web seeds that end up on the client's local network (i.e. in a private IP │ │ │ │ +address range) may not include query string arguments. This applies to web │ │ │ │ +seeds redirecting to the local network as well. │ │ │ │ +Web seeds on global IPs (i.e. not local network) may not redirect to a local │ │ │ │ +network address │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_l_o_w___i_d_n_a_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when disabled, any tracker or web seed with an IDNA hostname (internationalized │ │ │ │ +domain name) is ignored. This is a security precaution to avoid various unicode │ │ │ │ +encoding attacks that might happen at the application level. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_e_n_a_b_l_e___s_e_t___f_i_l_e___v_a_l_i_d___d_a_t_a_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +when set to true, enables the attempt to use SetFileValidData() to pre-allocate │ │ │ │ +disk space. This system call will only work when running with Administrator │ │ │ │ +privileges on Windows, and so this setting is only relevant in that scenario. │ │ │ │ +Using SetFileValidData() poses a security risk, as it may reveal previously │ │ │ │ +deleted information from the disk. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_o_c_k_s_5___u_d_p___s_e_n_d___l_o_c_a_l___e_p_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +When using a SOCKS5 proxy, UDP traffic is routed through the proxy by sending a │ │ │ │ +UDP ASSOCIATE command. If this option is true, the UDP ASSOCIATE command will │ │ │ │ +include the IP address and listen port to the local UDP socket. This indicates │ │ │ │ +to the proxy which source endpoint to expect our packets from. The benefit is │ │ │ │ +that incoming packets can be forwarded correctly, before any outgoing packets │ │ │ │ +are sent. The risk is that if there's a NAT between the client and the proxy, │ │ │ │ +the IP address specified in the protocol may not be valid from the proxy's │ │ │ │ +point of view. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_o_x_y___s_e_n_d___h_o_s_t___i_n___c_o_n_n_e_c_t_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +When using HTTP proxy (in proxy_type), libtorrent will connect to peers and │ │ │ │ +trackers using theCONNECTproxy command. In this command it's possible to reveal │ │ │ │ +the hostname of the server we're connecting to. When this option is true, the │ │ │ │ +hostname will be sent. This feature can be useful if the proxy is used to man- │ │ │ │ +in-the-middle connections. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_i_s_k___d_i_s_a_b_l_e___c_o_p_y___o_n___w_r_i_t_e_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +When set, downloaded files will have the no-copy-on-write flag (FS_NOCOW_FL) │ │ │ │ +set on Linux. This mitigates heavy fragmentation on filesystems like btrfs, but │ │ │ │ +has the unfortunate side effect of disabling useful CoW-related features │ │ │ │ +including checksumming and compression, and adding additional restrictions on │ │ │ │ +the use of reflinks. A NOCOW file can only be reflinked to NOCOW directories, │ │ │ │ +which can be a surprising change for existing users. Therefore, this option is │ │ │ │ +disabled by default. │ │ │ │ +An alternative to this option is for the user to manually set the NOCOW flag on │ │ │ │ +the download directory, which will cause all files created within it to have │ │ │ │ +the NOCOW flag set. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_l_o_w___m_u_l_t_i_p_l_e___c_o_n_n_e_c_t_i_o_n_s___p_e_r___p_i_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ +determines if connections from the same Peer ID as existing connections should │ │ │ │ +be rejected or not. Typically, we only establish a single connection with each │ │ │ │ +peer. If a peer has multiple IP addresses, enabling this feature may improve │ │ │ │ +transfer efficiency, but it may also increase network load. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_t_r_a_c_k_e_r___c_o_m_p_l_e_t_i_o_n___t_i_m_e_o_u_t_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ +tracker_completion_timeout is the number of seconds the tracker connection will │ │ │ │ +wait from when it sent the request until it considers the tracker to have │ │ │ │ +timed-out. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_t_r_a_c_k_e_r___r_e_c_e_i_v_e___t_i_m_e_o_u_t_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ +tracker_receive_timeout is the number of seconds to wait to receive any data │ │ │ │ +from the tracker. If no data is received for this number of seconds, the │ │ │ │ +tracker will be considered as having timed out. If a tracker is down, this is │ │ │ │ +the kind of timeout that will occur. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_t_o_p___t_r_a_c_k_e_r___t_i_m_e_o_u_t_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ +stop_tracker_timeout is the number of seconds to wait when sending a stopped │ │ │ │ +message before considering a tracker to have timed out. This is usually │ │ │ │ +shorter, to make the client quit faster. If the value is set to 0, the │ │ │ │ +connections to trackers with the stopped event are suppressed. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ | │ │ │ │ +|_t_r_a_c_k_e_r___m_a_x_i_m_u_m___r_e_s_p_o_n_s_e___l_e_n_g_t_h_|_i_n_t_ _|_1_0_2_4_*_1_0_2_4| │ │ │ │ +this is the maximum number of bytes in a tracker response. If a response size │ │ │ │ +passes this number of bytes it will be rejected and the connection will be │ │ │ │ +closed. On gzipped responses this size is measured on the uncompressed data. │ │ │ │ +So, if you get 20 bytes of gzip response that'll expand to 2 megabytes, it will │ │ │ │ +be interrupted before the entire response has been uncompressed (assuming the │ │ │ │ +limit is lower than 2 MiB). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_i_e_c_e___t_i_m_e_o_u_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ +the number of seconds from a request is sent until it times out if no piece │ │ │ │ +response is returned. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_e_q_u_e_s_t___t_i_m_e_o_u_t_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ +the number of seconds one block (16 kiB) is expected to be received within. If │ │ │ │ +it's not, the block is requested from a different peer │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_e_q_u_e_s_t___q_u_e_u_e___t_i_m_e_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +the length of the request queue given in the number of seconds it should take │ │ │ │ +for the other end to send all the pieces. i.e. the actual number of requests │ │ │ │ +depends on the download rate and this number. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___a_l_l_o_w_e_d___i_n___r_e_q_u_e_s_t___q_u_e_u_e_|_i_n_t_ _|_2_0_0_0_ _ _ | │ │ │ │ +the number of outstanding block requests a peer is allowed to queue up in the │ │ │ │ +client. If a peer sends more requests than this (before the first one has been │ │ │ │ +sent) the last request will be dropped. the higher this is, the faster upload │ │ │ │ +speeds the client can get to a single peer. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___o_u_t___r_e_q_u_e_s_t___q_u_e_u_e_|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ +max_out_request_queue is the maximum number of outstanding requests to send to │ │ │ │ +a peer. This limit takes precedence over request_queue_time. i.e. no matter the │ │ │ │ +download speed, the number of outstanding requests will never exceed this │ │ │ │ +limit. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_w_h_o_l_e___p_i_e_c_e_s___t_h_r_e_s_h_o_l_d_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ +if a whole piece can be downloaded in this number of seconds, or less, the │ │ │ │ +peer_connection will prefer to request whole pieces at a time from this peer. │ │ │ │ +The benefit of this is to better utilize disk caches by doing localized │ │ │ │ +accesses and also to make it easier to identify bad peers if a piece fails the │ │ │ │ +hash check. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_e_e_r___t_i_m_e_o_u_t_|_i_n_t_ _|_1_2_0_ _ _ _ | │ │ │ │ +peer_timeout is the number of seconds the peer connection should wait (for any │ │ │ │ +activity on the peer connection) before closing it due to time out. 120 seconds │ │ │ │ +is specified in the protocol specification. After half the time out, a keep │ │ │ │ +alive message is sent. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_r_l_s_e_e_d___t_i_m_e_o_u_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ +same as peer_timeout, but only applies to url-seeds. this is usually set lower, │ │ │ │ +because web servers are expected to be more reliable. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_r_l_s_e_e_d___p_i_p_e_l_i_n_e___s_i_z_e_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ +controls the pipelining size of url and http seeds. i.e. the number of HTTP │ │ │ │ +request to keep outstanding before waiting for the first one to complete. It's │ │ │ │ +common for web servers to limit this to a relatively low number, like 5 │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_r_l_s_e_e_d___w_a_i_t___r_e_t_r_y_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ +number of seconds until a new retry of a url-seed takes place. Default retry │ │ │ │ +value for http-seeds that don't provide a valid retry-after header. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_f_i_l_e___p_o_o_l___s_i_z_e_|_i_n_t_ _|_4_0_ _ _ _ _ | │ │ │ │ +sets the upper limit on the total number of files this _s_e_s_s_i_o_n will keep open. │ │ │ │ +The reason why files are left open at all is that some anti virus software │ │ │ │ +hooks on every file close, and scans the file for viruses. deferring the │ │ │ │ +closing of the files will be the difference between a usable system and a │ │ │ │ +completely hogged down system. Most operating systems also has a limit on the │ │ │ │ +total number of file descriptors a process may have open. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___f_a_i_l_c_o_u_n_t_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +max_failcount is the maximum times we try to connect to a peer before stop │ │ │ │ +connecting again. If a peer succeeds, the failure counter is reset. If a peer │ │ │ │ +is retrieved from a peer source (other than DHT) the failcount is decremented │ │ │ │ +by one, allowing another try. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_i_n___r_e_c_o_n_n_e_c_t___t_i_m_e_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ +the number of seconds to wait to reconnect to a peer. this time is multiplied │ │ │ │ +with the failcount. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_e_e_r___c_o_n_n_e_c_t___t_i_m_e_o_u_t_|_i_n_t_ _|_1_5_ _ _ _ _ | │ │ │ │ +peer_connect_timeout the number of seconds to wait after a connection attempt │ │ │ │ +is initiated to a peer until it is considered as having timed out. This setting │ │ │ │ +is especially important in case the number of half-open connections are │ │ │ │ +limited, since stale half-open connection may delay the connection of other │ │ │ │ +peers considerably. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_c_o_n_n_e_c_t_i_o_n___s_p_e_e_d_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ +connection_speed is the number of connection attempts that are made per second. │ │ │ │ +If a number < 0 is specified, it will default to 200 connections per second. If │ │ │ │ +0 is specified, it means don't make outgoing connections at all. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_n_a_c_t_i_v_i_t_y___t_i_m_e_o_u_t_|_i_n_t_ _|_6_0_0_ _ _ _ | │ │ │ │ +if a peer is uninteresting and uninterested for longer than this number of │ │ │ │ +seconds, it will be disconnected. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_n_c_h_o_k_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_1_5_ _ _ _ _ | │ │ │ │ +unchoke_interval is the number of seconds between chokes/unchokes. On this │ │ │ │ +interval, peers are re-evaluated for being choked/unchoked. This is defined as │ │ │ │ +30 seconds in the protocol, and it should be significantly longer than what it │ │ │ │ +takes for TCP to ramp up to it's max rate. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_o_p_t_i_m_i_s_t_i_c___u_n_c_h_o_k_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ +optimistic_unchoke_interval is the number of seconds between each ooppttiimmiissttiicc │ │ │ │ +unchoke. On this timer, the currently optimistically unchoked peer will change. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_n_u_m___w_a_n_t_|_i_n_t_ _|_2_0_0_ _ _ _ | │ │ │ │ +num_want is the number of peers we want from each tracker request. It defines │ │ │ │ +what is sent as the &num_want= parameter to the tracker. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_n_i_t_i_a_l___p_i_c_k_e_r___t_h_r_e_s_h_o_l_d_|_i_n_t_ _|_4_ _ _ _ _ _ | │ │ │ │ +initial_picker_threshold specifies the number of pieces we need before we │ │ │ │ +switch to rarest first picking. The first initial_picker_threshold pieces in │ │ │ │ +any torrent are picked at random , the following pieces are picked in rarest │ │ │ │ +first order. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_l_o_w_e_d___f_a_s_t___s_e_t___s_i_z_e_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ +the number of allowed pieces to send to peers that supports the fast extensions │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_u_g_g_e_s_t___m_o_d_e_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_n_o___p_i_e_c_e___s_u_g_g_e_s_t_i_o_n_s| │ │ │ │ +suggest_mode controls whether or not libtorrent will send out suggest messages │ │ │ │ +to create a bias of its peers to request certain pieces. The modes are: │ │ │ │ + * no_piece_suggestions which will not send out suggest messages. │ │ │ │ + * suggest_read_cache which will send out suggest messages for the most │ │ │ │ + recent pieces that are in the read cache. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_m_a_x___q_u_e_u_e_d___d_i_s_k___b_y_t_e_s_|_i_n_t_ _|_1_0_0_ _*_ _1_0_2_4_ _*_ _1_0_2_4| │ │ │ │ +max_queued_disk_bytes is the maximum number of bytes, to be written to disk, │ │ │ │ +that can wait in the disk I/O thread queue. This queue is only for waiting for │ │ │ │ +the disk I/O thread to receive the job and either write it to disk or insert it │ │ │ │ +in the write cache. When this limit is reached, the peer connections will stop │ │ │ │ +reading data from their sockets, until the disk thread catches up. Setting this │ │ │ │ +too low will severely limit your download rate. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_h_a_n_d_s_h_a_k_e___t_i_m_e_o_u_t_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ +the number of seconds to wait for a handshake response from a peer. If no │ │ │ │ +response is received within this time, the peer is disconnected. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ | │ │ │ │ +|_s_e_n_d___b_u_f_f_e_r___l_o_w___w_a_t_e_r_m_a_r_k_ _ _ _|_i_n_t_ _|_1_0_ _*_ _1_0_2_4_ | │ │ │ │ +|_s_e_n_d___b_u_f_f_e_r___w_a_t_e_r_m_a_r_k_ _ _ _ _ _ _ _|_i_n_t_ _|_5_0_0_ _*_ _1_0_2_4| │ │ │ │ +|_s_e_n_d___b_u_f_f_e_r___w_a_t_e_r_m_a_r_k___f_a_c_t_o_r_|_i_n_t_ _|_5_0_ _ _ _ _ _ _ _ | │ │ │ │ +send_buffer_low_watermark the minimum send buffer target size (send buffer │ │ │ │ +includes bytes pending being read from disk). For good and snappy seeding │ │ │ │ +performance, set this fairly high, to at least fit a few blocks. This is │ │ │ │ +essentially the initial window size which will determine how fast we can ramp │ │ │ │ +up the send rate │ │ │ │ +if the send buffer has fewer bytes than send_buffer_watermark, we'll read │ │ │ │ +another 16 kiB block onto it. If set too small, upload rate capacity will │ │ │ │ +suffer. If set too high, memory will be wasted. The actual watermark may be │ │ │ │ +lower than this in case the upload rate is low, this is the upper limit. │ │ │ │ +the current upload rate to a peer is multiplied by this factor to get the send │ │ │ │ +buffer watermark. The factor is specified as a percentage. i.e. 50 -> 0.5 This │ │ │ │ +product is clamped to the send_buffer_watermark setting to not exceed the max. │ │ │ │ +For high speed upload, this should be set to a greater value than 100. For high │ │ │ │ +capacity connections, setting this higher can improve upload performance and │ │ │ │ +disk throughput. Setting it too high may waste RAM and create a bias towards │ │ │ │ +read jobs over write jobs. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m_ _ _ _ _ _|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_f_i_x_e_d___s_l_o_t_s___c_h_o_k_e_r| │ │ │ │ +|_s_e_e_d___c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_r_o_u_n_d___r_o_b_i_n_ _ _ _ _ _ _ | │ │ │ │ +choking_algorithm specifies which algorithm to use to determine how many peers │ │ │ │ +to unchoke. The unchoking algorithm for downloading torrents is always "tit- │ │ │ │ +for-tat", i.e. the peers we download the fastest from are unchoked. │ │ │ │ +The options for choking algorithms are defined in the _c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t enum. │ │ │ │ +seed_choking_algorithm controls the seeding unchoke behavior. i.e. How we │ │ │ │ +select which peers to unchoke for seeding torrents. Since a seeding torrent │ │ │ │ +isn't downloading anything, the tit-for-tat mechanism cannot be used. The │ │ │ │ +available options are defined in the _s_e_e_d___c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t enum. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_i_s_k___i_o___w_r_i_t_e___m_o_d_e_|_i_n_t_ _|_D_I_S_K___W_R_I_T_E___M_O_D_E_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_i_s_k___i_o___r_e_a_d___m_o_d_e_ _|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_e_n_a_b_l_e___o_s___c_a_c_h_e| │ │ │ │ +determines how files are opened when they're in read only mode versus read and │ │ │ │ +write mode. The options are: │ │ │ │ + enable_os_cache │ │ │ │ + Files are opened normally, with the OS caching reads and writes. │ │ │ │ + disable_os_cache │ │ │ │ + This opens all files in no-cache mode. This corresponds to the OS not │ │ │ │ + letting blocks for the files linger in the cache. This makes sense in │ │ │ │ + order to avoid the bittorrent client to potentially evict all other │ │ │ │ + processes' cache by simply handling high throughput and large files. If │ │ │ │ + libtorrent's read cache is disabled, enabling this may reduce │ │ │ │ + performance. │ │ │ │ + write_through │ │ │ │ + flush pieces to disk as they complete validation. │ │ │ │ +One reason to disable caching is that it may help the operating system from │ │ │ │ +growing its file cache indefinitely. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_o_u_t_g_o_i_n_g___p_o_r_t_ _ _ _ _ _|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +|_n_u_m___o_u_t_g_o_i_n_g___p_o_r_t_s_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +this is the first port to use for binding outgoing connections to. This is │ │ │ │ +useful for users that have routers that allow QoS settings based on local port. │ │ │ │ +when binding outgoing connections to specific ports, num_outgoing_ports is the │ │ │ │ +size of the range. It should be more than a few │ │ │ │ +Warning │ │ │ │ +setting outgoing ports will limit the ability to keep multiple connections to │ │ │ │ +the same client, even for different torrents. It is not recommended to change │ │ │ │ +this setting. Its main purpose is to use as an escape hatch for cheap routers │ │ │ │ +with QoS capability but can only classify flows based on port numbers. │ │ │ │ +It is a range instead of a single port because of the problems with failing to │ │ │ │ +reconnect to peers if a previous socket to that peer and port is in TIME_WAIT │ │ │ │ +state. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_e_e_r___d_s_c_p_|_i_n_t_ _|_0_x_0_1_ _ _ | │ │ │ │ +peer_dscp determines the DSCP field in the IP header of every packet sent to │ │ │ │ +peers (including web seeds). 0x0 means no marking, 0x01 represents Lower │ │ │ │ +Effort. For more details see _R_F_C_ _8_6_2_2 and IANA's _d_s_c_p_ _r_e_g_i_s_t_r_y. │ │ │ │ +peer_tos is the old name for peer_dscp, it's still available for backwards │ │ │ │ +compatibility. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_c_t_i_v_e___d_o_w_n_l_o_a_d_s_ _ _ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +|_a_c_t_i_v_e___s_e_e_d_s_ _ _ _ _ _ _ _ _|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ +|_a_c_t_i_v_e___c_h_e_c_k_i_n_g_ _ _ _ _ _|_i_n_t_ _|_1_ _ _ _ _ _ | │ │ │ │ +|_a_c_t_i_v_e___d_h_t___l_i_m_i_t_ _ _ _ _|_i_n_t_ _|_8_8_ _ _ _ _ | │ │ │ │ +|_a_c_t_i_v_e___t_r_a_c_k_e_r___l_i_m_i_t_|_i_n_t_ _|_1_6_0_0_ _ _ | │ │ │ │ +|_a_c_t_i_v_e___l_s_d___l_i_m_i_t_ _ _ _ _|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ +|_a_c_t_i_v_e___l_i_m_i_t_ _ _ _ _ _ _ _ _|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ +for auto managed torrents, these are the limits they are subject to. If there │ │ │ │ +are too many torrents some of the auto managed ones will be paused until some │ │ │ │ +slots free up. active_downloads and active_seeds controls how many active │ │ │ │ +seeding and downloading torrents the queuing mechanism allows. The target │ │ │ │ +number of active torrents is min(active_downloads + active_seeds, │ │ │ │ +active_limit). active_downloads and active_seeds are upper limits on the number │ │ │ │ +of downloading torrents and seeding torrents respectively. Setting the value to │ │ │ │ +-1 means unlimited. │ │ │ │ +For example if there are 10 seeding torrents and 10 downloading torrents, and │ │ │ │ +active_downloads is 4 and active_seeds is 4, there will be 4 seeds active and 4 │ │ │ │ +downloading torrents. If the settings are active_downloads = 2 and active_seeds │ │ │ │ += 4, then there will be 2 downloading torrents and 4 seeding torrents active. │ │ │ │ +Torrents that are not auto managed are not counted against these limits. │ │ │ │ +active_checking is the limit of number of simultaneous checking torrents. │ │ │ │ +active_limit is a hard limit on the number of active (auto managed) torrents. │ │ │ │ +This limit also applies to slow torrents. │ │ │ │ +active_dht_limit is the max number of torrents to announce to the DHT. │ │ │ │ +active_tracker_limit is the max number of torrents to announce to their │ │ │ │ +trackers. │ │ │ │ +active_lsd_limit is the max number of torrents to announce to the local network │ │ │ │ +over the local service discovery protocol. │ │ │ │ +You can have more torrents aaccttiivvee, even though they are not announced to the │ │ │ │ +DHT, lsd or their tracker. If some peer knows about you for any reason and │ │ │ │ +tries to connect, it will still be accepted, unless the torrent is paused, │ │ │ │ +which means it won't accept any connections. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_u_t_o___m_a_n_a_g_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ +auto_manage_interval is the number of seconds between the torrent queue is │ │ │ │ +updated, and rotated. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ | │ │ │ │ +|_s_e_e_d___t_i_m_e___l_i_m_i_t_|_i_n_t_ _|_2_4_ _*_ _6_0_ _*_ _6_0| │ │ │ │ +this is the limit on the time a torrent has been an active seed (specified in │ │ │ │ +seconds) before it is considered having met the seed limit criteria. See │ │ │ │ +_q_u_e_u_i_n_g. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_u_t_o___s_c_r_a_p_e___i_n_t_e_r_v_a_l_ _ _ _ _|_i_n_t_ _|_1_8_0_0_ _ _ | │ │ │ │ +|_a_u_t_o___s_c_r_a_p_e___m_i_n___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_0_ _ _ _ | │ │ │ │ +auto_scrape_interval is the number of seconds between scrapes of queued │ │ │ │ +torrents (auto managed and paused torrents). Auto managed torrents that are │ │ │ │ +paused, are scraped regularly in order to keep track of their downloader/seed │ │ │ │ +ratio. This ratio is used to determine which torrents to seed and which to │ │ │ │ +pause. │ │ │ │ +auto_scrape_min_interval is the minimum number of seconds between any automatic │ │ │ │ +scrape (regardless of torrent). In case there are a large number of paused auto │ │ │ │ +managed torrents, this puts a limit on how often a scrape request is sent. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___p_e_e_r_l_i_s_t___s_i_z_e_ _ _ _ _ _ _ _|_i_n_t_ _|_3_0_0_0_ _ _ | │ │ │ │ +|_m_a_x___p_a_u_s_e_d___p_e_e_r_l_i_s_t___s_i_z_e_|_i_n_t_ _|_1_0_0_0_ _ _ | │ │ │ │ +max_peerlist_size is the maximum number of peers in the list of known peers. │ │ │ │ +These peers are not necessarily connected, so this number should be much │ │ │ │ +greater than the maximum number of connected peers. Peers are evicted from the │ │ │ │ +cache when the list grows passed 90% of this limit, and once the size hits the │ │ │ │ +limit, peers are no longer added to the list. If this limit is set to 0, there │ │ │ │ +is no limit on how many peers we'll keep in the peer list. │ │ │ │ +max_paused_peerlist_size is the max peer list size used for torrents that are │ │ │ │ +paused. This can be used to save memory for paused torrents, since it's not as │ │ │ │ +important for them to keep a large peer list. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_i_n___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_5_ _*_ _6_0_ | │ │ │ │ +this is the minimum allowed announce interval for a tracker. This is specified │ │ │ │ +in seconds and is used as a sanity check on what is returned from a tracker. It │ │ │ │ +mitigates hammering mis-configured trackers. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_u_t_o___m_a_n_a_g_e___s_t_a_r_t_u_p_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ +this is the number of seconds a torrent is considered active after it was │ │ │ │ +started, regardless of upload and download speed. This is so that newly started │ │ │ │ +torrents are not considered inactive until they have a fair chance to start │ │ │ │ +downloading. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_e_e_d_i_n_g___p_i_e_c_e___q_u_o_t_a_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ +seeding_piece_quota is the number of pieces to send to a peer, when seeding, │ │ │ │ +before rotating in another peer to the unchoke set. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___r_e_j_e_c_t_s_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ +max_rejects is the number of piece requests we will reject in a row while a │ │ │ │ +peer is choked before the peer is considered abusive and is disconnected. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_e_c_v___s_o_c_k_e_t___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +|_s_e_n_d___s_o_c_k_e_t___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +specifies the buffer sizes set on peer sockets. 0 means the OS default (i.e. │ │ │ │ +don't change the buffer sizes). The socket buffer sizes are changed using │ │ │ │ +setsockopt() with SOL_SOCKET/SO_RCVBUF and SO_SNDBUFFER. │ │ │ │ +Note that uTP peers share a single UDP socket buffer for each of the │ │ │ │ +listen_interfaces, along with DHT and UDP tracker traffic. If the buffer size │ │ │ │ +is too small for the combined traffic through the socket, packets may be │ │ │ │ +dropped. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ | │ │ │ │ +|_m_a_x___p_e_e_r___r_e_c_v___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_2_ _*_ _1_0_2_4_ _*_ _1_0_2_4| │ │ │ │ +the max number of bytes a single peer connection's receive buffer is allowed to │ │ │ │ +grow to. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_o_p_t_i_m_i_s_t_i_c___d_i_s_k___r_e_t_r_y_|_i_n_t_ _|_1_0_ _*_ _6_0| │ │ │ │ +optimistic_disk_retry is the number of seconds from a disk write errors occur │ │ │ │ +on a torrent until libtorrent will take it out of the upload mode, to test if │ │ │ │ +the error condition has been fixed. │ │ │ │ +libtorrent will only do this automatically for auto managed torrents. │ │ │ │ +You can explicitly take a torrent out of upload only mode using set_upload_mode │ │ │ │ +(). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___s_u_g_g_e_s_t___p_i_e_c_e_s_|_i_n_t_ _|_1_6_ _ _ _ _ | │ │ │ │ +max_suggest_pieces is the max number of suggested piece indices received from a │ │ │ │ +peer that's remembered. If a peer floods suggest messages, this limit prevents │ │ │ │ +libtorrent from using too much RAM. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_l_o_c_a_l___s_e_r_v_i_c_e___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_5_ _*_ _6_0_ | │ │ │ │ +local_service_announce_interval is the time between local network announces for │ │ │ │ +a torrent. This interval is specified in seconds. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_1_5_ _*_ _6_0| │ │ │ │ +dht_announce_interval is the number of seconds between announcing torrents to │ │ │ │ +the distributed hash table (DHT). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_d_p___t_r_a_c_k_e_r___t_o_k_e_n___e_x_p_i_r_y_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ +udp_tracker_token_expiry is the number of seconds libtorrent will keep UDP │ │ │ │ +tracker connection tokens around for. This is specified to be 60 seconds. The │ │ │ │ +higher this value is, the fewer packets have to be sent to the UDP tracker. In │ │ │ │ +order for higher values to work, the tracker needs to be configured to match │ │ │ │ +the expiration time for tokens. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_n_u_m___o_p_t_i_m_i_s_t_i_c___u_n_c_h_o_k_e___s_l_o_t_s_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +num_optimistic_unchoke_slots is the number of optimistic unchoke slots to use. │ │ │ │ +Having a higher number of optimistic unchoke slots mean you will find the good │ │ │ │ +peers faster but with the trade-off to use up more bandwidth. 0 means │ │ │ │ +automatic, where libtorrent opens up 20% of your allowed upload slots as │ │ │ │ +optimistic unchoke slots. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___p_e_x___p_e_e_r_s_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ +the max number of peers we accept from pex messages from a single peer. this │ │ │ │ +limits the number of concurrent peers any of our peers claims to be connected │ │ │ │ +to. If they claim to be connected to more than this, we'll ignore any peer that │ │ │ │ +exceeds this limit │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_t_i_c_k___i_n_t_e_r_v_a_l_|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ +tick_interval specifies the number of milliseconds between internal ticks. This │ │ │ │ +is the frequency with which bandwidth quota is distributed to peers. It should │ │ │ │ +not be more than one second (i.e. 1000 ms). Setting this to a low value (around │ │ │ │ +100) means higher resolution bandwidth quota distribution, setting it to a │ │ │ │ +higher value saves CPU cycles. │ │ │ │ +A negative value disables the once-per-second gate on the second_tick path (the │ │ │ │ +heavier per-torrent work). The timer itself still fires every millisecond. This │ │ │ │ +is intended for test and fuzzing scenarios that need the _s_e_s_s_i_o_n to react │ │ │ │ +instantly; do not use it in production. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_h_a_r_e___m_o_d_e___t_a_r_g_e_t_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +share_mode_target specifies the target share ratio for share mode torrents. If │ │ │ │ +set to 3, we'll try to upload 3 times as much as we download. Setting this very │ │ │ │ +high, will make it very conservative and you might end up not downloading │ │ │ │ +anything ever (and not affecting your share ratio). It does not make any sense │ │ │ │ +to set this any lower than 2. For instance, if only 3 peers need to download │ │ │ │ +the rarest piece, it's impossible to download a single piece and upload it more │ │ │ │ +than 3 times. If the share_mode_target is set to more than 3, nothing is │ │ │ │ +downloaded. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_p_l_o_a_d___r_a_t_e___l_i_m_i_t_ _ _|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +|_d_o_w_n_l_o_a_d___r_a_t_e___l_i_m_i_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +upload_rate_limit and download_rate_limit sets the session-global limits of │ │ │ │ +upload and download rate limits, in bytes per second. By default peers on the │ │ │ │ +local network are not rate limited. │ │ │ │ +A value of 0 means unlimited. │ │ │ │ +For fine grained control over rate limits, including making them apply to local │ │ │ │ +peers, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___u_p_l_o_a_d___r_a_t_e___l_i_m_i_t_|_i_n_t_ _|_8_0_0_0_ _ _ | │ │ │ │ +the number of bytes per second (on average) the DHT is allowed to send. If the │ │ │ │ +incoming requests causes to many bytes to be sent in responses, incoming │ │ │ │ +requests will be dropped until the quota has been replenished. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_n_c_h_o_k_e___s_l_o_t_s___l_i_m_i_t_|_i_n_t_ _|_8_ _ _ _ _ _ | │ │ │ │ +unchoke_slots_limit is the max number of unchoked peers in the _s_e_s_s_i_o_n. The │ │ │ │ +number of unchoke slots may be ignored depending on what choking_algorithm is │ │ │ │ +set to. Setting this limit to -1 means unlimited, i.e. all peers will always be │ │ │ │ +unchoked. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_c_o_n_n_e_c_t_i_o_n_s___l_i_m_i_t_|_i_n_t_ _|_2_0_0_ _ _ _ | │ │ │ │ +connections_limit sets a global limit on the number of connections opened. The │ │ │ │ +number of connections is set to a hard minimum of at least two per torrent, so │ │ │ │ +if you set a too low connections limit, and open too many torrents, the limit │ │ │ │ +will not be met. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_c_o_n_n_e_c_t_i_o_n_s___s_l_a_c_k_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ +connections_slack is the number of incoming connections exceeding the │ │ │ │ +connection limit to accept in order to potentially replace existing ones. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_t_p___t_a_r_g_e_t___d_e_l_a_y_ _ _ _|_i_n_t_ _|_1_0_0_ _ _ _ | │ │ │ │ +|_u_t_p___g_a_i_n___f_a_c_t_o_r_ _ _ _ _|_i_n_t_ _|_3_0_0_0_ _ _ | │ │ │ │ +|_u_t_p___m_i_n___t_i_m_e_o_u_t_ _ _ _ _|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ +|_u_t_p___s_y_n___r_e_s_e_n_d_s_ _ _ _ _|_i_n_t_ _|_2_ _ _ _ _ _ | │ │ │ │ +|_u_t_p___f_i_n___r_e_s_e_n_d_s_ _ _ _ _|_i_n_t_ _|_2_ _ _ _ _ _ | │ │ │ │ +|_u_t_p___n_u_m___r_e_s_e_n_d_s_ _ _ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +|_u_t_p___c_o_n_n_e_c_t___t_i_m_e_o_u_t_|_i_n_t_ _|_3_0_0_0_ _ _ | │ │ │ │ +|_u_t_p___l_o_s_s___m_u_l_t_i_p_l_i_e_r_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ +utp_target_delay is the target delay for uTP sockets in milliseconds. A high │ │ │ │ +value will make uTP connections more aggressive and cause longer queues in the │ │ │ │ +upload bottleneck. It cannot be too low, since the noise in the measurements │ │ │ │ +would cause it to send too slow. utp_gain_factor is the number of bytes the uTP │ │ │ │ +congestion window can increase at the most in one RTT. If this is set too high, │ │ │ │ +the congestion controller reacts too hard to noise and will not be stable, if │ │ │ │ +it's set too low, it will react slow to congestion and not back off as fast. │ │ │ │ +utp_min_timeout is the shortest allowed uTP socket timeout, specified in │ │ │ │ +milliseconds. The timeout depends on the RTT of the connection, but is never │ │ │ │ +smaller than this value. A connection times out when every packet in a window │ │ │ │ +is lost, or when a packet is lost twice in a row (i.e. the resent packet is │ │ │ │ +lost as well). │ │ │ │ +The shorter the timeout is, the faster the connection will recover from this │ │ │ │ +situation, assuming the RTT is low enough. utp_syn_resends is the number of SYN │ │ │ │ +packets that are sent (and timed out) before giving up and closing the socket. │ │ │ │ +utp_num_resends is the number of times a packet is sent (and lost or timed out) │ │ │ │ +before giving up and closing the connection. utp_connect_timeout is the number │ │ │ │ +of milliseconds of timeout for the initial SYN packet for uTP connections. For │ │ │ │ +each timed out packet (in a row), the timeout is doubled. utp_loss_multiplier │ │ │ │ +controls how the congestion window is changed when a packet loss is │ │ │ │ +experienced. It's specified as a percentage multiplier for cwnd. Do not change │ │ │ │ +this value unless you know what you're doing. Never set it higher than 100. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_m_i_x_e_d___m_o_d_e___a_l_g_o_r_i_t_h_m_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e_e_r___p_r_o_p_o_r_t_i_o_n_a_l| │ │ │ │ +The mixed_mode_algorithm determines how to treat TCP connections when there are │ │ │ │ +uTP connections. Since uTP is designed to yield to TCP, there's an inherent │ │ │ │ +problem when using swarms that have both TCP and uTP connections. If nothing is │ │ │ │ +done, uTP connections would often be starved out for bandwidth by the TCP │ │ │ │ +connections. This mode is prefer_tcp. The peer_proportional mode simply looks │ │ │ │ +at the current throughput and rate limits all TCP connections to their │ │ │ │ +proportional share based on how many of the connections are TCP. This works │ │ │ │ +best if uTP connections are not rate limited by the global rate limiter (which │ │ │ │ +they aren't by default). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_l_i_s_t_e_n___q_u_e_u_e___s_i_z_e_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ +listen_queue_size is the value passed in to listen() for the listen socket. It │ │ │ │ +is the number of outstanding incoming connections to queue up while we're not │ │ │ │ +actively waiting for a connection to be accepted. 5 should be sufficient for │ │ │ │ +any normal client. If this is a high performance server which expects to │ │ │ │ +receive a lot of connections, or used in a simulator or test, it might make │ │ │ │ +sense to raise this number. It will not take affect until the listen_interfaces │ │ │ │ +settings is updated. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_t_o_r_r_e_n_t___c_o_n_n_e_c_t___b_o_o_s_t_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ +torrent_connect_boost is the number of peers to try to connect to immediately │ │ │ │ +when the first tracker response is received for a torrent. This is a boost to │ │ │ │ +given to new torrents to accelerate them starting up. The normal connect │ │ │ │ +scheduler is run once every second, this allows peers to be connected │ │ │ │ +immediately instead of waiting for the _s_e_s_s_i_o_n tick to trigger connections. │ │ │ │ +This may not be set higher than 255. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_e_r_t___q_u_e_u_e___s_i_z_e_|_i_n_t_ _|_2_0_0_0_ _ _ | │ │ │ │ +alert_queue_size is the maximum number of alerts queued up internally. If │ │ │ │ +alerts are not popped, the queue will eventually fill up to this level. Once │ │ │ │ +the _a_l_e_r_t queue is full, additional alerts will be dropped, and not delivered │ │ │ │ +to the client. Once the client drains the queue, new alerts may be delivered │ │ │ │ +again. In order to know that alerts have been dropped, see session_handle:: │ │ │ │ +dropped_alerts(). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ | │ │ │ │ +|_m_a_x___m_e_t_a_d_a_t_a___s_i_z_e_|_i_n_t_ _|_3_ _*_ _1_0_2_4_ _*_ _1_0_2_4_0| │ │ │ │ +max_metadata_size is the maximum allowed size (in bytes) to be received by the │ │ │ │ +metadata extension, i.e. magnet links. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_h_a_s_h_i_n_g___t_h_r_e_a_d_s_|_i_n_t_ _|_1_ _ _ _ _ _ | │ │ │ │ +hashing_threads is the number of disk I/O threads to use for piece hash │ │ │ │ +verification. These threads are iinn aaddddiittiioonn to the regular disk I/O threads │ │ │ │ +specified by _s_e_t_t_i_n_g_s___p_a_c_k_:_:_a_i_o___t_h_r_e_a_d_s. These threads are only used for full │ │ │ │ +checking of torrents. The hash checking done while downloading are done by the │ │ │ │ +regular disk I/O threads. The _h_a_s_h_e_r threads do not only compute hashes, but │ │ │ │ +also perform the read from disk. On storage optimal for sequential access, such │ │ │ │ +as hard drives, this setting should be set to 1, which is also the default. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_c_h_e_c_k_i_n_g___m_e_m___u_s_a_g_e_|_i_n_t_ _|_2_5_6_ _ _ _ | │ │ │ │ +the number of blocks to keep outstanding at any given time when checking │ │ │ │ +torrents. Higher numbers give faster re-checks but uses more memory. Specified │ │ │ │ +in number of 16 kiB blocks │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_e_d_i_c_t_i_v_e___p_i_e_c_e___a_n_n_o_u_n_c_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +if set to > 0, pieces will be announced to other peers before they are fully │ │ │ │ +downloaded (and before they are hash checked). The intention is to gain 1.5 │ │ │ │ +potential round trip times per downloaded piece. When non-zero, this indicates │ │ │ │ +how many milliseconds in advance pieces should be announced, before they are │ │ │ │ +expected to be completed. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_i_o___t_h_r_e_a_d_s_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ +for some aio back-ends, aio_threads specifies the number of io-threads to use. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_t_r_a_c_k_e_r___b_a_c_k_o_f_f_|_i_n_t_ _|_2_5_0_ _ _ _ | │ │ │ │ +tracker_backoff determines how aggressively to back off from retrying failing │ │ │ │ +trackers. This value determines xx in the following formula, determining the │ │ │ │ +number of seconds to wait until the next retry: │ │ │ │ + delay = 5 + 5 * x / 100 * fails^2 │ │ │ │ +This setting may be useful to make libtorrent more or less aggressive in │ │ │ │ +hitting trackers. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_h_a_r_e___r_a_t_i_o___l_i_m_i_t_ _ _ _ _|_i_n_t_ _|_2_0_0_ _ _ _ | │ │ │ │ +|_s_e_e_d___t_i_m_e___r_a_t_i_o___l_i_m_i_t_|_i_n_t_ _|_7_0_0_ _ _ _ | │ │ │ │ +when a seeding torrent reaches either the share ratio (bytes up / bytes down) │ │ │ │ +or the seed time ratio (seconds as seed / seconds as downloader) or the seed │ │ │ │ +time limit (seconds as seed) it is considered done, and it will leave room for │ │ │ │ +other torrents. These are specified as percentages. Torrents that are │ │ │ │ +considered done will still be allowed to be seeded, they just won't have │ │ │ │ +priority anymore. For more, see _q_u_e_u_i_n_g. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_e_e_r___t_u_r_n_o_v_e_r_ _ _ _ _ _ _ _ _ _|_i_n_t_ _|_4_ _ _ _ _ _ | │ │ │ │ +|_p_e_e_r___t_u_r_n_o_v_e_r___c_u_t_o_f_f_ _ _|_i_n_t_ _|_9_0_ _ _ _ _ | │ │ │ │ +|_p_e_e_r___t_u_r_n_o_v_e_r___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_0_ _ _ _ | │ │ │ │ +peer_turnover is the percentage of peers to disconnect every turnover │ │ │ │ +peer_turnover_interval (if we're at the peer limit), this is specified in │ │ │ │ +percent when we are connected to more than limit * peer_turnover_cutoff peers │ │ │ │ +disconnect peer_turnover fraction of the peers. It is specified in percent │ │ │ │ +peer_turnover_interval is the interval (in seconds) between optimistic │ │ │ │ +disconnects if the disconnects happen and how many peers are disconnected is │ │ │ │ +controlled by peer_turnover and peer_turnover_cutoff │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_c_o_n_n_e_c_t___s_e_e_d___e_v_e_r_y___n___d_o_w_n_l_o_a_d_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ +this setting controls the priority of downloading torrents over seeding or │ │ │ │ +finished torrents when it comes to making peer connections. Peer connections │ │ │ │ +are throttled by the connection_speed and the half-open connection limit. This │ │ │ │ +makes peer connections a limited resource. Torrents that still have pieces to │ │ │ │ +download are prioritized by default, to avoid having many seeding torrents use │ │ │ │ +most of the connection attempts and only give one peer every now and then to │ │ │ │ +the downloading torrent. libtorrent will loop over the downloading torrents to │ │ │ │ +connect a peer each, and every n:th connection attempt, a finished torrent is │ │ │ │ +picked to be allowed to connect to a peer. This setting controls n. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ | │ │ │ │ +|_m_a_x___h_t_t_p___r_e_c_v___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_4_*_1_0_2_4_*_2_0_4| │ │ │ │ +the max number of bytes to allow an HTTP response to be when announcing to │ │ │ │ +trackers or downloading .torrent files via the url provided in │ │ │ │ +add_torrent_params. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___r_e_t_r_y___p_o_r_t___b_i_n_d_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ +if binding to a specific port fails, should the port be incremented by one and │ │ │ │ +tried again? This setting specifies how many times to retry a failed port bind │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_l_e_r_t___m_a_s_k_|_i_n_t_ _|_i_n_t_ _ _ _ | │ │ │ │ +a bitmask combining flags from _a_l_e_r_t___c_a_t_e_g_o_r_y___t defining which kinds of alerts │ │ │ │ +to receive │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_o_u_t___e_n_c___p_o_l_i_c_y_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e___e_n_a_b_l_e_d| │ │ │ │ +|_i_n___e_n_c___p_o_l_i_c_y_ _|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e___e_n_a_b_l_e_d| │ │ │ │ +control the settings for incoming and outgoing connections respectively. see │ │ │ │ +_e_n_c___p_o_l_i_c_y enum for the available options. Keep in mind that protocol │ │ │ │ +encryption degrades performance in several respects: │ │ │ │ + 1. It prevents "zero copy" disk buffers being sent to peers, since each peer │ │ │ │ + needs to mutate the data (i.e. encrypt it) the data must be copied per │ │ │ │ + peer connection rather than sending the same buffer to multiple peers. │ │ │ │ + 2. The encryption itself requires more CPU than plain bittorrent protocol. │ │ │ │ + The highest cost is the Diffie Hellman exchange on connection setup. │ │ │ │ + 3. The encryption handshake adds several round-trips to the connection │ │ │ │ + setup, and delays transferring data. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_a_l_l_o_w_e_d___e_n_c___l_e_v_e_l_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e___b_o_t_h| │ │ │ │ +determines the encryption level of the connections. This setting will adjust │ │ │ │ +which encryption scheme is offered to the other peer, as well as which │ │ │ │ +encryption scheme is selected by the client. See _e_n_c___l_e_v_e_l enum for options. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_n_a_c_t_i_v_e___d_o_w_n___r_a_t_e_|_i_n_t_ _|_2_0_4_8_ _ _ | │ │ │ │ +|_i_n_a_c_t_i_v_e___u_p___r_a_t_e_ _ _|_i_n_t_ _|_2_0_4_8_ _ _ | │ │ │ │ +the download and upload rate limits for a torrent to be considered active by │ │ │ │ +the queuing mechanism. A torrent whose download rate is less than │ │ │ │ +inactive_down_rate and whose upload rate is less than inactive_up_rate for │ │ │ │ +auto_manage_startup seconds, is considered inactive, and another queued torrent │ │ │ │ +may be started. This logic is disabled if dont_count_slow_torrents is false. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_r_o_x_y___t_y_p_e_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_n_o_n_e| │ │ │ │ +proxy to use. see _p_r_o_x_y___t_y_p_e___t. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_p_r_o_x_y___p_o_r_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +the port of the proxy server │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_2_p___p_o_r_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +sets the _i_2_p SAM bridge port to connect to. set the hostname with the │ │ │ │ +i2p_hostname setting. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_r_l_s_e_e_d___m_a_x___r_e_q_u_e_s_t___b_y_t_e_s_|_i_n_t_ _|_1_6_ _*_ _1_0_2_4_ _*_ _1_0_2_4| │ │ │ │ +The maximum request range of an url seed in bytes. This value defines the │ │ │ │ +largest possible sequential web seed request. Lower values are possible but │ │ │ │ +will be ignored if they are lower then piece size. This value should be related │ │ │ │ +to your download speed to prevent libtorrent from creating too many expensive │ │ │ │ +http requests per second. You can select a value as high as you want but keep │ │ │ │ +in mind that libtorrent can't create parallel requests if the first request did │ │ │ │ +already select the whole file. If you combine bittorrent seeds with web seeds │ │ │ │ +and pick strategies like rarest first you may find your web seed requests split │ │ │ │ +into smaller parts because we don't download already picked pieces twice. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_w_e_b___s_e_e_d___n_a_m_e___l_o_o_k_u_p___r_e_t_r_y_|_i_n_t_ _|_1_8_0_0_ _ _ | │ │ │ │ +time to wait until a new retry of a web seed name lookup │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_c_l_o_s_e___f_i_l_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_C_L_O_S_E___F_I_L_E___I_N_T_E_R_V_A_L| │ │ │ │ +the number of seconds between closing the file opened the longest ago. 0 means │ │ │ │ +to disable the feature. The purpose of this is to periodically close files to │ │ │ │ +trigger the operating system flushing disk cache. Specifically it has been │ │ │ │ +observed to be required on windows to not have the disk cache grow │ │ │ │ +indefinitely. This defaults to 240 seconds on windows, and disabled on other │ │ │ │ +systems. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_t_p___c_w_n_d___r_e_d_u_c_e___t_i_m_e_r_|_i_n_t_ _|_1_0_0_ _ _ _ | │ │ │ │ +When uTP experiences packet loss, it will reduce the congestion window, and not │ │ │ │ +reduce it again for this many milliseconds, even if experiencing another lost │ │ │ │ +packet. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___w_e_b___s_e_e_d___c_o_n_n_e_c_t_i_o_n_s_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +the max number of web seeds to have connected per torrent at any given time. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_e_s_o_l_v_e_r___c_a_c_h_e___t_i_m_e_o_u_t_|_i_n_t_ _|_1_2_0_0_ _ _ | │ │ │ │ +the number of seconds before the internal host name resolver considers a cache │ │ │ │ +value out of date, and removes it. Negative values are interpreted as zero. The │ │ │ │ +host name cache also caches failed DNS lookups, but only for 1/8th of the time │ │ │ │ +of this timeout. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_s_e_n_d___n_o_t___s_e_n_t___l_o_w___w_a_t_e_r_m_a_r_k_|_i_n_t_ _|_1_6_3_8_4_ _ | │ │ │ │ +specify the not-sent low watermark for socket send buffers. This corresponds to │ │ │ │ +the, Linux-specific, TCP_NOTSENT_LOWAT TCP socket option. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_r_a_t_e___c_h_o_k_e_r___i_n_i_t_i_a_l___t_h_r_e_s_h_o_l_d_|_i_n_t_ _|_1_0_2_4_ _ _ | │ │ │ │ +the rate based choker compares the upload rate to peers against a threshold │ │ │ │ +that increases proportionally by its size for every peer it visits, visiting │ │ │ │ +peers in decreasing upload rate. The number of upload slots is determined by │ │ │ │ +the number of peers whose upload rate exceeds the threshold. This option sets │ │ │ │ +the start value for this threshold. A higher value leads to fewer unchoke │ │ │ │ +slots, a lower value leads to more. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_u_p_n_p___l_e_a_s_e___d_u_r_a_t_i_o_n_|_i_n_t_ _|_3_6_0_0_ _ _ | │ │ │ │ +The expiration time of UPnP port-mappings, specified in seconds. 0 means │ │ │ │ +permanent lease. Some routers do not support expiration times on port-maps (nor │ │ │ │ +correctly returning an error indicating lack of support). In those cases, set │ │ │ │ +this to 0. Otherwise, don't set it any lower than 5 minutes. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_a_x___c_o_n_c_u_r_r_e_n_t___h_t_t_p___a_n_n_o_u_n_c_e_s_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ +limits the number of concurrent HTTP tracker announces. Once the limit is hit, │ │ │ │ +tracker requests are queued and issued when an outstanding announce completes. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___m_a_x___p_e_e_r_s___r_e_p_l_y_|_i_n_t_ _|_1_0_0_ _ _ _ | │ │ │ │ +the maximum number of peers to send in a reply to get_peers │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___s_e_a_r_c_h___b_r_a_n_c_h_i_n_g_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ +the number of concurrent search request the node will send when announcing and │ │ │ │ +refreshing the routing table. This parameter is called alpha in the kademlia │ │ │ │ +paper │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___m_a_x___f_a_i_l___c_o_u_n_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ +the maximum number of failed tries to contact a node before it is removed from │ │ │ │ +the routing table. If there are known working nodes that are ready to replace a │ │ │ │ +failing node, it will be replaced immediately, this limit is only used to clear │ │ │ │ +out nodes that don't have any node that can replace them. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___m_a_x___t_o_r_r_e_n_t_s_|_i_n_t_ _|_2_0_0_0_ _ _ | │ │ │ │ +the total number of torrents to track from the DHT. This is simply an upper │ │ │ │ +limit to make sure malicious DHT nodes cannot make us allocate an unbounded │ │ │ │ +amount of memory. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___m_a_x___d_h_t___i_t_e_m_s_|_i_n_t_ _|_7_0_0_ _ _ _ | │ │ │ │ +max number of items the DHT will store │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___m_a_x___p_e_e_r_s_|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ +the max number of peers to store per torrent (for the DHT) │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___m_a_x___t_o_r_r_e_n_t___s_e_a_r_c_h___r_e_p_l_y_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ +the max number of torrents to return in a torrent search query to the DHT │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___b_l_o_c_k___t_i_m_e_o_u_t_|_i_n_t_ _|_5_ _*_ _6_0_ | │ │ │ │ +the number of seconds a DHT node is banned if it exceeds the rate limit. The │ │ │ │ +rate limit is averaged over 10 seconds to allow for bursts above the limit. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___b_l_o_c_k___r_a_t_e_l_i_m_i_t_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ +the max number of packets per second a DHT node is allowed to send without │ │ │ │ +getting banned. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___i_t_e_m___l_i_f_e_t_i_m_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +the number of seconds a immutable/mutable item will be expired. default is 0, │ │ │ │ +means never expires. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___s_a_m_p_l_e___i_n_f_o_h_a_s_h_e_s___i_n_t_e_r_v_a_l_|_i_n_t_ _|_2_1_6_0_0_ _ | │ │ │ │ +the info-hashes sample recomputation interval (in seconds). The node will │ │ │ │ +precompute a subset of the tracked info-hashes and return that instead of │ │ │ │ +calculating it upon each request. The permissible range is between 0 and 21600 │ │ │ │ +seconds (inclusive). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_d_h_t___m_a_x___i_n_f_o_h_a_s_h_e_s___s_a_m_p_l_e___c_o_u_n_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ +the maximum number of elements in the sampled subset of info-hashes. If this │ │ │ │ +number is too big, expect the DHT storage implementations to clamp it in order │ │ │ │ +to allow UDP packets go through │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ | │ │ │ │ +|_m_a_x___p_i_e_c_e___c_o_u_n_t_|_i_n_t_ _|_0_x_2_0_0_0_0_0| │ │ │ │ +max_piece_count is the maximum allowed number of pieces in metadata received │ │ │ │ +via magnet links. Loading large torrents (with more pieces than the default │ │ │ │ +limit) may also require passing in a higher limit to _r_e_a_d___r_e_s_u_m_e___d_a_t_a_(_) and │ │ │ │ +_l_o_a_d___t_o_r_r_e_n_t___f_i_l_e_(_). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_e_t_a_d_a_t_a___t_o_k_e_n___l_i_m_i_t_|_i_n_t_ _|_2_5_0_0_0_0_0| │ │ │ │ +when receiving metadata (torrent file) from peers, this is the max number of │ │ │ │ +bencoded tokens we're willing to parse. This limit is meant to prevent DoS │ │ │ │ +attacks on peers. For very large torrents, this limit may have to be raised. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_i_s_k___w_r_i_t_e___m_o_d_e_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_m_m_a_p___w_r_i_t_e___m_o_d_e___t_:_:_a_l_w_a_y_s___m_m_a_p___w_r_i_t_e| │ │ │ │ +controls whether disk writes will be made through a memory mapped file or via │ │ │ │ +normal write calls. This only affects the mmap_disk_io. When saving to a non- │ │ │ │ +local drive (network share, NFS or NAS) using memory mapped files is most │ │ │ │ +likely inferior. When writing to a local SSD (especially in DAX mode) using │ │ │ │ +memory mapped files likely gives the best performance. The values for this │ │ │ │ +setting are specified as _m_m_a_p___w_r_i_t_e___m_o_d_e___t. │ │ │ │ +A very important consideration when changing this is that some operating │ │ │ │ +systems and filesystems do not support mixing write calls with memory mapped │ │ │ │ +files. Notably, Windows does not support mixing, since windows does not use the │ │ │ │ +page cache for caching files. Also, ZFS and Btrfs use their own caching layer, │ │ │ │ +not the page cache, so they also do not support mixing. Since reading large │ │ │ │ +files always happen via mmap, enabling writes via write calls on this systems │ │ │ │ +may cause corruption. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_m_a_p___f_i_l_e___s_i_z_e___c_u_t_o_f_f_|_i_n_t_ _|_4_0_ _ _ _ _ | │ │ │ │ +when using mmap_disk_io, files smaller than this number of blocks will not be │ │ │ │ +memory mapped, but will use normal pread/pwrite operations. This file size │ │ │ │ +limit is specified in 16 kiB blocks. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_2_p___i_n_b_o_u_n_d___q_u_a_n_t_i_t_y_ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +|_i_2_p___o_u_t_b_o_u_n_d___q_u_a_n_t_i_t_y_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +|_i_2_p___i_n_b_o_u_n_d___l_e_n_g_t_h_ _ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +|_i_2_p___o_u_t_b_o_u_n_d___l_e_n_g_t_h_ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ +Configures the SAM _s_e_s_s_i_o_n quantity of I2P inbound and outbound tunnels │ │ │ │ +[1..16]. number of hops for I2P inbound and outbound tunnels [0..7] Changing │ │ │ │ +these will not trigger a reconnect to the SAM bridge, they will take effect the │ │ │ │ +next time the SAM connection is re-established (by restarting or changing │ │ │ │ +i2p_hostname or i2p_port). │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_a_n_n_o_u_n_c_e___p_o_r_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +announce_port is the port passed along as the port parameter to remote trackers │ │ │ │ +such as HTTP or DHT. This setting does not affect the effective listening port │ │ │ │ +nor local service discovery announcements. If left as zero (default), the │ │ │ │ +listening port value is used. │ │ │ │ +Note │ │ │ │ +This setting is only meant for very special cases where a seed's listening port │ │ │ │ +differs from the external port. As an example, if a local proxy is used and │ │ │ │ +that the proxy supports reverse tunnels through NAT-PMP, the tracker must │ │ │ │ +connect to the external NAT-PMP port (configured using announce_port) instead │ │ │ │ +of the actual local listening port. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_i_2_p___i_n_b_o_u_n_d___l_e_n_g_t_h___v_a_r_i_a_n_c_e_ _|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +|_i_2_p___o_u_t_b_o_u_n_d___l_e_n_g_t_h___v_a_r_i_a_n_c_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ +Configures the variance for I2P inbound and outbound tunnel lengths [-7..7] │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_n_a_t_p_m_p___l_e_a_s_e___d_u_r_a_t_i_o_n_|_i_n_t_ _|_3_6_0_0_ _ _ | │ │ │ │ +The life time of NAT-PMP and PCP port-mappings, specified in seconds. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_m_i_n___w_e_b_s_o_c_k_e_t___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_1_ _*_ _6_0_ | │ │ │ │ +this is the minimum allowed announce interval for a WebSocket tracker used by │ │ │ │ +WebTorrent to signal WebRTC connections. This is specified in seconds and is │ │ │ │ +used as a sanity check on what is returned from a tracker. │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ +|_w_e_b_t_o_r_r_e_n_t___c_o_n_n_e_c_t_i_o_n___t_i_m_e_o_u_t_|_i_n_t_ _|_2_ _*_ _6_0_ | │ │ │ │ +the WebRTC connection timeout used by WebTorrent (in seconds) │ │ │ │ +struct settings_pack final : settings_interface │ │ │ │ +{ │ │ │ │ + void sseett__ssttrr (int name, std::string val) override; │ │ │ │ + void sseett__bbooooll (int name, bool val) override; │ │ │ │ + void sseett__iinntt (int name, int val) override; │ │ │ │ + bool hhaass__vvaall (int name) const override; │ │ │ │ + void cclleeaarr (); │ │ │ │ + void cclleeaarr (int name); │ │ │ │ + std::string const& ggeett__ssttrr (int name) const override; │ │ │ │ + int ggeett__iinntt (int name) const override; │ │ │ │ + bool ggeett__bbooooll (int name) const override; │ │ │ │ + │ │ │ │ + enum type_bases │ │ │ │ + { │ │ │ │ + string_type_base, │ │ │ │ + int_type_base, │ │ │ │ + bool_type_base, │ │ │ │ + type_mask, │ │ │ │ + index_mask, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum mmap_write_mode_t │ │ │ │ + { │ │ │ │ + always_pwrite, │ │ │ │ + always_mmap_write, │ │ │ │ + auto_mmap_write, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum suggest_mode_t │ │ │ │ + { │ │ │ │ + no_piece_suggestions, │ │ │ │ + suggest_read_cache, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum choking_algorithm_t │ │ │ │ + { │ │ │ │ + fixed_slots_choker, │ │ │ │ + rate_based_choker, │ │ │ │ + deprecated_bittyrant_choker, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum seed_choking_algorithm_t │ │ │ │ + { │ │ │ │ + round_robin, │ │ │ │ + fastest_upload, │ │ │ │ + anti_leech, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum io_buffer_mode_t │ │ │ │ + { │ │ │ │ + enable_os_cache, │ │ │ │ + deprecated_disable_os_cache_for_aligned_files, │ │ │ │ + disable_os_cache, │ │ │ │ + write_through, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum bandwidth_mixed_algo_t │ │ │ │ + { │ │ │ │ + prefer_tcp, │ │ │ │ + peer_proportional, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum enc_policy │ │ │ │ + { │ │ │ │ + pe_forced, │ │ │ │ + pe_enabled, │ │ │ │ + pe_disabled, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum enc_level │ │ │ │ + { │ │ │ │ + pe_plaintext, │ │ │ │ + pe_rc4, │ │ │ │ + pe_both, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + enum proxy_type_t │ │ │ │ + { │ │ │ │ + none, │ │ │ │ + socks4, │ │ │ │ + socks5, │ │ │ │ + socks5_pw, │ │ │ │ + http, │ │ │ │ + http_pw, │ │ │ │ + }; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sseett__bbooooll(()) sseett__ssttrr(()) sseett__iinntt(()) ********** │ │ │ │ +void sseett__ssttrr (int name, std::string val) override; │ │ │ │ +void sseett__bbooooll (int name, bool val) override; │ │ │ │ +void sseett__iinntt (int name, int val) override; │ │ │ │ +set a configuration option in the _s_e_t_t_i_n_g_s___p_a_c_k. name is one of the enum values │ │ │ │ +from string_types, int_types or bool_types. They must match the respective type │ │ │ │ +of the set_* function. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaass__vvaall(()) ********** │ │ │ │ +bool hhaass__vvaall (int name) const override; │ │ │ │ +queries whether the specified configuration option has a value set in this │ │ │ │ +pack. name can be any enumeration value from string_types, int_types or │ │ │ │ +bool_types. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** cclleeaarr(()) ********** │ │ │ │ +void cclleeaarr (); │ │ │ │ +clear the settings pack from all settings │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** cclleeaarr(()) ********** │ │ │ │ +void cclleeaarr (int name); │ │ │ │ +clear a specific setting from the pack │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ggeett__ssttrr(()) ggeett__iinntt(()) ggeett__bbooooll(()) ********** │ │ │ │ +std::string const& ggeett__ssttrr (int name) const override; │ │ │ │ +int ggeett__iinntt (int name) const override; │ │ │ │ +bool ggeett__bbooooll (int name) const override; │ │ │ │ +queries the current configuration option from the _s_e_t_t_i_n_g_s___p_a_c_k. name is one of │ │ │ │ +the enumeration values from string_types, int_types or bool_types. The enum │ │ │ │ +value must match the type of the get_* function. If the specified setting field │ │ │ │ +has not been set, the default value is returned. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm ttyyppee__bbaasseess ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_s_t_r_i_n_g___t_y_p_e___b_a_s_e_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_t___t_y_p_e___b_a_s_e_ _ _ _|_1_6_3_8_4_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_b_o_o_l___t_y_p_e___b_a_s_e_ _ _|_3_2_7_6_8_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_y_p_e___m_a_s_k_ _ _ _ _ _ _ _|_4_9_1_5_2_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_d_e_x___m_a_s_k_ _ _ _ _ _ _|_1_6_3_8_3_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm mmmmaapp__wwrriittee__mmooddee__tt ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|always_pwrite |0 |disable writing to disk via mmap, always use normal | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_r_i_t_e_ _c_a_l_l_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|always_mmap_write|1 |prefer using memory mapped files for disk writes (at| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_a_s_t_ _f_o_r_ _l_a_r_g_e_ _f_i_l_e_s_ _w_h_e_r_e_ _i_t_ _m_i_g_h_t_ _m_a_k_e_ _s_e_n_s_e_)_ _ _ _ | │ │ │ │ +| | |determine whether to use pwrite or memory mapped | │ │ │ │ +|auto_mmap_write |2 |files for disk writes depending on the kind of | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_t_o_r_a_g_e_ _b_e_h_i_n_d_ _t_h_e_ _s_a_v_e_ _p_a_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm ssuuggggeesstt__mmooddee__tt ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___p_i_e_c_e___s_u_g_g_e_s_t_i_o_n_s_|_0_ _ _ _ _|_d_i_s_a_b_l_e_s_ _s_u_g_g_e_s_t_i_o_n_ _m_e_s_s_a_g_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |sends suggest messages for the pieces currently in| │ │ │ │ +|suggest_read_cache |1 |the read cache, as a hint to peers about cache- | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_r_i_e_n_d_l_y_ _p_i_e_c_e_ _s_e_l_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm cchhookkiinngg__aallggoorriitthhmm__tt ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |This is the traditional choker with a fixed| │ │ │ │ +|fixed_slots_choker |0 |number of unchoke slots (as specified by | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_u_n_c_h_o_k_e___s_l_o_t_s___l_i_m_i_t_)_._ _ _ _ _ _ _ | │ │ │ │ +| | |This opens up unchoke slots based on the | │ │ │ │ +| | |upload rate achieved to peers. The more | │ │ │ │ +| | |slots that are opened, the marginal upload | │ │ │ │ +| | |rate required to open up another slot | │ │ │ │ +|rate_based_choker |2 |increases. Configure the initial threshold | │ │ │ │ +| | |with _s_e_t_t_i_n_g_s___p_a_c_k_:_: | │ │ │ │ +| | |_r_a_t_e___c_h_o_k_e_r___i_n_i_t_i_a_l___t_h_r_e_s_h_o_l_d. | │ │ │ │ +| | |For more information, see _r_a_t_e_ _b_a_s_e_d | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_h_o_k_i_n_g_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___b_i_t_t_y_r_a_n_t___c_h_o_k_e_r_|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm sseeeedd__cchhookkiinngg__aallggoorriitthhmm__tt ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |which round-robins the peers that are unchoked when | │ │ │ │ +|round_robin |0 |seeding. This distributes the upload bandwidth uniformly| │ │ │ │ +| | |and fairly. It minimizes the ability for a peer to | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_o_w_n_l_o_a_d_ _e_v_e_r_y_t_h_i_n_g_ _w_i_t_h_o_u_t_ _r_e_d_i_s_t_r_i_b_u_t_i_n_g_ _i_t_._ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |unchokes the peers we can send to the fastest. This | │ │ │ │ +|fastest_upload|1 |might be a bit more reliable in utilizing all available | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_p_a_c_i_t_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |prioritizes peers who have just started or are just | │ │ │ │ +| | |about to finish the download. The intention is to force | │ │ │ │ +|anti_leech |2 |peers in the middle of the download to trade with each | │ │ │ │ +| | |other. This does not just take into account the pieces a| │ │ │ │ +| | |peer is reporting having downloaded, but also the pieces| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_e_ _h_a_v_e_ _s_e_n_t_ _t_o_ _i_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm iioo__bbuuffffeerr__mmooddee__tt ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_e_n_a_b_l_e___o_s___c_a_c_h_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___d_i_s_a_b_l_e___o_s___c_a_c_h_e___f_o_r___a_l_i_g_n_e_d___f_i_l_e_s_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_i_s_a_b_l_e___o_s___c_a_c_h_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_w_r_i_t_e___t_h_r_o_u_g_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm bbaannddwwiiddtthh__mmiixxeedd__aallggoo__tt ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_r_e_f_e_r___t_c_p_ _ _ _ _ _ _ _|_0_ _ _ _ _|_d_i_s_a_b_l_e_s_ _t_h_e_ _m_i_x_e_d_ _m_o_d_e_ _b_a_n_d_w_i_d_t_h_ _b_a_l_a_n_c_i_n_g_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|peer_proportional|1 |does not throttle uTP, throttles TCP to the same | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_r_o_p_o_r_t_i_o_n_ _o_f_ _t_h_r_o_u_g_h_p_u_t_ _a_s_ _t_h_e_r_e_ _a_r_e_ _T_C_P_ _c_o_n_n_e_c_t_i_o_n_s| │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm eenncc__ppoolliiccyy ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |Only encrypted connections are allowed. Incoming | │ │ │ │ +|pe_forced |0 |connections that are not encrypted are closed and if the | │ │ │ │ +| | |encrypted outgoing connection fails, a non-encrypted retry| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_i_l_l_ _n_o_t_ _b_e_ _m_a_d_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |encrypted connections are enabled, but non-encrypted | │ │ │ │ +| | |connections are allowed. An incoming non-encrypted | │ │ │ │ +|pe_enabled |1 |connection will be accepted, and if an outgoing encrypted | │ │ │ │ +| | |connection fails, a non- encrypted connection will be | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_i_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_e___d_i_s_a_b_l_e_d_|_2_ _ _ _ _|_o_n_l_y_ _n_o_n_-_e_n_c_r_y_p_t_e_d_ _c_o_n_n_e_c_t_i_o_n_s_ _a_r_e_ _a_l_l_o_w_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm eenncc__lleevveell ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_e___p_l_a_i_n_t_e_x_t_|_1_ _ _ _ _|_u_s_e_ _o_n_l_y_ _p_l_a_i_n_ _t_e_x_t_ _e_n_c_r_y_p_t_i_o_n| │ │ │ │ +|_p_e___r_c_4_ _ _ _ _ _ _|_2_ _ _ _ _|_u_s_e_ _o_n_l_y_ _R_C_4_ _e_n_c_r_y_p_t_i_o_n_ _ _ _ _ _ _ | │ │ │ │ +|_p_e___b_o_t_h_ _ _ _ _ _|_3_ _ _ _ _|_a_l_l_o_w_ _b_o_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm pprrooxxyy__ttyyppee__tt ********** │ │ │ │ +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" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o_n_e_ _ _ _ _ _|_0_ _ _ _ _|_N_o_ _p_r_o_x_y_ _s_e_r_v_e_r_ _i_s_ _u_s_e_d_ _a_n_d_ _a_l_l_ _o_t_h_e_r_ _f_i_e_l_d_s_ _a_r_e_ _i_g_n_o_r_e_d_._ _ _ _ | │ │ │ │ +|socks4 |1 |The server is assumed to be a _S_O_C_K_S_4_ _s_e_r_v_e_r that requires a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_u_s_e_r_n_a_m_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The server is assumed to be a SOCKS5 server (_R_F_C_ _1_9_2_8) that | │ │ │ │ +|socks5 |2 |does not require any authentication. The username and | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_a_s_s_w_o_r_d_ _a_r_e_ _i_g_n_o_r_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The server is assumed to be a SOCKS5 server that supports | │ │ │ │ +|socks5_pw|3 |plain text username and password authentication (_R_F_C_ _1_9_2_9). | │ │ │ │ +| | |The username and password specified may be sent to the proxy | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_f_ _i_t_ _r_e_q_u_i_r_e_s_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The server is assumed to be an HTTP proxy. If the transport | │ │ │ │ +| | |used for the connection is non-HTTP, the server is assumed to| │ │ │ │ +|http |4 |support the _C_O_N_N_E_C_T method. i.e. for web seeds and HTTP | │ │ │ │ +| | |trackers, a plain proxy will suffice. The proxy is assumed to| │ │ │ │ +| | |not require authorization. The username and password will not| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_e_ _u_s_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The server is assumed to be an HTTP proxy that requires user | │ │ │ │ +|http_pw |5 |authorization. The username and password will be sent to the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_r_o_x_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ nnaammee__ffoorr__sseettttiinngg(()) sseettttiinngg__bbyy__nnaammee(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ +int sseettttiinngg__bbyy__nnaammee (string_view name); │ │ │ │ +char const* nnaammee__ffoorr__sseettttiinngg (int s); │ │ │ │ +converts a setting integer (from the enums string_types, int_types or │ │ │ │ +bool_types) to a string, and vice versa. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddeeffaauulltt__sseettttiinnggss(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ +settings_pack ddeeffaauulltt__sseettttiinnggss (); │ │ │ │ +returns a _s_e_t_t_i_n_g_s___p_a_c_k with every setting set to its default value │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ hhiigghh__ppeerrffoorrmmaannccee__sseeeedd(()) mmiinn__mmeemmoorryy__uussaaggee(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ +settings_pack mmiinn__mmeemmoorryy__uussaaggee (); │ │ │ │ +settings_pack hhiigghh__ppeerrffoorrmmaannccee__sseeeedd (); │ │ │ │ +The default values of the _s_e_s_s_i_o_n settings are set for a regular bittorrent │ │ │ │ +client running on a desktop system. There are functions that can set the │ │ │ │ +_s_e_s_s_i_o_n settings to pre set settings for other environments. These can be used │ │ │ │ +for the basis, and should be tweaked to fit your needs better. │ │ │ │ +min_memory_usage returns settings that will use the minimal amount of RAM, at │ │ │ │ +the potential expense of upload and download performance. It adjusts the socket │ │ │ │ +buffer sizes, disables the disk cache, lowers the send buffer watermarks so │ │ │ │ +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. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ggeenneerraattee__ffiinnggeerrpprriinntt(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_n_g_e_r_p_r_i_n_t_._h_p_p" │ │ │ │ +std::string ggeenneerraattee__ffiinnggeerrpprriinntt (std::string name │ │ │ │ + , int major, int minor = 0, int revision = 0, int tag = 0); │ │ │ │ +This is a utility function to produce a client ID fingerprint formatted to the │ │ │ │ +most common convention. The fingerprint can be set via the peer_fingerprint │ │ │ │ +setting, in _s_e_t_t_i_n_g_s___p_a_c_k. │ │ │ │ +The name string should contain exactly two characters. These are the characters │ │ │ │ +unique to your client, used to identify it. Make sure not to clash with anybody │ │ │ │ +else. Here are some taken id's: │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_ii_dd_ _cc_hh_aa_rr_ss_|_cc_ll_ii_ee_nn_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_L_T_ _ _ _ _ _ _|_l_i_b_t_o_r_r_e_n_t_ _(_d_e_f_a_u_l_t_)| │ │ │ │ +|_U_T_ _ _ _ _ _ _|_u_T_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_U_M_ _ _ _ _ _ _|_u_T_o_r_r_e_n_t_ _M_a_c_ _ _ _ _ _ _ _ | │ │ │ │ +|_q_B_ _ _ _ _ _ _|_q_B_i_t_t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ | │ │ │ │ +|_B_P_ _ _ _ _ _ _|_B_i_t_T_o_r_r_e_n_t_ _P_r_o_ _ _ _ _ _ | │ │ │ │ +|_B_T_ _ _ _ _ _ _|_B_i_t_T_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_D_E_ _ _ _ _ _ _|_D_e_l_u_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_A_Z_ _ _ _ _ _ _|_A_z_u_r_e_u_s_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_T_L_ _ _ _ _ _ _|_T_r_i_b_l_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +There's an informal directory of client id's _h_e_r_e. │ │ │ │ +The major, minor, revision and tag parameters are used to identify the version │ │ │ │ +of your client. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_._h_p_p" │ │ │ │ +peer_class_type_filter is a simple container for rules for adding and │ │ │ │ +subtracting peer-classes from peers. It is applied aafftteerr the peer class filter │ │ │ │ +is applied (which is based on the peer's IP address). │ │ │ │ +struct peer_class_type_filter │ │ │ │ +{ │ │ │ │ + void rreemmoovvee (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ + void aadddd (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ + void ddiissaallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ + void aallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ + std::uint32_t aappppllyy (socket_type_t const st, std::uint32_t peer_class_mask); │ │ │ │ + friend bool ooppeerraattoorr==== (peer_class_type_filter const& lhs │ │ │ │ + , peer_class_type_filter const& rhs); │ │ │ │ + │ │ │ │ + enum socket_type_t │ │ │ │ + { │ │ │ │ + tcp_socket, │ │ │ │ + utp_socket, │ │ │ │ + ssl_tcp_socket, │ │ │ │ + ssl_utp_socket, │ │ │ │ + i2p_socket, │ │ │ │ + rtc_socket, │ │ │ │ + num_socket_types, │ │ │ │ + }; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** rreemmoovvee(()) aadddd(()) ********** │ │ │ │ +void rreemmoovvee (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ +void aadddd (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ +add() and remove() adds and removes a peer class to be added to new peers based │ │ │ │ +on socket type. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ddiissaallllooww(()) aallllooww(()) ********** │ │ │ │ +void ddiissaallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ +void aallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ +disallow() and allow() adds and removes a peer class to be removed from new │ │ │ │ +peers based on socket type. │ │ │ │ +The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ │ +peer classes in the peer_class_type_filter are 32 bits. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** aappppllyy(()) ********** │ │ │ │ +std::uint32_t aappppllyy (socket_type_t const st, std::uint32_t peer_class_mask); │ │ │ │ +takes a bitmask of peer classes and returns a new bitmask of peer classes after │ │ │ │ +the rules have been applied, based on the socket type argument (st). │ │ │ │ +[_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_/_p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_._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___s_o_c_k_e_t_ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_t_p___s_o_c_k_e_t_ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_s_l___t_c_p___s_o_c_k_e_t_ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_s_l___u_t_p___s_o_c_k_e_t_ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_2_p___s_o_c_k_e_t_ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_t_c___s_o_c_k_e_t_ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_u_m___s_o_c_k_e_t___t_y_p_e_s_|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__ccllaassss__iinnffoo ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_l_a_s_s_._h_p_p" │ │ │ │ +holds settings for a peer class. Used in _s_e_t___p_e_e_r___c_l_a_s_s_(_) and _g_e_t___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ +calls. │ │ │ │ +struct peer_class_info │ │ │ │ +{ │ │ │ │ + bool ignore_unchoke_slots; │ │ │ │ + int connection_limit_factor; │ │ │ │ + std::string label; │ │ │ │ + int upload_limit; │ │ │ │ + int download_limit; │ │ │ │ + int upload_priority; │ │ │ │ + int download_priority; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + ignore_unchoke_slots │ │ │ │ + ignore_unchoke_slots determines whether peers should always unchoke a │ │ │ │ + peer, regardless of the choking algorithm, or if it should honor the │ │ │ │ + unchoke slot limits. It's used for local peers by default. If aannyy of the │ │ │ │ + peer classes a peer belongs to has this set to true, that peer will be │ │ │ │ + unchoked at all times. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + connection_limit_factor │ │ │ │ + adjusts the connection limit (global and per torrent) that applies to │ │ │ │ + this peer class. By default, local peers are allowed to exceed the normal │ │ │ │ + connection limit for instance. This is specified as a percent factor. 100 │ │ │ │ + makes the peer class apply normally to the limit. 200 means as long as │ │ │ │ + there are fewer connections than twice the limit, we accept this peer. │ │ │ │ + This factor applies both to the global connection limit and the per- │ │ │ │ + torrent limit. Note that if not used carefully one peer class can │ │ │ │ + potentially completely starve out all other over time. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + label │ │ │ │ + not used by libtorrent. It's intended as a potentially user-facing │ │ │ │ + identifier of this peer class. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + upload_limit download_limit │ │ │ │ + transfer rates limits for the whole peer class. They are specified in │ │ │ │ + bytes per second and apply to the sum of all peers that are members of │ │ │ │ + this class. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + upload_priority download_priority │ │ │ │ + relative priorities used by the bandwidth allocator in the rate limiter. │ │ │ │ + If no rate limits are in use, the priority is not used either. Priorities │ │ │ │ + start at 1 (0 is not a valid priority) and may not exceed 255. │ │ │ │ +The _p_o_p___a_l_e_r_t_s_(_) function on _s_e_s_s_i_o_n is the main interface for retrieving │ │ │ │ +alerts (warnings, messages and errors from libtorrent). If no alerts have been │ │ │ │ +posted by libtorrent _p_o_p___a_l_e_r_t_s_(_) will return an empty list. │ │ │ │ +By default, only errors are reported. _s_e_t_t_i_n_g_s___p_a_c_k_:_:_a_l_e_r_t___m_a_s_k can be used to │ │ │ │ +specify which kinds of events should be reported. The _a_l_e_r_t mask is a │ │ │ │ +combination of the _a_l_e_r_t___c_a_t_e_g_o_r_y___t flags in the _a_l_e_r_t class. │ │ │ │ +Every _a_l_e_r_t belongs to one or more category. There is a cost associated with │ │ │ │ +posting alerts. Only alerts that belong to an enabled category are posted. │ │ │ │ +Setting the _a_l_e_r_t bitmask to 0 will disable all alerts (except those that are │ │ │ │ +non-discardable). Alerts that are responses to API calls such as │ │ │ │ +_s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) and _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) are non-discardable and will be │ │ │ │ +posted even if their category is disabled. │ │ │ │ +There are other _a_l_e_r_t base classes that some alerts derive from, all the alerts │ │ │ │ +that are generated for a specific torrent are derived from _t_o_r_r_e_n_t___a_l_e_r_t, and │ │ │ │ +tracker events derive from _t_r_a_c_k_e_r___a_l_e_r_t. │ │ │ │ +Alerts returned by _p_o_p___a_l_e_r_t_s_(_) are only valid until the next call to │ │ │ │ +_p_o_p___a_l_e_r_t_s_(_). You may not copy an _a_l_e_r_t object to access it after the next call │ │ │ │ +to _p_o_p___a_l_e_r_t_s_(_). Internal members of alerts also become invalid once _p_o_p___a_l_e_r_t_s │ │ │ │ +_(_) is called again. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__rroouuttiinngg__bbuucckkeett ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +struct to hold information about a single DHT routing table bucket │ │ │ │ +struct dht_routing_bucket │ │ │ │ +{ │ │ │ │ + int nnuumm__nnooddeess = 0; │ │ │ │ + int nnuumm__rreeppllaacceemmeennttss = 0; │ │ │ │ + int llaasstt__aaccttiivvee = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + num_nodes num_replacements │ │ │ │ + the total number of nodes and replacement nodes in the routing table │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + last_active │ │ │ │ + number of seconds since last activity │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is a base class for alerts that are associated with a specific torrent. It │ │ │ │ +contains a handle to the torrent. │ │ │ │ +Note that by the time the client receives a _t_o_r_r_e_n_t___a_l_e_r_t, its handle member │ │ │ │ +may be invalid. │ │ │ │ +struct torrent_alert : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + torrent_handle handle; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** mmeessssaaggee(()) ********** │ │ │ │ +std::string mmeessssaaggee () const override; │ │ │ │ +returns the message associated with this _a_l_e_r_t │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + handle │ │ │ │ + The _t_o_r_r_e_n_t___h_a_n_d_l_e pointing to the torrent this _a_l_e_r_t is associated with. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +The peer _a_l_e_r_t is a base class for alerts that refer to a specific peer. It │ │ │ │ +includes all the information to identify the peer. i.e. ip and peer-id. │ │ │ │ +struct peer_alert : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + enum endpoint_type_t │ │ │ │ + { │ │ │ │ + ip_endpoint, │ │ │ │ + i2p_endpoint, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + peer_endpoint_t ep; │ │ │ │ + peer_id pid; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm eennddppooiinntt__ttyyppee__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_i_p___e_n_d_p_o_i_n_t_ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_2_p___e_n_d_p_o_i_n_t_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + ep │ │ │ │ + The peer's endpoint, either IP address and port or i2p destination hash. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + pid │ │ │ │ + the peer ID, if known. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrraacckkeerr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is a base class used for alerts that are associated with a specific │ │ │ │ +tracker. It derives from _t_o_r_r_e_n_t___a_l_e_r_t since a tracker is also associated with │ │ │ │ +a specific torrent. │ │ │ │ +struct tracker_alert : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ttrraacckkeerr__uurrll () const; │ │ │ │ + │ │ │ │ + aux::noexcept_movable<_t_c_p_:_:_e_n_d_p_o_i_n_t> local_endpoint; │ │ │ │ + protocol_version version; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ttrraacckkeerr__uurrll(()) ********** │ │ │ │ +char const* ttrraacckkeerr__uurrll () const; │ │ │ │ +returns a 0-terminated string of the tracker's URL │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + local_endpoint │ │ │ │ + endpoint of the listen interface being announced │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + version │ │ │ │ + the bittorrent protocol version that was announced │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__rreemmoovveedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +The torrent_removed_alert is posted whenever a torrent is removed. Since the │ │ │ │ +torrent handle in its base class will usually be invalid (since the torrent is │ │ │ │ +already removed) it has the info hash as a member, to identify it. It's posted │ │ │ │ +when the alert_category::status bit is set in the alert_mask. │ │ │ │ +Note that the handle remains valid for some time after _t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t is │ │ │ │ +posted, as long as some internal libtorrent task (such as an I/O task) refers │ │ │ │ +to it. Additionally, other alerts like _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t may be posted │ │ │ │ +after _t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t. To synchronize on whether the torrent has been │ │ │ │ +removed or not, call _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_i_n___s_e_s_s_i_o_n_(_). This will return true before │ │ │ │ +_t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t is posted, and false afterward. │ │ │ │ +Even though the handle member doesn't point to an existing torrent anymore, it │ │ │ │ +is still useful for comparing to other handles, which may also no longer point │ │ │ │ +to existing torrents, but to the same non-existing torrents. │ │ │ │ +The torrent_handle acts as a weak_ptr, even though its object no longer exists, │ │ │ │ +it can still compare equal to another weak pointer which points to the same │ │ │ │ +non-existent object. │ │ │ │ +struct torrent_removed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ + info_hash_t info_hashes; │ │ │ │ + client_data_t userdata; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + userdata │ │ │ │ + 'userdata`as set in _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s at torrent creation. This can be │ │ │ │ + used to associate this torrent with related data in the client │ │ │ │ + application more efficiently than info_hashes. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ rreeaadd__ppiieeccee__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when the asynchronous read operation initiated by a call │ │ │ │ +to _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_a_d___p_i_e_c_e_(_) is completed. If the read failed, the torrent │ │ │ │ +is paused and an error state is set and the buffer member of the _a_l_e_r_t is 0. If │ │ │ │ +successful, buffer points to a buffer containing all the data of the piece. │ │ │ │ +piece is the piece index that was read. size is the number of bytes that was │ │ │ │ +read. │ │ │ │ +If the operation fails, error will indicate what went wrong. │ │ │ │ +struct read_piece_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ + error_code const error; │ │ │ │ + boost::shared_array const buffer; │ │ │ │ + piece_index_t const piece; │ │ │ │ + int const size; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffiillee__ccoommpplleetteedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is posted whenever an individual file completes its download. i.e. All │ │ │ │ +pieces overlapping this file have passed their hash check. │ │ │ │ +struct file_completed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + file_index_t const index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + index │ │ │ │ + refers to the index of the file that completed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffiillee__rreennaammeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is posted as a response to a _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_n_a_m_e___f_i_l_e_(_) call, if the │ │ │ │ +rename operation succeeds. │ │ │ │ +struct file_renamed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* oolldd__nnaammee () const; │ │ │ │ + char const* nneeww__nnaammee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ + file_index_t const index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** oolldd__nnaammee(()) nneeww__nnaammee(()) ********** │ │ │ │ +char const* oolldd__nnaammee () const; │ │ │ │ +char const* nneeww__nnaammee () const; │ │ │ │ +returns the new and previous file name, respectively. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + index │ │ │ │ + refers to the index of the file that was renamed, │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffiillee__rreennaammee__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is posted as a response to a _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_n_a_m_e___f_i_l_e_(_) call, if the │ │ │ │ +rename operation failed. │ │ │ │ +struct file_rename_failed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ + file_index_t const index; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + index error │ │ │ │ + refers to the index of the file that was supposed to be renamed, error is │ │ │ │ + the error code returned from the filesystem. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeerrffoorrmmaannccee__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a limit is reached that might have a negative │ │ │ │ +impact on upload or download rate performance. │ │ │ │ +struct performance_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + enum performance_warning_t │ │ │ │ + { │ │ │ │ + outstanding_disk_buffer_limit_reached, │ │ │ │ + outstanding_request_limit_reached, │ │ │ │ + upload_limit_too_low, │ │ │ │ + download_limit_too_low, │ │ │ │ + send_buffer_watermark_too_low, │ │ │ │ + too_many_optimistic_unchoke_slots, │ │ │ │ + too_high_disk_queue_limit, │ │ │ │ + aio_limit_reached, │ │ │ │ + deprecated_bittyrant_with_no_uplimit, │ │ │ │ + too_few_outgoing_ports, │ │ │ │ + too_few_file_descriptors, │ │ │ │ + num_warnings, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +performance_warning; │ │ │ │ + performance_warning_t const warning_code; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm ppeerrffoorrmmaannccee__wwaarrnniinngg__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |This warning means that the | │ │ │ │ +| | |number of bytes queued to be | │ │ │ │ +| | |written to disk exceeds the max | │ │ │ │ +| | |disk byte queue setting | │ │ │ │ +| | |(settings_pack:: | │ │ │ │ +| | |max_queued_disk_bytes). This | │ │ │ │ +| | |might restrict the download rate,| │ │ │ │ +| | |by not queuing up enough write | │ │ │ │ +|outstanding_disk_buffer_limit_reached|0 |jobs to the disk I/O thread. When| │ │ │ │ +| | |this _a_l_e_r_t is posted, peer | │ │ │ │ +| | |connections are temporarily | │ │ │ │ +| | |stopped from downloading, until | │ │ │ │ +| | |the queued disk bytes have fallen| │ │ │ │ +| | |below the limit again. Unless | │ │ │ │ +| | |your max_queued_disk_bytes | │ │ │ │ +| | |setting is already high, you | │ │ │ │ +| | |might want to increase it to get | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_e_t_t_e_r_ _p_e_r_f_o_r_m_a_n_c_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |This is posted when libtorrent | │ │ │ │ +| | |would like to send more requests | │ │ │ │ +| | |to a peer, but it's limited by | │ │ │ │ +| | |settings_pack:: | │ │ │ │ +| | |max_out_request_queue. The queue | │ │ │ │ +| | |length libtorrent is trying to | │ │ │ │ +| | |achieve is determined by the | │ │ │ │ +| | |download rate and the assumed | │ │ │ │ +| | |round-trip-time (settings_pack:: | │ │ │ │ +| | |request_queue_time). The assumed | │ │ │ │ +| | |round-trip-time is not limited to| │ │ │ │ +| | |just the network RTT, but also | │ │ │ │ +|outstanding_request_limit_reached |1 |the remote disk access time and | │ │ │ │ +| | |message handling time. It | │ │ │ │ +| | |defaults to 3 seconds. The target| │ │ │ │ +| | |number of outstanding requests is| │ │ │ │ +| | |set to fill the bandwidth-delay | │ │ │ │ +| | |product (assumed RTT times | │ │ │ │ +| | |download rate divided by number | │ │ │ │ +| | |of bytes per request). When this | │ │ │ │ +| | |_a_l_e_r_t is posted, there is a risk | │ │ │ │ +| | |that the number of outstanding | │ │ │ │ +| | |requests is too low and limits | │ │ │ │ +| | |the download rate. You might want| │ │ │ │ +| | |to increase the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_x___o_u_t___r_e_q_u_e_s_t___q_u_e_u_e_ _s_e_t_t_i_n_g_._ _ _ | │ │ │ │ +| | |This warning is posted when the | │ │ │ │ +| | |amount of TCP/IP overhead is | │ │ │ │ +| | |greater than the upload rate | │ │ │ │ +| | |limit. When this happens, the | │ │ │ │ +| | |TCP/IP overhead is caused by a | │ │ │ │ +| | |much faster download rate, | │ │ │ │ +| | |triggering TCP ACK packets. These| │ │ │ │ +| | |packets eat into the rate limit | │ │ │ │ +| | |specified to libtorrent. When the| │ │ │ │ +| | |overhead traffic is greater than | │ │ │ │ +| | |the rate limit, libtorrent will | │ │ │ │ +|upload_limit_too_low |2 |not be able to send any actual | │ │ │ │ +| | |payload, such as piece requests. | │ │ │ │ +| | |This means the download rate will| │ │ │ │ +| | |suffer, and new requests can be | │ │ │ │ +| | |sent again. There will be an | │ │ │ │ +| | |equilibrium where the download | │ │ │ │ +| | |rate, on average, is about 20 | │ │ │ │ +| | |times the upload rate limit. If | │ │ │ │ +| | |you want to maximize the download| │ │ │ │ +| | |rate, increase the upload rate | │ │ │ │ +| | |limit above 5% of your download | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_p_a_c_i_t_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |This is the same warning as | │ │ │ │ +| | |upload_limit_too_low but | │ │ │ │ +| | |referring to the download limit | │ │ │ │ +| | |instead of upload. This suggests | │ │ │ │ +| | |that your download rate limit is | │ │ │ │ +|download_limit_too_low |3 |much lower than your upload | │ │ │ │ +| | |capacity. Your upload rate will | │ │ │ │ +| | |suffer. To maximize upload rate, | │ │ │ │ +| | |make sure your download rate | │ │ │ │ +| | |limit is above 5% of your upload | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_p_a_c_i_t_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |We're stalled on the disk. We | │ │ │ │ +| | |want to write to the socket, and | │ │ │ │ +| | |we can write but our send buffer | │ │ │ │ +| | |is empty, waiting to be refilled | │ │ │ │ +| | |from the disk. This either means | │ │ │ │ +| | |the disk is slower than the | │ │ │ │ +| | |network connection or that our | │ │ │ │ +| | |send buffer watermark is too | │ │ │ │ +| | |small, because we can send it all| │ │ │ │ +|send_buffer_watermark_too_low |4 |before the disk gets back to us. | │ │ │ │ +| | |The number of bytes that we keep | │ │ │ │ +| | |outstanding, requested from the | │ │ │ │ +| | |disk, is calculated as follows: | │ │ │ │ +| | |min(512, max(upload_rate * | │ │ │ │ +| | |send_buffer_watermark_factor / | │ │ │ │ +| | |100, send_buffer_watermark)) | │ │ │ │ +| | |If you receive this _a_l_e_r_t, you | │ │ │ │ +| | |might want to either increase | │ │ │ │ +| | |your send_buffer_watermark or | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_n_d___b_u_f_f_e_r___w_a_t_e_r_m_a_r_k___f_a_c_t_o_r_._ _ _ _ | │ │ │ │ +| | |If the half (or more) of all | │ │ │ │ +| | |upload slots are set as | │ │ │ │ +|too_many_optimistic_unchoke_slots |5 |optimistic unchoke slots, this | │ │ │ │ +| | |warning is issued. You probably | │ │ │ │ +| | |want more regular (rate based) | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_u_n_c_h_o_k_e_ _s_l_o_t_s_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |If the disk write queue ever | │ │ │ │ +| | |grows larger than half of the | │ │ │ │ +| | |cache size, this warning is | │ │ │ │ +| | |posted. The disk write queue eats| │ │ │ │ +| | |into the total disk cache and | │ │ │ │ +| | |leaves very little left for the | │ │ │ │ +|too_high_disk_queue_limit |6 |actual cache. This causes the | │ │ │ │ +| | |disk cache to oscillate in | │ │ │ │ +| | |evicting large portions of the | │ │ │ │ +| | |cache before allowing peers to | │ │ │ │ +| | |download any more, onto the disk | │ │ │ │ +| | |write queue. Either lower | │ │ │ │ +| | |max_queued_disk_bytes or increase| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_c_h_e___s_i_z_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_a_i_o___l_i_m_i_t___r_e_a_c_h_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___b_i_t_t_y_r_a_n_t___w_i_t_h___n_o___u_p_l_i_m_i_t_ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |This is generated if outgoing | │ │ │ │ +| | |peer connections are failing | │ │ │ │ +| | |because of aaddddrreessss iinn uussee errors,| │ │ │ │ +| | |indicating that settings_pack:: | │ │ │ │ +|too_few_outgoing_ports |9 |outgoing_ports is set and is too | │ │ │ │ +| | |small of a range. Consider not | │ │ │ │ +| | |using the outgoing_ports setting | │ │ │ │ +| | |at all, or widen the range to | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_c_l_u_d_e_ _m_o_r_e_ _p_o_r_t_s_._ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_o_o___f_e_w___f_i_l_e___d_e_s_c_r_i_p_t_o_r_s_ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_u_m___w_a_r_n_i_n_g_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttaattee__cchhaannggeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +Generated whenever a torrent changes its state. │ │ │ │ +struct state_changed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ + torrent_status::state_t const state; │ │ │ │ + torrent_status::state_t const prev_state; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + state │ │ │ │ + the new state of the torrent. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + prev_state │ │ │ │ + the previous state. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrraacckkeerr__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated on tracker time outs, premature disconnects, invalid │ │ │ │ +response or a HTTP response other than "200 OK". From the _a_l_e_r_t you can get the │ │ │ │ +handle to the torrent the tracker belongs to. │ │ │ │ +struct tracker_error_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ffaaiilluurree__rreeaassoonn () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +tracker | alert_category::error; │ │ │ │ + int const times_in_row; │ │ │ │ + error_code const error; │ │ │ │ + operation_t op; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffaaiilluurree__rreeaassoonn(()) ********** │ │ │ │ +char const* ffaaiilluurree__rreeaassoonn () const; │ │ │ │ +if the tracker sent a "failure reason" string, it will be returned here. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + times_in_row │ │ │ │ + This member says how many times in a row this tracker has failed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error code indicating why the tracker announce failed. If it is is │ │ │ │ + lt::errors::tracker_failure the _f_a_i_l_u_r_e___r_e_a_s_o_n_(_) might contain a more │ │ │ │ + detailed description of why the tracker rejected the request. HTTP status │ │ │ │ + codes indicating errors are also set in this field. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrraacckkeerr__wwaarrnniinngg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is triggered if the tracker reply contains a warning field. Usually │ │ │ │ +this means that the tracker announce was successful, but the tracker has a │ │ │ │ +message to the client. │ │ │ │ +struct tracker_warning_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* wwaarrnniinngg__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +tracker | alert_category::error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** wwaarrnniinngg__mmeessssaaggee(()) ********** │ │ │ │ +char const* wwaarrnniinngg__mmeessssaaggee () const; │ │ │ │ +the message associated with this warning │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssccrraappee__rreeppllyy__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a scrape request succeeds. │ │ │ │ +struct scrape_reply_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +tracker; │ │ │ │ + int const incomplete; │ │ │ │ + int const complete; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + incomplete complete │ │ │ │ + the data returned in the scrape response. These numbers may be -1 if the │ │ │ │ + response was malformed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssccrraappee__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +If a scrape request fails, this _a_l_e_r_t is generated. This might be due to the │ │ │ │ +tracker timing out, refusing connection or returning an http response code │ │ │ │ +indicating an error. │ │ │ │ +struct scrape_failed_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +tracker | alert_category::error; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eerrrroorr__mmeessssaaggee(()) ********** │ │ │ │ +char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ +if the error indicates there is an associated message, this returns that │ │ │ │ +message. Otherwise and empty string. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error itself. This may indicate that the tracker sent an error │ │ │ │ + message (error::tracker_failure), in which case it can be retrieved by │ │ │ │ + calling error_message(). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrraacckkeerr__rreeppllyy__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is only for informational purpose. It is generated when a tracker │ │ │ │ +announce succeeds. It is generated regardless what kind of tracker was used, be │ │ │ │ +it UDP, HTTP or the DHT. │ │ │ │ +struct tracker_reply_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +tracker; │ │ │ │ + int const num_peers; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + num_peers │ │ │ │ + tells how many peers the tracker returned in this response. This is not │ │ │ │ + expected to be greater than the num_want settings. These are not │ │ │ │ + necessarily all new peers, some of them may already be connected. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__rreeppllyy__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated each time the DHT receives peers from a node. num_peers │ │ │ │ +is the number of peers we received in this packet. Typically these packets are │ │ │ │ +received from multiple DHT nodes, and so the alerts are typically generated a │ │ │ │ +few at a time. │ │ │ │ +struct dht_reply_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht | alert_category::tracker; │ │ │ │ + int const num_peers; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrraacckkeerr__aannnnoouunnccee__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated each time a tracker announce is sent (or attempted to │ │ │ │ +be sent). There are no extra data members in this _a_l_e_r_t. The url can be found │ │ │ │ +in the base class however. │ │ │ │ +struct tracker_announce_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +tracker; │ │ │ │ + event_t const event; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + event │ │ │ │ + specifies what event was sent to the tracker. See _e_v_e_n_t___t. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ hhaasshh__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a finished piece fails its hash check. You can get │ │ │ │ +the handle to the torrent which got the failed piece and the index of the piece │ │ │ │ +itself from the _a_l_e_r_t. │ │ │ │ +struct hash_failed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__bbaann__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a peer is banned because it has sent too many │ │ │ │ +corrupt pieces to us. ip is the endpoint to the peer that was banned. │ │ │ │ +struct peer_ban_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__uunnssnnuubbbbeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a peer is un-snubbed. Essentially when it was │ │ │ │ +snubbed for stalling sending data, and now it started sending data again. │ │ │ │ +struct peer_unsnubbed_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__ssnnuubbbbeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a peer is snubbed, when it stops sending data when │ │ │ │ +we request it. │ │ │ │ +struct peer_snubbed_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a peer sends invalid data over the peer-peer │ │ │ │ +protocol. The peer will be disconnected, but you get its ip address from the │ │ │ │ +_a_l_e_r_t, to identify it. │ │ │ │ +struct peer_error_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ + operation_t op; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + op │ │ │ │ + a 0-terminated string of the low-level operation that failed, or nullptr │ │ │ │ + if there was no low level disk operation. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + tells you what error caused this _a_l_e_r_t. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__ccoonnnneecctt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted every time an incoming peer connection both successfully │ │ │ │ +passes the protocol handshake and is associated with a torrent, or an outgoing │ │ │ │ +peer connection attempt succeeds. For arbitrary incoming connections, see │ │ │ │ +_i_n_c_o_m_i_n_g___c_o_n_n_e_c_t_i_o_n___a_l_e_r_t. │ │ │ │ +struct peer_connect_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + enum direction_t │ │ │ │ + { │ │ │ │ + in, │ │ │ │ + out, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +connect; │ │ │ │ + direction_t direction; │ │ │ │ + socket_type_t socket_type; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm ddiirreeccttiioonn__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_i_n_ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_o_u_t_ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + direction │ │ │ │ + Tells you if the peer was incoming or outgoing │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__ddiissccoonnnneecctteedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a peer is disconnected for any reason (other than │ │ │ │ +the ones covered by _p_e_e_r___e_r_r_o_r___a_l_e_r_t ). │ │ │ │ +struct peer_disconnected_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +connect; │ │ │ │ + socket_type_t const socket_type; │ │ │ │ + operation_t const op; │ │ │ │ + error_code const error; │ │ │ │ + close_reason_t const reason; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + socket_type │ │ │ │ + the kind of socket this peer was connected over │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + op │ │ │ │ + the operation or level where the error occurred. Specified as an value │ │ │ │ + from the _o_p_e_r_a_t_i_o_n___t enum. Defined in operations.hpp. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + tells you what error caused peer to disconnect. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + reason │ │ │ │ + the reason the peer disconnected (if specified) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ iinnvvaalliidd__rreeqquueesstt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is a debug _a_l_e_r_t that is generated by an incoming invalid piece request. │ │ │ │ +ip is the address of the peer and the request is the actual incoming request │ │ │ │ +from the peer. See _p_e_e_r___r_e_q_u_e_s_t for more info. │ │ │ │ +struct invalid_request_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ + peer_request const request; │ │ │ │ + bool const we_have; │ │ │ │ + bool const peer_interested; │ │ │ │ + bool const withheld; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + request │ │ │ │ + the request we received from the peer │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + we_have │ │ │ │ + true if we have this piece │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + peer_interested │ │ │ │ + true if the peer indicated that it was interested to download before │ │ │ │ + sending the request │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + withheld │ │ │ │ + if this is true, the peer is not allowed to download this piece because │ │ │ │ + of super-seeding rules. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__ffiinniisshheedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a torrent switches from being a downloader to a │ │ │ │ +seed. It will only be generated once per torrent. It contains a _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ +to the torrent in question. │ │ │ │ +struct torrent_finished_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppiieeccee__ffiinniisshheedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is posted every time a piece completes downloading and passes the │ │ │ │ +hash check. This _a_l_e_r_t derives from _t_o_r_r_e_n_t___a_l_e_r_t which contains the │ │ │ │ +_t_o_r_r_e_n_t___h_a_n_d_l_e to the torrent the piece belongs to. Note that being downloaded │ │ │ │ +and passing the hash check may happen before the piece is also fully flushed to │ │ │ │ +disk. So _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_h_a_v_e___p_i_e_c_e_(_) may still return false │ │ │ │ +struct piece_finished_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + piece_index │ │ │ │ + the index of the piece that finished │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ rreeqquueesstt__ddrrooppppeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a peer rejects or ignores a piece request. │ │ │ │ +struct request_dropped_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + int const block_index; │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ bblloocckk__ttiimmeeoouutt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a block request times out. │ │ │ │ +struct block_timeout_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + int const block_index; │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ bblloocckk__ffiinniisshheedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a block request receives a response. │ │ │ │ +struct block_finished_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + int const block_index; │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ bblloocckk__ddoowwnnllooaaddiinngg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a block request is sent to a peer. │ │ │ │ +struct block_downloading_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + int const block_index; │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ uunnwwaanntteedd__bblloocckk__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a block is received that was not requested or │ │ │ │ +whose request timed out. │ │ │ │ +struct unwanted_block_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ + int const block_index; │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttoorraaggee__mmoovveedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +The storage_moved_alert is generated when all the disk IO has completed and the │ │ │ │ +files have been moved, as an effect of a call to torrent_handle::move_storage. │ │ │ │ +This is useful to synchronize with the actual disk. The storage_path() member │ │ │ │ +return the new path of the storage. │ │ │ │ +struct storage_moved_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ + char const* oolldd__ppaatthh () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ssttoorraaggee__ppaatthh(()) oolldd__ppaatthh(()) ********** │ │ │ │ +char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ +char const* oolldd__ppaatthh () const; │ │ │ │ +the path the torrent was moved to and from, respectively. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttoorraaggee__mmoovveedd__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +The storage_moved_failed_alert is generated when an attempt to move the │ │ │ │ +storage, via _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_m_o_v_e___s_t_o_r_a_g_e_(_), fails. │ │ │ │ +struct storage_moved_failed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ffiillee__ppaatthh () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ + error_code const error; │ │ │ │ + operation_t op; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffiillee__ppaatthh(()) ********** │ │ │ │ +char const* ffiillee__ppaatthh () const; │ │ │ │ +If the error happened for a specific file, this returns its path. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + op │ │ │ │ + this indicates what underlying operation caused the error │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__ddeelleetteedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a request to delete the files of a torrent │ │ │ │ +complete. │ │ │ │ +This _a_l_e_r_t is posted in the alert_category::storage category, and that bit │ │ │ │ +needs to be set in the alert_mask. │ │ │ │ +struct torrent_deleted_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ + info_hash_t info_hashes; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + info_hashes │ │ │ │ + The info-hash of the torrent that was just deleted. Most of the time the │ │ │ │ + _t_o_r_r_e_n_t___h_a_n_d_l_e in the torrent_alert will be invalid by the time this │ │ │ │ + _a_l_e_r_t arrives, since the torrent is being deleted. The info_hashes member │ │ │ │ + is hence the main way of identifying which torrent just completed the │ │ │ │ + delete. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__ddeelleettee__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a request to delete the files of a torrent fails. │ │ │ │ +Just removing a torrent from the _s_e_s_s_i_o_n cannot fail │ │ │ │ +struct torrent_delete_failed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage │ │ │ │ + | alert_category::error; │ │ │ │ + error_code const error; │ │ │ │ + info_hash_t info_hashes; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + tells you why it failed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + info_hashes │ │ │ │ + the info hash of the torrent whose files failed to be deleted │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssaavvee__rreessuummee__ddaattaa__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated as a response to a torrent_handle::save_resume_data │ │ │ │ +request. It is generated once the disk IO thread is done writing the state for │ │ │ │ +this torrent. │ │ │ │ +struct save_resume_data_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ + add_torrent_params params; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + params │ │ │ │ + the params object is populated with the torrent file whose resume data │ │ │ │ + was saved. It is suitable to be: │ │ │ │ + * added to a _s_e_s_s_i_o_n with _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 to disk with _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ + * turned into a magnet link with _m_a_k_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ + * saved as a .torrent file with _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssaavvee__rreessuummee__ddaattaa__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated instead of save_resume_data_alert if there was an error │ │ │ │ +generating the resume data. error describes what went wrong. │ │ │ │ +struct save_resume_data_failed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage │ │ │ │ + | alert_category::error; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error code from the resume_data failure │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__ppaauusseedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated as a response to a torrent_handle::pause request. It is │ │ │ │ +generated once all disk IO is complete and the files in the torrent have been │ │ │ │ +closed. This is useful for synchronizing with the disk. │ │ │ │ +struct torrent_paused_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__rreessuummeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated as a response to a _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_s_u_m_e_(_) request. It │ │ │ │ +is generated when a torrent goes from a paused state to an active state. │ │ │ │ +struct torrent_resumed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__cchheecckkeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when a torrent completes checking. i.e. when it │ │ │ │ +transitions out of the checking files state into a state where it is ready to │ │ │ │ +start downloading │ │ │ │ +struct torrent_checked_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ uurrll__sseeeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a HTTP seed name lookup fails. │ │ │ │ +struct url_seed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* sseerrvveerr__uurrll () const; │ │ │ │ + char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer | alert_category::error; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sseerrvveerr__uurrll(()) ********** │ │ │ │ +char const* sseerrvveerr__uurrll () const; │ │ │ │ +the URL the error is associated with │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eerrrroorr__mmeessssaaggee(()) ********** │ │ │ │ +char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ +in case the web server sent an error message, this function returns it. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error the web seed encountered. If this is not set, the server sent │ │ │ │ + an error message, call error_message(). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffiillee__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +If the storage fails to read or write files that it needs access to, this _a_l_e_r_t │ │ │ │ +is generated and the torrent is paused. │ │ │ │ +struct file_error_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ffiilleennaammee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status │ │ │ │ + | alert_category::storage; │ │ │ │ + error_code const error; │ │ │ │ + operation_t op; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffiilleennaammee(()) ********** │ │ │ │ +char const* ffiilleennaammee () const; │ │ │ │ +the file that experienced the error │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error code describing the error. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + op │ │ │ │ + indicates which underlying operation caused the error │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ mmeettaaddaattaa__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when the metadata has been completely received and the │ │ │ │ +info-hash failed to match it. i.e. the metadata that was received was corrupt. │ │ │ │ +libtorrent will automatically retry to fetch it in this case. This is only │ │ │ │ +relevant when running a torrent-less download, with the metadata extension │ │ │ │ +provided by libtorrent. │ │ │ │ +struct metadata_failed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + indicates what failed when parsing the metadata. This error is what's │ │ │ │ + returned from lazy_bdecode(). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ mmeettaaddaattaa__rreecceeiivveedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when the metadata has been completely received and the │ │ │ │ +torrent can start downloading. It is not generated on torrents that are started │ │ │ │ +with metadata, but only those that needs to download it from peers (via │ │ │ │ +ut_metadata). │ │ │ │ +There are no additional data members in this _a_l_e_r_t. │ │ │ │ +Typically, when receiving this _a_l_e_r_t, you would want to trigger saving its │ │ │ │ +resume data. You do that by calling _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) on the torrent handle, │ │ │ │ +like this: .. code:: c++ │ │ │ │ + torrent_handle h = alert->handle; h.save_resume_data(torrent_handle:: │ │ │ │ + save_info_dict); │ │ │ │ +In the handler for the save_resume_alert, you can save the resume data but also │ │ │ │ +a copy of torrent file: .. code:: c++ │ │ │ │ + save_resume_data_alert* alert = ...; std::vector buf = │ │ │ │ + write_resume_data_buf(alert->params); std::ofstream f("resume-data"); │ │ │ │ + f.write(buf.data(), buf.size()); │ │ │ │ +If writing a .torrent file that may be a v2 torrent and may not yet have │ │ │ │ +downloaded the piece layers from its peers, you need to specify the │ │ │ │ +allow_missing_piece_layer flag. │ │ │ │ +struct metadata_received_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ uuddpp__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when there is an error on a UDP socket. The UDP sockets │ │ │ │ +are used for all uTP, DHT and UDP tracker traffic. They are global to the │ │ │ │ +_s_e_s_s_i_o_n. │ │ │ │ +struct udp_error_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error; │ │ │ │ + aux::noexcept_movable endpoint; │ │ │ │ + operation_t operation; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + endpoint │ │ │ │ + the source address associated with the error (if any) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + operation │ │ │ │ + the operation that failed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error code describing the error │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ eexxtteerrnnaall__iipp__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +Whenever libtorrent learns about the machines external IP, this _a_l_e_r_t is │ │ │ │ +generated. The external IP address can be acquired from the tracker (if it │ │ │ │ +supports that) or from peers that supports the extension protocol. The address │ │ │ │ +can be accessed through the external_address member. │ │ │ │ +struct external_ip_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ + aux::noexcept_movable
      external_address; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + external_address │ │ │ │ + the IP address that is believed to be our external IP │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ lliisstteenn__ffaaiilleedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when none of the ports, given in the port range, to │ │ │ │ +_s_e_s_s_i_o_n can be opened for listening. The listen_interface member is the │ │ │ │ +interface that failed, error is the error code describing the failure. │ │ │ │ +In the case an endpoint was created before generating the _a_l_e_r_t, it is │ │ │ │ +represented by address and port. The combinations of socket type and operation │ │ │ │ +in which such address and port are not valid are: accept - i2p accept - socks5 │ │ │ │ +enum_if - tcp │ │ │ │ +libtorrent may sometimes try to listen on port 0, if all other ports failed. │ │ │ │ +Port 0 asks the operating system to pick a port that's free). If that fails you │ │ │ │ +may see a _l_i_s_t_e_n___f_a_i_l_e_d___a_l_e_r_t with port 0 even if you didn't ask to listen on │ │ │ │ +it. │ │ │ │ +struct listen_failed_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* lliisstteenn__iinntteerrffaaccee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status | alert_category::error; │ │ │ │ + error_code const error; │ │ │ │ + operation_t op; │ │ │ │ + lt::socket_type_t const socket_type; │ │ │ │ + aux::noexcept_movable address; │ │ │ │ + int const port; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** lliisstteenn__iinntteerrffaaccee(()) ********** │ │ │ │ +char const* lliisstteenn__iinntteerrffaaccee () const; │ │ │ │ +the network device libtorrent attempted to listen on, or the IP address │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error the system returned │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + op │ │ │ │ + the underlying operation that failed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + socket_type │ │ │ │ + the type of listen socket this _a_l_e_r_t refers to. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + address │ │ │ │ + the address libtorrent attempted to listen on see _a_l_e_r_t documentation for │ │ │ │ + validity of this value │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + port │ │ │ │ + the port libtorrent attempted to listen on see _a_l_e_r_t documentation for │ │ │ │ + validity of this value │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ lliisstteenn__ssuucccceeeeddeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when the listen port succeeds to be opened on a particular │ │ │ │ +interface. address and port is the endpoint that successfully was opened for │ │ │ │ +listening. │ │ │ │ +struct listen_succeeded_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ + aux::noexcept_movable address; │ │ │ │ + int const port; │ │ │ │ + lt::socket_type_t const socket_type; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + address │ │ │ │ + the address libtorrent ended up listening on. This address refers to the │ │ │ │ + local interface. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + port │ │ │ │ + the port libtorrent ended up listening on. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + socket_type │ │ │ │ + the type of listen socket this _a_l_e_r_t refers to. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppoorrttmmaapp__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a NAT router was successfully found but some part │ │ │ │ +of the port mapping request failed. It contains a text message that may help │ │ │ │ +the user figure out what is wrong. This _a_l_e_r_t is not generated in case it │ │ │ │ +appears the client is not running on a NAT:ed network or if it appears there is │ │ │ │ +no NAT router that can be remote controlled to add port mappings. │ │ │ │ +struct portmap_error_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +port_mapping │ │ │ │ + | alert_category::error; │ │ │ │ + port_mapping_t const mapping; │ │ │ │ + portmap_transport map_transport; │ │ │ │ + aux::noexcept_movable
      local_address; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + mapping │ │ │ │ + refers to the mapping index of the port map that failed, i.e. the index │ │ │ │ + returned from add_mapping(). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + map_transport │ │ │ │ + UPnP or NAT-PMP │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + local_address │ │ │ │ + the local network the port mapper is running on │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + tells you what failed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppoorrttmmaapp__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a NAT router was successfully found and a port was │ │ │ │ +successfully mapped on it. On a NAT:ed network with a NAT-PMP capable router, │ │ │ │ +this is typically generated once when mapping the TCP port and, if DHT is │ │ │ │ +enabled, when the UDP port is mapped. │ │ │ │ +struct portmap_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +port_mapping; │ │ │ │ + port_mapping_t const mapping; │ │ │ │ + int const external_port; │ │ │ │ + portmap_protocol const map_protocol; │ │ │ │ + portmap_transport const map_transport; │ │ │ │ + aux::noexcept_movable
      local_address; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + mapping │ │ │ │ + refers to the mapping index of the port map that failed, i.e. the index │ │ │ │ + returned from add_mapping(). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + external_port │ │ │ │ + the external port allocated for the mapping. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + local_address │ │ │ │ + the local network the port mapper is running on │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppoorrttmmaapp__lloogg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated to log informational events related to either UPnP or │ │ │ │ +NAT-PMP. They contain a log line and the type (0 = NAT-PMP and 1 = UPnP). │ │ │ │ +Displaying these messages to an end user is only useful for debugging the UPnP │ │ │ │ +or NAT-PMP implementation. This _a_l_e_r_t is only posted if the alert_category:: │ │ │ │ +port_mapping_log flag is enabled in the _a_l_e_r_t mask. │ │ │ │ +struct portmap_log_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* lloogg__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +port_mapping_log; │ │ │ │ + portmap_transport const map_transport; │ │ │ │ + aux::noexcept_movable
      local_address; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ +char const* lloogg__mmeessssaaggee () const; │ │ │ │ +the message associated with this log line │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + local_address │ │ │ │ + the local network the port mapper is running on │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffaassttrreessuummee__rreejjeecctteedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a fast resume file has been passed to _a_d_d___t_o_r_r_e_n_t │ │ │ │ +_(_) but the files on disk did not match the fast resume file. The error_code │ │ │ │ +explains the reason why the resume file was rejected. │ │ │ │ +struct fastresume_rejected_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ffiillee__ppaatthh () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status │ │ │ │ + | alert_category::error; │ │ │ │ + error_code error; │ │ │ │ + operation_t op; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffiillee__ppaatthh(()) ********** │ │ │ │ +char const* ffiillee__ppaatthh () const; │ │ │ │ +If the error happened to a specific file, this returns the path to it. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + op │ │ │ │ + the underlying operation that failed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__bblloocckkeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when an incoming peer connection, or a peer that's about │ │ │ │ +to be added to our peer list, is blocked for some reason. This could be any of: │ │ │ │ + * the IP filter │ │ │ │ + * i2p mixed mode restrictions (a normal peer is not allowed on an i2p │ │ │ │ + swarm) │ │ │ │ + * the port filter │ │ │ │ + * the peer has a low port and no_connect_privileged_ports is enabled │ │ │ │ + * the protocol of the peer is blocked (uTP/TCP blocking) │ │ │ │ +struct peer_blocked_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + enum reason_t │ │ │ │ + { │ │ │ │ + ip_filter, │ │ │ │ + port_filter, │ │ │ │ + i2p_mixed, │ │ │ │ + privileged_ports, │ │ │ │ + utp_disabled, │ │ │ │ + tcp_disabled, │ │ │ │ + invalid_local_interface, │ │ │ │ + ssrf_mitigation, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +ip_block; │ │ │ │ + int const reason; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm rreeaassoonn__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_i_p___f_i_l_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_o_r_t___f_i_l_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_2_p___m_i_x_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_r_i_v_i_l_e_g_e_d___p_o_r_t_s_ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_t_p___d_i_s_a_b_l_e_d_ _ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_c_p___d_i_s_a_b_l_e_d_ _ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___l_o_c_a_l___i_n_t_e_r_f_a_c_e_|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_s_r_f___m_i_t_i_g_a_t_i_o_n_ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + reason │ │ │ │ + the reason for the peer being blocked. Is one of the values from the │ │ │ │ + _r_e_a_s_o_n___t enum. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__aannnnoouunnccee__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a DHT node announces to an info-hash on our DHT │ │ │ │ +node. It belongs to the alert_category::dht category. │ │ │ │ +struct dht_announce_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + aux::noexcept_movable
      ip; │ │ │ │ + int port; │ │ │ │ + sha1_hash info_hash; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ggeett__ppeeeerrss__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when a DHT node sends a get_peers message to our DHT │ │ │ │ +node. It belongs to the alert_category::dht category. │ │ │ │ +struct dht_get_peers_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + sha1_hash info_hash; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ccaacchhee__fflluusshheedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when the disk cache has been flushed for a specific │ │ │ │ +torrent as a result of a call to _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_f_l_u_s_h___c_a_c_h_e_(_). This _a_l_e_r_t │ │ │ │ +belongs to the alert_category::storage category, which must be enabled to let │ │ │ │ +this _a_l_e_r_t through. The _a_l_e_r_t is also posted when removing a torrent from the │ │ │ │ +_s_e_s_s_i_o_n, once the outstanding cache flush is complete and the torrent does no │ │ │ │ +longer have any files open. │ │ │ │ +struct cache_flushed_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ llssdd__ppeeeerr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when we receive a local service discovery message from │ │ │ │ +a peer for a torrent we're currently participating in. │ │ │ │ +struct lsd_peer_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrraacckkeerriidd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted whenever a tracker responds with a trackerid. The tracker │ │ │ │ +ID is like a cookie. libtorrent will store the tracker ID for this tracker and │ │ │ │ +repeat it in subsequent announces. │ │ │ │ +struct trackerid_alert final : tracker_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ttrraacckkeerr__iidd () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ttrraacckkeerr__iidd(()) ********** │ │ │ │ +char const* ttrraacckkeerr__iidd () const; │ │ │ │ +The tracker ID returned by the tracker │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__bboooottssttrraapp__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when the initial DHT bootstrap is done. │ │ │ │ +struct dht_bootstrap_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is posted whenever a torrent is transitioned into the error state. If the │ │ │ │ +error code is duplicate_torrent (_e_r_r_o_r___c_o_d_e___e_n_u_m) error, it suggests two magnet │ │ │ │ +links ended up resolving to the same hybrid torrent. For more details, see │ │ │ │ +_B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. │ │ │ │ +struct torrent_error_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* ffiilleennaammee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error | alert_category::status; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ffiilleennaammee(()) ********** │ │ │ │ +char const* ffiilleennaammee () const; │ │ │ │ +the filename (or object) the error occurred on. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + specifies which error the torrent encountered. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__nneeeedd__cceerrtt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is always posted for SSL torrents. This is a reminder to the client that │ │ │ │ +the torrent won't work unless _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e_(_) is called │ │ │ │ +with a valid certificate. Valid certificates MUST be signed by the SSL │ │ │ │ +certificate in the .torrent file. │ │ │ │ +struct torrent_need_cert_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ iinnccoommiinngg__ccoonnnneeccttiioonn__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +The incoming connection _a_l_e_r_t is posted every time we successfully accept an │ │ │ │ +incoming connection, through any mean. The most straight-forward ways of │ │ │ │ +accepting incoming connections are through the TCP listen socket and the UDP │ │ │ │ +listen socket for uTP sockets. However, connections may also be accepted │ │ │ │ +through a Socks5 or i2p listen socket, or via an SSL listen socket. │ │ │ │ +struct incoming_connection_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer; │ │ │ │ + socket_type_t socket_type; │ │ │ │ + aux::noexcept_movable<_t_c_p_:_:_e_n_d_p_o_i_n_t> endpoint; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + socket_type │ │ │ │ + tells you what kind of socket the connection was accepted │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + endpoint │ │ │ │ + is the IP address and port the connection came from. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ aadddd__ttoorrrreenntt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is always posted when a torrent was attempted to be added and │ │ │ │ +contains the return status of the add operation. The torrent handle of the new │ │ │ │ +torrent can be found as the handle member in the base class. If adding the │ │ │ │ +torrent failed, error contains the error code. │ │ │ │ +struct add_torrent_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ + add_torrent_params params; │ │ │ │ + error_code error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + params │ │ │ │ + This contains copies of the most important fields from the original │ │ │ │ + _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object, passed to _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 │ │ │ │ + _(_). Specifically, these fields are copied: │ │ │ │ + * version │ │ │ │ + * ti │ │ │ │ + * name │ │ │ │ + * save_path │ │ │ │ + * userdata │ │ │ │ + * tracker_id │ │ │ │ + * flags │ │ │ │ + * info_hash │ │ │ │ + the info_hash field will be updated with the info-hash of the torrent │ │ │ │ + specified by ti. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + set to the error, if one occurred while adding the torrent. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttaattee__uuppddaattee__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is only posted when requested by the user, by calling session:: │ │ │ │ +post_torrent_updates() on the _s_e_s_s_i_o_n. It contains the torrent status of all │ │ │ │ +torrents that changed since last time this message was posted. Its category is │ │ │ │ +alert_category::status, but it's not subject to filtering, since it's only │ │ │ │ +manually posted anyway. │ │ │ │ +struct state_update_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +status; │ │ │ │ + std::vector status; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + status │ │ │ │ + contains the torrent status of all torrents that changed since last time │ │ │ │ + this message was posted. Note that you can map a torrent status to a │ │ │ │ + specific torrent via its handle member. The receiving end is suggested to │ │ │ │ + have all torrents sorted by the _t_o_r_r_e_n_t___h_a_n_d_l_e or hashed by it, for │ │ │ │ + efficient updates. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ sseessssiioonn__ssttaattss__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +The _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t is posted when the user requests _s_e_s_s_i_o_n statistics by │ │ │ │ +calling _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) on the _s_e_s_s_i_o_n object. This _a_l_e_r_t does not have a │ │ │ │ +category, since it's only posted in response to an API call. It is not subject │ │ │ │ +to the alert_mask filter. │ │ │ │ +the message() member function returns a string representation of the values │ │ │ │ +that properly match the line returned in session_stats_header_alert::message(). │ │ │ │ +this specific output is parsed by tools/parse_session_stats.py if this is │ │ │ │ +changed, that parser should also be changed │ │ │ │ +struct session_stats_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + span ccoouunntteerrss () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = {}; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ccoouunntteerrss(()) ********** │ │ │ │ +span ccoouunntteerrss () const; │ │ │ │ +An array are a mix of ccoouunntteerrss and ggaauuggeess, which meanings can be queries via │ │ │ │ +the _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_) function on the _s_e_s_s_i_o_n. The mapping from a │ │ │ │ +specific metric to an index into this array is constant for a specific version │ │ │ │ +of libtorrent, but may differ for other versions. The intended usage is to │ │ │ │ +request the mapping, i.e. call _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_), once on startup, and │ │ │ │ +then use that mapping to interpret these values throughout the process' │ │ │ │ +runtime. │ │ │ │ +For more information, see the _s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when something fails in the DHT. This is not necessarily a fatal error, │ │ │ │ +but it could prevent proper operation │ │ │ │ +struct dht_error_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error | alert_category::dht; │ │ │ │ + error_code error; │ │ │ │ + operation_t op; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error code │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + op │ │ │ │ + the operation that failed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__iimmmmuuttaabbllee__iitteemm__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is posted as a response to a call to session::get_item(), │ │ │ │ +specifically the overload for looking up immutable items in the DHT. │ │ │ │ +struct dht_immutable_item_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + sha1_hash target; │ │ │ │ + entry item; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + target │ │ │ │ + the target hash of the immutable item. This must match the SHA-1 hash of │ │ │ │ + the bencoded form of item. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + item │ │ │ │ + the data for this item │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__mmuuttaabbllee__iitteemm__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is posted as a response to a call to session::get_item(), │ │ │ │ +specifically the overload for looking up mutable items in the DHT. │ │ │ │ +struct dht_mutable_item_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + std::array key; │ │ │ │ + std::array signature; │ │ │ │ + std::int64_t seq; │ │ │ │ + std::string salt; │ │ │ │ + entry item; │ │ │ │ + bool authoritative; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + key │ │ │ │ + the public key that was looked up │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + signature │ │ │ │ + the signature of the data. This is not the signature of the plain encoded │ │ │ │ + form of the item, but it includes the sequence number and possibly the │ │ │ │ + hash as well. See the dht_store document for more information. This is │ │ │ │ + primarily useful for echoing back in a store request. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + seq │ │ │ │ + the sequence number of this item │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + salt │ │ │ │ + the salt, if any, used to lookup and store this item. If no salt was │ │ │ │ + used, this is an empty string │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + item │ │ │ │ + the data for this item │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + authoritative │ │ │ │ + the last response for mutable data is authoritative. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ppuutt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this is posted when a DHT put operation completes. This is useful if the client │ │ │ │ +is waiting for a put to complete before shutting down for instance. │ │ │ │ +struct dht_put_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + sha1_hash target; │ │ │ │ + std::array public_key; │ │ │ │ + std::array signature; │ │ │ │ + std::string salt; │ │ │ │ + std::int64_t seq; │ │ │ │ + int num_success; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + target │ │ │ │ + the target hash the item was stored under if this was an iimmmmuuttaabbllee item. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + public_key signature salt seq │ │ │ │ + if a mutable item was stored, these are the public key, signature, salt │ │ │ │ + and sequence number the item was stored under. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + num_success │ │ │ │ + DHT put operation usually writes item to k nodes, maybe the node is stale │ │ │ │ + so no response, or the node doesn't support 'put', or the token for write │ │ │ │ + is out of date, etc. num_success is the number of successful responses we │ │ │ │ + got from the puts. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ii22pp__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is used to report errors in the i2p SAM connection │ │ │ │ +struct i2p_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error; │ │ │ │ + error_code error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + the error that occurred in the i2p SAM connection │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__oouuttggooiinngg__ggeett__ppeeeerrss__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is generated when we send a get_peers request It belongs to the │ │ │ │ +alert_category::dht category. │ │ │ │ +struct dht_outgoing_get_peers_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + sha1_hash info_hash; │ │ │ │ + sha1_hash obfuscated_info_hash; │ │ │ │ + aux::noexcept_movable endpoint; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + info_hash │ │ │ │ + the info_hash of the torrent we're looking for peers for. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + obfuscated_info_hash │ │ │ │ + if this was an obfuscated lookup, this is the info-hash target actually │ │ │ │ + sent to the node. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + endpoint │ │ │ │ + the endpoint we're sending this query to │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ lloogg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted by some _s_e_s_s_i_o_n wide event. Its main purpose is trouble │ │ │ │ +shooting and debugging. It's not enabled by the default _a_l_e_r_t mask and is │ │ │ │ +enabled by the alert_category::session_log bit. Furthermore, it's by default │ │ │ │ +disabled as a build configuration. │ │ │ │ +struct log_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* lloogg__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +session_log; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ +char const* lloogg__mmeessssaaggee () const; │ │ │ │ +returns the log message │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__lloogg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted by torrent wide events. It's meant to be used for trouble │ │ │ │ +shooting and debugging. It's not enabled by the default _a_l_e_r_t mask and is │ │ │ │ +enabled by the alert_category::torrent_log bit. By default it is disabled as a │ │ │ │ +build configuration. │ │ │ │ +struct torrent_log_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* lloogg__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +torrent_log; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ +char const* lloogg__mmeessssaaggee () const; │ │ │ │ +returns the log message │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__lloogg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted by events specific to a peer. It's meant to be used for │ │ │ │ +trouble shooting and debugging. It's not enabled by the default _a_l_e_r_t mask and │ │ │ │ +is enabled by the alert_category::peer_log bit. By default it is disabled as a │ │ │ │ +build configuration. │ │ │ │ +struct peer_log_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* lloogg__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + enum direction_t │ │ │ │ + { │ │ │ │ + incoming_message, │ │ │ │ + outgoing_message, │ │ │ │ + incoming, │ │ │ │ + outgoing, │ │ │ │ + info, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +peer_log; │ │ │ │ + event_t event_type; │ │ │ │ + direction_t direction; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ +char const* lloogg__mmeessssaaggee () const; │ │ │ │ +returns the log message │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm ddiirreeccttiioonn__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_i_n_c_o_m_i_n_g___m_e_s_s_a_g_e_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_o_u_t_g_o_i_n_g___m_e_s_s_a_g_e_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_c_o_m_i_n_g_ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_o_u_t_g_o_i_n_g_ _ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_f_o_ _ _ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + event_type │ │ │ │ + enum indicating the kind of event. For messages, this is the message │ │ │ │ + name. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ llssdd__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted if the local service discovery socket fails to start properly. it's │ │ │ │ +categorized as alert_category::error. │ │ │ │ +struct lsd_error_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error; │ │ │ │ + aux::noexcept_movable
      local_address; │ │ │ │ + error_code error; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + local_address │ │ │ │ + the local network the corresponding local service discovery is running on │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + error │ │ │ │ + The error code │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__llooookkuupp ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +holds statistics about a current _d_h_t___l_o_o_k_u_p operation. a DHT lookup is the │ │ │ │ +traversal of nodes, looking up a set of target nodes in the DHT for retrieving │ │ │ │ +and possibly storing information in the DHT │ │ │ │ +struct dht_lookup │ │ │ │ +{ │ │ │ │ + char const* type; │ │ │ │ + int outstanding_requests; │ │ │ │ + int timeouts; │ │ │ │ + int responses; │ │ │ │ + int branch_factor; │ │ │ │ + int nodes_left; │ │ │ │ + int last_sent; │ │ │ │ + int first_timeout; │ │ │ │ + sha1_hash target; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + type │ │ │ │ + string literal indicating which kind of lookup this is │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + outstanding_requests │ │ │ │ + the number of outstanding request to individual nodes this lookup has │ │ │ │ + right now │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + timeouts │ │ │ │ + the total number of requests that have timed out so far for this lookup │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + responses │ │ │ │ + the total number of responses we have received for this lookup so far for │ │ │ │ + this lookup │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + branch_factor │ │ │ │ + the branch factor for this lookup. This is the number of nodes we keep │ │ │ │ + outstanding requests to in parallel by default. when nodes time out we │ │ │ │ + may increase this. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + nodes_left │ │ │ │ + the number of nodes left that could be queries for this lookup. Many of │ │ │ │ + these are likely to be part of the trail while performing the lookup and │ │ │ │ + would never end up actually being queried. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + last_sent │ │ │ │ + the number of seconds ago the last message was sent that's still │ │ │ │ + outstanding │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + first_timeout │ │ │ │ + the number of outstanding requests that have exceeded the short timeout │ │ │ │ + and are considered timed out in the sense that they increased the branch │ │ │ │ + factor │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + target │ │ │ │ + the node-id or info-hash target for this lookup │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ssttaattss__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +contains current DHT state. Posted in response to session::post_dht_stats(). │ │ │ │ +struct dht_stats_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = {}; │ │ │ │ + std::vector active_requests; │ │ │ │ + std::vector routing_table; │ │ │ │ + sha1_hash nid; │ │ │ │ + aux::noexcept_movable local_endpoint; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + active_requests │ │ │ │ + a vector of the currently running DHT lookups. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + routing_table │ │ │ │ + contains information about every bucket in the DHT routing table. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + nid │ │ │ │ + the node ID of the DHT node instance │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + local_endpoint │ │ │ │ + the local socket this DHT node is running on │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ iinnccoommiinngg__rreeqquueesstt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted every time an incoming request from a peer is accepted and queued up for │ │ │ │ +being serviced. This _a_l_e_r_t is only posted if the alert_category:: │ │ │ │ +incoming_request flag is enabled in the _a_l_e_r_t mask. │ │ │ │ +struct incoming_request_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +incoming_request; │ │ │ │ + peer_request req; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + req │ │ │ │ + the request this peer sent to us │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__lloogg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +debug logging of the DHT when alert_category::dht_log is set in the _a_l_e_r_t mask. │ │ │ │ +struct dht_log_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + char const* lloogg__mmeessssaaggee () const; │ │ │ │ + │ │ │ │ + enum dht_module_t │ │ │ │ + { │ │ │ │ + tracker, │ │ │ │ + node, │ │ │ │ + routing_table, │ │ │ │ + rpc_manager, │ │ │ │ + traversal, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht_log; │ │ │ │ + dht_module_t module; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ +char const* lloogg__mmeessssaaggee () const; │ │ │ │ +the log message │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm ddhhtt__mmoodduullee__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_t_r_a_c_k_e_r_ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o_d_e_ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_o_u_t_i_n_g___t_a_b_l_e_|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_p_c___m_a_n_a_g_e_r_ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_r_a_v_e_r_s_a_l_ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + module │ │ │ │ + the module, or part, of the DHT that produced this log message. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ppkktt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted every time a DHT message is sent or received. It is only │ │ │ │ +posted if the alert_category::dht_log _a_l_e_r_t category is enabled. It contains a │ │ │ │ +verbatim copy of the message. │ │ │ │ +struct dht_pkt_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + span ppkktt__bbuuff () const; │ │ │ │ + │ │ │ │ + enum direction_t │ │ │ │ + { │ │ │ │ + incoming, │ │ │ │ + outgoing, │ │ │ │ + }; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht_log; │ │ │ │ + direction_t direction; │ │ │ │ + aux::noexcept_movable node; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ppkktt__bbuuff(()) ********** │ │ │ │ +span ppkktt__bbuuff () const; │ │ │ │ +returns a pointer to the packet buffer and size of the packet, respectively. │ │ │ │ +This buffer is only valid for as long as the _a_l_e_r_t itself is valid, which is │ │ │ │ +owned by libtorrent and reclaimed whenever _p_o_p___a_l_e_r_t_s_(_) is called on the │ │ │ │ +_s_e_s_s_i_o_n. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** eennuumm ddiirreeccttiioonn__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_i_n_c_o_m_i_n_g_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_o_u_t_g_o_i_n_g_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + direction │ │ │ │ + whether this is an incoming or outgoing packet. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + node │ │ │ │ + the DHT node we received this packet from, or sent this packet to │ │ │ │ + (depending on direction). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ggeett__ppeeeerrss__rreeppllyy__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +Posted when we receive a response to a DHT get_peers request. │ │ │ │ +struct dht_get_peers_reply_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + int nnuumm__ppeeeerrss () const; │ │ │ │ + std::vector<_t_c_p_:_:_e_n_d_p_o_i_n_t> ppeeeerrss () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht_operation; │ │ │ │ + sha1_hash info_hash; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ddiirreecctt__rreessppoonnssee__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This is posted exactly once for every call to session_handle:: │ │ │ │ +dht_direct_request. If the request failed, _r_e_s_p_o_n_s_e_(_) will return a default │ │ │ │ +constructed _b_d_e_c_o_d_e___n_o_d_e. │ │ │ │ +struct dht_direct_response_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + bdecode_node rreessppoonnssee () const; │ │ │ │ │ │ │ │ - static inline constexpr file_flags_t ffllaagg__ppaadd__ffiillee = 0_bit; │ │ │ │ - static inline constexpr file_flags_t ffllaagg__hhiiddddeenn = 1_bit; │ │ │ │ - static inline constexpr file_flags_t ffllaagg__eexxeeccuuttaabbllee = 2_bit; │ │ │ │ - static inline constexpr file_flags_t ffllaagg__ssyymmlliinnkk = 3_bit; │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + client_data_t userdata; │ │ │ │ + aux::noexcept_movable endpoint; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iiss__vvaalliidd(()) ********** │ │ │ │ -bool iiss__vvaalliidd () const; │ │ │ │ -returns true if the piece length has been initialized on the _f_i_l_e___s_t_o_r_a_g_e. This │ │ │ │ -is typically taken as a proxy of whether the _f_i_l_e___s_t_o_r_a_g_e as a whole is │ │ │ │ -initialized or not. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseerrvvee(()) ********** │ │ │ │ -void rreesseerrvvee (int num_files); │ │ │ │ -allocates space for num_files in the internal file list. This can be used to │ │ │ │ -avoid reallocating the internal file list when the number of files to be added │ │ │ │ -is known up-front. │ │ │ │ +************ ppiicckkeerr__lloogg__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this is posted when one or more blocks are picked by the piece picker, assuming │ │ │ │ +the verbose piece picker logging is enabled (see alert_category::picker_log). │ │ │ │ +struct picker_log_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + std::vector bblloocckkss () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +picker_log; │ │ │ │ + static inline constexpr picker_flags_t ppaarrttiiaall__rraattiioo = 0_bit; │ │ │ │ + static inline constexpr picker_flags_t pprriioorriittiizzee__ppaarrttiiaallss = 1_bit; │ │ │ │ + static inline constexpr picker_flags_t rraarreesstt__ffiirrsstt__ppaarrttiiaallss = 2_bit; │ │ │ │ + static inline constexpr picker_flags_t rraarreesstt__ffiirrsstt = 3_bit; │ │ │ │ + static inline constexpr picker_flags_t rreevveerrssee__rraarreesstt__ffiirrsstt = 4_bit; │ │ │ │ + static inline constexpr picker_flags_t ssuuggggeesstteedd__ppiieecceess = 5_bit; │ │ │ │ + static inline constexpr picker_flags_t pprriioo__sseeqquueennttiiaall__ppiieecceess = 6_bit; │ │ │ │ + static inline constexpr picker_flags_t sseeqquueennttiiaall__ppiieecceess = 7_bit; │ │ │ │ + static inline constexpr picker_flags_t rreevveerrssee__ppiieecceess = 8_bit; │ │ │ │ + static inline constexpr picker_flags_t ttiimmee__ccrriittiiccaall = 9_bit; │ │ │ │ + static inline constexpr picker_flags_t rraannddoomm__ppiieecceess = 10_bit; │ │ │ │ + static inline constexpr picker_flags_t pprreeffeerr__ccoonnttiigguuoouuss = 11_bit; │ │ │ │ + static inline constexpr picker_flags_t rreevveerrssee__sseeqquueennttiiaall = 12_bit; │ │ │ │ + static inline constexpr picker_flags_t bbaacckkuupp11 = 13_bit; │ │ │ │ + static inline constexpr picker_flags_t bbaacckkuupp22 = 14_bit; │ │ │ │ + static inline constexpr picker_flags_t eenndd__ggaammee = 15_bit; │ │ │ │ + static inline constexpr picker_flags_t eexxtteenntt__aaffffiinniittyy = 16_bit; │ │ │ │ + picker_flags_t picker_flags; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ffiillee__bboorrrrooww(()) aadddd__ffiillee(()) ********** │ │ │ │ -void aadddd__ffiillee__bboorrrrooww (string_view filename │ │ │ │ - , std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ - , string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ -void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ -Adds a file to the file storage. The add_file_borrow version expects that │ │ │ │ -filename is the file name (without a path) of the file that's being added. This │ │ │ │ -memory is bboorrrroowweedd, i.e. it is the caller's responsibility to make sure it │ │ │ │ -stays valid throughout the lifetime of this _f_i_l_e___s_t_o_r_a_g_e object or any copy of │ │ │ │ -it. The same thing applies to filehash, which is an optional pointer to a 20 │ │ │ │ -byte binary SHA-1 hash of the file. │ │ │ │ -if filename is empty, the filename from path is used and not borrowed. │ │ │ │ -The path argument is the full path (in the torrent file) to the file to add. │ │ │ │ -Note that this is not supposed to be an absolute path, but it is expected to │ │ │ │ -include the name of the torrent as the first path element. │ │ │ │ -file_size is the size of the file in bytes. │ │ │ │ -The file_flags argument sets attributes on the file. The file attributes is an │ │ │ │ -extension and may not work in all bittorrent clients. │ │ │ │ -For possible file attributes, see file_storage::flags_t. │ │ │ │ -The mtime argument is optional and can be set to 0. If non-zero, it is the │ │ │ │ -posix time of the last modification time of this file. │ │ │ │ -symlink_path is the path the file is a symlink to. To make this a symlink you │ │ │ │ -also need to set the _f_i_l_e___s_t_o_r_a_g_e_:_:_f_l_a_g___s_y_m_l_i_n_k file flag. │ │ │ │ -root_hash is an optional pointer to a 32 byte SHA-256 hash, being the merkle │ │ │ │ -tree root hash for this file. This is only used for v2 torrents. If the root │ │ │ │ -hash is specified for one file, it has to be specified for all, otherwise this │ │ │ │ -function will fail. Note that the buffer root_hash points to must out-live the │ │ │ │ -_f_i_l_e___s_t_o_r_a_g_e object, it will not be copied. This parameter is only used when │ │ │ │ -llooaaddiinngg torrents, that already have their file hashes computed. When creating │ │ │ │ -torrents, the file hashes will be computed by the piece hashes. │ │ │ │ -If more files than one are added, certain restrictions to their paths apply. In │ │ │ │ -a multi-file file storage (torrent), all files must share the same root │ │ │ │ -directory. │ │ │ │ -That is, the first path element of all files must be the same. This shared path │ │ │ │ -element is also set to the name of the torrent. It can be changed by calling │ │ │ │ -set_name. │ │ │ │ -The overloads that take anerror_codereference will report failures via that │ │ │ │ -variable, otherwisesystem_erroris thrown. │ │ │ │ + picker_flags │ │ │ │ + this is a bitmask of which features were enabled for this particular │ │ │ │ + pick. The bits are defined in the picker_flags_t enum. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ffiillee__bboorrrrooww(()) aadddd__ffiillee(()) ********** │ │ │ │ -void aadddd__ffiillee__bboorrrrooww (error_code& ec, string_view filename │ │ │ │ - , std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ - , string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ -void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ -these overloads report failures through the ec reference rather than throwing. │ │ │ │ -add_file_borrow() does not copy the filename string; it is borrowed by │ │ │ │ -reference and the caller must keep it alive for the lifetime of this │ │ │ │ -file_storage object. This is useful when constructing the file list from a │ │ │ │ -memory-mapped .torrent file. │ │ │ │ +************ sseessssiioonn__eerrrroorr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is posted when the _s_e_s_s_i_o_n encounters a serious error, potentially │ │ │ │ +fatal │ │ │ │ +struct session_error_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error; │ │ │ │ + error_code const error; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmaapp__bblloocckk(()) ********** │ │ │ │ -std::vector mmaapp__bblloocckk (piece_index_t piece, std::int64_t offset │ │ │ │ - , std::int64_t size) const; │ │ │ │ -returns a list of _f_i_l_e___s_l_i_c_e objects representing the portions of files the │ │ │ │ -specified piece index, byte offset and size range overlaps. this is the inverse │ │ │ │ -mapping of _m_a_p___f_i_l_e_(_). │ │ │ │ -Preconditions of this function is that the input range is within the torrents │ │ │ │ -address space. piece may not be negative and │ │ │ │ - piece * piece_size + offset + size │ │ │ │ -may not exceed the total size of the torrent. │ │ │ │ + error │ │ │ │ + The error code, if one is associated with this error │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmaapp__ffiillee(()) ********** │ │ │ │ -peer_request mmaapp__ffiillee (file_index_t file, std::int64_t offset, int size) const; │ │ │ │ -returns a _p_e_e_r___r_e_q_u_e_s_t representing the piece index, byte offset and size the │ │ │ │ -specified file range overlaps. This is the inverse mapping over _m_a_p___b_l_o_c_k_(_). │ │ │ │ -Note that the peer_request return type is meant to hold bittorrent block │ │ │ │ -requests, which may not be larger than 16 kiB. Mapping a range larger than that │ │ │ │ -may return an overflown integer. │ │ │ │ +************ ddhhtt__lliivvee__nnooddeess__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted in response to a call to session::dht_live_nodes(). It contains the live │ │ │ │ +nodes from the DHT routing table of one of the DHT nodes running locally. │ │ │ │ +struct dht_live_nodes_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + int nnuumm__nnooddeess () const; │ │ │ │ + std::vector> nnooddeess () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht; │ │ │ │ + sha1_hash node_id; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ffiilleess(()) ********** │ │ │ │ -int nnuumm__ffiilleess () const noexcept; │ │ │ │ -returns the number of files in the _f_i_l_e___s_t_o_r_a_g_e │ │ │ │ +********** nnooddeess(()) nnuumm__nnooddeess(()) ********** │ │ │ │ +int nnuumm__nnooddeess () const; │ │ │ │ +std::vector> nnooddeess () const; │ │ │ │ +the number of nodes in the routing table and the actual nodes. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eenndd__ffiillee(()) ********** │ │ │ │ -file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ -returns the index of the one-past-end file in the file storage │ │ │ │ + node_id │ │ │ │ + the local DHT node's node-ID this routing table belongs to │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__rraannggee(()) ********** │ │ │ │ -index_range ffiillee__rraannggee () const noexcept; │ │ │ │ -returns an implementation-defined type that can be used as the container in a │ │ │ │ -range-for loop. Where the values are the indices of all files in the │ │ │ │ -_f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ +************ sseessssiioonn__ssttaattss__hheeaaddeerr__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +The session_stats_header _a_l_e_r_t is posted the first time _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) is │ │ │ │ +called │ │ │ │ +the message() member function returns a string representation of the header │ │ │ │ +that properly match the stats values string returned in session_stats_alert:: │ │ │ │ +message(). │ │ │ │ +this specific output is parsed by tools/parse_session_stats.py if this is │ │ │ │ +changed, that parser should also be changed │ │ │ │ +struct session_stats_header_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = {}; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttoottaall__ssiizzee(()) ********** │ │ │ │ -std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ -returns the total number of bytes all the files in this torrent spans including │ │ │ │ -pad files │ │ │ │ +************ ddhhtt__ssaammppllee__iinnffoohhaasshheess__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted as a response to a call to session::dht_sample_infohashes() with the │ │ │ │ +information from the DHT response message. │ │ │ │ +struct dht_sample_infohashes_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + std::vector ssaammpplleess () const; │ │ │ │ + int nnuumm__ssaammpplleess () const; │ │ │ │ + int nnuumm__nnooddeess () const; │ │ │ │ + std::vector> nnooddeess () const; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +dht_operation; │ │ │ │ + sha1_hash node_id; │ │ │ │ + aux::noexcept_movable endpoint; │ │ │ │ + time_duration const interval; │ │ │ │ + int const num_infohashes; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssiizzee__oonn__ddiisskk(()) ********** │ │ │ │ -std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ -returns the sum of all non pad file sizes │ │ │ │ +********** nnuumm__ssaammpplleess(()) ssaammpplleess(()) ********** │ │ │ │ +std::vector ssaammpplleess () const; │ │ │ │ +int nnuumm__ssaammpplleess () const; │ │ │ │ +returns the number of info-hashes returned by the node, as well as the actual │ │ │ │ +info-hashes. num_samples() is more efficient than samples().size(). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__nnuumm__ppiieecceess(()) nnuumm__ppiieecceess(()) ********** │ │ │ │ -void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ -int nnuumm__ppiieecceess () const; │ │ │ │ -set and get the number of pieces in the torrent │ │ │ │ +********** nnuumm__nnooddeess(()) ********** │ │ │ │ +int nnuumm__nnooddeess () const; │ │ │ │ +The total number of nodes returned by nodes(). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eenndd__ppiieeccee(()) ********** │ │ │ │ -piece_index_t eenndd__ppiieeccee () const; │ │ │ │ -returns the index of the one-past-end piece in the file storage │ │ │ │ +********** nnooddeess(()) ********** │ │ │ │ +std::vector> nnooddeess () const; │ │ │ │ +This is the set of more DHT nodes returned by the request. │ │ │ │ +The information is included so that indexing nodes can perform a key space │ │ │ │ +traversal with a single RPC per node by adjusting the target value for each │ │ │ │ +RPC. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** llaasstt__ppiieeccee(()) ********** │ │ │ │ -piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ -returns the index of the last piece in the torrent. The last piece is special │ │ │ │ -in that it may be smaller than the other pieces (and the other pieces are all │ │ │ │ -the same size). │ │ │ │ + node_id │ │ │ │ + id of the node the request was sent to (and this response was received │ │ │ │ + from) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__rraannggee(()) ********** │ │ │ │ -index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ -returns an implementation-defined type that can be used as the container in a │ │ │ │ -range-for loop. Where the values are the indices of all pieces in the │ │ │ │ -_f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ + endpoint │ │ │ │ + the node the request was sent to (and this response was received from) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ppiieeccee__lleennggtthh(()) ppiieeccee__lleennggtthh(()) ********** │ │ │ │ -int ppiieeccee__lleennggtthh () const; │ │ │ │ -void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ -set and get the size of each piece in this torrent. It must be a power of two │ │ │ │ -and at least 16 kiB. │ │ │ │ + interval │ │ │ │ + the interval to wait before making another request to this node │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__ssiizzee(()) ********** │ │ │ │ -int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ -returns the piece size of index. This will be the same as _p_i_e_c_e___l_e_n_g_t_h_(_), │ │ │ │ -except for the last piece, which may be shorter. │ │ │ │ + num_infohashes │ │ │ │ + This field indicates how many info-hash keys are currently in the node's │ │ │ │ + storage. If the value is larger than the number of returned samples it │ │ │ │ + indicates that the indexer may obtain additional samples after waiting │ │ │ │ + out the interval. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__ssiizzee22(()) ********** │ │ │ │ -int ppiieeccee__ssiizzee22 (piece_index_t index) const; │ │ │ │ -Returns the size of the given piece. If the piece spans multiple files, only │ │ │ │ -the first file is considered part of the piece. This is used for v2 torrents, │ │ │ │ -where all files are piece aligned and padded. i.e. The pad files are not │ │ │ │ -considered part of the piece for this purpose. │ │ │ │ +************ bblloocckk__uuppllooaaddeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +This _a_l_e_r_t is posted when a block intended to be sent to a peer is placed in │ │ │ │ +the send buffer. Note that if the connection is closed before the send buffer │ │ │ │ +is sent, the _a_l_e_r_t may be posted without the bytes having been sent to the │ │ │ │ +peer. It belongs to the alert_category::upload category. │ │ │ │ +struct block_uploaded_alert final : peer_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + int const block_index; │ │ │ │ + piece_index_t const piece_index; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bblloocckkss__iinn__ppiieeccee22(()) ********** │ │ │ │ -int bblloocckkss__iinn__ppiieeccee22 (piece_index_t index) const; │ │ │ │ -returns the number of blocks in the specified piece, for v2 torrents. │ │ │ │ +************ aalleerrttss__ddrrooppppeedd__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is posted to indicate to the client that some alerts were dropped. │ │ │ │ +Dropped meaning that the _a_l_e_r_t failed to be delivered to the client. The most │ │ │ │ +common cause of such failure is that the internal _a_l_e_r_t queue grew too big │ │ │ │ +(controlled by alert_queue_size). │ │ │ │ +struct alerts_dropped_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + ssttaattiicc__aasssseerrtt (num_alert_types <= abi_alert_count, "need to increase bitset. │ │ │ │ +This is an ABI break"); │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error; │ │ │ │ + std::bitset dropped_alerts; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bblloocckkss__ppeerr__ppiieeccee(()) ********** │ │ │ │ -int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ -returns the number of blocks there are in the typical piece. There may be fewer │ │ │ │ -in the last piece) │ │ │ │ + dropped_alerts │ │ │ │ + a bitmask indicating which alerts were dropped. Each bit represents the │ │ │ │ + _a_l_e_r_t type ID, where bit 0 represents whether any _a_l_e_r_t of type 0 has │ │ │ │ + been dropped, and so on. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__nnaammee(()) nnaammee(()) ********** │ │ │ │ -void sseett__nnaammee (std::string const& n); │ │ │ │ -std::string const& nnaammee () const; │ │ │ │ -set and get the name of this torrent. For multi-file torrents, this is also the │ │ │ │ -name of the root directory all the files are stored in. │ │ │ │ +************ ssoocckkss55__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is posted with SOCKS5 related errors, when a SOCKS5 proxy is │ │ │ │ +configured. It's enabled with the alert_category::error _a_l_e_r_t category. │ │ │ │ +struct socks5_alert final : alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +error; │ │ │ │ + error_code error; │ │ │ │ + operation_t op; │ │ │ │ + aux::noexcept_movable<_t_c_p_:_:_e_n_d_p_o_i_n_t> ip; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sswwaapp(()) ********** │ │ │ │ -void sswwaapp (file_storage& ti) noexcept; │ │ │ │ -swap all content of tthhiiss with ttii. │ │ │ │ + error │ │ │ │ + the error │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppaadd__ffiillee__aatt(()) rroooott(()) ffiillee__ooffffsseett(()) ffiillee__ppaatthh(()) rroooott__ppttrr(()) ffiillee__nnaammee(()) │ │ │ │ -mmttiimmee(()) ssyymmlliinnkk(()) ffiillee__ssiizzee(()) ********** │ │ │ │ -bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ -string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ -char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ -std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = "") │ │ │ │ -const; │ │ │ │ -std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ -std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ -sha256_hash rroooott (file_index_t index) const; │ │ │ │ -std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ -std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ -These functions are used to query attributes of files at a given index. │ │ │ │ -root() returns the SHA-256 merkle tree root of the specified file, in case this │ │ │ │ -is a v2 torrent. Otherwise returns zeros. root_ptr() returns a pointer to the │ │ │ │ -SHA-256 merkle tree root hash for the specified file. The pointer points into │ │ │ │ -storage referred to when the file was added, it is not owned by this object. │ │ │ │ -Torrents that are not v2 torrents return nullptr. │ │ │ │ -The mtime() is the modification time is the posix time when a file was last │ │ │ │ -modified when the torrent was created, or 0 if it was not included in the │ │ │ │ -torrent file. │ │ │ │ -file_path() returns the full path to a file. │ │ │ │ -file_size() returns the size of a file. │ │ │ │ -pad_file_at() returns true if the file at the given index is a pad-file. │ │ │ │ -file_name() returns jjuusstt the name of the file, whereas file_path() returns the │ │ │ │ -path (inside the torrent file) with the filename appended. │ │ │ │ -symlink() returns the path the file at index is a symlink to. If the file is │ │ │ │ -not a symlink, the returned string is empty. │ │ │ │ -file_offset() returns the byte offset within the torrent file where this file │ │ │ │ -starts. It can be used to map the file to a piece index (given the piece size). │ │ │ │ + op │ │ │ │ + the operation that failed │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppiieeccee__rraannggee(()) ffiillee__nnuumm__ppiieecceess(()) ffiillee__nnuumm__bblloocckkss(()) ********** │ │ │ │ -int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ -index_range ffiillee__ppiieeccee__rraannggee (file_index_t) const; │ │ │ │ -int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ -Returns the number of pieces or blocks the file atindexspans, under the │ │ │ │ -assumption that the file is aligned to the start of a piece. This is only │ │ │ │ -meaningful for v2 torrents, where files are guaranteed such alignment. These │ │ │ │ -numbers are used to size and navigate the merkle hash tree for each file. │ │ │ │ + ip │ │ │ │ + the endpoint configured as the proxy │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ffiirrsstt__ppiieeccee__nnooddee(()) ffiillee__ffiirrsstt__bblloocckk__nnooddee(()) ********** │ │ │ │ -int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ -int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ -index of first piece node in the merkle tree │ │ │ │ +************ ffiillee__pprriioo__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when a _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_) or _f_i_l_e___p_r_i_o_r_i_t_y_(_) update of the file │ │ │ │ +priorities complete, which requires a round-trip to the disk thread. │ │ │ │ +If the disk operation fails this _a_l_e_r_t won't be posted, but a _f_i_l_e___e_r_r_o_r___a_l_e_r_t │ │ │ │ +is posted instead, and the torrent is stopped. │ │ │ │ +struct file_prio_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ + error_code error; │ │ │ │ + operation_t op; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppaatthh__hhaasshh(()) ********** │ │ │ │ -std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& save_path) │ │ │ │ -const; │ │ │ │ -returns the crc32 hash of file_path(index) │ │ │ │ + error │ │ │ │ + the error │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aallll__ppaatthh__hhaasshheess(()) ********** │ │ │ │ -void aallll__ppaatthh__hhaasshheess (std::unordered_set& table) const; │ │ │ │ -this will add the CRC32 hash of all directory entries to the table. No filename │ │ │ │ -will be included, just directories. Every depth of directories are added │ │ │ │ -separately to allow test for collisions with files at all levels. i.e. if one │ │ │ │ -path in the torrent is foo/bar/baz, the CRC32 hashes for foo, foo/bar and foo/ │ │ │ │ -bar/baz will be added to the set. │ │ │ │ + op │ │ │ │ + the operation that failed │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ffllaaggss(()) ********** │ │ │ │ -file_flags_t ffiillee__ffllaaggss (file_index_t index) const; │ │ │ │ -returns a bitmask of flags from file_flags_t that apply to file at index. │ │ │ │ +************ oovveerrssiizzeedd__ffiillee__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t may be posted when the initial checking of resume data and files on │ │ │ │ +disk (just existence, not piece hashes) completes. If a file belonging to the │ │ │ │ +torrent is found on disk, but is larger than the file in the torrent, that's │ │ │ │ +when this _a_l_e_r_t is posted. the client may want to call _t_r_u_n_c_a_t_e___f_i_l_e_s_(_) in that │ │ │ │ +case, or perhaps interpret it as a sign that some other file is in the way, │ │ │ │ +that shouldn't be overwritten. │ │ │ │ +struct oversized_file_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +storage; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ -bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t index) const; │ │ │ │ -returns true if the file at the specified index has been renamed to have an │ │ │ │ -absolute path, i.e. is not anchored in the save path of the torrent. │ │ │ │ +************ ttoorrrreenntt__ccoonnfflliicctt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +this _a_l_e_r_t is posted when two separate torrents (magnet links) resolve to the │ │ │ │ +same torrent, thus causing the same torrent being added twice. In that case, │ │ │ │ +both torrents enter an error state with duplicate_torrent as the error code. │ │ │ │ +This _a_l_e_r_t is posted containing the metadata. For more information, see │ │ │ │ +_B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. The torrent this _a_l_e_r_t originated from was the one that │ │ │ │ +downloaded the metadata (i.e. thehandlemember from the _t_o_r_r_e_n_t___a_l_e_r_t base │ │ │ │ +class). │ │ │ │ +struct torrent_conflict_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::error; │ │ │ │ + torrent_handle conflicting_torrent; │ │ │ │ + std::shared_ptr metadata; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee(()) ffiillee__iinnddeexx__aatt__ooffffsseett(()) ffiillee__iinnddeexx__aatt__ppiieeccee(()) │ │ │ │ -********** │ │ │ │ -file_index_t ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ -file_index_t llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ -file_index_t ffiillee__iinnddeexx__aatt__ooffffsseett (std::int64_t offset) const; │ │ │ │ -returns the index of the file at the given offset or piece in the torrent │ │ │ │ + conflicting_torrent │ │ │ │ + the handle to the torrent in conflict. The swarm associated with this │ │ │ │ + torrent handle did not download the metadata, but the downloaded metadata │ │ │ │ + collided with this swarm's info-hash. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__iinnddeexx__ffoorr__rroooott(()) ********** │ │ │ │ -file_index_t ffiillee__iinnddeexx__ffoorr__rroooott (sha256_hash const& root_hash) const; │ │ │ │ -finds the file with the given root hash and returns its index if there is no │ │ │ │ -file with the root hash, file_index_t{-1} is returned │ │ │ │ + metadata │ │ │ │ + the metadata that was received by one of the torrents in conflict. One │ │ │ │ + way to resolve the conflict is to remove both failing torrents and re-add │ │ │ │ + it using this metadata │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__iinnddeexx__aatt__ffiillee(()) llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee(()) ********** │ │ │ │ -piece_index_t llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ -piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ -returns the first or last piece index of the given file in the torrent │ │ │ │ +************ ppeeeerr__iinnffoo__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___p_e_e_r___i_n_f_o_(_) is called │ │ │ │ +struct peer_info_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ + std::vector peer_info; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssaanniittiizzee__ssyymmlliinnkkss(()) ********** │ │ │ │ -void ssaanniittiizzee__ssyymmlliinnkkss (); │ │ │ │ -validate any symlinks, to ensure they all point to other files or directories │ │ │ │ -inside this storage. Any invalid symlinks are updated to point to themselves. │ │ │ │ + peer_info │ │ │ │ + the list of the currently connected peers │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** vv22(()) ********** │ │ │ │ -bool vv22 () const; │ │ │ │ -returns true if this torrent contains v2 metadata. │ │ │ │ +************ ffiillee__pprrooggrreessss__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___f_i_l_e___p_r_o_g_r_e_s_s_(_) is called │ │ │ │ +struct file_progress_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +file_progress; │ │ │ │ + aux::vector files; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flag_pad_file │ │ │ │ - the file is a pad file. It's required to contain zeros at it will not be │ │ │ │ - saved to disk. Its purpose is to make the following file start on a piece │ │ │ │ - boundary. │ │ │ │ + files │ │ │ │ + the list of the files in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flag_hidden │ │ │ │ - this file has the hidden attribute set. This is primarily a windows │ │ │ │ - attribute │ │ │ │ +************ ppiieeccee__iinnffoo__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_) is called │ │ │ │ +struct piece_info_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ +piece_progress; │ │ │ │ + std::vector piece_info; │ │ │ │ + std::vector block_data; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flag_executable │ │ │ │ - this file has the executable attribute set. │ │ │ │ + piece_info │ │ │ │ + info about pieces being downloaded for the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flag_symlink │ │ │ │ - this file is a symbolic link. It should have a link target string │ │ │ │ - associated with it. │ │ │ │ + block_data │ │ │ │ + storage for _b_l_o_c_k___i_n_f_o pointers in _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o objects │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ rreennaammeedd__ffiilleess ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ -this is a wrapper around _f_i_l_e___s_t_o_r_a_g_e for renaming files without having to │ │ │ │ -mutate the _f_i_l_e___s_t_o_r_a_g_e object itself. │ │ │ │ -struct renamed_files │ │ │ │ +************ ppiieeccee__aavvaaiillaabbiilliittyy__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_) is called │ │ │ │ +struct piece_availability_alert final : torrent_alert │ │ │ │ { │ │ │ │ - std::string ffiillee__ppaatthh (file_storage const& fs, file_index_t index, std:: │ │ │ │ -string const& save_path = "") const; │ │ │ │ - bool ffiillee__aabbssoolluuttee__ppaatthh (file_storage const& fs, file_index_t index) const; │ │ │ │ - string_view ffiillee__nnaammee (file_storage const& fs, file_index_t index) const; │ │ │ │ - void rreennaammee__ffiillee (file_storage const& fs, file_index_t index, std::string │ │ │ │ -const& new_filename); │ │ │ │ - void iimmppoorrtt__ffiilleennaammeess (file_storage const& fs, std::map const& renamed_files); │ │ │ │ - std::map eexxppoorrtt__ffiilleennaammeess (file_storage const& │ │ │ │ -fs) const; │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ + std::vector piece_availability; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppaatthh(()) ffiillee__nnaammee(()) ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ -std::string ffiillee__ppaatthh (file_storage const& fs, file_index_t index, std::string │ │ │ │ -const& save_path = "") const; │ │ │ │ -bool ffiillee__aabbssoolluuttee__ppaatthh (file_storage const& fs, file_index_t index) const; │ │ │ │ -string_view ffiillee__nnaammee (file_storage const& fs, file_index_t index) const; │ │ │ │ -returns information about the file at index in fs, honoring any rename recorded │ │ │ │ -in this object. file_path() returns the full on-disk path (prepending save_path │ │ │ │ -to relative paths). file_name() returns just the leaf filename. │ │ │ │ -file_absolute_path() returns true if the recorded rename is an absolute path │ │ │ │ -(in which case save_path is ignored). │ │ │ │ + piece_availability │ │ │ │ + info about pieces being downloaded for the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreennaammee__ffiillee(()) ********** │ │ │ │ -void rreennaammee__ffiillee (file_storage const& fs, file_index_t index, std::string │ │ │ │ -const& new_filename); │ │ │ │ -records that the file at index in fs should be renamed to new_filename on disk. │ │ │ │ -The underlying file_storage is not modified. │ │ │ │ +************ ttrraacckkeerr__lliisstt__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___t_r_a_c_k_e_r_s_(_) is called │ │ │ │ +struct tracker_list_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ + std::vector trackers; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eexxppoorrtt__ffiilleennaammeess(()) iimmppoorrtt__ffiilleennaammeess(()) ********** │ │ │ │ -void iimmppoorrtt__ffiilleennaammeess (file_storage const& fs, std::map const& renamed_files); │ │ │ │ -std::map eexxppoorrtt__ffiilleennaammeess (file_storage const& fs) │ │ │ │ -const; │ │ │ │ -bulk import or export the set of file renames recorded in this object. │ │ │ │ -import_filenames() adds the given renames (dropping entries whose file index is │ │ │ │ -out of range). export_filenames() returns the current renames as a map suitable │ │ │ │ -for serializing and later passing back to import_filenames(). │ │ │ │ + trackers │ │ │ │ + list of trackers and their status for the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiilleennaammeess ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ -a lightweight view that pairs a file_storage with the rename overrides in a │ │ │ │ -renamed_files. It exposes the read-only subset of file_storage that downstream │ │ │ │ -code (e.g. the disk I/O backends) needs, with file paths automatically resolved │ │ │ │ -through the rename layer. │ │ │ │ -struct filenames │ │ │ │ +************ ffiillee__pprriioorriittiieess__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_) is called │ │ │ │ +struct file_priorities_alert final : torrent_alert │ │ │ │ { │ │ │ │ - ffiilleennaammeess (file_storage const& fs, renamed_files const& rf); │ │ │ │ - file_flags_t ffiillee__ffllaaggss (file_index_t const index) const; │ │ │ │ - file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ - bool ppaadd__ffiillee__aatt (file_index_t const index) const; │ │ │ │ - std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ - std::int64_t ffiillee__ooffffsseett (file_index_t const index) const; │ │ │ │ - bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ - std::string ffiillee__ppaatthh (file_index_t const index, std::string const& │ │ │ │ -save_path = "") const; │ │ │ │ - std::string ssyymmlliinnkk (file_index_t const index) const; │ │ │ │ - index_range ffiillee__rraannggee () const noexcept; │ │ │ │ - int nnuumm__ppiieecceess () const; │ │ │ │ - piece_index_t eenndd__ppiieeccee () const; │ │ │ │ - int nnuumm__ffiilleess () const noexcept; │ │ │ │ - std::vector mmaapp__bblloocckk (piece_index_t const piece, std::int64_t │ │ │ │ -const offset │ │ │ │ - , std::int64_t const size) const; │ │ │ │ - peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t const offset, │ │ │ │ -int const size) const; │ │ │ │ - sha256_hash rroooott (file_index_t const index) const; │ │ │ │ - int ppiieeccee__lleennggtthh () const; │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ + std::vector priorities; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiilleennaammeess(()) ********** │ │ │ │ -ffiilleennaammeess (file_storage const& fs, renamed_files const& rf); │ │ │ │ -construct a view over fs with the renames recorded in rf applied. Both │ │ │ │ -references must outlive the view. │ │ │ │ + priorities │ │ │ │ + the download priority of each file in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ffllaaggss(()) ********** │ │ │ │ -file_flags_t ffiillee__ffllaaggss (file_index_t const index) const; │ │ │ │ -returns the file flags for the file at index │ │ │ │ +************ ffiillee__ssttaattuuss__aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ +posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___f_i_l_e___s_t_a_t_u_s_(_) is called │ │ │ │ +struct file_status_alert final : torrent_alert │ │ │ │ +{ │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ + │ │ │ │ + static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ + std::vector state; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eenndd__ffiillee(()) ********** │ │ │ │ -file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ -one past-the-end file index │ │ │ │ + state │ │ │ │ + the open-file state of each currently open file in the torrent. Files │ │ │ │ + that are not open are not included. Each entry's file_index field │ │ │ │ + identifies which file it refers to. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppaadd__ffiillee__aatt(()) ********** │ │ │ │ -bool ppaadd__ffiillee__aatt (file_index_t const index) const; │ │ │ │ -returns true if the file at index is a pad file │ │ │ │ +************ aalleerrtt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t_._h_p_p" │ │ │ │ +The alert class is the base class that specific messages are derived from. │ │ │ │ +_a_l_e_r_t types are not copyable, and cannot be constructed by the client. The │ │ │ │ +pointers returned by libtorrent are short lived (the details are described │ │ │ │ +under _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_p_o_p___a_l_e_r_t_s_(_)) │ │ │ │ +struct alert │ │ │ │ +{ │ │ │ │ + time_point ttiimmeessttaammpp () const; │ │ │ │ + virtual int ttyyppee () const noexcept = 0; │ │ │ │ + virtual char const* wwhhaatt () const noexcept = 0; │ │ │ │ + virtual std::string mmeessssaaggee () const = 0; │ │ │ │ + virtual alert_category_t ccaatteeggoorryy () const noexcept = 0; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ssiizzee(()) ffiillee__ooffffsseett(()) ********** │ │ │ │ -std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ -std::int64_t ffiillee__ooffffsseett (file_index_t const index) const; │ │ │ │ -returns the file size or file offset for the file at index. The file offset is │ │ │ │ -in the torrent space, of all files in the torrent, in the order they are │ │ │ │ -defined. │ │ │ │ +********** ttiimmeessttaammpp(()) ********** │ │ │ │ +time_point ttiimmeessttaammpp () const; │ │ │ │ +a timestamp is automatically created in the constructor │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppaatthh(()) ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ -bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ -std::string ffiillee__ppaatthh (file_index_t const index, std::string const& save_path = │ │ │ │ -"") const; │ │ │ │ -returns the on-disk path for the file at index, applying any rename recorded in │ │ │ │ -the underlying renamed_files. If save_path is non-empty it is prepended to │ │ │ │ -relative paths. file_absolute_path() returns true if the recorded rename is an │ │ │ │ -absolute path (in which case save_path is ignored). │ │ │ │ +********** ttyyppee(()) ********** │ │ │ │ +virtual int ttyyppee () const noexcept = 0; │ │ │ │ +returns an integer that is unique to this _a_l_e_r_t type. It can be compared │ │ │ │ +against a specific _a_l_e_r_t by querying a static constant called alert_type in the │ │ │ │ +_a_l_e_r_t. It can be used to determine the run-time type of an alert* in order to │ │ │ │ +cast to that _a_l_e_r_t type and access specific members. │ │ │ │ +e.g: │ │ │ │ +std::vector alerts; │ │ │ │ +ses.pop_alerts(&alerts); │ │ │ │ +for (alert* a : alerts) { │ │ │ │ + switch (a->type()) { │ │ │ │ + │ │ │ │ + case read_piece_alert::alert_type: │ │ │ │ + { │ │ │ │ + auto* p = static_cast(a); │ │ │ │ + if (p->ec) { │ │ │ │ + // read_piece failed │ │ │ │ + break; │ │ │ │ + } │ │ │ │ + // use p │ │ │ │ + break; │ │ │ │ + } │ │ │ │ + case file_renamed_alert::alert_type: │ │ │ │ + { │ │ │ │ + // etc... │ │ │ │ + } │ │ │ │ + } │ │ │ │ +} │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssyymmlliinnkk(()) ********** │ │ │ │ -std::string ssyymmlliinnkk (file_index_t const index) const; │ │ │ │ -If the file at index is a symbolic link, its link target is returned. otherwise │ │ │ │ -an empty string. │ │ │ │ +********** wwhhaatt(()) ********** │ │ │ │ +virtual char const* wwhhaatt () const noexcept = 0; │ │ │ │ +returns a string literal describing the type of the _a_l_e_r_t. It does not include │ │ │ │ +any information that might be bundled with the _a_l_e_r_t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__rraannggee(()) ********** │ │ │ │ -index_range ffiillee__rraannggee () const noexcept; │ │ │ │ -all file indices in the underlying _f_i_l_e___s_t_o_r_a_g_e. Convenient in range-for loops. │ │ │ │ +********** mmeessssaaggee(()) ********** │ │ │ │ +virtual std::string mmeessssaaggee () const = 0; │ │ │ │ +generate a string describing the _a_l_e_r_t and the information bundled with it. │ │ │ │ +This is mainly intended for debug and development use. It is not suitable to │ │ │ │ +use this for applications that may be localized. Instead, handle each _a_l_e_r_t │ │ │ │ +type individually and extract and render the information from the _a_l_e_r_t │ │ │ │ +depending on the locale. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ffiilleess(()) eenndd__ppiieeccee(()) nnuumm__ppiieecceess(()) ********** │ │ │ │ -int nnuumm__ppiieecceess () const; │ │ │ │ -piece_index_t eenndd__ppiieeccee () const; │ │ │ │ -int nnuumm__ffiilleess () const noexcept; │ │ │ │ -the number of files in the underlying _f_i_l_e___s_t_o_r_a_g_e, the number of pieces, and │ │ │ │ -the one-past-the-end piece index. │ │ │ │ +********** ccaatteeggoorryy(()) ********** │ │ │ │ +virtual alert_category_t ccaatteeggoorryy () const noexcept = 0; │ │ │ │ +returns a bitmask specifying which categories this _a_l_e_r_t belong to. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmaapp__bblloocckk(()) ********** │ │ │ │ -std::vector mmaapp__bblloocckk (piece_index_t const piece, std::int64_t │ │ │ │ -const offset │ │ │ │ - , std::int64_t const size) const; │ │ │ │ -returns the list of file slices that make up the piece at piece, starting at │ │ │ │ -offset into the piece and covering size bytes. Each _e_n_t_r_y identifies one file │ │ │ │ -and the byte range within it that contributes to the requested block. │ │ │ │ +************ ooppeerraattiioonn__nnaammee(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_o_p_e_r_a_t_i_o_n_s_._h_p_p" │ │ │ │ +char const* ooppeerraattiioonn__nnaammee (operation_t op); │ │ │ │ +maps an operation id (from _p_e_e_r___e_r_r_o_r___a_l_e_r_t and _p_e_e_r___d_i_s_c_o_n_n_e_c_t_e_d___a_l_e_r_t) to its │ │ │ │ +name. See _o_p_e_r_a_t_i_o_n___t for the constants │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmaapp__ffiillee(()) ********** │ │ │ │ -peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t const offset, int │ │ │ │ -const size) const; │ │ │ │ -inverse of map_block(): maps a byte range within the file at file (starting at │ │ │ │ -offset, of length size) to a peer_request identifying the piece, piece-offset │ │ │ │ -and length in torrent space. │ │ │ │ +************ aalleerrtt__ccaasstt(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t_._h_p_p" │ │ │ │ +template T const* aalleerrtt__ccaasstt (alert const* a); │ │ │ │ +template T* aalleerrtt__ccaasstt (alert* a); │ │ │ │ +When you get an _a_l_e_r_t, you can use alert_cast<> to attempt to cast the pointer │ │ │ │ +to a specific _a_l_e_r_t type, in order to query it for more information. │ │ │ │ +Note │ │ │ │ +alert_cast<> can only cast to an exact _a_l_e_r_t type, not a base class │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rroooott(()) ********** │ │ │ │ -sha256_hash rroooott (file_index_t const index) const; │ │ │ │ -returns the v2 merkle root (pieces root) for the file at index. Returns a zero │ │ │ │ -hash for v1-only torrents. │ │ │ │ +************ eennuumm ooppeerraattiioonn__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_o_p_e_r_a_t_i_o_n_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|unknown |0 |the error was unexpected and it is unknown which | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_p_e_r_a_t_i_o_n_ _c_a_u_s_e_d_ _i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|bittorrent |1 |this is used when the bittorrent logic determines | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_ _d_i_s_c_o_n_n_e_c_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_o_c_o_n_t_r_o_l_ _ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_a_ _c_a_l_l_ _t_o_ _i_o_c_o_n_t_r_o_l_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|getpeername |3 |a call to getpeername() failed (querying the remote| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_I_P_ _o_f_ _a_ _c_o_n_n_e_c_t_i_o_n_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|getname |4 |a call to getname failed (querying the local IP of | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _c_o_n_n_e_c_t_i_o_n_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_a_l_l_o_c___r_e_c_v_b_u_f_ _ _ _ _ _ _|_5_ _ _ _ _|_a_n_ _a_t_t_e_m_p_t_ _t_o_ _a_l_l_o_c_a_t_e_ _a_ _r_e_c_e_i_v_e_ _b_u_f_f_e_r_ _f_a_i_l_e_d_ _ _ _ _ | │ │ │ │ +|_a_l_l_o_c___s_n_d_b_u_f_ _ _ _ _ _ _ _|_6_ _ _ _ _|_a_n_ _a_t_t_e_m_p_t_ _t_o_ _a_l_l_o_c_a_t_e_ _a_ _s_e_n_d_ _b_u_f_f_e_r_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___w_r_i_t_e_ _ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_w_r_i_t_i_n_g_ _t_o_ _a_ _f_i_l_e_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___r_e_a_d_ _ _ _ _ _ _ _ _ _ _|_8_ _ _ _ _|_r_e_a_d_i_n_g_ _f_r_o_m_ _a_ _f_i_l_e_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_ _ _ _ _|_a_ _n_o_n_-_r_e_a_d_ _a_n_d_ _n_o_n_-_w_r_i_t_e_ _f_i_l_e_ _o_p_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ | │ │ │ │ +|_s_o_c_k___w_r_i_t_e_ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_a_ _s_o_c_k_e_t_ _w_r_i_t_e_ _o_p_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k___r_e_a_d_ _ _ _ _ _ _ _ _ _ _|_1_1_ _ _ _|_a_ _s_o_c_k_e_t_ _r_e_a_d_ _o_p_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k___o_p_e_n_ _ _ _ _ _ _ _ _ _ _|_1_2_ _ _ _|_a_ _c_a_l_l_ _t_o_ _o_p_e_n_(_)_,_ _t_o_ _c_r_e_a_t_e_ _a_ _s_o_c_k_e_t_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ | │ │ │ │ +|_s_o_c_k___b_i_n_d_ _ _ _ _ _ _ _ _ _ _|_1_3_ _ _ _|_a_ _c_a_l_l_ _t_o_ _b_i_n_d_(_)_ _o_n_ _a_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|available |14 |an attempt to query the number of bytes available | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_ _r_e_a_d_ _f_r_o_m_ _a_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|encryption |15 |a call related to bittorrent protocol encryption | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_c_o_n_n_e_c_t_ _ _ _ _ _ _ _ _ _ _ _ _|_1_6_ _ _ _|_a_n_ _a_t_t_e_m_p_t_ _t_o_ _c_o_n_n_e_c_t_ _a_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_s_l___h_a_n_d_s_h_a_k_e_ _ _ _ _ _ _|_1_7_ _ _ _|_e_s_t_a_b_l_i_s_h_i_n_g_ _a_n_ _S_S_L_ _c_o_n_n_e_c_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|get_interface |18 |a connection failed to satisfy the bind interface | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_t_t_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k___l_i_s_t_e_n_ _ _ _ _ _ _ _ _|_1_9_ _ _ _|_a_ _c_a_l_l_ _t_o_ _l_i_s_t_e_n_(_)_ _o_n_ _a_ _s_o_c_k_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|sock_bind_to_device|20 |a call to the ioctl to bind a socket to a specific | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_e_t_w_o_r_k_ _d_e_v_i_c_e_ _o_r_ _a_d_a_p_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k___a_c_c_e_p_t_ _ _ _ _ _ _ _ _|_2_1_ _ _ _|_a_ _c_a_l_l_ _t_o_ _a_c_c_e_p_t_(_)_ _o_n_ _a_ _s_o_c_k_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_a_r_s_e___a_d_d_r_e_s_s_ _ _ _ _ _ _|_2_2_ _ _ _|_c_o_n_v_e_r_t_ _a_ _s_t_r_i_n_g_ _i_n_t_o_ _a_ _v_a_l_i_d_ _n_e_t_w_o_r_k_ _a_d_d_r_e_s_s_ _ _ _ _ _ | │ │ │ │ +|_e_n_u_m___i_f_ _ _ _ _ _ _ _ _ _ _ _ _|_2_3_ _ _ _|_e_n_u_m_e_r_a_t_i_o_n_ _n_e_t_w_o_r_k_ _d_e_v_i_c_e_s_ _o_r_ _a_d_a_p_t_e_r_s_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___s_t_a_t_ _ _ _ _ _ _ _ _ _ _|_2_4_ _ _ _|_i_n_v_o_k_i_n_g_ _s_t_a_t_(_)_ _o_n_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___c_o_p_y_ _ _ _ _ _ _ _ _ _ _|_2_5_ _ _ _|_c_o_p_y_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___f_a_l_l_o_c_a_t_e_ _ _ _ _ _|_2_6_ _ _ _|_a_l_l_o_c_a_t_i_n_g_ _s_t_o_r_a_g_e_ _f_o_r_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___h_a_r_d___l_i_n_k_ _ _ _ _ _|_2_7_ _ _ _|_c_r_e_a_t_i_n_g_ _a_ _h_a_r_d_ _l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___r_e_m_o_v_e_ _ _ _ _ _ _ _ _|_2_8_ _ _ _|_r_e_m_o_v_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___r_e_n_a_m_e_ _ _ _ _ _ _ _ _|_2_9_ _ _ _|_r_e_n_a_m_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___o_p_e_n_ _ _ _ _ _ _ _ _ _ _|_3_0_ _ _ _|_o_p_e_n_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_m_k_d_i_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_1_ _ _ _|_c_r_e_a_t_i_n_g_ _a_ _d_i_r_e_c_t_o_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_c_h_e_c_k___r_e_s_u_m_e_ _ _ _ _ _ _ _|_3_2_ _ _ _|_c_h_e_c_k_ _f_a_s_t_ _r_e_s_u_m_e_ _d_a_t_a_ _a_g_a_i_n_s_t_ _f_i_l_e_s_ _o_n_ _d_i_s_k_ _ _ _ _ _ _ | │ │ │ │ +|_e_x_c_e_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _|_3_3_ _ _ _|_a_n_ _u_n_k_n_o_w_n_ _e_x_c_e_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_a_l_l_o_c___c_a_c_h_e___p_i_e_c_e_ _ _|_3_4_ _ _ _|_a_l_l_o_c_a_t_e_ _s_p_a_c_e_ _f_o_r_ _a_ _p_i_e_c_e_ _i_n_ _t_h_e_ _c_a_c_h_e_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_a_r_t_f_i_l_e___m_o_v_e_ _ _ _ _ _ _|_3_5_ _ _ _|_m_o_v_e_ _a_ _p_a_r_t_-_f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_a_r_t_f_i_l_e___r_e_a_d_ _ _ _ _ _ _|_3_6_ _ _ _|_r_e_a_d_ _f_r_o_m_ _a_ _p_a_r_t_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_a_r_t_f_i_l_e___w_r_i_t_e_ _ _ _ _ _|_3_7_ _ _ _|_w_r_i_t_e_ _t_o_ _a_ _p_a_r_t_-_f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_h_o_s_t_n_a_m_e___l_o_o_k_u_p_ _ _ _ _|_3_8_ _ _ _|_a_ _h_o_s_t_n_a_m_e_ _l_o_o_k_u_p_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_y_m_l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _|_3_9_ _ _ _|_c_r_e_a_t_e_ _o_r_ _r_e_a_d_ _a_ _s_y_m_l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_h_a_n_d_s_h_a_k_e_ _ _ _ _ _ _ _ _ _ _|_4_0_ _ _ _|_h_a_n_d_s_h_a_k_e_ _w_i_t_h_ _a_ _p_e_e_r_ _o_r_ _s_e_r_v_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k___o_p_t_i_o_n_ _ _ _ _ _ _ _ _|_4_1_ _ _ _|_s_e_t_ _s_o_c_k_e_t_ _o_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_e_n_u_m___r_o_u_t_e_ _ _ _ _ _ _ _ _ _|_4_2_ _ _ _|_e_n_u_m_e_r_a_t_i_o_n_ _o_f_ _n_e_t_w_o_r_k_ _r_o_u_t_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___s_e_e_k_ _ _ _ _ _ _ _ _ _ _|_4_3_ _ _ _|_m_o_v_i_n_g_ _r_e_a_d_/_w_r_i_t_e_ _p_o_s_i_t_i_o_n_ _i_n_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_i_m_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_4_4_ _ _ _|_a_n_ _a_s_y_n_c_ _w_a_i_t_ _o_p_e_r_a_t_i_o_n_ _o_n_ _a_ _t_i_m_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___m_m_a_p_ _ _ _ _ _ _ _ _ _ _|_4_5_ _ _ _|_c_a_l_l_ _t_o_ _m_m_a_p_(_)_ _(_o_r_ _w_i_n_d_o_w_s_ _c_o_u_n_t_e_r_p_a_r_t_)_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_i_l_e___t_r_u_n_c_a_t_e_ _ _ _ _ _ _|_4_6_ _ _ _|_c_a_l_l_ _t_o_ _f_t_r_u_n_c_a_t_e_(_)_ _(_o_r_ _S_e_t_E_n_d_O_f_F_i_l_e_(_)_ _o_n_ _w_i_n_d_o_w_s_)_ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__lleennggtthh(()) ********** │ │ │ │ -int ppiieeccee__lleennggtthh () const; │ │ │ │ -the piece size, in bytes. All pieces have this size except the last, which may │ │ │ │ -be shorter. │ │ │ │ +************ iinntt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ + user_alert_id │ │ │ │ + user defined alerts should use IDs greater than this │ │ │ │ + num_alert_types │ │ │ │ + this constant represents "max_alert_index" + 1 │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttoorraaggee__ppaarraammss ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ -a parameter pack used to construct the storage for a torrent, used in │ │ │ │ -_d_i_s_k___i_n_t_e_r_f_a_c_e │ │ │ │ -struct storage_params │ │ │ │ +************ aalleerrtt__ccaatteeggoorryy__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t_._h_p_p" │ │ │ │ + error │ │ │ │ + Enables alerts that report an error. This includes: │ │ │ │ + * tracker errors │ │ │ │ + * tracker warnings │ │ │ │ + * file errors │ │ │ │ + * resume data failures │ │ │ │ + * web seed errors │ │ │ │ + * .torrent files errors │ │ │ │ + * listen socket errors │ │ │ │ + * port mapping errors │ │ │ │ + peer │ │ │ │ + Enables alerts when peers send invalid requests, get banned or snubbed. │ │ │ │ + port_mapping │ │ │ │ + Enables alerts for port mapping events. For NAT-PMP and UPnP. │ │ │ │ + storage │ │ │ │ + Enables alerts for events related to the storage. File errors and │ │ │ │ + synchronization events for moving the storage, renaming files etc. │ │ │ │ + tracker │ │ │ │ + Enables all tracker events. Includes announcing to trackers, receiving │ │ │ │ + responses, warnings and errors. │ │ │ │ + connect │ │ │ │ + Low level alerts for when peers are connected and disconnected. │ │ │ │ + status │ │ │ │ + Enables alerts for when a torrent or the _s_e_s_s_i_o_n changes state. │ │ │ │ + ip_block │ │ │ │ + Alerts when a peer is blocked by the ip blocker or port blocker. │ │ │ │ + performance_warning │ │ │ │ + Alerts when some limit is reached that might limit the download or upload │ │ │ │ + rate. │ │ │ │ + dht │ │ │ │ + Alerts on events in the DHT node. For incoming searches or bootstrapping │ │ │ │ + being done etc. │ │ │ │ + stats │ │ │ │ + If you enable these alerts, you will receive a stats_alert approximately │ │ │ │ + once every second, for every active torrent. These alerts contain all │ │ │ │ + statistics _c_o_u_n_t_e_r_s for the interval since the lasts stats _a_l_e_r_t. │ │ │ │ + session_log │ │ │ │ + Enables debug logging alerts. These are available unless libtorrent was │ │ │ │ + built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being │ │ │ │ + posted are _l_o_g___a_l_e_r_t and are _s_e_s_s_i_o_n wide. │ │ │ │ + torrent_log │ │ │ │ + Enables debug logging alerts for torrents. These are available unless │ │ │ │ + libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The │ │ │ │ + alerts being posted are _t_o_r_r_e_n_t___l_o_g___a_l_e_r_t and are torrent wide debug │ │ │ │ + events. │ │ │ │ + peer_log │ │ │ │ + Enables debug logging alerts for peers. These are available unless │ │ │ │ + libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The │ │ │ │ + alerts being posted are _p_e_e_r___l_o_g___a_l_e_r_t and low-level peer events and │ │ │ │ + messages. │ │ │ │ + incoming_request │ │ │ │ + enables the _i_n_c_o_m_i_n_g___r_e_q_u_e_s_t___a_l_e_r_t. │ │ │ │ + dht_log │ │ │ │ + enables _d_h_t___l_o_g___a_l_e_r_t, debug logging for the DHT │ │ │ │ + dht_operation │ │ │ │ + enable events from pure dht operations not related to torrents │ │ │ │ + port_mapping_log │ │ │ │ + enables port mapping log events. This log is useful for debugging the │ │ │ │ + UPnP or NAT-PMP implementation │ │ │ │ + picker_log │ │ │ │ + enables verbose logging from the piece picker. │ │ │ │ + file_progress │ │ │ │ + alerts when files complete downloading │ │ │ │ + piece_progress │ │ │ │ + alerts when pieces complete downloading or fail hash check │ │ │ │ + upload │ │ │ │ + alerts when we upload blocks to other peers │ │ │ │ + block_progress │ │ │ │ + alerts on individual blocks being requested, downloading, finished, │ │ │ │ + rejected, time-out and cancelled. This is likely to post alerts at a high │ │ │ │ + rate. │ │ │ │ + all │ │ │ │ + The full bitmask, representing all available categories. │ │ │ │ + since the enum is signed, make sure this isn't interpreted as -1. For │ │ │ │ + instance, boost.python does that and fails when assigning it to an │ │ │ │ + unsigned parameter. │ │ │ │ +[_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 │ │ │ │ { │ │ │ │ - ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ - , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ - , aux::vector const& prio │ │ │ │ - , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ + sseessssiioonn__ppaarraammss (); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ + , std::vector> exts); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ + , std::vector> exts); │ │ │ │ │ │ │ │ - file_storage const& files; │ │ │ │ - lt::renamed_files const& renamed_files; │ │ │ │ - string_view path; │ │ │ │ - string_view part_file_dir; │ │ │ │ - storage_mode_t mmooddee {storage_mode_sparse}; │ │ │ │ - aux::vector const& priorities; │ │ │ │ - sha1_hash info_hash; │ │ │ │ - bool v1; │ │ │ │ - bool v2; │ │ │ │ + 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] │ │ │ │ -********** ssttoorraaggee__ppaarraammss(()) ********** │ │ │ │ -ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ - , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ - , aux::vector const& prio │ │ │ │ - , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ -constructs a parameter pack from the layout, save path, mode, per-file │ │ │ │ -priorities, info-hash and protocol-version flags. v1 indicates that the torrent │ │ │ │ -has v1 metadata (a SHA-1 info-hash); v2 that it has v2 metadata (BEP 52). A │ │ │ │ -hybrid torrent has both set. │ │ │ │ +********** 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] │ │ │ │ - files │ │ │ │ - the file layout (sizes, paths, flags) of the torrent │ │ │ │ +********** sseessssiioonn__ppaarraammss(()) ********** │ │ │ │ +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] │ │ │ │ - renamed_files │ │ │ │ - rename overlay applied on top of files; on-disk paths resolved through │ │ │ │ - this object take precedence over the originals │ │ │ │ + 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] │ │ │ │ - path │ │ │ │ - the directory where the torrent's files are stored │ │ │ │ + flags │ │ │ │ + specifies flags affecting the _s_e_s_s_i_o_n construction. E.g. they can be used │ │ │ │ + to start a _s_e_s_s_i_o_n in paused mode (by passing in session::paused). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - part_file_dir │ │ │ │ - directory in which the part file is created. If empty, the part file is │ │ │ │ - placed under path. │ │ │ │ + extensions │ │ │ │ + the plugins to add to the _s_e_s_s_i_o_n as it is constructed │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - mode │ │ │ │ - the storage allocation mode (sparse vs. pre-allocated) │ │ │ │ + dht_state │ │ │ │ + DHT node ID and node addresses to bootstrap the DHT with. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - priorities │ │ │ │ - per-file download priorities, indexed by file index │ │ │ │ + dht_storage_constructor │ │ │ │ + function object to construct the storage object for DHT items. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - info_hash │ │ │ │ - the SHA-1 info-hash of the torrent (zero for v2-only torrents) │ │ │ │ + disk_io_constructor │ │ │ │ + function object to create the disk I/O subsystem. Defaults to │ │ │ │ + default_disk_io_constructor, which is implied by leaving the field │ │ │ │ + default initialized. Built-in options are: │ │ │ │ + * mmap_disk_io_constructor. Multi-threaded disk I/O using memory │ │ │ │ + mapped files │ │ │ │ + * posix_disk_io_constructor. Single-threaded simple portable disk I/O │ │ │ │ + * disabled_disk_io_constructor. Throws away all data and reads │ │ │ │ + garbage. │ │ │ │ + Useful for testing and benchmarking. │ │ │ │ + * pread_disk_io_constructor (experimental). Multi-threaded disk I/ │ │ │ │ + O using preadv/pwritev with a write cache. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - v1 v2 │ │ │ │ - indicates which BitTorrent protocol version(s) this storage is for. v1 is │ │ │ │ - true if the torrent has v1 metadata; v2 is true if the torrent has v2 │ │ │ │ - metadata (BEP 52). A hybrid torrent has both flags set. │ │ │ │ + ext_state │ │ │ │ + this container can be used by extensions/plugins to store settings. It's │ │ │ │ + primarily here to make it convenient to save and restore state across │ │ │ │ + sessions, using _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) and _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_a_b_l_e_d___d_i_s_k___i_o_._h_p_p" │ │ │ │ -std::unique_ptr ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -creates a disk io object that discards all data written to it, and only returns │ │ │ │ -zero-buffers when read from. May be useful for testing and benchmarking. │ │ │ │ + ip_filter │ │ │ │ + the IP filter to use for the _s_e_s_s_i_o_n. This restricts which peers are │ │ │ │ + allowed to connect. As if passed to _s_e_t___i_p___f_i_l_t_e_r_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_m_a_p___d_i_s_k___i_o_._h_p_p" │ │ │ │ -std::unique_ptr mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -constructs a memory mapped file disk I/O object. │ │ │ │ +************ sseessssiioonn__pprrooxxyy ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ +this is a holder for the internal _s_e_s_s_i_o_n implementation object. Once the │ │ │ │ +_s_e_s_s_i_o_n destruction is explicitly initiated, this holder is used to synchronize │ │ │ │ +the completion of the shutdown. The lifetime of this object may outlive │ │ │ │ +_s_e_s_s_i_o_n, causing the _s_e_s_s_i_o_n destructor to not block. The _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ +destructor will block however, until the underlying _s_e_s_s_i_o_n is done shutting │ │ │ │ +down. │ │ │ │ +struct session_proxy │ │ │ │ +{ │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ + ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ + session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ + sseessssiioonn__pprrooxxyy (); │ │ │ │ + session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_s_i_x___d_i_s_k___i_o_._h_p_p" │ │ │ │ -std::unique_ptr ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -this is a simple posix disk I/O back-end, used for systems that don't have a 64 │ │ │ │ -bit virtual address space or don't support memory mapped files. It's │ │ │ │ -implemented using portable C file functions and is single-threaded. │ │ │ │ +********** sseessssiioonn__pprrooxxyy(()) ~~sseessssiioonn__pprrooxxyy(()) ooppeerraattoorr==(()) ********** │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ +~~sseessssiioonn__pprrooxxyy (); │ │ │ │ +session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ +sseessssiioonn__pprrooxxyy (); │ │ │ │ +session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ +default constructor, does not refer to any _s_e_s_s_i_o_n implementation object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +************ sseessssiioonn ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -std::unique_ptr ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -the constructor function for the default storage. On systems that support │ │ │ │ -memory mapped files (and a 64 bit address space) the memory mapped storage will │ │ │ │ -be constructed, otherwise the portable posix storage. │ │ │ │ +The _s_e_s_s_i_o_n holds all state that spans multiple torrents. Among other things it │ │ │ │ +runs the network loop and manages all torrents. Once it's created, the _s_e_s_s_i_o_n │ │ │ │ +object will spawn the main thread that will do all the work. The main thread │ │ │ │ +will be idle as long it doesn't have any torrents to participate in. │ │ │ │ +You have some control over _s_e_s_s_i_o_n configuration through the session_handle:: │ │ │ │ +apply_settings() member function. To change one or more configuration options, │ │ │ │ +create a _s_e_t_t_i_n_g_s___p_a_c_k. object and fill it with the settings to be set and pass │ │ │ │ +it in to session::apply_settings(). │ │ │ │ +see _a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ +struct session : session_handle │ │ │ │ +{ │ │ │ │ + explicit sseessssiioonn (session_params const& params); │ │ │ │ + sseessssiioonn (); │ │ │ │ + explicit sseessssiioonn (session_params&& params); │ │ │ │ + sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ + sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ + ~~sseessssiioonn (); │ │ │ │ + session_proxy aabboorrtt (); │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm ssttoorraaggee__mmooddee__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |All pieces will be written to their final | │ │ │ │ -| | |position, all files will be allocated in full | │ │ │ │ -|storage_mode_allocate|0 |when the torrent is first started. This mode | │ │ │ │ -| | |minimizes fragmentation but could be a costly | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_p_e_r_a_t_i_o_n_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |All pieces will be written to the place where | │ │ │ │ -|storage_mode_sparse |1 |they belong and sparse files will be used. This| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_s_ _t_h_e_ _r_e_c_o_m_m_e_n_d_e_d_,_ _a_n_d_ _d_e_f_a_u_l_t_ _m_o_d_e_._ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** sseessssiioonn(()) ********** │ │ │ │ +explicit sseessssiioonn (session_params const& params); │ │ │ │ +sseessssiioonn (); │ │ │ │ +explicit sseessssiioonn (session_params&& params); │ │ │ │ +Constructs the _s_e_s_s_i_o_n objects which acts as the container of torrents. In │ │ │ │ +order to avoid a race condition between starting the _s_e_s_s_i_o_n and configuring │ │ │ │ +it, you can pass in a _s_e_s_s_i_o_n___p_a_r_a_m_s object. Its settings will take effect │ │ │ │ +before the _s_e_s_s_i_o_n starts up. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm mmoovvee__ffllaaggss__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|always_replace_files |0 |replace any files in the destination when | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_p_y_i_n_g_ _o_r_ _m_o_v_i_n_g_ _t_h_e_ _s_t_o_r_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |if any files that we want to copy exist in | │ │ │ │ -| | |the destination exist, fail the whole | │ │ │ │ -| | |operation and don't perform any copy or move.| │ │ │ │ -| | |There is an inherent race condition in this | │ │ │ │ -|fail_if_exist |1 |mode. The files are checked for existence | │ │ │ │ -| | |before the operation starts. In between the | │ │ │ │ -| | |check and performing the copy, the | │ │ │ │ -| | |destination files may be created, in which | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_s_e_ _t_h_e_y_ _a_r_e_ _r_e_p_l_a_c_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |if any file exist in the target, take those | │ │ │ │ -|dont_replace |2 |files instead of the ones we may have in the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_o_u_r_c_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |don't move any source files, just forget | │ │ │ │ -|reset_save_path |3 |about them and begin checking files at new | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_a_v_e_ _p_a_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|reset_save_path_unchecked|4 |don't move any source files, just change save| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_a_t_h_ _a_n_d_ _c_o_n_t_i_n_u_e_ _w_o_r_k_i_n_g_ _w_i_t_h_o_u_t_ _a_n_y_ _c_h_e_c_k_s_ | │ │ │ │ +********** sseessssiioonn(()) ********** │ │ │ │ +sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ +sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ +Overload of the constructor that takes an external io_context to run the │ │ │ │ +_s_e_s_s_i_o_n object on. This is primarily useful for tests that may want to run │ │ │ │ +multiple sessions on a single io_context, or low resource systems where │ │ │ │ +additional threads are expensive and sharing an io_context with other events is │ │ │ │ +fine. │ │ │ │ +Warning │ │ │ │ +The _s_e_s_s_i_o_n object does not cleanly terminate with an external io_context. The │ │ │ │ +io_context::run() call mmuusstt have returned before it's safe to destruct the │ │ │ │ +_s_e_s_s_i_o_n. Which means you MMUUSSTT call _s_e_s_s_i_o_n_:_:_a_b_o_r_t_(_) and save the _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ +first, then destruct the _s_e_s_s_i_o_n object, then sync with the io_context, then │ │ │ │ +destruct the _s_e_s_s_i_o_n___p_r_o_x_y object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ cclliieenntt__ddaattaa__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_l_i_e_n_t___d_a_t_a_._h_p_p" │ │ │ │ -A thin wrapper around a void pointer used as "user data". i.e. an opaque cookie │ │ │ │ -passed in to libtorrent and returned on demand. It adds type-safety by │ │ │ │ -requiring the same type be requested out of it as was assigned to it. │ │ │ │ -struct client_data_t │ │ │ │ +********** ~~sseessssiioonn(()) ********** │ │ │ │ +~~sseessssiioonn (); │ │ │ │ +The destructor of _s_e_s_s_i_o_n will notify all trackers that our torrents have been │ │ │ │ +shut down. If some trackers are down, they will time out. All this before the │ │ │ │ +destructor of _s_e_s_s_i_o_n returns. So, it's advised that any kind of interface │ │ │ │ +(such as windows) are closed before destructing the _s_e_s_s_i_o_n object. Because it │ │ │ │ +can take a few second for it to finish. The timeout can be set with │ │ │ │ +_a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** aabboorrtt(()) ********** │ │ │ │ +session_proxy aabboorrtt (); │ │ │ │ +In case you want to destruct the _s_e_s_s_i_o_n asynchronously, you can request a │ │ │ │ +_s_e_s_s_i_o_n destruction proxy. If you don't do this, the destructor of the _s_e_s_s_i_o_n │ │ │ │ +object will block while the trackers are contacted. If you keep one │ │ │ │ +session_proxy to the _s_e_s_s_i_o_n when destructing it, the destructor will not │ │ │ │ +block, but start to close down the _s_e_s_s_i_o_n, the destructor of the proxy will │ │ │ │ +then synchronize the threads. So, the destruction of the _s_e_s_s_i_o_n is performed │ │ │ │ +from the session destructor call until the session_proxy destructor call. The │ │ │ │ +session_proxy does not have any operations on it (since the _s_e_s_s_i_o_n is being │ │ │ │ +closed down, no operations are allowed on it). The only valid operation is │ │ │ │ +calling the destructor: │ │ │ │ +struct session_proxy {}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ sseessssiioonn__hhaannddllee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___h_a_n_d_l_e_._h_p_p" │ │ │ │ +this class provides a non-owning handle to a _s_e_s_s_i_o_n and a subset of the │ │ │ │ +interface of the _s_e_s_s_i_o_n class. If the underlying _s_e_s_s_i_o_n is destructed any │ │ │ │ +handle to it will no longer be valid. _i_s___v_a_l_i_d_(_) will return false and any │ │ │ │ +operation on it will throw a system_error exception, with error code │ │ │ │ +invalid_session_handle. │ │ │ │ +struct session_handle │ │ │ │ { │ │ │ │ - cclliieenntt__ddaattaa__tt () = default; │ │ │ │ - explicit cclliieenntt__ddaattaa__tt (T* v); │ │ │ │ - client_data_t& ooppeerraattoorr== (T* v); │ │ │ │ - T* ggeett () const; │ │ │ │ - explicit operator TT () const; │ │ │ │ - client_data_t& ooppeerraattoorr== (void const*) = delete; │ │ │ │ - operator void ccoonnsstt** () const = delete; │ │ │ │ - operator vvooiidd** () const = delete; │ │ │ │ - client_data_t& ooppeerraattoorr== (void*) = delete; │ │ │ │ + bool iiss__vvaalliidd () const; │ │ │ │ + session_params sseessssiioonn__ssttaattee (save_state_flags_t flags = │ │ │ │ +save_state_flags_t::all()) const; │ │ │ │ + std::vector ggeett__ttoorrrreenntt__ssttaattuuss ( │ │ │ │ + std::function const& pred │ │ │ │ + , status_flags_t flags = {}) const; │ │ │ │ + void rreeffrreesshh__ttoorrrreenntt__ssttaattuuss (std::vector* ret │ │ │ │ + , status_flags_t flags = {}) const; │ │ │ │ + void ppoosstt__ttoorrrreenntt__uuppddaatteess (status_flags_t flags = status_flags_t::all()); │ │ │ │ + void ppoosstt__sseessssiioonn__ssttaattss (); │ │ │ │ + void ppoosstt__ddhhtt__ssttaattss (); │ │ │ │ + void sseett__ddhhtt__ssttaattee (dht::dht_state const& st); │ │ │ │ + void sseett__ddhhtt__ssttaattee (dht::dht_state&& 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 aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& │ │ │ │ +ec); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ + void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ + void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ + 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); │ │ │ │ + void ddhhtt__ppuutt__iitteemm (std::array key │ │ │ │ + , std::function& │ │ │ │ + , std::int64_t&, std::string const&)> cb │ │ │ │ + , std::string salt = std::string()); │ │ │ │ + void ddhhtt__aannnnoouunnccee (sha1_hash const& info_hash, int port = 0, dht:: │ │ │ │ +announce_flags_t flags = {}); │ │ │ │ + void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ + void ddhhtt__lliivvee__nnooddeess (sha1_hash const& nid); │ │ │ │ + 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::function( │ │ │ │ + torrent_handle const&, client_data_t)> ext); │ │ │ │ + void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ + ip_filter ggeett__iipp__ffiilltteerr () const; │ │ │ │ + void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ + void sseett__ppoorrtt__ffiilltteerr (port_filter const& f); │ │ │ │ + unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ + bool iiss__lliisstteenniinngg () const; │ │ │ │ + unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ + ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ + void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ + void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ + 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); │ │ │ │ + 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 = {}); │ │ │ │ + settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ + void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ + void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ + bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ + void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ + void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ + std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ +external_port, int local_port); │ │ │ │ + void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ + void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ +reopen_map_ports); │ │ │ │ + std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ + │ │ │ │ + static 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; │ │ │ │ + static inline constexpr save_state_flags_t ssaavvee__iipp__ffiilltteerr = 12_bit; │ │ │ │ + static inline constexpr peer_class_t gglloobbaall__ppeeeerr__ccllaassss__iidd {0}; │ │ │ │ + static inline constexpr peer_class_t ttccpp__ppeeeerr__ccllaassss__iidd {1}; │ │ │ │ + static inline constexpr peer_class_t llooccaall__ppeeeerr__ccllaassss__iidd {2}; │ │ │ │ + static inline constexpr remove_flags_t ddeelleettee__ffiilleess = 0_bit; │ │ │ │ + static inline constexpr remove_flags_t ddeelleettee__ppaarrttffiillee = 1_bit; │ │ │ │ + static inline constexpr session_flags_t ppaauusseedd = 2_bit; │ │ │ │ + static constexpr portmap_protocol uuddpp = portmap_protocol::udp; │ │ │ │ + static constexpr portmap_protocol ttccpp = portmap_protocol::tcp; │ │ │ │ + static inline constexpr reopen_network_flags_t rreeooppeenn__mmaapp__ppoorrttss = 0_bit; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cclliieenntt__ddaattaa__tt(()) ********** │ │ │ │ -cclliieenntt__ddaattaa__tt () = default; │ │ │ │ -construct a nullptr client data │ │ │ │ +********** iiss__vvaalliidd(()) ********** │ │ │ │ +bool iiss__vvaalliidd () const; │ │ │ │ +returns true if this handle refers to a valid _s_e_s_s_i_o_n object. If the _s_e_s_s_i_o_n │ │ │ │ +has been destroyed, all _s_e_s_s_i_o_n___h_a_n_d_l_e objects will expire and not be valid. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cclliieenntt__ddaattaa__tt(()) ********** │ │ │ │ -explicit cclliieenntt__ddaattaa__tt (T* v); │ │ │ │ -initialize the client data with the specified pointer │ │ │ │ +********** sseessssiioonn__ssttaattee(()) ********** │ │ │ │ +session_params sseessssiioonn__ssttaattee (save_state_flags_t flags = save_state_flags_t:: │ │ │ │ +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] │ │ │ │ -********** ooppeerraattoorr==(()) ********** │ │ │ │ -client_data_t& ooppeerraattoorr== (T* v); │ │ │ │ -assigns a new pointer to the client data │ │ │ │ +********** ggeett__ttoorrrreenntt__ssttaattuuss(()) rreeffrreesshh__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 │ │ │ │ +torrents. If you're concerned about performance, consider using │ │ │ │ +post_torrent_updates() instead. │ │ │ │ +get_torrent_status returns a vector of the _t_o_r_r_e_n_t___s_t_a_t_u_s for every torrent │ │ │ │ +which satisfies pred, which is a predicate function which determines if a │ │ │ │ +torrent should be included in the returned set or not. Returning true means it │ │ │ │ +should be included and false means excluded. The flags argument is the same as │ │ │ │ +to _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_t_a_t_u_s_(_). Since pred is guaranteed to be called for every │ │ │ │ +torrent, it may be used to count the number of torrents of different categories │ │ │ │ +as well. │ │ │ │ +refresh_torrent_status takes a vector of _t_o_r_r_e_n_t___s_t_a_t_u_s structs (for instance │ │ │ │ +the same vector that was returned by _g_e_t___t_o_r_r_e_n_t___s_t_a_t_u_s_(_) ) and refreshes the │ │ │ │ +status based on the handle member. It is possible to use this function by first │ │ │ │ +setting up a vector of default constructed torrent_status objects, only │ │ │ │ +initializing the handle member, in order to request the torrent status for │ │ │ │ +multiple torrents in a single call. This can save a significant amount of time │ │ │ │ +if you have a lot of torrents. │ │ │ │ +Any _t_o_r_r_e_n_t___s_t_a_t_u_s object whose handle member is not referring to a valid │ │ │ │ +torrent are ignored. │ │ │ │ +The intended use of these functions is to start off by calling │ │ │ │ +get_torrent_status() to get a list of all torrents that match your criteria. │ │ │ │ +Then call refresh_torrent_status() on that list. This will only refresh the │ │ │ │ +status for the torrents in your list, and thus ignore all other torrents you │ │ │ │ +might be running. This may save a significant amount of time, especially if the │ │ │ │ +number of torrents you're interested in is small. In order to keep your list of │ │ │ │ +interested torrents up to date, you can either call get_torrent_status() from │ │ │ │ +time to time, to include torrents you might have become interested in since the │ │ │ │ +last time. In order to stop refreshing a certain torrent, simply remove it from │ │ │ │ +the list. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** TT(()) ggeett(()) ********** │ │ │ │ -T* ggeett () const; │ │ │ │ -explicit operator TT () const; │ │ │ │ -request to retrieve the pointer back again. The type T must be identical to the │ │ │ │ -type of the pointer assigned earlier, including const & volatile qualifiers. │ │ │ │ +********** ppoosstt__ttoorrrreenntt__uuppddaatteess(()) ********** │ │ │ │ +void ppoosstt__ttoorrrreenntt__uuppddaatteess (status_flags_t flags = status_flags_t::all()); │ │ │ │ +This functions instructs the _s_e_s_s_i_o_n to post the _s_t_a_t_e___u_p_d_a_t_e___a_l_e_r_t, containing │ │ │ │ +the status of all torrents whose state changed since the last time this │ │ │ │ +function was called. │ │ │ │ +Only torrents who have the state subscription flag set will be included. This │ │ │ │ +flag is on by default. See _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s. the flags argument is the same │ │ │ │ +as for _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_t_a_t_u_s_(_). see status_flags_t in _t_o_r_r_e_n_t___h_a_n_d_l_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** vvooiidd**(()) ooppeerraattoorr==(()) ccoonnsstt**(()) ********** │ │ │ │ -client_data_t& ooppeerraattoorr== (void const*) = delete; │ │ │ │ -operator void ccoonnsstt** () const = delete; │ │ │ │ -operator vvooiidd** () const = delete; │ │ │ │ -client_data_t& ooppeerraattoorr== (void*) = delete; │ │ │ │ -we don't allow type-unsafe operations │ │ │ │ +********** ppoosstt__sseessssiioonn__ssttaattss(()) ********** │ │ │ │ +void ppoosstt__sseessssiioonn__ssttaattss (); │ │ │ │ +This function will post a _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t object, containing a snapshot of │ │ │ │ +the performance _c_o_u_n_t_e_r_s from the internals of libtorrent. To interpret these │ │ │ │ +_c_o_u_n_t_e_r_s, query the _s_e_s_s_i_o_n via _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_). │ │ │ │ +For more information, see the _s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ aadddd__ttoorrrreenntt__ppaarraammss ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s_._h_p_p" │ │ │ │ -The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s contains all the information in a .torrent file along │ │ │ │ -with all information necessary to add that torrent to a _s_e_s_s_i_o_n. The key fields │ │ │ │ -when adding a torrent are: │ │ │ │ - * ti - the immutable info-dict part of the torrent │ │ │ │ - * info_hash - when you don't have the metadata (.torrent file). This │ │ │ │ - uniquely identifies the torrent and can validate the info-dict when │ │ │ │ - received from the swarm. │ │ │ │ -In order to add a torrent to a _s_e_s_s_i_o_n, one of those fields must be set in │ │ │ │ -addition to save_path. The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object can then be passed into │ │ │ │ -one of the session::add_torrent() overloads or session::async_add_torrent(). │ │ │ │ -If you only specify the info-hash, the torrent file will be downloaded from │ │ │ │ -peers, which requires them to support the metadata extension. For the metadata │ │ │ │ -extension to work, libtorrent must be built with extensions enabled │ │ │ │ -(TORRENT_DISABLE_EXTENSIONS must not be defined). It also takes an optional │ │ │ │ -name argument. This may be left empty in case no name should be assigned to the │ │ │ │ -torrent. In case it's not, the name is used for the torrent as long as it │ │ │ │ -doesn't have metadata. See torrent_handle::name. │ │ │ │ -The add_torrent_params is also used when requesting resume data for a torrent. │ │ │ │ -It can be saved to and restored from a file and added back to a new _s_e_s_s_i_o_n. │ │ │ │ -For serialization and de-serialization of add_torrent_params objects, see │ │ │ │ -_r_e_a_d___r_e_s_u_m_e___d_a_t_a_(_) and _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_(_). │ │ │ │ -The add_torrent_params is also used to represent a parsed .torrent file. It can │ │ │ │ -be loaded via _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_(_) and │ │ │ │ -_l_o_a_d___t_o_r_r_e_n_t___p_a_r_s_e_d_(_). It can be saved via _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_). │ │ │ │ -struct add_torrent_params │ │ │ │ -{ │ │ │ │ - int vveerrssiioonn = LIBTORRENT_VERSION_NUM; │ │ │ │ - std::shared_ptr ti; │ │ │ │ - std::vector trackers; │ │ │ │ - std::vector tracker_tiers; │ │ │ │ - std::vector> dht_nodes; │ │ │ │ - std::string name; │ │ │ │ - std::string save_path; │ │ │ │ - std::string part_file_dir; │ │ │ │ - storage_mode_t ssttoorraaggee__mmooddee = storage_mode_sparse; │ │ │ │ - client_data_t userdata; │ │ │ │ - std::vector file_priorities; │ │ │ │ - std::string trackerid; │ │ │ │ - torrent_flags_t ffllaaggss = torrent_flags::default_flags; │ │ │ │ - info_hash_t info_hashes; │ │ │ │ - int mmaaxx__uuppllooaaddss = -1; │ │ │ │ - int mmaaxx__ccoonnnneeccttiioonnss = -1; │ │ │ │ - int uuppllooaadd__lliimmiitt = -1; │ │ │ │ - int ddoowwnnllooaadd__lliimmiitt = -1; │ │ │ │ - std::int64_t ttoottaall__uuppllooaaddeedd = 0; │ │ │ │ - std::int64_t ttoottaall__ddoowwnnllooaaddeedd = 0; │ │ │ │ - int aaccttiivvee__ttiimmee = 0; │ │ │ │ - int ffiinniisshheedd__ttiimmee = 0; │ │ │ │ - int sseeeeddiinngg__ttiimmee = 0; │ │ │ │ - std::time_t aaddddeedd__ttiimmee = 0; │ │ │ │ - std::time_t ccoommpplleetteedd__ttiimmee = 0; │ │ │ │ - std::time_t llaasstt__sseeeenn__ccoommpplleettee = 0; │ │ │ │ - int nnuumm__ccoommpplleettee = -1; │ │ │ │ - int nnuumm__iinnccoommpplleettee = -1; │ │ │ │ - int nnuumm__ddoowwnnllooaaddeedd = -1; │ │ │ │ - std::vector url_seeds; │ │ │ │ - std::vector peers; │ │ │ │ - std::vector banned_peers; │ │ │ │ - aux::noexcept_movable> unfinished_pieces; │ │ │ │ - typed_bitfield have_pieces; │ │ │ │ - typed_bitfield verified_pieces; │ │ │ │ - std::vector piece_priorities; │ │ │ │ - aux::vector, file_index_t> merkle_trees; │ │ │ │ - aux::vector merkle_tree_mask; │ │ │ │ - aux::vector verified_leaf_hashes; │ │ │ │ - aux::noexcept_movable> renamed_files; │ │ │ │ - std::time_t llaasstt__ddoowwnnllooaadd = 0; │ │ │ │ - std::time_t llaasstt__uuppllooaadd = 0; │ │ │ │ - std::string comment; │ │ │ │ - std::string created_by; │ │ │ │ - std::time_t ccrreeaattiioonn__ddaattee = 0; │ │ │ │ - std::string root_certificate; │ │ │ │ -}; │ │ │ │ +********** ppoosstt__ddhhtt__ssttaattss(()) ********** │ │ │ │ +void ppoosstt__ddhhtt__ssttaattss (); │ │ │ │ +This will cause a _d_h_t___s_t_a_t_s___a_l_e_r_t to be posted. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - version │ │ │ │ - filled in by the constructor and should be left untouched. It is used for │ │ │ │ - forward binary compatibility. │ │ │ │ +********** sseett__ddhhtt__ssttaattee(()) ********** │ │ │ │ +void sseett__ddhhtt__ssttaattee (dht::dht_state const& st); │ │ │ │ +void sseett__ddhhtt__ssttaattee (dht::dht_state&& 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] │ │ │ │ - ti │ │ │ │ - _t_o_r_r_e_n_t___i_n_f_o object with the torrent to add. Unless the info_hash is set, │ │ │ │ - this is required to be initialized. │ │ │ │ +********** ffiinndd__ttoorrrreenntt(()) ggeett__ttoorrrreennttss(()) ********** │ │ │ │ +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; │ │ │ │ +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] │ │ │ │ - trackers │ │ │ │ - If the torrent doesn't have a tracker, but relies on the DHT to find │ │ │ │ - peers, the trackers can specify tracker URLs for the torrent. │ │ │ │ +********** aassyynncc__aadddd__ttoorrrreenntt(()) aadddd__ttoorrrreenntt(()) ********** │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& ec); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ +void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ +void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ +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 │ │ │ │ +files for the torrent will be saved. Even when using a custom storage, this │ │ │ │ +needs to be set to something. If the save_path is empty, the call to │ │ │ │ +_a_d_d___t_o_r_r_e_n_t_(_) will throw a system_error exception. │ │ │ │ +The overload that does not take an error_code throws an exception on error and │ │ │ │ +is not available when building without exception support. The _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ +returned by _a_d_d___t_o_r_r_e_n_t_(_) can be used to retrieve information about the │ │ │ │ +torrent's progress, its peers etc. It is also used to abort a torrent. │ │ │ │ +If the torrent you are trying to add already exists in the _s_e_s_s_i_o_n (is either │ │ │ │ +queued for checking, being checked or downloading) add_torrent() will throw │ │ │ │ +system_error which derives from std::exception unless duplicate_is_error is set │ │ │ │ +to false. In that case, _a_d_d___t_o_r_r_e_n_t_(_) will return the handle to the existing │ │ │ │ +torrent. │ │ │ │ +The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s class has a flags field. It can be used to control what │ │ │ │ +state the new torrent will be added in. Common flags to want to control are │ │ │ │ +torrent_flags::paused and torrent_flags::auto_managed. In order to add a magnet │ │ │ │ +link that will just download the metadata, but no payload, set the │ │ │ │ +torrent_flags::upload_mode flag. │ │ │ │ +Special consideration has to be taken when adding hybrid torrents (i.e. │ │ │ │ +torrents that are BitTorrent v2 torrents that are backwards compatible with │ │ │ │ +v1). For more details, see _B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - tracker_tiers │ │ │ │ - the tiers the URLs in trackers belong to. Trackers belonging to different │ │ │ │ - tiers may be treated differently, as defined by the multi tracker │ │ │ │ - extension. This is optional, if not specified trackers are assumed to be │ │ │ │ - part of tier 0, or whichever the last tier was as iterating over the │ │ │ │ - trackers. │ │ │ │ +********** ppaauussee(()) iiss__ppaauusseedd(()) 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] │ │ │ │ - dht_nodes │ │ │ │ - a list of hostname and port pairs, representing DHT nodes to be added to │ │ │ │ - the _s_e_s_s_i_o_n (if DHT is enabled). The hostname may be an IP address. │ │ │ │ +********** iiss__ddhhtt__rruunnnniinngg(()) ********** │ │ │ │ +bool iiss__ddhhtt__rruunnnniinngg () const; │ │ │ │ +is_dht_running() returns true if the DHT support has been started and false │ │ │ │ +otherwise. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - name │ │ │ │ - in case there's no other name in this torrent, this name will be used. │ │ │ │ - The name out of the _t_o_r_r_e_n_t___i_n_f_o object takes precedence if available. │ │ │ │ +********** sseett__ddhhtt__ssttoorraaggee(()) ********** │ │ │ │ +void sseett__ddhhtt__ssttoorraaggee (dht::dht_storage_constructor_type sc); │ │ │ │ +set_dht_storage set a dht custom storage constructor function to be used │ │ │ │ +internally when the dht is created. │ │ │ │ +Since the dht storage is a critical component for the dht behavior, this │ │ │ │ +function will only be effective the next time the dht is started. If you never │ │ │ │ +touch this feature, a default map-memory based storage is used. │ │ │ │ +If you want to make sure the dht is initially created with your custom storage, │ │ │ │ +create a _s_e_s_s_i_o_n with the setting settings_pack::enable_dht to false, set your │ │ │ │ +constructor function and call apply_settings with settings_pack::enable_dht to │ │ │ │ +true. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - save_path │ │ │ │ - The path to the directory where the torrent is or will be stored. │ │ │ │ - Note │ │ │ │ - On windows this path (and other paths) are interpreted as UNC paths. This │ │ │ │ - means they must use backslashes as directory separators and may not │ │ │ │ - contain the special directories "." or "..". │ │ │ │ - Setting this to an absolute path performs slightly better than a relative │ │ │ │ - path. │ │ │ │ +********** aadddd__ddhhtt__nnooddee(()) ********** │ │ │ │ +void aadddd__ddhhtt__nnooddee (std::pair const& node); │ │ │ │ +add_dht_node takes a host name and port pair. That endpoint will be pinged, and │ │ │ │ +if a valid DHT reply is received, the node will be added to the routing table. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - part_file_dir │ │ │ │ - This is an optional field. If set, the part-file for this torrent will be │ │ │ │ - stored in the specified subdirectory, still inside its download │ │ │ │ - directory. i.e. part_file_dir is a relative directory. The part file name │ │ │ │ - is disambiguated by including the info-hash, in hexadecimal form. By │ │ │ │ - default it's stored directly in the download directory. If the storage │ │ │ │ - for a torrent is moved, the part file is also moved along with it, to the │ │ │ │ - new download directory. A part file contains partial pieces that need to │ │ │ │ - be downloaded in order to verify hashes and seeding, but are part of │ │ │ │ - files whose priority is zero. │ │ │ │ +********** ddhhtt__ggeett__iitteemm(()) ********** │ │ │ │ +void ddhhtt__ggeett__iitteemm (sha1_hash const& target); │ │ │ │ +query the DHT for an immutable item at the target hash. the result is posted as │ │ │ │ +a _d_h_t___i_m_m_u_t_a_b_l_e___i_t_e_m___a_l_e_r_t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - storage_mode │ │ │ │ - One of the values from _s_t_o_r_a_g_e___m_o_d_e___t. For more information, see _s_t_o_r_a_g_e │ │ │ │ - _a_l_l_o_c_a_t_i_o_n. │ │ │ │ +********** ddhhtt__ggeett__iitteemm(()) ********** │ │ │ │ +void ddhhtt__ggeett__iitteemm (std::array key │ │ │ │ + , std::string salt = std::string()); │ │ │ │ +query the DHT for a mutable item under the public key key. this is an ed25519 │ │ │ │ +key. salt is optional and may be left as an empty string if no salt is to be │ │ │ │ +used. if the item is found in the DHT, a _d_h_t___m_u_t_a_b_l_e___i_t_e_m___a_l_e_r_t is posted. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - userdata │ │ │ │ - The userdata parameter is optional and will be passed on to the extension │ │ │ │ - constructor functions, if any (see _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_(_)). It │ │ │ │ - will also be stored in the torrent object and can be retrieved by calling │ │ │ │ - _u_s_e_r_d_a_t_a_(_). │ │ │ │ +********** ddhhtt__ppuutt__iitteemm(()) ********** │ │ │ │ +sha1_hash ddhhtt__ppuutt__iitteemm (entry data); │ │ │ │ +store the given bencoded data as an immutable item in the DHT. the returned │ │ │ │ +hash is the key that is to be used to look the item up again. It's just the │ │ │ │ +SHA-1 hash of the bencoded form of the structure. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - file_priorities │ │ │ │ - can be set to control the initial file priorities when adding a torrent. │ │ │ │ - The semantics are the same as for torrent_handle::prioritize_files(). The │ │ │ │ - file priorities specified in here take precedence over those specified in │ │ │ │ - the resume data, if any. If this vector of file priorities is shorter │ │ │ │ - than the number of files in the torrent, the remaining files (not covered │ │ │ │ - by this) will still have the default download priority. This default can │ │ │ │ - be changed by setting the default_dont_download torrent_flag. │ │ │ │ +********** ddhhtt__ppuutt__iitteemm(()) ********** │ │ │ │ +void ddhhtt__ppuutt__iitteemm (std::array key │ │ │ │ + , std::function& │ │ │ │ + , std::int64_t&, std::string const&)> cb │ │ │ │ + , std::string salt = std::string()); │ │ │ │ +store a mutable item. The key is the public key the blob is to be stored under. │ │ │ │ +The optional salt argument is a string that is to be mixed in with the key when │ │ │ │ +determining where in the DHT the value is to be stored. The callback function │ │ │ │ +is called from within the libtorrent network thread once we've found where to │ │ │ │ +store the blob, possibly with the current value stored under the key. The │ │ │ │ +values passed to the callback functions are: │ │ │ │ + entry& value │ │ │ │ + the current value stored under the key (may be empty). Also expected to │ │ │ │ + be set to the value to be stored by the function. │ │ │ │ + std::array& signature │ │ │ │ + the signature authenticating the current value. This may be zeros if │ │ │ │ + there is currently no value stored. The function is expected to fill in │ │ │ │ + this buffer with the signature of the new value to store. To generate the │ │ │ │ + signature, you may want to use the sign_mutable_item function. │ │ │ │ + std::int64_t& seq │ │ │ │ + current sequence number. May be zero if there is no current value. The │ │ │ │ + function is expected to set this to the new sequence number of the value │ │ │ │ + that is to be stored. Sequence numbers must be monotonically increasing. │ │ │ │ + Attempting to overwrite a value with a lower or equal sequence number │ │ │ │ + will fail, even if the signature is correct. │ │ │ │ + std::string const& salt │ │ │ │ + this is the salt that was used for this put call. │ │ │ │ +Since the callback function cb is called from within libtorrent, it is critical │ │ │ │ +to not perform any blocking operations. Ideally not even locking a mutex. Pass │ │ │ │ +any data required for this function along with the function object's context │ │ │ │ +and make the function entirely self-contained. The only reason data blob's │ │ │ │ +value is computed via a function instead of just passing in the new value is to │ │ │ │ +avoid race conditions. If you want to uuppddaattee the value in the DHT, you must │ │ │ │ +first retrieve it, then modify it, then write it back. The way the DHT works, │ │ │ │ +it is natural to always do a lookup before storing and calling the callback in │ │ │ │ +between is convenient. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - trackerid │ │ │ │ - the default tracker id to be used when announcing to trackers. By default │ │ │ │ - this is empty, and no tracker ID is used, since this is an optional │ │ │ │ - argument. If a tracker returns a tracker ID, that ID is used instead of │ │ │ │ - this. │ │ │ │ +********** ddhhtt__ggeett__ppeeeerrss(()) ddhhtt__aannnnoouunnccee(()) ********** │ │ │ │ +void ddhhtt__aannnnoouunnccee (sha1_hash const& info_hash, int port = 0, dht:: │ │ │ │ +announce_flags_t flags = {}); │ │ │ │ +void ddhhtt__ggeett__ppeeeerrss (sha1_hash const& info_hash); │ │ │ │ +dht_get_peers() will issue a DHT get_peer request to the DHT for the specified │ │ │ │ +info-hash. The response (the peers) will be posted back in a │ │ │ │ +_d_h_t___g_e_t___p_e_e_r_s___r_e_p_l_y___a_l_e_r_t. │ │ │ │ +dht_announce() will issue a DHT announce request to the DHT to the specified │ │ │ │ +info-hash, advertising the specified port. If the port is left at its default, │ │ │ │ +0, the port will be implied by the DHT message's source port (which may improve │ │ │ │ +connectivity through a NAT). dht_announce() is not affected by the │ │ │ │ +announce_port override setting. │ │ │ │ +Both these functions are exposed for advanced custom use of the DHT. All │ │ │ │ +torrents eligible to be announce to the DHT will be automatically, by │ │ │ │ +libtorrent. │ │ │ │ +For possible flags, see _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] │ │ │ │ - flags │ │ │ │ - flags controlling aspects of this torrent and how it's added. See │ │ │ │ - _t_o_r_r_e_n_t___f_l_a_g_s___t for details. │ │ │ │ - Note │ │ │ │ - The flags field is initialized with default flags by the constructor. In │ │ │ │ - order to preserve default behavior when clearing or setting other flags, │ │ │ │ - make sure to bitwise OR or in a flag or bitwise AND the inverse of a flag │ │ │ │ - to clear it. │ │ │ │ +********** ddhhtt__lliivvee__nnooddeess(()) ********** │ │ │ │ +void ddhhtt__lliivvee__nnooddeess (sha1_hash const& nid); │ │ │ │ +Retrieve all the live DHT (identified by nid) nodes. All the nodes id and │ │ │ │ +endpoint will be returned in the list of nodes in the _a_l_e_r_t │ │ │ │ +dht_live_nodes_alert. Since this _a_l_e_r_t is a response to an explicit call, it │ │ │ │ +will always be posted, regardless of the _a_l_e_r_t mask. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - info_hashes │ │ │ │ - set this to the info hash of the torrent to add in case the info-hash is │ │ │ │ - the only known property of the torrent. i.e. you don't have a .torrent │ │ │ │ - file nor a magnet link. To add a magnet link, use _p_a_r_s_e___m_a_g_n_e_t___u_r_i_(_) to │ │ │ │ - populate fields in the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. │ │ │ │ +********** ddhhtt__ssaammppllee__iinnffoohhaasshheess(()) ********** │ │ │ │ +void ddhhtt__ssaammppllee__iinnffoohhaasshheess (udp::endpoint const& ep, sha1_hash const& target); │ │ │ │ +Query the DHT node specified by ep to retrieve a sample of the info-hashes that │ │ │ │ +the node currently have in their storage. The target is included for iterative │ │ │ │ +lookups so that indexing nodes can perform a key space traversal with a single │ │ │ │ +RPC per node by adjusting the target value for each RPC. It has no effect on │ │ │ │ +the returned sample value. The result is posted as a │ │ │ │ +dht_sample_infohashes_alert. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - max_uploads max_connections │ │ │ │ - max_uploads, max_connections, upload_limit, download_limit correspond to │ │ │ │ - the set_max_uploads(), set_max_connections(), set_upload_limit() and │ │ │ │ - set_download_limit() functions on _t_o_r_r_e_n_t___h_a_n_d_l_e. These values let you │ │ │ │ - initialize these settings when the torrent is added, instead of calling │ │ │ │ - these functions immediately following adding it. │ │ │ │ - -1 means unlimited on these settings just like their counterpart │ │ │ │ - functions on _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ - For fine grained control over rate limits, including making them apply to │ │ │ │ - local peers, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ +********** ddhhtt__ddiirreecctt__rreeqquueesstt(()) ********** │ │ │ │ +void ddhhtt__ddiirreecctt__rreeqquueesstt (udp::endpoint const& ep, entry const& e, client_data_t │ │ │ │ +userdata = {}); │ │ │ │ +Send an arbitrary DHT request directly to the specified endpoint. This function │ │ │ │ +is intended for use by plugins. When a response is received or the request │ │ │ │ +times out, a _d_h_t___d_i_r_e_c_t___r_e_s_p_o_n_s_e___a_l_e_r_t will be posted with the response (if │ │ │ │ +any) and the userdata pointer passed in here. Since this _a_l_e_r_t is a response to │ │ │ │ +an explicit call, it will always be posted, regardless of the _a_l_e_r_t mask. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - upload_limit download_limit │ │ │ │ - the upload and download rate limits for this torrent, specified in bytes │ │ │ │ - per second. -1 means unlimited. │ │ │ │ +********** aadddd__eexxtteennssiioonn(()) ********** │ │ │ │ +void aadddd__eexxtteennssiioonn (std::function( │ │ │ │ + torrent_handle const&, client_data_t)> ext); │ │ │ │ +void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ +This function adds an extension to this _s_e_s_s_i_o_n. The argument is a function │ │ │ │ +object that is called with a torrent_handle and which should return a std:: │ │ │ │ +shared_ptr. To write custom plugins, see _l_i_b_t_o_r_r_e_n_t_ _p_l_u_g_i_n_s. │ │ │ │ +For the typical bittorrent client all of these extensions should be added. The │ │ │ │ +main plugins implemented in libtorrent are: │ │ │ │ + uTorrent metadata │ │ │ │ + Allows peers to download the metadata (.torrent files) from the swarm │ │ │ │ + directly. Makes it possible to join a swarm with just a tracker and info- │ │ │ │ + hash. │ │ │ │ +#include │ │ │ │ +ses.add_extension(<::create_ut_metadata_plugin); │ │ │ │ + uTorrent peer exchange │ │ │ │ + Exchanges peers between clients. │ │ │ │ +#include │ │ │ │ +ses.add_extension(<::create_ut_pex_plugin); │ │ │ │ + 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] │ │ │ │ - total_uploaded total_downloaded │ │ │ │ - the total number of bytes uploaded and downloaded by this torrent so far. │ │ │ │ +********** 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. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - active_time finished_time seeding_time │ │ │ │ - the number of seconds this torrent has spent in started, finished and │ │ │ │ - seeding state so far, respectively. │ │ │ │ +********** 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] │ │ │ │ - added_time completed_time │ │ │ │ - if set to a non-zero value, this is the posix time of when this torrent │ │ │ │ - was first added, including previous runs/sessions. If set to zero, the │ │ │ │ - internal added_time will be set to the time of when _a_d_d___t_o_r_r_e_n_t_(_) is │ │ │ │ - called. │ │ │ │ +********** iiss__lliisstteenniinngg(()) lliisstteenn__ppoorrtt(()) ssssll__lliisstteenn__ppoorrtt(()) ********** │ │ │ │ +unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ +bool iiss__lliisstteenniinngg () const; │ │ │ │ +unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ +is_listening() will tell you whether or not the _s_e_s_s_i_o_n has successfully opened │ │ │ │ +a listening port. If it hasn't, this function will return false, and then you │ │ │ │ +can set a new _s_e_t_t_i_n_g_s___p_a_c_k_:_:_l_i_s_t_e_n___i_n_t_e_r_f_a_c_e_s to try another interface and │ │ │ │ +port to bind to. │ │ │ │ +listen_port() returns the port we ended up listening on. │ │ │ │ +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] │ │ │ │ - last_seen_complete │ │ │ │ - if set to non-zero, initializes the time (expressed in posix time) when │ │ │ │ - we last saw a seed or peers that together formed a complete copy of the │ │ │ │ - torrent. If left set to zero, the internal counterpart to this field will │ │ │ │ - be updated when we see a seed or a distributed copies >= 1.0. │ │ │ │ +********** 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. │ │ │ │ +For example, to make all peers in the range 200.1.1.0 - 200.1.255.255 belong to │ │ │ │ +their own peer class, apply the following filter: │ │ │ │ +ip_filter f = ses.get_peer_class_filter(); │ │ │ │ +peer_class_t my_class = ses.create_peer_class("200.1.x.x IP range"); │ │ │ │ +f.add_rule(make_address("200.1.1.0"), make_address("200.1.255.255") │ │ │ │ + , 1 << static_cast(my_class)); │ │ │ │ +ses.set_peer_class_filter(f); │ │ │ │ +This setting only applies to new connections, it won't affect existing peer │ │ │ │ +connections. │ │ │ │ +This function is limited to only peer class 0-31, since there are only 32 bits │ │ │ │ +in the IP range mapping. Only the set bits matter; no peer class will be │ │ │ │ +removed from a peer as a result of this call, peer classes are only added. │ │ │ │ +The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ │ +peer classes in the peer_class_filter are 32 bits. │ │ │ │ +The get_peer_class_filter() function returns the current filter. │ │ │ │ +For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - num_complete num_incomplete num_downloaded │ │ │ │ - these field can be used to initialize the torrent's cached scrape data. │ │ │ │ - The scrape data is high level metadata about the current state of the │ │ │ │ - swarm, as returned by the tracker (either when announcing to it or by │ │ │ │ - sending a specific scrape request). num_complete is the number of peers │ │ │ │ - in the swarm that are seeds, or have every piece in the torrent. │ │ │ │ - num_incomplete is the number of peers in the swarm that do not have every │ │ │ │ - piece. num_downloaded is the number of times the torrent has been │ │ │ │ - downloaded (not initiated, but the number of times a download has │ │ │ │ - completed). │ │ │ │ - Leaving any of these values set to -1 indicates we don't know, or we have │ │ │ │ - not received any scrape data. │ │ │ │ +********** ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ********** │ │ │ │ +void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ +peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ +Sets and gets the ppeeeerr ccllaassss ttyyppee ffiilltteerr. This is controls automatic peer class │ │ │ │ +assignments to peers based on what kind of socket it is. │ │ │ │ +It does not only support assigning peer classes, it also supports removing peer │ │ │ │ +classes based on socket type. │ │ │ │ +The order of these rules being applied are: │ │ │ │ + 1. peer-class IP filter │ │ │ │ + 2. peer-class type filter, removing classes │ │ │ │ + 3. peer-class type filter, adding classes │ │ │ │ +For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - url_seeds │ │ │ │ - URLs can be added to these two lists to specify additional web seeds to │ │ │ │ - be used by the torrent. If the override_web_seeds flag is set, these will │ │ │ │ - be the _only_ ones to be used. i.e. any web seeds found in the .torrent │ │ │ │ - file will be overridden. │ │ │ │ - URLs are expected to be regular web servers, aka "get right" style, │ │ │ │ - specified in _B_E_P_ _1_9. │ │ │ │ +********** ccrreeaattee__ppeeeerr__ccllaassss(()) ********** │ │ │ │ +peer_class_t ccrreeaattee__ppeeeerr__ccllaassss (char const* name); │ │ │ │ +Creates a new peer class (see _p_e_e_r_ _c_l_a_s_s_e_s) with the given name. The returned │ │ │ │ +integer is the new peer class identifier. Peer classes may have the same name, │ │ │ │ +so each invocation of this function creates a new class and returns a unique │ │ │ │ +identifier. │ │ │ │ +Identifiers are assigned from low numbers to higher. So if you plan on using │ │ │ │ +certain peer classes in a call to _s_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_), make sure to create │ │ │ │ +those early on, to get low identifiers. │ │ │ │ +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] │ │ │ │ - peers │ │ │ │ - peers to add to the torrent, to be tried to be connected to as bittorrent │ │ │ │ - peers. │ │ │ │ +********** ddeelleettee__ppeeeerr__ccllaassss(()) ********** │ │ │ │ +void ddeelleettee__ppeeeerr__ccllaassss (peer_class_t cid); │ │ │ │ +This call dereferences the reference count of the specified peer class. When │ │ │ │ +creating a peer class it's automatically referenced by 1. If you want to │ │ │ │ +recycle a peer class, you may call this function. You may only call this │ │ │ │ +function oonnccee per peer class you create. Calling it more than once for the same │ │ │ │ +class will lead to memory corruption. │ │ │ │ +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] │ │ │ │ - banned_peers │ │ │ │ - peers banned from this torrent. They will not be connected to │ │ │ │ +********** sseett__ppeeeerr__ccllaassss(()) ggeett__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 │ │ │ │ +any of its classes is the one that is taken into account. │ │ │ │ +For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - unfinished_pieces │ │ │ │ - this is a map of partially downloaded piece. The key is the piece index │ │ │ │ - and the value is a _b_i_t_f_i_e_l_d where each bit represents a 16 kiB block. A │ │ │ │ - set bit means we have that block. │ │ │ │ +********** rreemmoovvee__ttoorrrreenntt(()) ********** │ │ │ │ +void rreemmoovvee__ttoorrrreenntt (const torrent_handle&, remove_flags_t = {}); │ │ │ │ +remove_torrent() will close all peer connections associated with the torrent │ │ │ │ +and tell the tracker that we've stopped participating in the swarm. This │ │ │ │ +operation cannot fail. When it completes, you will receive a │ │ │ │ +_t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t. │ │ │ │ +_r_e_m_o_v_e___t_o_r_r_e_n_t_(_) is non-blocking, but will remove the torrent from the _s_e_s_s_i_o_n │ │ │ │ +synchronously. Calling _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_a_d_d___t_o_r_r_e_n_t_(_) immediately afterward with │ │ │ │ +the same torrent will succeed. Note that this creates a new handle which is not │ │ │ │ +equal to the removed one. │ │ │ │ +The optional second argument options can be used to delete all the files │ │ │ │ +downloaded by this torrent. To do so, pass in the value session_handle:: │ │ │ │ +delete_files. Once the torrent is deleted, a _t_o_r_r_e_n_t___d_e_l_e_t_e_d___a_l_e_r_t is posted. │ │ │ │ +The _t_o_r_r_e_n_t___h_a_n_d_l_e remains valid for some time after _r_e_m_o_v_e___t_o_r_r_e_n_t_(_) is │ │ │ │ +called. It will become invalid only after all libtorrent tasks (such as I/ │ │ │ │ +O tasks) release their references to the torrent. Until this happens, │ │ │ │ +_t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_i_s___v_a_l_i_d_(_) will return true, and other calls such as │ │ │ │ +_t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_t_a_t_u_s_(_) will succeed. Because of this, and because │ │ │ │ +_r_e_m_o_v_e___t_o_r_r_e_n_t_(_) is non-blocking, the following sequence usually succeeds (does │ │ │ │ +not throw system_error): .. code:: c++ │ │ │ │ + session.remove_handle(handle); handle.save_resume_data(); │ │ │ │ +Note that when a queued or downloading torrent is removed, its position in the │ │ │ │ +download queue is vacated and every subsequent torrent in the queue has their │ │ │ │ +queue positions updated. This can potentially cause a large state_update to be │ │ │ │ +posted. When removing all torrents, it is advised to remove them from the back │ │ │ │ +of the queue, to minimize the shifting. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - have_pieces │ │ │ │ - this is a _b_i_t_f_i_e_l_d indicating which pieces we already have of this │ │ │ │ - torrent. │ │ │ │ +********** ggeett__sseettttiinnggss(()) aappppllyy__sseettttiinnggss(()) ********** │ │ │ │ +settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ +void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ +void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ +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] │ │ │ │ - verified_pieces │ │ │ │ - when in seed_mode, pieces with a set bit in this _b_i_t_f_i_e_l_d have been │ │ │ │ - verified to be valid. Other pieces will be verified the first time a peer │ │ │ │ - requests it. │ │ │ │ +********** ppoopp__aalleerrttss(()) wwaaiitt__ffoorr__aalleerrtt(()) sseett__aalleerrtt__nnoottiiffyy(()) ********** │ │ │ │ +bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ +void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ +void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ +Alerts is the main mechanism for libtorrent to report errors and events. │ │ │ │ +pop_alerts fills in the vector passed to it with pointers to new alerts. The │ │ │ │ +_s_e_s_s_i_o_n still owns these alerts and they will stay valid until the next time │ │ │ │ +pop_alerts is called. You may not delete the _a_l_e_r_t objects. │ │ │ │ +It is safe to call pop_alerts from multiple different threads, as long as the │ │ │ │ +alerts themselves are not accessed once another thread calls pop_alerts. Doing │ │ │ │ +this requires manual synchronization between the popping threads. │ │ │ │ +wait_for_alert will block the current thread for max_wait time duration, or │ │ │ │ +until another _a_l_e_r_t is posted. If an _a_l_e_r_t is already available at the time of │ │ │ │ +the call, it returns immediately. It returns true if an _a_l_e_r_t is pending (i.e. │ │ │ │ +a subsequent pop_alerts call would return at least one _a_l_e_r_t), and false if the │ │ │ │ +timeout expired with no _a_l_e_r_t available. │ │ │ │ +In TORRENT_ABI_VERSION < 4 the return type is alert* for backwards │ │ │ │ +compatibility; the returned pointer is non-null when an _a_l_e_r_t is pending and │ │ │ │ +null on timeout, but it does not point at any real _a_l_e_r_t (it is a placeholder) │ │ │ │ +and must not be dereferenced. Use pop_alerts to retrieve the actual alerts. │ │ │ │ +In the python binding, wait_for_alert takes the number of milliseconds to wait │ │ │ │ +as an integer and returns a bool. │ │ │ │ +The _a_l_e_r_t queue in the _s_e_s_s_i_o_n will not grow indefinitely. Make sure to pop │ │ │ │ +periodically to not miss notifications. To control the max number of alerts │ │ │ │ +that's queued by the _s_e_s_s_i_o_n, see settings_pack::alert_queue_size. │ │ │ │ +Some alerts are considered so important that they are posted even when the │ │ │ │ +_a_l_e_r_t queue is full. Some alerts are considered mandatory and cannot be │ │ │ │ +disabled by the alert_mask. For instance, _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t and │ │ │ │ +_s_a_v_e___r_e_s_u_m_e___d_a_t_a___f_a_i_l_e_d___a_l_e_r_t are always posted, regardless of the _a_l_e_r_t mask. │ │ │ │ +To control which alerts are posted, set the alert_mask (_s_e_t_t_i_n_g_s___p_a_c_k_:_: │ │ │ │ +_a_l_e_r_t___m_a_s_k). │ │ │ │ +If the _a_l_e_r_t queue fills up to the point where alerts are dropped, this will be │ │ │ │ +indicated by a _a_l_e_r_t_s___d_r_o_p_p_e_d___a_l_e_r_t, which contains a bitmask of which types of │ │ │ │ +alerts were dropped. Generally it is a good idea to make sure the _a_l_e_r_t queue │ │ │ │ +is large enough, the alert_mask doesn't have unnecessary categories enabled and │ │ │ │ +to call pop_alert() frequently, to avoid alerts being dropped. │ │ │ │ +the set_alert_notify function lets the client set a function object to be │ │ │ │ +invoked every time the _a_l_e_r_t queue goes from having 0 alerts to 1 _a_l_e_r_t. This │ │ │ │ +function is called from within libtorrent, it may be the main thread, or it may │ │ │ │ +be from within a user call. The intention of of the function is that the client │ │ │ │ +wakes up its main thread, to poll for more alerts using pop_alerts(). If the │ │ │ │ +notify function fails to do so, it won't be called again, until pop_alerts is │ │ │ │ +called for some other reason. For instance, it could signal an eventfd, post a │ │ │ │ +message to an HWND or some other main message pump. The actual retrieval of │ │ │ │ +alerts should not be done in the callback. In fact, the callback should not │ │ │ │ +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] │ │ │ │ - piece_priorities │ │ │ │ - this sets the priorities for each individual piece in the torrent. Each │ │ │ │ - element in the vector represent the piece with the same index. If you set │ │ │ │ - both file- and piece priorities, file priorities will take precedence. │ │ │ │ +********** aadddd__ppoorrtt__mmaappppiinngg(()) ddeelleettee__ppoorrtt__mmaappppiinngg(()) ********** │ │ │ │ +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] │ │ │ │ - merkle_trees │ │ │ │ - v2 hashes, if known │ │ │ │ +********** rreeooppeenn__nneettwwoorrkk__ssoocckkeettss(()) ********** │ │ │ │ +void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ +reopen_map_ports); │ │ │ │ +Instructs the _s_e_s_s_i_o_n to reopen all listen and outgoing sockets. │ │ │ │ +It's useful in the case your platform doesn't support the built in IP notifier │ │ │ │ +mechanism, or if you have a better more reliable way to detect changes in the │ │ │ │ +IP routing table. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - merkle_tree_mask │ │ │ │ - if set, indicates which hashes are included in the corresponding vector │ │ │ │ - of merkle_trees. These bitmasks always cover the full tree, a cleared bit │ │ │ │ - means the hash is all zeros (i.e. not set) and set bit means the next │ │ │ │ - hash in the corresponding vector in merkle_trees is the hash for that │ │ │ │ - node. This is an optimization to avoid storing a lot of zeros. │ │ │ │ +********** nnaattiivvee__hhaannddllee(()) ********** │ │ │ │ +std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ +This function is intended only for use by plugins. This type does not have a │ │ │ │ +stable API and should be relied on as little as possible. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - verified_leaf_hashes │ │ │ │ - bit-fields indicating which v2 leaf hashes have been verified against the │ │ │ │ - root hash. If this vector is empty and merkle_trees is non-empty it │ │ │ │ - implies that all hashes in merkle_trees are verified. │ │ │ │ + save_settings │ │ │ │ + saves settings (i.e. the _s_e_t_t_i_n_g_s___p_a_c_k) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - renamed_files │ │ │ │ - this is a map of file indices in the torrent and new _f_i_l_e_n_a_m_e_s to be │ │ │ │ - applied before the torrent is added. │ │ │ │ + save_dht_state │ │ │ │ + saves dht state such as nodes and node-id, possibly accelerating joining │ │ │ │ + the DHT if provided at next _s_e_s_s_i_o_n startup. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - last_download last_upload │ │ │ │ - the posix time of the last time payload was received or sent for this │ │ │ │ - torrent, respectively. A value of 0 means we don't know when we last │ │ │ │ - uploaded or downloaded, or we have never uploaded or downloaded any │ │ │ │ - payload for this torrent. │ │ │ │ + save_extension_state │ │ │ │ + load or save state from plugins │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - comment │ │ │ │ - if a comment is found in the torrent file this will be set to that │ │ │ │ - comment │ │ │ │ + save_ip_filter │ │ │ │ + load or save the IP filter set on the _s_e_s_s_i_o_n │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - created_by │ │ │ │ - an optional string naming the software used to create the torrent file │ │ │ │ + global_peer_class_id tcp_peer_class_id local_peer_class_id │ │ │ │ + built-in peer classes │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - creation_date │ │ │ │ - if a creation date is found in the torrent file this will be set to that, │ │ │ │ - otherwise it'll be 1970, Jan 1 │ │ │ │ + delete_files │ │ │ │ + delete the files belonging to the torrent from disk. including the part- │ │ │ │ + file, if there is one │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - root_certificate │ │ │ │ - If this torrent is an infohash only SSL torrent, specify the root │ │ │ │ - certificate here. If a peer does not have a matching certificate during │ │ │ │ - metadata exchange it will be rejected and the download will not proceed. │ │ │ │ + delete_partfile │ │ │ │ + delete just the part-file associated with this torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__ccllaassss__iinnffoo ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_l_a_s_s_._h_p_p" │ │ │ │ -holds settings for a peer class. Used in _s_e_t___p_e_e_r___c_l_a_s_s_(_) and _g_e_t___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ -calls. │ │ │ │ -struct peer_class_info │ │ │ │ + paused │ │ │ │ + when set, the _s_e_s_s_i_o_n will start paused. Call _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_r_e_s_u_m_e_(_) to │ │ │ │ + start │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + udp tcp │ │ │ │ + protocols used by _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + reopen_map_ports │ │ │ │ + This option indicates if the ports are mapped using natpmp and upnp. If │ │ │ │ + mapping was already made, they are deleted and added again. This only │ │ │ │ + works if natpmp and/or upnp are configured to be enable. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ wwrriittee__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss__bbuuff(()) rreeaadd__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" │ │ │ │ +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 │ │ │ │ + , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ +entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ + , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ +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 │ │ │ │ +_s_e_s_s_i_o_n are not part of the _s_e_s_s_i_o_n___p_a_r_a_m_s state, they have to be restored │ │ │ │ +separately. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ llooaadd__ttoorrrreenntt__lliimmiittss ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___i_n_f_o_._h_p_p" │ │ │ │ +this object holds configuration options for limits to use when loading │ │ │ │ +torrents. They are meant to prevent loading potentially malicious torrents that │ │ │ │ +cause excessive memory allocations. │ │ │ │ +struct load_torrent_limits │ │ │ │ { │ │ │ │ - bool ignore_unchoke_slots; │ │ │ │ - int connection_limit_factor; │ │ │ │ - std::string label; │ │ │ │ - int upload_limit; │ │ │ │ - int download_limit; │ │ │ │ - int upload_priority; │ │ │ │ - int download_priority; │ │ │ │ + int mmaaxx__bbuuffffeerr__ssiizzee = 10000000; │ │ │ │ + int mmaaxx__ppiieecceess = 0x200000; │ │ │ │ + int mmaaxx__ddeeccooddee__ddeepptthh = 100; │ │ │ │ + int mmaaxx__ddeeccooddee__ttookkeennss = 3000000; │ │ │ │ + int mmaaxx__dduupplliiccaattee__ffiilleennaammeess = 500; │ │ │ │ + int mmaaxx__ddiirreeccttoorryy__ddeepptthh = 100; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - ignore_unchoke_slots │ │ │ │ - ignore_unchoke_slots determines whether peers should always unchoke a │ │ │ │ - peer, regardless of the choking algorithm, or if it should honor the │ │ │ │ - unchoke slot limits. It's used for local peers by default. If aannyy of the │ │ │ │ - peer classes a peer belongs to has this set to true, that peer will be │ │ │ │ - unchoked at all times. │ │ │ │ + max_buffer_size │ │ │ │ + the max size of a .torrent file to load into RAM │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - connection_limit_factor │ │ │ │ - adjusts the connection limit (global and per torrent) that applies to │ │ │ │ - this peer class. By default, local peers are allowed to exceed the normal │ │ │ │ - connection limit for instance. This is specified as a percent factor. 100 │ │ │ │ - makes the peer class apply normally to the limit. 200 means as long as │ │ │ │ - there are fewer connections than twice the limit, we accept this peer. │ │ │ │ - This factor applies both to the global connection limit and the per- │ │ │ │ - torrent limit. Note that if not used carefully one peer class can │ │ │ │ - potentially completely starve out all other over time. │ │ │ │ + max_pieces │ │ │ │ + the max number of pieces allowed in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - label │ │ │ │ - not used by libtorrent. It's intended as a potentially user-facing │ │ │ │ - identifier of this peer class. │ │ │ │ + max_decode_depth │ │ │ │ + the max recursion depth in the bdecoded structure │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - upload_limit download_limit │ │ │ │ - transfer rates limits for the whole peer class. They are specified in │ │ │ │ - bytes per second and apply to the sum of all peers that are members of │ │ │ │ - this class. │ │ │ │ + max_decode_tokens │ │ │ │ + the max number of bdecode tokens │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - upload_priority download_priority │ │ │ │ - relative priorities used by the bandwidth allocator in the rate limiter. │ │ │ │ - If no rate limits are in use, the priority is not used either. Priorities │ │ │ │ - start at 1 (0 is not a valid priority) and may not exceed 255. │ │ │ │ + max_duplicate_filenames │ │ │ │ + the max number of files with same filename allowed in the torrent. Files │ │ │ │ + with the same filename are disambiguated by appending a counter. This │ │ │ │ + operation is not cheap and a malicious torrent may pose a DoS attack, │ │ │ │ + stalling torrent parsing. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_._h_p_p" │ │ │ │ -peer_class_type_filter is a simple container for rules for adding and │ │ │ │ -subtracting peer-classes from peers. It is applied aafftteerr the peer class filter │ │ │ │ -is applied (which is based on the peer's IP address). │ │ │ │ -struct peer_class_type_filter │ │ │ │ + max_directory_depth │ │ │ │ + the max depth of the directory structure of files in the torrent. It │ │ │ │ + protects against malicious torrents with a deeply nested directory │ │ │ │ + structure. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttoorrrreenntt__iinnffoo ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___i_n_f_o_._h_p_p" │ │ │ │ +the _t_o_r_r_e_n_t___i_n_f_o class holds the information found in a .torrent file. │ │ │ │ +class torrent_info │ │ │ │ { │ │ │ │ - void rreemmoovvee (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ - void aadddd (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ - void aallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ - void ddiissaallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ - std::uint32_t aappppllyy (socket_type_t const st, std::uint32_t peer_class_mask); │ │ │ │ - friend bool ooppeerraattoorr==== (peer_class_type_filter const& lhs │ │ │ │ - , peer_class_type_filter const& rhs); │ │ │ │ - │ │ │ │ - enum socket_type_t │ │ │ │ - { │ │ │ │ - tcp_socket, │ │ │ │ - utp_socket, │ │ │ │ - ssl_tcp_socket, │ │ │ │ - ssl_utp_socket, │ │ │ │ - i2p_socket, │ │ │ │ - rtc_socket, │ │ │ │ - num_socket_types, │ │ │ │ - }; │ │ │ │ + explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ + ttoorrrreenntt__iinnffoo (torrent_info const& t); │ │ │ │ + ttoorrrreenntt__iinnffoo (bdecode_node const& info_section, error_code& ec │ │ │ │ + , load_torrent_limits const& cfg │ │ │ │ + , from_info_section_t); │ │ │ │ + ~~ttoorrrreenntt__iinnffoo (); │ │ │ │ + file_storage const& llaayyoouutt () const; │ │ │ │ + std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ + std::vector ccoolllleeccttiioonnss () const; │ │ │ │ + std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ + std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ + int ppiieeccee__lleennggtthh () const; │ │ │ │ + int nnuumm__ppiieecceess () const; │ │ │ │ + int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ + piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ + index_range ppiieeccee__rraannggee () const; │ │ │ │ + piece_index_t eenndd__ppiieeccee () const; │ │ │ │ + sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ + info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ + bool vv11 () const; │ │ │ │ + bool vv22 () const; │ │ │ │ + int nnuumm__ffiilleess () const; │ │ │ │ + std::vector mmaapp__bblloocckk (piece_index_t const piece │ │ │ │ + , std::int64_t offset, int size) const; │ │ │ │ + peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t offset, int │ │ │ │ +size) const; │ │ │ │ + string_view ssssll__cceerrtt () const; │ │ │ │ + bool iiss__vvaalliidd () const; │ │ │ │ + bool pprriivv () const; │ │ │ │ + bool iiss__ii22pp () const; │ │ │ │ + int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ + int ppiieeccee__ssiizzee__ffoorr__rreeqq (piece_index_t index) const; │ │ │ │ + sha1_hash hhaasshh__ffoorr__ppiieeccee (piece_index_t index) const; │ │ │ │ + char const* hhaasshh__ffoorr__ppiieeccee__ppttrr (piece_index_t const index) const; │ │ │ │ + bool iiss__llooaaddeedd () const; │ │ │ │ + const std::string& nnaammee () const; │ │ │ │ + span iinnffoo__sseeccttiioonn () const; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreemmoovvee(()) aadddd(()) ********** │ │ │ │ -void rreemmoovvee (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ -void aadddd (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ -add() and remove() adds and removes a peer class to be added to new peers based │ │ │ │ -on socket type. │ │ │ │ +********** ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ +explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ +constructs an empty torrent_info containing only an info-hash. Useful for │ │ │ │ +magnet links: the resulting object has no metadata (no file list, no piece │ │ │ │ +hashes) but the info-hash is set so it can be passed to session::add_torrent(). │ │ │ │ +This object is not filled in once metadata is received from peers. The torrent │ │ │ │ +installs a new torrent_info instance internally rather than updating this one. │ │ │ │ +Retrieve the populated metadata via torrent_handle::torrent_file(). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aallllooww(()) ddiissaallllooww(()) ********** │ │ │ │ -void aallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ -void ddiissaallllooww (socket_type_t const st, peer_class_t const peer_class); │ │ │ │ -disallow() and allow() adds and removes a peer class to be removed from new │ │ │ │ -peers based on socket type. │ │ │ │ -The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ │ -peer classes in the peer_class_type_filter are 32 bits. │ │ │ │ +********** ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ +ttoorrrreenntt__iinnffoo (bdecode_node const& info_section, error_code& ec │ │ │ │ + , load_torrent_limits const& cfg │ │ │ │ + , from_info_section_t); │ │ │ │ +Construct a _t_o_r_r_e_n_t___i_n_f_o object from the parsed info-section pointed to │ │ │ │ +byinfo_section. The info-section buffer will be copied into _t_o_r_r_e_n_t___i_n_f_o. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aappppllyy(()) ********** │ │ │ │ -std::uint32_t aappppllyy (socket_type_t const st, std::uint32_t peer_class_mask); │ │ │ │ -takes a bitmask of peer classes and returns a new bitmask of peer classes after │ │ │ │ -the rules have been applied, based on the socket type argument (st). │ │ │ │ +********** ~~ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ +~~ttoorrrreenntt__iinnffoo (); │ │ │ │ +frees all storage associated with this _t_o_r_r_e_n_t___i_n_f_o object │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ssoocckkeett__ttyyppee__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_._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___s_o_c_k_e_t_ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_t_p___s_o_c_k_e_t_ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_s_l___t_c_p___s_o_c_k_e_t_ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_s_l___u_t_p___s_o_c_k_e_t_ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_2_p___s_o_c_k_e_t_ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_t_c___s_o_c_k_e_t_ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_u_m___s_o_c_k_e_t___t_y_p_e_s_|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** llaayyoouutt(()) ********** │ │ │ │ +file_storage const& llaayyoouutt () const; │ │ │ │ +The _f_i_l_e___s_t_o_r_a_g_e object contains the information on how to map the pieces to │ │ │ │ +files. It is separated from the _t_o_r_r_e_n_t___i_n_f_o object as the disk I/O subsystem │ │ │ │ +only needs access to file names and sizes. The _f_i_l_e___s_t_o_r_a_g_e object is │ │ │ │ +immutable, renamed files are recorded separately. layout() returns the original │ │ │ │ +_f_i_l_e_n_a_m_e_s, as found in the .torrent file. Files may be renamed to de-duplicate │ │ │ │ +names, or to correct invalid _f_i_l_e_n_a_m_e_s. │ │ │ │ +For more information on the _f_i_l_e___s_t_o_r_a_g_e object, see the separate document on │ │ │ │ +how to create torrents. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ccoolllleeccttiioonnss(()) ssiimmiillaarr__ttoorrrreennttss(()) ********** │ │ │ │ +std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ +std::vector ccoolllleeccttiioonnss () const; │ │ │ │ +These two functions are related to _B_E_P_ _3_8 (mutable torrents). The vectors │ │ │ │ +returned from these correspond to the "similar" and "collections" keys in the │ │ │ │ +.torrent file. Both info-hashes and collections from within the info-dict and │ │ │ │ +from outside of it are included. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ttoottaall__ssiizzee(()) ********** │ │ │ │ +std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ +total_size() returns the total number of bytes the torrent-file represents. │ │ │ │ +Note that this is the number of pieces times the piece size (modulo the last │ │ │ │ +piece possibly being smaller). With pad files, the total size will be larger │ │ │ │ +than the sum of all (regular) file sizes. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ssiizzee__oonn__ddiisskk(()) ********** │ │ │ │ +std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ +returns the sum of all non-pad file sizes. i.e. the files that will actually be │ │ │ │ +saved to disk by this torrent. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** nnuumm__ppiieecceess(()) ppiieeccee__lleennggtthh(()) ********** │ │ │ │ +int ppiieeccee__lleennggtthh () const; │ │ │ │ +int nnuumm__ppiieecceess () const; │ │ │ │ +piece_length() and num_pieces() returns the number of byte for each piece and │ │ │ │ +the total number of pieces, respectively. The difference between piece_size() │ │ │ │ +and piece_length() is that piece_size() takes the piece index as argument and │ │ │ │ +gives you the exact size of that piece. It will always be the same as │ │ │ │ +piece_length() except in the case of the last piece, which may be smaller. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** bblloocckkss__ppeerr__ppiieeccee(()) ********** │ │ │ │ +int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ +returns the number of blocks there are in the typical piece. There may be fewer │ │ │ │ +in the last piece) │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** llaasstt__ppiieeccee(()) eenndd__ppiieeccee(()) ppiieeccee__rraannggee(()) ********** │ │ │ │ +piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ +index_range ppiieeccee__rraannggee () const; │ │ │ │ +piece_index_t eenndd__ppiieeccee () const; │ │ │ │ +last_piece() returns the index to the last piece in the torrent and end_piece() │ │ │ │ +returns the index to the one-past-end piece in the torrent piece_range() │ │ │ │ +returns an implementation-defined type that can be used as the container in a │ │ │ │ +range-for loop. Where the values are the indices of all pieces in the │ │ │ │ +_f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) ********** │ │ │ │ +sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ +info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ +returns the info-hash of the torrent. For BitTorrent v2 support, use │ │ │ │ +info_hashes() to get an object that may hold both a v1 and v2 info-hash │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** vv11(()) vv22(()) ********** │ │ │ │ +bool vv11 () const; │ │ │ │ +bool vv22 () const; │ │ │ │ +returns whether this torrent has v1 and/or v2 metadata, respectively. Hybrid │ │ │ │ +torrents have both. These are shortcuts for info_hashes().has_v1() and │ │ │ │ +info_hashes().has_v2() calls. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** nnuumm__ffiilleess(()) ********** │ │ │ │ +int nnuumm__ffiilleess () const; │ │ │ │ +If you need index-access to files you can use the num_files() along with the │ │ │ │ +file_path(), file_size()-family of functions to access files using indices. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** mmaapp__bblloocckk(()) ********** │ │ │ │ +std::vector mmaapp__bblloocckk (piece_index_t const piece │ │ │ │ + , std::int64_t offset, int size) const; │ │ │ │ +This function will map a piece index, a byte offset within that piece and a │ │ │ │ +size (in bytes) into the corresponding files with offsets where that data for │ │ │ │ +that piece is supposed to be stored. See _f_i_l_e___s_l_i_c_e. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** mmaapp__ffiillee(()) ********** │ │ │ │ +peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t offset, int size) │ │ │ │ +const; │ │ │ │ +This function will map a range in a specific file into a range in the torrent. │ │ │ │ +The file_offset parameter is the offset in the file, given in bytes, where 0 is │ │ │ │ +the start of the file. See _p_e_e_r___r_e_q_u_e_s_t. │ │ │ │ +The input range is assumed to be valid within the torrent. file_offset + size │ │ │ │ +is not allowed to be greater than the file size. file_index must refer to a │ │ │ │ +valid file, i.e. it cannot be >= num_files(). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ssssll__cceerrtt(()) ********** │ │ │ │ +string_view ssssll__cceerrtt () const; │ │ │ │ +Returns the SSL root certificate for the torrent, if it is an SSL torrent. │ │ │ │ +Otherwise returns an empty string. The certificate is the public certificate in │ │ │ │ +x509 format. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iiss__vvaalliidd(()) ********** │ │ │ │ +bool iiss__vvaalliidd () const; │ │ │ │ +returns true if this _t_o_r_r_e_n_t___i_n_f_o object has a torrent loaded. This is │ │ │ │ +primarily used to determine if a magnet link has had its metadata resolved yet │ │ │ │ +or not. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** pprriivv(()) ********** │ │ │ │ +bool pprriivv () const; │ │ │ │ +returns true if this torrent is private. i.e., the client should not advertise │ │ │ │ +itself on the trackerless network (the Kademlia DHT) for this torrent. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iiss__ii22pp(()) ********** │ │ │ │ +bool iiss__ii22pp () const; │ │ │ │ +returns true if this is an i2p torrent. This is determined by whether or not it │ │ │ │ +has a tracker whose URL domain name ends with ".i2p". i2p torrents disable the │ │ │ │ +DHT and local peer discovery as well as talking to peers over anything other │ │ │ │ +than the i2p network. This is not reliably set for torrents created via resume │ │ │ │ +data or magnet links. Prefer using torrent::is_i2p() instead. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ppiieeccee__ssiizzee(()) ********** │ │ │ │ +int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ +returns the piece size of file with index. This will be the same as │ │ │ │ +_p_i_e_c_e___l_e_n_g_t_h_(_), except for the last piece, which may be shorter. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ppiieeccee__ssiizzee__ffoorr__rreeqq(()) ********** │ │ │ │ +int ppiieeccee__ssiizzee__ffoorr__rreeqq (piece_index_t index) const; │ │ │ │ +returns the piece size appropriate for computing request lengths. for v2-only │ │ │ │ +torrents, pieces at the end of files may be shorter than the main piece size. │ │ │ │ +For v1 and hybrid torrents, piece sizes must be full (except for the last │ │ │ │ +piece) in order to correctly compute the piece hash. Note: this is not a │ │ │ │ +trivial accessor. For v2-only torrents it calls _f_i_l_e___s_t_o_r_a_g_e_:_:_p_i_e_c_e___s_i_z_e_2_(_), │ │ │ │ +which performs an O(log n) upper_bound over the file list to find the file │ │ │ │ +boundary that may shorten the piece. Cache the result when calling it │ │ │ │ +repeatedly for the same piece in a hot path. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaasshh__ffoorr__ppiieeccee(()) hhaasshh__ffoorr__ppiieeccee__ppttrr(()) ********** │ │ │ │ +sha1_hash hhaasshh__ffoorr__ppiieeccee (piece_index_t index) const; │ │ │ │ +char const* hhaasshh__ffoorr__ppiieeccee__ppttrr (piece_index_t const index) const; │ │ │ │ +hash_for_piece() takes a piece-index and returns the 20-bytes sha1-hash for │ │ │ │ +that piece. hash_for_piece_ptr() returns a pointer to the 20 byte sha1 digest │ │ │ │ +for the piece. Note that the string is not 0-terminated. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iiss__llooaaddeedd(()) ********** │ │ │ │ +bool iiss__llooaaddeedd () const; │ │ │ │ +returns true if the metadata for this torrent has been loaded (i.e. the file │ │ │ │ +list is populated). For a torrent_info constructed from just an info-hash this │ │ │ │ +returns false. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** nnaammee(()) ********** │ │ │ │ +const std::string& nnaammee () const; │ │ │ │ +name() returns the name of the torrent. name contains UTF-8 encoded string. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iinnffoo__sseeccttiioonn(()) ********** │ │ │ │ +span iinnffoo__sseeccttiioonn () const; │ │ │ │ +returns a the raw info section of the torrent file. The underlying buffer is │ │ │ │ +still owned by the _t_o_r_r_e_n_t___i_n_f_o object │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ bblloocckk__iinnffoo ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___h_a_n_d_l_e_._h_p_p" │ │ │ │ holds the state of a block in a piece. Who we requested it from and how far │ │ │ │ along we are at downloading it. │ │ │ │ struct block_info │ │ │ │ { │ │ │ │ @@ -5185,15 +8518,15 @@ │ │ │ │ │ │ │ │ std::uint16_t num_peers:15; │ │ │ │ std::uint32_t bytes_progress:15; │ │ │ │ std::uint32_t block_size:15; │ │ │ │ std::uint32_t state:2; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ppeeeerr(()) ppeeeerr(()) ********** │ │ │ │ +********** ppeeeerr(()) sseett__ppeeeerr(()) ********** │ │ │ │ _t_c_p_:_:_e_n_d_p_o_i_n_t ppeeeerr () const; │ │ │ │ void sseett__ppeeeerr (tcp::endpoint const& ep); │ │ │ │ The peer is the ip address of the peer this block was downloaded from. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** eennuumm bblloocckk__ssttaattee__tt ********** │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___h_a_n_d_l_e_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ @@ -5283,127 +8616,127 @@ │ │ │ │ the handle is no longer referring to a torrent. There is one exception _i_s___v_a_l_i_d │ │ │ │ _(_) will never throw. Since the torrents are processed by a background thread, │ │ │ │ there is no guarantee that a handle will remain valid between two calls. │ │ │ │ struct torrent_handle │ │ │ │ { │ │ │ │ friend std::size_t hhaasshh__vvaalluuee (torrent_handle const& th); │ │ │ │ ttoorrrreenntt__hhaannddllee () noexcept = default; │ │ │ │ - void aadddd__ppiieeccee (piece_index_t piece, char const* data, add_piece_flags_t │ │ │ │ -flags = {}) const; │ │ │ │ void aadddd__ppiieeccee (piece_index_t piece, std::vector data, │ │ │ │ add_piece_flags_t flags = {}) const; │ │ │ │ + void aadddd__ppiieeccee (piece_index_t piece, char const* data, add_piece_flags_t │ │ │ │ +flags = {}) const; │ │ │ │ void rreeaadd__ppiieeccee (piece_index_t piece) const; │ │ │ │ void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece) const; │ │ │ │ void sseett__sseeqquueennttiiaall__rraannggee (piece_index_t first_piece, piece_index_t │ │ │ │ last_piece) const; │ │ │ │ bool hhaavvee__ppiieeccee (piece_index_t piece) const; │ │ │ │ - void ppoosstt__ppeeeerr__iinnffoo () const; │ │ │ │ void ggeett__ppeeeerr__iinnffoo (std::vector& v) const; │ │ │ │ + void ppoosstt__ppeeeerr__iinnffoo () const; │ │ │ │ void ppoosstt__ssttaattuuss (status_flags_t flags = status_flags_t::all()) const; │ │ │ │ torrent_status ssttaattuuss (status_flags_t flags = status_flags_t::all()) const; │ │ │ │ - std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const; │ │ │ │ void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const; │ │ │ │ void ggeett__ddoowwnnllooaadd__qquueeuuee (std::vector& queue) const; │ │ │ │ - void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const; │ │ │ │ - void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const; │ │ │ │ + std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const; │ │ │ │ void sseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index, int deadline, deadline_flags_t │ │ │ │ flags = {}) const; │ │ │ │ + void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const; │ │ │ │ + void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const; │ │ │ │ void ppoosstt__ffiillee__pprrooggrreessss (file_progress_flags_t flags) const; │ │ │ │ std::vector ffiillee__pprrooggrreessss (file_progress_flags_t flags = {}) │ │ │ │ const; │ │ │ │ void ffiillee__pprrooggrreessss (std::vector& progress, │ │ │ │ file_progress_flags_t flags = {}) const; │ │ │ │ - void ppoosstt__ffiillee__ssttaattuuss () const; │ │ │ │ std::vector ffiillee__ssttaattuuss () const; │ │ │ │ + void ppoosstt__ffiillee__ssttaattuuss () const; │ │ │ │ void cclleeaarr__eerrrroorr () const; │ │ │ │ - void aadddd__ttrraacckkeerr (announce_entry const&) const; │ │ │ │ - void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const; │ │ │ │ void ppoosstt__ttrraacckkeerrss () const; │ │ │ │ std::vector ttrraacckkeerrss () const; │ │ │ │ + void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const; │ │ │ │ + void aadddd__ttrraacckkeerr (announce_entry const&) const; │ │ │ │ + std::set uurrll__sseeeeddss () const; │ │ │ │ void aadddd__uurrll__sseeeedd (std::string const& url) const; │ │ │ │ void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const; │ │ │ │ - std::set uurrll__sseeeeddss () const; │ │ │ │ void aadddd__eexxtteennssiioonn ( │ │ │ │ std::function(torrent_handle const&, │ │ │ │ client_data_t)> const& ext │ │ │ │ , client_data_t userdata = client_data_t{}); │ │ │ │ bool sseett__mmeettaaddaattaa (span metadata) const; │ │ │ │ bool iiss__vvaalliidd () const; │ │ │ │ - void ppaauussee (pause_flags_t flags = {}) const; │ │ │ │ void rreessuummee () const; │ │ │ │ - void sseett__ffllaaggss (torrent_flags_t flags) const; │ │ │ │ + void ppaauussee (pause_flags_t flags = {}) const; │ │ │ │ torrent_flags_t ffllaaggss () const; │ │ │ │ void uunnsseett__ffllaaggss (torrent_flags_t flags) const; │ │ │ │ void sseett__ffllaaggss (torrent_flags_t flags, torrent_flags_t mask) const; │ │ │ │ + void sseett__ffllaaggss (torrent_flags_t flags) const; │ │ │ │ void fflluusshh__ccaacchhee () const; │ │ │ │ void ffoorrccee__rreecchheecckk () const; │ │ │ │ add_torrent_params ggeett__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const; │ │ │ │ void ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const; │ │ │ │ bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const; │ │ │ │ bool nneeeedd__ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags) const; │ │ │ │ - void qquueeuuee__ppoossiittiioonn__ttoopp () const; │ │ │ │ - void qquueeuuee__ppoossiittiioonn__bboottttoomm () const; │ │ │ │ - void qquueeuuee__ppoossiittiioonn__ddoowwnn () const; │ │ │ │ queue_position_t qquueeuuee__ppoossiittiioonn () const; │ │ │ │ + void qquueeuuee__ppoossiittiioonn__ddoowwnn () const; │ │ │ │ + void qquueeuuee__ppoossiittiioonn__bboottttoomm () const; │ │ │ │ void qquueeuuee__ppoossiittiioonn__uupp () const; │ │ │ │ + void qquueeuuee__ppoossiittiioonn__ttoopp () const; │ │ │ │ void qquueeuuee__ppoossiittiioonn__sseett (queue_position_t p) const; │ │ │ │ - void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate │ │ │ │ - , std::string const& private_key │ │ │ │ - , std::string const& dh_params); │ │ │ │ void sseett__ssssll__cceerrttiiffiiccaattee (std::string const& certificate │ │ │ │ , std::string const& private_key │ │ │ │ , std::string const& dh_params │ │ │ │ , std::string const& passphrase = ""); │ │ │ │ + void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate │ │ │ │ + , std::string const& private_key │ │ │ │ + , std::string const& dh_params); │ │ │ │ std::shared_ptr ttoorrrreenntt__ffiillee () const; │ │ │ │ renamed_files ggeett__rreennaammeedd__ffiilleess () const; │ │ │ │ std::vector> ppiieeccee__llaayyeerrss () const; │ │ │ │ void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const; │ │ │ │ void ppiieeccee__aavvaaiillaabbiilliittyy (std::vector& avail) const; │ │ │ │ - void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority) │ │ │ │ -const; │ │ │ │ std::vector ggeett__ppiieeccee__pprriioorriittiieess () const; │ │ │ │ void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces) │ │ │ │ const; │ │ │ │ + download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const; │ │ │ │ void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const; │ │ │ │ - download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const; │ │ │ │ + void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority) │ │ │ │ +const; │ │ │ │ + std::vector ggeett__ffiillee__pprriioorriittiieess () const; │ │ │ │ void pprriioorriittiizzee__ffiilleess (std::vector const& files) const; │ │ │ │ void ffiillee__pprriioorriittyy (file_index_t index, download_priority_t priority) const; │ │ │ │ - std::vector ggeett__ffiillee__pprriioorriittiieess () const; │ │ │ │ download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const; │ │ │ │ void ppoosstt__ffiillee__pprriioorriittiieess () const; │ │ │ │ + void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const; │ │ │ │ void ffoorrccee__rreeaannnnoouunnccee (int seconds = 0, reannounce_flags_t = {}) const; │ │ │ │ void ffoorrccee__llssdd__aannnnoouunnccee () const; │ │ │ │ - void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const; │ │ │ │ + void ffoorrccee__ddhhtt__aannnnoouunnccee () const; │ │ │ │ void ffoorrccee__rreeaannnnoouunnccee (int seconds, std::string const& url, │ │ │ │ reannounce_flags_t = {}) const; │ │ │ │ - void ffoorrccee__ddhhtt__aannnnoouunnccee () const; │ │ │ │ - void ssccrraappee__ttrraacckkeerr () const; │ │ │ │ void ssccrraappee__ttrraacckkeerr (int idx) const; │ │ │ │ + void ssccrraappee__ttrraacckkeerr () const; │ │ │ │ void ssccrraappee__ttrraacckkeerr (std::string url) const; │ │ │ │ int uuppllooaadd__lliimmiitt () const; │ │ │ │ - int ddoowwnnllooaadd__lliimmiitt () const; │ │ │ │ void sseett__uuppllooaadd__lliimmiitt (int limit) const; │ │ │ │ + int ddoowwnnllooaadd__lliimmiitt () const; │ │ │ │ void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const; │ │ │ │ void ccoonnnneecctt__ppeeeerr (tcp::endpoint const& adr, peer_source_flags_t source = {} │ │ │ │ , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const; │ │ │ │ void cclleeaarr__ppeeeerrss (); │ │ │ │ void sseett__mmaaxx__uuppllooaaddss (int max_uploads) const; │ │ │ │ int mmaaxx__uuppllooaaddss () const; │ │ │ │ void sseett__mmaaxx__ccoonnnneeccttiioonnss (int max_connections) const; │ │ │ │ int mmaaxx__ccoonnnneeccttiioonnss () const; │ │ │ │ void mmoovvee__ssttoorraaggee (std::string const& save_path │ │ │ │ , move_flags_t flags = move_flags_t::always_replace_files │ │ │ │ ) const; │ │ │ │ void rreennaammee__ffiillee (file_index_t index, std::string const& new_name) const; │ │ │ │ - info_hash_t iinnffoo__hhaasshheess () const; │ │ │ │ sha1_hash iinnffoo__hhaasshh () const; │ │ │ │ + info_hash_t iinnffoo__hhaasshheess () const; │ │ │ │ bool ooppeerraattoorr!!== (const torrent_handle& h) const; │ │ │ │ - bool ooppeerraattoorr==== (const torrent_handle& h) const; │ │ │ │ bool ooppeerraattoorr<< (const torrent_handle& h) const; │ │ │ │ + bool ooppeerraattoorr==== (const torrent_handle& h) const; │ │ │ │ std::uint32_t iidd () const; │ │ │ │ std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ client_data_t uusseerrddaattaa () const; │ │ │ │ bool iinn__sseessssiioonn () const; │ │ │ │ │ │ │ │ static inline constexpr add_piece_flags_t oovveerrwwrriittee__eexxiissttiinngg = 0_bit; │ │ │ │ static inline constexpr status_flags_t qquueerryy__ddiissttrriibbuutteedd__ccooppiieess = 0_bit; │ │ │ │ @@ -5440,18 +8773,18 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ttoorrrreenntt__hhaannddllee(()) ********** │ │ │ │ ttoorrrreenntt__hhaannddllee () noexcept = default; │ │ │ │ constructs a torrent handle that does not refer to a torrent. i.e. _i_s___v_a_l_i_d_(_) │ │ │ │ will return false. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aadddd__ppiieeccee(()) ********** │ │ │ │ -void aadddd__ppiieeccee (piece_index_t piece, char const* data, add_piece_flags_t flags │ │ │ │ -= {}) const; │ │ │ │ void aadddd__ppiieeccee (piece_index_t piece, std::vector data, add_piece_flags_t │ │ │ │ flags = {}) const; │ │ │ │ +void aadddd__ppiieeccee (piece_index_t piece, char const* data, add_piece_flags_t flags │ │ │ │ += {}) const; │ │ │ │ This function will write data to the storage as piece piece, as if it had been │ │ │ │ downloaded from a peer. │ │ │ │ By default, data that's already been downloaded is not overwritten by this │ │ │ │ buffer. If you trust this data to be correct (and pass the piece hash check) │ │ │ │ you may pass the overwrite_existing flag. This will instruct libtorrent to │ │ │ │ overwrite any data that may already have been downloaded with this data. │ │ │ │ Since the data is written asynchronously, you may know that is passed or failed │ │ │ │ @@ -5495,17 +8828,17 @@ │ │ │ │ metadata has not been downloaded yet then the functions do nothing. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** hhaavvee__ppiieeccee(()) ********** │ │ │ │ bool hhaavvee__ppiieeccee (piece_index_t piece) const; │ │ │ │ Returns true if this piece has been completely downloaded and written to disk, │ │ │ │ and false otherwise. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppoosstt__ppeeeerr__iinnffoo(()) ggeett__ppeeeerr__iinnffoo(()) ********** │ │ │ │ -void ppoosstt__ppeeeerr__iinnffoo () const; │ │ │ │ +********** ggeett__ppeeeerr__iinnffoo(()) ppoosstt__ppeeeerr__iinnffoo(()) ********** │ │ │ │ void ggeett__ppeeeerr__iinnffoo (std::vector& v) const; │ │ │ │ +void ppoosstt__ppeeeerr__iinnffoo () const; │ │ │ │ Query information about connected peers for this torrent. If the _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ is invalid, it will throw a system_error exception. │ │ │ │ post_peer_info() is asynchronous and will trigger the posting of a │ │ │ │ _p_e_e_r___i_n_f_o___a_l_e_r_t. The _a_l_e_r_t contain a list of _p_e_e_r___i_n_f_o objects, one for each │ │ │ │ connected peer. │ │ │ │ get_peer_info() is synchronous and takes a reference to a vector that will be │ │ │ │ cleared and filled with one _e_n_t_r_y for each peer connected to this torrent, │ │ │ │ @@ -5527,34 +8860,34 @@ │ │ │ │ object for this torrent. │ │ │ │ In order to get regular updates for torrents whose status changes, consider │ │ │ │ calling session::post_torrent_updates()`` instead. │ │ │ │ By default everything is included. The flags you can use to decide what to │ │ │ │ iinncclluuddee are defined in this class. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ppoosstt__ddoowwnnllooaadd__qquueeuuee(()) ggeett__ddoowwnnllooaadd__qquueeuuee(()) ********** │ │ │ │ -std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const; │ │ │ │ void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const; │ │ │ │ void ggeett__ddoowwnnllooaadd__qquueeuuee (std::vector& queue) const; │ │ │ │ +std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const; │ │ │ │ post_download_queue() triggers a download_queue_alert to be posted. │ │ │ │ get_download_queue() is a synchronous call and returns a vector with │ │ │ │ information about pieces that are partially downloaded or not downloaded but │ │ │ │ partially requested. See _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o for the fields in the returned │ │ │ │ vector. │ │ │ │ Warning │ │ │ │ get_download_queue() is prone to threading errors. The _b_l_o_c_k___i_n_f_o pointers its │ │ │ │ return value points to are owned by the _s_e_s_s_i_o_n and will be cleared the next │ │ │ │ time get_download_queue() is called. Therefore it's not safe to call this │ │ │ │ function from multiple threads. Using post_download_queue() is a safe │ │ │ │ alternative. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cclleeaarr__ppiieeccee__ddeeaaddlliinneess(()) rreesseett__ppiieeccee__ddeeaaddlliinnee(()) sseett__ppiieeccee__ddeeaaddlliinnee(()) ********** │ │ │ │ -void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const; │ │ │ │ -void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const; │ │ │ │ +********** cclleeaarr__ppiieeccee__ddeeaaddlliinneess(()) sseett__ppiieeccee__ddeeaaddlliinnee(()) rreesseett__ppiieeccee__ddeeaaddlliinnee(()) ********** │ │ │ │ void sseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index, int deadline, deadline_flags_t │ │ │ │ flags = {}) const; │ │ │ │ +void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const; │ │ │ │ +void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const; │ │ │ │ This function sets or resets the deadline associated with a specific piece │ │ │ │ index (index). libtorrent will attempt to download this entire piece before the │ │ │ │ deadline expires. This is not necessarily possible, but pieces with a more │ │ │ │ recent deadline will always be prioritized over pieces with a deadline further │ │ │ │ ahead in time. The deadline (and flags) of a piece can be changed by calling │ │ │ │ this function again. │ │ │ │ If the piece is already downloaded when this call is made, nothing happens, │ │ │ │ @@ -5584,34 +8917,34 @@ │ │ │ │ piece_granularity is specified, the progress will be specified in piece │ │ │ │ granularity. i.e. only pieces that have been fully downloaded and passed the │ │ │ │ hash check count. When specifying piece granularity, the operation is a lot │ │ │ │ cheaper, since libtorrent already keeps track of this internally and no │ │ │ │ calculation is required. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__ssttaattuuss(()) ppoosstt__ffiillee__ssttaattuuss(()) ********** │ │ │ │ -void ppoosstt__ffiillee__ssttaattuuss () const; │ │ │ │ std::vector ffiillee__ssttaattuuss () const; │ │ │ │ +void ppoosstt__ffiillee__ssttaattuuss () const; │ │ │ │ file_status() returns a vector with status about files that are open for this │ │ │ │ torrent. Any file that is not open will not be reported in the vector, i.e. │ │ │ │ it's possible that the vector is empty when returning, if none of the files in │ │ │ │ the torrent are currently open. │ │ │ │ post_file_status() will trigger a _f_i_l_e___s_t_a_t_u_s___a_l_e_r_t to be posted, containing │ │ │ │ the open-file state of all currently open files in the torrent. │ │ │ │ See _o_p_e_n___f_i_l_e___s_t_a_t_e │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** cclleeaarr__eerrrroorr(()) ********** │ │ │ │ void cclleeaarr__eerrrroorr () const; │ │ │ │ If the torrent is in an error state (i.e. torrent_status::error is non-empty), │ │ │ │ this will clear the error and start the torrent again. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ttrraacckkeerr(()) ttrraacckkeerrss(()) ppoosstt__ttrraacckkeerrss(()) rreeppllaaccee__ttrraacckkeerrss(()) ********** │ │ │ │ -void aadddd__ttrraacckkeerr (announce_entry const&) const; │ │ │ │ -void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const; │ │ │ │ +********** ppoosstt__ttrraacckkeerrss(()) rreeppllaaccee__ttrraacckkeerrss(()) ttrraacckkeerrss(()) aadddd__ttrraacckkeerr(()) ********** │ │ │ │ void ppoosstt__ttrraacckkeerrss () const; │ │ │ │ std::vector ttrraacckkeerrss () const; │ │ │ │ +void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const; │ │ │ │ +void aadddd__ttrraacckkeerr (announce_entry const&) const; │ │ │ │ trackers() returns the list of trackers for this torrent. The announce _e_n_t_r_y │ │ │ │ contains both a string url which specify the announce url for the tracker as │ │ │ │ well as an _i_n_t tier, which is specifies the order in which this tracker is │ │ │ │ tried. If you want libtorrent to use another list of trackers for this torrent, │ │ │ │ you can use replace_trackers() which takes a list of the same form as the one │ │ │ │ returned from trackers() and will replace it. If you want an immediate effect, │ │ │ │ you have to call _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_). See _a_n_n_o_u_n_c_e___e_n_t_r_y. │ │ │ │ @@ -5620,18 +8953,18 @@ │ │ │ │ add_tracker() will look if the specified tracker is already in the set. If it │ │ │ │ is, it doesn't do anything. If it's not in the current set of trackers, it will │ │ │ │ insert it in the tier specified in the _a_n_n_o_u_n_c_e___e_n_t_r_y. │ │ │ │ The updated set of trackers will be saved in the resume data, and when a │ │ │ │ torrent is started with resume data, the trackers from the resume data will │ │ │ │ replace the original ones. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** uurrll__sseeeeddss(()) rreemmoovvee__uurrll__sseeeedd(()) aadddd__uurrll__sseeeedd(()) ********** │ │ │ │ +********** aadddd__uurrll__sseeeedd(()) rreemmoovvee__uurrll__sseeeedd(()) uurrll__sseeeeddss(()) ********** │ │ │ │ +std::set uurrll__sseeeeddss () const; │ │ │ │ void aadddd__uurrll__sseeeedd (std::string const& url) const; │ │ │ │ void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const; │ │ │ │ -std::set uurrll__sseeeeddss () const; │ │ │ │ add_url_seed() adds another url to the torrent's list of url seeds. If the │ │ │ │ given url already exists in that list, the call has no effect. The torrent will │ │ │ │ connect to the server and try to download pieces from it, unless it's paused, │ │ │ │ queued, checking or seeding. remove_url_seed() removes the given url if it │ │ │ │ exists already. url_seeds() return a set of the url seeds currently in this │ │ │ │ torrent. Note that URLs that fails may be removed automatically from the list. │ │ │ │ See _h_t_t_p_ _s_e_e_d_i_n_g for more information. │ │ │ │ @@ -5666,36 +8999,36 @@ │ │ │ │ and false afterward. │ │ │ │ Clients should only use _i_s___v_a_l_i_d_(_) to determine if the result of session:: │ │ │ │ find_torrent() was successful. │ │ │ │ Unlike other member functions which return a value, _i_s___v_a_l_i_d_(_) completes │ │ │ │ immediately, without blocking on a result from the network thread. Also unlike │ │ │ │ other functions, it never throws the system_error exception. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreessuummee(()) ppaauussee(()) ********** │ │ │ │ -void ppaauussee (pause_flags_t flags = {}) const; │ │ │ │ +********** ppaauussee(()) rreessuummee(()) ********** │ │ │ │ void rreessuummee () const; │ │ │ │ +void ppaauussee (pause_flags_t flags = {}) const; │ │ │ │ pause(), and resume() will disconnect all peers and reconnect all peers │ │ │ │ respectively. When a torrent is paused, it will however remember all share │ │ │ │ ratios to all peers and remember all potential (not connected) peers. Torrents │ │ │ │ may be paused automatically if there is a file error (e.g. disk full) or │ │ │ │ something similar. See _f_i_l_e___e_r_r_o_r___a_l_e_r_t. │ │ │ │ For possible values of the flags parameter, see pause_flags_t. │ │ │ │ To know if a torrent is paused or not, call torrent_handle::flags() and check │ │ │ │ for the torrent_status::paused flag. │ │ │ │ Note │ │ │ │ Torrents that are auto-managed may be automatically resumed again. It does not │ │ │ │ make sense to pause an auto-managed torrent without making it not auto-managed │ │ │ │ first. Torrents are auto-managed by default when added to the _s_e_s_s_i_o_n. For more │ │ │ │ information, see _q_u_e_u_i_n_g. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffllaaggss(()) sseett__ffllaaggss(()) uunnsseett__ffllaaggss(()) ********** │ │ │ │ -void sseett__ffllaaggss (torrent_flags_t flags) const; │ │ │ │ +********** uunnsseett__ffllaaggss(()) ffllaaggss(()) sseett__ffllaaggss(()) ********** │ │ │ │ torrent_flags_t ffllaaggss () const; │ │ │ │ void uunnsseett__ffllaaggss (torrent_flags_t flags) const; │ │ │ │ void sseett__ffllaaggss (torrent_flags_t flags, torrent_flags_t mask) const; │ │ │ │ +void sseett__ffllaaggss (torrent_flags_t flags) const; │ │ │ │ sets and gets the torrent state flags. See _t_o_r_r_e_n_t___f_l_a_g_s___t. The set_flags │ │ │ │ overload that take a mask will affect all flags part of the mask, and set their │ │ │ │ values to what the flags argument is set to. This allows clearing and setting │ │ │ │ flags in a single function call. The set_flags overload that just takes flags, │ │ │ │ sets all the specified flags and leave any other flags unchanged. unset_flags │ │ │ │ clears the specified flags, while leaving any other flags unchanged. │ │ │ │ Theseed_modeflag is special, it can only be cleared once the torrent has been │ │ │ │ @@ -5754,3867 +9087,2446 @@ │ │ │ │ accelerate the shutdown process by not saving resume data again for those │ │ │ │ torrents. Completed torrents should have their resume data saved when they │ │ │ │ complete and on exit, since their statistics might be updated. │ │ │ │ Example code to pause and save resume data for all torrents and wait for the │ │ │ │ alerts: │ │ │ │ extern int outstanding_resume_data; // global counter of outstanding resume │ │ │ │ data │ │ │ │ -std::vector handles = ses.get_torrents(); │ │ │ │ -for (torrent_handle const& h : handles) try │ │ │ │ -{ │ │ │ │ - h.save_resume_data(torrent_handle::only_if_modified); │ │ │ │ - ++outstanding_resume_data; │ │ │ │ -} │ │ │ │ -catch (lt::system_error const& e) │ │ │ │ -{ │ │ │ │ - // the handle was invalid, ignore this one and move to the next │ │ │ │ -} │ │ │ │ - │ │ │ │ -while (outstanding_resume_data > 0) │ │ │ │ -{ │ │ │ │ - // if we don't get an alert within 30 seconds, abort │ │ │ │ - if (!ses.wait_for_alert(seconds(30))) break; │ │ │ │ - │ │ │ │ - std::vector alerts; │ │ │ │ - ses.pop_alerts(&alerts); │ │ │ │ - │ │ │ │ - for (alert* i : alerts) │ │ │ │ - { │ │ │ │ - if (alert_cast(i)) │ │ │ │ - { │ │ │ │ - process_alert(i); │ │ │ │ - --outstanding_resume_data; │ │ │ │ - continue; │ │ │ │ - } │ │ │ │ - │ │ │ │ - save_resume_data_alert const* rd = │ │ │ │ -alert_cast(i); │ │ │ │ - if (rd == nullptr) │ │ │ │ - { │ │ │ │ - process_alert(i); │ │ │ │ - continue; │ │ │ │ - } │ │ │ │ - │ │ │ │ - std::ofstream out((rd->params.save_path │ │ │ │ - + "/" + rd->params.name + ".fastresume").c_str() │ │ │ │ - , std::ios_base::binary); │ │ │ │ - std::vector buf = write_resume_data_buf(rd->params); │ │ │ │ - out.write(buf.data(), buf.size()); │ │ │ │ - --outstanding_resume_data; │ │ │ │ - } │ │ │ │ -} │ │ │ │ -Note │ │ │ │ -Note how outstanding_resume_data is a global counter in this example. This is │ │ │ │ -deliberate, otherwise there is a race condition for torrents that was just │ │ │ │ -asked to save their resume data, they posted the _a_l_e_r_t, but it has not been │ │ │ │ -received yet. Those torrents would report that they don't need to save resume │ │ │ │ -data again, and skipped by the initial loop, and thwart the counter otherwise. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nneeeedd__ssaavvee__rreessuummee__ddaattaa(()) ********** │ │ │ │ -bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const; │ │ │ │ -bool nneeeedd__ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags) const; │ │ │ │ -This function returns true if anything that is stored in the resume data has │ │ │ │ -changed since the last time resume data was saved. The overload that takes │ │ │ │ -flags let you ask if specific categories of properties have changed. These │ │ │ │ -flags have the same behavior as in the _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) call. │ │ │ │ -This is a bblloocckkiinngg call. It will wait for a response from libtorrent's main │ │ │ │ -thread. A way to avoid blocking is to instead call _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) directly, │ │ │ │ -specifying the conditions under which resume data should be saved. │ │ │ │ -Note │ │ │ │ -A torrent's resume data is considered saved as soon as the │ │ │ │ -_s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t is posted. It is important to make sure this _a_l_e_r_t is │ │ │ │ -received and handled in order for this function to be meaningful. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** qquueeuuee__ppoossiittiioonn__uupp(()) qquueeuuee__ppoossiittiioonn__ttoopp(()) qquueeuuee__ppoossiittiioonn(()) │ │ │ │ -qquueeuuee__ppoossiittiioonn__ddoowwnn(()) qquueeuuee__ppoossiittiioonn__bboottttoomm(()) ********** │ │ │ │ -void qquueeuuee__ppoossiittiioonn__ttoopp () const; │ │ │ │ -void qquueeuuee__ppoossiittiioonn__bboottttoomm () const; │ │ │ │ -void qquueeuuee__ppoossiittiioonn__ddoowwnn () const; │ │ │ │ -queue_position_t qquueeuuee__ppoossiittiioonn () const; │ │ │ │ -void qquueeuuee__ppoossiittiioonn__uupp () const; │ │ │ │ -Every torrent that is added is assigned a queue position exactly one greater │ │ │ │ -than the greatest queue position of all existing torrents. Torrents that are │ │ │ │ -being seeded have -1 as their queue position, since they're no longer in line │ │ │ │ -to be downloaded. │ │ │ │ -When a torrent is removed or turns into a seed, all torrents with greater queue │ │ │ │ -positions have their positions decreased to fill in the space in the sequence. │ │ │ │ -queue_position() returns the torrent's position in the download queue. The │ │ │ │ -torrents with the smallest numbers are the ones that are being downloaded. The │ │ │ │ -smaller number, the closer the torrent is to the front of the line to be │ │ │ │ -started. │ │ │ │ -The queue position is also available in the _t_o_r_r_e_n_t___s_t_a_t_u_s. │ │ │ │ -The queue_position_*() functions adjust the torrents position in the queue. Up │ │ │ │ -means closer to the front and down means closer to the back of the queue. Top │ │ │ │ -and bottom refers to the front and the back of the queue respectively. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** qquueeuuee__ppoossiittiioonn__sseett(()) ********** │ │ │ │ -void qquueeuuee__ppoossiittiioonn__sseett (queue_position_t p) const; │ │ │ │ -updates the position in the queue for this torrent. The relative order of all │ │ │ │ -other torrents remain intact but their numerical queue position shifts to make │ │ │ │ -space for this torrent's new position │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr(()) sseett__ssssll__cceerrttiiffiiccaattee(()) ********** │ │ │ │ -void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate │ │ │ │ - , std::string const& private_key │ │ │ │ - , std::string const& dh_params); │ │ │ │ -void sseett__ssssll__cceerrttiiffiiccaattee (std::string const& certificate │ │ │ │ - , std::string const& private_key │ │ │ │ - , std::string const& dh_params │ │ │ │ - , std::string const& passphrase = ""); │ │ │ │ -For SSL torrents, use this to specify a path to a .pem file to use as this │ │ │ │ -client's certificate. The certificate must be signed by the certificate in the │ │ │ │ -.torrent file to be valid. │ │ │ │ -The _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e___b_u_f_f_e_r_(_) overload takes the actual certificate, private │ │ │ │ -key and DH params as strings, rather than paths to files. │ │ │ │ -cert is a path to the (signed) certificate in .pem format corresponding to this │ │ │ │ -torrent. │ │ │ │ -private_key is a path to the private key for the specified certificate. This │ │ │ │ -must be in .pem format. │ │ │ │ -dh_params is a path to the Diffie-Hellman parameter file, which needs to be in │ │ │ │ -.pem format. You can generate this file using the openssl command like this: │ │ │ │ -openssl dhparam -outform PEM -out dhparams.pem 512. │ │ │ │ -passphrase may be specified if the private key is encrypted and requires a │ │ │ │ -passphrase to be decrypted. │ │ │ │ -Note that when a torrent first starts up, and it needs a certificate, it will │ │ │ │ -suspend connecting to any peers until it has one. It's typically desirable to │ │ │ │ -resume the torrent after setting the SSL certificate. │ │ │ │ -If you receive a _t_o_r_r_e_n_t___n_e_e_d___c_e_r_t___a_l_e_r_t, you need to call this to provide a │ │ │ │ -valid cert. If you don't have a cert you won't be allowed to connect to any │ │ │ │ -peers. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttoorrrreenntt__ffiillee(()) ********** │ │ │ │ -std::shared_ptr ttoorrrreenntt__ffiillee () const; │ │ │ │ -_t_o_r_r_e_n_t___f_i_l_e_(_) returns a pointer to the _t_o_r_r_e_n_t___i_n_f_o object associated with │ │ │ │ -this torrent. The _t_o_r_r_e_n_t___i_n_f_o object may be a copy of the internal object. If │ │ │ │ -the torrent doesn't have metadata, the pointer will not be initialized (i.e. a │ │ │ │ -nullptr). The torrent may be in a state without metadata only if it was started │ │ │ │ -without a .torrent file, e.g. by being added by magnet link. │ │ │ │ -Note that the _t_o_r_r_e_n_t___i_n_f_o object returned here may be a different instance │ │ │ │ -than the one added to the _s_e_s_s_i_o_n, with different attributes like piece layers, │ │ │ │ -dht nodes and trackers. A _t_o_r_r_e_n_t___i_n_f_o object does not round-trip cleanly when │ │ │ │ -added to a _s_e_s_s_i_o_n. │ │ │ │ -If you want to save a .torrent file from the _t_o_r_r_e_n_t___h_a_n_d_l_e, instead call │ │ │ │ -_s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) and _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object │ │ │ │ -passed back in the _a_l_e_r_t. │ │ │ │ -Note that a torrent added from a magnet link may not have the full merkle trees │ │ │ │ -for all files, and hence not have the complete piece layers. In that state, you │ │ │ │ -cannot create a .torrent file from the _t_o_r_r_e_n_t___i_n_f_o returned. Once the torrent │ │ │ │ -completes downloading all files, becoming a seed, you can make a .torrent file │ │ │ │ -from it. │ │ │ │ -If any files in the torrent have been renamed, using _t_o_r_r_e_n_t___h_a_n_d_l_e_:_: │ │ │ │ -_r_e_n_a_m_e___f_i_l_e_(_), the new names will not be reflected in the returned _t_o_r_r_e_n_t___i_n_f_o │ │ │ │ -object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__rreennaammeedd__ffiilleess(()) ********** │ │ │ │ -renamed_files ggeett__rreennaammeedd__ffiilleess () const; │ │ │ │ -Returns a copy of the _r_e_n_a_m_e_d___f_i_l_e_s object for this torrent. This records all │ │ │ │ -file renames applied via _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_n_a_m_e___f_i_l_e_(_). To get a complete view │ │ │ │ -of the current file layout (original names plus any renames), combine this with │ │ │ │ -the _f_i_l_e___s_t_o_r_a_g_e from torrent_file()->layout(): │ │ │ │ -auto tf = handle.torrent_file(); │ │ │ │ -auto renames = handle.get_renamed_files(); │ │ │ │ -lt::filenames fn(tf->layout(), renames); │ │ │ │ -for (auto i : fn.file_range()) │ │ │ │ - std::cout << fn.file_path(i) << "\n"; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__llaayyeerrss(()) ********** │ │ │ │ -std::vector> ppiieeccee__llaayyeerrss () const; │ │ │ │ -returns the piece layers for all files in the torrent. If this is a v1 torrent │ │ │ │ -(and doesn't have any piece layers) it returns an empty vector. This is a │ │ │ │ -blocking call that will synchronize with the libtorrent network thread. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__aavvaaiillaabbiilliittyy(()) ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy(()) ********** │ │ │ │ -void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const; │ │ │ │ -void ppiieeccee__aavvaaiillaabbiilliittyy (std::vector& avail) const; │ │ │ │ -The piece availability is the number of peers that we are connected that has │ │ │ │ -advertised having a particular piece. This is the information that libtorrent │ │ │ │ -uses in order to prefer picking rare pieces. │ │ │ │ -post_piece_availability() will trigger a _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y___a_l_e_r_t to be posted. │ │ │ │ -piece_availability() fills the specified std::vector with the availability │ │ │ │ -for each piece in this torrent. libtorrent does not keep track of availability │ │ │ │ -for seeds, so if the torrent is seeding the availability for all pieces is │ │ │ │ -reported as 0. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__pprriioorriittyy(()) ggeett__ppiieeccee__pprriioorriittiieess(()) pprriioorriittiizzee__ppiieecceess(()) ********** │ │ │ │ -void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority) const; │ │ │ │ -std::vector ggeett__ppiieeccee__pprriioorriittiieess () const; │ │ │ │ -void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces) const; │ │ │ │ -void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const; │ │ │ │ -download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const; │ │ │ │ -These functions are used to set and get the priority of individual pieces. By │ │ │ │ -default all pieces have priority 4. That means that the random rarest first │ │ │ │ -algorithm is effectively active for all pieces. You may however change the │ │ │ │ -priority of individual pieces. There are 8 priority levels. 0 means not to │ │ │ │ -download the piece at all. Otherwise, lower priority values means less likely │ │ │ │ -to be picked. Piece priority takes precedence over piece availability. Every │ │ │ │ -piece with priority 7 will be attempted to be picked before a priority 6 piece │ │ │ │ -and so on. │ │ │ │ -The default priority of pieces is 4. │ │ │ │ -Piece priorities can not be changed for torrents that have not downloaded the │ │ │ │ -metadata yet. Magnet links won't have metadata immediately. see the │ │ │ │ -_m_e_t_a_d_a_t_a___r_e_c_e_i_v_e_d___a_l_e_r_t. │ │ │ │ -piece_priority sets or gets the priority for an individual piece, specified by │ │ │ │ -index. │ │ │ │ -prioritize_pieces takes a vector of integers, one integer per piece in the │ │ │ │ -torrent. All the piece priorities will be updated with the priorities in the │ │ │ │ -vector. The second overload of prioritize_pieces that takes a vector of pairs │ │ │ │ -will update the priorities of only select pieces, and leave all other │ │ │ │ -unaffected. Each pair is (piece, priority). That is, the first item is the │ │ │ │ -piece index and the second item is the priority of that piece. Invalid entries, │ │ │ │ -where the piece index or priority is out of range, are not allowed. │ │ │ │ -get_piece_priorities returns a vector with one element for each piece in the │ │ │ │ -torrent. Each element is the current priority of that piece. │ │ │ │ -It's possible to cancel the effect of ffiillee priorities by setting the priorities │ │ │ │ -for the affected pieces. Care has to be taken when mixing usage of file- and │ │ │ │ -piece priorities. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__pprriioorriittyy(()) ggeett__ffiillee__pprriioorriittiieess(()) pprriioorriittiizzee__ffiilleess(()) ********** │ │ │ │ -void pprriioorriittiizzee__ffiilleess (std::vector const& files) const; │ │ │ │ -void ffiillee__pprriioorriittyy (file_index_t index, download_priority_t priority) const; │ │ │ │ -std::vector ggeett__ffiillee__pprriioorriittiieess () const; │ │ │ │ -download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const; │ │ │ │ -index must be in the range [0, number_of_files). │ │ │ │ -file_priority() queries or sets the priority of file index. │ │ │ │ -prioritize_files() takes a vector that has at as many elements as there are │ │ │ │ -files in the torrent. Each _e_n_t_r_y is the priority of that file. The function │ │ │ │ -sets the priorities of all the pieces in the torrent based on the vector. │ │ │ │ -get_file_priorities() returns a vector with the priorities of all files. │ │ │ │ -The priority values are the same as for _p_i_e_c_e___p_r_i_o_r_i_t_y_(_). See │ │ │ │ -_d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y___t. │ │ │ │ -Whenever a file priority is changed, all other piece priorities are reset to │ │ │ │ -match the file priorities. In order to maintain special priorities for │ │ │ │ -particular pieces, _p_i_e_c_e___p_r_i_o_r_i_t_y_(_) has to be called again for those pieces. │ │ │ │ -You cannot set the file priorities on a torrent that does not yet have metadata │ │ │ │ -or a torrent that is a seed. file_priority(int, int) and _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_) are │ │ │ │ -both no-ops for such torrents. │ │ │ │ -Since changing file priorities may involve disk operations (of moving files in- │ │ │ │ -and out of the part file), the internal accounting of file priorities happen │ │ │ │ -asynchronously. i.e. setting file priorities and then immediately querying them │ │ │ │ -may not yield the same priorities just set. To synchronize with the priorities │ │ │ │ -taking effect, wait for the _f_i_l_e___p_r_i_o___a_l_e_r_t. │ │ │ │ -When combining file- and piece priorities, the resume file will record both. │ │ │ │ -When loading the resume data, the file priorities will be applied first, then │ │ │ │ -the piece priorities. │ │ │ │ -Moving data from a file into the part file is currently not supported. If a │ │ │ │ -file has its priority set to 0 aafftteerr it has already been created, it will not │ │ │ │ -be moved into the partfile. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppoosstt__ffiillee__pprriioorriittiieess(()) ********** │ │ │ │ -void ppoosstt__ffiillee__pprriioorriittiieess () const; │ │ │ │ -post_file_priorities() will trigger a _f_i_l_e___p_r_i_o_r_i_t_i_e_s___a_l_e_r_t to be posted, │ │ │ │ -containing the download priority of each file in the torrent. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffoorrccee__rreeaannnnoouunnccee(()) ffoorrccee__llssdd__aannnnoouunnccee(()) ffoorrccee__ddhhtt__aannnnoouunnccee(()) ********** │ │ │ │ -void ffoorrccee__rreeaannnnoouunnccee (int seconds = 0, reannounce_flags_t = {}) const; │ │ │ │ -void ffoorrccee__llssdd__aannnnoouunnccee () const; │ │ │ │ -void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const; │ │ │ │ -void ffoorrccee__rreeaannnnoouunnccee (int seconds, std::string const& url, reannounce_flags_t │ │ │ │ -= {}) const; │ │ │ │ -void ffoorrccee__ddhhtt__aannnnoouunnccee () const; │ │ │ │ -force_reannounce() will force this torrent to do another tracker request, to │ │ │ │ -receive new peers. The seconds argument specifies how many seconds from now to │ │ │ │ -issue the tracker announces. │ │ │ │ -If the tracker's min_interval has not passed since the last announce, the │ │ │ │ -forced announce will be scheduled to happen immediately as the min_interval │ │ │ │ -expires. This is to honor trackers minimum re-announce interval settings. │ │ │ │ -The tracker_index argument specifies which tracker to re-announce. If set to - │ │ │ │ -1 (which is the default), all trackers are re-announce. │ │ │ │ -The flags argument can be used to affect the re-announce. See │ │ │ │ -ignore_min_interval and high_priority. │ │ │ │ -force_dht_announce will announce the torrent to the DHT immediately. │ │ │ │ -force_lsd_announce will announce the torrent on LSD immediately. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssccrraappee__ttrraacckkeerr(()) ********** │ │ │ │ -void ssccrraappee__ttrraacckkeerr () const; │ │ │ │ -void ssccrraappee__ttrraacckkeerr (int idx) const; │ │ │ │ -void ssccrraappee__ttrraacckkeerr (std::string url) const; │ │ │ │ -scrape_tracker() will send a scrape request to a tracker. By default (idx = -1) │ │ │ │ -it will scrape the last working tracker. If idx is >= 0, the tracker with the │ │ │ │ -specified index will scraped. │ │ │ │ -A scrape request queries the tracker for statistics such as total number of │ │ │ │ -incomplete peers, complete peers, number of downloads etc. │ │ │ │ -This request will specifically update the num_complete and num_incomplete │ │ │ │ -fields in the _t_o_r_r_e_n_t___s_t_a_t_u_s struct once it completes. When it completes, it │ │ │ │ -will generate a _s_c_r_a_p_e___r_e_p_l_y___a_l_e_r_t. If it fails, it will generate a │ │ │ │ -_s_c_r_a_p_e___f_a_i_l_e_d___a_l_e_r_t. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ddoowwnnllooaadd__lliimmiitt(()) ddoowwnnllooaadd__lliimmiitt(()) uuppllooaadd__lliimmiitt(()) sseett__uuppllooaadd__lliimmiitt(()) │ │ │ │ -********** │ │ │ │ -int uuppllooaadd__lliimmiitt () const; │ │ │ │ -int ddoowwnnllooaadd__lliimmiitt () const; │ │ │ │ -void sseett__uuppllooaadd__lliimmiitt (int limit) const; │ │ │ │ -void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const; │ │ │ │ -set_upload_limit will limit the upload bandwidth used by this particular │ │ │ │ -torrent to the limit you set. It is given as the number of bytes per second the │ │ │ │ -torrent is allowed to upload. set_download_limit works the same way but for │ │ │ │ -download bandwidth instead of upload bandwidth. Note that setting a higher │ │ │ │ -limit on a torrent then the global limit (settings_pack::upload_rate_limit) │ │ │ │ -will not override the global rate limit. The torrent can never upload more than │ │ │ │ -the global rate limit. │ │ │ │ -upload_limit and download_limit will return the current limit setting, for │ │ │ │ -upload and download, respectively. │ │ │ │ -Local peers are not rate limited by default. see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccoonnnneecctt__ppeeeerr(()) ********** │ │ │ │ -void ccoonnnneecctt__ppeeeerr (tcp::endpoint const& adr, peer_source_flags_t source = {} │ │ │ │ - , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const; │ │ │ │ -connect_peer() is a way to manually connect to peers that one believe is a part │ │ │ │ -of the torrent. If the peer does not respond, or is not a member of this │ │ │ │ -torrent, it will simply be disconnected. No harm can be done by using this │ │ │ │ -other than an unnecessary connection attempt is made. If the torrent is │ │ │ │ -uninitialized or in queued or checking mode, this will throw system_error. The │ │ │ │ -second (optional) argument will be bitwise ORed into the source mask of this │ │ │ │ -peer. Typically this is one of the source flags in _p_e_e_r___i_n_f_o. i.e. tracker, │ │ │ │ -pex, dht etc. │ │ │ │ -For possible values of flags, see _p_e_x___f_l_a_g_s___t. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cclleeaarr__ppeeeerrss(()) ********** │ │ │ │ -void cclleeaarr__ppeeeerrss (); │ │ │ │ -This will disconnect all peers and clear the peer list for this torrent. New │ │ │ │ -peers will have to be acquired before resuming, from trackers, DHT or local │ │ │ │ -service discovery, for example. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmaaxx__uuppllooaaddss(()) sseett__mmaaxx__uuppllooaaddss(()) ********** │ │ │ │ -void sseett__mmaaxx__uuppllooaaddss (int max_uploads) const; │ │ │ │ -int mmaaxx__uuppllooaaddss () const; │ │ │ │ -set_max_uploads() sets the maximum number of peers that's unchoked at the same │ │ │ │ -time on this torrent. If you set this to -1, there will be no limit. This │ │ │ │ -defaults to infinite. The primary setting controlling this is the global │ │ │ │ -unchoke slots limit, set by unchoke_slots_limit in _s_e_t_t_i_n_g_s___p_a_c_k. │ │ │ │ -max_uploads() returns the current settings. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__mmaaxx__ccoonnnneeccttiioonnss(()) mmaaxx__ccoonnnneeccttiioonnss(()) ********** │ │ │ │ -void sseett__mmaaxx__ccoonnnneeccttiioonnss (int max_connections) const; │ │ │ │ -int mmaaxx__ccoonnnneeccttiioonnss () const; │ │ │ │ -set_max_connections() sets the maximum number of connection this torrent will │ │ │ │ -open. If all connections are used up, incoming connections may be refused or │ │ │ │ -poor connections may be closed. This must be at least 2. The default is │ │ │ │ -unlimited number of connections. If -1 is given to the function, it means │ │ │ │ -unlimited. There is also a global limit of the number of connections, set by │ │ │ │ -connections_limit in _s_e_t_t_i_n_g_s___p_a_c_k. │ │ │ │ -max_connections() returns the current settings. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmoovvee__ssttoorraaggee(()) ********** │ │ │ │ -void mmoovvee__ssttoorraaggee (std::string const& save_path │ │ │ │ - , move_flags_t flags = move_flags_t::always_replace_files │ │ │ │ - ) const; │ │ │ │ -Moves the file(s) that this torrent are currently seeding from or downloading │ │ │ │ -to. If the given save_path is not located on the same drive as the original │ │ │ │ -save path, the files will be copied to the new drive and removed from their │ │ │ │ -original location. This will block all other disk IO, and other torrents │ │ │ │ -download and upload rates may drop while copying the file. │ │ │ │ -Since disk IO is performed in a separate thread, this operation is also │ │ │ │ -asynchronous. Once the operation completes, the storage_moved_alert is │ │ │ │ -generated, with the new path as the message. If the move fails for some reason, │ │ │ │ -storage_moved_failed_alert is generated instead, containing the error message. │ │ │ │ -The flags argument determines the behavior of the copying/moving of the files │ │ │ │ -in the torrent. see _m_o_v_e___f_l_a_g_s___t. │ │ │ │ -always_replace_files is the default and replaces any file that exist in both │ │ │ │ -the source directory and the target directory. │ │ │ │ -fail_if_exist first check to see that none of the copy operations would cause │ │ │ │ -an overwrite. If it would, it will fail. Otherwise it will proceed as if it was │ │ │ │ -in always_replace_files mode. Note that there is an inherent race condition │ │ │ │ -here. If the files in the target directory appear after the check but before │ │ │ │ -the copy or move completes, they will be overwritten. When failing because of │ │ │ │ -files already existing in the target path, the error of │ │ │ │ -move_storage_failed_alert is set to boost::system::errc::file_exists. │ │ │ │ -The intention is that a client may use this as a probe, and if it fails, ask │ │ │ │ -the user which mode to use. The client may then re-issue the move_storage call │ │ │ │ -with one of the other modes. │ │ │ │ -dont_replace always keeps the existing file in the target directory, if there │ │ │ │ -is one. The source files will still be removed in that case. Note that it won't │ │ │ │ -automatically re-check files. If an incomplete torrent is moved into a │ │ │ │ -directory with the complete files, pause, move, force-recheck and resume. │ │ │ │ -Without the re-checking, the torrent will keep downloading and files in the new │ │ │ │ -download directory will be overwritten. │ │ │ │ -Files that have been renamed to have absolute paths are not moved by this │ │ │ │ -function. Keep in mind that files that don't belong to the torrent but are │ │ │ │ -stored in the torrent's directory may be moved as well. This goes for files │ │ │ │ -that have been renamed to absolute paths that still end up inside the save │ │ │ │ -path. │ │ │ │ -When copying files, sparse regions are not likely to be preserved. This makes │ │ │ │ -it proportionally more expensive to move a large torrent when only few pieces │ │ │ │ -have been downloaded, since the files are then allocated with zeros in the │ │ │ │ -destination directory. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreennaammee__ffiillee(()) ********** │ │ │ │ -void rreennaammee__ffiillee (file_index_t index, std::string const& new_name) const; │ │ │ │ -Renames the file with the given index asynchronously. The rename operation is │ │ │ │ -complete when either a _f_i_l_e___r_e_n_a_m_e_d___a_l_e_r_t or _f_i_l_e___r_e_n_a_m_e___f_a_i_l_e_d___a_l_e_r_t is │ │ │ │ -posted. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) ********** │ │ │ │ -info_hash_t iinnffoo__hhaasshheess () const; │ │ │ │ -sha1_hash iinnffoo__hhaasshh () const; │ │ │ │ -returns the info-hash(es) of the torrent. If this handle is to a torrent that │ │ │ │ -hasn't loaded yet (for instance by being added) by a URL, the returned value is │ │ │ │ -undefined. The info_hash() returns the SHA-1 info-hash for v1 torrents and a │ │ │ │ -truncated hash for v2 torrents. For the full v2 info-hash, use info_hashes() │ │ │ │ -instead. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr!!==(()) ooppeerraattoorr<<(()) ooppeerraattoorr====(()) ********** │ │ │ │ -bool ooppeerraattoorr!!== (const torrent_handle& h) const; │ │ │ │ -bool ooppeerraattoorr==== (const torrent_handle& h) const; │ │ │ │ -bool ooppeerraattoorr<< (const torrent_handle& h) const; │ │ │ │ -comparison operators. The order of the torrents is unspecified but stable. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iidd(()) ********** │ │ │ │ -std::uint32_t iidd () const; │ │ │ │ -returns a unique identifier for this torrent. It's not a dense index. It's not │ │ │ │ -preserved across sessions. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnaattiivvee__hhaannddllee(()) ********** │ │ │ │ -std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ -This function is intended only for use by plugins and the _a_l_e_r_t dispatch │ │ │ │ -function. This type does not have a stable ABI and should be relied on as │ │ │ │ -little as possible. Accessing the handle returned by this function is not │ │ │ │ -thread safe outside of libtorrent's internal thread (which is used to invoke │ │ │ │ -_p_l_u_g_i_n callbacks). │ │ │ │ -The aux::torrent class is not only eligible for changing ABI across minor │ │ │ │ -versions of libtorrent, its layout is also dependent on build configuration. │ │ │ │ -This adds additional requirements on a client to be built with the exact same │ │ │ │ -build configuration as libtorrent itself. i.e. the TORRENT_ macros must match │ │ │ │ -between libtorrent and the client builds. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** uusseerrddaattaa(()) ********** │ │ │ │ -client_data_t uusseerrddaattaa () const; │ │ │ │ -returns the userdata pointer as set in _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinn__sseessssiioonn(()) ********** │ │ │ │ -bool iinn__sseessssiioonn () const; │ │ │ │ -Returns true if the torrent is in the _s_e_s_s_i_o_n. It returns true before session:: │ │ │ │ -remove_torrent() is called, and false afterward. │ │ │ │ -Note that this is a blocking function, unlike _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_i_s___v_a_l_i_d_(_) which │ │ │ │ -returns immediately. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - overwrite_existing │ │ │ │ - instruct libtorrent to overwrite any data that may already have been │ │ │ │ - downloaded with the data of the new piece being added. Using this flag │ │ │ │ - when adding a piece that is actively being downloaded from other peers │ │ │ │ - may have some unexpected consequences, as blocks currently being │ │ │ │ - downloaded from peers may not be replaced. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_distributed_copies │ │ │ │ - calculates distributed_copies, distributed_full_copies and │ │ │ │ - distributed_fraction. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_accurate_download_counters │ │ │ │ - includes partial downloaded blocks in total_done and total_wanted_done. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_last_seen_complete │ │ │ │ - includes last_seen_complete. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_pieces │ │ │ │ - populate the pieces field in _t_o_r_r_e_n_t___s_t_a_t_u_s. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_verified_pieces │ │ │ │ - includes verified_pieces (only applies to torrents in sseeeedd mmooddee). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_torrent_file │ │ │ │ - includes torrent_file, which is all the static information from the │ │ │ │ - .torrent file. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_name │ │ │ │ - includes name, the name of the torrent. This is either derived from the │ │ │ │ - .torrent file, or from the &dn= magnet link argument or possibly some │ │ │ │ - other source. If the name of the torrent is not known, this is an empty │ │ │ │ - string. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_save_path │ │ │ │ - includes save_path, the path to the directory the files of the torrent │ │ │ │ - are saved to. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - query_renamed_files │ │ │ │ - includes renamed_files, a map of files that have been renamed in this │ │ │ │ - torrent. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - alert_when_available │ │ │ │ - used to ask libtorrent to send an _a_l_e_r_t once the piece has been │ │ │ │ - downloaded, by passing alert_when_available. When set, the │ │ │ │ - _r_e_a_d___p_i_e_c_e___a_l_e_r_t _a_l_e_r_t will be delivered, with the piece data, when it's │ │ │ │ - downloaded. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - piece_granularity │ │ │ │ - only calculate file progress at piece granularity. This makes the │ │ │ │ - _f_i_l_e___p_r_o_g_r_e_s_s_(_) call cheaper and also only takes bytes that have passed │ │ │ │ - the hash check into account, so progress cannot regress in this mode. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - graceful_pause │ │ │ │ - will delay the disconnect of peers that we're still downloading │ │ │ │ - outstanding requests from. The torrent will not accept any more requests │ │ │ │ - and will disconnect all idle peers. As soon as a peer is done │ │ │ │ - transferring the blocks that were requested from it, it is disconnected. │ │ │ │ - This is a graceful shut down of the torrent in the sense that no │ │ │ │ - downloaded bytes are wasted. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flush_disk_cache │ │ │ │ - the disk cache will be flushed before creating the resume data. This │ │ │ │ - avoids a problem with file timestamps in the resume data in case the │ │ │ │ - cache hasn't been flushed yet. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - save_info_dict │ │ │ │ - the resume data will contain the metadata from the torrent file as well. │ │ │ │ - This is useful for clients that don't keep .torrent files around │ │ │ │ - separately, or for torrents that were added via a magnet link. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - if_counters_changed │ │ │ │ - save resume data if any _c_o_u_n_t_e_r_s has changed since the last time resume │ │ │ │ - data was saved. This includes upload/download _c_o_u_n_t_e_r_s, active time │ │ │ │ - _c_o_u_n_t_e_r_s and scrape data. A torrent that is not paused will have its │ │ │ │ - active time _c_o_u_n_t_e_r_s incremented continuously. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - if_download_progress │ │ │ │ - save the resume data if any blocks have been downloaded since the last │ │ │ │ - time resume data was saved. This includes: * checking existing files on │ │ │ │ - disk * downloading a block from a peer │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - if_config_changed │ │ │ │ - save the resume data if configuration options changed since last time the │ │ │ │ - resume data was saved. This includes: * file- or piece priorities * │ │ │ │ - upload- and download rate limits * change max-uploads (unchoke slots) * │ │ │ │ - change max connection limit * enable/disable peer-exchange, local service │ │ │ │ - discovery or DHT * enable/disable apply IP-filter * enable/disable auto- │ │ │ │ - managed * enable/disable share-mode * enable/disable sequential-mode * │ │ │ │ - files renamed * storage moved (save_path changed) │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - if_state_changed │ │ │ │ - save the resume data if torrent state has changed since last time the │ │ │ │ - resume data was saved. This includes: * upload mode * paused state * │ │ │ │ - super-seeding * seed-mode │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - if_metadata_changed │ │ │ │ - save the resume data if any mmeettaaddaattaa changed since the last time resume │ │ │ │ - data was saved. This includes: * add/remove web seeds * add/remove │ │ │ │ - trackers * receiving metadata for a magnet link │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - only_if_modified if_counters_changed │ │ │ │ - this flag has the same behavior as the combination of: │ │ │ │ - if_counters_changed | if_download_progress | if_config_changed | │ │ │ │ - if_state_changed | if_metadata_changed │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - ignore_min_interval │ │ │ │ - by default, force-reannounce will still honor the min-interval published │ │ │ │ - by the tracker. If this flag is set, it will be ignored and the tracker │ │ │ │ - is announced immediately. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - high_priority │ │ │ │ - by default, force-reannounce will queue the announce normally. If this │ │ │ │ - flag is set, the announce will be put at the front of the tracker queue │ │ │ │ - for immediate processing. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhaasshh__vvaalluuee(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___h_a_n_d_l_e_._h_p_p" │ │ │ │ -std::size_t hhaasshh__vvaalluuee (torrent_handle const& h); │ │ │ │ -for std::hash (and to support using this type in unordered_map etc.) │ │ │ │ -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: │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ooppeenn__ffiillee__ssttaattee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___i_n_t_e_r_f_a_c_e_._h_p_p" │ │ │ │ -this contains information about a file that's currently open by the libtorrent │ │ │ │ -disk I/O subsystem. It's associated with a single torrent. │ │ │ │ -struct open_file_state │ │ │ │ -{ │ │ │ │ - file_index_t file_index; │ │ │ │ - file_open_mode_t open_mode; │ │ │ │ - time_point last_use; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - file_index │ │ │ │ - the index of the file this _e_n_t_r_y refers to into the file_storage file │ │ │ │ - list of this torrent. This starts indexing at 0. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - open_mode │ │ │ │ - open_mode is a bitmask of the file flags this file is currently opened │ │ │ │ - with. For possible flags, see _f_i_l_e___o_p_e_n___m_o_d_e___t. │ │ │ │ - Note that the read/write mode is not a bitmask. The two least significant │ │ │ │ - bits are used to represent the read/write mode. Those bits can be masked │ │ │ │ - out using the rw_mask constant. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - last_use │ │ │ │ - a (high precision) timestamp of when the file was last used. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddiisskk__iinntteerrffaaccee ************ │ │ │ │ -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" │ │ │ │ -The _d_i_s_k___i_n_t_e_r_f_a_c_e is the customization point for disk I/O in libtorrent. │ │ │ │ -implement this interface and provide a factory function to the _s_e_s_s_i_o_n │ │ │ │ -constructor use custom disk I/O. All functions on the disk subsystem │ │ │ │ -(implementing _d_i_s_k___i_n_t_e_r_f_a_c_e) are called from within libtorrent's network │ │ │ │ -thread. For disk I/O to be performed in a separate thread, the disk subsystem │ │ │ │ -has to manage that itself. │ │ │ │ -Although the functions are called async_*, they do not technically hhaavvee to be │ │ │ │ -asynchronous, but they support being asynchronous, by expecting the result │ │ │ │ -passed back into a callback. The callbacks must be posted back onto the network │ │ │ │ -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 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 │ │ │ │ - , std::function handler) = 0; │ │ │ │ - virtual void aassyynncc__mmoovvee__ssttoorraaggee (storage_index_t storage, std::string p, │ │ │ │ -move_flags_t flags │ │ │ │ - , std::function │ │ │ │ -handler) = 0; │ │ │ │ - virtual void aassyynncc__rreelleeaassee__ffiilleess (storage_index_t storage │ │ │ │ - , std::function handler = std::function()) = 0; │ │ │ │ - virtual void aassyynncc__cchheecckk__ffiilleess (storage_index_t storage │ │ │ │ - , add_torrent_params const* resume_data │ │ │ │ - , aux::vector links │ │ │ │ - , std::function handler) = 0; │ │ │ │ - virtual void aassyynncc__ssttoopp__ttoorrrreenntt (storage_index_t storage │ │ │ │ - , std::function handler = std::function()) = 0; │ │ │ │ - virtual void aassyynncc__rreennaammee__ffiillee (storage_index_t storage │ │ │ │ - , file_index_t index, std::string name │ │ │ │ - , std::function handler) = 0; │ │ │ │ - virtual void aassyynncc__ddeelleettee__ffiilleess (storage_index_t storage, remove_flags_t │ │ │ │ -options │ │ │ │ - , std::function handler) = 0; │ │ │ │ - virtual void aassyynncc__sseett__ffiillee__pprriioorriittyy (storage_index_t storage │ │ │ │ - , aux::vector prio │ │ │ │ - , std::function)> handler) = 0; │ │ │ │ - virtual void aassyynncc__cclleeaarr__ppiieeccee (storage_index_t storage, piece_index_t index │ │ │ │ - , std::function handler) = 0; │ │ │ │ - virtual void uuppddaattee__ssttaattss__ccoouunntteerrss (counters& c) const = 0; │ │ │ │ - virtual std::vector ggeett__ssttaattuuss (storage_index_t) const = 0; │ │ │ │ - virtual void aabboorrtt (bool wait) = 0; │ │ │ │ - virtual void ssuubbmmiitt__jjoobbss () = 0; │ │ │ │ - virtual void sseettttiinnggss__uuppddaatteedd () = 0; │ │ │ │ - │ │ │ │ - static inline constexpr disk_job_flags_t ffoorrccee__ccooppyy = 0_bit; │ │ │ │ - static inline constexpr disk_job_flags_t sseeqquueennttiiaall__aacccceessss = 3_bit; │ │ │ │ - static inline constexpr disk_job_flags_t vvoollaattiillee__rreeaadd = 4_bit; │ │ │ │ - static inline constexpr disk_job_flags_t vv11__hhaasshh = 5_bit; │ │ │ │ - static constexpr disk_job_flags_t fflluusshh__ppiieeccee = 7_bit; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nneeww__ttoorrrreenntt(()) ********** │ │ │ │ -virtual storage_holder nneeww__ttoorrrreenntt (storage_params const& p │ │ │ │ - , std::shared_ptr const& torrent) = 0; │ │ │ │ -this is called when a new torrent is added. The shared_ptr can be used to hold │ │ │ │ -the internal torrent object alive as long as there are outstanding disk │ │ │ │ -operations on the storage. The returned _s_t_o_r_a_g_e___h_o_l_d_e_r is an owning reference │ │ │ │ -to the underlying storage that was just created. It is fundamentally a │ │ │ │ -storage_index_t │ │ │ │ -[_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__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 │ │ │ │ -will stop further writes and wait for the passed-in disk_observer to be │ │ │ │ -notified before resuming. │ │ │ │ -Note that for async_read, the _p_e_e_r___r_e_q_u_e_s_t (r) is not necessarily aligned to │ │ │ │ -blocks (but it is most of the time). However, all writes (passed to │ │ │ │ -async_write) are guaranteed to be block aligned. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__hhaasshh(()) ********** │ │ │ │ -virtual void aassyynncc__hhaasshh (storage_index_t storage, piece_index_t piece, │ │ │ │ -span v2 │ │ │ │ - , disk_job_flags_t flags │ │ │ │ - , std::function handler) = 0; │ │ │ │ -Compute hash(es) for the specified piece. Unless the v1_hash flag is set (in │ │ │ │ -flags), the SHA-1 hash of the whole piece does not need to be computed. │ │ │ │ -Thev2span is optional and can be empty, which means v2 hashes should not be │ │ │ │ -computed. If v2 is non-empty it must be at least large enough to hold all v2 │ │ │ │ -blocks in the piece, and this function will fill in the span with the SHA-256 │ │ │ │ -block hashes of the piece. │ │ │ │ -The contents of thev2span on _e_n_t_r_y are not read by the implementation; it is │ │ │ │ -treated as output only. Callers may safely reuse the same buffer across pieces │ │ │ │ -without clearing it. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__hhaasshh22(()) ********** │ │ │ │ -virtual void aassyynncc__hhaasshh22 (storage_index_t storage, piece_index_t piece, int │ │ │ │ -offset, disk_job_flags_t flags │ │ │ │ - , std::function handler) = 0; │ │ │ │ -computes the v2 hash (SHA-256) of a single block. The block at offset in piece │ │ │ │ -piece. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__mmoovvee__ssttoorraaggee(()) ********** │ │ │ │ -virtual void aassyynncc__mmoovvee__ssttoorraaggee (storage_index_t storage, std::string p, │ │ │ │ -move_flags_t flags │ │ │ │ - , std::function │ │ │ │ -handler) = 0; │ │ │ │ -called to request the files for the specified storage/torrent be moved to a new │ │ │ │ -location. It is the disk I/O object's responsibility to synchronize this with │ │ │ │ -any currently outstanding disk operations to the storage. Whether files are │ │ │ │ -replaced at the destination path or not is controlled by flags (see │ │ │ │ -_m_o_v_e___f_l_a_g_s___t). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__rreelleeaassee__ffiilleess(()) ********** │ │ │ │ -virtual void aassyynncc__rreelleeaassee__ffiilleess (storage_index_t storage │ │ │ │ - , std::function handler = std::function()) = 0; │ │ │ │ -This is called on disk I/O objects to request they close all open files for the │ │ │ │ -specified storage/torrent. If file handles are not pooled/cached, it can be a │ │ │ │ -no-op. For truly asynchronous disk I/O, this should provide at least one point │ │ │ │ -in time when all files are closed. It is possible that later asynchronous │ │ │ │ -operations will re-open some of the files, by the time this completion handler │ │ │ │ -is called, that's fine. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__cchheecckk__ffiilleess(()) ********** │ │ │ │ -virtual void aassyynncc__cchheecckk__ffiilleess (storage_index_t storage │ │ │ │ - , add_torrent_params const* resume_data │ │ │ │ - , aux::vector links │ │ │ │ - , std::function handler) = 0; │ │ │ │ -this is called when torrents are added to validate their resume data against │ │ │ │ -the files on disk. This function is expected to do a few things: │ │ │ │ -if links is non-empty, it contains a string for each file in the torrent. The │ │ │ │ -string being a path to an existing identical file. The default behavior is to │ │ │ │ -create hard links of those files into the storage of the new torrent (specified │ │ │ │ -by storage). An empty string indicates that there is no known identical file. │ │ │ │ -This is part of the "mutable torrent" feature, where files can be reused from │ │ │ │ -other torrents. │ │ │ │ -The resume_data points the resume data passed in by the client. │ │ │ │ -If the resume_data->flags field has the seed_mode flag set, all files/pieces │ │ │ │ -are expected to be on disk already. This should be verified. Not just the │ │ │ │ -existence of the file, but also that it has the correct size. │ │ │ │ -Any file with a piece set in the resume_data->have_pieces bitmask should exist │ │ │ │ -on disk, this should be verified. Pad files and files with zero priority may be │ │ │ │ -skipped. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__ssttoopp__ttoorrrreenntt(()) ********** │ │ │ │ -virtual void aassyynncc__ssttoopp__ttoorrrreenntt (storage_index_t storage │ │ │ │ - , std::function handler = std::function()) = 0; │ │ │ │ -This is called when a torrent is stopped. It gives the disk I/O object an │ │ │ │ -opportunity to flush any data to disk that's currently kept cached. This │ │ │ │ -function should at least do the same thing as _a_s_y_n_c___r_e_l_e_a_s_e___f_i_l_e_s_(_). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__rreennaammee__ffiillee(()) ********** │ │ │ │ -virtual void aassyynncc__rreennaammee__ffiillee (storage_index_t storage │ │ │ │ - , file_index_t index, std::string name │ │ │ │ - , std::function handler) = 0; │ │ │ │ -This function is called when the name of a file in the specified storage has │ │ │ │ -been requested to be renamed. The disk I/O object is responsible for renaming │ │ │ │ -the file without racing with other potentially outstanding operations against │ │ │ │ -the file (such as read, write, move, etc.). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__ddeelleettee__ffiilleess(()) ********** │ │ │ │ -virtual void aassyynncc__ddeelleettee__ffiilleess (storage_index_t storage, remove_flags_t │ │ │ │ -options │ │ │ │ - , std::function handler) = 0; │ │ │ │ -This function is called when some file(s) on disk have been requested to be │ │ │ │ -removed by the client. storage indicates which torrent is referred to. See │ │ │ │ -_s_e_s_s_i_o_n___h_a_n_d_l_e for remove_flags_t flags indicating which files are to be │ │ │ │ -removed. e.g. _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_d_e_l_e_t_e___f_i_l_e_s - delete all files _s_e_s_s_i_o_n___h_a_n_d_l_e_:_: │ │ │ │ -_d_e_l_e_t_e___p_a_r_t_f_i_l_e - only delete part file. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__sseett__ffiillee__pprriioorriittyy(()) ********** │ │ │ │ -virtual void aassyynncc__sseett__ffiillee__pprriioorriittyy (storage_index_t storage │ │ │ │ - , aux::vector prio │ │ │ │ - , std::function)> handler) = 0; │ │ │ │ -This is called to set the priority of some or all files. Changing the priority │ │ │ │ -from or to 0 may involve moving data to and from the partfile. The disk I/ │ │ │ │ -O object is responsible for correctly synchronizing this work to not race with │ │ │ │ -any potentially outstanding asynchronous operations affecting these files. │ │ │ │ -prio is a vector of the file priority for all files. If it's shorter than the │ │ │ │ -total number of files in the torrent, they are assumed to be set to the default │ │ │ │ -priority. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__cclleeaarr__ppiieeccee(()) ********** │ │ │ │ -virtual void aassyynncc__cclleeaarr__ppiieeccee (storage_index_t storage, piece_index_t index │ │ │ │ - , std::function handler) = 0; │ │ │ │ -This is called when a piece fails the hash check, to ensure there are no │ │ │ │ -outstanding disk operations to the piece before blocks are re-requested from │ │ │ │ -peers to overwrite the existing blocks. The disk I/O object does not need to │ │ │ │ -perform any action other than synchronize with all outstanding disk operations │ │ │ │ -to the specified piece before posting the result back. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** uuppddaattee__ssttaattss__ccoouunntteerrss(()) ********** │ │ │ │ -virtual void uuppddaattee__ssttaattss__ccoouunntteerrss (counters& c) const = 0; │ │ │ │ -_u_p_d_a_t_e___s_t_a_t_s___c_o_u_n_t_e_r_s_(_) is called to give the disk storage an opportunity to │ │ │ │ -update gauges in the c stats _c_o_u_n_t_e_r_s, that aren't updated continuously as │ │ │ │ -operations are performed. This is called before a snapshot of the _c_o_u_n_t_e_r_s are │ │ │ │ -passed to the client. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__ssttaattuuss(()) ********** │ │ │ │ -virtual std::vector ggeett__ssttaattuuss (storage_index_t) const = 0; │ │ │ │ -Return a list of all the files that are currently open for the specified │ │ │ │ -storage/torrent. This is is just used for the client to query the currently │ │ │ │ -open files, and which modes those files are open in. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aabboorrtt(()) ********** │ │ │ │ -virtual void aabboorrtt (bool wait) = 0; │ │ │ │ -this is called when the _s_e_s_s_i_o_n is starting to shut down. The disk I/O object │ │ │ │ -is expected to flush any outstanding write jobs, cancel hash jobs and initiate │ │ │ │ -tearing down of any internal threads. If wait is true, this should be │ │ │ │ -asynchronous. i.e. this call should not return until all threads have stopped │ │ │ │ -and all jobs have either been aborted or completed and the disk I/O object is │ │ │ │ -ready to be destructed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssuubbmmiitt__jjoobbss(()) ********** │ │ │ │ -virtual void ssuubbmmiitt__jjoobbss () = 0; │ │ │ │ -This will be called after a batch of disk jobs has been issues (via the async_* │ │ │ │ -). It gives the disk I/O object an opportunity to notify any potential │ │ │ │ -condition variables to wake up the disk thread(s). The async_* calls can of │ │ │ │ -course also notify condition variables, but doing it in this call allows for │ │ │ │ -batching jobs, by issuing the notification once for a collection of jobs. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseettttiinnggss__uuppddaatteedd(()) ********** │ │ │ │ -virtual void sseettttiinnggss__uuppddaatteedd () = 0; │ │ │ │ -This is called to notify the disk I/O object that the settings have been │ │ │ │ -updated. In the disk io constructor, a _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e reference is passed │ │ │ │ -in. Whenever these settings are updated, this function is called to allow the │ │ │ │ -disk I/O object to react to any changed settings relevant to its operations. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - force_copy │ │ │ │ - force making a copy of the cached block, rather than getting a reference │ │ │ │ - to a block already in the cache. This is used the block is expected to be │ │ │ │ - overwritten very soon, by _a_s_y_n_c___w_r_i_t_e_(_), and we need access to the │ │ │ │ - previous content. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - sequential_access │ │ │ │ - hint that there may be more disk operations with sequential access to the │ │ │ │ - file │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - volatile_read │ │ │ │ - don't keep the read block in cache. This is a hint that this block is │ │ │ │ - unlikely to be read again anytime soon, and caching it would be wasteful. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - v1_hash │ │ │ │ - compute a v1 piece hash. This is only used by the _a_s_y_n_c___h_a_s_h_(_) call. If │ │ │ │ - this flag is not set in the _a_s_y_n_c___h_a_s_h_(_) call, the SHA-1 piece hash does │ │ │ │ - not need to be computed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flush_piece │ │ │ │ - this flag instructs a hash job that we just completed this piece, and it │ │ │ │ - should be flushed to disk │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttoorraaggee__hhoollddeerr ************ │ │ │ │ -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" │ │ │ │ -a unique, owning, reference to the storage of a torrent in a disk io subsystem │ │ │ │ -(class that implements _d_i_s_k___i_n_t_e_r_f_a_c_e). This is held by the internal libtorrent │ │ │ │ -torrent object to tie the storage object allocated for a torrent to the │ │ │ │ -lifetime of the internal torrent object. When a torrent is removed from the │ │ │ │ -_s_e_s_s_i_o_n, this holder is destructed and will inform the disk object. │ │ │ │ -struct storage_holder │ │ │ │ -{ │ │ │ │ - ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io); │ │ │ │ - ~~ssttoorraaggee__hhoollddeerr (); │ │ │ │ - ssttoorraaggee__hhoollddeerr () = default; │ │ │ │ - explicit operator bbooooll () const; │ │ │ │ - operator ssttoorraaggee__iinnddeexx__tt () const; │ │ │ │ - void rreesseett (); │ │ │ │ - storage_holder& ooppeerraattoorr== (storage_holder const&) = delete; │ │ │ │ - ssttoorraaggee__hhoollddeerr (storage_holder const&) = delete; │ │ │ │ - ssttoorraaggee__hhoollddeerr (storage_holder&& rhs) noexcept; │ │ │ │ - storage_holder& ooppeerraattoorr== (storage_holder&& rhs) noexcept; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssttoorraaggee__hhoollddeerr(()) ********** │ │ │ │ -ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io); │ │ │ │ -constructs a storage holder, for storage idx held at disk interface disk_io. │ │ │ │ -When the holder is destructed or reset, disk_io will be notified that the │ │ │ │ -storage can be removed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseett(()) ********** │ │ │ │ -void rreesseett (); │ │ │ │ -release ownership of the storage, removing the torrent from the disk subsystem. │ │ │ │ -After this call the holder is empty and operator bool() returns false. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddiisskk__oobbsseerrvveerr ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___o_b_s_e_r_v_e_r_._h_p_p" │ │ │ │ -callback interface used to be notified when the disk write queue has drained │ │ │ │ -below the low watermark. When the disk subsystem applies back-pressure, peers │ │ │ │ -wanting to upload are paused; once the queue drains, on_disk() is invoked so │ │ │ │ -that those peers can resume. │ │ │ │ -struct disk_observer │ │ │ │ -{ │ │ │ │ - virtual void oonn__ddiisskk () = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** oonn__ddiisskk(()) ********** │ │ │ │ -virtual void oonn__ddiisskk () = 0; │ │ │ │ -called when the disk cache size has dropped below the low watermark again and │ │ │ │ -we can resume downloading from peers │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bbuuffffeerr__aallllooccaattoorr__iinntteerrffaaccee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p" │ │ │ │ -the interface for freeing disk buffers, used by the _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r. when │ │ │ │ -implementing _d_i_s_k___i_n_t_e_r_f_a_c_e, this must also be implemented in order to return │ │ │ │ -disk buffers back to libtorrent │ │ │ │ -struct buffer_allocator_interface │ │ │ │ -{ │ │ │ │ - virtual void ffrreeee__ddiisskk__bbuuffffeerr (char* b) = 0; │ │ │ │ - virtual void ffrreeee__mmuullttiippllee__bbuuffffeerrss (span bufs) = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffrreeee__mmuullttiippllee__bbuuffffeerrss(()) ffrreeee__ddiisskk__bbuuffffeerr(()) ********** │ │ │ │ -virtual void ffrreeee__ddiisskk__bbuuffffeerr (char* b) = 0; │ │ │ │ -virtual void ffrreeee__mmuullttiippllee__bbuuffffeerrss (span bufs) = 0; │ │ │ │ -returns one or more disk buffers (previously handed out by the disk subsystem) │ │ │ │ -back to the allocator. The bulk overload, free_multiple_buffers(), lets callers │ │ │ │ -free a batch of buffers under a single mutex acquisition. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddiisskk__bbuuffffeerr__hhoollddeerr ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p" │ │ │ │ -The disk buffer holder acts like a unique_ptr that frees a disk buffer when │ │ │ │ -it's destructed │ │ │ │ -If this buffer holder is moved-from, default constructed or reset, data() will │ │ │ │ -return nullptr. │ │ │ │ -struct disk_buffer_holder │ │ │ │ -{ │ │ │ │ - disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder&&) & noexcept; │ │ │ │ - ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder&&) noexcept; │ │ │ │ - disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder const&) = delete; │ │ │ │ - ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder const&) = delete; │ │ │ │ - ddiisskk__bbuuffffeerr__hhoollddeerr (buffer_allocator_interface& alloc, char* buf) 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; │ │ │ │ - explicit operator bbooooll () const noexcept; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddiisskk__bbuuffffeerr__hhoollddeerr(()) ********** │ │ │ │ -ddiisskk__bbuuffffeerr__hhoollddeerr (buffer_allocator_interface& alloc, char* buf) noexcept; │ │ │ │ -construct a buffer holder that will free the held buffer using a disk buffer │ │ │ │ -pool directly (there's only one disk_buffer_pool per _s_e_s_s_i_o_n) │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddiisskk__bbuuffffeerr__hhoollddeerr(()) ********** │ │ │ │ -ddiisskk__bbuuffffeerr__hhoollddeerr () noexcept = default; │ │ │ │ -default construct a holder that does not own any buffer │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~ddiisskk__bbuuffffeerr__hhoollddeerr(()) ********** │ │ │ │ -~~ddiisskk__bbuuffffeerr__hhoollddeerr (); │ │ │ │ -frees disk buffer held by this object │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddaattaa(()) ********** │ │ │ │ -char* ddaattaa () const noexcept; │ │ │ │ -return a pointer to the held buffer, if any. Otherwise returns nullptr. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseett(()) ********** │ │ │ │ -void rreesseett (); │ │ │ │ -free the held disk buffer, if any, and clear the holder. This sets the holder │ │ │ │ -object to a default-constructed state │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sswwaapp(()) ********** │ │ │ │ -void sswwaapp (disk_buffer_holder& h) noexcept; │ │ │ │ -swap pointers of two disk buffer holders. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iiss__mmuuttaabbllee(()) ********** │ │ │ │ -bool iiss__mmuuttaabbllee () const noexcept; │ │ │ │ -if this returns true, the buffer may not be modified in place │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bbooooll(()) ********** │ │ │ │ -explicit operator bbooooll () const noexcept; │ │ │ │ -implicitly convertible to true if the object is currently holding a buffer │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddiisskk__bbuuffffeerr__rreeff ************ │ │ │ │ -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" │ │ │ │ -Pointer-only disk buffer reference. Holds a char* but neither the allocator nor │ │ │ │ -the size. Has unique_ptr-like move semantics. The destructor asserts that the │ │ │ │ -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 (disk_buffer_ref const&) = delete; │ │ │ │ - ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref&&) noexcept; │ │ │ │ - ~~ddiisskk__bbuuffffeerr__rreeff (); │ │ │ │ - disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref&&) noexcept; │ │ │ │ - disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref const&) = delete; │ │ │ │ - char* ddaattaa () const noexcept; │ │ │ │ - explicit operator bbooooll () 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; │ │ │ │ -explicit operator bbooooll () 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); │ │ │ │ -}; │ │ │ │ -[_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] │ │ │ │ -********** aadddd(()) ~~bbuullkk__ffrreeee__bbuuffffeerr(()) ********** │ │ │ │ -~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ -void aadddd (disk_buffer_ref r); │ │ │ │ -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__iinntt (int name, int val) = 0; │ │ │ │ - virtual void sseett__ssttrr (int name, std::string 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__bbooooll(()) sseett__ssttrr(()) sseett__iinntt(()) ********** │ │ │ │ -virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ -virtual void sseett__ssttrr (int name, std::string 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__ssttrr(()) ggeett__bbooooll(()) ggeett__iinntt(()) ********** │ │ │ │ -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] │ │ │ │ -************ 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 │ │ │ │ - returned from check_fastresume to indicate that resume data failed │ │ │ │ - validation and a full piece-hash check is required. │ │ │ │ - file_exist │ │ │ │ - returned from move_storage when the destination already exists and the │ │ │ │ - dont_replace flag was set. │ │ │ │ - oversized_file │ │ │ │ - returned from check_fastresume when a file on disk is larger than the │ │ │ │ - size recorded in the .torrent metadata. This triggers an _a_l_e_r_t to let the │ │ │ │ - user decide whether to truncate the file or save the torrent in another │ │ │ │ - directory. │ │ │ │ - job_deferred │ │ │ │ - Returned by do_job(hash) when the job was hung on a cache piece. │ │ │ │ - kick_hasher will post it to completed_jobs once hashing finishes. │ │ │ │ - perform_job() checks this flag before writing j->ret. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__ooppeenn__mmooddee__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" │ │ │ │ - read_only │ │ │ │ - open the file for reading only │ │ │ │ - write_only │ │ │ │ - open the file for writing only │ │ │ │ - read_write │ │ │ │ - open the file for reading and writing │ │ │ │ - rw_mask │ │ │ │ - the mask for the bits determining read or write mode │ │ │ │ - sparse │ │ │ │ - open the file in sparse mode (if supported by the filesystem). │ │ │ │ - no_atime │ │ │ │ - don't update the access timestamps on the file (if supported by the │ │ │ │ - operating system and filesystem). this generally improves disk │ │ │ │ - performance. │ │ │ │ - random_access │ │ │ │ - When this is not set, the kernel is hinted that access to this file will │ │ │ │ - be made sequentially. │ │ │ │ - mmapped │ │ │ │ - the file is memory mapped │ │ │ │ -The _p_o_p___a_l_e_r_t_s_(_) function on _s_e_s_s_i_o_n is the main interface for retrieving │ │ │ │ -alerts (warnings, messages and errors from libtorrent). If no alerts have been │ │ │ │ -posted by libtorrent _p_o_p___a_l_e_r_t_s_(_) will return an empty list. │ │ │ │ -By default, only errors are reported. _s_e_t_t_i_n_g_s___p_a_c_k_:_:_a_l_e_r_t___m_a_s_k can be used to │ │ │ │ -specify which kinds of events should be reported. The _a_l_e_r_t mask is a │ │ │ │ -combination of the _a_l_e_r_t___c_a_t_e_g_o_r_y___t flags in the _a_l_e_r_t class. │ │ │ │ -Every _a_l_e_r_t belongs to one or more category. There is a cost associated with │ │ │ │ -posting alerts. Only alerts that belong to an enabled category are posted. │ │ │ │ -Setting the _a_l_e_r_t bitmask to 0 will disable all alerts (except those that are │ │ │ │ -non-discardable). Alerts that are responses to API calls such as │ │ │ │ -_s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) and _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) are non-discardable and will be │ │ │ │ -posted even if their category is disabled. │ │ │ │ -There are other _a_l_e_r_t base classes that some alerts derive from, all the alerts │ │ │ │ -that are generated for a specific torrent are derived from _t_o_r_r_e_n_t___a_l_e_r_t, and │ │ │ │ -tracker events derive from _t_r_a_c_k_e_r___a_l_e_r_t. │ │ │ │ -Alerts returned by _p_o_p___a_l_e_r_t_s_(_) are only valid until the next call to │ │ │ │ -_p_o_p___a_l_e_r_t_s_(_). You may not copy an _a_l_e_r_t object to access it after the next call │ │ │ │ -to _p_o_p___a_l_e_r_t_s_(_). Internal members of alerts also become invalid once _p_o_p___a_l_e_r_t_s │ │ │ │ -_(_) is called again. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t_._h_p_p" │ │ │ │ -The alert class is the base class that specific messages are derived from. │ │ │ │ -_a_l_e_r_t types are not copyable, and cannot be constructed by the client. The │ │ │ │ -pointers returned by libtorrent are short lived (the details are described │ │ │ │ -under _s_e_s_s_i_o_n___h_a_n_d_l_e_:_:_p_o_p___a_l_e_r_t_s_(_)) │ │ │ │ -struct alert │ │ │ │ -{ │ │ │ │ - time_point ttiimmeessttaammpp () const; │ │ │ │ - virtual int ttyyppee () const noexcept = 0; │ │ │ │ - virtual char const* wwhhaatt () const noexcept = 0; │ │ │ │ - virtual std::string mmeessssaaggee () const = 0; │ │ │ │ - virtual alert_category_t ccaatteeggoorryy () const noexcept = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttiimmeessttaammpp(()) ********** │ │ │ │ -time_point ttiimmeessttaammpp () const; │ │ │ │ -a timestamp is automatically created in the constructor │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttyyppee(()) ********** │ │ │ │ -virtual int ttyyppee () const noexcept = 0; │ │ │ │ -returns an integer that is unique to this _a_l_e_r_t type. It can be compared │ │ │ │ -against a specific _a_l_e_r_t by querying a static constant called alert_type in the │ │ │ │ -_a_l_e_r_t. It can be used to determine the run-time type of an alert* in order to │ │ │ │ -cast to that _a_l_e_r_t type and access specific members. │ │ │ │ -e.g: │ │ │ │ -std::vector alerts; │ │ │ │ -ses.pop_alerts(&alerts); │ │ │ │ -for (alert* a : alerts) { │ │ │ │ - switch (a->type()) { │ │ │ │ - │ │ │ │ - case read_piece_alert::alert_type: │ │ │ │ - { │ │ │ │ - auto* p = static_cast(a); │ │ │ │ - if (p->ec) { │ │ │ │ - // read_piece failed │ │ │ │ - break; │ │ │ │ - } │ │ │ │ - // use p │ │ │ │ - break; │ │ │ │ - } │ │ │ │ - case file_renamed_alert::alert_type: │ │ │ │ - { │ │ │ │ - // etc... │ │ │ │ - } │ │ │ │ - } │ │ │ │ -} │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** wwhhaatt(()) ********** │ │ │ │ -virtual char const* wwhhaatt () const noexcept = 0; │ │ │ │ -returns a string literal describing the type of the _a_l_e_r_t. It does not include │ │ │ │ -any information that might be bundled with the _a_l_e_r_t. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmeessssaaggee(()) ********** │ │ │ │ -virtual std::string mmeessssaaggee () const = 0; │ │ │ │ -generate a string describing the _a_l_e_r_t and the information bundled with it. │ │ │ │ -This is mainly intended for debug and development use. It is not suitable to │ │ │ │ -use this for applications that may be localized. Instead, handle each _a_l_e_r_t │ │ │ │ -type individually and extract and render the information from the _a_l_e_r_t │ │ │ │ -depending on the locale. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccaatteeggoorryy(()) ********** │ │ │ │ -virtual alert_category_t ccaatteeggoorryy () const noexcept = 0; │ │ │ │ -returns a bitmask specifying which categories this _a_l_e_r_t belong to. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__rroouuttiinngg__bbuucckkeett ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -struct to hold information about a single DHT routing table bucket │ │ │ │ -struct dht_routing_bucket │ │ │ │ -{ │ │ │ │ - int nnuumm__nnooddeess = 0; │ │ │ │ - int nnuumm__rreeppllaacceemmeennttss = 0; │ │ │ │ - int llaasstt__aaccttiivvee = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - num_nodes num_replacements │ │ │ │ - the total number of nodes and replacement nodes in the routing table │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - last_active │ │ │ │ - number of seconds since last activity │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is a base class for alerts that are associated with a specific torrent. It │ │ │ │ -contains a handle to the torrent. │ │ │ │ -Note that by the time the client receives a _t_o_r_r_e_n_t___a_l_e_r_t, its handle member │ │ │ │ -may be invalid. │ │ │ │ -struct torrent_alert : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - torrent_handle handle; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmeessssaaggee(()) ********** │ │ │ │ -std::string mmeessssaaggee () const override; │ │ │ │ -returns the message associated with this _a_l_e_r_t │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - handle │ │ │ │ - The _t_o_r_r_e_n_t___h_a_n_d_l_e pointing to the torrent this _a_l_e_r_t is associated with. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -The peer _a_l_e_r_t is a base class for alerts that refer to a specific peer. It │ │ │ │ -includes all the information to identify the peer. i.e. ip and peer-id. │ │ │ │ -struct peer_alert : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - enum endpoint_type_t │ │ │ │ - { │ │ │ │ - ip_endpoint, │ │ │ │ - i2p_endpoint, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - peer_endpoint_t ep; │ │ │ │ - peer_id pid; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm eennddppooiinntt__ttyyppee__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_i_p___e_n_d_p_o_i_n_t_ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_2_p___e_n_d_p_o_i_n_t_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - ep │ │ │ │ - The peer's endpoint, either IP address and port or i2p destination hash. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - pid │ │ │ │ - the peer ID, if known. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrraacckkeerr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is a base class used for alerts that are associated with a specific │ │ │ │ -tracker. It derives from _t_o_r_r_e_n_t___a_l_e_r_t since a tracker is also associated with │ │ │ │ -a specific torrent. │ │ │ │ -struct tracker_alert : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* ttrraacckkeerr__uurrll () const; │ │ │ │ - │ │ │ │ - aux::noexcept_movable<_t_c_p_:_:_e_n_d_p_o_i_n_t> local_endpoint; │ │ │ │ - protocol_version version; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttrraacckkeerr__uurrll(()) ********** │ │ │ │ -char const* ttrraacckkeerr__uurrll () const; │ │ │ │ -returns a 0-terminated string of the tracker's URL │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - local_endpoint │ │ │ │ - endpoint of the listen interface being announced │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - version │ │ │ │ - the bittorrent protocol version that was announced │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__rreemmoovveedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -The torrent_removed_alert is posted whenever a torrent is removed. Since the │ │ │ │ -torrent handle in its base class will usually be invalid (since the torrent is │ │ │ │ -already removed) it has the info hash as a member, to identify it. It's posted │ │ │ │ -when the alert_category::status bit is set in the alert_mask. │ │ │ │ -Note that the handle remains valid for some time after _t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t is │ │ │ │ -posted, as long as some internal libtorrent task (such as an I/O task) refers │ │ │ │ -to it. Additionally, other alerts like _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t may be posted │ │ │ │ -after _t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t. To synchronize on whether the torrent has been │ │ │ │ -removed or not, call _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_i_n___s_e_s_s_i_o_n_(_). This will return true before │ │ │ │ -_t_o_r_r_e_n_t___r_e_m_o_v_e_d___a_l_e_r_t is posted, and false afterward. │ │ │ │ -Even though the handle member doesn't point to an existing torrent anymore, it │ │ │ │ -is still useful for comparing to other handles, which may also no longer point │ │ │ │ -to existing torrents, but to the same non-existing torrents. │ │ │ │ -The torrent_handle acts as a weak_ptr, even though its object no longer exists, │ │ │ │ -it can still compare equal to another weak pointer which points to the same │ │ │ │ -non-existent object. │ │ │ │ -struct torrent_removed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ - info_hash_t info_hashes; │ │ │ │ - client_data_t userdata; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - userdata │ │ │ │ - 'userdata`as set in _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s at torrent creation. This can be │ │ │ │ - used to associate this torrent with related data in the client │ │ │ │ - application more efficiently than info_hashes. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ rreeaadd__ppiieeccee__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when the asynchronous read operation initiated by a call │ │ │ │ -to _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_a_d___p_i_e_c_e_(_) is completed. If the read failed, the torrent │ │ │ │ -is paused and an error state is set and the buffer member of the _a_l_e_r_t is 0. If │ │ │ │ -successful, buffer points to a buffer containing all the data of the piece. │ │ │ │ -piece is the piece index that was read. size is the number of bytes that was │ │ │ │ -read. │ │ │ │ -If the operation fails, error will indicate what went wrong. │ │ │ │ -struct read_piece_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ - error_code const error; │ │ │ │ - boost::shared_array const buffer; │ │ │ │ - piece_index_t const piece; │ │ │ │ - int const size; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__ccoommpplleetteedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is posted whenever an individual file completes its download. i.e. All │ │ │ │ -pieces overlapping this file have passed their hash check. │ │ │ │ -struct file_completed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - file_index_t const index; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - index │ │ │ │ - refers to the index of the file that completed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__rreennaammeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is posted as a response to a _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_n_a_m_e___f_i_l_e_(_) call, if the │ │ │ │ -rename operation succeeds. │ │ │ │ -struct file_renamed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* oolldd__nnaammee () const; │ │ │ │ - char const* nneeww__nnaammee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ - file_index_t const index; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nneeww__nnaammee(()) oolldd__nnaammee(()) ********** │ │ │ │ -char const* oolldd__nnaammee () const; │ │ │ │ -char const* nneeww__nnaammee () const; │ │ │ │ -returns the new and previous file name, respectively. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - index │ │ │ │ - refers to the index of the file that was renamed, │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__rreennaammee__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is posted as a response to a _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_n_a_m_e___f_i_l_e_(_) call, if the │ │ │ │ -rename operation failed. │ │ │ │ -struct file_rename_failed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ - file_index_t const index; │ │ │ │ - error_code const error; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - index error │ │ │ │ - refers to the index of the file that was supposed to be renamed, error is │ │ │ │ - the error code returned from the filesystem. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeerrffoorrmmaannccee__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a limit is reached that might have a negative │ │ │ │ -impact on upload or download rate performance. │ │ │ │ -struct performance_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - enum performance_warning_t │ │ │ │ - { │ │ │ │ - outstanding_disk_buffer_limit_reached, │ │ │ │ - outstanding_request_limit_reached, │ │ │ │ - upload_limit_too_low, │ │ │ │ - download_limit_too_low, │ │ │ │ - send_buffer_watermark_too_low, │ │ │ │ - too_many_optimistic_unchoke_slots, │ │ │ │ - too_high_disk_queue_limit, │ │ │ │ - aio_limit_reached, │ │ │ │ - deprecated_bittyrant_with_no_uplimit, │ │ │ │ - too_few_outgoing_ports, │ │ │ │ - too_few_file_descriptors, │ │ │ │ - num_warnings, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -performance_warning; │ │ │ │ - performance_warning_t const warning_code; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ppeerrffoorrmmaannccee__wwaarrnniinngg__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |This warning means that the | │ │ │ │ -| | |number of bytes queued to be | │ │ │ │ -| | |written to disk exceeds the max | │ │ │ │ -| | |disk byte queue setting | │ │ │ │ -| | |(settings_pack:: | │ │ │ │ -| | |max_queued_disk_bytes). This | │ │ │ │ -| | |might restrict the download rate,| │ │ │ │ -| | |by not queuing up enough write | │ │ │ │ -|outstanding_disk_buffer_limit_reached|0 |jobs to the disk I/O thread. When| │ │ │ │ -| | |this _a_l_e_r_t is posted, peer | │ │ │ │ -| | |connections are temporarily | │ │ │ │ -| | |stopped from downloading, until | │ │ │ │ -| | |the queued disk bytes have fallen| │ │ │ │ -| | |below the limit again. Unless | │ │ │ │ -| | |your max_queued_disk_bytes | │ │ │ │ -| | |setting is already high, you | │ │ │ │ -| | |might want to increase it to get | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_e_t_t_e_r_ _p_e_r_f_o_r_m_a_n_c_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |This is posted when libtorrent | │ │ │ │ -| | |would like to send more requests | │ │ │ │ -| | |to a peer, but it's limited by | │ │ │ │ -| | |settings_pack:: | │ │ │ │ -| | |max_out_request_queue. The queue | │ │ │ │ -| | |length libtorrent is trying to | │ │ │ │ -| | |achieve is determined by the | │ │ │ │ -| | |download rate and the assumed | │ │ │ │ -| | |round-trip-time (settings_pack:: | │ │ │ │ -| | |request_queue_time). The assumed | │ │ │ │ -| | |round-trip-time is not limited to| │ │ │ │ -| | |just the network RTT, but also | │ │ │ │ -|outstanding_request_limit_reached |1 |the remote disk access time and | │ │ │ │ -| | |message handling time. It | │ │ │ │ -| | |defaults to 3 seconds. The target| │ │ │ │ -| | |number of outstanding requests is| │ │ │ │ -| | |set to fill the bandwidth-delay | │ │ │ │ -| | |product (assumed RTT times | │ │ │ │ -| | |download rate divided by number | │ │ │ │ -| | |of bytes per request). When this | │ │ │ │ -| | |_a_l_e_r_t is posted, there is a risk | │ │ │ │ -| | |that the number of outstanding | │ │ │ │ -| | |requests is too low and limits | │ │ │ │ -| | |the download rate. You might want| │ │ │ │ -| | |to increase the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_x___o_u_t___r_e_q_u_e_s_t___q_u_e_u_e_ _s_e_t_t_i_n_g_._ _ _ | │ │ │ │ -| | |This warning is posted when the | │ │ │ │ -| | |amount of TCP/IP overhead is | │ │ │ │ -| | |greater than the upload rate | │ │ │ │ -| | |limit. When this happens, the | │ │ │ │ -| | |TCP/IP overhead is caused by a | │ │ │ │ -| | |much faster download rate, | │ │ │ │ -| | |triggering TCP ACK packets. These| │ │ │ │ -| | |packets eat into the rate limit | │ │ │ │ -| | |specified to libtorrent. When the| │ │ │ │ -| | |overhead traffic is greater than | │ │ │ │ -| | |the rate limit, libtorrent will | │ │ │ │ -|upload_limit_too_low |2 |not be able to send any actual | │ │ │ │ -| | |payload, such as piece requests. | │ │ │ │ -| | |This means the download rate will| │ │ │ │ -| | |suffer, and new requests can be | │ │ │ │ -| | |sent again. There will be an | │ │ │ │ -| | |equilibrium where the download | │ │ │ │ -| | |rate, on average, is about 20 | │ │ │ │ -| | |times the upload rate limit. If | │ │ │ │ -| | |you want to maximize the download| │ │ │ │ -| | |rate, increase the upload rate | │ │ │ │ -| | |limit above 5% of your download | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_p_a_c_i_t_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |This is the same warning as | │ │ │ │ -| | |upload_limit_too_low but | │ │ │ │ -| | |referring to the download limit | │ │ │ │ -| | |instead of upload. This suggests | │ │ │ │ -| | |that your download rate limit is | │ │ │ │ -|download_limit_too_low |3 |much lower than your upload | │ │ │ │ -| | |capacity. Your upload rate will | │ │ │ │ -| | |suffer. To maximize upload rate, | │ │ │ │ -| | |make sure your download rate | │ │ │ │ -| | |limit is above 5% of your upload | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_p_a_c_i_t_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |We're stalled on the disk. We | │ │ │ │ -| | |want to write to the socket, and | │ │ │ │ -| | |we can write but our send buffer | │ │ │ │ -| | |is empty, waiting to be refilled | │ │ │ │ -| | |from the disk. This either means | │ │ │ │ -| | |the disk is slower than the | │ │ │ │ -| | |network connection or that our | │ │ │ │ -| | |send buffer watermark is too | │ │ │ │ -| | |small, because we can send it all| │ │ │ │ -|send_buffer_watermark_too_low |4 |before the disk gets back to us. | │ │ │ │ -| | |The number of bytes that we keep | │ │ │ │ -| | |outstanding, requested from the | │ │ │ │ -| | |disk, is calculated as follows: | │ │ │ │ -| | |min(512, max(upload_rate * | │ │ │ │ -| | |send_buffer_watermark_factor / | │ │ │ │ -| | |100, send_buffer_watermark)) | │ │ │ │ -| | |If you receive this _a_l_e_r_t, you | │ │ │ │ -| | |might want to either increase | │ │ │ │ -| | |your send_buffer_watermark or | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_n_d___b_u_f_f_e_r___w_a_t_e_r_m_a_r_k___f_a_c_t_o_r_._ _ _ _ | │ │ │ │ -| | |If the half (or more) of all | │ │ │ │ -| | |upload slots are set as | │ │ │ │ -|too_many_optimistic_unchoke_slots |5 |optimistic unchoke slots, this | │ │ │ │ -| | |warning is issued. You probably | │ │ │ │ -| | |want more regular (rate based) | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_u_n_c_h_o_k_e_ _s_l_o_t_s_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |If the disk write queue ever | │ │ │ │ -| | |grows larger than half of the | │ │ │ │ -| | |cache size, this warning is | │ │ │ │ -| | |posted. The disk write queue eats| │ │ │ │ -| | |into the total disk cache and | │ │ │ │ -| | |leaves very little left for the | │ │ │ │ -|too_high_disk_queue_limit |6 |actual cache. This causes the | │ │ │ │ -| | |disk cache to oscillate in | │ │ │ │ -| | |evicting large portions of the | │ │ │ │ -| | |cache before allowing peers to | │ │ │ │ -| | |download any more, onto the disk | │ │ │ │ -| | |write queue. Either lower | │ │ │ │ -| | |max_queued_disk_bytes or increase| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_c_h_e___s_i_z_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_a_i_o___l_i_m_i_t___r_e_a_c_h_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___b_i_t_t_y_r_a_n_t___w_i_t_h___n_o___u_p_l_i_m_i_t_ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |This is generated if outgoing | │ │ │ │ -| | |peer connections are failing | │ │ │ │ -| | |because of aaddddrreessss iinn uussee errors,| │ │ │ │ -| | |indicating that settings_pack:: | │ │ │ │ -|too_few_outgoing_ports |9 |outgoing_ports is set and is too | │ │ │ │ -| | |small of a range. Consider not | │ │ │ │ -| | |using the outgoing_ports setting | │ │ │ │ -| | |at all, or widen the range to | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_c_l_u_d_e_ _m_o_r_e_ _p_o_r_t_s_._ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_o_o___f_e_w___f_i_l_e___d_e_s_c_r_i_p_t_o_r_s_ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_u_m___w_a_r_n_i_n_g_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttaattee__cchhaannggeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -Generated whenever a torrent changes its state. │ │ │ │ -struct state_changed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ - torrent_status::state_t const state; │ │ │ │ - torrent_status::state_t const prev_state; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - state │ │ │ │ - the new state of the torrent. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - prev_state │ │ │ │ - the previous state. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrraacckkeerr__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated on tracker time outs, premature disconnects, invalid │ │ │ │ -response or a HTTP response other than "200 OK". From the _a_l_e_r_t you can get the │ │ │ │ -handle to the torrent the tracker belongs to. │ │ │ │ -struct tracker_error_alert final : tracker_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* ffaaiilluurree__rreeaassoonn () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -tracker | alert_category::error; │ │ │ │ - int const times_in_row; │ │ │ │ - error_code const error; │ │ │ │ - operation_t op; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffaaiilluurree__rreeaassoonn(()) ********** │ │ │ │ -char const* ffaaiilluurree__rreeaassoonn () const; │ │ │ │ -if the tracker sent a "failure reason" string, it will be returned here. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - times_in_row │ │ │ │ - This member says how many times in a row this tracker has failed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error code indicating why the tracker announce failed. If it is is │ │ │ │ - lt::errors::tracker_failure the _f_a_i_l_u_r_e___r_e_a_s_o_n_(_) might contain a more │ │ │ │ - detailed description of why the tracker rejected the request. HTTP status │ │ │ │ - codes indicating errors are also set in this field. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrraacckkeerr__wwaarrnniinngg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is triggered if the tracker reply contains a warning field. Usually │ │ │ │ -this means that the tracker announce was successful, but the tracker has a │ │ │ │ -message to the client. │ │ │ │ -struct tracker_warning_alert final : tracker_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* wwaarrnniinngg__mmeessssaaggee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -tracker | alert_category::error; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** wwaarrnniinngg__mmeessssaaggee(()) ********** │ │ │ │ -char const* wwaarrnniinngg__mmeessssaaggee () const; │ │ │ │ -the message associated with this warning │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssccrraappee__rreeppllyy__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a scrape request succeeds. │ │ │ │ -struct scrape_reply_alert final : tracker_alert │ │ │ │ +std::vector handles = ses.get_torrents(); │ │ │ │ +for (torrent_handle const& h : handles) try │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ + h.save_resume_data(torrent_handle::only_if_modified); │ │ │ │ + ++outstanding_resume_data; │ │ │ │ +} │ │ │ │ +catch (lt::system_error const& e) │ │ │ │ +{ │ │ │ │ + // the handle was invalid, ignore this one and move to the next │ │ │ │ +} │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -tracker; │ │ │ │ - int const incomplete; │ │ │ │ - int const complete; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - incomplete complete │ │ │ │ - the data returned in the scrape response. These numbers may be -1 if the │ │ │ │ - response was malformed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssccrraappee__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -If a scrape request fails, this _a_l_e_r_t is generated. This might be due to the │ │ │ │ -tracker timing out, refusing connection or returning an http response code │ │ │ │ -indicating an error. │ │ │ │ -struct scrape_failed_alert final : tracker_alert │ │ │ │ +while (outstanding_resume_data > 0) │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ + // if we don't get an alert within 30 seconds, abort │ │ │ │ + if (!ses.wait_for_alert(seconds(30))) break; │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -tracker | alert_category::error; │ │ │ │ - error_code const error; │ │ │ │ -}; │ │ │ │ + std::vector alerts; │ │ │ │ + ses.pop_alerts(&alerts); │ │ │ │ + │ │ │ │ + for (alert* i : alerts) │ │ │ │ + { │ │ │ │ + if (alert_cast(i)) │ │ │ │ + { │ │ │ │ + process_alert(i); │ │ │ │ + --outstanding_resume_data; │ │ │ │ + continue; │ │ │ │ + } │ │ │ │ + │ │ │ │ + save_resume_data_alert const* rd = │ │ │ │ +alert_cast(i); │ │ │ │ + if (rd == nullptr) │ │ │ │ + { │ │ │ │ + process_alert(i); │ │ │ │ + continue; │ │ │ │ + } │ │ │ │ + │ │ │ │ + std::ofstream out((rd->params.save_path │ │ │ │ + + "/" + rd->params.name + ".fastresume").c_str() │ │ │ │ + , std::ios_base::binary); │ │ │ │ + std::vector buf = write_resume_data_buf(rd->params); │ │ │ │ + out.write(buf.data(), buf.size()); │ │ │ │ + --outstanding_resume_data; │ │ │ │ + } │ │ │ │ +} │ │ │ │ +Note │ │ │ │ +Note how outstanding_resume_data is a global counter in this example. This is │ │ │ │ +deliberate, otherwise there is a race condition for torrents that was just │ │ │ │ +asked to save their resume data, they posted the _a_l_e_r_t, but it has not been │ │ │ │ +received yet. Those torrents would report that they don't need to save resume │ │ │ │ +data again, and skipped by the initial loop, and thwart the counter otherwise. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eerrrroorr__mmeessssaaggee(()) ********** │ │ │ │ -char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ -if the error indicates there is an associated message, this returns that │ │ │ │ -message. Otherwise and empty string. │ │ │ │ +********** nneeeedd__ssaavvee__rreessuummee__ddaattaa(()) ********** │ │ │ │ +bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const; │ │ │ │ +bool nneeeedd__ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags) const; │ │ │ │ +This function returns true if anything that is stored in the resume data has │ │ │ │ +changed since the last time resume data was saved. The overload that takes │ │ │ │ +flags let you ask if specific categories of properties have changed. These │ │ │ │ +flags have the same behavior as in the _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) call. │ │ │ │ +This is a bblloocckkiinngg call. It will wait for a response from libtorrent's main │ │ │ │ +thread. A way to avoid blocking is to instead call _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) directly, │ │ │ │ +specifying the conditions under which resume data should be saved. │ │ │ │ +Note │ │ │ │ +A torrent's resume data is considered saved as soon as the │ │ │ │ +_s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t is posted. It is important to make sure this _a_l_e_r_t is │ │ │ │ +received and handled in order for this function to be meaningful. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error itself. This may indicate that the tracker sent an error │ │ │ │ - message (error::tracker_failure), in which case it can be retrieved by │ │ │ │ - calling error_message(). │ │ │ │ +********** qquueeuuee__ppoossiittiioonn__ddoowwnn(()) qquueeuuee__ppoossiittiioonn__uupp(()) qquueeuuee__ppoossiittiioonn__ttoopp(()) │ │ │ │ +qquueeuuee__ppoossiittiioonn__bboottttoomm(()) qquueeuuee__ppoossiittiioonn(()) ********** │ │ │ │ +queue_position_t qquueeuuee__ppoossiittiioonn () const; │ │ │ │ +void qquueeuuee__ppoossiittiioonn__ddoowwnn () const; │ │ │ │ +void qquueeuuee__ppoossiittiioonn__bboottttoomm () const; │ │ │ │ +void qquueeuuee__ppoossiittiioonn__uupp () const; │ │ │ │ +void qquueeuuee__ppoossiittiioonn__ttoopp () const; │ │ │ │ +Every torrent that is added is assigned a queue position exactly one greater │ │ │ │ +than the greatest queue position of all existing torrents. Torrents that are │ │ │ │ +being seeded have -1 as their queue position, since they're no longer in line │ │ │ │ +to be downloaded. │ │ │ │ +When a torrent is removed or turns into a seed, all torrents with greater queue │ │ │ │ +positions have their positions decreased to fill in the space in the sequence. │ │ │ │ +queue_position() returns the torrent's position in the download queue. The │ │ │ │ +torrents with the smallest numbers are the ones that are being downloaded. The │ │ │ │ +smaller number, the closer the torrent is to the front of the line to be │ │ │ │ +started. │ │ │ │ +The queue position is also available in the _t_o_r_r_e_n_t___s_t_a_t_u_s. │ │ │ │ +The queue_position_*() functions adjust the torrents position in the queue. Up │ │ │ │ +means closer to the front and down means closer to the back of the queue. Top │ │ │ │ +and bottom refers to the front and the back of the queue respectively. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrraacckkeerr__rreeppllyy__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is only for informational purpose. It is generated when a tracker │ │ │ │ -announce succeeds. It is generated regardless what kind of tracker was used, be │ │ │ │ -it UDP, HTTP or the DHT. │ │ │ │ -struct tracker_reply_alert final : tracker_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -tracker; │ │ │ │ - int const num_peers; │ │ │ │ -}; │ │ │ │ +********** qquueeuuee__ppoossiittiioonn__sseett(()) ********** │ │ │ │ +void qquueeuuee__ppoossiittiioonn__sseett (queue_position_t p) const; │ │ │ │ +updates the position in the queue for this torrent. The relative order of all │ │ │ │ +other torrents remain intact but their numerical queue position shifts to make │ │ │ │ +space for this torrent's new position │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - num_peers │ │ │ │ - tells how many peers the tracker returned in this response. This is not │ │ │ │ - expected to be greater than the num_want settings. These are not │ │ │ │ - necessarily all new peers, some of them may already be connected. │ │ │ │ +********** sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr(()) sseett__ssssll__cceerrttiiffiiccaattee(()) ********** │ │ │ │ +void sseett__ssssll__cceerrttiiffiiccaattee (std::string const& certificate │ │ │ │ + , std::string const& private_key │ │ │ │ + , std::string const& dh_params │ │ │ │ + , std::string const& passphrase = ""); │ │ │ │ +void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate │ │ │ │ + , std::string const& private_key │ │ │ │ + , std::string const& dh_params); │ │ │ │ +For SSL torrents, use this to specify a path to a .pem file to use as this │ │ │ │ +client's certificate. The certificate must be signed by the certificate in the │ │ │ │ +.torrent file to be valid. │ │ │ │ +The _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e___b_u_f_f_e_r_(_) overload takes the actual certificate, private │ │ │ │ +key and DH params as strings, rather than paths to files. │ │ │ │ +cert is a path to the (signed) certificate in .pem format corresponding to this │ │ │ │ +torrent. │ │ │ │ +private_key is a path to the private key for the specified certificate. This │ │ │ │ +must be in .pem format. │ │ │ │ +dh_params is a path to the Diffie-Hellman parameter file, which needs to be in │ │ │ │ +.pem format. You can generate this file using the openssl command like this: │ │ │ │ +openssl dhparam -outform PEM -out dhparams.pem 512. │ │ │ │ +passphrase may be specified if the private key is encrypted and requires a │ │ │ │ +passphrase to be decrypted. │ │ │ │ +Note that when a torrent first starts up, and it needs a certificate, it will │ │ │ │ +suspend connecting to any peers until it has one. It's typically desirable to │ │ │ │ +resume the torrent after setting the SSL certificate. │ │ │ │ +If you receive a _t_o_r_r_e_n_t___n_e_e_d___c_e_r_t___a_l_e_r_t, you need to call this to provide a │ │ │ │ +valid cert. If you don't have a cert you won't be allowed to connect to any │ │ │ │ +peers. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__rreeppllyy__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated each time the DHT receives peers from a node. num_peers │ │ │ │ -is the number of peers we received in this packet. Typically these packets are │ │ │ │ -received from multiple DHT nodes, and so the alerts are typically generated a │ │ │ │ -few at a time. │ │ │ │ -struct dht_reply_alert final : tracker_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht | alert_category::tracker; │ │ │ │ - int const num_peers; │ │ │ │ -}; │ │ │ │ +********** ttoorrrreenntt__ffiillee(()) ********** │ │ │ │ +std::shared_ptr ttoorrrreenntt__ffiillee () const; │ │ │ │ +_t_o_r_r_e_n_t___f_i_l_e_(_) returns a pointer to the _t_o_r_r_e_n_t___i_n_f_o object associated with │ │ │ │ +this torrent. The _t_o_r_r_e_n_t___i_n_f_o object may be a copy of the internal object. If │ │ │ │ +the torrent doesn't have metadata, the pointer will not be initialized (i.e. a │ │ │ │ +nullptr). The torrent may be in a state without metadata only if it was started │ │ │ │ +without a .torrent file, e.g. by being added by magnet link. │ │ │ │ +Note that the _t_o_r_r_e_n_t___i_n_f_o object returned here may be a different instance │ │ │ │ +than the one added to the _s_e_s_s_i_o_n, with different attributes like piece layers, │ │ │ │ +dht nodes and trackers. A _t_o_r_r_e_n_t___i_n_f_o object does not round-trip cleanly when │ │ │ │ +added to a _s_e_s_s_i_o_n. │ │ │ │ +If you want to save a .torrent file from the _t_o_r_r_e_n_t___h_a_n_d_l_e, instead call │ │ │ │ +_s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) and _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object │ │ │ │ +passed back in the _a_l_e_r_t. │ │ │ │ +Note that a torrent added from a magnet link may not have the full merkle trees │ │ │ │ +for all files, and hence not have the complete piece layers. In that state, you │ │ │ │ +cannot create a .torrent file from the _t_o_r_r_e_n_t___i_n_f_o returned. Once the torrent │ │ │ │ +completes downloading all files, becoming a seed, you can make a .torrent file │ │ │ │ +from it. │ │ │ │ +If any files in the torrent have been renamed, using _t_o_r_r_e_n_t___h_a_n_d_l_e_:_: │ │ │ │ +_r_e_n_a_m_e___f_i_l_e_(_), the new names will not be reflected in the returned _t_o_r_r_e_n_t___i_n_f_o │ │ │ │ +object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrraacckkeerr__aannnnoouunnccee__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated each time a tracker announce is sent (or attempted to │ │ │ │ -be sent). There are no extra data members in this _a_l_e_r_t. The url can be found │ │ │ │ -in the base class however. │ │ │ │ -struct tracker_announce_alert final : tracker_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -tracker; │ │ │ │ - event_t const event; │ │ │ │ -}; │ │ │ │ +********** ggeett__rreennaammeedd__ffiilleess(()) ********** │ │ │ │ +renamed_files ggeett__rreennaammeedd__ffiilleess () const; │ │ │ │ +Returns a copy of the _r_e_n_a_m_e_d___f_i_l_e_s object for this torrent. This records all │ │ │ │ +file renames applied via _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_n_a_m_e___f_i_l_e_(_). To get a complete view │ │ │ │ +of the current file layout (original names plus any renames), combine this with │ │ │ │ +the _f_i_l_e___s_t_o_r_a_g_e from torrent_file()->layout(): │ │ │ │ +auto tf = handle.torrent_file(); │ │ │ │ +auto renames = handle.get_renamed_files(); │ │ │ │ +lt::filenames fn(tf->layout(), renames); │ │ │ │ +for (auto i : fn.file_range()) │ │ │ │ + std::cout << fn.file_path(i) << "\n"; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - event │ │ │ │ - specifies what event was sent to the tracker. See _e_v_e_n_t___t. │ │ │ │ +********** ppiieeccee__llaayyeerrss(()) ********** │ │ │ │ +std::vector> ppiieeccee__llaayyeerrss () const; │ │ │ │ +returns the piece layers for all files in the torrent. If this is a v1 torrent │ │ │ │ +(and doesn't have any piece layers) it returns an empty vector. This is a │ │ │ │ +blocking call that will synchronize with the libtorrent network thread. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhaasshh__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a finished piece fails its hash check. You can get │ │ │ │ -the handle to the torrent which got the failed piece and the index of the piece │ │ │ │ -itself from the _a_l_e_r_t. │ │ │ │ -struct hash_failed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ +********** ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy(()) ppiieeccee__aavvaaiillaabbiilliittyy(()) ********** │ │ │ │ +void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const; │ │ │ │ +void ppiieeccee__aavvaaiillaabbiilliittyy (std::vector& avail) const; │ │ │ │ +The piece availability is the number of peers that we are connected that has │ │ │ │ +advertised having a particular piece. This is the information that libtorrent │ │ │ │ +uses in order to prefer picking rare pieces. │ │ │ │ +post_piece_availability() will trigger a _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y___a_l_e_r_t to be posted. │ │ │ │ +piece_availability() fills the specified std::vector with the availability │ │ │ │ +for each piece in this torrent. libtorrent does not keep track of availability │ │ │ │ +for seeds, so if the torrent is seeding the availability for all pieces is │ │ │ │ +reported as 0. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__bbaann__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a peer is banned because it has sent too many │ │ │ │ -corrupt pieces to us. ip is the endpoint to the peer that was banned. │ │ │ │ -struct peer_ban_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ -}; │ │ │ │ +********** ggeett__ppiieeccee__pprriioorriittiieess(()) pprriioorriittiizzee__ppiieecceess(()) ppiieeccee__pprriioorriittyy(()) ********** │ │ │ │ +std::vector ggeett__ppiieeccee__pprriioorriittiieess () const; │ │ │ │ +void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces) const; │ │ │ │ +download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const; │ │ │ │ +void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const; │ │ │ │ +void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority) const; │ │ │ │ +These functions are used to set and get the priority of individual pieces. By │ │ │ │ +default all pieces have priority 4. That means that the random rarest first │ │ │ │ +algorithm is effectively active for all pieces. You may however change the │ │ │ │ +priority of individual pieces. There are 8 priority levels. 0 means not to │ │ │ │ +download the piece at all. Otherwise, lower priority values means less likely │ │ │ │ +to be picked. Piece priority takes precedence over piece availability. Every │ │ │ │ +piece with priority 7 will be attempted to be picked before a priority 6 piece │ │ │ │ +and so on. │ │ │ │ +The default priority of pieces is 4. │ │ │ │ +Piece priorities can not be changed for torrents that have not downloaded the │ │ │ │ +metadata yet. Magnet links won't have metadata immediately. see the │ │ │ │ +_m_e_t_a_d_a_t_a___r_e_c_e_i_v_e_d___a_l_e_r_t. │ │ │ │ +piece_priority sets or gets the priority for an individual piece, specified by │ │ │ │ +index. │ │ │ │ +prioritize_pieces takes a vector of integers, one integer per piece in the │ │ │ │ +torrent. All the piece priorities will be updated with the priorities in the │ │ │ │ +vector. The second overload of prioritize_pieces that takes a vector of pairs │ │ │ │ +will update the priorities of only select pieces, and leave all other │ │ │ │ +unaffected. Each pair is (piece, priority). That is, the first item is the │ │ │ │ +piece index and the second item is the priority of that piece. Invalid entries, │ │ │ │ +where the piece index or priority is out of range, are not allowed. │ │ │ │ +get_piece_priorities returns a vector with one element for each piece in the │ │ │ │ +torrent. Each element is the current priority of that piece. │ │ │ │ +It's possible to cancel the effect of ffiillee priorities by setting the priorities │ │ │ │ +for the affected pieces. Care has to be taken when mixing usage of file- and │ │ │ │ +piece priorities. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__uunnssnnuubbbbeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a peer is un-snubbed. Essentially when it was │ │ │ │ -snubbed for stalling sending data, and now it started sending data again. │ │ │ │ -struct peer_unsnubbed_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ -}; │ │ │ │ +********** ggeett__ffiillee__pprriioorriittiieess(()) pprriioorriittiizzee__ffiilleess(()) ffiillee__pprriioorriittyy(()) ********** │ │ │ │ +std::vector ggeett__ffiillee__pprriioorriittiieess () const; │ │ │ │ +void pprriioorriittiizzee__ffiilleess (std::vector const& files) const; │ │ │ │ +void ffiillee__pprriioorriittyy (file_index_t index, download_priority_t priority) const; │ │ │ │ +download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const; │ │ │ │ +index must be in the range [0, number_of_files). │ │ │ │ +file_priority() queries or sets the priority of file index. │ │ │ │ +prioritize_files() takes a vector that has at as many elements as there are │ │ │ │ +files in the torrent. Each _e_n_t_r_y is the priority of that file. The function │ │ │ │ +sets the priorities of all the pieces in the torrent based on the vector. │ │ │ │ +get_file_priorities() returns a vector with the priorities of all files. │ │ │ │ +The priority values are the same as for _p_i_e_c_e___p_r_i_o_r_i_t_y_(_). See │ │ │ │ +_d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y___t. │ │ │ │ +Whenever a file priority is changed, all other piece priorities are reset to │ │ │ │ +match the file priorities. In order to maintain special priorities for │ │ │ │ +particular pieces, _p_i_e_c_e___p_r_i_o_r_i_t_y_(_) has to be called again for those pieces. │ │ │ │ +You cannot set the file priorities on a torrent that does not yet have metadata │ │ │ │ +or a torrent that is a seed. file_priority(int, int) and _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_) are │ │ │ │ +both no-ops for such torrents. │ │ │ │ +Since changing file priorities may involve disk operations (of moving files in- │ │ │ │ +and out of the part file), the internal accounting of file priorities happen │ │ │ │ +asynchronously. i.e. setting file priorities and then immediately querying them │ │ │ │ +may not yield the same priorities just set. To synchronize with the priorities │ │ │ │ +taking effect, wait for the _f_i_l_e___p_r_i_o___a_l_e_r_t. │ │ │ │ +When combining file- and piece priorities, the resume file will record both. │ │ │ │ +When loading the resume data, the file priorities will be applied first, then │ │ │ │ +the piece priorities. │ │ │ │ +Moving data from a file into the part file is currently not supported. If a │ │ │ │ +file has its priority set to 0 aafftteerr it has already been created, it will not │ │ │ │ +be moved into the partfile. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__ssnnuubbbbeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a peer is snubbed, when it stops sending data when │ │ │ │ -we request it. │ │ │ │ -struct peer_snubbed_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ -}; │ │ │ │ +********** ppoosstt__ffiillee__pprriioorriittiieess(()) ********** │ │ │ │ +void ppoosstt__ffiillee__pprriioorriittiieess () const; │ │ │ │ +post_file_priorities() will trigger a _f_i_l_e___p_r_i_o_r_i_t_i_e_s___a_l_e_r_t to be posted, │ │ │ │ +containing the download priority of each file in the torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a peer sends invalid data over the peer-peer │ │ │ │ -protocol. The peer will be disconnected, but you get its ip address from the │ │ │ │ -_a_l_e_r_t, to identify it. │ │ │ │ -struct peer_error_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ - operation_t op; │ │ │ │ - error_code const error; │ │ │ │ -}; │ │ │ │ +********** ffoorrccee__rreeaannnnoouunnccee(()) ffoorrccee__llssdd__aannnnoouunnccee(()) ffoorrccee__ddhhtt__aannnnoouunnccee(()) ********** │ │ │ │ +void ffoorrccee__rreeaannnnoouunnccee (int seconds, int idx, reannounce_flags_t = {}) const; │ │ │ │ +void ffoorrccee__rreeaannnnoouunnccee (int seconds = 0, reannounce_flags_t = {}) const; │ │ │ │ +void ffoorrccee__llssdd__aannnnoouunnccee () const; │ │ │ │ +void ffoorrccee__ddhhtt__aannnnoouunnccee () const; │ │ │ │ +void ffoorrccee__rreeaannnnoouunnccee (int seconds, std::string const& url, reannounce_flags_t │ │ │ │ += {}) const; │ │ │ │ +force_reannounce() will force this torrent to do another tracker request, to │ │ │ │ +receive new peers. The seconds argument specifies how many seconds from now to │ │ │ │ +issue the tracker announces. │ │ │ │ +If the tracker's min_interval has not passed since the last announce, the │ │ │ │ +forced announce will be scheduled to happen immediately as the min_interval │ │ │ │ +expires. This is to honor trackers minimum re-announce interval settings. │ │ │ │ +The tracker_index argument specifies which tracker to re-announce. If set to - │ │ │ │ +1 (which is the default), all trackers are re-announce. │ │ │ │ +The flags argument can be used to affect the re-announce. See │ │ │ │ +ignore_min_interval and high_priority. │ │ │ │ +force_dht_announce will announce the torrent to the DHT immediately. │ │ │ │ +force_lsd_announce will announce the torrent on LSD immediately. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - a 0-terminated string of the low-level operation that failed, or nullptr │ │ │ │ - if there was no low level disk operation. │ │ │ │ +********** ssccrraappee__ttrraacckkeerr(()) ********** │ │ │ │ +void ssccrraappee__ttrraacckkeerr (int idx) const; │ │ │ │ +void ssccrraappee__ttrraacckkeerr () const; │ │ │ │ +void ssccrraappee__ttrraacckkeerr (std::string url) const; │ │ │ │ +scrape_tracker() will send a scrape request to a tracker. By default (idx = -1) │ │ │ │ +it will scrape the last working tracker. If idx is >= 0, the tracker with the │ │ │ │ +specified index will scraped. │ │ │ │ +A scrape request queries the tracker for statistics such as total number of │ │ │ │ +incomplete peers, complete peers, number of downloads etc. │ │ │ │ +This request will specifically update the num_complete and num_incomplete │ │ │ │ +fields in the _t_o_r_r_e_n_t___s_t_a_t_u_s struct once it completes. When it completes, it │ │ │ │ +will generate a _s_c_r_a_p_e___r_e_p_l_y___a_l_e_r_t. If it fails, it will generate a │ │ │ │ +_s_c_r_a_p_e___f_a_i_l_e_d___a_l_e_r_t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - tells you what error caused this _a_l_e_r_t. │ │ │ │ +********** uuppllooaadd__lliimmiitt(()) sseett__uuppllooaadd__lliimmiitt(()) sseett__ddoowwnnllooaadd__lliimmiitt(()) ddoowwnnllooaadd__lliimmiitt(()) │ │ │ │ +********** │ │ │ │ +int uuppllooaadd__lliimmiitt () const; │ │ │ │ +void sseett__uuppllooaadd__lliimmiitt (int limit) const; │ │ │ │ +int ddoowwnnllooaadd__lliimmiitt () const; │ │ │ │ +void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const; │ │ │ │ +set_upload_limit will limit the upload bandwidth used by this particular │ │ │ │ +torrent to the limit you set. It is given as the number of bytes per second the │ │ │ │ +torrent is allowed to upload. set_download_limit works the same way but for │ │ │ │ +download bandwidth instead of upload bandwidth. Note that setting a higher │ │ │ │ +limit on a torrent then the global limit (settings_pack::upload_rate_limit) │ │ │ │ +will not override the global rate limit. The torrent can never upload more than │ │ │ │ +the global rate limit. │ │ │ │ +upload_limit and download_limit will return the current limit setting, for │ │ │ │ +upload and download, respectively. │ │ │ │ +Local peers are not rate limited by default. see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__ccoonnnneecctt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted every time an incoming peer connection both successfully │ │ │ │ -passes the protocol handshake and is associated with a torrent, or an outgoing │ │ │ │ -peer connection attempt succeeds. For arbitrary incoming connections, see │ │ │ │ -_i_n_c_o_m_i_n_g___c_o_n_n_e_c_t_i_o_n___a_l_e_r_t. │ │ │ │ -struct peer_connect_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - enum direction_t │ │ │ │ - { │ │ │ │ - in, │ │ │ │ - out, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -connect; │ │ │ │ - direction_t direction; │ │ │ │ - socket_type_t socket_type; │ │ │ │ -}; │ │ │ │ +********** ccoonnnneecctt__ppeeeerr(()) ********** │ │ │ │ +void ccoonnnneecctt__ppeeeerr (tcp::endpoint const& adr, peer_source_flags_t source = {} │ │ │ │ + , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const; │ │ │ │ +connect_peer() is a way to manually connect to peers that one believe is a part │ │ │ │ +of the torrent. If the peer does not respond, or is not a member of this │ │ │ │ +torrent, it will simply be disconnected. No harm can be done by using this │ │ │ │ +other than an unnecessary connection attempt is made. If the torrent is │ │ │ │ +uninitialized or in queued or checking mode, this will throw system_error. The │ │ │ │ +second (optional) argument will be bitwise ORed into the source mask of this │ │ │ │ +peer. Typically this is one of the source flags in _p_e_e_r___i_n_f_o. i.e. tracker, │ │ │ │ +pex, dht etc. │ │ │ │ +For possible values of flags, see _p_e_x___f_l_a_g_s___t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ddiirreeccttiioonn__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_i_n_ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_o_u_t_ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** cclleeaarr__ppeeeerrss(()) ********** │ │ │ │ +void cclleeaarr__ppeeeerrss (); │ │ │ │ +This will disconnect all peers and clear the peer list for this torrent. New │ │ │ │ +peers will have to be acquired before resuming, from trackers, DHT or local │ │ │ │ +service discovery, for example. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - direction │ │ │ │ - Tells you if the peer was incoming or outgoing │ │ │ │ +********** sseett__mmaaxx__uuppllooaaddss(()) mmaaxx__uuppllooaaddss(()) ********** │ │ │ │ +void sseett__mmaaxx__uuppllooaaddss (int max_uploads) const; │ │ │ │ +int mmaaxx__uuppllooaaddss () const; │ │ │ │ +set_max_uploads() sets the maximum number of peers that's unchoked at the same │ │ │ │ +time on this torrent. If you set this to -1, there will be no limit. This │ │ │ │ +defaults to infinite. The primary setting controlling this is the global │ │ │ │ +unchoke slots limit, set by unchoke_slots_limit in _s_e_t_t_i_n_g_s___p_a_c_k. │ │ │ │ +max_uploads() returns the current settings. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__ddiissccoonnnneecctteedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a peer is disconnected for any reason (other than │ │ │ │ -the ones covered by _p_e_e_r___e_r_r_o_r___a_l_e_r_t ). │ │ │ │ -struct peer_disconnected_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -connect; │ │ │ │ - socket_type_t const socket_type; │ │ │ │ - operation_t const op; │ │ │ │ - error_code const error; │ │ │ │ - close_reason_t const reason; │ │ │ │ -}; │ │ │ │ +********** sseett__mmaaxx__ccoonnnneeccttiioonnss(()) mmaaxx__ccoonnnneeccttiioonnss(()) ********** │ │ │ │ +void sseett__mmaaxx__ccoonnnneeccttiioonnss (int max_connections) const; │ │ │ │ +int mmaaxx__ccoonnnneeccttiioonnss () const; │ │ │ │ +set_max_connections() sets the maximum number of connection this torrent will │ │ │ │ +open. If all connections are used up, incoming connections may be refused or │ │ │ │ +poor connections may be closed. This must be at least 2. The default is │ │ │ │ +unlimited number of connections. If -1 is given to the function, it means │ │ │ │ +unlimited. There is also a global limit of the number of connections, set by │ │ │ │ +connections_limit in _s_e_t_t_i_n_g_s___p_a_c_k. │ │ │ │ +max_connections() returns the current settings. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - socket_type │ │ │ │ - the kind of socket this peer was connected over │ │ │ │ +********** mmoovvee__ssttoorraaggee(()) ********** │ │ │ │ +void mmoovvee__ssttoorraaggee (std::string const& save_path │ │ │ │ + , move_flags_t flags = move_flags_t::always_replace_files │ │ │ │ + ) const; │ │ │ │ +Moves the file(s) that this torrent are currently seeding from or downloading │ │ │ │ +to. If the given save_path is not located on the same drive as the original │ │ │ │ +save path, the files will be copied to the new drive and removed from their │ │ │ │ +original location. This will block all other disk IO, and other torrents │ │ │ │ +download and upload rates may drop while copying the file. │ │ │ │ +Since disk IO is performed in a separate thread, this operation is also │ │ │ │ +asynchronous. Once the operation completes, the storage_moved_alert is │ │ │ │ +generated, with the new path as the message. If the move fails for some reason, │ │ │ │ +storage_moved_failed_alert is generated instead, containing the error message. │ │ │ │ +The flags argument determines the behavior of the copying/moving of the files │ │ │ │ +in the torrent. see _m_o_v_e___f_l_a_g_s___t. │ │ │ │ +always_replace_files is the default and replaces any file that exist in both │ │ │ │ +the source directory and the target directory. │ │ │ │ +fail_if_exist first check to see that none of the copy operations would cause │ │ │ │ +an overwrite. If it would, it will fail. Otherwise it will proceed as if it was │ │ │ │ +in always_replace_files mode. Note that there is an inherent race condition │ │ │ │ +here. If the files in the target directory appear after the check but before │ │ │ │ +the copy or move completes, they will be overwritten. When failing because of │ │ │ │ +files already existing in the target path, the error of │ │ │ │ +move_storage_failed_alert is set to boost::system::errc::file_exists. │ │ │ │ +The intention is that a client may use this as a probe, and if it fails, ask │ │ │ │ +the user which mode to use. The client may then re-issue the move_storage call │ │ │ │ +with one of the other modes. │ │ │ │ +dont_replace always keeps the existing file in the target directory, if there │ │ │ │ +is one. The source files will still be removed in that case. Note that it won't │ │ │ │ +automatically re-check files. If an incomplete torrent is moved into a │ │ │ │ +directory with the complete files, pause, move, force-recheck and resume. │ │ │ │ +Without the re-checking, the torrent will keep downloading and files in the new │ │ │ │ +download directory will be overwritten. │ │ │ │ +Files that have been renamed to have absolute paths are not moved by this │ │ │ │ +function. Keep in mind that files that don't belong to the torrent but are │ │ │ │ +stored in the torrent's directory may be moved as well. This goes for files │ │ │ │ +that have been renamed to absolute paths that still end up inside the save │ │ │ │ +path. │ │ │ │ +When copying files, sparse regions are not likely to be preserved. This makes │ │ │ │ +it proportionally more expensive to move a large torrent when only few pieces │ │ │ │ +have been downloaded, since the files are then allocated with zeros in the │ │ │ │ +destination directory. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - the operation or level where the error occurred. Specified as an value │ │ │ │ - from the _o_p_e_r_a_t_i_o_n___t enum. Defined in operations.hpp. │ │ │ │ +********** rreennaammee__ffiillee(()) ********** │ │ │ │ +void rreennaammee__ffiillee (file_index_t index, std::string const& new_name) const; │ │ │ │ +Renames the file with the given index asynchronously. The rename operation is │ │ │ │ +complete when either a _f_i_l_e___r_e_n_a_m_e_d___a_l_e_r_t or _f_i_l_e___r_e_n_a_m_e___f_a_i_l_e_d___a_l_e_r_t is │ │ │ │ +posted. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - tells you what error caused peer to disconnect. │ │ │ │ +********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) ********** │ │ │ │ +sha1_hash iinnffoo__hhaasshh () const; │ │ │ │ +info_hash_t iinnffoo__hhaasshheess () const; │ │ │ │ +returns the info-hash(es) of the torrent. If this handle is to a torrent that │ │ │ │ +hasn't loaded yet (for instance by being added) by a URL, the returned value is │ │ │ │ +undefined. The info_hash() returns the SHA-1 info-hash for v1 torrents and a │ │ │ │ +truncated hash for v2 torrents. For the full v2 info-hash, use info_hashes() │ │ │ │ +instead. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - reason │ │ │ │ - the reason the peer disconnected (if specified) │ │ │ │ +********** ooppeerraattoorr<<(()) ooppeerraattoorr!!==(()) ooppeerraattoorr====(()) ********** │ │ │ │ +bool ooppeerraattoorr!!== (const torrent_handle& h) const; │ │ │ │ +bool ooppeerraattoorr<< (const torrent_handle& h) const; │ │ │ │ +bool ooppeerraattoorr==== (const torrent_handle& h) const; │ │ │ │ +comparison operators. The order of the torrents is unspecified but stable. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ iinnvvaalliidd__rreeqquueesstt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is a debug _a_l_e_r_t that is generated by an incoming invalid piece request. │ │ │ │ -ip is the address of the peer and the request is the actual incoming request │ │ │ │ -from the peer. See _p_e_e_r___r_e_q_u_e_s_t for more info. │ │ │ │ -struct invalid_request_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ - peer_request const request; │ │ │ │ - bool const we_have; │ │ │ │ - bool const peer_interested; │ │ │ │ - bool const withheld; │ │ │ │ -}; │ │ │ │ +********** iidd(()) ********** │ │ │ │ +std::uint32_t iidd () const; │ │ │ │ +returns a unique identifier for this torrent. It's not a dense index. It's not │ │ │ │ +preserved across sessions. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - request │ │ │ │ - the request we received from the peer │ │ │ │ +********** nnaattiivvee__hhaannddllee(()) ********** │ │ │ │ +std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ +This function is intended only for use by plugins and the _a_l_e_r_t dispatch │ │ │ │ +function. This type does not have a stable ABI and should be relied on as │ │ │ │ +little as possible. Accessing the handle returned by this function is not │ │ │ │ +thread safe outside of libtorrent's internal thread (which is used to invoke │ │ │ │ +_p_l_u_g_i_n callbacks). │ │ │ │ +The aux::torrent class is not only eligible for changing ABI across minor │ │ │ │ +versions of libtorrent, its layout is also dependent on build configuration. │ │ │ │ +This adds additional requirements on a client to be built with the exact same │ │ │ │ +build configuration as libtorrent itself. i.e. the TORRENT_ macros must match │ │ │ │ +between libtorrent and the client builds. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - we_have │ │ │ │ - true if we have this piece │ │ │ │ +********** uusseerrddaattaa(()) ********** │ │ │ │ +client_data_t uusseerrddaattaa () const; │ │ │ │ +returns the userdata pointer as set in _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - peer_interested │ │ │ │ - true if the peer indicated that it was interested to download before │ │ │ │ - sending the request │ │ │ │ +********** iinn__sseessssiioonn(()) ********** │ │ │ │ +bool iinn__sseessssiioonn () const; │ │ │ │ +Returns true if the torrent is in the _s_e_s_s_i_o_n. It returns true before session:: │ │ │ │ +remove_torrent() is called, and false afterward. │ │ │ │ +Note that this is a blocking function, unlike _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_i_s___v_a_l_i_d_(_) which │ │ │ │ +returns immediately. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - withheld │ │ │ │ - if this is true, the peer is not allowed to download this piece because │ │ │ │ - of super-seeding rules. │ │ │ │ + overwrite_existing │ │ │ │ + instruct libtorrent to overwrite any data that may already have been │ │ │ │ + downloaded with the data of the new piece being added. Using this flag │ │ │ │ + when adding a piece that is actively being downloaded from other peers │ │ │ │ + may have some unexpected consequences, as blocks currently being │ │ │ │ + downloaded from peers may not be replaced. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__ffiinniisshheedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a torrent switches from being a downloader to a │ │ │ │ -seed. It will only be generated once per torrent. It contains a _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ -to the torrent in question. │ │ │ │ -struct torrent_finished_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ -}; │ │ │ │ + query_distributed_copies │ │ │ │ + calculates distributed_copies, distributed_full_copies and │ │ │ │ + distributed_fraction. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppiieeccee__ffiinniisshheedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is posted every time a piece completes downloading and passes the │ │ │ │ -hash check. This _a_l_e_r_t derives from _t_o_r_r_e_n_t___a_l_e_r_t which contains the │ │ │ │ -_t_o_r_r_e_n_t___h_a_n_d_l_e to the torrent the piece belongs to. Note that being downloaded │ │ │ │ -and passing the hash check may happen before the piece is also fully flushed to │ │ │ │ -disk. So _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_h_a_v_e___p_i_e_c_e_(_) may still return false │ │ │ │ -struct piece_finished_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ + query_accurate_download_counters │ │ │ │ + includes partial downloaded blocks in total_done and total_wanted_done. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - piece_index │ │ │ │ - the index of the piece that finished │ │ │ │ + query_last_seen_complete │ │ │ │ + includes last_seen_complete. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ rreeqquueesstt__ddrrooppppeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a peer rejects or ignores a piece request. │ │ │ │ -struct request_dropped_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - int const block_index; │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ + query_pieces │ │ │ │ + populate the pieces field in _t_o_r_r_e_n_t___s_t_a_t_u_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bblloocckk__ttiimmeeoouutt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a block request times out. │ │ │ │ -struct block_timeout_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - int const block_index; │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ + query_verified_pieces │ │ │ │ + includes verified_pieces (only applies to torrents in sseeeedd mmooddee). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bblloocckk__ffiinniisshheedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a block request receives a response. │ │ │ │ -struct block_finished_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - int const block_index; │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ + query_torrent_file │ │ │ │ + includes torrent_file, which is all the static information from the │ │ │ │ + .torrent file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bblloocckk__ddoowwnnllooaaddiinngg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a block request is sent to a peer. │ │ │ │ -struct block_downloading_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - int const block_index; │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ + query_name │ │ │ │ + includes name, the name of the torrent. This is either derived from the │ │ │ │ + .torrent file, or from the &dn= magnet link argument or possibly some │ │ │ │ + other source. If the name of the torrent is not known, this is an empty │ │ │ │ + string. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ uunnwwaanntteedd__bblloocckk__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a block is received that was not requested or │ │ │ │ -whose request timed out. │ │ │ │ -struct unwanted_block_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ - int const block_index; │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ + query_save_path │ │ │ │ + includes save_path, the path to the directory the files of the torrent │ │ │ │ + are saved to. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttoorraaggee__mmoovveedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -The storage_moved_alert is generated when all the disk IO has completed and the │ │ │ │ -files have been moved, as an effect of a call to torrent_handle::move_storage. │ │ │ │ -This is useful to synchronize with the actual disk. The storage_path() member │ │ │ │ -return the new path of the storage. │ │ │ │ -struct storage_moved_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* oolldd__ppaatthh () const; │ │ │ │ - char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ -}; │ │ │ │ + query_renamed_files │ │ │ │ + includes renamed_files, a map of files that have been renamed in this │ │ │ │ + torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssttoorraaggee__ppaatthh(()) oolldd__ppaatthh(()) ********** │ │ │ │ -char const* oolldd__ppaatthh () const; │ │ │ │ -char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ -the path the torrent was moved to and from, respectively. │ │ │ │ + alert_when_available │ │ │ │ + used to ask libtorrent to send an _a_l_e_r_t once the piece has been │ │ │ │ + downloaded, by passing alert_when_available. When set, the │ │ │ │ + _r_e_a_d___p_i_e_c_e___a_l_e_r_t _a_l_e_r_t will be delivered, with the piece data, when it's │ │ │ │ + downloaded. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttoorraaggee__mmoovveedd__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -The storage_moved_failed_alert is generated when an attempt to move the │ │ │ │ -storage, via _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_m_o_v_e___s_t_o_r_a_g_e_(_), fails. │ │ │ │ -struct storage_moved_failed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* ffiillee__ppaatthh () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ - error_code const error; │ │ │ │ - operation_t op; │ │ │ │ -}; │ │ │ │ + piece_granularity │ │ │ │ + only calculate file progress at piece granularity. This makes the │ │ │ │ + _f_i_l_e___p_r_o_g_r_e_s_s_(_) call cheaper and also only takes bytes that have passed │ │ │ │ + the hash check into account, so progress cannot regress in this mode. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppaatthh(()) ********** │ │ │ │ -char const* ffiillee__ppaatthh () const; │ │ │ │ -If the error happened for a specific file, this returns its path. │ │ │ │ + graceful_pause │ │ │ │ + will delay the disconnect of peers that we're still downloading │ │ │ │ + outstanding requests from. The torrent will not accept any more requests │ │ │ │ + and will disconnect all idle peers. As soon as a peer is done │ │ │ │ + transferring the blocks that were requested from it, it is disconnected. │ │ │ │ + This is a graceful shut down of the torrent in the sense that no │ │ │ │ + downloaded bytes are wasted. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - this indicates what underlying operation caused the error │ │ │ │ + flush_disk_cache │ │ │ │ + the disk cache will be flushed before creating the resume data. This │ │ │ │ + avoids a problem with file timestamps in the resume data in case the │ │ │ │ + cache hasn't been flushed yet. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__ddeelleetteedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a request to delete the files of a torrent │ │ │ │ -complete. │ │ │ │ -This _a_l_e_r_t is posted in the alert_category::storage category, and that bit │ │ │ │ -needs to be set in the alert_mask. │ │ │ │ -struct torrent_deleted_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ - info_hash_t info_hashes; │ │ │ │ -}; │ │ │ │ + save_info_dict │ │ │ │ + the resume data will contain the metadata from the torrent file as well. │ │ │ │ + This is useful for clients that don't keep .torrent files around │ │ │ │ + separately, or for torrents that were added via a magnet link. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - info_hashes │ │ │ │ - The info-hash of the torrent that was just deleted. Most of the time the │ │ │ │ - _t_o_r_r_e_n_t___h_a_n_d_l_e in the torrent_alert will be invalid by the time this │ │ │ │ - _a_l_e_r_t arrives, since the torrent is being deleted. The info_hashes member │ │ │ │ - is hence the main way of identifying which torrent just completed the │ │ │ │ - delete. │ │ │ │ + if_counters_changed │ │ │ │ + save resume data if any _c_o_u_n_t_e_r_s has changed since the last time resume │ │ │ │ + data was saved. This includes upload/download _c_o_u_n_t_e_r_s, active time │ │ │ │ + _c_o_u_n_t_e_r_s and scrape data. A torrent that is not paused will have its │ │ │ │ + active time _c_o_u_n_t_e_r_s incremented continuously. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__ddeelleettee__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a request to delete the files of a torrent fails. │ │ │ │ -Just removing a torrent from the _s_e_s_s_i_o_n cannot fail │ │ │ │ -struct torrent_delete_failed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage │ │ │ │ - | alert_category::error; │ │ │ │ - error_code const error; │ │ │ │ - info_hash_t info_hashes; │ │ │ │ -}; │ │ │ │ + if_download_progress │ │ │ │ + save the resume data if any blocks have been downloaded since the last │ │ │ │ + time resume data was saved. This includes: * checking existing files on │ │ │ │ + disk * downloading a block from a peer │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - tells you why it failed. │ │ │ │ + if_config_changed │ │ │ │ + save the resume data if configuration options changed since last time the │ │ │ │ + resume data was saved. This includes: * file- or piece priorities * │ │ │ │ + upload- and download rate limits * change max-uploads (unchoke slots) * │ │ │ │ + change max connection limit * enable/disable peer-exchange, local service │ │ │ │ + discovery or DHT * enable/disable apply IP-filter * enable/disable auto- │ │ │ │ + managed * enable/disable share-mode * enable/disable sequential-mode * │ │ │ │ + files renamed * storage moved (save_path changed) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - info_hashes │ │ │ │ - the info hash of the torrent whose files failed to be deleted │ │ │ │ + if_state_changed │ │ │ │ + save the resume data if torrent state has changed since last time the │ │ │ │ + resume data was saved. This includes: * upload mode * paused state * │ │ │ │ + super-seeding * seed-mode │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssaavvee__rreessuummee__ddaattaa__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated as a response to a torrent_handle::save_resume_data │ │ │ │ -request. It is generated once the disk IO thread is done writing the state for │ │ │ │ -this torrent. │ │ │ │ -struct save_resume_data_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ - add_torrent_params params; │ │ │ │ -}; │ │ │ │ + if_metadata_changed │ │ │ │ + save the resume data if any mmeettaaddaattaa changed since the last time resume │ │ │ │ + data was saved. This includes: * add/remove web seeds * add/remove │ │ │ │ + trackers * receiving metadata for a magnet link │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - params │ │ │ │ - the params object is populated with the torrent file whose resume data │ │ │ │ - was saved. It is suitable to be: │ │ │ │ - * added to a _s_e_s_s_i_o_n with _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 to disk with _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_(_) │ │ │ │ - * turned into a magnet link with _m_a_k_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ - * saved as a .torrent file with _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ + only_if_modified if_counters_changed │ │ │ │ + this flag has the same behavior as the combination of: │ │ │ │ + if_counters_changed | if_download_progress | if_config_changed | │ │ │ │ + if_state_changed | if_metadata_changed │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssaavvee__rreessuummee__ddaattaa__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated instead of save_resume_data_alert if there was an error │ │ │ │ -generating the resume data. error describes what went wrong. │ │ │ │ -struct save_resume_data_failed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage │ │ │ │ - | alert_category::error; │ │ │ │ - error_code const error; │ │ │ │ -}; │ │ │ │ + ignore_min_interval │ │ │ │ + by default, force-reannounce will still honor the min-interval published │ │ │ │ + by the tracker. If this flag is set, it will be ignored and the tracker │ │ │ │ + is announced immediately. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error code from the resume_data failure │ │ │ │ + high_priority │ │ │ │ + by default, force-reannounce will queue the announce normally. If this │ │ │ │ + flag is set, the announce will be put at the front of the tracker queue │ │ │ │ + for immediate processing. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__ppaauusseedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated as a response to a torrent_handle::pause request. It is │ │ │ │ -generated once all disk IO is complete and the files in the torrent have been │ │ │ │ -closed. This is useful for synchronizing with the disk. │ │ │ │ -struct torrent_paused_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ -}; │ │ │ │ +************ hhaasshh__vvaalluuee(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___h_a_n_d_l_e_._h_p_p" │ │ │ │ +std::size_t hhaasshh__vvaalluuee (torrent_handle const& h); │ │ │ │ +for std::hash (and to support using this type in unordered_map etc.) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__rreessuummeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated as a response to a _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_s_u_m_e_(_) request. It │ │ │ │ -is generated when a torrent goes from a paused state to an active state. │ │ │ │ -struct torrent_resumed_alert final : torrent_alert │ │ │ │ +************ ssttoorraaggee__ppaarraammss ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ +a parameter pack used to construct the storage for a torrent, used in │ │ │ │ +_d_i_s_k___i_n_t_e_r_f_a_c_e │ │ │ │ +struct storage_params │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ + ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ + , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ + , aux::vector const& prio │ │ │ │ + , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ + file_storage const& files; │ │ │ │ + lt::renamed_files const& renamed_files; │ │ │ │ + string_view path; │ │ │ │ + string_view part_file_dir; │ │ │ │ + storage_mode_t mmooddee {storage_mode_sparse}; │ │ │ │ + aux::vector const& priorities; │ │ │ │ + sha1_hash info_hash; │ │ │ │ + bool v1; │ │ │ │ + bool v2; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__cchheecckkeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when a torrent completes checking. i.e. when it │ │ │ │ -transitions out of the checking files state into a state where it is ready to │ │ │ │ -start downloading │ │ │ │ -struct torrent_checked_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ -}; │ │ │ │ +********** ssttoorraaggee__ppaarraammss(()) ********** │ │ │ │ +ssttoorraaggee__ppaarraammss (file_storage const& f, lt::renamed_files const& mf │ │ │ │ + , string_view sp, string_view pfd, storage_mode_t const sm │ │ │ │ + , aux::vector const& prio │ │ │ │ + , sha1_hash const& ih, bool v1_torrent, bool v2_torrent); │ │ │ │ +constructs a parameter pack from the layout, save path, mode, per-file │ │ │ │ +priorities, info-hash and protocol-version flags. v1 indicates that the torrent │ │ │ │ +has v1 metadata (a SHA-1 info-hash); v2 that it has v2 metadata (BEP 52). A │ │ │ │ +hybrid torrent has both set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ uurrll__sseeeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a HTTP seed name lookup fails. │ │ │ │ -struct url_seed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* sseerrvveerr__uurrll () const; │ │ │ │ - char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer | alert_category::error; │ │ │ │ - error_code const error; │ │ │ │ -}; │ │ │ │ + files │ │ │ │ + the file layout (sizes, paths, flags) of the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseerrvveerr__uurrll(()) ********** │ │ │ │ -char const* sseerrvveerr__uurrll () const; │ │ │ │ -the URL the error is associated with │ │ │ │ + renamed_files │ │ │ │ + rename overlay applied on top of files; on-disk paths resolved through │ │ │ │ + this object take precedence over the originals │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eerrrroorr__mmeessssaaggee(()) ********** │ │ │ │ -char const* eerrrroorr__mmeessssaaggee () const; │ │ │ │ -in case the web server sent an error message, this function returns it. │ │ │ │ + path │ │ │ │ + the directory where the torrent's files are stored │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error the web seed encountered. If this is not set, the server sent │ │ │ │ - an error message, call error_message(). │ │ │ │ + part_file_dir │ │ │ │ + directory in which the part file is created. If empty, the part file is │ │ │ │ + placed under path. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -If the storage fails to read or write files that it needs access to, this _a_l_e_r_t │ │ │ │ -is generated and the torrent is paused. │ │ │ │ -struct file_error_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* ffiilleennaammee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status │ │ │ │ - | alert_category::storage; │ │ │ │ - error_code const error; │ │ │ │ - operation_t op; │ │ │ │ -}; │ │ │ │ + mode │ │ │ │ + the storage allocation mode (sparse vs. pre-allocated) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiilleennaammee(()) ********** │ │ │ │ -char const* ffiilleennaammee () const; │ │ │ │ -the file that experienced the error │ │ │ │ + priorities │ │ │ │ + per-file download priorities, indexed by file index │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error code describing the error. │ │ │ │ + info_hash │ │ │ │ + the SHA-1 info-hash of the torrent (zero for v2-only torrents) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - indicates which underlying operation caused the error │ │ │ │ + v1 v2 │ │ │ │ + indicates which BitTorrent protocol version(s) this storage is for. v1 is │ │ │ │ + true if the torrent has v1 metadata; v2 is true if the torrent has v2 │ │ │ │ + metadata (BEP 52). A hybrid torrent has both flags set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ mmeettaaddaattaa__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when the metadata has been completely received and the │ │ │ │ -info-hash failed to match it. i.e. the metadata that was received was corrupt. │ │ │ │ -libtorrent will automatically retry to fetch it in this case. This is only │ │ │ │ -relevant when running a torrent-less download, with the metadata extension │ │ │ │ -provided by libtorrent. │ │ │ │ -struct metadata_failed_alert final : torrent_alert │ │ │ │ +************ ffiillee__sslliiccee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ +represents a window of a file in a torrent. │ │ │ │ +The file_index refers to the index of the file (in the _t_o_r_r_e_n_t___i_n_f_o). To get │ │ │ │ +the path and filename, use file_path() and give the file_index as argument. The │ │ │ │ +offset is the byte offset in the file where the range starts, and size is the │ │ │ │ +number of bytes this range is. The size + offset will never be greater than the │ │ │ │ +file size. │ │ │ │ +struct file_slice │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error; │ │ │ │ - error_code const error; │ │ │ │ + file_index_t file_index; │ │ │ │ + std::int64_t offset; │ │ │ │ + std::int64_t size; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - indicates what failed when parsing the metadata. This error is what's │ │ │ │ - returned from lazy_bdecode(). │ │ │ │ + file_index │ │ │ │ + the index of the file │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ mmeettaaddaattaa__rreecceeiivveedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when the metadata has been completely received and the │ │ │ │ -torrent can start downloading. It is not generated on torrents that are started │ │ │ │ -with metadata, but only those that needs to download it from peers (via │ │ │ │ -ut_metadata). │ │ │ │ -There are no additional data members in this _a_l_e_r_t. │ │ │ │ -Typically, when receiving this _a_l_e_r_t, you would want to trigger saving its │ │ │ │ -resume data. You do that by calling _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) on the torrent handle, │ │ │ │ -like this: .. code:: c++ │ │ │ │ - torrent_handle h = alert->handle; h.save_resume_data(torrent_handle:: │ │ │ │ - save_info_dict); │ │ │ │ -In the handler for the save_resume_alert, you can save the resume data but also │ │ │ │ -a copy of torrent file: .. code:: c++ │ │ │ │ - save_resume_data_alert* alert = ...; std::vector buf = │ │ │ │ - write_resume_data_buf(alert->params); std::ofstream f("resume-data"); │ │ │ │ - f.write(buf.data(), buf.size()); │ │ │ │ -If writing a .torrent file that may be a v2 torrent and may not yet have │ │ │ │ -downloaded the piece layers from its peers, you need to specify the │ │ │ │ -allow_missing_piece_layer flag. │ │ │ │ -struct metadata_received_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ -}; │ │ │ │ + offset │ │ │ │ + the offset from the start of the file, in bytes │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ uuddpp__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when there is an error on a UDP socket. The UDP sockets │ │ │ │ -are used for all uTP, DHT and UDP tracker traffic. They are global to the │ │ │ │ -_s_e_s_s_i_o_n. │ │ │ │ -struct udp_error_alert final : alert │ │ │ │ + size │ │ │ │ + the size of the window, in bytes │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffiillee__ssttoorraaggee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ +The file_storage class represents a file list and the piece size. Everything │ │ │ │ +necessary to interpret a regular bittorrent storage file structure. │ │ │ │ +class file_storage │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ + bool iiss__vvaalliidd () const; │ │ │ │ + void rreesseerrvvee (int num_files); │ │ │ │ + void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ + void aadddd__ffiillee__bboorrrrooww (string_view filename │ │ │ │ + , std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ + , string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ + void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t │ │ │ │ +file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ + void aadddd__ffiillee__bboorrrrooww (error_code& ec, string_view filename │ │ │ │ + , std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ + , string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ + std::vector mmaapp__bblloocckk (piece_index_t piece, std::int64_t offset │ │ │ │ + , std::int64_t size) const; │ │ │ │ + peer_request mmaapp__ffiillee (file_index_t file, std::int64_t offset, int size) │ │ │ │ +const; │ │ │ │ + int nnuumm__ffiilleess () const noexcept; │ │ │ │ + file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ + index_range ffiillee__rraannggee () const noexcept; │ │ │ │ + std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ + std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ + int nnuumm__ppiieecceess () const; │ │ │ │ + void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ + piece_index_t eenndd__ppiieeccee () const; │ │ │ │ + piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ + index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ + int ppiieeccee__lleennggtthh () const; │ │ │ │ + void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ + int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ + int ppiieeccee__ssiizzee22 (piece_index_t index) const; │ │ │ │ + int bblloocckkss__iinn__ppiieeccee22 (piece_index_t index) const; │ │ │ │ + int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ + std::string const& nnaammee () const; │ │ │ │ + void sseett__nnaammee (std::string const& n); │ │ │ │ + void sswwaapp (file_storage& ti) noexcept; │ │ │ │ + std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ + string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ + std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = │ │ │ │ +"") const; │ │ │ │ + char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ + bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ + std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ + std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ + sha256_hash rroooott (file_index_t index) const; │ │ │ │ + std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ + int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ + int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ + index_range ffiillee__ppiieeccee__rraannggee (file_index_t) const; │ │ │ │ + int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ + int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ + std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& │ │ │ │ +save_path) const; │ │ │ │ + void aallll__ppaatthh__hhaasshheess (std::unordered_set& table) const; │ │ │ │ + file_flags_t ffiillee__ffllaaggss (file_index_t index) const; │ │ │ │ + bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t index) const; │ │ │ │ + file_index_t ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ + file_index_t llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ + file_index_t ffiillee__iinnddeexx__aatt__ooffffsseett (std::int64_t offset) const; │ │ │ │ + file_index_t ffiillee__iinnddeexx__ffoorr__rroooott (sha256_hash const& root_hash) const; │ │ │ │ + piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ + piece_index_t llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ + void ssaanniittiizzee__ssyymmlliinnkkss (); │ │ │ │ + bool vv22 () const; │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error; │ │ │ │ - aux::noexcept_movable endpoint; │ │ │ │ - operation_t operation; │ │ │ │ - error_code const error; │ │ │ │ + static inline constexpr file_flags_t ffllaagg__ppaadd__ffiillee = 0_bit; │ │ │ │ + static inline constexpr file_flags_t ffllaagg__hhiiddddeenn = 1_bit; │ │ │ │ + static inline constexpr file_flags_t ffllaagg__eexxeeccuuttaabbllee = 2_bit; │ │ │ │ + static inline constexpr file_flags_t ffllaagg__ssyymmlliinnkk = 3_bit; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - endpoint │ │ │ │ - the source address associated with the error (if any) │ │ │ │ +********** iiss__vvaalliidd(()) ********** │ │ │ │ +bool iiss__vvaalliidd () const; │ │ │ │ +returns true if the piece length has been initialized on the _f_i_l_e___s_t_o_r_a_g_e. This │ │ │ │ +is typically taken as a proxy of whether the _f_i_l_e___s_t_o_r_a_g_e as a whole is │ │ │ │ +initialized or not. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - operation │ │ │ │ - the operation that failed │ │ │ │ +********** rreesseerrvvee(()) ********** │ │ │ │ +void rreesseerrvvee (int num_files); │ │ │ │ +allocates space for num_files in the internal file list. This can be used to │ │ │ │ +avoid reallocating the internal file list when the number of files to be added │ │ │ │ +is known up-front. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error code describing the error │ │ │ │ +********** aadddd__ffiillee__bboorrrrooww(()) aadddd__ffiillee(()) ********** │ │ │ │ +void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ +void aadddd__ffiillee__bboorrrrooww (string_view filename │ │ │ │ + , std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ + , string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ +Adds a file to the file storage. The add_file_borrow version expects that │ │ │ │ +filename is the file name (without a path) of the file that's being added. This │ │ │ │ +memory is bboorrrroowweedd, i.e. it is the caller's responsibility to make sure it │ │ │ │ +stays valid throughout the lifetime of this _f_i_l_e___s_t_o_r_a_g_e object or any copy of │ │ │ │ +it. The same thing applies to filehash, which is an optional pointer to a 20 │ │ │ │ +byte binary SHA-1 hash of the file. │ │ │ │ +if filename is empty, the filename from path is used and not borrowed. │ │ │ │ +The path argument is the full path (in the torrent file) to the file to add. │ │ │ │ +Note that this is not supposed to be an absolute path, but it is expected to │ │ │ │ +include the name of the torrent as the first path element. │ │ │ │ +file_size is the size of the file in bytes. │ │ │ │ +The file_flags argument sets attributes on the file. The file attributes is an │ │ │ │ +extension and may not work in all bittorrent clients. │ │ │ │ +For possible file attributes, see file_storage::flags_t. │ │ │ │ +The mtime argument is optional and can be set to 0. If non-zero, it is the │ │ │ │ +posix time of the last modification time of this file. │ │ │ │ +symlink_path is the path the file is a symlink to. To make this a symlink you │ │ │ │ +also need to set the _f_i_l_e___s_t_o_r_a_g_e_:_:_f_l_a_g___s_y_m_l_i_n_k file flag. │ │ │ │ +root_hash is an optional pointer to a 32 byte SHA-256 hash, being the merkle │ │ │ │ +tree root hash for this file. This is only used for v2 torrents. If the root │ │ │ │ +hash is specified for one file, it has to be specified for all, otherwise this │ │ │ │ +function will fail. Note that the buffer root_hash points to must out-live the │ │ │ │ +_f_i_l_e___s_t_o_r_a_g_e object, it will not be copied. This parameter is only used when │ │ │ │ +llooaaddiinngg torrents, that already have their file hashes computed. When creating │ │ │ │ +torrents, the file hashes will be computed by the piece hashes. │ │ │ │ +If more files than one are added, certain restrictions to their paths apply. In │ │ │ │ +a multi-file file storage (torrent), all files must share the same root │ │ │ │ +directory. │ │ │ │ +That is, the first path element of all files must be the same. This shared path │ │ │ │ +element is also set to the name of the torrent. It can be changed by calling │ │ │ │ +set_name. │ │ │ │ +The overloads that take anerror_codereference will report failures via that │ │ │ │ +variable, otherwisesystem_erroris thrown. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eexxtteerrnnaall__iipp__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -Whenever libtorrent learns about the machines external IP, this _a_l_e_r_t is │ │ │ │ -generated. The external IP address can be acquired from the tracker (if it │ │ │ │ -supports that) or from peers that supports the extension protocol. The address │ │ │ │ -can be accessed through the external_address member. │ │ │ │ -struct external_ip_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ - aux::noexcept_movable
      external_address; │ │ │ │ -}; │ │ │ │ +********** aadddd__ffiillee__bboorrrrooww(()) aadddd__ffiillee(()) ********** │ │ │ │ +void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ +void aadddd__ffiillee__bboorrrrooww (error_code& ec, string_view filename │ │ │ │ + , std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {}, std::int64_t mtime = 0 │ │ │ │ + , string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ +these overloads report failures through the ec reference rather than throwing. │ │ │ │ +add_file_borrow() does not copy the filename string; it is borrowed by │ │ │ │ +reference and the caller must keep it alive for the lifetime of this │ │ │ │ +file_storage object. This is useful when constructing the file list from a │ │ │ │ +memory-mapped .torrent file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - external_address │ │ │ │ - the IP address that is believed to be our external IP │ │ │ │ +********** mmaapp__bblloocckk(()) ********** │ │ │ │ +std::vector mmaapp__bblloocckk (piece_index_t piece, std::int64_t offset │ │ │ │ + , std::int64_t size) const; │ │ │ │ +returns a list of _f_i_l_e___s_l_i_c_e objects representing the portions of files the │ │ │ │ +specified piece index, byte offset and size range overlaps. this is the inverse │ │ │ │ +mapping of _m_a_p___f_i_l_e_(_). │ │ │ │ +Preconditions of this function is that the input range is within the torrents │ │ │ │ +address space. piece may not be negative and │ │ │ │ + piece * piece_size + offset + size │ │ │ │ +may not exceed the total size of the torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ lliisstteenn__ffaaiilleedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when none of the ports, given in the port range, to │ │ │ │ -_s_e_s_s_i_o_n can be opened for listening. The listen_interface member is the │ │ │ │ -interface that failed, error is the error code describing the failure. │ │ │ │ -In the case an endpoint was created before generating the _a_l_e_r_t, it is │ │ │ │ -represented by address and port. The combinations of socket type and operation │ │ │ │ -in which such address and port are not valid are: accept - i2p accept - socks5 │ │ │ │ -enum_if - tcp │ │ │ │ -libtorrent may sometimes try to listen on port 0, if all other ports failed. │ │ │ │ -Port 0 asks the operating system to pick a port that's free). If that fails you │ │ │ │ -may see a _l_i_s_t_e_n___f_a_i_l_e_d___a_l_e_r_t with port 0 even if you didn't ask to listen on │ │ │ │ -it. │ │ │ │ -struct listen_failed_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* lliisstteenn__iinntteerrffaaccee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status | alert_category::error; │ │ │ │ - error_code const error; │ │ │ │ - operation_t op; │ │ │ │ - lt::socket_type_t const socket_type; │ │ │ │ - aux::noexcept_movable address; │ │ │ │ - int const port; │ │ │ │ -}; │ │ │ │ +********** mmaapp__ffiillee(()) ********** │ │ │ │ +peer_request mmaapp__ffiillee (file_index_t file, std::int64_t offset, int size) const; │ │ │ │ +returns a _p_e_e_r___r_e_q_u_e_s_t representing the piece index, byte offset and size the │ │ │ │ +specified file range overlaps. This is the inverse mapping over _m_a_p___b_l_o_c_k_(_). │ │ │ │ +Note that the peer_request return type is meant to hold bittorrent block │ │ │ │ +requests, which may not be larger than 16 kiB. Mapping a range larger than that │ │ │ │ +may return an overflown integer. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** lliisstteenn__iinntteerrffaaccee(()) ********** │ │ │ │ -char const* lliisstteenn__iinntteerrffaaccee () const; │ │ │ │ -the network device libtorrent attempted to listen on, or the IP address │ │ │ │ +********** nnuumm__ffiilleess(()) ********** │ │ │ │ +int nnuumm__ffiilleess () const noexcept; │ │ │ │ +returns the number of files in the _f_i_l_e___s_t_o_r_a_g_e │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error the system returned │ │ │ │ +********** eenndd__ffiillee(()) ********** │ │ │ │ +file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ +returns the index of the one-past-end file in the file storage │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - the underlying operation that failed │ │ │ │ +********** ffiillee__rraannggee(()) ********** │ │ │ │ +index_range ffiillee__rraannggee () const noexcept; │ │ │ │ +returns an implementation-defined type that can be used as the container in a │ │ │ │ +range-for loop. Where the values are the indices of all files in the │ │ │ │ +_f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - socket_type │ │ │ │ - the type of listen socket this _a_l_e_r_t refers to. │ │ │ │ +********** ttoottaall__ssiizzee(()) ********** │ │ │ │ +std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ +returns the total number of bytes all the files in this torrent spans including │ │ │ │ +pad files │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - address │ │ │ │ - the address libtorrent attempted to listen on see _a_l_e_r_t documentation for │ │ │ │ - validity of this value │ │ │ │ +********** ssiizzee__oonn__ddiisskk(()) ********** │ │ │ │ +std::int64_t ssiizzee__oonn__ddiisskk () const; │ │ │ │ +returns the sum of all non pad file sizes │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - port │ │ │ │ - the port libtorrent attempted to listen on see _a_l_e_r_t documentation for │ │ │ │ - validity of this value │ │ │ │ +********** sseett__nnuumm__ppiieecceess(()) nnuumm__ppiieecceess(()) ********** │ │ │ │ +int nnuumm__ppiieecceess () const; │ │ │ │ +void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ +set and get the number of pieces in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ lliisstteenn__ssuucccceeeeddeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when the listen port succeeds to be opened on a particular │ │ │ │ -interface. address and port is the endpoint that successfully was opened for │ │ │ │ -listening. │ │ │ │ -struct listen_succeeded_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ - aux::noexcept_movable address; │ │ │ │ - int const port; │ │ │ │ - lt::socket_type_t const socket_type; │ │ │ │ -}; │ │ │ │ +********** eenndd__ppiieeccee(()) ********** │ │ │ │ +piece_index_t eenndd__ppiieeccee () const; │ │ │ │ +returns the index of the one-past-end piece in the file storage │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - address │ │ │ │ - the address libtorrent ended up listening on. This address refers to the │ │ │ │ - local interface. │ │ │ │ +********** llaasstt__ppiieeccee(()) ********** │ │ │ │ +piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ +returns the index of the last piece in the torrent. The last piece is special │ │ │ │ +in that it may be smaller than the other pieces (and the other pieces are all │ │ │ │ +the same size). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - port │ │ │ │ - the port libtorrent ended up listening on. │ │ │ │ +********** ppiieeccee__rraannggee(()) ********** │ │ │ │ +index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ +returns an implementation-defined type that can be used as the container in a │ │ │ │ +range-for loop. Where the values are the indices of all pieces in the │ │ │ │ +_f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - socket_type │ │ │ │ - the type of listen socket this _a_l_e_r_t refers to. │ │ │ │ +********** sseett__ppiieeccee__lleennggtthh(()) ppiieeccee__lleennggtthh(()) ********** │ │ │ │ +int ppiieeccee__lleennggtthh () const; │ │ │ │ +void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ +set and get the size of each piece in this torrent. It must be a power of two │ │ │ │ +and at least 16 kiB. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppoorrttmmaapp__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a NAT router was successfully found but some part │ │ │ │ -of the port mapping request failed. It contains a text message that may help │ │ │ │ -the user figure out what is wrong. This _a_l_e_r_t is not generated in case it │ │ │ │ -appears the client is not running on a NAT:ed network or if it appears there is │ │ │ │ -no NAT router that can be remote controlled to add port mappings. │ │ │ │ -struct portmap_error_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -port_mapping │ │ │ │ - | alert_category::error; │ │ │ │ - port_mapping_t const mapping; │ │ │ │ - portmap_transport map_transport; │ │ │ │ - aux::noexcept_movable
      local_address; │ │ │ │ - error_code const error; │ │ │ │ -}; │ │ │ │ +********** ppiieeccee__ssiizzee(()) ********** │ │ │ │ +int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ +returns the piece size of index. This will be the same as _p_i_e_c_e___l_e_n_g_t_h_(_), │ │ │ │ +except for the last piece, which may be shorter. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - mapping │ │ │ │ - refers to the mapping index of the port map that failed, i.e. the index │ │ │ │ - returned from add_mapping(). │ │ │ │ +********** ppiieeccee__ssiizzee22(()) ********** │ │ │ │ +int ppiieeccee__ssiizzee22 (piece_index_t index) const; │ │ │ │ +Returns the size of the given piece. If the piece spans multiple files, only │ │ │ │ +the first file is considered part of the piece. This is used for v2 torrents, │ │ │ │ +where all files are piece aligned and padded. i.e. The pad files are not │ │ │ │ +considered part of the piece for this purpose. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - map_transport │ │ │ │ - UPnP or NAT-PMP │ │ │ │ +********** bblloocckkss__iinn__ppiieeccee22(()) ********** │ │ │ │ +int bblloocckkss__iinn__ppiieeccee22 (piece_index_t index) const; │ │ │ │ +returns the number of blocks in the specified piece, for v2 torrents. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - local_address │ │ │ │ - the local network the port mapper is running on │ │ │ │ +********** bblloocckkss__ppeerr__ppiieeccee(()) ********** │ │ │ │ +int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ +returns the number of blocks there are in the typical piece. There may be fewer │ │ │ │ +in the last piece) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - tells you what failed. │ │ │ │ +********** nnaammee(()) sseett__nnaammee(()) ********** │ │ │ │ +std::string const& nnaammee () const; │ │ │ │ +void sseett__nnaammee (std::string const& n); │ │ │ │ +set and get the name of this torrent. For multi-file torrents, this is also the │ │ │ │ +name of the root directory all the files are stored in. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppoorrttmmaapp__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a NAT router was successfully found and a port was │ │ │ │ -successfully mapped on it. On a NAT:ed network with a NAT-PMP capable router, │ │ │ │ -this is typically generated once when mapping the TCP port and, if DHT is │ │ │ │ -enabled, when the UDP port is mapped. │ │ │ │ -struct portmap_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -port_mapping; │ │ │ │ - port_mapping_t const mapping; │ │ │ │ - int const external_port; │ │ │ │ - portmap_protocol const map_protocol; │ │ │ │ - portmap_transport const map_transport; │ │ │ │ - aux::noexcept_movable
      local_address; │ │ │ │ -}; │ │ │ │ +********** sswwaapp(()) ********** │ │ │ │ +void sswwaapp (file_storage& ti) noexcept; │ │ │ │ +swap all content of tthhiiss with ttii. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - mapping │ │ │ │ - refers to the mapping index of the port map that failed, i.e. the index │ │ │ │ - returned from add_mapping(). │ │ │ │ +********** ffiillee__ooffffsseett(()) rroooott__ppttrr(()) ppaadd__ffiillee__aatt(()) ffiillee__nnaammee(()) ffiillee__ppaatthh(()) rroooott(()) │ │ │ │ +ffiillee__ssiizzee(()) mmttiimmee(()) ssyymmlliinnkk(()) ********** │ │ │ │ +std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ +string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ +std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = "") │ │ │ │ +const; │ │ │ │ +char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ +bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ +std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ +std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ +sha256_hash rroooott (file_index_t index) const; │ │ │ │ +std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ +These functions are used to query attributes of files at a given index. │ │ │ │ +root() returns the SHA-256 merkle tree root of the specified file, in case this │ │ │ │ +is a v2 torrent. Otherwise returns zeros. root_ptr() returns a pointer to the │ │ │ │ +SHA-256 merkle tree root hash for the specified file. The pointer points into │ │ │ │ +storage referred to when the file was added, it is not owned by this object. │ │ │ │ +Torrents that are not v2 torrents return nullptr. │ │ │ │ +The mtime() is the modification time is the posix time when a file was last │ │ │ │ +modified when the torrent was created, or 0 if it was not included in the │ │ │ │ +torrent file. │ │ │ │ +file_path() returns the full path to a file. │ │ │ │ +file_size() returns the size of a file. │ │ │ │ +pad_file_at() returns true if the file at the given index is a pad-file. │ │ │ │ +file_name() returns jjuusstt the name of the file, whereas file_path() returns the │ │ │ │ +path (inside the torrent file) with the filename appended. │ │ │ │ +symlink() returns the path the file at index is a symlink to. If the file is │ │ │ │ +not a symlink, the returned string is empty. │ │ │ │ +file_offset() returns the byte offset within the torrent file where this file │ │ │ │ +starts. It can be used to map the file to a piece index (given the piece size). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - external_port │ │ │ │ - the external port allocated for the mapping. │ │ │ │ +********** ffiillee__nnuumm__ppiieecceess(()) ffiillee__nnuumm__bblloocckkss(()) ffiillee__ppiieeccee__rraannggee(()) ********** │ │ │ │ +int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ +int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ +index_range ffiillee__ppiieeccee__rraannggee (file_index_t) const; │ │ │ │ +Returns the number of pieces or blocks the file atindexspans, under the │ │ │ │ +assumption that the file is aligned to the start of a piece. This is only │ │ │ │ +meaningful for v2 torrents, where files are guaranteed such alignment. These │ │ │ │ +numbers are used to size and navigate the merkle hash tree for each file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - local_address │ │ │ │ - the local network the port mapper is running on │ │ │ │ +********** ffiillee__ffiirrsstt__bblloocckk__nnooddee(()) ffiillee__ffiirrsstt__ppiieeccee__nnooddee(()) ********** │ │ │ │ +int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ +int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ +index of first piece node in the merkle tree │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppoorrttmmaapp__lloogg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated to log informational events related to either UPnP or │ │ │ │ -NAT-PMP. They contain a log line and the type (0 = NAT-PMP and 1 = UPnP). │ │ │ │ -Displaying these messages to an end user is only useful for debugging the UPnP │ │ │ │ -or NAT-PMP implementation. This _a_l_e_r_t is only posted if the alert_category:: │ │ │ │ -port_mapping_log flag is enabled in the _a_l_e_r_t mask. │ │ │ │ -struct portmap_log_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* lloogg__mmeessssaaggee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -port_mapping_log; │ │ │ │ - portmap_transport const map_transport; │ │ │ │ - aux::noexcept_movable
      local_address; │ │ │ │ -}; │ │ │ │ +********** ffiillee__ppaatthh__hhaasshh(()) ********** │ │ │ │ +std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& save_path) │ │ │ │ +const; │ │ │ │ +returns the crc32 hash of file_path(index) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ -char const* lloogg__mmeessssaaggee () const; │ │ │ │ -the message associated with this log line │ │ │ │ +********** aallll__ppaatthh__hhaasshheess(()) ********** │ │ │ │ +void aallll__ppaatthh__hhaasshheess (std::unordered_set& table) const; │ │ │ │ +this will add the CRC32 hash of all directory entries to the table. No filename │ │ │ │ +will be included, just directories. Every depth of directories are added │ │ │ │ +separately to allow test for collisions with files at all levels. i.e. if one │ │ │ │ +path in the torrent is foo/bar/baz, the CRC32 hashes for foo, foo/bar and foo/ │ │ │ │ +bar/baz will be added to the set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - local_address │ │ │ │ - the local network the port mapper is running on │ │ │ │ +********** ffiillee__ffllaaggss(()) ********** │ │ │ │ +file_flags_t ffiillee__ffllaaggss (file_index_t index) const; │ │ │ │ +returns a bitmask of flags from file_flags_t that apply to file at index. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffaassttrreessuummee__rreejjeecctteedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a fast resume file has been passed to _a_d_d___t_o_r_r_e_n_t │ │ │ │ -_(_) but the files on disk did not match the fast resume file. The error_code │ │ │ │ -explains the reason why the resume file was rejected. │ │ │ │ -struct fastresume_rejected_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* ffiillee__ppaatthh () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status │ │ │ │ - | alert_category::error; │ │ │ │ - error_code error; │ │ │ │ - operation_t op; │ │ │ │ -}; │ │ │ │ +********** ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ +bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t index) const; │ │ │ │ +returns true if the file at the specified index has been renamed to have an │ │ │ │ +absolute path, i.e. is not anchored in the save path of the torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppaatthh(()) ********** │ │ │ │ -char const* ffiillee__ppaatthh () const; │ │ │ │ -If the error happened to a specific file, this returns the path to it. │ │ │ │ +********** llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee(()) ffiillee__iinnddeexx__aatt__ooffffsseett(()) ffiillee__iinnddeexx__aatt__ppiieeccee(()) │ │ │ │ +********** │ │ │ │ +file_index_t ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ +file_index_t llaasstt__ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ +file_index_t ffiillee__iinnddeexx__aatt__ooffffsseett (std::int64_t offset) const; │ │ │ │ +returns the index of the file at the given offset or piece in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - the underlying operation that failed │ │ │ │ +********** ffiillee__iinnddeexx__ffoorr__rroooott(()) ********** │ │ │ │ +file_index_t ffiillee__iinnddeexx__ffoorr__rroooott (sha256_hash const& root_hash) const; │ │ │ │ +finds the file with the given root hash and returns its index if there is no │ │ │ │ +file with the root hash, file_index_t{-1} is returned │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__bblloocckkeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when an incoming peer connection, or a peer that's about │ │ │ │ -to be added to our peer list, is blocked for some reason. This could be any of: │ │ │ │ - * the IP filter │ │ │ │ - * i2p mixed mode restrictions (a normal peer is not allowed on an i2p │ │ │ │ - swarm) │ │ │ │ - * the port filter │ │ │ │ - * the peer has a low port and no_connect_privileged_ports is enabled │ │ │ │ - * the protocol of the peer is blocked (uTP/TCP blocking) │ │ │ │ -struct peer_blocked_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - enum reason_t │ │ │ │ - { │ │ │ │ - ip_filter, │ │ │ │ - port_filter, │ │ │ │ - i2p_mixed, │ │ │ │ - privileged_ports, │ │ │ │ - utp_disabled, │ │ │ │ - tcp_disabled, │ │ │ │ - invalid_local_interface, │ │ │ │ - ssrf_mitigation, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -ip_block; │ │ │ │ - int const reason; │ │ │ │ -}; │ │ │ │ +********** ppiieeccee__iinnddeexx__aatt__ffiillee(()) llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee(()) ********** │ │ │ │ +piece_index_t ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ +piece_index_t llaasstt__ppiieeccee__iinnddeexx__aatt__ffiillee (file_index_t f) const; │ │ │ │ +returns the first or last piece index of the given file in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm rreeaassoonn__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_i_p___f_i_l_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_o_r_t___f_i_l_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_2_p___m_i_x_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_r_i_v_i_l_e_g_e_d___p_o_r_t_s_ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_t_p___d_i_s_a_b_l_e_d_ _ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_c_p___d_i_s_a_b_l_e_d_ _ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_v_a_l_i_d___l_o_c_a_l___i_n_t_e_r_f_a_c_e_|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_s_r_f___m_i_t_i_g_a_t_i_o_n_ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** ssaanniittiizzee__ssyymmlliinnkkss(()) ********** │ │ │ │ +void ssaanniittiizzee__ssyymmlliinnkkss (); │ │ │ │ +validate any symlinks, to ensure they all point to other files or directories │ │ │ │ +inside this storage. Any invalid symlinks are updated to point to themselves. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - reason │ │ │ │ - the reason for the peer being blocked. Is one of the values from the │ │ │ │ - _r_e_a_s_o_n___t enum. │ │ │ │ +********** vv22(()) ********** │ │ │ │ +bool vv22 () const; │ │ │ │ +returns true if this torrent contains v2 metadata. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__aannnnoouunnccee__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a DHT node announces to an info-hash on our DHT │ │ │ │ -node. It belongs to the alert_category::dht category. │ │ │ │ -struct dht_announce_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - aux::noexcept_movable
      ip; │ │ │ │ - int port; │ │ │ │ - sha1_hash info_hash; │ │ │ │ -}; │ │ │ │ + flag_pad_file │ │ │ │ + the file is a pad file. It's required to contain zeros at it will not be │ │ │ │ + saved to disk. Its purpose is to make the following file start on a piece │ │ │ │ + boundary. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__ggeett__ppeeeerrss__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when a DHT node sends a get_peers message to our DHT │ │ │ │ -node. It belongs to the alert_category::dht category. │ │ │ │ -struct dht_get_peers_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - sha1_hash info_hash; │ │ │ │ -}; │ │ │ │ + flag_hidden │ │ │ │ + this file has the hidden attribute set. This is primarily a windows │ │ │ │ + attribute │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ccaacchhee__fflluusshheedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when the disk cache has been flushed for a specific │ │ │ │ -torrent as a result of a call to _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_f_l_u_s_h___c_a_c_h_e_(_). This _a_l_e_r_t │ │ │ │ -belongs to the alert_category::storage category, which must be enabled to let │ │ │ │ -this _a_l_e_r_t through. The _a_l_e_r_t is also posted when removing a torrent from the │ │ │ │ -_s_e_s_s_i_o_n, once the outstanding cache flush is complete and the torrent does no │ │ │ │ -longer have any files open. │ │ │ │ -struct cache_flushed_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ -}; │ │ │ │ + flag_executable │ │ │ │ + this file has the executable attribute set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ llssdd__ppeeeerr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when we receive a local service discovery message from │ │ │ │ -a peer for a torrent we're currently participating in. │ │ │ │ -struct lsd_peer_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ -}; │ │ │ │ + flag_symlink │ │ │ │ + this file is a symbolic link. It should have a link target string │ │ │ │ + associated with it. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrraacckkeerriidd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted whenever a tracker responds with a trackerid. The tracker │ │ │ │ -ID is like a cookie. libtorrent will store the tracker ID for this tracker and │ │ │ │ -repeat it in subsequent announces. │ │ │ │ -struct trackerid_alert final : tracker_alert │ │ │ │ +************ rreennaammeedd__ffiilleess ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ +this is a wrapper around _f_i_l_e___s_t_o_r_a_g_e for renaming files without having to │ │ │ │ +mutate the _f_i_l_e___s_t_o_r_a_g_e object itself. │ │ │ │ +struct renamed_files │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* ttrraacckkeerr__iidd () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ + bool ffiillee__aabbssoolluuttee__ppaatthh (file_storage const& fs, file_index_t index) const; │ │ │ │ + string_view ffiillee__nnaammee (file_storage const& fs, file_index_t index) const; │ │ │ │ + std::string ffiillee__ppaatthh (file_storage const& fs, file_index_t index, std:: │ │ │ │ +string const& save_path = "") const; │ │ │ │ + void rreennaammee__ffiillee (file_storage const& fs, file_index_t index, std::string │ │ │ │ +const& new_filename); │ │ │ │ + void iimmppoorrtt__ffiilleennaammeess (file_storage const& fs, std::map const& renamed_files); │ │ │ │ + std::map eexxppoorrtt__ffiilleennaammeess (file_storage const& │ │ │ │ +fs) const; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttrraacckkeerr__iidd(()) ********** │ │ │ │ -char const* ttrraacckkeerr__iidd () const; │ │ │ │ -The tracker ID returned by the tracker │ │ │ │ +********** ffiillee__ppaatthh(()) ffiillee__nnaammee(()) ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ +bool ffiillee__aabbssoolluuttee__ppaatthh (file_storage const& fs, file_index_t index) const; │ │ │ │ +string_view ffiillee__nnaammee (file_storage const& fs, file_index_t index) const; │ │ │ │ +std::string ffiillee__ppaatthh (file_storage const& fs, file_index_t index, std::string │ │ │ │ +const& save_path = "") const; │ │ │ │ +returns information about the file at index in fs, honoring any rename recorded │ │ │ │ +in this object. file_path() returns the full on-disk path (prepending save_path │ │ │ │ +to relative paths). file_name() returns just the leaf filename. │ │ │ │ +file_absolute_path() returns true if the recorded rename is an absolute path │ │ │ │ +(in which case save_path is ignored). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__bboooottssttrraapp__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when the initial DHT bootstrap is done. │ │ │ │ -struct dht_bootstrap_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ -}; │ │ │ │ +********** rreennaammee__ffiillee(()) ********** │ │ │ │ +void rreennaammee__ffiillee (file_storage const& fs, file_index_t index, std::string │ │ │ │ +const& new_filename); │ │ │ │ +records that the file at index in fs should be renamed to new_filename on disk. │ │ │ │ +The underlying file_storage is not modified. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is posted whenever a torrent is transitioned into the error state. If the │ │ │ │ -error code is duplicate_torrent (_e_r_r_o_r___c_o_d_e___e_n_u_m) error, it suggests two magnet │ │ │ │ -links ended up resolving to the same hybrid torrent. For more details, see │ │ │ │ -_B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. │ │ │ │ -struct torrent_error_alert final : torrent_alert │ │ │ │ +********** eexxppoorrtt__ffiilleennaammeess(()) iimmppoorrtt__ffiilleennaammeess(()) ********** │ │ │ │ +void iimmppoorrtt__ffiilleennaammeess (file_storage const& fs, std::map const& renamed_files); │ │ │ │ +std::map eexxppoorrtt__ffiilleennaammeess (file_storage const& fs) │ │ │ │ +const; │ │ │ │ +bulk import or export the set of file renames recorded in this object. │ │ │ │ +import_filenames() adds the given renames (dropping entries whose file index is │ │ │ │ +out of range). export_filenames() returns the current renames as a map suitable │ │ │ │ +for serializing and later passing back to import_filenames(). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ffiilleennaammeess ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ +a lightweight view that pairs a file_storage with the rename overrides in a │ │ │ │ +renamed_files. It exposes the read-only subset of file_storage that downstream │ │ │ │ +code (e.g. the disk I/O backends) needs, with file paths automatically resolved │ │ │ │ +through the rename layer. │ │ │ │ +struct filenames │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* ffiilleennaammee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error | alert_category::status; │ │ │ │ - error_code const error; │ │ │ │ + ffiilleennaammeess (file_storage const& fs, renamed_files const& rf); │ │ │ │ + file_flags_t ffiillee__ffllaaggss (file_index_t const index) const; │ │ │ │ + file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ + bool ppaadd__ffiillee__aatt (file_index_t const index) const; │ │ │ │ + std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ + std::int64_t ffiillee__ooffffsseett (file_index_t const index) const; │ │ │ │ + bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ + std::string ffiillee__ppaatthh (file_index_t const index, std::string const& │ │ │ │ +save_path = "") const; │ │ │ │ + std::string ssyymmlliinnkk (file_index_t const index) const; │ │ │ │ + index_range ffiillee__rraannggee () const noexcept; │ │ │ │ + int nnuumm__ppiieecceess () const; │ │ │ │ + piece_index_t eenndd__ppiieeccee () const; │ │ │ │ + int nnuumm__ffiilleess () const noexcept; │ │ │ │ + std::vector mmaapp__bblloocckk (piece_index_t const piece, std::int64_t │ │ │ │ +const offset │ │ │ │ + , std::int64_t const size) const; │ │ │ │ + peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t const offset, │ │ │ │ +int const size) const; │ │ │ │ + sha256_hash rroooott (file_index_t const index) const; │ │ │ │ + int ppiieeccee__lleennggtthh () const; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiilleennaammee(()) ********** │ │ │ │ -char const* ffiilleennaammee () const; │ │ │ │ -the filename (or object) the error occurred on. │ │ │ │ +********** ffiilleennaammeess(()) ********** │ │ │ │ +ffiilleennaammeess (file_storage const& fs, renamed_files const& rf); │ │ │ │ +construct a view over fs with the renames recorded in rf applied. Both │ │ │ │ +references must outlive the view. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - specifies which error the torrent encountered. │ │ │ │ +********** ffiillee__ffllaaggss(()) ********** │ │ │ │ +file_flags_t ffiillee__ffllaaggss (file_index_t const index) const; │ │ │ │ +returns the file flags for the file at index │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__nneeeedd__cceerrtt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is always posted for SSL torrents. This is a reminder to the client that │ │ │ │ -the torrent won't work unless _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e_(_) is called │ │ │ │ -with a valid certificate. Valid certificates MUST be signed by the SSL │ │ │ │ -certificate in the .torrent file. │ │ │ │ -struct torrent_need_cert_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ -}; │ │ │ │ +********** eenndd__ffiillee(()) ********** │ │ │ │ +file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ +one past-the-end file index │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ iinnccoommiinngg__ccoonnnneeccttiioonn__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -The incoming connection _a_l_e_r_t is posted every time we successfully accept an │ │ │ │ -incoming connection, through any mean. The most straight-forward ways of │ │ │ │ -accepting incoming connections are through the TCP listen socket and the UDP │ │ │ │ -listen socket for uTP sockets. However, connections may also be accepted │ │ │ │ -through a Socks5 or i2p listen socket, or via an SSL listen socket. │ │ │ │ -struct incoming_connection_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer; │ │ │ │ - socket_type_t socket_type; │ │ │ │ - aux::noexcept_movable<_t_c_p_:_:_e_n_d_p_o_i_n_t> endpoint; │ │ │ │ -}; │ │ │ │ +********** ppaadd__ffiillee__aatt(()) ********** │ │ │ │ +bool ppaadd__ffiillee__aatt (file_index_t const index) const; │ │ │ │ +returns true if the file at index is a pad file │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - socket_type │ │ │ │ - tells you what kind of socket the connection was accepted │ │ │ │ +********** ffiillee__ssiizzee(()) ffiillee__ooffffsseett(()) ********** │ │ │ │ +std::int64_t ffiillee__ssiizzee (file_index_t const index) const; │ │ │ │ +std::int64_t ffiillee__ooffffsseett (file_index_t const index) const; │ │ │ │ +returns the file size or file offset for the file at index. The file offset is │ │ │ │ +in the torrent space, of all files in the torrent, in the order they are │ │ │ │ +defined. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - endpoint │ │ │ │ - is the IP address and port the connection came from. │ │ │ │ +********** ffiillee__ppaatthh(()) ffiillee__aabbssoolluuttee__ppaatthh(()) ********** │ │ │ │ +bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t const index) const; │ │ │ │ +std::string ffiillee__ppaatthh (file_index_t const index, std::string const& save_path = │ │ │ │ +"") const; │ │ │ │ +returns the on-disk path for the file at index, applying any rename recorded in │ │ │ │ +the underlying renamed_files. If save_path is non-empty it is prepended to │ │ │ │ +relative paths. file_absolute_path() returns true if the recorded rename is an │ │ │ │ +absolute path (in which case save_path is ignored). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ aadddd__ttoorrrreenntt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is always posted when a torrent was attempted to be added and │ │ │ │ -contains the return status of the add operation. The torrent handle of the new │ │ │ │ -torrent can be found as the handle member in the base class. If adding the │ │ │ │ -torrent failed, error contains the error code. │ │ │ │ -struct add_torrent_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ - add_torrent_params params; │ │ │ │ - error_code error; │ │ │ │ -}; │ │ │ │ +********** ssyymmlliinnkk(()) ********** │ │ │ │ +std::string ssyymmlliinnkk (file_index_t const index) const; │ │ │ │ +If the file at index is a symbolic link, its link target is returned. otherwise │ │ │ │ +an empty string. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - params │ │ │ │ - This contains copies of the most important fields from the original │ │ │ │ - _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object, passed to _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 │ │ │ │ - _(_). Specifically, these fields are copied: │ │ │ │ - * version │ │ │ │ - * ti │ │ │ │ - * name │ │ │ │ - * save_path │ │ │ │ - * userdata │ │ │ │ - * tracker_id │ │ │ │ - * flags │ │ │ │ - * info_hash │ │ │ │ - the info_hash field will be updated with the info-hash of the torrent │ │ │ │ - specified by ti. │ │ │ │ +********** ffiillee__rraannggee(()) ********** │ │ │ │ +index_range ffiillee__rraannggee () const noexcept; │ │ │ │ +all file indices in the underlying _f_i_l_e___s_t_o_r_a_g_e. Convenient in range-for loops. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - set to the error, if one occurred while adding the torrent. │ │ │ │ +********** nnuumm__ppiieecceess(()) eenndd__ppiieeccee(()) nnuumm__ffiilleess(()) ********** │ │ │ │ +int nnuumm__ppiieecceess () const; │ │ │ │ +piece_index_t eenndd__ppiieeccee () const; │ │ │ │ +int nnuumm__ffiilleess () const noexcept; │ │ │ │ +the number of files in the underlying _f_i_l_e___s_t_o_r_a_g_e, the number of pieces, and │ │ │ │ +the one-past-the-end piece index. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttaattee__uuppddaattee__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is only posted when requested by the user, by calling session:: │ │ │ │ -post_torrent_updates() on the _s_e_s_s_i_o_n. It contains the torrent status of all │ │ │ │ -torrents that changed since last time this message was posted. Its category is │ │ │ │ -alert_category::status, but it's not subject to filtering, since it's only │ │ │ │ -manually posted anyway. │ │ │ │ -struct state_update_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -status; │ │ │ │ - std::vector status; │ │ │ │ -}; │ │ │ │ +********** mmaapp__bblloocckk(()) ********** │ │ │ │ +std::vector mmaapp__bblloocckk (piece_index_t const piece, std::int64_t │ │ │ │ +const offset │ │ │ │ + , std::int64_t const size) const; │ │ │ │ +returns the list of file slices that make up the piece at piece, starting at │ │ │ │ +offset into the piece and covering size bytes. Each _e_n_t_r_y identifies one file │ │ │ │ +and the byte range within it that contributes to the requested block. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - status │ │ │ │ - contains the torrent status of all torrents that changed since last time │ │ │ │ - this message was posted. Note that you can map a torrent status to a │ │ │ │ - specific torrent via its handle member. The receiving end is suggested to │ │ │ │ - have all torrents sorted by the _t_o_r_r_e_n_t___h_a_n_d_l_e or hashed by it, for │ │ │ │ - efficient updates. │ │ │ │ +********** mmaapp__ffiillee(()) ********** │ │ │ │ +peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t const offset, int │ │ │ │ +const size) const; │ │ │ │ +inverse of map_block(): maps a byte range within the file at file (starting at │ │ │ │ +offset, of length size) to a peer_request identifying the piece, piece-offset │ │ │ │ +and length in torrent space. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseessssiioonn__ssttaattss__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -The _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t is posted when the user requests _s_e_s_s_i_o_n statistics by │ │ │ │ -calling _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) on the _s_e_s_s_i_o_n object. This _a_l_e_r_t does not have a │ │ │ │ -category, since it's only posted in response to an API call. It is not subject │ │ │ │ -to the alert_mask filter. │ │ │ │ -the message() member function returns a string representation of the values │ │ │ │ -that properly match the line returned in session_stats_header_alert::message(). │ │ │ │ -this specific output is parsed by tools/parse_session_stats.py if this is │ │ │ │ -changed, that parser should also be changed │ │ │ │ -struct session_stats_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - span ccoouunntteerrss () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = {}; │ │ │ │ -}; │ │ │ │ +********** rroooott(()) ********** │ │ │ │ +sha256_hash rroooott (file_index_t const index) const; │ │ │ │ +returns the v2 merkle root (pieces root) for the file at index. Returns a zero │ │ │ │ +hash for v1-only torrents. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccoouunntteerrss(()) ********** │ │ │ │ -span ccoouunntteerrss () const; │ │ │ │ -An array are a mix of ccoouunntteerrss and ggaauuggeess, which meanings can be queries via │ │ │ │ -the _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_) function on the _s_e_s_s_i_o_n. The mapping from a │ │ │ │ -specific metric to an index into this array is constant for a specific version │ │ │ │ -of libtorrent, but may differ for other versions. The intended usage is to │ │ │ │ -request the mapping, i.e. call _s_e_s_s_i_o_n___s_t_a_t_s___m_e_t_r_i_c_s_(_), once on startup, and │ │ │ │ -then use that mapping to interpret these values throughout the process' │ │ │ │ -runtime. │ │ │ │ -For more information, see the _s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ +********** ppiieeccee__lleennggtthh(()) ********** │ │ │ │ +int ppiieeccee__lleennggtthh () const; │ │ │ │ +the piece size, in bytes. All pieces have this size except the last, which may │ │ │ │ +be shorter. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when something fails in the DHT. This is not necessarily a fatal error, │ │ │ │ -but it could prevent proper operation │ │ │ │ -struct dht_error_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error | alert_category::dht; │ │ │ │ - error_code error; │ │ │ │ - operation_t op; │ │ │ │ -}; │ │ │ │ +************ mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_m_a_p___d_i_s_k___i_o_._h_p_p" │ │ │ │ +std::unique_ptr mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +constructs a memory mapped file disk I/O object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error code │ │ │ │ +************ ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ +std::unique_ptr ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +the constructor function for the default storage. On systems that support │ │ │ │ +memory mapped files (and a 64 bit address space) the memory mapped storage will │ │ │ │ +be constructed, otherwise the portable posix storage. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - the operation that failed │ │ │ │ +************ ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_a_b_l_e_d___d_i_s_k___i_o_._h_p_p" │ │ │ │ +std::unique_ptr ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +creates a disk io object that discards all data written to it, and only returns │ │ │ │ +zero-buffers when read from. May be useful for testing and benchmarking. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__iimmmmuuttaabbllee__iitteemm__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is posted as a response to a call to session::get_item(), │ │ │ │ -specifically the overload for looking up immutable items in the DHT. │ │ │ │ -struct dht_immutable_item_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - sha1_hash target; │ │ │ │ - entry item; │ │ │ │ -}; │ │ │ │ +************ ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_s_i_x___d_i_s_k___i_o_._h_p_p" │ │ │ │ +std::unique_ptr ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +this is a simple posix disk I/O back-end, used for systems that don't have a 64 │ │ │ │ +bit virtual address space or don't support memory mapped files. It's │ │ │ │ +implemented using portable C file functions and is single-threaded. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - target │ │ │ │ - the target hash of the immutable item. This must match the SHA-1 hash of │ │ │ │ - the bencoded form of item. │ │ │ │ +************ eennuumm ssttoorraaggee__mmooddee__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |All pieces will be written to their final | │ │ │ │ +| | |position, all files will be allocated in full | │ │ │ │ +|storage_mode_allocate|0 |when the torrent is first started. This mode | │ │ │ │ +| | |minimizes fragmentation but could be a costly | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_p_e_r_a_t_i_o_n_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |All pieces will be written to the place where | │ │ │ │ +|storage_mode_sparse |1 |they belong and sparse files will be used. This| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_s_ _t_h_e_ _r_e_c_o_m_m_e_n_d_e_d_,_ _a_n_d_ _d_e_f_a_u_l_t_ _m_o_d_e_._ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - item │ │ │ │ - the data for this item │ │ │ │ +************ eennuumm mmoovvee__ffllaaggss__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|always_replace_files |0 |replace any files in the destination when | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_p_y_i_n_g_ _o_r_ _m_o_v_i_n_g_ _t_h_e_ _s_t_o_r_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |if any files that we want to copy exist in | │ │ │ │ +| | |the destination exist, fail the whole | │ │ │ │ +| | |operation and don't perform any copy or move.| │ │ │ │ +| | |There is an inherent race condition in this | │ │ │ │ +|fail_if_exist |1 |mode. The files are checked for existence | │ │ │ │ +| | |before the operation starts. In between the | │ │ │ │ +| | |check and performing the copy, the | │ │ │ │ +| | |destination files may be created, in which | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_s_e_ _t_h_e_y_ _a_r_e_ _r_e_p_l_a_c_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |if any file exist in the target, take those | │ │ │ │ +|dont_replace |2 |files instead of the ones we may have in the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_o_u_r_c_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |don't move any source files, just forget | │ │ │ │ +|reset_save_path |3 |about them and begin checking files at new | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_a_v_e_ _p_a_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|reset_save_path_unchecked|4 |don't move any source files, just change save| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_a_t_h_ _a_n_d_ _c_o_n_t_i_n_u_e_ _w_o_r_k_i_n_g_ _w_i_t_h_o_u_t_ _a_n_y_ _c_h_e_c_k_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 │ │ │ │ + etc. │ │ │ │ + 3. Read through all the files in the torrent, SHA-1 all the data and set the │ │ │ │ + piece hashes. │ │ │ │ + 4. The torrent is bencoded into a file or buffer. │ │ │ │ +If there are a lot of files and or deep directory hierarchies to traverse, step │ │ │ │ +one can be time consuming. │ │ │ │ +Typically step 3 is by far the most time consuming step, since it requires to │ │ │ │ +read all the bytes from all the files in the torrent. │ │ │ │ +All of these classes and functions are declared by including libtorrent/ │ │ │ │ +create_torrent.hpp. │ │ │ │ +example: │ │ │ │ +// recursively create a list of all files in the directory │ │ │ │ +auto fs = list_files("./my_torrent"); │ │ │ │ + │ │ │ │ +create_torrent t(std::move(fs)); │ │ │ │ +t.add_tracker("http://my.tracker.com/announce"); │ │ │ │ +t.set_creator("libtorrent example"); │ │ │ │ + │ │ │ │ +// reads the files and calculates the hashes │ │ │ │ +set_piece_hashes(t, "."); │ │ │ │ + │ │ │ │ +ofstream out("my_torrent.torrent", std::ios_base::binary); │ │ │ │ +std::vector buf = t.generate_buf(); │ │ │ │ +out.write(buf.data(), buf.size()); │ │ │ │ + │ │ │ │ +// alternatively, generate an entry and encode it directly to an ostream │ │ │ │ +// iterator │ │ │ │ +bencode(std::ostream_iterator(out), t.generate()); │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__mmuuttaabbllee__iitteemm__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is posted as a response to a call to session::get_item(), │ │ │ │ -specifically the overload for looking up mutable items in the DHT. │ │ │ │ -struct dht_mutable_item_alert final : alert │ │ │ │ +************ ccrreeaattee__ffiillee__eennttrryy ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ +This represents one file in the torrent file to be created │ │ │ │ +struct create_file_entry │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ + ccrreeaattee__ffiillee__eennttrryy (std::string fn, std::int64_t const sz │ │ │ │ + , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = │ │ │ │ +{}); │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - std::array key; │ │ │ │ - std::array signature; │ │ │ │ - std::int64_t seq; │ │ │ │ - std::string salt; │ │ │ │ - entry item; │ │ │ │ - bool authoritative; │ │ │ │ + std::string filename; │ │ │ │ + std::int64_t size; │ │ │ │ + file_flags_t flags; │ │ │ │ + std::time_t mtime; │ │ │ │ + std::string symlink; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - key │ │ │ │ - the public key that was looked up │ │ │ │ +********** ccrreeaattee__ffiillee__eennttrryy(()) ********** │ │ │ │ +ccrreeaattee__ffiillee__eennttrryy (std::string fn, std::int64_t const sz │ │ │ │ + , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = │ │ │ │ +{}); │ │ │ │ +construct a file _e_n_t_r_y for the file at relative path fn with size sz. f is the │ │ │ │ +set of file flags that applies to the file, see file_flags_t. ts is an optional │ │ │ │ +modification time (0 to omit). sl is the symlink target, only used when f │ │ │ │ +includes the symlink flag. Symlinks are only allowed to target other files or │ │ │ │ +directories in the torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - signature │ │ │ │ - the signature of the data. This is not the signature of the plain encoded │ │ │ │ - form of the item, but it includes the sequence number and possibly the │ │ │ │ - hash as well. See the dht_store document for more information. This is │ │ │ │ - primarily useful for echoing back in a store request. │ │ │ │ + filename │ │ │ │ + the path and name of the file. The path is relative to the root of the │ │ │ │ + torrent file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - seq │ │ │ │ - the sequence number of this item │ │ │ │ + size │ │ │ │ + the size of the file │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - salt │ │ │ │ - the salt, if any, used to lookup and store this item. If no salt was │ │ │ │ - used, this is an empty string │ │ │ │ + flags │ │ │ │ + bitmask of file_flags_t (pad-file, hidden, executable, symlink) for this │ │ │ │ + file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - item │ │ │ │ - the data for this item │ │ │ │ + mtime │ │ │ │ + optional modification time of the file. 0 means "do not record". │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - authoritative │ │ │ │ - the last response for mutable data is authoritative. │ │ │ │ + symlink │ │ │ │ + the link target, only considered if the symlink flag is set │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__ppuutt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this is posted when a DHT put operation completes. This is useful if the client │ │ │ │ -is waiting for a put to complete before shutting down for instance. │ │ │ │ -struct dht_put_alert final : alert │ │ │ │ +************ ccrreeaattee__ttoorrrreenntt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ +This class holds state for creating a torrent. After having added all │ │ │ │ +information to it, call _c_r_e_a_t_e___t_o_r_r_e_n_t_:_:_g_e_n_e_r_a_t_e_(_) to generate the torrent. The │ │ │ │ +_e_n_t_r_y that's returned can then be bencoded into a .torrent file using _b_e_n_c_o_d_e │ │ │ │ +_(_). │ │ │ │ +struct create_torrent │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ + explicit ccrreeaattee__ttoorrrreenntt (std::vector files, int │ │ │ │ +piece_size = 0 │ │ │ │ + , create_flags_t flags = {}); │ │ │ │ + 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); │ │ │ │ + void aadddd__nnooddee (std::pair node); │ │ │ │ + void aadddd__ttrraacckkeerr (string_view url, int tier = 0); │ │ │ │ + void sseett__rroooott__cceerrtt (string_view cert); │ │ │ │ + void sseett__pprriivv (bool p); │ │ │ │ + bool pprriivv () const; │ │ │ │ + bool iiss__vv22__oonnllyy () const; │ │ │ │ + bool iiss__vv11__oonnllyy () const; │ │ │ │ + int nnuumm__ppiieecceess () const; │ │ │ │ + piece_index_t eenndd__ppiieeccee () const; │ │ │ │ + index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ + file_index_t eenndd__ffiillee () const; │ │ │ │ + index_range ffiillee__rraannggee () const noexcept; │ │ │ │ + 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); │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - sha1_hash target; │ │ │ │ - std::array public_key; │ │ │ │ - std::array signature; │ │ │ │ - std::string salt; │ │ │ │ - std::int64_t seq; │ │ │ │ - int num_success; │ │ │ │ + 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; │ │ │ │ + static inline constexpr create_flags_t ccaannoonniiccaall__ffiilleess__nnoo__ttaaiill__ppaaddddiinngg = │ │ │ │ +9_bit; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - target │ │ │ │ - the target hash the item was stored under if this was an iimmmmuuttaabbllee item. │ │ │ │ +********** ccrreeaattee__ttoorrrreenntt(()) ********** │ │ │ │ +explicit ccrreeaattee__ttoorrrreenntt (std::vector files, int piece_size = │ │ │ │ +0 │ │ │ │ + , create_flags_t flags = {}); │ │ │ │ +The piece_size is the size of each piece in bytes. It must be a power of 2 and │ │ │ │ +a minimum of 16 kiB. If a piece size of 0 is specified, a piece_size will be │ │ │ │ +set automatically. Piece sizes greater than 128 MiB are considered unreasonable │ │ │ │ +and will be rejected (with an lt::system_error exception). │ │ │ │ +The flags arguments specifies options for the torrent creation. It can be any │ │ │ │ +combination of the flags defined by create_flags_t. │ │ │ │ +The files argument is a list of all files to be included in the torrent file. │ │ │ │ +If it has more than one file in it, all files must share a common root │ │ │ │ +directory (which will be the name of the torrent). │ │ │ │ +If files has a single file without any directory component (i.e. just a │ │ │ │ +filename) it will create a single file torrent. If it has a directory path, it │ │ │ │ +will create a multi-file torrent with a single file. This is in order to │ │ │ │ +preserve the directory path. │ │ │ │ +********** ddeepprreeccaatteedd oovveerrllooaaddss ********** │ │ │ │ +There are two deprecated constructors that take a _f_i_l_e___s_t_o_r_a_g_e object and a │ │ │ │ +_t_o_r_r_e_n_t___i_n_f_o object respectively. │ │ │ │ +The _f_i_l_e___s_t_o_r_a_g_e (fs) parameter defines the files, sizes and their properties │ │ │ │ +for the torrent to be created. Set this up first, before passing it to the │ │ │ │ +_c_r_e_a_t_e___t_o_r_r_e_n_t constructor. Instead of using this overload, consider using the │ │ │ │ +overload taking a vector of _c_r_e_a_t_e___f_i_l_e___e_n_t_r_y objects instead. It is more │ │ │ │ +efficient. │ │ │ │ +The overload that takes a torrent_info object will make a verbatim copy of its │ │ │ │ +info dictionary (to preserve the info-hash). The copy of the info dictionary │ │ │ │ +will be used by _c_r_e_a_t_e___t_o_r_r_e_n_t_:_:_g_e_n_e_r_a_t_e_(_). This means that none of the member │ │ │ │ +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] │ │ │ │ - public_key signature salt seq │ │ │ │ - if a mutable item was stored, these are the public key, signature, salt │ │ │ │ - and sequence number the item was stored under. │ │ │ │ +********** 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 │ │ │ │ +set, the resulting torrent depends on which hashes were set. If both v1 and v2 │ │ │ │ +hashes were set, a hybrid torrent is created. │ │ │ │ +Any failure will cause this function to throw system_error, with an appropriate │ │ │ │ +error message. These are the reasons this call may throw: │ │ │ │ + * the file storage has 0 files │ │ │ │ + * the total size of the file storage is 0 bytes (i.e. it only has empty │ │ │ │ + files) │ │ │ │ + * not all v1 hashes (_s_e_t___h_a_s_h_(_)) and not all v2 hashes (_s_e_t___h_a_s_h_2_(_)) were │ │ │ │ + set │ │ │ │ + * for v2 torrents, you may not have a directory with the same name as a │ │ │ │ + file. If that's encountered in the file storage, _g_e_n_e_r_a_t_e_(_) fails. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - num_success │ │ │ │ - DHT put operation usually writes item to k nodes, maybe the node is stale │ │ │ │ - so no response, or the node doesn't support 'put', or the token for write │ │ │ │ - is out of date, etc. num_success is the number of successful responses we │ │ │ │ - got from the puts. │ │ │ │ +********** sseett__ccoommmmeenntt(()) ********** │ │ │ │ +void sseett__ccoommmmeenntt (char const* str); │ │ │ │ +Sets the comment for the torrent. The string str should be utf-8 encoded. The │ │ │ │ +comment in a torrent file is optional. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ii22pp__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is used to report errors in the i2p SAM connection │ │ │ │ -struct i2p_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error; │ │ │ │ - error_code error; │ │ │ │ -}; │ │ │ │ +********** sseett__ccrreeaattoorr(()) ********** │ │ │ │ +void sseett__ccrreeaattoorr (char const* str); │ │ │ │ +Sets the creator of the torrent. The string str should be utf-8 encoded. This │ │ │ │ +is optional. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error that occurred in the i2p SAM connection │ │ │ │ +********** sseett__ccrreeaattiioonn__ddaattee(()) ********** │ │ │ │ +void sseett__ccrreeaattiioonn__ddaattee (std::time_t timestamp); │ │ │ │ +sets the "creation time" field. Defaults to the system clock at the time of │ │ │ │ +construction of the _c_r_e_a_t_e___t_o_r_r_e_n_t object. The timestamp is specified in │ │ │ │ +seconds, posix time. If the creation date is set to 0, the "creation date" │ │ │ │ +field will be omitted from the generated torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__oouuttggooiinngg__ggeett__ppeeeerrss__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is generated when we send a get_peers request It belongs to the │ │ │ │ -alert_category::dht category. │ │ │ │ -struct dht_outgoing_get_peers_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - sha1_hash info_hash; │ │ │ │ - sha1_hash obfuscated_info_hash; │ │ │ │ - aux::noexcept_movable endpoint; │ │ │ │ -}; │ │ │ │ +********** sseett__hhaasshh(()) ********** │ │ │ │ +void sseett__hhaasshh (piece_index_t index, sha1_hash const& h); │ │ │ │ +This sets the SHA-1 hash for the specified piece (index). You are required to │ │ │ │ +set the hash for every piece in the torrent before generating it. If you have │ │ │ │ +the files on disk, you can use the high level convenience function to do this. │ │ │ │ +See _s_e_t___p_i_e_c_e___h_a_s_h_e_s_(_). A SHA-1 hash of all zeros is internally used to │ │ │ │ +indicate a hash that has not been set. Setting such hash will not be considered │ │ │ │ +set when calling _g_e_n_e_r_a_t_e_(_). This function will throw std::system_error if it │ │ │ │ +is called on an object constructed with the v2_only flag. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - info_hash │ │ │ │ - the info_hash of the torrent we're looking for peers for. │ │ │ │ +********** sseett__hhaasshh22(()) ********** │ │ │ │ +void sseett__hhaasshh22 (file_index_t file, piece_index_t::diff_type piece, sha256_hash │ │ │ │ +const& h); │ │ │ │ +sets the bittorrent v2 hash for filefileof the piecepiece.pieceis relative to │ │ │ │ +the first piece of the file, starting at 0. The first piece in the file can be │ │ │ │ +computed with _f_i_l_e___s_t_o_r_a_g_e_:_:_f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_). The hash,h, is the root of │ │ │ │ +the merkle tree formed by the piece's 16 kiB blocks. Note that piece sizes must │ │ │ │ +be powers-of-2, so all per-piece merkle trees are complete. A SHA-256 hash of │ │ │ │ +all zeros is internally used to indicate a hash that has not been set. Setting │ │ │ │ +such hash will not be considered set when calling _g_e_n_e_r_a_t_e_(_). This function │ │ │ │ +will throw std::system_error if it is called on an object constructed with the │ │ │ │ +v1_only flag. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - obfuscated_info_hash │ │ │ │ - if this was an obfuscated lookup, this is the info-hash target actually │ │ │ │ - sent to the node. │ │ │ │ +********** aadddd__uurrll__sseeeedd(()) ********** │ │ │ │ +void aadddd__uurrll__sseeeedd (string_view url); │ │ │ │ +This adds a url seed to the torrent. You can have any number of url seeds. For │ │ │ │ +a single file torrent, this should be an HTTP url, pointing to a file with │ │ │ │ +identical content as the file of the torrent. For a multi-file torrent, it │ │ │ │ +should point to a directory containing a directory with the same name as this │ │ │ │ +torrent, and all the files of the torrent in it. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - endpoint │ │ │ │ - the endpoint we're sending this query to │ │ │ │ +********** aadddd__nnooddee(()) ********** │ │ │ │ +void aadddd__nnooddee (std::pair node); │ │ │ │ +This adds a DHT node to the torrent. This especially useful if you're creating │ │ │ │ +a tracker less torrent. It can be used by clients to bootstrap their DHT node │ │ │ │ +from. The node is a hostname and a port number where there is a DHT node │ │ │ │ +running. You can have any number of DHT nodes in a torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ lloogg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted by some _s_e_s_s_i_o_n wide event. Its main purpose is trouble │ │ │ │ -shooting and debugging. It's not enabled by the default _a_l_e_r_t mask and is │ │ │ │ -enabled by the alert_category::session_log bit. Furthermore, it's by default │ │ │ │ -disabled as a build configuration. │ │ │ │ -struct log_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* lloogg__mmeessssaaggee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -session_log; │ │ │ │ -}; │ │ │ │ +********** aadddd__ttrraacckkeerr(()) ********** │ │ │ │ +void aadddd__ttrraacckkeerr (string_view url, int tier = 0); │ │ │ │ +Adds a tracker to the torrent. This is not strictly required, but most torrents │ │ │ │ +use a tracker as their main source of peers. The url should be an _h_t_t_p_:_/_/ or │ │ │ │ +udp:// url to a machine running a bittorrent tracker that accepts announces for │ │ │ │ +this torrent's info-hash. The tier is the fallback priority of the tracker. All │ │ │ │ +trackers with tier 0 are tried first (in any order). If all fail, trackers with │ │ │ │ +tier 1 are tried. If all of those fail, trackers with tier 2 are tried, and so │ │ │ │ +on. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ -char const* lloogg__mmeessssaaggee () const; │ │ │ │ -returns the log message │ │ │ │ +********** sseett__rroooott__cceerrtt(()) ********** │ │ │ │ +void sseett__rroooott__cceerrtt (string_view cert); │ │ │ │ +This function sets an X.509 certificate in PEM format to the torrent. This │ │ │ │ +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] │ │ │ │ -************ ttoorrrreenntt__lloogg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted by torrent wide events. It's meant to be used for trouble │ │ │ │ -shooting and debugging. It's not enabled by the default _a_l_e_r_t mask and is │ │ │ │ -enabled by the alert_category::torrent_log bit. By default it is disabled as a │ │ │ │ -build configuration. │ │ │ │ -struct torrent_log_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* lloogg__mmeessssaaggee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -torrent_log; │ │ │ │ -}; │ │ │ │ +********** sseett__pprriivv(()) pprriivv(()) ********** │ │ │ │ +void sseett__pprriivv (bool p); │ │ │ │ +bool pprriivv () const; │ │ │ │ +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] │ │ │ │ -********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ -char const* lloogg__mmeessssaaggee () const; │ │ │ │ -returns the log message │ │ │ │ +********** iiss__vv22__oonnllyy(()) iiss__vv11__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] │ │ │ │ -************ ppeeeerr__lloogg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted by events specific to a peer. It's meant to be used for │ │ │ │ -trouble shooting and debugging. It's not enabled by the default _a_l_e_r_t mask and │ │ │ │ -is enabled by the alert_category::peer_log bit. By default it is disabled as a │ │ │ │ -build configuration. │ │ │ │ -struct peer_log_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* lloogg__mmeessssaaggee () const; │ │ │ │ - │ │ │ │ - enum direction_t │ │ │ │ - { │ │ │ │ - incoming_message, │ │ │ │ - outgoing_message, │ │ │ │ - incoming, │ │ │ │ - outgoing, │ │ │ │ - info, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -peer_log; │ │ │ │ - event_t event_type; │ │ │ │ - direction_t direction; │ │ │ │ -}; │ │ │ │ +********** nnuumm__ppiieecceess(()) ********** │ │ │ │ +int nnuumm__ppiieecceess () const; │ │ │ │ +returns the number of pieces in the associated _f_i_l_e___s_t_o_r_a_g_e object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ -char const* lloogg__mmeessssaaggee () const; │ │ │ │ -returns the log message │ │ │ │ +********** eenndd__ppiieeccee(()) ********** │ │ │ │ +piece_index_t eenndd__ppiieeccee () const; │ │ │ │ +one past-the-end piece index │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ddiirreeccttiioonn__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_i_n_c_o_m_i_n_g___m_e_s_s_a_g_e_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_o_u_t_g_o_i_n_g___m_e_s_s_a_g_e_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_c_o_m_i_n_g_ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_o_u_t_g_o_i_n_g_ _ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_f_o_ _ _ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** ppiieeccee__rraannggee(()) ********** │ │ │ │ +index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ +all piece indices in the torrent to be created │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - event_type │ │ │ │ - enum indicating the kind of event. For messages, this is the message │ │ │ │ - name. │ │ │ │ +********** eenndd__ffiillee(()) ********** │ │ │ │ +file_index_t eenndd__ffiillee () const; │ │ │ │ +one past-the-end file index │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ llssdd__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted if the local service discovery socket fails to start properly. it's │ │ │ │ -categorized as alert_category::error. │ │ │ │ -struct lsd_error_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error; │ │ │ │ - aux::noexcept_movable
      local_address; │ │ │ │ - error_code error; │ │ │ │ -}; │ │ │ │ +********** ffiillee__rraannggee(()) ********** │ │ │ │ +index_range ffiillee__rraannggee () const noexcept; │ │ │ │ +all file indices in the torrent to be created │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - local_address │ │ │ │ - the local network the corresponding local service discovery is running on │ │ │ │ +********** ffiillee__aatt(()) ********** │ │ │ │ +create_file_entry const& ffiillee__aatt (file_index_t f) const; │ │ │ │ +returns a reference to the _c_r_e_a_t_e___f_i_l_e___e_n_t_r_y at the given file index. Note that │ │ │ │ +this is not necessarily the same entries passed into the constructor, since the │ │ │ │ +layout may have been canonicalized. e.g. file order and padding may have │ │ │ │ +changed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - The error code │ │ │ │ +********** ffiillee__ppiieeccee__rraannggee(()) ********** │ │ │ │ +index_range ffiillee__ppiieeccee__rraannggee (file_index_t f); │ │ │ │ +for v2 and hybrid torrents only, the pieces in the specified file, specified as │ │ │ │ +delta from the first piece in the file. i.e. the first index is 0. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__llooookkuupp ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -holds statistics about a current _d_h_t___l_o_o_k_u_p operation. a DHT lookup is the │ │ │ │ -traversal of nodes, looking up a set of target nodes in the DHT for retrieving │ │ │ │ -and possibly storing information in the DHT │ │ │ │ -struct dht_lookup │ │ │ │ -{ │ │ │ │ - char const* type; │ │ │ │ - int outstanding_requests; │ │ │ │ - int timeouts; │ │ │ │ - int responses; │ │ │ │ - int branch_factor; │ │ │ │ - int nodes_left; │ │ │ │ - int last_sent; │ │ │ │ - int first_timeout; │ │ │ │ - sha1_hash target; │ │ │ │ -}; │ │ │ │ +********** ttoottaall__ssiizzee(()) ********** │ │ │ │ +std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ +the total number of bytes of all files and pad files │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - type │ │ │ │ - string literal indicating which kind of lookup this is │ │ │ │ +********** 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] │ │ │ │ - outstanding_requests │ │ │ │ - the number of outstanding request to individual nodes this lookup has │ │ │ │ - right now │ │ │ │ +********** aadddd__ssiimmiillaarr__ttoorrrreenntt(()) aadddd__ccoolllleeccttiioonn(()) ********** │ │ │ │ +void aadddd__ccoolllleeccttiioonn (string_view c); │ │ │ │ +void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih); │ │ │ │ +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] │ │ │ │ - timeouts │ │ │ │ - the total number of requests that have timed out so far for this lookup │ │ │ │ + modification_time │ │ │ │ + This will include the file modification time as part of the torrent. This │ │ │ │ + is not enabled by default, as it might cause problems when you create a │ │ │ │ + torrent from separate files with the same content, hoping to yield the │ │ │ │ + same info-hash. If the files have different modification times, with this │ │ │ │ + option enabled, you would get different info-hashes for the files. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - responses │ │ │ │ - the total number of responses we have received for this lookup so far for │ │ │ │ - this lookup │ │ │ │ + symlinks │ │ │ │ + If this flag is set, files that are symlinks get a symlink attribute set │ │ │ │ + on them and their data will not be included in the torrent. This is │ │ │ │ + useful if you need to reconstruct a file hierarchy which contains │ │ │ │ + symlinks. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - branch_factor │ │ │ │ - the branch factor for this lookup. This is the number of nodes we keep │ │ │ │ - outstanding requests to in parallel by default. when nodes time out we │ │ │ │ - may increase this. │ │ │ │ + v2_only │ │ │ │ + Do not generate v1 metadata. The resulting torrent will only be usable by │ │ │ │ + clients which support v2. This requires setting all v2 hashes, with │ │ │ │ + _s_e_t___h_a_s_h_2_(_) before calling _g_e_n_e_r_a_t_e_(_). Setting v1 hashes (with _s_e_t___h_a_s_h │ │ │ │ + _(_)) is an error with this flag set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - nodes_left │ │ │ │ - the number of nodes left that could be queries for this lookup. Many of │ │ │ │ - these are likely to be part of the trail while performing the lookup and │ │ │ │ - would never end up actually being queried. │ │ │ │ + v1_only │ │ │ │ + do not generate v2 metadata or enforce v2 alignment and padding rules │ │ │ │ + this is mainly for tests, not recommended for production use. This │ │ │ │ + requires setting all v1 hashes, with _s_e_t___h_a_s_h_(_), before calling _g_e_n_e_r_a_t_e │ │ │ │ + _(_). Setting v2 hashes (with _s_e_t___h_a_s_h_2_(_)) is an error with this flag set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - last_sent │ │ │ │ - the number of seconds ago the last message was sent that's still │ │ │ │ - outstanding │ │ │ │ + canonical_files │ │ │ │ + This flag only affects v1-only torrents, and is only relevant together │ │ │ │ + with the v1_only_flag. This flag will force the same file order and │ │ │ │ + padding as a v2 (or hybrid) torrent would have. It has the effect of │ │ │ │ + ordering files and inserting pad files to align them with piece │ │ │ │ + boundaries. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - first_timeout │ │ │ │ - the number of outstanding requests that have exceeded the short timeout │ │ │ │ - and are considered timed out in the sense that they increased the branch │ │ │ │ - factor │ │ │ │ + no_attributes │ │ │ │ + passing this flag to _l_i_s_t___f_i_l_e_s_(_) will ignore file attributes (such as │ │ │ │ + executable or hidden) when adding the files to the file storage. Since │ │ │ │ + not all filesystems and operating systems support all file attributes the │ │ │ │ + resulting torrent may differ depending on where it's created. If it's │ │ │ │ + important for torrents to be created consistently across systems, this │ │ │ │ + flag should be set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - target │ │ │ │ - the node-id or info-hash target for this lookup │ │ │ │ + canonical_files_no_tail_padding │ │ │ │ + this flag enforces the file layout to be canonical according to the │ │ │ │ + bittorrent v2 specification (just like the canonical_files flag) with the │ │ │ │ + one exception that tail padding is not added to the last file. This │ │ │ │ + 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] │ │ │ │ -************ ddhhtt__ssttaattss__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -contains current DHT state. Posted in response to session::post_dht_stats(). │ │ │ │ -struct dht_stats_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ +************ 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 │ │ │ │ + , 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 │ │ │ │ +directory. If no predicate is specified, all files are added, and all │ │ │ │ +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 │ │ │ │ + , std::function const& f); │ │ │ │ +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); │ │ │ │ +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); │ │ │ │ +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); │ │ │ │ +void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ + , settings_pack const& settings │ │ │ │ + , std::function const& f, 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. │ │ │ │ +The overloads that don't take an error_code& may throw an exception in case of │ │ │ │ +a file error, the other overloads sets the error code to reflect the error, if │ │ │ │ +any. │ │ │ │ +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. │ │ │ │ +In short, the _p_l_u_g_i_n interface makes it possible to: │ │ │ │ + * register extension messages (sent in the extension handshake), see │ │ │ │ + _e_x_t_e_n_s_i_o_n_s. │ │ │ │ + * add data and parse data from the extension handshake. │ │ │ │ + * send extension messages and standard bittorrent messages. │ │ │ │ + * override or block the handling of standard bittorrent messages. │ │ │ │ + * save and restore state via the _s_e_s_s_i_o_n state │ │ │ │ + * see all alerts that are posted │ │ │ │ +************ aa wwoorrdd ooff ccaauuttiioonn ************ │ │ │ │ +Writing your own _p_l_u_g_i_n is a very easy way to introduce serious bugs such as │ │ │ │ +dead locks and race conditions. Since a _p_l_u_g_i_n has access to internal │ │ │ │ +structures it is also quite easy to sabotage libtorrent's operation. │ │ │ │ +All the callbacks are always called from the libtorrent network thread. In case │ │ │ │ +portions of your _p_l_u_g_i_n are called from other threads, typically the main │ │ │ │ +thread, you cannot use any of the member functions on the internal structures │ │ │ │ +in libtorrent, since those require being called from the libtorrent network │ │ │ │ +thread . Furthermore, you also need to synchronize your own shared data within │ │ │ │ +the _p_l_u_g_i_n, to make sure it is not accessed at the same time from the │ │ │ │ +libtorrent thread (through a callback). If you need to send out a message from │ │ │ │ +another thread, it is advised to use an internal queue, and do the actual │ │ │ │ +sending in tick(). │ │ │ │ +Since the _p_l_u_g_i_n interface gives you easy access to internal structures, it is │ │ │ │ +not supported as a stable API. Plugins should be considered specific to a │ │ │ │ +specific version of libtorrent. Although, in practice the internals mostly │ │ │ │ +don't change that dramatically. │ │ │ │ +************ pplluuggiinn--iinntteerrffaaccee ************ │ │ │ │ +The _p_l_u_g_i_n interface consists of three base classes that the _p_l_u_g_i_n may │ │ │ │ +implement. These are called _p_l_u_g_i_n, _t_o_r_r_e_n_t___p_l_u_g_i_n and _p_e_e_r___p_l_u_g_i_n. They are │ │ │ │ +found in the header. │ │ │ │ +These plugins are instantiated for each _s_e_s_s_i_o_n, torrent and possibly each │ │ │ │ +peer, respectively. │ │ │ │ +For plugins that only need per torrent state, it is enough to only implement │ │ │ │ +torrent_plugin and pass a constructor function or function object to session:: │ │ │ │ +add_extension() or torrent_handle::add_extension() (if the torrent has already │ │ │ │ +been started and you want to hook in the extension at run-time). │ │ │ │ +The signature of the function is: │ │ │ │ +std::shared_ptr (*)(torrent_handle const&, client_data_t); │ │ │ │ +The second argument is the userdata passed to session::add_torrent() or │ │ │ │ +torrent_handle::add_extension(). │ │ │ │ +The function should return a std::shared_ptr which may or may │ │ │ │ +not be 0. If it is a nullptr, the extension is simply ignored for this torrent. │ │ │ │ +If it is a valid pointer (to a class inheriting torrent_plugin), it will be │ │ │ │ +associated with this torrent and callbacks will be made on torrent events. │ │ │ │ +For more elaborate plugins which require _s_e_s_s_i_o_n wide state, you would │ │ │ │ +implement plugin, construct an object (in a std::shared_ptr) and pass it in to │ │ │ │ +session::add_extension(). │ │ │ │ +************ ccuussttoomm aalleerrttss ************ │ │ │ │ +Since plugins are running within internal libtorrent threads, one convenient │ │ │ │ +way to communicate with the client is to post custom alerts. │ │ │ │ +The expected interface of any _a_l_e_r_t, apart from deriving from the _a_l_e_r_t base │ │ │ │ +class, looks like this: │ │ │ │ +static const int alert_type = <>; │ │ │ │ +virtual int type() const { return alert_type; } │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = {}; │ │ │ │ - std::vector active_requests; │ │ │ │ - std::vector routing_table; │ │ │ │ - sha1_hash nid; │ │ │ │ - aux::noexcept_movable local_endpoint; │ │ │ │ +virtual std::string message() const; │ │ │ │ + │ │ │ │ +static const alert_category_t static_category = <>; │ │ │ │ +virtual alert_category_t category() const { return static_category; } │ │ │ │ + │ │ │ │ +virtual char const* what() const { return <>; } │ │ │ │ +The alert_type is used for the type-checking in alert_cast. It must not collide │ │ │ │ +with any other _a_l_e_r_t. The built-in alerts in libtorrent will not use _a_l_e_r_t type │ │ │ │ +IDs greater than user_alert_id. When defining your own _a_l_e_r_t, make sure it's │ │ │ │ +greater than this constant. │ │ │ │ +type() is the run-time equivalence of the alert_type. │ │ │ │ +The message() virtual function is expected to construct a useful string │ │ │ │ +representation of the _a_l_e_r_t and the event or data it represents. Something │ │ │ │ +convenient to put in a log file for instance. │ │ │ │ +clone() is used internally to copy alerts. The suggested implementation of │ │ │ │ +simply allocating a new instance as a copy of *this is all that's expected. │ │ │ │ +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__cchhookkeedd () const; │ │ │ │ + bool iiss__iinntteerreessttiinngg () const; │ │ │ │ + bool iiss__ppeeeerr__iinntteerreesstteedd () const; │ │ │ │ + bool hhaass__ppeeeerr__cchhookkeedd () const; │ │ │ │ + void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr (); │ │ │ │ + void cchhookkee__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 llooccaall__eennddppooiinntt () const; │ │ │ │ + _t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const; │ │ │ │ + bool iiss__ccoonnnneeccttiinngg () const; │ │ │ │ + void ddiissccoonnnneecctt (error_code const& ec, operation_t op │ │ │ │ + , disconnect_severity_t = peer_connection_interface::normal); │ │ │ │ + bool iiss__oouuttggooiinngg () const; │ │ │ │ + bool iiss__ddiissccoonnnneeccttiinngg () 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); │ │ │ │ + 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] │ │ │ │ - active_requests │ │ │ │ - a vector of the currently running DHT lookups. │ │ │ │ +********** 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] │ │ │ │ - routing_table │ │ │ │ - contains information about every bucket in the DHT routing table. │ │ │ │ +********** 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] │ │ │ │ - nid │ │ │ │ - the node ID of the DHT node instance │ │ │ │ +********** ffiinndd__pplluuggiinn(()) aadddd__eexxtteennssiioonn(()) ********** │ │ │ │ +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] │ │ │ │ - local_endpoint │ │ │ │ - the local socket this DHT node is running on │ │ │ │ +********** 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] │ │ │ │ -************ iinnccoommiinngg__rreeqquueesstt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted every time an incoming request from a peer is accepted and queued up for │ │ │ │ -being serviced. This _a_l_e_r_t is only posted if the alert_category:: │ │ │ │ -incoming_request flag is enabled in the _a_l_e_r_t mask. │ │ │ │ -struct incoming_request_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -incoming_request; │ │ │ │ - peer_request req; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ - req │ │ │ │ - the request this peer sent to us │ │ │ │ +********** 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] │ │ │ │ -************ ddhhtt__lloogg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -debug logging of the DHT when alert_category::dht_log is set in the _a_l_e_r_t mask. │ │ │ │ -struct dht_log_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - char const* lloogg__mmeessssaaggee () const; │ │ │ │ - │ │ │ │ - enum dht_module_t │ │ │ │ - { │ │ │ │ - tracker, │ │ │ │ - node, │ │ │ │ - routing_table, │ │ │ │ - rpc_manager, │ │ │ │ - traversal, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht_log; │ │ │ │ - dht_module_t module; │ │ │ │ -}; │ │ │ │ +********** iiss__cchhookkeedd(()) iiss__iinntteerreessttiinngg(()) ********** │ │ │ │ +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] │ │ │ │ -********** lloogg__mmeessssaaggee(()) ********** │ │ │ │ -char const* lloogg__mmeessssaaggee () const; │ │ │ │ -the log message │ │ │ │ +********** 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] │ │ │ │ -********** eennuumm ddhhtt__mmoodduullee__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_t_r_a_c_k_e_r_ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o_d_e_ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_o_u_t_i_n_g___t_a_b_l_e_|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_p_c___m_a_n_a_g_e_r_ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_r_a_v_e_r_s_a_l_ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr(()) cchhookkee__tthhiiss__ppeeeerr(()) ********** │ │ │ │ +void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr (); │ │ │ │ +void cchhookkee__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] │ │ │ │ - module │ │ │ │ - the module, or part, of the DHT that produced this log message. │ │ │ │ +********** 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] │ │ │ │ -************ ddhhtt__ppkktt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted every time a DHT message is sent or received. It is only │ │ │ │ -posted if the alert_category::dht_log _a_l_e_r_t category is enabled. It contains a │ │ │ │ -verbatim copy of the message. │ │ │ │ -struct dht_pkt_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - span ppkktt__bbuuff () const; │ │ │ │ - │ │ │ │ - enum direction_t │ │ │ │ - { │ │ │ │ - incoming, │ │ │ │ - outgoing, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht_log; │ │ │ │ - direction_t direction; │ │ │ │ - aux::noexcept_movable node; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ -********** ppkktt__bbuuff(()) ********** │ │ │ │ -span ppkktt__bbuuff () const; │ │ │ │ -returns a pointer to the packet buffer and size of the packet, respectively. │ │ │ │ -This buffer is only valid for as long as the _a_l_e_r_t itself is valid, which is │ │ │ │ -owned by libtorrent and reclaimed whenever _p_o_p___a_l_e_r_t_s_(_) is called on the │ │ │ │ -_s_e_s_s_i_o_n. │ │ │ │ +********** llooccaall__eennddppooiinntt(()) rreemmoottee(()) ********** │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const; │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () 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] │ │ │ │ -********** eennuumm ddiirreeccttiioonn__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_i_n_c_o_m_i_n_g_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_o_u_t_g_o_i_n_g_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** iiss__ccoonnnneeccttiinngg(()) iiss__ddiissccoonnnneeccttiinngg(()) ddiissccoonnnneecctt(()) iiss__oouuttggooiinngg(()) ********** │ │ │ │ +bool iiss__ccoonnnneeccttiinngg () const; │ │ │ │ +void ddiissccoonnnneecctt (error_code const& ec, operation_t op │ │ │ │ + , disconnect_severity_t = peer_connection_interface::normal); │ │ │ │ +bool iiss__oouuttggooiinngg () const; │ │ │ │ +bool iiss__ddiissccoonnnneeccttiinngg () 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] │ │ │ │ - direction │ │ │ │ - whether this is an incoming or outgoing packet. │ │ │ │ +********** iiggnnoorree__uunncchhookkee__sslloottss(()) oonn__llooccaall__nneettwwoorrkk(()) ********** │ │ │ │ +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] │ │ │ │ - node │ │ │ │ - the DHT node we received this packet from, or sent this packet to │ │ │ │ - (depending on direction). │ │ │ │ +********** 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] │ │ │ │ -************ ddhhtt__ggeett__ppeeeerrss__rreeppllyy__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -Posted when we receive a response to a DHT get_peers request. │ │ │ │ -struct dht_get_peers_reply_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - int nnuumm__ppeeeerrss () const; │ │ │ │ - std::vector<_t_c_p_:_:_e_n_d_p_o_i_n_t> ppeeeerrss () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht_operation; │ │ │ │ - sha1_hash info_hash; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ -************ ddhhtt__ddiirreecctt__rreessppoonnssee__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This is posted exactly once for every call to session_handle:: │ │ │ │ -dht_direct_request. If the request failed, _r_e_s_p_o_n_s_e_(_) will return a default │ │ │ │ -constructed _b_d_e_c_o_d_e___n_o_d_e. │ │ │ │ -struct dht_direct_response_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - bdecode_node rreessppoonnssee () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - client_data_t userdata; │ │ │ │ - aux::noexcept_movable endpoint; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ -************ ppiicckkeerr__lloogg__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this is posted when one or more blocks are picked by the piece picker, assuming │ │ │ │ -the verbose piece picker logging is enabled (see alert_category::picker_log). │ │ │ │ -struct picker_log_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - std::vector bblloocckkss () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -picker_log; │ │ │ │ - static inline constexpr picker_flags_t ppaarrttiiaall__rraattiioo = 0_bit; │ │ │ │ - static inline constexpr picker_flags_t pprriioorriittiizzee__ppaarrttiiaallss = 1_bit; │ │ │ │ - static inline constexpr picker_flags_t rraarreesstt__ffiirrsstt__ppaarrttiiaallss = 2_bit; │ │ │ │ - static inline constexpr picker_flags_t rraarreesstt__ffiirrsstt = 3_bit; │ │ │ │ - static inline constexpr picker_flags_t rreevveerrssee__rraarreesstt__ffiirrsstt = 4_bit; │ │ │ │ - static inline constexpr picker_flags_t ssuuggggeesstteedd__ppiieecceess = 5_bit; │ │ │ │ - static inline constexpr picker_flags_t pprriioo__sseeqquueennttiiaall__ppiieecceess = 6_bit; │ │ │ │ - static inline constexpr picker_flags_t sseeqquueennttiiaall__ppiieecceess = 7_bit; │ │ │ │ - static inline constexpr picker_flags_t rreevveerrssee__ppiieecceess = 8_bit; │ │ │ │ - static inline constexpr picker_flags_t ttiimmee__ccrriittiiccaall = 9_bit; │ │ │ │ - static inline constexpr picker_flags_t rraannddoomm__ppiieecceess = 10_bit; │ │ │ │ - static inline constexpr picker_flags_t pprreeffeerr__ccoonnttiigguuoouuss = 11_bit; │ │ │ │ - static inline constexpr picker_flags_t rreevveerrssee__sseeqquueennttiiaall = 12_bit; │ │ │ │ - static inline constexpr picker_flags_t bbaacckkuupp11 = 13_bit; │ │ │ │ - static inline constexpr picker_flags_t bbaacckkuupp22 = 14_bit; │ │ │ │ - static inline constexpr picker_flags_t eenndd__ggaammee = 15_bit; │ │ │ │ - static inline constexpr picker_flags_t eexxtteenntt__aaffffiinniittyy = 16_bit; │ │ │ │ - picker_flags_t picker_flags; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ - picker_flags │ │ │ │ - this is a bitmask of which features were enabled for this particular │ │ │ │ - pick. The bits are defined in the picker_flags_t enum. │ │ │ │ +********** 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] │ │ │ │ -************ sseessssiioonn__eerrrroorr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is posted when the _s_e_s_s_i_o_n encounters a serious error, potentially │ │ │ │ -fatal │ │ │ │ -struct session_error_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error; │ │ │ │ - error_code const error; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ - error │ │ │ │ - The error code, if one is associated with this error │ │ │ │ +********** ttiimmee__ooff__llaasstt__uunncchhookkee(()) llaasstt__sseeeenn__ccoommpplleettee(()) ********** │ │ │ │ +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] │ │ │ │ -************ ddhhtt__lliivvee__nnooddeess__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted in response to a call to session::dht_live_nodes(). It contains the live │ │ │ │ -nodes from the DHT routing table of one of the DHT nodes running locally. │ │ │ │ -struct dht_live_nodes_alert final : alert │ │ │ │ +********** 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 │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - std::vector> nnooddeess () const; │ │ │ │ - int nnuumm__nnooddeess () const; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht; │ │ │ │ - sha1_hash node_id; │ │ │ │ + explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc); │ │ │ │ + bool ssuuppppoorrtt__eexxtteennssiioonnss () const; │ │ │ │ + bool ppaacckkeett__ffiinniisshheedd () const; │ │ │ │ + bool ssuuppppoorrttss__eennccrryyppttiioonn () const; │ │ │ │ + void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto); │ │ │ │ + void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto); │ │ │ │ + std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__nnooddeess(()) nnooddeess(()) ********** │ │ │ │ -std::vector> nnooddeess () const; │ │ │ │ -int nnuumm__nnooddeess () const; │ │ │ │ -the number of nodes in the routing table and the actual nodes. │ │ │ │ +********** 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] │ │ │ │ - node_id │ │ │ │ - the local DHT node's node-ID this routing table belongs to │ │ │ │ +********** 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] │ │ │ │ -************ sseessssiioonn__ssttaattss__hheeaaddeerr__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -The session_stats_header _a_l_e_r_t is posted the first time _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) is │ │ │ │ -called │ │ │ │ -the message() member function returns a string representation of the header │ │ │ │ -that properly match the stats values string returned in session_stats_alert:: │ │ │ │ -message(). │ │ │ │ -this specific output is parsed by tools/parse_session_stats.py if this is │ │ │ │ -changed, that parser should also be changed │ │ │ │ -struct session_stats_header_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = {}; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ -************ ddhhtt__ssaammppllee__iinnffoohhaasshheess__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted as a response to a call to session::dht_sample_infohashes() with the │ │ │ │ -information from the DHT response message. │ │ │ │ -struct dht_sample_infohashes_alert final : alert │ │ │ │ +********** sswwiittcchh__rreeccvv__ccrryyppttoo(()) sswwiittcchh__sseenndd__ccrryyppttoo(()) ********** │ │ │ │ +void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto); │ │ │ │ +void sswwiittcchh__rreeccvv__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 │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - std::vector ssaammpplleess () const; │ │ │ │ - int nnuumm__ssaammpplleess () const; │ │ │ │ - int nnuumm__nnooddeess () const; │ │ │ │ - std::vector> nnooddeess () const; │ │ │ │ + virtual feature_flags_t iimmpplleemmeenntteedd__ffeeaattuurreess (); │ │ │ │ + virtual std::shared_ptr nneeww__ttoorrrreenntt (torrent_handle const&, │ │ │ │ +client_data_t); │ │ │ │ + virtual void aaddddeedd (session_handle const&); │ │ │ │ + virtual void aabboorrtt (); │ │ │ │ + virtual bool oonn__ddhhtt__rreeqquueesstt (string_view //** qquueerryy **// │ │ │ │ + , udp::endpoint const& //** ssoouurrccee **//, bdecode_node const& //** mmeessssaaggee **// │ │ │ │ + , entry& //** rreessppoonnssee **//); │ │ │ │ + virtual void oonn__aalleerrtt (alert const*); │ │ │ │ + virtual bool oonn__uunnkknnoowwnn__ttoorrrreenntt (info_hash_t const& //** iinnffoo__hhaasshh **// │ │ │ │ + , peer_connection_handle const& //** ppcc **//, add_torrent_params& //** pp **//); │ │ │ │ + virtual void oonn__ttiicckk (); │ │ │ │ + virtual uint64_t ggeett__uunncchhookkee__pprriioorriittyy (peer_connection_handle const& //** ppeeeerr │ │ │ │ +**//); │ │ │ │ + virtual std::map ssaavvee__ssttaattee () const; │ │ │ │ + virtual void llooaadd__ssttaattee (std::map const&); │ │ │ │ │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -dht_operation; │ │ │ │ - sha1_hash node_id; │ │ │ │ - aux::noexcept_movable endpoint; │ │ │ │ - time_duration const interval; │ │ │ │ - int const num_infohashes; │ │ │ │ + static inline constexpr feature_flags_t ooppttiimmiissttiicc__uunncchhookkee__ffeeaattuurree = 1_bit; │ │ │ │ + static inline constexpr feature_flags_t ttiicckk__ffeeaattuurree = 2_bit; │ │ │ │ + static inline constexpr feature_flags_t ddhhtt__rreeqquueesstt__ffeeaattuurree = 3_bit; │ │ │ │ + static inline constexpr feature_flags_t aalleerrtt__ffeeaattuurree = 4_bit; │ │ │ │ + static inline constexpr feature_flags_t uunnkknnoowwnn__ttoorrrreenntt__ffeeaattuurree = 5_bit; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ssaammpplleess(()) ssaammpplleess(()) ********** │ │ │ │ -std::vector ssaammpplleess () const; │ │ │ │ -int nnuumm__ssaammpplleess () const; │ │ │ │ -returns the number of info-hashes returned by the node, as well as the actual │ │ │ │ -info-hashes. num_samples() is more efficient than samples().size(). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__nnooddeess(()) ********** │ │ │ │ -int nnuumm__nnooddeess () const; │ │ │ │ -The total number of nodes returned by nodes(). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnooddeess(()) ********** │ │ │ │ -std::vector> nnooddeess () const; │ │ │ │ -This is the set of more DHT nodes returned by the request. │ │ │ │ -The information is included so that indexing nodes can perform a key space │ │ │ │ -traversal with a single RPC per node by adjusting the target value for each │ │ │ │ -RPC. │ │ │ │ +********** iimmpplleemmeenntteedd__ffeeaattuurreess(()) ********** │ │ │ │ +virtual feature_flags_t iimmpplleemmeenntteedd__ffeeaattuurreess (); │ │ │ │ +This function is expected to return a bitmask indicating which features this │ │ │ │ +_p_l_u_g_i_n implements. Some callbacks on this object may not be called unless the │ │ │ │ +corresponding feature flag is returned here. Note that callbacks may still be │ │ │ │ +called even if the corresponding feature is not specified in the return value │ │ │ │ +here. See feature_flags_t for possible flags to return. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - node_id │ │ │ │ - id of the node the request was sent to (and this response was received │ │ │ │ - from) │ │ │ │ +********** nneeww__ttoorrrreenntt(()) ********** │ │ │ │ +virtual std::shared_ptr nneeww__ttoorrrreenntt (torrent_handle const&, │ │ │ │ +client_data_t); │ │ │ │ +this is called by the _s_e_s_s_i_o_n every time a new torrent is added. The torrent* │ │ │ │ +points to the internal torrent object created for the new torrent. The │ │ │ │ +_c_l_i_e_n_t___d_a_t_a___t is the userdata pointer as passed in via _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s. │ │ │ │ +If the _p_l_u_g_i_n returns a _t_o_r_r_e_n_t___p_l_u_g_i_n instance, it will be added to the new │ │ │ │ +torrent. Otherwise, return an empty shared_ptr to a _t_o_r_r_e_n_t___p_l_u_g_i_n (the │ │ │ │ +default). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - endpoint │ │ │ │ - the node the request was sent to (and this response was received from) │ │ │ │ +********** aaddddeedd(()) ********** │ │ │ │ +virtual void aaddddeedd (session_handle const&); │ │ │ │ +called when _p_l_u_g_i_n is added to a _s_e_s_s_i_o_n │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - interval │ │ │ │ - the interval to wait before making another request to this node │ │ │ │ +********** aabboorrtt(()) ********** │ │ │ │ +virtual void aabboorrtt (); │ │ │ │ +called when the _s_e_s_s_i_o_n is aborted the _p_l_u_g_i_n should perform any cleanup │ │ │ │ +necessary to allow the session's destruction (e.g. cancel outstanding async │ │ │ │ +operations) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - num_infohashes │ │ │ │ - This field indicates how many info-hash keys are currently in the node's │ │ │ │ - storage. If the value is larger than the number of returned samples it │ │ │ │ - indicates that the indexer may obtain additional samples after waiting │ │ │ │ - out the interval. │ │ │ │ +********** oonn__ddhhtt__rreeqquueesstt(()) ********** │ │ │ │ +virtual bool oonn__ddhhtt__rreeqquueesstt (string_view //** qquueerryy **// │ │ │ │ + , udp::endpoint const& //** ssoouurrccee **//, bdecode_node const& //** mmeessssaaggee **// │ │ │ │ + , entry& //** rreessppoonnssee **//); │ │ │ │ +called when a dht request is received. If your _p_l_u_g_i_n expects this to be │ │ │ │ +called, make sure to include the flag dht_request_feature in the return value │ │ │ │ +from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bblloocckk__uuppllooaaddeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -This _a_l_e_r_t is posted when a block intended to be sent to a peer is placed in │ │ │ │ -the send buffer. Note that if the connection is closed before the send buffer │ │ │ │ -is sent, the _a_l_e_r_t may be posted without the bytes having been sent to the │ │ │ │ -peer. It belongs to the alert_category::upload category. │ │ │ │ -struct block_uploaded_alert final : peer_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - int const block_index; │ │ │ │ - piece_index_t const piece_index; │ │ │ │ -}; │ │ │ │ +********** oonn__aalleerrtt(()) ********** │ │ │ │ +virtual void oonn__aalleerrtt (alert const*); │ │ │ │ +called when an _a_l_e_r_t is posted alerts that are filtered are not posted. If your │ │ │ │ +_p_l_u_g_i_n expects this to be called, make sure to include the flag alert_feature │ │ │ │ +in the return value from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ aalleerrttss__ddrrooppppeedd__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is posted to indicate to the client that some alerts were dropped. │ │ │ │ -Dropped meaning that the _a_l_e_r_t failed to be delivered to the client. The most │ │ │ │ -common cause of such failure is that the internal _a_l_e_r_t queue grew too big │ │ │ │ -(controlled by alert_queue_size). │ │ │ │ -struct alerts_dropped_alert final : alert │ │ │ │ -{ │ │ │ │ - ssttaattiicc__aasssseerrtt (num_alert_types <= abi_alert_count, "need to increase bitset. │ │ │ │ -This is an ABI break"); │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error; │ │ │ │ - std::bitset dropped_alerts; │ │ │ │ -}; │ │ │ │ +********** oonn__uunnkknnoowwnn__ttoorrrreenntt(()) ********** │ │ │ │ +virtual bool oonn__uunnkknnoowwnn__ttoorrrreenntt (info_hash_t const& //** iinnffoo__hhaasshh **// │ │ │ │ + , peer_connection_handle const& //** ppcc **//, add_torrent_params& //** pp **//); │ │ │ │ +return true if the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s should be added │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - dropped_alerts │ │ │ │ - a bitmask indicating which alerts were dropped. Each bit represents the │ │ │ │ - _a_l_e_r_t type ID, where bit 0 represents whether any _a_l_e_r_t of type 0 has │ │ │ │ - been dropped, and so on. │ │ │ │ +********** oonn__ttiicckk(()) ********** │ │ │ │ +virtual void oonn__ttiicckk (); │ │ │ │ +called once per second. If your _p_l_u_g_i_n expects this to be called, make sure to │ │ │ │ +include the flag tick_feature in the return value from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssoocckkss55__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is posted with SOCKS5 related errors, when a SOCKS5 proxy is │ │ │ │ -configured. It's enabled with the alert_category::error _a_l_e_r_t category. │ │ │ │ -struct socks5_alert final : alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static inline constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -error; │ │ │ │ - error_code error; │ │ │ │ - operation_t op; │ │ │ │ - aux::noexcept_movable<_t_c_p_:_:_e_n_d_p_o_i_n_t> ip; │ │ │ │ -}; │ │ │ │ +********** ggeett__uunncchhookkee__pprriioorriittyy(()) ********** │ │ │ │ +virtual uint64_t ggeett__uunncchhookkee__pprriioorriittyy (peer_connection_handle const& //** ppeeeerr **// │ │ │ │ +); │ │ │ │ +called when choosing peers to optimistically unchoke. The return value │ │ │ │ +indicates the peer's priority for unchoking. Lower return values correspond to │ │ │ │ +higher priority. Priorities above 2^63-1 are reserved. If your _p_l_u_g_i_n has no │ │ │ │ +priority to assign a peer it should return 2^64-1. If your _p_l_u_g_i_n expects this │ │ │ │ +to be called, make sure to include the flag optimistic_unchoke_feature in the │ │ │ │ +return value from _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_). If multiple plugins implement this │ │ │ │ +function the lowest return value (i.e. the highest priority) is used. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error │ │ │ │ +********** ssaavvee__ssttaattee(()) ********** │ │ │ │ +virtual std::map ssaavvee__ssttaattee () const; │ │ │ │ +called when serializing _s_e_s_s_i_o_n state. The returned map of key/value strings is │ │ │ │ +stored alongside the _s_e_s_s_i_o_n state and passed back to load_state() on the next │ │ │ │ +_s_e_s_s_i_o_n. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - the operation that failed │ │ │ │ +********** llooaadd__ssttaattee(()) ********** │ │ │ │ +virtual void llooaadd__ssttaattee (std::map const&); │ │ │ │ +called on startup while loading settings state from the _s_e_s_s_i_o_n___p_a_r_a_m_s │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - ip │ │ │ │ - the endpoint configured as the proxy │ │ │ │ + optimistic_unchoke_feature │ │ │ │ + include this bit if your _p_l_u_g_i_n needs to alter the order of the │ │ │ │ + optimistic unchoke of peers. i.e. have the on_optimistic_unchoke() │ │ │ │ + callback be called. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__pprriioo__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when a _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_) or _f_i_l_e___p_r_i_o_r_i_t_y_(_) update of the file │ │ │ │ -priorities complete, which requires a round-trip to the disk thread. │ │ │ │ -If the disk operation fails this _a_l_e_r_t won't be posted, but a _f_i_l_e___e_r_r_o_r___a_l_e_r_t │ │ │ │ -is posted instead, and the torrent is stopped. │ │ │ │ -struct file_prio_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ - error_code error; │ │ │ │ - operation_t op; │ │ │ │ -}; │ │ │ │ + tick_feature │ │ │ │ + include this bit if your _p_l_u_g_i_n needs to have _o_n___t_i_c_k_(_) called │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - error │ │ │ │ - the error │ │ │ │ + dht_request_feature │ │ │ │ + include this bit if your _p_l_u_g_i_n needs to have _o_n___d_h_t___r_e_q_u_e_s_t_(_) called │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - op │ │ │ │ - the operation that failed │ │ │ │ + alert_feature │ │ │ │ + include this bit if your _p_l_u_g_i_n needs to have _o_n___a_l_e_r_t_(_) called │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ oovveerrssiizzeedd__ffiillee__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t may be posted when the initial checking of resume data and files on │ │ │ │ -disk (just existence, not piece hashes) completes. If a file belonging to the │ │ │ │ -torrent is found on disk, but is larger than the file in the torrent, that's │ │ │ │ -when this _a_l_e_r_t is posted. the client may want to call _t_r_u_n_c_a_t_e___f_i_l_e_s_(_) in that │ │ │ │ -case, or perhaps interpret it as a sign that some other file is in the way, │ │ │ │ -that shouldn't be overwritten. │ │ │ │ -struct oversized_file_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -storage; │ │ │ │ -}; │ │ │ │ + unknown_torrent_feature │ │ │ │ + include this bit if your _p_l_u_g_i_n needs to have _o_n___u_n_k_n_o_w_n___t_o_r_r_e_n_t_(_) called │ │ │ │ + even if there is no active torrent in the _s_e_s_s_i_o_n │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttoorrrreenntt__ccoonnfflliicctt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -this _a_l_e_r_t is posted when two separate torrents (magnet links) resolve to the │ │ │ │ -same torrent, thus causing the same torrent being added twice. In that case, │ │ │ │ -both torrents enter an error state with duplicate_torrent as the error code. │ │ │ │ -This _a_l_e_r_t is posted containing the metadata. For more information, see │ │ │ │ -_B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. The torrent this _a_l_e_r_t originated from was the one that │ │ │ │ -downloaded the metadata (i.e. thehandlemember from the _t_o_r_r_e_n_t___a_l_e_r_t base │ │ │ │ -class). │ │ │ │ -struct torrent_conflict_alert final : torrent_alert │ │ │ │ +************ ttoorrrreenntt__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" │ │ │ │ +Torrent plugins are associated with a single torrent and have a number of │ │ │ │ +functions called at certain events. Many of its functions have the ability to │ │ │ │ +change or override the default libtorrent behavior. │ │ │ │ +struct torrent_plugin │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ + 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__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 constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::error; │ │ │ │ - torrent_handle conflicting_torrent; │ │ │ │ - std::shared_ptr metadata; │ │ │ │ + static inline constexpr add_peer_flags_t ffiirrsstt__ttiimmee = 1_bit; │ │ │ │ + static inline constexpr add_peer_flags_t ffiilltteerreedd = 2_bit; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - conflicting_torrent │ │ │ │ - the handle to the torrent in conflict. The swarm associated with this │ │ │ │ - torrent handle did not download the metadata, but the downloaded metadata │ │ │ │ - collided with this swarm's info-hash. │ │ │ │ +********** nneeww__ccoonnnneeccttiioonn(()) ********** │ │ │ │ +virtual std::shared_ptr nneeww__ccoonnnneeccttiioonn (peer_connection_handle │ │ │ │ +const&); │ │ │ │ +This function is called each time a new peer is connected to the torrent. You │ │ │ │ +may choose to ignore this by just returning a default constructed shared_ptr │ │ │ │ +(in which case you don't need to override this member function). │ │ │ │ +If you need an extension to the peer connection (which most plugins do) you are │ │ │ │ +supposed to return an instance of your _p_e_e_r___p_l_u_g_i_n class. Which in turn will │ │ │ │ +have its hook functions called on event specific to that peer. │ │ │ │ +The peer_connection_handle will be valid as long as the shared_ptr is being │ │ │ │ +held by the torrent object. So, it is generally a good idea to not keep a │ │ │ │ +shared_ptr to your own _p_e_e_r___p_l_u_g_i_n. If you want to keep references to it, use │ │ │ │ +weak_ptr. │ │ │ │ +If this function throws an exception, the connection will be closed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - metadata │ │ │ │ - the metadata that was received by one of the torrents in conflict. One │ │ │ │ - way to resolve the conflict is to remove both failing torrents and re-add │ │ │ │ - it using this metadata │ │ │ │ +********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) ********** │ │ │ │ +virtual void oonn__ppiieeccee__ppaassss (piece_index_t); │ │ │ │ +virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t); │ │ │ │ +These hooks are called when a piece passes the hash check or fails the hash │ │ │ │ +check, respectively. The index is the piece index that was downloaded. It is │ │ │ │ +possible to access the list of peers that participated in sending the piece │ │ │ │ +through the torrent and the piece_picker. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__iinnffoo__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___p_e_e_r___i_n_f_o_(_) is called │ │ │ │ -struct peer_info_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ - std::vector peer_info; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ - peer_info │ │ │ │ - the list of the currently connected peers │ │ │ │ +********** oonn__ppaauussee(()) 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 │ │ │ │ +will recurse back into your handler, so in order to invoke the standard │ │ │ │ +handler, you have to keep your own state on whether you want standard behavior │ │ │ │ +or overridden behavior. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__pprrooggrreessss__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___f_i_l_e___p_r_o_g_r_e_s_s_(_) is called │ │ │ │ -struct file_progress_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -file_progress; │ │ │ │ - aux::vector files; │ │ │ │ -}; │ │ │ │ +********** oonn__ffiilleess__cchheecckkeedd(()) ********** │ │ │ │ +virtual void oonn__ffiilleess__cchheecckkeedd (); │ │ │ │ +This function is called when the initial files of the torrent have been │ │ │ │ +checked. If there are no files to check, this function is called immediately. │ │ │ │ +i.e. This function is always called when the torrent is in a state where it can │ │ │ │ +start downloading. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - files │ │ │ │ - the list of the files in the torrent │ │ │ │ +********** oonn__ssttaattee(()) ********** │ │ │ │ +virtual void oonn__ssttaattee (torrent_status::state_t); │ │ │ │ +called when the torrent changes state the state is one of _t_o_r_r_e_n_t___s_t_a_t_u_s_:_: │ │ │ │ +_s_t_a_t_e___t enum members │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppiieeccee__iinnffoo__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_) is called │ │ │ │ -struct piece_info_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ -piece_progress; │ │ │ │ - std::vector piece_info; │ │ │ │ - std::vector block_data; │ │ │ │ -}; │ │ │ │ +********** oonn__aadddd__ppeeeerr(()) ********** │ │ │ │ +virtual void oonn__aadddd__ppeeeerr (tcp::endpoint const&, │ │ │ │ + peer_source_flags_t, add_peer_flags_t); │ │ │ │ +called every time a new peer is added to the peer list. This is before the peer │ │ │ │ +is connected to. For flags, see torrent_plugin::flags_t. The source argument │ │ │ │ +refers to the source where we learned about this peer from. It's a bitmask, │ │ │ │ +because many sources may have told us about the same peer. For peer source │ │ │ │ +flags, see peer_info::peer_source_flags. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - piece_info │ │ │ │ - info about pieces being downloaded for the torrent │ │ │ │ + first_time │ │ │ │ + this is the first time we see this peer │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - block_data │ │ │ │ - storage for _b_l_o_c_k___i_n_f_o pointers in _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o objects │ │ │ │ + filtered │ │ │ │ + this peer was not added because it was filtered by the IP filter │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppiieeccee__aavvaaiillaabbiilliittyy__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_) is called │ │ │ │ -struct piece_availability_alert final : torrent_alert │ │ │ │ +************ ppeeeerr__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" │ │ │ │ +peer plugins are associated with a specific peer. A peer could be both a │ │ │ │ +regular bittorrent peer (bt_peer_connection) or one of the web seed connections │ │ │ │ +(web_peer_connection). In order to only attach to certain peers, make your │ │ │ │ +torrent_plugin::new_connection only return a _p_l_u_g_i_n for certain peer connection │ │ │ │ +types │ │ │ │ +struct peer_plugin │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ - std::vector piece_availability; │ │ │ │ + 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 (piece_index_t); │ │ │ │ + virtual bool oonn__ddoonntt__hhaavvee (piece_index_t); │ │ │ │ + virtual bool oonn__rreeqquueesstt (peer_request const&); │ │ │ │ + virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//); │ │ │ │ + virtual bool oonn__iinntteerreesstteedd (); │ │ │ │ + virtual bool oonn__nnoott__iinntteerreesstteedd (); │ │ │ │ + virtual bool oonn__hhaavvee__aallll (); │ │ │ │ + virtual bool oonn__uunncchhookkee (); │ │ │ │ + virtual bool oonn__hhaavvee__nnoonnee (); │ │ │ │ + virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t); │ │ │ │ + virtual bool oonn__cchhookkee (); │ │ │ │ + virtual bool oonn__ppiieeccee (peer_request const& //**ppiieeccee**// │ │ │ │ + , span //**bbuuff**//); │ │ │ │ + virtual bool oonn__ccaanncceell (peer_request const&); │ │ │ │ + virtual bool oonn__rreejjeecctt (peer_request const&); │ │ │ │ + virtual bool oonn__ssuuggggeesstt (piece_index_t); │ │ │ │ + virtual void sseenntt__ccaanncceell (peer_request const&); │ │ │ │ + virtual void sseenntt__hhaavvee__aallll (); │ │ │ │ + virtual void sseenntt__rreeqquueesstt (peer_request const&); │ │ │ │ + virtual void sseenntt__cchhookkee (); │ │ │ │ + virtual void sseenntt__ssuuggggeesstt (piece_index_t); │ │ │ │ + virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&); │ │ │ │ + virtual void sseenntt__nnoott__iinntteerreesstteedd (); │ │ │ │ + virtual void sseenntt__hhaavvee (piece_index_t); │ │ │ │ + virtual void sseenntt__ppiieeccee (peer_request const&); │ │ │ │ + virtual void sseenntt__iinntteerreesstteedd (); │ │ │ │ + virtual void sseenntt__hhaavvee__nnoonnee (); │ │ │ │ + virtual void sseenntt__uunncchhookkee (); │ │ │ │ + virtual void sseenntt__aallllooww__ffaasstt (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); │ │ │ │ + virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t); │ │ │ │ + virtual void ttiicckk (); │ │ │ │ + virtual bool wwrriittee__rreeqquueesstt (peer_request const&); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - piece_availability │ │ │ │ - info about pieces being downloaded for the torrent │ │ │ │ +********** ttyyppee(()) ********** │ │ │ │ +virtual string_view ttyyppee () const; │ │ │ │ +This function is expected to return the name of the _p_l_u_g_i_n. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrraacckkeerr__lliisstt__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___t_r_a_c_k_e_r_s_(_) is called │ │ │ │ -struct tracker_list_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ - std::vector trackers; │ │ │ │ -}; │ │ │ │ +********** aadddd__hhaannddsshhaakkee(()) ********** │ │ │ │ +virtual void aadddd__hhaannddsshhaakkee (entry&); │ │ │ │ +can add entries to the extension handshake this is not called for web seeds │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - trackers │ │ │ │ - list of trackers and their status for the torrent │ │ │ │ +********** oonn__ddiissccoonnnneecctt(()) ********** │ │ │ │ +virtual void oonn__ddiissccoonnnneecctt (error_code const&); │ │ │ │ +called when the peer is being disconnected. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__pprriioorriittiieess__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_) is called │ │ │ │ -struct file_priorities_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ - std::vector priorities; │ │ │ │ -}; │ │ │ │ +********** oonn__ccoonnnneecctteedd(()) ********** │ │ │ │ +virtual void oonn__ccoonnnneecctteedd (); │ │ │ │ +called when the peer is successfully connected. Note that incoming connections │ │ │ │ +will have been connected by the time the peer _p_l_u_g_i_n is attached to it, and │ │ │ │ +won't have this hook called. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - priorities │ │ │ │ - the download priority of each file in the torrent │ │ │ │ +********** oonn__hhaannddsshhaakkee(()) ********** │ │ │ │ +virtual bool oonn__hhaannddsshhaakkee (span); │ │ │ │ +this is called when the initial bittorrent handshake is received. Returning │ │ │ │ +false means that the other end doesn't support this extension and will remove │ │ │ │ +it from the list of plugins. this is not called for web seeds │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiillee__ssttaattuuss__aalleerrtt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ -posted when _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_p_o_s_t___f_i_l_e___s_t_a_t_u_s_(_) is called │ │ │ │ -struct file_status_alert final : torrent_alert │ │ │ │ -{ │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ - │ │ │ │ - static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::status; │ │ │ │ - std::vector state; │ │ │ │ -}; │ │ │ │ +********** 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] │ │ │ │ - state │ │ │ │ - the open-file state of each currently open file in the torrent. Files │ │ │ │ - that are not open are not included. Each entry's file_index field │ │ │ │ - identifies which file it refers to. │ │ │ │ +********** oonn__uunncchhookkee(()) oonn__nnoott__iinntteerreesstteedd(()) oonn__ddoonntt__hhaavvee(()) oonn__rreeqquueesstt(()) │ │ │ │ +oonn__iinntteerreesstteedd(()) oonn__aalllloowweedd__ffaasstt(()) oonn__hhaavvee(()) oonn__cchhookkee(()) oonn__hhaavvee__aallll(()) │ │ │ │ +oonn__bbiittffiieelldd(()) oonn__hhaavvee__nnoonnee(()) ********** │ │ │ │ +virtual bool oonn__hhaavvee (piece_index_t); │ │ │ │ +virtual bool oonn__ddoonntt__hhaavvee (piece_index_t); │ │ │ │ +virtual bool oonn__rreeqquueesstt (peer_request const&); │ │ │ │ +virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//); │ │ │ │ +virtual bool oonn__iinntteerreesstteedd (); │ │ │ │ +virtual bool oonn__nnoott__iinntteerreesstteedd (); │ │ │ │ +virtual bool oonn__hhaavvee__aallll (); │ │ │ │ +virtual bool oonn__uunncchhookkee (); │ │ │ │ +virtual bool oonn__hhaavvee__nnoonnee (); │ │ │ │ +virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t); │ │ │ │ +virtual bool oonn__cchhookkee (); │ │ │ │ +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] │ │ │ │ -************ aalleerrtt__ccaasstt(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t_._h_p_p" │ │ │ │ -template T* aalleerrtt__ccaasstt (alert* a); │ │ │ │ -template T const* aalleerrtt__ccaasstt (alert const* a); │ │ │ │ -When you get an _a_l_e_r_t, you can use alert_cast<> to attempt to cast the pointer │ │ │ │ -to a specific _a_l_e_r_t type, in order to query it for more information. │ │ │ │ -Note │ │ │ │ -alert_cast<> can only cast to an exact _a_l_e_r_t type, not a base class │ │ │ │ +********** 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] │ │ │ │ -************ ooppeerraattiioonn__nnaammee(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_o_p_e_r_a_t_i_o_n_s_._h_p_p" │ │ │ │ -char const* ooppeerraattiioonn__nnaammee (operation_t op); │ │ │ │ -maps an operation id (from _p_e_e_r___e_r_r_o_r___a_l_e_r_t and _p_e_e_r___d_i_s_c_o_n_n_e_c_t_e_d___a_l_e_r_t) to its │ │ │ │ -name. See _o_p_e_r_a_t_i_o_n___t for the constants │ │ │ │ +********** oonn__ccaanncceell(()) oonn__rreejjeecctt(()) oonn__ssuuggggeesstt(()) ********** │ │ │ │ +virtual bool oonn__ccaanncceell (peer_request const&); │ │ │ │ +virtual bool oonn__rreejjeecctt (peer_request const&); │ │ │ │ +virtual bool oonn__ssuuggggeesstt (piece_index_t); │ │ │ │ +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] │ │ │ │ -************ eennuumm ooppeerraattiioonn__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_o_p_e_r_a_t_i_o_n_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|unknown |0 |the error was unexpected and it is unknown which | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_p_e_r_a_t_i_o_n_ _c_a_u_s_e_d_ _i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|bittorrent |1 |this is used when the bittorrent logic determines | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_ _d_i_s_c_o_n_n_e_c_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_o_c_o_n_t_r_o_l_ _ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_a_ _c_a_l_l_ _t_o_ _i_o_c_o_n_t_r_o_l_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|getpeername |3 |a call to getpeername() failed (querying the remote| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_I_P_ _o_f_ _a_ _c_o_n_n_e_c_t_i_o_n_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|getname |4 |a call to getname failed (querying the local IP of | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _c_o_n_n_e_c_t_i_o_n_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_a_l_l_o_c___r_e_c_v_b_u_f_ _ _ _ _ _ _|_5_ _ _ _ _|_a_n_ _a_t_t_e_m_p_t_ _t_o_ _a_l_l_o_c_a_t_e_ _a_ _r_e_c_e_i_v_e_ _b_u_f_f_e_r_ _f_a_i_l_e_d_ _ _ _ _ | │ │ │ │ -|_a_l_l_o_c___s_n_d_b_u_f_ _ _ _ _ _ _ _|_6_ _ _ _ _|_a_n_ _a_t_t_e_m_p_t_ _t_o_ _a_l_l_o_c_a_t_e_ _a_ _s_e_n_d_ _b_u_f_f_e_r_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___w_r_i_t_e_ _ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_w_r_i_t_i_n_g_ _t_o_ _a_ _f_i_l_e_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___r_e_a_d_ _ _ _ _ _ _ _ _ _ _|_8_ _ _ _ _|_r_e_a_d_i_n_g_ _f_r_o_m_ _a_ _f_i_l_e_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_ _ _ _ _|_a_ _n_o_n_-_r_e_a_d_ _a_n_d_ _n_o_n_-_w_r_i_t_e_ _f_i_l_e_ _o_p_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ | │ │ │ │ -|_s_o_c_k___w_r_i_t_e_ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_a_ _s_o_c_k_e_t_ _w_r_i_t_e_ _o_p_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k___r_e_a_d_ _ _ _ _ _ _ _ _ _ _|_1_1_ _ _ _|_a_ _s_o_c_k_e_t_ _r_e_a_d_ _o_p_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k___o_p_e_n_ _ _ _ _ _ _ _ _ _ _|_1_2_ _ _ _|_a_ _c_a_l_l_ _t_o_ _o_p_e_n_(_)_,_ _t_o_ _c_r_e_a_t_e_ _a_ _s_o_c_k_e_t_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ | │ │ │ │ -|_s_o_c_k___b_i_n_d_ _ _ _ _ _ _ _ _ _ _|_1_3_ _ _ _|_a_ _c_a_l_l_ _t_o_ _b_i_n_d_(_)_ _o_n_ _a_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|available |14 |an attempt to query the number of bytes available | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_ _r_e_a_d_ _f_r_o_m_ _a_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|encryption |15 |a call related to bittorrent protocol encryption | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_c_o_n_n_e_c_t_ _ _ _ _ _ _ _ _ _ _ _ _|_1_6_ _ _ _|_a_n_ _a_t_t_e_m_p_t_ _t_o_ _c_o_n_n_e_c_t_ _a_ _s_o_c_k_e_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_s_l___h_a_n_d_s_h_a_k_e_ _ _ _ _ _ _|_1_7_ _ _ _|_e_s_t_a_b_l_i_s_h_i_n_g_ _a_n_ _S_S_L_ _c_o_n_n_e_c_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|get_interface |18 |a connection failed to satisfy the bind interface | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_t_t_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k___l_i_s_t_e_n_ _ _ _ _ _ _ _ _|_1_9_ _ _ _|_a_ _c_a_l_l_ _t_o_ _l_i_s_t_e_n_(_)_ _o_n_ _a_ _s_o_c_k_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|sock_bind_to_device|20 |a call to the ioctl to bind a socket to a specific | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_e_t_w_o_r_k_ _d_e_v_i_c_e_ _o_r_ _a_d_a_p_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k___a_c_c_e_p_t_ _ _ _ _ _ _ _ _|_2_1_ _ _ _|_a_ _c_a_l_l_ _t_o_ _a_c_c_e_p_t_(_)_ _o_n_ _a_ _s_o_c_k_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_a_r_s_e___a_d_d_r_e_s_s_ _ _ _ _ _ _|_2_2_ _ _ _|_c_o_n_v_e_r_t_ _a_ _s_t_r_i_n_g_ _i_n_t_o_ _a_ _v_a_l_i_d_ _n_e_t_w_o_r_k_ _a_d_d_r_e_s_s_ _ _ _ _ _ | │ │ │ │ -|_e_n_u_m___i_f_ _ _ _ _ _ _ _ _ _ _ _ _|_2_3_ _ _ _|_e_n_u_m_e_r_a_t_i_o_n_ _n_e_t_w_o_r_k_ _d_e_v_i_c_e_s_ _o_r_ _a_d_a_p_t_e_r_s_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___s_t_a_t_ _ _ _ _ _ _ _ _ _ _|_2_4_ _ _ _|_i_n_v_o_k_i_n_g_ _s_t_a_t_(_)_ _o_n_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___c_o_p_y_ _ _ _ _ _ _ _ _ _ _|_2_5_ _ _ _|_c_o_p_y_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___f_a_l_l_o_c_a_t_e_ _ _ _ _ _|_2_6_ _ _ _|_a_l_l_o_c_a_t_i_n_g_ _s_t_o_r_a_g_e_ _f_o_r_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___h_a_r_d___l_i_n_k_ _ _ _ _ _|_2_7_ _ _ _|_c_r_e_a_t_i_n_g_ _a_ _h_a_r_d_ _l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___r_e_m_o_v_e_ _ _ _ _ _ _ _ _|_2_8_ _ _ _|_r_e_m_o_v_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___r_e_n_a_m_e_ _ _ _ _ _ _ _ _|_2_9_ _ _ _|_r_e_n_a_m_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___o_p_e_n_ _ _ _ _ _ _ _ _ _ _|_3_0_ _ _ _|_o_p_e_n_i_n_g_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_m_k_d_i_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_1_ _ _ _|_c_r_e_a_t_i_n_g_ _a_ _d_i_r_e_c_t_o_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_c_h_e_c_k___r_e_s_u_m_e_ _ _ _ _ _ _ _|_3_2_ _ _ _|_c_h_e_c_k_ _f_a_s_t_ _r_e_s_u_m_e_ _d_a_t_a_ _a_g_a_i_n_s_t_ _f_i_l_e_s_ _o_n_ _d_i_s_k_ _ _ _ _ _ _ | │ │ │ │ -|_e_x_c_e_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _|_3_3_ _ _ _|_a_n_ _u_n_k_n_o_w_n_ _e_x_c_e_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_a_l_l_o_c___c_a_c_h_e___p_i_e_c_e_ _ _|_3_4_ _ _ _|_a_l_l_o_c_a_t_e_ _s_p_a_c_e_ _f_o_r_ _a_ _p_i_e_c_e_ _i_n_ _t_h_e_ _c_a_c_h_e_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_a_r_t_f_i_l_e___m_o_v_e_ _ _ _ _ _ _|_3_5_ _ _ _|_m_o_v_e_ _a_ _p_a_r_t_-_f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_a_r_t_f_i_l_e___r_e_a_d_ _ _ _ _ _ _|_3_6_ _ _ _|_r_e_a_d_ _f_r_o_m_ _a_ _p_a_r_t_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_a_r_t_f_i_l_e___w_r_i_t_e_ _ _ _ _ _|_3_7_ _ _ _|_w_r_i_t_e_ _t_o_ _a_ _p_a_r_t_-_f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_h_o_s_t_n_a_m_e___l_o_o_k_u_p_ _ _ _ _|_3_8_ _ _ _|_a_ _h_o_s_t_n_a_m_e_ _l_o_o_k_u_p_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_y_m_l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _|_3_9_ _ _ _|_c_r_e_a_t_e_ _o_r_ _r_e_a_d_ _a_ _s_y_m_l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_h_a_n_d_s_h_a_k_e_ _ _ _ _ _ _ _ _ _ _|_4_0_ _ _ _|_h_a_n_d_s_h_a_k_e_ _w_i_t_h_ _a_ _p_e_e_r_ _o_r_ _s_e_r_v_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k___o_p_t_i_o_n_ _ _ _ _ _ _ _ _|_4_1_ _ _ _|_s_e_t_ _s_o_c_k_e_t_ _o_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_e_n_u_m___r_o_u_t_e_ _ _ _ _ _ _ _ _ _|_4_2_ _ _ _|_e_n_u_m_e_r_a_t_i_o_n_ _o_f_ _n_e_t_w_o_r_k_ _r_o_u_t_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___s_e_e_k_ _ _ _ _ _ _ _ _ _ _|_4_3_ _ _ _|_m_o_v_i_n_g_ _r_e_a_d_/_w_r_i_t_e_ _p_o_s_i_t_i_o_n_ _i_n_ _a_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_i_m_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_4_4_ _ _ _|_a_n_ _a_s_y_n_c_ _w_a_i_t_ _o_p_e_r_a_t_i_o_n_ _o_n_ _a_ _t_i_m_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___m_m_a_p_ _ _ _ _ _ _ _ _ _ _|_4_5_ _ _ _|_c_a_l_l_ _t_o_ _m_m_a_p_(_)_ _(_o_r_ _w_i_n_d_o_w_s_ _c_o_u_n_t_e_r_p_a_r_t_)_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_f_i_l_e___t_r_u_n_c_a_t_e_ _ _ _ _ _ _|_4_6_ _ _ _|_c_a_l_l_ _t_o_ _f_t_r_u_n_c_a_t_e_(_)_ _(_o_r_ _S_e_t_E_n_d_O_f_F_i_l_e_(_)_ _o_n_ _w_i_n_d_o_w_s_)_ | │ │ │ │ +********** sseenntt__ppiieeccee(()) sseenntt__hhaavvee__aallll(()) sseenntt__iinntteerreesstteedd(()) sseenntt__ccaanncceell(()) sseenntt__hhaavvee(()) │ │ │ │ +sseenntt__uunncchhookkee(()) sseenntt__hhaavvee__nnoonnee(()) sseenntt__ssuuggggeesstt(()) sseenntt__rreejjeecctt__rreeqquueesstt(()) │ │ │ │ +sseenntt__rreeqquueesstt(()) sseenntt__cchhookkee(()) sseenntt__nnoott__iinntteerreesstteedd(()) sseenntt__aallllooww__ffaasstt(()) ********** │ │ │ │ +virtual void sseenntt__ccaanncceell (peer_request const&); │ │ │ │ +virtual void sseenntt__hhaavvee__aallll (); │ │ │ │ +virtual void sseenntt__rreeqquueesstt (peer_request const&); │ │ │ │ +virtual void sseenntt__cchhookkee (); │ │ │ │ +virtual void sseenntt__ssuuggggeesstt (piece_index_t); │ │ │ │ +virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&); │ │ │ │ +virtual void sseenntt__nnoott__iinntteerreesstteedd (); │ │ │ │ +virtual void sseenntt__hhaavvee (piece_index_t); │ │ │ │ +virtual void sseenntt__ppiieeccee (peer_request const&); │ │ │ │ +virtual void sseenntt__iinntteerreesstteedd (); │ │ │ │ +virtual void sseenntt__hhaavvee__nnoonnee (); │ │ │ │ +virtual void sseenntt__uunncchhookkee (); │ │ │ │ +virtual void sseenntt__aallllooww__ffaasstt (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] │ │ │ │ -************ aalleerrtt__ccaatteeggoorryy__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t_._h_p_p" │ │ │ │ - error │ │ │ │ - Enables alerts that report an error. This includes: │ │ │ │ - * tracker errors │ │ │ │ - * tracker warnings │ │ │ │ - * file errors │ │ │ │ - * resume data failures │ │ │ │ - * web seed errors │ │ │ │ - * .torrent files errors │ │ │ │ - * listen socket errors │ │ │ │ - * port mapping errors │ │ │ │ - peer │ │ │ │ - Enables alerts when peers send invalid requests, get banned or snubbed. │ │ │ │ - port_mapping │ │ │ │ - Enables alerts for port mapping events. For NAT-PMP and UPnP. │ │ │ │ - storage │ │ │ │ - Enables alerts for events related to the storage. File errors and │ │ │ │ - synchronization events for moving the storage, renaming files etc. │ │ │ │ - tracker │ │ │ │ - Enables all tracker events. Includes announcing to trackers, receiving │ │ │ │ - responses, warnings and errors. │ │ │ │ - connect │ │ │ │ - Low level alerts for when peers are connected and disconnected. │ │ │ │ - status │ │ │ │ - Enables alerts for when a torrent or the _s_e_s_s_i_o_n changes state. │ │ │ │ - ip_block │ │ │ │ - Alerts when a peer is blocked by the ip blocker or port blocker. │ │ │ │ - performance_warning │ │ │ │ - Alerts when some limit is reached that might limit the download or upload │ │ │ │ - rate. │ │ │ │ - dht │ │ │ │ - Alerts on events in the DHT node. For incoming searches or bootstrapping │ │ │ │ - being done etc. │ │ │ │ - stats │ │ │ │ - If you enable these alerts, you will receive a stats_alert approximately │ │ │ │ - once every second, for every active torrent. These alerts contain all │ │ │ │ - statistics _c_o_u_n_t_e_r_s for the interval since the lasts stats _a_l_e_r_t. │ │ │ │ - session_log │ │ │ │ - Enables debug logging alerts. These are available unless libtorrent was │ │ │ │ - built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being │ │ │ │ - posted are _l_o_g___a_l_e_r_t and are _s_e_s_s_i_o_n wide. │ │ │ │ - torrent_log │ │ │ │ - Enables debug logging alerts for torrents. These are available unless │ │ │ │ - libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The │ │ │ │ - alerts being posted are _t_o_r_r_e_n_t___l_o_g___a_l_e_r_t and are torrent wide debug │ │ │ │ - events. │ │ │ │ - peer_log │ │ │ │ - Enables debug logging alerts for peers. These are available unless │ │ │ │ - libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The │ │ │ │ - alerts being posted are _p_e_e_r___l_o_g___a_l_e_r_t and low-level peer events and │ │ │ │ - messages. │ │ │ │ - incoming_request │ │ │ │ - enables the _i_n_c_o_m_i_n_g___r_e_q_u_e_s_t___a_l_e_r_t. │ │ │ │ - dht_log │ │ │ │ - enables _d_h_t___l_o_g___a_l_e_r_t, debug logging for the DHT │ │ │ │ - dht_operation │ │ │ │ - enable events from pure dht operations not related to torrents │ │ │ │ - port_mapping_log │ │ │ │ - enables port mapping log events. This log is useful for debugging the │ │ │ │ - UPnP or NAT-PMP implementation │ │ │ │ - picker_log │ │ │ │ - enables verbose logging from the piece picker. │ │ │ │ - file_progress │ │ │ │ - alerts when files complete downloading │ │ │ │ - piece_progress │ │ │ │ - alerts when pieces complete downloading or fail hash check │ │ │ │ - upload │ │ │ │ - alerts when we upload blocks to other peers │ │ │ │ - block_progress │ │ │ │ - alerts on individual blocks being requested, downloading, finished, │ │ │ │ - rejected, time-out and cancelled. This is likely to post alerts at a high │ │ │ │ - rate. │ │ │ │ - all │ │ │ │ - The full bitmask, representing all available categories. │ │ │ │ - since the enum is signed, make sure this isn't interpreted as -1. For │ │ │ │ - instance, boost.python does that and fails when assigning it to an │ │ │ │ - unsigned parameter. │ │ │ │ +********** 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] │ │ │ │ -************ iinntt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ - user_alert_id │ │ │ │ - user defined alerts should use IDs greater than this │ │ │ │ - num_alert_types │ │ │ │ - this constant represents "max_alert_index" + 1 │ │ │ │ +********** ccaann__ddiissccoonnnneecctt(()) ********** │ │ │ │ +virtual bool ccaann__ddiissccoonnnneecctt (error_code const& //**eecc**//); │ │ │ │ +called when libtorrent think this peer should be disconnected. if the _p_l_u_g_i_n │ │ │ │ +returns false, the peer will not be disconnected. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ccoouunntteerrss ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_r_f_o_r_m_a_n_c_e___c_o_u_n_t_e_r_s_._h_p_p" │ │ │ │ -holds the session-wide _c_o_u_n_t_e_r_s and gauges backing the session_stats_alert and │ │ │ │ -session_status reporting paths. One instance lives on the _s_e_s_s_i_o_n and is │ │ │ │ -incremented from the network thread; reads from other threads use the lock-free │ │ │ │ -operator[] overload when ATOMIC_LLONG_LOCK_FREE is set, otherwise a single │ │ │ │ -shared mutex guards the whole array. │ │ │ │ -A reference to this object is passed to custom disk I/O implementations (see │ │ │ │ -_d_i_s_k___i_n_t_e_r_f_a_c_e and the disk_io_constructor passed via _s_e_s_s_i_o_n___p_a_r_a_m_s), which │ │ │ │ -update the disk related metrics through it. The specific _c_o_u_n_t_e_r_s and gauges │ │ │ │ -are documented under the _s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ -struct counters │ │ │ │ -{ │ │ │ │ - ccoouunntteerrss () ; │ │ │ │ - ccoouunntteerrss (counters const&) ; │ │ │ │ - counters& ooppeerraattoorr== (counters const&) & ; │ │ │ │ - std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ - std::int64_t ooppeerraattoorr[[]] (int i) const ; │ │ │ │ - void bblleenndd__ssttaattss__ccoouunntteerr (int c, std::int64_t value, int ratio) ; │ │ │ │ - void sseett__vvaalluuee (int c, std::int64_t value) ; │ │ │ │ -}; │ │ │ │ +********** oonn__eexxtteennddeedd(()) ********** │ │ │ │ +virtual bool oonn__eexxtteennddeedd (int //**lleennggtthh**//, int //**mmssgg**//, │ │ │ │ + span //**bbooddyy**//); │ │ │ │ +called when an extended message is received. If returning true, the message is │ │ │ │ +not processed by any other _p_l_u_g_i_n and if false is returned the next _p_l_u_g_i_n in │ │ │ │ +the chain will receive it to be able to handle it. This is not called for web │ │ │ │ +seeds. thus function may be called more than once per incoming message, but │ │ │ │ +only the last of the calls will the body size equal the length. i.e. Every time │ │ │ │ +another fragment of the message is received, this function will be called, │ │ │ │ +until finally the whole message has been received. The purpose of this is to │ │ │ │ +allow early disconnects for invalid messages and for reporting progress of │ │ │ │ +receiving large messages. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinncc__ssttaattss__ccoouunntteerr(()) ********** │ │ │ │ -std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ -increments the counter or gauge c (an index into the counter array) by value │ │ │ │ -and returns the new value. │ │ │ │ +********** oonn__uunnkknnoowwnn__mmeessssaaggee(()) ********** │ │ │ │ +virtual bool oonn__uunnkknnoowwnn__mmeessssaaggee (int //**lleennggtthh**//, int //**mmssgg**//, │ │ │ │ + span //**bbooddyy**//); │ │ │ │ +this is not called for web seeds │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr[[]](()) ********** │ │ │ │ -std::int64_t ooppeerraattoorr[[]] (int i) const ; │ │ │ │ -returns the current value of counter or gauge i (an index into the counter │ │ │ │ -array). │ │ │ │ +********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) ********** │ │ │ │ +virtual void oonn__ppiieeccee__ppaassss (piece_index_t); │ │ │ │ +virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t); │ │ │ │ +called when a piece that this peer participated in either fails or passes the │ │ │ │ +hash_check │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bblleenndd__ssttaattss__ccoouunntteerr(()) sseett__vvaalluuee(()) ********** │ │ │ │ -void bblleenndd__ssttaattss__ccoouunntteerr (int c, std::int64_t value, int ratio) ; │ │ │ │ -void sseett__vvaalluuee (int c, std::int64_t value) ; │ │ │ │ -overwrites the value of counter or gauge c (an index into the counter array). │ │ │ │ -blend_stats_counter() adjusts the stat value toward the specified value, ratio │ │ │ │ -specifies the percent of the new value should be influenced by value. │ │ │ │ +********** ttiicckk(()) ********** │ │ │ │ +virtual void ttiicckk (); │ │ │ │ +called approximately once every second │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttaattss__mmeettrriicc ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ -describes one statistics metric from the _s_e_s_s_i_o_n. For more information, see the │ │ │ │ -_s_e_s_s_i_o_n_ _s_t_a_t_i_s_t_i_c_s section. │ │ │ │ -struct stats_metric │ │ │ │ +********** wwrriittee__rreeqquueesstt(()) ********** │ │ │ │ +virtual bool wwrriittee__rreeqquueesstt (peer_request const&); │ │ │ │ +called each time a request message is to be sent. If true is returned, the │ │ │ │ +original request message won't be sent and no other _p_l_u_g_i_n will have this │ │ │ │ +function called. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ccrryyppttoo__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" │ │ │ │ +interface implemented by a _p_l_u_g_i_n that wants to take over the encryption / │ │ │ │ +decryption of a peer connection. Returned by peer_plugin::wrap_socket() to plug │ │ │ │ +into the BitTorrent peer connection's send / receive path. Used by the built-in │ │ │ │ +protocol encryption (MSE) implementation. │ │ │ │ +struct crypto_plugin │ │ │ │ { │ │ │ │ - char const* name; │ │ │ │ - int value_index; │ │ │ │ - metric_type_t type; │ │ │ │ + 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] │ │ │ │ - name │ │ │ │ - the name of the counter or gauge │ │ │ │ +********** sseett__iinnccoommiinngg__kkeeyy(()) sseett__oouuttggooiinngg__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] │ │ │ │ - value_index type │ │ │ │ - the index into the _s_e_s_s_i_o_n stats array, where the underlying value of │ │ │ │ - this counter or gauge is found. The _s_e_s_s_i_o_n stats array is part of the │ │ │ │ - _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t object. │ │ │ │ +********** eennccrryypptt(()) ********** │ │ │ │ +eennccrryypptt (span> //**sseenndd__vveecc**//) = 0; │ │ │ │ +encrypted the provided buffers and returns the number of bytes which are now │ │ │ │ +ready to be sent to the lower layer. This must be at least as large as the │ │ │ │ +number of bytes passed in and may be larger if there is additional data to be │ │ │ │ +inserted at the head of the send buffer. The additional data is returned as the │ │ │ │ +second tuple value. Any returned buffer as well as the iovec itself, to be │ │ │ │ +prepended to the send buffer, must be owned by the crypto _p_l_u_g_i_n and guaranteed │ │ │ │ +to stay alive until the _c_r_y_p_t_o___p_l_u_g_i_n is destructed or this function is called │ │ │ │ +again. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseessssiioonn__ssttaattss__mmeettrriiccss(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ -std::vector sseessssiioonn__ssttaattss__mmeettrriiccss (); │ │ │ │ -This free function returns the list of available metrics exposed by │ │ │ │ -libtorrent's statistics API. Each metric has a name and a vvaalluuee iinnddeexx. The │ │ │ │ -value index is the index into the array in _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t where this │ │ │ │ -metric's value can be found when the _s_e_s_s_i_o_n stats is sampled (by calling │ │ │ │ -_p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_)). │ │ │ │ +********** ddeeccrryypptt(()) ********** │ │ │ │ +virtual std::tuple ddeeccrryypptt (span> //**rreecceeiivvee__vveecc**//) = │ │ │ │ +0; │ │ │ │ +decrypt the provided buffers. returns is a tuple representing the values │ │ │ │ +(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 │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ffiinndd__mmeettrriicc__iiddxx(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ -int ffiinndd__mmeettrriicc__iiddxx (string_view name); │ │ │ │ -given a name of a metric, this function returns the counter index of it, or - │ │ │ │ -1 if it could not be found. The counter index is the index into the values │ │ │ │ -array returned by _s_e_s_s_i_o_n___s_t_a_t_s___a_l_e_r_t. │ │ │ │ +************ 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 │ │ │ │ +default unless explicitly disabled in the _s_e_s_s_i_o_n constructor. │ │ │ │ +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 mmeettrriicc__ttyyppee__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_c_o_u_n_t_e_r_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_g_a_u_g_e_ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +************ ccrreeaattee__ssmmaarrtt__bbaann__pplluuggiinn(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_x_t_e_n_s_i_o_n_s_/_s_m_a_r_t___b_a_n_._h_p_p" │ │ │ │ +std::shared_ptr ccrreeaattee__ssmmaarrtt__bbaann__pplluuggiinn (torrent_handle const&, │ │ │ │ +client_data_t); │ │ │ │ +constructor function for the smart ban extension. The extension keeps track of │ │ │ │ +the data peers have sent us for failing pieces and once the piece completes and │ │ │ │ +passes the hash check bans the peers that turned out to have sent corrupt data. │ │ │ │ +This function can either be passed in the add_torrent_params::extensions field, │ │ │ │ +or via _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] │ │ │ │ +************ ccrreeaattee__uutt__mmeettaaddaattaa__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___m_e_t_a_d_a_t_a_._h_p_p" │ │ │ │ +std::shared_ptr ccrreeaattee__uutt__mmeettaaddaattaa__pplluuggiinn (torrent_handle │ │ │ │ +const&, client_data_t); │ │ │ │ +constructor function for the ut_metadata extension. The ut_metadata extension │ │ │ │ +allows peers to request the .torrent file (or more specifically the info- │ │ │ │ +dictionary of the .torrent file) from each other. This is the main building │ │ │ │ +block in making magnet links work. This extension is enabled by default unless │ │ │ │ +explicitly disabled in the _s_e_s_s_i_o_n constructor. │ │ │ │ +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] │ │ │ │ ************ iipp__ffiilltteerr ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_p___f_i_l_t_e_r_._h_p_p" │ │ │ │ The ip_filter class is a set of rules that uniquely categorizes all ip │ │ │ │ addresses as allowed or disallowed. The default constructor creates a single │ │ │ │ rule that allows all addresses (0.0.0.0 - 255.255.255.255 for the IPv4 range, │ │ │ │ and the equivalent range covering all addresses for the IPv6 range). │ │ │ │ A default constructed _i_p___f_i_l_t_e_r does not filter any address. │ │ │ │ struct ip_filter │ │ │ │ { │ │ │ │ - iipp__ffiilltteerr (ip_filter&&) noexcept; │ │ │ │ - ip_filter& ooppeerraattoorr== (ip_filter&&) noexcept; │ │ │ │ iipp__ffiilltteerr (); │ │ │ │ + ip_filter& ooppeerraattoorr== (ip_filter const&); │ │ │ │ + iipp__ffiilltteerr (ip_filter&&) noexcept; │ │ │ │ iipp__ffiilltteerr (ip_filter const&); │ │ │ │ ~~iipp__ffiilltteerr (); │ │ │ │ - ip_filter& ooppeerraattoorr== (ip_filter const&); │ │ │ │ + ip_filter& ooppeerraattoorr== (ip_filter&&) noexcept; │ │ │ │ bool eemmppttyy () const; │ │ │ │ void aadddd__rruullee (address const& first, address const& last, std::uint32_t │ │ │ │ flags); │ │ │ │ std::uint32_t aacccceessss (address const& addr) const; │ │ │ │ filter_tuple_t eexxppoorrtt__ffiilltteerr () const; │ │ │ │ │ │ │ │ enum access_flags │ │ │ │ @@ -9663,20 +11575,20 @@ │ │ │ │ ************ ppoorrtt__ffiilltteerr ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_p___f_i_l_t_e_r_._h_p_p" │ │ │ │ the port filter maps non-overlapping port ranges to flags. This is primarily │ │ │ │ used to indicate whether a range of ports should be connected to or not. The │ │ │ │ default is to have the full port range (0-65535) set to flag 0. │ │ │ │ class port_filter │ │ │ │ { │ │ │ │ - port_filter& ooppeerraattoorr== (port_filter&&); │ │ │ │ - ppoorrtt__ffiilltteerr (); │ │ │ │ ppoorrtt__ffiilltteerr (port_filter const&); │ │ │ │ - ppoorrtt__ffiilltteerr (port_filter&&); │ │ │ │ port_filter& ooppeerraattoorr== (port_filter const&); │ │ │ │ ~~ppoorrtt__ffiilltteerr (); │ │ │ │ + ppoorrtt__ffiilltteerr (port_filter&&); │ │ │ │ + ppoorrtt__ffiilltteerr (); │ │ │ │ + port_filter& ooppeerraattoorr== (port_filter&&); │ │ │ │ void aadddd__rruullee (std::uint16_t first, std::uint16_t last, std::uint32_t │ │ │ │ flags); │ │ │ │ std::uint32_t aacccceessss (std::uint16_t port) const; │ │ │ │ │ │ │ │ enum access_flags │ │ │ │ { │ │ │ │ blocked, │ │ │ │ @@ -9696,848 +11608,1184 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** eennuumm aacccceessss__ffllaaggss ********** │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_p___f_i_l_t_e_r_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |blocked|1 |this flag indicates that destination ports in the range should| │ │ │ │ |_ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_t_ _b_e_ _c_o_n_n_e_c_t_e_d_ _t_o_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -Bencoding is a common representation in bittorrent used for dictionary, list, │ │ │ │ -_i_n_t and string hierarchies. It's used to encode .torrent files and some │ │ │ │ -messages in the network protocol. libtorrent also uses it to store settings, │ │ │ │ -resume data and other _s_e_s_s_i_o_n state. │ │ │ │ -Strings in bencoded structures do not necessarily represent text. Strings are │ │ │ │ -raw byte buffers of a certain length. If a string is meant to be interpreted as │ │ │ │ -text, it is required to be UTF-8 encoded. See _B_E_P_ _3. │ │ │ │ -The function for decoding bencoded data _b_d_e_c_o_d_e_(_), returning a _b_d_e_c_o_d_e___n_o_d_e. │ │ │ │ -This function builds a tree that points back into the original buffer. The │ │ │ │ -returned _b_d_e_c_o_d_e___n_o_d_e will not be valid once the buffer it was parsed out of is │ │ │ │ -discarded. │ │ │ │ -It's possible to construct an _e_n_t_r_y from a _b_d_e_c_o_d_e___n_o_d_e, if a structure needs │ │ │ │ -to be altered and re-encoded. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennttrryy ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_n_t_r_y_._h_p_p" │ │ │ │ -The entry class represents one node in a bencoded hierarchy. It works as a │ │ │ │ -variant type, it can be either a list, a dictionary (std::map), an integer or a │ │ │ │ -string. │ │ │ │ -struct entry : entry_types::variant_type │ │ │ │ -{ │ │ │ │ - data_type ttyyppee () const; │ │ │ │ - eennttrryy (preformatted_type); │ │ │ │ - eennttrryy (integer_type); │ │ │ │ - eennttrryy (span); │ │ │ │ - eennttrryy (dictionary_type); │ │ │ │ - eennttrryy (string_view); │ │ │ │ - eennttrryy (list_type); │ │ │ │ - eennttrryy (string_type); │ │ │ │ - eennttrryy (data_type t); │ │ │ │ - eennttrryy (bdecode_node const& n); │ │ │ │ - entry& ooppeerraattoorr== (integer_type) &; │ │ │ │ - entry& ooppeerraattoorr== (dictionary_type) &; │ │ │ │ - entry& ooppeerraattoorr== (entry&&) & ; │ │ │ │ - entry& ooppeerraattoorr== (string_type) &; │ │ │ │ - entry& ooppeerraattoorr== (preformatted_type) &; │ │ │ │ - entry& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ - entry& ooppeerraattoorr== (span) &; │ │ │ │ - entry& ooppeerraattoorr== (list_type) &; │ │ │ │ - entry& ooppeerraattoorr== (entry const&) &; │ │ │ │ - entry& ooppeerraattoorr== (string_view) &; │ │ │ │ - list_type const& lliisstt () const; │ │ │ │ - preformatted_type const& pprreeffoorrmmaatttteedd () const; │ │ │ │ - string_type const& ssttrriinngg () const; │ │ │ │ - integer_type const& iinntteeggeerr () const; │ │ │ │ - string_type& ssttrriinngg (); │ │ │ │ - list_type& lliisstt (); │ │ │ │ - dictionary_type const& ddiicctt () const; │ │ │ │ - integer_type& iinntteeggeerr (); │ │ │ │ - preformatted_type& pprreeffoorrmmaatttteedd (); │ │ │ │ - dictionary_type& ddiicctt (); │ │ │ │ - entry const& ooppeerraattoorr[[]] (string_view key) const; │ │ │ │ - entry& ooppeerraattoorr[[]] (string_view key); │ │ │ │ - entry* ffiinndd__kkeeyy (string_view key); │ │ │ │ - entry const* ffiinndd__kkeeyy (string_view key) const; │ │ │ │ - std::string ttoo__ssttrriinngg (bool single_line = false) const; │ │ │ │ +************ bbddeeccooddee__nnooddee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ +Sometimes it's important to get a non-owning reference to the root node ( to be │ │ │ │ +able to copy it as a reference for instance). For that, use the _n_o_n___o_w_n_i_n_g_(_) │ │ │ │ +member function. │ │ │ │ +There are 5 different types of nodes, see _t_y_p_e___t. │ │ │ │ +struct bdecode_node │ │ │ │ +{ │ │ │ │ + bbddeeccooddee__nnooddee () = default; │ │ │ │ + bbddeeccooddee__nnooddee (bdecode_node const&); │ │ │ │ + bdecode_node& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ + bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ + bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ + type_t ttyyppee () const noexcept; │ │ │ │ + explicit operator bbooooll () const noexcept; │ │ │ │ + bdecode_node nnoonn__oowwnniinngg () const; │ │ │ │ + std::ptrdiff_t ddaattaa__ooffffsseett () const noexcept; │ │ │ │ + span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ + std::int64_t lliisstt__iinntt__vvaalluuee__aatt (int i │ │ │ │ + , std::int64_t default_val = 0) const; │ │ │ │ + bdecode_node lliisstt__aatt (int i) const; │ │ │ │ + string_view lliisstt__ssttrriinngg__vvaalluuee__aatt (int i │ │ │ │ + , string_view default_val = string_view()) const; │ │ │ │ + int lliisstt__ssiizzee () const; │ │ │ │ + bdecode_node ddiicctt__ffiinndd (string_view key) const; │ │ │ │ + std::int64_t ddiicctt__ffiinndd__iinntt__vvaalluuee (string_view key │ │ │ │ + , std::int64_t default_val = 0) const; │ │ │ │ + bdecode_node ddiicctt__ffiinndd__ddiicctt (string_view key) const; │ │ │ │ + bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ + std::pair ddiicctt__aatt__nnooddee (int i) const; │ │ │ │ + int ddiicctt__ssiizzee () const; │ │ │ │ + bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ + std::pair ddiicctt__aatt (int i) const; │ │ │ │ + string_view ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee (string_view key │ │ │ │ + , string_view default_value = string_view()) const; │ │ │ │ + bdecode_node ddiicctt__ffiinndd__lliisstt (string_view key) const; │ │ │ │ + std::int64_t iinntt__vvaalluuee () const; │ │ │ │ + string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ + int ssttrriinngg__lleennggtthh () const; │ │ │ │ + std::ptrdiff_t ssttrriinngg__ooffffsseett () const; │ │ │ │ + char const* ssttrriinngg__ppttrr () const; │ │ │ │ + void cclleeaarr (); │ │ │ │ + void sswwaapp (bdecode_node& n); │ │ │ │ + void rreesseerrvvee (int tokens); │ │ │ │ + void sswwiittcchh__uunnddeerrllyyiinngg__bbuuffffeerr (char const* buf) noexcept; │ │ │ │ + bool hhaass__ssoofftt__eerrrroorr (span error) const; │ │ │ │ │ │ │ │ - enum data_type │ │ │ │ + enum type_t │ │ │ │ { │ │ │ │ - int_t, │ │ │ │ - string_t, │ │ │ │ + none_t, │ │ │ │ + dict_t, │ │ │ │ list_t, │ │ │ │ - dictionary_t, │ │ │ │ - preformatted_t, │ │ │ │ - undefined_t, │ │ │ │ + string_t, │ │ │ │ + int_t, │ │ │ │ }; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttyyppee(()) ********** │ │ │ │ -data_type ttyyppee () const; │ │ │ │ -returns the concrete type of the _e_n_t_r_y │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennttrryy(()) ********** │ │ │ │ -eennttrryy (preformatted_type); │ │ │ │ -eennttrryy (integer_type); │ │ │ │ -eennttrryy (span); │ │ │ │ -eennttrryy (dictionary_type); │ │ │ │ -eennttrryy (string_view); │ │ │ │ -eennttrryy (list_type); │ │ │ │ -eennttrryy (string_type); │ │ │ │ -constructors directly from a specific type. The content of the argument is │ │ │ │ -copied into the newly constructed _e_n_t_r_y │ │ │ │ +********** bbddeeccooddee__nnooddee(()) ********** │ │ │ │ +bbddeeccooddee__nnooddee () = default; │ │ │ │ +creates a default constructed node, it will have the type none_t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennttrryy(()) ********** │ │ │ │ -eennttrryy (data_type t); │ │ │ │ -construct an empty _e_n_t_r_y of the specified type. see _d_a_t_a___t_y_p_e enum. │ │ │ │ +********** ooppeerraattoorr==(()) bbddeeccooddee__nnooddee(()) ********** │ │ │ │ +bbddeeccooddee__nnooddee (bdecode_node const&); │ │ │ │ +bdecode_node& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ +bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ +bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ +For owning nodes, the copy will create a copy of the tree, but the underlying │ │ │ │ +buffer remains the same. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennttrryy(()) ********** │ │ │ │ -eennttrryy (bdecode_node const& n); │ │ │ │ -construct from _b_d_e_c_o_d_e___n_o_d_e parsed form (see _b_d_e_c_o_d_e_(_)) │ │ │ │ +********** ttyyppee(()) ********** │ │ │ │ +type_t ttyyppee () const noexcept; │ │ │ │ +the type of this node. See _t_y_p_e___t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) ********** │ │ │ │ -entry& ooppeerraattoorr== (integer_type) &; │ │ │ │ -entry& ooppeerraattoorr== (dictionary_type) &; │ │ │ │ -entry& ooppeerraattoorr== (entry&&) & ; │ │ │ │ -entry& ooppeerraattoorr== (string_type) &; │ │ │ │ -entry& ooppeerraattoorr== (preformatted_type) &; │ │ │ │ -entry& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ -entry& ooppeerraattoorr== (span) &; │ │ │ │ -entry& ooppeerraattoorr== (list_type) &; │ │ │ │ -entry& ooppeerraattoorr== (entry const&) &; │ │ │ │ -entry& ooppeerraattoorr== (string_view) &; │ │ │ │ -copies the structure of the right hand side into this _e_n_t_r_y. │ │ │ │ +********** bbooooll(()) ********** │ │ │ │ +explicit operator bbooooll () const noexcept; │ │ │ │ +returns true if _t_y_p_e_(_) != none_t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddiicctt(()) iinntteeggeerr(()) ssttrriinngg(()) pprreeffoorrmmaatttteedd(()) lliisstt(()) ********** │ │ │ │ -list_type const& lliisstt () const; │ │ │ │ -preformatted_type const& pprreeffoorrmmaatttteedd () const; │ │ │ │ -string_type const& ssttrriinngg () const; │ │ │ │ -integer_type const& iinntteeggeerr () const; │ │ │ │ -string_type& ssttrriinngg (); │ │ │ │ -list_type& lliisstt (); │ │ │ │ -dictionary_type const& ddiicctt () const; │ │ │ │ -integer_type& iinntteeggeerr (); │ │ │ │ -preformatted_type& pprreeffoorrmmaatttteedd (); │ │ │ │ -dictionary_type& ddiicctt (); │ │ │ │ -The integer(), string(), list(), dict() and preformatted() functions are │ │ │ │ -accessors that return the respective type. If the entry object isn't of the │ │ │ │ -type you request, the accessor will throw system_error. You can ask an entry │ │ │ │ -for its type through the type() function. │ │ │ │ -If you want to create an entry you give it the type you want it to have in its │ │ │ │ -constructor, and then use one of the non-const accessors to get a reference │ │ │ │ -which you then can assign the value you want it to have. │ │ │ │ -The typical code to get info from a torrent file will then look like this: │ │ │ │ -entry torrent_file; │ │ │ │ -// ... │ │ │ │ - │ │ │ │ -// throws if this is not a dictionary │ │ │ │ -entry::dictionary_type const& dict = torrent_file.dict(); │ │ │ │ -entry::dictionary_type::const_iterator i; │ │ │ │ -i = dict.find("announce"); │ │ │ │ -if (i != dict.end()) │ │ │ │ -{ │ │ │ │ - std::string tracker_url = i->second.string(); │ │ │ │ - std::cout << tracker_url << "\n"; │ │ │ │ -} │ │ │ │ -The following code is equivalent, but a little bit shorter: │ │ │ │ -entry torrent_file; │ │ │ │ -// ... │ │ │ │ - │ │ │ │ -// throws if this is not a dictionary │ │ │ │ -if (entry* i = torrent_file.find_key("announce")) │ │ │ │ -{ │ │ │ │ - std::string tracker_url = i->string(); │ │ │ │ - std::cout << tracker_url << "\n"; │ │ │ │ -} │ │ │ │ -To make it easier to extract information from a torrent file, the class │ │ │ │ -_t_o_r_r_e_n_t___i_n_f_o exists. │ │ │ │ +********** nnoonn__oowwnniinngg(()) ********** │ │ │ │ +bdecode_node nnoonn__oowwnniinngg () const; │ │ │ │ +return a non-owning reference to this node. This is useful to refer to the root │ │ │ │ +node without copying it in assignments. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr[[]](()) ********** │ │ │ │ -entry const& ooppeerraattoorr[[]] (string_view key) const; │ │ │ │ -entry& ooppeerraattoorr[[]] (string_view key); │ │ │ │ -All of these functions requires the _e_n_t_r_y to be a dictionary, if it isn't they │ │ │ │ -will throw system_error. │ │ │ │ -The non-const versions of the operator[] will return a reference to either the │ │ │ │ -existing element at the given key or, if there is no element with the given │ │ │ │ -key, a reference to a newly inserted element at that key. │ │ │ │ -The const version of operator[] will only return a reference to an existing │ │ │ │ -element at the given key. If the key is not found, it will throw system_error. │ │ │ │ +********** ddaattaa__sseeccttiioonn(()) ddaattaa__ooffffsseett(()) ********** │ │ │ │ +std::ptrdiff_t ddaattaa__ooffffsseett () const noexcept; │ │ │ │ +span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ +returns the buffer and length of the section in the original bencoded buffer │ │ │ │ +where this node is defined. For a dictionary for instance, this starts with d │ │ │ │ +and ends with e, and has all the content of the dictionary in between. the │ │ │ │ +data_offset() function returns the byte-offset to this node in, starting from │ │ │ │ +the beginning of the buffer that was parsed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinndd__kkeeyy(()) ********** │ │ │ │ -entry* ffiinndd__kkeeyy (string_view key); │ │ │ │ -entry const* ffiinndd__kkeeyy (string_view key) const; │ │ │ │ -These functions requires the _e_n_t_r_y to be a dictionary, if it isn't they will │ │ │ │ -throw system_error. │ │ │ │ -They will look for an element at the given key in the dictionary, if the │ │ │ │ -element cannot be found, they will return nullptr. If an element with the given │ │ │ │ -key is found, the return a pointer to it. │ │ │ │ +********** lliisstt__iinntt__vvaalluuee__aatt(()) lliisstt__aatt(()) lliisstt__ssttrriinngg__vvaalluuee__aatt(()) lliisstt__ssiizzee(()) ********** │ │ │ │ +std::int64_t lliisstt__iinntt__vvaalluuee__aatt (int i │ │ │ │ + , std::int64_t default_val = 0) const; │ │ │ │ +bdecode_node lliisstt__aatt (int i) const; │ │ │ │ +string_view lliisstt__ssttrriinngg__vvaalluuee__aatt (int i │ │ │ │ + , string_view default_val = string_view()) const; │ │ │ │ +int lliisstt__ssiizzee () const; │ │ │ │ +functions with the list_ prefix operate on lists. These functions are only │ │ │ │ +valid if type() == list_t. list_at() returns the item in the list at index i. i │ │ │ │ +may not be greater than or equal to the size of the list. list_size() returns │ │ │ │ +the size of the list. list_int_value_at() and list_string_value_at() return the │ │ │ │ +integer or string value of the item at index i directly. If that item is not of │ │ │ │ +the requested type, the provided default_val is returned instead. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttoo__ssttrriinngg(()) ********** │ │ │ │ -std::string ttoo__ssttrriinngg (bool single_line = false) const; │ │ │ │ -returns a pretty-printed string representation of the bencoded structure, with │ │ │ │ -JSON-style syntax │ │ │ │ +********** ddiicctt__aatt(()) ddiicctt__ffiinndd__ddiicctt(()) ddiicctt__ssiizzee(()) ddiicctt__ffiinndd(()) ddiicctt__ffiinndd__ssttrriinngg(()) │ │ │ │ +ddiicctt__aatt__nnooddee(()) ddiicctt__ffiinndd__iinntt(()) ddiicctt__ffiinndd__iinntt__vvaalluuee(()) ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee(()) │ │ │ │ +ddiicctt__ffiinndd__lliisstt(()) ********** │ │ │ │ +bdecode_node ddiicctt__ffiinndd (string_view key) const; │ │ │ │ +std::int64_t ddiicctt__ffiinndd__iinntt__vvaalluuee (string_view key │ │ │ │ + , std::int64_t default_val = 0) const; │ │ │ │ +bdecode_node ddiicctt__ffiinndd__ddiicctt (string_view key) const; │ │ │ │ +bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ +std::pair ddiicctt__aatt__nnooddee (int i) const; │ │ │ │ +int ddiicctt__ssiizzee () const; │ │ │ │ +bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ +std::pair ddiicctt__aatt (int i) const; │ │ │ │ +string_view ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee (string_view key │ │ │ │ + , string_view default_value = string_view()) const; │ │ │ │ +bdecode_node ddiicctt__ffiinndd__lliisstt (string_view key) const; │ │ │ │ +Functions with the dict_ prefix operates on dictionaries. They are only valid │ │ │ │ +if type() == dict_t. In case a key you're looking up contains a 0 byte, you │ │ │ │ +cannot use the 0-terminated string overloads, but have to use string_view │ │ │ │ +instead. dict_find_list will return a valid bdecode_node if the key is found │ │ │ │ +_and_ it is a list. Otherwise it will return a default-constructed │ │ │ │ +_b_d_e_c_o_d_e___n_o_d_e. │ │ │ │ +Functions with the _value suffix return the value of the node directly, rather │ │ │ │ +than the nodes. In case the node is not found, or it has a different type, a │ │ │ │ +default value is returned (which can be specified). │ │ │ │ +dict_at() returns the (key, value)-pair at the specified index in a dictionary. │ │ │ │ +Keys are only allowed to be strings. dict_at_node() also returns the (key, │ │ │ │ +value)-pair, but the key is returned as a bdecode_node (and it will always be a │ │ │ │ +string). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ddaattaa__ttyyppee ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_n_t_r_y_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_i_n_t___t_ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_t_r_i_n_g___t_ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_l_i_s_t___t_ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_i_c_t_i_o_n_a_r_y___t_ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_r_e_f_o_r_m_a_t_t_e_d___t_|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_n_d_e_f_i_n_e_d___t_ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** iinntt__vvaalluuee(()) ********** │ │ │ │ +std::int64_t iinntt__vvaalluuee () const; │ │ │ │ +this function is only valid if type() == int_t. It returns the value of the │ │ │ │ +integer. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ooppeerraattoorr<<<<(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_n_t_r_y_._h_p_p" │ │ │ │ -inline std::ostream& ooppeerraattoorr<<<< (std::ostream& os, const entry& e); │ │ │ │ -prints the bencoded structure to the ostream as a JSON-style structure. │ │ │ │ +********** ssttrriinngg__ooffffsseett(()) ssttrriinngg__vvaalluuee(()) ssttrriinngg__lleennggtthh(()) ssttrriinngg__ppttrr(()) ********** │ │ │ │ +string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ +int ssttrriinngg__lleennggtthh () const; │ │ │ │ +std::ptrdiff_t ssttrriinngg__ooffffsseett () const; │ │ │ │ +char const* ssttrriinngg__ppttrr () const; │ │ │ │ +these functions are only valid if type() == string_t. They return the string │ │ │ │ +values. Note that string_ptr() is nnoott 0-terminated. string_length() returns the │ │ │ │ +number of bytes in the string. string_offset() returns the byte offset from the │ │ │ │ +start of the parsed bencoded buffer this string can be found. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bbeennccooddee(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_e_n_c_o_d_e_._h_p_p" │ │ │ │ -template int bbeennccooddee (OutIt out, const entry& e); │ │ │ │ -std::vector bbeennccooddee (entry const& e); │ │ │ │ -The bencode() function has two overloads that serializes a tree structure of │ │ │ │ -_e_n_t_r_y objects into a bencoded, flat, buffer. The _e_n_t_r_y class is the internal │ │ │ │ -representation of the bencoded data. │ │ │ │ -The simplest overload simply takes an _e_n_t_r_y object and returns a vector with │ │ │ │ -the serialized data. │ │ │ │ -The second overload encode it into the OutIt iterator. │ │ │ │ -OutIt is an _O_u_t_p_u_t_I_t_e_r_a_t_o_r. It's a template and usually instantiated as │ │ │ │ -_o_s_t_r_e_a_m___i_t_e_r_a_t_o_r or _b_a_c_k___i_n_s_e_r_t___i_t_e_r_a_t_o_r. This function assumes the value_type │ │ │ │ -of the iterator is a char. In order to encode _e_n_t_r_y e into a buffer, do: │ │ │ │ -std::vector buf; │ │ │ │ -bencode(std::back_inserter(buf), e); │ │ │ │ -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 │ │ │ │ - etc. │ │ │ │ - 3. Read through all the files in the torrent, SHA-1 all the data and set the │ │ │ │ - piece hashes. │ │ │ │ - 4. The torrent is bencoded into a file or buffer. │ │ │ │ -If there are a lot of files and or deep directory hierarchies to traverse, step │ │ │ │ -one can be time consuming. │ │ │ │ -Typically step 3 is by far the most time consuming step, since it requires to │ │ │ │ -read all the bytes from all the files in the torrent. │ │ │ │ -All of these classes and functions are declared by including libtorrent/ │ │ │ │ -create_torrent.hpp. │ │ │ │ -example: │ │ │ │ -// recursively create a list of all files in the directory │ │ │ │ -auto fs = list_files("./my_torrent"); │ │ │ │ - │ │ │ │ -create_torrent t(std::move(fs)); │ │ │ │ -t.add_tracker("http://my.tracker.com/announce"); │ │ │ │ -t.set_creator("libtorrent example"); │ │ │ │ - │ │ │ │ -// reads the files and calculates the hashes │ │ │ │ -set_piece_hashes(t, "."); │ │ │ │ - │ │ │ │ -ofstream out("my_torrent.torrent", std::ios_base::binary); │ │ │ │ -std::vector buf = t.generate_buf(); │ │ │ │ -out.write(buf.data(), buf.size()); │ │ │ │ - │ │ │ │ -// alternatively, generate an entry and encode it directly to an ostream │ │ │ │ -// iterator │ │ │ │ -bencode(std::ostream_iterator(out), t.generate()); │ │ │ │ +********** cclleeaarr(()) ********** │ │ │ │ +void cclleeaarr (); │ │ │ │ +resets the bdecoded_node to a default constructed state. If this is an owning │ │ │ │ +node, the tree is freed and all child nodes are invalidated. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ccrreeaattee__ffiillee__eennttrryy ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ -This represents one file in the torrent file to be created │ │ │ │ -struct create_file_entry │ │ │ │ -{ │ │ │ │ - ccrreeaattee__ffiillee__eennttrryy (std::string fn, std::int64_t const sz │ │ │ │ - , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = │ │ │ │ -{}); │ │ │ │ - │ │ │ │ - std::string filename; │ │ │ │ - std::int64_t size; │ │ │ │ - file_flags_t flags; │ │ │ │ - std::time_t mtime; │ │ │ │ - std::string symlink; │ │ │ │ -}; │ │ │ │ +********** sswwaapp(()) ********** │ │ │ │ +void sswwaapp (bdecode_node& n); │ │ │ │ +Swap contents. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccrreeaattee__ffiillee__eennttrryy(()) ********** │ │ │ │ -ccrreeaattee__ffiillee__eennttrryy (std::string fn, std::int64_t const sz │ │ │ │ - , file_flags_t const f = {}, std::time_t const ts = 0, std::string sl = │ │ │ │ -{}); │ │ │ │ -construct a file _e_n_t_r_y for the file at relative path fn with size sz. f is the │ │ │ │ -set of file flags that applies to the file, see file_flags_t. ts is an optional │ │ │ │ -modification time (0 to omit). sl is the symlink target, only used when f │ │ │ │ -includes the symlink flag. Symlinks are only allowed to target other files or │ │ │ │ -directories in the torrent. │ │ │ │ +********** rreesseerrvvee(()) ********** │ │ │ │ +void rreesseerrvvee (int tokens); │ │ │ │ +preallocate memory for the specified numbers of tokens. This is useful if you │ │ │ │ +know approximately how many tokens are in the file you are about to parse. │ │ │ │ +Doing so will save realloc operations while parsing. You should only call this │ │ │ │ +on the root node, before passing it in to _b_d_e_c_o_d_e_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - filename │ │ │ │ - the path and name of the file. The path is relative to the root of the │ │ │ │ - torrent file. │ │ │ │ +********** sswwiittcchh__uunnddeerrllyyiinngg__bbuuffffeerr(()) ********** │ │ │ │ +void sswwiittcchh__uunnddeerrllyyiinngg__bbuuffffeerr (char const* buf) noexcept; │ │ │ │ +this buffer MMUUSSTT be identical to the one originally parsed. This operation is │ │ │ │ +only defined on owning root nodes, i.e. the one passed in to decode(). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - size │ │ │ │ - the size of the file │ │ │ │ +********** hhaass__ssoofftt__eerrrroorr(()) ********** │ │ │ │ +bool hhaass__ssoofftt__eerrrroorr (span error) const; │ │ │ │ +returns true if there is a non-fatal error in the bencoding of this node or its │ │ │ │ +children │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - flags │ │ │ │ - bitmask of file_flags_t (pad-file, hidden, executable, symlink) for this │ │ │ │ - file. │ │ │ │ +********** eennuumm ttyyppee__tt ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|none_t |0 |uninitialized or default constructed. This is also used to| │ │ │ │ +|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_d_i_c_a_t_e_ _t_h_a_t_ _a_ _n_o_d_e_ _w_a_s_ _n_o_t_ _f_o_u_n_d_ _i_n_ _s_o_m_e_ _c_a_s_e_s_._ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_i_c_t___t_ _ _|_1_ _ _ _ _|_a_ _d_i_c_t_i_o_n_a_r_y_ _n_o_d_e_._ _T_h_e_ _d_i_c_t___f_i_n_d___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ | │ │ │ │ +|_l_i_s_t___t_ _ _|_2_ _ _ _ _|_a_ _l_i_s_t_ _n_o_d_e_._ _T_h_e_ _l_i_s_t___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_t_r_i_n_g___t_|_3_ _ _ _ _|_a_ _s_t_r_i_n_g_ _n_o_d_e_,_ _t_h_e_ _s_t_r_i_n_g___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_t___t_ _ _ _|_4_ _ _ _ _|_a_n_ _i_n_t_e_g_e_r_ _n_o_d_e_._ _T_h_e_ _i_n_t___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - mtime │ │ │ │ - optional modification time of the file. 0 means "do not record". │ │ │ │ +************ pprriinntt__eennttrryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ +std::string pprriinntt__eennttrryy (bdecode_node const& e │ │ │ │ + , bool single_line = false, int indent = 0); │ │ │ │ +print the bencoded structure in a human-readable format to a string that's │ │ │ │ +returned. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - symlink │ │ │ │ - the link target, only considered if the symlink flag is set │ │ │ │ +************ bbddeeccooddee(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ +int bbddeeccooddee (char const* start, char const* end, bdecode_node& ret │ │ │ │ + , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 │ │ │ │ + , int token_limit = 2000000); │ │ │ │ +bdecode_node bbddeeccooddee (span buffer │ │ │ │ + , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 │ │ │ │ + , int token_limit = 2000000); │ │ │ │ +bdecode_node bbddeeccooddee (span buffer │ │ │ │ + , int depth_limit = 100, int token_limit = 2000000); │ │ │ │ +This function decodes/parses bdecoded data (for example a .torrent file). The │ │ │ │ +data structure is returned in the ret argument. the buffer to parse is │ │ │ │ +specified by the start of the buffer as well as the end, i.e. one byte past the │ │ │ │ +end. If the buffer fails to parse, the function returns a non-zero value and │ │ │ │ +fills in ec with the error code. The optional argument error_pos, if set to │ │ │ │ +non-nullptr, will be set to the byte offset into the buffer where the parse │ │ │ │ +failure occurred. │ │ │ │ +depth_limit specifies the max number of nested lists or dictionaries are │ │ │ │ +allowed in the data structure. (This affects the stack usage of the function, │ │ │ │ +be careful not to set it too high). │ │ │ │ +token_limit is the max number of tokens allowed to be parsed from the buffer. │ │ │ │ +This is simply a sanity check to not have unbounded memory usage. │ │ │ │ +The resulting bdecode_node is an oowwnniinngg node. That means it will be holding the │ │ │ │ +whole parsed tree. When iterating lists and dictionaries, those bdecode_node │ │ │ │ +objects will simply have references to the root or owning bdecode_node. If the │ │ │ │ +root node is destructed, all other nodes that refer to anything in that tree │ │ │ │ +become invalid. │ │ │ │ +However, the underlying buffer passed in to this function (start, end) must │ │ │ │ +also remain valid while the bdecoded tree is used. The parsed tree produced by │ │ │ │ +this function does not copy any data out of the buffer, but simply produces │ │ │ │ +references back into it. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ccrreeaattee__ttoorrrreenntt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ -This class holds state for creating a torrent. After having added all │ │ │ │ -information to it, call _c_r_e_a_t_e___t_o_r_r_e_n_t_:_:_g_e_n_e_r_a_t_e_(_) to generate the torrent. The │ │ │ │ -_e_n_t_r_y that's returned can then be bencoded into a .torrent file using _b_e_n_c_o_d_e │ │ │ │ -_(_). │ │ │ │ -struct create_torrent │ │ │ │ +************ ssttoorraaggee__eerrrroorr ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ +used by storage to return errors also includes which underlying file the error │ │ │ │ +happened on │ │ │ │ +struct storage_error │ │ │ │ { │ │ │ │ - explicit ccrreeaattee__ttoorrrreenntt (std::vector files, int │ │ │ │ -piece_size = 0 │ │ │ │ - , create_flags_t flags = {}); │ │ │ │ - entry ggeenneerraattee () const; │ │ │ │ - std::vector ggeenneerraattee__bbuuff () 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); │ │ │ │ - void aadddd__nnooddee (std::pair node); │ │ │ │ - void aadddd__ttrraacckkeerr (string_view url, int tier = 0); │ │ │ │ - void sseett__rroooott__cceerrtt (string_view cert); │ │ │ │ - void sseett__pprriivv (bool p); │ │ │ │ - bool pprriivv () const; │ │ │ │ - bool iiss__vv11__oonnllyy () const; │ │ │ │ - bool iiss__vv22__oonnllyy () const; │ │ │ │ - int nnuumm__ppiieecceess () const; │ │ │ │ - piece_index_t eenndd__ppiieeccee () const; │ │ │ │ - index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ - file_index_t eenndd__ffiillee () const; │ │ │ │ - index_range ffiillee__rraannggee () const noexcept; │ │ │ │ - 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); │ │ │ │ + explicit operator bbooooll () const; │ │ │ │ + void ffiillee (file_index_t f); │ │ │ │ + file_index_t ffiillee () const; │ │ │ │ │ │ │ │ - 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; │ │ │ │ - static inline constexpr create_flags_t ccaannoonniiccaall__ffiilleess__nnoo__ttaaiill__ppaaddddiinngg = │ │ │ │ -9_bit; │ │ │ │ + error_code ec; │ │ │ │ + operation_t operation; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccrreeaattee__ttoorrrreenntt(()) ********** │ │ │ │ -explicit ccrreeaattee__ttoorrrreenntt (std::vector files, int piece_size = │ │ │ │ -0 │ │ │ │ - , create_flags_t flags = {}); │ │ │ │ -The piece_size is the size of each piece in bytes. It must be a power of 2 and │ │ │ │ -a minimum of 16 kiB. If a piece size of 0 is specified, a piece_size will be │ │ │ │ -set automatically. Piece sizes greater than 128 MiB are considered unreasonable │ │ │ │ -and will be rejected (with an lt::system_error exception). │ │ │ │ -The flags arguments specifies options for the torrent creation. It can be any │ │ │ │ -combination of the flags defined by create_flags_t. │ │ │ │ -The files argument is a list of all files to be included in the torrent file. │ │ │ │ -If it has more than one file in it, all files must share a common root │ │ │ │ -directory (which will be the name of the torrent). │ │ │ │ -If files has a single file without any directory component (i.e. just a │ │ │ │ -filename) it will create a single file torrent. If it has a directory path, it │ │ │ │ -will create a multi-file torrent with a single file. This is in order to │ │ │ │ -preserve the directory path. │ │ │ │ -********** ddeepprreeccaatteedd oovveerrllooaaddss ********** │ │ │ │ -There are two deprecated constructors that take a _f_i_l_e___s_t_o_r_a_g_e object and a │ │ │ │ -_t_o_r_r_e_n_t___i_n_f_o object respectively. │ │ │ │ -The _f_i_l_e___s_t_o_r_a_g_e (fs) parameter defines the files, sizes and their properties │ │ │ │ -for the torrent to be created. Set this up first, before passing it to the │ │ │ │ -_c_r_e_a_t_e___t_o_r_r_e_n_t constructor. Instead of using this overload, consider using the │ │ │ │ -overload taking a vector of _c_r_e_a_t_e___f_i_l_e___e_n_t_r_y objects instead. It is more │ │ │ │ -efficient. │ │ │ │ -The overload that takes a torrent_info object will make a verbatim copy of its │ │ │ │ -info dictionary (to preserve the info-hash). The copy of the info dictionary │ │ │ │ -will be used by _c_r_e_a_t_e___t_o_r_r_e_n_t_:_:_g_e_n_e_r_a_t_e_(_). This means that none of the member │ │ │ │ -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. │ │ │ │ +********** bbooooll(()) ********** │ │ │ │ +explicit operator bbooooll () const; │ │ │ │ +explicitly converts to true if this object represents an error, and false if it │ │ │ │ +does not. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeenneerraattee__bbuuff(()) ggeenneerraattee(()) ********** │ │ │ │ -entry ggeenneerraattee () const; │ │ │ │ -std::vector ggeenneerraattee__bbuuff () const; │ │ │ │ -This function will generate the .torrent file as a bencode tree, or a bencoded │ │ │ │ -into a buffer. In order to encode the _e_n_t_r_y into a flat file, use the _b_e_n_c_o_d_e_(_) │ │ │ │ -function. │ │ │ │ -The function returning an _e_n_t_r_y may be useful to add custom entries to the │ │ │ │ -torrent file before bencoding it and saving it to disk. │ │ │ │ -Whether the resulting torrent object is v1, v2 or hybrid depends on whether any │ │ │ │ -of the v1_only or v2_only flags were set on the constructor. If neither were │ │ │ │ -set, the resulting torrent depends on which hashes were set. If both v1 and v2 │ │ │ │ -hashes were set, a hybrid torrent is created. │ │ │ │ -Any failure will cause this function to throw system_error, with an appropriate │ │ │ │ -error message. These are the reasons this call may throw: │ │ │ │ - * the file storage has 0 files │ │ │ │ - * the total size of the file storage is 0 bytes (i.e. it only has empty │ │ │ │ - files) │ │ │ │ - * not all v1 hashes (_s_e_t___h_a_s_h_(_)) and not all v2 hashes (_s_e_t___h_a_s_h_2_(_)) were │ │ │ │ - set │ │ │ │ - * for v2 torrents, you may not have a directory with the same name as a │ │ │ │ - file. If that's encountered in the file storage, _g_e_n_e_r_a_t_e_(_) fails. │ │ │ │ +********** ffiillee(()) ********** │ │ │ │ +void ffiillee (file_index_t f); │ │ │ │ +file_index_t ffiillee () const; │ │ │ │ +set and query the index (in the torrent) of the file this error occurred on. │ │ │ │ +This may also have special values defined in _t_o_r_r_e_n_t___s_t_a_t_u_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ccoommmmeenntt(()) ********** │ │ │ │ -void sseett__ccoommmmeenntt (char const* str); │ │ │ │ -Sets the comment for the torrent. The string str should be utf-8 encoded. The │ │ │ │ -comment in a torrent file is optional. │ │ │ │ + ec │ │ │ │ + the error that occurred │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ccrreeaattoorr(()) ********** │ │ │ │ -void sseett__ccrreeaattoorr (char const* str); │ │ │ │ -Sets the creator of the torrent. The string str should be utf-8 encoded. This │ │ │ │ -is optional. │ │ │ │ + operation │ │ │ │ + A code from _o_p_e_r_a_t_i_o_n___t enum, indicating what kind of operation failed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__ccrreeaattiioonn__ddaattee(()) ********** │ │ │ │ -void sseett__ccrreeaattiioonn__ddaattee (std::time_t timestamp); │ │ │ │ -sets the "creation time" field. Defaults to the system clock at the time of │ │ │ │ -construction of the _c_r_e_a_t_e___t_o_r_r_e_n_t object. The timestamp is specified in │ │ │ │ -seconds, posix time. If the creation date is set to 0, the "creation date" │ │ │ │ -field will be omitted from the generated torrent. │ │ │ │ +************ ppccpp__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_n_a_t_p_m_p_._h_p_p" │ │ │ │ +boost::system::error_category& ppccpp__ccaatteeggoorryy (); │ │ │ │ +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. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__hhaasshh(()) ********** │ │ │ │ -void sseett__hhaasshh (piece_index_t index, sha1_hash const& h); │ │ │ │ -This sets the SHA-1 hash for the specified piece (index). You are required to │ │ │ │ -set the hash for every piece in the torrent before generating it. If you have │ │ │ │ -the files on disk, you can use the high level convenience function to do this. │ │ │ │ -See _s_e_t___p_i_e_c_e___h_a_s_h_e_s_(_). A SHA-1 hash of all zeros is internally used to │ │ │ │ -indicate a hash that has not been set. Setting such hash will not be considered │ │ │ │ -set when calling _g_e_n_e_r_a_t_e_(_). This function will throw std::system_error if it │ │ │ │ -is called on an object constructed with the v2_only flag. │ │ │ │ +************ uuppnnpp__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_u_p_n_p_._h_p_p" │ │ │ │ +boost::system::error_category& uuppnnpp__ccaatteeggoorryy (); │ │ │ │ +the boost.system error category for UPnP errors │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__hhaasshh22(()) ********** │ │ │ │ -void sseett__hhaasshh22 (file_index_t file, piece_index_t::diff_type piece, sha256_hash │ │ │ │ -const& h); │ │ │ │ -sets the bittorrent v2 hash for filefileof the piecepiece.pieceis relative to │ │ │ │ -the first piece of the file, starting at 0. The first piece in the file can be │ │ │ │ -computed with _f_i_l_e___s_t_o_r_a_g_e_:_:_f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_). The hash,h, is the root of │ │ │ │ -the merkle tree formed by the piece's 16 kiB blocks. Note that piece sizes must │ │ │ │ -be powers-of-2, so all per-piece merkle trees are complete. A SHA-256 hash of │ │ │ │ -all zeros is internally used to indicate a hash that has not been set. Setting │ │ │ │ -such hash will not be considered set when calling _g_e_n_e_r_a_t_e_(_). This function │ │ │ │ -will throw std::system_error if it is called on an object constructed with the │ │ │ │ -v1_only flag. │ │ │ │ +************ ssoocckkss__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_s_5___s_t_r_e_a_m_._h_p_p" │ │ │ │ +boost::system::error_category& ssoocckkss__ccaatteeggoorryy (); │ │ │ │ +returns the error_category for SOCKS5 errors │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__uurrll__sseeeedd(()) ********** │ │ │ │ -void aadddd__uurrll__sseeeedd (string_view url); │ │ │ │ -This adds a url seed to the torrent. You can have any number of url seeds. For │ │ │ │ -a single file torrent, this should be an HTTP url, pointing to a file with │ │ │ │ -identical content as the file of the torrent. For a multi-file torrent, it │ │ │ │ -should point to a directory containing a directory with the same name as this │ │ │ │ -torrent, and all the files of the torrent in it. │ │ │ │ +************ ggzziipp__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_g_z_i_p_._h_p_p" │ │ │ │ +boost::system::error_category& ggzziipp__ccaatteeggoorryy (); │ │ │ │ +get the error_category for zip errors │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__nnooddee(()) ********** │ │ │ │ -void aadddd__nnooddee (std::pair node); │ │ │ │ -This adds a DHT node to the torrent. This especially useful if you're creating │ │ │ │ -a tracker less torrent. It can be used by clients to bootstrap their DHT node │ │ │ │ -from. The node is a hostname and a port number where there is a DHT node │ │ │ │ -running. You can have any number of DHT nodes in a torrent. │ │ │ │ +************ ii22pp__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_2_p___s_t_r_e_a_m_._h_p_p" │ │ │ │ +boost::system::error_category& ii22pp__ccaatteeggoorryy (); │ │ │ │ +returns the error category for I2P errors │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ttrraacckkeerr(()) ********** │ │ │ │ -void aadddd__ttrraacckkeerr (string_view url, int tier = 0); │ │ │ │ -Adds a tracker to the torrent. This is not strictly required, but most torrents │ │ │ │ -use a tracker as their main source of peers. The url should be an _h_t_t_p_:_/_/ or │ │ │ │ -udp:// url to a machine running a bittorrent tracker that accepts announces for │ │ │ │ -this torrent's info-hash. The tier is the fallback priority of the tracker. All │ │ │ │ -trackers with tier 0 are tried first (in any order). If all fail, trackers with │ │ │ │ -tier 1 are tried. If all of those fail, trackers with tier 2 are tried, and so │ │ │ │ -on. │ │ │ │ +************ bbddeeccooddee__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ +boost::system::error_category& bbddeeccooddee__ccaatteeggoorryy (); │ │ │ │ +returns the boost::system::error_category used for the bdecode_errors:: │ │ │ │ +error_code_enum errors. error_code objects produced by bdecode() use this │ │ │ │ +category. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__rroooott__cceerrtt(()) ********** │ │ │ │ -void sseett__rroooott__cceerrtt (string_view cert); │ │ │ │ -This function sets an X.509 certificate in PEM format to the torrent. This │ │ │ │ -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. │ │ │ │ +************ lliibbttoorrrreenntt__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ +boost::system::error_category& lliibbttoorrrreenntt__ccaatteeggoorryy (); │ │ │ │ +return the instance of the libtorrent_error_category which maps libtorrent │ │ │ │ +error codes to human readable error messages. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__pprriivv(()) pprriivv(()) ********** │ │ │ │ -void sseett__pprriivv (bool p); │ │ │ │ -bool pprriivv () const; │ │ │ │ -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. │ │ │ │ +************ hhttttpp__ccaatteeggoorryy(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ +boost::system::error_category& hhttttpp__ccaatteeggoorryy (); │ │ │ │ +returns the error_category for HTTP errors │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iiss__vv22__oonnllyy(()) iiss__vv11__oonnllyy(()) ********** │ │ │ │ -bool iiss__vv11__oonnllyy () const; │ │ │ │ -bool iiss__vv22__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. │ │ │ │ +************ eennuumm ppccpp__eerrrroorrss ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_n_a_t_p_m_p_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_p_c_p___s_u_c_c_e_s_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___u_n_s_u_p_p___v_e_r_s_i_o_n_ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___n_o_t___a_u_t_h_o_r_i_z_e_d_ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___m_a_l_f_o_r_m_e_d___r_e_q_u_e_s_t_ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___u_n_s_u_p_p___o_p_c_o_d_e_ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___u_n_s_u_p_p___o_p_t_i_o_n_ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___m_a_l_f_o_r_m_e_d___o_p_t_i_o_n_ _ _ _ _ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___n_e_t_w_o_r_k___f_a_i_l_u_r_e_ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___n_o___r_e_s_o_u_r_c_e_s_ _ _ _ _ _ _ _ _ _ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___u_n_s_u_p_p___p_r_o_t_o_c_o_l_ _ _ _ _ _ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___u_s_e_r___e_x___q_u_o_t_a_ _ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___c_a_n_n_o_t___p_r_o_v_i_d_e___e_x_t_e_r_n_a_l_|_1_1_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___a_d_d_r_e_s_s___m_i_s_m_a_t_c_h_ _ _ _ _ _ _ _|_1_2_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_c_p___e_x_c_e_s_s_i_v_e___r_e_m_o_t_e___p_e_e_r_s_ _|_1_3_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ppiieecceess(()) ********** │ │ │ │ -int nnuumm__ppiieecceess () const; │ │ │ │ -returns the number of pieces in the associated _f_i_l_e___s_t_o_r_a_g_e object. │ │ │ │ +************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_u_p_n_p_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_argument |402 |One of the arguments in the request | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_s_ _i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_a_c_t_i_o_n___f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_5_0_1_ _ _|_T_h_e_ _r_e_q_u_e_s_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|value_not_in_array |714 |The specified value does not exist | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_ _t_h_e_ _a_r_r_a_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The source IP address cannot be | │ │ │ │ +|source_ip_cannot_be_wildcarded |715 |wild-carded, but must be fully | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_p_e_c_i_f_i_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|external_port_cannot_be_wildcarded|716 |The external port cannot be a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_i_l_d_c_a_r_d_,_ _b_u_t_ _m_u_s_t_ _b_e_ _s_p_e_c_i_f_i_e_d_ _ _ _ _ | │ │ │ │ +| | |The port mapping _e_n_t_r_y specified | │ │ │ │ +|port_mapping_conflict |718 |conflicts with a mapping assigned | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_r_e_v_i_o_u_s_l_y_ _t_o_ _a_n_o_t_h_e_r_ _c_l_i_e_n_t_ _ _ _ _ _ _ _ | │ │ │ │ +|internal_port_must_match_external |724 |Internal and external port value | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_u_s_t_ _b_e_ _t_h_e_ _s_a_m_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The NAT implementation only supports| │ │ │ │ +|only_permanent_leases_supported |725 |permanent lease times on port | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_p_p_i_n_g_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |RemoteHost must be a wildcard and | │ │ │ │ +|remote_host_must_be_wildcard |726 |cannot be a specific IP address or | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_D_N_S_ _n_a_m_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|external_port_must_be_wildcard |727 |ExternalPort must be a wildcard and | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_n_n_o_t_ _b_e_ _a_ _s_p_e_c_i_f_i_c_ _p_o_r_t_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eenndd__ppiieeccee(()) ********** │ │ │ │ -piece_index_t eenndd__ppiieeccee () const; │ │ │ │ -one past-the-end piece index │ │ │ │ +************ eennuumm ssoocckkss__eerrrroorr__ccooddee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_s_5___s_t_r_e_a_m_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_n_s_u_p_p_o_r_t_e_d___v_e_r_s_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_n_s_u_p_p_o_r_t_e_d___a_u_t_h_e_n_t_i_c_a_t_i_o_n___m_e_t_h_o_d_ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_n_s_u_p_p_o_r_t_e_d___a_u_t_h_e_n_t_i_c_a_t_i_o_n___v_e_r_s_i_o_n_|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_a_u_t_h_e_n_t_i_c_a_t_i_o_n___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_s_e_r_n_a_m_e___r_e_q_u_i_r_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_g_e_n_e_r_a_l___f_a_i_l_u_r_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_c_o_m_m_a_n_d___n_o_t___s_u_p_p_o_r_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___i_d_e_n_t_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_d_e_n_t_d___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_u_m___e_r_r_o_r_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_0_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__rraannggee(()) ********** │ │ │ │ -index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ -all piece indices in the torrent to be created │ │ │ │ +************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_g_z_i_p_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_t_ _a_n_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_gzip_header |1 |the supplied gzip buffer has | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _h_e_a_d_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |the gzip buffer would inflate to | │ │ │ │ +|inflated_data_too_large |2 |more bytes than the specified | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_x_i_m_u_m_ _s_i_z_e_,_ _a_n_d_ _w_a_s_ _r_e_j_e_c_t_e_d_._ _ _ _ | │ │ │ │ +|data_did_not_terminate |3 |available inflate data did not | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_e_r_m_i_n_a_t_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|space_exhausted |4 |output space exhausted before | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_m_p_l_e_t_i_n_g_ _i_n_f_l_a_t_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___b_l_o_c_k___t_y_p_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_5_ _ _ _ _|_i_n_v_a_l_i_d_ _b_l_o_c_k_ _t_y_p_e_ _(_t_y_p_e_ _=_=_ _3_)_ _ _ _ _ | │ │ │ │ +|invalid_stored_block_length |6 |stored block length did not match | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_n_e_'_s_ _c_o_m_p_l_e_m_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|too_many_length_or_distance_codes |7 |dynamic block code description: too| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_a_n_y_ _l_e_n_g_t_h_ _o_r_ _d_i_s_t_a_n_c_e_ _c_o_d_e_s_ _ _ _ _ _ | │ │ │ │ +|code_lengths_codes_incomplete |8 |dynamic block code description: | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_d_e_ _l_e_n_g_t_h_s_ _c_o_d_e_s_ _i_n_c_o_m_p_l_e_t_e_ _ _ _ _ _ | │ │ │ │ +|repeat_lengths_with_no_first_length|9 |dynamic block code description: | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_p_e_a_t_ _l_e_n_g_t_h_s_ _w_i_t_h_ _n_o_ _f_i_r_s_t_ _l_e_n_g_t_h| │ │ │ │ +|repeat_more_than_specified_lengths |10 |dynamic block code description: | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_p_e_a_t_ _m_o_r_e_ _t_h_a_n_ _s_p_e_c_i_f_i_e_d_ _l_e_n_g_t_h_s_ | │ │ │ │ +|invalid_literal_length_code_lengths|11 |dynamic block code description: | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _l_i_t_e_r_a_l_/_l_e_n_g_t_h_ _c_o_d_e_ _l_e_n_g_t_h_s| │ │ │ │ +|invalid_distance_code_lengths |12 |dynamic block code description: | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _d_i_s_t_a_n_c_e_ _c_o_d_e_ _l_e_n_g_t_h_s_ _ _ _ _ _ | │ │ │ │ +|invalid_literal_code_in_block |13 |invalid literal/length or distance | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_d_e_ _i_n_ _f_i_x_e_d_ _o_r_ _d_y_n_a_m_i_c_ _b_l_o_c_k_ _ _ _ _ | │ │ │ │ +|distance_too_far_back_in_block |14 |distance is too far back in fixed | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _d_y_n_a_m_i_c_ _b_l_o_c_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|unknown_gzip_error |15 |an unknown error occurred during | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_g_z_i_p_ _i_n_f_l_a_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_e_r_r_o_r___c_o_d_e___m_a_x_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_6_ _ _ _|_t_h_e_ _n_u_m_b_e_r_ _o_f_ _e_r_r_o_r_ _c_o_d_e_s_ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eenndd__ffiillee(()) ********** │ │ │ │ -file_index_t eenndd__ffiillee () const; │ │ │ │ -one past-the-end file index │ │ │ │ +************ eennuumm ii22pp__eerrrroorr__ccooddee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_2_p___s_t_r_e_a_m_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_a_r_s_e___f_a_i_l_e_d_ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_c_a_n_t___r_e_a_c_h___p_e_e_r_|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_2_p___e_r_r_o_r_ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___k_e_y_ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___i_d_ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_i_m_e_o_u_t_ _ _ _ _ _ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_k_e_y___n_o_t___f_o_u_n_d_ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_u_p_l_i_c_a_t_e_d___i_d_ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_u_m___e_r_r_o_r_s_ _ _ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__rraannggee(()) ********** │ │ │ │ -index_range ffiillee__rraannggee () const noexcept; │ │ │ │ -all file indices in the torrent to be created │ │ │ │ +************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___e_r_r_o_r_ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_t_ _a_n_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_e_x_p_e_c_t_e_d___d_i_g_i_t_|_1_ _ _ _ _|_e_x_p_e_c_t_e_d_ _d_i_g_i_t_ _i_n_ _b_e_n_c_o_d_e_d_ _s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_e_x_p_e_c_t_e_d___c_o_l_o_n_|_2_ _ _ _ _|_e_x_p_e_c_t_e_d_ _c_o_l_o_n_ _i_n_ _b_e_n_c_o_d_e_d_ _s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_n_e_x_p_e_c_t_e_d___e_o_f_|_3_ _ _ _ _|_u_n_e_x_p_e_c_t_e_d_ _e_n_d_ _o_f_ _f_i_l_e_ _i_n_ _b_e_n_c_o_d_e_d_ _s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|expected_value|4 |expected value (list, dict, _i_n_t or string) in bencoded| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_t_r_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_t_h___e_x_c_e_e_d_e_d_|_5_ _ _ _ _|_b_e_n_c_o_d_e_d_ _r_e_c_u_r_s_i_o_n_ _d_e_p_t_h_ _l_i_m_i_t_ _e_x_c_e_e_d_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_l_i_m_i_t___e_x_c_e_e_d_e_d_|_6_ _ _ _ _|_b_e_n_c_o_d_e_d_ _i_t_e_m_ _c_o_u_n_t_ _l_i_m_i_t_ _e_x_c_e_e_d_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_o_v_e_r_f_l_o_w_ _ _ _ _ _ _|_7_ _ _ _ _|_i_n_t_e_g_e_r_ _o_v_e_r_f_l_o_w_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_e_r_r_o_r___c_o_d_e___m_a_x_|_8_ _ _ _ _|_t_h_e_ _n_u_m_b_e_r_ _o_f_ _e_r_r_o_r_ _c_o_d_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__aatt(()) ********** │ │ │ │ -create_file_entry const& ffiillee__aatt (file_index_t f) const; │ │ │ │ -returns a reference to the _c_r_e_a_t_e___f_i_l_e___e_n_t_r_y at the given file index. Note that │ │ │ │ -this is not necessarily the same entries passed into the constructor, since the │ │ │ │ -layout may have been canonicalized. e.g. file order and padding may have │ │ │ │ -changed. │ │ │ │ +************ eennuumm eerrrroorr__ccooddee__eennuumm ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_N_o_t_ _a_n_ _e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|file_collision |1 |Two torrents has files which end | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_u_p_ _o_v_e_r_w_r_i_t_i_n_g_ _e_a_c_h_ _o_t_h_e_r_ _ _ _ _ _ _ _ _ | │ │ │ │ +|failed_hash_check |2 |A piece did not match its piece | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_a_s_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The .torrent file does not contain| │ │ │ │ +|torrent_is_no_dict |3 |a bencoded dictionary at its top | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_v_e_l_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_missing_info |4 |The .torrent file does not have an| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_f_o_ _d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_info_no_dict |5 |The .torrent file's info _e_n_t_r_y is | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_t_ _a_ _d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_missing_piece_length |6 |The .torrent file does not have a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_ _l_e_n_g_t_h_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_missing_name |7 |The .torrent file does not have a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_a_m_e_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_invalid_name |8 |The .torrent file's name _e_n_t_r_y is | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The length of a file, or of the | │ │ │ │ +|torrent_invalid_length |9 |whole .torrent file is invalid. | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_E_i_t_h_e_r_ _n_e_g_a_t_i_v_e_ _o_r_ _n_o_t_ _a_n_ _i_n_t_e_g_e_r_ | │ │ │ │ +|torrent_file_parse_failed |10 |Failed to parse a file _e_n_t_r_y in | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _._t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_missing_pieces |11 |The pieces field is missing or | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _i_n_ _t_h_e_ _._t_o_r_r_e_n_t_ _f_i_l_e_ _ _ _ _ _ | │ │ │ │ +|torrent_invalid_hashes |12 |The pieces string has incorrect | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_n_g_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|too_many_pieces_in_torrent |13 |The .torrent file has more pieces | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_a_n_ _i_s_ _s_u_p_p_o_r_t_e_d_ _b_y_ _l_i_b_t_o_r_r_e_n_t_ _ _ | │ │ │ │ +| | |The metadata (.torrent file) that | │ │ │ │ +|invalid_swarm_metadata |14 |was received from the swarm | │ │ │ │ +| | |matched the info-hash, but failed | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_ _b_e_ _p_a_r_s_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_bencoding |15 |The file or buffer is not | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_r_r_e_c_t_l_y_ _b_e_n_c_o_d_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|no_files_in_torrent |16 |The .torrent file does not contain| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_n_y_ _f_i_l_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_escaped_string |17 |The string was not properly url- | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_n_c_o_d_e_d_ _a_s_ _e_x_p_e_c_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|session_is_closing |18 |Operation is not permitted since | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _s_e_s_s_i_o_n_ _i_s_ _s_h_u_t_t_i_n_g_ _d_o_w_n_ _ _ _ _ _ | │ │ │ │ +| | |There's already a torrent with | │ │ │ │ +|duplicate_torrent |19 |that info-hash added to the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_s_s_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_torrent_handle |20 |The supplied _t_o_r_r_e_n_t___h_a_n_d_l_e is not| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_f_e_r_r_i_n_g_ _t_o_ _a_ _v_a_l_i_d_ _t_o_r_r_e_n_t_ _ _ _ _ _ | │ │ │ │ +|invalid_entry_type |21 |The type requested from the _e_n_t_r_y | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_i_d_ _n_o_t_ _m_a_t_c_h_ _i_t_s_ _t_y_p_e_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|missing_info_hash_in_uri |22 |The specified URI does not contain| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _v_a_l_i_d_ _i_n_f_o_-_h_a_s_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |One of the files in the torrent | │ │ │ │ +|file_too_short |23 |was unexpectedly small. This might| │ │ │ │ +| | |be caused by files being changed | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_y_ _a_n_ _e_x_t_e_r_n_a_l_ _p_r_o_c_e_s_s_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The URL used an unknown protocol. | │ │ │ │ +| | |Currently http and https (if built| │ │ │ │ +|unsupported_url_protocol |24 |with openssl support) are | │ │ │ │ +| | |recognized. For trackers udp is | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_c_o_g_n_i_z_e_d_ _a_s_ _w_e_l_l_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|url_parse_error |25 |The URL did not conform to URL | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_y_n_t_a_x_ _a_n_d_ _f_a_i_l_e_d_ _t_o_ _b_e_ _p_a_r_s_e_d_ _ _ _ | │ │ │ │ +|peer_sent_empty_piece |26 |The peer sent a piece message of | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_n_g_t_h_ _0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|parse_failed |27 |A bencoded structure was corrupt | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_n_d_ _f_a_i_l_e_d_ _t_o_ _b_e_ _p_a_r_s_e_d_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_file_tag |28 |The fast resume file was missing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _h_a_d_ _a_n_ _i_n_v_a_l_i_d_ _f_i_l_e_ _v_e_r_s_i_o_n_ _t_a_g| │ │ │ │ +|missing_info_hash |29 |The fast resume file was missing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _h_a_d_ _a_n_ _i_n_v_a_l_i_d_ _i_n_f_o_-_h_a_s_h_ _ _ _ _ _ _ | │ │ │ │ +|mismatching_info_hash |30 |The info-hash did not match the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_hostname |31 |The URL contained an invalid | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_o_s_t_n_a_m_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___p_o_r_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_2_ _ _ _|_T_h_e_ _U_R_L_ _h_a_d_ _a_n_ _i_n_v_a_l_i_d_ _p_o_r_t_ _ _ _ _ _ _ | │ │ │ │ +| | |The port is blocked by the port- | │ │ │ │ +|port_blocked |33 |filter, and prevented the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_n_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|expected_close_bracket_in_address |34 |The IPv6 address was expected to | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_n_d_ _w_i_t_h_ _"_]_"_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The torrent is being destructed, | │ │ │ │ +|destructing_torrent |35 |preventing the operation to | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_u_c_c_e_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_i_m_e_d___o_u_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_6_ _ _ _|_T_h_e_ _c_o_n_n_e_c_t_i_o_n_ _t_i_m_e_d_ _o_u_t_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer is upload only, and we | │ │ │ │ +|upload_upload_connection |37 |are upload only. There's no point | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_ _k_e_e_p_i_n_g_ _t_h_e_ _c_o_n_n_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer is upload only, and we're| │ │ │ │ +|uninteresting_upload_peer |38 |not interested in it. There's no | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_o_i_n_t_ _i_n_ _k_e_e_p_i_n_g_ _t_h_e_ _c_o_n_n_e_c_t_i_o_n_ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___i_n_f_o___h_a_s_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_9_ _ _ _|_T_h_e_ _p_e_e_r_ _s_e_n_t_ _a_n_ _u_n_k_n_o_w_n_ _i_n_f_o_-_h_a_s_h| │ │ │ │ +|torrent_paused |40 |The torrent is paused, preventing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _f_r_o_m_ _s_u_c_c_e_e_d_i_n_g_ _ _ _ _ | │ │ │ │ +| | |The peer sent an invalid have | │ │ │ │ +|invalid_have |41 |message, either wrong size or | │ │ │ │ +| | |referring to a piece that doesn't | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_i_s_t_ _i_n_ _t_h_e_ _t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_bitfield_size |42 |The _b_i_t_f_i_e_l_d message had the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_c_o_r_r_e_c_t_ _s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer kept requesting pieces | │ │ │ │ +|too_many_requests_when_choked |43 |after it was choked, possible | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_b_u_s_e_ _a_t_t_e_m_p_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer sent a piece message that| │ │ │ │ +|invalid_piece |44 |does not correspond to a piece | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_q_u_e_s_t_ _s_e_n_t_ _b_y_ _t_h_e_ _c_l_i_e_n_t_ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___m_e_m_o_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_4_5_ _ _ _|_m_e_m_o_r_y_ _a_l_l_o_c_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_aborted |46 |The torrent is aborted, preventing| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _t_o_ _s_u_c_c_e_e_d_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|self_connection |47 |The peer is a connection to | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_u_r_s_e_l_f_,_ _n_o_ _p_o_i_n_t_ _i_n_ _k_e_e_p_i_n_g_ _i_t_ _ _ | │ │ │ │ +| | |The peer sent a piece message with| │ │ │ │ +|invalid_piece_size |48 |invalid size, either negative or | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_g_r_e_a_t_e_r_ _t_h_a_n_ _o_n_e_ _b_l_o_c_k_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer has not been interesting | │ │ │ │ +|timed_out_no_interest |49 |or interested in us for too long, | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_ _p_o_i_n_t_ _i_n_ _k_e_e_p_i_n_g_ _i_t_ _a_r_o_u_n_d_ _ _ _ _ | │ │ │ │ +|timed_out_inactivity |50 |The peer has not said anything in | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _l_o_n_g_ _t_i_m_e_,_ _p_o_s_s_i_b_l_y_ _d_e_a_d_ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer did not send a handshake | │ │ │ │ +|timed_out_no_handshake |51 |within a reasonable amount of | │ │ │ │ +| | |time, it might not be a bittorrent| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_e_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer has been unchoked for too| │ │ │ │ +|timed_out_no_request |52 |long without requesting any data. | │ │ │ │ +| | |It might be lying about its | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_t_e_r_e_s_t_ _i_n_ _u_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_choke |53 |The peer sent an invalid choke | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_unchoke |54 |The peer send an invalid unchoke | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_interested |55 |The peer sent an invalid | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_t_e_r_e_s_t_e_d_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_not_interested |56 |The peer sent an invalid not- | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_t_e_r_e_s_t_e_d_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_request |57 |The peer sent an invalid piece | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_q_u_e_s_t_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer sent an invalid hash-list| │ │ │ │ +|invalid_hash_list |58 |message (this is part of the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_r_k_l_e_-_t_o_r_r_e_n_t_ _e_x_t_e_n_s_i_o_n_)_ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer sent an invalid hash- | │ │ │ │ +|invalid_hash_piece |59 |piece message (this is part of the| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_r_k_l_e_-_t_o_r_r_e_n_t_ _e_x_t_e_n_s_i_o_n_)_ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_cancel |60 |The peer sent an invalid cancel | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_dht_port |61 |The peer sent an invalid DHT port-| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_suggest |62 |The peer sent an invalid suggest | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_-_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_have_all |63 |The peer sent an invalid have all-| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_have_none |64 |The peer sent an invalid have | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_n_e_-_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_reject |65 |The peer sent an invalid reject | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_allow_fast |66 |The peer sent an invalid allow | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_a_s_t_-_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_extended |67 |The peer sent an invalid extension| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _I_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_message |68 |The peer sent an invalid message | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_I_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|sync_hash_not_found |69 |The synchronization hash was not | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_o_u_n_d_ _i_n_ _t_h_e_ _e_n_c_r_y_p_t_e_d_ _h_a_n_d_s_h_a_k_e_ _ | │ │ │ │ +|invalid_encryption_constant |70 |The encryption constant in the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_a_n_d_s_h_a_k_e_ _i_s_ _i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|no_plaintext_mode |71 |The peer does not support plain | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_e_x_t_,_ _w_h_i_c_h_ _i_s_ _t_h_e_ _s_e_l_e_c_t_e_d_ _m_o_d_e_ _ | │ │ │ │ +|no_rc4_mode |72 |The peer does not support RC4, | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_h_i_c_h_ _i_s_ _t_h_e_ _s_e_l_e_c_t_e_d_ _m_o_d_e_ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer does not support any of | │ │ │ │ +|unsupported_encryption_mode |73 |the encryption modes that the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_l_i_e_n_t_ _s_u_p_p_o_r_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer selected an encryption | │ │ │ │ +|unsupported_encryption_mode_selected|74 |mode that the client did not | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_d_v_e_r_t_i_s_e_ _a_n_d_ _d_o_e_s_ _n_o_t_ _s_u_p_p_o_r_t_ _ _ _ | │ │ │ │ +| | |The pad size used in the | │ │ │ │ +|invalid_pad_size |75 |encryption handshake is of invalid| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_encrypt_handshake |76 |The encryption handshake is | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The client is set to not support | │ │ │ │ +|no_incoming_encrypted |77 |incoming encrypted connections and| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_i_s_ _i_s_ _a_n_ _e_n_c_r_y_p_t_e_d_ _c_o_n_n_e_c_t_i_o_n_ _ _ | │ │ │ │ +| | |The client is set to not support | │ │ │ │ +|no_incoming_regular |78 |incoming regular bittorrent | │ │ │ │ +| | |connections, and this is a regular| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_n_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|duplicate_peer_id |79 |The client is already connected to| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_i_s_ _p_e_e_r_-_I_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_o_r_r_e_n_t___r_e_m_o_v_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_0_ _ _ _|_T_o_r_r_e_n_t_ _w_a_s_ _r_e_m_o_v_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|packet_too_large |81 |The packet size exceeded the upper| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_a_n_i_t_y_ _c_h_e_c_k_-_l_i_m_i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_s_e_r_v_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_2_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|http_error |83 |The web server responded with an | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_r_r_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|missing_location |84 |The web server response is missing| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _l_o_c_a_t_i_o_n_ _h_e_a_d_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The web seed redirected to a path | │ │ │ │ +|invalid_redirection |85 |that no longer matches the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_._t_o_r_r_e_n_t_ _d_i_r_e_c_t_o_r_y_ _s_t_r_u_c_t_u_r_e_ _ _ _ _ _ | │ │ │ │ +|redirecting |86 |The connection was closed because | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_t_ _r_e_d_i_r_e_c_t_e_d_ _t_o_ _a_ _d_i_f_f_e_r_e_n_t_ _U_R_L_ _ | │ │ │ │ +|_i_n_v_a_l_i_d___r_a_n_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_7_ _ _ _|_T_h_e_ _H_T_T_P_ _r_a_n_g_e_ _h_e_a_d_e_r_ _i_s_ _i_n_v_a_l_i_d_ _ | │ │ │ │ +|no_content_length |88 |The HTTP response did not have a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_t_e_n_t_ _l_e_n_g_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_b_a_n_n_e_d___b_y___i_p___f_i_l_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_8_9_ _ _ _|_T_h_e_ _I_P_ _i_s_ _b_l_o_c_k_e_d_ _b_y_ _t_h_e_ _I_P_ _f_i_l_t_e_r| │ │ │ │ +|_t_o_o___m_a_n_y___c_o_n_n_e_c_t_i_o_n_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_0_ _ _ _|_A_t_ _t_h_e_ _c_o_n_n_e_c_t_i_o_n_ _l_i_m_i_t_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_e_e_r___b_a_n_n_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_1_ _ _ _|_T_h_e_ _p_e_e_r_ _i_s_ _m_a_r_k_e_d_ _a_s_ _b_a_n_n_e_d_ _ _ _ _ _ | │ │ │ │ +|stopping_torrent |92 |The torrent is stopping, causing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _t_o_ _f_a_i_l_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|too_many_corrupt_pieces |93 |The peer has sent too many corrupt| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_s_ _a_n_d_ _i_s_ _b_a_n_n_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_not_ready |94 |The torrent is not ready to | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_c_e_i_v_e_ _p_e_e_r_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|peer_not_constructed |95 |The peer is not completely | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_s_t_r_u_c_t_e_d_ _y_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|session_closing |96 |The _s_e_s_s_i_o_n is closing, causing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _o_p_e_r_a_t_i_o_n_ _t_o_ _f_a_i_l_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer was disconnected in order| │ │ │ │ +|optimistic_disconnect |97 |to leave room for a potentially | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_e_t_t_e_r_ _p_e_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_o_r_r_e_n_t___f_i_n_i_s_h_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_8_ _ _ _|_T_h_e_ _t_o_r_r_e_n_t_ _i_s_ _f_i_n_i_s_h_e_d_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___r_o_u_t_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_9_9_ _ _ _|_N_o_ _U_P_n_P_ _r_o_u_t_e_r_ _f_o_u_n_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|metadata_too_large |100 |The metadata message says the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_t_a_d_a_t_a_ _e_x_c_e_e_d_s_ _t_h_e_ _l_i_m_i_t_ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_metadata_request |101 |The peer sent an invalid metadata | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_q_u_e_s_t_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_metadata_size |102 |The peer advertised an invalid | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_t_a_d_a_t_a_ _s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_metadata_offset |103 |The peer sent a message with an | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _m_e_t_a_d_a_t_a_ _o_f_f_s_e_t_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_metadata_message |104 |The peer sent an invalid metadata | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|pex_message_too_large |105 |The peer sent a peer exchange | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_s_s_a_g_e_ _t_h_a_t_ _w_a_s_ _t_o_o_ _l_a_r_g_e_ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_pex_message |106 |The peer sent an invalid peer | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_c_h_a_n_g_e_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_lt_tracker_message |107 |The peer sent an invalid tracker | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_c_h_a_n_g_e_ _m_e_s_s_a_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer sent an pex messages too | │ │ │ │ +|too_frequent_pex |108 |often. This is a possible attempt | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_f_ _a_n_d_ _a_t_t_a_c_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The operation failed because it | │ │ │ │ +| | |requires the torrent to have the | │ │ │ │ +| | |metadata (.torrent file) and it | │ │ │ │ +|no_metadata |109 |doesn't have it yet. This happens | │ │ │ │ +| | |for magnet links before they have | │ │ │ │ +| | |downloaded the metadata, and also | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_r_r_e_n_t_s_ _a_d_d_e_d_ _b_y_ _U_R_L_._ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer sent an invalid dont_have| │ │ │ │ +| | |message. The don't have message is| │ │ │ │ +|invalid_dont_have |110 |an extension to allow peers to | │ │ │ │ +| | |advertise that the no longer has a| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_ _t_h_e_y_ _p_r_e_v_i_o_u_s_l_y_ _h_a_d_._ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer tried to connect to an | │ │ │ │ +|requires_ssl_connection |111 |SSL torrent without connecting | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_v_e_r_ _S_S_L_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The peer tried to connect to a | │ │ │ │ +|invalid_ssl_cert |112 |torrent with a certificate for a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_i_f_f_e_r_e_n_t_ _t_o_r_r_e_n_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |the torrent is not an SSL torrent,| │ │ │ │ +|not_an_ssl_torrent |113 |and the operation requires an SSL | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |peer was banned because its listen| │ │ │ │ +|banned_by_port_filter |114 |port is within a banned port | │ │ │ │ +| | |range, as specified by the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_o_r_t___f_i_l_t_e_r_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_session_handle |115 |The _s_e_s_s_i_o_n___h_a_n_d_l_e is not | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_f_e_r_r_i_n_g_ _t_o_ _a_ _v_a_l_i_d_ _s_e_s_s_i_o_n___i_m_p_l_ | │ │ │ │ +|invalid_listen_socket |116 |the listen socket associated with | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_i_s_ _r_e_q_u_e_s_t_ _w_a_s_ _c_l_o_s_e_d_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___h_a_s_h___r_e_q_u_e_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_7_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___h_a_s_h_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_8_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___h_a_s_h___r_e_j_e_c_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_1_9_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___1_2_0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___1_2_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___1_2_2_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___1_2_3_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_3_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_e_p_r_e_c_a_t_e_d___1_2_4_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_2_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|missing_file_sizes |130 |The resume data file is missing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _f_i_l_e_ _s_i_z_e_s_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|no_files_in_resume_data |131 |The resume data file file sizes | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_n_t_r_y_ _i_s_ _e_m_p_t_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|missing_pieces |132 |The resume data file is missing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_h_e_ _p_i_e_c_e_s_ _a_n_d_ _s_l_o_t_s_ _e_n_t_r_y_ _ _ _ _ _ _ _ | │ │ │ │ +| | |The number of files in the resume | │ │ │ │ +|mismatching_number_of_files |133 |data does not match the number of | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_i_l_e_s_ _i_n_ _t_h_e_ _t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |One of the files on disk has a | │ │ │ │ +|mismatching_file_size |134 |different size than in the fast | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_s_u_m_e_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |One of the files on disk has a | │ │ │ │ +|mismatching_file_timestamp |135 |different timestamp than in the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_a_s_t_ _r_e_s_u_m_e_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|not_a_dictionary |136 |The resume data file is not a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_blocks_per_piece |137 |The blocks per piece _e_n_t_r_y is | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _i_n_ _t_h_e_ _r_e_s_u_m_e_ _d_a_t_a_ _f_i_l_e_ _ _ | │ │ │ │ +| | |The resume file is missing the | │ │ │ │ +|missing_slots |138 |slots _e_n_t_r_y, which is required for| │ │ │ │ +| | |torrents with compact allocation. | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_DD_EE_PP_RR_EE_CC_AA_TT_EE_DD_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|too_many_slots |139 |The resume file contains more | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_l_o_t_s_ _t_h_a_n_ _t_h_e_ _t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_slot_list |140 |The slot _e_n_t_r_y is invalid in the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_r_e_s_u_m_e_ _d_a_t_a_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_piece_index |141 |One index in the slot list is | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The pieces on disk needs to be re-| │ │ │ │ +| | |ordered for the specified | │ │ │ │ +| | |allocation mode. This happens if | │ │ │ │ +|pieces_need_reorder |142 |you specify sparse allocation and | │ │ │ │ +| | |the files on disk are using | │ │ │ │ +| | |compact storage. The pieces needs | │ │ │ │ +| | |to be moved to their right | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_o_s_i_t_i_o_n_._ _DD_EE_PP_RR_EE_CC_AA_TT_EE_DD_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |this error is returned when asking| │ │ │ │ +| | |to save resume data and specifying| │ │ │ │ +|resume_data_not_modified |143 |the flag to only save when there's| │ │ │ │ +| | |anything new to save | │ │ │ │ +| | |(_t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_o_n_l_y___i_f___m_o_d_i_f_i_e_d)| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_n_d_ _t_h_e_r_e_ _w_a_s_n_'_t_ _a_n_y_t_h_i_n_g_ _c_h_a_n_g_e_d_.| │ │ │ │ +|invalid_save_path |144 |the save_path in | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s_ _i_s_ _n_o_t_ _v_a_l_i_d_ _ _ | │ │ │ │ +| | |The torrent contained too many | │ │ │ │ +|too_many_duplicate_filenames |145 |duplicate _f_i_l_e_n_a_m_e_s, exceeding the| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_o_n_f_i_g_u_r_e_d_ _l_i_m_i_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|http_parse_error |150 |The HTTP header was not correctly | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_o_r_m_a_t_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The HTTP response was in the 300- | │ │ │ │ +|http_missing_location |151 |399 range but lacked a location | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_h_e_a_d_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |The HTTP response was encoded with| │ │ │ │ +|http_failed_decompress |152 |gzip or deflate but decompressing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_t_ _f_a_i_l_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|no_i2p_router |160 |The URL specified an i2p address, | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_u_t_ _n_o_ _i_2_p_ _r_o_u_t_e_r_ _i_s_ _c_o_n_f_i_g_u_r_e_d_ _ _ | │ │ │ │ +|no_i2p_endpoint |161 |i2p acceptor is not available yet,| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_n_'_t_ _a_n_n_o_u_n_c_e_ _w_i_t_h_o_u_t_ _e_n_d_p_o_i_n_t_ _ _ | │ │ │ │ +| | |The tracker URL doesn't support | │ │ │ │ +|scrape_not_available |170 |transforming it into a scrape URL.| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_._e_._ _i_t_ _d_o_e_s_n_'_t_ _c_o_n_t_a_i_n_ _"_a_n_n_o_u_n_c_e_.| │ │ │ │ +|_i_n_v_a_l_i_d___t_r_a_c_k_e_r___r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_1_ _ _|_i_n_v_a_l_i_d_ _t_r_a_c_k_e_r_ _r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_peer_dict |172 |invalid peer dictionary _e_n_t_r_y. Not| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_ _d_i_c_t_i_o_n_a_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_r_a_c_k_e_r___f_a_i_l_u_r_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_3_ _ _|_t_r_a_c_k_e_r_ _s_e_n_t_ _a_ _f_a_i_l_u_r_e_ _m_e_s_s_a_g_e_ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___f_i_l_e_s___e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_4_ _ _|_m_i_s_s_i_n_g_ _o_r_ _i_n_v_a_l_i_d_ _f_i_l_e_s_ _e_n_t_r_y_ _ _ _ | │ │ │ │ +|_i_n_v_a_l_i_d___h_a_s_h___e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_7_5_ _ _|_m_i_s_s_i_n_g_ _o_r_ _i_n_v_a_l_i_d_ _h_a_s_h_ _e_n_t_r_y_ _ _ _ _ | │ │ │ │ +|invalid_peers_entry |176 |missing or invalid peers and | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_e_e_r_s_6_ _e_n_t_r_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_tracker_response_length |177 |UDP tracker response packet has | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_v_a_l_i_d_ _s_i_z_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_tracker_transaction_id |178 |invalid transaction id in UDP | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_a_c_k_e_r_ _r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|invalid_tracker_action |179 |invalid action field in UDP | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_a_c_k_e_r_ _r_e_s_p_o_n_s_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |skipped announce (because it's | │ │ │ │ +|announce_skipped |180 |assumed to be unreachable over the| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_g_i_v_e_n_ _s_o_u_r_c_e_ _n_e_t_w_o_r_k_ _i_n_t_e_r_f_a_c_e_)_ _ _ | │ │ │ │ +|_n_o___e_n_t_r_o_p_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_0_ _ _|_r_a_n_d_o_m_ _n_u_m_b_e_r_ _g_e_n_e_r_a_t_i_o_n_ _f_a_i_l_e_d_ _ _ | │ │ │ │ +|_s_s_r_f___m_i_t_i_g_a_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_1_ _ _|_b_l_o_c_k_e_d_ _b_y_ _S_S_R_F_ _m_i_t_i_g_a_t_i_o_n_ _ _ _ _ _ _ _ | │ │ │ │ +|blocked_by_idna |202 |blocked because IDNA host names | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_r_e_ _b_a_n_n_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_unknown_version |210 |the torrent file has an unknown | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_m_e_t_a_ _v_e_r_s_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_missing_file_tree |211 |the v2 torrent file has no file | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_e_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_missing_meta_version |212 |the torrent contains v2 keys but | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_o_e_s_ _n_o_t_ _s_p_e_c_i_f_y_ _m_e_t_a_ _v_e_r_s_i_o_n_ _2_ _ _ | │ │ │ │ +|torrent_inconsistent_files |213 |the v1 and v2 file metadata does | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_n_o_t_ _m_a_t_c_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_missing_piece_layer |214 |one or more files are missing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_i_e_c_e_ _l_a_y_e_r_ _h_a_s_h_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_invalid_piece_layer |215 |a piece layer has the wrong size | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_o_r_ _f_a_i_l_e_d_ _h_a_s_h_ _c_h_e_c_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_o_r_r_e_n_t___m_i_s_s_i_n_g___p_i_e_c_e_s___r_o_o_t_ _ _ _ _ _ _ _ _ _|_2_1_6_ _ _|_a_ _v_2_ _f_i_l_e_ _e_n_t_r_y_ _h_a_s_ _n_o_ _r_o_o_t_ _h_a_s_h_ _ | │ │ │ │ +|torrent_inconsistent_hashes |217 |the v1 and v2 hashes do not | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_e_s_c_r_i_b_e_ _t_h_e_ _s_a_m_e_ _d_a_t_a_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|torrent_invalid_pad_file |218 |a file in the v2 metadata has the | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_a_d_ _a_t_t_r_i_b_u_t_e_ _s_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |the directory structure of files | │ │ │ │ +|torrent_directory_too_deep |219 |in the torrent exceeds the | │ │ │ │ +| | |configured maximum depth (see | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_e_r_r_o_r___c_o_d_e___m_a_x_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_2_0_ _ _|_t_h_e_ _n_u_m_b_e_r_ _o_f_ _e_r_r_o_r_ _c_o_d_e_s_ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiillee__ppiieeccee__rraannggee(()) ********** │ │ │ │ -index_range ffiillee__ppiieeccee__rraannggee (file_index_t f); │ │ │ │ -for v2 and hybrid torrents only, the pieces in the specified file, specified as │ │ │ │ -delta from the first piece in the file. i.e. the first index is 0. │ │ │ │ +************ eennuumm hhttttpp__eerrrroorrss ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_r_r_o_r___c_o_d_e_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_c_o_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_1_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_o_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_c_r_e_a_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_a_c_c_e_p_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_0_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o___c_o_n_t_e_n_t_ _ _ _ _ _ _ _ _ _ _ _|_2_0_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_m_u_l_t_i_p_l_e___c_h_o_i_c_e_s_ _ _ _ _ _|_3_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_m_o_v_e_d___p_e_r_m_a_n_e_n_t_l_y_ _ _ _ _|_3_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_m_o_v_e_d___t_e_m_p_o_r_a_r_i_l_y_ _ _ _ _|_3_0_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o_t___m_o_d_i_f_i_e_d_ _ _ _ _ _ _ _ _ _|_3_0_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_b_a_d___r_e_q_u_e_s_t_ _ _ _ _ _ _ _ _ _ _|_4_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_n_a_u_t_h_o_r_i_z_e_d_ _ _ _ _ _ _ _ _ _|_4_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_f_o_r_b_i_d_d_e_n_ _ _ _ _ _ _ _ _ _ _ _ _|_4_0_3_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o_t___f_o_u_n_d_ _ _ _ _ _ _ _ _ _ _ _ _|_4_0_4_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_n_t_e_r_n_a_l___s_e_r_v_e_r___e_r_r_o_r_|_5_0_0_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_n_o_t___i_m_p_l_e_m_e_n_t_e_d_ _ _ _ _ _ _|_5_0_1_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_b_a_d___g_a_t_e_w_a_y_ _ _ _ _ _ _ _ _ _ _|_5_0_2_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_e_r_v_i_c_e___u_n_a_v_a_i_l_a_b_l_e_ _ _|_5_0_3_ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttoottaall__ssiizzee(()) ********** │ │ │ │ -std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ -the total number of bytes of all files and pad files │ │ │ │ +************ aadddd__ttoorrrreenntt__ppaarraammss ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s_._h_p_p" │ │ │ │ +The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s contains all the information in a .torrent file along │ │ │ │ +with all information necessary to add that torrent to a _s_e_s_s_i_o_n. The key fields │ │ │ │ +when adding a torrent are: │ │ │ │ + * ti - the immutable info-dict part of the torrent │ │ │ │ + * info_hash - when you don't have the metadata (.torrent file). This │ │ │ │ + uniquely identifies the torrent and can validate the info-dict when │ │ │ │ + received from the swarm. │ │ │ │ +In order to add a torrent to a _s_e_s_s_i_o_n, one of those fields must be set in │ │ │ │ +addition to save_path. The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object can then be passed into │ │ │ │ +one of the session::add_torrent() overloads or session::async_add_torrent(). │ │ │ │ +If you only specify the info-hash, the torrent file will be downloaded from │ │ │ │ +peers, which requires them to support the metadata extension. For the metadata │ │ │ │ +extension to work, libtorrent must be built with extensions enabled │ │ │ │ +(TORRENT_DISABLE_EXTENSIONS must not be defined). It also takes an optional │ │ │ │ +name argument. This may be left empty in case no name should be assigned to the │ │ │ │ +torrent. In case it's not, the name is used for the torrent as long as it │ │ │ │ +doesn't have metadata. See torrent_handle::name. │ │ │ │ +The add_torrent_params is also used when requesting resume data for a torrent. │ │ │ │ +It can be saved to and restored from a file and added back to a new _s_e_s_s_i_o_n. │ │ │ │ +For serialization and de-serialization of add_torrent_params objects, see │ │ │ │ +_r_e_a_d___r_e_s_u_m_e___d_a_t_a_(_) and _w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_(_). │ │ │ │ +The add_torrent_params is also used to represent a parsed .torrent file. It can │ │ │ │ +be loaded via _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_(_) and │ │ │ │ +_l_o_a_d___t_o_r_r_e_n_t___p_a_r_s_e_d_(_). It can be saved via _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_). │ │ │ │ +struct add_torrent_params │ │ │ │ +{ │ │ │ │ + int vveerrssiioonn = LIBTORRENT_VERSION_NUM; │ │ │ │ + std::shared_ptr ti; │ │ │ │ + std::vector trackers; │ │ │ │ + std::vector tracker_tiers; │ │ │ │ + std::vector> dht_nodes; │ │ │ │ + std::string name; │ │ │ │ + std::string save_path; │ │ │ │ + std::string part_file_dir; │ │ │ │ + storage_mode_t ssttoorraaggee__mmooddee = storage_mode_sparse; │ │ │ │ + client_data_t userdata; │ │ │ │ + std::vector file_priorities; │ │ │ │ + std::string trackerid; │ │ │ │ + torrent_flags_t ffllaaggss = torrent_flags::default_flags; │ │ │ │ + info_hash_t info_hashes; │ │ │ │ + int mmaaxx__uuppllooaaddss = -1; │ │ │ │ + int mmaaxx__ccoonnnneeccttiioonnss = -1; │ │ │ │ + int uuppllooaadd__lliimmiitt = -1; │ │ │ │ + int ddoowwnnllooaadd__lliimmiitt = -1; │ │ │ │ + std::int64_t ttoottaall__uuppllooaaddeedd = 0; │ │ │ │ + std::int64_t ttoottaall__ddoowwnnllooaaddeedd = 0; │ │ │ │ + int aaccttiivvee__ttiimmee = 0; │ │ │ │ + int ffiinniisshheedd__ttiimmee = 0; │ │ │ │ + int sseeeeddiinngg__ttiimmee = 0; │ │ │ │ + std::time_t aaddddeedd__ttiimmee = 0; │ │ │ │ + std::time_t ccoommpplleetteedd__ttiimmee = 0; │ │ │ │ + std::time_t llaasstt__sseeeenn__ccoommpplleettee = 0; │ │ │ │ + int nnuumm__ccoommpplleettee = -1; │ │ │ │ + int nnuumm__iinnccoommpplleettee = -1; │ │ │ │ + int nnuumm__ddoowwnnllooaaddeedd = -1; │ │ │ │ + std::vector url_seeds; │ │ │ │ + std::vector peers; │ │ │ │ + std::vector banned_peers; │ │ │ │ + aux::noexcept_movable> unfinished_pieces; │ │ │ │ + typed_bitfield have_pieces; │ │ │ │ + typed_bitfield verified_pieces; │ │ │ │ + std::vector piece_priorities; │ │ │ │ + aux::vector, file_index_t> merkle_trees; │ │ │ │ + aux::vector merkle_tree_mask; │ │ │ │ + aux::vector verified_leaf_hashes; │ │ │ │ + aux::noexcept_movable> renamed_files; │ │ │ │ + std::time_t llaasstt__ddoowwnnllooaadd = 0; │ │ │ │ + std::time_t llaasstt__uuppllooaadd = 0; │ │ │ │ + std::string comment; │ │ │ │ + std::string created_by; │ │ │ │ + std::time_t ccrreeaattiioonn__ddaattee = 0; │ │ │ │ + std::string root_certificate; │ │ │ │ +}; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** 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. │ │ │ │ + version │ │ │ │ + filled in by the constructor and should be left untouched. It is used for │ │ │ │ + forward binary compatibility. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ccoolllleeccttiioonn(()) aadddd__ssiimmiillaarr__ttoorrrreenntt(()) ********** │ │ │ │ -void aadddd__ccoolllleeccttiioonn (string_view c); │ │ │ │ -void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih); │ │ │ │ -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. │ │ │ │ + ti │ │ │ │ + _t_o_r_r_e_n_t___i_n_f_o object with the torrent to add. Unless the info_hash is set, │ │ │ │ + this is required to be initialized. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - modification_time │ │ │ │ - This will include the file modification time as part of the torrent. This │ │ │ │ - is not enabled by default, as it might cause problems when you create a │ │ │ │ - torrent from separate files with the same content, hoping to yield the │ │ │ │ - same info-hash. If the files have different modification times, with this │ │ │ │ - option enabled, you would get different info-hashes for the files. │ │ │ │ + trackers │ │ │ │ + If the torrent doesn't have a tracker, but relies on the DHT to find │ │ │ │ + peers, the trackers can specify tracker URLs for the torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - symlinks │ │ │ │ - If this flag is set, files that are symlinks get a symlink attribute set │ │ │ │ - on them and their data will not be included in the torrent. This is │ │ │ │ - useful if you need to reconstruct a file hierarchy which contains │ │ │ │ - symlinks. │ │ │ │ + tracker_tiers │ │ │ │ + the tiers the URLs in trackers belong to. Trackers belonging to different │ │ │ │ + tiers may be treated differently, as defined by the multi tracker │ │ │ │ + extension. This is optional, if not specified trackers are assumed to be │ │ │ │ + part of tier 0, or whichever the last tier was as iterating over the │ │ │ │ + trackers. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - v2_only │ │ │ │ - Do not generate v1 metadata. The resulting torrent will only be usable by │ │ │ │ - clients which support v2. This requires setting all v2 hashes, with │ │ │ │ - _s_e_t___h_a_s_h_2_(_) before calling _g_e_n_e_r_a_t_e_(_). Setting v1 hashes (with _s_e_t___h_a_s_h │ │ │ │ - _(_)) is an error with this flag set. │ │ │ │ + dht_nodes │ │ │ │ + a list of hostname and port pairs, representing DHT nodes to be added to │ │ │ │ + the _s_e_s_s_i_o_n (if DHT is enabled). The hostname may be an IP address. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - v1_only │ │ │ │ - do not generate v2 metadata or enforce v2 alignment and padding rules │ │ │ │ - this is mainly for tests, not recommended for production use. This │ │ │ │ - requires setting all v1 hashes, with _s_e_t___h_a_s_h_(_), before calling _g_e_n_e_r_a_t_e │ │ │ │ - _(_). Setting v2 hashes (with _s_e_t___h_a_s_h_2_(_)) is an error with this flag set. │ │ │ │ + name │ │ │ │ + in case there's no other name in this torrent, this name will be used. │ │ │ │ + The name out of the _t_o_r_r_e_n_t___i_n_f_o object takes precedence if available. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - canonical_files │ │ │ │ - This flag only affects v1-only torrents, and is only relevant together │ │ │ │ - with the v1_only_flag. This flag will force the same file order and │ │ │ │ - padding as a v2 (or hybrid) torrent would have. It has the effect of │ │ │ │ - ordering files and inserting pad files to align them with piece │ │ │ │ - boundaries. │ │ │ │ + save_path │ │ │ │ + The path to the directory where the torrent is or will be stored. │ │ │ │ + Note │ │ │ │ + On windows this path (and other paths) are interpreted as UNC paths. This │ │ │ │ + means they must use backslashes as directory separators and may not │ │ │ │ + contain the special directories "." or "..". │ │ │ │ + Setting this to an absolute path performs slightly better than a relative │ │ │ │ + path. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - no_attributes │ │ │ │ - passing this flag to _l_i_s_t___f_i_l_e_s_(_) will ignore file attributes (such as │ │ │ │ - executable or hidden) when adding the files to the file storage. Since │ │ │ │ - not all filesystems and operating systems support all file attributes the │ │ │ │ - resulting torrent may differ depending on where it's created. If it's │ │ │ │ - important for torrents to be created consistently across systems, this │ │ │ │ - flag should be set. │ │ │ │ + part_file_dir │ │ │ │ + This is an optional field. If set, the part-file for this torrent will be │ │ │ │ + stored in the specified subdirectory, still inside its download │ │ │ │ + directory. i.e. part_file_dir is a relative directory. The part file name │ │ │ │ + is disambiguated by including the info-hash, in hexadecimal form. By │ │ │ │ + default it's stored directly in the download directory. If the storage │ │ │ │ + for a torrent is moved, the part file is also moved along with it, to the │ │ │ │ + new download directory. A part file contains partial pieces that need to │ │ │ │ + be downloaded in order to verify hashes and seeding, but are part of │ │ │ │ + files whose priority is zero. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - canonical_files_no_tail_padding │ │ │ │ - this flag enforces the file layout to be canonical according to the │ │ │ │ - bittorrent v2 specification (just like the canonical_files flag) with the │ │ │ │ - one exception that tail padding is not added to the last file. This │ │ │ │ - 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. │ │ │ │ + storage_mode │ │ │ │ + One of the values from _s_t_o_r_a_g_e___m_o_d_e___t. For more information, see _s_t_o_r_a_g_e │ │ │ │ + _a_l_l_o_c_a_t_i_o_n. │ │ │ │ [_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 = {}); │ │ │ │ -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 │ │ │ │ -directory. If no predicate is specified, all files are added, and all │ │ │ │ -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. │ │ │ │ + userdata │ │ │ │ + The userdata parameter is optional and will be passed on to the extension │ │ │ │ + constructor functions, if any (see _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_(_)). It │ │ │ │ + will also be stored in the torrent object and can be retrieved by calling │ │ │ │ + _u_s_e_r_d_a_t_a_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseett__ppiieeccee__hhaasshheess(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ -void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ - , std::function const& f, error_code& ec); │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ - , settings_pack const& settings │ │ │ │ - , std::function const& f); │ │ │ │ -void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ - , settings_pack const& settings │ │ │ │ - , std::function const& f, error_code& ec); │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p); │ │ │ │ -void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p │ │ │ │ - , settings_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 │ │ │ │ - , 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. │ │ │ │ -The overloads that don't take an error_code& may throw an exception in case of │ │ │ │ -a file error, the other overloads sets the error code to reflect the error, if │ │ │ │ -any. │ │ │ │ + file_priorities │ │ │ │ + can be set to control the initial file priorities when adding a torrent. │ │ │ │ + The semantics are the same as for torrent_handle::prioritize_files(). The │ │ │ │ + file priorities specified in here take precedence over those specified in │ │ │ │ + the resume data, if any. If this vector of file priorities is shorter │ │ │ │ + than the number of files in the torrent, the remaining files (not covered │ │ │ │ + by this) will still have the default download priority. This default can │ │ │ │ + be changed by setting the default_dont_download torrent_flag. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bbiittffiieelldd ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_i_t_f_i_e_l_d_._h_p_p" │ │ │ │ -The _b_i_t_f_i_e_l_d type stores any number of bits as a _b_i_t_f_i_e_l_d in a heap allocated │ │ │ │ -array. │ │ │ │ -struct bitfield │ │ │ │ -{ │ │ │ │ - bbiittffiieelldd (char const* b, int bits); │ │ │ │ - bbiittffiieelldd (int bits, bool val); │ │ │ │ - explicit bbiittffiieelldd (int bits); │ │ │ │ - bbiittffiieelldd (bitfield const& rhs); │ │ │ │ - bbiittffiieelldd () noexcept = default; │ │ │ │ - bbiittffiieelldd (bitfield&& rhs) noexcept = default; │ │ │ │ - void aassssiiggnn (char const* b, int const bits); │ │ │ │ - bool ooppeerraattoorr[[]] (int index) const noexcept; │ │ │ │ - bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ - void sseett__bbiitt (int index) noexcept; │ │ │ │ - void cclleeaarr__bbiitt (int index) noexcept; │ │ │ │ - bool aallll__sseett () const noexcept; │ │ │ │ - bool nnoonnee__sseett () const noexcept; │ │ │ │ - int ssiizzee () const noexcept; │ │ │ │ - int nnuumm__wwoorrddss () const noexcept; │ │ │ │ - int nnuumm__bbyytteess () const noexcept; │ │ │ │ - bool eemmppttyy () const noexcept; │ │ │ │ - char* ddaattaa () noexcept; │ │ │ │ - char const* ddaattaa () const noexcept; │ │ │ │ - void sswwaapp (bitfield& rhs) noexcept; │ │ │ │ - int ccoouunntt () const noexcept; │ │ │ │ - int ffiinndd__ffiirrsstt__sseett () const noexcept; │ │ │ │ - int ffiinndd__llaasstt__cclleeaarr () const noexcept; │ │ │ │ - bool ooppeerraattoorr==== (lt::bitfield const& rhs) const; │ │ │ │ -}; │ │ │ │ + trackerid │ │ │ │ + the default tracker id to be used when announcing to trackers. By default │ │ │ │ + this is empty, and no tracker ID is used, since this is an optional │ │ │ │ + argument. If a tracker returns a tracker ID, that ID is used instead of │ │ │ │ + this. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bbiittffiieelldd(()) ********** │ │ │ │ -bbiittffiieelldd (char const* b, int bits); │ │ │ │ -bbiittffiieelldd (int bits, bool val); │ │ │ │ -explicit bbiittffiieelldd (int bits); │ │ │ │ -bbiittffiieelldd (bitfield const& rhs); │ │ │ │ -bbiittffiieelldd () noexcept = default; │ │ │ │ -bbiittffiieelldd (bitfield&& rhs) noexcept = default; │ │ │ │ -constructs a new _b_i_t_f_i_e_l_d. The default constructor creates an empty _b_i_t_f_i_e_l_d. │ │ │ │ -bits is the size of the _b_i_t_f_i_e_l_d (specified in bits). val is the value to │ │ │ │ -initialize the bits to. If not specified all bits are initialized to 0. │ │ │ │ -The constructor taking a pointer b and bits copies a _b_i_t_f_i_e_l_d from the │ │ │ │ -specified buffer, and bits number of bits (rounded up to the nearest byte │ │ │ │ -boundary). │ │ │ │ + flags │ │ │ │ + flags controlling aspects of this torrent and how it's added. See │ │ │ │ + _t_o_r_r_e_n_t___f_l_a_g_s___t for details. │ │ │ │ + Note │ │ │ │ + The flags field is initialized with default flags by the constructor. In │ │ │ │ + order to preserve default behavior when clearing or setting other flags, │ │ │ │ + make sure to bitwise OR or in a flag or bitwise AND the inverse of a flag │ │ │ │ + to clear it. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassssiiggnn(()) ********** │ │ │ │ -void aassssiiggnn (char const* b, int const bits); │ │ │ │ -copy _b_i_t_f_i_e_l_d from buffer b of bits number of bits, rounded up to the nearest │ │ │ │ -byte boundary. │ │ │ │ + info_hashes │ │ │ │ + set this to the info hash of the torrent to add in case the info-hash is │ │ │ │ + the only known property of the torrent. i.e. you don't have a .torrent │ │ │ │ + file nor a magnet link. To add a magnet link, use _p_a_r_s_e___m_a_g_n_e_t___u_r_i_(_) to │ │ │ │ + populate fields in the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__bbiitt(()) ooppeerraattoorr[[]](()) ********** │ │ │ │ -bool ooppeerraattoorr[[]] (int index) const noexcept; │ │ │ │ -bool ggeett__bbiitt (int index) const noexcept; │ │ │ │ -query bit at index. Returns true if bit is 1, otherwise false. │ │ │ │ + max_uploads max_connections │ │ │ │ + max_uploads, max_connections, upload_limit, download_limit correspond to │ │ │ │ + the set_max_uploads(), set_max_connections(), set_upload_limit() and │ │ │ │ + set_download_limit() functions on _t_o_r_r_e_n_t___h_a_n_d_l_e. These values let you │ │ │ │ + initialize these settings when the torrent is added, instead of calling │ │ │ │ + these functions immediately following adding it. │ │ │ │ + -1 means unlimited on these settings just like their counterpart │ │ │ │ + functions on _t_o_r_r_e_n_t___h_a_n_d_l_e │ │ │ │ + For fine grained control over rate limits, including making them apply to │ │ │ │ + local peers, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__bbiitt(()) cclleeaarr__bbiitt(()) ********** │ │ │ │ -void sseett__bbiitt (int index) noexcept; │ │ │ │ -void cclleeaarr__bbiitt (int index) noexcept; │ │ │ │ -set bit at index to 0 (clear_bit) or 1 (set_bit). │ │ │ │ + upload_limit download_limit │ │ │ │ + the upload and download rate limits for this torrent, specified in bytes │ │ │ │ + per second. -1 means unlimited. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aallll__sseett(()) ********** │ │ │ │ -bool aallll__sseett () const noexcept; │ │ │ │ -returns true if all bits in the _b_i_t_f_i_e_l_d are set │ │ │ │ + total_uploaded total_downloaded │ │ │ │ + the total number of bytes uploaded and downloaded by this torrent so far. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnoonnee__sseett(()) ********** │ │ │ │ -bool nnoonnee__sseett () const noexcept; │ │ │ │ -returns true if no bit in the _b_i_t_f_i_e_l_d is set │ │ │ │ + active_time finished_time seeding_time │ │ │ │ + the number of seconds this torrent has spent in started, finished and │ │ │ │ + seeding state so far, respectively. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssiizzee(()) ********** │ │ │ │ -int ssiizzee () const noexcept; │ │ │ │ -returns the size of the _b_i_t_f_i_e_l_d in bits. │ │ │ │ + added_time completed_time │ │ │ │ + if set to a non-zero value, this is the posix time of when this torrent │ │ │ │ + was first added, including previous runs/sessions. If set to zero, the │ │ │ │ + internal added_time will be set to the time of when _a_d_d___t_o_r_r_e_n_t_(_) is │ │ │ │ + called. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__wwoorrddss(()) ********** │ │ │ │ -int nnuumm__wwoorrddss () const noexcept; │ │ │ │ -returns the number of 32 bit words are needed to represent all bits in this │ │ │ │ -_b_i_t_f_i_e_l_d. │ │ │ │ + last_seen_complete │ │ │ │ + if set to non-zero, initializes the time (expressed in posix time) when │ │ │ │ + we last saw a seed or peers that together formed a complete copy of the │ │ │ │ + torrent. If left set to zero, the internal counterpart to this field will │ │ │ │ + be updated when we see a seed or a distributed copies >= 1.0. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__bbyytteess(()) ********** │ │ │ │ -int nnuumm__bbyytteess () const noexcept; │ │ │ │ -returns the number of bytes needed to represent all bits in this _b_i_t_f_i_e_l_d │ │ │ │ + num_complete num_incomplete num_downloaded │ │ │ │ + these field can be used to initialize the torrent's cached scrape data. │ │ │ │ + The scrape data is high level metadata about the current state of the │ │ │ │ + swarm, as returned by the tracker (either when announcing to it or by │ │ │ │ + sending a specific scrape request). num_complete is the number of peers │ │ │ │ + in the swarm that are seeds, or have every piece in the torrent. │ │ │ │ + num_incomplete is the number of peers in the swarm that do not have every │ │ │ │ + piece. num_downloaded is the number of times the torrent has been │ │ │ │ + downloaded (not initiated, but the number of times a download has │ │ │ │ + completed). │ │ │ │ + Leaving any of these values set to -1 indicates we don't know, or we have │ │ │ │ + not received any scrape data. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eemmppttyy(()) ********** │ │ │ │ -bool eemmppttyy () const noexcept; │ │ │ │ -returns true if the _b_i_t_f_i_e_l_d has zero size. │ │ │ │ + url_seeds │ │ │ │ + URLs can be added to these two lists to specify additional web seeds to │ │ │ │ + be used by the torrent. If the override_web_seeds flag is set, these will │ │ │ │ + be the _only_ ones to be used. i.e. any web seeds found in the .torrent │ │ │ │ + file will be overridden. │ │ │ │ + URLs are expected to be regular web servers, aka "get right" style, │ │ │ │ + specified in _B_E_P_ _1_9. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddaattaa(()) ********** │ │ │ │ -char* ddaattaa () noexcept; │ │ │ │ -char const* ddaattaa () const noexcept; │ │ │ │ -returns a pointer to the internal buffer of the _b_i_t_f_i_e_l_d, or nullptr if it's │ │ │ │ -empty. │ │ │ │ + peers │ │ │ │ + peers to add to the torrent, to be tried to be connected to as bittorrent │ │ │ │ + peers. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sswwaapp(()) ********** │ │ │ │ -void sswwaapp (bitfield& rhs) noexcept; │ │ │ │ -swaps the bit-fields two variables refer to │ │ │ │ + banned_peers │ │ │ │ + peers banned from this torrent. They will not be connected to │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccoouunntt(()) ********** │ │ │ │ -int ccoouunntt () const noexcept; │ │ │ │ -count the number of bits in the _b_i_t_f_i_e_l_d that are set to 1. │ │ │ │ + unfinished_pieces │ │ │ │ + this is a map of partially downloaded piece. The key is the piece index │ │ │ │ + and the value is a _b_i_t_f_i_e_l_d where each bit represents a 16 kiB block. A │ │ │ │ + set bit means we have that block. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinndd__ffiirrsstt__sseett(()) ********** │ │ │ │ -int ffiinndd__ffiirrsstt__sseett () const noexcept; │ │ │ │ -returns the index of the first set bit in the _b_i_t_f_i_e_l_d, i.e. 1 bit. │ │ │ │ + have_pieces │ │ │ │ + this is a _b_i_t_f_i_e_l_d indicating which pieces we already have of this │ │ │ │ + torrent. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinndd__llaasstt__cclleeaarr(()) ********** │ │ │ │ -int ffiinndd__llaasstt__cclleeaarr () const noexcept; │ │ │ │ -returns the index to the last cleared bit in the _b_i_t_f_i_e_l_d, i.e. 0 bit. │ │ │ │ + verified_pieces │ │ │ │ + when in seed_mode, pieces with a set bit in this _b_i_t_f_i_e_l_d have been │ │ │ │ + verified to be valid. Other pieces will be verified the first time a peer │ │ │ │ + requests it. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhaasshheerr ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ -this is a SHA-1 hash class. │ │ │ │ -You use it by first instantiating it, then call update() to feed it with data. │ │ │ │ -i.e. you don't have to keep the entire buffer of which you want to create the │ │ │ │ -hash in memory. You can feed the _h_a_s_h_e_r parts of it at a time. When You have │ │ │ │ -fed the _h_a_s_h_e_r with all the data, you call final() and it will return the sha1- │ │ │ │ -hash of the data. │ │ │ │ -The constructor that takes a char const* and an integer will construct the sha1 │ │ │ │ -context and feed it the data passed in. │ │ │ │ -If you want to reuse the _h_a_s_h_e_r object once you have created a hash, you have │ │ │ │ -to call reset() to reinitialize it. │ │ │ │ -The built-in software version of sha1-algorithm was implemented by Steve Reid │ │ │ │ -and released as public domain. For more info, see src/sha1.cpp. │ │ │ │ -class hasher │ │ │ │ -{ │ │ │ │ - hhaasshheerr (); │ │ │ │ - hhaasshheerr (char const* data, int len); │ │ │ │ - explicit hhaasshheerr (span data); │ │ │ │ - hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ - hhaasshheerr (hasher&&) noexcept; │ │ │ │ - hhaasshheerr (hasher const&); │ │ │ │ - hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ - hasher& uuppddaattee (span data); │ │ │ │ - hasher& uuppddaattee (char const* data, int len); │ │ │ │ - sha1_hash ffiinnaall (); │ │ │ │ - void rreesseett (); │ │ │ │ -}; │ │ │ │ + piece_priorities │ │ │ │ + this sets the priorities for each individual piece in the torrent. Each │ │ │ │ + element in the vector represent the piece with the same index. If you set │ │ │ │ + both file- and piece priorities, file priorities will take precedence. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) hhaasshheerr(()) ********** │ │ │ │ -hhaasshheerr (char const* data, int len); │ │ │ │ -explicit hhaasshheerr (span data); │ │ │ │ -hasher& ooppeerraattoorr== (hasher const&) &; │ │ │ │ -hhaasshheerr (hasher&&) noexcept; │ │ │ │ -hhaasshheerr (hasher const&); │ │ │ │ -hasher& ooppeerraattoorr== (hasher&&) & noexcept; │ │ │ │ -this is the same as default constructing followed by a call to update(data, │ │ │ │ -len). │ │ │ │ + merkle_trees │ │ │ │ + v2 hashes, if known │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** uuppddaattee(()) ********** │ │ │ │ -hasher& uuppddaattee (span data); │ │ │ │ -hasher& uuppddaattee (char const* data, int len); │ │ │ │ -append the following bytes to what is being hashed │ │ │ │ + merkle_tree_mask │ │ │ │ + if set, indicates which hashes are included in the corresponding vector │ │ │ │ + of merkle_trees. These bitmasks always cover the full tree, a cleared bit │ │ │ │ + means the hash is all zeros (i.e. not set) and set bit means the next │ │ │ │ + hash in the corresponding vector in merkle_trees is the hash for that │ │ │ │ + node. This is an optimization to avoid storing a lot of zeros. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinnaall(()) ********** │ │ │ │ -sha1_hash ffiinnaall (); │ │ │ │ -returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ -_h_a_s_h_e_r constructor. │ │ │ │ + verified_leaf_hashes │ │ │ │ + bit-fields indicating which v2 leaf hashes have been verified against the │ │ │ │ + root hash. If this vector is empty and merkle_trees is non-empty it │ │ │ │ + implies that all hashes in merkle_trees are verified. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseett(()) ********** │ │ │ │ -void rreesseett (); │ │ │ │ -restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ -constructed. │ │ │ │ + renamed_files │ │ │ │ + this is a map of file indices in the torrent and new _f_i_l_e_n_a_m_e_s to be │ │ │ │ + applied before the torrent is added. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhaasshheerr225566 ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_h_a_s_h_e_r_._h_p_p" │ │ │ │ -hasher256 computes a SHA-256 message digest. It is the counterpart to hasher │ │ │ │ -(which computes SHA-1) and is used for BitTorrent v2 piece and merkle-tree │ │ │ │ -hashes. It can be fed input incrementally via update() and the digest is │ │ │ │ -produced by final(). Call reset() to reuse the object for another digest. │ │ │ │ -class hasher256 │ │ │ │ + last_download last_upload │ │ │ │ + the posix time of the last time payload was received or sent for this │ │ │ │ + torrent, respectively. A value of 0 means we don't know when we last │ │ │ │ + uploaded or downloaded, or we have never uploaded or downloaded any │ │ │ │ + payload for this torrent. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + comment │ │ │ │ + if a comment is found in the torrent file this will be set to that │ │ │ │ + comment │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + created_by │ │ │ │ + an optional string naming the software used to create the torrent file │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + creation_date │ │ │ │ + if a creation date is found in the torrent file this will be set to that, │ │ │ │ + otherwise it'll be 1970, Jan 1 │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + root_certificate │ │ │ │ + If this torrent is an infohash only SSL torrent, specify the root │ │ │ │ + certificate here. If a peer does not have a matching certificate during │ │ │ │ + metadata exchange it will be rejected and the download will not proceed. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ cclliieenntt__ddaattaa__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_l_i_e_n_t___d_a_t_a_._h_p_p" │ │ │ │ +A thin wrapper around a void pointer used as "user data". i.e. an opaque cookie │ │ │ │ +passed in to libtorrent and returned on demand. It adds type-safety by │ │ │ │ +requiring the same type be requested out of it as was assigned to it. │ │ │ │ +struct client_data_t │ │ │ │ { │ │ │ │ - hhaasshheerr225566 (); │ │ │ │ - hhaasshheerr225566 (char const* data, int len); │ │ │ │ - hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ - hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ - explicit hhaasshheerr225566 (span data); │ │ │ │ - hhaasshheerr225566 (hasher256 const&); │ │ │ │ - hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ - hasher256& uuppddaattee (span data); │ │ │ │ - hasher256& uuppddaattee (char const* data, int len); │ │ │ │ - sha256_hash ffiinnaall (); │ │ │ │ - void rreesseett (); │ │ │ │ - ~~hhaasshheerr225566 (); │ │ │ │ + cclliieenntt__ddaattaa__tt () = default; │ │ │ │ + explicit cclliieenntt__ddaattaa__tt (T* v); │ │ │ │ + client_data_t& ooppeerraattoorr== (T* v); │ │ │ │ + explicit operator TT () const; │ │ │ │ + T* ggeett () const; │ │ │ │ + operator void ccoonnsstt** () const = delete; │ │ │ │ + operator vvooiidd** () const = delete; │ │ │ │ + client_data_t& ooppeerraattoorr== (void const*) = delete; │ │ │ │ + client_data_t& ooppeerraattoorr== (void*) = delete; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) hhaasshheerr225566(()) ********** │ │ │ │ -hhaasshheerr225566 (char const* data, int len); │ │ │ │ -hasher256& ooppeerraattoorr== (hasher256&&) & noexcept; │ │ │ │ -hhaasshheerr225566 (hasher256&&) noexcept; │ │ │ │ -explicit hhaasshheerr225566 (span data); │ │ │ │ -hhaasshheerr225566 (hasher256 const&); │ │ │ │ -hasher256& ooppeerraattoorr== (hasher256 const&) &; │ │ │ │ -this is the same as default constructing followed by a call to update(data, │ │ │ │ -len). │ │ │ │ +********** cclliieenntt__ddaattaa__tt(()) ********** │ │ │ │ +cclliieenntt__ddaattaa__tt () = default; │ │ │ │ +construct a nullptr client data │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** uuppddaattee(()) ********** │ │ │ │ -hasher256& uuppddaattee (span data); │ │ │ │ -hasher256& uuppddaattee (char const* data, int len); │ │ │ │ -append the following bytes to what is being hashed │ │ │ │ +********** cclliieenntt__ddaattaa__tt(()) ********** │ │ │ │ +explicit cclliieenntt__ddaattaa__tt (T* v); │ │ │ │ +initialize the client data with the specified pointer │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinnaall(()) ********** │ │ │ │ -sha256_hash ffiinnaall (); │ │ │ │ -returns the SHA-1 digest of the buffers previously passed to _u_p_d_a_t_e_(_) and the │ │ │ │ -_h_a_s_h_e_r constructor. │ │ │ │ +********** ooppeerraattoorr==(()) ********** │ │ │ │ +client_data_t& ooppeerraattoorr== (T* v); │ │ │ │ +assigns a new pointer to the client data │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseett(()) ********** │ │ │ │ -void rreesseett (); │ │ │ │ -restore the _h_a_s_h_e_r state to be as if the _h_a_s_h_e_r has just been default │ │ │ │ -constructed. │ │ │ │ +********** TT(()) ggeett(()) ********** │ │ │ │ +explicit operator TT () const; │ │ │ │ +T* ggeett () const; │ │ │ │ +request to retrieve the pointer back again. The type T must be identical to the │ │ │ │ +type of the pointer assigned earlier, including const & volatile qualifiers. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ccoonnsstt**(()) ooppeerraattoorr==(()) vvooiidd**(()) ********** │ │ │ │ +operator void ccoonnsstt** () const = delete; │ │ │ │ +operator vvooiidd** () const = delete; │ │ │ │ +client_data_t& ooppeerraattoorr== (void const*) = delete; │ │ │ │ +client_data_t& ooppeerraattoorr== (void*) = delete; │ │ │ │ +we don't allow type-unsafe operations │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ttoorrrreenntt__ssttaattuuss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___s_t_a_t_u_s_._h_p_p" │ │ │ │ holds a snapshot of the status of a torrent, as queried by _t_o_r_r_e_n_t___h_a_n_d_l_e_:_: │ │ │ │ _s_t_a_t_u_s_(_). │ │ │ │ struct torrent_status │ │ │ │ { │ │ │ │ @@ -10990,2178 +13238,218 @@ │ │ │ │ flags │ │ │ │ reflects several of the torrent's flags. For more information, see │ │ │ │ torrent_handle::flags(). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ renamed_files │ │ │ │ contains a mapping of any files that have been renamed in this torrent. │ │ │ │ It can act as an overlay over _f_i_l_e___s_t_o_r_a_g_e (which is immutable). │ │ │ │ +Bencoding is a common representation in bittorrent used for dictionary, list, │ │ │ │ +_i_n_t and string hierarchies. It's used to encode .torrent files and some │ │ │ │ +messages in the network protocol. libtorrent also uses it to store settings, │ │ │ │ +resume data and other _s_e_s_s_i_o_n state. │ │ │ │ +Strings in bencoded structures do not necessarily represent text. Strings are │ │ │ │ +raw byte buffers of a certain length. If a string is meant to be interpreted as │ │ │ │ +text, it is required to be UTF-8 encoded. See _B_E_P_ _3. │ │ │ │ +The function for decoding bencoded data _b_d_e_c_o_d_e_(_), returning a _b_d_e_c_o_d_e___n_o_d_e. │ │ │ │ +This function builds a tree that points back into the original buffer. The │ │ │ │ +returned _b_d_e_c_o_d_e___n_o_d_e will not be valid once the buffer it was parsed out of is │ │ │ │ +discarded. │ │ │ │ +It's possible to construct an _e_n_t_r_y from a _b_d_e_c_o_d_e___n_o_d_e, if a structure needs │ │ │ │ +to be altered and re-encoded. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ aannnnoouunnccee__iinnffoohhaasshh ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ -holds the per-info-hash state for a tracker, separately for the v1 and v2 info- │ │ │ │ -hashes. Since a hybrid torrent has both info-hashes, the state for the two │ │ │ │ -announces (the message returned by the tracker, the time of the next announce, │ │ │ │ -the most recent scrape numbers, etc.) are kept independently. announce_endpoint │ │ │ │ -owns one announce_infohash for each protocol version. │ │ │ │ -struct announce_infohash │ │ │ │ -{ │ │ │ │ - std::string message; │ │ │ │ - error_code last_error; │ │ │ │ - int ssccrraappee__iinnccoommpplleettee = -1; │ │ │ │ - int ssccrraappee__ccoommpplleettee = -1; │ │ │ │ - int ssccrraappee__ddoowwnnllooaaddeedd = -1; │ │ │ │ - std::uint8_t fails : 7; │ │ │ │ - bool updating : 1; │ │ │ │ - bool start_sent : 1; │ │ │ │ - bool complete_sent : 1; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - message │ │ │ │ - if this tracker has returned an error or warning message that message is │ │ │ │ - stored here │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - last_error │ │ │ │ - if this tracker failed the last time it was contacted this error code │ │ │ │ - specifies what error occurred │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - scrape_incomplete scrape_complete scrape_downloaded │ │ │ │ - if this tracker has returned scrape data, these fields are filled in with │ │ │ │ - valid numbers. Otherwise they are set to -1. incomplete counts the number │ │ │ │ - of current downloaders. complete counts the number of current peers │ │ │ │ - completed the download, or "seeds". downloaded is the cumulative number │ │ │ │ - of completed downloads. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - fails │ │ │ │ - the number of times in a row we have failed to announce to this tracker. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - updating │ │ │ │ - true while we're waiting for a response from the tracker. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - start_sent │ │ │ │ - set to true when we get a valid response from an announce with │ │ │ │ - event=started. If it is set, we won't send start in the subsequent │ │ │ │ - announces. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - complete_sent │ │ │ │ - set to true when we send a event=completed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ aannnnoouunnccee__eennddppooiinntt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ -announces are sent to each tracker using every listen socket this class holds │ │ │ │ -information about one listen socket for one tracker │ │ │ │ -struct announce_endpoint │ │ │ │ -{ │ │ │ │ - aannnnoouunnccee__eennddppooiinntt (); │ │ │ │ - │ │ │ │ - _t_c_p_:_:_e_n_d_p_o_i_n_t local_endpoint; │ │ │ │ - aux::array info_hashes; │ │ │ │ - bool eennaabblleedd = true; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - local_endpoint │ │ │ │ - the local endpoint of the listen interface associated with this endpoint │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - info_hashes │ │ │ │ - info_hashes[0] is the v1 info hash (SHA1) info_hashes[1] is the v2 info │ │ │ │ - hash (truncated SHA-256) │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - enabled │ │ │ │ - set to false to not announce from this endpoint │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ aannnnoouunnccee__eennttrryy ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ -this class holds information about one bittorrent tracker, as it relates to a │ │ │ │ -specific torrent. │ │ │ │ -struct announce_entry │ │ │ │ +************ eennttrryy ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_n_t_r_y_._h_p_p" │ │ │ │ +The entry class represents one node in a bencoded hierarchy. It works as a │ │ │ │ +variant type, it can be either a list, a dictionary (std::map), an integer or a │ │ │ │ +string. │ │ │ │ +struct entry : entry_types::variant_type │ │ │ │ { │ │ │ │ - announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ - ~~aannnnoouunnccee__eennttrryy (); │ │ │ │ - aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ - aannnnoouunnccee__eennttrryy (); │ │ │ │ - explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ + data_type ttyyppee () const; │ │ │ │ + eennttrryy (span); │ │ │ │ + eennttrryy (dictionary_type); │ │ │ │ + eennttrryy (string_view); │ │ │ │ + eennttrryy (string_type); │ │ │ │ + eennttrryy (list_type); │ │ │ │ + eennttrryy (preformatted_type); │ │ │ │ + eennttrryy (integer_type); │ │ │ │ + eennttrryy (data_type t); │ │ │ │ + eennttrryy (bdecode_node const& n); │ │ │ │ + entry& ooppeerraattoorr== (dictionary_type) &; │ │ │ │ + entry& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ + entry& ooppeerraattoorr== (integer_type) &; │ │ │ │ + entry& ooppeerraattoorr== (entry const&) &; │ │ │ │ + entry& ooppeerraattoorr== (entry&&) & ; │ │ │ │ + entry& ooppeerraattoorr== (span) &; │ │ │ │ + entry& ooppeerraattoorr== (preformatted_type) &; │ │ │ │ + entry& ooppeerraattoorr== (string_view) &; │ │ │ │ + entry& ooppeerraattoorr== (string_type) &; │ │ │ │ + entry& ooppeerraattoorr== (list_type) &; │ │ │ │ + preformatted_type const& pprreeffoorrmmaatttteedd () const; │ │ │ │ + integer_type const& iinntteeggeerr () const; │ │ │ │ + preformatted_type& pprreeffoorrmmaatttteedd (); │ │ │ │ + dictionary_type& ddiicctt (); │ │ │ │ + dictionary_type const& ddiicctt () const; │ │ │ │ + integer_type& iinntteeggeerr (); │ │ │ │ + string_type& ssttrriinngg (); │ │ │ │ + string_type const& ssttrriinngg () const; │ │ │ │ + list_type const& lliisstt () const; │ │ │ │ + list_type& lliisstt (); │ │ │ │ + entry const& ooppeerraattoorr[[]] (string_view key) const; │ │ │ │ + entry& ooppeerraattoorr[[]] (string_view key); │ │ │ │ + entry* ffiinndd__kkeeyy (string_view key); │ │ │ │ + entry const* ffiinndd__kkeeyy (string_view key) const; │ │ │ │ + std::string ttoo__ssttrriinngg (bool single_line = false) const; │ │ │ │ │ │ │ │ - enum tracker_source │ │ │ │ + enum data_type │ │ │ │ { │ │ │ │ - source_torrent, │ │ │ │ - source_client, │ │ │ │ - source_magnet_link, │ │ │ │ - source_tex, │ │ │ │ + int_t, │ │ │ │ + string_t, │ │ │ │ + list_t, │ │ │ │ + dictionary_t, │ │ │ │ + preformatted_t, │ │ │ │ + undefined_t, │ │ │ │ }; │ │ │ │ - │ │ │ │ - std::string url; │ │ │ │ - std::string trackerid; │ │ │ │ - std::vector endpoints; │ │ │ │ - std::uint8_t ttiieerr = 0; │ │ │ │ - std::uint8_t ffaaiill__lliimmiitt = 0; │ │ │ │ - std::uint8_t source:4; │ │ │ │ - bool verified:1; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~aannnnoouunnccee__eennttrryy(()) ooppeerraattoorr==(()) aannnnoouunnccee__eennttrryy(()) ********** │ │ │ │ -announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ -~~aannnnoouunnccee__eennttrryy (); │ │ │ │ -aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ -aannnnoouunnccee__eennttrryy (); │ │ │ │ -explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ -constructs a tracker announce _e_n_t_r_y with u as the URL. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ttrraacckkeerr__ssoouurrccee ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_u_r_c_e___t_o_r_r_e_n_t_ _ _ _ _|_1_ _ _ _ _|_t_h_e_ _t_r_a_c_k_e_r_ _w_a_s_ _p_a_r_t_ _o_f_ _t_h_e_ _._t_o_r_r_e_n_t_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|source_client |2 |the tracker was added programmatically via the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_a_d_d___t_r_a_c_k_e_r_(_)_ _f_u_n_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_u_r_c_e___m_a_g_n_e_t___l_i_n_k_|_4_ _ _ _ _|_t_h_e_ _t_r_a_c_k_e_r_ _w_a_s_ _p_a_r_t_ _o_f_ _a_ _m_a_g_n_e_t_ _l_i_n_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|source_tex |8 |the tracker was received from the swarm via tracker| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_e_x_c_h_a_n_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - url │ │ │ │ - tracker URL as it appeared in the torrent file │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - trackerid │ │ │ │ - the current &trackerid= argument passed to the tracker. this is optional │ │ │ │ - and is normally empty (in which case no trackerid is sent). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - endpoints │ │ │ │ - each local listen socket (endpoint) will announce to the tracker. This │ │ │ │ - list contains state per endpoint. │ │ │ │ +********** ttyyppee(()) ********** │ │ │ │ +data_type ttyyppee () const; │ │ │ │ +returns the concrete type of the _e_n_t_r_y │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - tier │ │ │ │ - the tier this tracker belongs to │ │ │ │ +********** eennttrryy(()) ********** │ │ │ │ +eennttrryy (span); │ │ │ │ +eennttrryy (dictionary_type); │ │ │ │ +eennttrryy (string_view); │ │ │ │ +eennttrryy (string_type); │ │ │ │ +eennttrryy (list_type); │ │ │ │ +eennttrryy (preformatted_type); │ │ │ │ +eennttrryy (integer_type); │ │ │ │ +constructors directly from a specific type. The content of the argument is │ │ │ │ +copied into the newly constructed _e_n_t_r_y │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - fail_limit │ │ │ │ - the max number of failures to announce to this tracker in a row, before │ │ │ │ - this tracker is not used anymore. 0 means unlimited │ │ │ │ +********** eennttrryy(()) ********** │ │ │ │ +eennttrryy (data_type t); │ │ │ │ +construct an empty _e_n_t_r_y of the specified type. see _d_a_t_a___t_y_p_e enum. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - source │ │ │ │ - a bitmask specifying which sources we got this tracker from. │ │ │ │ +********** eennttrryy(()) ********** │ │ │ │ +eennttrryy (bdecode_node const& n); │ │ │ │ +construct from _b_d_e_c_o_d_e___n_o_d_e parsed form (see _b_d_e_c_o_d_e_(_)) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - verified │ │ │ │ - set to true the first time we receive a valid response from this tracker. │ │ │ │ -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: │ │ │ │ +********** ooppeerraattoorr==(()) ********** │ │ │ │ +entry& ooppeerraattoorr== (dictionary_type) &; │ │ │ │ +entry& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ +entry& ooppeerraattoorr== (integer_type) &; │ │ │ │ +entry& ooppeerraattoorr== (entry const&) &; │ │ │ │ +entry& ooppeerraattoorr== (entry&&) & ; │ │ │ │ +entry& ooppeerraattoorr== (span) &; │ │ │ │ +entry& ooppeerraattoorr== (preformatted_type) &; │ │ │ │ +entry& ooppeerraattoorr== (string_view) &; │ │ │ │ +entry& ooppeerraattoorr== (string_type) &; │ │ │ │ +entry& ooppeerraattoorr== (list_type) &; │ │ │ │ +copies the structure of the right hand side into this _e_n_t_r_y. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseettttiinnggss__ppaacckk ************ │ │ │ │ -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 settings_pack struct, contains the names of all settings as enum values. │ │ │ │ -These values are passed in to the set_str(), set_int(), set_bool() functions, │ │ │ │ -to specify the setting to change. │ │ │ │ -The settings_pack only stores values for settings that have been explicitly set │ │ │ │ -on this object. However, it can still be queried for settings that have not │ │ │ │ -been set and returns the default value for those settings. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ | │ │ │ │ -|_u_s_e_r___a_g_e_n_t_|_s_t_r_i_n_g_|_l_i_b_t_o_r_r_e_n_t_/| │ │ │ │ -this is the client identification to the tracker. The recommended format of │ │ │ │ -this string is: "client-name/client-version libtorrent/libtorrent-version". │ │ │ │ -This name will not only be used when making HTTP requests, but also when │ │ │ │ -sending extended headers to peers that support that extension. It may not │ │ │ │ -contain r or n │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_n_n_o_u_n_c_e___i_p_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -announce_ip is the ip address passed along to trackers as the &ip= parameter. │ │ │ │ -If left as the default, that parameter is omitted. │ │ │ │ -Note │ │ │ │ -This setting is only meant for very special cases where a seed is running on │ │ │ │ -the same host as the tracker, and the tracker accepts the IP parameter (which │ │ │ │ -normal trackers don't). Do not set this option unless you also control the │ │ │ │ -tracker. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_h_a_n_d_s_h_a_k_e___c_l_i_e_n_t___v_e_r_s_i_o_n_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -this is the client name and version identifier sent to peers in the handshake │ │ │ │ -message. If this is an empty string, the user_agent is used instead. This │ │ │ │ -string must be a UTF-8 encoded unicode string. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_o_u_t_g_o_i_n_g___i_n_t_e_r_f_a_c_e_s_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -This controls which IP address outgoing TCP peer connections are bound to, in │ │ │ │ -addition to controlling whether such connections are also bound to a specific │ │ │ │ -network interface/adapter (bbiinndd--ttoo--ddeevviiccee). │ │ │ │ -This string is a comma-separated list of IP addresses and interface names. An │ │ │ │ -empty string will not bind TCP sockets to a device, and let the network stack │ │ │ │ -assign the local address. │ │ │ │ -A list of names will be used to bind outgoing TCP sockets in a round-robin │ │ │ │ -fashion. An IP address will simply be used tobind()the socket. An interface │ │ │ │ -name will attempt to bind the socket to that interface. If that fails, or is │ │ │ │ -unsupported, one of the IP addresses configured for that interface is used │ │ │ │ -tobind()the socket to. If the interface or adapter doesn't exist, the outgoing │ │ │ │ -peer connection will fail with an error message suggesting the device cannot be │ │ │ │ -found. Adapter names on Unix systems are of the form "eth0", "eth1", "tun0", │ │ │ │ -etc. This may be useful for clients that are multi-homed. Binding an outgoing │ │ │ │ -connection to a local IP does not necessarily make the connection via the │ │ │ │ -associated NIC/Adapter. │ │ │ │ -When outgoing interfaces are specified, incoming connections or packets sent to │ │ │ │ -a local interface or IP that's nnoott in this list will be rejected with a │ │ │ │ -_p_e_e_r___b_l_o_c_k_e_d___a_l_e_r_t with invalid_local_interface as the reason. │ │ │ │ -Note that these are just interface/adapter names or IP addresses. There are no │ │ │ │ -ports specified in this list. IPv6 addresses without port should be specified │ │ │ │ -without enclosing [, ]. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_l_i_s_t_e_n___i_n_t_e_r_f_a_c_e_s_|_s_t_r_i_n_g_|_0_._0_._0_._0_:_6_8_8_1_,_[_:_:_]_:_6_8_8_1| │ │ │ │ -a comma-separated list of (IP or device name, port) pairs. These are the listen │ │ │ │ -ports that will be opened for accepting incoming uTP and TCP peer connections. │ │ │ │ -These are also used for oouuttggooiinngg uTP and UDP tracker connections and DHT nodes. │ │ │ │ -It is possible to listen on multiple interfaces and multiple ports. Binding to │ │ │ │ -port 0 will make the operating system pick the port. │ │ │ │ -Note │ │ │ │ -There are reasons to stick to the same port across sessions, which would mean │ │ │ │ -only using port 0 on the first start, and recording the port that was picked │ │ │ │ -for subsequent startups. Trackers, the DHT and other peers will remember the │ │ │ │ -port they see you use and hand that port out to other peers trying to connect │ │ │ │ -to you, as well as trying to connect to you themselves. │ │ │ │ -A port that has an "s" suffix will accept SSL peer connections. (note that SSL │ │ │ │ -sockets are only available in builds with SSL support) │ │ │ │ -A port that has an "l" suffix will be considered a local network. i.e. it's │ │ │ │ -assumed to only be able to reach hosts in the same local network as the IP │ │ │ │ -address (based on the netmask associated with the IP, queried from the │ │ │ │ -operating system). │ │ │ │ -if binding fails, the _l_i_s_t_e_n___f_a_i_l_e_d___a_l_e_r_t is posted. Once a socket binding │ │ │ │ -succeeds (if it does), the _l_i_s_t_e_n___s_u_c_c_e_e_d_e_d___a_l_e_r_t is posted. There may be │ │ │ │ -multiple failures before a success. │ │ │ │ -If a device name that does not exist is configured, no listen socket will be │ │ │ │ -opened for that interface. If this is the only interface configured, it will be │ │ │ │ -as if no listen ports are configured. │ │ │ │ -If no listen ports are configured (e.g. listen_interfaces is an empty string), │ │ │ │ -networking will be disabled. No DHT will start, no outgoing uTP or tracker │ │ │ │ -connections will be made. No incoming TCP or uTP connections will be accepted. │ │ │ │ -(outgoing TCP connections will still be possible, depending on _s_e_t_t_i_n_g_s___p_a_c_k_:_: │ │ │ │ -_o_u_t_g_o_i_n_g___i_n_t_e_r_f_a_c_e_s). │ │ │ │ -For example: [::1]:8888 - will only accept connections on the IPv6 loopback │ │ │ │ -address on port 8888. │ │ │ │ -eth0:4444,eth1:4444 - will accept connections on port 4444 on any IP address │ │ │ │ -bound to device eth0 or eth1. │ │ │ │ -[::]:0s - will accept SSL connections on a port chosen by the OS. And not │ │ │ │ -accept non-SSL connections at all. │ │ │ │ -0.0.0.0:6881,[::]:6881 - binds to all interfaces on port 6881. │ │ │ │ -10.0.1.13:6881l - binds to the local IP address, port 6881, but only allow │ │ │ │ -talking to peers on the same local network. The netmask is queried from the │ │ │ │ -operating system. Interfaces marked l are not announced to trackers, unless the │ │ │ │ -tracker is also on the same local network. │ │ │ │ -Windows OS network adapter device name must be specified with GUID. It can be │ │ │ │ -obtained from "netsh lan show interfaces" command output. GUID must be │ │ │ │ -uppercased string embraced in curly brackets. {E4F0B674-0DFC-48BB-98A5- │ │ │ │ -2AA730BDB6D6}:7777 - will accept connections on port 7777 on adapter with this │ │ │ │ -GUID. │ │ │ │ -For more information, see the _M_u_l_t_i_-_h_o_m_e_d_ _h_o_s_t_s section. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_o_x_y___h_o_s_t_n_a_m_e_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -when using a proxy, this is the hostname where the proxy is running see │ │ │ │ -proxy_type. Note that when using a proxy, the _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 │ │ │ │ -setting is overridden and only a single interface is created, just to contact │ │ │ │ -the proxy. This means a proxy cannot be combined with SSL torrents or multiple │ │ │ │ -listen interfaces. This proxy listen interface will not accept incoming TCP │ │ │ │ -connections, will not map ports with any gateway and will not enable local │ │ │ │ -service discovery. All traffic is supposed to be channeled through the proxy. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_o_x_y___u_s_e_r_n_a_m_e_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -|_p_r_o_x_y___p_a_s_s_w_o_r_d_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -when using a proxy, these are the credentials (if any) to use when connecting │ │ │ │ -to it. see proxy_type │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_2_p___h_o_s_t_n_a_m_e_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -sets the _i_2_p SAM bridge to connect to. set the port with the i2p_port setting. │ │ │ │ -Unless this is set, i2p torrents are not supported. This setting is separate │ │ │ │ -from the other proxy settings since i2p torrents and their peers are │ │ │ │ -orthogonal. You can have i2p peers as well as regular peers via a proxy. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ | │ │ │ │ -|_p_e_e_r___f_i_n_g_e_r_p_r_i_n_t_|_s_t_r_i_n_g_|_-_L_T_2_1_0_0_-| │ │ │ │ -this is the fingerprint for the client. It will be used as the prefix to the │ │ │ │ -peer_id. If this is 20 bytes (or longer) it will be truncated to 20 bytes and │ │ │ │ -used as the entire peer-id │ │ │ │ -There is a utility function, _g_e_n_e_r_a_t_e___f_i_n_g_e_r_p_r_i_n_t_(_) that can be used to │ │ │ │ -generate a standard client peer ID fingerprint prefix. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_h_t___b_o_o_t_s_t_r_a_p___n_o_d_e_s_|_s_t_r_i_n_g_|_d_h_t_._l_i_b_t_o_r_r_e_n_t_._o_r_g_:_2_5_4_0_1| │ │ │ │ -This is a comma-separated list of IP port-pairs. They will be added to the DHT │ │ │ │ -node (if it's enabled) as back-up nodes in case we don't know of any. │ │ │ │ -Changing these after the DHT has been started may not have any effect until the │ │ │ │ -DHT is restarted. Here are some other bootstrap nodes that may work: │ │ │ │ -router.bittorrent.com:6881, dht.transmissionbt.com:6881 router.bt.ouinet.work: │ │ │ │ -6881, │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_n_a_t_p_m_p___g_a_t_e_w_a_y_|_s_t_r_i_n_g_|_ _ _ _ _ _ _ | │ │ │ │ -Overrides the NAT-PMP service gateway. When set, libtorrent won't try to │ │ │ │ -resolve the default gateway and instead will send the requests to the address │ │ │ │ -specified. This only takes affect when NAT-PMP first starts. If you change this │ │ │ │ -setting after NAT-PMP has been enabled, you need to disable it and re-enable │ │ │ │ -it. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_ _ _|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_w_e_b_t_o_r_r_e_n_t___s_t_u_n___s_e_r_v_e_r_|_s_t_r_i_n_g_|_s_t_u_n_._l_._g_o_o_g_l_e_._c_o_m_:_1_9_3_0_2| │ │ │ │ -This is the STUN server used by WebTorrent to enable ICE NAT traversal for │ │ │ │ -WebRTC. It must have the format hostname:port. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_l_o_w___m_u_l_t_i_p_l_e___c_o_n_n_e_c_t_i_o_n_s___p_e_r___i_p_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -determines if connections from the same IP address as existing connections │ │ │ │ -should be rejected or not. Rejecting multiple connections from the same IP │ │ │ │ -address will prevent abusive behavior by peers. The logic for determining │ │ │ │ -whether connections are to the same peer is more complicated with this enabled, │ │ │ │ -and more likely to fail in some edge cases. It is not recommended to enable │ │ │ │ -this feature. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_e_n_d___r_e_d_u_n_d_a_n_t___h_a_v_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -send_redundant_have controls if have messages will be sent to peers that │ │ │ │ -already have the piece. This is typically not necessary, but it might be │ │ │ │ -necessary for collecting statistics in some cases. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_s_e___d_h_t___a_s___f_a_l_l_b_a_c_k_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -use_dht_as_fallback determines how the DHT is used. If this is true, the DHT │ │ │ │ -will only be used for torrents where all trackers in its tracker list has │ │ │ │ -failed. Either by an explicit error message or a time out. If this is false, │ │ │ │ -the DHT is used regardless of if the trackers fail or not. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_p_n_p___i_g_n_o_r_e___n_o_n_r_o_u_t_e_r_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -upnp_ignore_nonrouters indicates whether or not the UPnP implementation should │ │ │ │ -ignore any broadcast response from a device whose address is not on our subnet. │ │ │ │ -i.e. it's a way to not talk to other people's routers by mistake. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_s_e___p_a_r_o_l_e___m_o_d_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -use_parole_mode specifies if parole mode should be used. Parole mode means that │ │ │ │ -peers that participate in pieces that fail the hash check are put in a mode │ │ │ │ -where they are only allowed to download whole pieces. If the whole piece a peer │ │ │ │ -in parole mode fails the hash check, it is banned. If a peer participates in a │ │ │ │ -piece that passes the hash check, it is taken out of parole mode. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_u_t_o___m_a_n_a_g_e___p_r_e_f_e_r___s_e_e_d_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -if true, prefer seeding torrents when determining which torrents to give active │ │ │ │ -slots to. If false, give preference to downloading torrents │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_o_n_t___c_o_u_n_t___s_l_o_w___t_o_r_r_e_n_t_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if dont_count_slow_torrents is true, torrents without any payload transfers are │ │ │ │ -not subject to the active_seeds and active_downloads limits. This is intended │ │ │ │ -to make it more likely to utilize all available bandwidth, and avoid having │ │ │ │ -torrents that don't transfer anything block the active slots. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_c_l_o_s_e___r_e_d_u_n_d_a_n_t___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -close_redundant_connections specifies whether libtorrent should close │ │ │ │ -connections where both ends have no utility in keeping the connection open. For │ │ │ │ -instance if both ends have completed their downloads, there's no point in │ │ │ │ -keeping it open. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_i_o_r_i_t_i_z_e___p_a_r_t_i_a_l___p_i_e_c_e_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -If prioritize_partial_pieces is true, partial pieces are picked before pieces │ │ │ │ -that are more rare. If false, rare pieces are always prioritized, unless the │ │ │ │ -number of partial pieces is growing out of proportion. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_a_t_e___l_i_m_i_t___i_p___o_v_e_r_h_e_a_d_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if set to true, the estimated TCP/IP overhead is drained from the rate │ │ │ │ -limiters, to avoid exceeding the limits with the total traffic │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_n_n_o_u_n_c_e___t_o___a_l_l___t_i_e_r_s_ _ _ _|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -|_a_n_n_o_u_n_c_e___t_o___a_l_l___t_r_a_c_k_e_r_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -announce_to_all_trackers controls how multi tracker torrents are treated. If │ │ │ │ -this is set to true, all trackers in the same tier are announced to in │ │ │ │ -parallel. If all trackers in tier 0 fails, all trackers in tier 1 are announced │ │ │ │ -as well. If it's set to false, the behavior is as defined by the multi tracker │ │ │ │ -specification. │ │ │ │ -announce_to_all_tiers also controls how multi tracker torrents are treated. │ │ │ │ -When this is set to true, one tracker from each tier is announced to. This is │ │ │ │ -the uTorrent behavior. To be compliant with the Multi-tracker specification, │ │ │ │ -set it to false. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_e_f_e_r___u_d_p___t_r_a_c_k_e_r_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -prefer_udp_trackers: true means that trackers may be rearranged in a way that │ │ │ │ -udp trackers are always tried before http trackers for the same hostname. │ │ │ │ -Setting this to false means that the tracker's tier is respected and there's no │ │ │ │ -preference of one protocol over another. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_i_s_a_b_l_e___h_a_s_h___c_h_e_c_k_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when set to true, all data downloaded from peers will be assumed to be correct, │ │ │ │ -and not tested to match the hashes in the torrent this is only useful for │ │ │ │ -simulation and testing purposes (typically combined with disabled_storage) │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_l_o_w___i_2_p___m_i_x_e_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -if this is true, i2p torrents are allowed to also get peers from other sources │ │ │ │ -than the tracker, and connect to regular IPs, not providing any anonymization. │ │ │ │ -This may be useful if the user is not interested in the anonymization of i2p, │ │ │ │ -but still wants to be able to connect to i2p peers. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_n_o___a_t_i_m_e___s_t_o_r_a_g_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -no_atime_storage this is a Linux-only option and passes in the O_NOATIME to │ │ │ │ -open() when opening files. This may lead to some disk performance improvements. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_n_c_o_m_i_n_g___s_t_a_r_t_s___q_u_e_u_e_d___t_o_r_r_e_n_t_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -incoming_starts_queued_torrents. If a torrent has been paused by the auto │ │ │ │ -managed feature in libtorrent, i.e. the torrent is paused and auto managed, │ │ │ │ -this feature affects whether or not it is automatically started on an incoming │ │ │ │ -connection. The main reason to queue torrents, is not to make them unavailable, │ │ │ │ -but to save on the overhead of announcing to the trackers, the DHT and to avoid │ │ │ │ -spreading one's unchoke slots too thin. If a peer managed to find us, even │ │ │ │ -though we're no in the torrent anymore, this setting can make us start the │ │ │ │ -torrent and serve it. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_e_p_o_r_t___t_r_u_e___d_o_w_n_l_o_a_d_e_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when set to true, the downloaded counter sent to trackers will include the │ │ │ │ -actual number of payload bytes downloaded including redundant bytes. If set to │ │ │ │ -false, it will not include any redundancy bytes │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_t_r_i_c_t___e_n_d___g_a_m_e___m_o_d_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -strict_end_game_mode controls when a block may be requested twice. If this is │ │ │ │ -true, a block may only be requested twice when there's at least one request to │ │ │ │ -every piece that's left to download in the torrent. This may slow down progress │ │ │ │ -on some pieces sometimes, but it may also avoid downloading a lot of redundant │ │ │ │ -bytes. If this is false, libtorrent attempts to use each peer connection to its │ │ │ │ -max, by always requesting something, even if it means requesting something that │ │ │ │ -has been requested from another peer already. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_e_n_a_b_l_e___o_u_t_g_o_i_n_g___u_t_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -|_e_n_a_b_l_e___i_n_c_o_m_i_n_g___u_t_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -|_e_n_a_b_l_e___o_u_t_g_o_i_n_g___t_c_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -|_e_n_a_b_l_e___i_n_c_o_m_i_n_g___t_c_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -Enables incoming and outgoing, TCP and uTP peer connections. false is disabled │ │ │ │ -and true is enabled. When outgoing connections are disabled, libtorrent will │ │ │ │ -simply not make outgoing peer connections with the specific transport protocol. │ │ │ │ -Disabled incoming peer connections will simply be rejected. These options only │ │ │ │ -apply to peer connections, not tracker- or any other kinds of connections. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_n_o___r_e_c_h_e_c_k___i_n_c_o_m_p_l_e_t_e___r_e_s_u_m_e_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -no_recheck_incomplete_resume determines if the storage should check the whole │ │ │ │ -files when resume data is incomplete or missing or whether it should simply │ │ │ │ -assume we don't have any of the data. If false, any existing files will be │ │ │ │ -checked. By setting this setting to true, the files won't be checked, but will │ │ │ │ -go straight to download mode. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_n_o_n_y_m_o_u_s___m_o_d_e_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -anonymous_mode: When set to true, the client tries to hide its identity to a │ │ │ │ -certain degree. │ │ │ │ - * A generic user-agent will be used for trackers (except for private │ │ │ │ - torrents). │ │ │ │ - * Your local IPv4 and IPv6 address won't be sent as query string parameters │ │ │ │ - to private trackers. │ │ │ │ - * If announce_ip is configured, it will not be sent to trackers │ │ │ │ - * The client version will not be sent to peers in the extension handshake. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_e_p_o_r_t___w_e_b___s_e_e_d___d_o_w_n_l_o_a_d_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -specifies whether downloads from web seeds is reported to the tracker or not. │ │ │ │ -Turning it off also excludes web seed traffic from other stats and download │ │ │ │ -rate reporting via the libtorrent API. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_e_e_d_i_n_g___o_u_t_g_o_i_n_g___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -seeding_outgoing_connections determines if seeding (and finished) torrents │ │ │ │ -should attempt to make outgoing connections or not. It may be set to false in │ │ │ │ -very specific applications where the cost of making outgoing connections is │ │ │ │ -high, and there are no or small benefits of doing so. For instance, if no nodes │ │ │ │ -are behind a firewall or a NAT, seeds don't need to make outgoing connections. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_n_o___c_o_n_n_e_c_t___p_r_i_v_i_l_e_g_e_d___p_o_r_t_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when this is true, libtorrent will not attempt to make outgoing connections to │ │ │ │ -peers whose port is < 1024. This is a safety precaution to avoid being part of │ │ │ │ -a DDoS attack │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_m_o_o_t_h___c_o_n_n_e_c_t_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -smooth_connects means the number of connection attempts per second may be │ │ │ │ -limited to below the connection_speed, in case we're close to bump up against │ │ │ │ -the limit of number of connections. The intention of this setting is to more │ │ │ │ -evenly distribute our connection attempts over time, instead of attempting to │ │ │ │ -connect in batches, and timing them out in batches. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_w_a_y_s___s_e_n_d___u_s_e_r___a_g_e_n_t_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -always send user-agent in every web seed request. If false, only the first │ │ │ │ -request per http connection will include the user agent │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_p_p_l_y___i_p___f_i_l_t_e_r___t_o___t_r_a_c_k_e_r_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -apply_ip_filter_to_trackers determines whether the IP filter applies to │ │ │ │ -trackers as well as peers. If this is set to false, trackers are exempt from │ │ │ │ -the IP filter (if there is one). If no IP filter is set, this setting is │ │ │ │ -irrelevant. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_b_a_n___w_e_b___s_e_e_d_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -when true, web seeds sending bad data will be banned │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_u_p_p_o_r_t___s_h_a_r_e___m_o_d_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if false, prevents libtorrent to advertise share-mode support │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_e_p_o_r_t___r_e_d_u_n_d_a_n_t___b_y_t_e_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if this is true, the number of redundant bytes is sent to the tracker │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_l_i_s_t_e_n___s_y_s_t_e_m___p_o_r_t___f_a_l_l_b_a_c_k_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if this is true, libtorrent will fall back to listening on a port chosen by the │ │ │ │ -operating system (i.e. binding to port 0). If a failure is preferred, set this │ │ │ │ -to false. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_n_n_o_u_n_c_e___c_r_y_p_t_o___s_u_p_p_o_r_t_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -when this is true, and incoming encrypted connections are enabled, │ │ │ │ -&supportcrypt=1 is included in http tracker announces │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_e_n_a_b_l_e___u_p_n_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -Starts and stops the UPnP service. When started, the listen port and the DHT │ │ │ │ -port are attempted to be forwarded on local UPnP router devices. │ │ │ │ -The upnp object returned by start_upnp() can be used to add and remove │ │ │ │ -arbitrary port mappings. Mapping status is returned through the _p_o_r_t_m_a_p___a_l_e_r_t │ │ │ │ -and the _p_o_r_t_m_a_p___e_r_r_o_r___a_l_e_r_t. The object will be valid until stop_upnp() is │ │ │ │ -called. See _u_p_n_p_ _a_n_d_ _n_a_t_ _p_m_p. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_e_n_a_b_l_e___n_a_t_p_m_p_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -Starts and stops the NAT-PMP service. When started, the listen port and the DHT │ │ │ │ -port are attempted to be forwarded on the router through NAT-PMP. │ │ │ │ -The natpmp object returned by start_natpmp() can be used to add and remove │ │ │ │ -arbitrary port mappings. Mapping status is returned through the _p_o_r_t_m_a_p___a_l_e_r_t │ │ │ │ -and the _p_o_r_t_m_a_p___e_r_r_o_r___a_l_e_r_t. The object will be valid until stop_natpmp() is │ │ │ │ -called. See _u_p_n_p_ _a_n_d_ _n_a_t_ _p_m_p. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_e_n_a_b_l_e___l_s_d_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -Starts and stops Local Service Discovery. This service will broadcast the info- │ │ │ │ -hashes of all the non-private torrents on the local network to look for peers │ │ │ │ -on the same swarm within multicast reach. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_e_n_a_b_l_e___d_h_t_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -starts the dht node and makes the trackerless service available to torrents. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_e_f_e_r___r_c_4_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -if the allowed encryption level is both, setting this to true will prefer RC4 │ │ │ │ -if both methods are offered, plain text otherwise │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_o_x_y___h_o_s_t_n_a_m_e_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if true, hostname lookups are done via the configured proxy (if any). This is │ │ │ │ -only supported by SOCKS5 and HTTP. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_o_x_y___p_e_e_r___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if true, peer connections are made (and accepted) over the configured proxy, if │ │ │ │ -any. Web seeds as well as regular bittorrent peer connections are considered │ │ │ │ -"peer connections". Anything transporting actual torrent payload (trackers and │ │ │ │ -DHT traffic are not considered peer connections). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_u_t_o___s_e_q_u_e_n_t_i_a_l_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if this setting is true, torrents with a very high availability of pieces (and │ │ │ │ -seeds) are downloaded sequentially. This is more efficient for the disk I/O. │ │ │ │ -With many seeds, the download order is unlikely to matter anyway │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_o_x_y___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -if true, tracker connections are made over the configured proxy, if any. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_e_n_a_b_l_e___i_p___n_o_t_i_f_i_e_r_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -Starts and stops the internal IP table route changes notifier. │ │ │ │ -The current implementation supports multiple platforms, and it is recommended │ │ │ │ -to have it enable, but you may want to disable it if it's supported but │ │ │ │ -unreliable, or if you have a better way to detect the changes. In the later │ │ │ │ -case, you should manually call session_handle::reopen_network_sockets to ensure │ │ │ │ -network changes are taken in consideration. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___p_r_e_f_e_r___v_e_r_i_f_i_e_d___n_o_d_e___i_d_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -when this is true, nodes whose IDs are derived from their source IP according │ │ │ │ -to _B_E_P_ _4_2 are preferred in the routing table. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___r_e_s_t_r_i_c_t___r_o_u_t_i_n_g___i_p_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -determines if the routing table entries should restrict entries to one per IP. │ │ │ │ -This defaults to true, which helps mitigate some attacks on the DHT. It │ │ │ │ -prevents adding multiple nodes with IPs with a very close CIDR distance. │ │ │ │ -when set, nodes whose IP address that's in the same /24 (or /64 for IPv6) range │ │ │ │ -in the same routing table bucket. This is an attempt to mitigate node ID │ │ │ │ -spoofing attacks also restrict any IP to only have a single _e_n_t_r_y in the whole │ │ │ │ -routing table │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___r_e_s_t_r_i_c_t___s_e_a_r_c_h___i_p_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -determines if DHT searches should prevent adding nodes with IPs with very close │ │ │ │ -CIDR distance. This also defaults to true and helps mitigate certain attacks on │ │ │ │ -the DHT. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___e_x_t_e_n_d_e_d___r_o_u_t_i_n_g___t_a_b_l_e_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -makes the first buckets in the DHT routing table fit 128, 64, 32 and 16 nodes │ │ │ │ -respectively, as opposed to the standard size of 8. All other buckets have size │ │ │ │ -8 still. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___a_g_g_r_e_s_s_i_v_e___l_o_o_k_u_p_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -slightly changes the lookup behavior in terms of how many outstanding requests │ │ │ │ -we keep. Instead of having branch factor be a hard limit, we always keep bbrraanncchh │ │ │ │ -ffaaccttoorr outstanding requests to the closest nodes. i.e. every time we get │ │ │ │ -results back with closer nodes, we query them right away. It lowers the lookup │ │ │ │ -times at the cost of more outstanding queries. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___p_r_i_v_a_c_y___l_o_o_k_u_p_s_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when set, perform lookups in a way that is slightly more expensive, but which │ │ │ │ -minimizes the amount of information leaked about you. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___e_n_f_o_r_c_e___n_o_d_e___i_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when set, node's whose IDs that are not correctly generated based on its │ │ │ │ -external IP are ignored. When a query arrives from such node, an error message │ │ │ │ -is returned with a message saying "invalid node ID". │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___i_g_n_o_r_e___d_a_r_k___i_n_t_e_r_n_e_t_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -ignore DHT messages from parts of the internet we wouldn't expect to see any │ │ │ │ -traffic from │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___r_e_a_d___o_n_l_y_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when set, the other nodes won't keep this node in their routing tables, it's │ │ │ │ -meant for low-power and/or ephemeral devices that cannot support the DHT, it is │ │ │ │ -also useful for mobile devices which are sensitive to network traffic and │ │ │ │ -battery life. this node no longer responds to 'query' messages, and will place │ │ │ │ -a 'ro' key (value = 1) in the top-level message dictionary of outgoing query │ │ │ │ -messages. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_i_e_c_e___e_x_t_e_n_t___a_f_f_i_n_i_t_y_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when this is true, create an affinity for downloading 4 MiB extents of adjacent │ │ │ │ -pieces. This is an attempt to achieve better disk I/O throughput by downloading │ │ │ │ -larger extents of bytes, for torrents with small piece sizes │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_v_a_l_i_d_a_t_e___h_t_t_p_s___t_r_a_c_k_e_r_s_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -when set to true, the certificate of HTTPS trackers, HTTPS web seeds and │ │ │ │ -WebTorrent (wss://) trackers will be validated against the system's certificate │ │ │ │ -store (as defined by OpenSSL/GnuTLS). If the system does not have a certificate │ │ │ │ -store, this option may have to be disabled in order to get trackers and web │ │ │ │ -seeds to work). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_s_r_f___m_i_t_i_g_a_t_i_o_n_|_b_o_o_l_|_t_r_u_e_ _ _ | │ │ │ │ -when enabled, tracker and web seed requests are subject to certain │ │ │ │ -restrictions. │ │ │ │ -An HTTP(s) tracker requests to localhost (loopback) must have the request path │ │ │ │ -start with "/announce". This is the conventional bittorrent tracker request. │ │ │ │ -Any other HTTP(S) tracker request to loopback will be rejected. This applies to │ │ │ │ -trackers that redirect to loopback as well. │ │ │ │ -Web seeds that end up on the client's local network (i.e. in a private IP │ │ │ │ -address range) may not include query string arguments. This applies to web │ │ │ │ -seeds redirecting to the local network as well. │ │ │ │ -Web seeds on global IPs (i.e. not local network) may not redirect to a local │ │ │ │ -network address │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_l_o_w___i_d_n_a_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when disabled, any tracker or web seed with an IDNA hostname (internationalized │ │ │ │ -domain name) is ignored. This is a security precaution to avoid various unicode │ │ │ │ -encoding attacks that might happen at the application level. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_e_n_a_b_l_e___s_e_t___f_i_l_e___v_a_l_i_d___d_a_t_a_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -when set to true, enables the attempt to use SetFileValidData() to pre-allocate │ │ │ │ -disk space. This system call will only work when running with Administrator │ │ │ │ -privileges on Windows, and so this setting is only relevant in that scenario. │ │ │ │ -Using SetFileValidData() poses a security risk, as it may reveal previously │ │ │ │ -deleted information from the disk. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_o_c_k_s_5___u_d_p___s_e_n_d___l_o_c_a_l___e_p_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -When using a SOCKS5 proxy, UDP traffic is routed through the proxy by sending a │ │ │ │ -UDP ASSOCIATE command. If this option is true, the UDP ASSOCIATE command will │ │ │ │ -include the IP address and listen port to the local UDP socket. This indicates │ │ │ │ -to the proxy which source endpoint to expect our packets from. The benefit is │ │ │ │ -that incoming packets can be forwarded correctly, before any outgoing packets │ │ │ │ -are sent. The risk is that if there's a NAT between the client and the proxy, │ │ │ │ -the IP address specified in the protocol may not be valid from the proxy's │ │ │ │ -point of view. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_o_x_y___s_e_n_d___h_o_s_t___i_n___c_o_n_n_e_c_t_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -When using HTTP proxy (in proxy_type), libtorrent will connect to peers and │ │ │ │ -trackers using theCONNECTproxy command. In this command it's possible to reveal │ │ │ │ -the hostname of the server we're connecting to. When this option is true, the │ │ │ │ -hostname will be sent. This feature can be useful if the proxy is used to man- │ │ │ │ -in-the-middle connections. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_i_s_k___d_i_s_a_b_l_e___c_o_p_y___o_n___w_r_i_t_e_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -When set, downloaded files will have the no-copy-on-write flag (FS_NOCOW_FL) │ │ │ │ -set on Linux. This mitigates heavy fragmentation on filesystems like btrfs, but │ │ │ │ -has the unfortunate side effect of disabling useful CoW-related features │ │ │ │ -including checksumming and compression, and adding additional restrictions on │ │ │ │ -the use of reflinks. A NOCOW file can only be reflinked to NOCOW directories, │ │ │ │ -which can be a surprising change for existing users. Therefore, this option is │ │ │ │ -disabled by default. │ │ │ │ -An alternative to this option is for the user to manually set the NOCOW flag on │ │ │ │ -the download directory, which will cause all files created within it to have │ │ │ │ -the NOCOW flag set. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_l_o_w___m_u_l_t_i_p_l_e___c_o_n_n_e_c_t_i_o_n_s___p_e_r___p_i_d_|_b_o_o_l_|_f_a_l_s_e_ _ | │ │ │ │ -determines if connections from the same Peer ID as existing connections should │ │ │ │ -be rejected or not. Typically, we only establish a single connection with each │ │ │ │ -peer. If a peer has multiple IP addresses, enabling this feature may improve │ │ │ │ -transfer efficiency, but it may also increase network load. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_t_r_a_c_k_e_r___c_o_m_p_l_e_t_i_o_n___t_i_m_e_o_u_t_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ -tracker_completion_timeout is the number of seconds the tracker connection will │ │ │ │ -wait from when it sent the request until it considers the tracker to have │ │ │ │ -timed-out. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_t_r_a_c_k_e_r___r_e_c_e_i_v_e___t_i_m_e_o_u_t_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ -tracker_receive_timeout is the number of seconds to wait to receive any data │ │ │ │ -from the tracker. If no data is received for this number of seconds, the │ │ │ │ -tracker will be considered as having timed out. If a tracker is down, this is │ │ │ │ -the kind of timeout that will occur. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_t_o_p___t_r_a_c_k_e_r___t_i_m_e_o_u_t_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ -stop_tracker_timeout is the number of seconds to wait when sending a stopped │ │ │ │ -message before considering a tracker to have timed out. This is usually │ │ │ │ -shorter, to make the client quit faster. If the value is set to 0, the │ │ │ │ -connections to trackers with the stopped event are suppressed. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ | │ │ │ │ -|_t_r_a_c_k_e_r___m_a_x_i_m_u_m___r_e_s_p_o_n_s_e___l_e_n_g_t_h_|_i_n_t_ _|_1_0_2_4_*_1_0_2_4| │ │ │ │ -this is the maximum number of bytes in a tracker response. If a response size │ │ │ │ -passes this number of bytes it will be rejected and the connection will be │ │ │ │ -closed. On gzipped responses this size is measured on the uncompressed data. │ │ │ │ -So, if you get 20 bytes of gzip response that'll expand to 2 megabytes, it will │ │ │ │ -be interrupted before the entire response has been uncompressed (assuming the │ │ │ │ -limit is lower than 2 MiB). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_i_e_c_e___t_i_m_e_o_u_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ -the number of seconds from a request is sent until it times out if no piece │ │ │ │ -response is returned. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_e_q_u_e_s_t___t_i_m_e_o_u_t_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ -the number of seconds one block (16 kiB) is expected to be received within. If │ │ │ │ -it's not, the block is requested from a different peer │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_e_q_u_e_s_t___q_u_e_u_e___t_i_m_e_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -the length of the request queue given in the number of seconds it should take │ │ │ │ -for the other end to send all the pieces. i.e. the actual number of requests │ │ │ │ -depends on the download rate and this number. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___a_l_l_o_w_e_d___i_n___r_e_q_u_e_s_t___q_u_e_u_e_|_i_n_t_ _|_2_0_0_0_ _ _ | │ │ │ │ -the number of outstanding block requests a peer is allowed to queue up in the │ │ │ │ -client. If a peer sends more requests than this (before the first one has been │ │ │ │ -sent) the last request will be dropped. the higher this is, the faster upload │ │ │ │ -speeds the client can get to a single peer. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___o_u_t___r_e_q_u_e_s_t___q_u_e_u_e_|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ -max_out_request_queue is the maximum number of outstanding requests to send to │ │ │ │ -a peer. This limit takes precedence over request_queue_time. i.e. no matter the │ │ │ │ -download speed, the number of outstanding requests will never exceed this │ │ │ │ -limit. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_w_h_o_l_e___p_i_e_c_e_s___t_h_r_e_s_h_o_l_d_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ -if a whole piece can be downloaded in this number of seconds, or less, the │ │ │ │ -peer_connection will prefer to request whole pieces at a time from this peer. │ │ │ │ -The benefit of this is to better utilize disk caches by doing localized │ │ │ │ -accesses and also to make it easier to identify bad peers if a piece fails the │ │ │ │ -hash check. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_e_e_r___t_i_m_e_o_u_t_|_i_n_t_ _|_1_2_0_ _ _ _ | │ │ │ │ -peer_timeout is the number of seconds the peer connection should wait (for any │ │ │ │ -activity on the peer connection) before closing it due to time out. 120 seconds │ │ │ │ -is specified in the protocol specification. After half the time out, a keep │ │ │ │ -alive message is sent. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_r_l_s_e_e_d___t_i_m_e_o_u_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ -same as peer_timeout, but only applies to url-seeds. this is usually set lower, │ │ │ │ -because web servers are expected to be more reliable. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_r_l_s_e_e_d___p_i_p_e_l_i_n_e___s_i_z_e_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ -controls the pipelining size of url and http seeds. i.e. the number of HTTP │ │ │ │ -request to keep outstanding before waiting for the first one to complete. It's │ │ │ │ -common for web servers to limit this to a relatively low number, like 5 │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_r_l_s_e_e_d___w_a_i_t___r_e_t_r_y_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ -number of seconds until a new retry of a url-seed takes place. Default retry │ │ │ │ -value for http-seeds that don't provide a valid retry-after header. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_f_i_l_e___p_o_o_l___s_i_z_e_|_i_n_t_ _|_4_0_ _ _ _ _ | │ │ │ │ -sets the upper limit on the total number of files this _s_e_s_s_i_o_n will keep open. │ │ │ │ -The reason why files are left open at all is that some anti virus software │ │ │ │ -hooks on every file close, and scans the file for viruses. deferring the │ │ │ │ -closing of the files will be the difference between a usable system and a │ │ │ │ -completely hogged down system. Most operating systems also has a limit on the │ │ │ │ -total number of file descriptors a process may have open. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___f_a_i_l_c_o_u_n_t_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -max_failcount is the maximum times we try to connect to a peer before stop │ │ │ │ -connecting again. If a peer succeeds, the failure counter is reset. If a peer │ │ │ │ -is retrieved from a peer source (other than DHT) the failcount is decremented │ │ │ │ -by one, allowing another try. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_i_n___r_e_c_o_n_n_e_c_t___t_i_m_e_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ -the number of seconds to wait to reconnect to a peer. this time is multiplied │ │ │ │ -with the failcount. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_e_e_r___c_o_n_n_e_c_t___t_i_m_e_o_u_t_|_i_n_t_ _|_1_5_ _ _ _ _ | │ │ │ │ -peer_connect_timeout the number of seconds to wait after a connection attempt │ │ │ │ -is initiated to a peer until it is considered as having timed out. This setting │ │ │ │ -is especially important in case the number of half-open connections are │ │ │ │ -limited, since stale half-open connection may delay the connection of other │ │ │ │ -peers considerably. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_c_o_n_n_e_c_t_i_o_n___s_p_e_e_d_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ -connection_speed is the number of connection attempts that are made per second. │ │ │ │ -If a number < 0 is specified, it will default to 200 connections per second. If │ │ │ │ -0 is specified, it means don't make outgoing connections at all. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_n_a_c_t_i_v_i_t_y___t_i_m_e_o_u_t_|_i_n_t_ _|_6_0_0_ _ _ _ | │ │ │ │ -if a peer is uninteresting and uninterested for longer than this number of │ │ │ │ -seconds, it will be disconnected. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_n_c_h_o_k_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_1_5_ _ _ _ _ | │ │ │ │ -unchoke_interval is the number of seconds between chokes/unchokes. On this │ │ │ │ -interval, peers are re-evaluated for being choked/unchoked. This is defined as │ │ │ │ -30 seconds in the protocol, and it should be significantly longer than what it │ │ │ │ -takes for TCP to ramp up to it's max rate. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_o_p_t_i_m_i_s_t_i_c___u_n_c_h_o_k_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ -optimistic_unchoke_interval is the number of seconds between each ooppttiimmiissttiicc │ │ │ │ -unchoke. On this timer, the currently optimistically unchoked peer will change. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_n_u_m___w_a_n_t_|_i_n_t_ _|_2_0_0_ _ _ _ | │ │ │ │ -num_want is the number of peers we want from each tracker request. It defines │ │ │ │ -what is sent as the &num_want= parameter to the tracker. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_n_i_t_i_a_l___p_i_c_k_e_r___t_h_r_e_s_h_o_l_d_|_i_n_t_ _|_4_ _ _ _ _ _ | │ │ │ │ -initial_picker_threshold specifies the number of pieces we need before we │ │ │ │ -switch to rarest first picking. The first initial_picker_threshold pieces in │ │ │ │ -any torrent are picked at random , the following pieces are picked in rarest │ │ │ │ -first order. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_l_o_w_e_d___f_a_s_t___s_e_t___s_i_z_e_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ -the number of allowed pieces to send to peers that supports the fast extensions │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_u_g_g_e_s_t___m_o_d_e_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_n_o___p_i_e_c_e___s_u_g_g_e_s_t_i_o_n_s| │ │ │ │ -suggest_mode controls whether or not libtorrent will send out suggest messages │ │ │ │ -to create a bias of its peers to request certain pieces. The modes are: │ │ │ │ - * no_piece_suggestions which will not send out suggest messages. │ │ │ │ - * suggest_read_cache which will send out suggest messages for the most │ │ │ │ - recent pieces that are in the read cache. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_m_a_x___q_u_e_u_e_d___d_i_s_k___b_y_t_e_s_|_i_n_t_ _|_1_0_0_ _*_ _1_0_2_4_ _*_ _1_0_2_4| │ │ │ │ -max_queued_disk_bytes is the maximum number of bytes, to be written to disk, │ │ │ │ -that can wait in the disk I/O thread queue. This queue is only for waiting for │ │ │ │ -the disk I/O thread to receive the job and either write it to disk or insert it │ │ │ │ -in the write cache. When this limit is reached, the peer connections will stop │ │ │ │ -reading data from their sockets, until the disk thread catches up. Setting this │ │ │ │ -too low will severely limit your download rate. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_h_a_n_d_s_h_a_k_e___t_i_m_e_o_u_t_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ -the number of seconds to wait for a handshake response from a peer. If no │ │ │ │ -response is received within this time, the peer is disconnected. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ | │ │ │ │ -|_s_e_n_d___b_u_f_f_e_r___l_o_w___w_a_t_e_r_m_a_r_k_ _ _ _|_i_n_t_ _|_1_0_ _*_ _1_0_2_4_ | │ │ │ │ -|_s_e_n_d___b_u_f_f_e_r___w_a_t_e_r_m_a_r_k_ _ _ _ _ _ _ _|_i_n_t_ _|_5_0_0_ _*_ _1_0_2_4| │ │ │ │ -|_s_e_n_d___b_u_f_f_e_r___w_a_t_e_r_m_a_r_k___f_a_c_t_o_r_|_i_n_t_ _|_5_0_ _ _ _ _ _ _ _ | │ │ │ │ -send_buffer_low_watermark the minimum send buffer target size (send buffer │ │ │ │ -includes bytes pending being read from disk). For good and snappy seeding │ │ │ │ -performance, set this fairly high, to at least fit a few blocks. This is │ │ │ │ -essentially the initial window size which will determine how fast we can ramp │ │ │ │ -up the send rate │ │ │ │ -if the send buffer has fewer bytes than send_buffer_watermark, we'll read │ │ │ │ -another 16 kiB block onto it. If set too small, upload rate capacity will │ │ │ │ -suffer. If set too high, memory will be wasted. The actual watermark may be │ │ │ │ -lower than this in case the upload rate is low, this is the upper limit. │ │ │ │ -the current upload rate to a peer is multiplied by this factor to get the send │ │ │ │ -buffer watermark. The factor is specified as a percentage. i.e. 50 -> 0.5 This │ │ │ │ -product is clamped to the send_buffer_watermark setting to not exceed the max. │ │ │ │ -For high speed upload, this should be set to a greater value than 100. For high │ │ │ │ -capacity connections, setting this higher can improve upload performance and │ │ │ │ -disk throughput. Setting it too high may waste RAM and create a bias towards │ │ │ │ -read jobs over write jobs. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m_ _ _ _ _ _|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_f_i_x_e_d___s_l_o_t_s___c_h_o_k_e_r| │ │ │ │ -|_s_e_e_d___c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_r_o_u_n_d___r_o_b_i_n_ _ _ _ _ _ _ | │ │ │ │ -choking_algorithm specifies which algorithm to use to determine how many peers │ │ │ │ -to unchoke. The unchoking algorithm for downloading torrents is always "tit- │ │ │ │ -for-tat", i.e. the peers we download the fastest from are unchoked. │ │ │ │ -The options for choking algorithms are defined in the _c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t enum. │ │ │ │ -seed_choking_algorithm controls the seeding unchoke behavior. i.e. How we │ │ │ │ -select which peers to unchoke for seeding torrents. Since a seeding torrent │ │ │ │ -isn't downloading anything, the tit-for-tat mechanism cannot be used. The │ │ │ │ -available options are defined in the _s_e_e_d___c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t enum. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_i_s_k___i_o___w_r_i_t_e___m_o_d_e_|_i_n_t_ _|_D_I_S_K___W_R_I_T_E___M_O_D_E_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_i_s_k___i_o___r_e_a_d___m_o_d_e_ _|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_e_n_a_b_l_e___o_s___c_a_c_h_e| │ │ │ │ -determines how files are opened when they're in read only mode versus read and │ │ │ │ -write mode. The options are: │ │ │ │ - enable_os_cache │ │ │ │ - Files are opened normally, with the OS caching reads and writes. │ │ │ │ - disable_os_cache │ │ │ │ - This opens all files in no-cache mode. This corresponds to the OS not │ │ │ │ - letting blocks for the files linger in the cache. This makes sense in │ │ │ │ - order to avoid the bittorrent client to potentially evict all other │ │ │ │ - processes' cache by simply handling high throughput and large files. If │ │ │ │ - libtorrent's read cache is disabled, enabling this may reduce │ │ │ │ - performance. │ │ │ │ - write_through │ │ │ │ - flush pieces to disk as they complete validation. │ │ │ │ -One reason to disable caching is that it may help the operating system from │ │ │ │ -growing its file cache indefinitely. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_o_u_t_g_o_i_n_g___p_o_r_t_ _ _ _ _ _|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -|_n_u_m___o_u_t_g_o_i_n_g___p_o_r_t_s_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -this is the first port to use for binding outgoing connections to. This is │ │ │ │ -useful for users that have routers that allow QoS settings based on local port. │ │ │ │ -when binding outgoing connections to specific ports, num_outgoing_ports is the │ │ │ │ -size of the range. It should be more than a few │ │ │ │ -Warning │ │ │ │ -setting outgoing ports will limit the ability to keep multiple connections to │ │ │ │ -the same client, even for different torrents. It is not recommended to change │ │ │ │ -this setting. Its main purpose is to use as an escape hatch for cheap routers │ │ │ │ -with QoS capability but can only classify flows based on port numbers. │ │ │ │ -It is a range instead of a single port because of the problems with failing to │ │ │ │ -reconnect to peers if a previous socket to that peer and port is in TIME_WAIT │ │ │ │ -state. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_e_e_r___d_s_c_p_|_i_n_t_ _|_0_x_0_1_ _ _ | │ │ │ │ -peer_dscp determines the DSCP field in the IP header of every packet sent to │ │ │ │ -peers (including web seeds). 0x0 means no marking, 0x01 represents Lower │ │ │ │ -Effort. For more details see _R_F_C_ _8_6_2_2 and IANA's _d_s_c_p_ _r_e_g_i_s_t_r_y. │ │ │ │ -peer_tos is the old name for peer_dscp, it's still available for backwards │ │ │ │ -compatibility. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_c_t_i_v_e___d_o_w_n_l_o_a_d_s_ _ _ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -|_a_c_t_i_v_e___s_e_e_d_s_ _ _ _ _ _ _ _ _|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ -|_a_c_t_i_v_e___c_h_e_c_k_i_n_g_ _ _ _ _ _|_i_n_t_ _|_1_ _ _ _ _ _ | │ │ │ │ -|_a_c_t_i_v_e___d_h_t___l_i_m_i_t_ _ _ _ _|_i_n_t_ _|_8_8_ _ _ _ _ | │ │ │ │ -|_a_c_t_i_v_e___t_r_a_c_k_e_r___l_i_m_i_t_|_i_n_t_ _|_1_6_0_0_ _ _ | │ │ │ │ -|_a_c_t_i_v_e___l_s_d___l_i_m_i_t_ _ _ _ _|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ -|_a_c_t_i_v_e___l_i_m_i_t_ _ _ _ _ _ _ _ _|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ -for auto managed torrents, these are the limits they are subject to. If there │ │ │ │ -are too many torrents some of the auto managed ones will be paused until some │ │ │ │ -slots free up. active_downloads and active_seeds controls how many active │ │ │ │ -seeding and downloading torrents the queuing mechanism allows. The target │ │ │ │ -number of active torrents is min(active_downloads + active_seeds, │ │ │ │ -active_limit). active_downloads and active_seeds are upper limits on the number │ │ │ │ -of downloading torrents and seeding torrents respectively. Setting the value to │ │ │ │ --1 means unlimited. │ │ │ │ -For example if there are 10 seeding torrents and 10 downloading torrents, and │ │ │ │ -active_downloads is 4 and active_seeds is 4, there will be 4 seeds active and 4 │ │ │ │ -downloading torrents. If the settings are active_downloads = 2 and active_seeds │ │ │ │ -= 4, then there will be 2 downloading torrents and 4 seeding torrents active. │ │ │ │ -Torrents that are not auto managed are not counted against these limits. │ │ │ │ -active_checking is the limit of number of simultaneous checking torrents. │ │ │ │ -active_limit is a hard limit on the number of active (auto managed) torrents. │ │ │ │ -This limit also applies to slow torrents. │ │ │ │ -active_dht_limit is the max number of torrents to announce to the DHT. │ │ │ │ -active_tracker_limit is the max number of torrents to announce to their │ │ │ │ -trackers. │ │ │ │ -active_lsd_limit is the max number of torrents to announce to the local network │ │ │ │ -over the local service discovery protocol. │ │ │ │ -You can have more torrents aaccttiivvee, even though they are not announced to the │ │ │ │ -DHT, lsd or their tracker. If some peer knows about you for any reason and │ │ │ │ -tries to connect, it will still be accepted, unless the torrent is paused, │ │ │ │ -which means it won't accept any connections. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_u_t_o___m_a_n_a_g_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ -auto_manage_interval is the number of seconds between the torrent queue is │ │ │ │ -updated, and rotated. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ | │ │ │ │ -|_s_e_e_d___t_i_m_e___l_i_m_i_t_|_i_n_t_ _|_2_4_ _*_ _6_0_ _*_ _6_0| │ │ │ │ -this is the limit on the time a torrent has been an active seed (specified in │ │ │ │ -seconds) before it is considered having met the seed limit criteria. See │ │ │ │ -_q_u_e_u_i_n_g. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_u_t_o___s_c_r_a_p_e___i_n_t_e_r_v_a_l_ _ _ _ _|_i_n_t_ _|_1_8_0_0_ _ _ | │ │ │ │ -|_a_u_t_o___s_c_r_a_p_e___m_i_n___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_0_ _ _ _ | │ │ │ │ -auto_scrape_interval is the number of seconds between scrapes of queued │ │ │ │ -torrents (auto managed and paused torrents). Auto managed torrents that are │ │ │ │ -paused, are scraped regularly in order to keep track of their downloader/seed │ │ │ │ -ratio. This ratio is used to determine which torrents to seed and which to │ │ │ │ -pause. │ │ │ │ -auto_scrape_min_interval is the minimum number of seconds between any automatic │ │ │ │ -scrape (regardless of torrent). In case there are a large number of paused auto │ │ │ │ -managed torrents, this puts a limit on how often a scrape request is sent. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___p_e_e_r_l_i_s_t___s_i_z_e_ _ _ _ _ _ _ _|_i_n_t_ _|_3_0_0_0_ _ _ | │ │ │ │ -|_m_a_x___p_a_u_s_e_d___p_e_e_r_l_i_s_t___s_i_z_e_|_i_n_t_ _|_1_0_0_0_ _ _ | │ │ │ │ -max_peerlist_size is the maximum number of peers in the list of known peers. │ │ │ │ -These peers are not necessarily connected, so this number should be much │ │ │ │ -greater than the maximum number of connected peers. Peers are evicted from the │ │ │ │ -cache when the list grows passed 90% of this limit, and once the size hits the │ │ │ │ -limit, peers are no longer added to the list. If this limit is set to 0, there │ │ │ │ -is no limit on how many peers we'll keep in the peer list. │ │ │ │ -max_paused_peerlist_size is the max peer list size used for torrents that are │ │ │ │ -paused. This can be used to save memory for paused torrents, since it's not as │ │ │ │ -important for them to keep a large peer list. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_i_n___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_5_ _*_ _6_0_ | │ │ │ │ -this is the minimum allowed announce interval for a tracker. This is specified │ │ │ │ -in seconds and is used as a sanity check on what is returned from a tracker. It │ │ │ │ -mitigates hammering mis-configured trackers. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_u_t_o___m_a_n_a_g_e___s_t_a_r_t_u_p_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ -this is the number of seconds a torrent is considered active after it was │ │ │ │ -started, regardless of upload and download speed. This is so that newly started │ │ │ │ -torrents are not considered inactive until they have a fair chance to start │ │ │ │ -downloading. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_e_e_d_i_n_g___p_i_e_c_e___q_u_o_t_a_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ -seeding_piece_quota is the number of pieces to send to a peer, when seeding, │ │ │ │ -before rotating in another peer to the unchoke set. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___r_e_j_e_c_t_s_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ -max_rejects is the number of piece requests we will reject in a row while a │ │ │ │ -peer is choked before the peer is considered abusive and is disconnected. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_e_c_v___s_o_c_k_e_t___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -|_s_e_n_d___s_o_c_k_e_t___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -specifies the buffer sizes set on peer sockets. 0 means the OS default (i.e. │ │ │ │ -don't change the buffer sizes). The socket buffer sizes are changed using │ │ │ │ -setsockopt() with SOL_SOCKET/SO_RCVBUF and SO_SNDBUFFER. │ │ │ │ -Note that uTP peers share a single UDP socket buffer for each of the │ │ │ │ -listen_interfaces, along with DHT and UDP tracker traffic. If the buffer size │ │ │ │ -is too small for the combined traffic through the socket, packets may be │ │ │ │ -dropped. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ | │ │ │ │ -|_m_a_x___p_e_e_r___r_e_c_v___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_2_ _*_ _1_0_2_4_ _*_ _1_0_2_4| │ │ │ │ -the max number of bytes a single peer connection's receive buffer is allowed to │ │ │ │ -grow to. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_o_p_t_i_m_i_s_t_i_c___d_i_s_k___r_e_t_r_y_|_i_n_t_ _|_1_0_ _*_ _6_0| │ │ │ │ -optimistic_disk_retry is the number of seconds from a disk write errors occur │ │ │ │ -on a torrent until libtorrent will take it out of the upload mode, to test if │ │ │ │ -the error condition has been fixed. │ │ │ │ -libtorrent will only do this automatically for auto managed torrents. │ │ │ │ -You can explicitly take a torrent out of upload only mode using set_upload_mode │ │ │ │ -(). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___s_u_g_g_e_s_t___p_i_e_c_e_s_|_i_n_t_ _|_1_6_ _ _ _ _ | │ │ │ │ -max_suggest_pieces is the max number of suggested piece indices received from a │ │ │ │ -peer that's remembered. If a peer floods suggest messages, this limit prevents │ │ │ │ -libtorrent from using too much RAM. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_l_o_c_a_l___s_e_r_v_i_c_e___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_5_ _*_ _6_0_ | │ │ │ │ -local_service_announce_interval is the time between local network announces for │ │ │ │ -a torrent. This interval is specified in seconds. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_1_5_ _*_ _6_0| │ │ │ │ -dht_announce_interval is the number of seconds between announcing torrents to │ │ │ │ -the distributed hash table (DHT). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_d_p___t_r_a_c_k_e_r___t_o_k_e_n___e_x_p_i_r_y_|_i_n_t_ _|_6_0_ _ _ _ _ | │ │ │ │ -udp_tracker_token_expiry is the number of seconds libtorrent will keep UDP │ │ │ │ -tracker connection tokens around for. This is specified to be 60 seconds. The │ │ │ │ -higher this value is, the fewer packets have to be sent to the UDP tracker. In │ │ │ │ -order for higher values to work, the tracker needs to be configured to match │ │ │ │ -the expiration time for tokens. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_n_u_m___o_p_t_i_m_i_s_t_i_c___u_n_c_h_o_k_e___s_l_o_t_s_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -num_optimistic_unchoke_slots is the number of optimistic unchoke slots to use. │ │ │ │ -Having a higher number of optimistic unchoke slots mean you will find the good │ │ │ │ -peers faster but with the trade-off to use up more bandwidth. 0 means │ │ │ │ -automatic, where libtorrent opens up 20% of your allowed upload slots as │ │ │ │ -optimistic unchoke slots. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___p_e_x___p_e_e_r_s_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ -the max number of peers we accept from pex messages from a single peer. this │ │ │ │ -limits the number of concurrent peers any of our peers claims to be connected │ │ │ │ -to. If they claim to be connected to more than this, we'll ignore any peer that │ │ │ │ -exceeds this limit │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_t_i_c_k___i_n_t_e_r_v_a_l_|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ -tick_interval specifies the number of milliseconds between internal ticks. This │ │ │ │ -is the frequency with which bandwidth quota is distributed to peers. It should │ │ │ │ -not be more than one second (i.e. 1000 ms). Setting this to a low value (around │ │ │ │ -100) means higher resolution bandwidth quota distribution, setting it to a │ │ │ │ -higher value saves CPU cycles. │ │ │ │ -A negative value disables the once-per-second gate on the second_tick path (the │ │ │ │ -heavier per-torrent work). The timer itself still fires every millisecond. This │ │ │ │ -is intended for test and fuzzing scenarios that need the _s_e_s_s_i_o_n to react │ │ │ │ -instantly; do not use it in production. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_h_a_r_e___m_o_d_e___t_a_r_g_e_t_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -share_mode_target specifies the target share ratio for share mode torrents. If │ │ │ │ -set to 3, we'll try to upload 3 times as much as we download. Setting this very │ │ │ │ -high, will make it very conservative and you might end up not downloading │ │ │ │ -anything ever (and not affecting your share ratio). It does not make any sense │ │ │ │ -to set this any lower than 2. For instance, if only 3 peers need to download │ │ │ │ -the rarest piece, it's impossible to download a single piece and upload it more │ │ │ │ -than 3 times. If the share_mode_target is set to more than 3, nothing is │ │ │ │ -downloaded. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_p_l_o_a_d___r_a_t_e___l_i_m_i_t_ _ _|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -|_d_o_w_n_l_o_a_d___r_a_t_e___l_i_m_i_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -upload_rate_limit and download_rate_limit sets the session-global limits of │ │ │ │ -upload and download rate limits, in bytes per second. By default peers on the │ │ │ │ -local network are not rate limited. │ │ │ │ -A value of 0 means unlimited. │ │ │ │ -For fine grained control over rate limits, including making them apply to local │ │ │ │ -peers, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___u_p_l_o_a_d___r_a_t_e___l_i_m_i_t_|_i_n_t_ _|_8_0_0_0_ _ _ | │ │ │ │ -the number of bytes per second (on average) the DHT is allowed to send. If the │ │ │ │ -incoming requests causes to many bytes to be sent in responses, incoming │ │ │ │ -requests will be dropped until the quota has been replenished. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_n_c_h_o_k_e___s_l_o_t_s___l_i_m_i_t_|_i_n_t_ _|_8_ _ _ _ _ _ | │ │ │ │ -unchoke_slots_limit is the max number of unchoked peers in the _s_e_s_s_i_o_n. The │ │ │ │ -number of unchoke slots may be ignored depending on what choking_algorithm is │ │ │ │ -set to. Setting this limit to -1 means unlimited, i.e. all peers will always be │ │ │ │ -unchoked. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_c_o_n_n_e_c_t_i_o_n_s___l_i_m_i_t_|_i_n_t_ _|_2_0_0_ _ _ _ | │ │ │ │ -connections_limit sets a global limit on the number of connections opened. The │ │ │ │ -number of connections is set to a hard minimum of at least two per torrent, so │ │ │ │ -if you set a too low connections limit, and open too many torrents, the limit │ │ │ │ -will not be met. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_c_o_n_n_e_c_t_i_o_n_s___s_l_a_c_k_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ -connections_slack is the number of incoming connections exceeding the │ │ │ │ -connection limit to accept in order to potentially replace existing ones. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_t_p___t_a_r_g_e_t___d_e_l_a_y_ _ _ _|_i_n_t_ _|_1_0_0_ _ _ _ | │ │ │ │ -|_u_t_p___g_a_i_n___f_a_c_t_o_r_ _ _ _ _|_i_n_t_ _|_3_0_0_0_ _ _ | │ │ │ │ -|_u_t_p___m_i_n___t_i_m_e_o_u_t_ _ _ _ _|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ -|_u_t_p___s_y_n___r_e_s_e_n_d_s_ _ _ _ _|_i_n_t_ _|_2_ _ _ _ _ _ | │ │ │ │ -|_u_t_p___f_i_n___r_e_s_e_n_d_s_ _ _ _ _|_i_n_t_ _|_2_ _ _ _ _ _ | │ │ │ │ -|_u_t_p___n_u_m___r_e_s_e_n_d_s_ _ _ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -|_u_t_p___c_o_n_n_e_c_t___t_i_m_e_o_u_t_|_i_n_t_ _|_3_0_0_0_ _ _ | │ │ │ │ -|_u_t_p___l_o_s_s___m_u_l_t_i_p_l_i_e_r_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ -utp_target_delay is the target delay for uTP sockets in milliseconds. A high │ │ │ │ -value will make uTP connections more aggressive and cause longer queues in the │ │ │ │ -upload bottleneck. It cannot be too low, since the noise in the measurements │ │ │ │ -would cause it to send too slow. utp_gain_factor is the number of bytes the uTP │ │ │ │ -congestion window can increase at the most in one RTT. If this is set too high, │ │ │ │ -the congestion controller reacts too hard to noise and will not be stable, if │ │ │ │ -it's set too low, it will react slow to congestion and not back off as fast. │ │ │ │ -utp_min_timeout is the shortest allowed uTP socket timeout, specified in │ │ │ │ -milliseconds. The timeout depends on the RTT of the connection, but is never │ │ │ │ -smaller than this value. A connection times out when every packet in a window │ │ │ │ -is lost, or when a packet is lost twice in a row (i.e. the resent packet is │ │ │ │ -lost as well). │ │ │ │ -The shorter the timeout is, the faster the connection will recover from this │ │ │ │ -situation, assuming the RTT is low enough. utp_syn_resends is the number of SYN │ │ │ │ -packets that are sent (and timed out) before giving up and closing the socket. │ │ │ │ -utp_num_resends is the number of times a packet is sent (and lost or timed out) │ │ │ │ -before giving up and closing the connection. utp_connect_timeout is the number │ │ │ │ -of milliseconds of timeout for the initial SYN packet for uTP connections. For │ │ │ │ -each timed out packet (in a row), the timeout is doubled. utp_loss_multiplier │ │ │ │ -controls how the congestion window is changed when a packet loss is │ │ │ │ -experienced. It's specified as a percentage multiplier for cwnd. Do not change │ │ │ │ -this value unless you know what you're doing. Never set it higher than 100. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_m_i_x_e_d___m_o_d_e___a_l_g_o_r_i_t_h_m_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e_e_r___p_r_o_p_o_r_t_i_o_n_a_l| │ │ │ │ -The mixed_mode_algorithm determines how to treat TCP connections when there are │ │ │ │ -uTP connections. Since uTP is designed to yield to TCP, there's an inherent │ │ │ │ -problem when using swarms that have both TCP and uTP connections. If nothing is │ │ │ │ -done, uTP connections would often be starved out for bandwidth by the TCP │ │ │ │ -connections. This mode is prefer_tcp. The peer_proportional mode simply looks │ │ │ │ -at the current throughput and rate limits all TCP connections to their │ │ │ │ -proportional share based on how many of the connections are TCP. This works │ │ │ │ -best if uTP connections are not rate limited by the global rate limiter (which │ │ │ │ -they aren't by default). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_l_i_s_t_e_n___q_u_e_u_e___s_i_z_e_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ -listen_queue_size is the value passed in to listen() for the listen socket. It │ │ │ │ -is the number of outstanding incoming connections to queue up while we're not │ │ │ │ -actively waiting for a connection to be accepted. 5 should be sufficient for │ │ │ │ -any normal client. If this is a high performance server which expects to │ │ │ │ -receive a lot of connections, or used in a simulator or test, it might make │ │ │ │ -sense to raise this number. It will not take affect until the listen_interfaces │ │ │ │ -settings is updated. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_t_o_r_r_e_n_t___c_o_n_n_e_c_t___b_o_o_s_t_|_i_n_t_ _|_3_0_ _ _ _ _ | │ │ │ │ -torrent_connect_boost is the number of peers to try to connect to immediately │ │ │ │ -when the first tracker response is received for a torrent. This is a boost to │ │ │ │ -given to new torrents to accelerate them starting up. The normal connect │ │ │ │ -scheduler is run once every second, this allows peers to be connected │ │ │ │ -immediately instead of waiting for the _s_e_s_s_i_o_n tick to trigger connections. │ │ │ │ -This may not be set higher than 255. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_e_r_t___q_u_e_u_e___s_i_z_e_|_i_n_t_ _|_2_0_0_0_ _ _ | │ │ │ │ -alert_queue_size is the maximum number of alerts queued up internally. If │ │ │ │ -alerts are not popped, the queue will eventually fill up to this level. Once │ │ │ │ -the _a_l_e_r_t queue is full, additional alerts will be dropped, and not delivered │ │ │ │ -to the client. Once the client drains the queue, new alerts may be delivered │ │ │ │ -again. In order to know that alerts have been dropped, see session_handle:: │ │ │ │ -dropped_alerts(). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ | │ │ │ │ -|_m_a_x___m_e_t_a_d_a_t_a___s_i_z_e_|_i_n_t_ _|_3_ _*_ _1_0_2_4_ _*_ _1_0_2_4_0| │ │ │ │ -max_metadata_size is the maximum allowed size (in bytes) to be received by the │ │ │ │ -metadata extension, i.e. magnet links. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_h_a_s_h_i_n_g___t_h_r_e_a_d_s_|_i_n_t_ _|_1_ _ _ _ _ _ | │ │ │ │ -hashing_threads is the number of disk I/O threads to use for piece hash │ │ │ │ -verification. These threads are iinn aaddddiittiioonn to the regular disk I/O threads │ │ │ │ -specified by _s_e_t_t_i_n_g_s___p_a_c_k_:_:_a_i_o___t_h_r_e_a_d_s. These threads are only used for full │ │ │ │ -checking of torrents. The hash checking done while downloading are done by the │ │ │ │ -regular disk I/O threads. The _h_a_s_h_e_r threads do not only compute hashes, but │ │ │ │ -also perform the read from disk. On storage optimal for sequential access, such │ │ │ │ -as hard drives, this setting should be set to 1, which is also the default. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_c_h_e_c_k_i_n_g___m_e_m___u_s_a_g_e_|_i_n_t_ _|_2_5_6_ _ _ _ | │ │ │ │ -the number of blocks to keep outstanding at any given time when checking │ │ │ │ -torrents. Higher numbers give faster re-checks but uses more memory. Specified │ │ │ │ -in number of 16 kiB blocks │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_e_d_i_c_t_i_v_e___p_i_e_c_e___a_n_n_o_u_n_c_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -if set to > 0, pieces will be announced to other peers before they are fully │ │ │ │ -downloaded (and before they are hash checked). The intention is to gain 1.5 │ │ │ │ -potential round trip times per downloaded piece. When non-zero, this indicates │ │ │ │ -how many milliseconds in advance pieces should be announced, before they are │ │ │ │ -expected to be completed. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_i_o___t_h_r_e_a_d_s_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ -for some aio back-ends, aio_threads specifies the number of io-threads to use. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_t_r_a_c_k_e_r___b_a_c_k_o_f_f_|_i_n_t_ _|_2_5_0_ _ _ _ | │ │ │ │ -tracker_backoff determines how aggressively to back off from retrying failing │ │ │ │ -trackers. This value determines xx in the following formula, determining the │ │ │ │ -number of seconds to wait until the next retry: │ │ │ │ - delay = 5 + 5 * x / 100 * fails^2 │ │ │ │ -This setting may be useful to make libtorrent more or less aggressive in │ │ │ │ -hitting trackers. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_h_a_r_e___r_a_t_i_o___l_i_m_i_t_ _ _ _ _|_i_n_t_ _|_2_0_0_ _ _ _ | │ │ │ │ -|_s_e_e_d___t_i_m_e___r_a_t_i_o___l_i_m_i_t_|_i_n_t_ _|_7_0_0_ _ _ _ | │ │ │ │ -when a seeding torrent reaches either the share ratio (bytes up / bytes down) │ │ │ │ -or the seed time ratio (seconds as seed / seconds as downloader) or the seed │ │ │ │ -time limit (seconds as seed) it is considered done, and it will leave room for │ │ │ │ -other torrents. These are specified as percentages. Torrents that are │ │ │ │ -considered done will still be allowed to be seeded, they just won't have │ │ │ │ -priority anymore. For more, see _q_u_e_u_i_n_g. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_e_e_r___t_u_r_n_o_v_e_r_ _ _ _ _ _ _ _ _ _|_i_n_t_ _|_4_ _ _ _ _ _ | │ │ │ │ -|_p_e_e_r___t_u_r_n_o_v_e_r___c_u_t_o_f_f_ _ _|_i_n_t_ _|_9_0_ _ _ _ _ | │ │ │ │ -|_p_e_e_r___t_u_r_n_o_v_e_r___i_n_t_e_r_v_a_l_|_i_n_t_ _|_3_0_0_ _ _ _ | │ │ │ │ -peer_turnover is the percentage of peers to disconnect every turnover │ │ │ │ -peer_turnover_interval (if we're at the peer limit), this is specified in │ │ │ │ -percent when we are connected to more than limit * peer_turnover_cutoff peers │ │ │ │ -disconnect peer_turnover fraction of the peers. It is specified in percent │ │ │ │ -peer_turnover_interval is the interval (in seconds) between optimistic │ │ │ │ -disconnects if the disconnects happen and how many peers are disconnected is │ │ │ │ -controlled by peer_turnover and peer_turnover_cutoff │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_c_o_n_n_e_c_t___s_e_e_d___e_v_e_r_y___n___d_o_w_n_l_o_a_d_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ -this setting controls the priority of downloading torrents over seeding or │ │ │ │ -finished torrents when it comes to making peer connections. Peer connections │ │ │ │ -are throttled by the connection_speed and the half-open connection limit. This │ │ │ │ -makes peer connections a limited resource. Torrents that still have pieces to │ │ │ │ -download are prioritized by default, to avoid having many seeding torrents use │ │ │ │ -most of the connection attempts and only give one peer every now and then to │ │ │ │ -the downloading torrent. libtorrent will loop over the downloading torrents to │ │ │ │ -connect a peer each, and every n:th connection attempt, a finished torrent is │ │ │ │ -picked to be allowed to connect to a peer. This setting controls n. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ | │ │ │ │ -|_m_a_x___h_t_t_p___r_e_c_v___b_u_f_f_e_r___s_i_z_e_|_i_n_t_ _|_4_*_1_0_2_4_*_2_0_4| │ │ │ │ -the max number of bytes to allow an HTTP response to be when announcing to │ │ │ │ -trackers or downloading .torrent files via the url provided in │ │ │ │ -add_torrent_params. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___r_e_t_r_y___p_o_r_t___b_i_n_d_|_i_n_t_ _|_1_0_ _ _ _ _ | │ │ │ │ -if binding to a specific port fails, should the port be incremented by one and │ │ │ │ -tried again? This setting specifies how many times to retry a failed port bind │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_l_e_r_t___m_a_s_k_|_i_n_t_ _|_i_n_t_ _ _ _ | │ │ │ │ -a bitmask combining flags from _a_l_e_r_t___c_a_t_e_g_o_r_y___t defining which kinds of alerts │ │ │ │ -to receive │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_o_u_t___e_n_c___p_o_l_i_c_y_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e___e_n_a_b_l_e_d| │ │ │ │ -|_i_n___e_n_c___p_o_l_i_c_y_ _|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e___e_n_a_b_l_e_d| │ │ │ │ -control the settings for incoming and outgoing connections respectively. see │ │ │ │ -_e_n_c___p_o_l_i_c_y enum for the available options. Keep in mind that protocol │ │ │ │ -encryption degrades performance in several respects: │ │ │ │ - 1. It prevents "zero copy" disk buffers being sent to peers, since each peer │ │ │ │ - needs to mutate the data (i.e. encrypt it) the data must be copied per │ │ │ │ - peer connection rather than sending the same buffer to multiple peers. │ │ │ │ - 2. The encryption itself requires more CPU than plain bittorrent protocol. │ │ │ │ - The highest cost is the Diffie Hellman exchange on connection setup. │ │ │ │ - 3. The encryption handshake adds several round-trips to the connection │ │ │ │ - setup, and delays transferring data. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_a_l_l_o_w_e_d___e_n_c___l_e_v_e_l_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_p_e___b_o_t_h| │ │ │ │ -determines the encryption level of the connections. This setting will adjust │ │ │ │ -which encryption scheme is offered to the other peer, as well as which │ │ │ │ -encryption scheme is selected by the client. See _e_n_c___l_e_v_e_l enum for options. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_n_a_c_t_i_v_e___d_o_w_n___r_a_t_e_|_i_n_t_ _|_2_0_4_8_ _ _ | │ │ │ │ -|_i_n_a_c_t_i_v_e___u_p___r_a_t_e_ _ _|_i_n_t_ _|_2_0_4_8_ _ _ | │ │ │ │ -the download and upload rate limits for a torrent to be considered active by │ │ │ │ -the queuing mechanism. A torrent whose download rate is less than │ │ │ │ -inactive_down_rate and whose upload rate is less than inactive_up_rate for │ │ │ │ -auto_manage_startup seconds, is considered inactive, and another queued torrent │ │ │ │ -may be started. This logic is disabled if dont_count_slow_torrents is false. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_r_o_x_y___t_y_p_e_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_n_o_n_e| │ │ │ │ -proxy to use. see _p_r_o_x_y___t_y_p_e___t. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_p_r_o_x_y___p_o_r_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -the port of the proxy server │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_2_p___p_o_r_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -sets the _i_2_p SAM bridge port to connect to. set the hostname with the │ │ │ │ -i2p_hostname setting. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_r_l_s_e_e_d___m_a_x___r_e_q_u_e_s_t___b_y_t_e_s_|_i_n_t_ _|_1_6_ _*_ _1_0_2_4_ _*_ _1_0_2_4| │ │ │ │ -The maximum request range of an url seed in bytes. This value defines the │ │ │ │ -largest possible sequential web seed request. Lower values are possible but │ │ │ │ -will be ignored if they are lower then piece size. This value should be related │ │ │ │ -to your download speed to prevent libtorrent from creating too many expensive │ │ │ │ -http requests per second. You can select a value as high as you want but keep │ │ │ │ -in mind that libtorrent can't create parallel requests if the first request did │ │ │ │ -already select the whole file. If you combine bittorrent seeds with web seeds │ │ │ │ -and pick strategies like rarest first you may find your web seed requests split │ │ │ │ -into smaller parts because we don't download already picked pieces twice. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_w_e_b___s_e_e_d___n_a_m_e___l_o_o_k_u_p___r_e_t_r_y_|_i_n_t_ _|_1_8_0_0_ _ _ | │ │ │ │ -time to wait until a new retry of a web seed name lookup │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_c_l_o_s_e___f_i_l_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_C_L_O_S_E___F_I_L_E___I_N_T_E_R_V_A_L| │ │ │ │ -the number of seconds between closing the file opened the longest ago. 0 means │ │ │ │ -to disable the feature. The purpose of this is to periodically close files to │ │ │ │ -trigger the operating system flushing disk cache. Specifically it has been │ │ │ │ -observed to be required on windows to not have the disk cache grow │ │ │ │ -indefinitely. This defaults to 240 seconds on windows, and disabled on other │ │ │ │ -systems. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_t_p___c_w_n_d___r_e_d_u_c_e___t_i_m_e_r_|_i_n_t_ _|_1_0_0_ _ _ _ | │ │ │ │ -When uTP experiences packet loss, it will reduce the congestion window, and not │ │ │ │ -reduce it again for this many milliseconds, even if experiencing another lost │ │ │ │ -packet. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___w_e_b___s_e_e_d___c_o_n_n_e_c_t_i_o_n_s_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -the max number of web seeds to have connected per torrent at any given time. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_e_s_o_l_v_e_r___c_a_c_h_e___t_i_m_e_o_u_t_|_i_n_t_ _|_1_2_0_0_ _ _ | │ │ │ │ -the number of seconds before the internal host name resolver considers a cache │ │ │ │ -value out of date, and removes it. Negative values are interpreted as zero. The │ │ │ │ -host name cache also caches failed DNS lookups, but only for 1/8th of the time │ │ │ │ -of this timeout. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_s_e_n_d___n_o_t___s_e_n_t___l_o_w___w_a_t_e_r_m_a_r_k_|_i_n_t_ _|_1_6_3_8_4_ _ | │ │ │ │ -specify the not-sent low watermark for socket send buffers. This corresponds to │ │ │ │ -the, Linux-specific, TCP_NOTSENT_LOWAT TCP socket option. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_r_a_t_e___c_h_o_k_e_r___i_n_i_t_i_a_l___t_h_r_e_s_h_o_l_d_|_i_n_t_ _|_1_0_2_4_ _ _ | │ │ │ │ -the rate based choker compares the upload rate to peers against a threshold │ │ │ │ -that increases proportionally by its size for every peer it visits, visiting │ │ │ │ -peers in decreasing upload rate. The number of upload slots is determined by │ │ │ │ -the number of peers whose upload rate exceeds the threshold. This option sets │ │ │ │ -the start value for this threshold. A higher value leads to fewer unchoke │ │ │ │ -slots, a lower value leads to more. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_u_p_n_p___l_e_a_s_e___d_u_r_a_t_i_o_n_|_i_n_t_ _|_3_6_0_0_ _ _ | │ │ │ │ -The expiration time of UPnP port-mappings, specified in seconds. 0 means │ │ │ │ -permanent lease. Some routers do not support expiration times on port-maps (nor │ │ │ │ -correctly returning an error indicating lack of support). In those cases, set │ │ │ │ -this to 0. Otherwise, don't set it any lower than 5 minutes. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_a_x___c_o_n_c_u_r_r_e_n_t___h_t_t_p___a_n_n_o_u_n_c_e_s_|_i_n_t_ _|_5_0_ _ _ _ _ | │ │ │ │ -limits the number of concurrent HTTP tracker announces. Once the limit is hit, │ │ │ │ -tracker requests are queued and issued when an outstanding announce completes. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___m_a_x___p_e_e_r_s___r_e_p_l_y_|_i_n_t_ _|_1_0_0_ _ _ _ | │ │ │ │ -the maximum number of peers to send in a reply to get_peers │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___s_e_a_r_c_h___b_r_a_n_c_h_i_n_g_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ -the number of concurrent search request the node will send when announcing and │ │ │ │ -refreshing the routing table. This parameter is called alpha in the kademlia │ │ │ │ -paper │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___m_a_x___f_a_i_l___c_o_u_n_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ -the maximum number of failed tries to contact a node before it is removed from │ │ │ │ -the routing table. If there are known working nodes that are ready to replace a │ │ │ │ -failing node, it will be replaced immediately, this limit is only used to clear │ │ │ │ -out nodes that don't have any node that can replace them. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___m_a_x___t_o_r_r_e_n_t_s_|_i_n_t_ _|_2_0_0_0_ _ _ | │ │ │ │ -the total number of torrents to track from the DHT. This is simply an upper │ │ │ │ -limit to make sure malicious DHT nodes cannot make us allocate an unbounded │ │ │ │ -amount of memory. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___m_a_x___d_h_t___i_t_e_m_s_|_i_n_t_ _|_7_0_0_ _ _ _ | │ │ │ │ -max number of items the DHT will store │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___m_a_x___p_e_e_r_s_|_i_n_t_ _|_5_0_0_ _ _ _ | │ │ │ │ -the max number of peers to store per torrent (for the DHT) │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___m_a_x___t_o_r_r_e_n_t___s_e_a_r_c_h___r_e_p_l_y_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ -the max number of torrents to return in a torrent search query to the DHT │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___b_l_o_c_k___t_i_m_e_o_u_t_|_i_n_t_ _|_5_ _*_ _6_0_ | │ │ │ │ -the number of seconds a DHT node is banned if it exceeds the rate limit. The │ │ │ │ -rate limit is averaged over 10 seconds to allow for bursts above the limit. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___b_l_o_c_k___r_a_t_e_l_i_m_i_t_|_i_n_t_ _|_5_ _ _ _ _ _ | │ │ │ │ -the max number of packets per second a DHT node is allowed to send without │ │ │ │ -getting banned. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___i_t_e_m___l_i_f_e_t_i_m_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -the number of seconds a immutable/mutable item will be expired. default is 0, │ │ │ │ -means never expires. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___s_a_m_p_l_e___i_n_f_o_h_a_s_h_e_s___i_n_t_e_r_v_a_l_|_i_n_t_ _|_2_1_6_0_0_ _ | │ │ │ │ -the info-hashes sample recomputation interval (in seconds). The node will │ │ │ │ -precompute a subset of the tracked info-hashes and return that instead of │ │ │ │ -calculating it upon each request. The permissible range is between 0 and 21600 │ │ │ │ -seconds (inclusive). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_d_h_t___m_a_x___i_n_f_o_h_a_s_h_e_s___s_a_m_p_l_e___c_o_u_n_t_|_i_n_t_ _|_2_0_ _ _ _ _ | │ │ │ │ -the maximum number of elements in the sampled subset of info-hashes. If this │ │ │ │ -number is too big, expect the DHT storage implementations to clamp it in order │ │ │ │ -to allow UDP packets go through │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ | │ │ │ │ -|_m_a_x___p_i_e_c_e___c_o_u_n_t_|_i_n_t_ _|_0_x_2_0_0_0_0_0| │ │ │ │ -max_piece_count is the maximum allowed number of pieces in metadata received │ │ │ │ -via magnet links. Loading large torrents (with more pieces than the default │ │ │ │ -limit) may also require passing in a higher limit to _r_e_a_d___r_e_s_u_m_e___d_a_t_a_(_) and │ │ │ │ -_l_o_a_d___t_o_r_r_e_n_t___f_i_l_e_(_). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_e_t_a_d_a_t_a___t_o_k_e_n___l_i_m_i_t_|_i_n_t_ _|_2_5_0_0_0_0_0| │ │ │ │ -when receiving metadata (torrent file) from peers, this is the max number of │ │ │ │ -bencoded tokens we're willing to parse. This limit is meant to prevent DoS │ │ │ │ -attacks on peers. For very large torrents, this limit may have to be raised. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_i_s_k___w_r_i_t_e___m_o_d_e_|_i_n_t_ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_m_m_a_p___w_r_i_t_e___m_o_d_e___t_:_:_a_l_w_a_y_s___m_m_a_p___w_r_i_t_e| │ │ │ │ -controls whether disk writes will be made through a memory mapped file or via │ │ │ │ -normal write calls. This only affects the mmap_disk_io. When saving to a non- │ │ │ │ -local drive (network share, NFS or NAS) using memory mapped files is most │ │ │ │ -likely inferior. When writing to a local SSD (especially in DAX mode) using │ │ │ │ -memory mapped files likely gives the best performance. The values for this │ │ │ │ -setting are specified as _m_m_a_p___w_r_i_t_e___m_o_d_e___t. │ │ │ │ -A very important consideration when changing this is that some operating │ │ │ │ -systems and filesystems do not support mixing write calls with memory mapped │ │ │ │ -files. Notably, Windows does not support mixing, since windows does not use the │ │ │ │ -page cache for caching files. Also, ZFS and Btrfs use their own caching layer, │ │ │ │ -not the page cache, so they also do not support mixing. Since reading large │ │ │ │ -files always happen via mmap, enabling writes via write calls on this systems │ │ │ │ -may cause corruption. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_m_a_p___f_i_l_e___s_i_z_e___c_u_t_o_f_f_|_i_n_t_ _|_4_0_ _ _ _ _ | │ │ │ │ -when using mmap_disk_io, files smaller than this number of blocks will not be │ │ │ │ -memory mapped, but will use normal pread/pwrite operations. This file size │ │ │ │ -limit is specified in 16 kiB blocks. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_2_p___i_n_b_o_u_n_d___q_u_a_n_t_i_t_y_ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -|_i_2_p___o_u_t_b_o_u_n_d___q_u_a_n_t_i_t_y_|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -|_i_2_p___i_n_b_o_u_n_d___l_e_n_g_t_h_ _ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -|_i_2_p___o_u_t_b_o_u_n_d___l_e_n_g_t_h_ _ _|_i_n_t_ _|_3_ _ _ _ _ _ | │ │ │ │ -Configures the SAM _s_e_s_s_i_o_n quantity of I2P inbound and outbound tunnels │ │ │ │ -[1..16]. number of hops for I2P inbound and outbound tunnels [0..7] Changing │ │ │ │ -these will not trigger a reconnect to the SAM bridge, they will take effect the │ │ │ │ -next time the SAM connection is re-established (by restarting or changing │ │ │ │ -i2p_hostname or i2p_port). │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_a_n_n_o_u_n_c_e___p_o_r_t_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -announce_port is the port passed along as the port parameter to remote trackers │ │ │ │ -such as HTTP or DHT. This setting does not affect the effective listening port │ │ │ │ -nor local service discovery announcements. If left as zero (default), the │ │ │ │ -listening port value is used. │ │ │ │ -Note │ │ │ │ -This setting is only meant for very special cases where a seed's listening port │ │ │ │ -differs from the external port. As an example, if a local proxy is used and │ │ │ │ -that the proxy supports reverse tunnels through NAT-PMP, the tracker must │ │ │ │ -connect to the external NAT-PMP port (configured using announce_port) instead │ │ │ │ -of the actual local listening port. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_i_2_p___i_n_b_o_u_n_d___l_e_n_g_t_h___v_a_r_i_a_n_c_e_ _|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -|_i_2_p___o_u_t_b_o_u_n_d___l_e_n_g_t_h___v_a_r_i_a_n_c_e_|_i_n_t_ _|_0_ _ _ _ _ _ | │ │ │ │ -Configures the variance for I2P inbound and outbound tunnel lengths [-7..7] │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_n_a_t_p_m_p___l_e_a_s_e___d_u_r_a_t_i_o_n_|_i_n_t_ _|_3_6_0_0_ _ _ | │ │ │ │ -The life time of NAT-PMP and PCP port-mappings, specified in seconds. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_m_i_n___w_e_b_s_o_c_k_e_t___a_n_n_o_u_n_c_e___i_n_t_e_r_v_a_l_|_i_n_t_ _|_1_ _*_ _6_0_ | │ │ │ │ -this is the minimum allowed announce interval for a WebSocket tracker used by │ │ │ │ -WebTorrent to signal WebRTC connections. This is specified in seconds and is │ │ │ │ -used as a sanity check on what is returned from a tracker. │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_tt_yy_pp_ee_|_dd_ee_ff_aa_uu_ll_tt| │ │ │ │ -|_w_e_b_t_o_r_r_e_n_t___c_o_n_n_e_c_t_i_o_n___t_i_m_e_o_u_t_|_i_n_t_ _|_2_ _*_ _6_0_ | │ │ │ │ -the WebRTC connection timeout used by WebTorrent (in seconds) │ │ │ │ -struct settings_pack final : settings_interface │ │ │ │ -{ │ │ │ │ - void sseett__bbooooll (int name, bool val) override; │ │ │ │ - void sseett__iinntt (int name, int val) override; │ │ │ │ - void sseett__ssttrr (int name, std::string val) override; │ │ │ │ - bool hhaass__vvaall (int name) const override; │ │ │ │ - void cclleeaarr (); │ │ │ │ - void cclleeaarr (int name); │ │ │ │ - int ggeett__iinntt (int name) const override; │ │ │ │ - bool ggeett__bbooooll (int name) const override; │ │ │ │ - std::string const& ggeett__ssttrr (int name) const override; │ │ │ │ - │ │ │ │ - enum type_bases │ │ │ │ - { │ │ │ │ - string_type_base, │ │ │ │ - int_type_base, │ │ │ │ - bool_type_base, │ │ │ │ - type_mask, │ │ │ │ - index_mask, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum mmap_write_mode_t │ │ │ │ - { │ │ │ │ - always_pwrite, │ │ │ │ - always_mmap_write, │ │ │ │ - auto_mmap_write, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum suggest_mode_t │ │ │ │ - { │ │ │ │ - no_piece_suggestions, │ │ │ │ - suggest_read_cache, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum choking_algorithm_t │ │ │ │ - { │ │ │ │ - fixed_slots_choker, │ │ │ │ - rate_based_choker, │ │ │ │ - deprecated_bittyrant_choker, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum seed_choking_algorithm_t │ │ │ │ - { │ │ │ │ - round_robin, │ │ │ │ - fastest_upload, │ │ │ │ - anti_leech, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum io_buffer_mode_t │ │ │ │ - { │ │ │ │ - enable_os_cache, │ │ │ │ - deprecated_disable_os_cache_for_aligned_files, │ │ │ │ - disable_os_cache, │ │ │ │ - write_through, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum bandwidth_mixed_algo_t │ │ │ │ - { │ │ │ │ - prefer_tcp, │ │ │ │ - peer_proportional, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum enc_policy │ │ │ │ - { │ │ │ │ - pe_forced, │ │ │ │ - pe_enabled, │ │ │ │ - pe_disabled, │ │ │ │ - }; │ │ │ │ - │ │ │ │ - enum enc_level │ │ │ │ - { │ │ │ │ - pe_plaintext, │ │ │ │ - pe_rc4, │ │ │ │ - pe_both, │ │ │ │ - }; │ │ │ │ +********** iinntteeggeerr(()) ssttrriinngg(()) lliisstt(()) pprreeffoorrmmaatttteedd(()) ddiicctt(()) ********** │ │ │ │ +preformatted_type const& pprreeffoorrmmaatttteedd () const; │ │ │ │ +integer_type const& iinntteeggeerr () const; │ │ │ │ +preformatted_type& pprreeffoorrmmaatttteedd (); │ │ │ │ +dictionary_type& ddiicctt (); │ │ │ │ +dictionary_type const& ddiicctt () const; │ │ │ │ +integer_type& iinntteeggeerr (); │ │ │ │ +string_type& ssttrriinngg (); │ │ │ │ +string_type const& ssttrriinngg () const; │ │ │ │ +list_type const& lliisstt () const; │ │ │ │ +list_type& lliisstt (); │ │ │ │ +The integer(), string(), list(), dict() and preformatted() functions are │ │ │ │ +accessors that return the respective type. If the entry object isn't of the │ │ │ │ +type you request, the accessor will throw system_error. You can ask an entry │ │ │ │ +for its type through the type() function. │ │ │ │ +If you want to create an entry you give it the type you want it to have in its │ │ │ │ +constructor, and then use one of the non-const accessors to get a reference │ │ │ │ +which you then can assign the value you want it to have. │ │ │ │ +The typical code to get info from a torrent file will then look like this: │ │ │ │ +entry torrent_file; │ │ │ │ +// ... │ │ │ │ │ │ │ │ - enum proxy_type_t │ │ │ │ - { │ │ │ │ - none, │ │ │ │ - socks4, │ │ │ │ - socks5, │ │ │ │ - socks5_pw, │ │ │ │ - http, │ │ │ │ - http_pw, │ │ │ │ - }; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__bbooooll(()) sseett__ssttrr(()) sseett__iinntt(()) ********** │ │ │ │ -void sseett__bbooooll (int name, bool val) override; │ │ │ │ -void sseett__iinntt (int name, int val) override; │ │ │ │ -void sseett__ssttrr (int name, std::string val) override; │ │ │ │ -set a configuration option in the _s_e_t_t_i_n_g_s___p_a_c_k. name is one of the enum values │ │ │ │ -from string_types, int_types or bool_types. They must match the respective type │ │ │ │ -of the set_* function. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaass__vvaall(()) ********** │ │ │ │ -bool hhaass__vvaall (int name) const override; │ │ │ │ -queries whether the specified configuration option has a value set in this │ │ │ │ -pack. name can be any enumeration value from string_types, int_types or │ │ │ │ -bool_types. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cclleeaarr(()) ********** │ │ │ │ -void cclleeaarr (); │ │ │ │ -clear the settings pack from all settings │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cclleeaarr(()) ********** │ │ │ │ -void cclleeaarr (int name); │ │ │ │ -clear a specific setting from the pack │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__ssttrr(()) ggeett__bbooooll(()) ggeett__iinntt(()) ********** │ │ │ │ -int ggeett__iinntt (int name) const override; │ │ │ │ -bool ggeett__bbooooll (int name) const override; │ │ │ │ -std::string const& ggeett__ssttrr (int name) const override; │ │ │ │ -queries the current configuration option from the _s_e_t_t_i_n_g_s___p_a_c_k. name is one of │ │ │ │ -the enumeration values from string_types, int_types or bool_types. The enum │ │ │ │ -value must match the type of the get_* function. If the specified setting field │ │ │ │ -has not been set, the default value is returned. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ttyyppee__bbaasseess ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_s_t_r_i_n_g___t_y_p_e___b_a_s_e_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_t___t_y_p_e___b_a_s_e_ _ _ _|_1_6_3_8_4_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_b_o_o_l___t_y_p_e___b_a_s_e_ _ _|_3_2_7_6_8_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_y_p_e___m_a_s_k_ _ _ _ _ _ _ _|_4_9_1_5_2_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_d_e_x___m_a_s_k_ _ _ _ _ _ _|_1_6_3_8_3_|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm mmmmaapp__wwrriittee__mmooddee__tt ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|always_pwrite |0 |disable writing to disk via mmap, always use normal | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_r_i_t_e_ _c_a_l_l_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|always_mmap_write|1 |prefer using memory mapped files for disk writes (at| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_l_e_a_s_t_ _f_o_r_ _l_a_r_g_e_ _f_i_l_e_s_ _w_h_e_r_e_ _i_t_ _m_i_g_h_t_ _m_a_k_e_ _s_e_n_s_e_)_ _ _ _ | │ │ │ │ -| | |determine whether to use pwrite or memory mapped | │ │ │ │ -|auto_mmap_write |2 |files for disk writes depending on the kind of | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_t_o_r_a_g_e_ _b_e_h_i_n_d_ _t_h_e_ _s_a_v_e_ _p_a_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ssuuggggeesstt__mmooddee__tt ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o___p_i_e_c_e___s_u_g_g_e_s_t_i_o_n_s_|_0_ _ _ _ _|_d_i_s_a_b_l_e_s_ _s_u_g_g_e_s_t_i_o_n_ _m_e_s_s_a_g_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |sends suggest messages for the pieces currently in| │ │ │ │ -|suggest_read_cache |1 |the read cache, as a hint to peers about cache- | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_f_r_i_e_n_d_l_y_ _p_i_e_c_e_ _s_e_l_e_c_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm cchhookkiinngg__aallggoorriitthhmm__tt ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |This is the traditional choker with a fixed| │ │ │ │ -|fixed_slots_choker |0 |number of unchoke slots (as specified by | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_s_e_t_t_i_n_g_s___p_a_c_k_:_:_u_n_c_h_o_k_e___s_l_o_t_s___l_i_m_i_t_)_._ _ _ _ _ _ _ | │ │ │ │ -| | |This opens up unchoke slots based on the | │ │ │ │ -| | |upload rate achieved to peers. The more | │ │ │ │ -| | |slots that are opened, the marginal upload | │ │ │ │ -| | |rate required to open up another slot | │ │ │ │ -|rate_based_choker |2 |increases. Configure the initial threshold | │ │ │ │ -| | |with _s_e_t_t_i_n_g_s___p_a_c_k_:_: | │ │ │ │ -| | |_r_a_t_e___c_h_o_k_e_r___i_n_i_t_i_a_l___t_h_r_e_s_h_o_l_d. | │ │ │ │ -| | |For more information, see _r_a_t_e_ _b_a_s_e_d | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_h_o_k_i_n_g_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___b_i_t_t_y_r_a_n_t___c_h_o_k_e_r_|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm sseeeedd__cchhookkiinngg__aallggoorriitthhmm__tt ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |which round-robins the peers that are unchoked when | │ │ │ │ -|round_robin |0 |seeding. This distributes the upload bandwidth uniformly| │ │ │ │ -| | |and fairly. It minimizes the ability for a peer to | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_d_o_w_n_l_o_a_d_ _e_v_e_r_y_t_h_i_n_g_ _w_i_t_h_o_u_t_ _r_e_d_i_s_t_r_i_b_u_t_i_n_g_ _i_t_._ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |unchokes the peers we can send to the fastest. This | │ │ │ │ -|fastest_upload|1 |might be a bit more reliable in utilizing all available | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_c_a_p_a_c_i_t_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |prioritizes peers who have just started or are just | │ │ │ │ -| | |about to finish the download. The intention is to force | │ │ │ │ -|anti_leech |2 |peers in the middle of the download to trade with each | │ │ │ │ -| | |other. This does not just take into account the pieces a| │ │ │ │ -| | |peer is reporting having downloaded, but also the pieces| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_e_ _h_a_v_e_ _s_e_n_t_ _t_o_ _i_t_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm iioo__bbuuffffeerr__mmooddee__tt ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_e_n_a_b_l_e___o_s___c_a_c_h_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_e_p_r_e_c_a_t_e_d___d_i_s_a_b_l_e___o_s___c_a_c_h_e___f_o_r___a_l_i_g_n_e_d___f_i_l_e_s_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_i_s_a_b_l_e___o_s___c_a_c_h_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_w_r_i_t_e___t_h_r_o_u_g_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm bbaannddwwiiddtthh__mmiixxeedd__aallggoo__tt ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_r_e_f_e_r___t_c_p_ _ _ _ _ _ _ _|_0_ _ _ _ _|_d_i_s_a_b_l_e_s_ _t_h_e_ _m_i_x_e_d_ _m_o_d_e_ _b_a_n_d_w_i_d_t_h_ _b_a_l_a_n_c_i_n_g_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|peer_proportional|1 |does not throttle uTP, throttles TCP to the same | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_r_o_p_o_r_t_i_o_n_ _o_f_ _t_h_r_o_u_g_h_p_u_t_ _a_s_ _t_h_e_r_e_ _a_r_e_ _T_C_P_ _c_o_n_n_e_c_t_i_o_n_s| │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm eenncc__ppoolliiccyy ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |Only encrypted connections are allowed. Incoming | │ │ │ │ -|pe_forced |0 |connections that are not encrypted are closed and if the | │ │ │ │ -| | |encrypted outgoing connection fails, a non-encrypted retry| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_w_i_l_l_ _n_o_t_ _b_e_ _m_a_d_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |encrypted connections are enabled, but non-encrypted | │ │ │ │ -| | |connections are allowed. An incoming non-encrypted | │ │ │ │ -|pe_enabled |1 |connection will be accepted, and if an outgoing encrypted | │ │ │ │ -| | |connection fails, a non- encrypted connection will be | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_t_r_i_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_e___d_i_s_a_b_l_e_d_|_2_ _ _ _ _|_o_n_l_y_ _n_o_n_-_e_n_c_r_y_p_t_e_d_ _c_o_n_n_e_c_t_i_o_n_s_ _a_r_e_ _a_l_l_o_w_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm eenncc__lleevveell ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_p_e___p_l_a_i_n_t_e_x_t_|_1_ _ _ _ _|_u_s_e_ _o_n_l_y_ _p_l_a_i_n_ _t_e_x_t_ _e_n_c_r_y_p_t_i_o_n| │ │ │ │ -|_p_e___r_c_4_ _ _ _ _ _ _|_2_ _ _ _ _|_u_s_e_ _o_n_l_y_ _R_C_4_ _e_n_c_r_y_p_t_i_o_n_ _ _ _ _ _ _ | │ │ │ │ -|_p_e___b_o_t_h_ _ _ _ _ _|_3_ _ _ _ _|_a_l_l_o_w_ _b_o_t_h_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm pprrooxxyy__ttyyppee__tt ********** │ │ │ │ -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" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_n_o_n_e_ _ _ _ _ _|_0_ _ _ _ _|_N_o_ _p_r_o_x_y_ _s_e_r_v_e_r_ _i_s_ _u_s_e_d_ _a_n_d_ _a_l_l_ _o_t_h_e_r_ _f_i_e_l_d_s_ _a_r_e_ _i_g_n_o_r_e_d_._ _ _ _ | │ │ │ │ -|socks4 |1 |The server is assumed to be a _S_O_C_K_S_4_ _s_e_r_v_e_r that requires a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_u_s_e_r_n_a_m_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The server is assumed to be a SOCKS5 server (_R_F_C_ _1_9_2_8) that | │ │ │ │ -|socks5 |2 |does not require any authentication. The username and | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_a_s_s_w_o_r_d_ _a_r_e_ _i_g_n_o_r_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The server is assumed to be a SOCKS5 server that supports | │ │ │ │ -|socks5_pw|3 |plain text username and password authentication (_R_F_C_ _1_9_2_9). | │ │ │ │ -| | |The username and password specified may be sent to the proxy | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_f_ _i_t_ _r_e_q_u_i_r_e_s_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The server is assumed to be an HTTP proxy. If the transport | │ │ │ │ -| | |used for the connection is non-HTTP, the server is assumed to| │ │ │ │ -|http |4 |support the _C_O_N_N_E_C_T method. i.e. for web seeds and HTTP | │ │ │ │ -| | |trackers, a plain proxy will suffice. The proxy is assumed to| │ │ │ │ -| | |not require authorization. The username and password will not| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_e_ _u_s_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |The server is assumed to be an HTTP proxy that requires user | │ │ │ │ -|http_pw |5 |authorization. The username and password will be sent to the | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_r_o_x_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ggeenneerraattee__ffiinnggeerrpprriinntt(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_n_g_e_r_p_r_i_n_t_._h_p_p" │ │ │ │ -std::string ggeenneerraattee__ffiinnggeerrpprriinntt (std::string name │ │ │ │ - , int major, int minor = 0, int revision = 0, int tag = 0); │ │ │ │ -This is a utility function to produce a client ID fingerprint formatted to the │ │ │ │ -most common convention. The fingerprint can be set via the peer_fingerprint │ │ │ │ -setting, in _s_e_t_t_i_n_g_s___p_a_c_k. │ │ │ │ -The name string should contain exactly two characters. These are the characters │ │ │ │ -unique to your client, used to identify it. Make sure not to clash with anybody │ │ │ │ -else. Here are some taken id's: │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_ii_dd_ _cc_hh_aa_rr_ss_|_cc_ll_ii_ee_nn_tt_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_L_T_ _ _ _ _ _ _|_l_i_b_t_o_r_r_e_n_t_ _(_d_e_f_a_u_l_t_)| │ │ │ │ -|_U_T_ _ _ _ _ _ _|_u_T_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_U_M_ _ _ _ _ _ _|_u_T_o_r_r_e_n_t_ _M_a_c_ _ _ _ _ _ _ _ | │ │ │ │ -|_q_B_ _ _ _ _ _ _|_q_B_i_t_t_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ | │ │ │ │ -|_B_P_ _ _ _ _ _ _|_B_i_t_T_o_r_r_e_n_t_ _P_r_o_ _ _ _ _ _ | │ │ │ │ -|_B_T_ _ _ _ _ _ _|_B_i_t_T_o_r_r_e_n_t_ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_D_E_ _ _ _ _ _ _|_D_e_l_u_g_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_A_Z_ _ _ _ _ _ _|_A_z_u_r_e_u_s_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_T_L_ _ _ _ _ _ _|_T_r_i_b_l_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -There's an informal directory of client id's _h_e_r_e. │ │ │ │ -The major, minor, revision and tag parameters are used to identify the version │ │ │ │ -of your client. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhiigghh__ppeerrffoorrmmaannccee__sseeeedd(()) mmiinn__mmeemmoorryy__uussaaggee(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -settings_pack hhiigghh__ppeerrffoorrmmaannccee__sseeeedd (); │ │ │ │ -settings_pack mmiinn__mmeemmoorryy__uussaaggee (); │ │ │ │ -The default values of the _s_e_s_s_i_o_n settings are set for a regular bittorrent │ │ │ │ -client running on a desktop system. There are functions that can set the │ │ │ │ -_s_e_s_s_i_o_n settings to pre set settings for other environments. These can be used │ │ │ │ -for the basis, and should be tweaked to fit your needs better. │ │ │ │ -min_memory_usage returns settings that will use the minimal amount of RAM, at │ │ │ │ -the potential expense of upload and download performance. It adjusts the socket │ │ │ │ -buffer sizes, disables the disk cache, lowers the send buffer watermarks so │ │ │ │ -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. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseettttiinngg__bbyy__nnaammee(()) nnaammee__ffoorr__sseettttiinngg(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ -char const* nnaammee__ffoorr__sseettttiinngg (int s); │ │ │ │ -int sseettttiinngg__bbyy__nnaammee (string_view name); │ │ │ │ -converts a setting integer (from the enums string_types, int_types or │ │ │ │ -bool_types) to a string, and vice versa. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddeeffaauulltt__sseettttiinnggss(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ -settings_pack ddeeffaauulltt__sseettttiinnggss (); │ │ │ │ -returns a _s_e_t_t_i_n_g_s___p_a_c_k with every setting set to its default value │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bbddeeccooddee__nnooddee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ -Sometimes it's important to get a non-owning reference to the root node ( to be │ │ │ │ -able to copy it as a reference for instance). For that, use the _n_o_n___o_w_n_i_n_g_(_) │ │ │ │ -member function. │ │ │ │ -There are 5 different types of nodes, see _t_y_p_e___t. │ │ │ │ -struct bdecode_node │ │ │ │ +// throws if this is not a dictionary │ │ │ │ +entry::dictionary_type const& dict = torrent_file.dict(); │ │ │ │ +entry::dictionary_type::const_iterator i; │ │ │ │ +i = dict.find("announce"); │ │ │ │ +if (i != dict.end()) │ │ │ │ { │ │ │ │ - bbddeeccooddee__nnooddee () = default; │ │ │ │ - bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ - bbddeeccooddee__nnooddee (bdecode_node const&); │ │ │ │ - bdecode_node& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ - bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ - type_t ttyyppee () const noexcept; │ │ │ │ - explicit operator bbooooll () const noexcept; │ │ │ │ - bdecode_node nnoonn__oowwnniinngg () const; │ │ │ │ - span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ - std::ptrdiff_t ddaattaa__ooffffsseett () const noexcept; │ │ │ │ - string_view lliisstt__ssttrriinngg__vvaalluuee__aatt (int i │ │ │ │ - , string_view default_val = string_view()) const; │ │ │ │ - int lliisstt__ssiizzee () const; │ │ │ │ - bdecode_node lliisstt__aatt (int i) const; │ │ │ │ - std::int64_t lliisstt__iinntt__vvaalluuee__aatt (int i │ │ │ │ - , std::int64_t default_val = 0) const; │ │ │ │ - bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ - string_view ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee (string_view key │ │ │ │ - , string_view default_value = string_view()) const; │ │ │ │ - std::pair ddiicctt__aatt (int i) const; │ │ │ │ - bdecode_node ddiicctt__ffiinndd (string_view key) const; │ │ │ │ - std::int64_t ddiicctt__ffiinndd__iinntt__vvaalluuee (string_view key │ │ │ │ - , std::int64_t default_val = 0) const; │ │ │ │ - int ddiicctt__ssiizzee () const; │ │ │ │ - bdecode_node ddiicctt__ffiinndd__ddiicctt (string_view key) const; │ │ │ │ - std::pair ddiicctt__aatt__nnooddee (int i) const; │ │ │ │ - bdecode_node ddiicctt__ffiinndd__lliisstt (string_view key) const; │ │ │ │ - bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ - std::int64_t iinntt__vvaalluuee () const; │ │ │ │ - char const* ssttrriinngg__ppttrr () const; │ │ │ │ - string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ - int ssttrriinngg__lleennggtthh () const; │ │ │ │ - std::ptrdiff_t ssttrriinngg__ooffffsseett () const; │ │ │ │ - void cclleeaarr (); │ │ │ │ - void sswwaapp (bdecode_node& n); │ │ │ │ - void rreesseerrvvee (int tokens); │ │ │ │ - void sswwiittcchh__uunnddeerrllyyiinngg__bbuuffffeerr (char const* buf) noexcept; │ │ │ │ - bool hhaass__ssoofftt__eerrrroorr (span error) const; │ │ │ │ + std::string tracker_url = i->second.string(); │ │ │ │ + std::cout << tracker_url << "\n"; │ │ │ │ +} │ │ │ │ +The following code is equivalent, but a little bit shorter: │ │ │ │ +entry torrent_file; │ │ │ │ +// ... │ │ │ │ │ │ │ │ - enum type_t │ │ │ │ - { │ │ │ │ - none_t, │ │ │ │ - dict_t, │ │ │ │ - list_t, │ │ │ │ - string_t, │ │ │ │ - int_t, │ │ │ │ - }; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bbddeeccooddee__nnooddee(()) ********** │ │ │ │ -bbddeeccooddee__nnooddee () = default; │ │ │ │ -creates a default constructed node, it will have the type none_t. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) bbddeeccooddee__nnooddee(()) ********** │ │ │ │ -bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ -bbddeeccooddee__nnooddee (bdecode_node const&); │ │ │ │ -bdecode_node& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ -bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ -For owning nodes, the copy will create a copy of the tree, but the underlying │ │ │ │ -buffer remains the same. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ttyyppee(()) ********** │ │ │ │ -type_t ttyyppee () const noexcept; │ │ │ │ -the type of this node. See _t_y_p_e___t. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** bbooooll(()) ********** │ │ │ │ -explicit operator bbooooll () const noexcept; │ │ │ │ -returns true if _t_y_p_e_(_) != none_t. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnoonn__oowwnniinngg(()) ********** │ │ │ │ -bdecode_node nnoonn__oowwnniinngg () const; │ │ │ │ -return a non-owning reference to this node. This is useful to refer to the root │ │ │ │ -node without copying it in assignments. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddaattaa__ooffffsseett(()) ddaattaa__sseeccttiioonn(()) ********** │ │ │ │ -span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ -std::ptrdiff_t ddaattaa__ooffffsseett () const noexcept; │ │ │ │ -returns the buffer and length of the section in the original bencoded buffer │ │ │ │ -where this node is defined. For a dictionary for instance, this starts with d │ │ │ │ -and ends with e, and has all the content of the dictionary in between. the │ │ │ │ -data_offset() function returns the byte-offset to this node in, starting from │ │ │ │ -the beginning of the buffer that was parsed. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** lliisstt__ssiizzee(()) lliisstt__ssttrriinngg__vvaalluuee__aatt(()) lliisstt__aatt(()) lliisstt__iinntt__vvaalluuee__aatt(()) ********** │ │ │ │ -string_view lliisstt__ssttrriinngg__vvaalluuee__aatt (int i │ │ │ │ - , string_view default_val = string_view()) const; │ │ │ │ -int lliisstt__ssiizzee () const; │ │ │ │ -bdecode_node lliisstt__aatt (int i) const; │ │ │ │ -std::int64_t lliisstt__iinntt__vvaalluuee__aatt (int i │ │ │ │ - , std::int64_t default_val = 0) const; │ │ │ │ -functions with the list_ prefix operate on lists. These functions are only │ │ │ │ -valid if type() == list_t. list_at() returns the item in the list at index i. i │ │ │ │ -may not be greater than or equal to the size of the list. list_size() returns │ │ │ │ -the size of the list. list_int_value_at() and list_string_value_at() return the │ │ │ │ -integer or string value of the item at index i directly. If that item is not of │ │ │ │ -the requested type, the provided default_val is returned instead. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddiicctt__aatt(()) ddiicctt__ssiizzee(()) ddiicctt__ffiinndd__iinntt(()) ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee(()) │ │ │ │ -ddiicctt__ffiinndd__iinntt__vvaalluuee(()) ddiicctt__ffiinndd__ddiicctt(()) ddiicctt__aatt__nnooddee(()) ddiicctt__ffiinndd(()) │ │ │ │ -ddiicctt__ffiinndd__ssttrriinngg(()) ddiicctt__ffiinndd__lliisstt(()) ********** │ │ │ │ -bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ -string_view ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee (string_view key │ │ │ │ - , string_view default_value = string_view()) const; │ │ │ │ -std::pair ddiicctt__aatt (int i) const; │ │ │ │ -bdecode_node ddiicctt__ffiinndd (string_view key) const; │ │ │ │ -std::int64_t ddiicctt__ffiinndd__iinntt__vvaalluuee (string_view key │ │ │ │ - , std::int64_t default_val = 0) const; │ │ │ │ -int ddiicctt__ssiizzee () const; │ │ │ │ -bdecode_node ddiicctt__ffiinndd__ddiicctt (string_view key) const; │ │ │ │ -std::pair ddiicctt__aatt__nnooddee (int i) const; │ │ │ │ -bdecode_node ddiicctt__ffiinndd__lliisstt (string_view key) const; │ │ │ │ -bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ -Functions with the dict_ prefix operates on dictionaries. They are only valid │ │ │ │ -if type() == dict_t. In case a key you're looking up contains a 0 byte, you │ │ │ │ -cannot use the 0-terminated string overloads, but have to use string_view │ │ │ │ -instead. dict_find_list will return a valid bdecode_node if the key is found │ │ │ │ -_and_ it is a list. Otherwise it will return a default-constructed │ │ │ │ -_b_d_e_c_o_d_e___n_o_d_e. │ │ │ │ -Functions with the _value suffix return the value of the node directly, rather │ │ │ │ -than the nodes. In case the node is not found, or it has a different type, a │ │ │ │ -default value is returned (which can be specified). │ │ │ │ -dict_at() returns the (key, value)-pair at the specified index in a dictionary. │ │ │ │ -Keys are only allowed to be strings. dict_at_node() also returns the (key, │ │ │ │ -value)-pair, but the key is returned as a bdecode_node (and it will always be a │ │ │ │ -string). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinntt__vvaalluuee(()) ********** │ │ │ │ -std::int64_t iinntt__vvaalluuee () const; │ │ │ │ -this function is only valid if type() == int_t. It returns the value of the │ │ │ │ -integer. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssttrriinngg__ooffffsseett(()) ssttrriinngg__vvaalluuee(()) ssttrriinngg__ppttrr(()) ssttrriinngg__lleennggtthh(()) ********** │ │ │ │ -char const* ssttrriinngg__ppttrr () const; │ │ │ │ -string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ -int ssttrriinngg__lleennggtthh () const; │ │ │ │ -std::ptrdiff_t ssttrriinngg__ooffffsseett () const; │ │ │ │ -these functions are only valid if type() == string_t. They return the string │ │ │ │ -values. Note that string_ptr() is nnoott 0-terminated. string_length() returns the │ │ │ │ -number of bytes in the string. string_offset() returns the byte offset from the │ │ │ │ -start of the parsed bencoded buffer this string can be found. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** cclleeaarr(()) ********** │ │ │ │ -void cclleeaarr (); │ │ │ │ -resets the bdecoded_node to a default constructed state. If this is an owning │ │ │ │ -node, the tree is freed and all child nodes are invalidated. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sswwaapp(()) ********** │ │ │ │ -void sswwaapp (bdecode_node& n); │ │ │ │ -Swap contents. │ │ │ │ +// throws if this is not a dictionary │ │ │ │ +if (entry* i = torrent_file.find_key("announce")) │ │ │ │ +{ │ │ │ │ + std::string tracker_url = i->string(); │ │ │ │ + std::cout << tracker_url << "\n"; │ │ │ │ +} │ │ │ │ +To make it easier to extract information from a torrent file, the class │ │ │ │ +_t_o_r_r_e_n_t___i_n_f_o exists. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreesseerrvvee(()) ********** │ │ │ │ -void rreesseerrvvee (int tokens); │ │ │ │ -preallocate memory for the specified numbers of tokens. This is useful if you │ │ │ │ -know approximately how many tokens are in the file you are about to parse. │ │ │ │ -Doing so will save realloc operations while parsing. You should only call this │ │ │ │ -on the root node, before passing it in to _b_d_e_c_o_d_e_(_). │ │ │ │ +********** ooppeerraattoorr[[]](()) ********** │ │ │ │ +entry const& ooppeerraattoorr[[]] (string_view key) const; │ │ │ │ +entry& ooppeerraattoorr[[]] (string_view key); │ │ │ │ +All of these functions requires the _e_n_t_r_y to be a dictionary, if it isn't they │ │ │ │ +will throw system_error. │ │ │ │ +The non-const versions of the operator[] will return a reference to either the │ │ │ │ +existing element at the given key or, if there is no element with the given │ │ │ │ +key, a reference to a newly inserted element at that key. │ │ │ │ +The const version of operator[] will only return a reference to an existing │ │ │ │ +element at the given key. If the key is not found, it will throw system_error. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sswwiittcchh__uunnddeerrllyyiinngg__bbuuffffeerr(()) ********** │ │ │ │ -void sswwiittcchh__uunnddeerrllyyiinngg__bbuuffffeerr (char const* buf) noexcept; │ │ │ │ -this buffer MMUUSSTT be identical to the one originally parsed. This operation is │ │ │ │ -only defined on owning root nodes, i.e. the one passed in to decode(). │ │ │ │ +********** ffiinndd__kkeeyy(()) ********** │ │ │ │ +entry* ffiinndd__kkeeyy (string_view key); │ │ │ │ +entry const* ffiinndd__kkeeyy (string_view key) const; │ │ │ │ +These functions requires the _e_n_t_r_y to be a dictionary, if it isn't they will │ │ │ │ +throw system_error. │ │ │ │ +They will look for an element at the given key in the dictionary, if the │ │ │ │ +element cannot be found, they will return nullptr. If an element with the given │ │ │ │ +key is found, the return a pointer to it. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaass__ssoofftt__eerrrroorr(()) ********** │ │ │ │ -bool hhaass__ssoofftt__eerrrroorr (span error) const; │ │ │ │ -returns true if there is a non-fatal error in the bencoding of this node or its │ │ │ │ -children │ │ │ │ +********** ttoo__ssttrriinngg(()) ********** │ │ │ │ +std::string ttoo__ssttrriinngg (bool single_line = false) const; │ │ │ │ +returns a pretty-printed string representation of the bencoded structure, with │ │ │ │ +JSON-style syntax │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** eennuumm ttyyppee__tt ********** │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|none_t |0 |uninitialized or default constructed. This is also used to| │ │ │ │ -|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_i_n_d_i_c_a_t_e_ _t_h_a_t_ _a_ _n_o_d_e_ _w_a_s_ _n_o_t_ _f_o_u_n_d_ _i_n_ _s_o_m_e_ _c_a_s_e_s_._ _ _ _ _ _ _ _ _ | │ │ │ │ -|_d_i_c_t___t_ _ _|_1_ _ _ _ _|_a_ _d_i_c_t_i_o_n_a_r_y_ _n_o_d_e_._ _T_h_e_ _d_i_c_t___f_i_n_d___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ | │ │ │ │ -|_l_i_s_t___t_ _ _|_2_ _ _ _ _|_a_ _l_i_s_t_ _n_o_d_e_._ _T_h_e_ _l_i_s_t___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_t_r_i_n_g___t_|_3_ _ _ _ _|_a_ _s_t_r_i_n_g_ _n_o_d_e_,_ _t_h_e_ _s_t_r_i_n_g___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_n_t___t_ _ _ _|_4_ _ _ _ _|_a_n_ _i_n_t_e_g_e_r_ _n_o_d_e_._ _T_h_e_ _i_n_t___ _f_u_n_c_t_i_o_n_s_ _a_r_e_ _v_a_l_i_d_._ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +********** eennuumm ddaattaa__ttyyppee ********** │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_n_t_r_y_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_i_n_t___t_ _ _ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_t_r_i_n_g___t_ _ _ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_l_i_s_t___t_ _ _ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_d_i_c_t_i_o_n_a_r_y___t_ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_p_r_e_f_o_r_m_a_t_t_e_d___t_|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_n_d_e_f_i_n_e_d___t_ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ pprriinntt__eennttrryy(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ -std::string pprriinntt__eennttrryy (bdecode_node const& e │ │ │ │ - , bool single_line = false, int indent = 0); │ │ │ │ -print the bencoded structure in a human-readable format to a string that's │ │ │ │ -returned. │ │ │ │ +************ bbeennccooddee(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_e_n_c_o_d_e_._h_p_p" │ │ │ │ +template int bbeennccooddee (OutIt out, const entry& e); │ │ │ │ +std::vector bbeennccooddee (entry const& e); │ │ │ │ +The bencode() function has two overloads that serializes a tree structure of │ │ │ │ +_e_n_t_r_y objects into a bencoded, flat, buffer. The _e_n_t_r_y class is the internal │ │ │ │ +representation of the bencoded data. │ │ │ │ +The simplest overload simply takes an _e_n_t_r_y object and returns a vector with │ │ │ │ +the serialized data. │ │ │ │ +The second overload encode it into the OutIt iterator. │ │ │ │ +OutIt is an _O_u_t_p_u_t_I_t_e_r_a_t_o_r. It's a template and usually instantiated as │ │ │ │ +_o_s_t_r_e_a_m___i_t_e_r_a_t_o_r or _b_a_c_k___i_n_s_e_r_t___i_t_e_r_a_t_o_r. This function assumes the value_type │ │ │ │ +of the iterator is a char. In order to encode _e_n_t_r_y e into a buffer, do: │ │ │ │ +std::vector buf; │ │ │ │ +bencode(std::back_inserter(buf), e); │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ bbddeeccooddee(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ -int bbddeeccooddee (char const* start, char const* end, bdecode_node& ret │ │ │ │ - , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 │ │ │ │ - , int token_limit = 2000000); │ │ │ │ -bdecode_node bbddeeccooddee (span buffer │ │ │ │ - , int depth_limit = 100, int token_limit = 2000000); │ │ │ │ -bdecode_node bbddeeccooddee (span buffer │ │ │ │ - , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 │ │ │ │ - , int token_limit = 2000000); │ │ │ │ -This function decodes/parses bdecoded data (for example a .torrent file). The │ │ │ │ -data structure is returned in the ret argument. the buffer to parse is │ │ │ │ -specified by the start of the buffer as well as the end, i.e. one byte past the │ │ │ │ -end. If the buffer fails to parse, the function returns a non-zero value and │ │ │ │ -fills in ec with the error code. The optional argument error_pos, if set to │ │ │ │ -non-nullptr, will be set to the byte offset into the buffer where the parse │ │ │ │ -failure occurred. │ │ │ │ -depth_limit specifies the max number of nested lists or dictionaries are │ │ │ │ -allowed in the data structure. (This affects the stack usage of the function, │ │ │ │ -be careful not to set it too high). │ │ │ │ -token_limit is the max number of tokens allowed to be parsed from the buffer. │ │ │ │ -This is simply a sanity check to not have unbounded memory usage. │ │ │ │ -The resulting bdecode_node is an oowwnniinngg node. That means it will be holding the │ │ │ │ -whole parsed tree. When iterating lists and dictionaries, those bdecode_node │ │ │ │ -objects will simply have references to the root or owning bdecode_node. If the │ │ │ │ -root node is destructed, all other nodes that refer to anything in that tree │ │ │ │ -become invalid. │ │ │ │ -However, the underlying buffer passed in to this function (start, end) must │ │ │ │ -also remain valid while the bdecoded tree is used. The parsed tree produced by │ │ │ │ -this function does not copy any data out of the buffer, but simply produces │ │ │ │ -references back into it. │ │ │ │ +************ ooppeerraattoorr<<<<(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_n_t_r_y_._h_p_p" │ │ │ │ +inline std::ostream& ooppeerraattoorr<<<< (std::ostream& os, const entry& e); │ │ │ │ +prints the bencoded structure to the ostream as a JSON-style structure. │ │ │ │ [_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 │ │ │ │ { │ │ │ │ @@ -13369,54 +13657,54 @@ │ │ │ │ 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 │ │ │ │ specified in the message. This may improve the chances of traversing NATs │ │ │ │ when using uTP. │ │ │ │ ssl_torrent │ │ │ │ Specify the port number for the SSL listen socket in the DHT announce. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ rreeaadd__rreessuummee__ddaattaa(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_r_e_a_d___r_e_s_u_m_e___d_a_t_a_._h_p_p" │ │ │ │ -add_torrent_params rreeaadd__rreessuummee__ddaattaa (bdecode_node const& rd │ │ │ │ - , error_code& ec, int piece_limit = 0x200000); │ │ │ │ add_torrent_params rreeaadd__rreessuummee__ddaattaa (span buffer │ │ │ │ , load_torrent_limits const& cfg = {}); │ │ │ │ +add_torrent_params rreeaadd__rreessuummee__ddaattaa (bdecode_node const& rd │ │ │ │ + , error_code& ec, int piece_limit = 0x200000); │ │ │ │ add_torrent_params rreeaadd__rreessuummee__ddaattaa (span buffer │ │ │ │ , error_code& ec, load_torrent_limits const& cfg = {}); │ │ │ │ add_torrent_params rreeaadd__rreessuummee__ddaattaa (bdecode_node const& rd │ │ │ │ , int piece_limit = 0x200000); │ │ │ │ these functions are used to parse resume data and populate the appropriate │ │ │ │ fields in an _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. This object can then be used to add the │ │ │ │ actual _t_o_r_r_e_n_t___i_n_f_o object to and pass to session::add_torrent() or session:: │ │ │ │ @@ -13453,18 +13741,18 @@ │ │ │ │ std::vector wwrriittee__rreessuummee__ddaattaa__bbuuff (add_torrent_params const& atp); │ │ │ │ entry wwrriittee__rreessuummee__ddaattaa (add_torrent_params const& atp); │ │ │ │ this function turns the resume data in an add_torrent_params object into a │ │ │ │ bencoded structure │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ wwrriittee__ttoorrrreenntt__ffiillee(()) wwrriittee__ttoorrrreenntt__ffiillee__bbuuff(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_w_r_i_t_e___r_e_s_u_m_e___d_a_t_a_._h_p_p" │ │ │ │ -entry wwrriittee__ttoorrrreenntt__ffiillee (add_torrent_params const& atp, write_torrent_flags_t │ │ │ │ -flags); │ │ │ │ std::vector wwrriittee__ttoorrrreenntt__ffiillee__bbuuff (add_torrent_params const& atp │ │ │ │ , write_torrent_flags_t flags); │ │ │ │ +entry wwrriittee__ttoorrrreenntt__ffiillee (add_torrent_params const& atp, write_torrent_flags_t │ │ │ │ +flags); │ │ │ │ entry wwrriittee__ttoorrrreenntt__ffiillee (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: │ │ │ │ * The _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object passed to this function does not contain │ │ │ │ the info dictionary (the ti field) │ │ │ │ * The piece layers are not complete for all files that need them │ │ │ │ The write_torrent_file_buf() overload returns the torrent file in bencoded │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ @@ -1120,2950 +1120,2950 @@ │ │ │ 000045f0: 2c20 6f29 3b0a 0a3c 2f70 7265 3e3c 2f74 , o);..
    relevanc │ │ │ 00004630: 6526 6e62 7370 3b33 3c2f 7464 3e3c 7464 e 3 │ │ │ -00004660: 2e2e 2f73 7263 2f75 745f 6d65 7461 6461 ../src/ut_metada │ │ │ -00004670: 7461 2e63 7070 3a32 3433 3c2f 613e 3c2f ta.cpp:243use the a │ │ │ -00004690: 7578 3a3a 7772 6974 655f 2a20 6675 6e63 ux::write_* func │ │ │ -000046a0: 7469 6f6e 7320 616e 6420 7468 6520 7370 tions and the sp │ │ │ -000046b0: 616e 2068 6572 6520 696e 7374 6561 642c an here instead, │ │ │ -000046c0: 2069 7420 7769 6c6c 2066 6974 2062 6574 it will fit bet │ │ │ -000046d0: 7465 7220 7769 7468 2073 656e 645f 6275 ter with send_bu │ │ │ -000046e0: 6666 6572 2829 3c2f 7464 3e3c 2f74 723e ffer() │ │ │ -000046f0: 3c74 7220 6964 3d22 3922 2073 7479 6c65 use the aux::w │ │ │ -00004740: 7269 7465 5f2a 2066 756e 6374 696f 6e73 rite_* functions │ │ │ -00004750: 2061 6e64 2074 6865 2073 7061 6e20 6865 and the span he │ │ │ -00004760: 7265 2069 6e73 7465 6164 2c20 6974 0a77 re instead, it.w │ │ │ -00004770: 696c 6c20 6669 7420 6265 7474 6572 2077 ill fit better w │ │ │ -00004780: 6974 6820 7365 6e64 5f62 7566 6665 7228 ith send_buffer( │ │ │ -00004790: 293c 2f68 323e 3c68 343e 2e2e 2f73 7263 )

    ../src │ │ │ -000047a0: 2f75 745f 6d65 7461 6461 7461 2e63 7070 /ut_metadata.cpp │ │ │ -000047b0: 3a32 3433 3c2f 6834 3e3c 7072 6520 7374 :243

    ...int metada
    │ │ │ -00004800: 7461 5f70 6965 6365 5f73 697a 6520 3d20  ta_piece_size = 
    │ │ │ -00004810: 303b 0a0a 0909 0969 6620 286d 5f74 6f72  0;.....if (m_tor
    │ │ │ -00004820: 7265 6e74 2e76 616c 6964 5f6d 6574 6164  rent.valid_metad
    │ │ │ -00004830: 6174 6128 2929 0a09 0909 0965 5b22 746f  ata()).....e["to
    │ │ │ -00004840: 7461 6c5f 7369 7a65 225d 203d 206d 5f74  tal_size"] = m_t
    │ │ │ -00004850: 702e 6d65 7461 6461 7461 2829 2e73 697a  p.metadata().siz
    │ │ │ -00004860: 6528 293b 0a0a 0909 0969 6620 2874 7970  e();.....if (typ
    │ │ │ -00004870: 6520 3d3d 206d 7367 5f74 3a3a 7069 6563  e == msg_t::piec
    │ │ │ -00004880: 6529 0a09 0909 7b0a 0909 0909 544f 5252  e)....{.....TORR
    │ │ │ -00004890: 454e 545f 4153 5345 5254 2870 6965 6365  ENT_ASSERT(piece
    │ │ │ -000048a0: 2026 6774 3b3d 2030 2026 616d 703b 2661   >= 0 &&a
    │ │ │ -000048b0: 6d70 3b20 7069 6563 6520 266c 743b 2028  mp; piece < (
    │ │ │ -000048c0: 6d5f 7470 2e6d 6574 6164 6174 6128 292e  m_tp.metadata().
    │ │ │ -000048d0: 7369 7a65 2829 202b 2031 3620 2a20 3130  size() + 16 * 10
    │ │ │ -000048e0: 3234 202d 2031 2920 2f20 2831 3620 2a20  24 - 1) / (16 * 
    │ │ │ -000048f0: 3130 3234 2929 3b0a 0909 0909 544f 5252  1024));.....TORR
    │ │ │ -00004900: 454e 545f 4153 5345 5254 286d 5f70 632e  ENT_ASSERT(m_pc.
    │ │ │ -00004910: 6173 736f 6369 6174 6564 5f74 6f72 7265  associated_torre
    │ │ │ -00004920: 6e74 2829 2e6c 6f63 6b28 292d 2667 743b  nt().lock()->
    │ │ │ -00004930: 7661 6c69 645f 6d65 7461 6461 7461 2829  valid_metadata()
    │ │ │ -00004940: 293b 0a09 0909 0954 4f52 5245 4e54 5f41  );.....TORRENT_A
    │ │ │ -00004950: 5353 4552 5428 6d5f 746f 7272 656e 742e  SSERT(m_torrent.
    │ │ │ -00004960: 7661 6c69 645f 6d65 7461 6461 7461 2829  valid_metadata()
    │ │ │ -00004970: 293b 0a0a 0909 0909 696e 7420 636f 6e73  );......int cons
    │ │ │ -00004980: 7420 6f66 6673 6574 203d 2070 6965 6365  t offset = piece
    │ │ │ -00004990: 202a 2031 3620 2a20 3130 3234 3b0a 0909   * 16 * 1024;...
    │ │ │ -000049a0: 0909 6d65 7461 6461 7461 203d 206d 5f74  ..metadata = m_t
    │ │ │ -000049b0: 702e 6d65 7461 6461 7461 2829 2e64 6174  p.metadata().dat
    │ │ │ -000049c0: 6128 2920 2b20 6f66 6673 6574 3b0a 0909  a() + offset;...
    │ │ │ -000049d0: 0909 6d65 7461 6461 7461 5f70 6965 6365  ..metadata_piece
    │ │ │ -000049e0: 5f73 697a 6520 3d20 7374 643a 3a6d 696e  _size = std::min
    │ │ │ -000049f0: 280a 0909 0909 0969 6e74 286d 5f74 702e  (......int(m_tp.
    │ │ │ -00004a00: 6d65 7461 6461 7461 2829 2e73 697a 6528  metadata().size(
    │ │ │ -00004a10: 2929 202d 206f 6666 7365 742c 2031 3620  )) - offset, 16 
    │ │ │ -00004a20: 2a20 3130 3234 293b 0a09 0909 0954 4f52  * 1024);.....TOR
    │ │ │ -00004a30: 5245 4e54 5f41 5353 4552 5428 6d65 7461  RENT_ASSERT(meta
    │ │ │ -00004a40: 6461 7461 5f70 6965 6365 5f73 697a 6520  data_piece_size 
    │ │ │ -00004a50: 2667 743b 2030 293b 0a09 0909 0954 4f52  > 0);.....TOR
    │ │ │ -00004a60: 5245 4e54 5f41 5353 4552 5428 6f66 6673  RENT_ASSERT(offs
    │ │ │ -00004a70: 6574 2026 6774 3b3d 2030 293b 0a09 0909  et >= 0);....
    │ │ │ -00004a80: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -00004a90: 6f66 6673 6574 202b 206d 6574 6164 6174  offset + metadat
    │ │ │ -00004aa0: 615f 7069 6563 655f 7369 7a65 2026 6c74  a_piece_size <
    │ │ │ -00004ab0: 3b3d 206d 5f74 702e 6d65 7461 6461 7461  ;= m_tp.metadata
    │ │ │ -00004ac0: 2829 2e73 697a 6528 2929 3b0a 0909 097d  ().size());....}
    │ │ │ -00004ad0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00004b00: 0909 0963 6861 7220 6d73 675b 3230 305d ...char msg[200] │ │ │ -00004b10: 3b0a 3c2f 6469 763e 0909 0963 6861 722a ;.
    ...char* │ │ │ -00004b20: 2068 6561 6465 7220 3d20 6d73 673b 0a09 header = msg;.. │ │ │ -00004b30: 0909 6368 6172 2a20 7020 3d20 2661 6d70 ..char* p = & │ │ │ -00004b40: 3b6d 7367 5b36 5d3b 0a09 0909 696e 7420 ;msg[6];....int │ │ │ -00004b50: 636f 6e73 7420 6c65 6e20 3d20 6265 6e63 const len = benc │ │ │ -00004b60: 6f64 6528 702c 2065 293b 0a09 0909 696e ode(p, e);....in │ │ │ -00004b70: 7420 636f 6e73 7420 746f 7461 6c5f 7369 t const total_si │ │ │ -00004b80: 7a65 203d 2032 202b 206c 656e 202b 206d ze = 2 + len + m │ │ │ -00004b90: 6574 6164 6174 615f 7069 6563 655f 7369 etadata_piece_si │ │ │ -00004ba0: 7a65 3b0a 0909 096e 616d 6573 7061 6365 ze;....namespace │ │ │ -00004bb0: 2069 6f20 3d20 6175 783b 0a09 0909 696f io = aux;....io │ │ │ -00004bc0: 3a3a 7772 6974 655f 7569 6e74 3332 2874 ::write_uint32(t │ │ │ -00004bd0: 6f74 616c 5f73 697a 652c 2068 6561 6465 otal_size, heade │ │ │ -00004be0: 7229 3b0a 0909 0969 6f3a 3a77 7269 7465 r);....io::write │ │ │ -00004bf0: 5f75 696e 7438 2861 7578 3a3a 6274 5f70 _uint8(aux::bt_p │ │ │ -00004c00: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a eer_connection:: │ │ │ -00004c10: 6d73 675f 6578 7465 6e64 6564 2c20 6865 msg_extended, he │ │ │ -00004c20: 6164 6572 293b 0a09 0909 696f 3a3a 7772 ader);....io::wr │ │ │ -00004c30: 6974 655f 7569 6e74 3828 6d5f 6d65 7373 ite_uint8(m_mess │ │ │ -00004c40: 6167 655f 696e 6465 782c 2068 6561 6465 age_index, heade │ │ │ -00004c50: 7229 3b0a 0a09 0909 6d5f 7063 2e73 656e r);.....m_pc.sen │ │ │ -00004c60: 645f 6275 6666 6572 287b 6d73 672c 206c d_buffer({msg, l │ │ │ -00004c70: 656e 202b 2036 7d29 3b0a 3c2f 7072 653e en + 6});.
    │ │ │ -00004c80: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00004cb0: 616e 6365 266e 6273 703b 333c 2f74 643e ance 3 │ │ │ -00004cc0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/web_p │ │ │ -00004cf0: 6565 725f 636f 6e6e 6563 7469 6f6e 2e63 eer_connection.c │ │ │ -00004d00: 7070 3a31 3735 3c2f 613e 3c2f 7464 3e3c pp:175< │ │ │ -00004d10: 7464 3e74 6869 7320 7368 6f75 6c64 2062 td>this should b │ │ │ -00004d20: 6520 616e 206f 7074 696f 6e61 6c3c 7069 e an optional, pi │ │ │ -00004d40: 6563 6520 696e 6465 7820 2d31 2073 686f ece index -1 sho │ │ │ -00004d50: 756c 6420 6e6f 7420 6265 2061 6c6c 6f77 uld not be allow │ │ │ -00004d60: 6564 3c2f 7464 3e3c 2f74 723e 3c74 7220 ed

    t │ │ │ -00004db0: 6869 7320 7368 6f75 6c64 2062 6520 616e his should be an │ │ │ -00004dc0: 206f 7074 696f 6e61 6c3c 7069 6563 655f optional, piece │ │ │ -00004de0: 696e 6465 7820 2d31 2073 686f 756c 640a index -1 should. │ │ │ -00004df0: 6e6f 7420 6265 2061 6c6c 6f77 6564 3c2f not be allowed

    ../src/we │ │ │ -00004e10: 625f 7065 6572 5f63 6f6e 6e65 6374 696f b_peer_connectio │ │ │ -00004e20: 6e2e 6370 703a 3137 353c 2f68 343e 3c70 n.cpp:175

    ...if (m │ │ │ -00004e70: 5f77 6562 2d26 6774 3b68 6176 655f 6669 _web->have_fi │ │ │ -00004e80: 6c65 732e 6765 745f 6269 7428 6929 207c les.get_bit(i) | │ │ │ -00004e90: 7c20 6673 2e70 6164 5f66 696c 655f 6174 | fs.pad_file_at │ │ │ -00004ea0: 2869 2929 2063 6f6e 7469 6e75 653b 0a0a (i)) continue;.. │ │ │ -00004eb0: 0909 0966 6f72 2028 7069 6563 655f 696e ...for (piece_in │ │ │ -00004ec0: 6465 785f 7420 636f 6e73 7420 6b20 3a20 dex_t const k : │ │ │ -00004ed0: 6175 783a 3a66 696c 655f 7069 6563 655f aux::file_piece_ │ │ │ -00004ee0: 7261 6e67 655f 696e 636c 7573 6976 6528 range_inclusive( │ │ │ -00004ef0: 6673 2c20 6929 290a 0909 0909 6861 7665 fs, i)).....have │ │ │ -00004f00: 2e63 6c65 6172 5f62 6974 286b 293b 0a09 .clear_bit(k);.. │ │ │ -00004f10: 097d 0a09 0974 2d26 6774 3b73 6574 5f73 .}...t->set_s │ │ │ -00004f20: 6565 6428 7065 6572 5f69 6e66 6f5f 7374 eed(peer_info_st │ │ │ -00004f30: 7275 6374 2829 2c20 6661 6c73 6529 3b0a ruct(), false);. │ │ │ -00004f40: 0909 6966 2028 6861 7665 2e6e 6f6e 655f ..if (have.none_ │ │ │ -00004f50: 7365 7428 2929 0a09 097b 0a09 0909 696e set())...{....in │ │ │ -00004f60: 636f 6d69 6e67 5f68 6176 655f 6e6f 6e65 coming_have_none │ │ │ -00004f70: 2829 3b0a 0909 096d 5f77 6562 2d26 6774 ();....m_web-> │ │ │ -00004f80: 3b69 6e74 6572 6573 7469 6e67 203d 2066 ;interesting = f │ │ │ -00004f90: 616c 7365 3b0a 2369 666e 6465 6620 544f alse;.#ifndef TO │ │ │ -00004fa0: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ -00004fb0: 4747 494e 470a 0909 0970 6565 725f 6c6f GGING....peer_lo │ │ │ -00004fc0: 6728 7065 6572 5f6c 6f67 5f61 6c65 7274 g(peer_log_alert │ │ │ -00004fd0: 3a3a 696e 666f 2c20 7065 6572 5f6c 6f67 ::info, peer_log │ │ │ -00004fe0: 5f61 6c65 7274 3a3a 7765 625f 7365 6564 _alert::web_seed │ │ │ -00004ff0: 2c20 2268 6176 6520 6e6f 2070 6965 6365 , "have no piece │ │ │ -00005000: 732c 206e 6f74 2069 6e74 6572 6573 7469 s, not interesti │ │ │ -00005010: 6e67 2e20 2573 222c 206d 5f75 726c 2e63 ng. %s", m_url.c │ │ │ -00005020: 5f73 7472 2829 293b 0a23 656e 6469 660a _str());.#endif. │ │ │ -00005030: 0909 7d0a 0909 656c 7365 0a09 097b 0a09 ..}...else...{.. │ │ │ -00005040: 0909 696e 636f 6d69 6e67 5f62 6974 6669 ..incoming_bitfi │ │ │ -00005050: 656c 6428 6861 7665 293b 0a09 097d 0a09 eld(have);...}.. │ │ │ -00005060: 7d0a 0a3c 6469 7620 7374 796c 653d 2262 }..

    .if (m_web-> │ │ │ -000050a0: 7265 7374 6172 745f 7265 7175 6573 742e restart_request. │ │ │ -000050b0: 7069 6563 6520 213d 2070 6965 6365 5f69 piece != piece_i │ │ │ -000050c0: 6e64 6578 5f74 282d 3129 290a 3c2f 6469 ndex_t(-1))..{...// increa │ │ │ -000050e0: 7365 2074 6865 2063 6861 6e63 6573 206f se the chances o │ │ │ -000050f0: 6620 7265 7175 6573 7469 6e67 2074 6865 f requesting the │ │ │ -00005100: 2062 6c6f 636b 0a09 092f 2f20 7765 2068 block...// we h │ │ │ -00005110: 6176 6520 7061 7274 6961 6c20 6461 7461 ave partial data │ │ │ -00005120: 2066 6f72 2061 6c72 6561 6479 2c20 746f for already, to │ │ │ -00005130: 2066 696e 6973 6820 6974 0a09 0969 6e63 finish it...inc │ │ │ -00005140: 6f6d 696e 675f 7375 6767 6573 7428 6d5f oming_suggest(m_ │ │ │ -00005150: 7765 622d 2667 743b 7265 7374 6172 745f web->restart_ │ │ │ -00005160: 7265 7175 6573 742e 7069 6563 6529 3b0a request.piece);. │ │ │ -00005170: 097d 0a09 7765 625f 636f 6e6e 6563 7469 .}..web_connecti │ │ │ -00005180: 6f6e 5f62 6173 653a 3a6f 6e5f 636f 6e6e on_base::on_conn │ │ │ -00005190: 6563 7465 6428 293b 0a7d 0a0a 766f 6964 ected();.}..void │ │ │ -000051a0: 2077 6562 5f70 6565 725f 636f 6e6e 6563 web_peer_connec │ │ │ -000051b0: 7469 6f6e 3a3a 6469 7363 6f6e 6e65 6374 tion::disconnect │ │ │ -000051c0: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ -000051d0: 7426 616d 703b 2065 630a 092c 206f 7065 t& ec.., ope │ │ │ -000051e0: 7261 7469 6f6e 5f74 206f 702c 2064 6973 ration_t op, dis │ │ │ -000051f0: 636f 6e6e 6563 745f 7365 7665 7269 7479 connect_severity │ │ │ -00005200: 5f74 2063 6f6e 7374 2065 7272 6f72 290a _t const error). │ │ │ -00005210: 7b0a 0969 6620 2869 735f 6469 7363 6f6e {..if (is_discon │ │ │ -00005220: 6e65 6374 696e 6728 2929 2072 6574 7572 necting()) retur │ │ │ -00005230: 6e3b 0a0a 0969 6620 286f 7020 3d3d 206f n;...if (op == o │ │ │ -00005240: 7065 7261 7469 6f6e 5f74 3a3a 736f 636b peration_t::sock │ │ │ -00005250: 5f77 7269 7465 2026 616d 703b 2661 6d70 _write && │ │ │ -00005260: 3b20 6563 203d 3d20 626f 6f73 743a 3a73 ; ec == boost::s │ │ │ -00005270: 7973 7465 6d3a 3a65 7272 633a 3a62 726f ystem::errc::bro │ │ │ -00005280: 6b65 6e5f 7069 7065 290a 097b 0a23 6966 ken_pipe)..{.#if │ │ │ -00005290: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -000052a0: 4142 4c45 5f4c 4f47 4749 4e47 0a09 092f ABLE_LOGGING.../ │ │ │ -000052b0: 2f20 6120 7772 6974 6520 6f70 6572 6174 / a write operat │ │ │ -000052c0: 696f 6e20 6661 696c 6564 2077 6974 6820 ion failed with │ │ │ -000052d0: 6272 6f6b 656e 2d70 6970 652e 2054 6869 broken-pipe. Thi │ │ │ -000052e0: 7320 7479 7069 6361 6c6c 7920 6861 7070 s typically happ │ │ │ -000052f0: 656e 730a 0909 2f2f 2077 6974 6820 4854 ens...// with HT │ │ │ -00005300: 5450 2031 2e30 2073 6572 7665 7273 2074 TP 1.0 servers t │ │ │ -00005310: 6861 7420 636c 6f73 6520 7468 6569 7220 hat close their │ │ │ -00005320: 696e 636f 6d69 6e67 2063 6861 6e6e 656c incoming channel │ │ │ -00005330: 206f 6620 7468 6520 5443 500a 0909 2f2f of the TCP...// │ │ │ -00005340: 2073 7472 6561 6d20 7768 656e 6576 6572 stream whenever │ │ │ -00005350: 2074 6865 7927 7265 2064 6f6e 6520 7265 they're done re │ │ │ -00005360: 6164 696e 6720 6f6e 6520 6675 6c6c 2072 ading one full r │ │ │ -00005370: 6571 7565 7374 2e20 496e 7374 6561 6420 equest. Instead │ │ │ -00005380: 6f66 0a09 092f 2f20 7573 2062 6169 6c69 of...// us baili │ │ │ -00005390: 6e67 206f 7574 2061 6e64 2066 6169 6c69 ng out and faili │ │ │ -000053a0: 6e67 2074 6865 2065 6e74 6972 6520 7265 ng the entire re │ │ │ -000053b0: 7175 6573 7420 6a75 7374 2062 6563 6175 quest just becau │ │ │ -000053c0: 7365 206f 7572 0a09 092f 2f20 7772 6974 se our...// writ │ │ │ -000053d0: 652d 656e 6420 7761 7320 636c 6f73 6564 e-end was closed │ │ │ -000053e0: 2c20 6967 6e6f 7265 2069 7420 616e 6420 , ignore it and │ │ │ -000053f0: 6b65 6570 2072 6561 6469 6e67 2075 6e74 keep reading unt │ │ │ -00005400: 696c 2074 6865 2072 6561 642d 656e 640a il the read-end. │ │ │ -00005410: 0909 2f2f 2061 6c73 6f20 6973 2063 6c6f ..// also is clo │ │ │ -00005420: 7365 642e 0a09 0970 6565 725f 6c6f 6728 sed....peer_log( │ │ │ -00005430: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a peer_log_alert:: │ │ │ -00005440: 696e 666f 2c20 7065 6572 5f6c 6f67 5f61 info, peer_log_a │ │ │ -00005450: 6c65 7274 3a3a 7765 625f 7365 6564 2c20 lert::web_seed, │ │ │ -00005460: 2243 4c4f 5345 4422 293b 0a23 656e 6469 "CLOSED");.#endi │ │ │ -00005470: 660a 0a09 092f 2f20 7072 6576 656e 7420 f....// prevent │ │ │ -00005480: 7468 6520 7065 6572 2066 726f 6d20 7472 the peer from tr │ │ │ -00005490: 7969 6e67 2074 6f20 7365 6e64 2061 6e79 ying to send any │ │ │ -000054a0: 7468 696e 6720 6d6f 7265 0a09 096d 5f73 thing more...m_s │ │ │ -000054b0: 656e 645f 6275 6666 6572 2e63 6c65 6172 end_buffer.clear │ │ │ -000054c0: 2829 3b0a 0a09 092f 2f20 7768 656e 2074 ();....// when t │ │ │ -000054d0: 6865 2077 6562 2073 6572 7665 7220 636c he web server cl │ │ │ -000054e0: 6f73 6564 206f 7572 2077 7269 7465 2d65 osed our write-e │ │ │ -000054f0: 6e64 206f 6620 7468 6520 736f 636b 6574 nd of the socket │ │ │ -00005500: 2028 692e 652e 2069 7473 0a09 092f 2f20 (i.e. its...// │ │ │ -00005510: 7265 6164 2d65 6e64 292c 2069 6620 6974 read-end), if it │ │ │ -00005520: 2773 2061 6e20 4854 5450 2031 2e30 2073 's an HTTP 1.0 s │ │ │ -00005530: 6572 7665 722e 2077 6520 7769 6c6c 2073 erver. we will s │ │ │ -00005540: 746f 7020 7365 6e64 696e 6720 6d6f 7265 top sending more │ │ │ -00005550: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ -00005590: 3b33 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;3../sr │ │ │ -000055c0: 632f 7765 625f 7065 6572 5f63 6f6e 6e65 c/web_peer_conne │ │ │ -000055d0: 6374 696f 6e2e 6370 703a 3339 373c 2f61 ction.cpp:397do we │ │ │ -000055f0: 7265 616c 6c79 206e 6565 6420 6120 7370 really need a sp │ │ │ -00005600: 6563 6961 6c20 6361 7365 2068 6572 653f ecial case here? │ │ │ -00005610: 2077 6f75 6c64 6e27 7420 7468 6520 6d75 wouldn't the mu │ │ │ -00005620: 6c74 692d 6669 6c65 2063 6173 6520 6861 lti-file case ha │ │ │ -00005630: 6e64 6c65 2073 696e 676c 6520 6669 6c65 ndle single file │ │ │ -00005640: 2074 6f72 7265 6e74 7320 636f 7272 6563 torrents correc │ │ │ -00005650: 746c 7920 746f 6f3f 3c2f 7464 3e3c 2f74 tly too?

    do we reall │ │ │ -000056b0: 7920 6e65 6564 2061 2073 7065 6369 616c y need a special │ │ │ -000056c0: 2063 6173 6520 6865 7265 3f20 776f 756c case here? woul │ │ │ -000056d0: 646e 2774 2074 6865 206d 756c 7469 2d66 dn't the multi-f │ │ │ -000056e0: 696c 650a 6361 7365 2068 616e 646c 6520 ile.case handle │ │ │ -000056f0: 7369 6e67 6c65 2066 696c 6520 746f 7272 single file torr │ │ │ -00005700: 656e 7473 2063 6f72 7265 6374 6c79 2074 ents correctly t │ │ │ -00005710: 6f6f 3f3c 2f68 323e 3c68 343e 2e2e 2f73 oo?

    ../s │ │ │ -00005720: 7263 2f77 6562 5f70 6565 725f 636f 6e6e rc/web_peer_conn │ │ │ -00005730: 6563 7469 6f6e 2e63 7070 3a33 3937 3c2f ection.cpp:397
    ..}
    │ │ │ -00005780: 0a09 7d0a 0a23 6966 6e64 6566 2054 4f52  ..}..#ifndef TOR
    │ │ │ -00005790: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ -000057a0: 4749 4e47 0a09 7065 6572 5f6c 6f67 2870  GING..peer_log(p
    │ │ │ -000057b0: 6565 725f 6c6f 675f 616c 6572 743a 3a6f  eer_log_alert::o
    │ │ │ -000057c0: 7574 676f 696e 675f 6d65 7373 6167 652c  utgoing_message,
    │ │ │ -000057d0: 2070 6565 725f 6c6f 675f 616c 6572 743a   peer_log_alert:
    │ │ │ -000057e0: 3a72 6571 7565 7374 2c20 2228 7069 6563  :request, "(piec
    │ │ │ -000057f0: 653a 2025 6420 7374 6172 743a 2025 6429  e: %d start: %d)
    │ │ │ -00005800: 202d 2028 7069 6563 653a 2025 6420 656e   - (piece: %d en
    │ │ │ -00005810: 643a 2025 6429 220a 0909 2c20 7374 6174  d: %d)"..., stat
    │ │ │ -00005820: 6963 5f63 6173 7426 6c74 3b69 6e74 2667  ic_cast<int&g
    │ │ │ -00005830: 743b 2872 2e70 6965 6365 292c 2072 2e73  t;(r.piece), r.s
    │ │ │ -00005840: 7461 7274 0a09 092c 2073 7461 7469 635f  tart..., static_
    │ │ │ -00005850: 6361 7374 266c 743b 696e 7426 6774 3b28  cast<int>(
    │ │ │ -00005860: 7072 2e70 6965 6365 292c 2070 722e 7374  pr.piece), pr.st
    │ │ │ -00005870: 6172 7420 2b20 7072 2e6c 656e 6774 6829  art + pr.length)
    │ │ │ -00005880: 3b0a 2365 6e64 6966 0a0a 0962 6f6f 6c20  ;.#endif...bool 
    │ │ │ -00005890: 636f 6e73 7420 7369 6e67 6c65 5f66 696c  const single_fil
    │ │ │ -000058a0: 655f 7265 7175 6573 7420 3d20 742d 2667  e_request = t-&g
    │ │ │ -000058b0: 743b 746f 7272 656e 745f 6669 6c65 2829  t;torrent_file()
    │ │ │ -000058c0: 2e6e 756d 5f66 696c 6573 2829 203d 3d20  .num_files() == 
    │ │ │ -000058d0: 313b 0a09 696e 7420 636f 6e73 7420 7072  1;..int const pr
    │ │ │ -000058e0: 6f78 795f 7479 7065 203d 206d 5f73 6574  oxy_type = m_set
    │ │ │ -000058f0: 7469 6e67 732e 6765 745f 696e 7428 7365  tings.get_int(se
    │ │ │ -00005900: 7474 696e 6773 5f70 6163 6b3a 3a70 726f  ttings_pack::pro
    │ │ │ -00005910: 7879 5f74 7970 6529 3b0a 0962 6f6f 6c20  xy_type);..bool 
    │ │ │ -00005920: 636f 6e73 7420 7573 696e 675f 7072 6f78  const using_prox
    │ │ │ -00005930: 7920 3d20 2870 726f 7879 5f74 7970 6520  y = (proxy_type 
    │ │ │ -00005940: 3d3d 2073 6574 7469 6e67 735f 7061 636b  == settings_pack
    │ │ │ -00005950: 3a3a 6874 7470 0a09 097c 7c20 7072 6f78  ::http...|| prox
    │ │ │ -00005960: 795f 7479 7065 203d 3d20 7365 7474 696e  y_type == settin
    │ │ │ -00005970: 6773 5f70 6163 6b3a 3a68 7474 705f 7077  gs_pack::http_pw
    │ │ │ -00005980: 2920 2661 6d70 3b26 616d 703b 2021 6d5f  ) && !m_
    │ │ │ -00005990: 7373 6c3b 0a0a 092f 2f20 7468 6520 6e75  ssl;...// the nu
    │ │ │ -000059a0: 6d62 6572 206f 6620 7061 6420 6669 6c65  mber of pad file
    │ │ │ -000059b0: 7320 7468 6174 2068 6176 6520 6265 656e  s that have been
    │ │ │ -000059c0: 2022 7265 7175 6573 7465 6422 2e20 496e   "requested". In
    │ │ │ -000059d0: 2063 6173 6520 7765 205f 6f6e 6c79 5f0a   case we _only_.
    │ │ │ -000059e0: 092f 2f20 7265 7175 6573 7420 7061 6466  .// request padf
    │ │ │ -000059f0: 696c 6573 2c20 7765 2063 616e 2774 2072  iles, we can't r
    │ │ │ -00005a00: 656c 7920 6f6e 2068 616e 646c 696e 6720  ely on handling 
    │ │ │ -00005a10: 7468 656d 2069 6e20 7468 6520 6f6e 5f72  them in the on_r
    │ │ │ -00005a20: 6563 6569 7665 2829 0a09 2f2f 2063 616c  eceive()..// cal
    │ │ │ -00005a30: 6c62 6163 6b20 2862 6563 6175 7365 2077  lback (because w
    │ │ │ -00005a40: 6520 776f 6e27 7420 7265 6365 6976 6520  e won't receive 
    │ │ │ -00005a50: 616e 7974 6869 6e67 292c 2069 6e73 7465  anything), inste
    │ │ │ -00005a60: 6164 2077 6520 6861 7665 2074 6f20 706f  ad we have to po
    │ │ │ -00005a70: 7374 2061 0a09 2f2f 2070 7265 7465 6e64  st a..// pretend
    │ │ │ -00005a80: 2072 6561 6420 6361 6c6c 6261 636b 2077   read callback w
    │ │ │ -00005a90: 6865 7265 2077 6520 6361 6e20 6465 6c69  here we can deli
    │ │ │ -00005aa0: 7665 7220 7468 6520 7a65 726f 6573 2066  ver the zeroes f
    │ │ │ -00005ab0: 6f72 2074 6865 2070 6172 7466 696c 650a  or the partfile.
    │ │ │ -00005ac0: 0969 6e74 206e 756d 5f70 6164 5f66 696c  .int num_pad_fil
    │ │ │ -00005ad0: 6573 203d 2030 3b0a 0a3c 6469 7620 7374  es = 0;..
    .if (sing │ │ │ -00005b10: 6c65 5f66 696c 655f 7265 7175 6573 7429 le_file_request) │ │ │ -00005b20: 0a3c 2f64 6976 3e09 7b0a 0909 6669 6c65 .
    .{...file │ │ │ -00005b30: 5f72 6571 7565 7374 5f74 2066 696c 655f _request_t file_ │ │ │ -00005b40: 7265 713b 0a09 0966 696c 655f 7265 712e req;...file_req. │ │ │ -00005b50: 6669 6c65 5f69 6e64 6578 203d 2066 696c file_index = fil │ │ │ -00005b60: 655f 696e 6465 785f 7428 3029 3b0a 0909 e_index_t(0);... │ │ │ -00005b70: 6669 6c65 5f72 6571 2e73 7461 7274 203d file_req.start = │ │ │ -00005b80: 2073 7464 3a3a 696e 7436 345f 7428 7374 std::int64_t(st │ │ │ -00005b90: 6174 6963 5f63 6173 7426 6c74 3b69 6e74 atic_cast<int │ │ │ -00005ba0: 2667 743b 2872 6571 2e70 6965 6365 2929 >(req.piece)) │ │ │ -00005bb0: 202a 2069 6e66 6f2e 7069 6563 655f 6c65 * info.piece_le │ │ │ -00005bc0: 6e67 7468 2829 0a09 0909 2b20 7265 712e ngth()....+ req. │ │ │ -00005bd0: 7374 6172 743b 0a09 0966 696c 655f 7265 start;...file_re │ │ │ -00005be0: 712e 6c65 6e67 7468 203d 2072 6571 2e6c q.length = req.l │ │ │ -00005bf0: 656e 6774 683b 0a0a 0909 7265 7175 6573 ength;....reques │ │ │ -00005c00: 7420 2b3d 2022 4745 5420 223b 0a09 092f t += "GET ";.../ │ │ │ -00005c10: 2f20 646f 206e 6f74 2065 6e63 6f64 6520 / do not encode │ │ │ -00005c20: 7369 6e67 6c65 2066 696c 6520 7061 7468 single file path │ │ │ -00005c30: 732c 2074 6865 7920 6172 650a 0909 2f2f s, they are...// │ │ │ -00005c40: 2061 7373 756d 6564 2074 6f20 6265 2065 assumed to be e │ │ │ -00005c50: 6e63 6f64 6564 2069 6e20 7468 6520 746f ncoded in the to │ │ │ -00005c60: 7272 656e 7420 6669 6c65 0a09 0972 6571 rrent file...req │ │ │ -00005c70: 7565 7374 202b 3d20 7573 696e 675f 7072 uest += using_pr │ │ │ -00005c80: 6f78 7920 3f20 6d5f 7572 6c20 3a20 6d5f oxy ? m_url : m_ │ │ │ -00005c90: 7061 7468 3b0a 0909 7265 7175 6573 7420 path;...request │ │ │ -00005ca0: 2b3d 2022 2048 5454 502f 312e 315c 725c += " HTTP/1.1\r\ │ │ │ -00005cb0: 6e22 3b0a 0909 6164 645f 6865 6164 6572 n";...add_header │ │ │ -00005cc0: 7328 7265 7175 6573 742c 206d 5f73 6574 s(request, m_set │ │ │ -00005cd0: 7469 6e67 732c 2075 7369 6e67 5f70 726f tings, using_pro │ │ │ -00005ce0: 7879 293b 0a09 0972 6571 7565 7374 202b xy);...request + │ │ │ -00005cf0: 3d20 225c 725c 6e52 616e 6765 3a20 6279 = "\r\nRange: by │ │ │ -00005d00: 7465 733d 223b 0a09 0972 6571 7565 7374 tes=";...request │ │ │ -00005d10: 202b 3d20 746f 5f73 7472 696e 6728 6669 += to_string(fi │ │ │ -00005d20: 6c65 5f72 6571 2e73 7461 7274 292e 6461 le_req.start).da │ │ │ -00005d30: 7461 2829 3b0a 0909 7265 7175 6573 7420 ta();...request │ │ │ -00005d40: 2b3d 2022 2d22 3b0a 0909 7265 7175 6573 += "-";...reques │ │ │ -00005d50: 7420 2b3d 2074 6f5f 7374 7269 6e67 2866 t += to_string(f │ │ │ -00005d60: 696c 655f 7265 712e 7374 6172 7420 2b20 ile_req.start + │ │ │ -00005d70: 6669 6c65 5f72 6571 2e6c 656e 6774 6820 file_req.length │ │ │ -00005d80: 2d20 3129 2e64 6174 6128 293b 0a09 0972 - 1).data();...r │ │ │ -00005d90: 6571 7565 7374 202b 3d20 225c 725c 6e5c equest += "\r\n\ │ │ │ -00005da0: 725c 6e22 3b0a 0909 6d5f 6669 7273 745f r\n";...m_first_ │ │ │ -00005db0: 7265 7175 6573 7420 3d20 6661 6c73 653b request = false; │ │ │ -00005dc0: 0a0a 0909 6d5f 6669 6c65 5f72 6571 7565 ....m_file_reque │ │ │ -00005dd0: 7374 732e 7075 7368 5f62 6163 6b28 6669 sts.push_back(fi │ │ │ -00005de0: 6c65 5f72 6571 293b 0a09 7d0a 0965 6c73 le_req);..}..els │ │ │ -00005df0: 650a 097b 0a09 092f 2f20 666f 7220 7632 e..{...// for v2 │ │ │ -00005e00: 2074 6f72 7265 6e74 732c 2072 6571 2e6c torrents, req.l │ │ │ -00005e10: 656e 6774 6820 6973 2074 6865 2073 756d ength is the sum │ │ │ -00005e20: 206f 6620 7265 616c 2d64 6174 6120 626c of real-data bl │ │ │ -00005e30: 6f63 6b20 7369 7a65 7320 7768 6963 680a ock sizes which. │ │ │ -00005e40: 0909 2f2f 2065 7863 6c75 6465 7320 7061 ..// excludes pa │ │ │ -00005e50: 6420 6279 7465 732e 206d 6170 5f62 6c6f d bytes. map_blo │ │ │ -00005e60: 636b 2072 6571 7569 7265 7320 6120 746f ck requires a to │ │ │ -00005e70: 7272 656e 742d 636f 6e74 6967 756f 7573 rrent-contiguous │ │ │ -00005e80: 2062 7974 6520 7370 616e 2c0a 0909 2f2f byte span,...// │ │ │ -00005e90: 2073 6f20 636f 6d70 7574 6520 7468 6520 so compute the │ │ │ -00005ea0: 6163 7475 616c 2073 7061 6e20 6672 6f6d actual span from │ │ │ -00005eb0: 2072 6571 2073 7461 7274 2074 6f20 656e req start to en │ │ │ -00005ec0: 6420 6f66 206c 6173 7420 626c 6f63 6b20 d of last block │ │ │ -00005ed0: 2870 7229 2e0a 0909 696e 7420 636f 6e73 (pr)....int cons │ │ │ -00005ee0: 7420 6d61 705f 6c65 6e67 7468 203d 2069 t map_length = i │ │ │ -00005ef0: 6e66 6f2e 7632 2829 0a09 0909 3f20 696e nfo.v2()....? in │ │ │ -00005f00: 7428 7374 6174 6963 5f63 6173 7426 6c74 t(static_cast< │ │ │ -00005f10: 3b69 6e74 2667 743b 2870 722e 7069 6563 ;int>(pr.piec │ │ │ -00005f20: 6529 202a 2073 7464 3a3a 696e 7436 345f e) * std::int64_ │ │ │ -00005f30: 7428 7069 6563 655f 7369 7a65 290a 0909 t(piece_size)... │ │ │ -00005f40: 0909 2b20 7072 2e73 7461 7274 202b 2070 ..+ pr.start + p │ │ │ -00005f50: 722e 6c65 6e67 7468 0a3c 2f70 7265 3e3c r.length.
    < │ │ │ -00005f60: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00005f90: 6e63 6526 6e62 7370 3b33 3c2f 7464 3e3c nce 3< │ │ │ -00005fa0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/web_pe │ │ │ -00005fd0: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ -00005fe0: 703a 3439 313c 2f61 3e3c 2f74 643e 3c74 p:491file_index_t s │ │ │ -00006000: 686f 756c 6420 6e6f 7420 616c 6c6f 7720 hould not allow │ │ │ -00006010: 6e65 6761 7469 7665 2076 616c 7565 733c negative values< │ │ │ -00006020: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    file │ │ │ -00006070: 5f69 6e64 6578 5f74 2073 686f 756c 6420 _index_t should │ │ │ -00006080: 6e6f 7420 616c 6c6f 7720 6e65 6761 7469 not allow negati │ │ │ -00006090: 7665 2076 616c 7565 733c 2f68 323e 3c68 ve values

    ../src/web_pee │ │ │ -000060b0: 725f 636f 6e6e 6563 7469 6f6e 2e63 7070 r_connection.cpp │ │ │ -000060c0: 3a34 3931 3c2f 6834 3e3c 7072 6520 7374 :491

    .....// with 
    │ │ │ -00006110: 7468 6520 636f 7272 6563 7420 736c 6173  the correct slas
    │ │ │ -00006120: 6865 732e 2044 6f6e 2774 2065 6e63 6f64  hes. Don't encod
    │ │ │ -00006130: 6520 6974 2061 6761 696e 0a09 0909 0909  e it again......
    │ │ │ -00006140: 7265 7175 6573 7420 2b3d 206d 5f70 6174  request += m_pat
    │ │ │ -00006150: 683b 0a09 0909 097d 0a0a 0909 0909 7265  h;.....}......re
    │ │ │ -00006160: 7175 6573 7420 2b3d 2065 7363 6170 655f  quest += escape_
    │ │ │ -00006170: 6669 6c65 5f70 6174 6828 696e 666f 2e6c  file_path(info.l
    │ │ │ -00006180: 6179 6f75 7428 292c 2066 2e66 696c 655f  ayout(), f.file_
    │ │ │ -00006190: 696e 6465 7829 3b0a 0909 097d 0a09 0909  index);....}....
    │ │ │ -000061a0: 7265 7175 6573 7420 2b3d 2022 2048 5454  request += " HTT
    │ │ │ -000061b0: 502f 312e 315c 725c 6e22 3b0a 0909 0961  P/1.1\r\n";....a
    │ │ │ -000061c0: 6464 5f68 6561 6465 7273 2872 6571 7565  dd_headers(reque
    │ │ │ -000061d0: 7374 2c20 6d5f 7365 7474 696e 6773 2c20  st, m_settings, 
    │ │ │ -000061e0: 7573 696e 675f 7072 6f78 7929 3b0a 0909  using_proxy);...
    │ │ │ -000061f0: 0972 6571 7565 7374 202b 3d20 225c 725c  .request += "\r\
    │ │ │ -00006200: 6e52 616e 6765 3a20 6279 7465 733d 223b  nRange: bytes=";
    │ │ │ -00006210: 0a09 0909 7265 7175 6573 7420 2b3d 2074  ....request += t
    │ │ │ -00006220: 6f5f 7374 7269 6e67 2866 2e6f 6666 7365  o_string(f.offse
    │ │ │ -00006230: 7429 2e64 6174 6128 293b 0a09 0909 7265  t).data();....re
    │ │ │ -00006240: 7175 6573 7420 2b3d 2022 2d22 3b0a 0909  quest += "-";...
    │ │ │ -00006250: 0972 6571 7565 7374 202b 3d20 746f 5f73  .request += to_s
    │ │ │ -00006260: 7472 696e 6728 662e 6f66 6673 6574 202b  tring(f.offset +
    │ │ │ -00006270: 2066 2e73 697a 6520 2d20 3129 2e64 6174   f.size - 1).dat
    │ │ │ -00006280: 6128 293b 0a09 0909 7265 7175 6573 7420  a();....request 
    │ │ │ -00006290: 2b3d 2022 5c72 5c6e 5c72 5c6e 223b 0a09  += "\r\n\r\n";..
    │ │ │ -000062a0: 0909 6d5f 6669 7273 745f 7265 7175 6573  ..m_first_reques
    │ │ │ -000062b0: 7420 3d20 6661 6c73 653b 0a0a 2369 6620  t = false;..#if 
    │ │ │ -000062c0: 300a 0909 0973 7464 3a3a 6365 7272 2026  0....std::cerr &
    │ │ │ -000062d0: 6c74 3b26 6c74 3b20 7468 6973 2026 6c74  lt;< this <
    │ │ │ -000062e0: 3b26 6c74 3b20 2220 5345 4e44 2d52 4551  ;< " SEND-REQ
    │ │ │ -000062f0: 5545 5354 3a20 663a 2022 2026 6c74 3b26  UEST: f: " <&
    │ │ │ -00006300: 6c74 3b20 662e 6669 6c65 5f69 6e64 6578  lt; f.file_index
    │ │ │ -00006310: 0a09 0909 0926 6c74 3b26 6c74 3b20 2220  .....<< " 
    │ │ │ -00006320: 733a 2022 2026 6c74 3b26 6c74 3b20 662e  s: " << f.
    │ │ │ -00006330: 6f66 6673 6574 0a09 0909 0926 6c74 3b26  offset.....<&
    │ │ │ -00006340: 6c74 3b20 2220 653a 2022 2026 6c74 3b26  lt; " e: " <&
    │ │ │ -00006350: 6c74 3b20 2866 2e6f 6666 7365 7420 2b20  lt; (f.offset + 
    │ │ │ -00006360: 662e 7369 7a65 202d 2031 2920 266c 743b  f.size - 1) <
    │ │ │ -00006370: 266c 743b 2073 7464 3a3a 656e 646c 3b0a  < std::endl;.
    │ │ │ -00006380: 2365 6e64 6966 0a3c 6469 7620 7374 796c  #endif.
    ...TORRENT_ │ │ │ -000063c0: 4153 5345 5254 2866 2e66 696c 655f 696e ASSERT(f.file_in │ │ │ -000063d0: 6465 7820 2667 743b 3d20 6669 6c65 5f69 dex >= file_i │ │ │ -000063e0: 6e64 6578 5f74 2830 2929 3b0a 3c2f 6469 ndex_t(0));.....m_file_req │ │ │ -00006400: 7565 7374 732e 7075 7368 5f62 6163 6b28 uests.push_back( │ │ │ -00006410: 6669 6c65 5f72 6571 293b 0a09 097d 0a09 file_req);...}.. │ │ │ -00006420: 7d0a 0a09 6966 2028 6e75 6d5f 7061 645f }...if (num_pad_ │ │ │ -00006430: 6669 6c65 7320 3d3d 2069 6e74 286d 5f66 files == int(m_f │ │ │ -00006440: 696c 655f 7265 7175 6573 7473 2e73 697a ile_requests.siz │ │ │ -00006450: 6528 2929 290a 097b 0a09 0970 6f73 7428 e()))..{...post( │ │ │ -00006460: 6765 745f 636f 6e74 6578 7428 292c 2073 get_context(), s │ │ │ -00006470: 7464 3a3a 6269 6e64 280a 0909 0926 616d td::bind(....&am │ │ │ -00006480: 703b 7765 625f 7065 6572 5f63 6f6e 6e65 p;web_peer_conne │ │ │ -00006490: 6374 696f 6e3a 3a6f 6e5f 7265 6365 6976 ction::on_receiv │ │ │ -000064a0: 655f 7061 6466 696c 652c 0a09 0909 7374 e_padfile,....st │ │ │ -000064b0: 643a 3a73 7461 7469 635f 706f 696e 7465 d::static_pointe │ │ │ -000064c0: 725f 6361 7374 266c 743b 7765 625f 7065 r_cast<web_pe │ │ │ -000064d0: 6572 5f63 6f6e 6e65 6374 696f 6e26 6774 er_connection> │ │ │ -000064e0: 3b28 7365 6c66 2829 2929 293b 0a09 0972 ;(self())));...r │ │ │ -000064f0: 6574 7572 6e3b 0a09 7d0a 0a23 6966 6e64 eturn;..}..#ifnd │ │ │ -00006500: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ -00006510: 4c45 5f4c 4f47 4749 4e47 0a09 7065 6572 LE_LOGGING..peer │ │ │ -00006520: 5f6c 6f67 2870 6565 725f 6c6f 675f 616c _log(peer_log_al │ │ │ -00006530: 6572 743a 3a6f 7574 676f 696e 675f 6d65 ert::outgoing_me │ │ │ -00006540: 7373 6167 652c 2070 6565 725f 6c6f 675f ssage, peer_log_ │ │ │ -00006550: 616c 6572 743a 3a72 6571 7565 7374 2c20 alert::request, │ │ │ -00006560: 2225 7322 2c20 7265 7175 6573 742e 635f "%s", request.c_ │ │ │ -00006570: 7374 7228 2929 3b0a 2365 6e64 6966 0a0a str());.#endif.. │ │ │ -00006580: 0973 656e 645f 6275 6666 6572 2872 6571 .send_buffer(req │ │ │ -00006590: 7565 7374 293b 0a7d 0a0a 6e61 6d65 7370 uest);.}..namesp │ │ │ -000065a0: 6163 6520 7b0a 0a09 7374 643a 3a73 7472 ace {...std::str │ │ │ -000065b0: 696e 6720 6765 745f 7065 6572 5f6e 616d ing get_peer_nam │ │ │ -000065c0: 6528 6175 783a 3a68 7474 705f 7061 7273 e(aux::http_pars │ │ │ -000065d0: 6572 2063 6f6e 7374 2661 6d70 3b20 702c er const& p, │ │ │ -000065e0: 2073 7464 3a3a 7374 7269 6e67 2063 6f6e std::string con │ │ │ -000065f0: 7374 2661 6d70 3b20 686f 7374 290a 097b st& host)..{ │ │ │ -00006600: 0a09 0973 7464 3a3a 7374 7269 6e67 2063 ...std::string c │ │ │ -00006610: 6f6e 7374 2661 6d70 3b20 7365 7276 6572 onst& server │ │ │ -00006620: 5f76 6572 7369 6f6e 203d 2070 2e68 6561 _version = p.hea │ │ │ -00006630: 6465 7228 2273 6572 7665 7222 293b 0a09 der("server");.. │ │ │ -00006640: 0969 6620 2821 7365 7276 6572 5f76 6572 .if (!server_ver │ │ │ -00006650: 7369 6f6e 2e65 6d70 7479 2829 290a 0909 sion.empty())... │ │ │ -00006660: 0972 6574 7572 6e20 7365 7276 6572 5f76 .return server_v │ │ │ -00006670: 6572 7369 6f6e 3b0a 0909 7265 7475 726e ersion;...return │ │ │ -00006680: 2068 6f73 743b 0a09 7d0a 0a3c 2f70 7265 host;..}..
    rele │ │ │ -000066c0: 7661 6e63 6526 6e62 7370 3b33 3c2f 7464 vance 3../src/web_ │ │ │ -00006700: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2e peer_connection. │ │ │ -00006710: 6370 703a 3639 313c 2f61 3e3c 2f74 643e cpp:691 │ │ │ -00006720: 3c74 643e 7468 6973 2063 6f75 6c64 2062 this could b │ │ │ -00006730: 6520 6d61 6465 206d 6f72 6520 6566 6669 e made more effi │ │ │ -00006740: 6369 656e 7420 666f 7220 7468 6520 6361 cient for the ca │ │ │ -00006750: 7365 2077 6865 6e20 7765 2075 7365 2061 se when we use a │ │ │ -00006760: 6e20 4854 5450 2070 726f 7879 2e20 5468 n HTTP proxy. Th │ │ │ -00006770: 656e 2077 6520 776f 756c 646e 2774 206e en we wouldn't n │ │ │ -00006780: 6565 6420 746f 2061 6464 206e 6577 2077 eed to add new w │ │ │ -00006790: 6562 2073 6565 6473 2074 6f20 7468 6520 eb seeds to the │ │ │ -000067a0: 746f 7272 656e 742c 2077 6520 636f 756c torrent, we coul │ │ │ -000067b0: 6420 6a75 7374 206d 616b 6520 7468 6520 d just make the │ │ │ -000067c0: 7265 6469 7265 6374 2074 6162 6c65 2063 redirect table c │ │ │ -000067d0: 6f6e 7461 696e 2066 756c 6c20 5552 4c73 ontain full URLs │ │ │ -000067e0: 2e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 .

    th │ │ │ -00006830: 6973 2063 6f75 6c64 2062 6520 6d61 6465 is could be made │ │ │ -00006840: 206d 6f72 6520 6566 6669 6369 656e 7420 more efficient │ │ │ -00006850: 666f 7220 7468 6520 6361 7365 2077 6865 for the case whe │ │ │ -00006860: 6e20 7765 2075 7365 2061 6e0a 4854 5450 n we use an.HTTP │ │ │ -00006870: 2070 726f 7879 2e20 5468 656e 2077 6520 proxy. Then we │ │ │ -00006880: 776f 756c 646e 2774 206e 6565 6420 746f wouldn't need to │ │ │ -00006890: 2061 6464 206e 6577 2077 6562 2073 6565 add new web see │ │ │ -000068a0: 6473 2074 6f20 7468 6520 746f 7272 656e ds to the torren │ │ │ -000068b0: 742c 0a77 6520 636f 756c 6420 6a75 7374 t,.we could just │ │ │ -000068c0: 206d 616b 6520 7468 6520 7265 6469 7265 make the redire │ │ │ -000068d0: 6374 2074 6162 6c65 2063 6f6e 7461 696e ct table contain │ │ │ -000068e0: 2066 756c 6c20 5552 4c73 2e3c 2f68 323e full URLs.

    │ │ │ -000068f0: 3c68 343e 2e2e 2f73 7263 2f77 6562 5f70

    ../src/web_p │ │ │ -00006900: 6565 725f 636f 6e6e 6563 7469 6f6e 2e63 eer_connection.c │ │ │ -00006910: 7070 3a36 3931 3c2f 6834 3e3c 7072 6520 pp:691

    ...? torren
    │ │ │ -00006960: 743a 3a6e 6f5f 6c6f 6361 6c5f 6970 7320  t::no_local_ips 
    │ │ │ -00006970: 3a20 7765 625f 7365 6564 5f66 6c61 675f  : web_seed_flag_
    │ │ │ -00006980: 747b 7d29 3b0a 0a09 2f2f 2061 6464 2074  t{});...// add t
    │ │ │ -00006990: 6865 2072 6564 6972 6563 7465 6420 7572  he redirected ur
    │ │ │ -000069a0: 6c20 616e 6420 7265 6d6f 7665 2074 6865  l and remove the
    │ │ │ -000069b0: 2063 7572 7265 6e74 206f 6e65 0a09 6966   current one..if
    │ │ │ -000069c0: 2028 2173 696e 676c 655f 6669 6c65 5f72   (!single_file_r
    │ │ │ -000069d0: 6571 7565 7374 290a 097b 0a09 0969 6620  equest)..{...if 
    │ │ │ -000069e0: 286d 5f66 696c 655f 7265 7175 6573 7473  (m_file_requests
    │ │ │ -000069f0: 2e65 6d70 7479 2829 290a 0909 7b0a 0909  .empty())...{...
    │ │ │ -00006a00: 092f 2f20 7468 6520 7365 7276 6572 2073  .// the server s
    │ │ │ -00006a10: 656e 7420 6120 7265 6469 7265 6374 2072  ent a redirect r
    │ │ │ -00006a20: 6573 706f 6e73 6520 7769 7468 6f75 7420  esponse without 
    │ │ │ -00006a30: 6120 6d61 7463 6869 6e67 2072 6571 7565  a matching reque
    │ │ │ -00006a40: 7374 0a09 0909 6469 7363 6f6e 6e65 6374  st....disconnect
    │ │ │ -00006a50: 2865 7272 6f72 733a 3a68 7474 705f 7061  (errors::http_pa
    │ │ │ -00006a60: 7273 655f 6572 726f 722c 206f 7065 7261  rse_error, opera
    │ │ │ -00006a70: 7469 6f6e 5f74 3a3a 6269 7474 6f72 7265  tion_t::bittorre
    │ │ │ -00006a80: 6e74 2c20 7065 6572 5f65 7272 6f72 293b  nt, peer_error);
    │ │ │ -00006a90: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a  ....return;...}.
    │ │ │ -00006aa0: 0909 6669 6c65 5f69 6e64 6578 5f74 2063  ..file_index_t c
    │ │ │ -00006ab0: 6f6e 7374 2066 696c 655f 696e 6465 7820  onst file_index 
    │ │ │ -00006ac0: 3d20 6d5f 6669 6c65 5f72 6571 7565 7374  = m_file_request
    │ │ │ -00006ad0: 732e 6672 6f6e 7428 292e 6669 6c65 5f69  s.front().file_i
    │ │ │ -00006ae0: 6e64 6578 3b0a 0a09 096c 6f63 6174 696f  ndex;....locatio
    │ │ │ -00006af0: 6e20 3d20 6175 783a 3a72 6573 6f6c 7665  n = aux::resolve
    │ │ │ -00006b00: 5f72 6564 6972 6563 745f 6c6f 6361 7469  _redirect_locati
    │ │ │ -00006b10: 6f6e 286d 5f75 726c 2c20 6c6f 6361 7469  on(m_url, locati
    │ │ │ -00006b20: 6f6e 293b 0a0a 0909 2f2f 2077 6f72 6b2d  on);....// work-
    │ │ │ -00006b30: 6172 6f75 6e64 2066 6f72 2062 7567 6779  around for buggy
    │ │ │ -00006b40: 2048 5454 5020 7365 7276 6572 732c 2074   HTTP servers, t
    │ │ │ -00006b50: 6861 7420 6661 696c 2074 6f20 656e 636f  hat fail to enco
    │ │ │ -00006b60: 6465 2074 6865 2072 6564 6972 6563 7420  de the redirect 
    │ │ │ -00006b70: 5552 4c0a 0909 6c6f 6361 7469 6f6e 203d  URL...location =
    │ │ │ -00006b80: 206d 6179 6265 5f75 726c 5f65 6e63 6f64   maybe_url_encod
    │ │ │ -00006b90: 6528 6c6f 6361 7469 6f6e 293b 0a23 6966  e(location);.#if
    │ │ │ -00006ba0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ -00006bb0: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0970  ABLE_LOGGING...p
    │ │ │ -00006bc0: 6565 725f 6c6f 6728 7065 6572 5f6c 6f67  eer_log(peer_log
    │ │ │ -00006bd0: 5f61 6c65 7274 3a3a 696e 666f 2c20 7065  _alert::info, pe
    │ │ │ -00006be0: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 6c6f  er_log_alert::lo
    │ │ │ -00006bf0: 6361 7469 6f6e 2c20 2225 7322 2c20 6c6f  cation, "%s", lo
    │ │ │ -00006c00: 6361 7469 6f6e 2e63 5f73 7472 2829 293b  cation.c_str());
    │ │ │ -00006c10: 0a23 656e 6469 660a 3c64 6976 2073 7479  .#endif.
    ..error_co │ │ │ -00006c50: 6465 2065 633b 0a3c 2f64 6976 3e09 0961 de ec;.
    ..a │ │ │ -00006c60: 7574 6f20 636f 6e73 7420 5b72 6564 6972 uto const [redir │ │ │ -00006c70: 6563 745f 6261 7365 2c20 7265 6469 7265 ect_base, redire │ │ │ -00006c80: 6374 5f70 6174 685d 203d 2073 706c 6974 ct_path] = split │ │ │ -00006c90: 5f75 726c 286c 6f63 6174 696f 6e2c 2065 _url(location, e │ │ │ -00006ca0: 6329 3b0a 0a09 0969 6620 2865 6329 0a09 c);....if (ec).. │ │ │ -00006cb0: 097b 0a09 0909 2f2f 2077 6520 7368 6f75 .{....// we shou │ │ │ -00006cc0: 6c64 206e 6f74 2074 7279 2074 6869 7320 ld not try this │ │ │ -00006cd0: 7365 7276 6572 2061 6761 696e 2e0a 0909 server again.... │ │ │ -00006ce0: 0964 6973 636f 6e6e 6563 7428 6572 726f .disconnect(erro │ │ │ -00006cf0: 7273 3a3a 6d69 7373 696e 675f 6c6f 6361 rs::missing_loca │ │ │ -00006d00: 7469 6f6e 2c20 6f70 6572 6174 696f 6e5f tion, operation_ │ │ │ -00006d10: 743a 3a62 6974 746f 7272 656e 742c 2066 t::bittorrent, f │ │ │ -00006d20: 6169 6c75 7265 293b 0a09 0909 7265 7475 ailure);....retu │ │ │ -00006d30: 726e 3b0a 0909 7d0a 0a09 092f 2f20 6164 rn;...}....// ad │ │ │ -00006d40: 645f 7765 625f 7365 6564 2077 6f6e 2774 d_web_seed won't │ │ │ -00006d50: 2061 6464 2064 7570 6c69 6361 7465 732e add duplicates. │ │ │ -00006d60: 2049 6620 7765 2068 6176 6520 616c 7265 If we have alre │ │ │ -00006d70: 6164 7920 6164 6465 6420 616e 2065 6e74 ady added an ent │ │ │ -00006d80: 7279 0a09 092f 2f20 7769 7468 2074 6869 ry...// with thi │ │ │ -00006d90: 7320 5552 4c2c 2077 6527 6c6c 2067 6574 s URL, we'll get │ │ │ -00006da0: 2062 6163 6b20 7468 6520 6578 6973 7469 back the existi │ │ │ -00006db0: 6e67 2065 6e74 7279 0a0a 0909 2f2f 2044 ng entry....// D │ │ │ -00006dc0: 6f6e 2774 2066 6f72 7761 7264 206f 7572 on't forward our │ │ │ -00006dd0: 2063 7265 6465 6e74 6961 6c73 2028 7468 credentials (th │ │ │ -00006de0: 6520 7765 625f 7365 6564 5f65 6e74 7279 e web_seed_entry │ │ │ -00006df0: 3a3a 6175 7468 2076 616c 7565 2c20 7365 ::auth value, se │ │ │ -00006e00: 6e74 0a09 092f 2f20 6173 2074 6865 2041 nt...// as the A │ │ │ -00006e10: 7574 686f 7269 7a61 7469 6f6e 2068 6561 uthorization hea │ │ │ -00006e20: 6465 7229 2074 6f20 6120 6469 6666 6572 der) to a differ │ │ │ -00006e30: 656e 7420 6f72 6967 696e 2e20 5468 6520 ent origin. The │ │ │ -00006e40: 7265 6469 7265 6374 0a09 092f 2f20 7461 redirect...// ta │ │ │ -00006e50: 7267 6574 206d 6179 2062 6520 6120 7468 rget may be a th │ │ │ -00006e60: 6972 6420 7061 7274 7920 7365 7276 6572 ird party server │ │ │ -00006e70: 2074 6861 7420 7368 6f75 6c64 206e 6f74 that should not │ │ │ -00006e80: 2073 6565 2074 6865 6d2e 204e 6f74 650a see them. Note. │ │ │ -00006e90: 0909 2f2f 2074 6861 7420 616e 7920 7573 ..// that any us │ │ │ -00006ea0: 6572 2d73 7570 706c 6965 6420 6d5f 6578 er-supplied m_ex │ │ │ -00006eb0: 7472 615f 6865 6164 6572 7320 6172 6520 tra_headers are │ │ │ -00006ec0: 7374 696c 6c20 666f 7277 6172 6465 6420 still forwarded │ │ │ -00006ed0: 2d2d 2073 6565 2074 6865 0a09 092f 2f20 -- see the...// │ │ │ -00006ee0: 7761 726e 696e 6720 6f6e 2077 6562 5f73 warning on web_s │ │ │ -00006ef0: 6565 645f 656e 7472 793a 3a65 7874 7261 eed_entry::extra │ │ │ -00006f00: 5f68 6561 6465 7273 2e0a 0909 7374 643a _headers....std: │ │ │ -00006f10: 3a73 7472 696e 6720 636f 6e73 7420 6175 :string const au │ │ │ -00006f20: 7468 203d 2073 616d 655f 6f72 6967 696e th = same_origin │ │ │ -00006f30: 286d 5f75 726c 2c20 6c6f 6361 7469 6f6e (m_url, location │ │ │ -00006f40: 2920 3f20 6d5f 6578 7465 726e 616c 5f61 ) ? m_external_a │ │ │ -00006f50: 7574 6820 3a20 7374 643a 3a73 7472 696e uth : std::strin │ │ │ -00006f60: 6728 293b 0a0a 0909 2f2f 2022 6570 6865 g();....// "ephe │ │ │ -00006f70: 6d65 7261 6c22 2066 6c61 6720 7368 6f75 meral" flag shou │ │ │ -00006f80: 6c64 2062 6520 7365 7420 746f 2061 766f ld be set to avo │ │ │ -00006f90: 6964 2022 7765 625f 7365 6564 5f74 2220 id "web_seed_t" │ │ │ -00006fa0: 7361 7669 6e67 2069 6e20 7265 7375 6d65 saving in resume │ │ │ -00006fb0: 2064 6174 612e 0a09 092f 2f20 452e 672e data....// E.g. │ │ │ -00006fc0: 206f 7269 6769 6e61 6c20 2277 6562 5f73 original "web_s │ │ │ -00006fd0: 6565 645f 7422 2072 6571 7565 7374 2075 eed_t" request u │ │ │ -00006fe0: 726c 2070 6f69 6e74 7320 746f 2022 6874 rl points to "ht │ │ │ -00006ff0: 7470 3a2f 2f65 7861 6d70 6c65 312e 636f tp://example1.co │ │ │ -00007000: 6d2f 6669 6c65 3122 2061 6e64 0a09 092f m/file1" and.../ │ │ │ -00007010: 2f20 7765 6220 7365 7276 6572 2072 6573 / web server res │ │ │ -00007020: 706f 6e73 6573 2077 6974 6820 7265 6469 ponses with redi │ │ │ -00007030: 7265 6374 206c 6f63 6174 696f 6e20 2268 rect location "h │ │ │ -00007040: 7474 703a 2f2f 6578 616d 706c 6532 2e63 ttp://example2.c │ │ │ -00007050: 6f6d 2f73 7562 7061 7468 2f66 696c 6532 om/subpath/file2 │ │ │ -00007060: 222e 0a09 092f 2f20 2268 616e 646c 655f "....// "handle_ │ │ │ -00007070: 7265 6469 7265 6374 2220 7072 6f63 6573 redirect" proces │ │ │ -00007080: 7320 7468 6973 206c 6f63 6174 696f 6e20 s this location │ │ │ -00007090: 746f 2063 7265 6174 6520 6e65 7720 2277 to create new "w │ │ │ -000070a0: 6562 5f73 6565 645f 7422 0a09 092f 2f20 eb_seed_t"...// │ │ │ -000070b0: 7769 7468 2062 6173 6520 7572 6c3d 3d22 with base url==" │ │ │ -000070c0: 6874 7470 3a2f 2f65 7861 6d70 6c65 322e http://example2. │ │ │ -000070d0: 636f 6d2f 2220 616e 6420 7265 6469 7265 com/" and redire │ │ │ -000070e0: 6374 735b 305d 3d3d 222f 7375 6270 6174 cts[0]=="/subpat │ │ │ -000070f0: 682f 6669 6c65 3222 292e 0a09 092f 2f20 h/file2")....// │ │ │ -00007100: 4966 2077 6520 7472 7920 746f 206c 6f61 If we try to loa │ │ │ -00007110: 6420 7265 7375 6d65 2077 6974 6820 7375 d resume with su │ │ │ -00007120: 6368 2022 7765 625f 7365 6564 5f74 2220 ch "web_seed_t" │ │ │ -00007130: 7468 656e 2022 7765 625f 7065 6572 5f63 then "web_peer_c │ │ │ -00007140: 6f6e 6e65 6374 696f 6e22 2077 696c 6c20 onnection" will │ │ │ -00007150: 7365 6e64 0a09 092f 2f20 7265 7175 6573 send...// reques │ │ │ -00007160: 7420 7769 7468 2077 726f 6e67 2070 6174 t with wrong pat │ │ │ -00007170: 6820 2268 7474 703a 2f2f 6578 616d 706c h "http://exampl │ │ │ -00007180: 6532 2e63 6f6d 2f66 696c 6531 2220 2863 e2.com/file1" (c │ │ │ -00007190: 6175 7365 2022 7265 6469 7265 6374 7322 ause "redirects" │ │ │ -000071a0: 206d 6170 2069 7320 6e6f 7420 7365 7269 map is not seri │ │ │ -000071b0: 616c 697a 6564 2069 6e20 7265 7375 6d65 alized in resume │ │ │ -000071c0: 290a 0909 7765 625f 7365 6564 5f74 2a20 )...web_seed_t* │ │ │ -000071d0: 7765 6220 3d20 742d 2667 743b 6164 645f web = t->add_ │ │ │ -000071e0: 7765 625f 7365 6564 2872 6564 6972 6563 web_seed(redirec │ │ │ -000071f0: 745f 6261 7365 2c20 6175 7468 2c20 6d5f t_base, auth, m_ │ │ │ -00007200: 6578 7472 615f 6865 6164 6572 732c 2077 extra_headers, w │ │ │ -00007210: 6562 5f73 6565 645f 666c 6167 7329 3b0a eb_seed_flags);. │ │ │ -00007220: 0909 7765 622d 2667 743b 6861 7665 5f66 ..web->have_f │ │ │ -00007230: 696c 6573 2e72 6573 697a 6528 742d 2667 iles.resize(t-&g │ │ │ -00007240: 743b 746f 7272 656e 745f 6669 6c65 2829 t;torrent_file() │ │ │ -00007250: 2e6e 756d 5f66 696c 6573 2829 2c20 6661 .num_files(), fa │ │ │ -00007260: 6c73 6529 3b0a 0a09 092f 2f20 7468 6520 lse);....// the │ │ │ -00007270: 6e65 7720 7765 6220 7365 6564 2077 6527 new web seed we' │ │ │ -00007280: 7265 2061 6464 696e 6720 6f6e 6c79 2068 re adding only h │ │ │ -00007290: 6173 2074 6869 7320 6669 6c65 2066 6f72 as this file for │ │ │ -000072a0: 206e 6f77 0a3c 2f70 7265 3e3c 2f74 643e now.
    │ │ │ -000072b0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -000072e0: 6e62 7370 3b33 3c2f 7464 3e3c 7464 3e3c nbsp;3< │ │ │ -000072f0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00007300: 7074 3a65 7870 616e 6428 3134 2922 3e2e pt:expand(14)">. │ │ │ -00007310: 2e2f 7372 632f 7365 7373 696f 6e5f 6861 ./src/session_ha │ │ │ -00007320: 6e64 6c65 2e63 7070 3a36 3433 3c2f 613e ndle.cpp:643 │ │ │ -00007330: 3c2f 7464 3e3c 7464 3e65 7870 6f73 6520 expose │ │ │ -00007340: 7468 6520 7365 7175 656e 6365 5f6e 756d the sequence_num │ │ │ -00007350: 6265 722c 2070 7562 6c69 635f 6b65 792c ber, public_key, │ │ │ -00007360: 2073 6563 7265 745f 6b65 7920 616e 6420 secret_key and │ │ │ -00007370: 7369 676e 6174 7572 6520 7479 7065 7320 signature types │ │ │ -00007380: 746f 2074 6865 2063 6c69 656e 743c 2f74 to the client

    expose │ │ │ -000073e0: 2074 6865 2073 6571 7565 6e63 655f 6e75 the sequence_nu │ │ │ -000073f0: 6d62 6572 2c20 7075 626c 6963 5f6b 6579 mber, public_key │ │ │ -00007400: 2c20 7365 6372 6574 5f6b 6579 2061 6e64 , secret_key and │ │ │ -00007410: 2073 6967 6e61 7475 7265 0a74 7970 6573 signature.types │ │ │ -00007420: 2074 6f20 7468 6520 636c 6965 6e74 3c2f to the client

    ../src/se │ │ │ -00007440: 7373 696f 6e5f 6861 6e64 6c65 2e63 7070 ssion_handle.cpp │ │ │ -00007450: 3a36 3433 3c2f 6834 3e3c 7072 6520 7374 :643

    .void session
    │ │ │ -000074a0: 5f68 616e 646c 653a 3a64 6874 5f67 6574  _handle::dht_get
    │ │ │ -000074b0: 5f69 7465 6d28 7368 6131 5f68 6173 6820  _item(sha1_hash 
    │ │ │ -000074c0: 636f 6e73 7426 616d 703b 2074 6172 6765  const& targe
    │ │ │ -000074d0: 7429 0a09 7b0a 2369 666e 6465 6620 544f  t)..{.#ifndef TO
    │ │ │ -000074e0: 5252 454e 545f 4449 5341 424c 455f 4448  RRENT_DISABLE_DH
    │ │ │ -000074f0: 540a 0909 6173 796e 635f 6361 6c6c 2826  T...async_call(&
    │ │ │ -00007500: 616d 703b 7365 7373 696f 6e5f 696d 706c  amp;session_impl
    │ │ │ -00007510: 3a3a 6468 745f 6765 745f 696d 6d75 7461  ::dht_get_immuta
    │ │ │ -00007520: 626c 655f 6974 656d 2c20 7461 7267 6574  ble_item, target
    │ │ │ -00007530: 293b 0a23 656c 7365 0a09 0954 4f52 5245  );.#else...TORRE
    │ │ │ -00007540: 4e54 5f55 4e55 5345 4428 7461 7267 6574  NT_UNUSED(target
    │ │ │ -00007550: 293b 0a23 656e 6469 660a 097d 0a0a 0976  );.#endif..}...v
    │ │ │ -00007560: 6f69 6420 7365 7373 696f 6e5f 6861 6e64  oid session_hand
    │ │ │ -00007570: 6c65 3a3a 6468 745f 6765 745f 6974 656d  le::dht_get_item
    │ │ │ -00007580: 2873 7464 3a3a 6172 7261 7926 6c74 3b63  (std::array<c
    │ │ │ -00007590: 6861 722c 2033 3226 6774 3b20 6b65 790a  har, 32> key.
    │ │ │ -000075a0: 0909 2c20 7374 643a 3a73 7472 696e 6720  .., std::string 
    │ │ │ -000075b0: 7361 6c74 290a 097b 0a23 6966 6e64 6566  salt)..{.#ifndef
    │ │ │ -000075c0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ -000075d0: 5f44 4854 0a09 0961 7379 6e63 5f63 616c  _DHT...async_cal
    │ │ │ -000075e0: 6c28 2661 6d70 3b73 6573 7369 6f6e 5f69  l(&session_i
    │ │ │ -000075f0: 6d70 6c3a 3a64 6874 5f67 6574 5f6d 7574  mpl::dht_get_mut
    │ │ │ -00007600: 6162 6c65 5f69 7465 6d2c 206b 6579 2c20  able_item, key, 
    │ │ │ -00007610: 7361 6c74 293b 0a23 656c 7365 0a09 0954  salt);.#else...T
    │ │ │ -00007620: 4f52 5245 4e54 5f55 4e55 5345 4428 6b65  ORRENT_UNUSED(ke
    │ │ │ -00007630: 7929 3b0a 0909 544f 5252 454e 545f 554e  y);...TORRENT_UN
    │ │ │ -00007640: 5553 4544 2873 616c 7429 3b0a 2365 6e64  USED(salt);.#end
    │ │ │ -00007650: 6966 0a09 7d0a 0a3c 6469 7620 7374 796c  if..}..
    .sha1_hash │ │ │ -00007690: 7365 7373 696f 6e5f 6861 6e64 6c65 3a3a session_handle:: │ │ │ -000076a0: 6468 745f 7075 745f 6974 656d 2865 6e74 dht_put_item(ent │ │ │ -000076b0: 7279 2064 6174 6129 0a3c 2f64 6976 3e09 ry data).
    . │ │ │ -000076c0: 7b0a 0909 7374 643a 3a76 6563 746f 7226 {...std::vector& │ │ │ -000076d0: 6c74 3b63 6861 7226 6774 3b20 6275 663b lt;char> buf; │ │ │ -000076e0: 0a09 0962 656e 636f 6465 2873 7464 3a3a ...bencode(std:: │ │ │ -000076f0: 6261 636b 5f69 6e73 6572 7465 7228 6275 back_inserter(bu │ │ │ -00007700: 6629 2c20 6461 7461 293b 0a09 0973 6861 f), data);...sha │ │ │ -00007710: 315f 6861 7368 2063 6f6e 7374 2072 6574 1_hash const ret │ │ │ -00007720: 203d 2068 6173 6865 7228 6275 6629 2e66 = hasher(buf).f │ │ │ -00007730: 696e 616c 2829 3b0a 0a23 6966 6e64 6566 inal();..#ifndef │ │ │ -00007740: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -00007750: 5f44 4854 0a09 0961 7379 6e63 5f63 616c _DHT...async_cal │ │ │ -00007760: 6c28 2661 6d70 3b73 6573 7369 6f6e 5f69 l(&session_i │ │ │ -00007770: 6d70 6c3a 3a64 6874 5f70 7574 5f69 6d6d mpl::dht_put_imm │ │ │ -00007780: 7574 6162 6c65 5f69 7465 6d2c 2064 6174 utable_item, dat │ │ │ -00007790: 612c 2072 6574 293b 0a23 656e 6469 660a a, ret);.#endif. │ │ │ -000077a0: 0909 7265 7475 726e 2072 6574 3b0a 097d ..return ret;..} │ │ │ -000077b0: 0a0a 0976 6f69 6420 7365 7373 696f 6e5f ...void session_ │ │ │ -000077c0: 6861 6e64 6c65 3a3a 6468 745f 7075 745f handle::dht_put_ │ │ │ -000077d0: 6974 656d 2873 7464 3a3a 6172 7261 7926 item(std::array& │ │ │ -000077e0: 6c74 3b63 6861 722c 2033 3226 6774 3b20 lt;char, 32> │ │ │ -000077f0: 6b65 790a 0909 2c20 7374 643a 3a66 756e key..., std::fun │ │ │ -00007800: 6374 696f 6e26 6c74 3b76 6f69 6428 656e ction<void(en │ │ │ -00007810: 7472 7926 616d 703b 2c20 7374 643a 3a61 try&, std::a │ │ │ -00007820: 7272 6179 266c 743b 6368 6172 2c36 3426 rray<char,64& │ │ │ -00007830: 6774 3b26 616d 703b 0a09 0909 2c20 7374 gt;&...., st │ │ │ -00007840: 643a 3a69 6e74 3634 5f74 2661 6d70 3b2c d::int64_t&, │ │ │ -00007850: 2073 7464 3a3a 7374 7269 6e67 2063 6f6e std::string con │ │ │ -00007860: 7374 2661 6d70 3b29 2667 743b 2063 620a st&)> cb. │ │ │ -00007870: 0909 2c20 7374 643a 3a73 7472 696e 6720 .., std::string │ │ │ -00007880: 7361 6c74 290a 097b 0a23 6966 6e64 6566 salt)..{.#ifndef │ │ │ -00007890: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -000078a0: 5f44 4854 0a09 0961 7379 6e63 5f63 616c _DHT...async_cal │ │ │ -000078b0: 6c28 2661 6d70 3b73 6573 7369 6f6e 5f69 l(&session_i │ │ │ -000078c0: 6d70 6c3a 3a64 6874 5f70 7574 5f6d 7574 mpl::dht_put_mut │ │ │ -000078d0: 6162 6c65 5f69 7465 6d2c 206b 6579 2c20 able_item, key, │ │ │ -000078e0: 6362 2c20 7361 6c74 293b 0a23 656c 7365 cb, salt);.#else │ │ │ -000078f0: 0a09 0954 4f52 5245 4e54 5f55 4e55 5345 ...TORRENT_UNUSE │ │ │ -00007900: 4428 6b65 7929 3b0a 0909 544f 5252 454e D(key);...TORREN │ │ │ -00007910: 545f 554e 5553 4544 2863 6229 3b0a 0909 T_UNUSED(cb);... │ │ │ -00007920: 544f 5252 454e 545f 554e 5553 4544 2873 TORRENT_UNUSED(s │ │ │ -00007930: 616c 7429 3b0a 2365 6e64 6966 0a09 7d0a alt);.#endif..}. │ │ │ -00007940: 0a09 766f 6964 2073 6573 7369 6f6e 5f68 ..void session_h │ │ │ -00007950: 616e 646c 653a 3a64 6874 5f67 6574 5f70 andle::dht_get_p │ │ │ -00007960: 6565 7273 2873 6861 315f 6861 7368 2063 eers(sha1_hash c │ │ │ -00007970: 6f6e 7374 2661 6d70 3b20 696e 666f 5f68 onst& info_h │ │ │ -00007980: 6173 6829 0a09 7b0a 2369 666e 6465 6620 ash)..{.#ifndef │ │ │ -00007990: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -000079a0: 4448 540a 0909 6173 796e 635f 6361 6c6c DHT...async_call │ │ │ -000079b0: 2826 616d 703b 7365 7373 696f 6e5f 696d (&session_im │ │ │ -000079c0: 706c 3a3a 6468 745f 6765 745f 7065 6572 pl::dht_get_peer │ │ │ -000079d0: 732c 2069 6e66 6f5f 6861 7368 293b 0a23 s, info_hash);.# │ │ │ -000079e0: 656c 7365 0a3c 2f70 7265 3e3c 2f74 643e else.
    │ │ │ -000079f0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00007a20: 6e62 7370 3b33 3c2f 7464 3e3c 7464 3e3c nbsp;3< │ │ │ -00007a30: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00007a40: 7074 3a65 7870 616e 6428 3135 2922 3e2e pt:expand(15)">. │ │ │ -00007a50: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ -00007a60: 6374 696f 6e2e 6370 703a 3331 3237 3c2f ction.cpp:3127inste │ │ │ -00007a80: 6164 206f 6620 6861 7669 6e67 2074 6f20 ad of having to │ │ │ -00007a90: 6173 6b20 7468 6520 746f 7272 656e 7420 ask the torrent │ │ │ -00007aa0: 7768 6574 6865 7220 6974 2773 2069 6e20 whether it's in │ │ │ -00007ab0: 6772 6163 6566 756c 2070 6175 7365 206d graceful pause m │ │ │ -00007ac0: 6f64 6520 6f72 206e 6f74 2c20 7468 6520 ode or not, the │ │ │ -00007ad0: 7065 6572 7320 7368 6f75 6c64 206b 6565 peers should kee │ │ │ -00007ae0: 7020 7468 6174 2073 7461 7465 2028 616e p that state (an │ │ │ -00007af0: 6420 7468 6520 746f 7272 656e 7420 7368 d the torrent sh │ │ │ -00007b00: 6f75 6c64 2075 7064 6174 6520 7468 656d ould update them │ │ │ -00007b10: 2077 6865 6e20 6974 2065 6e74 6572 7320 when it enters │ │ │ -00007b20: 6772 6163 6566 756c 2070 6175 7365 292e graceful pause). │ │ │ -00007b30: 2057 6865 6e20 6120 7065 6572 2065 6e74 When a peer ent │ │ │ -00007b40: 6572 7320 6772 6163 6566 756c 2070 6175 ers graceful pau │ │ │ -00007b50: 7365 206d 6f64 652c 2069 7420 7368 6f75 se mode, it shou │ │ │ -00007b60: 6c64 2063 616e 6365 6c20 616c 6c20 6f75 ld cancel all ou │ │ │ -00007b70: 7473 7461 6e64 696e 6720 7265 7175 6573 tstanding reques │ │ │ -00007b80: 7473 2061 6e64 2063 6c65 6172 2069 7473 ts and clear its │ │ │ -00007b90: 2072 6571 7565 7374 2071 7565 7565 2e3c request queue.< │ │ │ -00007ba0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    inst │ │ │ -00007bf0: 6561 6420 6f66 2068 6176 696e 6720 746f ead of having to │ │ │ -00007c00: 2061 736b 2074 6865 2074 6f72 7265 6e74 ask the torrent │ │ │ -00007c10: 2077 6865 7468 6572 2069 7427 7320 696e whether it's in │ │ │ -00007c20: 2067 7261 6365 6675 6c0a 7061 7573 6520 graceful.pause │ │ │ -00007c30: 6d6f 6465 206f 7220 6e6f 742c 2074 6865 mode or not, the │ │ │ -00007c40: 2070 6565 7273 2073 686f 756c 6420 6b65 peers should ke │ │ │ -00007c50: 6570 2074 6861 7420 7374 6174 6520 2861 ep that state (a │ │ │ -00007c60: 6e64 2074 6865 2074 6f72 7265 6e74 0a73 nd the torrent.s │ │ │ -00007c70: 686f 756c 6420 7570 6461 7465 2074 6865 hould update the │ │ │ -00007c80: 6d20 7768 656e 2069 7420 656e 7465 7273 m when it enters │ │ │ -00007c90: 2067 7261 6365 6675 6c20 7061 7573 6529 graceful pause) │ │ │ -00007ca0: 2e20 5768 656e 2061 2070 6565 7220 656e . When a peer en │ │ │ -00007cb0: 7465 7273 0a67 7261 6365 6675 6c20 7061 ters.graceful pa │ │ │ -00007cc0: 7573 6520 6d6f 6465 2c20 6974 2073 686f use mode, it sho │ │ │ -00007cd0: 756c 6420 6361 6e63 656c 2061 6c6c 206f uld cancel all o │ │ │ -00007ce0: 7574 7374 616e 6469 6e67 2072 6571 7565 utstanding reque │ │ │ -00007cf0: 7374 7320 616e 640a 636c 6561 7220 6974 sts and.clear it │ │ │ -00007d00: 7320 7265 7175 6573 7420 7175 6575 652e s request queue. │ │ │ -00007d10: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00007d20: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2e peer_connection. │ │ │ -00007d30: 6370 703a 3331 3237 3c2f 6834 3e3c 7072 cpp:3127

    ..// to d │ │ │ -00007d80: 6973 6b20 6f72 2061 7265 2069 6e20 7468 isk or are in th │ │ │ -00007d90: 6520 6469 736b 2077 7269 7465 2063 6163 e disk write cac │ │ │ -00007da0: 6865 0a09 0969 6620 2870 6963 6b65 722e he...if (picker. │ │ │ -00007db0: 6973 5f70 6965 6365 5f66 696e 6973 6865 is_piece_finishe │ │ │ -00007dc0: 6428 702e 7069 6563 6529 2026 616d 703b d(p.piece) & │ │ │ -00007dd0: 2661 6d70 3b20 2177 6173 5f66 696e 6973 & !was_finis │ │ │ -00007de0: 6865 6429 0a09 097b 0a23 6966 2054 4f52 hed)...{.#if TOR │ │ │ -00007df0: 5245 4e54 5f55 5345 5f49 4e56 4152 4941 RENT_USE_INVARIA │ │ │ -00007e00: 4e54 5f43 4845 434b 530a 0909 0963 6865 NT_CHECKS....che │ │ │ -00007e10: 636b 5f70 6f73 7463 6f6e 6469 7469 6f6e ck_postcondition │ │ │ -00007e20: 2070 6f73 745f 6368 6563 6b65 7232 5f28 post_checker2_( │ │ │ -00007e30: 742c 2066 616c 7365 293b 0a23 656e 6469 t, false);.#endi │ │ │ -00007e40: 660a 0909 0974 2d26 6774 3b76 6572 6966 f....t->verif │ │ │ -00007e50: 795f 7069 6563 6528 702e 7069 6563 6529 y_piece(p.piece) │ │ │ -00007e60: 3b0a 0909 7d0a 0a09 0963 6865 636b 5f67 ;...}....check_g │ │ │ -00007e70: 7261 6365 6675 6c5f 7061 7573 6528 293b raceful_pause(); │ │ │ -00007e80: 0a0a 0909 6966 2028 6973 5f64 6973 636f ....if (is_disco │ │ │ -00007e90: 6e6e 6563 7469 6e67 2829 2920 7265 7475 nnecting()) retu │ │ │ -00007ea0: 726e 3b0a 0a09 0969 6620 2872 6571 7565 rn;....if (reque │ │ │ -00007eb0: 7374 5f61 5f62 6c6f 636b 282a 742c 202a st_a_block(*t, * │ │ │ -00007ec0: 7468 6973 2929 0a09 0909 6d5f 636f 756e this))....m_coun │ │ │ -00007ed0: 7465 7273 2e69 6e63 5f73 7461 7473 5f63 ters.inc_stats_c │ │ │ -00007ee0: 6f75 6e74 6572 2863 6f75 6e74 6572 733a ounter(counters: │ │ │ -00007ef0: 3a69 6e63 6f6d 696e 675f 7069 6563 655f :incoming_piece_ │ │ │ -00007f00: 7069 636b 7329 3b0a 0909 7365 6e64 5f62 picks);...send_b │ │ │ -00007f10: 6c6f 636b 5f72 6571 7565 7374 7328 293b lock_requests(); │ │ │ -00007f20: 0a09 7d0a 0a09 766f 6964 2070 6565 725f ..}...void peer_ │ │ │ -00007f30: 636f 6e6e 6563 7469 6f6e 3a3a 6368 6563 connection::chec │ │ │ -00007f40: 6b5f 6772 6163 6566 756c 5f70 6175 7365 k_graceful_pause │ │ │ -00007f50: 2829 0a09 7b0a 3c64 6976 2073 7479 6c65 ()..{.
    ..auto t = m │ │ │ -00007f90: 5f74 6f72 7265 6e74 2e6c 6f63 6b28 293b _torrent.lock(); │ │ │ -00007fa0: 0a3c 2f64 6976 3e09 0969 6620 2821 7420 .
    ..if (!t │ │ │ -00007fb0: 7c7c 2021 742d 2667 743b 6772 6163 6566 || !t->gracef │ │ │ -00007fc0: 756c 5f70 6175 7365 2829 2920 7265 7475 ul_pause()) retu │ │ │ -00007fd0: 726e 3b0a 0a09 0969 6620 286d 5f6f 7574 rn;....if (m_out │ │ │ -00007fe0: 7374 616e 6469 6e67 5f62 7974 6573 2026 standing_bytes & │ │ │ -00007ff0: 6774 3b20 3029 2072 6574 7572 6e3b 0a0a gt; 0) return;.. │ │ │ -00008000: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ -00008010: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ -00008020: 0909 7065 6572 5f6c 6f67 2870 6565 725f ..peer_log(peer_ │ │ │ -00008030: 6c6f 675f 616c 6572 743a 3a69 6e66 6f2c log_alert::info, │ │ │ -00008040: 2070 6565 725f 6c6f 675f 616c 6572 743a peer_log_alert: │ │ │ -00008050: 3a67 7261 6365 6675 6c5f 7061 7573 652c :graceful_pause, │ │ │ -00008060: 2022 4e4f 204d 4f52 4520 444f 574e 4c4f "NO MORE DOWNLO │ │ │ -00008070: 4144 2229 3b0a 2365 6e64 6966 0a09 0964 AD");.#endif...d │ │ │ -00008080: 6973 636f 6e6e 6563 7428 6572 726f 7273 isconnect(errors │ │ │ -00008090: 3a3a 746f 7272 656e 745f 7061 7573 6564 ::torrent_paused │ │ │ -000080a0: 2c20 6f70 6572 6174 696f 6e5f 743a 3a62 , operation_t::b │ │ │ -000080b0: 6974 746f 7272 656e 7429 3b0a 097d 0a0a ittorrent);..}.. │ │ │ -000080c0: 0976 6f69 6420 7065 6572 5f63 6f6e 6e65 .void peer_conne │ │ │ -000080d0: 6374 696f 6e3a 3a6f 6e5f 6469 736b 5f77 ction::on_disk_w │ │ │ -000080e0: 7269 7465 5f63 6f6d 706c 6574 6528 7374 rite_complete(st │ │ │ -000080f0: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ -00008100: 7426 616d 703b 2065 7272 6f72 0a09 092c t& error..., │ │ │ -00008110: 2070 6565 725f 7265 7175 6573 7420 636f peer_request co │ │ │ -00008120: 6e73 7426 616d 703b 2070 2c20 7374 643a nst& p, std: │ │ │ -00008130: 3a73 6861 7265 645f 7074 7226 6c74 3b61 :shared_ptr<a │ │ │ -00008140: 7578 3a3a 746f 7272 656e 7426 6774 3b20 ux::torrent> │ │ │ -00008150: 7429 0a09 7b0a 0909 544f 5252 454e 545f t)..{...TORRENT_ │ │ │ -00008160: 4153 5345 5254 2869 735f 7369 6e67 6c65 ASSERT(is_single │ │ │ -00008170: 5f74 6872 6561 6428 2929 3b0a 2369 666e _thread());.#ifn │ │ │ -00008180: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -00008190: 424c 455f 4c4f 4747 494e 470a 0909 6966 BLE_LOGGING...if │ │ │ -000081a0: 2028 7368 6f75 6c64 5f6c 6f67 2870 6565 (should_log(pee │ │ │ -000081b0: 725f 6c6f 675f 616c 6572 743a 3a69 6e66 r_log_alert::inf │ │ │ -000081c0: 6f29 290a 0909 7b0a 0909 0970 6565 725f o))...{....peer_ │ │ │ -000081d0: 6c6f 6728 7065 6572 5f6c 6f67 5f61 6c65 log(peer_log_ale │ │ │ -000081e0: 7274 3a3a 696e 666f 2c20 7065 6572 5f6c rt::info, peer_l │ │ │ -000081f0: 6f67 5f61 6c65 7274 3a3a 6669 6c65 5f61 og_alert::file_a │ │ │ -00008200: 7379 6e63 5f77 7269 7465 5f63 6f6d 706c sync_write_compl │ │ │ -00008210: 6574 652c 2022 7069 6563 653a 2025 6420 ete, "piece: %d │ │ │ -00008220: 733a 2025 7820 6c3a 2025 7820 653a 2025 s: %x l: %x e: % │ │ │ -00008230: 7322 0a09 0909 092c 2073 7461 7469 635f s"....., static_ │ │ │ -00008240: 6361 7374 266c 743b 696e 7426 6774 3b28 cast<int>( │ │ │ -00008250: 702e 7069 6563 6529 2c20 7374 643a 3a75 p.piece), std::u │ │ │ -00008260: 696e 7433 325f 7428 702e 7374 6172 7429 int32_t(p.start) │ │ │ -00008270: 2c20 7374 643a 3a75 696e 7433 325f 7428 , std::uint32_t( │ │ │ -00008280: 702e 6c65 6e67 7468 292c 2065 7272 6f72 p.length), error │ │ │ -00008290: 2e65 632e 6d65 7373 6167 6528 292e 635f .ec.message().c_ │ │ │ -000082a0: 7374 7228 2929 3b0a 0909 7d0a 2365 6e64 str());...}.#end │ │ │ -000082b0: 6966 0a0a 0909 6d5f 636f 756e 7465 7273 if....m_counters │ │ │ -000082c0: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74 .inc_stats_count │ │ │ -000082d0: 6572 2863 6f75 6e74 6572 733a 3a71 7565 er(counters::que │ │ │ -000082e0: 7565 645f 7772 6974 655f 6279 7465 732c ued_write_bytes, │ │ │ -000082f0: 202d 702e 6c65 6e67 7468 293b 0a09 096d -p.length);...m │ │ │ -00008300: 5f6f 7574 7374 616e 6469 6e67 5f77 7269 _outstanding_wri │ │ │ -00008310: 7469 6e67 5f62 7974 6573 202d 3d20 702e ting_bytes -= p. │ │ │ -00008320: 6c65 6e67 7468 3b0a 0a09 0954 4f52 5245 length;....TORRE │ │ │ -00008330: 4e54 5f41 5353 4552 5428 6d5f 6f75 7473 NT_ASSERT(m_outs │ │ │ -00008340: 7461 6e64 696e 675f 7772 6974 696e 675f tanding_writing_ │ │ │ -00008350: 6279 7465 7320 2667 743b 3d20 3029 3b0a bytes >= 0);. │ │ │ -00008360: 0a09 092f 2f20 6576 6572 7920 7065 6572 ...// every peer │ │ │ -00008370: 2069 7320 656e 7469 746c 6564 2074 6f20 is entitled to │ │ │ -00008380: 616c 6c6f 6361 7465 2061 2064 6973 6b20 allocate a disk │ │ │ -00008390: 6275 6666 6572 2069 6620 6974 2068 6173 buffer if it has │ │ │ -000083a0: 206e 6f20 7772 6974 6573 206f 7574 7374 no writes outst │ │ │ -000083b0: 616e 6469 6e67 0a09 092f 2f20 7365 6520 anding...// see │ │ │ -000083c0: 7468 6520 636f 6d6d 656e 7420 696e 2069 the comment in i │ │ │ -000083d0: 6e63 6f6d 696e 675f 7069 6563 650a 0909 ncoming_piece... │ │ │ -000083e0: 6966 2028 6d5f 6f75 7473 7461 6e64 696e if (m_outstandin │ │ │ -000083f0: 675f 7772 6974 696e 675f 6279 7465 7320 g_writing_bytes │ │ │ -00008400: 3d3d 2030 0a3c 2f70 7265 3e3c 2f74 643e == 0. │ │ │ -00008410: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00008440: 6e62 7370 3b33 3c2f 7464 3e3c 7464 3e3c nbsp;3< │ │ │ -00008450: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00008460: 7074 3a65 7870 616e 6428 3136 2922 3e2e pt:expand(16)">. │ │ │ -00008470: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ -00008480: 6374 696f 6e2e 6370 703a 3430 3232 3c2f ction.cpp:4022once │ │ │ -000084a0: 7065 6572 7320 6172 6520 7072 6f70 6572 peers are proper │ │ │ -000084b0: 6c79 2070 7574 2069 6e20 6772 6163 6566 ly put in gracef │ │ │ -000084c0: 756c 2070 6175 7365 206d 6f64 652c 2074 ul pause mode, t │ │ │ -000084d0: 6865 7920 6361 6e20 6361 6e63 656c 2061 hey can cancel a │ │ │ -000084e0: 6c6c 206f 7574 7374 616e 6469 6e67 2072 ll outstanding r │ │ │ -000084f0: 6571 7565 7374 7320 616e 6420 7468 6973 equests and this │ │ │ -00008500: 2074 6573 7420 6361 6e20 6265 2072 656d test can be rem │ │ │ -00008510: 6f76 6564 2e3c 2f74 643e 3c2f 7472 3e3c oved.< │ │ │ -00008520: 7472 2069 643d 2231 3622 2073 7479 6c65 tr id="16" style │ │ │ -00008530: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ -00008540: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">once peers are │ │ │ -00008570: 2070 726f 7065 726c 7920 7075 7420 696e properly put in │ │ │ -00008580: 2067 7261 6365 6675 6c20 7061 7573 6520 graceful pause │ │ │ -00008590: 6d6f 6465 2c20 7468 6579 2063 616e 0a63 mode, they can.c │ │ │ -000085a0: 616e 6365 6c20 616c 6c20 6f75 7473 7461 ancel all outsta │ │ │ -000085b0: 6e64 696e 6720 7265 7175 6573 7473 2061 nding requests a │ │ │ -000085c0: 6e64 2074 6869 7320 7465 7374 2063 616e nd this test can │ │ │ -000085d0: 2062 6520 7265 6d6f 7665 642e 3c2f 6832 be removed.

    ../src/peer │ │ │ -000085f0: 5f63 6f6e 6e65 6374 696f 6e2e 6370 703a _connection.cpp: │ │ │ -00008600: 3430 3232 3c2f 6834 3e3c 7072 6520 7374 4022

    ....if (!p-&g
    │ │ │ -00008650: 743b 6d5f 6465 6665 7272 6564 5f73 656e  t;m_deferred_sen
    │ │ │ -00008660: 645f 626c 6f63 6b5f 7265 7175 6573 7473  d_block_requests
    │ │ │ -00008670: 290a 0909 0909 7265 7475 726e 3b0a 0a09  ).....return;...
    │ │ │ -00008680: 0909 702d 2667 743b 6d5f 6465 6665 7272  ..p->m_deferr
    │ │ │ -00008690: 6564 5f73 656e 645f 626c 6f63 6b5f 7265  ed_send_block_re
    │ │ │ -000086a0: 7175 6573 7473 203d 2066 616c 7365 3b0a  quests = false;.
    │ │ │ -000086b0: 0909 0970 2d26 6774 3b73 656e 645f 626c  ...p->send_bl
    │ │ │ -000086c0: 6f63 6b5f 7265 7175 6573 7473 5f69 6d70  ock_requests_imp
    │ │ │ -000086d0: 6c28 293b 0a09 097d 293b 0a09 096d 5f64  l();...});...m_d
    │ │ │ -000086e0: 6566 6572 7265 645f 7365 6e64 5f62 6c6f  eferred_send_blo
    │ │ │ -000086f0: 636b 5f72 6571 7565 7374 7320 3d20 7472  ck_requests = tr
    │ │ │ -00008700: 7565 3b0a 097d 0a0a 0976 6f69 6420 7065  ue;..}...void pe
    │ │ │ -00008710: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a73  er_connection::s
    │ │ │ -00008720: 656e 645f 626c 6f63 6b5f 7265 7175 6573  end_block_reques
    │ │ │ -00008730: 7473 5f69 6d70 6c28 290a 097b 0a09 0954  ts_impl()..{...T
    │ │ │ -00008740: 4f52 5245 4e54 5f41 5353 4552 5428 6973  ORRENT_ASSERT(is
    │ │ │ -00008750: 5f73 696e 676c 655f 7468 7265 6164 2829  _single_thread()
    │ │ │ -00008760: 293b 0a09 0949 4e56 4152 4941 4e54 5f43  );...INVARIANT_C
    │ │ │ -00008770: 4845 434b 3b0a 0a09 0961 7574 6f20 7420  HECK;....auto t 
    │ │ │ -00008780: 3d20 6d5f 746f 7272 656e 742e 6c6f 636b  = m_torrent.lock
    │ │ │ -00008790: 2829 3b0a 0909 6966 2028 2174 2920 7265  ();...if (!t) re
    │ │ │ -000087a0: 7475 726e 3b0a 0a09 0969 6620 286d 5f64  turn;....if (m_d
    │ │ │ -000087b0: 6973 636f 6e6e 6563 7469 6e67 2920 7265  isconnecting) re
    │ │ │ -000087c0: 7475 726e 3b0a 0a3c 6469 7620 7374 796c  turn;..
    ..if (t-> │ │ │ -00008800: 3b67 7261 6365 6675 6c5f 7061 7573 6528 ;graceful_pause( │ │ │ -00008810: 2929 2072 6574 7572 6e3b 0a3c 2f64 6976 )) return;.
    ...// we can't │ │ │ -00008830: 646f 776e 6c6f 6164 2070 6965 6365 7320 download pieces │ │ │ -00008840: 696e 2074 6865 7365 2073 7461 7465 730a in these states. │ │ │ -00008850: 0909 6966 2028 742d 2667 743b 7374 6174 ..if (t->stat │ │ │ -00008860: 6528 2920 3d3d 2074 6f72 7265 6e74 5f73 e() == torrent_s │ │ │ -00008870: 7461 7475 733a 3a63 6865 636b 696e 675f tatus::checking_ │ │ │ -00008880: 6669 6c65 730a 0909 097c 7c20 742d 2667 files....|| t-&g │ │ │ -00008890: 743b 7374 6174 6528 2920 3d3d 2074 6f72 t;state() == tor │ │ │ -000088a0: 7265 6e74 5f73 7461 7475 733a 3a63 6865 rent_status::che │ │ │ -000088b0: 636b 696e 675f 7265 7375 6d65 5f64 6174 cking_resume_dat │ │ │ -000088c0: 610a 0909 097c 7c20 742d 2667 743b 7374 a....|| t->st │ │ │ -000088d0: 6174 6528 2920 3d3d 2074 6f72 7265 6e74 ate() == torrent │ │ │ -000088e0: 5f73 7461 7475 733a 3a64 6f77 6e6c 6f61 _status::downloa │ │ │ -000088f0: 6469 6e67 5f6d 6574 6164 6174 6129 0a09 ding_metadata).. │ │ │ -00008900: 0909 7265 7475 726e 3b0a 0a09 0969 6620 ..return;....if │ │ │ -00008910: 2869 6e74 286d 5f64 6f77 6e6c 6f61 645f (int(m_download_ │ │ │ -00008920: 7175 6575 652e 7369 7a65 2829 2920 2667 queue.size()) &g │ │ │ -00008930: 743b 3d20 6d5f 6465 7369 7265 645f 7175 t;= m_desired_qu │ │ │ -00008940: 6575 655f 7369 7a65 0a09 0909 7c7c 2074 eue_size....|| t │ │ │ -00008950: 2d26 6774 3b75 706c 6f61 645f 6d6f 6465 ->upload_mode │ │ │ -00008960: 2829 2920 7265 7475 726e 3b0a 0a09 0962 ()) return;....b │ │ │ -00008970: 6f6f 6c20 636f 6e73 7420 656d 7074 795f ool const empty_ │ │ │ -00008980: 646f 776e 6c6f 6164 5f71 7565 7565 203d download_queue = │ │ │ -00008990: 206d 5f64 6f77 6e6c 6f61 645f 7175 6575 m_download_queu │ │ │ -000089a0: 652e 656d 7074 7928 293b 0a0a 0909 7768 e.empty();....wh │ │ │ -000089b0: 696c 6520 2821 6d5f 7265 7175 6573 745f ile (!m_request_ │ │ │ -000089c0: 7175 6575 652e 656d 7074 7928 290a 0909 queue.empty()... │ │ │ -000089d0: 0926 616d 703b 2661 6d70 3b20 2869 6e74 .&& (int │ │ │ -000089e0: 286d 5f64 6f77 6e6c 6f61 645f 7175 6575 (m_download_queu │ │ │ -000089f0: 652e 7369 7a65 2829 2920 266c 743b 206d e.size()) < m │ │ │ -00008a00: 5f64 6573 6972 6564 5f71 7565 7565 5f73 _desired_queue_s │ │ │ -00008a10: 697a 650a 0909 0909 7c7c 206d 5f71 7565 ize.....|| m_que │ │ │ -00008a20: 7565 645f 7469 6d65 5f63 7269 7469 6361 ued_time_critica │ │ │ -00008a30: 6c20 2667 743b 2030 2929 0a09 097b 0a09 l > 0))...{.. │ │ │ -00008a40: 0909 7065 6e64 696e 675f 626c 6f63 6b20 ..pending_block │ │ │ -00008a50: 626c 6f63 6b20 3d20 6d5f 7265 7175 6573 block = m_reques │ │ │ -00008a60: 745f 7175 6575 652e 6672 6f6e 7428 293b t_queue.front(); │ │ │ -00008a70: 0a0a 0909 096d 5f72 6571 7565 7374 5f71 .....m_request_q │ │ │ -00008a80: 7565 7565 2e65 7261 7365 286d 5f72 6571 ueue.erase(m_req │ │ │ -00008a90: 7565 7374 5f71 7565 7565 2e62 6567 696e uest_queue.begin │ │ │ -00008aa0: 2829 293b 0a09 0909 6966 2028 6d5f 7175 ());....if (m_qu │ │ │ -00008ab0: 6575 6564 5f74 696d 655f 6372 6974 6963 eued_time_critic │ │ │ -00008ac0: 616c 2920 2d2d 6d5f 7175 6575 6564 5f74 al) --m_queued_t │ │ │ -00008ad0: 696d 655f 6372 6974 6963 616c 3b0a 0a09 ime_critical;... │ │ │ -00008ae0: 0909 2f2f 2069 6620 7765 2772 6520 6120 ..// if we're a │ │ │ -00008af0: 7365 6564 2c20 7765 2064 6f6e 2774 2068 seed, we don't h │ │ │ -00008b00: 6176 6520 6120 7069 6563 6520 7069 636b ave a piece pick │ │ │ -00008b10: 6572 0a09 0909 2f2f 2073 6f20 7765 2064 er....// so we d │ │ │ -00008b20: 6f6e 2774 2068 6176 6520 746f 2077 6f72 on't have to wor │ │ │ -00008b30: 7279 2061 626f 7574 2069 6e76 6172 6961 ry about invaria │ │ │ -00008b40: 6e74 7320 6765 7474 696e 670a 0909 092f nts getting..../ │ │ │ -00008b50: 2f20 6f75 7420 6f66 2073 796e 6320 7769 / out of sync wi │ │ │ -00008b60: 7468 2069 740a 0909 0969 6620 2821 742d th it....if (!t- │ │ │ -00008b70: 2667 743b 6861 735f 7069 636b 6572 2829 >has_picker() │ │ │ -00008b80: 2920 636f 6e74 696e 7565 3b0a 0a09 0909 ) continue;..... │ │ │ -00008b90: 2f2f 2074 6869 7320 6361 6e20 6861 7070 // this can happ │ │ │ -00008ba0: 656e 2069 6620 6120 626c 6f63 6b20 7469 en if a block ti │ │ │ -00008bb0: 6d65 7320 6f75 742c 2069 7320 7265 2d72 mes out, is re-r │ │ │ -00008bc0: 6571 7565 7374 6564 2061 6e64 0a09 0909 equested and.... │ │ │ -00008bd0: 2f2f 2074 6865 6e20 6172 7269 7665 7320 // then arrives │ │ │ -00008be0: 2275 6e65 7870 6563 7465 646c 7922 0a09 "unexpectedly".. │ │ │ -00008bf0: 0909 6966 2028 742d 2667 743b 7069 636b ..if (t->pick │ │ │ -00008c00: 6572 2829 2e69 735f 646f 776e 6c6f 6164 er().is_download │ │ │ -00008c10: 6564 2862 6c6f 636b 2e62 6c6f 636b 2929 ed(block.block)) │ │ │ -00008c20: 0a09 0909 7b0a 3c2f 7072 653e 3c2f 7464 ....{.
    relevance │ │ │ -00008c60: 266e 6273 703b 333c 2f74 643e 3c74 643e  3 │ │ │ -00008c70: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ -00008c90: 2e2e 2f73 7263 2f70 6565 725f 636f 6e6e ../src/peer_conn │ │ │ -00008ca0: 6563 7469 6f6e 2e63 7070 3a34 3730 333c ection.cpp:4703< │ │ │ -00008cb0: 2f61 3e3c 2f74 643e 3c74 643e 6e65 775f /a>new_ │ │ │ -00008cc0: 7069 6563 6520 7368 6f75 6c64 2062 6520 piece should be │ │ │ -00008cd0: 616e 206f 7074 696f 6e61 6c3c 7069 6563 an optional. piec │ │ │ -00008cf0: 6520 696e 6465 7820 2d31 2073 686f 756c e index -1 shoul │ │ │ -00008d00: 6420 6e6f 7420 6265 2061 6c6c 6f77 6564 d not be allowed │ │ │ -00008d10: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    new │ │ │ -00008d60: 5f70 6965 6365 2073 686f 756c 6420 6265 _piece should be │ │ │ -00008d70: 2061 6e20 6f70 7469 6f6e 616c 3c70 6965 an optional. pie │ │ │ -00008d90: 6365 2069 6e64 6578 202d 310a 7368 6f75 ce index -1.shou │ │ │ -00008da0: 6c64 206e 6f74 2062 6520 616c 6c6f 7765 ld not be allowe │ │ │ -00008db0: 643c 2f68 323e 3c68 343e 2e2e 2f73 7263 d

    ../src │ │ │ -00008dc0: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e /peer_connection │ │ │ -00008dd0: 2e63 7070 3a34 3730 333c 2f68 343e 3c70 .cpp:4703

    ...// pi │ │ │ -00008e20: 6563 6573 206d 6179 2062 6520 656d 7074 eces may be empt │ │ │ -00008e30: 7920 6966 2077 6520 646f 6e27 7420 6861 y if we don't ha │ │ │ -00008e40: 7665 206d 6574 6164 6174 6120 7965 740a ve metadata yet. │ │ │ -00008e50: 0909 6966 2028 702e 7069 6563 6573 2e65 ..if (p.pieces.e │ │ │ -00008e60: 6d70 7479 2829 290a 0909 7b0a 0909 0970 mpty())...{....p │ │ │ -00008e70: 2e70 726f 6772 6573 7320 3d20 302e 663b .progress = 0.f; │ │ │ -00008e80: 0a09 0909 702e 7072 6f67 7265 7373 5f70 ....p.progress_p │ │ │ -00008e90: 706d 203d 2030 3b0a 0909 7d0a 0909 656c pm = 0;...}...el │ │ │ -00008ea0: 7365 0a09 097b 0a23 6966 2054 4f52 5245 se...{.#if TORRE │ │ │ -00008eb0: 4e54 5f4e 4f5f 4650 550a 0909 0970 2e70 NT_NO_FPU....p.p │ │ │ -00008ec0: 726f 6772 6573 7320 3d20 302e 663b 0a23 rogress = 0.f;.# │ │ │ -00008ed0: 656c 7365 0a09 0909 702e 7072 6f67 7265 else....p.progre │ │ │ -00008ee0: 7373 203d 2066 6c6f 6174 2870 2e70 6965 ss = float(p.pie │ │ │ -00008ef0: 6365 732e 636f 756e 7428 2929 202f 2066 ces.count()) / f │ │ │ -00008f00: 6c6f 6174 2870 2e70 6965 6365 732e 7369 loat(p.pieces.si │ │ │ -00008f10: 7a65 2829 293b 0a23 656e 6469 660a 0909 ze());.#endif... │ │ │ -00008f20: 0970 2e70 726f 6772 6573 735f 7070 6d20 .p.progress_ppm │ │ │ -00008f30: 3d20 696e 7428 7374 643a 3a69 6e74 3634 = int(std::int64 │ │ │ -00008f40: 5f74 2870 2e70 6965 6365 732e 636f 756e _t(p.pieces.coun │ │ │ -00008f50: 7428 2929 202a 2031 3030 3030 3030 202f t()) * 1000000 / │ │ │ -00008f60: 2070 2e70 6965 6365 732e 7369 7a65 2829 p.pieces.size() │ │ │ -00008f70: 293b 0a09 097d 0a0a 097d 0a0a 2369 666e );...}...}..#ifn │ │ │ -00008f80: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -00008f90: 424c 455f 5355 5045 5253 4545 4449 4e47 BLE_SUPERSEEDING │ │ │ -00008fa0: 0a3c 6469 7620 7374 796c 653d 2262 6163 .

    . │ │ │ -00008fd0: 766f 6964 2070 6565 725f 636f 6e6e 6563 void peer_connec │ │ │ -00008fe0: 7469 6f6e 3a3a 7375 7065 7273 6565 645f tion::superseed_ │ │ │ -00008ff0: 7069 6563 6528 7069 6563 655f 696e 6465 piece(piece_inde │ │ │ -00009000: 785f 7420 636f 6e73 7420 7265 706c 6163 x_t const replac │ │ │ -00009010: 655f 7069 6563 650a 3c2f 6469 763e 0909 e_piece.
    .. │ │ │ -00009020: 2c20 7069 6563 655f 696e 6465 785f 7420 , piece_index_t │ │ │ -00009030: 636f 6e73 7420 6e65 775f 7069 6563 6529 const new_piece) │ │ │ -00009040: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ -00009050: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ -00009060: 6872 6561 6428 2929 3b0a 0a09 0969 6620 hread());....if │ │ │ -00009070: 2869 735f 636f 6e6e 6563 7469 6e67 2829 (is_connecting() │ │ │ -00009080: 2920 7265 7475 726e 3b0a 0909 6966 2028 ) return;...if ( │ │ │ -00009090: 696e 5f68 616e 6473 6861 6b65 2829 2920 in_handshake()) │ │ │ -000090a0: 7265 7475 726e 3b0a 0a09 0969 6620 286e return;....if (n │ │ │ -000090b0: 6577 5f70 6965 6365 203d 3d20 7069 6563 ew_piece == piec │ │ │ -000090c0: 655f 696e 6465 785f 7428 2d31 2929 0a09 e_index_t(-1)).. │ │ │ -000090d0: 097b 0a09 0909 6966 2028 6d5f 7375 7065 .{....if (m_supe │ │ │ -000090e0: 7273 6565 645f 7069 6563 655b 305d 203d rseed_piece[0] = │ │ │ -000090f0: 3d20 7069 6563 655f 696e 6465 785f 7428 = piece_index_t( │ │ │ -00009100: 2d31 2929 2072 6574 7572 6e3b 0a09 0909 -1)) return;.... │ │ │ -00009110: 6d5f 7375 7065 7273 6565 645f 7069 6563 m_superseed_piec │ │ │ -00009120: 655b 305d 203d 2070 6965 6365 5f69 6e64 e[0] = piece_ind │ │ │ -00009130: 6578 5f74 282d 3129 3b0a 0909 096d 5f73 ex_t(-1);....m_s │ │ │ -00009140: 7570 6572 7365 6564 5f70 6965 6365 5b31 uperseed_piece[1 │ │ │ -00009150: 5d20 3d20 7069 6563 655f 696e 6465 785f ] = piece_index_ │ │ │ -00009160: 7428 2d31 293b 0a0a 2369 666e 6465 6620 t(-1);..#ifndef │ │ │ -00009170: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00009180: 4c4f 4747 494e 470a 0909 0970 6565 725f LOGGING....peer_ │ │ │ -00009190: 6c6f 6728 7065 6572 5f6c 6f67 5f61 6c65 log(peer_log_ale │ │ │ -000091a0: 7274 3a3a 696e 666f 2c20 7065 6572 5f6c rt::info, peer_l │ │ │ -000091b0: 6f67 5f61 6c65 7274 3a3a 7375 7065 725f og_alert::super_ │ │ │ -000091c0: 7365 6564 696e 672c 2022 656e 6469 6e67 seeding, "ending │ │ │ -000091d0: 2229 3b0a 2365 6e64 6966 0a09 0909 6175 ");.#endif....au │ │ │ -000091e0: 746f 2074 203d 206d 5f74 6f72 7265 6e74 to t = m_torrent │ │ │ -000091f0: 2e6c 6f63 6b28 293b 0a09 0909 544f 5252 .lock();....TORR │ │ │ -00009200: 454e 545f 4153 5345 5254 2874 293b 0a0a ENT_ASSERT(t);.. │ │ │ -00009210: 0909 092f 2f20 7468 6973 2077 696c 6c20 ...// this will │ │ │ -00009220: 6569 7468 6572 2073 656e 6420 6120 6675 either send a fu │ │ │ -00009230: 6c6c 2062 6974 6669 656c 6420 6f72 0a09 ll bitfield or.. │ │ │ -00009240: 0909 2f2f 2061 2068 6176 652d 616c 6c20 ..// a have-all │ │ │ -00009250: 6d65 7373 6167 652c 2065 6666 6563 7469 message, effecti │ │ │ -00009260: 7665 6c79 2074 6572 6d69 6e61 7469 6e67 vely terminating │ │ │ -00009270: 0a09 0909 2f2f 2073 7570 6572 2d73 6565 ....// super-see │ │ │ -00009280: 6469 6e67 2c20 7369 6e63 6520 7468 6520 ding, since the │ │ │ -00009290: 7065 6572 206d 6179 2070 6963 6b20 616e peer may pick an │ │ │ -000092a0: 7920 7069 6563 650a 0909 0977 7269 7465 y piece....write │ │ │ -000092b0: 5f62 6974 6669 656c 6428 293b 0a0a 0909 _bitfield();.... │ │ │ -000092c0: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909 .return;...}.... │ │ │ -000092d0: 544f 5252 454e 545f 4153 5345 5254 2821 TORRENT_ASSERT(! │ │ │ -000092e0: 6861 735f 7069 6563 6528 6e65 775f 7069 has_piece(new_pi │ │ │ -000092f0: 6563 6529 293b 0a0a 2369 666e 6465 6620 ece));..#ifndef │ │ │ -00009300: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00009310: 4c4f 4747 494e 470a 3c2f 7072 653e 3c2f LOGGING.relevan │ │ │ -00009350: 6365 266e 6273 703b 333c 2f74 643e 3c74 ce 3
    ../src/session │ │ │ -00009390: 5f69 6d70 6c2e 6370 703a 3131 3035 3c2f _impl.cpp:1105closi │ │ │ -000093b0: 6e67 2074 6865 2075 6470 2073 6f63 6b65 ng the udp socke │ │ │ -000093c0: 7473 2068 6572 6520 6d65 616e 7320 7468 ts here means th │ │ │ -000093d0: 6174 2074 6865 2075 5450 2063 6f6e 6e65 at the uTP conne │ │ │ -000093e0: 6374 696f 6e73 2063 616e 6e6f 7420 6265 ctions cannot be │ │ │ -000093f0: 2063 6c6f 7365 6420 6772 6163 6566 756c closed graceful │ │ │ -00009400: 6c79 3c2f 7464 3e3c 2f74 723e 3c74 7220 ly

    c │ │ │ -00009450: 6c6f 7369 6e67 2074 6865 2075 6470 2073 losing the udp s │ │ │ -00009460: 6f63 6b65 7473 2068 6572 6520 6d65 616e ockets here mean │ │ │ -00009470: 7320 7468 6174 0a74 6865 2075 5450 2063 s that.the uTP c │ │ │ -00009480: 6f6e 6e65 6374 696f 6e73 2063 616e 6e6f onnections canno │ │ │ -00009490: 7420 6265 2063 6c6f 7365 6420 6772 6163 t be closed grac │ │ │ -000094a0: 6566 756c 6c79 3c2f 6832 3e3c 6834 3e2e efully

    . │ │ │ -000094b0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -000094c0: 706c 2e63 7070 3a31 3130 353c 2f68 343e pl.cpp:1105

    │ │ │ -000094d0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    #ifnde
    │ │ │ -00009510: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ -00009520: 455f 4c4f 4747 494e 470a 0909 7365 7373  E_LOGGING...sess
    │ │ │ -00009530: 696f 6e5f 6c6f 6728 2220 6162 6f72 7469  ion_log(" aborti
    │ │ │ -00009540: 6e67 2061 6c6c 2063 6f6e 6e65 6374 696f  ng all connectio
    │ │ │ -00009550: 6e73 2028 2564 2922 2c20 696e 7428 6d5f  ns (%d)", int(m_
    │ │ │ -00009560: 636f 6e6e 6563 7469 6f6e 732e 7369 7a65  connections.size
    │ │ │ -00009570: 2829 2929 3b0a 2365 6e64 6966 0a09 092f  ()));.#endif.../
    │ │ │ -00009580: 2f20 6162 6f72 7420 616c 6c20 636f 6e6e  / abort all conn
    │ │ │ -00009590: 6563 7469 6f6e 730a 0909 666f 7220 2861  ections...for (a
    │ │ │ -000095a0: 7574 6f20 6920 3d20 6d5f 636f 6e6e 6563  uto i = m_connec
    │ │ │ -000095b0: 7469 6f6e 732e 6265 6769 6e28 293b 2069  tions.begin(); i
    │ │ │ -000095c0: 2021 3d20 6d5f 636f 6e6e 6563 7469 6f6e   != m_connection
    │ │ │ -000095d0: 732e 656e 6428 293b 290a 0909 7b0a 0909  s.end();)...{...
    │ │ │ -000095e0: 0970 6565 725f 636f 6e6e 6563 7469 6f6e  .peer_connection
    │ │ │ -000095f0: 2a20 7020 3d20 282a 6929 2e67 6574 2829  * p = (*i).get()
    │ │ │ -00009600: 3b0a 0909 092b 2b69 3b0a 0909 0970 2d26  ;....++i;....p-&
    │ │ │ -00009610: 6774 3b64 6973 636f 6e6e 6563 7428 6572  gt;disconnect(er
    │ │ │ -00009620: 726f 7273 3a3a 7374 6f70 7069 6e67 5f74  rors::stopping_t
    │ │ │ -00009630: 6f72 7265 6e74 2c20 6f70 6572 6174 696f  orrent, operatio
    │ │ │ -00009640: 6e5f 743a 3a62 6974 746f 7272 656e 7429  n_t::bittorrent)
    │ │ │ -00009650: 3b0a 0909 7d0a 0a09 092f 2f20 636c 6f73  ;...}....// clos
    │ │ │ -00009660: 6520 7468 6520 6c69 7374 656e 2073 6f63  e the listen soc
    │ │ │ -00009670: 6b65 7473 0a09 0966 6f72 2028 6175 746f  kets...for (auto
    │ │ │ -00009680: 2063 6f6e 7374 2661 6d70 3b20 6c20 3a20   const& l : 
    │ │ │ -00009690: 6d5f 6c69 7374 656e 5f73 6f63 6b65 7473  m_listen_sockets
    │ │ │ -000096a0: 290a 0909 7b0a 0909 0969 6620 286c 2d26  )...{....if (l-&
    │ │ │ -000096b0: 6774 3b73 6f63 6b29 0a09 0909 7b0a 0909  gt;sock)....{...
    │ │ │ -000096c0: 0909 6c2d 2667 743b 736f 636b 2d26 6774  ..l->sock->
    │ │ │ -000096d0: 3b63 6c6f 7365 2865 6329 3b0a 0909 0909  ;close(ec);.....
    │ │ │ -000096e0: 544f 5252 454e 545f 4153 5345 5254 2821  TORRENT_ASSERT(!
    │ │ │ -000096f0: 6563 293b 0a09 0909 7d0a 0a3c 6469 7620  ec);....}..
    ...if ( │ │ │ -00009730: 6c2d 2667 743b 7564 705f 736f 636b 290a l->udp_sock). │ │ │ -00009740: 3c2f 6469 763e 0909 097b 0a09 0909 096c
    ...{.....l │ │ │ -00009750: 2d26 6774 3b75 6470 5f73 6f63 6b2d 2667 ->udp_sock-&g │ │ │ -00009760: 743b 736f 636b 2e63 6c6f 7365 2829 3b0a t;sock.close();. │ │ │ -00009770: 0909 097d 0a09 097d 0a0a 0909 2f2f 2077 ...}...}....// w │ │ │ -00009780: 6520 6e65 6564 2074 6f20 6769 7665 2061 e need to give a │ │ │ -00009790: 6c6c 2074 6865 2073 6f63 6b65 7473 2061 ll the sockets a │ │ │ -000097a0: 6e20 6f70 706f 7274 756e 6974 7920 746f n opportunity to │ │ │ -000097b0: 2061 6374 7561 6c6c 7920 6861 7665 2074 actually have t │ │ │ -000097c0: 6865 6972 2068 616e 646c 6572 730a 0909 heir handlers... │ │ │ -000097d0: 2f2f 2063 616c 6c65 6420 616e 6420 6361 // called and ca │ │ │ -000097e0: 6e63 656c 6c65 6420 6265 666f 7265 2077 ncelled before w │ │ │ -000097f0: 6520 636f 6e74 696e 7565 2074 6865 2073 e continue the s │ │ │ -00009800: 6875 7464 6f77 6e2e 2054 6869 7320 6973 hutdown. This is │ │ │ -00009810: 2061 2062 6974 0a09 092f 2f20 636f 6d70 a bit...// comp │ │ │ -00009820: 6c69 6361 7465 642c 2069 6620 7468 6572 licated, if ther │ │ │ -00009830: 6520 6172 6520 6e6f 2022 756e 6465 6164 e are no "undead │ │ │ -00009840: 2220 7065 6572 732c 2069 7427 7320 7361 " peers, it's sa │ │ │ -00009850: 6665 2074 6f20 7265 7375 6d65 2074 6865 fe to resume the │ │ │ -00009860: 0a09 092f 2f20 7368 7574 646f 776e 2c20 ...// shutdown, │ │ │ -00009870: 6275 7420 6966 2074 6865 7265 2061 7265 but if there are │ │ │ -00009880: 2c20 7765 2068 6176 6520 746f 2077 6169 , we have to wai │ │ │ -00009890: 7420 666f 7220 7468 656d 2074 6f20 6265 t for them to be │ │ │ -000098a0: 2063 6c65 6172 6564 206f 7574 0a09 092f cleared out.../ │ │ │ -000098b0: 2f20 6669 7273 742e 2049 6e20 7365 7373 / first. In sess │ │ │ -000098c0: 696f 6e5f 696d 706c 3a3a 6f6e 5f74 6963 ion_impl::on_tic │ │ │ -000098d0: 6b28 2920 7765 2063 6865 636b 2074 6865 k() we check the │ │ │ -000098e0: 6d20 7065 7269 6f64 6963 616c 6c79 2e20 m periodically. │ │ │ -000098f0: 4966 2077 6527 7265 0a09 092f 2f20 7368 If we're...// sh │ │ │ -00009900: 7574 7469 6e67 2064 6f77 6e20 616e 6420 utting down and │ │ │ -00009910: 7765 2072 656d 6f76 6520 7468 6520 6c61 we remove the la │ │ │ -00009920: 7374 206f 6e65 2c20 7765 276c 6c20 696e st one, we'll in │ │ │ -00009930: 6974 6961 7465 0a09 092f 2f20 7368 7574 itiate...// shut │ │ │ -00009940: 646f 776e 5f73 7461 6765 3220 6672 6f6d down_stage2 from │ │ │ -00009950: 2074 6865 7265 2e0a 0909 6966 2028 6d5f there....if (m_ │ │ │ -00009960: 756e 6465 6164 5f70 6565 7273 2e65 6d70 undead_peers.emp │ │ │ -00009970: 7479 2829 290a 0909 7b0a 0909 0970 6f73 ty())...{....pos │ │ │ -00009980: 7428 6d5f 696f 5f63 6f6e 7465 7874 2c20 t(m_io_context, │ │ │ -00009990: 6d61 6b65 5f68 616e 646c 6572 285b 7468 make_handler([th │ │ │ -000099a0: 6973 5d20 7b20 6162 6f72 745f 7374 6167 is] { abort_stag │ │ │ -000099b0: 6532 2829 3b20 7d0a 0909 0909 2c20 6d5f e2(); }....., m_ │ │ │ -000099c0: 6162 6f72 745f 6861 6e64 6c65 725f 7374 abort_handler_st │ │ │ -000099d0: 6f72 6167 652c 202a 7468 6973 2929 3b0a orage, *this));. │ │ │ -000099e0: 0909 7d0a 097d 0a0a 0976 6f69 6420 7365 ..}..}...void se │ │ │ -000099f0: 7373 696f 6e5f 696d 706c 3a3a 6162 6f72 ssion_impl::abor │ │ │ -00009a00: 745f 7374 6167 6532 2829 206e 6f65 7863 t_stage2() noexc │ │ │ -00009a10: 6570 740a 097b 0a09 096d 5f64 6f77 6e6c ept..{...m_downl │ │ │ -00009a20: 6f61 645f 7261 7465 2e63 6c6f 7365 2829 oad_rate.close() │ │ │ -00009a30: 3b0a 0909 6d5f 7570 6c6f 6164 5f72 6174 ;...m_upload_rat │ │ │ -00009a40: 652e 636c 6f73 6528 293b 0a0a 0909 2f2f e.close();....// │ │ │ -00009a50: 2069 7427 7320 4f4b 2074 6f20 6465 7461 it's OK to deta │ │ │ -00009a60: 6368 2074 6865 2074 6872 6561 6473 2068 ch the threads h │ │ │ -00009a70: 6572 652e 2054 6865 2064 6973 6b5f 696f ere. The disk_io │ │ │ -00009a80: 5f74 6872 6561 640a 0909 2f2f 2068 6173 _thread...// has │ │ │ -00009a90: 2061 6e20 696e 7465 726e 616c 2063 6f75 an internal cou │ │ │ -00009aa0: 6e74 6572 2061 6e64 2077 6f6e 2774 2072 nter and won't r │ │ │ -00009ab0: 656c 6561 7365 2074 6865 206e 6574 776f elease the netwo │ │ │ -00009ac0: 726b 0a09 092f 2f20 7468 7265 6164 2075 rk...// thread u │ │ │ -00009ad0: 6e74 696c 2074 6865 7927 7265 2061 6c6c ntil they're all │ │ │ -00009ae0: 2064 6561 6420 2876 6961 206d 5f77 6f72 dead (via m_wor │ │ │ -00009af0: 6b29 2e0a 0909 6d5f 6469 736b 5f74 6872 k)....m_disk_thr │ │ │ -00009b00: 6561 642d 2667 743b 6162 6f72 7428 6661 ead->abort(fa │ │ │ -00009b10: 6c73 6529 3b0a 0a09 092f 2f20 6e6f 7720 lse);....// now │ │ │ -00009b20: 6974 2773 204f 4b20 666f 7220 7468 6520 it's OK for the │ │ │ -00009b30: 6e65 7477 6f72 6b20 7468 7265 6164 2074 network thread t │ │ │ -00009b40: 6f20 6578 6974 0a3c 2f70 7265 3e3c 2f74 o exit.
    relevanc │ │ │ -00009b80: 6526 6e62 7370 3b33 3c2f 7464 3e3c 7464 e 3../src/session_ │ │ │ -00009bc0: 696d 706c 2e63 7070 3a31 3631 303c 2f61 impl.cpp:1610the lo │ │ │ -00009be0: 6769 6320 696e 2074 6869 7320 6966 2d62 gic in this if-b │ │ │ -00009bf0: 6c6f 636b 2073 686f 756c 6420 6265 2066 lock should be f │ │ │ -00009c00: 6163 746f 7265 6420 6f75 7420 696e 746f actored out into │ │ │ -00009c10: 2061 2073 6570 6172 6174 6520 6675 6e63 a separate func │ │ │ -00009c20: 7469 6f6e 2e20 4174 206c 6561 7374 206d tion. At least m │ │ │ -00009c30: 6f73 7420 6f66 2069 743c 2f74 643e 3c2f ost of it │ │ │ +00004680: 3c2f 7464 3e3c 7464 3e63 6c6f 7369 6e67 closing │ │ │ +00004690: 2074 6865 2075 6470 2073 6f63 6b65 7473 the udp sockets │ │ │ +000046a0: 2068 6572 6520 6d65 616e 7320 7468 6174 here means that │ │ │ +000046b0: 2074 6865 2075 5450 2063 6f6e 6e65 6374 the uTP connect │ │ │ +000046c0: 696f 6e73 2063 616e 6e6f 7420 6265 2063 ions cannot be c │ │ │ +000046d0: 6c6f 7365 6420 6772 6163 6566 756c 6c79 losed gracefully │ │ │ +000046e0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    clos │ │ │ +00004730: 696e 6720 7468 6520 7564 7020 736f 636b ing the udp sock │ │ │ +00004740: 6574 7320 6865 7265 206d 6561 6e73 2074 ets here means t │ │ │ +00004750: 6861 740a 7468 6520 7554 5020 636f 6e6e hat.the uTP conn │ │ │ +00004760: 6563 7469 6f6e 7320 6361 6e6e 6f74 2062 ections cannot b │ │ │ +00004770: 6520 636c 6f73 6564 2067 7261 6365 6675 e closed gracefu │ │ │ +00004780: 6c6c 793c 2f68 323e 3c68 343e 2e2e 2f73 lly

    ../s │ │ │ +00004790: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +000047a0: 6370 703a 3131 3035 3c2f 6834 3e3c 7072 cpp:1105

    #ifndef T │ │ │ +000047f0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ +00004800: 4f47 4749 4e47 0a09 0973 6573 7369 6f6e OGGING...session │ │ │ +00004810: 5f6c 6f67 2822 2061 626f 7274 696e 6720 _log(" aborting │ │ │ +00004820: 616c 6c20 636f 6e6e 6563 7469 6f6e 7320 all connections │ │ │ +00004830: 2825 6429 222c 2069 6e74 286d 5f63 6f6e (%d)", int(m_con │ │ │ +00004840: 6e65 6374 696f 6e73 2e73 697a 6528 2929 nections.size()) │ │ │ +00004850: 293b 0a23 656e 6469 660a 0909 2f2f 2061 );.#endif...// a │ │ │ +00004860: 626f 7274 2061 6c6c 2063 6f6e 6e65 6374 bort all connect │ │ │ +00004870: 696f 6e73 0a09 0966 6f72 2028 6175 746f ions...for (auto │ │ │ +00004880: 2069 203d 206d 5f63 6f6e 6e65 6374 696f i = m_connectio │ │ │ +00004890: 6e73 2e62 6567 696e 2829 3b20 6920 213d ns.begin(); i != │ │ │ +000048a0: 206d 5f63 6f6e 6e65 6374 696f 6e73 2e65 m_connections.e │ │ │ +000048b0: 6e64 2829 3b29 0a09 097b 0a09 0909 7065 nd();)...{....pe │ │ │ +000048c0: 6572 5f63 6f6e 6e65 6374 696f 6e2a 2070 er_connection* p │ │ │ +000048d0: 203d 2028 2a69 292e 6765 7428 293b 0a09 = (*i).get();.. │ │ │ +000048e0: 0909 2b2b 693b 0a09 0909 702d 2667 743b ..++i;....p-> │ │ │ +000048f0: 6469 7363 6f6e 6e65 6374 2865 7272 6f72 disconnect(error │ │ │ +00004900: 733a 3a73 746f 7070 696e 675f 746f 7272 s::stopping_torr │ │ │ +00004910: 656e 742c 206f 7065 7261 7469 6f6e 5f74 ent, operation_t │ │ │ +00004920: 3a3a 6269 7474 6f72 7265 6e74 293b 0a09 ::bittorrent);.. │ │ │ +00004930: 097d 0a0a 0909 2f2f 2063 6c6f 7365 2074 .}....// close t │ │ │ +00004940: 6865 206c 6973 7465 6e20 736f 636b 6574 he listen socket │ │ │ +00004950: 730a 0909 666f 7220 2861 7574 6f20 636f s...for (auto co │ │ │ +00004960: 6e73 7426 616d 703b 206c 203a 206d 5f6c nst& l : m_l │ │ │ +00004970: 6973 7465 6e5f 736f 636b 6574 7329 0a09 isten_sockets).. │ │ │ +00004980: 097b 0a09 0909 6966 2028 6c2d 2667 743b .{....if (l-> │ │ │ +00004990: 736f 636b 290a 0909 097b 0a09 0909 096c sock)....{.....l │ │ │ +000049a0: 2d26 6774 3b73 6f63 6b2d 2667 743b 636c ->sock->cl │ │ │ +000049b0: 6f73 6528 6563 293b 0a09 0909 0954 4f52 ose(ec);.....TOR │ │ │ +000049c0: 5245 4e54 5f41 5353 4552 5428 2165 6329 RENT_ASSERT(!ec) │ │ │ +000049d0: 3b0a 0909 097d 0a0a 3c64 6976 2073 7479 ;....}..
    ...if (l-& │ │ │ +00004a10: 6774 3b75 6470 5f73 6f63 6b29 0a3c 2f64 gt;udp_sock)....{.....l-&g │ │ │ +00004a30: 743b 7564 705f 736f 636b 2d26 6774 3b73 t;udp_sock->s │ │ │ +00004a40: 6f63 6b2e 636c 6f73 6528 293b 0a09 0909 ock.close();.... │ │ │ +00004a50: 7d0a 0909 7d0a 0a09 092f 2f20 7765 206e }...}....// we n │ │ │ +00004a60: 6565 6420 746f 2067 6976 6520 616c 6c20 eed to give all │ │ │ +00004a70: 7468 6520 736f 636b 6574 7320 616e 206f the sockets an o │ │ │ +00004a80: 7070 6f72 7475 6e69 7479 2074 6f20 6163 pportunity to ac │ │ │ +00004a90: 7475 616c 6c79 2068 6176 6520 7468 6569 tually have thei │ │ │ +00004aa0: 7220 6861 6e64 6c65 7273 0a09 092f 2f20 r handlers...// │ │ │ +00004ab0: 6361 6c6c 6564 2061 6e64 2063 616e 6365 called and cance │ │ │ +00004ac0: 6c6c 6564 2062 6566 6f72 6520 7765 2063 lled before we c │ │ │ +00004ad0: 6f6e 7469 6e75 6520 7468 6520 7368 7574 ontinue the shut │ │ │ +00004ae0: 646f 776e 2e20 5468 6973 2069 7320 6120 down. This is a │ │ │ +00004af0: 6269 740a 0909 2f2f 2063 6f6d 706c 6963 bit...// complic │ │ │ +00004b00: 6174 6564 2c20 6966 2074 6865 7265 2061 ated, if there a │ │ │ +00004b10: 7265 206e 6f20 2275 6e64 6561 6422 2070 re no "undead" p │ │ │ +00004b20: 6565 7273 2c20 6974 2773 2073 6166 6520 eers, it's safe │ │ │ +00004b30: 746f 2072 6573 756d 6520 7468 650a 0909 to resume the... │ │ │ +00004b40: 2f2f 2073 6875 7464 6f77 6e2c 2062 7574 // shutdown, but │ │ │ +00004b50: 2069 6620 7468 6572 6520 6172 652c 2077 if there are, w │ │ │ +00004b60: 6520 6861 7665 2074 6f20 7761 6974 2066 e have to wait f │ │ │ +00004b70: 6f72 2074 6865 6d20 746f 2062 6520 636c or them to be cl │ │ │ +00004b80: 6561 7265 6420 6f75 740a 0909 2f2f 2066 eared out...// f │ │ │ +00004b90: 6972 7374 2e20 496e 2073 6573 7369 6f6e irst. In session │ │ │ +00004ba0: 5f69 6d70 6c3a 3a6f 6e5f 7469 636b 2829 _impl::on_tick() │ │ │ +00004bb0: 2077 6520 6368 6563 6b20 7468 656d 2070 we check them p │ │ │ +00004bc0: 6572 696f 6469 6361 6c6c 792e 2049 6620 eriodically. If │ │ │ +00004bd0: 7765 2772 650a 0909 2f2f 2073 6875 7474 we're...// shutt │ │ │ +00004be0: 696e 6720 646f 776e 2061 6e64 2077 6520 ing down and we │ │ │ +00004bf0: 7265 6d6f 7665 2074 6865 206c 6173 7420 remove the last │ │ │ +00004c00: 6f6e 652c 2077 6527 6c6c 2069 6e69 7469 one, we'll initi │ │ │ +00004c10: 6174 650a 0909 2f2f 2073 6875 7464 6f77 ate...// shutdow │ │ │ +00004c20: 6e5f 7374 6167 6532 2066 726f 6d20 7468 n_stage2 from th │ │ │ +00004c30: 6572 652e 0a09 0969 6620 286d 5f75 6e64 ere....if (m_und │ │ │ +00004c40: 6561 645f 7065 6572 732e 656d 7074 7928 ead_peers.empty( │ │ │ +00004c50: 2929 0a09 097b 0a09 0909 706f 7374 286d ))...{....post(m │ │ │ +00004c60: 5f69 6f5f 636f 6e74 6578 742c 206d 616b _io_context, mak │ │ │ +00004c70: 655f 6861 6e64 6c65 7228 5b74 6869 735d e_handler([this] │ │ │ +00004c80: 207b 2061 626f 7274 5f73 7461 6765 3228 { abort_stage2( │ │ │ +00004c90: 293b 207d 0a09 0909 092c 206d 5f61 626f ); }....., m_abo │ │ │ +00004ca0: 7274 5f68 616e 646c 6572 5f73 746f 7261 rt_handler_stora │ │ │ +00004cb0: 6765 2c20 2a74 6869 7329 293b 0a09 097d ge, *this));...} │ │ │ +00004cc0: 0a09 7d0a 0a09 766f 6964 2073 6573 7369 ..}...void sessi │ │ │ +00004cd0: 6f6e 5f69 6d70 6c3a 3a61 626f 7274 5f73 on_impl::abort_s │ │ │ +00004ce0: 7461 6765 3228 2920 6e6f 6578 6365 7074 tage2() noexcept │ │ │ +00004cf0: 0a09 7b0a 0909 6d5f 646f 776e 6c6f 6164 ..{...m_download │ │ │ +00004d00: 5f72 6174 652e 636c 6f73 6528 293b 0a09 _rate.close();.. │ │ │ +00004d10: 096d 5f75 706c 6f61 645f 7261 7465 2e63 .m_upload_rate.c │ │ │ +00004d20: 6c6f 7365 2829 3b0a 0a09 092f 2f20 6974 lose();....// it │ │ │ +00004d30: 2773 204f 4b20 746f 2064 6574 6163 6820 's OK to detach │ │ │ +00004d40: 7468 6520 7468 7265 6164 7320 6865 7265 the threads here │ │ │ +00004d50: 2e20 5468 6520 6469 736b 5f69 6f5f 7468 . The disk_io_th │ │ │ +00004d60: 7265 6164 0a09 092f 2f20 6861 7320 616e read...// has an │ │ │ +00004d70: 2069 6e74 6572 6e61 6c20 636f 756e 7465 internal counte │ │ │ +00004d80: 7220 616e 6420 776f 6e27 7420 7265 6c65 r and won't rele │ │ │ +00004d90: 6173 6520 7468 6520 6e65 7477 6f72 6b0a ase the network. │ │ │ +00004da0: 0909 2f2f 2074 6872 6561 6420 756e 7469 ..// thread unti │ │ │ +00004db0: 6c20 7468 6579 2772 6520 616c 6c20 6465 l they're all de │ │ │ +00004dc0: 6164 2028 7669 6120 6d5f 776f 726b 292e ad (via m_work). │ │ │ +00004dd0: 0a09 096d 5f64 6973 6b5f 7468 7265 6164 ...m_disk_thread │ │ │ +00004de0: 2d26 6774 3b61 626f 7274 2866 616c 7365 ->abort(false │ │ │ +00004df0: 293b 0a0a 0909 2f2f 206e 6f77 2069 7427 );....// now it' │ │ │ +00004e00: 7320 4f4b 2066 6f72 2074 6865 206e 6574 s OK for the net │ │ │ +00004e10: 776f 726b 2074 6872 6561 6420 746f 2065 work thread to e │ │ │ +00004e20: 7869 740a 3c2f 7072 653e 3c2f 7464 3e3c xit.< │ │ │ +00004e30: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00004e60: 6273 703b 333c 2f74 643e 3c74 643e 3c61 bsp;3.. │ │ │ +00004e90: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +00004ea0: 6c2e 6370 703a 3136 3130 3c2f 613e 3c2f l.cpp:1610the logic │ │ │ +00004ec0: 2069 6e20 7468 6973 2069 662d 626c 6f63 in this if-bloc │ │ │ +00004ed0: 6b20 7368 6f75 6c64 2062 6520 6661 6374 k should be fact │ │ │ +00004ee0: 6f72 6564 206f 7574 2069 6e74 6f20 6120 ored out into a │ │ │ +00004ef0: 7365 7061 7261 7465 2066 756e 6374 696f separate functio │ │ │ +00004f00: 6e2e 2041 7420 6c65 6173 7420 6d6f 7374 n. At least most │ │ │ +00004f10: 206f 6620 6974 3c2f 7464 3e3c 2f74 723e of it │ │ │ +00004f20: 3c74 7220 6964 3d22 3130 2220 7374 796c < │ │ │ +00004f50: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00004f60: 6832 3e74 6865 206c 6f67 6963 2069 6e20 h2>the logic in │ │ │ +00004f70: 7468 6973 2069 662d 626c 6f63 6b20 7368 this if-block sh │ │ │ +00004f80: 6f75 6c64 2062 6520 6661 6374 6f72 6564 ould be factored │ │ │ +00004f90: 206f 7574 2069 6e74 6f20 610a 7365 7061 out into a.sepa │ │ │ +00004fa0: 7261 7465 2066 756e 6374 696f 6e2e 2041 rate function. A │ │ │ +00004fb0: 7420 6c65 6173 7420 6d6f 7374 206f 6620 t least most of │ │ │ +00004fc0: 6974 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 it

    ../sr │ │ │ +00004fd0: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +00004fe0: 7070 3a31 3631 303c 2f68 343e 3c70 7265 pp:1610

    ...., (lep
    │ │ │ +00005030: 2e66 6c61 6773 2026 616d 703b 206c 6973  .flags & lis
    │ │ │ +00005040: 7465 6e5f 736f 636b 6574 5f74 3a3a 6163  ten_socket_t::ac
    │ │ │ +00005050: 6365 7074 5f69 6e63 6f6d 696e 6729 203f  cept_incoming) ?
    │ │ │ +00005060: 2022 6163 6365 7074 2d69 6e63 6f6d 696e   "accept-incomin
    │ │ │ +00005070: 6720 2220 3a20 226e 6f2d 696e 636f 6d69  g " : "no-incomi
    │ │ │ +00005080: 6e67 2022 0a09 0909 092c 2028 6c65 702e  ng "....., (lep.
    │ │ │ +00005090: 666c 6167 7320 2661 6d70 3b20 6c69 7374  flags & list
    │ │ │ +000050a0: 656e 5f73 6f63 6b65 745f 743a 3a77 6173  en_socket_t::was
    │ │ │ +000050b0: 5f65 7870 616e 6465 6429 203f 2022 6578  _expanded) ? "ex
    │ │ │ +000050c0: 7061 6e64 6564 2d69 7020 2220 3a20 2222  panded-ip " : ""
    │ │ │ +000050d0: 0a09 0909 092c 2028 6c65 702e 666c 6167  ....., (lep.flag
    │ │ │ +000050e0: 7320 2661 6d70 3b20 6c69 7374 656e 5f73  s & listen_s
    │ │ │ +000050f0: 6f63 6b65 745f 743a 3a70 726f 7879 2920  ocket_t::proxy) 
    │ │ │ +00005100: 3f20 2270 726f 7879 2022 203a 2022 2229  ? "proxy " : "")
    │ │ │ +00005110: 3b0a 0909 7d0a 2365 6e64 6966 0a0a 0909  ;...}.#endif....
    │ │ │ +00005120: 6175 746f 2072 6574 203d 2073 7464 3a3a  auto ret = std::
    │ │ │ +00005130: 6d61 6b65 5f73 6861 7265 6426 6c74 3b6c  make_shared<l
    │ │ │ +00005140: 6973 7465 6e5f 736f 636b 6574 5f74 2667  isten_socket_t&g
    │ │ │ +00005150: 743b 2829 3b0a 0909 7265 742d 2667 743b  t;();...ret->
    │ │ │ +00005160: 7373 6c20 3d20 6c65 702e 7373 6c3b 0a09  ssl = lep.ssl;..
    │ │ │ +00005170: 0972 6574 2d26 6774 3b6f 7269 6769 6e61  .ret->origina
    │ │ │ +00005180: 6c5f 706f 7274 203d 2062 696e 645f 6570  l_port = bind_ep
    │ │ │ +00005190: 2e70 6f72 7428 293b 0a09 0972 6574 2d26  .port();...ret-&
    │ │ │ +000051a0: 6774 3b66 6c61 6773 203d 206c 6570 2e66  gt;flags = lep.f
    │ │ │ +000051b0: 6c61 6773 3b0a 0909 7265 742d 2667 743b  lags;...ret->
    │ │ │ +000051c0: 6e65 746d 6173 6b20 3d20 6c65 702e 6e65  netmask = lep.ne
    │ │ │ +000051d0: 746d 6173 6b3b 0a09 096f 7065 7261 7469  tmask;...operati
    │ │ │ +000051e0: 6f6e 5f74 206c 6173 745f 6f70 203d 206f  on_t last_op = o
    │ │ │ +000051f0: 7065 7261 7469 6f6e 5f74 3a3a 756e 6b6e  peration_t::unkn
    │ │ │ +00005200: 6f77 6e3b 0a09 0973 6f63 6b65 745f 7479  own;...socket_ty
    │ │ │ +00005210: 7065 5f74 2063 6f6e 7374 2073 6f63 6b5f  pe_t const sock_
    │ │ │ +00005220: 7479 7065 0a09 0909 3d20 286c 6570 2e73  type....= (lep.s
    │ │ │ +00005230: 736c 203d 3d20 7472 616e 7370 6f72 743a  sl == transport:
    │ │ │ +00005240: 3a73 736c 290a 0909 093f 2073 6f63 6b65  :ssl)....? socke
    │ │ │ +00005250: 745f 7479 7065 5f74 3a3a 7463 705f 7373  t_type_t::tcp_ss
    │ │ │ +00005260: 6c0a 0909 093a 2073 6f63 6b65 745f 7479  l....: socket_ty
    │ │ │ +00005270: 7065 5f74 3a3a 7463 703b 0a0a 7265 7472  pe_t::tcp;..retr
    │ │ │ +00005280: 793a 0a09 092f 2f20 6966 2077 6527 7265  y:...// if we're
    │ │ │ +00005290: 2069 6e20 666f 7263 652d 7072 6f78 7920   in force-proxy 
    │ │ │ +000052a0: 6d6f 6465 2c20 646f 6e27 7420 6f70 656e  mode, don't open
    │ │ │ +000052b0: 2054 4350 206c 6973 7465 6e20 736f 636b   TCP listen sock
    │ │ │ +000052c0: 6574 732e 2057 6520 6361 6e6e 6f74 0a09  ets. We cannot..
    │ │ │ +000052d0: 092f 2f20 6163 6365 7074 2063 6f6e 6e65  .// accept conne
    │ │ │ +000052e0: 6374 696f 6e73 206f 6e20 6f75 7220 6c6f  ctions on our lo
    │ │ │ +000052f0: 6361 6c20 6d61 6368 696e 6520 696e 2074  cal machine in t
    │ │ │ +00005300: 6869 7320 6361 7365 2e0a 3c64 6976 2073  his case..
    ..if (re │ │ │ +00005340: 742d 2667 743b 666c 6167 7320 2661 6d70 t->flags & │ │ │ +00005350: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f ; listen_socket_ │ │ │ +00005360: 743a 3a61 6363 6570 745f 696e 636f 6d69 t::accept_incomi │ │ │ +00005370: 6e67 290a 3c2f 6469 763e 0909 7b0a 0909 ng).
    ..{... │ │ │ +00005380: 0972 6574 2d26 6774 3b73 6f63 6b20 3d20 .ret->sock = │ │ │ +00005390: 7374 643a 3a6d 616b 655f 7368 6172 6564 std::make_shared │ │ │ +000053a0: 266c 743b 7463 703a 3a61 6363 6570 746f <tcp::accepto │ │ │ +000053b0: 7226 6774 3b28 6d5f 696f 5f63 6f6e 7465 r>(m_io_conte │ │ │ +000053c0: 7874 293b 0a09 0909 7265 742d 2667 743b xt);....ret-> │ │ │ +000053d0: 736f 636b 2d26 6774 3b6f 7065 6e28 6269 sock->open(bi │ │ │ +000053e0: 6e64 5f65 702e 7072 6f74 6f63 6f6c 2829 nd_ep.protocol() │ │ │ +000053f0: 2c20 6563 293b 0a09 0909 6c61 7374 5f6f , ec);....last_o │ │ │ +00005400: 7020 3d20 6f70 6572 6174 696f 6e5f 743a p = operation_t: │ │ │ +00005410: 3a73 6f63 6b5f 6f70 656e 3b0a 0909 0969 :sock_open;....i │ │ │ +00005420: 6620 2865 6329 0a09 0909 7b0a 2369 666e f (ec)....{.#ifn │ │ │ +00005430: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +00005440: 424c 455f 4c4f 4747 494e 470a 0909 0909 BLE_LOGGING..... │ │ │ +00005450: 6966 2028 7368 6f75 6c64 5f6c 6f67 2829 if (should_log() │ │ │ +00005460: 290a 0909 0909 7b0a 0909 0909 0973 6573 ).....{......ses │ │ │ +00005470: 7369 6f6e 5f6c 6f67 2822 6661 696c 6564 sion_log("failed │ │ │ +00005480: 2074 6f20 6f70 656e 2073 6f63 6b65 743a to open socket: │ │ │ +00005490: 2025 7322 0a09 0909 0909 092c 2065 632e %s"......., ec. │ │ │ +000054a0: 6d65 7373 6167 6528 292e 635f 7374 7228 message().c_str( │ │ │ +000054b0: 2929 3b0a 0909 0909 7d0a 2365 6e64 6966 ));.....}.#endif │ │ │ +000054c0: 0a0a 0909 0909 6966 2028 6d5f 616c 6572 ......if (m_aler │ │ │ +000054d0: 7473 2e73 686f 756c 645f 706f 7374 266c ts.should_post&l │ │ │ +000054e0: 743b 6c69 7374 656e 5f66 6169 6c65 645f t;listen_failed_ │ │ │ +000054f0: 616c 6572 7426 6774 3b28 2929 0a09 0909 alert>()).... │ │ │ +00005500: 0909 6d5f 616c 6572 7473 2e65 6d70 6c61 ..m_alerts.empla │ │ │ +00005510: 6365 5f61 6c65 7274 266c 743b 6c69 7374 ce_alert<list │ │ │ +00005520: 656e 5f66 6169 6c65 645f 616c 6572 7426 en_failed_alert& │ │ │ +00005530: 6774 3b28 6c65 702e 6465 7669 6365 2c20 gt;(lep.device, │ │ │ +00005540: 6269 6e64 5f65 702c 206c 6173 745f 6f70 bind_ep, last_op │ │ │ +00005550: 0a09 0909 0909 092c 2065 632c 2073 6f63 ......., ec, soc │ │ │ +00005560: 6b5f 7479 7065 293b 0a09 0909 0972 6574 k_type);.....ret │ │ │ +00005570: 7572 6e20 7265 743b 0a09 0909 7d0a 0a23 urn ret;....}..# │ │ │ +00005580: 6966 6465 6620 544f 5252 454e 545f 5749 ifdef TORRENT_WI │ │ │ +00005590: 4e44 4f57 530a 0909 097b 0a09 0909 092f NDOWS....{...../ │ │ │ +000055a0: 2f20 7468 6973 2069 7320 6265 7374 2d65 / this is best-e │ │ │ +000055b0: 6666 6f72 742e 2069 676e 6f72 6520 6572 ffort. ignore er │ │ │ +000055c0: 726f 7273 0a09 0909 0965 7272 6f72 5f63 rors.....error_c │ │ │ +000055d0: 6f64 6520 6572 723b 0a09 0909 0972 6574 ode err;.....ret │ │ │ +000055e0: 2d26 6774 3b73 6f63 6b2d 2667 743b 7365 ->sock->se │ │ │ +000055f0: 745f 6f70 7469 6f6e 2865 7863 6c75 7369 t_option(exclusi │ │ │ +00005600: 7665 5f61 6464 7265 7373 5f75 7365 2874 ve_address_use(t │ │ │ +00005610: 7275 6529 2c20 6572 7229 3b0a 2369 666e rue), err);.#ifn │ │ │ +00005620: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +00005630: 424c 455f 4c4f 4747 494e 470a 0909 0909 BLE_LOGGING..... │ │ │ +00005640: 6966 2028 6572 7220 2661 6d70 3b26 616d if (err &&am │ │ │ +00005650: 703b 2073 686f 756c 645f 6c6f 6728 2929 p; should_log()) │ │ │ +00005660: 0a09 0909 097b 0a09 0909 0909 7365 7373 .....{......sess │ │ │ +00005670: 696f 6e5f 6c6f 6728 2266 6169 6c65 6420 ion_log("failed │ │ │ +00005680: 656e 6162 6c65 2065 7863 6c75 7369 7665 enable exclusive │ │ │ +00005690: 2061 6464 7265 7373 2075 7365 206f 6e20 address use on │ │ │ +000056a0: 6c69 7374 656e 2073 6f63 6b65 743a 2025 listen socket: % │ │ │ +000056b0: 7322 0a09 0909 0909 092c 2065 7272 2e6d s"......., err.m │ │ │ +000056c0: 6573 7361 6765 2829 2e63 5f73 7472 2829 essage().c_str() │ │ │ +000056d0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ +00005700: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00005710: 7370 3b33 3c2f 7464 3e3c 7464 3e3c 6120 sp;3../ │ │ │ +00005740: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ +00005750: 2e63 7070 3a32 3638 303c 2f61 3e3c 2f74 .cpp:2680it would b │ │ │ +00005770: 6520 6e65 6174 2069 6620 7468 6520 7574 e neat if the ut │ │ │ +00005780: 7020 736f 636b 6574 206d 616e 6167 6572 p socket manager │ │ │ +00005790: 2077 6f75 6c64 2068 616e 646c 6520 4943 would handle IC │ │ │ +000057a0: 4d50 2065 7272 6f72 7320 746f 6f3c 2f74 MP errors too

    it wou │ │ │ +00005800: 6c64 2062 6520 6e65 6174 2069 6620 7468 ld be neat if th │ │ │ +00005810: 6520 7574 7020 736f 636b 6574 206d 616e e utp socket man │ │ │ +00005820: 6167 6572 2077 6f75 6c64 0a68 616e 646c ager would.handl │ │ │ +00005830: 6520 4943 4d50 2065 7272 6f72 7320 746f e ICMP errors to │ │ │ +00005840: 6f3c 2f68 323e 3c68 343e 2e2e 2f73 7263 o

    ../src │ │ │ +00005850: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +00005860: 703a 3236 3830 3c2f 6834 3e3c 7072 6520 p:2680

    ...std::sha
    │ │ │ +000058b0: 7265 645f 7074 7226 6c74 3b73 6573 7369  red_ptr<sessi
    │ │ │ +000058c0: 6f6e 5f75 6470 5f73 6f63 6b65 7426 6774  on_udp_socket>
    │ │ │ +000058d0: 3b20 7320 3d20 736f 636b 6574 2e6c 6f63  ; s = socket.loc
    │ │ │ +000058e0: 6b28 293b 0a09 0969 6620 2821 7329 2072  k();...if (!s) r
    │ │ │ +000058f0: 6574 7572 6e3b 0a0a 0909 7374 7275 6374  eturn;....struct
    │ │ │ +00005900: 2075 7470 5f73 6f63 6b65 745f 6d61 6e61   utp_socket_mana
    │ │ │ +00005910: 6765 7226 616d 703b 206d 6772 203d 0a23  ger& mgr =.#
    │ │ │ +00005920: 6966 6465 6620 544f 5252 454e 545f 5353  ifdef TORRENT_SS
    │ │ │ +00005930: 4c5f 5045 4552 530a 0909 0973 736c 203d  L_PEERS....ssl =
    │ │ │ +00005940: 3d20 7472 616e 7370 6f72 743a 3a73 736c  = transport::ssl
    │ │ │ +00005950: 203f 206d 5f73 736c 5f75 7470 5f73 6f63   ? m_ssl_utp_soc
    │ │ │ +00005960: 6b65 745f 6d61 6e61 6765 7220 3a0a 2365  ket_manager :.#e
    │ │ │ +00005970: 6e64 6966 0a09 0909 6d5f 7574 705f 736f  ndif....m_utp_so
    │ │ │ +00005980: 636b 6574 5f6d 616e 6167 6572 3b0a 0a09  cket_manager;...
    │ │ │ +00005990: 0966 6f72 2028 3b3b 290a 0909 7b0a 0909  .for (;;)...{...
    │ │ │ +000059a0: 0961 7578 3a3a 6172 7261 7926 6c74 3b75  .aux::array<u
    │ │ │ +000059b0: 6470 5f73 6f63 6b65 743a 3a70 6163 6b65  dp_socket::packe
    │ │ │ +000059c0: 742c 2035 3026 6774 3b20 703b 0a09 0909  t, 50> p;....
    │ │ │ +000059d0: 6572 726f 725f 636f 6465 2065 7272 3b0a  error_code err;.
    │ │ │ +000059e0: 0909 0969 6e74 2063 6f6e 7374 206e 756d  ...int const num
    │ │ │ +000059f0: 5f70 6163 6b65 7473 203d 2073 2d26 6774  _packets = s->
    │ │ │ +00005a00: 3b73 6f63 6b2e 7265 6164 2870 2c20 6572  ;sock.read(p, er
    │ │ │ +00005a10: 7229 3b0a 0a09 0909 666f 7220 2875 6470  r);.....for (udp
    │ │ │ +00005a20: 5f73 6f63 6b65 743a 3a70 6163 6b65 7426  _socket::packet&
    │ │ │ +00005a30: 616d 703b 2070 6163 6b65 7420 3a20 7370  amp; packet : sp
    │ │ │ +00005a40: 616e 266c 743b 7564 705f 736f 636b 6574  an<udp_socket
    │ │ │ +00005a50: 3a3a 7061 636b 6574 2667 743b 2870 292e  ::packet>(p).
    │ │ │ +00005a60: 6669 7273 7428 6e75 6d5f 7061 636b 6574  first(num_packet
    │ │ │ +00005a70: 7329 290a 0909 097b 0a09 0909 0969 6620  s))....{.....if 
    │ │ │ +00005a80: 2870 6163 6b65 742e 6572 726f 7229 0a09  (packet.error)..
    │ │ │ +00005a90: 0909 097b 0a3c 6469 7620 7374 796c 653d  ...{.
    .
    #ifnde │ │ │ +00005ad0: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +00005ae0: 455f 4448 540a 0909 0909 0969 6620 286d E_DHT......if (m │ │ │ +00005af0: 5f64 6874 290a 0909 0909 0909 6d5f 6468 _dht).......m_dh │ │ │ +00005b00: 742d 2667 743b 696e 636f 6d69 6e67 5f65 t->incoming_e │ │ │ +00005b10: 7272 6f72 2870 6163 6b65 742e 6572 726f rror(packet.erro │ │ │ +00005b20: 722c 2070 6163 6b65 742e 6672 6f6d 293b r, packet.from); │ │ │ +00005b30: 0a23 656e 6469 660a 0a09 0909 0909 6d5f .#endif.......m_ │ │ │ +00005b40: 7472 6163 6b65 725f 6d61 6e61 6765 722e tracker_manager. │ │ │ +00005b50: 696e 636f 6d69 6e67 5f65 7272 6f72 2870 incoming_error(p │ │ │ +00005b60: 6163 6b65 742e 6572 726f 722c 2070 6163 acket.error, pac │ │ │ +00005b70: 6b65 742e 6672 6f6d 293b 0a09 0909 0909 ket.from);...... │ │ │ +00005b80: 636f 6e74 696e 7565 3b0a 0909 0909 7d0a continue;.....}. │ │ │ +00005b90: 0a09 0909 0973 7061 6e26 6c74 3b63 6861 .....span<cha │ │ │ +00005ba0: 7220 636f 6e73 7426 6774 3b20 636f 6e73 r const> cons │ │ │ +00005bb0: 7420 6275 6620 3d20 7061 636b 6574 2e64 t buf = packet.d │ │ │ +00005bc0: 6174 613b 0a09 0909 0969 6620 2821 7061 ata;.....if (!pa │ │ │ +00005bd0: 636b 6574 2e68 6f73 746e 616d 652e 656d cket.hostname.em │ │ │ +00005be0: 7074 7928 2929 0a09 0909 097b 0a09 0909 pty()).....{.... │ │ │ +00005bf0: 0909 2f2f 206f 6e6c 7920 7468 6520 7472 ..// only the tr │ │ │ +00005c00: 6163 6b65 7220 6d61 6e61 6765 7220 7375 acker manager su │ │ │ +00005c10: 7070 6f72 7473 2072 6563 6569 7669 6e67 pports receiving │ │ │ +00005c20: 2055 4450 2070 6163 6b65 7473 0a09 0909 UDP packets.... │ │ │ +00005c30: 0909 2f2f 2066 726f 6d20 686f 7374 6e61 ..// from hostna │ │ │ +00005c40: 6d65 732e 2049 6620 6974 2077 6f6e 2774 mes. If it won't │ │ │ +00005c50: 2068 616e 646c 6520 6974 2c20 6e6f 206f handle it, no o │ │ │ +00005c60: 6e65 2065 6c73 6520 7769 6c6c 0a09 0909 ne else will.... │ │ │ +00005c70: 0909 2f2f 2065 6974 6865 720a 0909 0909 ..// either..... │ │ │ +00005c80: 096d 5f74 7261 636b 6572 5f6d 616e 6167 .m_tracker_manag │ │ │ +00005c90: 6572 2e69 6e63 6f6d 696e 675f 7061 636b er.incoming_pack │ │ │ +00005ca0: 6574 2870 6163 6b65 742e 686f 7374 6e61 et(packet.hostna │ │ │ +00005cb0: 6d65 2c20 6275 6629 3b0a 0909 0909 0963 me, buf);......c │ │ │ +00005cc0: 6f6e 7469 6e75 653b 0a09 0909 097d 0a0a ontinue;.....}.. │ │ │ +00005cd0: 0909 0909 2f2f 2067 6976 6520 7468 6520 ....// give the │ │ │ +00005ce0: 7554 5020 736f 636b 6574 206d 616e 6167 uTP socket manag │ │ │ +00005cf0: 6572 2066 6972 7374 2064 6962 7320 6f6e er first dibs on │ │ │ +00005d00: 2074 6865 2070 6163 6b65 742e 2050 7265 the packet. Pre │ │ │ +00005d10: 7375 6d61 626c 790a 0909 0909 2f2f 2074 sumably.....// t │ │ │ +00005d20: 6865 206d 616a 6f72 6974 7920 6f66 2070 he majority of p │ │ │ +00005d30: 6163 6b65 7473 2061 7265 2075 5450 2070 ackets are uTP p │ │ │ +00005d40: 6163 6b65 7473 2e0a 0909 0909 6966 2028 ackets......if ( │ │ │ +00005d50: 216d 6772 2e69 6e63 6f6d 696e 675f 7061 !mgr.incoming_pa │ │ │ +00005d60: 636b 6574 286c 732c 2070 6163 6b65 742e cket(ls, packet. │ │ │ +00005d70: 6672 6f6d 2c20 6275 6629 290a 0909 0909 from, buf))..... │ │ │ +00005d80: 7b0a 0909 0909 092f 2f20 6966 2069 7420 {......// if it │ │ │ +00005d90: 7761 736e 2774 2061 2075 5450 2070 6163 wasn't a uTP pac │ │ │ +00005da0: 6b65 742c 2074 7279 2074 6865 206f 7468 ket, try the oth │ │ │ +00005db0: 6572 2075 7365 7273 206f 6620 7468 6520 er users of the │ │ │ +00005dc0: 5544 500a 0909 0909 092f 2f20 736f 636b UDP......// sock │ │ │ +00005dd0: 6574 0a09 0909 0909 626f 6f6c 2068 616e et......bool han │ │ │ +00005de0: 646c 6564 203d 2066 616c 7365 3b0a 2369 dled = false;.#i │ │ │ +00005df0: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +00005e00: 5341 424c 455f 4448 540a 0909 0909 0961 SABLE_DHT......a │ │ │ +00005e10: 7574 6f20 6c69 7374 656e 5f73 6f63 6b65 uto listen_socke │ │ │ +00005e20: 7420 3d20 6c73 2e6c 6f63 6b28 293b 0a09 t = ls.lock();.. │ │ │ +00005e30: 0909 0909 6966 2028 6d5f 6468 7420 2661 ....if (m_dht &a │ │ │ +00005e40: 6d70 3b26 616d 703b 2062 7566 2e73 697a mp;& buf.siz │ │ │ +00005e50: 6528 2920 2667 743b 2032 300a 0909 0909 e() > 20..... │ │ │ +00005e60: 0909 2661 6d70 3b26 616d 703b 2062 7566 ..&& buf │ │ │ +00005e70: 2e66 726f 6e74 2829 203d 3d20 2764 270a .front() == 'd'. │ │ │ +00005e80: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00005e90: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00005ec0: 333c 2f74 643e 3c74 643e 3c61 2068 7265 3../src │ │ │ +00005ef0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +00005f00: 703a 3433 3137 3c2f 613e 3c2f 7464 3e3c p:4317< │ │ │ +00005f10: 7464 3e69 7420 776f 756c 6420 7072 6f62 td>it would prob │ │ │ +00005f20: 6162 6c79 206d 616b 6520 7365 6e73 6520 ably make sense │ │ │ +00005f30: 746f 2068 6176 6520 6120 7365 7061 7261 to have a separa │ │ │ +00005f40: 7465 206c 6973 7420 6f66 2070 6565 7273 te list of peers │ │ │ +00005f50: 2074 6861 7420 6172 6520 656c 6967 6962 that are eligib │ │ │ +00005f60: 6c65 2066 6f72 206f 7074 696d 6973 7469 le for optimisti │ │ │ +00005f70: 6320 756e 6368 6f6b 652c 2073 696d 696c c unchoke, simil │ │ │ +00005f80: 6172 2074 6f20 7468 6520 746f 7272 656e ar to the torren │ │ │ +00005f90: 7473 2070 6572 6861 7073 2074 6869 7320 ts perhaps this │ │ │ +00005fa0: 636f 756c 6420 6576 656e 2069 7465 7261 could even itera │ │ │ +00005fb0: 7465 206f 7665 7220 7468 6520 706f 6f6c te over the pool │ │ │ +00005fc0: 2061 6c6c 6f63 6174 6f72 7320 6f66 2074 allocators of t │ │ │ +00005fd0: 6f72 7265 6e74 5f70 6565 7220 6f62 6a65 orrent_peer obje │ │ │ +00005fe0: 6374 732e 2049 7420 636f 756c 6420 7072 cts. It could pr │ │ │ +00005ff0: 6f62 6162 6c79 2062 6520 646f 6e65 2069 obably be done i │ │ │ +00006000: 6e20 6120 7369 6e67 6c65 2070 6173 7320 n a single pass │ │ │ +00006010: 616e 6420 636f 6c6c 6563 7420 7468 6520 and collect the │ │ │ +00006020: 6e20 6265 7374 2063 616e 6469 6461 7465 n best candidate │ │ │ +00006030: 732e 206d 6179 6265 206a 7573 7420 6120 s. maybe just a │ │ │ +00006040: 7175 6575 6520 6f66 2070 6565 7273 2077 queue of peers w │ │ │ +00006050: 6f75 6c64 206d 616b 6520 6576 656e 206d ould make even m │ │ │ +00006060: 6f72 6520 7365 6e73 652c 206a 7573 7420 ore sense, just │ │ │ +00006070: 7069 636b 2074 6865 206e 6578 7420 7065 pick the next pe │ │ │ +00006080: 6572 2069 6e20 7468 6520 7175 6575 6520 er in the queue │ │ │ +00006090: 666f 7220 756e 6368 6f6b 696e 672e 2049 for unchoking. I │ │ │ +000060a0: 7420 776f 756c 6420 6265 204f 2831 292e t would be O(1). │ │ │ +000060b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ +00006100: 776f 756c 6420 7072 6f62 6162 6c79 206d would probably m │ │ │ +00006110: 616b 6520 7365 6e73 6520 746f 2068 6176 ake sense to hav │ │ │ +00006120: 6520 6120 7365 7061 7261 7465 206c 6973 e a separate lis │ │ │ +00006130: 7420 6f66 2070 6565 7273 0a74 6861 7420 t of peers.that │ │ │ +00006140: 6172 6520 656c 6967 6962 6c65 2066 6f72 are eligible for │ │ │ +00006150: 206f 7074 696d 6973 7469 6320 756e 6368 optimistic unch │ │ │ +00006160: 6f6b 652c 2073 696d 696c 6172 2074 6f20 oke, similar to │ │ │ +00006170: 7468 6520 746f 7272 656e 7473 0a70 6572 the torrents.per │ │ │ +00006180: 6861 7073 2074 6869 7320 636f 756c 6420 haps this could │ │ │ +00006190: 6576 656e 2069 7465 7261 7465 206f 7665 even iterate ove │ │ │ +000061a0: 7220 7468 6520 706f 6f6c 2061 6c6c 6f63 r the pool alloc │ │ │ +000061b0: 6174 6f72 7320 6f66 0a74 6f72 7265 6e74 ators of.torrent │ │ │ +000061c0: 5f70 6565 7220 6f62 6a65 6374 732e 2049 _peer objects. I │ │ │ +000061d0: 7420 636f 756c 6420 7072 6f62 6162 6c79 t could probably │ │ │ +000061e0: 2062 6520 646f 6e65 2069 6e20 6120 7369 be done in a si │ │ │ +000061f0: 6e67 6c65 2070 6173 7320 616e 640a 636f ngle pass and.co │ │ │ +00006200: 6c6c 6563 7420 7468 6520 6e20 6265 7374 llect the n best │ │ │ +00006210: 2063 616e 6469 6461 7465 732e 206d 6179 candidates. may │ │ │ +00006220: 6265 206a 7573 7420 6120 7175 6575 6520 be just a queue │ │ │ +00006230: 6f66 2070 6565 7273 2077 6f75 6c64 206d of peers would m │ │ │ +00006240: 616b 650a 6576 656e 206d 6f72 6520 7365 ake.even more se │ │ │ +00006250: 6e73 652c 206a 7573 7420 7069 636b 2074 nse, just pick t │ │ │ +00006260: 6865 206e 6578 7420 7065 6572 2069 6e20 he next peer in │ │ │ +00006270: 7468 6520 7175 6575 6520 666f 7220 756e the queue for un │ │ │ +00006280: 6368 6f6b 696e 672e 2049 740a 776f 756c choking. It.woul │ │ │ +00006290: 6420 6265 204f 2831 292e 3c2f 6832 3e3c d be O(1).

    < │ │ │ +000062a0: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ +000062b0: 6e5f 696d 706c 2e63 7070 3a34 3331 373c n_impl.cpp:4317< │ │ │ +000062c0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .}
    │ │ │ +00006300: 0a0a 0976 6f69 6420 7365 7373 696f 6e5f  ...void session_
    │ │ │ +00006310: 696d 706c 3a3a 7265 6361 6c63 756c 6174  impl::recalculat
    │ │ │ +00006320: 655f 6f70 7469 6d69 7374 6963 5f75 6e63  e_optimistic_unc
    │ │ │ +00006330: 686f 6b65 5f73 6c6f 7473 2829 0a09 7b0a  hoke_slots()..{.
    │ │ │ +00006340: 0909 494e 5641 5249 414e 545f 4348 4543  ..INVARIANT_CHEC
    │ │ │ +00006350: 4b3b 0a0a 0909 544f 5252 454e 545f 4153  K;....TORRENT_AS
    │ │ │ +00006360: 5345 5254 2869 735f 7369 6e67 6c65 5f74  SERT(is_single_t
    │ │ │ +00006370: 6872 6561 6428 2929 3b0a 0909 6966 2028  hread());...if (
    │ │ │ +00006380: 6d5f 7374 6174 735f 636f 756e 7465 7273  m_stats_counters
    │ │ │ +00006390: 5b63 6f75 6e74 6572 733a 3a6e 756d 5f75  [counters::num_u
    │ │ │ +000063a0: 6e63 686f 6b65 5f73 6c6f 7473 5d20 3d3d  nchoke_slots] ==
    │ │ │ +000063b0: 2030 2920 7265 7475 726e 3b0a 0a09 092f   0) return;..../
    │ │ │ +000063c0: 2f20 6966 2077 6520 756e 6368 6f6b 6520  / if we unchoke 
    │ │ │ +000063d0: 6576 6572 796f 6e65 2c20 736b 6970 2074  everyone, skip t
    │ │ │ +000063e0: 6869 7320 6c6f 6769 630a 0909 6966 2028  his logic...if (
    │ │ │ +000063f0: 7365 7474 696e 6773 2829 2e67 6574 5f69  settings().get_i
    │ │ │ +00006400: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ +00006410: 3a3a 6368 6f6b 696e 675f 616c 676f 7269  ::choking_algori
    │ │ │ +00006420: 7468 6d29 203d 3d20 7365 7474 696e 6773  thm) == settings
    │ │ │ +00006430: 5f70 6163 6b3a 3a66 6978 6564 5f73 6c6f  _pack::fixed_slo
    │ │ │ +00006440: 7473 5f63 686f 6b65 720a 0909 0926 616d  ts_choker....&am
    │ │ │ +00006450: 703b 2661 6d70 3b20 7365 7474 696e 6773  p;& settings
    │ │ │ +00006460: 2829 2e67 6574 5f69 6e74 2873 6574 7469  ().get_int(setti
    │ │ │ +00006470: 6e67 735f 7061 636b 3a3a 756e 6368 6f6b  ngs_pack::unchok
    │ │ │ +00006480: 655f 736c 6f74 735f 6c69 6d69 7429 2026  e_slots_limit) &
    │ │ │ +00006490: 6c74 3b20 3029 0a09 0909 7265 7475 726e  lt; 0)....return
    │ │ │ +000064a0: 3b0a 0a09 0973 7464 3a3a 7665 6374 6f72  ;....std::vector
    │ │ │ +000064b0: 266c 743b 6f70 745f 756e 6368 6f6b 655f  <opt_unchoke_
    │ │ │ +000064c0: 6361 6e64 6964 6174 6526 6774 3b20 6f70  candidate> op
    │ │ │ +000064d0: 745f 756e 6368 6f6b 653b 0a0a 0909 2f2f  t_unchoke;....//
    │ │ │ +000064e0: 2063 6f6c 6c65 6374 2074 6865 2063 7572   collect the cur
    │ │ │ +000064f0: 7265 6e74 6c79 206f 7074 696d 6973 7469  rently optimisti
    │ │ │ +00006500: 6361 6c6c 7920 756e 6368 6f6b 6564 2070  cally unchoked p
    │ │ │ +00006510: 6565 7273 2068 6572 652c 2073 6f20 7765  eers here, so we
    │ │ │ +00006520: 2063 616e 0a09 092f 2f20 6368 6f6b 6520   can...// choke 
    │ │ │ +00006530: 7468 656d 2077 6865 6e20 7765 2776 6520  them when we've 
    │ │ │ +00006540: 666f 756e 6420 6e65 7720 6f70 7469 6d69  found new optimi
    │ │ │ +00006550: 7374 6963 2075 6e63 686f 6b65 2063 616e  stic unchoke can
    │ │ │ +00006560: 6469 6461 7465 732e 0a09 0973 7464 3a3a  didates....std::
    │ │ │ +00006570: 7665 6374 6f72 266c 743b 746f 7272 656e  vector<torren
    │ │ │ +00006580: 745f 7065 6572 2a26 6774 3b20 7072 6576  t_peer*> prev
    │ │ │ +00006590: 5f6f 7074 5f75 6e63 686f 6b65 3b0a 0a3c  _opt_unchoke;..<
    │ │ │ +000065a0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +000065b0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +000065c0: 7769 6474 683d 2231 3030 2522 3e09 0966  width="100%">..f
    │ │ │ +000065d0: 6f72 2028 6175 746f 2063 6f6e 7374 2661  or (auto const&a
    │ │ │ +000065e0: 6d70 3b20 6920 3a20 6d5f 636f 6e6e 6563  mp; i : m_connec
    │ │ │ +000065f0: 7469 6f6e 7329 0a3c 2f64 6976 3e09 097b  tions).
    ..{ │ │ │ +00006600: 0a09 0909 7065 6572 5f63 6f6e 6e65 6374 ....peer_connect │ │ │ +00006610: 696f 6e2a 2063 6f6e 7374 2070 203d 2069 ion* const p = i │ │ │ +00006620: 2e67 6574 2829 3b0a 0909 0954 4f52 5245 .get();....TORRE │ │ │ +00006630: 4e54 5f41 5353 4552 5428 7029 3b0a 0909 NT_ASSERT(p);... │ │ │ +00006640: 0974 6f72 7265 6e74 5f70 6565 722a 2070 .torrent_peer* p │ │ │ +00006650: 6920 3d20 702d 2667 743b 7065 6572 5f69 i = p->peer_i │ │ │ +00006660: 6e66 6f5f 7374 7275 6374 2829 3b0a 0909 nfo_struct();... │ │ │ +00006670: 0969 6620 2821 7069 2920 636f 6e74 696e .if (!pi) contin │ │ │ +00006680: 7565 3b0a 0909 0969 6620 2870 692d 2667 ue;....if (pi-&g │ │ │ +00006690: 743b 7765 625f 7365 6564 2920 636f 6e74 t;web_seed) cont │ │ │ +000066a0: 696e 7565 3b0a 0a09 0909 6966 2028 7069 inue;.....if (pi │ │ │ +000066b0: 2d26 6774 3b6f 7074 696d 6973 7469 6361 ->optimistica │ │ │ +000066c0: 6c6c 795f 756e 6368 6f6b 6564 290a 0909 lly_unchoked)... │ │ │ +000066d0: 097b 0a09 0909 0970 7265 765f 6f70 745f .{.....prev_opt_ │ │ │ +000066e0: 756e 6368 6f6b 652e 7075 7368 5f62 6163 unchoke.push_bac │ │ │ +000066f0: 6b28 7069 293b 0a09 0909 7d0a 0a09 0909 k(pi);....}..... │ │ │ +00006700: 746f 7272 656e 7420 636f 6e73 742a 2074 torrent const* t │ │ │ +00006710: 203d 2070 2d26 6774 3b61 7373 6f63 6961 = p->associa │ │ │ +00006720: 7465 645f 746f 7272 656e 7428 292e 6c6f ted_torrent().lo │ │ │ +00006730: 636b 2829 2e67 6574 2829 3b0a 0909 0969 ck().get();....i │ │ │ +00006740: 6620 2821 7429 2063 6f6e 7469 6e75 653b f (!t) continue; │ │ │ +00006750: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..< │ │ │ +00006780: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00006790: 703b 333c 2f74 643e 3c74 643e 3c61 2068 p;3../s │ │ │ +000067c0: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +000067d0: 6370 703a 3433 3430 3c2f 613e 3c2f 7464 cpp:4340peers shoul │ │ │ +000067f0: 6420 6b6e 6f77 2077 6865 7468 6572 2074 d know whether t │ │ │ +00006800: 6865 6972 2074 6f72 7265 6e74 2069 7320 heir torrent is │ │ │ +00006810: 7061 7573 6564 206f 7220 6e6f 742c 2069 paused or not, i │ │ │ +00006820: 6e73 7465 6164 206f 6620 6861 7669 6e67 nstead of having │ │ │ +00006830: 2074 6f20 6173 6b20 6974 206f 7665 7220 to ask it over │ │ │ +00006840: 616e 6420 6f76 6572 2061 6761 696e 3c2f and over again

    peers │ │ │ +000068a0: 2073 686f 756c 6420 6b6e 6f77 2077 6865 should know whe │ │ │ +000068b0: 7468 6572 2074 6865 6972 2074 6f72 7265 ther their torre │ │ │ +000068c0: 6e74 2069 7320 7061 7573 6564 206f 7220 nt is paused or │ │ │ +000068d0: 6e6f 742c 0a69 6e73 7465 6164 206f 6620 not,.instead of │ │ │ +000068e0: 6861 7669 6e67 2074 6f20 6173 6b20 6974 having to ask it │ │ │ +000068f0: 206f 7665 7220 616e 6420 6f76 6572 2061 over and over a │ │ │ +00006900: 6761 696e 3c2f 6832 3e3c 6834 3e2e 2e2f gain

    ../ │ │ │ +00006910: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ +00006920: 2e63 7070 3a34 3334 303c 2f68 343e 3c70 .cpp:4340

    ..// col │ │ │ +00006970: 6c65 6374 2074 6865 2063 7572 7265 6e74 lect the current │ │ │ +00006980: 6c79 206f 7074 696d 6973 7469 6361 6c6c ly optimisticall │ │ │ +00006990: 7920 756e 6368 6f6b 6564 2070 6565 7273 y unchoked peers │ │ │ +000069a0: 2068 6572 652c 2073 6f20 7765 2063 616e here, so we can │ │ │ +000069b0: 0a09 092f 2f20 6368 6f6b 6520 7468 656d ...// choke them │ │ │ +000069c0: 2077 6865 6e20 7765 2776 6520 666f 756e when we've foun │ │ │ +000069d0: 6420 6e65 7720 6f70 7469 6d69 7374 6963 d new optimistic │ │ │ +000069e0: 2075 6e63 686f 6b65 2063 616e 6469 6461 unchoke candida │ │ │ +000069f0: 7465 732e 0a09 0973 7464 3a3a 7665 6374 tes....std::vect │ │ │ +00006a00: 6f72 266c 743b 746f 7272 656e 745f 7065 or<torrent_pe │ │ │ +00006a10: 6572 2a26 6774 3b20 7072 6576 5f6f 7074 er*> prev_opt │ │ │ +00006a20: 5f75 6e63 686f 6b65 3b0a 0a09 0966 6f72 _unchoke;....for │ │ │ +00006a30: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ +00006a40: 3b20 6920 3a20 6d5f 636f 6e6e 6563 7469 ; i : m_connecti │ │ │ +00006a50: 6f6e 7329 0a09 097b 0a09 0909 7065 6572 ons)...{....peer │ │ │ +00006a60: 5f63 6f6e 6e65 6374 696f 6e2a 2063 6f6e _connection* con │ │ │ +00006a70: 7374 2070 203d 2069 2e67 6574 2829 3b0a st p = i.get();. │ │ │ +00006a80: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00006a90: 5428 7029 3b0a 0909 0974 6f72 7265 6e74 T(p);....torrent │ │ │ +00006aa0: 5f70 6565 722a 2070 6920 3d20 702d 2667 _peer* pi = p-&g │ │ │ +00006ab0: 743b 7065 6572 5f69 6e66 6f5f 7374 7275 t;peer_info_stru │ │ │ +00006ac0: 6374 2829 3b0a 0909 0969 6620 2821 7069 ct();....if (!pi │ │ │ +00006ad0: 2920 636f 6e74 696e 7565 3b0a 0909 0969 ) continue;....i │ │ │ +00006ae0: 6620 2870 692d 2667 743b 7765 625f 7365 f (pi->web_se │ │ │ +00006af0: 6564 2920 636f 6e74 696e 7565 3b0a 0a09 ed) continue;... │ │ │ +00006b00: 0909 6966 2028 7069 2d26 6774 3b6f 7074 ..if (pi->opt │ │ │ +00006b10: 696d 6973 7469 6361 6c6c 795f 756e 6368 imistically_unch │ │ │ +00006b20: 6f6b 6564 290a 0909 097b 0a09 0909 0970 oked)....{.....p │ │ │ +00006b30: 7265 765f 6f70 745f 756e 6368 6f6b 652e rev_opt_unchoke. │ │ │ +00006b40: 7075 7368 5f62 6163 6b28 7069 293b 0a09 push_back(pi);.. │ │ │ +00006b50: 0909 7d0a 0a09 0909 746f 7272 656e 7420 ..}.....torrent │ │ │ +00006b60: 636f 6e73 742a 2074 203d 2070 2d26 6774 const* t = p-> │ │ │ +00006b70: 3b61 7373 6f63 6961 7465 645f 746f 7272 ;associated_torr │ │ │ +00006b80: 656e 7428 292e 6c6f 636b 2829 2e67 6574 ent().lock().get │ │ │ +00006b90: 2829 3b0a 0909 0969 6620 2821 7429 2063 ();....if (!t) c │ │ │ +00006ba0: 6f6e 7469 6e75 653b 0a0a 3c64 6976 2073 ontinue;..

    ...if (t │ │ │ +00006be0: 2d26 6774 3b69 735f 7061 7573 6564 2829 ->is_paused() │ │ │ +00006bf0: 2920 636f 6e74 696e 7565 3b0a 3c2f 6469 ) continue;.....if (!p-> │ │ │ +00006c10: 3b69 735f 636f 6e6e 6563 7469 6e67 2829 ;is_connecting() │ │ │ +00006c20: 0a09 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ +00006c30: 2170 2d26 6774 3b69 735f 6469 7363 6f6e !p->is_discon │ │ │ +00006c40: 6e65 6374 696e 6728 290a 0909 0909 2661 necting().....&a │ │ │ +00006c50: 6d70 3b26 616d 703b 2070 2d26 6774 3b69 mp;& p->i │ │ │ +00006c60: 735f 7065 6572 5f69 6e74 6572 6573 7465 s_peer_intereste │ │ │ +00006c70: 6428 290a 0909 0909 2661 6d70 3b26 616d d().....&&am │ │ │ +00006c80: 703b 2074 2d26 6774 3b66 7265 655f 7570 p; t->free_up │ │ │ +00006c90: 6c6f 6164 5f73 6c6f 7473 2829 0a09 0909 load_slots().... │ │ │ +00006ca0: 0926 616d 703b 2661 6d70 3b20 2870 2d26 .&& (p-& │ │ │ +00006cb0: 6774 3b69 735f 6368 6f6b 6564 2829 207c gt;is_choked() | │ │ │ +00006cc0: 7c20 7069 2d26 6774 3b6f 7074 696d 6973 | pi->optimis │ │ │ +00006cd0: 7469 6361 6c6c 795f 756e 6368 6f6b 6564 tically_unchoked │ │ │ +00006ce0: 290a 0909 0909 2661 6d70 3b26 616d 703b ).....&& │ │ │ +00006cf0: 2021 702d 2667 743b 6967 6e6f 7265 5f75 !p->ignore_u │ │ │ +00006d00: 6e63 686f 6b65 5f73 6c6f 7473 2829 0a09 nchoke_slots().. │ │ │ +00006d10: 0909 0926 616d 703b 2661 6d70 3b20 742d ...&& t- │ │ │ +00006d20: 2667 743b 7661 6c69 645f 6d65 7461 6461 >valid_metada │ │ │ +00006d30: 7461 2829 290a 0909 097b 0a09 0909 096f ta())....{.....o │ │ │ +00006d40: 7074 5f75 6e63 686f 6b65 2e65 6d70 6c61 pt_unchoke.empla │ │ │ +00006d50: 6365 5f62 6163 6b28 2661 6d70 3b69 293b ce_back(&i); │ │ │ +00006d60: 0a09 0909 7d0a 0909 7d0a 0a09 092f 2f20 ....}...}....// │ │ │ +00006d70: 6669 6e64 2074 6865 2070 6565 7273 2074 find the peers t │ │ │ +00006d80: 6861 7420 6861 7320 6265 656e 2077 6169 hat has been wai │ │ │ +00006d90: 7469 6e67 2074 6865 206c 6f6e 6765 7374 ting the longest │ │ │ +00006da0: 2074 6f20 6265 206f 7074 696d 6973 7469 to be optimisti │ │ │ +00006db0: 6361 6c6c 790a 0909 2f2f 2075 6e63 686f cally...// uncho │ │ │ +00006dc0: 6b65 640a 0a09 0969 6e74 206e 756d 5f6f ked....int num_o │ │ │ +00006dd0: 7074 5f75 6e63 686f 6b65 203d 206d 5f73 pt_unchoke = m_s │ │ │ +00006de0: 6574 7469 6e67 732e 6765 745f 696e 7428 ettings.get_int( │ │ │ +00006df0: 7365 7474 696e 6773 5f70 6163 6b3a 3a6e settings_pack::n │ │ │ +00006e00: 756d 5f6f 7074 696d 6973 7469 635f 756e um_optimistic_un │ │ │ +00006e10: 6368 6f6b 655f 736c 6f74 7329 3b0a 0909 choke_slots);... │ │ │ +00006e20: 696e 7420 636f 6e73 7420 616c 6c6f 7765 int const allowe │ │ │ +00006e30: 645f 756e 6368 6f6b 655f 736c 6f74 7320 d_unchoke_slots │ │ │ +00006e40: 3d20 696e 7428 6d5f 7374 6174 735f 636f = int(m_stats_co │ │ │ +00006e50: 756e 7465 7273 5b63 6f75 6e74 6572 733a unters[counters: │ │ │ +00006e60: 3a6e 756d 5f75 6e63 686f 6b65 5f73 6c6f :num_unchoke_slo │ │ │ +00006e70: 7473 5d29 3b0a 0909 6966 2028 6e75 6d5f ts]);...if (num_ │ │ │ +00006e80: 6f70 745f 756e 6368 6f6b 6520 3d3d 2030 opt_unchoke == 0 │ │ │ +00006e90: 2920 6e75 6d5f 6f70 745f 756e 6368 6f6b ) num_opt_unchok │ │ │ +00006ea0: 6520 3d20 7374 643a 3a6d 6178 2831 2c20 e = std::max(1, │ │ │ +00006eb0: 616c 6c6f 7765 645f 756e 6368 6f6b 655f allowed_unchoke_ │ │ │ +00006ec0: 736c 6f74 7320 2f20 3529 3b0a 0909 6966 slots / 5);...if │ │ │ +00006ed0: 2028 6e75 6d5f 6f70 745f 756e 6368 6f6b (num_opt_unchok │ │ │ +00006ee0: 6520 2667 743b 2069 6e74 286f 7074 5f75 e > int(opt_u │ │ │ +00006ef0: 6e63 686f 6b65 2e73 697a 6528 2929 2920 nchoke.size())) │ │ │ +00006f00: 6e75 6d5f 6f70 745f 756e 6368 6f6b 6520 num_opt_unchoke │ │ │ +00006f10: 3d0a 0909 0969 6e74 286f 7074 5f75 6e63 =....int(opt_unc │ │ │ +00006f20: 686f 6b65 2e73 697a 6528 2929 3b0a 0a09 hoke.size());... │ │ │ +00006f30: 092f 2f20 6669 6e64 2074 6865 206e 2062 .// find the n b │ │ │ +00006f40: 6573 7420 6f70 7469 6d69 7374 6963 2075 est optimistic u │ │ │ +00006f50: 6e63 686f 6b65 2063 616e 6469 6461 7465 nchoke candidate │ │ │ +00006f60: 730a 0909 7374 643a 3a70 6172 7469 616c s...std::partial │ │ │ +00006f70: 5f73 6f72 7428 6f70 745f 756e 6368 6f6b _sort(opt_unchok │ │ │ +00006f80: 652e 6265 6769 6e28 290a 0909 092c 206f e.begin()...., o │ │ │ +00006f90: 7074 5f75 6e63 686f 6b65 2e62 6567 696e pt_unchoke.begin │ │ │ +00006fa0: 2829 202b 206e 756d 5f6f 7074 5f75 6e63 () + num_opt_unc │ │ │ +00006fb0: 686f 6b65 0a09 0909 2c20 6f70 745f 756e hoke...., opt_un │ │ │ +00006fc0: 6368 6f6b 652e 656e 6428 290a 2369 666e choke.end().#ifn │ │ │ +00006fd0: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +00006fe0: 424c 455f 4558 5445 4e53 494f 4e53 0a09 BLE_EXTENSIONS.. │ │ │ +00006ff0: 0909 2c20 6c61 7374 5f6f 7074 696d 6973 .., last_optimis │ │ │ +00007000: 7469 635f 756e 6368 6f6b 655f 636d 7028 tic_unchoke_cmp( │ │ │ +00007010: 6d5f 7365 735f 6578 7465 6e73 696f 6e73 m_ses_extensions │ │ │ +00007020: 5b70 6c75 6769 6e73 5f6f 7074 696d 6973 [plugins_optimis │ │ │ +00007030: 7469 635f 756e 6368 6f6b 655f 6964 785d tic_unchoke_idx] │ │ │ +00007040: 290a 2365 6c73 650a 0909 092c 206c 6173 ).#else...., las │ │ │ +00007050: 745f 6f70 7469 6d69 7374 6963 5f75 6e63 t_optimistic_unc │ │ │ +00007060: 686f 6b65 5f63 6d70 2829 0a3c 2f70 7265 hoke_cmp().rele │ │ │ +000070a0: 7661 6e63 6526 6e62 7370 3b33 3c2f 7464 vance 3../src/sess │ │ │ +000070e0: 696f 6e5f 696d 706c 2e63 7070 3a34 3538 ion_impl.cpp:458 │ │ │ +000070f0: 363c 2f61 3e3c 2f74 643e 3c74 643e 7468 6th │ │ │ +00007100: 6572 6520 7368 6f75 6c64 2062 6520 6120 ere should be a │ │ │ +00007110: 7072 652d 6361 6c63 756c 6174 6564 206c pre-calculated l │ │ │ +00007120: 6973 7420 6f66 2061 6c6c 2070 6565 7273 ist of all peers │ │ │ +00007130: 2065 6c69 6769 626c 6520 666f 7220 756e eligible for un │ │ │ +00007140: 6368 6f6b 696e 673c 2f74 643e 3c2f 7472 choking │ │ │ +00007180: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00007190: 3c68 323e 7468 6572 6520 7368 6f75 6c64

    there should │ │ │ +000071a0: 2062 6520 6120 7072 652d 6361 6c63 756c be a pre-calcul │ │ │ +000071b0: 6174 6564 206c 6973 7420 6f66 2061 6c6c ated list of all │ │ │ +000071c0: 2070 6565 7273 2065 6c69 6769 626c 6520 peers eligible │ │ │ +000071d0: 666f 720a 756e 6368 6f6b 696e 673c 2f68 for.unchoking

    ../src/ses │ │ │ +000071f0: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3435 sion_impl.cpp:45 │ │ │ +00007200: 3836 3c2f 6834 3e3c 7072 6520 7374 796c 86

    .}...void sessi
    │ │ │ +00007250: 6f6e 5f69 6d70 6c3a 3a72 6563 616c 6375  on_impl::recalcu
    │ │ │ +00007260: 6c61 7465 5f75 6e63 686f 6b65 5f73 6c6f  late_unchoke_slo
    │ │ │ +00007270: 7473 2829 0a09 7b0a 0909 544f 5252 454e  ts()..{...TORREN
    │ │ │ +00007280: 545f 4153 5345 5254 2869 735f 7369 6e67  T_ASSERT(is_sing
    │ │ │ +00007290: 6c65 5f74 6872 6561 6428 2929 3b0a 0a09  le_thread());...
    │ │ │ +000072a0: 0974 696d 655f 706f 696e 7420 636f 6e73  .time_point cons
    │ │ │ +000072b0: 7420 6e6f 7720 3d20 6175 783a 3a74 696d  t now = aux::tim
    │ │ │ +000072c0: 655f 6e6f 7728 293b 0a09 0974 696d 655f  e_now();...time_
    │ │ │ +000072d0: 6475 7261 7469 6f6e 2063 6f6e 7374 2075  duration const u
    │ │ │ +000072e0: 6e63 686f 6b65 5f69 6e74 6572 7661 6c20  nchoke_interval 
    │ │ │ +000072f0: 3d20 6e6f 7720 2d20 6d5f 6c61 7374 5f63  = now - m_last_c
    │ │ │ +00007300: 686f 6b65 3b0a 0909 6d5f 6c61 7374 5f63  hoke;...m_last_c
    │ │ │ +00007310: 686f 6b65 203d 206e 6f77 3b0a 0a09 092f  hoke = now;..../
    │ │ │ +00007320: 2f20 6966 2077 6520 756e 6368 6f6b 6520  / if we unchoke 
    │ │ │ +00007330: 6576 6572 796f 6e65 2c20 736b 6970 2074  everyone, skip t
    │ │ │ +00007340: 6869 7320 6c6f 6769 630a 0909 6966 2028  his logic...if (
    │ │ │ +00007350: 7365 7474 696e 6773 2829 2e67 6574 5f69  settings().get_i
    │ │ │ +00007360: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ +00007370: 3a3a 6368 6f6b 696e 675f 616c 676f 7269  ::choking_algori
    │ │ │ +00007380: 7468 6d29 203d 3d20 7365 7474 696e 6773  thm) == settings
    │ │ │ +00007390: 5f70 6163 6b3a 3a66 6978 6564 5f73 6c6f  _pack::fixed_slo
    │ │ │ +000073a0: 7473 5f63 686f 6b65 720a 0909 0926 616d  ts_choker....&am
    │ │ │ +000073b0: 703b 2661 6d70 3b20 7365 7474 696e 6773  p;& settings
    │ │ │ +000073c0: 2829 2e67 6574 5f69 6e74 2873 6574 7469  ().get_int(setti
    │ │ │ +000073d0: 6e67 735f 7061 636b 3a3a 756e 6368 6f6b  ngs_pack::unchok
    │ │ │ +000073e0: 655f 736c 6f74 735f 6c69 6d69 7429 2026  e_slots_limit) &
    │ │ │ +000073f0: 6c74 3b20 3029 0a09 097b 0a09 0909 6d5f  lt; 0)...{....m_
    │ │ │ +00007400: 7374 6174 735f 636f 756e 7465 7273 2e73  stats_counters.s
    │ │ │ +00007410: 6574 5f76 616c 7565 2863 6f75 6e74 6572  et_value(counter
    │ │ │ +00007420: 733a 3a6e 756d 5f75 6e63 686f 6b65 5f73  s::num_unchoke_s
    │ │ │ +00007430: 6c6f 7473 2c20 7374 643a 3a6e 756d 6572  lots, std::numer
    │ │ │ +00007440: 6963 5f6c 696d 6974 7326 6c74 3b69 6e74  ic_limits<int
    │ │ │ +00007450: 2667 743b 3a3a 6d61 7828 2929 3b0a 0909  >::max());...
    │ │ │ +00007460: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909  .return;...}....
    │ │ │ +00007470: 2f2f 2062 7569 6c64 206c 6973 7420 6f66  // build list of
    │ │ │ +00007480: 2061 6c6c 2070 6565 7273 2074 6861 7420   all peers that 
    │ │ │ +00007490: 6172 650a 0909 2f2f 2075 6e63 686f 6b61  are...// unchoka
    │ │ │ +000074a0: 626c 652e 0a3c 6469 7620 7374 796c 653d  ble..
    ..std::vector │ │ │ +000074e0: 266c 743b 7065 6572 5f63 6f6e 6e65 6374 <peer_connect │ │ │ +000074f0: 696f 6e2a 2667 743b 2070 6565 7273 3b0a ion*> peers;. │ │ │ +00007500: 3c2f 6469 763e 0909 666f 7220 2861 7574
    ..for (aut │ │ │ +00007510: 6f20 6920 3d20 6d5f 636f 6e6e 6563 7469 o i = m_connecti │ │ │ +00007520: 6f6e 732e 6265 6769 6e28 293b 2069 2021 ons.begin(); i ! │ │ │ +00007530: 3d20 6d5f 636f 6e6e 6563 7469 6f6e 732e = m_connections. │ │ │ +00007540: 656e 6428 293b 290a 0909 7b0a 0909 0973 end();)...{....s │ │ │ +00007550: 7464 3a3a 7368 6172 6564 5f70 7472 266c td::shared_ptr&l │ │ │ +00007560: 743b 7065 6572 5f63 6f6e 6e65 6374 696f t;peer_connectio │ │ │ +00007570: 6e26 6774 3b20 7020 3d20 2a69 3b0a 0909 n> p = *i;... │ │ │ +00007580: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00007590: 7029 3b0a 0909 092b 2b69 3b0a 0909 0974 p);....++i;....t │ │ │ +000075a0: 6f72 7265 6e74 2a20 636f 6e73 7420 7420 orrent* const t │ │ │ +000075b0: 3d20 702d 2667 743b 6173 736f 6369 6174 = p->associat │ │ │ +000075c0: 6564 5f74 6f72 7265 6e74 2829 2e6c 6f63 ed_torrent().loc │ │ │ +000075d0: 6b28 292e 6765 7428 293b 0a09 0909 746f k().get();....to │ │ │ +000075e0: 7272 656e 745f 7065 6572 2a20 636f 6e73 rrent_peer* cons │ │ │ +000075f0: 7420 7069 203d 2070 2d26 6774 3b70 6565 t pi = p->pee │ │ │ +00007600: 725f 696e 666f 5f73 7472 7563 7428 293b r_info_struct(); │ │ │ +00007610: 0a0a 0909 0969 6620 2870 2d26 6774 3b69 .....if (p->i │ │ │ +00007620: 676e 6f72 655f 756e 6368 6f6b 655f 736c gnore_unchoke_sl │ │ │ +00007630: 6f74 7328 2920 7c7c 2074 203d 3d20 6e75 ots() || t == nu │ │ │ +00007640: 6c6c 7074 7220 7c7c 2070 6920 3d3d 206e llptr || pi == n │ │ │ +00007650: 756c 6c70 7472 0a09 0909 097c 7c20 7069 ullptr.....|| pi │ │ │ +00007660: 2d26 6774 3b77 6562 5f73 6565 6420 7c7c ->web_seed || │ │ │ +00007670: 2074 2d26 6774 3b69 735f 7061 7573 6564 t->is_paused │ │ │ +00007680: 2829 290a 0909 097b 0a09 0909 0970 2d26 ())....{.....p-& │ │ │ +00007690: 6774 3b72 6573 6574 5f63 686f 6b65 5f63 gt;reset_choke_c │ │ │ +000076a0: 6f75 6e74 6572 7328 293b 0a09 0909 0963 ounters();.....c │ │ │ +000076b0: 6f6e 7469 6e75 653b 0a09 0909 7d0a 0a09 ontinue;....}... │ │ │ +000076c0: 0909 6966 2028 2170 2d26 6774 3b69 735f ..if (!p->is_ │ │ │ +000076d0: 7065 6572 5f69 6e74 6572 6573 7465 6428 peer_interested( │ │ │ +000076e0: 290a 0909 0909 7c7c 2070 2d26 6774 3b69 ).....|| p->i │ │ │ +000076f0: 735f 6469 7363 6f6e 6e65 6374 696e 6728 s_disconnecting( │ │ │ +00007700: 290a 0909 0909 7c7c 2070 2d26 6774 3b69 ).....|| p->i │ │ │ +00007710: 735f 636f 6e6e 6563 7469 6e67 2829 290a s_connecting()). │ │ │ +00007720: 0909 097b 0a09 0909 092f 2f20 7468 6973 ...{.....// this │ │ │ +00007730: 2070 6565 7220 6973 206e 6f74 2075 6e63 peer is not unc │ │ │ +00007740: 686f 6b61 626c 652e 2053 6f2c 2069 6620 hokable. So, if │ │ │ +00007750: 6974 2773 2075 6e63 686f 6b65 640a 0909 it's unchoked... │ │ │ +00007760: 0909 2f2f 2061 6c72 6561 6479 2c20 6d61 ..// already, ma │ │ │ +00007770: 6b65 2073 7572 6520 746f 2063 686f 6b65 ke sure to choke │ │ │ +00007780: 2069 742e 0a09 0909 0969 6620 2870 2d26 it......if (p-& │ │ │ +00007790: 6774 3b69 735f 6368 6f6b 6564 2829 290a gt;is_choked()). │ │ │ +000077a0: 0909 0909 7b0a 0909 0909 0970 2d26 6774 ....{......p-> │ │ │ +000077b0: 3b72 6573 6574 5f63 686f 6b65 5f63 6f75 ;reset_choke_cou │ │ │ +000077c0: 6e74 6572 7328 293b 0a09 0909 0909 636f nters();......co │ │ │ +000077d0: 6e74 696e 7565 3b0a 0909 0909 7d0a 0909 ntinue;.....}... │ │ │ +000077e0: 0909 6966 2028 7069 2026 616d 703b 2661 ..if (pi &&a │ │ │ +000077f0: 6d70 3b20 7069 2d26 6774 3b6f 7074 696d mp; pi->optim │ │ │ +00007800: 6973 7469 6361 6c6c 795f 756e 6368 6f6b istically_unchok │ │ │ +00007810: 6564 290a 0909 0909 7b0a 0909 0909 096d ed).....{......m │ │ │ +00007820: 5f73 7461 7473 5f63 6f75 6e74 6572 732e _stats_counters. │ │ │ +00007830: 696e 635f 7374 6174 735f 636f 756e 7465 inc_stats_counte │ │ │ +00007840: 7228 636f 756e 7465 7273 3a3a 6e75 6d5f r(counters::num_ │ │ │ +00007850: 7065 6572 735f 7570 5f75 6e63 686f 6b65 peers_up_unchoke │ │ │ +00007860: 645f 6f70 7469 6d69 7374 6963 2c20 2d31 d_optimistic, -1 │ │ │ +00007870: 293b 0a09 0909 0909 7069 2d26 6774 3b6f );......pi->o │ │ │ +00007880: 7074 696d 6973 7469 6361 6c6c 795f 756e ptimistically_un │ │ │ +00007890: 6368 6f6b 6564 203d 2066 616c 7365 3b0a choked = false;. │ │ │ +000078a0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +000078b0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +000078e0: 333c 2f74 643e 3c74 643e 3c61 2068 7265 3../src │ │ │ +00007910: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +00007920: 703a 3633 3232 3c2f 613e 3c2f 7464 3e3c p:6322< │ │ │ +00007930: 7464 3e75 7365 2070 7562 6c69 635f 6b65 td>use public_ke │ │ │ +00007940: 7920 6865 7265 2069 6e73 7465 6164 206f y here instead o │ │ │ +00007950: 6620 7374 643a 3a61 7272 6179 3c2f 7464 f std::array

    use pub │ │ │ +000079b0: 6c69 635f 6b65 7920 6865 7265 2069 6e73 lic_key here ins │ │ │ +000079c0: 7465 6164 206f 6620 7374 643a 3a61 7272 tead of std::arr │ │ │ +000079d0: 6179 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ay

    ../sr │ │ │ +000079e0: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +000079f0: 7070 3a36 3332 323c 2f68 343e 3c70 7265 pp:6322

    ..void ses
    │ │ │ +00007a40: 7369 6f6e 5f69 6d70 6c3a 3a64 6874 5f67  sion_impl::dht_g
    │ │ │ +00007a50: 6574 5f69 6d6d 7574 6162 6c65 5f69 7465  et_immutable_ite
    │ │ │ +00007a60: 6d28 7368 6131 5f68 6173 6820 636f 6e73  m(sha1_hash cons
    │ │ │ +00007a70: 7426 616d 703b 2074 6172 6765 7429 0a09  t& target)..
    │ │ │ +00007a80: 7b0a 0909 6966 2028 216d 5f64 6874 2920  {...if (!m_dht) 
    │ │ │ +00007a90: 7265 7475 726e 3b0a 0909 6d5f 6468 742d  return;...m_dht-
    │ │ │ +00007aa0: 2667 743b 6765 745f 6974 656d 2874 6172  >get_item(tar
    │ │ │ +00007ab0: 6765 742c 2073 7464 3a3a 6269 6e64 2826  get, std::bind(&
    │ │ │ +00007ac0: 616d 703b 7365 7373 696f 6e5f 696d 706c  amp;session_impl
    │ │ │ +00007ad0: 3a3a 6765 745f 696d 6d75 7461 626c 655f  ::get_immutable_
    │ │ │ +00007ae0: 6361 6c6c 6261 636b 0a09 0909 2c20 7468  callback...., th
    │ │ │ +00007af0: 6973 2c20 7461 7267 6574 2c20 5f31 2929  is, target, _1))
    │ │ │ +00007b00: 3b0a 097d 0a0a 092f 2f20 6361 6c6c 6261  ;..}...// callba
    │ │ │ +00007b10: 636b 2066 6f72 2064 6874 5f6d 7574 6162  ck for dht_mutab
    │ │ │ +00007b20: 6c65 5f67 6574 0a09 766f 6964 2073 6573  le_get..void ses
    │ │ │ +00007b30: 7369 6f6e 5f69 6d70 6c3a 3a67 6574 5f6d  sion_impl::get_m
    │ │ │ +00007b40: 7574 6162 6c65 5f63 616c 6c62 6163 6b28  utable_callback(
    │ │ │ +00007b50: 6468 743a 3a69 7465 6d20 636f 6e73 7426  dht::item const&
    │ │ │ +00007b60: 616d 703b 2069 0a09 092c 2062 6f6f 6c20  amp; i..., bool 
    │ │ │ +00007b70: 636f 6e73 7420 6175 7468 6f72 6974 6174  const authoritat
    │ │ │ +00007b80: 6976 6529 0a09 7b0a 0909 544f 5252 454e  ive)..{...TORREN
    │ │ │ +00007b90: 545f 4153 5345 5254 2869 2e69 735f 6d75  T_ASSERT(i.is_mu
    │ │ │ +00007ba0: 7461 626c 6528 2929 3b0a 0909 6d5f 616c  table());...m_al
    │ │ │ +00007bb0: 6572 7473 2e65 6d70 6c61 6365 5f61 6c65  erts.emplace_ale
    │ │ │ +00007bc0: 7274 266c 743b 6468 745f 6d75 7461 626c  rt<dht_mutabl
    │ │ │ +00007bd0: 655f 6974 656d 5f61 6c65 7274 2667 743b  e_item_alert>
    │ │ │ +00007be0: 2869 2e70 6b28 292e 6279 7465 730a 0909  (i.pk().bytes...
    │ │ │ +00007bf0: 092c 2069 2e73 6967 2829 2e62 7974 6573  ., i.sig().bytes
    │ │ │ +00007c00: 2c20 692e 7365 7128 292e 7661 6c75 650a  , i.seq().value.
    │ │ │ +00007c10: 0909 092c 2069 2e73 616c 7428 292c 2069  ..., i.salt(), i
    │ │ │ +00007c20: 2e76 616c 7565 2829 2c20 6175 7468 6f72  .value(), author
    │ │ │ +00007c30: 6974 6174 6976 6529 3b0a 097d 0a0a 092f  itative);..}.../
    │ │ │ +00007c40: 2f20 6b65 7920 6973 2061 2033 322d 6279  / key is a 32-by
    │ │ │ +00007c50: 7465 2062 696e 6172 7920 7374 7269 6e67  te binary string
    │ │ │ +00007c60: 2c20 7468 6520 7075 626c 6963 206b 6579  , the public key
    │ │ │ +00007c70: 2074 6f20 6c6f 6f6b 2075 702e 0a09 2f2f   to look up...//
    │ │ │ +00007c80: 2074 6865 2073 616c 7420 6973 206f 7074   the salt is opt
    │ │ │ +00007c90: 696f 6e61 6c0a 3c64 6976 2073 7479 6c65  ional.
    .void sessio │ │ │ +00007cd0: 6e5f 696d 706c 3a3a 6468 745f 6765 745f n_impl::dht_get_ │ │ │ +00007ce0: 6d75 7461 626c 655f 6974 656d 2873 7464 mutable_item(std │ │ │ +00007cf0: 3a3a 6172 7261 7926 6c74 3b63 6861 722c ::array<char, │ │ │ +00007d00: 2033 3226 6774 3b20 6b65 790a 3c2f 6469 32> key..., std::strin │ │ │ +00007d20: 6720 7361 6c74 290a 097b 0a09 0969 6620 g salt)..{...if │ │ │ +00007d30: 2821 6d5f 6468 7429 2072 6574 7572 6e3b (!m_dht) return; │ │ │ +00007d40: 0a09 096d 5f64 6874 2d26 6774 3b67 6574 ...m_dht->get │ │ │ +00007d50: 5f69 7465 6d28 6468 743a 3a70 7562 6c69 _item(dht::publi │ │ │ +00007d60: 635f 6b65 7928 6b65 792e 6461 7461 2829 c_key(key.data() │ │ │ +00007d70: 292c 2073 7464 3a3a 6269 6e64 2826 616d ), std::bind(&am │ │ │ +00007d80: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +00007d90: 6765 745f 6d75 7461 626c 655f 6361 6c6c get_mutable_call │ │ │ +00007da0: 6261 636b 0a09 0909 2c20 7468 6973 2c20 back...., this, │ │ │ +00007db0: 5f31 2c20 5f32 292c 2073 7464 3a3a 6d6f _1, _2), std::mo │ │ │ +00007dc0: 7665 2873 616c 7429 293b 0a09 7d0a 0a09 ve(salt));..}... │ │ │ +00007dd0: 6e61 6d65 7370 6163 6520 7b0a 0a09 0976 namespace {....v │ │ │ +00007de0: 6f69 6420 6f6e 5f64 6874 5f70 7574 5f69 oid on_dht_put_i │ │ │ +00007df0: 6d6d 7574 6162 6c65 5f69 7465 6d28 6175 mmutable_item(au │ │ │ +00007e00: 783a 3a61 6c65 7274 5f6d 616e 6167 6572 x::alert_manager │ │ │ +00007e10: 2661 6d70 3b20 616c 6572 7473 2c20 7368 & alerts, sh │ │ │ +00007e20: 6131 5f68 6173 6820 7461 7267 6574 2c20 a1_hash target, │ │ │ +00007e30: 696e 7420 6e75 6d29 0a09 097b 0a09 0909 int num)...{.... │ │ │ +00007e40: 6966 2028 616c 6572 7473 2e73 686f 756c if (alerts.shoul │ │ │ +00007e50: 645f 706f 7374 266c 743b 6468 745f 7075 d_post<dht_pu │ │ │ +00007e60: 745f 616c 6572 7426 6774 3b28 2929 0a09 t_alert>()).. │ │ │ +00007e70: 0909 0961 6c65 7274 732e 656d 706c 6163 ...alerts.emplac │ │ │ +00007e80: 655f 616c 6572 7426 6c74 3b64 6874 5f70 e_alert<dht_p │ │ │ +00007e90: 7574 5f61 6c65 7274 2667 743b 2874 6172 ut_alert>(tar │ │ │ +00007ea0: 6765 742c 206e 756d 293b 0a09 097d 0a0a get, num);...}.. │ │ │ +00007eb0: 0909 766f 6964 206f 6e5f 6468 745f 7075 ..void on_dht_pu │ │ │ +00007ec0: 745f 6d75 7461 626c 655f 6974 656d 2861 t_mutable_item(a │ │ │ +00007ed0: 7578 3a3a 616c 6572 745f 6d61 6e61 6765 ux::alert_manage │ │ │ +00007ee0: 7226 616d 703b 2061 6c65 7274 732c 2064 r& alerts, d │ │ │ +00007ef0: 6874 3a3a 6974 656d 2063 6f6e 7374 2661 ht::item const&a │ │ │ +00007f00: 6d70 3b20 692c 2069 6e74 206e 756d 290a mp; i, int num). │ │ │ +00007f10: 0909 7b0a 0909 0969 6620 2861 6c65 7274 ..{....if (alert │ │ │ +00007f20: 732e 7368 6f75 6c64 5f70 6f73 7426 6c74 s.should_post< │ │ │ +00007f30: 3b64 6874 5f70 7574 5f61 6c65 7274 2667 ;dht_put_alert&g │ │ │ +00007f40: 743b 2829 290a 0909 097b 0a09 0909 0964 t;())....{.....d │ │ │ +00007f50: 6874 3a3a 7369 676e 6174 7572 6520 636f ht::signature co │ │ │ +00007f60: 6e73 7420 7369 6720 3d20 692e 7369 6728 nst sig = i.sig( │ │ │ +00007f70: 293b 0a09 0909 0964 6874 3a3a 7075 626c );.....dht::publ │ │ │ +00007f80: 6963 5f6b 6579 2063 6f6e 7374 2070 6b20 ic_key const pk │ │ │ +00007f90: 3d20 692e 706b 2829 3b0a 0909 0909 6468 = i.pk();.....dh │ │ │ +00007fa0: 743a 3a73 6571 7565 6e63 655f 6e75 6d62 t::sequence_numb │ │ │ +00007fb0: 6572 2063 6f6e 7374 2073 6571 203d 2069 er const seq = i │ │ │ +00007fc0: 2e73 6571 2829 3b0a 0909 0909 7374 643a .seq();.....std: │ │ │ +00007fd0: 3a73 7472 696e 6720 7361 6c74 203d 2069 :string salt = i │ │ │ +00007fe0: 2e73 616c 7428 293b 0a09 0909 0961 6c65 .salt();.....ale │ │ │ +00007ff0: 7274 732e 656d 706c 6163 655f 616c 6572 rts.emplace_aler │ │ │ +00008000: 7426 6c74 3b64 6874 5f70 7574 5f61 6c65 t<dht_put_ale │ │ │ +00008010: 7274 2667 743b 2870 6b2e 6279 7465 732c rt>(pk.bytes, │ │ │ +00008020: 2073 6967 2e62 7974 6573 0a09 0909 0909 sig.bytes...... │ │ │ +00008030: 2c20 7374 643a 3a6d 6f76 6528 7361 6c74 , std::move(salt │ │ │ +00008040: 292c 2073 6571 2e76 616c 7565 2c20 6e75 ), seq.value, nu │ │ │ +00008050: 6d29 3b0a 0909 097d 0a09 097d 0a0a 0909 m);....}...}.... │ │ │ +00008060: 766f 6964 2070 7574 5f6d 7574 6162 6c65 void put_mutable │ │ │ +00008070: 5f63 616c 6c62 6163 6b28 6468 743a 3a69 _callback(dht::i │ │ │ +00008080: 7465 6d26 616d 703b 2069 0a09 0909 2c20 tem& i...., │ │ │ +00008090: 7374 643a 3a66 756e 6374 696f 6e26 6c74 std::function< │ │ │ +000080a0: 3b76 6f69 6428 656e 7472 7926 616d 703b ;void(entry& │ │ │ +000080b0: 2c20 7374 643a 3a61 7272 6179 266c 743b , std::array< │ │ │ +000080c0: 6368 6172 2c20 3634 2667 743b 2661 6d70 char, 64>& │ │ │ +000080d0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +00008100: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00008110: 703b 333c 2f74 643e 3c74 643e 3c61 2068 p;3../s │ │ │ +00008140: 7263 2f77 6562 5f70 6565 725f 636f 6e6e rc/web_peer_conn │ │ │ +00008150: 6563 7469 6f6e 2e63 7070 3a31 3735 3c2f ection.cpp:175this │ │ │ +00008170: 7368 6f75 6c64 2062 6520 616e 206f 7074 should be an opt │ │ │ +00008180: 696f 6e61 6c3c 7069 6563 655f 696e 6465 ional, piece inde │ │ │ +000081a0: 7820 2d31 2073 686f 756c 6420 6e6f 7420 x -1 should not │ │ │ +000081b0: 6265 2061 6c6c 6f77 6564 3c2f 7464 3e3c be allowed< │ │ │ +000081c0: 2f74 723e 3c74 7220 6964 3d22 3136 2220 /tr>

    this shou │ │ │ +00008210: 6c64 2062 6520 616e 206f 7074 696f 6e61 ld be an optiona │ │ │ +00008220: 6c3c 7069 6563 655f 696e 6465 785f 743e l │ │ │ +00008230: 2c20 7069 6563 6520 696e 6465 7820 2d31 , piece index -1 │ │ │ +00008240: 2073 686f 756c 640a 6e6f 7420 6265 2061 should.not be a │ │ │ +00008250: 6c6c 6f77 6564 3c2f 6832 3e3c 6834 3e2e llowed

    . │ │ │ +00008260: 2e2f 7372 632f 7765 625f 7065 6572 5f63 ./src/web_peer_c │ │ │ +00008270: 6f6e 6e65 6374 696f 6e2e 6370 703a 3137 onnection.cpp:17 │ │ │ +00008280: 353c 2f68 343e 3c70 7265 2073 7479 6c65 5

    │ │ │ +000082c0: 0909 0969 6620 286d 5f77 6562 2d26 6774  ...if (m_web->
    │ │ │ +000082d0: 3b68 6176 655f 6669 6c65 732e 6765 745f  ;have_files.get_
    │ │ │ +000082e0: 6269 7428 6929 207c 7c20 6673 2e70 6164  bit(i) || fs.pad
    │ │ │ +000082f0: 5f66 696c 655f 6174 2869 2929 2063 6f6e  _file_at(i)) con
    │ │ │ +00008300: 7469 6e75 653b 0a0a 0909 0966 6f72 2028  tinue;.....for (
    │ │ │ +00008310: 7069 6563 655f 696e 6465 785f 7420 636f  piece_index_t co
    │ │ │ +00008320: 6e73 7420 6b20 3a20 6175 783a 3a66 696c  nst k : aux::fil
    │ │ │ +00008330: 655f 7069 6563 655f 7261 6e67 655f 696e  e_piece_range_in
    │ │ │ +00008340: 636c 7573 6976 6528 6673 2c20 6929 290a  clusive(fs, i)).
    │ │ │ +00008350: 0909 0909 6861 7665 2e63 6c65 6172 5f62  ....have.clear_b
    │ │ │ +00008360: 6974 286b 293b 0a09 097d 0a09 0974 2d26  it(k);...}...t-&
    │ │ │ +00008370: 6774 3b73 6574 5f73 6565 6428 7065 6572  gt;set_seed(peer
    │ │ │ +00008380: 5f69 6e66 6f5f 7374 7275 6374 2829 2c20  _info_struct(), 
    │ │ │ +00008390: 6661 6c73 6529 3b0a 0909 6966 2028 6861  false);...if (ha
    │ │ │ +000083a0: 7665 2e6e 6f6e 655f 7365 7428 2929 0a09  ve.none_set())..
    │ │ │ +000083b0: 097b 0a09 0909 696e 636f 6d69 6e67 5f68  .{....incoming_h
    │ │ │ +000083c0: 6176 655f 6e6f 6e65 2829 3b0a 0909 096d  ave_none();....m
    │ │ │ +000083d0: 5f77 6562 2d26 6774 3b69 6e74 6572 6573  _web->interes
    │ │ │ +000083e0: 7469 6e67 203d 2066 616c 7365 3b0a 2369  ting = false;.#i
    │ │ │ +000083f0: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ +00008400: 5341 424c 455f 4c4f 4747 494e 470a 0909  SABLE_LOGGING...
    │ │ │ +00008410: 0970 6565 725f 6c6f 6728 7065 6572 5f6c  .peer_log(peer_l
    │ │ │ +00008420: 6f67 5f61 6c65 7274 3a3a 696e 666f 2c20  og_alert::info, 
    │ │ │ +00008430: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a  peer_log_alert::
    │ │ │ +00008440: 7765 625f 7365 6564 2c20 2268 6176 6520  web_seed, "have 
    │ │ │ +00008450: 6e6f 2070 6965 6365 732c 206e 6f74 2069  no pieces, not i
    │ │ │ +00008460: 6e74 6572 6573 7469 6e67 2e20 2573 222c  nteresting. %s",
    │ │ │ +00008470: 206d 5f75 726c 2e63 5f73 7472 2829 293b   m_url.c_str());
    │ │ │ +00008480: 0a23 656e 6469 660a 0909 7d0a 0909 656c  .#endif...}...el
    │ │ │ +00008490: 7365 0a09 097b 0a09 0909 696e 636f 6d69  se...{....incomi
    │ │ │ +000084a0: 6e67 5f62 6974 6669 656c 6428 6861 7665  ng_bitfield(have
    │ │ │ +000084b0: 293b 0a09 097d 0a09 7d0a 0a3c 6469 7620  );...}..}..
    .if (m_ │ │ │ +000084f0: 7765 622d 2667 743b 7265 7374 6172 745f web->restart_ │ │ │ +00008500: 7265 7175 6573 742e 7069 6563 6520 213d request.piece != │ │ │ +00008510: 2070 6965 6365 5f69 6e64 6578 5f74 282d piece_index_t(- │ │ │ +00008520: 3129 290a 3c2f 6469 763e 097b 0a09 092f 1)).
    .{.../ │ │ │ +00008530: 2f20 696e 6372 6561 7365 2074 6865 2063 / increase the c │ │ │ +00008540: 6861 6e63 6573 206f 6620 7265 7175 6573 hances of reques │ │ │ +00008550: 7469 6e67 2074 6865 2062 6c6f 636b 0a09 ting the block.. │ │ │ +00008560: 092f 2f20 7765 2068 6176 6520 7061 7274 .// we have part │ │ │ +00008570: 6961 6c20 6461 7461 2066 6f72 2061 6c72 ial data for alr │ │ │ +00008580: 6561 6479 2c20 746f 2066 696e 6973 6820 eady, to finish │ │ │ +00008590: 6974 0a09 0969 6e63 6f6d 696e 675f 7375 it...incoming_su │ │ │ +000085a0: 6767 6573 7428 6d5f 7765 622d 2667 743b ggest(m_web-> │ │ │ +000085b0: 7265 7374 6172 745f 7265 7175 6573 742e restart_request. │ │ │ +000085c0: 7069 6563 6529 3b0a 097d 0a09 7765 625f piece);..}..web_ │ │ │ +000085d0: 636f 6e6e 6563 7469 6f6e 5f62 6173 653a connection_base: │ │ │ +000085e0: 3a6f 6e5f 636f 6e6e 6563 7465 6428 293b :on_connected(); │ │ │ +000085f0: 0a7d 0a0a 766f 6964 2077 6562 5f70 6565 .}..void web_pee │ │ │ +00008600: 725f 636f 6e6e 6563 7469 6f6e 3a3a 6469 r_connection::di │ │ │ +00008610: 7363 6f6e 6e65 6374 2865 7272 6f72 5f63 sconnect(error_c │ │ │ +00008620: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ +00008630: 630a 092c 206f 7065 7261 7469 6f6e 5f74 c.., operation_t │ │ │ +00008640: 206f 702c 2064 6973 636f 6e6e 6563 745f op, disconnect_ │ │ │ +00008650: 7365 7665 7269 7479 5f74 2063 6f6e 7374 severity_t const │ │ │ +00008660: 2065 7272 6f72 290a 7b0a 0969 6620 2869 error).{..if (i │ │ │ +00008670: 735f 6469 7363 6f6e 6e65 6374 696e 6728 s_disconnecting( │ │ │ +00008680: 2929 2072 6574 7572 6e3b 0a0a 0969 6620 )) return;...if │ │ │ +00008690: 286f 7020 3d3d 206f 7065 7261 7469 6f6e (op == operation │ │ │ +000086a0: 5f74 3a3a 736f 636b 5f77 7269 7465 2026 _t::sock_write & │ │ │ +000086b0: 616d 703b 2661 6d70 3b20 6563 203d 3d20 amp;& ec == │ │ │ +000086c0: 626f 6f73 743a 3a73 7973 7465 6d3a 3a65 boost::system::e │ │ │ +000086d0: 7272 633a 3a62 726f 6b65 6e5f 7069 7065 rrc::broken_pipe │ │ │ +000086e0: 290a 097b 0a23 6966 6e64 6566 2054 4f52 )..{.#ifndef TOR │ │ │ +000086f0: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ +00008700: 4749 4e47 0a09 092f 2f20 6120 7772 6974 GING...// a writ │ │ │ +00008710: 6520 6f70 6572 6174 696f 6e20 6661 696c e operation fail │ │ │ +00008720: 6564 2077 6974 6820 6272 6f6b 656e 2d70 ed with broken-p │ │ │ +00008730: 6970 652e 2054 6869 7320 7479 7069 6361 ipe. This typica │ │ │ +00008740: 6c6c 7920 6861 7070 656e 730a 0909 2f2f lly happens...// │ │ │ +00008750: 2077 6974 6820 4854 5450 2031 2e30 2073 with HTTP 1.0 s │ │ │ +00008760: 6572 7665 7273 2074 6861 7420 636c 6f73 ervers that clos │ │ │ +00008770: 6520 7468 6569 7220 696e 636f 6d69 6e67 e their incoming │ │ │ +00008780: 2063 6861 6e6e 656c 206f 6620 7468 6520 channel of the │ │ │ +00008790: 5443 500a 0909 2f2f 2073 7472 6561 6d20 TCP...// stream │ │ │ +000087a0: 7768 656e 6576 6572 2074 6865 7927 7265 whenever they're │ │ │ +000087b0: 2064 6f6e 6520 7265 6164 696e 6720 6f6e done reading on │ │ │ +000087c0: 6520 6675 6c6c 2072 6571 7565 7374 2e20 e full request. │ │ │ +000087d0: 496e 7374 6561 6420 6f66 0a09 092f 2f20 Instead of...// │ │ │ +000087e0: 7573 2062 6169 6c69 6e67 206f 7574 2061 us bailing out a │ │ │ +000087f0: 6e64 2066 6169 6c69 6e67 2074 6865 2065 nd failing the e │ │ │ +00008800: 6e74 6972 6520 7265 7175 6573 7420 6a75 ntire request ju │ │ │ +00008810: 7374 2062 6563 6175 7365 206f 7572 0a09 st because our.. │ │ │ +00008820: 092f 2f20 7772 6974 652d 656e 6420 7761 .// write-end wa │ │ │ +00008830: 7320 636c 6f73 6564 2c20 6967 6e6f 7265 s closed, ignore │ │ │ +00008840: 2069 7420 616e 6420 6b65 6570 2072 6561 it and keep rea │ │ │ +00008850: 6469 6e67 2075 6e74 696c 2074 6865 2072 ding until the r │ │ │ +00008860: 6561 642d 656e 640a 0909 2f2f 2061 6c73 ead-end...// als │ │ │ +00008870: 6f20 6973 2063 6c6f 7365 642e 0a09 0970 o is closed....p │ │ │ +00008880: 6565 725f 6c6f 6728 7065 6572 5f6c 6f67 eer_log(peer_log │ │ │ +00008890: 5f61 6c65 7274 3a3a 696e 666f 2c20 7065 _alert::info, pe │ │ │ +000088a0: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 7765 er_log_alert::we │ │ │ +000088b0: 625f 7365 6564 2c20 2243 4c4f 5345 4422 b_seed, "CLOSED" │ │ │ +000088c0: 293b 0a23 656e 6469 660a 0a09 092f 2f20 );.#endif....// │ │ │ +000088d0: 7072 6576 656e 7420 7468 6520 7065 6572 prevent the peer │ │ │ +000088e0: 2066 726f 6d20 7472 7969 6e67 2074 6f20 from trying to │ │ │ +000088f0: 7365 6e64 2061 6e79 7468 696e 6720 6d6f send anything mo │ │ │ +00008900: 7265 0a09 096d 5f73 656e 645f 6275 6666 re...m_send_buff │ │ │ +00008910: 6572 2e63 6c65 6172 2829 3b0a 0a09 092f er.clear();..../ │ │ │ +00008920: 2f20 7768 656e 2074 6865 2077 6562 2073 / when the web s │ │ │ +00008930: 6572 7665 7220 636c 6f73 6564 206f 7572 erver closed our │ │ │ +00008940: 2077 7269 7465 2d65 6e64 206f 6620 7468 write-end of th │ │ │ +00008950: 6520 736f 636b 6574 2028 692e 652e 2069 e socket (i.e. i │ │ │ +00008960: 7473 0a09 092f 2f20 7265 6164 2d65 6e64 ts...// read-end │ │ │ +00008970: 292c 2069 6620 6974 2773 2061 6e20 4854 ), if it's an HT │ │ │ +00008980: 5450 2031 2e30 2073 6572 7665 722e 2077 TP 1.0 server. w │ │ │ +00008990: 6520 7769 6c6c 2073 746f 7020 7365 6e64 e will stop send │ │ │ +000089a0: 696e 6720 6d6f 7265 0a3c 2f70 7265 3e3c ing more.
    < │ │ │ +000089b0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +000089e0: 6e63 6526 6e62 7370 3b33 3c2f 7464 3e3c nce 3< │ │ │ +000089f0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../src/web_pe │ │ │ +00008a20: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ +00008a30: 703a 3339 373c 2f61 3e3c 2f74 643e 3c74 p:397do we really n │ │ │ +00008a50: 6565 6420 6120 7370 6563 6961 6c20 6361 eed a special ca │ │ │ +00008a60: 7365 2068 6572 653f 2077 6f75 6c64 6e27 se here? wouldn' │ │ │ +00008a70: 7420 7468 6520 6d75 6c74 692d 6669 6c65 t the multi-file │ │ │ +00008a80: 2063 6173 6520 6861 6e64 6c65 2073 696e case handle sin │ │ │ +00008a90: 676c 6520 6669 6c65 2074 6f72 7265 6e74 gle file torrent │ │ │ +00008aa0: 7320 636f 7272 6563 746c 7920 746f 6f3f s correctly too? │ │ │ +00008ab0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    do │ │ │ +00008b00: 7765 2072 6561 6c6c 7920 6e65 6564 2061 we really need a │ │ │ +00008b10: 2073 7065 6369 616c 2063 6173 6520 6865 special case he │ │ │ +00008b20: 7265 3f20 776f 756c 646e 2774 2074 6865 re? wouldn't the │ │ │ +00008b30: 206d 756c 7469 2d66 696c 650a 6361 7365 multi-file.case │ │ │ +00008b40: 2068 616e 646c 6520 7369 6e67 6c65 2066 handle single f │ │ │ +00008b50: 696c 6520 746f 7272 656e 7473 2063 6f72 ile torrents cor │ │ │ +00008b60: 7265 6374 6c79 2074 6f6f 3f3c 2f68 323e rectly too?

    │ │ │ +00008b70: 3c68 343e 2e2e 2f73 7263 2f77 6562 5f70

    ../src/web_p │ │ │ +00008b80: 6565 725f 636f 6e6e 6563 7469 6f6e 2e63 eer_connection.c │ │ │ +00008b90: 7070 3a33 3937 3c2f 6834 3e3c 7072 6520 pp:397

    ..}..}..#if
    │ │ │ +00008be0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ +00008bf0: 4142 4c45 5f4c 4f47 4749 4e47 0a09 7065  ABLE_LOGGING..pe
    │ │ │ +00008c00: 6572 5f6c 6f67 2870 6565 725f 6c6f 675f  er_log(peer_log_
    │ │ │ +00008c10: 616c 6572 743a 3a6f 7574 676f 696e 675f  alert::outgoing_
    │ │ │ +00008c20: 6d65 7373 6167 652c 2070 6565 725f 6c6f  message, peer_lo
    │ │ │ +00008c30: 675f 616c 6572 743a 3a72 6571 7565 7374  g_alert::request
    │ │ │ +00008c40: 2c20 2228 7069 6563 653a 2025 6420 7374  , "(piece: %d st
    │ │ │ +00008c50: 6172 743a 2025 6429 202d 2028 7069 6563  art: %d) - (piec
    │ │ │ +00008c60: 653a 2025 6420 656e 643a 2025 6429 220a  e: %d end: %d)".
    │ │ │ +00008c70: 0909 2c20 7374 6174 6963 5f63 6173 7426  .., static_cast&
    │ │ │ +00008c80: 6c74 3b69 6e74 2667 743b 2872 2e70 6965  lt;int>(r.pie
    │ │ │ +00008c90: 6365 292c 2072 2e73 7461 7274 0a09 092c  ce), r.start...,
    │ │ │ +00008ca0: 2073 7461 7469 635f 6361 7374 266c 743b   static_cast<
    │ │ │ +00008cb0: 696e 7426 6774 3b28 7072 2e70 6965 6365  int>(pr.piece
    │ │ │ +00008cc0: 292c 2070 722e 7374 6172 7420 2b20 7072  ), pr.start + pr
    │ │ │ +00008cd0: 2e6c 656e 6774 6829 3b0a 2365 6e64 6966  .length);.#endif
    │ │ │ +00008ce0: 0a0a 0962 6f6f 6c20 636f 6e73 7420 7369  ...bool const si
    │ │ │ +00008cf0: 6e67 6c65 5f66 696c 655f 7265 7175 6573  ngle_file_reques
    │ │ │ +00008d00: 7420 3d20 742d 2667 743b 746f 7272 656e  t = t->torren
    │ │ │ +00008d10: 745f 6669 6c65 2829 2e6e 756d 5f66 696c  t_file().num_fil
    │ │ │ +00008d20: 6573 2829 203d 3d20 313b 0a09 696e 7420  es() == 1;..int 
    │ │ │ +00008d30: 636f 6e73 7420 7072 6f78 795f 7479 7065  const proxy_type
    │ │ │ +00008d40: 203d 206d 5f73 6574 7469 6e67 732e 6765   = m_settings.ge
    │ │ │ +00008d50: 745f 696e 7428 7365 7474 696e 6773 5f70  t_int(settings_p
    │ │ │ +00008d60: 6163 6b3a 3a70 726f 7879 5f74 7970 6529  ack::proxy_type)
    │ │ │ +00008d70: 3b0a 0962 6f6f 6c20 636f 6e73 7420 7573  ;..bool const us
    │ │ │ +00008d80: 696e 675f 7072 6f78 7920 3d20 2870 726f  ing_proxy = (pro
    │ │ │ +00008d90: 7879 5f74 7970 6520 3d3d 2073 6574 7469  xy_type == setti
    │ │ │ +00008da0: 6e67 735f 7061 636b 3a3a 6874 7470 0a09  ngs_pack::http..
    │ │ │ +00008db0: 097c 7c20 7072 6f78 795f 7479 7065 203d  .|| proxy_type =
    │ │ │ +00008dc0: 3d20 7365 7474 696e 6773 5f70 6163 6b3a  = settings_pack:
    │ │ │ +00008dd0: 3a68 7474 705f 7077 2920 2661 6d70 3b26  :http_pw) &&
    │ │ │ +00008de0: 616d 703b 2021 6d5f 7373 6c3b 0a0a 092f  amp; !m_ssl;.../
    │ │ │ +00008df0: 2f20 7468 6520 6e75 6d62 6572 206f 6620  / the number of 
    │ │ │ +00008e00: 7061 6420 6669 6c65 7320 7468 6174 2068  pad files that h
    │ │ │ +00008e10: 6176 6520 6265 656e 2022 7265 7175 6573  ave been "reques
    │ │ │ +00008e20: 7465 6422 2e20 496e 2063 6173 6520 7765  ted". In case we
    │ │ │ +00008e30: 205f 6f6e 6c79 5f0a 092f 2f20 7265 7175   _only_..// requ
    │ │ │ +00008e40: 6573 7420 7061 6466 696c 6573 2c20 7765  est padfiles, we
    │ │ │ +00008e50: 2063 616e 2774 2072 656c 7920 6f6e 2068   can't rely on h
    │ │ │ +00008e60: 616e 646c 696e 6720 7468 656d 2069 6e20  andling them in 
    │ │ │ +00008e70: 7468 6520 6f6e 5f72 6563 6569 7665 2829  the on_receive()
    │ │ │ +00008e80: 0a09 2f2f 2063 616c 6c62 6163 6b20 2862  ..// callback (b
    │ │ │ +00008e90: 6563 6175 7365 2077 6520 776f 6e27 7420  ecause we won't 
    │ │ │ +00008ea0: 7265 6365 6976 6520 616e 7974 6869 6e67  receive anything
    │ │ │ +00008eb0: 292c 2069 6e73 7465 6164 2077 6520 6861  ), instead we ha
    │ │ │ +00008ec0: 7665 2074 6f20 706f 7374 2061 0a09 2f2f  ve to post a..//
    │ │ │ +00008ed0: 2070 7265 7465 6e64 2072 6561 6420 6361   pretend read ca
    │ │ │ +00008ee0: 6c6c 6261 636b 2077 6865 7265 2077 6520  llback where we 
    │ │ │ +00008ef0: 6361 6e20 6465 6c69 7665 7220 7468 6520  can deliver the 
    │ │ │ +00008f00: 7a65 726f 6573 2066 6f72 2074 6865 2070  zeroes for the p
    │ │ │ +00008f10: 6172 7466 696c 650a 0969 6e74 206e 756d  artfile..int num
    │ │ │ +00008f20: 5f70 6164 5f66 696c 6573 203d 2030 3b0a  _pad_files = 0;.
    │ │ │ +00008f30: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00008f60: 6966 2028 7369 6e67 6c65 5f66 696c 655f if (single_file_ │ │ │ +00008f70: 7265 7175 6573 7429 0a3c 2f64 6976 3e09 request).
    . │ │ │ +00008f80: 7b0a 0909 6669 6c65 5f72 6571 7565 7374 {...file_request │ │ │ +00008f90: 5f74 2066 696c 655f 7265 713b 0a09 0966 _t file_req;...f │ │ │ +00008fa0: 696c 655f 7265 712e 6669 6c65 5f69 6e64 ile_req.file_ind │ │ │ +00008fb0: 6578 203d 2066 696c 655f 696e 6465 785f ex = file_index_ │ │ │ +00008fc0: 7428 3029 3b0a 0909 6669 6c65 5f72 6571 t(0);...file_req │ │ │ +00008fd0: 2e73 7461 7274 203d 2073 7464 3a3a 696e .start = std::in │ │ │ +00008fe0: 7436 345f 7428 7374 6174 6963 5f63 6173 t64_t(static_cas │ │ │ +00008ff0: 7426 6c74 3b69 6e74 2667 743b 2872 6571 t<int>(req │ │ │ +00009000: 2e70 6965 6365 2929 202a 2069 6e66 6f2e .piece)) * info. │ │ │ +00009010: 7069 6563 655f 6c65 6e67 7468 2829 0a09 piece_length().. │ │ │ +00009020: 0909 2b20 7265 712e 7374 6172 743b 0a09 ..+ req.start;.. │ │ │ +00009030: 0966 696c 655f 7265 712e 6c65 6e67 7468 .file_req.length │ │ │ +00009040: 203d 2072 6571 2e6c 656e 6774 683b 0a0a = req.length;.. │ │ │ +00009050: 0909 7265 7175 6573 7420 2b3d 2022 4745 ..request += "GE │ │ │ +00009060: 5420 223b 0a09 092f 2f20 646f 206e 6f74 T ";...// do not │ │ │ +00009070: 2065 6e63 6f64 6520 7369 6e67 6c65 2066 encode single f │ │ │ +00009080: 696c 6520 7061 7468 732c 2074 6865 7920 ile paths, they │ │ │ +00009090: 6172 650a 0909 2f2f 2061 7373 756d 6564 are...// assumed │ │ │ +000090a0: 2074 6f20 6265 2065 6e63 6f64 6564 2069 to be encoded i │ │ │ +000090b0: 6e20 7468 6520 746f 7272 656e 7420 6669 n the torrent fi │ │ │ +000090c0: 6c65 0a09 0972 6571 7565 7374 202b 3d20 le...request += │ │ │ +000090d0: 7573 696e 675f 7072 6f78 7920 3f20 6d5f using_proxy ? m_ │ │ │ +000090e0: 7572 6c20 3a20 6d5f 7061 7468 3b0a 0909 url : m_path;... │ │ │ +000090f0: 7265 7175 6573 7420 2b3d 2022 2048 5454 request += " HTT │ │ │ +00009100: 502f 312e 315c 725c 6e22 3b0a 0909 6164 P/1.1\r\n";...ad │ │ │ +00009110: 645f 6865 6164 6572 7328 7265 7175 6573 d_headers(reques │ │ │ +00009120: 742c 206d 5f73 6574 7469 6e67 732c 2075 t, m_settings, u │ │ │ +00009130: 7369 6e67 5f70 726f 7879 293b 0a09 0972 sing_proxy);...r │ │ │ +00009140: 6571 7565 7374 202b 3d20 225c 725c 6e52 equest += "\r\nR │ │ │ +00009150: 616e 6765 3a20 6279 7465 733d 223b 0a09 ange: bytes=";.. │ │ │ +00009160: 0972 6571 7565 7374 202b 3d20 746f 5f73 .request += to_s │ │ │ +00009170: 7472 696e 6728 6669 6c65 5f72 6571 2e73 tring(file_req.s │ │ │ +00009180: 7461 7274 292e 6461 7461 2829 3b0a 0909 tart).data();... │ │ │ +00009190: 7265 7175 6573 7420 2b3d 2022 2d22 3b0a request += "-";. │ │ │ +000091a0: 0909 7265 7175 6573 7420 2b3d 2074 6f5f ..request += to_ │ │ │ +000091b0: 7374 7269 6e67 2866 696c 655f 7265 712e string(file_req. │ │ │ +000091c0: 7374 6172 7420 2b20 6669 6c65 5f72 6571 start + file_req │ │ │ +000091d0: 2e6c 656e 6774 6820 2d20 3129 2e64 6174 .length - 1).dat │ │ │ +000091e0: 6128 293b 0a09 0972 6571 7565 7374 202b a();...request + │ │ │ +000091f0: 3d20 225c 725c 6e5c 725c 6e22 3b0a 0909 = "\r\n\r\n";... │ │ │ +00009200: 6d5f 6669 7273 745f 7265 7175 6573 7420 m_first_request │ │ │ +00009210: 3d20 6661 6c73 653b 0a0a 0909 6d5f 6669 = false;....m_fi │ │ │ +00009220: 6c65 5f72 6571 7565 7374 732e 7075 7368 le_requests.push │ │ │ +00009230: 5f62 6163 6b28 6669 6c65 5f72 6571 293b _back(file_req); │ │ │ +00009240: 0a09 7d0a 0965 6c73 650a 097b 0a09 092f ..}..else..{.../ │ │ │ +00009250: 2f20 666f 7220 7632 2074 6f72 7265 6e74 / for v2 torrent │ │ │ +00009260: 732c 2072 6571 2e6c 656e 6774 6820 6973 s, req.length is │ │ │ +00009270: 2074 6865 2073 756d 206f 6620 7265 616c the sum of real │ │ │ +00009280: 2d64 6174 6120 626c 6f63 6b20 7369 7a65 -data block size │ │ │ +00009290: 7320 7768 6963 680a 0909 2f2f 2065 7863 s which...// exc │ │ │ +000092a0: 6c75 6465 7320 7061 6420 6279 7465 732e ludes pad bytes. │ │ │ +000092b0: 206d 6170 5f62 6c6f 636b 2072 6571 7569 map_block requi │ │ │ +000092c0: 7265 7320 6120 746f 7272 656e 742d 636f res a torrent-co │ │ │ +000092d0: 6e74 6967 756f 7573 2062 7974 6520 7370 ntiguous byte sp │ │ │ +000092e0: 616e 2c0a 0909 2f2f 2073 6f20 636f 6d70 an,...// so comp │ │ │ +000092f0: 7574 6520 7468 6520 6163 7475 616c 2073 ute the actual s │ │ │ +00009300: 7061 6e20 6672 6f6d 2072 6571 2073 7461 pan from req sta │ │ │ +00009310: 7274 2074 6f20 656e 6420 6f66 206c 6173 rt to end of las │ │ │ +00009320: 7420 626c 6f63 6b20 2870 7229 2e0a 0909 t block (pr).... │ │ │ +00009330: 696e 7420 636f 6e73 7420 6d61 705f 6c65 int const map_le │ │ │ +00009340: 6e67 7468 203d 2069 6e66 6f2e 7632 2829 ngth = info.v2() │ │ │ +00009350: 0a09 0909 3f20 696e 7428 7374 6174 6963 ....? int(static │ │ │ +00009360: 5f63 6173 7426 6c74 3b69 6e74 2667 743b _cast<int> │ │ │ +00009370: 2870 722e 7069 6563 6529 202a 2073 7464 (pr.piece) * std │ │ │ +00009380: 3a3a 696e 7436 345f 7428 7069 6563 655f ::int64_t(piece_ │ │ │ +00009390: 7369 7a65 290a 0909 0909 2b20 7072 2e73 size).....+ pr.s │ │ │ +000093a0: 7461 7274 202b 2070 722e 6c65 6e67 7468 tart + pr.length │ │ │ +000093b0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +000093f0: 3b33 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;3../sr │ │ │ +00009420: 632f 7765 625f 7065 6572 5f63 6f6e 6e65 c/web_peer_conne │ │ │ +00009430: 6374 696f 6e2e 6370 703a 3439 313c 2f61 ction.cpp:491file_i │ │ │ +00009450: 6e64 6578 5f74 2073 686f 756c 6420 6e6f ndex_t should no │ │ │ +00009460: 7420 616c 6c6f 7720 6e65 6761 7469 7665 t allow negative │ │ │ +00009470: 2076 616c 7565 733c 2f74 643e 3c2f 7472 values │ │ │ +000094b0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +000094c0: 3c68 323e 6669 6c65 5f69 6e64 6578 5f74

    file_index_t │ │ │ +000094d0: 2073 686f 756c 6420 6e6f 7420 616c 6c6f should not allo │ │ │ +000094e0: 7720 6e65 6761 7469 7665 2076 616c 7565 w negative value │ │ │ +000094f0: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ +00009500: 2f77 6562 5f70 6565 725f 636f 6e6e 6563 /web_peer_connec │ │ │ +00009510: 7469 6f6e 2e63 7070 3a34 3931 3c2f 6834 tion.cpp:491

    .....
    │ │ │ +00009560: 2f2f 2077 6974 6820 7468 6520 636f 7272  // with the corr
    │ │ │ +00009570: 6563 7420 736c 6173 6865 732e 2044 6f6e  ect slashes. Don
    │ │ │ +00009580: 2774 2065 6e63 6f64 6520 6974 2061 6761  't encode it aga
    │ │ │ +00009590: 696e 0a09 0909 0909 7265 7175 6573 7420  in......request 
    │ │ │ +000095a0: 2b3d 206d 5f70 6174 683b 0a09 0909 097d  += m_path;.....}
    │ │ │ +000095b0: 0a0a 0909 0909 7265 7175 6573 7420 2b3d  ......request +=
    │ │ │ +000095c0: 2065 7363 6170 655f 6669 6c65 5f70 6174   escape_file_pat
    │ │ │ +000095d0: 6828 696e 666f 2e6c 6179 6f75 7428 292c  h(info.layout(),
    │ │ │ +000095e0: 2066 2e66 696c 655f 696e 6465 7829 3b0a   f.file_index);.
    │ │ │ +000095f0: 0909 097d 0a09 0909 7265 7175 6573 7420  ...}....request 
    │ │ │ +00009600: 2b3d 2022 2048 5454 502f 312e 315c 725c  += " HTTP/1.1\r\
    │ │ │ +00009610: 6e22 3b0a 0909 0961 6464 5f68 6561 6465  n";....add_heade
    │ │ │ +00009620: 7273 2872 6571 7565 7374 2c20 6d5f 7365  rs(request, m_se
    │ │ │ +00009630: 7474 696e 6773 2c20 7573 696e 675f 7072  ttings, using_pr
    │ │ │ +00009640: 6f78 7929 3b0a 0909 0972 6571 7565 7374  oxy);....request
    │ │ │ +00009650: 202b 3d20 225c 725c 6e52 616e 6765 3a20   += "\r\nRange: 
    │ │ │ +00009660: 6279 7465 733d 223b 0a09 0909 7265 7175  bytes=";....requ
    │ │ │ +00009670: 6573 7420 2b3d 2074 6f5f 7374 7269 6e67  est += to_string
    │ │ │ +00009680: 2866 2e6f 6666 7365 7429 2e64 6174 6128  (f.offset).data(
    │ │ │ +00009690: 293b 0a09 0909 7265 7175 6573 7420 2b3d  );....request +=
    │ │ │ +000096a0: 2022 2d22 3b0a 0909 0972 6571 7565 7374   "-";....request
    │ │ │ +000096b0: 202b 3d20 746f 5f73 7472 696e 6728 662e   += to_string(f.
    │ │ │ +000096c0: 6f66 6673 6574 202b 2066 2e73 697a 6520  offset + f.size 
    │ │ │ +000096d0: 2d20 3129 2e64 6174 6128 293b 0a09 0909  - 1).data();....
    │ │ │ +000096e0: 7265 7175 6573 7420 2b3d 2022 5c72 5c6e  request += "\r\n
    │ │ │ +000096f0: 5c72 5c6e 223b 0a09 0909 6d5f 6669 7273  \r\n";....m_firs
    │ │ │ +00009700: 745f 7265 7175 6573 7420 3d20 6661 6c73  t_request = fals
    │ │ │ +00009710: 653b 0a0a 2369 6620 300a 0909 0973 7464  e;..#if 0....std
    │ │ │ +00009720: 3a3a 6365 7272 2026 6c74 3b26 6c74 3b20  ::cerr << 
    │ │ │ +00009730: 7468 6973 2026 6c74 3b26 6c74 3b20 2220  this << " 
    │ │ │ +00009740: 5345 4e44 2d52 4551 5545 5354 3a20 663a  SEND-REQUEST: f:
    │ │ │ +00009750: 2022 2026 6c74 3b26 6c74 3b20 662e 6669   " << f.fi
    │ │ │ +00009760: 6c65 5f69 6e64 6578 0a09 0909 0926 6c74  le_index.....<
    │ │ │ +00009770: 3b26 6c74 3b20 2220 733a 2022 2026 6c74  ;< " s: " <
    │ │ │ +00009780: 3b26 6c74 3b20 662e 6f66 6673 6574 0a09  ;< f.offset..
    │ │ │ +00009790: 0909 0926 6c74 3b26 6c74 3b20 2220 653a  ...<< " e:
    │ │ │ +000097a0: 2022 2026 6c74 3b26 6c74 3b20 2866 2e6f   " << (f.o
    │ │ │ +000097b0: 6666 7365 7420 2b20 662e 7369 7a65 202d  ffset + f.size -
    │ │ │ +000097c0: 2031 2920 266c 743b 266c 743b 2073 7464   1) << std
    │ │ │ +000097d0: 3a3a 656e 646c 3b0a 2365 6e64 6966 0a3c  ::endl;.#endif.<
    │ │ │ +000097e0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +000097f0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +00009800: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ +00009810: 544f 5252 454e 545f 4153 5345 5254 2866  TORRENT_ASSERT(f
    │ │ │ +00009820: 2e66 696c 655f 696e 6465 7820 2667 743b  .file_index >
    │ │ │ +00009830: 3d20 6669 6c65 5f69 6e64 6578 5f74 2830  = file_index_t(0
    │ │ │ +00009840: 2929 3b0a 3c2f 6469 763e 0a09 0909 6d5f  ));.
    ....m_ │ │ │ +00009850: 6669 6c65 5f72 6571 7565 7374 732e 7075 file_requests.pu │ │ │ +00009860: 7368 5f62 6163 6b28 6669 6c65 5f72 6571 sh_back(file_req │ │ │ +00009870: 293b 0a09 097d 0a09 7d0a 0a09 6966 2028 );...}..}...if ( │ │ │ +00009880: 6e75 6d5f 7061 645f 6669 6c65 7320 3d3d num_pad_files == │ │ │ +00009890: 2069 6e74 286d 5f66 696c 655f 7265 7175 int(m_file_requ │ │ │ +000098a0: 6573 7473 2e73 697a 6528 2929 290a 097b ests.size()))..{ │ │ │ +000098b0: 0a09 0970 6f73 7428 6765 745f 636f 6e74 ...post(get_cont │ │ │ +000098c0: 6578 7428 292c 2073 7464 3a3a 6269 6e64 ext(), std::bind │ │ │ +000098d0: 280a 0909 0926 616d 703b 7765 625f 7065 (....&web_pe │ │ │ +000098e0: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a6f er_connection::o │ │ │ +000098f0: 6e5f 7265 6365 6976 655f 7061 6466 696c n_receive_padfil │ │ │ +00009900: 652c 0a09 0909 7374 643a 3a73 7461 7469 e,....std::stati │ │ │ +00009910: 635f 706f 696e 7465 725f 6361 7374 266c c_pointer_cast&l │ │ │ +00009920: 743b 7765 625f 7065 6572 5f63 6f6e 6e65 t;web_peer_conne │ │ │ +00009930: 6374 696f 6e26 6774 3b28 7365 6c66 2829 ction>(self() │ │ │ +00009940: 2929 293b 0a09 0972 6574 7572 6e3b 0a09 )));...return;.. │ │ │ +00009950: 7d0a 0a23 6966 6e64 6566 2054 4f52 5245 }..#ifndef TORRE │ │ │ +00009960: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ +00009970: 4e47 0a09 7065 6572 5f6c 6f67 2870 6565 NG..peer_log(pee │ │ │ +00009980: 725f 6c6f 675f 616c 6572 743a 3a6f 7574 r_log_alert::out │ │ │ +00009990: 676f 696e 675f 6d65 7373 6167 652c 2070 going_message, p │ │ │ +000099a0: 6565 725f 6c6f 675f 616c 6572 743a 3a72 eer_log_alert::r │ │ │ +000099b0: 6571 7565 7374 2c20 2225 7322 2c20 7265 equest, "%s", re │ │ │ +000099c0: 7175 6573 742e 635f 7374 7228 2929 3b0a quest.c_str());. │ │ │ +000099d0: 2365 6e64 6966 0a0a 0973 656e 645f 6275 #endif...send_bu │ │ │ +000099e0: 6666 6572 2872 6571 7565 7374 293b 0a7d ffer(request);.} │ │ │ +000099f0: 0a0a 6e61 6d65 7370 6163 6520 7b0a 0a09 ..namespace {... │ │ │ +00009a00: 7374 643a 3a73 7472 696e 6720 6765 745f std::string get_ │ │ │ +00009a10: 7065 6572 5f6e 616d 6528 6175 783a 3a68 peer_name(aux::h │ │ │ +00009a20: 7474 705f 7061 7273 6572 2063 6f6e 7374 ttp_parser const │ │ │ +00009a30: 2661 6d70 3b20 702c 2073 7464 3a3a 7374 & p, std::st │ │ │ +00009a40: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ +00009a50: 686f 7374 290a 097b 0a09 0973 7464 3a3a host)..{...std:: │ │ │ +00009a60: 7374 7269 6e67 2063 6f6e 7374 2661 6d70 string const& │ │ │ +00009a70: 3b20 7365 7276 6572 5f76 6572 7369 6f6e ; server_version │ │ │ +00009a80: 203d 2070 2e68 6561 6465 7228 2273 6572 = p.header("ser │ │ │ +00009a90: 7665 7222 293b 0a09 0969 6620 2821 7365 ver");...if (!se │ │ │ +00009aa0: 7276 6572 5f76 6572 7369 6f6e 2e65 6d70 rver_version.emp │ │ │ +00009ab0: 7479 2829 290a 0909 0972 6574 7572 6e20 ty())....return │ │ │ +00009ac0: 7365 7276 6572 5f76 6572 7369 6f6e 3b0a server_version;. │ │ │ +00009ad0: 0909 7265 7475 726e 2068 6f73 743b 0a09 ..return host;.. │ │ │ +00009ae0: 7d0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f }.. │ │ │ +00009b10: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00009b20: 7370 3b33 3c2f 7464 3e3c 7464 3e3c 6120 sp;3../ │ │ │ +00009b50: 7372 632f 7765 625f 7065 6572 5f63 6f6e src/web_peer_con │ │ │ +00009b60: 6e65 6374 696f 6e2e 6370 703a 3639 313c nection.cpp:691< │ │ │ +00009b70: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ +00009b80: 2063 6f75 6c64 2062 6520 6d61 6465 206d could be made m │ │ │ +00009b90: 6f72 6520 6566 6669 6369 656e 7420 666f ore efficient fo │ │ │ +00009ba0: 7220 7468 6520 6361 7365 2077 6865 6e20 r the case when │ │ │ +00009bb0: 7765 2075 7365 2061 6e20 4854 5450 2070 we use an HTTP p │ │ │ +00009bc0: 726f 7879 2e20 5468 656e 2077 6520 776f roxy. Then we wo │ │ │ +00009bd0: 756c 646e 2774 206e 6565 6420 746f 2061 uldn't need to a │ │ │ +00009be0: 6464 206e 6577 2077 6562 2073 6565 6473 dd new web seeds │ │ │ +00009bf0: 2074 6f20 7468 6520 746f 7272 656e 742c to the torrent, │ │ │ +00009c00: 2077 6520 636f 756c 6420 6a75 7374 206d we could just m │ │ │ +00009c10: 616b 6520 7468 6520 7265 6469 7265 6374 ake the redirect │ │ │ +00009c20: 2074 6162 6c65 2063 6f6e 7461 696e 2066 table contain f │ │ │ +00009c30: 756c 6c20 5552 4c73 2e3c 2f74 643e 3c2f ull URLs.

    the logic │ │ │ -00009c90: 696e 2074 6869 7320 6966 2d62 6c6f 636b in this if-block │ │ │ -00009ca0: 2073 686f 756c 6420 6265 2066 6163 746f should be facto │ │ │ -00009cb0: 7265 6420 6f75 7420 696e 746f 2061 0a73 red out into a.s │ │ │ -00009cc0: 6570 6172 6174 6520 6675 6e63 7469 6f6e eparate function │ │ │ -00009cd0: 2e20 4174 206c 6561 7374 206d 6f73 7420 . At least most │ │ │ -00009ce0: 6f66 2069 743c 2f68 323e 3c68 343e 2e2e of it

    .. │ │ │ -00009cf0: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ -00009d00: 6c2e 6370 703a 3136 3130 3c2f 6834 3e3c l.cpp:1610

    < │ │ │ -00009d10: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00009d20: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00009d30: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00009d40: 7820 2364 6464 3b22 3e09 0909 092c 2028 x #ddd;">...., ( │ │ │ -00009d50: 6c65 702e 666c 6167 7320 2661 6d70 3b20 lep.flags & │ │ │ -00009d60: 6c69 7374 656e 5f73 6f63 6b65 745f 743a listen_socket_t: │ │ │ -00009d70: 3a61 6363 6570 745f 696e 636f 6d69 6e67 :accept_incoming │ │ │ -00009d80: 2920 3f20 2261 6363 6570 742d 696e 636f ) ? "accept-inco │ │ │ -00009d90: 6d69 6e67 2022 203a 2022 6e6f 2d69 6e63 ming " : "no-inc │ │ │ -00009da0: 6f6d 696e 6720 220a 0909 0909 2c20 286c oming "....., (l │ │ │ -00009db0: 6570 2e66 6c61 6773 2026 616d 703b 206c ep.flags & l │ │ │ -00009dc0: 6973 7465 6e5f 736f 636b 6574 5f74 3a3a isten_socket_t:: │ │ │ -00009dd0: 7761 735f 6578 7061 6e64 6564 2920 3f20 was_expanded) ? │ │ │ -00009de0: 2265 7870 616e 6465 642d 6970 2022 203a "expanded-ip " : │ │ │ -00009df0: 2022 220a 0909 0909 2c20 286c 6570 2e66 ""....., (lep.f │ │ │ -00009e00: 6c61 6773 2026 616d 703b 206c 6973 7465 lags & liste │ │ │ -00009e10: 6e5f 736f 636b 6574 5f74 3a3a 7072 6f78 n_socket_t::prox │ │ │ -00009e20: 7929 203f 2022 7072 6f78 7920 2220 3a20 y) ? "proxy " : │ │ │ -00009e30: 2222 293b 0a09 097d 0a23 656e 6469 660a "");...}.#endif. │ │ │ -00009e40: 0a09 0961 7574 6f20 7265 7420 3d20 7374 ...auto ret = st │ │ │ -00009e50: 643a 3a6d 616b 655f 7368 6172 6564 266c d::make_shared&l │ │ │ -00009e60: 743b 6c69 7374 656e 5f73 6f63 6b65 745f t;listen_socket_ │ │ │ -00009e70: 7426 6774 3b28 293b 0a09 0972 6574 2d26 t>();...ret-& │ │ │ -00009e80: 6774 3b73 736c 203d 206c 6570 2e73 736c gt;ssl = lep.ssl │ │ │ -00009e90: 3b0a 0909 7265 742d 2667 743b 6f72 6967 ;...ret->orig │ │ │ -00009ea0: 696e 616c 5f70 6f72 7420 3d20 6269 6e64 inal_port = bind │ │ │ -00009eb0: 5f65 702e 706f 7274 2829 3b0a 0909 7265 _ep.port();...re │ │ │ -00009ec0: 742d 2667 743b 666c 6167 7320 3d20 6c65 t->flags = le │ │ │ -00009ed0: 702e 666c 6167 733b 0a09 0972 6574 2d26 p.flags;...ret-& │ │ │ -00009ee0: 6774 3b6e 6574 6d61 736b 203d 206c 6570 gt;netmask = lep │ │ │ -00009ef0: 2e6e 6574 6d61 736b 3b0a 0909 6f70 6572 .netmask;...oper │ │ │ -00009f00: 6174 696f 6e5f 7420 6c61 7374 5f6f 7020 ation_t last_op │ │ │ -00009f10: 3d20 6f70 6572 6174 696f 6e5f 743a 3a75 = operation_t::u │ │ │ -00009f20: 6e6b 6e6f 776e 3b0a 0909 736f 636b 6574 nknown;...socket │ │ │ -00009f30: 5f74 7970 655f 7420 636f 6e73 7420 736f _type_t const so │ │ │ -00009f40: 636b 5f74 7970 650a 0909 093d 2028 6c65 ck_type....= (le │ │ │ -00009f50: 702e 7373 6c20 3d3d 2074 7261 6e73 706f p.ssl == transpo │ │ │ -00009f60: 7274 3a3a 7373 6c29 0a09 0909 3f20 736f rt::ssl)....? so │ │ │ -00009f70: 636b 6574 5f74 7970 655f 743a 3a74 6370 cket_type_t::tcp │ │ │ -00009f80: 5f73 736c 0a09 0909 3a20 736f 636b 6574 _ssl....: socket │ │ │ -00009f90: 5f74 7970 655f 743a 3a74 6370 3b0a 0a72 _type_t::tcp;..r │ │ │ -00009fa0: 6574 7279 3a0a 0909 2f2f 2069 6620 7765 etry:...// if we │ │ │ -00009fb0: 2772 6520 696e 2066 6f72 6365 2d70 726f 're in force-pro │ │ │ -00009fc0: 7879 206d 6f64 652c 2064 6f6e 2774 206f xy mode, don't o │ │ │ -00009fd0: 7065 6e20 5443 5020 6c69 7374 656e 2073 pen TCP listen s │ │ │ -00009fe0: 6f63 6b65 7473 2e20 5765 2063 616e 6e6f ockets. We canno │ │ │ -00009ff0: 740a 0909 2f2f 2061 6363 6570 7420 636f t...// accept co │ │ │ -0000a000: 6e6e 6563 7469 6f6e 7320 6f6e 206f 7572 nnections on our │ │ │ -0000a010: 206c 6f63 616c 206d 6163 6869 6e65 2069 local machine i │ │ │ -0000a020: 6e20 7468 6973 2063 6173 652e 0a3c 6469 n this case....if │ │ │ -0000a060: 2872 6574 2d26 6774 3b66 6c61 6773 2026 (ret->flags & │ │ │ -0000a070: 616d 703b 206c 6973 7465 6e5f 736f 636b amp; listen_sock │ │ │ -0000a080: 6574 5f74 3a3a 6163 6365 7074 5f69 6e63 et_t::accept_inc │ │ │ -0000a090: 6f6d 696e 6729 0a3c 2f64 6976 3e09 097b oming).
    ..{ │ │ │ -0000a0a0: 0a09 0909 7265 742d 2667 743b 736f 636b ....ret->sock │ │ │ -0000a0b0: 203d 2073 7464 3a3a 6d61 6b65 5f73 6861 = std::make_sha │ │ │ -0000a0c0: 7265 6426 6c74 3b74 6370 3a3a 6163 6365 red<tcp::acce │ │ │ -0000a0d0: 7074 6f72 2667 743b 286d 5f69 6f5f 636f ptor>(m_io_co │ │ │ -0000a0e0: 6e74 6578 7429 3b0a 0909 0972 6574 2d26 ntext);....ret-& │ │ │ -0000a0f0: 6774 3b73 6f63 6b2d 2667 743b 6f70 656e gt;sock->open │ │ │ -0000a100: 2862 696e 645f 6570 2e70 726f 746f 636f (bind_ep.protoco │ │ │ -0000a110: 6c28 292c 2065 6329 3b0a 0909 096c 6173 l(), ec);....las │ │ │ -0000a120: 745f 6f70 203d 206f 7065 7261 7469 6f6e t_op = operation │ │ │ -0000a130: 5f74 3a3a 736f 636b 5f6f 7065 6e3b 0a09 _t::sock_open;.. │ │ │ -0000a140: 0909 6966 2028 6563 290a 0909 097b 0a23 ..if (ec)....{.# │ │ │ -0000a150: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ -0000a160: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ -0000a170: 0909 0969 6620 2873 686f 756c 645f 6c6f ...if (should_lo │ │ │ -0000a180: 6728 2929 0a09 0909 097b 0a09 0909 0909 g()).....{...... │ │ │ -0000a190: 7365 7373 696f 6e5f 6c6f 6728 2266 6169 session_log("fai │ │ │ -0000a1a0: 6c65 6420 746f 206f 7065 6e20 736f 636b led to open sock │ │ │ -0000a1b0: 6574 3a20 2573 220a 0909 0909 0909 2c20 et: %s"......., │ │ │ -0000a1c0: 6563 2e6d 6573 7361 6765 2829 2e63 5f73 ec.message().c_s │ │ │ -0000a1d0: 7472 2829 293b 0a09 0909 097d 0a23 656e tr());.....}.#en │ │ │ -0000a1e0: 6469 660a 0a09 0909 0969 6620 286d 5f61 dif......if (m_a │ │ │ -0000a1f0: 6c65 7274 732e 7368 6f75 6c64 5f70 6f73 lerts.should_pos │ │ │ -0000a200: 7426 6c74 3b6c 6973 7465 6e5f 6661 696c t<listen_fail │ │ │ -0000a210: 6564 5f61 6c65 7274 2667 743b 2829 290a ed_alert>()). │ │ │ -0000a220: 0909 0909 096d 5f61 6c65 7274 732e 656d .....m_alerts.em │ │ │ -0000a230: 706c 6163 655f 616c 6572 7426 6c74 3b6c place_alert<l │ │ │ -0000a240: 6973 7465 6e5f 6661 696c 6564 5f61 6c65 isten_failed_ale │ │ │ -0000a250: 7274 2667 743b 286c 6570 2e64 6576 6963 rt>(lep.devic │ │ │ -0000a260: 652c 2062 696e 645f 6570 2c20 6c61 7374 e, bind_ep, last │ │ │ -0000a270: 5f6f 700a 0909 0909 0909 2c20 6563 2c20 _op......., ec, │ │ │ -0000a280: 736f 636b 5f74 7970 6529 3b0a 0909 0909 sock_type);..... │ │ │ -0000a290: 7265 7475 726e 2072 6574 3b0a 0909 097d return ret;....} │ │ │ -0000a2a0: 0a0a 2369 6664 6566 2054 4f52 5245 4e54 ..#ifdef TORRENT │ │ │ -0000a2b0: 5f57 494e 444f 5753 0a09 0909 7b0a 0909 _WINDOWS....{... │ │ │ -0000a2c0: 0909 2f2f 2074 6869 7320 6973 2062 6573 ..// this is bes │ │ │ -0000a2d0: 742d 6566 666f 7274 2e20 6967 6e6f 7265 t-effort. ignore │ │ │ -0000a2e0: 2065 7272 6f72 730a 0909 0909 6572 726f errors.....erro │ │ │ -0000a2f0: 725f 636f 6465 2065 7272 3b0a 0909 0909 r_code err;..... │ │ │ -0000a300: 7265 742d 2667 743b 736f 636b 2d26 6774 ret->sock-> │ │ │ -0000a310: 3b73 6574 5f6f 7074 696f 6e28 6578 636c ;set_option(excl │ │ │ -0000a320: 7573 6976 655f 6164 6472 6573 735f 7573 usive_address_us │ │ │ -0000a330: 6528 7472 7565 292c 2065 7272 293b 0a23 e(true), err);.# │ │ │ -0000a340: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ -0000a350: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ -0000a360: 0909 0969 6620 2865 7272 2026 616d 703b ...if (err & │ │ │ -0000a370: 2661 6d70 3b20 7368 6f75 6c64 5f6c 6f67 & should_log │ │ │ -0000a380: 2829 290a 0909 0909 7b0a 0909 0909 0973 ()).....{......s │ │ │ -0000a390: 6573 7369 6f6e 5f6c 6f67 2822 6661 696c ession_log("fail │ │ │ -0000a3a0: 6564 2065 6e61 626c 6520 6578 636c 7573 ed enable exclus │ │ │ -0000a3b0: 6976 6520 6164 6472 6573 7320 7573 6520 ive address use │ │ │ -0000a3c0: 6f6e 206c 6973 7465 6e20 736f 636b 6574 on listen socket │ │ │ -0000a3d0: 3a20 2573 220a 0909 0909 0909 2c20 6572 : %s"......., er │ │ │ -0000a3e0: 722e 6d65 7373 6167 6528 292e 635f 7374 r.message().c_st │ │ │ -0000a3f0: 7228 2929 3b0a 3c2f 7072 653e 3c2f 7464 r());.relevance │ │ │ -0000a430: 266e 6273 703b 333c 2f74 643e 3c74 643e  3 │ │ │ -0000a440: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ -0000a460: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0000a470: 6d70 6c2e 6370 703a 3236 3830 3c2f 613e mpl.cpp:2680 │ │ │ -0000a480: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ -0000a490: 6420 6265 206e 6561 7420 6966 2074 6865 d be neat if the │ │ │ -0000a4a0: 2075 7470 2073 6f63 6b65 7420 6d61 6e61 utp socket mana │ │ │ -0000a4b0: 6765 7220 776f 756c 6420 6861 6e64 6c65 ger would handle │ │ │ -0000a4c0: 2049 434d 5020 6572 726f 7273 2074 6f6f ICMP errors too │ │ │ -0000a4d0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ -0000a520: 776f 756c 6420 6265 206e 6561 7420 6966 would be neat if │ │ │ -0000a530: 2074 6865 2075 7470 2073 6f63 6b65 7420 the utp socket │ │ │ -0000a540: 6d61 6e61 6765 7220 776f 756c 640a 6861 manager would.ha │ │ │ -0000a550: 6e64 6c65 2049 434d 5020 6572 726f 7273 ndle ICMP errors │ │ │ -0000a560: 2074 6f6f 3c2f 6832 3e3c 6834 3e2e 2e2f too

    ../ │ │ │ -0000a570: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0000a580: 2e63 7070 3a32 3638 303c 2f68 343e 3c70 .cpp:2680

    ...std:: │ │ │ -0000a5d0: 7368 6172 6564 5f70 7472 266c 743b 7365 shared_ptr<se │ │ │ -0000a5e0: 7373 696f 6e5f 7564 705f 736f 636b 6574 ssion_udp_socket │ │ │ -0000a5f0: 2667 743b 2073 203d 2073 6f63 6b65 742e > s = socket. │ │ │ -0000a600: 6c6f 636b 2829 3b0a 0909 6966 2028 2173 lock();...if (!s │ │ │ -0000a610: 2920 7265 7475 726e 3b0a 0a09 0973 7472 ) return;....str │ │ │ -0000a620: 7563 7420 7574 705f 736f 636b 6574 5f6d uct utp_socket_m │ │ │ -0000a630: 616e 6167 6572 2661 6d70 3b20 6d67 7220 anager& mgr │ │ │ -0000a640: 3d0a 2369 6664 6566 2054 4f52 5245 4e54 =.#ifdef TORRENT │ │ │ -0000a650: 5f53 534c 5f50 4545 5253 0a09 0909 7373 _SSL_PEERS....ss │ │ │ -0000a660: 6c20 3d3d 2074 7261 6e73 706f 7274 3a3a l == transport:: │ │ │ -0000a670: 7373 6c20 3f20 6d5f 7373 6c5f 7574 705f ssl ? m_ssl_utp_ │ │ │ -0000a680: 736f 636b 6574 5f6d 616e 6167 6572 203a socket_manager : │ │ │ -0000a690: 0a23 656e 6469 660a 0909 096d 5f75 7470 .#endif....m_utp │ │ │ -0000a6a0: 5f73 6f63 6b65 745f 6d61 6e61 6765 723b _socket_manager; │ │ │ -0000a6b0: 0a0a 0909 666f 7220 283b 3b29 0a09 097b ....for (;;)...{ │ │ │ -0000a6c0: 0a09 0909 6175 783a 3a61 7272 6179 266c ....aux::array&l │ │ │ -0000a6d0: 743b 7564 705f 736f 636b 6574 3a3a 7061 t;udp_socket::pa │ │ │ -0000a6e0: 636b 6574 2c20 3530 2667 743b 2070 3b0a cket, 50> p;. │ │ │ -0000a6f0: 0909 0965 7272 6f72 5f63 6f64 6520 6572 ...error_code er │ │ │ -0000a700: 723b 0a09 0909 696e 7420 636f 6e73 7420 r;....int const │ │ │ -0000a710: 6e75 6d5f 7061 636b 6574 7320 3d20 732d num_packets = s- │ │ │ -0000a720: 2667 743b 736f 636b 2e72 6561 6428 702c >sock.read(p, │ │ │ -0000a730: 2065 7272 293b 0a0a 0909 0966 6f72 2028 err);.....for ( │ │ │ -0000a740: 7564 705f 736f 636b 6574 3a3a 7061 636b udp_socket::pack │ │ │ -0000a750: 6574 2661 6d70 3b20 7061 636b 6574 203a et& packet : │ │ │ -0000a760: 2073 7061 6e26 6c74 3b75 6470 5f73 6f63 span<udp_soc │ │ │ -0000a770: 6b65 743a 3a70 6163 6b65 7426 6774 3b28 ket::packet>( │ │ │ -0000a780: 7029 2e66 6972 7374 286e 756d 5f70 6163 p).first(num_pac │ │ │ -0000a790: 6b65 7473 2929 0a09 0909 7b0a 0909 0909 kets))....{..... │ │ │ -0000a7a0: 6966 2028 7061 636b 6574 2e65 7272 6f72 if (packet.error │ │ │ -0000a7b0: 290a 0909 0909 7b0a 3c64 6976 2073 7479 ).....{.

    .
    #if │ │ │ -0000a7f0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -0000a800: 4142 4c45 5f44 4854 0a09 0909 0909 6966 ABLE_DHT......if │ │ │ -0000a810: 2028 6d5f 6468 7429 0a09 0909 0909 096d (m_dht).......m │ │ │ -0000a820: 5f64 6874 2d26 6774 3b69 6e63 6f6d 696e _dht->incomin │ │ │ -0000a830: 675f 6572 726f 7228 7061 636b 6574 2e65 g_error(packet.e │ │ │ -0000a840: 7272 6f72 2c20 7061 636b 6574 2e66 726f rror, packet.fro │ │ │ -0000a850: 6d29 3b0a 2365 6e64 6966 0a0a 0909 0909 m);.#endif...... │ │ │ -0000a860: 096d 5f74 7261 636b 6572 5f6d 616e 6167 .m_tracker_manag │ │ │ -0000a870: 6572 2e69 6e63 6f6d 696e 675f 6572 726f er.incoming_erro │ │ │ -0000a880: 7228 7061 636b 6574 2e65 7272 6f72 2c20 r(packet.error, │ │ │ -0000a890: 7061 636b 6574 2e66 726f 6d29 3b0a 0909 packet.from);... │ │ │ -0000a8a0: 0909 0963 6f6e 7469 6e75 653b 0a09 0909 ...continue;.... │ │ │ -0000a8b0: 097d 0a0a 0909 0909 7370 616e 266c 743b .}......span< │ │ │ -0000a8c0: 6368 6172 2063 6f6e 7374 2667 743b 2063 char const> c │ │ │ -0000a8d0: 6f6e 7374 2062 7566 203d 2070 6163 6b65 onst buf = packe │ │ │ -0000a8e0: 742e 6461 7461 3b0a 0909 0909 6966 2028 t.data;.....if ( │ │ │ -0000a8f0: 2170 6163 6b65 742e 686f 7374 6e61 6d65 !packet.hostname │ │ │ -0000a900: 2e65 6d70 7479 2829 290a 0909 0909 7b0a .empty()).....{. │ │ │ -0000a910: 0909 0909 092f 2f20 6f6e 6c79 2074 6865 .....// only the │ │ │ -0000a920: 2074 7261 636b 6572 206d 616e 6167 6572 tracker manager │ │ │ -0000a930: 2073 7570 706f 7274 7320 7265 6365 6976 supports receiv │ │ │ -0000a940: 696e 6720 5544 5020 7061 636b 6574 730a ing UDP packets. │ │ │ -0000a950: 0909 0909 092f 2f20 6672 6f6d 2068 6f73 .....// from hos │ │ │ -0000a960: 746e 616d 6573 2e20 4966 2069 7420 776f tnames. If it wo │ │ │ -0000a970: 6e27 7420 6861 6e64 6c65 2069 742c 206e n't handle it, n │ │ │ -0000a980: 6f20 6f6e 6520 656c 7365 2077 696c 6c0a o one else will. │ │ │ -0000a990: 0909 0909 092f 2f20 6569 7468 6572 0a09 .....// either.. │ │ │ -0000a9a0: 0909 0909 6d5f 7472 6163 6b65 725f 6d61 ....m_tracker_ma │ │ │ -0000a9b0: 6e61 6765 722e 696e 636f 6d69 6e67 5f70 nager.incoming_p │ │ │ -0000a9c0: 6163 6b65 7428 7061 636b 6574 2e68 6f73 acket(packet.hos │ │ │ -0000a9d0: 746e 616d 652c 2062 7566 293b 0a09 0909 tname, buf);.... │ │ │ -0000a9e0: 0909 636f 6e74 696e 7565 3b0a 0909 0909 ..continue;..... │ │ │ -0000a9f0: 7d0a 0a09 0909 092f 2f20 6769 7665 2074 }......// give t │ │ │ -0000aa00: 6865 2075 5450 2073 6f63 6b65 7420 6d61 he uTP socket ma │ │ │ -0000aa10: 6e61 6765 7220 6669 7273 7420 6469 6273 nager first dibs │ │ │ -0000aa20: 206f 6e20 7468 6520 7061 636b 6574 2e20 on the packet. │ │ │ -0000aa30: 5072 6573 756d 6162 6c79 0a09 0909 092f Presumably...../ │ │ │ -0000aa40: 2f20 7468 6520 6d61 6a6f 7269 7479 206f / the majority o │ │ │ -0000aa50: 6620 7061 636b 6574 7320 6172 6520 7554 f packets are uT │ │ │ -0000aa60: 5020 7061 636b 6574 732e 0a09 0909 0969 P packets......i │ │ │ -0000aa70: 6620 2821 6d67 722e 696e 636f 6d69 6e67 f (!mgr.incoming │ │ │ -0000aa80: 5f70 6163 6b65 7428 6c73 2c20 7061 636b _packet(ls, pack │ │ │ -0000aa90: 6574 2e66 726f 6d2c 2062 7566 2929 0a09 et.from, buf)).. │ │ │ -0000aaa0: 0909 097b 0a09 0909 0909 2f2f 2069 6620 ...{......// if │ │ │ -0000aab0: 6974 2077 6173 6e27 7420 6120 7554 5020 it wasn't a uTP │ │ │ -0000aac0: 7061 636b 6574 2c20 7472 7920 7468 6520 packet, try the │ │ │ -0000aad0: 6f74 6865 7220 7573 6572 7320 6f66 2074 other users of t │ │ │ -0000aae0: 6865 2055 4450 0a09 0909 0909 2f2f 2073 he UDP......// s │ │ │ -0000aaf0: 6f63 6b65 740a 0909 0909 0962 6f6f 6c20 ocket......bool │ │ │ -0000ab00: 6861 6e64 6c65 6420 3d20 6661 6c73 653b handled = false; │ │ │ -0000ab10: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -0000ab20: 5f44 4953 4142 4c45 5f44 4854 0a09 0909 _DISABLE_DHT.... │ │ │ -0000ab30: 0909 6175 746f 206c 6973 7465 6e5f 736f ..auto listen_so │ │ │ -0000ab40: 636b 6574 203d 206c 732e 6c6f 636b 2829 cket = ls.lock() │ │ │ -0000ab50: 3b0a 0909 0909 0969 6620 286d 5f64 6874 ;......if (m_dht │ │ │ -0000ab60: 2026 616d 703b 2661 6d70 3b20 6275 662e && buf. │ │ │ -0000ab70: 7369 7a65 2829 2026 6774 3b20 3230 0a09 size() > 20.. │ │ │ -0000ab80: 0909 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ -0000ab90: 6275 662e 6672 6f6e 7428 2920 3d3d 2027 buf.front() == ' │ │ │ -0000aba0: 6427 0a3c 2f70 7265 3e3c 2f74 643e 3c2f d'. │ │ │ -0000abd0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0000abe0: 7370 3b33 3c2f 7464 3e3c 7464 3e3c 6120 sp;3../ │ │ │ -0000ac10: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0000ac20: 2e63 7070 3a34 3331 373c 2f61 3e3c 2f74 .cpp:4317it would p │ │ │ -0000ac40: 726f 6261 626c 7920 6d61 6b65 2073 656e robably make sen │ │ │ -0000ac50: 7365 2074 6f20 6861 7665 2061 2073 6570 se to have a sep │ │ │ -0000ac60: 6172 6174 6520 6c69 7374 206f 6620 7065 arate list of pe │ │ │ -0000ac70: 6572 7320 7468 6174 2061 7265 2065 6c69 ers that are eli │ │ │ -0000ac80: 6769 626c 6520 666f 7220 6f70 7469 6d69 gible for optimi │ │ │ -0000ac90: 7374 6963 2075 6e63 686f 6b65 2c20 7369 stic unchoke, si │ │ │ -0000aca0: 6d69 6c61 7220 746f 2074 6865 2074 6f72 milar to the tor │ │ │ -0000acb0: 7265 6e74 7320 7065 7268 6170 7320 7468 rents perhaps th │ │ │ -0000acc0: 6973 2063 6f75 6c64 2065 7665 6e20 6974 is could even it │ │ │ -0000acd0: 6572 6174 6520 6f76 6572 2074 6865 2070 erate over the p │ │ │ -0000ace0: 6f6f 6c20 616c 6c6f 6361 746f 7273 206f ool allocators o │ │ │ -0000acf0: 6620 746f 7272 656e 745f 7065 6572 206f f torrent_peer o │ │ │ -0000ad00: 626a 6563 7473 2e20 4974 2063 6f75 6c64 bjects. It could │ │ │ -0000ad10: 2070 726f 6261 626c 7920 6265 2064 6f6e probably be don │ │ │ -0000ad20: 6520 696e 2061 2073 696e 676c 6520 7061 e in a single pa │ │ │ -0000ad30: 7373 2061 6e64 2063 6f6c 6c65 6374 2074 ss and collect t │ │ │ -0000ad40: 6865 206e 2062 6573 7420 6361 6e64 6964 he n best candid │ │ │ -0000ad50: 6174 6573 2e20 6d61 7962 6520 6a75 7374 ates. maybe just │ │ │ -0000ad60: 2061 2071 7565 7565 206f 6620 7065 6572 a queue of peer │ │ │ -0000ad70: 7320 776f 756c 6420 6d61 6b65 2065 7665 s would make eve │ │ │ -0000ad80: 6e20 6d6f 7265 2073 656e 7365 2c20 6a75 n more sense, ju │ │ │ -0000ad90: 7374 2070 6963 6b20 7468 6520 6e65 7874 st pick the next │ │ │ -0000ada0: 2070 6565 7220 696e 2074 6865 2071 7565 peer in the que │ │ │ -0000adb0: 7565 2066 6f72 2075 6e63 686f 6b69 6e67 ue for unchoking │ │ │ -0000adc0: 2e20 4974 2077 6f75 6c64 2062 6520 4f28 . It would be O( │ │ │ -0000add0: 3129 2e3c 2f74 643e 3c2f 7472 3e3c 7472 1).

    │ │ │ -0000ae20: 6974 2077 6f75 6c64 2070 726f 6261 626c it would probabl │ │ │ -0000ae30: 7920 6d61 6b65 2073 656e 7365 2074 6f20 y make sense to │ │ │ -0000ae40: 6861 7665 2061 2073 6570 6172 6174 6520 have a separate │ │ │ -0000ae50: 6c69 7374 206f 6620 7065 6572 730a 7468 list of peers.th │ │ │ -0000ae60: 6174 2061 7265 2065 6c69 6769 626c 6520 at are eligible │ │ │ -0000ae70: 666f 7220 6f70 7469 6d69 7374 6963 2075 for optimistic u │ │ │ -0000ae80: 6e63 686f 6b65 2c20 7369 6d69 6c61 7220 nchoke, similar │ │ │ -0000ae90: 746f 2074 6865 2074 6f72 7265 6e74 730a to the torrents. │ │ │ -0000aea0: 7065 7268 6170 7320 7468 6973 2063 6f75 perhaps this cou │ │ │ -0000aeb0: 6c64 2065 7665 6e20 6974 6572 6174 6520 ld even iterate │ │ │ -0000aec0: 6f76 6572 2074 6865 2070 6f6f 6c20 616c over the pool al │ │ │ -0000aed0: 6c6f 6361 746f 7273 206f 660a 746f 7272 locators of.torr │ │ │ -0000aee0: 656e 745f 7065 6572 206f 626a 6563 7473 ent_peer objects │ │ │ -0000aef0: 2e20 4974 2063 6f75 6c64 2070 726f 6261 . It could proba │ │ │ -0000af00: 626c 7920 6265 2064 6f6e 6520 696e 2061 bly be done in a │ │ │ -0000af10: 2073 696e 676c 6520 7061 7373 2061 6e64 single pass and │ │ │ -0000af20: 0a63 6f6c 6c65 6374 2074 6865 206e 2062 .collect the n b │ │ │ -0000af30: 6573 7420 6361 6e64 6964 6174 6573 2e20 est candidates. │ │ │ -0000af40: 6d61 7962 6520 6a75 7374 2061 2071 7565 maybe just a que │ │ │ -0000af50: 7565 206f 6620 7065 6572 7320 776f 756c ue of peers woul │ │ │ -0000af60: 6420 6d61 6b65 0a65 7665 6e20 6d6f 7265 d make.even more │ │ │ -0000af70: 2073 656e 7365 2c20 6a75 7374 2070 6963 sense, just pic │ │ │ -0000af80: 6b20 7468 6520 6e65 7874 2070 6565 7220 k the next peer │ │ │ -0000af90: 696e 2074 6865 2071 7565 7565 2066 6f72 in the queue for │ │ │ -0000afa0: 2075 6e63 686f 6b69 6e67 2e20 4974 0a77 unchoking. It.w │ │ │ -0000afb0: 6f75 6c64 2062 6520 4f28 3129 2e3c 2f68 ould be O(1).

    ../src/ses │ │ │ -0000afd0: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3433 sion_impl.cpp:43 │ │ │ -0000afe0: 3137 3c2f 6834 3e3c 7072 6520 7374 796c 17

    .}...void sessi
    │ │ │ -0000b030: 6f6e 5f69 6d70 6c3a 3a72 6563 616c 6375  on_impl::recalcu
    │ │ │ -0000b040: 6c61 7465 5f6f 7074 696d 6973 7469 635f  late_optimistic_
    │ │ │ -0000b050: 756e 6368 6f6b 655f 736c 6f74 7328 290a  unchoke_slots().
    │ │ │ -0000b060: 097b 0a09 0949 4e56 4152 4941 4e54 5f43  .{...INVARIANT_C
    │ │ │ -0000b070: 4845 434b 3b0a 0a09 0954 4f52 5245 4e54  HECK;....TORRENT
    │ │ │ -0000b080: 5f41 5353 4552 5428 6973 5f73 696e 676c  _ASSERT(is_singl
    │ │ │ -0000b090: 655f 7468 7265 6164 2829 293b 0a09 0969  e_thread());...i
    │ │ │ -0000b0a0: 6620 286d 5f73 7461 7473 5f63 6f75 6e74  f (m_stats_count
    │ │ │ -0000b0b0: 6572 735b 636f 756e 7465 7273 3a3a 6e75  ers[counters::nu
    │ │ │ -0000b0c0: 6d5f 756e 6368 6f6b 655f 736c 6f74 735d  m_unchoke_slots]
    │ │ │ -0000b0d0: 203d 3d20 3029 2072 6574 7572 6e3b 0a0a   == 0) return;..
    │ │ │ -0000b0e0: 0909 2f2f 2069 6620 7765 2075 6e63 686f  ..// if we uncho
    │ │ │ -0000b0f0: 6b65 2065 7665 7279 6f6e 652c 2073 6b69  ke everyone, ski
    │ │ │ -0000b100: 7020 7468 6973 206c 6f67 6963 0a09 0969  p this logic...i
    │ │ │ -0000b110: 6620 2873 6574 7469 6e67 7328 292e 6765  f (settings().ge
    │ │ │ -0000b120: 745f 696e 7428 7365 7474 696e 6773 5f70  t_int(settings_p
    │ │ │ -0000b130: 6163 6b3a 3a63 686f 6b69 6e67 5f61 6c67  ack::choking_alg
    │ │ │ -0000b140: 6f72 6974 686d 2920 3d3d 2073 6574 7469  orithm) == setti
    │ │ │ -0000b150: 6e67 735f 7061 636b 3a3a 6669 7865 645f  ngs_pack::fixed_
    │ │ │ -0000b160: 736c 6f74 735f 6368 6f6b 6572 0a09 0909  slots_choker....
    │ │ │ -0000b170: 2661 6d70 3b26 616d 703b 2073 6574 7469  && setti
    │ │ │ -0000b180: 6e67 7328 292e 6765 745f 696e 7428 7365  ngs().get_int(se
    │ │ │ -0000b190: 7474 696e 6773 5f70 6163 6b3a 3a75 6e63  ttings_pack::unc
    │ │ │ -0000b1a0: 686f 6b65 5f73 6c6f 7473 5f6c 696d 6974  hoke_slots_limit
    │ │ │ -0000b1b0: 2920 266c 743b 2030 290a 0909 0972 6574  ) < 0)....ret
    │ │ │ -0000b1c0: 7572 6e3b 0a0a 0909 7374 643a 3a76 6563  urn;....std::vec
    │ │ │ -0000b1d0: 746f 7226 6c74 3b6f 7074 5f75 6e63 686f  tor<opt_uncho
    │ │ │ -0000b1e0: 6b65 5f63 616e 6469 6461 7465 2667 743b  ke_candidate>
    │ │ │ -0000b1f0: 206f 7074 5f75 6e63 686f 6b65 3b0a 0a09   opt_unchoke;...
    │ │ │ -0000b200: 092f 2f20 636f 6c6c 6563 7420 7468 6520  .// collect the 
    │ │ │ -0000b210: 6375 7272 656e 746c 7920 6f70 7469 6d69  currently optimi
    │ │ │ -0000b220: 7374 6963 616c 6c79 2075 6e63 686f 6b65  stically unchoke
    │ │ │ -0000b230: 6420 7065 6572 7320 6865 7265 2c20 736f  d peers here, so
    │ │ │ -0000b240: 2077 6520 6361 6e0a 0909 2f2f 2063 686f   we can...// cho
    │ │ │ -0000b250: 6b65 2074 6865 6d20 7768 656e 2077 6527  ke them when we'
    │ │ │ -0000b260: 7665 2066 6f75 6e64 206e 6577 206f 7074  ve found new opt
    │ │ │ -0000b270: 696d 6973 7469 6320 756e 6368 6f6b 6520  imistic unchoke 
    │ │ │ -0000b280: 6361 6e64 6964 6174 6573 2e0a 0909 7374  candidates....st
    │ │ │ -0000b290: 643a 3a76 6563 746f 7226 6c74 3b74 6f72  d::vector<tor
    │ │ │ -0000b2a0: 7265 6e74 5f70 6565 722a 2667 743b 2070  rent_peer*> p
    │ │ │ -0000b2b0: 7265 765f 6f70 745f 756e 6368 6f6b 653b  rev_opt_unchoke;
    │ │ │ -0000b2c0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0000b2f0: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -0000b300: 7426 616d 703b 2069 203a 206d 5f63 6f6e t& i : m_con │ │ │ -0000b310: 6e65 6374 696f 6e73 290a 3c2f 6469 763e nections).
    │ │ │ -0000b320: 0909 7b0a 0909 0970 6565 725f 636f 6e6e ..{....peer_conn │ │ │ -0000b330: 6563 7469 6f6e 2a20 636f 6e73 7420 7020 ection* const p │ │ │ -0000b340: 3d20 692e 6765 7428 293b 0a09 0909 544f = i.get();....TO │ │ │ -0000b350: 5252 454e 545f 4153 5345 5254 2870 293b RRENT_ASSERT(p); │ │ │ -0000b360: 0a09 0909 746f 7272 656e 745f 7065 6572 ....torrent_peer │ │ │ -0000b370: 2a20 7069 203d 2070 2d26 6774 3b70 6565 * pi = p->pee │ │ │ -0000b380: 725f 696e 666f 5f73 7472 7563 7428 293b r_info_struct(); │ │ │ -0000b390: 0a09 0909 6966 2028 2170 6929 2063 6f6e ....if (!pi) con │ │ │ -0000b3a0: 7469 6e75 653b 0a09 0909 6966 2028 7069 tinue;....if (pi │ │ │ -0000b3b0: 2d26 6774 3b77 6562 5f73 6565 6429 2063 ->web_seed) c │ │ │ -0000b3c0: 6f6e 7469 6e75 653b 0a0a 0909 0969 6620 ontinue;.....if │ │ │ -0000b3d0: 2870 692d 2667 743b 6f70 7469 6d69 7374 (pi->optimist │ │ │ -0000b3e0: 6963 616c 6c79 5f75 6e63 686f 6b65 6429 ically_unchoked) │ │ │ -0000b3f0: 0a09 0909 7b0a 0909 0909 7072 6576 5f6f ....{.....prev_o │ │ │ -0000b400: 7074 5f75 6e63 686f 6b65 2e70 7573 685f pt_unchoke.push_ │ │ │ -0000b410: 6261 636b 2870 6929 3b0a 0909 097d 0a0a back(pi);....}.. │ │ │ -0000b420: 0909 0974 6f72 7265 6e74 2063 6f6e 7374 ...torrent const │ │ │ -0000b430: 2a20 7420 3d20 702d 2667 743b 6173 736f * t = p->asso │ │ │ -0000b440: 6369 6174 6564 5f74 6f72 7265 6e74 2829 ciated_torrent() │ │ │ -0000b450: 2e6c 6f63 6b28 292e 6765 7428 293b 0a09 .lock().get();.. │ │ │ -0000b460: 0909 6966 2028 2174 2920 636f 6e74 696e ..if (!t) contin │ │ │ -0000b470: 7565 3b0a 0a3c 2f70 7265 3e3c 2f74 643e ue;..
    │ │ │ -0000b480: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0000b4b0: 6e62 7370 3b33 3c2f 7464 3e3c 7464 3e3c nbsp;3< │ │ │ -0000b4c0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0000b4d0: 7074 3a65 7870 616e 6428 3232 2922 3e2e pt:expand(22)">. │ │ │ -0000b4e0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -0000b4f0: 706c 2e63 7070 3a34 3334 303c 2f61 3e3c pl.cpp:4340< │ │ │ -0000b500: 2f74 643e 3c74 643e 7065 6572 7320 7368 /td>peers sh │ │ │ -0000b510: 6f75 6c64 206b 6e6f 7720 7768 6574 6865 ould know whethe │ │ │ -0000b520: 7220 7468 6569 7220 746f 7272 656e 7420 r their torrent │ │ │ -0000b530: 6973 2070 6175 7365 6420 6f72 206e 6f74 is paused or not │ │ │ -0000b540: 2c20 696e 7374 6561 6420 6f66 2068 6176 , instead of hav │ │ │ -0000b550: 696e 6720 746f 2061 736b 2069 7420 6f76 ing to ask it ov │ │ │ -0000b560: 6572 2061 6e64 206f 7665 7220 6167 6169 er and over agai │ │ │ -0000b570: 6e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 n

    pe │ │ │ -0000b5c0: 6572 7320 7368 6f75 6c64 206b 6e6f 7720 ers should know │ │ │ -0000b5d0: 7768 6574 6865 7220 7468 6569 7220 746f whether their to │ │ │ -0000b5e0: 7272 656e 7420 6973 2070 6175 7365 6420 rrent is paused │ │ │ -0000b5f0: 6f72 206e 6f74 2c0a 696e 7374 6561 6420 or not,.instead │ │ │ -0000b600: 6f66 2068 6176 696e 6720 746f 2061 736b of having to ask │ │ │ -0000b610: 2069 7420 6f76 6572 2061 6e64 206f 7665 it over and ove │ │ │ -0000b620: 7220 6167 6169 6e3c 2f68 323e 3c68 343e r again

    │ │ │ -0000b630: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0000b640: 6d70 6c2e 6370 703a 3433 3430 3c2f 6834 mpl.cpp:4340

    ..// 
    │ │ │ -0000b690: 636f 6c6c 6563 7420 7468 6520 6375 7272  collect the curr
    │ │ │ -0000b6a0: 656e 746c 7920 6f70 7469 6d69 7374 6963  ently optimistic
    │ │ │ -0000b6b0: 616c 6c79 2075 6e63 686f 6b65 6420 7065  ally unchoked pe
    │ │ │ -0000b6c0: 6572 7320 6865 7265 2c20 736f 2077 6520  ers here, so we 
    │ │ │ -0000b6d0: 6361 6e0a 0909 2f2f 2063 686f 6b65 2074  can...// choke t
    │ │ │ -0000b6e0: 6865 6d20 7768 656e 2077 6527 7665 2066  hem when we've f
    │ │ │ -0000b6f0: 6f75 6e64 206e 6577 206f 7074 696d 6973  ound new optimis
    │ │ │ -0000b700: 7469 6320 756e 6368 6f6b 6520 6361 6e64  tic unchoke cand
    │ │ │ -0000b710: 6964 6174 6573 2e0a 0909 7374 643a 3a76  idates....std::v
    │ │ │ -0000b720: 6563 746f 7226 6c74 3b74 6f72 7265 6e74  ector<torrent
    │ │ │ -0000b730: 5f70 6565 722a 2667 743b 2070 7265 765f  _peer*> prev_
    │ │ │ -0000b740: 6f70 745f 756e 6368 6f6b 653b 0a0a 0909  opt_unchoke;....
    │ │ │ -0000b750: 666f 7220 2861 7574 6f20 636f 6e73 7426  for (auto const&
    │ │ │ -0000b760: 616d 703b 2069 203a 206d 5f63 6f6e 6e65  amp; i : m_conne
    │ │ │ -0000b770: 6374 696f 6e73 290a 0909 7b0a 0909 0970  ctions)...{....p
    │ │ │ -0000b780: 6565 725f 636f 6e6e 6563 7469 6f6e 2a20  eer_connection* 
    │ │ │ -0000b790: 636f 6e73 7420 7020 3d20 692e 6765 7428  const p = i.get(
    │ │ │ -0000b7a0: 293b 0a09 0909 544f 5252 454e 545f 4153  );....TORRENT_AS
    │ │ │ -0000b7b0: 5345 5254 2870 293b 0a09 0909 746f 7272  SERT(p);....torr
    │ │ │ -0000b7c0: 656e 745f 7065 6572 2a20 7069 203d 2070  ent_peer* pi = p
    │ │ │ -0000b7d0: 2d26 6774 3b70 6565 725f 696e 666f 5f73  ->peer_info_s
    │ │ │ -0000b7e0: 7472 7563 7428 293b 0a09 0909 6966 2028  truct();....if (
    │ │ │ -0000b7f0: 2170 6929 2063 6f6e 7469 6e75 653b 0a09  !pi) continue;..
    │ │ │ -0000b800: 0909 6966 2028 7069 2d26 6774 3b77 6562  ..if (pi->web
    │ │ │ -0000b810: 5f73 6565 6429 2063 6f6e 7469 6e75 653b  _seed) continue;
    │ │ │ -0000b820: 0a0a 0909 0969 6620 2870 692d 2667 743b  .....if (pi->
    │ │ │ -0000b830: 6f70 7469 6d69 7374 6963 616c 6c79 5f75  optimistically_u
    │ │ │ -0000b840: 6e63 686f 6b65 6429 0a09 0909 7b0a 0909  nchoked)....{...
    │ │ │ -0000b850: 0909 7072 6576 5f6f 7074 5f75 6e63 686f  ..prev_opt_uncho
    │ │ │ -0000b860: 6b65 2e70 7573 685f 6261 636b 2870 6929  ke.push_back(pi)
    │ │ │ -0000b870: 3b0a 0909 097d 0a0a 0909 0974 6f72 7265  ;....}.....torre
    │ │ │ -0000b880: 6e74 2063 6f6e 7374 2a20 7420 3d20 702d  nt const* t = p-
    │ │ │ -0000b890: 2667 743b 6173 736f 6369 6174 6564 5f74  >associated_t
    │ │ │ -0000b8a0: 6f72 7265 6e74 2829 2e6c 6f63 6b28 292e  orrent().lock().
    │ │ │ -0000b8b0: 6765 7428 293b 0a09 0909 6966 2028 2174  get();....if (!t
    │ │ │ -0000b8c0: 2920 636f 6e74 696e 7565 3b0a 0a3c 6469  ) continue;.....if
    │ │ │ -0000b900: 2028 742d 2667 743b 6973 5f70 6175 7365   (t->is_pause
    │ │ │ -0000b910: 6428 2929 2063 6f6e 7469 6e75 653b 0a3c  d()) continue;.<
    │ │ │ -0000b920: 2f64 6976 3e0a 0909 0969 6620 2821 702d  /div>....if (!p-
    │ │ │ -0000b930: 2667 743b 6973 5f63 6f6e 6e65 6374 696e  >is_connectin
    │ │ │ -0000b940: 6728 290a 0909 0909 2661 6d70 3b26 616d  g().....&&am
    │ │ │ -0000b950: 703b 2021 702d 2667 743b 6973 5f64 6973  p; !p->is_dis
    │ │ │ -0000b960: 636f 6e6e 6563 7469 6e67 2829 0a09 0909  connecting()....
    │ │ │ -0000b970: 0926 616d 703b 2661 6d70 3b20 702d 2667  .&& p-&g
    │ │ │ -0000b980: 743b 6973 5f70 6565 725f 696e 7465 7265  t;is_peer_intere
    │ │ │ -0000b990: 7374 6564 2829 0a09 0909 0926 616d 703b  sted().....&
    │ │ │ -0000b9a0: 2661 6d70 3b20 742d 2667 743b 6672 6565  & t->free
    │ │ │ -0000b9b0: 5f75 706c 6f61 645f 736c 6f74 7328 290a  _upload_slots().
    │ │ │ -0000b9c0: 0909 0909 2661 6d70 3b26 616d 703b 2028  ....&& (
    │ │ │ -0000b9d0: 702d 2667 743b 6973 5f63 686f 6b65 6428  p->is_choked(
    │ │ │ -0000b9e0: 2920 7c7c 2070 692d 2667 743b 6f70 7469  ) || pi->opti
    │ │ │ -0000b9f0: 6d69 7374 6963 616c 6c79 5f75 6e63 686f  mistically_uncho
    │ │ │ -0000ba00: 6b65 6429 0a09 0909 0926 616d 703b 2661  ked).....&&a
    │ │ │ -0000ba10: 6d70 3b20 2170 2d26 6774 3b69 676e 6f72  mp; !p->ignor
    │ │ │ -0000ba20: 655f 756e 6368 6f6b 655f 736c 6f74 7328  e_unchoke_slots(
    │ │ │ -0000ba30: 290a 0909 0909 2661 6d70 3b26 616d 703b  ).....&&
    │ │ │ -0000ba40: 2074 2d26 6774 3b76 616c 6964 5f6d 6574   t->valid_met
    │ │ │ -0000ba50: 6164 6174 6128 2929 0a09 0909 7b0a 0909  adata())....{...
    │ │ │ -0000ba60: 0909 6f70 745f 756e 6368 6f6b 652e 656d  ..opt_unchoke.em
    │ │ │ -0000ba70: 706c 6163 655f 6261 636b 2826 616d 703b  place_back(&
    │ │ │ -0000ba80: 6929 3b0a 0909 097d 0a09 097d 0a0a 0909  i);....}...}....
    │ │ │ -0000ba90: 2f2f 2066 696e 6420 7468 6520 7065 6572  // find the peer
    │ │ │ -0000baa0: 7320 7468 6174 2068 6173 2062 6565 6e20  s that has been 
    │ │ │ -0000bab0: 7761 6974 696e 6720 7468 6520 6c6f 6e67  waiting the long
    │ │ │ -0000bac0: 6573 7420 746f 2062 6520 6f70 7469 6d69  est to be optimi
    │ │ │ -0000bad0: 7374 6963 616c 6c79 0a09 092f 2f20 756e  stically...// un
    │ │ │ -0000bae0: 6368 6f6b 6564 0a0a 0909 696e 7420 6e75  choked....int nu
    │ │ │ -0000baf0: 6d5f 6f70 745f 756e 6368 6f6b 6520 3d20  m_opt_unchoke = 
    │ │ │ -0000bb00: 6d5f 7365 7474 696e 6773 2e67 6574 5f69  m_settings.get_i
    │ │ │ -0000bb10: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ -0000bb20: 3a3a 6e75 6d5f 6f70 7469 6d69 7374 6963  ::num_optimistic
    │ │ │ -0000bb30: 5f75 6e63 686f 6b65 5f73 6c6f 7473 293b  _unchoke_slots);
    │ │ │ -0000bb40: 0a09 0969 6e74 2063 6f6e 7374 2061 6c6c  ...int const all
    │ │ │ -0000bb50: 6f77 6564 5f75 6e63 686f 6b65 5f73 6c6f  owed_unchoke_slo
    │ │ │ -0000bb60: 7473 203d 2069 6e74 286d 5f73 7461 7473  ts = int(m_stats
    │ │ │ -0000bb70: 5f63 6f75 6e74 6572 735b 636f 756e 7465  _counters[counte
    │ │ │ -0000bb80: 7273 3a3a 6e75 6d5f 756e 6368 6f6b 655f  rs::num_unchoke_
    │ │ │ -0000bb90: 736c 6f74 735d 293b 0a09 0969 6620 286e  slots]);...if (n
    │ │ │ -0000bba0: 756d 5f6f 7074 5f75 6e63 686f 6b65 203d  um_opt_unchoke =
    │ │ │ -0000bbb0: 3d20 3029 206e 756d 5f6f 7074 5f75 6e63  = 0) num_opt_unc
    │ │ │ -0000bbc0: 686f 6b65 203d 2073 7464 3a3a 6d61 7828  hoke = std::max(
    │ │ │ -0000bbd0: 312c 2061 6c6c 6f77 6564 5f75 6e63 686f  1, allowed_uncho
    │ │ │ -0000bbe0: 6b65 5f73 6c6f 7473 202f 2035 293b 0a09  ke_slots / 5);..
    │ │ │ -0000bbf0: 0969 6620 286e 756d 5f6f 7074 5f75 6e63  .if (num_opt_unc
    │ │ │ -0000bc00: 686f 6b65 2026 6774 3b20 696e 7428 6f70  hoke > int(op
    │ │ │ -0000bc10: 745f 756e 6368 6f6b 652e 7369 7a65 2829  t_unchoke.size()
    │ │ │ -0000bc20: 2929 206e 756d 5f6f 7074 5f75 6e63 686f  )) num_opt_uncho
    │ │ │ -0000bc30: 6b65 203d 0a09 0909 696e 7428 6f70 745f  ke =....int(opt_
    │ │ │ -0000bc40: 756e 6368 6f6b 652e 7369 7a65 2829 293b  unchoke.size());
    │ │ │ -0000bc50: 0a0a 0909 2f2f 2066 696e 6420 7468 6520  ....// find the 
    │ │ │ -0000bc60: 6e20 6265 7374 206f 7074 696d 6973 7469  n best optimisti
    │ │ │ -0000bc70: 6320 756e 6368 6f6b 6520 6361 6e64 6964  c unchoke candid
    │ │ │ -0000bc80: 6174 6573 0a09 0973 7464 3a3a 7061 7274  ates...std::part
    │ │ │ -0000bc90: 6961 6c5f 736f 7274 286f 7074 5f75 6e63  ial_sort(opt_unc
    │ │ │ -0000bca0: 686f 6b65 2e62 6567 696e 2829 0a09 0909  hoke.begin()....
    │ │ │ -0000bcb0: 2c20 6f70 745f 756e 6368 6f6b 652e 6265  , opt_unchoke.be
    │ │ │ -0000bcc0: 6769 6e28 2920 2b20 6e75 6d5f 6f70 745f  gin() + num_opt_
    │ │ │ -0000bcd0: 756e 6368 6f6b 650a 0909 092c 206f 7074  unchoke...., opt
    │ │ │ -0000bce0: 5f75 6e63 686f 6b65 2e65 6e64 2829 0a23  _unchoke.end().#
    │ │ │ -0000bcf0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -0000bd00: 4953 4142 4c45 5f45 5854 454e 5349 4f4e  ISABLE_EXTENSION
    │ │ │ -0000bd10: 530a 0909 092c 206c 6173 745f 6f70 7469  S...., last_opti
    │ │ │ -0000bd20: 6d69 7374 6963 5f75 6e63 686f 6b65 5f63  mistic_unchoke_c
    │ │ │ -0000bd30: 6d70 286d 5f73 6573 5f65 7874 656e 7369  mp(m_ses_extensi
    │ │ │ -0000bd40: 6f6e 735b 706c 7567 696e 735f 6f70 7469  ons[plugins_opti
    │ │ │ -0000bd50: 6d69 7374 6963 5f75 6e63 686f 6b65 5f69  mistic_unchoke_i
    │ │ │ -0000bd60: 6478 5d29 0a23 656c 7365 0a09 0909 2c20  dx]).#else...., 
    │ │ │ -0000bd70: 6c61 7374 5f6f 7074 696d 6973 7469 635f  last_optimistic_
    │ │ │ -0000bd80: 756e 6368 6f6b 655f 636d 7028 290a 3c2f  unchoke_cmp().r
    │ │ │ -0000bdc0: 656c 6576 616e 6365 266e 6273 703b 333c  elevance 3<
    │ │ │ -0000bdd0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/s
    │ │ │ -0000be00: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a  ession_impl.cpp:
    │ │ │ -0000be10: 3435 3836 3c2f 613e 3c2f 7464 3e3c 7464  4586there should be
    │ │ │ -0000be30: 2061 2070 7265 2d63 616c 6375 6c61 7465   a pre-calculate
    │ │ │ -0000be40: 6420 6c69 7374 206f 6620 616c 6c20 7065  d list of all pe
    │ │ │ -0000be50: 6572 7320 656c 6967 6962 6c65 2066 6f72  ers eligible for
    │ │ │ -0000be60: 2075 6e63 686f 6b69 6e67 3c2f 7464 3e3c   unchoking<
    │ │ │ -0000be70: 2f74 723e 3c74 7220 6964 3d22 3233 2220  /tr>

    there sho │ │ │ -0000bec0: 756c 6420 6265 2061 2070 7265 2d63 616c uld be a pre-cal │ │ │ -0000bed0: 6375 6c61 7465 6420 6c69 7374 206f 6620 culated list of │ │ │ -0000bee0: 616c 6c20 7065 6572 7320 656c 6967 6962 all peers eligib │ │ │ -0000bef0: 6c65 2066 6f72 0a75 6e63 686f 6b69 6e67 le for.unchoking │ │ │ -0000bf00: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0000bf10: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -0000bf20: 3a34 3538 363c 2f68 343e 3c70 7265 2073 :4586

    .}...void se
    │ │ │ -0000bf70: 7373 696f 6e5f 696d 706c 3a3a 7265 6361  ssion_impl::reca
    │ │ │ -0000bf80: 6c63 756c 6174 655f 756e 6368 6f6b 655f  lculate_unchoke_
    │ │ │ -0000bf90: 736c 6f74 7328 290a 097b 0a09 0954 4f52  slots()..{...TOR
    │ │ │ -0000bfa0: 5245 4e54 5f41 5353 4552 5428 6973 5f73  RENT_ASSERT(is_s
    │ │ │ -0000bfb0: 696e 676c 655f 7468 7265 6164 2829 293b  ingle_thread());
    │ │ │ -0000bfc0: 0a0a 0909 7469 6d65 5f70 6f69 6e74 2063  ....time_point c
    │ │ │ -0000bfd0: 6f6e 7374 206e 6f77 203d 2061 7578 3a3a  onst now = aux::
    │ │ │ -0000bfe0: 7469 6d65 5f6e 6f77 2829 3b0a 0909 7469  time_now();...ti
    │ │ │ -0000bff0: 6d65 5f64 7572 6174 696f 6e20 636f 6e73  me_duration cons
    │ │ │ -0000c000: 7420 756e 6368 6f6b 655f 696e 7465 7276  t unchoke_interv
    │ │ │ -0000c010: 616c 203d 206e 6f77 202d 206d 5f6c 6173  al = now - m_las
    │ │ │ -0000c020: 745f 6368 6f6b 653b 0a09 096d 5f6c 6173  t_choke;...m_las
    │ │ │ -0000c030: 745f 6368 6f6b 6520 3d20 6e6f 773b 0a0a  t_choke = now;..
    │ │ │ -0000c040: 0909 2f2f 2069 6620 7765 2075 6e63 686f  ..// if we uncho
    │ │ │ -0000c050: 6b65 2065 7665 7279 6f6e 652c 2073 6b69  ke everyone, ski
    │ │ │ -0000c060: 7020 7468 6973 206c 6f67 6963 0a09 0969  p this logic...i
    │ │ │ -0000c070: 6620 2873 6574 7469 6e67 7328 292e 6765  f (settings().ge
    │ │ │ -0000c080: 745f 696e 7428 7365 7474 696e 6773 5f70  t_int(settings_p
    │ │ │ -0000c090: 6163 6b3a 3a63 686f 6b69 6e67 5f61 6c67  ack::choking_alg
    │ │ │ -0000c0a0: 6f72 6974 686d 2920 3d3d 2073 6574 7469  orithm) == setti
    │ │ │ -0000c0b0: 6e67 735f 7061 636b 3a3a 6669 7865 645f  ngs_pack::fixed_
    │ │ │ -0000c0c0: 736c 6f74 735f 6368 6f6b 6572 0a09 0909  slots_choker....
    │ │ │ -0000c0d0: 2661 6d70 3b26 616d 703b 2073 6574 7469  && setti
    │ │ │ -0000c0e0: 6e67 7328 292e 6765 745f 696e 7428 7365  ngs().get_int(se
    │ │ │ -0000c0f0: 7474 696e 6773 5f70 6163 6b3a 3a75 6e63  ttings_pack::unc
    │ │ │ -0000c100: 686f 6b65 5f73 6c6f 7473 5f6c 696d 6974  hoke_slots_limit
    │ │ │ -0000c110: 2920 266c 743b 2030 290a 0909 7b0a 0909  ) < 0)...{...
    │ │ │ -0000c120: 096d 5f73 7461 7473 5f63 6f75 6e74 6572  .m_stats_counter
    │ │ │ -0000c130: 732e 7365 745f 7661 6c75 6528 636f 756e  s.set_value(coun
    │ │ │ -0000c140: 7465 7273 3a3a 6e75 6d5f 756e 6368 6f6b  ters::num_unchok
    │ │ │ -0000c150: 655f 736c 6f74 732c 2073 7464 3a3a 6e75  e_slots, std::nu
    │ │ │ -0000c160: 6d65 7269 635f 6c69 6d69 7473 266c 743b  meric_limits<
    │ │ │ -0000c170: 696e 7426 6774 3b3a 3a6d 6178 2829 293b  int>::max());
    │ │ │ -0000c180: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a  ....return;...}.
    │ │ │ -0000c190: 0a09 092f 2f20 6275 696c 6420 6c69 7374  ...// build list
    │ │ │ -0000c1a0: 206f 6620 616c 6c20 7065 6572 7320 7468   of all peers th
    │ │ │ -0000c1b0: 6174 2061 7265 0a09 092f 2f20 756e 6368  at are...// unch
    │ │ │ -0000c1c0: 6f6b 6162 6c65 2e0a 3c64 6976 2073 7479  okable..
    ..std::vec │ │ │ -0000c200: 746f 7226 6c74 3b70 6565 725f 636f 6e6e tor<peer_conn │ │ │ -0000c210: 6563 7469 6f6e 2a26 6774 3b20 7065 6572 ection*> peer │ │ │ -0000c220: 733b 0a3c 2f64 6976 3e09 0966 6f72 2028 s;.
    ..for ( │ │ │ -0000c230: 6175 746f 2069 203d 206d 5f63 6f6e 6e65 auto i = m_conne │ │ │ -0000c240: 6374 696f 6e73 2e62 6567 696e 2829 3b20 ctions.begin(); │ │ │ -0000c250: 6920 213d 206d 5f63 6f6e 6e65 6374 696f i != m_connectio │ │ │ -0000c260: 6e73 2e65 6e64 2829 3b29 0a09 097b 0a09 ns.end();)...{.. │ │ │ -0000c270: 0909 7374 643a 3a73 6861 7265 645f 7074 ..std::shared_pt │ │ │ -0000c280: 7226 6c74 3b70 6565 725f 636f 6e6e 6563 r<peer_connec │ │ │ -0000c290: 7469 6f6e 2667 743b 2070 203d 202a 693b tion> p = *i; │ │ │ -0000c2a0: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -0000c2b0: 5254 2870 293b 0a09 0909 2b2b 693b 0a09 RT(p);....++i;.. │ │ │ -0000c2c0: 0909 746f 7272 656e 742a 2063 6f6e 7374 ..torrent* const │ │ │ -0000c2d0: 2074 203d 2070 2d26 6774 3b61 7373 6f63 t = p->assoc │ │ │ -0000c2e0: 6961 7465 645f 746f 7272 656e 7428 292e iated_torrent(). │ │ │ -0000c2f0: 6c6f 636b 2829 2e67 6574 2829 3b0a 0909 lock().get();... │ │ │ -0000c300: 0974 6f72 7265 6e74 5f70 6565 722a 2063 .torrent_peer* c │ │ │ -0000c310: 6f6e 7374 2070 6920 3d20 702d 2667 743b onst pi = p-> │ │ │ -0000c320: 7065 6572 5f69 6e66 6f5f 7374 7275 6374 peer_info_struct │ │ │ -0000c330: 2829 3b0a 0a09 0909 6966 2028 702d 2667 ();.....if (p-&g │ │ │ -0000c340: 743b 6967 6e6f 7265 5f75 6e63 686f 6b65 t;ignore_unchoke │ │ │ -0000c350: 5f73 6c6f 7473 2829 207c 7c20 7420 3d3d _slots() || t == │ │ │ -0000c360: 206e 756c 6c70 7472 207c 7c20 7069 203d nullptr || pi = │ │ │ -0000c370: 3d20 6e75 6c6c 7074 720a 0909 0909 7c7c = nullptr.....|| │ │ │ -0000c380: 2070 692d 2667 743b 7765 625f 7365 6564 pi->web_seed │ │ │ -0000c390: 207c 7c20 742d 2667 743b 6973 5f70 6175 || t->is_pau │ │ │ -0000c3a0: 7365 6428 2929 0a09 0909 7b0a 0909 0909 sed())....{..... │ │ │ -0000c3b0: 702d 2667 743b 7265 7365 745f 6368 6f6b p->reset_chok │ │ │ -0000c3c0: 655f 636f 756e 7465 7273 2829 3b0a 0909 e_counters();... │ │ │ -0000c3d0: 0909 636f 6e74 696e 7565 3b0a 0909 097d ..continue;....} │ │ │ -0000c3e0: 0a0a 0909 0969 6620 2821 702d 2667 743b .....if (!p-> │ │ │ -0000c3f0: 6973 5f70 6565 725f 696e 7465 7265 7374 is_peer_interest │ │ │ -0000c400: 6564 2829 0a09 0909 097c 7c20 702d 2667 ed().....|| p-&g │ │ │ -0000c410: 743b 6973 5f64 6973 636f 6e6e 6563 7469 t;is_disconnecti │ │ │ -0000c420: 6e67 2829 0a09 0909 097c 7c20 702d 2667 ng().....|| p-&g │ │ │ -0000c430: 743b 6973 5f63 6f6e 6e65 6374 696e 6728 t;is_connecting( │ │ │ -0000c440: 2929 0a09 0909 7b0a 0909 0909 2f2f 2074 ))....{.....// t │ │ │ -0000c450: 6869 7320 7065 6572 2069 7320 6e6f 7420 his peer is not │ │ │ -0000c460: 756e 6368 6f6b 6162 6c65 2e20 536f 2c20 unchokable. So, │ │ │ -0000c470: 6966 2069 7427 7320 756e 6368 6f6b 6564 if it's unchoked │ │ │ -0000c480: 0a09 0909 092f 2f20 616c 7265 6164 792c .....// already, │ │ │ -0000c490: 206d 616b 6520 7375 7265 2074 6f20 6368 make sure to ch │ │ │ -0000c4a0: 6f6b 6520 6974 2e0a 0909 0909 6966 2028 oke it......if ( │ │ │ -0000c4b0: 702d 2667 743b 6973 5f63 686f 6b65 6428 p->is_choked( │ │ │ -0000c4c0: 2929 0a09 0909 097b 0a09 0909 0909 702d )).....{......p- │ │ │ -0000c4d0: 2667 743b 7265 7365 745f 6368 6f6b 655f >reset_choke_ │ │ │ -0000c4e0: 636f 756e 7465 7273 2829 3b0a 0909 0909 counters();..... │ │ │ -0000c4f0: 0963 6f6e 7469 6e75 653b 0a09 0909 097d .continue;.....} │ │ │ -0000c500: 0a09 0909 0969 6620 2870 6920 2661 6d70 .....if (pi & │ │ │ -0000c510: 3b26 616d 703b 2070 692d 2667 743b 6f70 ;& pi->op │ │ │ -0000c520: 7469 6d69 7374 6963 616c 6c79 5f75 6e63 timistically_unc │ │ │ -0000c530: 686f 6b65 6429 0a09 0909 097b 0a09 0909 hoked).....{.... │ │ │ -0000c540: 0909 6d5f 7374 6174 735f 636f 756e 7465 ..m_stats_counte │ │ │ -0000c550: 7273 2e69 6e63 5f73 7461 7473 5f63 6f75 rs.inc_stats_cou │ │ │ -0000c560: 6e74 6572 2863 6f75 6e74 6572 733a 3a6e nter(counters::n │ │ │ -0000c570: 756d 5f70 6565 7273 5f75 705f 756e 6368 um_peers_up_unch │ │ │ -0000c580: 6f6b 6564 5f6f 7074 696d 6973 7469 632c oked_optimistic, │ │ │ -0000c590: 202d 3129 3b0a 0909 0909 0970 692d 2667 -1);......pi-&g │ │ │ -0000c5a0: 743b 6f70 7469 6d69 7374 6963 616c 6c79 t;optimistically │ │ │ -0000c5b0: 5f75 6e63 686f 6b65 6420 3d20 6661 6c73 _unchoked = fals │ │ │ -0000c5c0: 653b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f e;.
    │ │ │ -0000c5f0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0000c600: 7370 3b33 3c2f 7464 3e3c 7464 3e3c 6120 sp;3../ │ │ │ -0000c630: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0000c640: 2e63 7070 3a36 3332 323c 2f61 3e3c 2f74 .cpp:6322
    use public │ │ │ -0000c660: 5f6b 6579 2068 6572 6520 696e 7374 6561 _key here instea │ │ │ -0000c670: 6420 6f66 2073 7464 3a3a 6172 7261 793c d of std::array< │ │ │ -0000c680: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    use │ │ │ -0000c6d0: 7075 626c 6963 5f6b 6579 2068 6572 6520 public_key here │ │ │ -0000c6e0: 696e 7374 6561 6420 6f66 2073 7464 3a3a instead of std:: │ │ │ -0000c6f0: 6172 7261 793c 2f68 323e 3c68 343e 2e2e array

    .. │ │ │ -0000c700: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ -0000c710: 6c2e 6370 703a 3633 3232 3c2f 6834 3e3c l.cpp:6322

    < │ │ │ -0000c720: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0000c730: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0000c740: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0000c750: 7820 2364 6464 3b22 3e0a 0976 6f69 6420 x #ddd;">..void │ │ │ -0000c760: 7365 7373 696f 6e5f 696d 706c 3a3a 6468 session_impl::dh │ │ │ -0000c770: 745f 6765 745f 696d 6d75 7461 626c 655f t_get_immutable_ │ │ │ -0000c780: 6974 656d 2873 6861 315f 6861 7368 2063 item(sha1_hash c │ │ │ -0000c790: 6f6e 7374 2661 6d70 3b20 7461 7267 6574 onst& target │ │ │ -0000c7a0: 290a 097b 0a09 0969 6620 2821 6d5f 6468 )..{...if (!m_dh │ │ │ -0000c7b0: 7429 2072 6574 7572 6e3b 0a09 096d 5f64 t) return;...m_d │ │ │ -0000c7c0: 6874 2d26 6774 3b67 6574 5f69 7465 6d28 ht->get_item( │ │ │ -0000c7d0: 7461 7267 6574 2c20 7374 643a 3a62 696e target, std::bin │ │ │ -0000c7e0: 6428 2661 6d70 3b73 6573 7369 6f6e 5f69 d(&session_i │ │ │ -0000c7f0: 6d70 6c3a 3a67 6574 5f69 6d6d 7574 6162 mpl::get_immutab │ │ │ -0000c800: 6c65 5f63 616c 6c62 6163 6b0a 0909 092c le_callback...., │ │ │ -0000c810: 2074 6869 732c 2074 6172 6765 742c 205f this, target, _ │ │ │ -0000c820: 3129 293b 0a09 7d0a 0a09 2f2f 2063 616c 1));..}...// cal │ │ │ -0000c830: 6c62 6163 6b20 666f 7220 6468 745f 6d75 lback for dht_mu │ │ │ -0000c840: 7461 626c 655f 6765 740a 0976 6f69 6420 table_get..void │ │ │ -0000c850: 7365 7373 696f 6e5f 696d 706c 3a3a 6765 session_impl::ge │ │ │ -0000c860: 745f 6d75 7461 626c 655f 6361 6c6c 6261 t_mutable_callba │ │ │ -0000c870: 636b 2864 6874 3a3a 6974 656d 2063 6f6e ck(dht::item con │ │ │ -0000c880: 7374 2661 6d70 3b20 690a 0909 2c20 626f st& i..., bo │ │ │ -0000c890: 6f6c 2063 6f6e 7374 2061 7574 686f 7269 ol const authori │ │ │ -0000c8a0: 7461 7469 7665 290a 097b 0a09 0954 4f52 tative)..{...TOR │ │ │ -0000c8b0: 5245 4e54 5f41 5353 4552 5428 692e 6973 RENT_ASSERT(i.is │ │ │ -0000c8c0: 5f6d 7574 6162 6c65 2829 293b 0a09 096d _mutable());...m │ │ │ -0000c8d0: 5f61 6c65 7274 732e 656d 706c 6163 655f _alerts.emplace_ │ │ │ -0000c8e0: 616c 6572 7426 6c74 3b64 6874 5f6d 7574 alert<dht_mut │ │ │ -0000c8f0: 6162 6c65 5f69 7465 6d5f 616c 6572 7426 able_item_alert& │ │ │ -0000c900: 6774 3b28 692e 706b 2829 2e62 7974 6573 gt;(i.pk().bytes │ │ │ -0000c910: 0a09 0909 2c20 692e 7369 6728 292e 6279 ...., i.sig().by │ │ │ -0000c920: 7465 732c 2069 2e73 6571 2829 2e76 616c tes, i.seq().val │ │ │ -0000c930: 7565 0a09 0909 2c20 692e 7361 6c74 2829 ue...., i.salt() │ │ │ -0000c940: 2c20 692e 7661 6c75 6528 292c 2061 7574 , i.value(), aut │ │ │ -0000c950: 686f 7269 7461 7469 7665 293b 0a09 7d0a horitative);..}. │ │ │ -0000c960: 0a09 2f2f 206b 6579 2069 7320 6120 3332 ..// key is a 32 │ │ │ -0000c970: 2d62 7974 6520 6269 6e61 7279 2073 7472 -byte binary str │ │ │ -0000c980: 696e 672c 2074 6865 2070 7562 6c69 6320 ing, the public │ │ │ -0000c990: 6b65 7920 746f 206c 6f6f 6b20 7570 2e0a key to look up.. │ │ │ -0000c9a0: 092f 2f20 7468 6520 7361 6c74 2069 7320 .// the salt is │ │ │ -0000c9b0: 6f70 7469 6f6e 616c 0a3c 6469 7620 7374 optional.
    .void ses │ │ │ -0000c9f0: 7369 6f6e 5f69 6d70 6c3a 3a64 6874 5f67 sion_impl::dht_g │ │ │ -0000ca00: 6574 5f6d 7574 6162 6c65 5f69 7465 6d28 et_mutable_item( │ │ │ -0000ca10: 7374 643a 3a61 7272 6179 266c 743b 6368 std::array<ch │ │ │ -0000ca20: 6172 2c20 3332 2667 743b 206b 6579 0a3c ar, 32> key.< │ │ │ -0000ca30: 2f64 6976 3e09 092c 2073 7464 3a3a 7374 /div>.., std::st │ │ │ -0000ca40: 7269 6e67 2073 616c 7429 0a09 7b0a 0909 ring salt)..{... │ │ │ -0000ca50: 6966 2028 216d 5f64 6874 2920 7265 7475 if (!m_dht) retu │ │ │ -0000ca60: 726e 3b0a 0909 6d5f 6468 742d 2667 743b rn;...m_dht-> │ │ │ -0000ca70: 6765 745f 6974 656d 2864 6874 3a3a 7075 get_item(dht::pu │ │ │ -0000ca80: 626c 6963 5f6b 6579 286b 6579 2e64 6174 blic_key(key.dat │ │ │ -0000ca90: 6128 2929 2c20 7374 643a 3a62 696e 6428 a()), std::bind( │ │ │ -0000caa0: 2661 6d70 3b73 6573 7369 6f6e 5f69 6d70 &session_imp │ │ │ -0000cab0: 6c3a 3a67 6574 5f6d 7574 6162 6c65 5f63 l::get_mutable_c │ │ │ -0000cac0: 616c 6c62 6163 6b0a 0909 092c 2074 6869 allback...., thi │ │ │ -0000cad0: 732c 205f 312c 205f 3229 2c20 7374 643a s, _1, _2), std: │ │ │ -0000cae0: 3a6d 6f76 6528 7361 6c74 2929 3b0a 097d :move(salt));..} │ │ │ -0000caf0: 0a0a 096e 616d 6573 7061 6365 207b 0a0a ...namespace {.. │ │ │ -0000cb00: 0909 766f 6964 206f 6e5f 6468 745f 7075 ..void on_dht_pu │ │ │ -0000cb10: 745f 696d 6d75 7461 626c 655f 6974 656d t_immutable_item │ │ │ -0000cb20: 2861 7578 3a3a 616c 6572 745f 6d61 6e61 (aux::alert_mana │ │ │ -0000cb30: 6765 7226 616d 703b 2061 6c65 7274 732c ger& alerts, │ │ │ -0000cb40: 2073 6861 315f 6861 7368 2074 6172 6765 sha1_hash targe │ │ │ -0000cb50: 742c 2069 6e74 206e 756d 290a 0909 7b0a t, int num)...{. │ │ │ -0000cb60: 0909 0969 6620 2861 6c65 7274 732e 7368 ...if (alerts.sh │ │ │ -0000cb70: 6f75 6c64 5f70 6f73 7426 6c74 3b64 6874 ould_post<dht │ │ │ -0000cb80: 5f70 7574 5f61 6c65 7274 2667 743b 2829 _put_alert>() │ │ │ -0000cb90: 290a 0909 0909 616c 6572 7473 2e65 6d70 ).....alerts.emp │ │ │ -0000cba0: 6c61 6365 5f61 6c65 7274 266c 743b 6468 lace_alert<dh │ │ │ -0000cbb0: 745f 7075 745f 616c 6572 7426 6774 3b28 t_put_alert>( │ │ │ -0000cbc0: 7461 7267 6574 2c20 6e75 6d29 3b0a 0909 target, num);... │ │ │ -0000cbd0: 7d0a 0a09 0976 6f69 6420 6f6e 5f64 6874 }....void on_dht │ │ │ -0000cbe0: 5f70 7574 5f6d 7574 6162 6c65 5f69 7465 _put_mutable_ite │ │ │ -0000cbf0: 6d28 6175 783a 3a61 6c65 7274 5f6d 616e m(aux::alert_man │ │ │ -0000cc00: 6167 6572 2661 6d70 3b20 616c 6572 7473 ager& alerts │ │ │ -0000cc10: 2c20 6468 743a 3a69 7465 6d20 636f 6e73 , dht::item cons │ │ │ -0000cc20: 7426 616d 703b 2069 2c20 696e 7420 6e75 t& i, int nu │ │ │ -0000cc30: 6d29 0a09 097b 0a09 0909 6966 2028 616c m)...{....if (al │ │ │ -0000cc40: 6572 7473 2e73 686f 756c 645f 706f 7374 erts.should_post │ │ │ -0000cc50: 266c 743b 6468 745f 7075 745f 616c 6572 <dht_put_aler │ │ │ -0000cc60: 7426 6774 3b28 2929 0a09 0909 7b0a 0909 t>())....{... │ │ │ -0000cc70: 0909 6468 743a 3a73 6967 6e61 7475 7265 ..dht::signature │ │ │ -0000cc80: 2063 6f6e 7374 2073 6967 203d 2069 2e73 const sig = i.s │ │ │ -0000cc90: 6967 2829 3b0a 0909 0909 6468 743a 3a70 ig();.....dht::p │ │ │ -0000cca0: 7562 6c69 635f 6b65 7920 636f 6e73 7420 ublic_key const │ │ │ -0000ccb0: 706b 203d 2069 2e70 6b28 293b 0a09 0909 pk = i.pk();.... │ │ │ -0000ccc0: 0964 6874 3a3a 7365 7175 656e 6365 5f6e .dht::sequence_n │ │ │ -0000ccd0: 756d 6265 7220 636f 6e73 7420 7365 7120 umber const seq │ │ │ -0000cce0: 3d20 692e 7365 7128 293b 0a09 0909 0973 = i.seq();.....s │ │ │ -0000ccf0: 7464 3a3a 7374 7269 6e67 2073 616c 7420 td::string salt │ │ │ -0000cd00: 3d20 692e 7361 6c74 2829 3b0a 0909 0909 = i.salt();..... │ │ │ -0000cd10: 616c 6572 7473 2e65 6d70 6c61 6365 5f61 alerts.emplace_a │ │ │ -0000cd20: 6c65 7274 266c 743b 6468 745f 7075 745f lert<dht_put_ │ │ │ -0000cd30: 616c 6572 7426 6774 3b28 706b 2e62 7974 alert>(pk.byt │ │ │ -0000cd40: 6573 2c20 7369 672e 6279 7465 730a 0909 es, sig.bytes... │ │ │ -0000cd50: 0909 092c 2073 7464 3a3a 6d6f 7665 2873 ..., std::move(s │ │ │ -0000cd60: 616c 7429 2c20 7365 712e 7661 6c75 652c alt), seq.value, │ │ │ -0000cd70: 206e 756d 293b 0a09 0909 7d0a 0909 7d0a num);....}...}. │ │ │ -0000cd80: 0a09 0976 6f69 6420 7075 745f 6d75 7461 ...void put_muta │ │ │ -0000cd90: 626c 655f 6361 6c6c 6261 636b 2864 6874 ble_callback(dht │ │ │ -0000cda0: 3a3a 6974 656d 2661 6d70 3b20 690a 0909 ::item& i... │ │ │ -0000cdb0: 092c 2073 7464 3a3a 6675 6e63 7469 6f6e ., std::function │ │ │ -0000cdc0: 266c 743b 766f 6964 2865 6e74 7279 2661 <void(entry&a │ │ │ -0000cdd0: 6d70 3b2c 2073 7464 3a3a 6172 7261 7926 mp;, std::array& │ │ │ -0000cde0: 6c74 3b63 6861 722c 2036 3426 6774 3b26 lt;char, 64>& │ │ │ -0000cdf0: 616d 703b 0a3c 2f70 7265 3e3c 2f74 643e amp;.
    │ │ │ -0000ce00: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0000ce30: 6e62 7370 3b33 3c2f 7464 3e3c 7464 3e3c nbsp;3< │ │ │ -0000ce40: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0000ce50: 7074 3a65 7870 616e 6428 3235 2922 3e2e pt:expand(25)">. │ │ │ -0000ce60: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -0000ce70: 703a 3435 383c 2f61 3e3c 2f74 643e 3c74 p:458we could proba │ │ │ -0000ce90: 626c 7920 6765 7420 6177 6179 2077 6974 bly get away wit │ │ │ -0000cea0: 6820 6a75 7374 2073 6176 696e 6720 6120 h just saving a │ │ │ -0000ceb0: 6665 7720 6669 656c 6473 2068 6572 653c few fields here< │ │ │ -0000cec0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    we c │ │ │ -0000cf10: 6f75 6c64 2070 726f 6261 626c 7920 6765 ould probably ge │ │ │ -0000cf20: 7420 6177 6179 2077 6974 6820 6a75 7374 t away with just │ │ │ -0000cf30: 2073 6176 696e 6720 6120 6665 7720 6669 saving a few fi │ │ │ -0000cf40: 656c 6473 2068 6572 653c 2f68 323e 3c68 elds here

    ../src/torrent │ │ │ -0000cf60: 2e63 7070 3a34 3538 3c2f 6834 3e3c 7072 .cpp:458..// --- │ │ │ -0000cfb0: 5632 2048 4153 4845 5320 2d2d 2d0a 0a09 V2 HASHES ---... │ │ │ -0000cfc0: 0969 6620 286d 5f74 6f72 7265 6e74 5f66 .if (m_torrent_f │ │ │ -0000cfd0: 696c 652d 2667 743b 6973 5f76 616c 6964 ile->is_valid │ │ │ -0000cfe0: 2829 2026 616d 703b 2661 6d70 3b20 6d5f () && m_ │ │ │ -0000cff0: 746f 7272 656e 745f 6669 6c65 2d26 6774 torrent_file-> │ │ │ -0000d000: 3b69 6e66 6f5f 6861 7368 6573 2829 2e68 ;info_hashes().h │ │ │ -0000d010: 6173 5f76 3228 2929 0a09 097b 0a09 0909 as_v2())...{.... │ │ │ -0000d020: 6966 2028 2170 2e6d 6572 6b6c 655f 7472 if (!p.merkle_tr │ │ │ -0000d030: 6565 732e 656d 7074 7928 2929 0a09 0909 ees.empty()).... │ │ │ -0000d040: 096c 6f61 645f 6d65 726b 6c65 5f74 7265 .load_merkle_tre │ │ │ -0000d050: 6573 280a 0909 0909 0973 7464 3a3a 6d6f es(......std::mo │ │ │ -0000d060: 7665 2870 2e6d 6572 6b6c 655f 7472 6565 ve(p.merkle_tree │ │ │ -0000d070: 7329 0a09 0909 0909 2c20 7374 643a 3a6d s)......, std::m │ │ │ -0000d080: 6f76 6528 702e 6d65 726b 6c65 5f74 7265 ove(p.merkle_tre │ │ │ -0000d090: 655f 6d61 736b 290a 0909 0909 092c 2073 e_mask)......, s │ │ │ -0000d0a0: 7464 3a3a 6d6f 7665 2870 2e76 6572 6966 td::move(p.verif │ │ │ -0000d0b0: 6965 645f 6c65 6166 5f68 6173 6865 7329 ied_leaf_hashes) │ │ │ -0000d0c0: 293b 0a0a 0909 092f 2f20 7765 2072 6561 );.....// we rea │ │ │ -0000d0d0: 6c6c 7920 646f 6e27 7420 7761 6e74 2074 lly don't want t │ │ │ -0000d0e0: 6f20 7374 6f72 6520 6578 7472 6120 636f o store extra co │ │ │ -0000d0f0: 7069 6573 206f 6620 7468 6520 7472 6565 pies of the tree │ │ │ -0000d100: 730a 0909 0954 4f52 5245 4e54 5f41 5353 s....TORRENT_ASS │ │ │ -0000d110: 4552 5428 702e 6d65 726b 6c65 5f74 7265 ERT(p.merkle_tre │ │ │ -0000d120: 6573 2e65 6d70 7479 2829 293b 0a09 097d es.empty());...} │ │ │ -0000d130: 0a0a 0909 6966 2028 7661 6c69 645f 6d65 ....if (valid_me │ │ │ -0000d140: 7461 6461 7461 2829 290a 0909 7b0a 0909 tadata())...{... │ │ │ -0000d150: 0969 6e63 5f73 7461 7473 5f63 6f75 6e74 .inc_stats_count │ │ │ -0000d160: 6572 2863 6f75 6e74 6572 733a 3a6e 756d er(counters::num │ │ │ -0000d170: 5f74 6f74 616c 5f70 6965 6365 735f 6164 _total_pieces_ad │ │ │ -0000d180: 6465 640a 0909 0909 2c20 6d5f 746f 7272 ded....., m_torr │ │ │ -0000d190: 656e 745f 6669 6c65 2d26 6774 3b6e 756d ent_file->num │ │ │ -0000d1a0: 5f70 6965 6365 7328 2929 3b0a 0909 7d0a _pieces());...}. │ │ │ -0000d1b0: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ -0000d1e0: 096d 5f61 6464 5f74 6f72 7265 6e74 5f70 .m_add_torrent_p │ │ │ -0000d1f0: 6172 616d 7320 3d20 7374 643a 3a6d 616b arams = std::mak │ │ │ -0000d200: 655f 756e 6971 7565 266c 743b 6164 645f e_unique<add_ │ │ │ -0000d210: 746f 7272 656e 745f 7061 7261 6d73 2667 torrent_params&g │ │ │ -0000d220: 743b 2873 7464 3a3a 6d6f 7665 2870 2929 t;(std::move(p)) │ │ │ -0000d230: 3b0a 3c2f 6469 763e 097d 0a0a 0976 6f69 ;.
    .}...voi │ │ │ -0000d240: 6420 746f 7272 656e 743a 3a6c 6f61 645f d torrent::load_ │ │ │ -0000d250: 6d65 726b 6c65 5f74 7265 6573 280a 0909 merkle_trees(... │ │ │ -0000d260: 6175 783a 3a76 6563 746f 7226 6c74 3b73 aux::vector<s │ │ │ -0000d270: 7464 3a3a 7665 6374 6f72 266c 743b 7368 td::vector<sh │ │ │ -0000d280: 6132 3536 5f68 6173 6826 6774 3b2c 2066 a256_hash>, f │ │ │ -0000d290: 696c 655f 696e 6465 785f 7426 6774 3b20 ile_index_t> │ │ │ -0000d2a0: 7472 6565 735f 696d 706f 7274 0a09 092c trees_import..., │ │ │ -0000d2b0: 2061 7578 3a3a 7665 6374 6f72 266c 743b aux::vector< │ │ │ -0000d2c0: 6269 7466 6965 6c64 2c20 6669 6c65 5f69 bitfield, file_i │ │ │ -0000d2d0: 6e64 6578 5f74 2667 743b 206d 6173 6b0a ndex_t> mask. │ │ │ -0000d2e0: 0909 2c20 6175 783a 3a76 6563 746f 7226 .., aux::vector& │ │ │ -0000d2f0: 6c74 3b62 6974 6669 656c 642c 2066 696c lt;bitfield, fil │ │ │ -0000d300: 655f 696e 6465 785f 7426 6774 3b20 7665 e_index_t> ve │ │ │ -0000d310: 7269 6669 6564 290a 097b 0a09 0961 7574 rified)..{...aut │ │ │ -0000d320: 6f20 636f 6e73 7426 616d 703b 2066 7320 o const& fs │ │ │ -0000d330: 3d20 6d5f 746f 7272 656e 745f 6669 6c65 = m_torrent_file │ │ │ -0000d340: 2d26 6774 3b6c 6179 6f75 7428 293b 0a0a ->layout();.. │ │ │ -0000d350: 0909 6269 7466 6965 6c64 2063 6f6e 7374 ..bitfield const │ │ │ -0000d360: 2065 6d70 7479 5f76 6572 6966 6965 643b empty_verified; │ │ │ -0000d370: 0a09 0966 6f72 2028 6669 6c65 5f69 6e64 ...for (file_ind │ │ │ -0000d380: 6578 5f74 2069 7b30 7d3b 2069 2026 6c74 ex_t i{0}; i < │ │ │ -0000d390: 3b20 6673 2e65 6e64 5f66 696c 6528 293b ; fs.end_file(); │ │ │ -0000d3a0: 202b 2b69 290a 0909 7b0a 0909 0969 6620 ++i)...{....if │ │ │ -0000d3b0: 2866 732e 7061 645f 6669 6c65 5f61 7428 (fs.pad_file_at( │ │ │ -0000d3c0: 6929 207c 7c20 6673 2e66 696c 655f 7369 i) || fs.file_si │ │ │ -0000d3d0: 7a65 2869 2920 3d3d 2030 290a 0909 0909 ze(i) == 0)..... │ │ │ -0000d3e0: 636f 6e74 696e 7565 3b0a 0a09 0909 6966 continue;.....if │ │ │ -0000d3f0: 2028 6920 2667 743b 3d20 7472 6565 735f (i >= trees_ │ │ │ -0000d400: 696d 706f 7274 2e65 6e64 5f69 6e64 6578 import.end_index │ │ │ -0000d410: 2829 2920 6272 6561 6b3b 0a09 0909 6269 ()) break;....bi │ │ │ -0000d420: 7466 6965 6c64 2063 6f6e 7374 2661 6d70 tfield const& │ │ │ -0000d430: 3b20 7665 7269 6669 6564 5f62 6974 6d61 ; verified_bitma │ │ │ -0000d440: 736b 203d 2028 6920 2667 743b 3d20 7665 sk = (i >= ve │ │ │ -0000d450: 7269 6669 6564 2e65 6e64 5f69 6e64 6578 rified.end_index │ │ │ -0000d460: 2829 2920 3f20 656d 7074 795f 7665 7269 ()) ? empty_veri │ │ │ -0000d470: 6669 6564 203a 2076 6572 6966 6965 645b fied : verified[ │ │ │ -0000d480: 695d 3b0a 0909 0969 6620 2869 2026 6c74 i];....if (i < │ │ │ -0000d490: 3b20 6d61 736b 2e65 6e64 5f69 6e64 6578 ; mask.end_index │ │ │ -0000d4a0: 2829 2026 616d 703b 2661 6d70 3b20 216d () && !m │ │ │ -0000d4b0: 6173 6b5b 695d 2e65 6d70 7479 2829 290a ask[i].empty()). │ │ │ -0000d4c0: 0909 097b 0a09 0909 096d 5f6d 6572 6b6c ...{.....m_merkl │ │ │ -0000d4d0: 655f 7472 6565 735b 695d 2e6c 6f61 645f e_trees[i].load_ │ │ │ -0000d4e0: 7370 6172 7365 5f74 7265 6528 7472 6565 sparse_tree(tree │ │ │ -0000d4f0: 735f 696d 706f 7274 5b69 5d2c 206d 6173 s_import[i], mas │ │ │ -0000d500: 6b5b 695d 2c20 7665 7269 6669 6564 5f62 k[i], verified_b │ │ │ -0000d510: 6974 6d61 736b 293b 0a09 0909 7d0a 0909 itmask);....}... │ │ │ -0000d520: 0965 6c73 650a 0909 097b 0a09 0909 096d .else....{.....m │ │ │ -0000d530: 5f6d 6572 6b6c 655f 7472 6565 735b 695d _merkle_trees[i] │ │ │ -0000d540: 2e6c 6f61 645f 7472 6565 2874 7265 6573 .load_tree(trees │ │ │ -0000d550: 5f69 6d70 6f72 745b 695d 2c20 7665 7269 _import[i], veri │ │ │ -0000d560: 6669 6564 5f62 6974 6d61 736b 293b 0a09 fied_bitmask);.. │ │ │ -0000d570: 0909 7d0a 0909 7d0a 097d 0a0a 0976 6f69 ..}...}..}...voi │ │ │ -0000d580: 6420 746f 7272 656e 743a 3a69 6e63 5f73 d torrent::inc_s │ │ │ -0000d590: 7461 7473 5f63 6f75 6e74 6572 2869 6e74 tats_counter(int │ │ │ -0000d5a0: 2063 2c20 696e 7420 7661 6c75 6529 0a09 c, int value).. │ │ │ -0000d5b0: 7b20 6d5f 7365 732e 7374 6174 735f 636f { m_ses.stats_co │ │ │ -0000d5c0: 756e 7465 7273 2829 2e69 6e63 5f73 7461 unters().inc_sta │ │ │ -0000d5d0: 7473 5f63 6f75 6e74 6572 2863 2c20 7661 ts_counter(c, va │ │ │ -0000d5e0: 6c75 6529 3b20 7d0a 3c2f 7072 653e 3c2f lue); }.relevan │ │ │ -0000d620: 6365 266e 6273 703b 333c 2f74 643e 3c74 ce 3../src/torrent │ │ │ -0000d660: 2e63 7070 3a37 3634 3c2f 613e 3c2f 7464 .cpp:764assert ther │ │ │ -0000d680: 6520 6172 6520 6e6f 206f 7574 7374 616e e are no outstan │ │ │ -0000d690: 6469 6e67 2061 7379 6e63 206f 7065 7261 ding async opera │ │ │ -0000d6a0: 7469 6f6e 7320 6f6e 2074 6869 7320 746f tions on this to │ │ │ -0000d6b0: 7272 656e 743c 2f74 643e 3c2f 7472 3e3c rrent< │ │ │ -0000d6c0: 7472 2069 643d 2232 3622 2073 7479 6c65 tr id="26" style │ │ │ -0000d6d0: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ -0000d6e0: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">assert there a │ │ │ -0000d710: 7265 206e 6f20 6f75 7473 7461 6e64 696e re no outstandin │ │ │ -0000d720: 6720 6173 796e 6320 6f70 6572 6174 696f g async operatio │ │ │ -0000d730: 6e73 206f 6e20 7468 6973 0a74 6f72 7265 ns on this.torre │ │ │ -0000d740: 6e74 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 nt

    ../sr │ │ │ -0000d750: 632f 746f 7272 656e 742e 6370 703a 3736 c/torrent.cpp:76 │ │ │ -0000d760: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ -0000d7a0: 0909 0972 6574 7572 6e20 6661 6c73 653b  ...return false;
    │ │ │ -0000d7b0: 0a23 656e 6469 660a 0a09 0969 6620 2821  .#endif....if (!
    │ │ │ -0000d7c0: 6d5f 7365 732e 6468 7428 2929 2072 6574  m_ses.dht()) ret
    │ │ │ -0000d7d0: 7572 6e20 6661 6c73 653b 0a09 0969 6620  urn false;...if 
    │ │ │ -0000d7e0: 286d 5f74 6f72 7265 6e74 5f66 696c 652d  (m_torrent_file-
    │ │ │ -0000d7f0: 2667 743b 6973 5f76 616c 6964 2829 2026  >is_valid() &
    │ │ │ -0000d800: 616d 703b 2661 6d70 3b20 216d 5f66 696c  amp;& !m_fil
    │ │ │ -0000d810: 6573 5f63 6865 636b 6564 2920 7265 7475  es_checked) retu
    │ │ │ -0000d820: 726e 2066 616c 7365 3b0a 0909 6966 2028  rn false;...if (
    │ │ │ -0000d830: 216d 5f61 6e6e 6f75 6e63 655f 746f 5f64  !m_announce_to_d
    │ │ │ -0000d840: 6874 2920 7265 7475 726e 2066 616c 7365  ht) return false
    │ │ │ -0000d850: 3b0a 0909 6966 2028 6d5f 7061 7573 6564  ;...if (m_paused
    │ │ │ -0000d860: 2920 7265 7475 726e 2066 616c 7365 3b0a  ) return false;.
    │ │ │ -0000d870: 0a09 092f 2f20 646f 6e27 7420 616e 6e6f  ...// don't anno
    │ │ │ -0000d880: 756e 6365 2070 7269 7661 7465 2074 6f72  unce private tor
    │ │ │ -0000d890: 7265 6e74 730a 0909 6966 2028 6d5f 746f  rents...if (m_to
    │ │ │ -0000d8a0: 7272 656e 745f 6669 6c65 2d26 6774 3b69  rrent_file->i
    │ │ │ -0000d8b0: 735f 7661 6c69 6428 2920 2661 6d70 3b26  s_valid() &&
    │ │ │ -0000d8c0: 616d 703b 206d 5f74 6f72 7265 6e74 5f66  amp; m_torrent_f
    │ │ │ -0000d8d0: 696c 652d 2667 743b 7072 6976 2829 2920  ile->priv()) 
    │ │ │ -0000d8e0: 7265 7475 726e 2066 616c 7365 3b0a 0909  return false;...
    │ │ │ -0000d8f0: 6966 2028 6d5f 7472 6163 6b65 7273 2e65  if (m_trackers.e
    │ │ │ -0000d900: 6d70 7479 2829 2920 7265 7475 726e 2074  mpty()) return t
    │ │ │ -0000d910: 7275 653b 0a09 0969 6620 2821 7365 7474  rue;...if (!sett
    │ │ │ -0000d920: 696e 6773 2829 2e67 6574 5f62 6f6f 6c28  ings().get_bool(
    │ │ │ -0000d930: 7365 7474 696e 6773 5f70 6163 6b3a 3a75  settings_pack::u
    │ │ │ -0000d940: 7365 5f64 6874 5f61 735f 6661 6c6c 6261  se_dht_as_fallba
    │ │ │ -0000d950: 636b 2929 2072 6574 7572 6e20 7472 7565  ck)) return true
    │ │ │ -0000d960: 3b0a 0a09 0972 6574 7572 6e20 216d 5f74  ;....return !m_t
    │ │ │ -0000d970: 7261 636b 6572 732e 616e 795f 7665 7269  rackers.any_veri
    │ │ │ -0000d980: 6669 6564 2829 3b0a 097d 0a0a 2365 6e64  fied();..}..#end
    │ │ │ -0000d990: 6966 0a0a 0974 6f72 7265 6e74 3a3a 7e74  if...torrent::~t
    │ │ │ -0000d9a0: 6f72 7265 6e74 2829 0a09 7b0a 3c64 6976  orrent()..{.
    .
    #if TORRENT_USE │ │ │ -0000d9f0: 5f41 5353 4552 5453 0a09 092f 2f20 6279 _ASSERTS...// by │ │ │ -0000da00: 2074 6865 2074 696d 6520 6120 746f 7272 the time a torr │ │ │ -0000da10: 656e 7420 6973 2064 6573 7472 6f79 6564 ent is destroyed │ │ │ -0000da20: 2069 7420 6d75 7374 2061 6c72 6561 6479 it must already │ │ │ -0000da30: 2068 6176 6520 6265 656e 0a09 092f 2f20 have been...// │ │ │ -0000da40: 7265 6d6f 7665 6420 6672 6f6d 2065 7665 removed from eve │ │ │ -0000da50: 7279 2073 6573 7369 6f6e 5f69 6d70 6c3a ry session_impl: │ │ │ -0000da60: 3a6d 5f74 6f72 7265 6e74 5f6c 6973 7473 :m_torrent_lists │ │ │ -0000da70: 2065 6e74 7279 2c20 6f74 6865 7277 6973 entry, otherwis │ │ │ -0000da80: 650a 0909 2f2f 2074 6865 206c 6973 7420 e...// the list │ │ │ -0000da90: 6973 206c 6566 7420 7769 7468 2061 2064 is left with a d │ │ │ -0000daa0: 616e 676c 696e 6720 706f 696e 7465 722e angling pointer. │ │ │ -0000dab0: 0a09 0966 6f72 2028 6175 746f 2063 6f6e ...for (auto con │ │ │ -0000dac0: 7374 2661 6d70 3b20 6c20 3a20 6d5f 6c69 st& l : m_li │ │ │ -0000dad0: 6e6b 7329 0a09 097b 0a09 0909 544f 5252 nks)...{....TORR │ │ │ -0000dae0: 454e 545f 4153 5345 5254 2821 6c2e 696e ENT_ASSERT(!l.in │ │ │ -0000daf0: 5f6c 6973 7428 2929 3b0a 0909 7d0a 2365 _list());...}.#e │ │ │ -0000db00: 6e64 6966 0a0a 0909 2f2f 2054 6865 2069 ndif....// The i │ │ │ -0000db10: 6e76 6172 6961 6e74 2063 616e 2774 2062 nvariant can't b │ │ │ -0000db20: 6520 6d61 696e 7461 696e 6564 2068 6572 e maintained her │ │ │ -0000db30: 652c 2073 696e 6365 2074 6865 2074 6f72 e, since the tor │ │ │ -0000db40: 7265 6e74 0a09 092f 2f20 6973 2062 6569 rent...// is bei │ │ │ -0000db50: 6e67 2064 6573 7472 7563 7465 642c 2061 ng destructed, a │ │ │ -0000db60: 6c6c 2077 6561 6b20 7265 6665 7265 6e63 ll weak referenc │ │ │ -0000db70: 6573 2074 6f20 6974 2068 6176 6520 6265 es to it have be │ │ │ -0000db80: 656e 0a09 092f 2f20 7265 7365 742c 2077 en...// reset, w │ │ │ -0000db90: 6869 6368 206d 6561 6e73 2074 6861 7420 hich means that │ │ │ -0000dba0: 616c 6c20 6974 7320 7065 6572 7320 616c all its peers al │ │ │ -0000dbb0: 7265 6164 7920 6861 7665 2061 6e0a 0909 ready have an... │ │ │ -0000dbc0: 2f2f 2069 6e76 616c 6964 6174 6564 2074 // invalidated t │ │ │ -0000dbd0: 6f72 7265 6e74 2070 6f69 6e74 6572 2028 orrent pointer ( │ │ │ -0000dbe0: 736f 2069 7420 6361 6e6e 6f74 2062 6520 so it cannot be │ │ │ -0000dbf0: 7665 7269 6669 6564 2074 6f20 6265 2063 verified to be c │ │ │ -0000dc00: 6f72 7265 6374 290a 0a09 092f 2f20 692e orrect)....// i. │ │ │ -0000dc10: 652e 2074 6865 2069 6e76 6172 6961 6e74 e. the invariant │ │ │ -0000dc20: 2063 616e 206f 6e6c 7920 6265 206d 6169 can only be mai │ │ │ -0000dc30: 6e74 6169 6e65 6420 6966 2061 6c6c 2063 ntained if all c │ │ │ -0000dc40: 6f6e 6e65 6374 696f 6e73 2068 6176 650a onnections have. │ │ │ -0000dc50: 0909 2f2f 2062 6565 6e20 636c 6f73 6564 ..// been closed │ │ │ -0000dc60: 2062 7920 7468 6520 7469 6d65 2074 6865 by the time the │ │ │ -0000dc70: 2074 6f72 7265 6e74 2069 7320 6465 7374 torrent is dest │ │ │ -0000dc80: 7275 6374 6564 2e20 416e 6420 7468 6579 ructed. And they │ │ │ -0000dc90: 2061 7265 0a09 092f 2f20 7375 7070 6f73 are...// suppos │ │ │ -0000dca0: 6564 2074 6f20 6265 2063 6c6f 7365 642e ed to be closed. │ │ │ -0000dcb0: 2053 6f20 7765 2063 616e 2073 7469 6c6c So we can still │ │ │ -0000dcc0: 2064 6f20 7468 6520 696e 7661 7269 616e do the invarian │ │ │ -0000dcd0: 7420 6368 6563 6b2e 0a0a 0909 2f2f 2068 t check.....// h │ │ │ -0000dce0: 6f77 6576 6572 2c20 7468 6520 746f 7272 owever, the torr │ │ │ -0000dcf0: 656e 7420 6f62 6a65 6374 206d 6179 2062 ent object may b │ │ │ -0000dd00: 6520 6465 7374 7275 6374 6564 2066 726f e destructed fro │ │ │ -0000dd10: 6d20 7468 6520 6d61 696e 0a09 092f 2f20 m the main...// │ │ │ -0000dd20: 7468 7265 6164 2077 6865 6e20 7368 7574 thread when shut │ │ │ -0000dd30: 7469 6e67 2064 6f77 6e2c 2069 6620 7468 ting down, if th │ │ │ -0000dd40: 6520 6469 736b 2063 6163 6865 2068 6173 e disk cache has │ │ │ -0000dd50: 2072 6566 6572 656e 6365 7320 746f 2069 references to i │ │ │ -0000dd60: 742e 0a09 092f 2f20 7468 6973 206d 6561 t....// this mea │ │ │ -0000dd70: 6e73 2074 6861 7420 7468 6520 696e 7661 ns that the inva │ │ │ -0000dd80: 7269 616e 7420 6368 6563 6b20 7468 6174 riant check that │ │ │ -0000dd90: 2074 6869 7320 6973 2063 616c 6c65 6420 this is called │ │ │ -0000dda0: 6672 6f6d 2074 6865 0a09 092f 2f20 6e65 from the...// ne │ │ │ -0000ddb0: 7477 6f72 6b20 7468 7265 6164 2063 616e twork thread can │ │ │ -0000ddc0: 6e6f 7420 6265 206d 6169 6e74 6169 6e65 not be maintaine │ │ │ -0000ddd0: 640a 0a09 0954 4f52 5245 4e54 5f41 5353 d....TORRENT_ASS │ │ │ -0000dde0: 4552 5428 6d5f 7065 6572 5f63 6c61 7373 ERT(m_peer_class │ │ │ -0000ddf0: 203d 3d20 7065 6572 5f63 6c61 7373 5f74 == peer_class_t │ │ │ -0000de00: 7b30 7d29 3b0a 0909 544f 5252 454e 545f {0});...TORRENT_ │ │ │ -0000de10: 4153 5345 5254 286d 5f63 6f6e 6e65 6374 ASSERT(m_connect │ │ │ -0000de20: 696f 6e73 2e65 6d70 7479 2829 293b 0a09 ions.empty());.. │ │ │ -0000de30: 092f 2f20 6a75 7374 2069 6e20 6361 7365 .// just in case │ │ │ -0000de40: 2c20 6d61 6b65 2073 7572 6520 7468 6520 , make sure the │ │ │ -0000de50: 7365 7373 696f 6e20 6163 636f 756e 7469 session accounti │ │ │ -0000de60: 6e67 2069 7320 6b65 7074 2072 6967 6874 ng is kept right │ │ │ -0000de70: 0a09 0966 6f72 2028 6175 746f 2a20 7020 ...for (auto* p │ │ │ -0000de80: 3a20 6d5f 636f 6e6e 6563 7469 6f6e 7329 : m_connections) │ │ │ -0000de90: 0a09 0909 6d5f 7365 732e 636c 6f73 655f ....m_ses.close_ │ │ │ -0000dea0: 636f 6e6e 6563 7469 6f6e 2870 293b 0a09 connection(p);.. │ │ │ -0000deb0: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -0000dee0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0000def0: 703b 333c 2f74 643e 3c74 643e 3c61 2068 p;3../s │ │ │ -0000df20: 7263 2f74 6f72 7265 6e74 2e63 7070 3a31 rc/torrent.cpp:1 │ │ │ -0000df30: 3433 363c 2f61 3e3c 2f74 643e 3c74 643e 436 │ │ │ -0000df40: 7468 6572 6527 7320 736f 6d65 2064 7570 there's some dup │ │ │ -0000df50: 6c69 6361 7469 6f6e 2062 6574 7765 656e lication between │ │ │ -0000df60: 2074 6869 7320 6675 6e63 7469 6f6e 2061 this function a │ │ │ -0000df70: 6e64 2070 6565 725f 636f 6e6e 6563 7469 nd peer_connecti │ │ │ -0000df80: 6f6e 3a3a 696e 636f 6d69 6e67 5f70 6965 on::incoming_pie │ │ │ -0000df90: 6365 2829 2e20 6973 2074 6865 7265 2061 ce(). is there a │ │ │ -0000dfa0: 2077 6179 2074 6f20 6d65 7267 6520 736f way to merge so │ │ │ -0000dfb0: 6d65 7468 696e 673f 3c2f 7464 3e3c 2f74 mething?

    there's som │ │ │ -0000e010: 6520 6475 706c 6963 6174 696f 6e20 6265 e duplication be │ │ │ -0000e020: 7477 6565 6e20 7468 6973 2066 756e 6374 tween this funct │ │ │ -0000e030: 696f 6e20 616e 640a 7065 6572 5f63 6f6e ion and.peer_con │ │ │ -0000e040: 6e65 6374 696f 6e3a 3a69 6e63 6f6d 696e nection::incomin │ │ │ -0000e050: 675f 7069 6563 6528 292e 2069 7320 7468 g_piece(). is th │ │ │ -0000e060: 6572 6520 6120 7761 7920 746f 206d 6572 ere a way to mer │ │ │ -0000e070: 6765 2073 6f6d 6574 6869 6e67 3f3c 2f68 ge something?

    ../src/tor │ │ │ -0000e090: 7265 6e74 2e63 7070 3a31 3433 363c 2f68 rent.cpp:1436
    .voi
    │ │ │ -0000e0e0: 6420 746f 7272 656e 743a 3a61 6464 5f70  d torrent::add_p
    │ │ │ -0000e0f0: 6965 6365 5f61 7379 6e63 2870 6965 6365  iece_async(piece
    │ │ │ -0000e100: 5f69 6e64 6578 5f74 2063 6f6e 7374 2070  _index_t const p
    │ │ │ -0000e110: 6965 6365 0a09 092c 2073 7464 3a3a 7665  iece..., std::ve
    │ │ │ -0000e120: 6374 6f72 266c 743b 6368 6172 2667 743b  ctor<char>
    │ │ │ -0000e130: 2064 6174 612c 2061 6464 5f70 6965 6365   data, add_piece
    │ │ │ -0000e140: 5f66 6c61 6773 5f74 2063 6f6e 7374 2066  _flags_t const f
    │ │ │ -0000e150: 6c61 6773 290a 097b 0a09 0954 4f52 5245  lags)..{...TORRE
    │ │ │ -0000e160: 4e54 5f41 5353 4552 5428 6973 5f73 696e  NT_ASSERT(is_sin
    │ │ │ -0000e170: 676c 655f 7468 7265 6164 2829 293b 0a0a  gle_thread());..
    │ │ │ -0000e180: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -0000e190: 5f50 5245 434f 4e44 2870 6965 6365 2026  _PRECOND(piece &
    │ │ │ -0000e1a0: 6c74 3b20 746f 7272 656e 745f 6669 6c65  lt; torrent_file
    │ │ │ -0000e1b0: 2829 2e65 6e64 5f70 6965 6365 2829 293b  ().end_piece());
    │ │ │ -0000e1c0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -0000e1d0: 545f 5052 4543 4f4e 4428 7069 6563 6520  T_PRECOND(piece 
    │ │ │ -0000e1e0: 2667 743b 3d20 7069 6563 655f 696e 6465  >= piece_inde
    │ │ │ -0000e1f0: 785f 747b 307d 293b 0a09 0954 4f52 5245  x_t{0});...TORRE
    │ │ │ -0000e200: 4e54 5f41 5353 4552 545f 5052 4543 4f4e  NT_ASSERT_PRECON
    │ │ │ -0000e210: 4428 6461 7461 2e73 697a 6528 2920 3d3d  D(data.size() ==
    │ │ │ -0000e220: 2073 7464 3a3a 7369 7a65 5f74 2870 6965   std::size_t(pie
    │ │ │ -0000e230: 6365 5f73 697a 655f 666f 725f 7265 7128  ce_size_for_req(
    │ │ │ -0000e240: 7069 6563 6529 2929 3b0a 0a09 092f 2f20  piece)));....// 
    │ │ │ -0000e250: 6d61 6b65 2073 7572 6520 7468 6520 7069  make sure the pi
    │ │ │ -0000e260: 6563 6520 696e 6465 7820 6973 2063 6f72  ece index is cor
    │ │ │ -0000e270: 7265 6374 0a09 0969 6620 2870 6965 6365  rect...if (piece
    │ │ │ -0000e280: 2026 6774 3b3d 2074 6f72 7265 6e74 5f66   >= torrent_f
    │ │ │ -0000e290: 696c 6528 292e 656e 645f 7069 6563 6528  ile().end_piece(
    │ │ │ -0000e2a0: 2929 0a09 0909 7265 7475 726e 3b0a 0a09  ))....return;...
    │ │ │ -0000e2b0: 092f 2f20 6d61 6b65 2073 7572 6520 7468  .// make sure th
    │ │ │ -0000e2c0: 6520 7069 6563 6520 7369 7a65 2069 7320  e piece size is 
    │ │ │ -0000e2d0: 636f 7272 6563 740a 0909 6966 2028 6461  correct...if (da
    │ │ │ -0000e2e0: 7461 2e73 697a 6528 2920 213d 2073 7464  ta.size() != std
    │ │ │ -0000e2f0: 3a3a 7369 7a65 5f74 2870 6965 6365 5f73  ::size_t(piece_s
    │ │ │ -0000e300: 697a 655f 666f 725f 7265 7128 7069 6563  ize_for_req(piec
    │ │ │ -0000e310: 6529 2929 0a09 0909 7265 7475 726e 3b0a  e)))....return;.
    │ │ │ -0000e320: 0a09 0961 6464 5f70 6965 6365 2870 6965  ...add_piece(pie
    │ │ │ -0000e330: 6365 2c20 6461 7461 2e64 6174 6128 292c  ce, data.data(),
    │ │ │ -0000e340: 2066 6c61 6773 293b 0a09 7d0a 0a3c 6469   flags);..}...void
    │ │ │ -0000e380: 2074 6f72 7265 6e74 3a3a 6164 645f 7069   torrent::add_pi
    │ │ │ -0000e390: 6563 6528 7069 6563 655f 696e 6465 785f  ece(piece_index_
    │ │ │ -0000e3a0: 7420 636f 6e73 7420 7069 6563 652c 2063  t const piece, c
    │ │ │ -0000e3b0: 6861 7220 636f 6e73 742a 2064 6174 610a  har const* data.
    │ │ │ -0000e3c0: 3c2f 6469 763e 0909 2c20 6164 645f 7069  

    .., add_pi │ │ │ -0000e3d0: 6563 655f 666c 6167 735f 7420 636f 6e73 ece_flags_t cons │ │ │ -0000e3e0: 7420 666c 6167 7329 0a09 7b0a 0909 544f t flags)..{...TO │ │ │ -0000e3f0: 5252 454e 545f 4153 5345 5254 2869 735f RRENT_ASSERT(is_ │ │ │ -0000e400: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ -0000e410: 3b0a 0a09 092f 2f20 6d61 6b65 2073 7572 ;....// make sur │ │ │ -0000e420: 6520 7468 6520 7069 6563 6520 696e 6465 e the piece inde │ │ │ -0000e430: 7820 6973 2063 6f72 7265 6374 0a09 0969 x is correct...i │ │ │ -0000e440: 6620 2870 6965 6365 2026 6774 3b3d 2074 f (piece >= t │ │ │ -0000e450: 6f72 7265 6e74 5f66 696c 6528 292e 656e orrent_file().en │ │ │ -0000e460: 645f 7069 6563 6528 2929 0a09 0909 7265 d_piece())....re │ │ │ -0000e470: 7475 726e 3b0a 0a09 0969 6e74 2063 6f6e turn;....int con │ │ │ -0000e480: 7374 2070 6965 6365 5f73 697a 6520 3d20 st piece_size = │ │ │ -0000e490: 7069 6563 655f 7369 7a65 5f66 6f72 5f72 piece_size_for_r │ │ │ -0000e4a0: 6571 2870 6965 6365 293b 0a09 0969 6e74 eq(piece);...int │ │ │ -0000e4b0: 2063 6f6e 7374 2062 6c6f 636b 735f 696e const blocks_in │ │ │ -0000e4c0: 5f70 6965 6365 203d 2028 7069 6563 655f _piece = (piece_ │ │ │ -0000e4d0: 7369 7a65 202b 2062 6c6f 636b 5f73 697a size + block_siz │ │ │ -0000e4e0: 6528 2920 2d20 3129 202f 2062 6c6f 636b e() - 1) / block │ │ │ -0000e4f0: 5f73 697a 6528 293b 0a0a 0909 6966 2028 _size();....if ( │ │ │ -0000e500: 6d5f 6465 6c65 7465 6429 2072 6574 7572 m_deleted) retur │ │ │ -0000e510: 6e3b 0a0a 0909 2f2f 2061 766f 6964 2063 n;....// avoid c │ │ │ -0000e520: 7261 7368 2074 7279 696e 6720 746f 2061 rash trying to a │ │ │ -0000e530: 6363 6573 7320 7468 6520 7069 636b 6572 ccess the picker │ │ │ -0000e540: 2077 6865 6e20 7468 6572 6520 6973 206e when there is n │ │ │ -0000e550: 6f6e 650a 0909 6966 2028 6d5f 6861 7665 one...if (m_have │ │ │ -0000e560: 5f61 6c6c 2026 616d 703b 2661 6d70 3b20 _all && │ │ │ -0000e570: 2168 6173 5f70 6963 6b65 7228 2929 2072 !has_picker()) r │ │ │ -0000e580: 6574 7572 6e3b 0a0a 0909 2f2f 2077 6520 eturn;....// we │ │ │ -0000e590: 646f 6e27 7420 7375 7070 6f72 7420 636c don't support cl │ │ │ -0000e5a0: 6f62 6265 7269 6e67 2074 6865 2070 6965 obbering the pie │ │ │ -0000e5b0: 6365 2070 6963 6b65 7220 7768 696c 6520 ce picker while │ │ │ -0000e5c0: 6368 6563 6b69 6e67 2074 6865 0a09 092f checking the.../ │ │ │ -0000e5d0: 2f20 6669 6c65 732e 2057 6520 6d61 7920 / files. We may │ │ │ -0000e5e0: 656e 6420 7570 2068 6176 696e 6720 7468 end up having th │ │ │ -0000e5f0: 6520 7361 6d65 2070 6965 6365 206d 756c e same piece mul │ │ │ -0000e600: 7469 706c 6520 7469 6d65 730a 0909 544f tiple times...TO │ │ │ -0000e610: 5252 454e 545f 4153 5345 5254 5f50 5245 RRENT_ASSERT_PRE │ │ │ -0000e620: 434f 4e44 2873 7461 7465 2829 2021 3d20 COND(state() != │ │ │ -0000e630: 746f 7272 656e 745f 7374 6174 7573 3a3a torrent_status:: │ │ │ -0000e640: 6368 6563 6b69 6e67 5f66 696c 6573 0a09 checking_files.. │ │ │ -0000e650: 0909 2661 6d70 3b26 616d 703b 2073 7461 ..&& sta │ │ │ -0000e660: 7465 2829 2021 3d20 746f 7272 656e 745f te() != torrent_ │ │ │ -0000e670: 7374 6174 7573 3a3a 6368 6563 6b69 6e67 status::checking │ │ │ -0000e680: 5f72 6573 756d 655f 6461 7461 293b 0a09 _resume_data);.. │ │ │ -0000e690: 0969 6620 2873 7461 7465 2829 203d 3d20 .if (state() == │ │ │ -0000e6a0: 746f 7272 656e 745f 7374 6174 7573 3a3a torrent_status:: │ │ │ -0000e6b0: 6368 6563 6b69 6e67 5f66 696c 6573 0a09 checking_files.. │ │ │ -0000e6c0: 0909 7c7c 2073 7461 7465 2829 203d 3d20 ..|| state() == │ │ │ -0000e6d0: 746f 7272 656e 745f 7374 6174 7573 3a3a torrent_status:: │ │ │ -0000e6e0: 6368 6563 6b69 6e67 5f72 6573 756d 655f checking_resume_ │ │ │ -0000e6f0: 6461 7461 290a 0909 0972 6574 7572 6e3b data)....return; │ │ │ -0000e700: 0a0a 0909 6e65 6564 5f70 6963 6b65 7228 ....need_picker( │ │ │ -0000e710: 293b 0a0a 0909 6966 2028 7069 636b 6572 );....if (picker │ │ │ -0000e720: 2829 2e68 6176 655f 7069 6563 6528 7069 ().have_piece(pi │ │ │ -0000e730: 6563 6529 0a09 0909 2661 6d70 3b26 616d ece)....&&am │ │ │ -0000e740: 703b 2021 2866 6c61 6773 2026 616d 703b p; !(flags & │ │ │ -0000e750: 2074 6f72 7265 6e74 5f68 616e 646c 653a torrent_handle: │ │ │ -0000e760: 3a6f 7665 7277 7269 7465 5f65 7869 7374 :overwrite_exist │ │ │ -0000e770: 696e 6729 290a 0909 0972 6574 7572 6e3b ing))....return; │ │ │ -0000e780: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..< │ │ │ -0000e7b0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0000e7c0: 703b 333c 2f74 643e 3c74 643e 3c61 2068 p;3../s │ │ │ -0000e7f0: 7263 2f74 6f72 7265 6e74 2e63 7070 3a34 rc/torrent.cpp:4 │ │ │ -0000e800: 3331 343c 2f61 3e3c 2f74 643e 3c74 643e 314 │ │ │ -0000e810: 7468 6973 2063 6f75 6c64 2070 726f 6261 this could proba │ │ │ -0000e820: 626c 7920 6265 2070 756c 6c65 6420 6f75 bly be pulled ou │ │ │ -0000e830: 7420 696e 746f 2061 2066 7265 6520 6675 t into a free fu │ │ │ -0000e840: 6e63 7469 6f6e 3c2f 7464 3e3c 2f74 723e nction │ │ │ -0000e850: 3c74 7220 6964 3d22 3238 2220 7374 796c < │ │ │ -0000e880: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0000e890: 6832 3e74 6869 7320 636f 756c 6420 7072 h2>this could pr │ │ │ -0000e8a0: 6f62 6162 6c79 2062 6520 7075 6c6c 6564 obably be pulled │ │ │ -0000e8b0: 206f 7574 2069 6e74 6f20 6120 6672 6565 out into a free │ │ │ -0000e8c0: 2066 756e 6374 696f 6e3c 2f68 323e 3c68 function../src/torrent │ │ │ -0000e8e0: 2e63 7070 3a34 3331 343c 2f68 343e 3c70 .cpp:4314

    .std::in │ │ │ -0000e930: 7436 345f 7420 6361 6c63 5f62 7974 6573 t64_t calc_bytes │ │ │ -0000e940: 2866 696c 655f 7374 6f72 6167 6520 636f (file_storage co │ │ │ -0000e950: 6e73 7426 616d 703b 2066 732c 2070 6965 nst& fs, pie │ │ │ -0000e960: 6365 5f63 6f75 6e74 2063 6f6e 7374 2661 ce_count const&a │ │ │ -0000e970: 6d70 3b20 7063 290a 097b 0a09 092f 2f20 mp; pc)..{...// │ │ │ -0000e980: 6974 2773 2061 6e20 696d 706f 7373 6962 it's an impossib │ │ │ -0000e990: 6c65 2063 6f6d 6269 6e61 7469 6f6e 2074 le combination t │ │ │ -0000e9a0: 6f20 6861 7665 2030 2070 6965 6365 732c o have 0 pieces, │ │ │ -0000e9b0: 2062 7574 2073 7469 6c6c 2068 6176 6520 but still have │ │ │ -0000e9c0: 6f6e 6520 6f66 2074 6865 6d20 6265 2074 one of them be t │ │ │ -0000e9d0: 6865 206c 6173 7420 7069 6563 650a 0909 he last piece... │ │ │ -0000e9e0: 544f 5252 454e 545f 4153 5345 5254 2821 TORRENT_ASSERT(! │ │ │ -0000e9f0: 2870 632e 6e75 6d5f 7069 6563 6573 203d (pc.num_pieces = │ │ │ -0000ea00: 3d20 3020 2661 6d70 3b26 616d 703b 2070 = 0 && p │ │ │ -0000ea10: 632e 6c61 7374 5f70 6965 6365 203d 3d20 c.last_piece == │ │ │ -0000ea20: 7472 7565 2929 3b0a 0a09 092f 2f20 6966 true));....// if │ │ │ -0000ea30: 2077 6520 6861 7665 2030 2070 6965 6365 we have 0 piece │ │ │ -0000ea40: 732c 2077 6520 6361 6e27 7420 6861 7665 s, we can't have │ │ │ -0000ea50: 2061 6e79 2070 6164 2062 6c6f 636b 7320 any pad blocks │ │ │ -0000ea60: 6569 7468 6572 0a09 0954 4f52 5245 4e54 either...TORRENT │ │ │ -0000ea70: 5f41 5353 4552 5428 2128 7063 2e6e 756d _ASSERT(!(pc.num │ │ │ -0000ea80: 5f70 6965 6365 7320 3d3d 2030 2026 616d _pieces == 0 &am │ │ │ -0000ea90: 703b 2661 6d70 3b20 7063 2e70 6164 5f62 p;& pc.pad_b │ │ │ -0000eaa0: 7974 6573 2026 6774 3b20 3029 293b 0a0a ytes > 0));.. │ │ │ -0000eab0: 0909 2f2f 2069 6620 7765 2068 6176 6520 ..// if we have │ │ │ -0000eac0: 616c 6c20 7069 6563 6573 2c20 7765 206d all pieces, we m │ │ │ -0000ead0: 7573 7420 616c 736f 2068 6176 6520 7468 ust also have th │ │ │ -0000eae0: 6520 6c61 7374 206f 6e65 0a09 0954 4f52 e last one...TOR │ │ │ -0000eaf0: 5245 4e54 5f41 5353 4552 5428 2128 7063 RENT_ASSERT(!(pc │ │ │ -0000eb00: 2e6e 756d 5f70 6965 6365 7320 3d3d 2066 .num_pieces == f │ │ │ -0000eb10: 732e 6e75 6d5f 7069 6563 6573 2829 2026 s.num_pieces() & │ │ │ -0000eb20: 616d 703b 2661 6d70 3b20 7063 2e6c 6173 amp;& pc.las │ │ │ -0000eb30: 745f 7069 6563 6520 3d3d 2066 616c 7365 t_piece == false │ │ │ -0000eb40: 2929 3b0a 0a09 092f 2f20 6576 6572 7920 ));....// every │ │ │ -0000eb50: 626c 6f63 6b20 7368 6f75 6c64 206e 6f74 block should not │ │ │ -0000eb60: 2062 6520 6120 7061 6420 626c 6f63 6b0a be a pad block. │ │ │ -0000eb70: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0000eb80: 2870 632e 7061 645f 6279 7465 7320 266c (pc.pad_bytes &l │ │ │ -0000eb90: 743b 3d20 7374 643a 3a69 6e74 3634 5f74 t;= std::int64_t │ │ │ -0000eba0: 2870 632e 6e75 6d5f 7069 6563 6573 2920 (pc.num_pieces) │ │ │ -0000ebb0: 2a20 6673 2e70 6965 6365 5f6c 656e 6774 * fs.piece_lengt │ │ │ -0000ebc0: 6828 2929 3b0a 0a09 0972 6574 7572 6e20 h());....return │ │ │ -0000ebd0: 7374 643a 3a69 6e74 3634 5f74 2870 632e std::int64_t(pc. │ │ │ -0000ebe0: 6e75 6d5f 7069 6563 6573 2920 2a20 6673 num_pieces) * fs │ │ │ -0000ebf0: 2e70 6965 6365 5f6c 656e 6774 6828 290a .piece_length(). │ │ │ -0000ec00: 0909 092d 2028 7063 2e6c 6173 745f 7069 ...- (pc.last_pi │ │ │ -0000ec10: 6563 6520 3f20 6673 2e70 6965 6365 5f6c ece ? fs.piece_l │ │ │ -0000ec20: 656e 6774 6828 2920 2d20 6673 2e70 6965 ength() - fs.pie │ │ │ -0000ec30: 6365 5f73 697a 6528 6673 2e6c 6173 745f ce_size(fs.last_ │ │ │ -0000ec40: 7069 6563 6528 2929 203a 2030 290a 0909 piece()) : 0)... │ │ │ -0000ec50: 092d 2073 7464 3a3a 696e 7436 345f 7428 .- std::int64_t( │ │ │ -0000ec60: 7063 2e70 6164 5f62 7974 6573 293b 0a09 pc.pad_bytes);.. │ │ │ -0000ec70: 7d0a 0a09 2f2f 2066 696c 6c73 2069 6e20 }...// fills in │ │ │ -0000ec80: 746f 7461 6c5f 7761 6e74 6564 2c20 746f total_wanted, to │ │ │ -0000ec90: 7461 6c5f 7761 6e74 6564 5f64 6f6e 6520 tal_wanted_done │ │ │ -0000eca0: 616e 6420 746f 7461 6c5f 646f 6e65 0a3c and total_done.< │ │ │ -0000ecb0: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -0000ecc0: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -0000ecd0: 7769 6474 683d 2231 3030 2522 3e09 766f width="100%">.vo │ │ │ -0000ece0: 6964 2074 6f72 7265 6e74 3a3a 6279 7465 id torrent::byte │ │ │ -0000ecf0: 735f 646f 6e65 2874 6f72 7265 6e74 5f73 s_done(torrent_s │ │ │ -0000ed00: 7461 7475 7326 616d 703b 2073 742c 2073 tatus& st, s │ │ │ -0000ed10: 7461 7475 735f 666c 6167 735f 7420 636f tatus_flags_t co │ │ │ -0000ed20: 6e73 7420 666c 6167 7329 2063 6f6e 7374 nst flags) const │ │ │ -0000ed30: 0a3c 2f64 6976 3e09 7b0a 0909 494e 5641 .

    .{...INVA │ │ │ -0000ed40: 5249 414e 545f 4348 4543 4b3b 0a0a 0909 RIANT_CHECK;.... │ │ │ -0000ed50: 7374 2e74 6f74 616c 5f64 6f6e 6520 3d20 st.total_done = │ │ │ -0000ed60: 303b 0a09 0973 742e 746f 7461 6c5f 7761 0;...st.total_wa │ │ │ -0000ed70: 6e74 6564 5f64 6f6e 6520 3d20 303b 0a09 nted_done = 0;.. │ │ │ -0000ed80: 0973 742e 746f 7461 6c5f 7761 6e74 6564 .st.total_wanted │ │ │ -0000ed90: 203d 206d 5f73 697a 655f 6f6e 5f64 6973 = m_size_on_dis │ │ │ -0000eda0: 6b3b 0a09 0973 742e 746f 7461 6c20 3d20 k;...st.total = │ │ │ -0000edb0: 6d5f 7369 7a65 5f6f 6e5f 6469 736b 3b0a m_size_on_disk;. │ │ │ -0000edc0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0000edd0: 5428 7374 2e74 6f74 616c 5f77 616e 7465 T(st.total_wante │ │ │ -0000ede0: 6420 266c 743b 3d20 6d5f 746f 7272 656e d <= m_torren │ │ │ -0000edf0: 745f 6669 6c65 2d26 6774 3b74 6f74 616c t_file->total │ │ │ -0000ee00: 5f73 697a 6528 2929 3b0a 0909 544f 5252 _size());...TORR │ │ │ -0000ee10: 454e 545f 4153 5345 5254 2873 742e 746f ENT_ASSERT(st.to │ │ │ -0000ee20: 7461 6c5f 7761 6e74 6564 2026 6774 3b3d tal_wanted >= │ │ │ -0000ee30: 2030 293b 0a0a 0909 544f 5252 454e 545f 0);....TORRENT_ │ │ │ -0000ee40: 4153 5345 5254 2821 7661 6c69 645f 6d65 ASSERT(!valid_me │ │ │ -0000ee50: 7461 6461 7461 2829 207c 7c20 6d5f 746f tadata() || m_to │ │ │ -0000ee60: 7272 656e 745f 6669 6c65 2d26 6774 3b6e rrent_file->n │ │ │ -0000ee70: 756d 5f70 6965 6365 7328 2920 2667 743b um_pieces() > │ │ │ -0000ee80: 2030 293b 0a09 0969 6620 2821 7661 6c69 0);...if (!vali │ │ │ -0000ee90: 645f 6d65 7461 6461 7461 2829 2920 7265 d_metadata()) re │ │ │ -0000eea0: 7475 726e 3b0a 0a09 0969 6620 286d 5f73 turn;....if (m_s │ │ │ -0000eeb0: 6565 645f 6d6f 6465 207c 7c20 6973 5f73 eed_mode || is_s │ │ │ -0000eec0: 6565 6428 2929 0a09 097b 0a09 0909 2f2f eed())...{....// │ │ │ -0000eed0: 206f 6e63 6520 7765 2772 6520 6120 7365 once we're a se │ │ │ -0000eee0: 6564 2061 6e64 2072 656d 6f76 6520 7468 ed and remove th │ │ │ -0000eef0: 6520 7069 6563 6520 7069 636b 6572 2c20 e piece picker, │ │ │ -0000ef00: 7765 2073 746f 7020 7472 6163 6b69 6e67 we stop tracking │ │ │ -0000ef10: 0a09 0909 2f2f 2070 6965 6365 2d20 616e ....// piece- an │ │ │ -0000ef20: 6420 6669 6c65 2070 7269 6f72 6974 792e d file priority. │ │ │ -0000ef30: 2057 6520 636f 6e73 6964 6572 2065 7665 We consider eve │ │ │ -0000ef40: 7279 7468 696e 6720 6173 2062 6569 6e67 rything as being │ │ │ -0000ef50: 0a09 0909 2f2f 2022 7761 6e74 6564 220a ....// "wanted". │ │ │ -0000ef60: 0909 0973 742e 746f 7461 6c5f 646f 6e65 ...st.total_done │ │ │ -0000ef70: 203d 206d 5f73 697a 655f 6f6e 5f64 6973 = m_size_on_dis │ │ │ -0000ef80: 6b3b 0a09 0909 7374 2e74 6f74 616c 5f77 k;....st.total_w │ │ │ -0000ef90: 616e 7465 645f 646f 6e65 203d 206d 5f73 anted_done = m_s │ │ │ -0000efa0: 697a 655f 6f6e 5f64 6973 6b3b 0a09 0909 ize_on_disk;.... │ │ │ -0000efb0: 544f 5252 454e 545f 4153 5345 5254 2873 TORRENT_ASSERT(s │ │ │ -0000efc0: 742e 746f 7461 6c5f 7761 6e74 6564 2026 t.total_wanted & │ │ │ -0000efd0: 6c74 3b3d 2073 742e 746f 7461 6c5f 646f lt;= st.total_do │ │ │ -0000efe0: 6e65 293b 0a09 0909 544f 5252 454e 545f ne);....TORRENT_ │ │ │ -0000eff0: 4153 5345 5254 2873 742e 746f 7461 6c5f ASSERT(st.total_ │ │ │ -0000f000: 7761 6e74 6564 5f64 6f6e 6520 266c 743b wanted_done < │ │ │ -0000f010: 3d20 7374 2e74 6f74 616c 5f77 616e 7465 = st.total_wante │ │ │ -0000f020: 6429 3b0a 0909 0954 4f52 5245 4e54 5f41 d);....TORRENT_A │ │ │ -0000f030: 5353 4552 5428 7374 2e74 6f74 616c 5f64 SSERT(st.total_d │ │ │ -0000f040: 6f6e 6520 266c 743b 3d20 6d5f 746f 7272 one <= m_torr │ │ │ -0000f050: 656e 745f 6669 6c65 2d26 6774 3b74 6f74 ent_file->tot │ │ │ -0000f060: 616c 5f73 697a 6528 2929 3b0a 0909 0972 al_size());....r │ │ │ -0000f070: 6574 7572 6e3b 0a09 097d 0a09 0965 6c73 eturn;...}...els │ │ │ -0000f080: 6520 6966 2028 2168 6173 5f70 6963 6b65 e if (!has_picke │ │ │ -0000f090: 7228 2929 0a09 0909 7265 7475 726e 3b0a r())....return;. │ │ │ -0000f0a0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0000f0b0: 5428 6861 735f 7069 636b 6572 2829 293b T(has_picker()); │ │ │ -0000f0c0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ -0000f100: 3b33 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;3../sr │ │ │ -0000f130: 632f 746f 7272 656e 742e 6370 703a 3532 c/torrent.cpp:52 │ │ │ -0000f140: 3838 3c2f 613e 3c2f 7464 3e3c 7464 3e73 88s │ │ │ -0000f150: 686f 756c 6420 7468 6973 2061 6c65 7274 hould this alert │ │ │ -0000f160: 2068 6176 6520 616e 2065 7272 6f72 2063 have an error c │ │ │ -0000f170: 6f64 6520 696e 2069 743f 3c2f 7464 3e3c ode in it?< │ │ │ -0000f180: 2f74 723e 3c74 7220 6964 3d22 3239 2220 /tr>

    should th │ │ │ -0000f1d0: 6973 2061 6c65 7274 2068 6176 6520 616e is alert have an │ │ │ -0000f1e0: 2065 7272 6f72 2063 6f64 6520 696e 2069 error code in i │ │ │ -0000f1f0: 743f 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 t?

    ../sr │ │ │ -0000f200: 632f 746f 7272 656e 742e 6370 703a 3532 c/torrent.cpp:52 │ │ │ -0000f210: 3838 3c2f 6834 3e3c 7072 6520 7374 796c 88

    ..on_remove_pee
    │ │ │ -0000f260: 7273 2829 3b0a 0909 544f 5252 454e 545f  rs();...TORRENT_
    │ │ │ -0000f270: 4153 5345 5254 286d 5f63 6f6e 6e65 6374  ASSERT(m_connect
    │ │ │ -0000f280: 696f 6e73 2e65 6d70 7479 2829 293b 0a0a  ions.empty());..
    │ │ │ -0000f290: 0909 2f2f 2070 6f73 7420 6120 6d65 7373  ..// post a mess
    │ │ │ -0000f2a0: 6167 6520 746f 2074 6865 206d 6169 6e20  age to the main 
    │ │ │ -0000f2b0: 7468 7265 6164 2074 6f20 6465 7374 7275  thread to destru
    │ │ │ -0000f2c0: 6374 0a09 092f 2f20 7468 6520 746f 7272  ct...// the torr
    │ │ │ -0000f2d0: 656e 7420 6f62 6a65 6374 2066 726f 6d20  ent object from 
    │ │ │ -0000f2e0: 7468 6572 650a 0909 6966 2028 6d5f 7374  there...if (m_st
    │ │ │ -0000f2f0: 6f72 6167 6529 0a09 097b 0a09 0909 7472  orage)...{....tr
    │ │ │ -0000f300: 7920 7b0a 0909 0909 6d5f 7365 732e 6469  y {.....m_ses.di
    │ │ │ -0000f310: 736b 5f74 6872 6561 6428 292e 6173 796e  sk_thread().asyn
    │ │ │ -0000f320: 635f 7374 6f70 5f74 6f72 7265 6e74 286d  c_stop_torrent(m
    │ │ │ -0000f330: 5f73 746f 7261 6765 0a09 0909 0909 2c20  _storage......, 
    │ │ │ -0000f340: 7374 643a 3a62 696e 6428 2661 6d70 3b74  std::bind(&t
    │ │ │ -0000f350: 6f72 7265 6e74 3a3a 6f6e 5f74 6f72 7265  orrent::on_torre
    │ │ │ -0000f360: 6e74 5f61 626f 7274 6564 2c20 7368 6172  nt_aborted, shar
    │ │ │ -0000f370: 6564 5f66 726f 6d5f 7468 6973 2829 2929  ed_from_this()))
    │ │ │ -0000f380: 3b0a 0909 097d 0a09 0909 6361 7463 6820  ;....}....catch 
    │ │ │ -0000f390: 2873 7464 3a3a 6578 6365 7074 696f 6e20  (std::exception 
    │ │ │ -0000f3a0: 636f 6e73 7426 616d 703b 2065 290a 0909  const& e)...
    │ │ │ -0000f3b0: 097b 0a09 0909 0954 4f52 5245 4e54 5f55  .{.....TORRENT_U
    │ │ │ -0000f3c0: 4e55 5345 4428 6529 3b0a 0909 0909 6d5f  NUSED(e);.....m_
    │ │ │ -0000f3d0: 7374 6f72 6167 652e 7265 7365 7428 293b  storage.reset();
    │ │ │ -0000f3e0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -0000f3f0: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ -0000f400: 0a09 0909 0964 6562 7567 5f6c 6f67 2822  .....debug_log("
    │ │ │ -0000f410: 4661 696c 6564 2074 6f20 666c 7573 6820  Failed to flush 
    │ │ │ -0000f420: 6469 736b 2063 6163 6865 3a20 2573 222c  disk cache: %s",
    │ │ │ -0000f430: 2065 2e77 6861 7428 2929 3b0a 2365 6e64   e.what());.#end
    │ │ │ -0000f440: 6966 0a09 0909 092f 2f20 636c 6965 6e74  if.....// client
    │ │ │ -0000f450: 7320 6d61 7920 7265 6c79 206f 6e20 7468  s may rely on th
    │ │ │ -0000f460: 6973 2061 6c65 7274 2074 6f20 6265 2070  is alert to be p
    │ │ │ -0000f470: 6f73 7465 642c 2073 6f20 6974 2773 2070  osted, so it's p
    │ │ │ -0000f480: 726f 6261 626c 7920 610a 0909 0909 2f2f  robably a.....//
    │ │ │ -0000f490: 2067 6f6f 6420 6964 6561 2074 6f20 706f   good idea to po
    │ │ │ -0000f4a0: 7374 2069 7420 6865 7265 2c20 6576 656e  st it here, even
    │ │ │ -0000f4b0: 2074 686f 7567 6820 7765 2066 6169 6c65   though we faile
    │ │ │ -0000f4c0: 640a 3c64 6976 2073 7479 6c65 3d22 6261  d.
    │ │ │ -0000f4f0: 0909 0909 6966 2028 616c 6572 7473 2829 ....if (alerts() │ │ │ -0000f500: 2e73 686f 756c 645f 706f 7374 266c 743b .should_post< │ │ │ -0000f510: 6361 6368 655f 666c 7573 6865 645f 616c cache_flushed_al │ │ │ -0000f520: 6572 7426 6774 3b28 2929 0a3c 2f64 6976 ert>()).
    .....alerts().e │ │ │ -0000f540: 6d70 6c61 6365 5f61 6c65 7274 266c 743b mplace_alert< │ │ │ -0000f550: 6361 6368 655f 666c 7573 6865 645f 616c cache_flushed_al │ │ │ -0000f560: 6572 7426 6774 3b28 6765 745f 6861 6e64 ert>(get_hand │ │ │ -0000f570: 6c65 2829 293b 0a09 0909 7d0a 0909 096d le());....}....m │ │ │ -0000f580: 5f73 6573 2e64 6566 6572 7265 645f 7375 _ses.deferred_su │ │ │ -0000f590: 626d 6974 5f6a 6f62 7328 293b 0a09 097d bmit_jobs();...} │ │ │ -0000f5a0: 0a09 0965 6c73 650a 0909 7b0a 0909 0969 ...else...{....i │ │ │ -0000f5b0: 6620 2861 6c65 7274 7328 292e 7368 6f75 f (alerts().shou │ │ │ -0000f5c0: 6c64 5f70 6f73 7426 6c74 3b63 6163 6865 ld_post<cache │ │ │ -0000f5d0: 5f66 6c75 7368 6564 5f61 6c65 7274 2667 _flushed_alert&g │ │ │ -0000f5e0: 743b 2829 290a 0909 0909 616c 6572 7473 t;()).....alerts │ │ │ -0000f5f0: 2829 2e65 6d70 6c61 6365 5f61 6c65 7274 ().emplace_alert │ │ │ -0000f600: 266c 743b 6361 6368 655f 666c 7573 6865 <cache_flushe │ │ │ -0000f610: 645f 616c 6572 7426 6774 3b28 6765 745f d_alert>(get_ │ │ │ -0000f620: 6861 6e64 6c65 2829 293b 0a09 0909 616c handle());....al │ │ │ -0000f630: 6572 7473 2829 2e65 6d70 6c61 6365 5f61 erts().emplace_a │ │ │ -0000f640: 6c65 7274 266c 743b 746f 7272 656e 745f lert<torrent_ │ │ │ -0000f650: 7265 6d6f 7665 645f 616c 6572 7426 6774 removed_alert> │ │ │ -0000f660: 3b28 6765 745f 6861 6e64 6c65 2829 0a09 ;(get_handle().. │ │ │ -0000f670: 0909 092c 2069 6e66 6f5f 6861 7368 2829 ..., info_hash() │ │ │ -0000f680: 2c20 6765 745f 7573 6572 6461 7461 2829 , get_userdata() │ │ │ -0000f690: 293b 0a09 097d 0a0a 3c2f 7072 653e 3c2f );...}..
    relevan │ │ │ -0000f6d0: 6365 266e 6273 703b 333c 2f74 643e 3c74 ce 3../src/torrent │ │ │ -0000f710: 2e63 7070 3a35 3335 323c 2f61 3e3c 2f74 .cpp:5352this shoul │ │ │ -0000f730: 6420 7265 7475 726e 206f 7074 696f 6e61 d return optiona │ │ │ -0000f740: 6c3c 3e2e 2070 6965 6365 2069 6e64 6578 l<>. piece index │ │ │ -0000f750: 202d 3120 7368 6f75 6c64 206e 6f74 2062 -1 should not b │ │ │ -0000f760: 6520 616c 6c6f 7765 643c 2f74 643e 3c2f e allowed

    this shoul │ │ │ -0000f7c0: 6420 7265 7475 726e 206f 7074 696f 6e61 d return optiona │ │ │ -0000f7d0: 6c3c 3e2e 2070 6965 6365 2069 6e64 6578 l<>. piece index │ │ │ -0000f7e0: 202d 3120 7368 6f75 6c64 206e 6f74 2062 -1 should not b │ │ │ -0000f7f0: 650a 616c 6c6f 7765 643c 2f68 323e 3c68 e.allowed

    ../src/torrent │ │ │ -0000f810: 2e63 7070 3a35 3335 323c 2f68 343e 3c70 .cpp:5352

    .}..#ifn │ │ │ -0000f860: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -0000f870: 424c 455f 5355 5045 5253 4545 4449 4e47 BLE_SUPERSEEDING │ │ │ -0000f880: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a ..void torrent:: │ │ │ -0000f890: 7365 745f 7375 7065 725f 7365 6564 696e set_super_seedin │ │ │ -0000f8a0: 6728 626f 6f6c 2063 6f6e 7374 206f 6e29 g(bool const on) │ │ │ -0000f8b0: 0a09 7b0a 0909 6966 2028 6f6e 203d 3d20 ..{...if (on == │ │ │ -0000f8c0: 6d5f 7375 7065 725f 7365 6564 696e 6729 m_super_seeding) │ │ │ -0000f8d0: 2072 6574 7572 6e3b 0a0a 0909 6d5f 7375 return;....m_su │ │ │ -0000f8e0: 7065 725f 7365 6564 696e 6720 3d20 6f6e per_seeding = on │ │ │ -0000f8f0: 3b0a 0909 7365 745f 6e65 6564 5f73 6176 ;...set_need_sav │ │ │ -0000f900: 655f 7265 7375 6d65 2874 6f72 7265 6e74 e_resume(torrent │ │ │ -0000f910: 5f68 616e 646c 653a 3a69 665f 7374 6174 _handle::if_stat │ │ │ -0000f920: 655f 6368 616e 6765 6429 3b0a 0909 7374 e_changed);...st │ │ │ -0000f930: 6174 655f 7570 6461 7465 6428 293b 0a0a ate_updated();.. │ │ │ -0000f940: 0909 6966 2028 6d5f 7375 7065 725f 7365 ..if (m_super_se │ │ │ -0000f950: 6564 696e 6729 2072 6574 7572 6e3b 0a0a eding) return;.. │ │ │ -0000f960: 0909 2f2f 2064 6973 6162 6c65 2073 7570 ..// disable sup │ │ │ -0000f970: 6572 2073 6565 6469 6e67 2066 6f72 2061 er seeding for a │ │ │ -0000f980: 6c6c 2070 6565 7273 0a09 0966 6f72 2028 ll peers...for ( │ │ │ -0000f990: 6175 746f 2a20 7063 203a 202a 7468 6973 auto* pc : *this │ │ │ -0000f9a0: 290a 0909 7b0a 0909 0970 632d 2667 743b )...{....pc-> │ │ │ -0000f9b0: 7375 7065 7273 6565 645f 7069 6563 6528 superseed_piece( │ │ │ -0000f9c0: 7069 6563 655f 696e 6465 785f 7428 2d31 piece_index_t(-1 │ │ │ -0000f9d0: 292c 2070 6965 6365 5f69 6e64 6578 5f74 ), piece_index_t │ │ │ -0000f9e0: 282d 3129 293b 0a09 097d 0a09 7d0a 0a3c (-1));...}..}..< │ │ │ -0000f9f0: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -0000fa00: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -0000fa10: 7769 6474 683d 2231 3030 2522 3e09 7069 width="100%">.pi │ │ │ -0000fa20: 6563 655f 696e 6465 785f 7420 746f 7272 ece_index_t torr │ │ │ -0000fa30: 656e 743a 3a67 6574 5f70 6965 6365 5f74 ent::get_piece_t │ │ │ -0000fa40: 6f5f 7375 7065 725f 7365 6564 2874 7970 o_super_seed(typ │ │ │ -0000fa50: 6564 5f62 6974 6669 656c 6426 6c74 3b70 ed_bitfield<p │ │ │ -0000fa60: 6965 6365 5f69 6e64 6578 5f74 2667 743b iece_index_t> │ │ │ -0000fa70: 2063 6f6e 7374 2661 6d70 3b20 6269 7473 const& bits │ │ │ -0000fa80: 290a 3c2f 6469 763e 097b 0a09 092f 2f20 ).

    .{...// │ │ │ -0000fa90: 7265 7475 726e 2061 2070 6965 6365 2077 return a piece w │ │ │ -0000faa0: 6974 6820 6c6f 7720 6176 6169 6c61 6269 ith low availabi │ │ │ -0000fab0: 6c69 7479 2074 6861 7420 6973 206e 6f74 lity that is not │ │ │ -0000fac0: 2069 6e0a 0909 2f2f 2074 6865 2062 6974 in...// the bit │ │ │ -0000fad0: 6669 656c 6420 616e 6420 7468 6174 2069 field and that i │ │ │ -0000fae0: 7320 6e6f 7420 6375 7272 656e 746c 7920 s not currently │ │ │ -0000faf0: 6265 696e 6720 7375 7065 720a 0909 2f2f being super...// │ │ │ -0000fb00: 2073 6565 6465 6420 6279 2061 6e79 2070 seeded by any p │ │ │ -0000fb10: 6565 720a 0909 544f 5252 454e 545f 4153 eer...TORRENT_AS │ │ │ -0000fb20: 5345 5254 286d 5f73 7570 6572 5f73 6565 SERT(m_super_see │ │ │ -0000fb30: 6469 6e67 293b 0a0a 0909 2f2f 2064 6f20 ding);....// do │ │ │ -0000fb40: 6120 6c69 6e65 6172 2073 6561 7263 6820 a linear search │ │ │ -0000fb50: 6672 6f6d 2074 6865 2066 6972 7374 2070 from the first p │ │ │ -0000fb60: 6965 6365 0a09 0969 6e74 206d 696e 5f61 iece...int min_a │ │ │ -0000fb70: 7661 696c 6162 696c 6974 7920 3d20 3939 vailability = 99 │ │ │ -0000fb80: 3939 3b0a 0909 7374 643a 3a76 6563 746f 99;...std::vecto │ │ │ -0000fb90: 7226 6c74 3b70 6965 6365 5f69 6e64 6578 r<piece_index │ │ │ -0000fba0: 5f74 2667 743b 2061 7661 696c 5f76 6563 _t> avail_vec │ │ │ -0000fbb0: 3b0a 0909 666f 7220 2861 7574 6f20 636f ;...for (auto co │ │ │ -0000fbc0: 6e73 7420 6920 3a20 6d5f 746f 7272 656e nst i : m_torren │ │ │ -0000fbd0: 745f 6669 6c65 2d26 6774 3b70 6965 6365 t_file->piece │ │ │ -0000fbe0: 5f72 616e 6765 2829 290a 0909 7b0a 0909 _range())...{... │ │ │ -0000fbf0: 0969 6620 2862 6974 735b 695d 2920 636f .if (bits[i]) co │ │ │ -0000fc00: 6e74 696e 7565 3b0a 0a09 0909 696e 7420 ntinue;.....int │ │ │ -0000fc10: 6176 6169 6c61 6269 6c69 7479 203d 2030 availability = 0 │ │ │ -0000fc20: 3b0a 0909 0966 6f72 2028 6175 746f 2a20 ;....for (auto* │ │ │ -0000fc30: 7063 203a 202a 7468 6973 290a 0909 097b pc : *this)....{ │ │ │ -0000fc40: 0a09 0909 0969 6620 2870 632d 2667 743b .....if (pc-> │ │ │ -0000fc50: 7375 7065 725f 7365 6564 6564 5f70 6965 super_seeded_pie │ │ │ -0000fc60: 6365 2869 2929 0a09 0909 097b 0a09 0909 ce(i)).....{.... │ │ │ -0000fc70: 0909 2f2f 2061 766f 6964 2073 7570 6572 ..// avoid super │ │ │ -0000fc80: 2d73 6565 6469 6e67 2074 6865 2073 616d -seeding the sam │ │ │ -0000fc90: 6520 7069 6563 6520 746f 206d 6f72 6520 e piece to more │ │ │ -0000fca0: 7468 616e 206f 6e65 0a09 0909 0909 2f2f than one......// │ │ │ -0000fcb0: 2070 6565 7220 6966 2077 6520 6361 6e20 peer if we can │ │ │ -0000fcc0: 6176 6f69 6420 6974 2e20 446f 2074 6869 avoid it. Do thi │ │ │ -0000fcd0: 7320 6279 2061 7274 6966 6963 6961 6c6c s by artificiall │ │ │ -0000fce0: 790a 0909 0909 092f 2f20 696e 6372 6561 y......// increa │ │ │ -0000fcf0: 7365 2074 6865 2061 7661 696c 6162 696c se the availabil │ │ │ -0000fd00: 6974 790a 0909 0909 0961 7661 696c 6162 ity......availab │ │ │ -0000fd10: 696c 6974 7920 3d20 3939 393b 0a09 0909 ility = 999;.... │ │ │ -0000fd20: 0909 6272 6561 6b3b 0a09 0909 097d 0a09 ..break;.....}.. │ │ │ -0000fd30: 0909 0969 6620 2870 632d 2667 743b 6861 ...if (pc->ha │ │ │ -0000fd40: 735f 7069 6563 6528 6929 2920 2b2b 6176 s_piece(i)) ++av │ │ │ -0000fd50: 6169 6c61 6269 6c69 7479 3b0a 0909 097d ailability;....} │ │ │ -0000fd60: 0a09 0909 6966 2028 6176 6169 6c61 6269 ....if (availabi │ │ │ -0000fd70: 6c69 7479 2026 6774 3b20 6d69 6e5f 6176 lity > min_av │ │ │ -0000fd80: 6169 6c61 6269 6c69 7479 2920 636f 6e74 ailability) cont │ │ │ -0000fd90: 696e 7565 3b0a 0909 0969 6620 2861 7661 inue;....if (ava │ │ │ -0000fda0: 696c 6162 696c 6974 7920 3d3d 206d 696e ilability == min │ │ │ -0000fdb0: 5f61 7661 696c 6162 696c 6974 7929 0a09 _availability).. │ │ │ -0000fdc0: 0909 7b0a 0909 0909 6176 6169 6c5f 7665 ..{.....avail_ve │ │ │ -0000fdd0: 632e 7075 7368 5f62 6163 6b28 6929 3b0a c.push_back(i);. │ │ │ +00009c80: 223e 3c68 323e 7468 6973 2063 6f75 6c64 ">

    this could │ │ │ +00009c90: 2062 6520 6d61 6465 206d 6f72 6520 6566 be made more ef │ │ │ +00009ca0: 6669 6369 656e 7420 666f 7220 7468 6520 ficient for the │ │ │ +00009cb0: 6361 7365 2077 6865 6e20 7765 2075 7365 case when we use │ │ │ +00009cc0: 2061 6e0a 4854 5450 2070 726f 7879 2e20 an.HTTP proxy. │ │ │ +00009cd0: 5468 656e 2077 6520 776f 756c 646e 2774 Then we wouldn't │ │ │ +00009ce0: 206e 6565 6420 746f 2061 6464 206e 6577 need to add new │ │ │ +00009cf0: 2077 6562 2073 6565 6473 2074 6f20 7468 web seeds to th │ │ │ +00009d00: 6520 746f 7272 656e 742c 0a77 6520 636f e torrent,.we co │ │ │ +00009d10: 756c 6420 6a75 7374 206d 616b 6520 7468 uld just make th │ │ │ +00009d20: 6520 7265 6469 7265 6374 2074 6162 6c65 e redirect table │ │ │ +00009d30: 2063 6f6e 7461 696e 2066 756c 6c20 5552 contain full UR │ │ │ +00009d40: 4c73 2e3c 2f68 323e 3c68 343e 2e2e 2f73 Ls.

    ../s │ │ │ +00009d50: 7263 2f77 6562 5f70 6565 725f 636f 6e6e rc/web_peer_conn │ │ │ +00009d60: 6563 7469 6f6e 2e63 7070 3a36 3931 3c2f ection.cpp:691
    ...
    │ │ │ +00009db0: 3f20 746f 7272 656e 743a 3a6e 6f5f 6c6f  ? torrent::no_lo
    │ │ │ +00009dc0: 6361 6c5f 6970 7320 3a20 7765 625f 7365  cal_ips : web_se
    │ │ │ +00009dd0: 6564 5f66 6c61 675f 747b 7d29 3b0a 0a09  ed_flag_t{});...
    │ │ │ +00009de0: 2f2f 2061 6464 2074 6865 2072 6564 6972  // add the redir
    │ │ │ +00009df0: 6563 7465 6420 7572 6c20 616e 6420 7265  ected url and re
    │ │ │ +00009e00: 6d6f 7665 2074 6865 2063 7572 7265 6e74  move the current
    │ │ │ +00009e10: 206f 6e65 0a09 6966 2028 2173 696e 676c   one..if (!singl
    │ │ │ +00009e20: 655f 6669 6c65 5f72 6571 7565 7374 290a  e_file_request).
    │ │ │ +00009e30: 097b 0a09 0969 6620 286d 5f66 696c 655f  .{...if (m_file_
    │ │ │ +00009e40: 7265 7175 6573 7473 2e65 6d70 7479 2829  requests.empty()
    │ │ │ +00009e50: 290a 0909 7b0a 0909 092f 2f20 7468 6520  )...{....// the 
    │ │ │ +00009e60: 7365 7276 6572 2073 656e 7420 6120 7265  server sent a re
    │ │ │ +00009e70: 6469 7265 6374 2072 6573 706f 6e73 6520  direct response 
    │ │ │ +00009e80: 7769 7468 6f75 7420 6120 6d61 7463 6869  without a matchi
    │ │ │ +00009e90: 6e67 2072 6571 7565 7374 0a09 0909 6469  ng request....di
    │ │ │ +00009ea0: 7363 6f6e 6e65 6374 2865 7272 6f72 733a  sconnect(errors:
    │ │ │ +00009eb0: 3a68 7474 705f 7061 7273 655f 6572 726f  :http_parse_erro
    │ │ │ +00009ec0: 722c 206f 7065 7261 7469 6f6e 5f74 3a3a  r, operation_t::
    │ │ │ +00009ed0: 6269 7474 6f72 7265 6e74 2c20 7065 6572  bittorrent, peer
    │ │ │ +00009ee0: 5f65 7272 6f72 293b 0a09 0909 7265 7475  _error);....retu
    │ │ │ +00009ef0: 726e 3b0a 0909 7d0a 0909 6669 6c65 5f69  rn;...}...file_i
    │ │ │ +00009f00: 6e64 6578 5f74 2063 6f6e 7374 2066 696c  ndex_t const fil
    │ │ │ +00009f10: 655f 696e 6465 7820 3d20 6d5f 6669 6c65  e_index = m_file
    │ │ │ +00009f20: 5f72 6571 7565 7374 732e 6672 6f6e 7428  _requests.front(
    │ │ │ +00009f30: 292e 6669 6c65 5f69 6e64 6578 3b0a 0a09  ).file_index;...
    │ │ │ +00009f40: 096c 6f63 6174 696f 6e20 3d20 6175 783a  .location = aux:
    │ │ │ +00009f50: 3a72 6573 6f6c 7665 5f72 6564 6972 6563  :resolve_redirec
    │ │ │ +00009f60: 745f 6c6f 6361 7469 6f6e 286d 5f75 726c  t_location(m_url
    │ │ │ +00009f70: 2c20 6c6f 6361 7469 6f6e 293b 0a0a 0909  , location);....
    │ │ │ +00009f80: 2f2f 2077 6f72 6b2d 6172 6f75 6e64 2066  // work-around f
    │ │ │ +00009f90: 6f72 2062 7567 6779 2048 5454 5020 7365  or buggy HTTP se
    │ │ │ +00009fa0: 7276 6572 732c 2074 6861 7420 6661 696c  rvers, that fail
    │ │ │ +00009fb0: 2074 6f20 656e 636f 6465 2074 6865 2072   to encode the r
    │ │ │ +00009fc0: 6564 6972 6563 7420 5552 4c0a 0909 6c6f  edirect URL...lo
    │ │ │ +00009fd0: 6361 7469 6f6e 203d 206d 6179 6265 5f75  cation = maybe_u
    │ │ │ +00009fe0: 726c 5f65 6e63 6f64 6528 6c6f 6361 7469  rl_encode(locati
    │ │ │ +00009ff0: 6f6e 293b 0a23 6966 6e64 6566 2054 4f52  on);.#ifndef TOR
    │ │ │ +0000a000: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ +0000a010: 4749 4e47 0a09 0970 6565 725f 6c6f 6728  GING...peer_log(
    │ │ │ +0000a020: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a  peer_log_alert::
    │ │ │ +0000a030: 696e 666f 2c20 7065 6572 5f6c 6f67 5f61  info, peer_log_a
    │ │ │ +0000a040: 6c65 7274 3a3a 6c6f 6361 7469 6f6e 2c20  lert::location, 
    │ │ │ +0000a050: 2225 7322 2c20 6c6f 6361 7469 6f6e 2e63  "%s", location.c
    │ │ │ +0000a060: 5f73 7472 2829 293b 0a23 656e 6469 660a  _str());.#endif.
    │ │ │ +0000a070: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +0000a0a0: 6572 726f 725f 636f 6465 2065 633b 0a3c error_code ec;.< │ │ │ +0000a0b0: 2f64 6976 3e09 0961 7574 6f20 636f 6e73 /div>..auto cons │ │ │ +0000a0c0: 7420 5b72 6564 6972 6563 745f 6261 7365 t [redirect_base │ │ │ +0000a0d0: 2c20 7265 6469 7265 6374 5f70 6174 685d , redirect_path] │ │ │ +0000a0e0: 203d 2073 706c 6974 5f75 726c 286c 6f63 = split_url(loc │ │ │ +0000a0f0: 6174 696f 6e2c 2065 6329 3b0a 0a09 0969 ation, ec);....i │ │ │ +0000a100: 6620 2865 6329 0a09 097b 0a09 0909 2f2f f (ec)...{....// │ │ │ +0000a110: 2077 6520 7368 6f75 6c64 206e 6f74 2074 we should not t │ │ │ +0000a120: 7279 2074 6869 7320 7365 7276 6572 2061 ry this server a │ │ │ +0000a130: 6761 696e 2e0a 0909 0964 6973 636f 6e6e gain.....disconn │ │ │ +0000a140: 6563 7428 6572 726f 7273 3a3a 6d69 7373 ect(errors::miss │ │ │ +0000a150: 696e 675f 6c6f 6361 7469 6f6e 2c20 6f70 ing_location, op │ │ │ +0000a160: 6572 6174 696f 6e5f 743a 3a62 6974 746f eration_t::bitto │ │ │ +0000a170: 7272 656e 742c 2066 6169 6c75 7265 293b rrent, failure); │ │ │ +0000a180: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a ....return;...}. │ │ │ +0000a190: 0a09 092f 2f20 6164 645f 7765 625f 7365 ...// add_web_se │ │ │ +0000a1a0: 6564 2077 6f6e 2774 2061 6464 2064 7570 ed won't add dup │ │ │ +0000a1b0: 6c69 6361 7465 732e 2049 6620 7765 2068 licates. If we h │ │ │ +0000a1c0: 6176 6520 616c 7265 6164 7920 6164 6465 ave already adde │ │ │ +0000a1d0: 6420 616e 2065 6e74 7279 0a09 092f 2f20 d an entry...// │ │ │ +0000a1e0: 7769 7468 2074 6869 7320 5552 4c2c 2077 with this URL, w │ │ │ +0000a1f0: 6527 6c6c 2067 6574 2062 6163 6b20 7468 e'll get back th │ │ │ +0000a200: 6520 6578 6973 7469 6e67 2065 6e74 7279 e existing entry │ │ │ +0000a210: 0a0a 0909 2f2f 2044 6f6e 2774 2066 6f72 ....// Don't for │ │ │ +0000a220: 7761 7264 206f 7572 2063 7265 6465 6e74 ward our credent │ │ │ +0000a230: 6961 6c73 2028 7468 6520 7765 625f 7365 ials (the web_se │ │ │ +0000a240: 6564 5f65 6e74 7279 3a3a 6175 7468 2076 ed_entry::auth v │ │ │ +0000a250: 616c 7565 2c20 7365 6e74 0a09 092f 2f20 alue, sent...// │ │ │ +0000a260: 6173 2074 6865 2041 7574 686f 7269 7a61 as the Authoriza │ │ │ +0000a270: 7469 6f6e 2068 6561 6465 7229 2074 6f20 tion header) to │ │ │ +0000a280: 6120 6469 6666 6572 656e 7420 6f72 6967 a different orig │ │ │ +0000a290: 696e 2e20 5468 6520 7265 6469 7265 6374 in. The redirect │ │ │ +0000a2a0: 0a09 092f 2f20 7461 7267 6574 206d 6179 ...// target may │ │ │ +0000a2b0: 2062 6520 6120 7468 6972 6420 7061 7274 be a third part │ │ │ +0000a2c0: 7920 7365 7276 6572 2074 6861 7420 7368 y server that sh │ │ │ +0000a2d0: 6f75 6c64 206e 6f74 2073 6565 2074 6865 ould not see the │ │ │ +0000a2e0: 6d2e 204e 6f74 650a 0909 2f2f 2074 6861 m. Note...// tha │ │ │ +0000a2f0: 7420 616e 7920 7573 6572 2d73 7570 706c t any user-suppl │ │ │ +0000a300: 6965 6420 6d5f 6578 7472 615f 6865 6164 ied m_extra_head │ │ │ +0000a310: 6572 7320 6172 6520 7374 696c 6c20 666f ers are still fo │ │ │ +0000a320: 7277 6172 6465 6420 2d2d 2073 6565 2074 rwarded -- see t │ │ │ +0000a330: 6865 0a09 092f 2f20 7761 726e 696e 6720 he...// warning │ │ │ +0000a340: 6f6e 2077 6562 5f73 6565 645f 656e 7472 on web_seed_entr │ │ │ +0000a350: 793a 3a65 7874 7261 5f68 6561 6465 7273 y::extra_headers │ │ │ +0000a360: 2e0a 0909 7374 643a 3a73 7472 696e 6720 ....std::string │ │ │ +0000a370: 636f 6e73 7420 6175 7468 203d 2073 616d const auth = sam │ │ │ +0000a380: 655f 6f72 6967 696e 286d 5f75 726c 2c20 e_origin(m_url, │ │ │ +0000a390: 6c6f 6361 7469 6f6e 2920 3f20 6d5f 6578 location) ? m_ex │ │ │ +0000a3a0: 7465 726e 616c 5f61 7574 6820 3a20 7374 ternal_auth : st │ │ │ +0000a3b0: 643a 3a73 7472 696e 6728 293b 0a0a 0909 d::string();.... │ │ │ +0000a3c0: 2f2f 2022 6570 6865 6d65 7261 6c22 2066 // "ephemeral" f │ │ │ +0000a3d0: 6c61 6720 7368 6f75 6c64 2062 6520 7365 lag should be se │ │ │ +0000a3e0: 7420 746f 2061 766f 6964 2022 7765 625f t to avoid "web_ │ │ │ +0000a3f0: 7365 6564 5f74 2220 7361 7669 6e67 2069 seed_t" saving i │ │ │ +0000a400: 6e20 7265 7375 6d65 2064 6174 612e 0a09 n resume data... │ │ │ +0000a410: 092f 2f20 452e 672e 206f 7269 6769 6e61 .// E.g. origina │ │ │ +0000a420: 6c20 2277 6562 5f73 6565 645f 7422 2072 l "web_seed_t" r │ │ │ +0000a430: 6571 7565 7374 2075 726c 2070 6f69 6e74 equest url point │ │ │ +0000a440: 7320 746f 2022 6874 7470 3a2f 2f65 7861 s to "http://exa │ │ │ +0000a450: 6d70 6c65 312e 636f 6d2f 6669 6c65 3122 mple1.com/file1" │ │ │ +0000a460: 2061 6e64 0a09 092f 2f20 7765 6220 7365 and...// web se │ │ │ +0000a470: 7276 6572 2072 6573 706f 6e73 6573 2077 rver responses w │ │ │ +0000a480: 6974 6820 7265 6469 7265 6374 206c 6f63 ith redirect loc │ │ │ +0000a490: 6174 696f 6e20 2268 7474 703a 2f2f 6578 ation "http://ex │ │ │ +0000a4a0: 616d 706c 6532 2e63 6f6d 2f73 7562 7061 ample2.com/subpa │ │ │ +0000a4b0: 7468 2f66 696c 6532 222e 0a09 092f 2f20 th/file2"....// │ │ │ +0000a4c0: 2268 616e 646c 655f 7265 6469 7265 6374 "handle_redirect │ │ │ +0000a4d0: 2220 7072 6f63 6573 7320 7468 6973 206c " process this l │ │ │ +0000a4e0: 6f63 6174 696f 6e20 746f 2063 7265 6174 ocation to creat │ │ │ +0000a4f0: 6520 6e65 7720 2277 6562 5f73 6565 645f e new "web_seed_ │ │ │ +0000a500: 7422 0a09 092f 2f20 7769 7468 2062 6173 t"...// with bas │ │ │ +0000a510: 6520 7572 6c3d 3d22 6874 7470 3a2f 2f65 e url=="http://e │ │ │ +0000a520: 7861 6d70 6c65 322e 636f 6d2f 2220 616e xample2.com/" an │ │ │ +0000a530: 6420 7265 6469 7265 6374 735b 305d 3d3d d redirects[0]== │ │ │ +0000a540: 222f 7375 6270 6174 682f 6669 6c65 3222 "/subpath/file2" │ │ │ +0000a550: 292e 0a09 092f 2f20 4966 2077 6520 7472 )....// If we tr │ │ │ +0000a560: 7920 746f 206c 6f61 6420 7265 7375 6d65 y to load resume │ │ │ +0000a570: 2077 6974 6820 7375 6368 2022 7765 625f with such "web_ │ │ │ +0000a580: 7365 6564 5f74 2220 7468 656e 2022 7765 seed_t" then "we │ │ │ +0000a590: 625f 7065 6572 5f63 6f6e 6e65 6374 696f b_peer_connectio │ │ │ +0000a5a0: 6e22 2077 696c 6c20 7365 6e64 0a09 092f n" will send.../ │ │ │ +0000a5b0: 2f20 7265 7175 6573 7420 7769 7468 2077 / request with w │ │ │ +0000a5c0: 726f 6e67 2070 6174 6820 2268 7474 703a rong path "http: │ │ │ +0000a5d0: 2f2f 6578 616d 706c 6532 2e63 6f6d 2f66 //example2.com/f │ │ │ +0000a5e0: 696c 6531 2220 2863 6175 7365 2022 7265 ile1" (cause "re │ │ │ +0000a5f0: 6469 7265 6374 7322 206d 6170 2069 7320 directs" map is │ │ │ +0000a600: 6e6f 7420 7365 7269 616c 697a 6564 2069 not serialized i │ │ │ +0000a610: 6e20 7265 7375 6d65 290a 0909 7765 625f n resume)...web_ │ │ │ +0000a620: 7365 6564 5f74 2a20 7765 6220 3d20 742d seed_t* web = t- │ │ │ +0000a630: 2667 743b 6164 645f 7765 625f 7365 6564 >add_web_seed │ │ │ +0000a640: 2872 6564 6972 6563 745f 6261 7365 2c20 (redirect_base, │ │ │ +0000a650: 6175 7468 2c20 6d5f 6578 7472 615f 6865 auth, m_extra_he │ │ │ +0000a660: 6164 6572 732c 2077 6562 5f73 6565 645f aders, web_seed_ │ │ │ +0000a670: 666c 6167 7329 3b0a 0909 7765 622d 2667 flags);...web-&g │ │ │ +0000a680: 743b 6861 7665 5f66 696c 6573 2e72 6573 t;have_files.res │ │ │ +0000a690: 697a 6528 742d 2667 743b 746f 7272 656e ize(t->torren │ │ │ +0000a6a0: 745f 6669 6c65 2829 2e6e 756d 5f66 696c t_file().num_fil │ │ │ +0000a6b0: 6573 2829 2c20 6661 6c73 6529 3b0a 0a09 es(), false);... │ │ │ +0000a6c0: 092f 2f20 7468 6520 6e65 7720 7765 6220 .// the new web │ │ │ +0000a6d0: 7365 6564 2077 6527 7265 2061 6464 696e seed we're addin │ │ │ +0000a6e0: 6720 6f6e 6c79 2068 6173 2074 6869 7320 g only has this │ │ │ +0000a6f0: 6669 6c65 2066 6f72 206e 6f77 0a3c 2f70 file for now.

    re │ │ │ +0000a730: 6c65 7661 6e63 6526 6e62 7370 3b33 3c2f levance 3../src/pe │ │ │ +0000a770: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ +0000a780: 703a 3331 3237 3c2f 613e 3c2f 7464 3e3c p:3127< │ │ │ +0000a790: 7464 3e69 6e73 7465 6164 206f 6620 6861 td>instead of ha │ │ │ +0000a7a0: 7669 6e67 2074 6f20 6173 6b20 7468 6520 ving to ask the │ │ │ +0000a7b0: 746f 7272 656e 7420 7768 6574 6865 7220 torrent whether │ │ │ +0000a7c0: 6974 2773 2069 6e20 6772 6163 6566 756c it's in graceful │ │ │ +0000a7d0: 2070 6175 7365 206d 6f64 6520 6f72 206e pause mode or n │ │ │ +0000a7e0: 6f74 2c20 7468 6520 7065 6572 7320 7368 ot, the peers sh │ │ │ +0000a7f0: 6f75 6c64 206b 6565 7020 7468 6174 2073 ould keep that s │ │ │ +0000a800: 7461 7465 2028 616e 6420 7468 6520 746f tate (and the to │ │ │ +0000a810: 7272 656e 7420 7368 6f75 6c64 2075 7064 rrent should upd │ │ │ +0000a820: 6174 6520 7468 656d 2077 6865 6e20 6974 ate them when it │ │ │ +0000a830: 2065 6e74 6572 7320 6772 6163 6566 756c enters graceful │ │ │ +0000a840: 2070 6175 7365 292e 2057 6865 6e20 6120 pause). When a │ │ │ +0000a850: 7065 6572 2065 6e74 6572 7320 6772 6163 peer enters grac │ │ │ +0000a860: 6566 756c 2070 6175 7365 206d 6f64 652c eful pause mode, │ │ │ +0000a870: 2069 7420 7368 6f75 6c64 2063 616e 6365 it should cance │ │ │ +0000a880: 6c20 616c 6c20 6f75 7473 7461 6e64 696e l all outstandin │ │ │ +0000a890: 6720 7265 7175 6573 7473 2061 6e64 2063 g requests and c │ │ │ +0000a8a0: 6c65 6172 2069 7473 2072 6571 7565 7374 lear its request │ │ │ +0000a8b0: 2071 7565 7565 2e3c 2f74 643e 3c2f 7472 queue. │ │ │ +0000a8f0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0000a900: 3c68 323e 696e 7374 6561 6420 6f66 2068

    instead of h │ │ │ +0000a910: 6176 696e 6720 746f 2061 736b 2074 6865 aving to ask the │ │ │ +0000a920: 2074 6f72 7265 6e74 2077 6865 7468 6572 torrent whether │ │ │ +0000a930: 2069 7427 7320 696e 2067 7261 6365 6675 it's in gracefu │ │ │ +0000a940: 6c0a 7061 7573 6520 6d6f 6465 206f 7220 l.pause mode or │ │ │ +0000a950: 6e6f 742c 2074 6865 2070 6565 7273 2073 not, the peers s │ │ │ +0000a960: 686f 756c 6420 6b65 6570 2074 6861 7420 hould keep that │ │ │ +0000a970: 7374 6174 6520 2861 6e64 2074 6865 2074 state (and the t │ │ │ +0000a980: 6f72 7265 6e74 0a73 686f 756c 6420 7570 orrent.should up │ │ │ +0000a990: 6461 7465 2074 6865 6d20 7768 656e 2069 date them when i │ │ │ +0000a9a0: 7420 656e 7465 7273 2067 7261 6365 6675 t enters gracefu │ │ │ +0000a9b0: 6c20 7061 7573 6529 2e20 5768 656e 2061 l pause). When a │ │ │ +0000a9c0: 2070 6565 7220 656e 7465 7273 0a67 7261 peer enters.gra │ │ │ +0000a9d0: 6365 6675 6c20 7061 7573 6520 6d6f 6465 ceful pause mode │ │ │ +0000a9e0: 2c20 6974 2073 686f 756c 6420 6361 6e63 , it should canc │ │ │ +0000a9f0: 656c 2061 6c6c 206f 7574 7374 616e 6469 el all outstandi │ │ │ +0000aa00: 6e67 2072 6571 7565 7374 7320 616e 640a ng requests and. │ │ │ +0000aa10: 636c 6561 7220 6974 7320 7265 7175 6573 clear its reques │ │ │ +0000aa20: 7420 7175 6575 652e 3c2f 6832 3e3c 6834 t queue.

    ../src/peer_con │ │ │ +0000aa40: 6e65 6374 696f 6e2e 6370 703a 3331 3237 nection.cpp:3127 │ │ │ +0000aa50: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0000aa90: 092f 2f20 746f 2064 6973 6b20 6f72 2061  .// to disk or a
    │ │ │ +0000aaa0: 7265 2069 6e20 7468 6520 6469 736b 2077  re in the disk w
    │ │ │ +0000aab0: 7269 7465 2063 6163 6865 0a09 0969 6620  rite cache...if 
    │ │ │ +0000aac0: 2870 6963 6b65 722e 6973 5f70 6965 6365  (picker.is_piece
    │ │ │ +0000aad0: 5f66 696e 6973 6865 6428 702e 7069 6563  _finished(p.piec
    │ │ │ +0000aae0: 6529 2026 616d 703b 2661 6d70 3b20 2177  e) && !w
    │ │ │ +0000aaf0: 6173 5f66 696e 6973 6865 6429 0a09 097b  as_finished)...{
    │ │ │ +0000ab00: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +0000ab10: 5f49 4e56 4152 4941 4e54 5f43 4845 434b  _INVARIANT_CHECK
    │ │ │ +0000ab20: 530a 0909 0963 6865 636b 5f70 6f73 7463  S....check_postc
    │ │ │ +0000ab30: 6f6e 6469 7469 6f6e 2070 6f73 745f 6368  ondition post_ch
    │ │ │ +0000ab40: 6563 6b65 7232 5f28 742c 2066 616c 7365  ecker2_(t, false
    │ │ │ +0000ab50: 293b 0a23 656e 6469 660a 0909 0974 2d26  );.#endif....t-&
    │ │ │ +0000ab60: 6774 3b76 6572 6966 795f 7069 6563 6528  gt;verify_piece(
    │ │ │ +0000ab70: 702e 7069 6563 6529 3b0a 0909 7d0a 0a09  p.piece);...}...
    │ │ │ +0000ab80: 0963 6865 636b 5f67 7261 6365 6675 6c5f  .check_graceful_
    │ │ │ +0000ab90: 7061 7573 6528 293b 0a0a 0909 6966 2028  pause();....if (
    │ │ │ +0000aba0: 6973 5f64 6973 636f 6e6e 6563 7469 6e67  is_disconnecting
    │ │ │ +0000abb0: 2829 2920 7265 7475 726e 3b0a 0a09 0969  ()) return;....i
    │ │ │ +0000abc0: 6620 2872 6571 7565 7374 5f61 5f62 6c6f  f (request_a_blo
    │ │ │ +0000abd0: 636b 282a 742c 202a 7468 6973 2929 0a09  ck(*t, *this))..
    │ │ │ +0000abe0: 0909 6d5f 636f 756e 7465 7273 2e69 6e63  ..m_counters.inc
    │ │ │ +0000abf0: 5f73 7461 7473 5f63 6f75 6e74 6572 2863  _stats_counter(c
    │ │ │ +0000ac00: 6f75 6e74 6572 733a 3a69 6e63 6f6d 696e  ounters::incomin
    │ │ │ +0000ac10: 675f 7069 6563 655f 7069 636b 7329 3b0a  g_piece_picks);.
    │ │ │ +0000ac20: 0909 7365 6e64 5f62 6c6f 636b 5f72 6571  ..send_block_req
    │ │ │ +0000ac30: 7565 7374 7328 293b 0a09 7d0a 0a09 766f  uests();..}...vo
    │ │ │ +0000ac40: 6964 2070 6565 725f 636f 6e6e 6563 7469  id peer_connecti
    │ │ │ +0000ac50: 6f6e 3a3a 6368 6563 6b5f 6772 6163 6566  on::check_gracef
    │ │ │ +0000ac60: 756c 5f70 6175 7365 2829 0a09 7b0a 3c64  ul_pause()..{...au
    │ │ │ +0000aca0: 746f 2074 203d 206d 5f74 6f72 7265 6e74  to t = m_torrent
    │ │ │ +0000acb0: 2e6c 6f63 6b28 293b 0a3c 2f64 6976 3e09  .lock();.
    . │ │ │ +0000acc0: 0969 6620 2821 7420 7c7c 2021 742d 2667 .if (!t || !t-&g │ │ │ +0000acd0: 743b 6772 6163 6566 756c 5f70 6175 7365 t;graceful_pause │ │ │ +0000ace0: 2829 2920 7265 7475 726e 3b0a 0a09 0969 ()) return;....i │ │ │ +0000acf0: 6620 286d 5f6f 7574 7374 616e 6469 6e67 f (m_outstanding │ │ │ +0000ad00: 5f62 7974 6573 2026 6774 3b20 3029 2072 _bytes > 0) r │ │ │ +0000ad10: 6574 7572 6e3b 0a0a 2369 666e 6465 6620 eturn;..#ifndef │ │ │ +0000ad20: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +0000ad30: 4c4f 4747 494e 470a 0909 7065 6572 5f6c LOGGING...peer_l │ │ │ +0000ad40: 6f67 2870 6565 725f 6c6f 675f 616c 6572 og(peer_log_aler │ │ │ +0000ad50: 743a 3a69 6e66 6f2c 2070 6565 725f 6c6f t::info, peer_lo │ │ │ +0000ad60: 675f 616c 6572 743a 3a67 7261 6365 6675 g_alert::gracefu │ │ │ +0000ad70: 6c5f 7061 7573 652c 2022 4e4f 204d 4f52 l_pause, "NO MOR │ │ │ +0000ad80: 4520 444f 574e 4c4f 4144 2229 3b0a 2365 E DOWNLOAD");.#e │ │ │ +0000ad90: 6e64 6966 0a09 0964 6973 636f 6e6e 6563 ndif...disconnec │ │ │ +0000ada0: 7428 6572 726f 7273 3a3a 746f 7272 656e t(errors::torren │ │ │ +0000adb0: 745f 7061 7573 6564 2c20 6f70 6572 6174 t_paused, operat │ │ │ +0000adc0: 696f 6e5f 743a 3a62 6974 746f 7272 656e ion_t::bittorren │ │ │ +0000add0: 7429 3b0a 097d 0a0a 0976 6f69 6420 7065 t);..}...void pe │ │ │ +0000ade0: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a6f er_connection::o │ │ │ +0000adf0: 6e5f 6469 736b 5f77 7269 7465 5f63 6f6d n_disk_write_com │ │ │ +0000ae00: 706c 6574 6528 7374 6f72 6167 655f 6572 plete(storage_er │ │ │ +0000ae10: 726f 7220 636f 6e73 7426 616d 703b 2065 ror const& e │ │ │ +0000ae20: 7272 6f72 0a09 092c 2070 6565 725f 7265 rror..., peer_re │ │ │ +0000ae30: 7175 6573 7420 636f 6e73 7426 616d 703b quest const& │ │ │ +0000ae40: 2070 2c20 7374 643a 3a73 6861 7265 645f p, std::shared_ │ │ │ +0000ae50: 7074 7226 6c74 3b61 7578 3a3a 746f 7272 ptr<aux::torr │ │ │ +0000ae60: 656e 7426 6774 3b20 7429 0a09 7b0a 0909 ent> t)..{... │ │ │ +0000ae70: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ +0000ae80: 735f 7369 6e67 6c65 5f74 6872 6561 6428 s_single_thread( │ │ │ +0000ae90: 2929 3b0a 2369 666e 6465 6620 544f 5252 ));.#ifndef TORR │ │ │ +0000aea0: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ +0000aeb0: 494e 470a 0909 6966 2028 7368 6f75 6c64 ING...if (should │ │ │ +0000aec0: 5f6c 6f67 2870 6565 725f 6c6f 675f 616c _log(peer_log_al │ │ │ +0000aed0: 6572 743a 3a69 6e66 6f29 290a 0909 7b0a ert::info))...{. │ │ │ +0000aee0: 0909 0970 6565 725f 6c6f 6728 7065 6572 ...peer_log(peer │ │ │ +0000aef0: 5f6c 6f67 5f61 6c65 7274 3a3a 696e 666f _log_alert::info │ │ │ +0000af00: 2c20 7065 6572 5f6c 6f67 5f61 6c65 7274 , peer_log_alert │ │ │ +0000af10: 3a3a 6669 6c65 5f61 7379 6e63 5f77 7269 ::file_async_wri │ │ │ +0000af20: 7465 5f63 6f6d 706c 6574 652c 2022 7069 te_complete, "pi │ │ │ +0000af30: 6563 653a 2025 6420 733a 2025 7820 6c3a ece: %d s: %x l: │ │ │ +0000af40: 2025 7820 653a 2025 7322 0a09 0909 092c %x e: %s"....., │ │ │ +0000af50: 2073 7461 7469 635f 6361 7374 266c 743b static_cast< │ │ │ +0000af60: 696e 7426 6774 3b28 702e 7069 6563 6529 int>(p.piece) │ │ │ +0000af70: 2c20 7374 643a 3a75 696e 7433 325f 7428 , std::uint32_t( │ │ │ +0000af80: 702e 7374 6172 7429 2c20 7374 643a 3a75 p.start), std::u │ │ │ +0000af90: 696e 7433 325f 7428 702e 6c65 6e67 7468 int32_t(p.length │ │ │ +0000afa0: 292c 2065 7272 6f72 2e65 632e 6d65 7373 ), error.ec.mess │ │ │ +0000afb0: 6167 6528 292e 635f 7374 7228 2929 3b0a age().c_str());. │ │ │ +0000afc0: 0909 7d0a 2365 6e64 6966 0a0a 0909 6d5f ..}.#endif....m_ │ │ │ +0000afd0: 636f 756e 7465 7273 2e69 6e63 5f73 7461 counters.inc_sta │ │ │ +0000afe0: 7473 5f63 6f75 6e74 6572 2863 6f75 6e74 ts_counter(count │ │ │ +0000aff0: 6572 733a 3a71 7565 7565 645f 7772 6974 ers::queued_writ │ │ │ +0000b000: 655f 6279 7465 732c 202d 702e 6c65 6e67 e_bytes, -p.leng │ │ │ +0000b010: 7468 293b 0a09 096d 5f6f 7574 7374 616e th);...m_outstan │ │ │ +0000b020: 6469 6e67 5f77 7269 7469 6e67 5f62 7974 ding_writing_byt │ │ │ +0000b030: 6573 202d 3d20 702e 6c65 6e67 7468 3b0a es -= p.length;. │ │ │ +0000b040: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0000b050: 5428 6d5f 6f75 7473 7461 6e64 696e 675f T(m_outstanding_ │ │ │ +0000b060: 7772 6974 696e 675f 6279 7465 7320 2667 writing_bytes &g │ │ │ +0000b070: 743b 3d20 3029 3b0a 0a09 092f 2f20 6576 t;= 0);....// ev │ │ │ +0000b080: 6572 7920 7065 6572 2069 7320 656e 7469 ery peer is enti │ │ │ +0000b090: 746c 6564 2074 6f20 616c 6c6f 6361 7465 tled to allocate │ │ │ +0000b0a0: 2061 2064 6973 6b20 6275 6666 6572 2069 a disk buffer i │ │ │ +0000b0b0: 6620 6974 2068 6173 206e 6f20 7772 6974 f it has no writ │ │ │ +0000b0c0: 6573 206f 7574 7374 616e 6469 6e67 0a09 es outstanding.. │ │ │ +0000b0d0: 092f 2f20 7365 6520 7468 6520 636f 6d6d .// see the comm │ │ │ +0000b0e0: 656e 7420 696e 2069 6e63 6f6d 696e 675f ent in incoming_ │ │ │ +0000b0f0: 7069 6563 650a 0909 6966 2028 6d5f 6f75 piece...if (m_ou │ │ │ +0000b100: 7473 7461 6e64 696e 675f 7772 6974 696e tstanding_writin │ │ │ +0000b110: 675f 6279 7465 7320 3d3d 2030 0a3c 2f70 g_bytes == 0.

    re │ │ │ +0000b150: 6c65 7661 6e63 6526 6e62 7370 3b33 3c2f levance 3../src/pe │ │ │ +0000b190: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ +0000b1a0: 703a 3430 3232 3c2f 613e 3c2f 7464 3e3c p:4022< │ │ │ +0000b1b0: 7464 3e6f 6e63 6520 7065 6572 7320 6172 td>once peers ar │ │ │ +0000b1c0: 6520 7072 6f70 6572 6c79 2070 7574 2069 e properly put i │ │ │ +0000b1d0: 6e20 6772 6163 6566 756c 2070 6175 7365 n graceful pause │ │ │ +0000b1e0: 206d 6f64 652c 2074 6865 7920 6361 6e20 mode, they can │ │ │ +0000b1f0: 6361 6e63 656c 2061 6c6c 206f 7574 7374 cancel all outst │ │ │ +0000b200: 616e 6469 6e67 2072 6571 7565 7374 7320 anding requests │ │ │ +0000b210: 616e 6420 7468 6973 2074 6573 7420 6361 and this test ca │ │ │ +0000b220: 6e20 6265 2072 656d 6f76 6564 2e3c 2f74 n be removed.

    once p │ │ │ +0000b280: 6565 7273 2061 7265 2070 726f 7065 726c eers are properl │ │ │ +0000b290: 7920 7075 7420 696e 2067 7261 6365 6675 y put in gracefu │ │ │ +0000b2a0: 6c20 7061 7573 6520 6d6f 6465 2c20 7468 l pause mode, th │ │ │ +0000b2b0: 6579 2063 616e 0a63 616e 6365 6c20 616c ey can.cancel al │ │ │ +0000b2c0: 6c20 6f75 7473 7461 6e64 696e 6720 7265 l outstanding re │ │ │ +0000b2d0: 7175 6573 7473 2061 6e64 2074 6869 7320 quests and this │ │ │ +0000b2e0: 7465 7374 2063 616e 2062 6520 7265 6d6f test can be remo │ │ │ +0000b2f0: 7665 642e 3c2f 6832 3e3c 6834 3e2e 2e2f ved.

    ../ │ │ │ +0000b300: 7372 632f 7065 6572 5f63 6f6e 6e65 6374 src/peer_connect │ │ │ +0000b310: 696f 6e2e 6370 703a 3430 3232 3c2f 6834 ion.cpp:4022

    ....i
    │ │ │ +0000b360: 6620 2821 702d 2667 743b 6d5f 6465 6665  f (!p->m_defe
    │ │ │ +0000b370: 7272 6564 5f73 656e 645f 626c 6f63 6b5f  rred_send_block_
    │ │ │ +0000b380: 7265 7175 6573 7473 290a 0909 0909 7265  requests).....re
    │ │ │ +0000b390: 7475 726e 3b0a 0a09 0909 702d 2667 743b  turn;.....p->
    │ │ │ +0000b3a0: 6d5f 6465 6665 7272 6564 5f73 656e 645f  m_deferred_send_
    │ │ │ +0000b3b0: 626c 6f63 6b5f 7265 7175 6573 7473 203d  block_requests =
    │ │ │ +0000b3c0: 2066 616c 7365 3b0a 0909 0970 2d26 6774   false;....p->
    │ │ │ +0000b3d0: 3b73 656e 645f 626c 6f63 6b5f 7265 7175  ;send_block_requ
    │ │ │ +0000b3e0: 6573 7473 5f69 6d70 6c28 293b 0a09 097d  ests_impl();...}
    │ │ │ +0000b3f0: 293b 0a09 096d 5f64 6566 6572 7265 645f  );...m_deferred_
    │ │ │ +0000b400: 7365 6e64 5f62 6c6f 636b 5f72 6571 7565  send_block_reque
    │ │ │ +0000b410: 7374 7320 3d20 7472 7565 3b0a 097d 0a0a  sts = true;..}..
    │ │ │ +0000b420: 0976 6f69 6420 7065 6572 5f63 6f6e 6e65  .void peer_conne
    │ │ │ +0000b430: 6374 696f 6e3a 3a73 656e 645f 626c 6f63  ction::send_bloc
    │ │ │ +0000b440: 6b5f 7265 7175 6573 7473 5f69 6d70 6c28  k_requests_impl(
    │ │ │ +0000b450: 290a 097b 0a09 0954 4f52 5245 4e54 5f41  )..{...TORRENT_A
    │ │ │ +0000b460: 5353 4552 5428 6973 5f73 696e 676c 655f  SSERT(is_single_
    │ │ │ +0000b470: 7468 7265 6164 2829 293b 0a09 0949 4e56  thread());...INV
    │ │ │ +0000b480: 4152 4941 4e54 5f43 4845 434b 3b0a 0a09  ARIANT_CHECK;...
    │ │ │ +0000b490: 0961 7574 6f20 7420 3d20 6d5f 746f 7272  .auto t = m_torr
    │ │ │ +0000b4a0: 656e 742e 6c6f 636b 2829 3b0a 0909 6966  ent.lock();...if
    │ │ │ +0000b4b0: 2028 2174 2920 7265 7475 726e 3b0a 0a09   (!t) return;...
    │ │ │ +0000b4c0: 0969 6620 286d 5f64 6973 636f 6e6e 6563  .if (m_disconnec
    │ │ │ +0000b4d0: 7469 6e67 2920 7265 7475 726e 3b0a 0a3c  ting) return;..<
    │ │ │ +0000b4e0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +0000b4f0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +0000b500: 7769 6474 683d 2231 3030 2522 3e09 0969  width="100%">..i
    │ │ │ +0000b510: 6620 2874 2d26 6774 3b67 7261 6365 6675  f (t->gracefu
    │ │ │ +0000b520: 6c5f 7061 7573 6528 2929 2072 6574 7572  l_pause()) retur
    │ │ │ +0000b530: 6e3b 0a3c 2f64 6976 3e0a 0909 2f2f 2077  n;.

    ...// w │ │ │ +0000b540: 6520 6361 6e27 7420 646f 776e 6c6f 6164 e can't download │ │ │ +0000b550: 2070 6965 6365 7320 696e 2074 6865 7365 pieces in these │ │ │ +0000b560: 2073 7461 7465 730a 0909 6966 2028 742d states...if (t- │ │ │ +0000b570: 2667 743b 7374 6174 6528 2920 3d3d 2074 >state() == t │ │ │ +0000b580: 6f72 7265 6e74 5f73 7461 7475 733a 3a63 orrent_status::c │ │ │ +0000b590: 6865 636b 696e 675f 6669 6c65 730a 0909 hecking_files... │ │ │ +0000b5a0: 097c 7c20 742d 2667 743b 7374 6174 6528 .|| t->state( │ │ │ +0000b5b0: 2920 3d3d 2074 6f72 7265 6e74 5f73 7461 ) == torrent_sta │ │ │ +0000b5c0: 7475 733a 3a63 6865 636b 696e 675f 7265 tus::checking_re │ │ │ +0000b5d0: 7375 6d65 5f64 6174 610a 0909 097c 7c20 sume_data....|| │ │ │ +0000b5e0: 742d 2667 743b 7374 6174 6528 2920 3d3d t->state() == │ │ │ +0000b5f0: 2074 6f72 7265 6e74 5f73 7461 7475 733a torrent_status: │ │ │ +0000b600: 3a64 6f77 6e6c 6f61 6469 6e67 5f6d 6574 :downloading_met │ │ │ +0000b610: 6164 6174 6129 0a09 0909 7265 7475 726e adata)....return │ │ │ +0000b620: 3b0a 0a09 0969 6620 2869 6e74 286d 5f64 ;....if (int(m_d │ │ │ +0000b630: 6f77 6e6c 6f61 645f 7175 6575 652e 7369 ownload_queue.si │ │ │ +0000b640: 7a65 2829 2920 2667 743b 3d20 6d5f 6465 ze()) >= m_de │ │ │ +0000b650: 7369 7265 645f 7175 6575 655f 7369 7a65 sired_queue_size │ │ │ +0000b660: 0a09 0909 7c7c 2074 2d26 6774 3b75 706c ....|| t->upl │ │ │ +0000b670: 6f61 645f 6d6f 6465 2829 2920 7265 7475 oad_mode()) retu │ │ │ +0000b680: 726e 3b0a 0a09 0962 6f6f 6c20 636f 6e73 rn;....bool cons │ │ │ +0000b690: 7420 656d 7074 795f 646f 776e 6c6f 6164 t empty_download │ │ │ +0000b6a0: 5f71 7565 7565 203d 206d 5f64 6f77 6e6c _queue = m_downl │ │ │ +0000b6b0: 6f61 645f 7175 6575 652e 656d 7074 7928 oad_queue.empty( │ │ │ +0000b6c0: 293b 0a0a 0909 7768 696c 6520 2821 6d5f );....while (!m_ │ │ │ +0000b6d0: 7265 7175 6573 745f 7175 6575 652e 656d request_queue.em │ │ │ +0000b6e0: 7074 7928 290a 0909 0926 616d 703b 2661 pty()....&&a │ │ │ +0000b6f0: 6d70 3b20 2869 6e74 286d 5f64 6f77 6e6c mp; (int(m_downl │ │ │ +0000b700: 6f61 645f 7175 6575 652e 7369 7a65 2829 oad_queue.size() │ │ │ +0000b710: 2920 266c 743b 206d 5f64 6573 6972 6564 ) < m_desired │ │ │ +0000b720: 5f71 7565 7565 5f73 697a 650a 0909 0909 _queue_size..... │ │ │ +0000b730: 7c7c 206d 5f71 7565 7565 645f 7469 6d65 || m_queued_time │ │ │ +0000b740: 5f63 7269 7469 6361 6c20 2667 743b 2030 _critical > 0 │ │ │ +0000b750: 2929 0a09 097b 0a09 0909 7065 6e64 696e ))...{....pendin │ │ │ +0000b760: 675f 626c 6f63 6b20 626c 6f63 6b20 3d20 g_block block = │ │ │ +0000b770: 6d5f 7265 7175 6573 745f 7175 6575 652e m_request_queue. │ │ │ +0000b780: 6672 6f6e 7428 293b 0a0a 0909 096d 5f72 front();.....m_r │ │ │ +0000b790: 6571 7565 7374 5f71 7565 7565 2e65 7261 equest_queue.era │ │ │ +0000b7a0: 7365 286d 5f72 6571 7565 7374 5f71 7565 se(m_request_que │ │ │ +0000b7b0: 7565 2e62 6567 696e 2829 293b 0a09 0909 ue.begin());.... │ │ │ +0000b7c0: 6966 2028 6d5f 7175 6575 6564 5f74 696d if (m_queued_tim │ │ │ +0000b7d0: 655f 6372 6974 6963 616c 2920 2d2d 6d5f e_critical) --m_ │ │ │ +0000b7e0: 7175 6575 6564 5f74 696d 655f 6372 6974 queued_time_crit │ │ │ +0000b7f0: 6963 616c 3b0a 0a09 0909 2f2f 2069 6620 ical;.....// if │ │ │ +0000b800: 7765 2772 6520 6120 7365 6564 2c20 7765 we're a seed, we │ │ │ +0000b810: 2064 6f6e 2774 2068 6176 6520 6120 7069 don't have a pi │ │ │ +0000b820: 6563 6520 7069 636b 6572 0a09 0909 2f2f ece picker....// │ │ │ +0000b830: 2073 6f20 7765 2064 6f6e 2774 2068 6176 so we don't hav │ │ │ +0000b840: 6520 746f 2077 6f72 7279 2061 626f 7574 e to worry about │ │ │ +0000b850: 2069 6e76 6172 6961 6e74 7320 6765 7474 invariants gett │ │ │ +0000b860: 696e 670a 0909 092f 2f20 6f75 7420 6f66 ing....// out of │ │ │ +0000b870: 2073 796e 6320 7769 7468 2069 740a 0909 sync with it... │ │ │ +0000b880: 0969 6620 2821 742d 2667 743b 6861 735f .if (!t->has_ │ │ │ +0000b890: 7069 636b 6572 2829 2920 636f 6e74 696e picker()) contin │ │ │ +0000b8a0: 7565 3b0a 0a09 0909 2f2f 2074 6869 7320 ue;.....// this │ │ │ +0000b8b0: 6361 6e20 6861 7070 656e 2069 6620 6120 can happen if a │ │ │ +0000b8c0: 626c 6f63 6b20 7469 6d65 7320 6f75 742c block times out, │ │ │ +0000b8d0: 2069 7320 7265 2d72 6571 7565 7374 6564 is re-requested │ │ │ +0000b8e0: 2061 6e64 0a09 0909 2f2f 2074 6865 6e20 and....// then │ │ │ +0000b8f0: 6172 7269 7665 7320 2275 6e65 7870 6563 arrives "unexpec │ │ │ +0000b900: 7465 646c 7922 0a09 0909 6966 2028 742d tedly"....if (t- │ │ │ +0000b910: 2667 743b 7069 636b 6572 2829 2e69 735f >picker().is_ │ │ │ +0000b920: 646f 776e 6c6f 6164 6564 2862 6c6f 636b downloaded(block │ │ │ +0000b930: 2e62 6c6f 636b 2929 0a09 0909 7b0a 3c2f .block))....{.r │ │ │ +0000b970: 656c 6576 616e 6365 266e 6273 703b 333c elevance 3< │ │ │ +0000b980: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/p │ │ │ +0000b9b0: 6565 725f 636f 6e6e 6563 7469 6f6e 2e63 eer_connection.c │ │ │ +0000b9c0: 7070 3a34 3730 333c 2f61 3e3c 2f74 643e pp:4703 │ │ │ +0000b9d0: 3c74 643e 6e65 775f 7069 6563 6520 7368 new_piece sh │ │ │ +0000b9e0: 6f75 6c64 2062 6520 616e 206f 7074 696f ould be an optio │ │ │ +0000b9f0: 6e61 6c3c 7069 6563 655f 696e 6465 785f nal. piece index │ │ │ +0000ba10: 2d31 2073 686f 756c 6420 6e6f 7420 6265 -1 should not be │ │ │ +0000ba20: 2061 6c6c 6f77 6564 3c2f 7464 3e3c 2f74 allowed

    new_piece s │ │ │ +0000ba80: 686f 756c 6420 6265 2061 6e20 6f70 7469 hould be an opti │ │ │ +0000ba90: 6f6e 616c 3c70 6965 6365 5f69 6e64 6578 onal. piece index │ │ │ +0000bab0: 202d 310a 7368 6f75 6c64 206e 6f74 2062 -1.should not b │ │ │ +0000bac0: 6520 616c 6c6f 7765 643c 2f68 323e 3c68 e allowed

    ../src/peer_co │ │ │ +0000bae0: 6e6e 6563 7469 6f6e 2e63 7070 3a34 3730 nnection.cpp:470 │ │ │ +0000baf0: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3
    │ │ │ +0000bb30: 0a09 092f 2f20 7069 6563 6573 206d 6179  ...// pieces may
    │ │ │ +0000bb40: 2062 6520 656d 7074 7920 6966 2077 6520   be empty if we 
    │ │ │ +0000bb50: 646f 6e27 7420 6861 7665 206d 6574 6164  don't have metad
    │ │ │ +0000bb60: 6174 6120 7965 740a 0909 6966 2028 702e  ata yet...if (p.
    │ │ │ +0000bb70: 7069 6563 6573 2e65 6d70 7479 2829 290a  pieces.empty()).
    │ │ │ +0000bb80: 0909 7b0a 0909 0970 2e70 726f 6772 6573  ..{....p.progres
    │ │ │ +0000bb90: 7320 3d20 302e 663b 0a09 0909 702e 7072  s = 0.f;....p.pr
    │ │ │ +0000bba0: 6f67 7265 7373 5f70 706d 203d 2030 3b0a  ogress_ppm = 0;.
    │ │ │ +0000bbb0: 0909 7d0a 0909 656c 7365 0a09 097b 0a23  ..}...else...{.#
    │ │ │ +0000bbc0: 6966 2054 4f52 5245 4e54 5f4e 4f5f 4650  if TORRENT_NO_FP
    │ │ │ +0000bbd0: 550a 0909 0970 2e70 726f 6772 6573 7320  U....p.progress 
    │ │ │ +0000bbe0: 3d20 302e 663b 0a23 656c 7365 0a09 0909  = 0.f;.#else....
    │ │ │ +0000bbf0: 702e 7072 6f67 7265 7373 203d 2066 6c6f  p.progress = flo
    │ │ │ +0000bc00: 6174 2870 2e70 6965 6365 732e 636f 756e  at(p.pieces.coun
    │ │ │ +0000bc10: 7428 2929 202f 2066 6c6f 6174 2870 2e70  t()) / float(p.p
    │ │ │ +0000bc20: 6965 6365 732e 7369 7a65 2829 293b 0a23  ieces.size());.#
    │ │ │ +0000bc30: 656e 6469 660a 0909 0970 2e70 726f 6772  endif....p.progr
    │ │ │ +0000bc40: 6573 735f 7070 6d20 3d20 696e 7428 7374  ess_ppm = int(st
    │ │ │ +0000bc50: 643a 3a69 6e74 3634 5f74 2870 2e70 6965  d::int64_t(p.pie
    │ │ │ +0000bc60: 6365 732e 636f 756e 7428 2929 202a 2031  ces.count()) * 1
    │ │ │ +0000bc70: 3030 3030 3030 202f 2070 2e70 6965 6365  000000 / p.piece
    │ │ │ +0000bc80: 732e 7369 7a65 2829 293b 0a09 097d 0a0a  s.size());...}..
    │ │ │ +0000bc90: 097d 0a0a 2369 666e 6465 6620 544f 5252  .}..#ifndef TORR
    │ │ │ +0000bca0: 454e 545f 4449 5341 424c 455f 5355 5045  ENT_DISABLE_SUPE
    │ │ │ +0000bcb0: 5253 4545 4449 4e47 0a3c 6469 7620 7374  RSEEDING.
    .void pee │ │ │ +0000bcf0: 725f 636f 6e6e 6563 7469 6f6e 3a3a 7375 r_connection::su │ │ │ +0000bd00: 7065 7273 6565 645f 7069 6563 6528 7069 perseed_piece(pi │ │ │ +0000bd10: 6563 655f 696e 6465 785f 7420 636f 6e73 ece_index_t cons │ │ │ +0000bd20: 7420 7265 706c 6163 655f 7069 6563 650a t replace_piece. │ │ │ +0000bd30: 3c2f 6469 763e 0909 2c20 7069 6563 655f
    .., piece_ │ │ │ +0000bd40: 696e 6465 785f 7420 636f 6e73 7420 6e65 index_t const ne │ │ │ +0000bd50: 775f 7069 6563 6529 0a09 7b0a 0909 544f w_piece)..{...TO │ │ │ +0000bd60: 5252 454e 545f 4153 5345 5254 2869 735f RRENT_ASSERT(is_ │ │ │ +0000bd70: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ +0000bd80: 3b0a 0a09 0969 6620 2869 735f 636f 6e6e ;....if (is_conn │ │ │ +0000bd90: 6563 7469 6e67 2829 2920 7265 7475 726e ecting()) return │ │ │ +0000bda0: 3b0a 0909 6966 2028 696e 5f68 616e 6473 ;...if (in_hands │ │ │ +0000bdb0: 6861 6b65 2829 2920 7265 7475 726e 3b0a hake()) return;. │ │ │ +0000bdc0: 0a09 0969 6620 286e 6577 5f70 6965 6365 ...if (new_piece │ │ │ +0000bdd0: 203d 3d20 7069 6563 655f 696e 6465 785f == piece_index_ │ │ │ +0000bde0: 7428 2d31 2929 0a09 097b 0a09 0909 6966 t(-1))...{....if │ │ │ +0000bdf0: 2028 6d5f 7375 7065 7273 6565 645f 7069 (m_superseed_pi │ │ │ +0000be00: 6563 655b 305d 203d 3d20 7069 6563 655f ece[0] == piece_ │ │ │ +0000be10: 696e 6465 785f 7428 2d31 2929 2072 6574 index_t(-1)) ret │ │ │ +0000be20: 7572 6e3b 0a09 0909 6d5f 7375 7065 7273 urn;....m_supers │ │ │ +0000be30: 6565 645f 7069 6563 655b 305d 203d 2070 eed_piece[0] = p │ │ │ +0000be40: 6965 6365 5f69 6e64 6578 5f74 282d 3129 iece_index_t(-1) │ │ │ +0000be50: 3b0a 0909 096d 5f73 7570 6572 7365 6564 ;....m_superseed │ │ │ +0000be60: 5f70 6965 6365 5b31 5d20 3d20 7069 6563 _piece[1] = piec │ │ │ +0000be70: 655f 696e 6465 785f 7428 2d31 293b 0a0a e_index_t(-1);.. │ │ │ +0000be80: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +0000be90: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ +0000bea0: 0909 0970 6565 725f 6c6f 6728 7065 6572 ...peer_log(peer │ │ │ +0000beb0: 5f6c 6f67 5f61 6c65 7274 3a3a 696e 666f _log_alert::info │ │ │ +0000bec0: 2c20 7065 6572 5f6c 6f67 5f61 6c65 7274 , peer_log_alert │ │ │ +0000bed0: 3a3a 7375 7065 725f 7365 6564 696e 672c ::super_seeding, │ │ │ +0000bee0: 2022 656e 6469 6e67 2229 3b0a 2365 6e64 "ending");.#end │ │ │ +0000bef0: 6966 0a09 0909 6175 746f 2074 203d 206d if....auto t = m │ │ │ +0000bf00: 5f74 6f72 7265 6e74 2e6c 6f63 6b28 293b _torrent.lock(); │ │ │ +0000bf10: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +0000bf20: 5254 2874 293b 0a0a 0909 092f 2f20 7468 RT(t);.....// th │ │ │ +0000bf30: 6973 2077 696c 6c20 6569 7468 6572 2073 is will either s │ │ │ +0000bf40: 656e 6420 6120 6675 6c6c 2062 6974 6669 end a full bitfi │ │ │ +0000bf50: 656c 6420 6f72 0a09 0909 2f2f 2061 2068 eld or....// a h │ │ │ +0000bf60: 6176 652d 616c 6c20 6d65 7373 6167 652c ave-all message, │ │ │ +0000bf70: 2065 6666 6563 7469 7665 6c79 2074 6572 effectively ter │ │ │ +0000bf80: 6d69 6e61 7469 6e67 0a09 0909 2f2f 2073 minating....// s │ │ │ +0000bf90: 7570 6572 2d73 6565 6469 6e67 2c20 7369 uper-seeding, si │ │ │ +0000bfa0: 6e63 6520 7468 6520 7065 6572 206d 6179 nce the peer may │ │ │ +0000bfb0: 2070 6963 6b20 616e 7920 7069 6563 650a pick any piece. │ │ │ +0000bfc0: 0909 0977 7269 7465 5f62 6974 6669 656c ...write_bitfiel │ │ │ +0000bfd0: 6428 293b 0a0a 0909 0972 6574 7572 6e3b d();.....return; │ │ │ +0000bfe0: 0a09 097d 0a0a 0909 544f 5252 454e 545f ...}....TORRENT_ │ │ │ +0000bff0: 4153 5345 5254 2821 6861 735f 7069 6563 ASSERT(!has_piec │ │ │ +0000c000: 6528 6e65 775f 7069 6563 6529 293b 0a0a e(new_piece));.. │ │ │ +0000c010: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +0000c020: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ +0000c030: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0000c040: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0000c070: 333c 2f74 643e 3c74 643e 3c61 2068 7265 3../src │ │ │ +0000c0a0: 2f74 6f72 7265 6e74 2e63 7070 3a34 3538 /torrent.cpp:458 │ │ │ +0000c0b0: 3c2f 613e 3c2f 7464 3e3c 7464 3e77 6520 we │ │ │ +0000c0c0: 636f 756c 6420 7072 6f62 6162 6c79 2067 could probably g │ │ │ +0000c0d0: 6574 2061 7761 7920 7769 7468 206a 7573 et away with jus │ │ │ +0000c0e0: 7420 7361 7669 6e67 2061 2066 6577 2066 t saving a few f │ │ │ +0000c0f0: 6965 6c64 7320 6865 7265 3c2f 7464 3e3c ields here< │ │ │ +0000c100: 2f74 723e 3c74 7220 6964 3d22 3233 2220 /tr>

    we could │ │ │ +0000c150: 7072 6f62 6162 6c79 2067 6574 2061 7761 probably get awa │ │ │ +0000c160: 7920 7769 7468 206a 7573 7420 7361 7669 y with just savi │ │ │ +0000c170: 6e67 2061 2066 6577 2066 6965 6c64 7320 ng a few fields │ │ │ +0000c180: 6865 7265 3c2f 6832 3e3c 6834 3e2e 2e2f here

    ../ │ │ │ +0000c190: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0000c1a0: 3435 383c 2f68 343e 3c70 7265 2073 7479 458

    ..// --- V2 HA
    │ │ │ +0000c1f0: 5348 4553 202d 2d2d 0a0a 0909 6966 2028  SHES ---....if (
    │ │ │ +0000c200: 6d5f 746f 7272 656e 745f 6669 6c65 2d26  m_torrent_file-&
    │ │ │ +0000c210: 6774 3b69 735f 7661 6c69 6428 2920 2661  gt;is_valid() &a
    │ │ │ +0000c220: 6d70 3b26 616d 703b 206d 5f74 6f72 7265  mp;& m_torre
    │ │ │ +0000c230: 6e74 5f66 696c 652d 2667 743b 696e 666f  nt_file->info
    │ │ │ +0000c240: 5f68 6173 6865 7328 292e 6861 735f 7632  _hashes().has_v2
    │ │ │ +0000c250: 2829 290a 0909 7b0a 0909 0969 6620 2821  ())...{....if (!
    │ │ │ +0000c260: 702e 6d65 726b 6c65 5f74 7265 6573 2e65  p.merkle_trees.e
    │ │ │ +0000c270: 6d70 7479 2829 290a 0909 0909 6c6f 6164  mpty()).....load
    │ │ │ +0000c280: 5f6d 6572 6b6c 655f 7472 6565 7328 0a09  _merkle_trees(..
    │ │ │ +0000c290: 0909 0909 7374 643a 3a6d 6f76 6528 702e  ....std::move(p.
    │ │ │ +0000c2a0: 6d65 726b 6c65 5f74 7265 6573 290a 0909  merkle_trees)...
    │ │ │ +0000c2b0: 0909 092c 2073 7464 3a3a 6d6f 7665 2870  ..., std::move(p
    │ │ │ +0000c2c0: 2e6d 6572 6b6c 655f 7472 6565 5f6d 6173  .merkle_tree_mas
    │ │ │ +0000c2d0: 6b29 0a09 0909 0909 2c20 7374 643a 3a6d  k)......, std::m
    │ │ │ +0000c2e0: 6f76 6528 702e 7665 7269 6669 6564 5f6c  ove(p.verified_l
    │ │ │ +0000c2f0: 6561 665f 6861 7368 6573 2929 3b0a 0a09  eaf_hashes));...
    │ │ │ +0000c300: 0909 2f2f 2077 6520 7265 616c 6c79 2064  ..// we really d
    │ │ │ +0000c310: 6f6e 2774 2077 616e 7420 746f 2073 746f  on't want to sto
    │ │ │ +0000c320: 7265 2065 7874 7261 2063 6f70 6965 7320  re extra copies 
    │ │ │ +0000c330: 6f66 2074 6865 2074 7265 6573 0a09 0909  of the trees....
    │ │ │ +0000c340: 544f 5252 454e 545f 4153 5345 5254 2870  TORRENT_ASSERT(p
    │ │ │ +0000c350: 2e6d 6572 6b6c 655f 7472 6565 732e 656d  .merkle_trees.em
    │ │ │ +0000c360: 7074 7928 2929 3b0a 0909 7d0a 0a09 0969  pty());...}....i
    │ │ │ +0000c370: 6620 2876 616c 6964 5f6d 6574 6164 6174  f (valid_metadat
    │ │ │ +0000c380: 6128 2929 0a09 097b 0a09 0909 696e 635f  a())...{....inc_
    │ │ │ +0000c390: 7374 6174 735f 636f 756e 7465 7228 636f  stats_counter(co
    │ │ │ +0000c3a0: 756e 7465 7273 3a3a 6e75 6d5f 746f 7461  unters::num_tota
    │ │ │ +0000c3b0: 6c5f 7069 6563 6573 5f61 6464 6564 0a09  l_pieces_added..
    │ │ │ +0000c3c0: 0909 092c 206d 5f74 6f72 7265 6e74 5f66  ..., m_torrent_f
    │ │ │ +0000c3d0: 696c 652d 2667 743b 6e75 6d5f 7069 6563  ile->num_piec
    │ │ │ +0000c3e0: 6573 2829 293b 0a09 097d 0a0a 3c64 6976  es());...}..
    ..m_ad │ │ │ +0000c420: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ +0000c430: 203d 2073 7464 3a3a 6d61 6b65 5f75 6e69 = std::make_uni │ │ │ +0000c440: 7175 6526 6c74 3b61 6464 5f74 6f72 7265 que<add_torre │ │ │ +0000c450: 6e74 5f70 6172 616d 7326 6774 3b28 7374 nt_params>(st │ │ │ +0000c460: 643a 3a6d 6f76 6528 7029 293b 0a3c 2f64 d::move(p));..}...void tor │ │ │ +0000c480: 7265 6e74 3a3a 6c6f 6164 5f6d 6572 6b6c rent::load_merkl │ │ │ +0000c490: 655f 7472 6565 7328 0a09 0961 7578 3a3a e_trees(...aux:: │ │ │ +0000c4a0: 7665 6374 6f72 266c 743b 7374 643a 3a76 vector<std::v │ │ │ +0000c4b0: 6563 746f 7226 6c74 3b73 6861 3235 365f ector<sha256_ │ │ │ +0000c4c0: 6861 7368 2667 743b 2c20 6669 6c65 5f69 hash>, file_i │ │ │ +0000c4d0: 6e64 6578 5f74 2667 743b 2074 7265 6573 ndex_t> trees │ │ │ +0000c4e0: 5f69 6d70 6f72 740a 0909 2c20 6175 783a _import..., aux: │ │ │ +0000c4f0: 3a76 6563 746f 7226 6c74 3b62 6974 6669 :vector<bitfi │ │ │ +0000c500: 656c 642c 2066 696c 655f 696e 6465 785f eld, file_index_ │ │ │ +0000c510: 7426 6774 3b20 6d61 736b 0a09 092c 2061 t> mask..., a │ │ │ +0000c520: 7578 3a3a 7665 6374 6f72 266c 743b 6269 ux::vector<bi │ │ │ +0000c530: 7466 6965 6c64 2c20 6669 6c65 5f69 6e64 tfield, file_ind │ │ │ +0000c540: 6578 5f74 2667 743b 2076 6572 6966 6965 ex_t> verifie │ │ │ +0000c550: 6429 0a09 7b0a 0909 6175 746f 2063 6f6e d)..{...auto con │ │ │ +0000c560: 7374 2661 6d70 3b20 6673 203d 206d 5f74 st& fs = m_t │ │ │ +0000c570: 6f72 7265 6e74 5f66 696c 652d 2667 743b orrent_file-> │ │ │ +0000c580: 6c61 796f 7574 2829 3b0a 0a09 0962 6974 layout();....bit │ │ │ +0000c590: 6669 656c 6420 636f 6e73 7420 656d 7074 field const empt │ │ │ +0000c5a0: 795f 7665 7269 6669 6564 3b0a 0909 666f y_verified;...fo │ │ │ +0000c5b0: 7220 2866 696c 655f 696e 6465 785f 7420 r (file_index_t │ │ │ +0000c5c0: 697b 307d 3b20 6920 266c 743b 2066 732e i{0}; i < fs. │ │ │ +0000c5d0: 656e 645f 6669 6c65 2829 3b20 2b2b 6929 end_file(); ++i) │ │ │ +0000c5e0: 0a09 097b 0a09 0909 6966 2028 6673 2e70 ...{....if (fs.p │ │ │ +0000c5f0: 6164 5f66 696c 655f 6174 2869 2920 7c7c ad_file_at(i) || │ │ │ +0000c600: 2066 732e 6669 6c65 5f73 697a 6528 6929 fs.file_size(i) │ │ │ +0000c610: 203d 3d20 3029 0a09 0909 0963 6f6e 7469 == 0).....conti │ │ │ +0000c620: 6e75 653b 0a0a 0909 0969 6620 2869 2026 nue;.....if (i & │ │ │ +0000c630: 6774 3b3d 2074 7265 6573 5f69 6d70 6f72 gt;= trees_impor │ │ │ +0000c640: 742e 656e 645f 696e 6465 7828 2929 2062 t.end_index()) b │ │ │ +0000c650: 7265 616b 3b0a 0909 0962 6974 6669 656c reak;....bitfiel │ │ │ +0000c660: 6420 636f 6e73 7426 616d 703b 2076 6572 d const& ver │ │ │ +0000c670: 6966 6965 645f 6269 746d 6173 6b20 3d20 ified_bitmask = │ │ │ +0000c680: 2869 2026 6774 3b3d 2076 6572 6966 6965 (i >= verifie │ │ │ +0000c690: 642e 656e 645f 696e 6465 7828 2929 203f d.end_index()) ? │ │ │ +0000c6a0: 2065 6d70 7479 5f76 6572 6966 6965 6420 empty_verified │ │ │ +0000c6b0: 3a20 7665 7269 6669 6564 5b69 5d3b 0a09 : verified[i];.. │ │ │ +0000c6c0: 0909 6966 2028 6920 266c 743b 206d 6173 ..if (i < mas │ │ │ +0000c6d0: 6b2e 656e 645f 696e 6465 7828 2920 2661 k.end_index() &a │ │ │ +0000c6e0: 6d70 3b26 616d 703b 2021 6d61 736b 5b69 mp;& !mask[i │ │ │ +0000c6f0: 5d2e 656d 7074 7928 2929 0a09 0909 7b0a ].empty())....{. │ │ │ +0000c700: 0909 0909 6d5f 6d65 726b 6c65 5f74 7265 ....m_merkle_tre │ │ │ +0000c710: 6573 5b69 5d2e 6c6f 6164 5f73 7061 7273 es[i].load_spars │ │ │ +0000c720: 655f 7472 6565 2874 7265 6573 5f69 6d70 e_tree(trees_imp │ │ │ +0000c730: 6f72 745b 695d 2c20 6d61 736b 5b69 5d2c ort[i], mask[i], │ │ │ +0000c740: 2076 6572 6966 6965 645f 6269 746d 6173 verified_bitmas │ │ │ +0000c750: 6b29 3b0a 0909 097d 0a09 0909 656c 7365 k);....}....else │ │ │ +0000c760: 0a09 0909 7b0a 0909 0909 6d5f 6d65 726b ....{.....m_merk │ │ │ +0000c770: 6c65 5f74 7265 6573 5b69 5d2e 6c6f 6164 le_trees[i].load │ │ │ +0000c780: 5f74 7265 6528 7472 6565 735f 696d 706f _tree(trees_impo │ │ │ +0000c790: 7274 5b69 5d2c 2076 6572 6966 6965 645f rt[i], verified_ │ │ │ +0000c7a0: 6269 746d 6173 6b29 3b0a 0909 097d 0a09 bitmask);....}.. │ │ │ +0000c7b0: 097d 0a09 7d0a 0a09 766f 6964 2074 6f72 .}..}...void tor │ │ │ +0000c7c0: 7265 6e74 3a3a 696e 635f 7374 6174 735f rent::inc_stats_ │ │ │ +0000c7d0: 636f 756e 7465 7228 696e 7420 632c 2069 counter(int c, i │ │ │ +0000c7e0: 6e74 2076 616c 7565 290a 097b 206d 5f73 nt value)..{ m_s │ │ │ +0000c7f0: 6573 2e73 7461 7473 5f63 6f75 6e74 6572 es.stats_counter │ │ │ +0000c800: 7328 292e 696e 635f 7374 6174 735f 636f s().inc_stats_co │ │ │ +0000c810: 756e 7465 7228 632c 2076 616c 7565 293b unter(c, value); │ │ │ +0000c820: 207d 0a3c 2f70 7265 3e3c 2f74 643e 3c2f }.
    │ │ │ +0000c850: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0000c860: 7370 3b33 3c2f 7464 3e3c 7464 3e3c 6120 sp;3../ │ │ │ +0000c890: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0000c8a0: 3736 343c 2f61 3e3c 2f74 643e 3c74 643e 764 │ │ │ +0000c8b0: 6173 7365 7274 2074 6865 7265 2061 7265 assert there are │ │ │ +0000c8c0: 206e 6f20 6f75 7473 7461 6e64 696e 6720 no outstanding │ │ │ +0000c8d0: 6173 796e 6320 6f70 6572 6174 696f 6e73 async operations │ │ │ +0000c8e0: 206f 6e20 7468 6973 2074 6f72 7265 6e74 on this torrent │ │ │ +0000c8f0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ass │ │ │ +0000c940: 6572 7420 7468 6572 6520 6172 6520 6e6f ert there are no │ │ │ +0000c950: 206f 7574 7374 616e 6469 6e67 2061 7379 outstanding asy │ │ │ +0000c960: 6e63 206f 7065 7261 7469 6f6e 7320 6f6e nc operations on │ │ │ +0000c970: 2074 6869 730a 746f 7272 656e 743c 2f68 this.torrent

    ../src/tor │ │ │ +0000c990: 7265 6e74 2e63 7070 3a37 3634 3c2f 6834 rent.cpp:764

    ...re
    │ │ │ +0000c9e0: 7475 726e 2066 616c 7365 3b0a 2365 6e64  turn false;.#end
    │ │ │ +0000c9f0: 6966 0a0a 0909 6966 2028 216d 5f73 6573  if....if (!m_ses
    │ │ │ +0000ca00: 2e64 6874 2829 2920 7265 7475 726e 2066  .dht()) return f
    │ │ │ +0000ca10: 616c 7365 3b0a 0909 6966 2028 6d5f 746f  alse;...if (m_to
    │ │ │ +0000ca20: 7272 656e 745f 6669 6c65 2d26 6774 3b69  rrent_file->i
    │ │ │ +0000ca30: 735f 7661 6c69 6428 2920 2661 6d70 3b26  s_valid() &&
    │ │ │ +0000ca40: 616d 703b 2021 6d5f 6669 6c65 735f 6368  amp; !m_files_ch
    │ │ │ +0000ca50: 6563 6b65 6429 2072 6574 7572 6e20 6661  ecked) return fa
    │ │ │ +0000ca60: 6c73 653b 0a09 0969 6620 2821 6d5f 616e  lse;...if (!m_an
    │ │ │ +0000ca70: 6e6f 756e 6365 5f74 6f5f 6468 7429 2072  nounce_to_dht) r
    │ │ │ +0000ca80: 6574 7572 6e20 6661 6c73 653b 0a09 0969  eturn false;...i
    │ │ │ +0000ca90: 6620 286d 5f70 6175 7365 6429 2072 6574  f (m_paused) ret
    │ │ │ +0000caa0: 7572 6e20 6661 6c73 653b 0a0a 0909 2f2f  urn false;....//
    │ │ │ +0000cab0: 2064 6f6e 2774 2061 6e6e 6f75 6e63 6520   don't announce 
    │ │ │ +0000cac0: 7072 6976 6174 6520 746f 7272 656e 7473  private torrents
    │ │ │ +0000cad0: 0a09 0969 6620 286d 5f74 6f72 7265 6e74  ...if (m_torrent
    │ │ │ +0000cae0: 5f66 696c 652d 2667 743b 6973 5f76 616c  _file->is_val
    │ │ │ +0000caf0: 6964 2829 2026 616d 703b 2661 6d70 3b20  id() && 
    │ │ │ +0000cb00: 6d5f 746f 7272 656e 745f 6669 6c65 2d26  m_torrent_file-&
    │ │ │ +0000cb10: 6774 3b70 7269 7628 2929 2072 6574 7572  gt;priv()) retur
    │ │ │ +0000cb20: 6e20 6661 6c73 653b 0a09 0969 6620 286d  n false;...if (m
    │ │ │ +0000cb30: 5f74 7261 636b 6572 732e 656d 7074 7928  _trackers.empty(
    │ │ │ +0000cb40: 2929 2072 6574 7572 6e20 7472 7565 3b0a  )) return true;.
    │ │ │ +0000cb50: 0909 6966 2028 2173 6574 7469 6e67 7328  ..if (!settings(
    │ │ │ +0000cb60: 292e 6765 745f 626f 6f6c 2873 6574 7469  ).get_bool(setti
    │ │ │ +0000cb70: 6e67 735f 7061 636b 3a3a 7573 655f 6468  ngs_pack::use_dh
    │ │ │ +0000cb80: 745f 6173 5f66 616c 6c62 6163 6b29 2920  t_as_fallback)) 
    │ │ │ +0000cb90: 7265 7475 726e 2074 7275 653b 0a0a 0909  return true;....
    │ │ │ +0000cba0: 7265 7475 726e 2021 6d5f 7472 6163 6b65  return !m_tracke
    │ │ │ +0000cbb0: 7273 2e61 6e79 5f76 6572 6966 6965 6428  rs.any_verified(
    │ │ │ +0000cbc0: 293b 0a09 7d0a 0a23 656e 6469 660a 0a09  );..}..#endif...
    │ │ │ +0000cbd0: 746f 7272 656e 743a 3a7e 746f 7272 656e  torrent::~torren
    │ │ │ +0000cbe0: 7428 290a 097b 0a3c 6469 7620 7374 796c  t()..{.
    .
    #if │ │ │ +0000cc20: 544f 5252 454e 545f 5553 455f 4153 5345 TORRENT_USE_ASSE │ │ │ +0000cc30: 5254 530a 0909 2f2f 2062 7920 7468 6520 RTS...// by the │ │ │ +0000cc40: 7469 6d65 2061 2074 6f72 7265 6e74 2069 time a torrent i │ │ │ +0000cc50: 7320 6465 7374 726f 7965 6420 6974 206d s destroyed it m │ │ │ +0000cc60: 7573 7420 616c 7265 6164 7920 6861 7665 ust already have │ │ │ +0000cc70: 2062 6565 6e0a 0909 2f2f 2072 656d 6f76 been...// remov │ │ │ +0000cc80: 6564 2066 726f 6d20 6576 6572 7920 7365 ed from every se │ │ │ +0000cc90: 7373 696f 6e5f 696d 706c 3a3a 6d5f 746f ssion_impl::m_to │ │ │ +0000cca0: 7272 656e 745f 6c69 7374 7320 656e 7472 rrent_lists entr │ │ │ +0000ccb0: 792c 206f 7468 6572 7769 7365 0a09 092f y, otherwise.../ │ │ │ +0000ccc0: 2f20 7468 6520 6c69 7374 2069 7320 6c65 / the list is le │ │ │ +0000ccd0: 6674 2077 6974 6820 6120 6461 6e67 6c69 ft with a dangli │ │ │ +0000cce0: 6e67 2070 6f69 6e74 6572 2e0a 0909 666f ng pointer....fo │ │ │ +0000ccf0: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ +0000cd00: 703b 206c 203a 206d 5f6c 696e 6b73 290a p; l : m_links). │ │ │ +0000cd10: 0909 7b0a 0909 0954 4f52 5245 4e54 5f41 ..{....TORRENT_A │ │ │ +0000cd20: 5353 4552 5428 216c 2e69 6e5f 6c69 7374 SSERT(!l.in_list │ │ │ +0000cd30: 2829 293b 0a09 097d 0a23 656e 6469 660a ());...}.#endif. │ │ │ +0000cd40: 0a09 092f 2f20 5468 6520 696e 7661 7269 ...// The invari │ │ │ +0000cd50: 616e 7420 6361 6e27 7420 6265 206d 6169 ant can't be mai │ │ │ +0000cd60: 6e74 6169 6e65 6420 6865 7265 2c20 7369 ntained here, si │ │ │ +0000cd70: 6e63 6520 7468 6520 746f 7272 656e 740a nce the torrent. │ │ │ +0000cd80: 0909 2f2f 2069 7320 6265 696e 6720 6465 ..// is being de │ │ │ +0000cd90: 7374 7275 6374 6564 2c20 616c 6c20 7765 structed, all we │ │ │ +0000cda0: 616b 2072 6566 6572 656e 6365 7320 746f ak references to │ │ │ +0000cdb0: 2069 7420 6861 7665 2062 6565 6e0a 0909 it have been... │ │ │ +0000cdc0: 2f2f 2072 6573 6574 2c20 7768 6963 6820 // reset, which │ │ │ +0000cdd0: 6d65 616e 7320 7468 6174 2061 6c6c 2069 means that all i │ │ │ +0000cde0: 7473 2070 6565 7273 2061 6c72 6561 6479 ts peers already │ │ │ +0000cdf0: 2068 6176 6520 616e 0a09 092f 2f20 696e have an...// in │ │ │ +0000ce00: 7661 6c69 6461 7465 6420 746f 7272 656e validated torren │ │ │ +0000ce10: 7420 706f 696e 7465 7220 2873 6f20 6974 t pointer (so it │ │ │ +0000ce20: 2063 616e 6e6f 7420 6265 2076 6572 6966 cannot be verif │ │ │ +0000ce30: 6965 6420 746f 2062 6520 636f 7272 6563 ied to be correc │ │ │ +0000ce40: 7429 0a0a 0909 2f2f 2069 2e65 2e20 7468 t)....// i.e. th │ │ │ +0000ce50: 6520 696e 7661 7269 616e 7420 6361 6e20 e invariant can │ │ │ +0000ce60: 6f6e 6c79 2062 6520 6d61 696e 7461 696e only be maintain │ │ │ +0000ce70: 6564 2069 6620 616c 6c20 636f 6e6e 6563 ed if all connec │ │ │ +0000ce80: 7469 6f6e 7320 6861 7665 0a09 092f 2f20 tions have...// │ │ │ +0000ce90: 6265 656e 2063 6c6f 7365 6420 6279 2074 been closed by t │ │ │ +0000cea0: 6865 2074 696d 6520 7468 6520 746f 7272 he time the torr │ │ │ +0000ceb0: 656e 7420 6973 2064 6573 7472 7563 7465 ent is destructe │ │ │ +0000cec0: 642e 2041 6e64 2074 6865 7920 6172 650a d. And they are. │ │ │ +0000ced0: 0909 2f2f 2073 7570 706f 7365 6420 746f ..// supposed to │ │ │ +0000cee0: 2062 6520 636c 6f73 6564 2e20 536f 2077 be closed. So w │ │ │ +0000cef0: 6520 6361 6e20 7374 696c 6c20 646f 2074 e can still do t │ │ │ +0000cf00: 6865 2069 6e76 6172 6961 6e74 2063 6865 he invariant che │ │ │ +0000cf10: 636b 2e0a 0a09 092f 2f20 686f 7765 7665 ck.....// howeve │ │ │ +0000cf20: 722c 2074 6865 2074 6f72 7265 6e74 206f r, the torrent o │ │ │ +0000cf30: 626a 6563 7420 6d61 7920 6265 2064 6573 bject may be des │ │ │ +0000cf40: 7472 7563 7465 6420 6672 6f6d 2074 6865 tructed from the │ │ │ +0000cf50: 206d 6169 6e0a 0909 2f2f 2074 6872 6561 main...// threa │ │ │ +0000cf60: 6420 7768 656e 2073 6875 7474 696e 6720 d when shutting │ │ │ +0000cf70: 646f 776e 2c20 6966 2074 6865 2064 6973 down, if the dis │ │ │ +0000cf80: 6b20 6361 6368 6520 6861 7320 7265 6665 k cache has refe │ │ │ +0000cf90: 7265 6e63 6573 2074 6f20 6974 2e0a 0909 rences to it.... │ │ │ +0000cfa0: 2f2f 2074 6869 7320 6d65 616e 7320 7468 // this means th │ │ │ +0000cfb0: 6174 2074 6865 2069 6e76 6172 6961 6e74 at the invariant │ │ │ +0000cfc0: 2063 6865 636b 2074 6861 7420 7468 6973 check that this │ │ │ +0000cfd0: 2069 7320 6361 6c6c 6564 2066 726f 6d20 is called from │ │ │ +0000cfe0: 7468 650a 0909 2f2f 206e 6574 776f 726b the...// network │ │ │ +0000cff0: 2074 6872 6561 6420 6361 6e6e 6f74 2062 thread cannot b │ │ │ +0000d000: 6520 6d61 696e 7461 696e 6564 0a0a 0909 e maintained.... │ │ │ +0000d010: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ +0000d020: 5f70 6565 725f 636c 6173 7320 3d3d 2070 _peer_class == p │ │ │ +0000d030: 6565 725f 636c 6173 735f 747b 307d 293b eer_class_t{0}); │ │ │ +0000d040: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0000d050: 5428 6d5f 636f 6e6e 6563 7469 6f6e 732e T(m_connections. │ │ │ +0000d060: 656d 7074 7928 2929 3b0a 0909 2f2f 206a empty());...// j │ │ │ +0000d070: 7573 7420 696e 2063 6173 652c 206d 616b ust in case, mak │ │ │ +0000d080: 6520 7375 7265 2074 6865 2073 6573 7369 e sure the sessi │ │ │ +0000d090: 6f6e 2061 6363 6f75 6e74 696e 6720 6973 on accounting is │ │ │ +0000d0a0: 206b 6570 7420 7269 6768 740a 0909 666f kept right...fo │ │ │ +0000d0b0: 7220 2861 7574 6f2a 2070 203a 206d 5f63 r (auto* p : m_c │ │ │ +0000d0c0: 6f6e 6e65 6374 696f 6e73 290a 0909 096d onnections)....m │ │ │ +0000d0d0: 5f73 6573 2e63 6c6f 7365 5f63 6f6e 6e65 _ses.close_conne │ │ │ +0000d0e0: 6374 696f 6e28 7029 3b0a 097d 0a3c 2f70 ction(p);..}.

    re │ │ │ +0000d120: 6c65 7661 6e63 6526 6e62 7370 3b33 3c2f levance 3../src/to │ │ │ +0000d160: 7272 656e 742e 6370 703a 3134 3336 3c2f rrent.cpp:1436there │ │ │ +0000d180: 2773 2073 6f6d 6520 6475 706c 6963 6174 's some duplicat │ │ │ +0000d190: 696f 6e20 6265 7477 6565 6e20 7468 6973 ion between this │ │ │ +0000d1a0: 2066 756e 6374 696f 6e20 616e 6420 7065 function and pe │ │ │ +0000d1b0: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a69 er_connection::i │ │ │ +0000d1c0: 6e63 6f6d 696e 675f 7069 6563 6528 292e ncoming_piece(). │ │ │ +0000d1d0: 2069 7320 7468 6572 6520 6120 7761 7920 is there a way │ │ │ +0000d1e0: 746f 206d 6572 6765 2073 6f6d 6574 6869 to merge somethi │ │ │ +0000d1f0: 6e67 3f3c 2f74 643e 3c2f 7472 3e3c 7472 ng?

    │ │ │ +0000d240: 7468 6572 6527 7320 736f 6d65 2064 7570 there's some dup │ │ │ +0000d250: 6c69 6361 7469 6f6e 2062 6574 7765 656e lication between │ │ │ +0000d260: 2074 6869 7320 6675 6e63 7469 6f6e 2061 this function a │ │ │ +0000d270: 6e64 0a70 6565 725f 636f 6e6e 6563 7469 nd.peer_connecti │ │ │ +0000d280: 6f6e 3a3a 696e 636f 6d69 6e67 5f70 6965 on::incoming_pie │ │ │ +0000d290: 6365 2829 2e20 6973 2074 6865 7265 2061 ce(). is there a │ │ │ +0000d2a0: 2077 6179 2074 6f20 6d65 7267 6520 736f way to merge so │ │ │ +0000d2b0: 6d65 7468 696e 673f 3c2f 6832 3e3c 6834 mething?

    ../src/torrent. │ │ │ +0000d2d0: 6370 703a 3134 3336 3c2f 6834 3e3c 7072 cpp:1436

    .void tor │ │ │ +0000d320: 7265 6e74 3a3a 6164 645f 7069 6563 655f rent::add_piece_ │ │ │ +0000d330: 6173 796e 6328 7069 6563 655f 696e 6465 async(piece_inde │ │ │ +0000d340: 785f 7420 636f 6e73 7420 7069 6563 650a x_t const piece. │ │ │ +0000d350: 0909 2c20 7374 643a 3a76 6563 746f 7226 .., std::vector& │ │ │ +0000d360: 6c74 3b63 6861 7226 6774 3b20 6461 7461 lt;char> data │ │ │ +0000d370: 2c20 6164 645f 7069 6563 655f 666c 6167 , add_piece_flag │ │ │ +0000d380: 735f 7420 636f 6e73 7420 666c 6167 7329 s_t const flags) │ │ │ +0000d390: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ +0000d3a0: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ +0000d3b0: 6872 6561 6428 2929 3b0a 0a09 0954 4f52 hread());....TOR │ │ │ +0000d3c0: 5245 4e54 5f41 5353 4552 545f 5052 4543 RENT_ASSERT_PREC │ │ │ +0000d3d0: 4f4e 4428 7069 6563 6520 266c 743b 2074 OND(piece < t │ │ │ +0000d3e0: 6f72 7265 6e74 5f66 696c 6528 292e 656e orrent_file().en │ │ │ +0000d3f0: 645f 7069 6563 6528 2929 3b0a 0909 544f d_piece());...TO │ │ │ +0000d400: 5252 454e 545f 4153 5345 5254 5f50 5245 RRENT_ASSERT_PRE │ │ │ +0000d410: 434f 4e44 2870 6965 6365 2026 6774 3b3d COND(piece >= │ │ │ +0000d420: 2070 6965 6365 5f69 6e64 6578 5f74 7b30 piece_index_t{0 │ │ │ +0000d430: 7d29 3b0a 0909 544f 5252 454e 545f 4153 });...TORRENT_AS │ │ │ +0000d440: 5345 5254 5f50 5245 434f 4e44 2864 6174 SERT_PRECOND(dat │ │ │ +0000d450: 612e 7369 7a65 2829 203d 3d20 7374 643a a.size() == std: │ │ │ +0000d460: 3a73 697a 655f 7428 7069 6563 655f 7369 :size_t(piece_si │ │ │ +0000d470: 7a65 5f66 6f72 5f72 6571 2870 6965 6365 ze_for_req(piece │ │ │ +0000d480: 2929 293b 0a0a 0909 2f2f 206d 616b 6520 )));....// make │ │ │ +0000d490: 7375 7265 2074 6865 2070 6965 6365 2069 sure the piece i │ │ │ +0000d4a0: 6e64 6578 2069 7320 636f 7272 6563 740a ndex is correct. │ │ │ +0000d4b0: 0909 6966 2028 7069 6563 6520 2667 743b ..if (piece > │ │ │ +0000d4c0: 3d20 746f 7272 656e 745f 6669 6c65 2829 = torrent_file() │ │ │ +0000d4d0: 2e65 6e64 5f70 6965 6365 2829 290a 0909 .end_piece())... │ │ │ +0000d4e0: 0972 6574 7572 6e3b 0a0a 0909 2f2f 206d .return;....// m │ │ │ +0000d4f0: 616b 6520 7375 7265 2074 6865 2070 6965 ake sure the pie │ │ │ +0000d500: 6365 2073 697a 6520 6973 2063 6f72 7265 ce size is corre │ │ │ +0000d510: 6374 0a09 0969 6620 2864 6174 612e 7369 ct...if (data.si │ │ │ +0000d520: 7a65 2829 2021 3d20 7374 643a 3a73 697a ze() != std::siz │ │ │ +0000d530: 655f 7428 7069 6563 655f 7369 7a65 5f66 e_t(piece_size_f │ │ │ +0000d540: 6f72 5f72 6571 2870 6965 6365 2929 290a or_req(piece))). │ │ │ +0000d550: 0909 0972 6574 7572 6e3b 0a0a 0909 6164 ...return;....ad │ │ │ +0000d560: 645f 7069 6563 6528 7069 6563 652c 2064 d_piece(piece, d │ │ │ +0000d570: 6174 612e 6461 7461 2829 2c20 666c 6167 ata.data(), flag │ │ │ +0000d580: 7329 3b0a 097d 0a0a 3c64 6976 2073 7479 s);..}..
    .void torr │ │ │ +0000d5c0: 656e 743a 3a61 6464 5f70 6965 6365 2870 ent::add_piece(p │ │ │ +0000d5d0: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e iece_index_t con │ │ │ +0000d5e0: 7374 2070 6965 6365 2c20 6368 6172 2063 st piece, char c │ │ │ +0000d5f0: 6f6e 7374 2a20 6461 7461 0a3c 2f64 6976 onst* data.
    .., add_piece_f │ │ │ +0000d610: 6c61 6773 5f74 2063 6f6e 7374 2066 6c61 lags_t const fla │ │ │ +0000d620: 6773 290a 097b 0a09 0954 4f52 5245 4e54 gs)..{...TORRENT │ │ │ +0000d630: 5f41 5353 4552 5428 6973 5f73 696e 676c _ASSERT(is_singl │ │ │ +0000d640: 655f 7468 7265 6164 2829 293b 0a0a 0909 e_thread());.... │ │ │ +0000d650: 2f2f 206d 616b 6520 7375 7265 2074 6865 // make sure the │ │ │ +0000d660: 2070 6965 6365 2069 6e64 6578 2069 7320 piece index is │ │ │ +0000d670: 636f 7272 6563 740a 0909 6966 2028 7069 correct...if (pi │ │ │ +0000d680: 6563 6520 2667 743b 3d20 746f 7272 656e ece >= torren │ │ │ +0000d690: 745f 6669 6c65 2829 2e65 6e64 5f70 6965 t_file().end_pie │ │ │ +0000d6a0: 6365 2829 290a 0909 0972 6574 7572 6e3b ce())....return; │ │ │ +0000d6b0: 0a0a 0909 696e 7420 636f 6e73 7420 7069 ....int const pi │ │ │ +0000d6c0: 6563 655f 7369 7a65 203d 2070 6965 6365 ece_size = piece │ │ │ +0000d6d0: 5f73 697a 655f 666f 725f 7265 7128 7069 _size_for_req(pi │ │ │ +0000d6e0: 6563 6529 3b0a 0909 696e 7420 636f 6e73 ece);...int cons │ │ │ +0000d6f0: 7420 626c 6f63 6b73 5f69 6e5f 7069 6563 t blocks_in_piec │ │ │ +0000d700: 6520 3d20 2870 6965 6365 5f73 697a 6520 e = (piece_size │ │ │ +0000d710: 2b20 626c 6f63 6b5f 7369 7a65 2829 202d + block_size() - │ │ │ +0000d720: 2031 2920 2f20 626c 6f63 6b5f 7369 7a65 1) / block_size │ │ │ +0000d730: 2829 3b0a 0a09 0969 6620 286d 5f64 656c ();....if (m_del │ │ │ +0000d740: 6574 6564 2920 7265 7475 726e 3b0a 0a09 eted) return;... │ │ │ +0000d750: 092f 2f20 6176 6f69 6420 6372 6173 6820 .// avoid crash │ │ │ +0000d760: 7472 7969 6e67 2074 6f20 6163 6365 7373 trying to access │ │ │ +0000d770: 2074 6865 2070 6963 6b65 7220 7768 656e the picker when │ │ │ +0000d780: 2074 6865 7265 2069 7320 6e6f 6e65 0a09 there is none.. │ │ │ +0000d790: 0969 6620 286d 5f68 6176 655f 616c 6c20 .if (m_have_all │ │ │ +0000d7a0: 2661 6d70 3b26 616d 703b 2021 6861 735f && !has_ │ │ │ +0000d7b0: 7069 636b 6572 2829 2920 7265 7475 726e picker()) return │ │ │ +0000d7c0: 3b0a 0a09 092f 2f20 7765 2064 6f6e 2774 ;....// we don't │ │ │ +0000d7d0: 2073 7570 706f 7274 2063 6c6f 6262 6572 support clobber │ │ │ +0000d7e0: 696e 6720 7468 6520 7069 6563 6520 7069 ing the piece pi │ │ │ +0000d7f0: 636b 6572 2077 6869 6c65 2063 6865 636b cker while check │ │ │ +0000d800: 696e 6720 7468 650a 0909 2f2f 2066 696c ing the...// fil │ │ │ +0000d810: 6573 2e20 5765 206d 6179 2065 6e64 2075 es. We may end u │ │ │ +0000d820: 7020 6861 7669 6e67 2074 6865 2073 616d p having the sam │ │ │ +0000d830: 6520 7069 6563 6520 6d75 6c74 6970 6c65 e piece multiple │ │ │ +0000d840: 2074 696d 6573 0a09 0954 4f52 5245 4e54 times...TORRENT │ │ │ +0000d850: 5f41 5353 4552 545f 5052 4543 4f4e 4428 _ASSERT_PRECOND( │ │ │ +0000d860: 7374 6174 6528 2920 213d 2074 6f72 7265 state() != torre │ │ │ +0000d870: 6e74 5f73 7461 7475 733a 3a63 6865 636b nt_status::check │ │ │ +0000d880: 696e 675f 6669 6c65 730a 0909 0926 616d ing_files....&am │ │ │ +0000d890: 703b 2661 6d70 3b20 7374 6174 6528 2920 p;& state() │ │ │ +0000d8a0: 213d 2074 6f72 7265 6e74 5f73 7461 7475 != torrent_statu │ │ │ +0000d8b0: 733a 3a63 6865 636b 696e 675f 7265 7375 s::checking_resu │ │ │ +0000d8c0: 6d65 5f64 6174 6129 3b0a 0909 6966 2028 me_data);...if ( │ │ │ +0000d8d0: 7374 6174 6528 2920 3d3d 2074 6f72 7265 state() == torre │ │ │ +0000d8e0: 6e74 5f73 7461 7475 733a 3a63 6865 636b nt_status::check │ │ │ +0000d8f0: 696e 675f 6669 6c65 730a 0909 097c 7c20 ing_files....|| │ │ │ +0000d900: 7374 6174 6528 2920 3d3d 2074 6f72 7265 state() == torre │ │ │ +0000d910: 6e74 5f73 7461 7475 733a 3a63 6865 636b nt_status::check │ │ │ +0000d920: 696e 675f 7265 7375 6d65 5f64 6174 6129 ing_resume_data) │ │ │ +0000d930: 0a09 0909 7265 7475 726e 3b0a 0a09 096e ....return;....n │ │ │ +0000d940: 6565 645f 7069 636b 6572 2829 3b0a 0a09 eed_picker();... │ │ │ +0000d950: 0969 6620 2870 6963 6b65 7228 292e 6861 .if (picker().ha │ │ │ +0000d960: 7665 5f70 6965 6365 2870 6965 6365 290a ve_piece(piece). │ │ │ +0000d970: 0909 0926 616d 703b 2661 6d70 3b20 2128 ...&& !( │ │ │ +0000d980: 666c 6167 7320 2661 6d70 3b20 746f 7272 flags & torr │ │ │ +0000d990: 656e 745f 6861 6e64 6c65 3a3a 6f76 6572 ent_handle::over │ │ │ +0000d9a0: 7772 6974 655f 6578 6973 7469 6e67 2929 write_existing)) │ │ │ +0000d9b0: 0a09 0909 7265 7475 726e 3b0a 0a3c 2f70 ....return;..

    re │ │ │ +0000d9f0: 6c65 7661 6e63 6526 6e62 7370 3b33 3c2f levance 3
    ../src/to │ │ │ +0000da30: 7272 656e 742e 6370 703a 3433 3134 3c2f rrent.cpp:4314this │ │ │ +0000da50: 636f 756c 6420 7072 6f62 6162 6c79 2062 could probably b │ │ │ +0000da60: 6520 7075 6c6c 6564 206f 7574 2069 6e74 e pulled out int │ │ │ +0000da70: 6f20 6120 6672 6565 2066 756e 6374 696f o a free functio │ │ │ +0000da80: 6e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 n

    th │ │ │ +0000dad0: 6973 2063 6f75 6c64 2070 726f 6261 626c is could probabl │ │ │ +0000dae0: 7920 6265 2070 756c 6c65 6420 6f75 7420 y be pulled out │ │ │ +0000daf0: 696e 746f 2061 2066 7265 6520 6675 6e63 into a free func │ │ │ +0000db00: 7469 6f6e 3c2f 6832 3e3c 6834 3e2e 2e2f tion

    ../ │ │ │ +0000db10: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0000db20: 3433 3134 3c2f 6834 3e3c 7072 6520 7374 4314

    .std::int64_t
    │ │ │ +0000db70: 2063 616c 635f 6279 7465 7328 6669 6c65   calc_bytes(file
    │ │ │ +0000db80: 5f73 746f 7261 6765 2063 6f6e 7374 2661  _storage const&a
    │ │ │ +0000db90: 6d70 3b20 6673 2c20 7069 6563 655f 636f  mp; fs, piece_co
    │ │ │ +0000dba0: 756e 7420 636f 6e73 7426 616d 703b 2070  unt const& p
    │ │ │ +0000dbb0: 6329 0a09 7b0a 0909 2f2f 2069 7427 7320  c)..{...// it's 
    │ │ │ +0000dbc0: 616e 2069 6d70 6f73 7369 626c 6520 636f  an impossible co
    │ │ │ +0000dbd0: 6d62 696e 6174 696f 6e20 746f 2068 6176  mbination to hav
    │ │ │ +0000dbe0: 6520 3020 7069 6563 6573 2c20 6275 7420  e 0 pieces, but 
    │ │ │ +0000dbf0: 7374 696c 6c20 6861 7665 206f 6e65 206f  still have one o
    │ │ │ +0000dc00: 6620 7468 656d 2062 6520 7468 6520 6c61  f them be the la
    │ │ │ +0000dc10: 7374 2070 6965 6365 0a09 0954 4f52 5245  st piece...TORRE
    │ │ │ +0000dc20: 4e54 5f41 5353 4552 5428 2128 7063 2e6e  NT_ASSERT(!(pc.n
    │ │ │ +0000dc30: 756d 5f70 6965 6365 7320 3d3d 2030 2026  um_pieces == 0 &
    │ │ │ +0000dc40: 616d 703b 2661 6d70 3b20 7063 2e6c 6173  amp;& pc.las
    │ │ │ +0000dc50: 745f 7069 6563 6520 3d3d 2074 7275 6529  t_piece == true)
    │ │ │ +0000dc60: 293b 0a0a 0909 2f2f 2069 6620 7765 2068  );....// if we h
    │ │ │ +0000dc70: 6176 6520 3020 7069 6563 6573 2c20 7765  ave 0 pieces, we
    │ │ │ +0000dc80: 2063 616e 2774 2068 6176 6520 616e 7920   can't have any 
    │ │ │ +0000dc90: 7061 6420 626c 6f63 6b73 2065 6974 6865  pad blocks eithe
    │ │ │ +0000dca0: 720a 0909 544f 5252 454e 545f 4153 5345  r...TORRENT_ASSE
    │ │ │ +0000dcb0: 5254 2821 2870 632e 6e75 6d5f 7069 6563  RT(!(pc.num_piec
    │ │ │ +0000dcc0: 6573 203d 3d20 3020 2661 6d70 3b26 616d  es == 0 &&am
    │ │ │ +0000dcd0: 703b 2070 632e 7061 645f 6279 7465 7320  p; pc.pad_bytes 
    │ │ │ +0000dce0: 2667 743b 2030 2929 3b0a 0a09 092f 2f20  > 0));....// 
    │ │ │ +0000dcf0: 6966 2077 6520 6861 7665 2061 6c6c 2070  if we have all p
    │ │ │ +0000dd00: 6965 6365 732c 2077 6520 6d75 7374 2061  ieces, we must a
    │ │ │ +0000dd10: 6c73 6f20 6861 7665 2074 6865 206c 6173  lso have the las
    │ │ │ +0000dd20: 7420 6f6e 650a 0909 544f 5252 454e 545f  t one...TORRENT_
    │ │ │ +0000dd30: 4153 5345 5254 2821 2870 632e 6e75 6d5f  ASSERT(!(pc.num_
    │ │ │ +0000dd40: 7069 6563 6573 203d 3d20 6673 2e6e 756d  pieces == fs.num
    │ │ │ +0000dd50: 5f70 6965 6365 7328 2920 2661 6d70 3b26  _pieces() &&
    │ │ │ +0000dd60: 616d 703b 2070 632e 6c61 7374 5f70 6965  amp; pc.last_pie
    │ │ │ +0000dd70: 6365 203d 3d20 6661 6c73 6529 293b 0a0a  ce == false));..
    │ │ │ +0000dd80: 0909 2f2f 2065 7665 7279 2062 6c6f 636b  ..// every block
    │ │ │ +0000dd90: 2073 686f 756c 6420 6e6f 7420 6265 2061   should not be a
    │ │ │ +0000dda0: 2070 6164 2062 6c6f 636b 0a09 0954 4f52   pad block...TOR
    │ │ │ +0000ddb0: 5245 4e54 5f41 5353 4552 5428 7063 2e70  RENT_ASSERT(pc.p
    │ │ │ +0000ddc0: 6164 5f62 7974 6573 2026 6c74 3b3d 2073  ad_bytes <= s
    │ │ │ +0000ddd0: 7464 3a3a 696e 7436 345f 7428 7063 2e6e  td::int64_t(pc.n
    │ │ │ +0000dde0: 756d 5f70 6965 6365 7329 202a 2066 732e  um_pieces) * fs.
    │ │ │ +0000ddf0: 7069 6563 655f 6c65 6e67 7468 2829 293b  piece_length());
    │ │ │ +0000de00: 0a0a 0909 7265 7475 726e 2073 7464 3a3a  ....return std::
    │ │ │ +0000de10: 696e 7436 345f 7428 7063 2e6e 756d 5f70  int64_t(pc.num_p
    │ │ │ +0000de20: 6965 6365 7329 202a 2066 732e 7069 6563  ieces) * fs.piec
    │ │ │ +0000de30: 655f 6c65 6e67 7468 2829 0a09 0909 2d20  e_length()....- 
    │ │ │ +0000de40: 2870 632e 6c61 7374 5f70 6965 6365 203f  (pc.last_piece ?
    │ │ │ +0000de50: 2066 732e 7069 6563 655f 6c65 6e67 7468   fs.piece_length
    │ │ │ +0000de60: 2829 202d 2066 732e 7069 6563 655f 7369  () - fs.piece_si
    │ │ │ +0000de70: 7a65 2866 732e 6c61 7374 5f70 6965 6365  ze(fs.last_piece
    │ │ │ +0000de80: 2829 2920 3a20 3029 0a09 0909 2d20 7374  ()) : 0)....- st
    │ │ │ +0000de90: 643a 3a69 6e74 3634 5f74 2870 632e 7061  d::int64_t(pc.pa
    │ │ │ +0000dea0: 645f 6279 7465 7329 3b0a 097d 0a0a 092f  d_bytes);..}.../
    │ │ │ +0000deb0: 2f20 6669 6c6c 7320 696e 2074 6f74 616c  / fills in total
    │ │ │ +0000dec0: 5f77 616e 7465 642c 2074 6f74 616c 5f77  _wanted, total_w
    │ │ │ +0000ded0: 616e 7465 645f 646f 6e65 2061 6e64 2074  anted_done and t
    │ │ │ +0000dee0: 6f74 616c 5f64 6f6e 650a 3c64 6976 2073  otal_done.
    .void to │ │ │ +0000df20: 7272 656e 743a 3a62 7974 6573 5f64 6f6e rrent::bytes_don │ │ │ +0000df30: 6528 746f 7272 656e 745f 7374 6174 7573 e(torrent_status │ │ │ +0000df40: 2661 6d70 3b20 7374 2c20 7374 6174 7573 & st, status │ │ │ +0000df50: 5f66 6c61 6773 5f74 2063 6f6e 7374 2066 _flags_t const f │ │ │ +0000df60: 6c61 6773 2920 636f 6e73 740a 3c2f 6469 lags) const..{...INVARIANT │ │ │ +0000df80: 5f43 4845 434b 3b0a 0a09 0973 742e 746f _CHECK;....st.to │ │ │ +0000df90: 7461 6c5f 646f 6e65 203d 2030 3b0a 0909 tal_done = 0;... │ │ │ +0000dfa0: 7374 2e74 6f74 616c 5f77 616e 7465 645f st.total_wanted_ │ │ │ +0000dfb0: 646f 6e65 203d 2030 3b0a 0909 7374 2e74 done = 0;...st.t │ │ │ +0000dfc0: 6f74 616c 5f77 616e 7465 6420 3d20 6d5f otal_wanted = m_ │ │ │ +0000dfd0: 7369 7a65 5f6f 6e5f 6469 736b 3b0a 0909 size_on_disk;... │ │ │ +0000dfe0: 7374 2e74 6f74 616c 203d 206d 5f73 697a st.total = m_siz │ │ │ +0000dff0: 655f 6f6e 5f64 6973 6b3b 0a0a 0909 544f e_on_disk;....TO │ │ │ +0000e000: 5252 454e 545f 4153 5345 5254 2873 742e RRENT_ASSERT(st. │ │ │ +0000e010: 746f 7461 6c5f 7761 6e74 6564 2026 6c74 total_wanted < │ │ │ +0000e020: 3b3d 206d 5f74 6f72 7265 6e74 5f66 696c ;= m_torrent_fil │ │ │ +0000e030: 652d 2667 743b 746f 7461 6c5f 7369 7a65 e->total_size │ │ │ +0000e040: 2829 293b 0a09 0954 4f52 5245 4e54 5f41 ());...TORRENT_A │ │ │ +0000e050: 5353 4552 5428 7374 2e74 6f74 616c 5f77 SSERT(st.total_w │ │ │ +0000e060: 616e 7465 6420 2667 743b 3d20 3029 3b0a anted >= 0);. │ │ │ +0000e070: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0000e080: 5428 2176 616c 6964 5f6d 6574 6164 6174 T(!valid_metadat │ │ │ +0000e090: 6128 2920 7c7c 206d 5f74 6f72 7265 6e74 a() || m_torrent │ │ │ +0000e0a0: 5f66 696c 652d 2667 743b 6e75 6d5f 7069 _file->num_pi │ │ │ +0000e0b0: 6563 6573 2829 2026 6774 3b20 3029 3b0a eces() > 0);. │ │ │ +0000e0c0: 0909 6966 2028 2176 616c 6964 5f6d 6574 ..if (!valid_met │ │ │ +0000e0d0: 6164 6174 6128 2929 2072 6574 7572 6e3b adata()) return; │ │ │ +0000e0e0: 0a0a 0909 6966 2028 6d5f 7365 6564 5f6d ....if (m_seed_m │ │ │ +0000e0f0: 6f64 6520 7c7c 2069 735f 7365 6564 2829 ode || is_seed() │ │ │ +0000e100: 290a 0909 7b0a 0909 092f 2f20 6f6e 6365 )...{....// once │ │ │ +0000e110: 2077 6527 7265 2061 2073 6565 6420 616e we're a seed an │ │ │ +0000e120: 6420 7265 6d6f 7665 2074 6865 2070 6965 d remove the pie │ │ │ +0000e130: 6365 2070 6963 6b65 722c 2077 6520 7374 ce picker, we st │ │ │ +0000e140: 6f70 2074 7261 636b 696e 670a 0909 092f op tracking..../ │ │ │ +0000e150: 2f20 7069 6563 652d 2061 6e64 2066 696c / piece- and fil │ │ │ +0000e160: 6520 7072 696f 7269 7479 2e20 5765 2063 e priority. We c │ │ │ +0000e170: 6f6e 7369 6465 7220 6576 6572 7974 6869 onsider everythi │ │ │ +0000e180: 6e67 2061 7320 6265 696e 670a 0909 092f ng as being..../ │ │ │ +0000e190: 2f20 2277 616e 7465 6422 0a09 0909 7374 / "wanted"....st │ │ │ +0000e1a0: 2e74 6f74 616c 5f64 6f6e 6520 3d20 6d5f .total_done = m_ │ │ │ +0000e1b0: 7369 7a65 5f6f 6e5f 6469 736b 3b0a 0909 size_on_disk;... │ │ │ +0000e1c0: 0973 742e 746f 7461 6c5f 7761 6e74 6564 .st.total_wanted │ │ │ +0000e1d0: 5f64 6f6e 6520 3d20 6d5f 7369 7a65 5f6f _done = m_size_o │ │ │ +0000e1e0: 6e5f 6469 736b 3b0a 0909 0954 4f52 5245 n_disk;....TORRE │ │ │ +0000e1f0: 4e54 5f41 5353 4552 5428 7374 2e74 6f74 NT_ASSERT(st.tot │ │ │ +0000e200: 616c 5f77 616e 7465 6420 266c 743b 3d20 al_wanted <= │ │ │ +0000e210: 7374 2e74 6f74 616c 5f64 6f6e 6529 3b0a st.total_done);. │ │ │ +0000e220: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0000e230: 5428 7374 2e74 6f74 616c 5f77 616e 7465 T(st.total_wante │ │ │ +0000e240: 645f 646f 6e65 2026 6c74 3b3d 2073 742e d_done <= st. │ │ │ +0000e250: 746f 7461 6c5f 7761 6e74 6564 293b 0a09 total_wanted);.. │ │ │ +0000e260: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0000e270: 2873 742e 746f 7461 6c5f 646f 6e65 2026 (st.total_done & │ │ │ +0000e280: 6c74 3b3d 206d 5f74 6f72 7265 6e74 5f66 lt;= m_torrent_f │ │ │ +0000e290: 696c 652d 2667 743b 746f 7461 6c5f 7369 ile->total_si │ │ │ +0000e2a0: 7a65 2829 293b 0a09 0909 7265 7475 726e ze());....return │ │ │ +0000e2b0: 3b0a 0909 7d0a 0909 656c 7365 2069 6620 ;...}...else if │ │ │ +0000e2c0: 2821 6861 735f 7069 636b 6572 2829 290a (!has_picker()). │ │ │ +0000e2d0: 0909 0972 6574 7572 6e3b 0a0a 0909 544f ...return;....TO │ │ │ +0000e2e0: 5252 454e 545f 4153 5345 5254 2868 6173 RRENT_ASSERT(has │ │ │ +0000e2f0: 5f70 6963 6b65 7228 2929 3b0a 3c2f 7072 _picker());.rel │ │ │ +0000e330: 6576 616e 6365 266e 6273 703b 333c 2f74 evance 3../src/tor │ │ │ +0000e370: 7265 6e74 2e63 7070 3a35 3238 383c 2f61 rent.cpp:5288should │ │ │ +0000e390: 2074 6869 7320 616c 6572 7420 6861 7665 this alert have │ │ │ +0000e3a0: 2061 6e20 6572 726f 7220 636f 6465 2069 an error code i │ │ │ +0000e3b0: 6e20 6974 3f3c 2f74 643e 3c2f 7472 3e3c n it?< │ │ │ +0000e3c0: 7472 2069 643d 2232 3722 2073 7479 6c65 tr id="27" style │ │ │ +0000e3d0: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ +0000e3e0: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">should this al │ │ │ +0000e410: 6572 7420 6861 7665 2061 6e20 6572 726f ert have an erro │ │ │ +0000e420: 7220 636f 6465 2069 6e20 6974 3f3c 2f68 r code in it?

    ../src/tor │ │ │ +0000e440: 7265 6e74 2e63 7070 3a35 3238 383c 2f68 rent.cpp:5288
    ..on
    │ │ │ +0000e490: 5f72 656d 6f76 655f 7065 6572 7328 293b  _remove_peers();
    │ │ │ +0000e4a0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +0000e4b0: 5428 6d5f 636f 6e6e 6563 7469 6f6e 732e  T(m_connections.
    │ │ │ +0000e4c0: 656d 7074 7928 2929 3b0a 0a09 092f 2f20  empty());....// 
    │ │ │ +0000e4d0: 706f 7374 2061 206d 6573 7361 6765 2074  post a message t
    │ │ │ +0000e4e0: 6f20 7468 6520 6d61 696e 2074 6872 6561  o the main threa
    │ │ │ +0000e4f0: 6420 746f 2064 6573 7472 7563 740a 0909  d to destruct...
    │ │ │ +0000e500: 2f2f 2074 6865 2074 6f72 7265 6e74 206f  // the torrent o
    │ │ │ +0000e510: 626a 6563 7420 6672 6f6d 2074 6865 7265  bject from there
    │ │ │ +0000e520: 0a09 0969 6620 286d 5f73 746f 7261 6765  ...if (m_storage
    │ │ │ +0000e530: 290a 0909 7b0a 0909 0974 7279 207b 0a09  )...{....try {..
    │ │ │ +0000e540: 0909 096d 5f73 6573 2e64 6973 6b5f 7468  ...m_ses.disk_th
    │ │ │ +0000e550: 7265 6164 2829 2e61 7379 6e63 5f73 746f  read().async_sto
    │ │ │ +0000e560: 705f 746f 7272 656e 7428 6d5f 7374 6f72  p_torrent(m_stor
    │ │ │ +0000e570: 6167 650a 0909 0909 092c 2073 7464 3a3a  age......, std::
    │ │ │ +0000e580: 6269 6e64 2826 616d 703b 746f 7272 656e  bind(&torren
    │ │ │ +0000e590: 743a 3a6f 6e5f 746f 7272 656e 745f 6162  t::on_torrent_ab
    │ │ │ +0000e5a0: 6f72 7465 642c 2073 6861 7265 645f 6672  orted, shared_fr
    │ │ │ +0000e5b0: 6f6d 5f74 6869 7328 2929 293b 0a09 0909  om_this()));....
    │ │ │ +0000e5c0: 7d0a 0909 0963 6174 6368 2028 7374 643a  }....catch (std:
    │ │ │ +0000e5d0: 3a65 7863 6570 7469 6f6e 2063 6f6e 7374  :exception const
    │ │ │ +0000e5e0: 2661 6d70 3b20 6529 0a09 0909 7b0a 0909  & e)....{...
    │ │ │ +0000e5f0: 0909 544f 5252 454e 545f 554e 5553 4544  ..TORRENT_UNUSED
    │ │ │ +0000e600: 2865 293b 0a09 0909 096d 5f73 746f 7261  (e);.....m_stora
    │ │ │ +0000e610: 6765 2e72 6573 6574 2829 3b0a 2369 666e  ge.reset();.#ifn
    │ │ │ +0000e620: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0000e630: 424c 455f 4c4f 4747 494e 470a 0909 0909  BLE_LOGGING.....
    │ │ │ +0000e640: 6465 6275 675f 6c6f 6728 2246 6169 6c65  debug_log("Faile
    │ │ │ +0000e650: 6420 746f 2066 6c75 7368 2064 6973 6b20  d to flush disk 
    │ │ │ +0000e660: 6361 6368 653a 2025 7322 2c20 652e 7768  cache: %s", e.wh
    │ │ │ +0000e670: 6174 2829 293b 0a23 656e 6469 660a 0909  at());.#endif...
    │ │ │ +0000e680: 0909 2f2f 2063 6c69 656e 7473 206d 6179  ..// clients may
    │ │ │ +0000e690: 2072 656c 7920 6f6e 2074 6869 7320 616c   rely on this al
    │ │ │ +0000e6a0: 6572 7420 746f 2062 6520 706f 7374 6564  ert to be posted
    │ │ │ +0000e6b0: 2c20 736f 2069 7427 7320 7072 6f62 6162  , so it's probab
    │ │ │ +0000e6c0: 6c79 2061 0a09 0909 092f 2f20 676f 6f64  ly a.....// good
    │ │ │ +0000e6d0: 2069 6465 6120 746f 2070 6f73 7420 6974   idea to post it
    │ │ │ +0000e6e0: 2068 6572 652c 2065 7665 6e20 7468 6f75   here, even thou
    │ │ │ +0000e6f0: 6768 2077 6520 6661 696c 6564 0a3c 6469  gh we failed.....i
    │ │ │ +0000e730: 6620 2861 6c65 7274 7328 292e 7368 6f75  f (alerts().shou
    │ │ │ +0000e740: 6c64 5f70 6f73 7426 6c74 3b63 6163 6865  ld_post<cache
    │ │ │ +0000e750: 5f66 6c75 7368 6564 5f61 6c65 7274 2667  _flushed_alert&g
    │ │ │ +0000e760: 743b 2829 290a 3c2f 6469 763e 0909 0909  t;()).

    .... │ │ │ +0000e770: 0961 6c65 7274 7328 292e 656d 706c 6163 .alerts().emplac │ │ │ +0000e780: 655f 616c 6572 7426 6c74 3b63 6163 6865 e_alert<cache │ │ │ +0000e790: 5f66 6c75 7368 6564 5f61 6c65 7274 2667 _flushed_alert&g │ │ │ +0000e7a0: 743b 2867 6574 5f68 616e 646c 6528 2929 t;(get_handle()) │ │ │ +0000e7b0: 3b0a 0909 097d 0a09 0909 6d5f 7365 732e ;....}....m_ses. │ │ │ +0000e7c0: 6465 6665 7272 6564 5f73 7562 6d69 745f deferred_submit_ │ │ │ +0000e7d0: 6a6f 6273 2829 3b0a 0909 7d0a 0909 656c jobs();...}...el │ │ │ +0000e7e0: 7365 0a09 097b 0a09 0909 6966 2028 616c se...{....if (al │ │ │ +0000e7f0: 6572 7473 2829 2e73 686f 756c 645f 706f erts().should_po │ │ │ +0000e800: 7374 266c 743b 6361 6368 655f 666c 7573 st<cache_flus │ │ │ +0000e810: 6865 645f 616c 6572 7426 6774 3b28 2929 hed_alert>()) │ │ │ +0000e820: 0a09 0909 0961 6c65 7274 7328 292e 656d .....alerts().em │ │ │ +0000e830: 706c 6163 655f 616c 6572 7426 6c74 3b63 place_alert<c │ │ │ +0000e840: 6163 6865 5f66 6c75 7368 6564 5f61 6c65 ache_flushed_ale │ │ │ +0000e850: 7274 2667 743b 2867 6574 5f68 616e 646c rt>(get_handl │ │ │ +0000e860: 6528 2929 3b0a 0909 0961 6c65 7274 7328 e());....alerts( │ │ │ +0000e870: 292e 656d 706c 6163 655f 616c 6572 7426 ).emplace_alert& │ │ │ +0000e880: 6c74 3b74 6f72 7265 6e74 5f72 656d 6f76 lt;torrent_remov │ │ │ +0000e890: 6564 5f61 6c65 7274 2667 743b 2867 6574 ed_alert>(get │ │ │ +0000e8a0: 5f68 616e 646c 6528 290a 0909 0909 2c20 _handle()....., │ │ │ +0000e8b0: 696e 666f 5f68 6173 6828 292c 2067 6574 info_hash(), get │ │ │ +0000e8c0: 5f75 7365 7264 6174 6128 2929 3b0a 0909 _userdata());... │ │ │ +0000e8d0: 7d0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f }..
    │ │ │ +0000e900: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0000e910: 7370 3b33 3c2f 7464 3e3c 7464 3e3c 6120 sp;3../ │ │ │ +0000e940: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0000e950: 3533 3532 3c2f 613e 3c2f 7464 3e3c 7464 5352this should ret │ │ │ +0000e970: 7572 6e20 6f70 7469 6f6e 616c 3c3e 2e20 urn optional<>. │ │ │ +0000e980: 7069 6563 6520 696e 6465 7820 2d31 2073 piece index -1 s │ │ │ +0000e990: 686f 756c 6420 6e6f 7420 6265 2061 6c6c hould not be all │ │ │ +0000e9a0: 6f77 6564 3c2f 7464 3e3c 2f74 723e 3c74 owed

    this should ret │ │ │ +0000ea00: 7572 6e20 6f70 7469 6f6e 616c 3c3e 2e20 urn optional<>. │ │ │ +0000ea10: 7069 6563 6520 696e 6465 7820 2d31 2073 piece index -1 s │ │ │ +0000ea20: 686f 756c 6420 6e6f 7420 6265 0a61 6c6c hould not be.all │ │ │ +0000ea30: 6f77 6564 3c2f 6832 3e3c 6834 3e2e 2e2f owed

    ../ │ │ │ +0000ea40: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0000ea50: 3533 3532 3c2f 6834 3e3c 7072 6520 7374 5352

    .}..#ifndef T
    │ │ │ +0000eaa0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f53  ORRENT_DISABLE_S
    │ │ │ +0000eab0: 5550 4552 5345 4544 494e 470a 0976 6f69  UPERSEEDING..voi
    │ │ │ +0000eac0: 6420 746f 7272 656e 743a 3a73 6574 5f73  d torrent::set_s
    │ │ │ +0000ead0: 7570 6572 5f73 6565 6469 6e67 2862 6f6f  uper_seeding(boo
    │ │ │ +0000eae0: 6c20 636f 6e73 7420 6f6e 290a 097b 0a09  l const on)..{..
    │ │ │ +0000eaf0: 0969 6620 286f 6e20 3d3d 206d 5f73 7570  .if (on == m_sup
    │ │ │ +0000eb00: 6572 5f73 6565 6469 6e67 2920 7265 7475  er_seeding) retu
    │ │ │ +0000eb10: 726e 3b0a 0a09 096d 5f73 7570 6572 5f73  rn;....m_super_s
    │ │ │ +0000eb20: 6565 6469 6e67 203d 206f 6e3b 0a09 0973  eeding = on;...s
    │ │ │ +0000eb30: 6574 5f6e 6565 645f 7361 7665 5f72 6573  et_need_save_res
    │ │ │ +0000eb40: 756d 6528 746f 7272 656e 745f 6861 6e64  ume(torrent_hand
    │ │ │ +0000eb50: 6c65 3a3a 6966 5f73 7461 7465 5f63 6861  le::if_state_cha
    │ │ │ +0000eb60: 6e67 6564 293b 0a09 0973 7461 7465 5f75  nged);...state_u
    │ │ │ +0000eb70: 7064 6174 6564 2829 3b0a 0a09 0969 6620  pdated();....if 
    │ │ │ +0000eb80: 286d 5f73 7570 6572 5f73 6565 6469 6e67  (m_super_seeding
    │ │ │ +0000eb90: 2920 7265 7475 726e 3b0a 0a09 092f 2f20  ) return;....// 
    │ │ │ +0000eba0: 6469 7361 626c 6520 7375 7065 7220 7365  disable super se
    │ │ │ +0000ebb0: 6564 696e 6720 666f 7220 616c 6c20 7065  eding for all pe
    │ │ │ +0000ebc0: 6572 730a 0909 666f 7220 2861 7574 6f2a  ers...for (auto*
    │ │ │ +0000ebd0: 2070 6320 3a20 2a74 6869 7329 0a09 097b   pc : *this)...{
    │ │ │ +0000ebe0: 0a09 0909 7063 2d26 6774 3b73 7570 6572  ....pc->super
    │ │ │ +0000ebf0: 7365 6564 5f70 6965 6365 2870 6965 6365  seed_piece(piece
    │ │ │ +0000ec00: 5f69 6e64 6578 5f74 282d 3129 2c20 7069  _index_t(-1), pi
    │ │ │ +0000ec10: 6563 655f 696e 6465 785f 7428 2d31 2929  ece_index_t(-1))
    │ │ │ +0000ec20: 3b0a 0909 7d0a 097d 0a0a 3c64 6976 2073  ;...}..}..
    .piece_i │ │ │ +0000ec60: 6e64 6578 5f74 2074 6f72 7265 6e74 3a3a ndex_t torrent:: │ │ │ +0000ec70: 6765 745f 7069 6563 655f 746f 5f73 7570 get_piece_to_sup │ │ │ +0000ec80: 6572 5f73 6565 6428 7479 7065 645f 6269 er_seed(typed_bi │ │ │ +0000ec90: 7466 6965 6c64 266c 743b 7069 6563 655f tfield<piece_ │ │ │ +0000eca0: 696e 6465 785f 7426 6774 3b20 636f 6e73 index_t> cons │ │ │ +0000ecb0: 7426 616d 703b 2062 6974 7329 0a3c 2f64 t& bits)..{...// retur │ │ │ +0000ecd0: 6e20 6120 7069 6563 6520 7769 7468 206c n a piece with l │ │ │ +0000ece0: 6f77 2061 7661 696c 6162 696c 6974 7920 ow availability │ │ │ +0000ecf0: 7468 6174 2069 7320 6e6f 7420 696e 0a09 that is not in.. │ │ │ +0000ed00: 092f 2f20 7468 6520 6269 7466 6965 6c64 .// the bitfield │ │ │ +0000ed10: 2061 6e64 2074 6861 7420 6973 206e 6f74 and that is not │ │ │ +0000ed20: 2063 7572 7265 6e74 6c79 2062 6569 6e67 currently being │ │ │ +0000ed30: 2073 7570 6572 0a09 092f 2f20 7365 6564 super...// seed │ │ │ +0000ed40: 6564 2062 7920 616e 7920 7065 6572 0a09 ed by any peer.. │ │ │ +0000ed50: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +0000ed60: 6d5f 7375 7065 725f 7365 6564 696e 6729 m_super_seeding) │ │ │ +0000ed70: 3b0a 0a09 092f 2f20 646f 2061 206c 696e ;....// do a lin │ │ │ +0000ed80: 6561 7220 7365 6172 6368 2066 726f 6d20 ear search from │ │ │ +0000ed90: 7468 6520 6669 7273 7420 7069 6563 650a the first piece. │ │ │ +0000eda0: 0909 696e 7420 6d69 6e5f 6176 6169 6c61 ..int min_availa │ │ │ +0000edb0: 6269 6c69 7479 203d 2039 3939 393b 0a09 bility = 9999;.. │ │ │ +0000edc0: 0973 7464 3a3a 7665 6374 6f72 266c 743b .std::vector< │ │ │ +0000edd0: 7069 6563 655f 696e 6465 785f 7426 6774 piece_index_t> │ │ │ +0000ede0: 3b20 6176 6169 6c5f 7665 633b 0a09 0966 ; avail_vec;...f │ │ │ +0000edf0: 6f72 2028 6175 746f 2063 6f6e 7374 2069 or (auto const i │ │ │ +0000ee00: 203a 206d 5f74 6f72 7265 6e74 5f66 696c : m_torrent_fil │ │ │ +0000ee10: 652d 2667 743b 7069 6563 655f 7261 6e67 e->piece_rang │ │ │ +0000ee20: 6528 2929 0a09 097b 0a09 0909 6966 2028 e())...{....if ( │ │ │ +0000ee30: 6269 7473 5b69 5d29 2063 6f6e 7469 6e75 bits[i]) continu │ │ │ +0000ee40: 653b 0a0a 0909 0969 6e74 2061 7661 696c e;.....int avail │ │ │ +0000ee50: 6162 696c 6974 7920 3d20 303b 0a09 0909 ability = 0;.... │ │ │ +0000ee60: 666f 7220 2861 7574 6f2a 2070 6320 3a20 for (auto* pc : │ │ │ +0000ee70: 2a74 6869 7329 0a09 0909 7b0a 0909 0909 *this)....{..... │ │ │ +0000ee80: 6966 2028 7063 2d26 6774 3b73 7570 6572 if (pc->super │ │ │ +0000ee90: 5f73 6565 6465 645f 7069 6563 6528 6929 _seeded_piece(i) │ │ │ +0000eea0: 290a 0909 0909 7b0a 0909 0909 092f 2f20 ).....{......// │ │ │ +0000eeb0: 6176 6f69 6420 7375 7065 722d 7365 6564 avoid super-seed │ │ │ +0000eec0: 696e 6720 7468 6520 7361 6d65 2070 6965 ing the same pie │ │ │ +0000eed0: 6365 2074 6f20 6d6f 7265 2074 6861 6e20 ce to more than │ │ │ +0000eee0: 6f6e 650a 0909 0909 092f 2f20 7065 6572 one......// peer │ │ │ +0000eef0: 2069 6620 7765 2063 616e 2061 766f 6964 if we can avoid │ │ │ +0000ef00: 2069 742e 2044 6f20 7468 6973 2062 7920 it. Do this by │ │ │ +0000ef10: 6172 7469 6669 6369 616c 6c79 0a09 0909 artificially.... │ │ │ +0000ef20: 0909 2f2f 2069 6e63 7265 6173 6520 7468 ..// increase th │ │ │ +0000ef30: 6520 6176 6169 6c61 6269 6c69 7479 0a09 e availability.. │ │ │ +0000ef40: 0909 0909 6176 6169 6c61 6269 6c69 7479 ....availability │ │ │ +0000ef50: 203d 2039 3939 3b0a 0909 0909 0962 7265 = 999;......bre │ │ │ +0000ef60: 616b 3b0a 0909 0909 7d0a 0909 0909 6966 ak;.....}.....if │ │ │ +0000ef70: 2028 7063 2d26 6774 3b68 6173 5f70 6965 (pc->has_pie │ │ │ +0000ef80: 6365 2869 2929 202b 2b61 7661 696c 6162 ce(i)) ++availab │ │ │ +0000ef90: 696c 6974 793b 0a09 0909 7d0a 0909 0969 ility;....}....i │ │ │ +0000efa0: 6620 2861 7661 696c 6162 696c 6974 7920 f (availability │ │ │ +0000efb0: 2667 743b 206d 696e 5f61 7661 696c 6162 > min_availab │ │ │ +0000efc0: 696c 6974 7929 2063 6f6e 7469 6e75 653b ility) continue; │ │ │ +0000efd0: 0a09 0909 6966 2028 6176 6169 6c61 6269 ....if (availabi │ │ │ +0000efe0: 6c69 7479 203d 3d20 6d69 6e5f 6176 6169 lity == min_avai │ │ │ +0000eff0: 6c61 6269 6c69 7479 290a 0909 097b 0a09 lability)....{.. │ │ │ +0000f000: 0909 0961 7661 696c 5f76 6563 2e70 7573 ...avail_vec.pus │ │ │ +0000f010: 685f 6261 636b 2869 293b 0a3c 2f70 7265 h_back(i);.
    rele │ │ │ +0000f050: 7661 6e63 6526 6e62 7370 3b33 3c2f 7464 vance 3../src/ut_m │ │ │ +0000f090: 6574 6164 6174 612e 6370 703a 3234 333c etadata.cpp:243< │ │ │ +0000f0a0: 2f61 3e3c 2f74 643e 3c74 643e 7573 6520 /a>use │ │ │ +0000f0b0: 7468 6520 6175 783a 3a77 7269 7465 5f2a the aux::write_* │ │ │ +0000f0c0: 2066 756e 6374 696f 6e73 2061 6e64 2074 functions and t │ │ │ +0000f0d0: 6865 2073 7061 6e20 6865 7265 2069 6e73 he span here ins │ │ │ +0000f0e0: 7465 6164 2c20 6974 2077 696c 6c20 6669 tead, it will fi │ │ │ +0000f0f0: 7420 6265 7474 6572 2077 6974 6820 7365 t better with se │ │ │ +0000f100: 6e64 5f62 7566 6665 7228 293c 2f74 643e nd_buffer() │ │ │ +0000f110: 3c2f 7472 3e3c 7472 2069 643d 2232 3922

    use the │ │ │ +0000f160: 6175 783a 3a77 7269 7465 5f2a 2066 756e aux::write_* fun │ │ │ +0000f170: 6374 696f 6e73 2061 6e64 2074 6865 2073 ctions and the s │ │ │ +0000f180: 7061 6e20 6865 7265 2069 6e73 7465 6164 pan here instead │ │ │ +0000f190: 2c20 6974 0a77 696c 6c20 6669 7420 6265 , it.will fit be │ │ │ +0000f1a0: 7474 6572 2077 6974 6820 7365 6e64 5f62 tter with send_b │ │ │ +0000f1b0: 7566 6665 7228 293c 2f68 323e 3c68 343e uffer()

    │ │ │ +0000f1c0: 2e2e 2f73 7263 2f75 745f 6d65 7461 6461 ../src/ut_metada │ │ │ +0000f1d0: 7461 2e63 7070 3a32 3433 3c2f 6834 3e3c ta.cpp:243

    < │ │ │ +0000f1e0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0000f1f0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0000f200: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0000f210: 7820 2364 6464 3b22 3e09 0909 696e 7420 x #ddd;">...int │ │ │ +0000f220: 6d65 7461 6461 7461 5f70 6965 6365 5f73 metadata_piece_s │ │ │ +0000f230: 697a 6520 3d20 303b 0a0a 0909 0969 6620 ize = 0;.....if │ │ │ +0000f240: 286d 5f74 6f72 7265 6e74 2e76 616c 6964 (m_torrent.valid │ │ │ +0000f250: 5f6d 6574 6164 6174 6128 2929 0a09 0909 _metadata()).... │ │ │ +0000f260: 0965 5b22 746f 7461 6c5f 7369 7a65 225d .e["total_size"] │ │ │ +0000f270: 203d 206d 5f74 702e 6d65 7461 6461 7461 = m_tp.metadata │ │ │ +0000f280: 2829 2e73 697a 6528 293b 0a0a 0909 0969 ().size();.....i │ │ │ +0000f290: 6620 2874 7970 6520 3d3d 206d 7367 5f74 f (type == msg_t │ │ │ +0000f2a0: 3a3a 7069 6563 6529 0a09 0909 7b0a 0909 ::piece)....{... │ │ │ +0000f2b0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0000f2c0: 2870 6965 6365 2026 6774 3b3d 2030 2026 (piece >= 0 & │ │ │ +0000f2d0: 616d 703b 2661 6d70 3b20 7069 6563 6520 amp;& piece │ │ │ +0000f2e0: 266c 743b 2028 6d5f 7470 2e6d 6574 6164 < (m_tp.metad │ │ │ +0000f2f0: 6174 6128 292e 7369 7a65 2829 202b 2031 ata().size() + 1 │ │ │ +0000f300: 3620 2a20 3130 3234 202d 2031 2920 2f20 6 * 1024 - 1) / │ │ │ +0000f310: 2831 3620 2a20 3130 3234 2929 3b0a 0909 (16 * 1024));... │ │ │ +0000f320: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0000f330: 286d 5f70 632e 6173 736f 6369 6174 6564 (m_pc.associated │ │ │ +0000f340: 5f74 6f72 7265 6e74 2829 2e6c 6f63 6b28 _torrent().lock( │ │ │ +0000f350: 292d 2667 743b 7661 6c69 645f 6d65 7461 )->valid_meta │ │ │ +0000f360: 6461 7461 2829 293b 0a09 0909 0954 4f52 data());.....TOR │ │ │ +0000f370: 5245 4e54 5f41 5353 4552 5428 6d5f 746f RENT_ASSERT(m_to │ │ │ +0000f380: 7272 656e 742e 7661 6c69 645f 6d65 7461 rrent.valid_meta │ │ │ +0000f390: 6461 7461 2829 293b 0a0a 0909 0909 696e data());......in │ │ │ +0000f3a0: 7420 636f 6e73 7420 6f66 6673 6574 203d t const offset = │ │ │ +0000f3b0: 2070 6965 6365 202a 2031 3620 2a20 3130 piece * 16 * 10 │ │ │ +0000f3c0: 3234 3b0a 0909 0909 6d65 7461 6461 7461 24;.....metadata │ │ │ +0000f3d0: 203d 206d 5f74 702e 6d65 7461 6461 7461 = m_tp.metadata │ │ │ +0000f3e0: 2829 2e64 6174 6128 2920 2b20 6f66 6673 ().data() + offs │ │ │ +0000f3f0: 6574 3b0a 0909 0909 6d65 7461 6461 7461 et;.....metadata │ │ │ +0000f400: 5f70 6965 6365 5f73 697a 6520 3d20 7374 _piece_size = st │ │ │ +0000f410: 643a 3a6d 696e 280a 0909 0909 0969 6e74 d::min(......int │ │ │ +0000f420: 286d 5f74 702e 6d65 7461 6461 7461 2829 (m_tp.metadata() │ │ │ +0000f430: 2e73 697a 6528 2929 202d 206f 6666 7365 .size()) - offse │ │ │ +0000f440: 742c 2031 3620 2a20 3130 3234 293b 0a09 t, 16 * 1024);.. │ │ │ +0000f450: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0000f460: 5428 6d65 7461 6461 7461 5f70 6965 6365 T(metadata_piece │ │ │ +0000f470: 5f73 697a 6520 2667 743b 2030 293b 0a09 _size > 0);.. │ │ │ +0000f480: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0000f490: 5428 6f66 6673 6574 2026 6774 3b3d 2030 T(offset >= 0 │ │ │ +0000f4a0: 293b 0a09 0909 0954 4f52 5245 4e54 5f41 );.....TORRENT_A │ │ │ +0000f4b0: 5353 4552 5428 6f66 6673 6574 202b 206d SSERT(offset + m │ │ │ +0000f4c0: 6574 6164 6174 615f 7069 6563 655f 7369 etadata_piece_si │ │ │ +0000f4d0: 7a65 2026 6c74 3b3d 206d 5f74 702e 6d65 ze <= m_tp.me │ │ │ +0000f4e0: 7461 6461 7461 2829 2e73 697a 6528 2929 tadata().size()) │ │ │ +0000f4f0: 3b0a 0909 097d 0a0a 3c64 6976 2073 7479 ;....}..
    ...char ms │ │ │ +0000f530: 675b 3230 305d 3b0a 3c2f 6469 763e 0909 g[200];.
    .. │ │ │ +0000f540: 0963 6861 722a 2068 6561 6465 7220 3d20 .char* header = │ │ │ +0000f550: 6d73 673b 0a09 0909 6368 6172 2a20 7020 msg;....char* p │ │ │ +0000f560: 3d20 2661 6d70 3b6d 7367 5b36 5d3b 0a09 = &msg[6];.. │ │ │ +0000f570: 0909 696e 7420 636f 6e73 7420 6c65 6e20 ..int const len │ │ │ +0000f580: 3d20 6265 6e63 6f64 6528 702c 2065 293b = bencode(p, e); │ │ │ +0000f590: 0a09 0909 696e 7420 636f 6e73 7420 746f ....int const to │ │ │ +0000f5a0: 7461 6c5f 7369 7a65 203d 2032 202b 206c tal_size = 2 + l │ │ │ +0000f5b0: 656e 202b 206d 6574 6164 6174 615f 7069 en + metadata_pi │ │ │ +0000f5c0: 6563 655f 7369 7a65 3b0a 0909 096e 616d ece_size;....nam │ │ │ +0000f5d0: 6573 7061 6365 2069 6f20 3d20 6175 783b espace io = aux; │ │ │ +0000f5e0: 0a09 0909 696f 3a3a 7772 6974 655f 7569 ....io::write_ui │ │ │ +0000f5f0: 6e74 3332 2874 6f74 616c 5f73 697a 652c nt32(total_size, │ │ │ +0000f600: 2068 6561 6465 7229 3b0a 0909 0969 6f3a header);....io: │ │ │ +0000f610: 3a77 7269 7465 5f75 696e 7438 2861 7578 :write_uint8(aux │ │ │ +0000f620: 3a3a 6274 5f70 6565 725f 636f 6e6e 6563 ::bt_peer_connec │ │ │ +0000f630: 7469 6f6e 3a3a 6d73 675f 6578 7465 6e64 tion::msg_extend │ │ │ +0000f640: 6564 2c20 6865 6164 6572 293b 0a09 0909 ed, header);.... │ │ │ +0000f650: 696f 3a3a 7772 6974 655f 7569 6e74 3828 io::write_uint8( │ │ │ +0000f660: 6d5f 6d65 7373 6167 655f 696e 6465 782c m_message_index, │ │ │ +0000f670: 2068 6561 6465 7229 3b0a 0a09 0909 6d5f header);.....m_ │ │ │ +0000f680: 7063 2e73 656e 645f 6275 6666 6572 287b pc.send_buffer({ │ │ │ +0000f690: 6d73 672c 206c 656e 202b 2036 7d29 3b0a msg, len + 6});. │ │ │ +0000f6a0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0000f6b0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0000f6e0: 333c 2f74 643e 3c74 643e 3c61 2068 7265 3../src │ │ │ +0000f710: 2f73 6573 7369 6f6e 5f68 616e 646c 652e /session_handle. │ │ │ +0000f720: 6370 703a 3634 333c 2f61 3e3c 2f74 643e cpp:643 │ │ │ +0000f730: 3c74 643e 6578 706f 7365 2074 6865 2073 expose the s │ │ │ +0000f740: 6571 7565 6e63 655f 6e75 6d62 6572 2c20 equence_number, │ │ │ +0000f750: 7075 626c 6963 5f6b 6579 2c20 7365 6372 public_key, secr │ │ │ +0000f760: 6574 5f6b 6579 2061 6e64 2073 6967 6e61 et_key and signa │ │ │ +0000f770: 7475 7265 2074 7970 6573 2074 6f20 7468 ture types to th │ │ │ +0000f780: 6520 636c 6965 6e74 3c2f 7464 3e3c 2f74 e client

    expose the │ │ │ +0000f7e0: 7365 7175 656e 6365 5f6e 756d 6265 722c sequence_number, │ │ │ +0000f7f0: 2070 7562 6c69 635f 6b65 792c 2073 6563 public_key, sec │ │ │ +0000f800: 7265 745f 6b65 7920 616e 6420 7369 676e ret_key and sign │ │ │ +0000f810: 6174 7572 650a 7479 7065 7320 746f 2074 ature.types to t │ │ │ +0000f820: 6865 2063 6c69 656e 743c 2f68 323e 3c68 he client

    ../src/session │ │ │ +0000f840: 5f68 616e 646c 652e 6370 703a 3634 333c _handle.cpp:643< │ │ │ +0000f850: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .v
    │ │ │ +0000f890: 6f69 6420 7365 7373 696f 6e5f 6861 6e64  oid session_hand
    │ │ │ +0000f8a0: 6c65 3a3a 6468 745f 6765 745f 6974 656d  le::dht_get_item
    │ │ │ +0000f8b0: 2873 6861 315f 6861 7368 2063 6f6e 7374  (sha1_hash const
    │ │ │ +0000f8c0: 2661 6d70 3b20 7461 7267 6574 290a 097b  & target)..{
    │ │ │ +0000f8d0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ +0000f8e0: 5f44 4953 4142 4c45 5f44 4854 0a09 0961  _DISABLE_DHT...a
    │ │ │ +0000f8f0: 7379 6e63 5f63 616c 6c28 2661 6d70 3b73  sync_call(&s
    │ │ │ +0000f900: 6573 7369 6f6e 5f69 6d70 6c3a 3a64 6874  ession_impl::dht
    │ │ │ +0000f910: 5f67 6574 5f69 6d6d 7574 6162 6c65 5f69  _get_immutable_i
    │ │ │ +0000f920: 7465 6d2c 2074 6172 6765 7429 3b0a 2365  tem, target);.#e
    │ │ │ +0000f930: 6c73 650a 0909 544f 5252 454e 545f 554e  lse...TORRENT_UN
    │ │ │ +0000f940: 5553 4544 2874 6172 6765 7429 3b0a 2365  USED(target);.#e
    │ │ │ +0000f950: 6e64 6966 0a09 7d0a 0a09 766f 6964 2073  ndif..}...void s
    │ │ │ +0000f960: 6573 7369 6f6e 5f68 616e 646c 653a 3a64  ession_handle::d
    │ │ │ +0000f970: 6874 5f67 6574 5f69 7465 6d28 7374 643a  ht_get_item(std:
    │ │ │ +0000f980: 3a61 7272 6179 266c 743b 6368 6172 2c20  :array<char, 
    │ │ │ +0000f990: 3332 2667 743b 206b 6579 0a09 092c 2073  32> key..., s
    │ │ │ +0000f9a0: 7464 3a3a 7374 7269 6e67 2073 616c 7429  td::string salt)
    │ │ │ +0000f9b0: 0a09 7b0a 2369 666e 6465 6620 544f 5252  ..{.#ifndef TORR
    │ │ │ +0000f9c0: 454e 545f 4449 5341 424c 455f 4448 540a  ENT_DISABLE_DHT.
    │ │ │ +0000f9d0: 0909 6173 796e 635f 6361 6c6c 2826 616d  ..async_call(&am
    │ │ │ +0000f9e0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a  p;session_impl::
    │ │ │ +0000f9f0: 6468 745f 6765 745f 6d75 7461 626c 655f  dht_get_mutable_
    │ │ │ +0000fa00: 6974 656d 2c20 6b65 792c 2073 616c 7429  item, key, salt)
    │ │ │ +0000fa10: 3b0a 2365 6c73 650a 0909 544f 5252 454e  ;.#else...TORREN
    │ │ │ +0000fa20: 545f 554e 5553 4544 286b 6579 293b 0a09  T_UNUSED(key);..
    │ │ │ +0000fa30: 0954 4f52 5245 4e54 5f55 4e55 5345 4428  .TORRENT_UNUSED(
    │ │ │ +0000fa40: 7361 6c74 293b 0a23 656e 6469 660a 097d  salt);.#endif..}
    │ │ │ +0000fa50: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +0000fa80: 0973 6861 315f 6861 7368 2073 6573 7369 .sha1_hash sessi │ │ │ +0000fa90: 6f6e 5f68 616e 646c 653a 3a64 6874 5f70 on_handle::dht_p │ │ │ +0000faa0: 7574 5f69 7465 6d28 656e 7472 7920 6461 ut_item(entry da │ │ │ +0000fab0: 7461 290a 3c2f 6469 763e 097b 0a09 0973 ta).
    .{...s │ │ │ +0000fac0: 7464 3a3a 7665 6374 6f72 266c 743b 6368 td::vector<ch │ │ │ +0000fad0: 6172 2667 743b 2062 7566 3b0a 0909 6265 ar> buf;...be │ │ │ +0000fae0: 6e63 6f64 6528 7374 643a 3a62 6163 6b5f ncode(std::back_ │ │ │ +0000faf0: 696e 7365 7274 6572 2862 7566 292c 2064 inserter(buf), d │ │ │ +0000fb00: 6174 6129 3b0a 0909 7368 6131 5f68 6173 ata);...sha1_has │ │ │ +0000fb10: 6820 636f 6e73 7420 7265 7420 3d20 6861 h const ret = ha │ │ │ +0000fb20: 7368 6572 2862 7566 292e 6669 6e61 6c28 sher(buf).final( │ │ │ +0000fb30: 293b 0a0a 2369 666e 6465 6620 544f 5252 );..#ifndef TORR │ │ │ +0000fb40: 454e 545f 4449 5341 424c 455f 4448 540a ENT_DISABLE_DHT. │ │ │ +0000fb50: 0909 6173 796e 635f 6361 6c6c 2826 616d ..async_call(&am │ │ │ +0000fb60: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0000fb70: 6468 745f 7075 745f 696d 6d75 7461 626c dht_put_immutabl │ │ │ +0000fb80: 655f 6974 656d 2c20 6461 7461 2c20 7265 e_item, data, re │ │ │ +0000fb90: 7429 3b0a 2365 6e64 6966 0a09 0972 6574 t);.#endif...ret │ │ │ +0000fba0: 7572 6e20 7265 743b 0a09 7d0a 0a09 766f urn ret;..}...vo │ │ │ +0000fbb0: 6964 2073 6573 7369 6f6e 5f68 616e 646c id session_handl │ │ │ +0000fbc0: 653a 3a64 6874 5f70 7574 5f69 7465 6d28 e::dht_put_item( │ │ │ +0000fbd0: 7374 643a 3a61 7272 6179 266c 743b 6368 std::array<ch │ │ │ +0000fbe0: 6172 2c20 3332 2667 743b 206b 6579 0a09 ar, 32> key.. │ │ │ +0000fbf0: 092c 2073 7464 3a3a 6675 6e63 7469 6f6e ., std::function │ │ │ +0000fc00: 266c 743b 766f 6964 2865 6e74 7279 2661 <void(entry&a │ │ │ +0000fc10: 6d70 3b2c 2073 7464 3a3a 6172 7261 7926 mp;, std::array& │ │ │ +0000fc20: 6c74 3b63 6861 722c 3634 2667 743b 2661 lt;char,64>&a │ │ │ +0000fc30: 6d70 3b0a 0909 092c 2073 7464 3a3a 696e mp;...., std::in │ │ │ +0000fc40: 7436 345f 7426 616d 703b 2c20 7374 643a t64_t&, std: │ │ │ +0000fc50: 3a73 7472 696e 6720 636f 6e73 7426 616d :string const&am │ │ │ +0000fc60: 703b 2926 6774 3b20 6362 0a09 092c 2073 p;)> cb..., s │ │ │ +0000fc70: 7464 3a3a 7374 7269 6e67 2073 616c 7429 td::string salt) │ │ │ +0000fc80: 0a09 7b0a 2369 666e 6465 6620 544f 5252 ..{.#ifndef TORR │ │ │ +0000fc90: 454e 545f 4449 5341 424c 455f 4448 540a ENT_DISABLE_DHT. │ │ │ +0000fca0: 0909 6173 796e 635f 6361 6c6c 2826 616d ..async_call(&am │ │ │ +0000fcb0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0000fcc0: 6468 745f 7075 745f 6d75 7461 626c 655f dht_put_mutable_ │ │ │ +0000fcd0: 6974 656d 2c20 6b65 792c 2063 622c 2073 item, key, cb, s │ │ │ +0000fce0: 616c 7429 3b0a 2365 6c73 650a 0909 544f alt);.#else...TO │ │ │ +0000fcf0: 5252 454e 545f 554e 5553 4544 286b 6579 RRENT_UNUSED(key │ │ │ +0000fd00: 293b 0a09 0954 4f52 5245 4e54 5f55 4e55 );...TORRENT_UNU │ │ │ +0000fd10: 5345 4428 6362 293b 0a09 0954 4f52 5245 SED(cb);...TORRE │ │ │ +0000fd20: 4e54 5f55 4e55 5345 4428 7361 6c74 293b NT_UNUSED(salt); │ │ │ +0000fd30: 0a23 656e 6469 660a 097d 0a0a 0976 6f69 .#endif..}...voi │ │ │ +0000fd40: 6420 7365 7373 696f 6e5f 6861 6e64 6c65 d session_handle │ │ │ +0000fd50: 3a3a 6468 745f 6765 745f 7065 6572 7328 ::dht_get_peers( │ │ │ +0000fd60: 7368 6131 5f68 6173 6820 636f 6e73 7426 sha1_hash const& │ │ │ +0000fd70: 616d 703b 2069 6e66 6f5f 6861 7368 290a amp; info_hash). │ │ │ +0000fd80: 097b 0a23 6966 6e64 6566 2054 4f52 5245 .{.#ifndef TORRE │ │ │ +0000fd90: 4e54 5f44 4953 4142 4c45 5f44 4854 0a09 NT_DISABLE_DHT.. │ │ │ +0000fda0: 0961 7379 6e63 5f63 616c 6c28 2661 6d70 .async_call(& │ │ │ +0000fdb0: 3b73 6573 7369 6f6e 5f69 6d70 6c3a 3a64 ;session_impl::d │ │ │ +0000fdc0: 6874 5f67 6574 5f70 6565 7273 2c20 696e ht_get_peers, in │ │ │ +0000fdd0: 666f 5f68 6173 6829 3b0a 2365 6c73 650a fo_hash);.#else. │ │ │ 0000fde0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ 0000fdf0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ 0000fe20: 333c 2f74 643e 3c74 643e 3c61 2068 7265 3../inc │ │ │ @@ -4425,5117 +4425,5117 @@ │ │ │ 00011480: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ 000114b0: 6e63 6526 6e62 7370 3b33 3c2f 7464 3e3c nce 3< │ │ │ 000114c0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/li │ │ │ -000114f0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7065 btorrent/aux_/pe │ │ │ -00011500: 5f63 7279 7074 6f2e 6870 703a 3439 3c2f _crypto.hpp:49dh_ke │ │ │ -00011520: 795f 6578 6368 616e 6765 2073 686f 756c y_exchange shoul │ │ │ -00011530: 6420 7072 6f62 6162 6c79 206d 6f76 6520 d probably move │ │ │ -00011540: 696e 746f 2069 7473 206f 776e 2066 696c into its own fil │ │ │ -00011550: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069 e

    dh │ │ │ -000115a0: 5f6b 6579 5f65 7863 6861 6e67 6520 7368 _key_exchange sh │ │ │ -000115b0: 6f75 6c64 2070 726f 6261 626c 7920 6d6f ould probably mo │ │ │ -000115c0: 7665 2069 6e74 6f20 6974 7320 6f77 6e20 ve into its own │ │ │ -000115d0: 6669 6c65 3c2f 6832 3e3c 6834 3e2e 2e2f file

    ../ │ │ │ -000115e0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -000115f0: 6e74 2f61 7578 5f2f 7065 5f63 7279 7074 nt/aux_/pe_crypt │ │ │ -00011600: 6f2e 6870 703a 3439 3c2f 6834 3e3c 7072 o.hpp:49

    .#include │ │ │ -00011650: 2026 6c74 3b6c 6973 7426 6774 3b0a 2369 <list>.#i │ │ │ -00011660: 6e63 6c75 6465 2026 6c74 3b61 7272 6179 nclude <array │ │ │ -00011670: 2667 743b 0a23 696e 636c 7564 6520 266c >.#include &l │ │ │ -00011680: 743b 6373 7464 696e 7426 6774 3b0a 0a6e t;cstdint>..n │ │ │ -00011690: 616d 6573 7061 6365 206c 6962 746f 7272 amespace libtorr │ │ │ -000116a0: 656e 743a 3a61 7578 207b 0a0a 096e 616d ent::aux {...nam │ │ │ -000116b0: 6573 7061 6365 206d 7020 3d20 626f 6f73 espace mp = boos │ │ │ -000116c0: 743a 3a6d 756c 7469 7072 6563 6973 696f t::multiprecisio │ │ │ -000116d0: 6e3b 0a0a 0975 7369 6e67 206b 6579 5f74 n;...using key_t │ │ │ -000116e0: 203d 206d 703a 3a6e 756d 6265 7226 6c74 = mp::number< │ │ │ -000116f0: 3b6d 703a 3a63 7070 5f69 6e74 5f62 6163 ;mp::cpp_int_bac │ │ │ -00011700: 6b65 6e64 266c 743b 3736 382c 2037 3638 kend<768, 768 │ │ │ -00011710: 2c20 6d70 3a3a 756e 7369 676e 6564 5f6d , mp::unsigned_m │ │ │ -00011720: 6167 6e69 7475 6465 2c20 6d70 3a3a 756e agnitude, mp::un │ │ │ -00011730: 6368 6563 6b65 642c 2076 6f69 6426 6774 checked, void> │ │ │ -00011740: 3b26 6774 3b3b 0a0a 0954 4f52 5245 4e54 ;>;...TORRENT │ │ │ -00011750: 5f45 5854 5241 5f45 5850 4f52 5420 7374 _EXTRA_EXPORT st │ │ │ -00011760: 643a 3a61 7272 6179 266c 743b 6368 6172 d::array<char │ │ │ -00011770: 2c20 3936 2667 743b 2065 7870 6f72 745f , 96> export_ │ │ │ -00011780: 6b65 7928 6b65 795f 7420 636f 6e73 7426 key(key_t const& │ │ │ -00011790: 616d 703b 206b 293b 0a0a 092f 2f20 5243 amp; k);...// RC │ │ │ -000117a0: 3420 7374 6174 6520 6672 6f6d 206c 6962 4 state from lib │ │ │ -000117b0: 746f 6d63 7279 7074 0a09 7374 7275 6374 tomcrypt..struct │ │ │ -000117c0: 2072 6334 207b 0a09 0969 6e74 2078 3b0a rc4 {...int x;. │ │ │ -000117d0: 0909 696e 7420 793b 0a09 0961 7578 3a3a ..int y;...aux:: │ │ │ -000117e0: 6172 7261 7926 6c74 3b73 7464 3a3a 7569 array<std::ui │ │ │ -000117f0: 6e74 385f 742c 2032 3536 2667 743b 2062 nt8_t, 256> b │ │ │ -00011800: 7566 3b0a 097d 3b0a 0a3c 6469 7620 7374 uf;..};..
    .class TO │ │ │ -00011840: 5252 454e 545f 4558 5452 415f 4558 504f RRENT_EXTRA_EXPO │ │ │ -00011850: 5254 2064 685f 6b65 795f 6578 6368 616e RT dh_key_exchan │ │ │ -00011860: 6765 0a3c 2f64 6976 3e09 7b0a 0970 7562 ge.
    .{..pub │ │ │ -00011870: 6c69 633a 0a09 0964 685f 6b65 795f 6578 lic:...dh_key_ex │ │ │ -00011880: 6368 616e 6765 2829 3b0a 0a09 092f 2f20 change();....// │ │ │ -00011890: 4765 7420 6c6f 6361 6c20 7075 626c 6963 Get local public │ │ │ -000118a0: 206b 6579 0a09 096b 6579 5f74 2063 6f6e key...key_t con │ │ │ -000118b0: 7374 2661 6d70 3b20 6765 745f 6c6f 6361 st& get_loca │ │ │ -000118c0: 6c5f 6b65 7928 2920 636f 6e73 7420 7b20 l_key() const { │ │ │ -000118d0: 7265 7475 726e 206d 5f64 685f 6c6f 6361 return m_dh_loca │ │ │ -000118e0: 6c5f 6b65 793b 207d 0a0a 0909 2f2f 2072 l_key; }....// r │ │ │ -000118f0: 6561 6420 7265 6d6f 7465 5f70 7562 6b65 ead remote_pubke │ │ │ -00011900: 792c 2067 656e 6572 6174 6520 616e 6420 y, generate and │ │ │ -00011910: 7374 6f72 6520 7368 6172 6564 2073 6563 store shared sec │ │ │ -00011920: 7265 7420 696e 0a09 092f 2f20 6d5f 6468 ret in...// m_dh │ │ │ -00011930: 5f73 6861 7265 645f 7365 6372 6574 2e20 _shared_secret. │ │ │ -00011940: 5265 7475 726e 7320 6661 6c73 6520 6966 Returns false if │ │ │ -00011950: 2074 6865 2072 656d 6f74 6520 7075 626c the remote publ │ │ │ -00011960: 6963 206b 6579 2069 730a 0909 2f2f 2064 ic key is...// d │ │ │ -00011970: 6567 656e 6572 6174 6520 2869 2e65 2e20 egenerate (i.e. │ │ │ -00011980: 6f75 7473 6964 6520 7468 6520 7261 6e67 outside the rang │ │ │ -00011990: 6520 5b32 2c20 702d 325d 2920 616e 6420 e [2, p-2]) and │ │ │ -000119a0: 7468 6520 7368 6172 6564 0a09 092f 2f20 the shared...// │ │ │ -000119b0: 7365 6372 6574 2077 6173 206e 6f74 2063 secret was not c │ │ │ -000119c0: 6f6d 7075 7465 642e 0a09 0962 6f6f 6c20 omputed....bool │ │ │ -000119d0: 636f 6d70 7574 655f 7365 6372 6574 2873 compute_secret(s │ │ │ -000119e0: 7464 3a3a 7569 6e74 385f 7420 636f 6e73 td::uint8_t cons │ │ │ -000119f0: 742a 2072 656d 6f74 655f 7075 626b 6579 t* remote_pubkey │ │ │ -00011a00: 293b 0a09 0962 6f6f 6c20 636f 6d70 7574 );...bool comput │ │ │ -00011a10: 655f 7365 6372 6574 286b 6579 5f74 2063 e_secret(key_t c │ │ │ -00011a20: 6f6e 7374 2661 6d70 3b20 7265 6d6f 7465 onst& remote │ │ │ -00011a30: 5f70 7562 6b65 7929 3b0a 0a09 096b 6579 _pubkey);....key │ │ │ -00011a40: 5f74 2063 6f6e 7374 2661 6d70 3b20 6765 _t const& ge │ │ │ -00011a50: 745f 7365 6372 6574 2829 2063 6f6e 7374 t_secret() const │ │ │ -00011a60: 207b 2072 6574 7572 6e20 6d5f 6468 5f73 { return m_dh_s │ │ │ -00011a70: 6861 7265 645f 7365 6372 6574 3b20 7d0a hared_secret; }. │ │ │ -00011a80: 0a09 0973 6861 315f 6861 7368 2063 6f6e ...sha1_hash con │ │ │ -00011a90: 7374 2661 6d70 3b20 6765 745f 6861 7368 st& get_hash │ │ │ -00011aa0: 5f78 6f72 5f6d 6173 6b28 2920 636f 6e73 _xor_mask() cons │ │ │ -00011ab0: 7420 7b20 7265 7475 726e 206d 5f78 6f72 t { return m_xor │ │ │ -00011ac0: 5f6d 6173 6b3b 207d 0a0a 0970 7269 7661 _mask; }...priva │ │ │ -00011ad0: 7465 3a0a 0a09 096b 6579 5f74 206d 5f64 te:....key_t m_d │ │ │ -00011ae0: 685f 6c6f 6361 6c5f 6b65 793b 0a09 096b h_local_key;...k │ │ │ -00011af0: 6579 5f74 206d 5f64 685f 6c6f 6361 6c5f ey_t m_dh_local_ │ │ │ -00011b00: 7365 6372 6574 3b0a 0909 6b65 795f 7420 secret;...key_t │ │ │ -00011b10: 6d5f 6468 5f73 6861 7265 645f 7365 6372 m_dh_shared_secr │ │ │ -00011b20: 6574 3b0a 0909 7368 6131 5f68 6173 6820 et;...sha1_hash │ │ │ -00011b30: 6d5f 786f 725f 6d61 736b 3b0a 097d 3b0a m_xor_mask;..};. │ │ │ -00011b40: 0a09 7374 7275 6374 2054 4f52 5245 4e54 ..struct TORRENT │ │ │ -00011b50: 5f45 5854 5241 5f45 5850 4f52 5420 656e _EXTRA_EXPORT en │ │ │ -00011b60: 6372 7970 7469 6f6e 5f68 616e 646c 6572 cryption_handler │ │ │ -00011b70: 0a09 7b0a 0909 7374 643a 3a74 7570 6c65 ..{...std::tuple │ │ │ -00011b80: 266c 743b 696e 742c 2073 7061 6e26 6c74 <int, span< │ │ │ -00011b90: 3b73 7061 6e26 6c74 3b63 6861 7220 636f ;span<char co │ │ │ -00011ba0: 6e73 7426 6774 3b26 6774 3b26 6774 3b0a nst>>>. │ │ │ -00011bb0: 0909 656e 6372 7970 7428 7370 616e 266c ..encrypt(span&l │ │ │ -00011bc0: 743b 7370 616e 266c 743b 6368 6172 2667 t;span<char&g │ │ │ -00011bd0: 743b 2667 743b 2069 6f76 6563 293b 0a3c t;> iovec);.< │ │ │ -00011be0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00011bf0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00011c00: 6f75 6e64 3a20 2366 6363 223e 3c74 643e ound: #fcc"> │ │ │ -00011c10: 7265 6c65 7661 6e63 6526 6e62 7370 3b33 relevance 3 │ │ │ -00011c20: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../incl │ │ │ -00011c50: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00011c60: 7578 5f2f 7374 6174 2e68 7070 3a32 3335 ux_/stat.hpp:235 │ │ │ -00011c70: 3c2f 613e 3c2f 7464 3e3c 7464 3e65 7665 eve │ │ │ -00011c80: 7279 7468 696e 6720 6275 7420 7061 796c rything but payl │ │ │ -00011c90: 6f61 6420 636f 756e 7465 7273 2061 6e64 oad counters and │ │ │ -00011ca0: 2072 6174 6573 2063 6f75 6c64 2070 726f rates could pro │ │ │ -00011cb0: 6261 626c 7920 6265 2072 656d 6f76 6564 bably be removed │ │ │ -00011cc0: 2066 726f 6d20 6865 7265 3c2f 7464 3e3c from here< │ │ │ -00011cd0: 2f74 723e 3c74 7220 6964 3d22 3334 2220 /tr>

    everythin │ │ │ -00011d20: 6720 6275 7420 7061 796c 6f61 6420 636f g but payload co │ │ │ -00011d30: 756e 7465 7273 2061 6e64 2072 6174 6573 unters and rates │ │ │ -00011d40: 2063 6f75 6c64 2070 726f 6261 626c 7920 could probably │ │ │ -00011d50: 6265 0a72 656d 6f76 6564 2066 726f 6d20 be.removed from │ │ │ -00011d60: 6865 7265 3c2f 6832 3e3c 6834 3e2e 2e2f here

    ../ │ │ │ -00011d70: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00011d80: 6e74 2f61 7578 5f2f 7374 6174 2e68 7070 nt/aux_/stat.hpp │ │ │ -00011d90: 3a32 3335 3c2f 6834 3e3c 7072 6520 7374 :235

    ..// peer_con
    │ │ │ -00011de0: 6e65 6374 696f 6e20 6973 206f 7065 6e65  nection is opene
    │ │ │ -00011df0: 6420 616e 6420 6861 7665 2073 6f6d 6520  d and have some 
    │ │ │ -00011e00: 7072 6576 696f 7573 0a09 092f 2f20 7472  previous...// tr
    │ │ │ -00011e10: 616e 7366 6572 7320 6672 6f6d 2065 6172  ansfers from ear
    │ │ │ -00011e20: 6c69 6572 2063 6f6e 6e65 6374 696f 6e73  lier connections
    │ │ │ -00011e30: 2e0a 0909 766f 6964 2061 6464 5f73 7461  ....void add_sta
    │ │ │ -00011e40: 7428 7374 643a 3a69 6e74 3634 5f74 2064  t(std::int64_t d
    │ │ │ -00011e50: 6f77 6e6c 6f61 6465 642c 2073 7464 3a3a  ownloaded, std::
    │ │ │ -00011e60: 696e 7436 345f 7420 7570 6c6f 6164 6564  int64_t uploaded
    │ │ │ -00011e70: 290a 0909 7b0a 0909 096d 5f73 7461 745b  )...{....m_stat[
    │ │ │ -00011e80: 646f 776e 6c6f 6164 5f70 6179 6c6f 6164  download_payload
    │ │ │ -00011e90: 5d2e 6f66 6673 6574 2864 6f77 6e6c 6f61  ].offset(downloa
    │ │ │ -00011ea0: 6465 6429 3b0a 0909 096d 5f73 7461 745b  ded);....m_stat[
    │ │ │ -00011eb0: 7570 6c6f 6164 5f70 6179 6c6f 6164 5d2e  upload_payload].
    │ │ │ -00011ec0: 6f66 6673 6574 2875 706c 6f61 6465 6429  offset(uploaded)
    │ │ │ -00011ed0: 3b0a 0909 7d0a 0a09 0969 6e74 206c 6173  ;...}....int las
    │ │ │ -00011ee0: 745f 7061 796c 6f61 645f 646f 776e 6c6f  t_payload_downlo
    │ │ │ -00011ef0: 6164 6564 2829 2063 6f6e 7374 0a09 097b  aded() const...{
    │ │ │ -00011f00: 2072 6574 7572 6e20 6d5f 7374 6174 5b64   return m_stat[d
    │ │ │ -00011f10: 6f77 6e6c 6f61 645f 7061 796c 6f61 645d  ownload_payload]
    │ │ │ -00011f20: 2e63 6f75 6e74 6572 2829 3b20 7d0a 0909  .counter(); }...
    │ │ │ -00011f30: 696e 7420 6c61 7374 5f70 6179 6c6f 6164  int last_payload
    │ │ │ -00011f40: 5f75 706c 6f61 6465 6428 2920 636f 6e73  _uploaded() cons
    │ │ │ -00011f50: 740a 0909 7b20 7265 7475 726e 206d 5f73  t...{ return m_s
    │ │ │ -00011f60: 7461 745b 7570 6c6f 6164 5f70 6179 6c6f  tat[upload_paylo
    │ │ │ -00011f70: 6164 5d2e 636f 756e 7465 7228 293b 207d  ad].counter(); }
    │ │ │ -00011f80: 0a09 0969 6e74 206c 6173 745f 7072 6f74  ...int last_prot
    │ │ │ -00011f90: 6f63 6f6c 5f64 6f77 6e6c 6f61 6465 6428  ocol_downloaded(
    │ │ │ -00011fa0: 2920 636f 6e73 740a 0909 7b20 7265 7475  ) const...{ retu
    │ │ │ -00011fb0: 726e 206d 5f73 7461 745b 646f 776e 6c6f  rn m_stat[downlo
    │ │ │ -00011fc0: 6164 5f70 726f 746f 636f 6c5d 2e63 6f75  ad_protocol].cou
    │ │ │ -00011fd0: 6e74 6572 2829 3b20 7d0a 0909 696e 7420  nter(); }...int 
    │ │ │ -00011fe0: 6c61 7374 5f70 726f 746f 636f 6c5f 7570  last_protocol_up
    │ │ │ -00011ff0: 6c6f 6164 6564 2829 2063 6f6e 7374 0a09  loaded() const..
    │ │ │ -00012000: 097b 2072 6574 7572 6e20 6d5f 7374 6174  .{ return m_stat
    │ │ │ -00012010: 5b75 706c 6f61 645f 7072 6f74 6f63 6f6c  [upload_protocol
    │ │ │ -00012020: 5d2e 636f 756e 7465 7228 293b 207d 0a0a  ].counter(); }..
    │ │ │ -00012030: 0909 2f2f 2074 6865 7365 2061 7265 2074  ..// these are t
    │ │ │ -00012040: 6865 2063 6861 6e6e 656c 7320 7765 206b  he channels we k
    │ │ │ -00012050: 6565 7020 7374 6174 7320 666f 720a 0909  eep stats for...
    │ │ │ -00012060: 656e 756d 0a09 097b 0a3c 6469 7620 7374  enum...{.
    ...upload │ │ │ -000120a0: 5f70 6179 6c6f 6164 2c0a 3c2f 6469 763e _payload,.
    │ │ │ -000120b0: 0909 0975 706c 6f61 645f 7072 6f74 6f63 ...upload_protoc │ │ │ -000120c0: 6f6c 2c0a 0909 0964 6f77 6e6c 6f61 645f ol,....download_ │ │ │ -000120d0: 7061 796c 6f61 642c 0a09 0909 646f 776e payload,....down │ │ │ -000120e0: 6c6f 6164 5f70 726f 746f 636f 6c2c 0a09 load_protocol,.. │ │ │ -000120f0: 0909 7570 6c6f 6164 5f69 705f 7072 6f74 ..upload_ip_prot │ │ │ -00012100: 6f63 6f6c 2c0a 0909 0964 6f77 6e6c 6f61 ocol,....downloa │ │ │ -00012110: 645f 6970 5f70 726f 746f 636f 6c2c 0a09 d_ip_protocol,.. │ │ │ -00012120: 0909 6e75 6d5f 6368 616e 6e65 6c73 0a09 ..num_channels.. │ │ │ -00012130: 097d 3b0a 0a09 0976 6f69 6420 636c 6561 .};....void clea │ │ │ -00012140: 7228 290a 0909 7b0a 0909 0966 6f72 2028 r()...{....for ( │ │ │ -00012150: 696e 7420 6920 3d20 303b 2069 2026 6c74 int i = 0; i < │ │ │ -00012160: 3b20 6e75 6d5f 6368 616e 6e65 6c73 3b20 ; num_channels; │ │ │ -00012170: 2b2b 6929 0a09 0909 096d 5f73 7461 745b ++i).....m_stat[ │ │ │ -00012180: 695d 2e63 6c65 6172 2829 3b0a 0909 7d0a i].clear();...}. │ │ │ -00012190: 0a09 0973 7461 745f 6368 616e 6e65 6c20 ...stat_channel │ │ │ -000121a0: 636f 6e73 7426 616d 703b 206f 7065 7261 const& opera │ │ │ -000121b0: 746f 725b 5d28 696e 7420 6929 2063 6f6e tor[](int i) con │ │ │ -000121c0: 7374 0a09 097b 0a09 0909 544f 5252 454e st...{....TORREN │ │ │ -000121d0: 545f 4153 5345 5254 2869 2026 6774 3b3d T_ASSERT(i >= │ │ │ -000121e0: 2030 2026 616d 703b 2661 6d70 3b20 6920 0 && i │ │ │ -000121f0: 266c 743b 206e 756d 5f63 6861 6e6e 656c < num_channel │ │ │ -00012200: 7329 3b0a 0909 0972 6574 7572 6e20 6d5f s);....return m_ │ │ │ -00012210: 7374 6174 5b69 5d3b 0a09 097d 0a0a 0970 stat[i];...}...p │ │ │ -00012220: 7269 7661 7465 3a0a 0a09 0961 7578 3a3a rivate:....aux:: │ │ │ -00012230: 6172 7261 7926 6c74 3b73 7461 745f 6368 array<stat_ch │ │ │ -00012240: 616e 6e65 6c2c 206e 756d 5f63 6861 6e6e annel, num_chann │ │ │ -00012250: 656c 7326 6774 3b20 6d5f 7374 6174 3b0a els> m_stat;. │ │ │ -00012260: 097d 3b0a 0a7d 0a0a 2365 6e64 6966 202f .};..}..#endif / │ │ │ -00012270: 2f20 544f 5252 454e 545f 5354 4154 5f48 / TORRENT_STAT_H │ │ │ -00012280: 5050 5f49 4e43 4c55 4445 440a 3c2f 7072 PP_INCLUDED.rel │ │ │ -000122c0: 6576 616e 6365 266e 6273 703b 333c 2f74 evance 3../include │ │ │ -00012300: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -00012310: 2f65 6e75 6d5f 6e65 742e 6870 703a 3134 /enum_net.hpp:14 │ │ │ -00012320: 313c 2f61 3e3c 2f74 643e 3c74 643e 7573 1us │ │ │ -00012330: 6520 7374 7269 6e67 5f76 6965 7720 666f e string_view fo │ │ │ -00012340: 7220 6465 7669 6365 5f6e 616d 653c 2f74 r device_name

    use st │ │ │ -000123a0: 7269 6e67 5f76 6965 7720 666f 7220 6465 ring_view for de │ │ │ -000123b0: 7669 6365 5f6e 616d 653c 2f68 323e 3c68 vice_name

    ../include/lib │ │ │ -000123d0: 746f 7272 656e 742f 6175 785f 2f65 6e75 torrent/aux_/enu │ │ │ -000123e0: 6d5f 6e65 742e 6870 703a 3134 313c 2f68 m_net.hpp:141
    .// 
    │ │ │ -00012430: 7265 7475 726e 206e 756c 6c6f 7074 2e0a  return nullopt..
    │ │ │ -00012440: 0954 4f52 5245 4e54 5f45 5854 5241 5f45  .TORRENT_EXTRA_E
    │ │ │ -00012450: 5850 4f52 5420 7374 643a 3a6f 7074 696f  XPORT std::optio
    │ │ │ -00012460: 6e61 6c26 6c74 3b61 6464 7265 7373 2667  nal<address&g
    │ │ │ -00012470: 743b 2067 6574 5f67 6174 6577 6179 280a  t; get_gateway(.
    │ │ │ -00012480: 0909 6970 5f69 6e74 6572 6661 6365 2063  ..ip_interface c
    │ │ │ -00012490: 6f6e 7374 2661 6d70 3b20 6966 6163 652c  onst& iface,
    │ │ │ -000124a0: 2073 7061 6e26 6c74 3b69 705f 726f 7574   span<ip_rout
    │ │ │ -000124b0: 6520 636f 6e73 7426 6774 3b20 726f 7574  e const> rout
    │ │ │ -000124c0: 6573 293b 0a0a 092f 2f20 7265 7475 726e  es);...// return
    │ │ │ -000124d0: 7320 7768 6574 6865 7220 7468 6572 6520  s whether there 
    │ │ │ -000124e0: 6973 2061 2072 6f75 7465 2074 6f20 7468  is a route to th
    │ │ │ -000124f0: 6520 7370 6563 6966 6965 6420 6465 7669  e specified devi
    │ │ │ -00012500: 6365 2066 6f72 2066 6f72 2061 6e79 2067  ce for for any g
    │ │ │ -00012510: 6c6f 6261 6c0a 092f 2f20 696e 7465 726e  lobal..// intern
    │ │ │ -00012520: 6574 2061 6464 7265 7373 206f 6620 7468  et address of th
    │ │ │ -00012530: 6520 7370 6563 6966 6965 6420 6164 6472  e specified addr
    │ │ │ -00012540: 6573 7320 6661 6d69 6c79 2e0a 0954 4f52  ess family...TOR
    │ │ │ -00012550: 5245 4e54 5f45 5854 5241 5f45 5850 4f52  RENT_EXTRA_EXPOR
    │ │ │ -00012560: 5420 626f 6f6c 2068 6173 5f69 6e74 6572  T bool has_inter
    │ │ │ -00012570: 6e65 745f 726f 7574 6528 7374 7269 6e67  net_route(string
    │ │ │ -00012580: 5f76 6965 7720 6465 7669 6365 2c20 696e  _view device, in
    │ │ │ -00012590: 7420 6661 6d69 6c79 0a09 092c 2073 7061  t family..., spa
    │ │ │ -000125a0: 6e26 6c74 3b69 705f 726f 7574 6520 636f  n<ip_route co
    │ │ │ -000125b0: 6e73 7426 6774 3b20 726f 7574 6573 293b  nst> routes);
    │ │ │ -000125c0: 0a0a 092f 2f20 7265 7475 726e 7320 7768  ...// returns wh
    │ │ │ -000125d0: 6574 6865 7220 7468 6572 6520 6172 6520  ether there are 
    │ │ │ -000125e0: 2a61 6e79 2a20 726f 7574 6573 2074 6f20  *any* routes to 
    │ │ │ -000125f0: 7468 6520 696e 7465 726e 6574 2069 6e20  the internet in 
    │ │ │ -00012600: 7468 6520 726f 7574 696e 670a 092f 2f20  the routing..// 
    │ │ │ -00012610: 7461 626c 652e 2054 6869 7320 6361 6e20  table. This can 
    │ │ │ -00012620: 6265 2075 7365 6420 746f 2064 6574 6572  be used to deter
    │ │ │ -00012630: 6d69 6e65 2069 6620 7468 6520 726f 7574  mine if the rout
    │ │ │ -00012640: 696e 6720 7461 626c 6520 6973 2066 756c  ing table is ful
    │ │ │ -00012650: 6c79 0a09 2f2f 2070 6f70 756c 6174 6564  ly..// populated
    │ │ │ -00012660: 206f 7220 6e6f 742e 0a09 544f 5252 454e   or not...TORREN
    │ │ │ -00012670: 545f 4558 5452 415f 4558 504f 5254 2062  T_EXTRA_EXPORT b
    │ │ │ -00012680: 6f6f 6c20 6861 735f 616e 795f 696e 7465  ool has_any_inte
    │ │ │ -00012690: 726e 6574 5f72 6f75 7465 2873 7061 6e26  rnet_route(span&
    │ │ │ -000126a0: 6c74 3b69 705f 726f 7574 6520 636f 6e73  lt;ip_route cons
    │ │ │ -000126b0: 7426 6774 3b20 726f 7574 6573 293b 0a0a  t> routes);..
    │ │ │ -000126c0: 092f 2f20 6174 7465 6d70 7420 746f 2062  .// attempt to b
    │ │ │ -000126d0: 696e 6420 736f 636b 6574 2074 6f20 7468  ind socket to th
    │ │ │ -000126e0: 6520 6465 7669 6365 2077 6974 6820 7468  e device with th
    │ │ │ -000126f0: 6520 7370 6563 6966 6965 6420 6e61 6d65  e specified name
    │ │ │ -00012700: 2e20 466f 7220 7379 7374 656d 730a 092f  . For systems../
    │ │ │ -00012710: 2f20 7468 6174 2064 6f6e 2774 2073 7570  / that don't sup
    │ │ │ -00012720: 706f 7274 2053 4f5f 4249 4e44 544f 4445  port SO_BINDTODE
    │ │ │ -00012730: 5649 4345 2074 6865 2073 6f63 6b65 7420  VICE the socket 
    │ │ │ -00012740: 7769 6c6c 2062 6520 626f 756e 6420 746f  will be bound to
    │ │ │ -00012750: 206f 6e65 206f 6620 7468 650a 092f 2f20   one of the..// 
    │ │ │ -00012760: 4950 2061 6464 7265 7373 6573 206f 6620  IP addresses of 
    │ │ │ -00012770: 7468 6520 7370 6563 6966 6965 6420 6465  the specified de
    │ │ │ -00012780: 7669 6365 2e20 496e 2074 6869 7320 6361  vice. In this ca
    │ │ │ -00012790: 7365 2069 7420 6973 206e 6563 6573 7361  se it is necessa
    │ │ │ -000127a0: 7279 2074 6f0a 092f 2f20 7665 7269 6679  ry to..// verify
    │ │ │ -000127b0: 2074 6865 206c 6f63 616c 2065 6e64 706f   the local endpo
    │ │ │ -000127c0: 696e 7420 6f66 2074 6865 2073 6f63 6b65  int of the socke
    │ │ │ -000127d0: 7420 6f6e 6365 2074 6865 2063 6f6e 6e65  t once the conne
    │ │ │ -000127e0: 6374 696f 6e20 6973 2065 7374 6162 6c69  ction is establi
    │ │ │ -000127f0: 7368 6564 2e0a 092f 2f20 7468 6520 7265  shed...// the re
    │ │ │ -00012800: 7475 726e 6564 2061 6464 7265 7373 2069  turned address i
    │ │ │ -00012810: 7320 7468 6520 6970 2074 6865 2073 6f63  s the ip the soc
    │ │ │ -00012820: 6b65 7420 7761 7320 626f 756e 6420 746f  ket was bound to
    │ │ │ -00012830: 2028 6f72 2061 6464 7265 7373 5f76 343a   (or address_v4:
    │ │ │ -00012840: 3a61 6e79 2829 0a09 2f2f 2069 6e20 6361  :any()..// in ca
    │ │ │ -00012850: 7365 2053 4f5f 4249 4e44 544f 4445 5649  se SO_BINDTODEVI
    │ │ │ -00012860: 4345 2073 7563 6365 6564 6564 2061 6e64  CE succeeded and
    │ │ │ -00012870: 2077 6520 646f 6e27 7420 6e65 6564 2074   we don't need t
    │ │ │ -00012880: 6f20 7665 7269 6679 2069 7429 2e0a 3c64  o verify it)...tem
    │ │ │ -000128c0: 706c 6174 6520 266c 743b 636c 6173 7320  plate <class 
    │ │ │ -000128d0: 536f 636b 6574 2667 743b 0a3c 2f64 6976  Socket>.
    .address bind_s │ │ │ -000128f0: 6f63 6b65 745f 746f 5f64 6576 6963 6528 ocket_to_device( │ │ │ -00012900: 696f 5f63 6f6e 7465 7874 2661 6d70 3b20 io_context& │ │ │ -00012910: 696f 732c 2053 6f63 6b65 7426 616d 703b ios, Socket& │ │ │ -00012920: 2073 6f63 6b0a 0909 2c20 7463 7020 636f sock..., tcp co │ │ │ -00012930: 6e73 7426 616d 703b 2070 726f 746f 636f nst& protoco │ │ │ -00012940: 6c0a 0909 2c20 6368 6172 2063 6f6e 7374 l..., char const │ │ │ -00012950: 2a20 6465 7669 6365 5f6e 616d 652c 2069 * device_name, i │ │ │ -00012960: 6e74 2070 6f72 742c 2065 7272 6f72 5f63 nt port, error_c │ │ │ -00012970: 6f64 6526 616d 703b 2065 6329 0a09 7b0a ode& ec)..{. │ │ │ -00012980: 0909 7463 703a 3a65 6e64 706f 696e 7420 ..tcp::endpoint │ │ │ -00012990: 6269 6e64 5f65 7028 6164 6472 6573 735f bind_ep(address_ │ │ │ -000129a0: 7634 3a3a 616e 7928 292c 2073 7464 3a3a v4::any(), std:: │ │ │ -000129b0: 7569 6e74 3136 5f74 2870 6f72 7429 293b uint16_t(port)); │ │ │ -000129c0: 0a0a 0909 6164 6472 6573 7320 6970 203d ....address ip = │ │ │ -000129d0: 206d 616b 655f 6164 6472 6573 7328 6465 make_address(de │ │ │ -000129e0: 7669 6365 5f6e 616d 652c 2065 6329 3b0a vice_name, ec);. │ │ │ -000129f0: 0909 6966 2028 2165 6329 0a09 097b 0a09 ..if (!ec)...{.. │ │ │ -00012a00: 0909 2f2f 2074 6869 7320 6973 2074 6f20 ..// this is to │ │ │ -00012a10: 636f 7665 7220 7468 6520 6361 7365 2077 cover the case w │ │ │ -00012a20: 6865 7265 2022 302e 302e 302e 3022 2069 here "0.0.0.0" i │ │ │ -00012a30: 7320 636f 6e73 6964 6572 6564 2061 6e79 s considered any │ │ │ -00012a40: 2049 5076 3420 6f72 0a09 0909 2f2f 2049 IPv4 or....// I │ │ │ -00012a50: 5076 3620 6164 6472 6573 732e 2049 6620 Pv6 address. If │ │ │ -00012a60: 7765 2772 6520 6173 6b69 6e67 2074 6f20 we're asking to │ │ │ -00012a70: 6265 2062 6f75 6e64 2074 6f20 616e 2049 be bound to an I │ │ │ -00012a80: 5076 3620 6164 6472 6573 7320 616e 640a Pv6 address and. │ │ │ -00012a90: 0909 092f 2f20 7072 6f76 6964 696e 6720 ...// providing │ │ │ -00012aa0: 302e 302e 302e 3020 6173 2074 6865 2064 0.0.0.0 as the d │ │ │ -00012ab0: 6576 6963 652c 2074 7572 6e20 6974 2069 evice, turn it i │ │ │ -00012ac0: 6e74 6f20 223a 3a22 0a09 0909 6966 2028 nto "::"....if ( │ │ │ -00012ad0: 6970 203d 3d20 6164 6472 6573 735f 7634 ip == address_v4 │ │ │ -00012ae0: 3a3a 616e 7928 2920 2661 6d70 3b26 616d ::any() &&am │ │ │ -00012af0: 703b 2070 726f 746f 636f 6c20 3d3d 2062 p; protocol == b │ │ │ -00012b00: 6f6f 7374 3a3a 6173 696f 3a3a 6970 3a3a oost::asio::ip:: │ │ │ -00012b10: 7463 703a 3a76 3628 2929 0a09 0909 0969 tcp::v6()).....i │ │ │ -00012b20: 7020 3d20 6164 6472 6573 735f 7636 3a3a p = address_v6:: │ │ │ -00012b30: 616e 7928 293b 0a09 0909 6269 6e64 5f65 any();....bind_e │ │ │ -00012b40: 702e 6164 6472 6573 7328 6970 293b 0a09 p.address(ip);.. │ │ │ -00012b50: 0909 2f2f 2069 7420 6170 7065 6172 7320 ..// it appears │ │ │ -00012b60: 746f 2062 6520 616e 2049 502e 204a 7573 to be an IP. Jus │ │ │ -00012b70: 7420 6269 6e64 2074 6f20 7468 6174 2061 t bind to that a │ │ │ -00012b80: 6464 7265 7373 0a09 0909 736f 636b 2e62 ddress....sock.b │ │ │ -00012b90: 696e 6428 6269 6e64 5f65 702c 2065 6329 ind(bind_ep, ec) │ │ │ -00012ba0: 3b0a 0909 0972 6574 7572 6e20 6269 6e64 ;....return bind │ │ │ -00012bb0: 5f65 702e 6164 6472 6573 7328 293b 0a09 _ep.address();.. │ │ │ -00012bc0: 097d 0a0a 0909 6563 2e63 6c65 6172 2829 .}....ec.clear() │ │ │ -00012bd0: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f48 ;..#if TORRENT_H │ │ │ -00012be0: 4153 5f42 494e 4454 4f44 4556 4943 450a AS_BINDTODEVICE. │ │ │ -00012bf0: 0909 2f2f 2074 7279 2074 6f20 7573 6520 ..// try to use │ │ │ -00012c00: 534f 5f42 494e 4454 4f44 4556 4943 4520 SO_BINDTODEVICE │ │ │ -00012c10: 6865 7265 2c20 6966 2074 6861 7420 6578 here, if that ex │ │ │ -00012c20: 6973 7473 2e20 4966 2069 7420 6661 696c ists. If it fail │ │ │ -00012c30: 732c 0a09 092f 2f20 6661 6c6c 2062 6163 s,...// fall bac │ │ │ -00012c40: 6b20 746f 2074 6865 206d 6563 6861 6e69 k to the mechani │ │ │ -00012c50: 736d 2077 6520 6861 7665 2062 656c 6f77 sm we have below │ │ │ -00012c60: 0a09 0961 7578 3a3a 6269 6e64 5f64 6576 ...aux::bind_dev │ │ │ -00012c70: 6963 6528 736f 636b 2c20 6465 7669 6365 ice(sock, device │ │ │ -00012c80: 5f6e 616d 652c 2065 6329 3b0a 0909 6966 _name, ec);...if │ │ │ -00012c90: 2028 6563 290a 2365 6e64 6966 0a09 097b (ec).#endif...{ │ │ │ -00012ca0: 0a09 0909 6563 2e63 6c65 6172 2829 3b0a ....ec.clear();. │ │ │ -00012cb0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e │ │ │ -00012cc0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00012cf0: 333c 2f74 643e 3c74 643e 3c61 2068 7265 3../inc │ │ │ -00012d20: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00012d30: 6175 785f 2f77 6562 5f70 6565 725f 636f aux_/web_peer_co │ │ │ -00012d40: 6e6e 6563 7469 6f6e 2e68 7070 3a39 363c nnection.hpp:96< │ │ │ -00012d50: 2f61 3e3c 2f74 643e 3c74 643e 6966 2077 /a>if w │ │ │ -00012d60: 6520 6d61 6b65 2074 6869 7320 6265 2061 e make this be a │ │ │ -00012d70: 2064 6973 6b5f 6275 6666 6572 5f68 6f6c disk_buffer_hol │ │ │ -00012d80: 6465 7220 696e 7374 6561 6420 7765 2077 der instead we w │ │ │ -00012d90: 6f75 6c64 2073 6176 6520 6120 636f 7079 ould save a copy │ │ │ -00012da0: 2075 7365 2061 6c6c 6f63 6174 655f 6469 use allocate_di │ │ │ -00012db0: 736b 5f72 6563 6569 7665 5f62 7566 6665 sk_receive_buffe │ │ │ -00012dc0: 7220 616e 6420 7265 6c65 6173 655f 6469 r and release_di │ │ │ -00012dd0: 736b 5f72 6563 6569 7665 5f62 7566 6665 sk_receive_buffe │ │ │ -00012de0: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    if │ │ │ -00012e30: 2077 6520 6d61 6b65 2074 6869 7320 6265 we make this be │ │ │ -00012e40: 2061 2064 6973 6b5f 6275 6666 6572 5f68 a disk_buffer_h │ │ │ -00012e50: 6f6c 6465 7220 696e 7374 6561 640a 7765 older instead.we │ │ │ -00012e60: 2077 6f75 6c64 2073 6176 6520 6120 636f would save a co │ │ │ -00012e70: 7079 0a75 7365 2061 6c6c 6f63 6174 655f py.use allocate_ │ │ │ -00012e80: 6469 736b 5f72 6563 6569 7665 5f62 7566 disk_receive_buf │ │ │ -00012e90: 6665 7220 616e 6420 7265 6c65 6173 655f fer and release_ │ │ │ -00012ea0: 6469 736b 5f72 6563 6569 7665 5f62 7566 disk_receive_buf │ │ │ -00012eb0: 6665 723c 2f68 323e 3c68 343e 2e2e 2f69 fer

    ../i │ │ │ -00012ec0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00012ed0: 742f 6175 785f 2f77 6562 5f70 6565 725f t/aux_/web_peer_ │ │ │ -00012ee0: 636f 6e6e 6563 7469 6f6e 2e68 7070 3a39 connection.hpp:9 │ │ │ -00012ef0: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ -00012f30: 0909 7069 6563 655f 626c 6f63 6b5f 7072  ..piece_block_pr
    │ │ │ -00012f40: 6f67 7265 7373 2064 6f77 6e6c 6f61 6469  ogress downloadi
    │ │ │ -00012f50: 6e67 5f70 6965 6365 5f70 726f 6772 6573  ng_piece_progres
    │ │ │ -00012f60: 7328 2920 636f 6e73 7420 6f76 6572 7269  s() const overri
    │ │ │ -00012f70: 6465 3b0a 0a09 0976 6f69 6420 6861 6e64  de;....void hand
    │ │ │ -00012f80: 6c65 5f70 6164 6669 6c65 2829 3b0a 0a09  le_padfile();...
    │ │ │ -00012f90: 092f 2f20 7468 6973 2068 6173 206f 6e65  .// this has one
    │ │ │ -00012fa0: 2065 6e74 7279 2070 6572 2068 7474 702d   entry per http-
    │ │ │ -00012fb0: 7265 7175 6573 740a 0909 2f2f 2028 6d69  request...// (mi
    │ │ │ -00012fc0: 6768 7420 6265 206d 6f72 6520 7468 616e  ght be more than
    │ │ │ -00012fd0: 2074 6865 2062 7420 7265 7175 6573 7473   the bt requests
    │ │ │ -00012fe0: 290a 0909 7374 7275 6374 2066 696c 655f  )...struct file_
    │ │ │ -00012ff0: 7265 7175 6573 745f 740a 0909 7b0a 0909  request_t...{...
    │ │ │ -00013000: 0966 696c 655f 696e 6465 785f 7420 6669  .file_index_t fi
    │ │ │ -00013010: 6c65 5f69 6e64 6578 3b0a 0909 0969 6e74  le_index;....int
    │ │ │ -00013020: 206c 656e 6774 683b 0a09 0909 7374 643a   length;....std:
    │ │ │ -00013030: 3a69 6e74 3634 5f74 2073 7461 7274 3b0a  :int64_t start;.
    │ │ │ -00013040: 0909 7d3b 0a09 0973 7464 3a3a 6465 7175  ..};...std::dequ
    │ │ │ -00013050: 6526 6c74 3b66 696c 655f 7265 7175 6573  e<file_reques
    │ │ │ -00013060: 745f 7426 6774 3b20 6d5f 6669 6c65 5f72  t_t> m_file_r
    │ │ │ -00013070: 6571 7565 7374 733b 0a0a 0909 7374 643a  equests;....std:
    │ │ │ -00013080: 3a73 7472 696e 6720 6d5f 7572 6c3b 0a0a  :string m_url;..
    │ │ │ -00013090: 0909 6175 783a 3a77 6562 5f73 6565 645f  ..aux::web_seed_
    │ │ │ -000130a0: 742a 206d 5f77 6562 3b0a 0a09 092f 2f20  t* m_web;....// 
    │ │ │ -000130b0: 7468 6973 2069 7320 7573 6564 2066 6f72  this is used for
    │ │ │ -000130c0: 2069 6e74 6572 6d65 6469 6174 6520 7374   intermediate st
    │ │ │ -000130d0: 6f72 6167 6520 6f66 2070 6965 6365 7320  orage of pieces 
    │ │ │ -000130e0: 746f 2062 6520 6465 6c69 7665 7265 6420  to be delivered 
    │ │ │ -000130f0: 746f 2074 6865 0a09 092f 2f20 6269 7474  to the...// bitt
    │ │ │ -00013100: 6f72 7265 6e74 2065 6e67 696e 650a 3c64  orrent engine...au
    │ │ │ -00013140: 783a 3a76 6563 746f 7226 6c74 3b63 6861  x::vector<cha
    │ │ │ -00013150: 7226 6774 3b20 6d5f 7069 6563 653b 0a3c  r> m_piece;.<
    │ │ │ -00013160: 2f64 6976 3e0a 0909 2f2f 2074 6865 206e  /div>...// the n
    │ │ │ -00013170: 756d 6265 7220 6f66 2062 7974 6573 2077  umber of bytes w
    │ │ │ -00013180: 6527 7665 2066 6f72 7761 7264 6564 2074  e've forwarded t
    │ │ │ -00013190: 6f20 7468 6520 696e 636f 6d69 6e67 5f70  o the incoming_p
    │ │ │ -000131a0: 6179 6c6f 6164 2829 2066 756e 6374 696f  ayload() functio
    │ │ │ -000131b0: 6e0a 0909 2f2f 2069 6e20 7468 6520 6375  n...// in the cu
    │ │ │ -000131c0: 7272 656e 7420 4854 5450 2072 6573 706f  rrent HTTP respo
    │ │ │ -000131d0: 6e73 652e 2075 7365 6420 746f 206b 6e6f  nse. used to kno
    │ │ │ -000131e0: 7720 7768 6572 6520 696e 2074 6865 2062  w where in the b
    │ │ │ -000131f0: 7566 6665 7220 7468 650a 0909 2f2f 206e  uffer the...// n
    │ │ │ -00013200: 6578 7420 7265 7370 6f6e 7365 2073 7461  ext response sta
    │ │ │ -00013210: 7274 730a 0909 696e 7420 6d5f 7265 6365  rts...int m_rece
    │ │ │ -00013220: 6976 6564 5f62 6f64 793b 0a0a 0909 2f2f  ived_body;....//
    │ │ │ -00013230: 2074 6869 7320 6973 2074 6865 206f 6666   this is the off
    │ │ │ -00013240: 7365 7420 696e 7369 6465 2074 6865 2063  set inside the c
    │ │ │ -00013250: 7572 7265 6e74 2072 6563 6569 7665 0a09  urrent receive..
    │ │ │ -00013260: 092f 2f20 6275 6666 6572 2077 6865 7265  .// buffer where
    │ │ │ -00013270: 2074 6865 206e 6578 7420 6368 756e 6b20   the next chunk 
    │ │ │ -00013280: 6865 6164 6572 2077 696c 6c20 6265 2e0a  header will be..
    │ │ │ -00013290: 0909 2f2f 2074 6869 7320 6973 2075 7064  ..// this is upd
    │ │ │ -000132a0: 6174 6564 2066 6f72 2065 6163 6820 6368  ated for each ch
    │ │ │ -000132b0: 756e 6b20 6865 6164 6572 2074 6861 7427  unk header that'
    │ │ │ -000132c0: 730a 0909 2f2f 2070 6172 7365 642e 2049  s...// parsed. I
    │ │ │ -000132d0: 7420 646f 6573 206e 6f74 206e 6563 6573  t does not neces
    │ │ │ -000132e0: 7361 7269 6c79 2070 6f69 6e74 2074 6f20  sarily point to 
    │ │ │ -000132f0: 6120 7661 6c69 640a 0909 2f2f 206f 6666  a valid...// off
    │ │ │ -00013300: 7365 7420 696e 2074 6865 2072 6563 6569  set in the recei
    │ │ │ -00013310: 7665 2062 7566 6665 722c 2069 6620 7765  ve buffer, if we
    │ │ │ -00013320: 2068 6176 656e 2774 2072 6563 6569 7665   haven't receive
    │ │ │ -00013330: 640a 0909 2f2f 2069 7420 7965 742e 2054  d...// it yet. T
    │ │ │ -00013340: 6869 7320 6f66 6673 6574 206e 6576 6572  his offset never
    │ │ │ -00013350: 2069 6e63 6c75 6465 7320 7468 6520 4854   includes the HT
    │ │ │ -00013360: 5450 2068 6561 6465 720a 0909 696e 7420  TP header...int 
    │ │ │ -00013370: 6d5f 6368 756e 6b5f 706f 733b 0a0a 0909  m_chunk_pos;....
    │ │ │ -00013380: 2f2f 2074 6869 7320 6973 2074 6865 206e  // this is the n
    │ │ │ -00013390: 756d 6265 7220 6f66 2062 7974 6573 2077  umber of bytes w
    │ │ │ -000133a0: 6527 7665 2061 6c72 6561 6479 2072 6563  e've already rec
    │ │ │ -000133b0: 6569 7665 640a 0909 2f2f 2066 726f 6d20  eived...// from 
    │ │ │ -000133c0: 7468 6520 6e65 7874 2063 6875 6e6b 2068  the next chunk h
    │ │ │ -000133d0: 6561 6465 7220 7765 2772 6520 7761 6974  eader we're wait
    │ │ │ -000133e0: 696e 6720 666f 720a 0909 696e 7420 6d5f  ing for...int m_
    │ │ │ -000133f0: 7061 7274 6961 6c5f 6368 756e 6b5f 6865  partial_chunk_he
    │ │ │ -00013400: 6164 6572 3b0a 0a09 092f 2f20 7468 6520  ader;....// the 
    │ │ │ -00013410: 6e75 6d62 6572 206f 6620 7265 7370 6f6e  number of respon
    │ │ │ -00013420: 7365 7320 7765 2776 6520 7265 6365 6976  ses we've receiv
    │ │ │ -00013430: 6564 2073 6f20 6661 7220 6f6e 0a09 092f  ed so far on.../
    │ │ │ -00013440: 2f20 7468 6973 2063 6f6e 6e65 6374 696f  / this connectio
    │ │ │ -00013450: 6e0a 0909 696e 7420 6d5f 6e75 6d5f 7265  n...int m_num_re
    │ │ │ -00013460: 7370 6f6e 7365 733b 0a09 7d3b 0a7d 0a0a  sponses;..};.}..
    │ │ │ -00013470: 2365 6e64 6966 202f 2f20 544f 5252 454e  #endif // TORREN
    │ │ │ -00013480: 545f 5745 425f 5045 4552 5f43 4f4e 4e45  T_WEB_PEER_CONNE
    │ │ │ -00013490: 4354 494f 4e5f 4850 505f 494e 434c 5544  CTION_HPP_INCLUD
    │ │ │ -000134a0: 4544 0a3c 2f70 7265 3e3c 2f74 643e 3c2f  ED.
    │ │ │ -000134d0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -000134e0: 7370 3b33 3c2f 7464 3e3c 7464 3e3c 6120 sp;3
    ../ │ │ │ -00013510: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00013520: 6e74 2f61 7578 5f2f 746f 7272 656e 742e nt/aux_/torrent. │ │ │ -00013530: 6870 703a 3134 3737 3c2f 613e 3c2f 7464 hpp:1477factor out │ │ │ -00013550: 7072 6564 6963 7469 7665 2070 6965 6365 predictive piece │ │ │ -00013560: 7320 616e 6420 616c 6c20 6f70 6572 6174 s and all operat │ │ │ -00013570: 696f 6e73 206f 6e20 6974 2069 6e74 6f20 ions on it into │ │ │ -00013580: 6120 7365 7061 7261 7465 2063 6c61 7373 a separate class │ │ │ -00013590: 2028 746f 2075 7365 2061 7320 6d65 6d62 (to use as memb │ │ │ -000135a0: 6572 2068 6572 6520 696e 7374 6561 6429 er here instead) │ │ │ -000135b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    fac │ │ │ -00013600: 746f 7220 6f75 7420 7072 6564 6963 7469 tor out predicti │ │ │ -00013610: 7665 2070 6965 6365 7320 616e 6420 616c ve pieces and al │ │ │ -00013620: 6c20 6f70 6572 6174 696f 6e73 206f 6e20 l operations on │ │ │ -00013630: 6974 2069 6e74 6f20 610a 7365 7061 7261 it into a.separa │ │ │ -00013640: 7465 2063 6c61 7373 2028 746f 2075 7365 te class (to use │ │ │ -00013650: 2061 7320 6d65 6d62 6572 2068 6572 6520 as member here │ │ │ -00013660: 696e 7374 6561 6429 3c2f 6832 3e3c 6834 instead)

    ../include/libt │ │ │ -00013680: 6f72 7265 6e74 2f61 7578 5f2f 746f 7272 orrent/aux_/torr │ │ │ -00013690: 656e 742e 6870 703a 3134 3737 3c2f 6834 ent.hpp:1477

    ..std
    │ │ │ -000136e0: 3a3a 7374 7269 6e67 206d 5f74 7261 636b  ::string m_track
    │ │ │ -000136f0: 6572 6964 3b0a 2369 6620 544f 5252 454e  erid;.#if TORREN
    │ │ │ -00013700: 545f 4142 495f 5645 5253 494f 4e20 3d3d  T_ABI_VERSION ==
    │ │ │ -00013710: 2031 0a09 092f 2f20 6465 7072 6563 6174   1...// deprecat
    │ │ │ -00013720: 6564 2069 6e20 312e 310a 0909 7374 643a  ed in 1.1...std:
    │ │ │ -00013730: 3a73 7472 696e 6720 6d5f 7573 6572 6e61  :string m_userna
    │ │ │ -00013740: 6d65 3b0a 0909 7374 643a 3a73 7472 696e  me;...std::strin
    │ │ │ -00013750: 6720 6d5f 7061 7373 776f 7264 3b0a 2365  g m_password;.#e
    │ │ │ -00013760: 6e64 6966 0a0a 0909 7374 643a 3a73 7472  ndif....std::str
    │ │ │ -00013770: 696e 6720 6d5f 7361 7665 5f70 6174 683b  ing m_save_path;
    │ │ │ -00013780: 0a09 0973 7464 3a3a 7374 7269 6e67 206d  ...std::string m
    │ │ │ -00013790: 5f70 6172 745f 6669 6c65 5f64 6972 3b0a  _part_file_dir;.
    │ │ │ -000137a0: 0909 6175 783a 3a63 6163 6865 645f 736c  ..aux::cached_sl
    │ │ │ -000137b0: 6f74 206d 5f6e 616d 655f 6964 783b 0a0a  ot m_name_idx;..
    │ │ │ -000137c0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -000137d0: 4449 5341 424c 455f 5052 4544 4943 5449  DISABLE_PREDICTI
    │ │ │ -000137e0: 5645 5f50 4945 4345 530a 0909 2f2f 2074  VE_PIECES...// t
    │ │ │ -000137f0: 6869 7320 6973 2061 206c 6973 7420 6f66  his is a list of
    │ │ │ -00013800: 2061 6c6c 2070 6965 6365 7320 7468 6174   all pieces that
    │ │ │ -00013810: 2077 6520 6861 7665 2061 6e6e 6f75 6e63   we have announc
    │ │ │ -00013820: 6564 0a09 092f 2f20 6173 2068 6176 696e  ed...// as havin
    │ │ │ -00013830: 672c 2077 6974 686f 7574 2061 6374 7561  g, without actua
    │ │ │ -00013840: 6c6c 7920 6861 7669 6e67 2079 6574 2e20  lly having yet. 
    │ │ │ -00013850: 4966 2077 6520 7265 6365 6976 650a 0909  If we receive...
    │ │ │ -00013860: 2f2f 2061 2072 6571 7565 7374 2066 6f72  // a request for
    │ │ │ -00013870: 2061 2070 6965 6365 2069 6e20 7468 6973   a piece in this
    │ │ │ -00013880: 206c 6973 742c 2077 6520 6e65 6564 2074   list, we need t
    │ │ │ -00013890: 6f20 686f 6c64 206f 6666 0a09 092f 2f20  o hold off...// 
    │ │ │ -000138a0: 6f6e 2072 6573 706f 6e64 696e 6720 756e  on responding un
    │ │ │ -000138b0: 7469 6c20 7765 2068 6176 6520 636f 6d70  til we have comp
    │ │ │ -000138c0: 6c65 7465 6420 7468 6520 7069 6563 6520  leted the piece 
    │ │ │ -000138d0: 616e 640a 0909 2f2f 2076 6572 6966 6965  and...// verifie
    │ │ │ -000138e0: 6420 6974 7320 6861 7368 2e20 4966 2074  d its hash. If t
    │ │ │ -000138f0: 6865 2068 6173 6820 6661 696c 732c 2073  he hash fails, s
    │ │ │ -00013900: 656e 6420 7265 6a65 6374 2074 6f0a 0909  end reject to...
    │ │ │ -00013910: 2f2f 2070 6565 7273 2077 6974 6820 6f75  // peers with ou
    │ │ │ -00013920: 7473 7461 6e64 696e 6720 7265 7175 6573  tstanding reques
    │ │ │ -00013930: 7473 2c20 616e 6420 646f 6e74 5f68 6176  ts, and dont_hav
    │ │ │ -00013940: 6520 746f 206f 7468 6572 0a09 092f 2f20  e to other...// 
    │ │ │ -00013950: 7065 6572 732e 2054 6869 7320 7665 6374  peers. This vect
    │ │ │ -00013960: 6f72 2069 7320 6f72 6465 7265 642c 2074  or is ordered, t
    │ │ │ -00013970: 6f20 6d61 6b65 206c 6f6f 6b75 7073 2066  o make lookups f
    │ │ │ -00013980: 6173 742e 0a0a 3c64 6976 2073 7479 6c65  ast...
    ..std::vecto │ │ │ -000139c0: 7226 6c74 3b70 6965 6365 5f69 6e64 6578 r<piece_index │ │ │ -000139d0: 5f74 2667 743b 206d 5f70 7265 6469 6374 _t> m_predict │ │ │ -000139e0: 6976 655f 7069 6563 6573 3b0a 3c2f 6469 ive_pieces;.#endif....// v │ │ │ -00013a00: 3220 6d65 726b 6c65 2074 7265 6520 666f 2 merkle tree fo │ │ │ -00013a10: 7220 6561 6368 2066 696c 650a 0909 6175 r each file...au │ │ │ -00013a20: 783a 3a76 6563 746f 7226 6c74 3b61 7578 x::vector<aux │ │ │ -00013a30: 3a3a 6d65 726b 6c65 5f74 7265 652c 2066 ::merkle_tree, f │ │ │ -00013a40: 696c 655f 696e 6465 785f 7426 6774 3b20 ile_index_t> │ │ │ -00013a50: 6d5f 6d65 726b 6c65 5f74 7265 6573 3b0a m_merkle_trees;. │ │ │ -00013a60: 0a09 092f 2f20 7468 6520 7065 7266 6f72 ...// the perfor │ │ │ -00013a70: 6d61 6e63 6520 636f 756e 7465 7273 206f mance counters o │ │ │ -00013a80: 6620 7468 6973 2073 6573 7369 6f6e 0a09 f this session.. │ │ │ -00013a90: 0963 6f75 6e74 6572 7326 616d 703b 206d .counters& m │ │ │ -00013aa0: 5f73 7461 7473 5f63 6f75 6e74 6572 733b _stats_counters; │ │ │ -00013ab0: 0a0a 0909 2f2f 2065 6163 6820 6269 7420 ....// each bit │ │ │ -00013ac0: 7265 7072 6573 656e 7473 2061 2070 6965 represents a pie │ │ │ -00013ad0: 6365 2e20 6120 7365 7420 6269 7420 6d65 ce. a set bit me │ │ │ -00013ae0: 616e 730a 0909 2f2f 2074 6865 2070 6965 ans...// the pie │ │ │ -00013af0: 6365 2068 6173 2068 6164 2069 7473 2068 ce has had its h │ │ │ -00013b00: 6173 6820 7665 7269 6669 6564 2e20 5468 ash verified. Th │ │ │ -00013b10: 6973 0a09 092f 2f20 6973 206f 6e6c 7920 is...// is only │ │ │ -00013b20: 7573 6564 2069 6e20 7365 6564 206d 6f64 used in seed mod │ │ │ -00013b30: 6520 2877 6865 6e20 6d5f 7365 6564 5f6d e (when m_seed_m │ │ │ -00013b40: 6f64 650a 0909 2f2f 2069 7320 7472 7565 ode...// is true │ │ │ -00013b50: 290a 0909 7479 7065 645f 6269 7466 6965 )...typed_bitfie │ │ │ -00013b60: 6c64 266c 743b 7069 6563 655f 696e 6465 ld<piece_inde │ │ │ -00013b70: 785f 7426 6774 3b20 6d5f 7665 7269 6669 x_t> m_verifi │ │ │ -00013b80: 6564 3b0a 0a09 092f 2f20 7468 6973 206d ed;....// this m │ │ │ -00013b90: 6561 6e73 2074 6865 7265 2069 7320 616e eans there is an │ │ │ -00013ba0: 206f 7574 7374 616e 6469 6e67 2c20 6173 outstanding, as │ │ │ -00013bb0: 796e 632c 206f 7065 7261 7469 6f6e 0a09 ync, operation.. │ │ │ -00013bc0: 092f 2f20 746f 2076 6572 6966 7920 6561 .// to verify ea │ │ │ -00013bd0: 6368 2070 6965 6365 2074 6861 7420 6861 ch piece that ha │ │ │ -00013be0: 7320 6120 310a 0909 7479 7065 645f 6269 s a 1...typed_bi │ │ │ -00013bf0: 7466 6965 6c64 266c 743b 7069 6563 655f tfield<piece_ │ │ │ -00013c00: 696e 6465 785f 7426 6774 3b20 6d5f 7665 index_t> m_ve │ │ │ -00013c10: 7269 6679 696e 673b 0a0a 0909 2f2f 2073 rifying;....// s │ │ │ -00013c20: 6574 2069 6620 7468 6572 6527 7320 616e et if there's an │ │ │ -00013c30: 2065 7272 6f72 206f 6e20 7468 6973 2074 error on this t │ │ │ -00013c40: 6f72 7265 6e74 0a09 0965 7272 6f72 5f63 orrent...error_c │ │ │ -00013c50: 6f64 6520 6d5f 6572 726f 723b 0a0a 0909 ode m_error;.... │ │ │ -00013c60: 2f2f 2075 7365 6420 6966 2074 6865 7265 // used if there │ │ │ -00013c70: 2069 7320 616e 7920 7265 7375 6d65 2064 is any resume d │ │ │ -00013c80: 6174 612e 2053 6f6d 6520 6f66 2074 6865 ata. Some of the │ │ │ -00013c90: 2069 6e66 6f72 6d61 7469 6f6e 2066 726f information fro │ │ │ -00013ca0: 6d20 7468 650a 0909 2f2f 2061 6464 5f74 m the...// add_t │ │ │ -00013cb0: 6f72 7265 6e74 5f70 6172 616d 7320 7374 orrent_params st │ │ │ -00013cc0: 7275 6374 2061 7265 206e 6565 6465 6420 ruct are needed │ │ │ -00013cd0: 6c61 7465 7220 696e 2074 6865 2074 6f72 later in the tor │ │ │ -00013ce0: 7265 6e74 206f 626a 6563 7427 7320 6c69 rent object's li │ │ │ -00013cf0: 6665 0a09 092f 2f20 6379 636c 652c 2061 fe...// cycle, a │ │ │ -00013d00: 6e64 206e 6f74 2069 6e20 7468 6520 636f nd not in the co │ │ │ -00013d10: 6e73 7472 7563 746f 722e 2053 6f20 7765 nstructor. So we │ │ │ -00013d20: 206e 6565 6420 746f 2073 6176 6520 6974 need to save it │ │ │ -00013d30: 2068 6572 650a 0909 7374 643a 3a75 6e69 here...std::uni │ │ │ -00013d40: 7175 655f 7074 7226 6c74 3b61 6464 5f74 que_ptr<add_t │ │ │ -00013d50: 6f72 7265 6e74 5f70 6172 616d 7326 6774 orrent_params> │ │ │ -00013d60: 3b20 6d5f 6164 645f 746f 7272 656e 745f ; m_add_torrent_ │ │ │ -00013d70: 7061 7261 6d73 3b0a 0a09 092f 2f20 6966 params;....// if │ │ │ -00013d80: 2074 6865 2074 6f72 7265 6e74 2069 7320 the torrent is │ │ │ -00013d90: 7374 6172 7465 6420 7769 7468 6f75 7420 started without │ │ │ -00013da0: 6d65 7461 6461 7461 2c20 6974 206d 6179 metadata, it may │ │ │ -00013db0: 0a09 092f 2f20 7374 696c 6c20 6265 2067 ...// still be g │ │ │ -00013dc0: 6976 656e 2061 206e 616d 6520 756e 7469 iven a name unti │ │ │ -00013dd0: 6c20 7468 6520 6d65 7461 6461 7461 2069 l the metadata i │ │ │ -00013de0: 7320 7265 6365 6976 6564 0a09 092f 2f20 s received...// │ │ │ -00013df0: 6f6e 6365 2074 6865 206d 6574 6164 6174 once the metadat │ │ │ -00013e00: 6120 6973 2072 6563 6569 7665 6420 7468 a is received th │ │ │ -00013e10: 6973 2066 6965 6c64 2077 696c 6c20 6e6f is field will no │ │ │ -00013e20: 0a09 092f 2f20 6c6f 6e67 6572 2062 6520 ...// longer be │ │ │ -00013e30: 7573 6564 2061 6e64 2077 696c 6c20 6265 used and will be │ │ │ -00013e40: 2072 6573 6574 0a3c 2f70 7265 3e3c 2f74 reset.
    relevanc │ │ │ -00013e80: 6526 6e62 7370 3b33 3c2f 7464 3e3c 7464 e 3../include/libt │ │ │ -00013ec0: 6f72 7265 6e74 2f61 7578 5f2f 746f 7272 orrent/aux_/torr │ │ │ -00013ed0: 656e 742e 6870 703a 3135 3439 3c2f 613e ent.hpp:1549 │ │ │ -00013ee0: 3c2f 7464 3e3c 7464 3e66 6163 746f 7220 factor │ │ │ -00013ef0: 6f75 7420 7468 6520 6c69 6e6b 7320 2861 out the links (a │ │ │ -00013f00: 7320 7765 6c6c 2061 7320 7570 6461 7465 s well as update │ │ │ -00013f10: 5f6c 6973 7428 2920 746f 2061 2073 6570 _list() to a sep │ │ │ -00013f20: 6172 6174 6520 636c 6173 7320 7468 6174 arate class that │ │ │ -00013f30: 2074 6f72 7265 6e74 2063 616e 2069 6e68 torrent can inh │ │ │ -00013f40: 6572 6974 293c 2f74 643e 3c2f 7472 3e3c erit)< │ │ │ -00013f50: 7472 2069 643d 2233 3822 2073 7479 6c65 tr id="38" style │ │ │ -00013f60: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ -00013f70: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">factor out the │ │ │ -00013fa0: 206c 696e 6b73 2028 6173 2077 656c 6c20 links (as well │ │ │ -00013fb0: 6173 2075 7064 6174 655f 6c69 7374 2829 as update_list() │ │ │ -00013fc0: 2074 6f20 6120 7365 7061 7261 7465 0a63 to a separate.c │ │ │ -00013fd0: 6c61 7373 2074 6861 7420 746f 7272 656e lass that torren │ │ │ -00013fe0: 7420 6361 6e20 696e 6865 7269 7429 3c2f t can inherit)

    ../includ │ │ │ -00014000: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -00014010: 5f2f 746f 7272 656e 742e 6870 703a 3135 _/torrent.hpp:15 │ │ │ -00014020: 3439 3c2f 6834 3e3c 7072 6520 7374 796c 49

    ..// protects m
    │ │ │ -00014070: 5f74 6f72 7265 6e74 5f66 696c 655f 6578  _torrent_file_ex
    │ │ │ -00014080: 7465 726e 616c 2c20 7768 6963 6820 6d61  ternal, which ma
    │ │ │ -00014090: 7920 6265 2072 6561 6420 6672 6f6d 2063  y be read from c
    │ │ │ -000140a0: 6c69 656e 740a 0909 2f2f 2074 6872 6561  lient...// threa
    │ │ │ -000140b0: 6473 2077 6974 686f 7574 2068 6f6c 6469  ds without holdi
    │ │ │ -000140c0: 6e67 2074 6865 206e 6574 776f 726b 2074  ng the network t
    │ │ │ -000140d0: 6872 6561 6420 6c6f 636b 0a09 096d 7574  hread lock...mut
    │ │ │ -000140e0: 6162 6c65 2073 7464 3a3a 6d75 7465 7820  able std::mutex 
    │ │ │ -000140f0: 6d5f 746f 7272 656e 745f 6669 6c65 5f6d  m_torrent_file_m
    │ │ │ -00014100: 7574 6578 3b0a 0909 7374 643a 3a73 6861  utex;...std::sha
    │ │ │ -00014110: 7265 645f 7074 7226 6c74 3b74 6f72 7265  red_ptr<torre
    │ │ │ -00014120: 6e74 5f69 6e66 6f20 636f 6e73 7426 6774  nt_info const>
    │ │ │ -00014130: 3b20 6d5f 746f 7272 656e 745f 6669 6c65  ; m_torrent_file
    │ │ │ -00014140: 5f65 7874 6572 6e61 6c3b 0a0a 0909 2f2f  _external;....//
    │ │ │ -00014150: 2074 6865 7365 2061 7265 2063 6f70 6965   these are copie
    │ │ │ -00014160: 6420 6672 6f6d 2074 6865 206f 7269 6769  d from the origi
    │ │ │ -00014170: 6e61 6c20 2e74 6f72 7265 6e74 2066 696c  nal .torrent fil
    │ │ │ -00014180: 652c 2061 6e64 2072 6561 6c6c 7920 6a75  e, and really ju
    │ │ │ -00014190: 7374 0a09 092f 2f20 6865 7265 2074 6f20  st...// here to 
    │ │ │ -000141a0: 616c 6c6f 7720 7265 2d63 7265 6174 696e  allow re-creatin
    │ │ │ -000141b0: 6720 7468 6520 746f 7272 656e 7420 6669  g the torrent fi
    │ │ │ -000141c0: 6c65 2061 6761 696e 2028 6279 0a09 092f  le again (by.../
    │ │ │ -000141d0: 2f20 7361 7665 5f72 6573 756d 655f 6461  / save_resume_da
    │ │ │ -000141e0: 7461 2829 290a 0909 7374 643a 3a73 7472  ta())...std::str
    │ │ │ -000141f0: 696e 6720 6d5f 636f 6d6d 656e 743b 0a09  ing m_comment;..
    │ │ │ -00014200: 0973 7464 3a3a 7374 7269 6e67 206d 5f63  .std::string m_c
    │ │ │ -00014210: 7265 6174 6564 5f62 793b 0a09 0973 7464  reated_by;...std
    │ │ │ -00014220: 3a3a 7469 6d65 5f74 206d 5f63 7265 6174  ::time_t m_creat
    │ │ │ -00014230: 696f 6e5f 6461 7465 3b0a 0a09 7075 626c  ion_date;...publ
    │ │ │ -00014240: 6963 3a0a 0909 2f2f 2074 6865 7365 2061  ic:...// these a
    │ │ │ -00014250: 7265 2074 6865 206c 6973 7473 2074 6869  re the lists thi
    │ │ │ -00014260: 7320 746f 7272 656e 7420 6265 6c6f 6e67  s torrent belong
    │ │ │ -00014270: 7320 746f 2e20 466f 7220 6d6f 7265 0a09  s to. For more..
    │ │ │ -00014280: 092f 2f20 6465 7461 696c 7320 6162 6f75  .// details abou
    │ │ │ -00014290: 7420 6561 6368 206c 6973 742c 2073 6565  t each list, see
    │ │ │ -000142a0: 2073 6573 7369 6f6e 5f69 6d70 6c2e 6870   session_impl.hp
    │ │ │ -000142b0: 702e 2045 6163 6820 6c69 7374 0a09 092f  p. Each list.../
    │ │ │ -000142c0: 2f20 7265 7072 6573 656e 7473 2061 2067  / represents a g
    │ │ │ -000142d0: 726f 7570 2074 6869 7320 746f 7272 656e  roup this torren
    │ │ │ -000142e0: 7420 6265 6c6f 6e67 7320 746f 2061 6e64  t belongs to and
    │ │ │ -000142f0: 206d 616b 6573 2069 740a 0909 2f2f 2065   makes it...// e
    │ │ │ -00014300: 6666 6963 6965 6e74 2074 6f20 656e 756d  fficient to enum
    │ │ │ -00014310: 6572 6174 6520 6f6e 6c79 2074 6f72 7265  erate only torre
    │ │ │ -00014320: 6e74 7320 6265 6c6f 6e67 696e 6720 746f  nts belonging to
    │ │ │ -00014330: 2061 2073 7065 6369 6669 630a 0909 2f2f   a specific...//
    │ │ │ -00014340: 2067 726f 7570 2e20 5375 6368 2061 7320   group. Such as 
    │ │ │ -00014350: 746f 7272 656e 7473 2074 6861 7420 7761  torrents that wa
    │ │ │ -00014360: 6e74 2070 6565 7220 636f 6e6e 6563 7469  nt peer connecti
    │ │ │ -00014370: 6f6e 7320 6f72 2077 616e 740a 0909 2f2f  ons or want...//
    │ │ │ -00014380: 2074 6f20 6265 2074 6963 6b65 6420 6574   to be ticked et
    │ │ │ -00014390: 632e 0a0a 3c64 6976 2073 7479 6c65 3d22  c...
    ..aux::array&l │ │ │ -000143d0: 743b 6c69 6e6b 2c20 6175 783a 3a73 6573 t;link, aux::ses │ │ │ -000143e0: 7369 6f6e 5f69 6e74 6572 6661 6365 3a3a sion_interface:: │ │ │ -000143f0: 6e75 6d5f 746f 7272 656e 745f 6c69 7374 num_torrent_list │ │ │ -00014400: 732c 2074 6f72 7265 6e74 5f6c 6973 745f s, torrent_list_ │ │ │ -00014410: 696e 6465 785f 7426 6774 3b0a 3c2f 6469 index_t>....m_links;... │ │ │ -00014430: 7072 6976 6174 653a 0a0a 0909 2f2f 206d private:....// m │ │ │ -00014440: 5f6e 756d 5f76 6572 6966 6965 6420 3d20 _num_verified = │ │ │ -00014450: 6d5f 7665 7269 6669 6564 2e63 6f75 6e74 m_verified.count │ │ │ -00014460: 2829 0a09 0973 7464 3a3a 7569 6e74 3332 ()...std::uint32 │ │ │ -00014470: 5f74 206d 5f6e 756d 5f76 6572 6966 6965 _t m_num_verifie │ │ │ -00014480: 6420 3d20 303b 0a0a 0909 2f2f 2069 6620 d = 0;....// if │ │ │ -00014490: 7468 6973 2074 6f72 7265 6e74 2069 7320 this torrent is │ │ │ -000144a0: 7275 6e6e 696e 672c 2074 6869 7320 7761 running, this wa │ │ │ -000144b0: 7320 7468 6520 7469 6d65 0a09 092f 2f20 s the time...// │ │ │ -000144c0: 7768 656e 2069 7420 7761 7320 7374 6172 when it was star │ │ │ -000144d0: 7465 642e 2054 6869 7320 6973 2075 7365 ted. This is use │ │ │ -000144e0: 6420 746f 2068 6176 6520 610a 0909 2f2f d to have a...// │ │ │ -000144f0: 2062 6961 7320 746f 7761 7264 7320 6b65 bias towards ke │ │ │ -00014500: 6570 696e 6720 7365 6564 696e 6720 746f eping seeding to │ │ │ -00014510: 7272 656e 7473 2074 6861 740a 0909 2f2f rrents that...// │ │ │ -00014520: 2072 6563 656e 746c 7920 7761 7320 7374 recently was st │ │ │ -00014530: 6172 7465 642c 2074 6f20 6176 6f69 6420 arted, to avoid │ │ │ -00014540: 6f73 6369 6c6c 6174 696f 6e0a 0909 2f2f oscillation...// │ │ │ -00014550: 2074 6869 7320 6973 2073 7065 6369 6669 this is specifi │ │ │ -00014560: 6564 2061 7420 6120 7365 636f 6e64 2067 ed at a second g │ │ │ -00014570: 7261 6e75 6c61 7269 7479 0a09 0974 696d ranularity...tim │ │ │ -00014580: 655f 706f 696e 7433 3220 6d5f 7374 6172 e_point32 m_star │ │ │ -00014590: 7465 6420 3d20 6175 783a 3a74 696d 655f ted = aux::time_ │ │ │ -000145a0: 6e6f 7733 3228 293b 0a0a 0909 2f2f 2069 now32();....// i │ │ │ -000145b0: 6620 7765 2772 6520 6120 7365 6564 2c20 f we're a seed, │ │ │ -000145c0: 7468 6973 2069 7320 7468 6520 7469 6d65 this is the time │ │ │ -000145d0: 7374 616d 7020 6f66 2077 6865 6e20 7765 stamp of when we │ │ │ -000145e0: 2062 6563 616d 6520 6f6e 650a 0909 7469 became one...ti │ │ │ -000145f0: 6d65 5f70 6f69 6e74 3332 206d 5f62 6563 me_point32 m_bec │ │ │ -00014600: 616d 655f 7365 6564 203d 2061 7578 3a3a ame_seed = aux:: │ │ │ -00014610: 7469 6d65 5f6e 6f77 3332 2829 3b0a 0a09 time_now32();... │ │ │ -00014620: 092f 2f20 6966 2077 6527 7265 2066 696e .// if we're fin │ │ │ -00014630: 6973 6865 642c 2074 6869 7320 6973 2074 ished, this is t │ │ │ -00014640: 6865 2074 696d 6573 7461 6d70 206f 6620 he timestamp of │ │ │ -00014650: 7768 656e 2077 6520 6669 6e69 7368 6564 when we finished │ │ │ -00014660: 0a09 0974 696d 655f 706f 696e 7433 3220 ...time_point32 │ │ │ -00014670: 6d5f 6265 6361 6d65 5f66 696e 6973 6865 m_became_finishe │ │ │ -00014680: 6420 3d20 6175 783a 3a74 696d 655f 6e6f d = aux::time_no │ │ │ -00014690: 7733 3228 293b 0a0a 0909 2f2f 2077 6865 w32();....// whe │ │ │ -000146a0: 6e20 6368 6563 6b69 6e67 2c20 7468 6973 n checking, this │ │ │ -000146b0: 2069 7320 7468 6520 6669 7273 7420 7069 is the first pi │ │ │ -000146c0: 6563 6520 7765 2068 6176 6520 6e6f 740a ece we have not. │ │ │ -000146d0: 0909 2f2f 2069 7373 7565 6420 6120 6861 ..// issued a ha │ │ │ -000146e0: 7368 206a 6f62 2066 6f72 0a09 0970 6965 sh job for...pie │ │ │ -000146f0: 6365 5f69 6e64 6578 5f74 206d 5f63 6865 ce_index_t m_che │ │ │ -00014700: 636b 696e 675f 7069 6563 657b 307d 3b0a cking_piece{0};. │ │ │ -00014710: 0a09 092f 2f20 7468 6520 6e75 6d62 6572 ...// the number │ │ │ -00014720: 206f 6620 7069 6563 6573 2077 6520 636f of pieces we co │ │ │ -00014730: 6d70 6c65 7465 6420 7468 6520 6368 6563 mpleted the chec │ │ │ -00014740: 6b20 6f66 0a09 0970 6965 6365 5f69 6e64 k of...piece_ind │ │ │ -00014750: 6578 5f74 206d 5f6e 756d 5f63 6865 636b ex_t m_num_check │ │ │ -00014760: 6564 5f70 6965 6365 737b 307d 3b0a 0a09 ed_pieces{0};... │ │ │ -00014770: 092f 2f20 6966 2074 6865 2065 7272 6f72 .// if the error │ │ │ -00014780: 206f 6363 7572 7265 6420 6f6e 2061 2066 occurred on a f │ │ │ -00014790: 696c 652c 2074 6869 7320 6973 2074 6865 ile, this is the │ │ │ -000147a0: 2069 6e64 6578 206f 6620 7468 6174 2066 index of that f │ │ │ -000147b0: 696c 650a 0909 2f2f 2074 6865 7265 2061 ile...// there a │ │ │ -000147c0: 7265 2061 2066 6577 2073 7065 6369 616c re a few special │ │ │ -000147d0: 2063 6173 6573 2c20 7768 656e 2074 6869 cases, when thi │ │ │ -000147e0: 7320 6973 206e 6567 6174 6976 652e 2053 s is negative. S │ │ │ -000147f0: 6565 0a09 092f 2f20 7365 745f 6572 726f ee...// set_erro │ │ │ -00014800: 7228 290a 3c2f 7072 653e 3c2f 7464 3e3c r().
    < │ │ │ +000114f0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7374 btorrent/aux_/st │ │ │ +00011500: 6174 2e68 7070 3a32 3335 3c2f 613e 3c2f at.hpp:235everythin │ │ │ +00011520: 6720 6275 7420 7061 796c 6f61 6420 636f g but payload co │ │ │ +00011530: 756e 7465 7273 2061 6e64 2072 6174 6573 unters and rates │ │ │ +00011540: 2063 6f75 6c64 2070 726f 6261 626c 7920 could probably │ │ │ +00011550: 6265 2072 656d 6f76 6564 2066 726f 6d20 be removed from │ │ │ +00011560: 6865 7265 3c2f 7464 3e3c 2f74 723e 3c74 here

    everything but │ │ │ +000115c0: 7061 796c 6f61 6420 636f 756e 7465 7273 payload counters │ │ │ +000115d0: 2061 6e64 2072 6174 6573 2063 6f75 6c64 and rates could │ │ │ +000115e0: 2070 726f 6261 626c 7920 6265 0a72 656d probably be.rem │ │ │ +000115f0: 6f76 6564 2066 726f 6d20 6865 7265 3c2f oved from here

    ../includ │ │ │ +00011610: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ +00011620: 5f2f 7374 6174 2e68 7070 3a32 3335 3c2f _/stat.hpp:235
    ../
    │ │ │ +00011670: 2f20 7065 6572 5f63 6f6e 6e65 6374 696f  / peer_connectio
    │ │ │ +00011680: 6e20 6973 206f 7065 6e65 6420 616e 6420  n is opened and 
    │ │ │ +00011690: 6861 7665 2073 6f6d 6520 7072 6576 696f  have some previo
    │ │ │ +000116a0: 7573 0a09 092f 2f20 7472 616e 7366 6572  us...// transfer
    │ │ │ +000116b0: 7320 6672 6f6d 2065 6172 6c69 6572 2063  s from earlier c
    │ │ │ +000116c0: 6f6e 6e65 6374 696f 6e73 2e0a 0909 766f  onnections....vo
    │ │ │ +000116d0: 6964 2061 6464 5f73 7461 7428 7374 643a  id add_stat(std:
    │ │ │ +000116e0: 3a69 6e74 3634 5f74 2064 6f77 6e6c 6f61  :int64_t downloa
    │ │ │ +000116f0: 6465 642c 2073 7464 3a3a 696e 7436 345f  ded, std::int64_
    │ │ │ +00011700: 7420 7570 6c6f 6164 6564 290a 0909 7b0a  t uploaded)...{.
    │ │ │ +00011710: 0909 096d 5f73 7461 745b 646f 776e 6c6f  ...m_stat[downlo
    │ │ │ +00011720: 6164 5f70 6179 6c6f 6164 5d2e 6f66 6673  ad_payload].offs
    │ │ │ +00011730: 6574 2864 6f77 6e6c 6f61 6465 6429 3b0a  et(downloaded);.
    │ │ │ +00011740: 0909 096d 5f73 7461 745b 7570 6c6f 6164  ...m_stat[upload
    │ │ │ +00011750: 5f70 6179 6c6f 6164 5d2e 6f66 6673 6574  _payload].offset
    │ │ │ +00011760: 2875 706c 6f61 6465 6429 3b0a 0909 7d0a  (uploaded);...}.
    │ │ │ +00011770: 0a09 0969 6e74 206c 6173 745f 7061 796c  ...int last_payl
    │ │ │ +00011780: 6f61 645f 646f 776e 6c6f 6164 6564 2829  oad_downloaded()
    │ │ │ +00011790: 2063 6f6e 7374 0a09 097b 2072 6574 7572   const...{ retur
    │ │ │ +000117a0: 6e20 6d5f 7374 6174 5b64 6f77 6e6c 6f61  n m_stat[downloa
    │ │ │ +000117b0: 645f 7061 796c 6f61 645d 2e63 6f75 6e74  d_payload].count
    │ │ │ +000117c0: 6572 2829 3b20 7d0a 0909 696e 7420 6c61  er(); }...int la
    │ │ │ +000117d0: 7374 5f70 6179 6c6f 6164 5f75 706c 6f61  st_payload_uploa
    │ │ │ +000117e0: 6465 6428 2920 636f 6e73 740a 0909 7b20  ded() const...{ 
    │ │ │ +000117f0: 7265 7475 726e 206d 5f73 7461 745b 7570  return m_stat[up
    │ │ │ +00011800: 6c6f 6164 5f70 6179 6c6f 6164 5d2e 636f  load_payload].co
    │ │ │ +00011810: 756e 7465 7228 293b 207d 0a09 0969 6e74  unter(); }...int
    │ │ │ +00011820: 206c 6173 745f 7072 6f74 6f63 6f6c 5f64   last_protocol_d
    │ │ │ +00011830: 6f77 6e6c 6f61 6465 6428 2920 636f 6e73  ownloaded() cons
    │ │ │ +00011840: 740a 0909 7b20 7265 7475 726e 206d 5f73  t...{ return m_s
    │ │ │ +00011850: 7461 745b 646f 776e 6c6f 6164 5f70 726f  tat[download_pro
    │ │ │ +00011860: 746f 636f 6c5d 2e63 6f75 6e74 6572 2829  tocol].counter()
    │ │ │ +00011870: 3b20 7d0a 0909 696e 7420 6c61 7374 5f70  ; }...int last_p
    │ │ │ +00011880: 726f 746f 636f 6c5f 7570 6c6f 6164 6564  rotocol_uploaded
    │ │ │ +00011890: 2829 2063 6f6e 7374 0a09 097b 2072 6574  () const...{ ret
    │ │ │ +000118a0: 7572 6e20 6d5f 7374 6174 5b75 706c 6f61  urn m_stat[uploa
    │ │ │ +000118b0: 645f 7072 6f74 6f63 6f6c 5d2e 636f 756e  d_protocol].coun
    │ │ │ +000118c0: 7465 7228 293b 207d 0a0a 0909 2f2f 2074  ter(); }....// t
    │ │ │ +000118d0: 6865 7365 2061 7265 2074 6865 2063 6861  hese are the cha
    │ │ │ +000118e0: 6e6e 656c 7320 7765 206b 6565 7020 7374  nnels we keep st
    │ │ │ +000118f0: 6174 7320 666f 720a 0909 656e 756d 0a09  ats for...enum..
    │ │ │ +00011900: 097b 0a3c 6469 7620 7374 796c 653d 2262  .{.
    ...upload_paylo │ │ │ +00011940: 6164 2c0a 3c2f 6469 763e 0909 0975 706c ad,.
    ...upl │ │ │ +00011950: 6f61 645f 7072 6f74 6f63 6f6c 2c0a 0909 oad_protocol,... │ │ │ +00011960: 0964 6f77 6e6c 6f61 645f 7061 796c 6f61 .download_payloa │ │ │ +00011970: 642c 0a09 0909 646f 776e 6c6f 6164 5f70 d,....download_p │ │ │ +00011980: 726f 746f 636f 6c2c 0a09 0909 7570 6c6f rotocol,....uplo │ │ │ +00011990: 6164 5f69 705f 7072 6f74 6f63 6f6c 2c0a ad_ip_protocol,. │ │ │ +000119a0: 0909 0964 6f77 6e6c 6f61 645f 6970 5f70 ...download_ip_p │ │ │ +000119b0: 726f 746f 636f 6c2c 0a09 0909 6e75 6d5f rotocol,....num_ │ │ │ +000119c0: 6368 616e 6e65 6c73 0a09 097d 3b0a 0a09 channels...};... │ │ │ +000119d0: 0976 6f69 6420 636c 6561 7228 290a 0909 .void clear()... │ │ │ +000119e0: 7b0a 0909 0966 6f72 2028 696e 7420 6920 {....for (int i │ │ │ +000119f0: 3d20 303b 2069 2026 6c74 3b20 6e75 6d5f = 0; i < num_ │ │ │ +00011a00: 6368 616e 6e65 6c73 3b20 2b2b 6929 0a09 channels; ++i).. │ │ │ +00011a10: 0909 096d 5f73 7461 745b 695d 2e63 6c65 ...m_stat[i].cle │ │ │ +00011a20: 6172 2829 3b0a 0909 7d0a 0a09 0973 7461 ar();...}....sta │ │ │ +00011a30: 745f 6368 616e 6e65 6c20 636f 6e73 7426 t_channel const& │ │ │ +00011a40: 616d 703b 206f 7065 7261 746f 725b 5d28 amp; operator[]( │ │ │ +00011a50: 696e 7420 6929 2063 6f6e 7374 0a09 097b int i) const...{ │ │ │ +00011a60: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +00011a70: 5254 2869 2026 6774 3b3d 2030 2026 616d RT(i >= 0 &am │ │ │ +00011a80: 703b 2661 6d70 3b20 6920 266c 743b 206e p;& i < n │ │ │ +00011a90: 756d 5f63 6861 6e6e 656c 7329 3b0a 0909 um_channels);... │ │ │ +00011aa0: 0972 6574 7572 6e20 6d5f 7374 6174 5b69 .return m_stat[i │ │ │ +00011ab0: 5d3b 0a09 097d 0a0a 0970 7269 7661 7465 ];...}...private │ │ │ +00011ac0: 3a0a 0a09 0961 7578 3a3a 6172 7261 7926 :....aux::array& │ │ │ +00011ad0: 6c74 3b73 7461 745f 6368 616e 6e65 6c2c lt;stat_channel, │ │ │ +00011ae0: 206e 756d 5f63 6861 6e6e 656c 7326 6774 num_channels> │ │ │ +00011af0: 3b20 6d5f 7374 6174 3b0a 097d 3b0a 0a7d ; m_stat;..};..} │ │ │ +00011b00: 0a0a 2365 6e64 6966 202f 2f20 544f 5252 ..#endif // TORR │ │ │ +00011b10: 454e 545f 5354 4154 5f48 5050 5f49 4e43 ENT_STAT_HPP_INC │ │ │ +00011b20: 4c55 4445 440a 3c2f 7072 653e 3c2f 7464 LUDED.
    relevance │ │ │ +00011b60: 266e 6273 703b 333c 2f74 643e 3c74 643e  3 │ │ │ +00011b70: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ +00011b90: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ +00011ba0: 7272 656e 742f 6175 785f 2f77 6562 5f70 rrent/aux_/web_p │ │ │ +00011bb0: 6565 725f 636f 6e6e 6563 7469 6f6e 2e68 eer_connection.h │ │ │ +00011bc0: 7070 3a39 363c 2f61 3e3c 2f74 643e 3c74 pp:96if we make thi │ │ │ +00011be0: 7320 6265 2061 2064 6973 6b5f 6275 6666 s be a disk_buff │ │ │ +00011bf0: 6572 5f68 6f6c 6465 7220 696e 7374 6561 er_holder instea │ │ │ +00011c00: 6420 7765 2077 6f75 6c64 2073 6176 6520 d we would save │ │ │ +00011c10: 6120 636f 7079 2075 7365 2061 6c6c 6f63 a copy use alloc │ │ │ +00011c20: 6174 655f 6469 736b 5f72 6563 6569 7665 ate_disk_receive │ │ │ +00011c30: 5f62 7566 6665 7220 616e 6420 7265 6c65 _buffer and rele │ │ │ +00011c40: 6173 655f 6469 736b 5f72 6563 6569 7665 ase_disk_receive │ │ │ +00011c50: 5f62 7566 6665 723c 2f74 643e 3c2f 7472 _buffer │ │ │ +00011c90: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00011ca0: 3c68 323e 6966 2077 6520 6d61 6b65 2074

    if we make t │ │ │ +00011cb0: 6869 7320 6265 2061 2064 6973 6b5f 6275 his be a disk_bu │ │ │ +00011cc0: 6666 6572 5f68 6f6c 6465 7220 696e 7374 ffer_holder inst │ │ │ +00011cd0: 6561 640a 7765 2077 6f75 6c64 2073 6176 ead.we would sav │ │ │ +00011ce0: 6520 6120 636f 7079 0a75 7365 2061 6c6c e a copy.use all │ │ │ +00011cf0: 6f63 6174 655f 6469 736b 5f72 6563 6569 ocate_disk_recei │ │ │ +00011d00: 7665 5f62 7566 6665 7220 616e 6420 7265 ve_buffer and re │ │ │ +00011d10: 6c65 6173 655f 6469 736b 5f72 6563 6569 lease_disk_recei │ │ │ +00011d20: 7665 5f62 7566 6665 723c 2f68 323e 3c68 ve_buffer

    ../include/lib │ │ │ +00011d40: 746f 7272 656e 742f 6175 785f 2f77 6562 torrent/aux_/web │ │ │ +00011d50: 5f70 6565 725f 636f 6e6e 6563 7469 6f6e _peer_connection │ │ │ +00011d60: 2e68 7070 3a39 363c 2f68 343e 3c70 7265 .hpp:96

    ..piece_bl
    │ │ │ +00011db0: 6f63 6b5f 7072 6f67 7265 7373 2064 6f77  ock_progress dow
    │ │ │ +00011dc0: 6e6c 6f61 6469 6e67 5f70 6965 6365 5f70  nloading_piece_p
    │ │ │ +00011dd0: 726f 6772 6573 7328 2920 636f 6e73 7420  rogress() const 
    │ │ │ +00011de0: 6f76 6572 7269 6465 3b0a 0a09 0976 6f69  override;....voi
    │ │ │ +00011df0: 6420 6861 6e64 6c65 5f70 6164 6669 6c65  d handle_padfile
    │ │ │ +00011e00: 2829 3b0a 0a09 092f 2f20 7468 6973 2068  ();....// this h
    │ │ │ +00011e10: 6173 206f 6e65 2065 6e74 7279 2070 6572  as one entry per
    │ │ │ +00011e20: 2068 7474 702d 7265 7175 6573 740a 0909   http-request...
    │ │ │ +00011e30: 2f2f 2028 6d69 6768 7420 6265 206d 6f72  // (might be mor
    │ │ │ +00011e40: 6520 7468 616e 2074 6865 2062 7420 7265  e than the bt re
    │ │ │ +00011e50: 7175 6573 7473 290a 0909 7374 7275 6374  quests)...struct
    │ │ │ +00011e60: 2066 696c 655f 7265 7175 6573 745f 740a   file_request_t.
    │ │ │ +00011e70: 0909 7b0a 0909 0966 696c 655f 696e 6465  ..{....file_inde
    │ │ │ +00011e80: 785f 7420 6669 6c65 5f69 6e64 6578 3b0a  x_t file_index;.
    │ │ │ +00011e90: 0909 0969 6e74 206c 656e 6774 683b 0a09  ...int length;..
    │ │ │ +00011ea0: 0909 7374 643a 3a69 6e74 3634 5f74 2073  ..std::int64_t s
    │ │ │ +00011eb0: 7461 7274 3b0a 0909 7d3b 0a09 0973 7464  tart;...};...std
    │ │ │ +00011ec0: 3a3a 6465 7175 6526 6c74 3b66 696c 655f  ::deque<file_
    │ │ │ +00011ed0: 7265 7175 6573 745f 7426 6774 3b20 6d5f  request_t> m_
    │ │ │ +00011ee0: 6669 6c65 5f72 6571 7565 7374 733b 0a0a  file_requests;..
    │ │ │ +00011ef0: 0909 7374 643a 3a73 7472 696e 6720 6d5f  ..std::string m_
    │ │ │ +00011f00: 7572 6c3b 0a0a 0909 6175 783a 3a77 6562  url;....aux::web
    │ │ │ +00011f10: 5f73 6565 645f 742a 206d 5f77 6562 3b0a  _seed_t* m_web;.
    │ │ │ +00011f20: 0a09 092f 2f20 7468 6973 2069 7320 7573  ...// this is us
    │ │ │ +00011f30: 6564 2066 6f72 2069 6e74 6572 6d65 6469  ed for intermedi
    │ │ │ +00011f40: 6174 6520 7374 6f72 6167 6520 6f66 2070  ate storage of p
    │ │ │ +00011f50: 6965 6365 7320 746f 2062 6520 6465 6c69  ieces to be deli
    │ │ │ +00011f60: 7665 7265 6420 746f 2074 6865 0a09 092f  vered to the.../
    │ │ │ +00011f70: 2f20 6269 7474 6f72 7265 6e74 2065 6e67  / bittorrent eng
    │ │ │ +00011f80: 696e 650a 3c64 6976 2073 7479 6c65 3d22  ine.
    ..aux::vector& │ │ │ +00011fc0: 6c74 3b63 6861 7226 6774 3b20 6d5f 7069 lt;char> m_pi │ │ │ +00011fd0: 6563 653b 0a3c 2f64 6976 3e0a 0909 2f2f ece;.
    ...// │ │ │ +00011fe0: 2074 6865 206e 756d 6265 7220 6f66 2062 the number of b │ │ │ +00011ff0: 7974 6573 2077 6527 7665 2066 6f72 7761 ytes we've forwa │ │ │ +00012000: 7264 6564 2074 6f20 7468 6520 696e 636f rded to the inco │ │ │ +00012010: 6d69 6e67 5f70 6179 6c6f 6164 2829 2066 ming_payload() f │ │ │ +00012020: 756e 6374 696f 6e0a 0909 2f2f 2069 6e20 unction...// in │ │ │ +00012030: 7468 6520 6375 7272 656e 7420 4854 5450 the current HTTP │ │ │ +00012040: 2072 6573 706f 6e73 652e 2075 7365 6420 response. used │ │ │ +00012050: 746f 206b 6e6f 7720 7768 6572 6520 696e to know where in │ │ │ +00012060: 2074 6865 2062 7566 6665 7220 7468 650a the buffer the. │ │ │ +00012070: 0909 2f2f 206e 6578 7420 7265 7370 6f6e ..// next respon │ │ │ +00012080: 7365 2073 7461 7274 730a 0909 696e 7420 se starts...int │ │ │ +00012090: 6d5f 7265 6365 6976 6564 5f62 6f64 793b m_received_body; │ │ │ +000120a0: 0a0a 0909 2f2f 2074 6869 7320 6973 2074 ....// this is t │ │ │ +000120b0: 6865 206f 6666 7365 7420 696e 7369 6465 he offset inside │ │ │ +000120c0: 2074 6865 2063 7572 7265 6e74 2072 6563 the current rec │ │ │ +000120d0: 6569 7665 0a09 092f 2f20 6275 6666 6572 eive...// buffer │ │ │ +000120e0: 2077 6865 7265 2074 6865 206e 6578 7420 where the next │ │ │ +000120f0: 6368 756e 6b20 6865 6164 6572 2077 696c chunk header wil │ │ │ +00012100: 6c20 6265 2e0a 0909 2f2f 2074 6869 7320 l be....// this │ │ │ +00012110: 6973 2075 7064 6174 6564 2066 6f72 2065 is updated for e │ │ │ +00012120: 6163 6820 6368 756e 6b20 6865 6164 6572 ach chunk header │ │ │ +00012130: 2074 6861 7427 730a 0909 2f2f 2070 6172 that's...// par │ │ │ +00012140: 7365 642e 2049 7420 646f 6573 206e 6f74 sed. It does not │ │ │ +00012150: 206e 6563 6573 7361 7269 6c79 2070 6f69 necessarily poi │ │ │ +00012160: 6e74 2074 6f20 6120 7661 6c69 640a 0909 nt to a valid... │ │ │ +00012170: 2f2f 206f 6666 7365 7420 696e 2074 6865 // offset in the │ │ │ +00012180: 2072 6563 6569 7665 2062 7566 6665 722c receive buffer, │ │ │ +00012190: 2069 6620 7765 2068 6176 656e 2774 2072 if we haven't r │ │ │ +000121a0: 6563 6569 7665 640a 0909 2f2f 2069 7420 eceived...// it │ │ │ +000121b0: 7965 742e 2054 6869 7320 6f66 6673 6574 yet. This offset │ │ │ +000121c0: 206e 6576 6572 2069 6e63 6c75 6465 7320 never includes │ │ │ +000121d0: 7468 6520 4854 5450 2068 6561 6465 720a the HTTP header. │ │ │ +000121e0: 0909 696e 7420 6d5f 6368 756e 6b5f 706f ..int m_chunk_po │ │ │ +000121f0: 733b 0a0a 0909 2f2f 2074 6869 7320 6973 s;....// this is │ │ │ +00012200: 2074 6865 206e 756d 6265 7220 6f66 2062 the number of b │ │ │ +00012210: 7974 6573 2077 6527 7665 2061 6c72 6561 ytes we've alrea │ │ │ +00012220: 6479 2072 6563 6569 7665 640a 0909 2f2f dy received...// │ │ │ +00012230: 2066 726f 6d20 7468 6520 6e65 7874 2063 from the next c │ │ │ +00012240: 6875 6e6b 2068 6561 6465 7220 7765 2772 hunk header we'r │ │ │ +00012250: 6520 7761 6974 696e 6720 666f 720a 0909 e waiting for... │ │ │ +00012260: 696e 7420 6d5f 7061 7274 6961 6c5f 6368 int m_partial_ch │ │ │ +00012270: 756e 6b5f 6865 6164 6572 3b0a 0a09 092f unk_header;..../ │ │ │ +00012280: 2f20 7468 6520 6e75 6d62 6572 206f 6620 / the number of │ │ │ +00012290: 7265 7370 6f6e 7365 7320 7765 2776 6520 responses we've │ │ │ +000122a0: 7265 6365 6976 6564 2073 6f20 6661 7220 received so far │ │ │ +000122b0: 6f6e 0a09 092f 2f20 7468 6973 2063 6f6e on...// this con │ │ │ +000122c0: 6e65 6374 696f 6e0a 0909 696e 7420 6d5f nection...int m_ │ │ │ +000122d0: 6e75 6d5f 7265 7370 6f6e 7365 733b 0a09 num_responses;.. │ │ │ +000122e0: 7d3b 0a7d 0a0a 2365 6e64 6966 202f 2f20 };.}..#endif // │ │ │ +000122f0: 544f 5252 454e 545f 5745 425f 5045 4552 TORRENT_WEB_PEER │ │ │ +00012300: 5f43 4f4e 4e45 4354 494f 4e5f 4850 505f _CONNECTION_HPP_ │ │ │ +00012310: 494e 434c 5544 4544 0a3c 2f70 7265 3e3c INCLUDED.
    < │ │ │ +00012320: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00012350: 6e63 6526 6e62 7370 3b33 3c2f 7464 3e3c nce 3< │ │ │ +00012360: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/li │ │ │ +00012390: 6274 6f72 7265 6e74 2f61 7578 5f2f 746f btorrent/aux_/to │ │ │ +000123a0: 7272 656e 742e 6870 703a 3134 3737 3c2f rrent.hpp:1477facto │ │ │ +000123c0: 7220 6f75 7420 7072 6564 6963 7469 7665 r out predictive │ │ │ +000123d0: 2070 6965 6365 7320 616e 6420 616c 6c20 pieces and all │ │ │ +000123e0: 6f70 6572 6174 696f 6e73 206f 6e20 6974 operations on it │ │ │ +000123f0: 2069 6e74 6f20 6120 7365 7061 7261 7465 into a separate │ │ │ +00012400: 2063 6c61 7373 2028 746f 2075 7365 2061 class (to use a │ │ │ +00012410: 7320 6d65 6d62 6572 2068 6572 6520 696e s member here in │ │ │ +00012420: 7374 6561 6429 3c2f 7464 3e3c 2f74 723e stead) │ │ │ +00012430: 3c74 7220 6964 3d22 3335 2220 7374 796c < │ │ │ +00012460: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00012470: 6832 3e66 6163 746f 7220 6f75 7420 7072 h2>factor out pr │ │ │ +00012480: 6564 6963 7469 7665 2070 6965 6365 7320 edictive pieces │ │ │ +00012490: 616e 6420 616c 6c20 6f70 6572 6174 696f and all operatio │ │ │ +000124a0: 6e73 206f 6e20 6974 2069 6e74 6f20 610a ns on it into a. │ │ │ +000124b0: 7365 7061 7261 7465 2063 6c61 7373 2028 separate class ( │ │ │ +000124c0: 746f 2075 7365 2061 7320 6d65 6d62 6572 to use as member │ │ │ +000124d0: 2068 6572 6520 696e 7374 6561 6429 3c2f here instead)

    ../includ │ │ │ +000124f0: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ +00012500: 5f2f 746f 7272 656e 742e 6870 703a 3134 _/torrent.hpp:14 │ │ │ +00012510: 3737 3c2f 6834 3e3c 7072 6520 7374 796c 77

    ..std::string m
    │ │ │ +00012560: 5f74 7261 636b 6572 6964 3b0a 2369 6620  _trackerid;.#if 
    │ │ │ +00012570: 544f 5252 454e 545f 4142 495f 5645 5253  TORRENT_ABI_VERS
    │ │ │ +00012580: 494f 4e20 3d3d 2031 0a09 092f 2f20 6465  ION == 1...// de
    │ │ │ +00012590: 7072 6563 6174 6564 2069 6e20 312e 310a  precated in 1.1.
    │ │ │ +000125a0: 0909 7374 643a 3a73 7472 696e 6720 6d5f  ..std::string m_
    │ │ │ +000125b0: 7573 6572 6e61 6d65 3b0a 0909 7374 643a  username;...std:
    │ │ │ +000125c0: 3a73 7472 696e 6720 6d5f 7061 7373 776f  :string m_passwo
    │ │ │ +000125d0: 7264 3b0a 2365 6e64 6966 0a0a 0909 7374  rd;.#endif....st
    │ │ │ +000125e0: 643a 3a73 7472 696e 6720 6d5f 7361 7665  d::string m_save
    │ │ │ +000125f0: 5f70 6174 683b 0a09 0973 7464 3a3a 7374  _path;...std::st
    │ │ │ +00012600: 7269 6e67 206d 5f70 6172 745f 6669 6c65  ring m_part_file
    │ │ │ +00012610: 5f64 6972 3b0a 0909 6175 783a 3a63 6163  _dir;...aux::cac
    │ │ │ +00012620: 6865 645f 736c 6f74 206d 5f6e 616d 655f  hed_slot m_name_
    │ │ │ +00012630: 6964 783b 0a0a 2369 666e 6465 6620 544f  idx;..#ifndef TO
    │ │ │ +00012640: 5252 454e 545f 4449 5341 424c 455f 5052  RRENT_DISABLE_PR
    │ │ │ +00012650: 4544 4943 5449 5645 5f50 4945 4345 530a  EDICTIVE_PIECES.
    │ │ │ +00012660: 0909 2f2f 2074 6869 7320 6973 2061 206c  ..// this is a l
    │ │ │ +00012670: 6973 7420 6f66 2061 6c6c 2070 6965 6365  ist of all piece
    │ │ │ +00012680: 7320 7468 6174 2077 6520 6861 7665 2061  s that we have a
    │ │ │ +00012690: 6e6e 6f75 6e63 6564 0a09 092f 2f20 6173  nnounced...// as
    │ │ │ +000126a0: 2068 6176 696e 672c 2077 6974 686f 7574   having, without
    │ │ │ +000126b0: 2061 6374 7561 6c6c 7920 6861 7669 6e67   actually having
    │ │ │ +000126c0: 2079 6574 2e20 4966 2077 6520 7265 6365   yet. If we rece
    │ │ │ +000126d0: 6976 650a 0909 2f2f 2061 2072 6571 7565  ive...// a reque
    │ │ │ +000126e0: 7374 2066 6f72 2061 2070 6965 6365 2069  st for a piece i
    │ │ │ +000126f0: 6e20 7468 6973 206c 6973 742c 2077 6520  n this list, we 
    │ │ │ +00012700: 6e65 6564 2074 6f20 686f 6c64 206f 6666  need to hold off
    │ │ │ +00012710: 0a09 092f 2f20 6f6e 2072 6573 706f 6e64  ...// on respond
    │ │ │ +00012720: 696e 6720 756e 7469 6c20 7765 2068 6176  ing until we hav
    │ │ │ +00012730: 6520 636f 6d70 6c65 7465 6420 7468 6520  e completed the 
    │ │ │ +00012740: 7069 6563 6520 616e 640a 0909 2f2f 2076  piece and...// v
    │ │ │ +00012750: 6572 6966 6965 6420 6974 7320 6861 7368  erified its hash
    │ │ │ +00012760: 2e20 4966 2074 6865 2068 6173 6820 6661  . If the hash fa
    │ │ │ +00012770: 696c 732c 2073 656e 6420 7265 6a65 6374  ils, send reject
    │ │ │ +00012780: 2074 6f0a 0909 2f2f 2070 6565 7273 2077   to...// peers w
    │ │ │ +00012790: 6974 6820 6f75 7473 7461 6e64 696e 6720  ith outstanding 
    │ │ │ +000127a0: 7265 7175 6573 7473 2c20 616e 6420 646f  requests, and do
    │ │ │ +000127b0: 6e74 5f68 6176 6520 746f 206f 7468 6572  nt_have to other
    │ │ │ +000127c0: 0a09 092f 2f20 7065 6572 732e 2054 6869  ...// peers. Thi
    │ │ │ +000127d0: 7320 7665 6374 6f72 2069 7320 6f72 6465  s vector is orde
    │ │ │ +000127e0: 7265 642c 2074 6f20 6d61 6b65 206c 6f6f  red, to make loo
    │ │ │ +000127f0: 6b75 7073 2066 6173 742e 0a0a 3c64 6976  kups fast...
    ..std: │ │ │ +00012830: 3a76 6563 746f 7226 6c74 3b70 6965 6365 :vector<piece │ │ │ +00012840: 5f69 6e64 6578 5f74 2667 743b 206d 5f70 _index_t> m_p │ │ │ +00012850: 7265 6469 6374 6976 655f 7069 6563 6573 redictive_pieces │ │ │ +00012860: 3b0a 3c2f 6469 763e 2365 6e64 6966 0a0a ;.
    #endif.. │ │ │ +00012870: 0909 2f2f 2076 3220 6d65 726b 6c65 2074 ..// v2 merkle t │ │ │ +00012880: 7265 6520 666f 7220 6561 6368 2066 696c ree for each fil │ │ │ +00012890: 650a 0909 6175 783a 3a76 6563 746f 7226 e...aux::vector& │ │ │ +000128a0: 6c74 3b61 7578 3a3a 6d65 726b 6c65 5f74 lt;aux::merkle_t │ │ │ +000128b0: 7265 652c 2066 696c 655f 696e 6465 785f ree, file_index_ │ │ │ +000128c0: 7426 6774 3b20 6d5f 6d65 726b 6c65 5f74 t> m_merkle_t │ │ │ +000128d0: 7265 6573 3b0a 0a09 092f 2f20 7468 6520 rees;....// the │ │ │ +000128e0: 7065 7266 6f72 6d61 6e63 6520 636f 756e performance coun │ │ │ +000128f0: 7465 7273 206f 6620 7468 6973 2073 6573 ters of this ses │ │ │ +00012900: 7369 6f6e 0a09 0963 6f75 6e74 6572 7326 sion...counters& │ │ │ +00012910: 616d 703b 206d 5f73 7461 7473 5f63 6f75 amp; m_stats_cou │ │ │ +00012920: 6e74 6572 733b 0a0a 0909 2f2f 2065 6163 nters;....// eac │ │ │ +00012930: 6820 6269 7420 7265 7072 6573 656e 7473 h bit represents │ │ │ +00012940: 2061 2070 6965 6365 2e20 6120 7365 7420 a piece. a set │ │ │ +00012950: 6269 7420 6d65 616e 730a 0909 2f2f 2074 bit means...// t │ │ │ +00012960: 6865 2070 6965 6365 2068 6173 2068 6164 he piece has had │ │ │ +00012970: 2069 7473 2068 6173 6820 7665 7269 6669 its hash verifi │ │ │ +00012980: 6564 2e20 5468 6973 0a09 092f 2f20 6973 ed. This...// is │ │ │ +00012990: 206f 6e6c 7920 7573 6564 2069 6e20 7365 only used in se │ │ │ +000129a0: 6564 206d 6f64 6520 2877 6865 6e20 6d5f ed mode (when m_ │ │ │ +000129b0: 7365 6564 5f6d 6f64 650a 0909 2f2f 2069 seed_mode...// i │ │ │ +000129c0: 7320 7472 7565 290a 0909 7479 7065 645f s true)...typed_ │ │ │ +000129d0: 6269 7466 6965 6c64 266c 743b 7069 6563 bitfield<piec │ │ │ +000129e0: 655f 696e 6465 785f 7426 6774 3b20 6d5f e_index_t> m_ │ │ │ +000129f0: 7665 7269 6669 6564 3b0a 0a09 092f 2f20 verified;....// │ │ │ +00012a00: 7468 6973 206d 6561 6e73 2074 6865 7265 this means there │ │ │ +00012a10: 2069 7320 616e 206f 7574 7374 616e 6469 is an outstandi │ │ │ +00012a20: 6e67 2c20 6173 796e 632c 206f 7065 7261 ng, async, opera │ │ │ +00012a30: 7469 6f6e 0a09 092f 2f20 746f 2076 6572 tion...// to ver │ │ │ +00012a40: 6966 7920 6561 6368 2070 6965 6365 2074 ify each piece t │ │ │ +00012a50: 6861 7420 6861 7320 6120 310a 0909 7479 hat has a 1...ty │ │ │ +00012a60: 7065 645f 6269 7466 6965 6c64 266c 743b ped_bitfield< │ │ │ +00012a70: 7069 6563 655f 696e 6465 785f 7426 6774 piece_index_t> │ │ │ +00012a80: 3b20 6d5f 7665 7269 6679 696e 673b 0a0a ; m_verifying;.. │ │ │ +00012a90: 0909 2f2f 2073 6574 2069 6620 7468 6572 ..// set if ther │ │ │ +00012aa0: 6527 7320 616e 2065 7272 6f72 206f 6e20 e's an error on │ │ │ +00012ab0: 7468 6973 2074 6f72 7265 6e74 0a09 0965 this torrent...e │ │ │ +00012ac0: 7272 6f72 5f63 6f64 6520 6d5f 6572 726f rror_code m_erro │ │ │ +00012ad0: 723b 0a0a 0909 2f2f 2075 7365 6420 6966 r;....// used if │ │ │ +00012ae0: 2074 6865 7265 2069 7320 616e 7920 7265 there is any re │ │ │ +00012af0: 7375 6d65 2064 6174 612e 2053 6f6d 6520 sume data. Some │ │ │ +00012b00: 6f66 2074 6865 2069 6e66 6f72 6d61 7469 of the informati │ │ │ +00012b10: 6f6e 2066 726f 6d20 7468 650a 0909 2f2f on from the...// │ │ │ +00012b20: 2061 6464 5f74 6f72 7265 6e74 5f70 6172 add_torrent_par │ │ │ +00012b30: 616d 7320 7374 7275 6374 2061 7265 206e ams struct are n │ │ │ +00012b40: 6565 6465 6420 6c61 7465 7220 696e 2074 eeded later in t │ │ │ +00012b50: 6865 2074 6f72 7265 6e74 206f 626a 6563 he torrent objec │ │ │ +00012b60: 7427 7320 6c69 6665 0a09 092f 2f20 6379 t's life...// cy │ │ │ +00012b70: 636c 652c 2061 6e64 206e 6f74 2069 6e20 cle, and not in │ │ │ +00012b80: 7468 6520 636f 6e73 7472 7563 746f 722e the constructor. │ │ │ +00012b90: 2053 6f20 7765 206e 6565 6420 746f 2073 So we need to s │ │ │ +00012ba0: 6176 6520 6974 2068 6572 650a 0909 7374 ave it here...st │ │ │ +00012bb0: 643a 3a75 6e69 7175 655f 7074 7226 6c74 d::unique_ptr< │ │ │ +00012bc0: 3b61 6464 5f74 6f72 7265 6e74 5f70 6172 ;add_torrent_par │ │ │ +00012bd0: 616d 7326 6774 3b20 6d5f 6164 645f 746f ams> m_add_to │ │ │ +00012be0: 7272 656e 745f 7061 7261 6d73 3b0a 0a09 rrent_params;... │ │ │ +00012bf0: 092f 2f20 6966 2074 6865 2074 6f72 7265 .// if the torre │ │ │ +00012c00: 6e74 2069 7320 7374 6172 7465 6420 7769 nt is started wi │ │ │ +00012c10: 7468 6f75 7420 6d65 7461 6461 7461 2c20 thout metadata, │ │ │ +00012c20: 6974 206d 6179 0a09 092f 2f20 7374 696c it may...// stil │ │ │ +00012c30: 6c20 6265 2067 6976 656e 2061 206e 616d l be given a nam │ │ │ +00012c40: 6520 756e 7469 6c20 7468 6520 6d65 7461 e until the meta │ │ │ +00012c50: 6461 7461 2069 7320 7265 6365 6976 6564 data is received │ │ │ +00012c60: 0a09 092f 2f20 6f6e 6365 2074 6865 206d ...// once the m │ │ │ +00012c70: 6574 6164 6174 6120 6973 2072 6563 6569 etadata is recei │ │ │ +00012c80: 7665 6420 7468 6973 2066 6965 6c64 2077 ved this field w │ │ │ +00012c90: 696c 6c20 6e6f 0a09 092f 2f20 6c6f 6e67 ill no...// long │ │ │ +00012ca0: 6572 2062 6520 7573 6564 2061 6e64 2077 er be used and w │ │ │ +00012cb0: 696c 6c20 6265 2072 6573 6574 0a3c 2f70 ill be reset.

    re │ │ │ +00012cf0: 6c65 7661 6e63 6526 6e62 7370 3b33 3c2f levance 3
    ../includ │ │ │ +00012d30: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ +00012d40: 5f2f 746f 7272 656e 742e 6870 703a 3135 _/torrent.hpp:15 │ │ │ +00012d50: 3439 3c2f 613e 3c2f 7464 3e3c 7464 3e66 49f │ │ │ +00012d60: 6163 746f 7220 6f75 7420 7468 6520 6c69 actor out the li │ │ │ +00012d70: 6e6b 7320 2861 7320 7765 6c6c 2061 7320 nks (as well as │ │ │ +00012d80: 7570 6461 7465 5f6c 6973 7428 2920 746f update_list() to │ │ │ +00012d90: 2061 2073 6570 6172 6174 6520 636c 6173 a separate clas │ │ │ +00012da0: 7320 7468 6174 2074 6f72 7265 6e74 2063 s that torrent c │ │ │ +00012db0: 616e 2069 6e68 6572 6974 293c 2f74 643e an inherit) │ │ │ +00012dc0: 3c2f 7472 3e3c 7472 2069 643d 2233 3622

    factor o │ │ │ +00012e10: 7574 2074 6865 206c 696e 6b73 2028 6173 ut the links (as │ │ │ +00012e20: 2077 656c 6c20 6173 2075 7064 6174 655f well as update_ │ │ │ +00012e30: 6c69 7374 2829 2074 6f20 6120 7365 7061 list() to a sepa │ │ │ +00012e40: 7261 7465 0a63 6c61 7373 2074 6861 7420 rate.class that │ │ │ +00012e50: 746f 7272 656e 7420 6361 6e20 696e 6865 torrent can inhe │ │ │ +00012e60: 7269 7429 3c2f 6832 3e3c 6834 3e2e 2e2f rit)

    ../ │ │ │ +00012e70: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ +00012e80: 6e74 2f61 7578 5f2f 746f 7272 656e 742e nt/aux_/torrent. │ │ │ +00012e90: 6870 703a 3135 3439 3c2f 6834 3e3c 7072 hpp:1549

    ..// prot │ │ │ +00012ee0: 6563 7473 206d 5f74 6f72 7265 6e74 5f66 ects m_torrent_f │ │ │ +00012ef0: 696c 655f 6578 7465 726e 616c 2c20 7768 ile_external, wh │ │ │ +00012f00: 6963 6820 6d61 7920 6265 2072 6561 6420 ich may be read │ │ │ +00012f10: 6672 6f6d 2063 6c69 656e 740a 0909 2f2f from client...// │ │ │ +00012f20: 2074 6872 6561 6473 2077 6974 686f 7574 threads without │ │ │ +00012f30: 2068 6f6c 6469 6e67 2074 6865 206e 6574 holding the net │ │ │ +00012f40: 776f 726b 2074 6872 6561 6420 6c6f 636b work thread lock │ │ │ +00012f50: 0a09 096d 7574 6162 6c65 2073 7464 3a3a ...mutable std:: │ │ │ +00012f60: 6d75 7465 7820 6d5f 746f 7272 656e 745f mutex m_torrent_ │ │ │ +00012f70: 6669 6c65 5f6d 7574 6578 3b0a 0909 7374 file_mutex;...st │ │ │ +00012f80: 643a 3a73 6861 7265 645f 7074 7226 6c74 d::shared_ptr< │ │ │ +00012f90: 3b74 6f72 7265 6e74 5f69 6e66 6f20 636f ;torrent_info co │ │ │ +00012fa0: 6e73 7426 6774 3b20 6d5f 746f 7272 656e nst> m_torren │ │ │ +00012fb0: 745f 6669 6c65 5f65 7874 6572 6e61 6c3b t_file_external; │ │ │ +00012fc0: 0a0a 0909 2f2f 2074 6865 7365 2061 7265 ....// these are │ │ │ +00012fd0: 2063 6f70 6965 6420 6672 6f6d 2074 6865 copied from the │ │ │ +00012fe0: 206f 7269 6769 6e61 6c20 2e74 6f72 7265 original .torre │ │ │ +00012ff0: 6e74 2066 696c 652c 2061 6e64 2072 6561 nt file, and rea │ │ │ +00013000: 6c6c 7920 6a75 7374 0a09 092f 2f20 6865 lly just...// he │ │ │ +00013010: 7265 2074 6f20 616c 6c6f 7720 7265 2d63 re to allow re-c │ │ │ +00013020: 7265 6174 696e 6720 7468 6520 746f 7272 reating the torr │ │ │ +00013030: 656e 7420 6669 6c65 2061 6761 696e 2028 ent file again ( │ │ │ +00013040: 6279 0a09 092f 2f20 7361 7665 5f72 6573 by...// save_res │ │ │ +00013050: 756d 655f 6461 7461 2829 290a 0909 7374 ume_data())...st │ │ │ +00013060: 643a 3a73 7472 696e 6720 6d5f 636f 6d6d d::string m_comm │ │ │ +00013070: 656e 743b 0a09 0973 7464 3a3a 7374 7269 ent;...std::stri │ │ │ +00013080: 6e67 206d 5f63 7265 6174 6564 5f62 793b ng m_created_by; │ │ │ +00013090: 0a09 0973 7464 3a3a 7469 6d65 5f74 206d ...std::time_t m │ │ │ +000130a0: 5f63 7265 6174 696f 6e5f 6461 7465 3b0a _creation_date;. │ │ │ +000130b0: 0a09 7075 626c 6963 3a0a 0909 2f2f 2074 ..public:...// t │ │ │ +000130c0: 6865 7365 2061 7265 2074 6865 206c 6973 hese are the lis │ │ │ +000130d0: 7473 2074 6869 7320 746f 7272 656e 7420 ts this torrent │ │ │ +000130e0: 6265 6c6f 6e67 7320 746f 2e20 466f 7220 belongs to. For │ │ │ +000130f0: 6d6f 7265 0a09 092f 2f20 6465 7461 696c more...// detail │ │ │ +00013100: 7320 6162 6f75 7420 6561 6368 206c 6973 s about each lis │ │ │ +00013110: 742c 2073 6565 2073 6573 7369 6f6e 5f69 t, see session_i │ │ │ +00013120: 6d70 6c2e 6870 702e 2045 6163 6820 6c69 mpl.hpp. Each li │ │ │ +00013130: 7374 0a09 092f 2f20 7265 7072 6573 656e st...// represen │ │ │ +00013140: 7473 2061 2067 726f 7570 2074 6869 7320 ts a group this │ │ │ +00013150: 746f 7272 656e 7420 6265 6c6f 6e67 7320 torrent belongs │ │ │ +00013160: 746f 2061 6e64 206d 616b 6573 2069 740a to and makes it. │ │ │ +00013170: 0909 2f2f 2065 6666 6963 6965 6e74 2074 ..// efficient t │ │ │ +00013180: 6f20 656e 756d 6572 6174 6520 6f6e 6c79 o enumerate only │ │ │ +00013190: 2074 6f72 7265 6e74 7320 6265 6c6f 6e67 torrents belong │ │ │ +000131a0: 696e 6720 746f 2061 2073 7065 6369 6669 ing to a specifi │ │ │ +000131b0: 630a 0909 2f2f 2067 726f 7570 2e20 5375 c...// group. Su │ │ │ +000131c0: 6368 2061 7320 746f 7272 656e 7473 2074 ch as torrents t │ │ │ +000131d0: 6861 7420 7761 6e74 2070 6565 7220 636f hat want peer co │ │ │ +000131e0: 6e6e 6563 7469 6f6e 7320 6f72 2077 616e nnections or wan │ │ │ +000131f0: 740a 0909 2f2f 2074 6f20 6265 2074 6963 t...// to be tic │ │ │ +00013200: 6b65 6420 6574 632e 0a0a 3c64 6976 2073 ked etc...
    ..aux::a │ │ │ +00013240: 7272 6179 266c 743b 6c69 6e6b 2c20 6175 rray<link, au │ │ │ +00013250: 783a 3a73 6573 7369 6f6e 5f69 6e74 6572 x::session_inter │ │ │ +00013260: 6661 6365 3a3a 6e75 6d5f 746f 7272 656e face::num_torren │ │ │ +00013270: 745f 6c69 7374 732c 2074 6f72 7265 6e74 t_lists, torrent │ │ │ +00013280: 5f6c 6973 745f 696e 6465 785f 7426 6774 _list_index_t> │ │ │ +00013290: 3b0a 3c2f 6469 763e 0909 096d 5f6c 696e ;.
    ...m_lin │ │ │ +000132a0: 6b73 3b0a 0a09 7072 6976 6174 653a 0a0a ks;...private:.. │ │ │ +000132b0: 0909 2f2f 206d 5f6e 756d 5f76 6572 6966 ..// m_num_verif │ │ │ +000132c0: 6965 6420 3d20 6d5f 7665 7269 6669 6564 ied = m_verified │ │ │ +000132d0: 2e63 6f75 6e74 2829 0a09 0973 7464 3a3a .count()...std:: │ │ │ +000132e0: 7569 6e74 3332 5f74 206d 5f6e 756d 5f76 uint32_t m_num_v │ │ │ +000132f0: 6572 6966 6965 6420 3d20 303b 0a0a 0909 erified = 0;.... │ │ │ +00013300: 2f2f 2069 6620 7468 6973 2074 6f72 7265 // if this torre │ │ │ +00013310: 6e74 2069 7320 7275 6e6e 696e 672c 2074 nt is running, t │ │ │ +00013320: 6869 7320 7761 7320 7468 6520 7469 6d65 his was the time │ │ │ +00013330: 0a09 092f 2f20 7768 656e 2069 7420 7761 ...// when it wa │ │ │ +00013340: 7320 7374 6172 7465 642e 2054 6869 7320 s started. This │ │ │ +00013350: 6973 2075 7365 6420 746f 2068 6176 6520 is used to have │ │ │ +00013360: 610a 0909 2f2f 2062 6961 7320 746f 7761 a...// bias towa │ │ │ +00013370: 7264 7320 6b65 6570 696e 6720 7365 6564 rds keeping seed │ │ │ +00013380: 696e 6720 746f 7272 656e 7473 2074 6861 ing torrents tha │ │ │ +00013390: 740a 0909 2f2f 2072 6563 656e 746c 7920 t...// recently │ │ │ +000133a0: 7761 7320 7374 6172 7465 642c 2074 6f20 was started, to │ │ │ +000133b0: 6176 6f69 6420 6f73 6369 6c6c 6174 696f avoid oscillatio │ │ │ +000133c0: 6e0a 0909 2f2f 2074 6869 7320 6973 2073 n...// this is s │ │ │ +000133d0: 7065 6369 6669 6564 2061 7420 6120 7365 pecified at a se │ │ │ +000133e0: 636f 6e64 2067 7261 6e75 6c61 7269 7479 cond granularity │ │ │ +000133f0: 0a09 0974 696d 655f 706f 696e 7433 3220 ...time_point32 │ │ │ +00013400: 6d5f 7374 6172 7465 6420 3d20 6175 783a m_started = aux: │ │ │ +00013410: 3a74 696d 655f 6e6f 7733 3228 293b 0a0a :time_now32();.. │ │ │ +00013420: 0909 2f2f 2069 6620 7765 2772 6520 6120 ..// if we're a │ │ │ +00013430: 7365 6564 2c20 7468 6973 2069 7320 7468 seed, this is th │ │ │ +00013440: 6520 7469 6d65 7374 616d 7020 6f66 2077 e timestamp of w │ │ │ +00013450: 6865 6e20 7765 2062 6563 616d 6520 6f6e hen we became on │ │ │ +00013460: 650a 0909 7469 6d65 5f70 6f69 6e74 3332 e...time_point32 │ │ │ +00013470: 206d 5f62 6563 616d 655f 7365 6564 203d m_became_seed = │ │ │ +00013480: 2061 7578 3a3a 7469 6d65 5f6e 6f77 3332 aux::time_now32 │ │ │ +00013490: 2829 3b0a 0a09 092f 2f20 6966 2077 6527 ();....// if we' │ │ │ +000134a0: 7265 2066 696e 6973 6865 642c 2074 6869 re finished, thi │ │ │ +000134b0: 7320 6973 2074 6865 2074 696d 6573 7461 s is the timesta │ │ │ +000134c0: 6d70 206f 6620 7768 656e 2077 6520 6669 mp of when we fi │ │ │ +000134d0: 6e69 7368 6564 0a09 0974 696d 655f 706f nished...time_po │ │ │ +000134e0: 696e 7433 3220 6d5f 6265 6361 6d65 5f66 int32 m_became_f │ │ │ +000134f0: 696e 6973 6865 6420 3d20 6175 783a 3a74 inished = aux::t │ │ │ +00013500: 696d 655f 6e6f 7733 3228 293b 0a0a 0909 ime_now32();.... │ │ │ +00013510: 2f2f 2077 6865 6e20 6368 6563 6b69 6e67 // when checking │ │ │ +00013520: 2c20 7468 6973 2069 7320 7468 6520 6669 , this is the fi │ │ │ +00013530: 7273 7420 7069 6563 6520 7765 2068 6176 rst piece we hav │ │ │ +00013540: 6520 6e6f 740a 0909 2f2f 2069 7373 7565 e not...// issue │ │ │ +00013550: 6420 6120 6861 7368 206a 6f62 2066 6f72 d a hash job for │ │ │ +00013560: 0a09 0970 6965 6365 5f69 6e64 6578 5f74 ...piece_index_t │ │ │ +00013570: 206d 5f63 6865 636b 696e 675f 7069 6563 m_checking_piec │ │ │ +00013580: 657b 307d 3b0a 0a09 092f 2f20 7468 6520 e{0};....// the │ │ │ +00013590: 6e75 6d62 6572 206f 6620 7069 6563 6573 number of pieces │ │ │ +000135a0: 2077 6520 636f 6d70 6c65 7465 6420 7468 we completed th │ │ │ +000135b0: 6520 6368 6563 6b20 6f66 0a09 0970 6965 e check of...pie │ │ │ +000135c0: 6365 5f69 6e64 6578 5f74 206d 5f6e 756d ce_index_t m_num │ │ │ +000135d0: 5f63 6865 636b 6564 5f70 6965 6365 737b _checked_pieces{ │ │ │ +000135e0: 307d 3b0a 0a09 092f 2f20 6966 2074 6865 0};....// if the │ │ │ +000135f0: 2065 7272 6f72 206f 6363 7572 7265 6420 error occurred │ │ │ +00013600: 6f6e 2061 2066 696c 652c 2074 6869 7320 on a file, this │ │ │ +00013610: 6973 2074 6865 2069 6e64 6578 206f 6620 is the index of │ │ │ +00013620: 7468 6174 2066 696c 650a 0909 2f2f 2074 that file...// t │ │ │ +00013630: 6865 7265 2061 7265 2061 2066 6577 2073 here are a few s │ │ │ +00013640: 7065 6369 616c 2063 6173 6573 2c20 7768 pecial cases, wh │ │ │ +00013650: 656e 2074 6869 7320 6973 206e 6567 6174 en this is negat │ │ │ +00013660: 6976 652e 2053 6565 0a09 092f 2f20 7365 ive. See...// se │ │ │ +00013670: 745f 6572 726f 7228 290a 3c2f 7072 653e t_error().
    │ │ │ +00013680: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +000136b0: 616e 6365 266e 6273 703b 333c 2f74 643e ance 3 │ │ │ +000136c0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/l │ │ │ +000136f0: 6962 746f 7272 656e 742f 6175 785f 2f70 ibtorrent/aux_/p │ │ │ +00013700: 655f 6372 7970 746f 2e68 7070 3a34 393c e_crypto.hpp:49< │ │ │ +00013710: 2f61 3e3c 2f74 643e 3c74 643e 6468 5f6b /a>dh_k │ │ │ +00013720: 6579 5f65 7863 6861 6e67 6520 7368 6f75 ey_exchange shou │ │ │ +00013730: 6c64 2070 726f 6261 626c 7920 6d6f 7665 ld probably move │ │ │ +00013740: 2069 6e74 6f20 6974 7320 6f77 6e20 6669 into its own fi │ │ │ +00013750: 6c65 3c2f 7464 3e3c 2f74 723e 3c74 7220 le

    d │ │ │ +000137a0: 685f 6b65 795f 6578 6368 616e 6765 2073 h_key_exchange s │ │ │ +000137b0: 686f 756c 6420 7072 6f62 6162 6c79 206d hould probably m │ │ │ +000137c0: 6f76 6520 696e 746f 2069 7473 206f 776e ove into its own │ │ │ +000137d0: 2066 696c 653c 2f68 323e 3c68 343e 2e2e file

    .. │ │ │ +000137e0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ +000137f0: 656e 742f 6175 785f 2f70 655f 6372 7970 ent/aux_/pe_cryp │ │ │ +00013800: 746f 2e68 7070 3a34 393c 2f68 343e 3c70 to.hpp:49

    .#includ │ │ │ +00013850: 6520 266c 743b 6c69 7374 2667 743b 0a23 e <list>.# │ │ │ +00013860: 696e 636c 7564 6520 266c 743b 6172 7261 include <arra │ │ │ +00013870: 7926 6774 3b0a 2369 6e63 6c75 6465 2026 y>.#include & │ │ │ +00013880: 6c74 3b63 7374 6469 6e74 2667 743b 0a0a lt;cstdint>.. │ │ │ +00013890: 6e61 6d65 7370 6163 6520 6c69 6274 6f72 namespace libtor │ │ │ +000138a0: 7265 6e74 3a3a 6175 7820 7b0a 0a09 6e61 rent::aux {...na │ │ │ +000138b0: 6d65 7370 6163 6520 6d70 203d 2062 6f6f mespace mp = boo │ │ │ +000138c0: 7374 3a3a 6d75 6c74 6970 7265 6369 7369 st::multiprecisi │ │ │ +000138d0: 6f6e 3b0a 0a09 7573 696e 6720 6b65 795f on;...using key_ │ │ │ +000138e0: 7420 3d20 6d70 3a3a 6e75 6d62 6572 266c t = mp::number&l │ │ │ +000138f0: 743b 6d70 3a3a 6370 705f 696e 745f 6261 t;mp::cpp_int_ba │ │ │ +00013900: 636b 656e 6426 6c74 3b37 3638 2c20 3736 ckend<768, 76 │ │ │ +00013910: 382c 206d 703a 3a75 6e73 6967 6e65 645f 8, mp::unsigned_ │ │ │ +00013920: 6d61 676e 6974 7564 652c 206d 703a 3a75 magnitude, mp::u │ │ │ +00013930: 6e63 6865 636b 6564 2c20 766f 6964 2667 nchecked, void&g │ │ │ +00013940: 743b 2667 743b 3b0a 0a09 544f 5252 454e t;>;...TORREN │ │ │ +00013950: 545f 4558 5452 415f 4558 504f 5254 2073 T_EXTRA_EXPORT s │ │ │ +00013960: 7464 3a3a 6172 7261 7926 6c74 3b63 6861 td::array<cha │ │ │ +00013970: 722c 2039 3626 6774 3b20 6578 706f 7274 r, 96> export │ │ │ +00013980: 5f6b 6579 286b 6579 5f74 2063 6f6e 7374 _key(key_t const │ │ │ +00013990: 2661 6d70 3b20 6b29 3b0a 0a09 2f2f 2052 & k);...// R │ │ │ +000139a0: 4334 2073 7461 7465 2066 726f 6d20 6c69 C4 state from li │ │ │ +000139b0: 6274 6f6d 6372 7970 740a 0973 7472 7563 btomcrypt..struc │ │ │ +000139c0: 7420 7263 3420 7b0a 0909 696e 7420 783b t rc4 {...int x; │ │ │ +000139d0: 0a09 0969 6e74 2079 3b0a 0909 6175 783a ...int y;...aux: │ │ │ +000139e0: 3a61 7272 6179 266c 743b 7374 643a 3a75 :array<std::u │ │ │ +000139f0: 696e 7438 5f74 2c20 3235 3626 6774 3b20 int8_t, 256> │ │ │ +00013a00: 6275 663b 0a09 7d3b 0a0a 3c64 6976 2073 buf;..};..

    .class T │ │ │ +00013a40: 4f52 5245 4e54 5f45 5854 5241 5f45 5850 ORRENT_EXTRA_EXP │ │ │ +00013a50: 4f52 5420 6468 5f6b 6579 5f65 7863 6861 ORT dh_key_excha │ │ │ +00013a60: 6e67 650a 3c2f 6469 763e 097b 0a09 7075 nge.
    .{..pu │ │ │ +00013a70: 626c 6963 3a0a 0909 6468 5f6b 6579 5f65 blic:...dh_key_e │ │ │ +00013a80: 7863 6861 6e67 6528 293b 0a0a 0909 2f2f xchange();....// │ │ │ +00013a90: 2047 6574 206c 6f63 616c 2070 7562 6c69 Get local publi │ │ │ +00013aa0: 6320 6b65 790a 0909 6b65 795f 7420 636f c key...key_t co │ │ │ +00013ab0: 6e73 7426 616d 703b 2067 6574 5f6c 6f63 nst& get_loc │ │ │ +00013ac0: 616c 5f6b 6579 2829 2063 6f6e 7374 207b al_key() const { │ │ │ +00013ad0: 2072 6574 7572 6e20 6d5f 6468 5f6c 6f63 return m_dh_loc │ │ │ +00013ae0: 616c 5f6b 6579 3b20 7d0a 0a09 092f 2f20 al_key; }....// │ │ │ +00013af0: 7265 6164 2072 656d 6f74 655f 7075 626b read remote_pubk │ │ │ +00013b00: 6579 2c20 6765 6e65 7261 7465 2061 6e64 ey, generate and │ │ │ +00013b10: 2073 746f 7265 2073 6861 7265 6420 7365 store shared se │ │ │ +00013b20: 6372 6574 2069 6e0a 0909 2f2f 206d 5f64 cret in...// m_d │ │ │ +00013b30: 685f 7368 6172 6564 5f73 6563 7265 742e h_shared_secret. │ │ │ +00013b40: 2052 6574 7572 6e73 2066 616c 7365 2069 Returns false i │ │ │ +00013b50: 6620 7468 6520 7265 6d6f 7465 2070 7562 f the remote pub │ │ │ +00013b60: 6c69 6320 6b65 7920 6973 0a09 092f 2f20 lic key is...// │ │ │ +00013b70: 6465 6765 6e65 7261 7465 2028 692e 652e degenerate (i.e. │ │ │ +00013b80: 206f 7574 7369 6465 2074 6865 2072 616e outside the ran │ │ │ +00013b90: 6765 205b 322c 2070 2d32 5d29 2061 6e64 ge [2, p-2]) and │ │ │ +00013ba0: 2074 6865 2073 6861 7265 640a 0909 2f2f the shared...// │ │ │ +00013bb0: 2073 6563 7265 7420 7761 7320 6e6f 7420 secret was not │ │ │ +00013bc0: 636f 6d70 7574 6564 2e0a 0909 626f 6f6c computed....bool │ │ │ +00013bd0: 2063 6f6d 7075 7465 5f73 6563 7265 7428 compute_secret( │ │ │ +00013be0: 7374 643a 3a75 696e 7438 5f74 2063 6f6e std::uint8_t con │ │ │ +00013bf0: 7374 2a20 7265 6d6f 7465 5f70 7562 6b65 st* remote_pubke │ │ │ +00013c00: 7929 3b0a 0909 626f 6f6c 2063 6f6d 7075 y);...bool compu │ │ │ +00013c10: 7465 5f73 6563 7265 7428 6b65 795f 7420 te_secret(key_t │ │ │ +00013c20: 636f 6e73 7426 616d 703b 2072 656d 6f74 const& remot │ │ │ +00013c30: 655f 7075 626b 6579 293b 0a0a 0909 6b65 e_pubkey);....ke │ │ │ +00013c40: 795f 7420 636f 6e73 7426 616d 703b 2067 y_t const& g │ │ │ +00013c50: 6574 5f73 6563 7265 7428 2920 636f 6e73 et_secret() cons │ │ │ +00013c60: 7420 7b20 7265 7475 726e 206d 5f64 685f t { return m_dh_ │ │ │ +00013c70: 7368 6172 6564 5f73 6563 7265 743b 207d shared_secret; } │ │ │ +00013c80: 0a0a 0909 7368 6131 5f68 6173 6820 636f ....sha1_hash co │ │ │ +00013c90: 6e73 7426 616d 703b 2067 6574 5f68 6173 nst& get_has │ │ │ +00013ca0: 685f 786f 725f 6d61 736b 2829 2063 6f6e h_xor_mask() con │ │ │ +00013cb0: 7374 207b 2072 6574 7572 6e20 6d5f 786f st { return m_xo │ │ │ +00013cc0: 725f 6d61 736b 3b20 7d0a 0a09 7072 6976 r_mask; }...priv │ │ │ +00013cd0: 6174 653a 0a0a 0909 6b65 795f 7420 6d5f ate:....key_t m_ │ │ │ +00013ce0: 6468 5f6c 6f63 616c 5f6b 6579 3b0a 0909 dh_local_key;... │ │ │ +00013cf0: 6b65 795f 7420 6d5f 6468 5f6c 6f63 616c key_t m_dh_local │ │ │ +00013d00: 5f73 6563 7265 743b 0a09 096b 6579 5f74 _secret;...key_t │ │ │ +00013d10: 206d 5f64 685f 7368 6172 6564 5f73 6563 m_dh_shared_sec │ │ │ +00013d20: 7265 743b 0a09 0973 6861 315f 6861 7368 ret;...sha1_hash │ │ │ +00013d30: 206d 5f78 6f72 5f6d 6173 6b3b 0a09 7d3b m_xor_mask;..}; │ │ │ +00013d40: 0a0a 0973 7472 7563 7420 544f 5252 454e ...struct TORREN │ │ │ +00013d50: 545f 4558 5452 415f 4558 504f 5254 2065 T_EXTRA_EXPORT e │ │ │ +00013d60: 6e63 7279 7074 696f 6e5f 6861 6e64 6c65 ncryption_handle │ │ │ +00013d70: 720a 097b 0a09 0973 7464 3a3a 7475 706c r..{...std::tupl │ │ │ +00013d80: 6526 6c74 3b69 6e74 2c20 7370 616e 266c e<int, span&l │ │ │ +00013d90: 743b 7370 616e 266c 743b 6368 6172 2063 t;span<char c │ │ │ +00013da0: 6f6e 7374 2667 743b 2667 743b 2667 743b onst>>> │ │ │ +00013db0: 0a09 0965 6e63 7279 7074 2873 7061 6e26 ...encrypt(span& │ │ │ +00013dc0: 6c74 3b73 7061 6e26 6c74 3b63 6861 7226 lt;span<char& │ │ │ +00013dd0: 6774 3b26 6774 3b20 696f 7665 6329 3b0a gt;> iovec);. │ │ │ +00013de0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e │ │ │ +00013df0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00013e20: 333c 2f74 643e 3c74 643e 3c61 2068 7265 3
    ../inc │ │ │ +00013e50: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ +00013e60: 6175 785f 2f65 6e75 6d5f 6e65 742e 6870 aux_/enum_net.hp │ │ │ +00013e70: 703a 3134 313c 2f61 3e3c 2f74 643e 3c74 p:141use string_vie │ │ │ +00013e90: 7720 666f 7220 6465 7669 6365 5f6e 616d w for device_nam │ │ │ +00013ea0: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069 e

    us │ │ │ +00013ef0: 6520 7374 7269 6e67 5f76 6965 7720 666f e string_view fo │ │ │ +00013f00: 7220 6465 7669 6365 5f6e 616d 653c 2f68 r device_name

    ../include │ │ │ +00013f20: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ +00013f30: 2f65 6e75 6d5f 6e65 742e 6870 703a 3134 /enum_net.hpp:14 │ │ │ +00013f40: 313c 2f68 343e 3c70 7265 2073 7479 6c65 1

    │ │ │ +00013f80: 092f 2f20 7265 7475 726e 206e 756c 6c6f  .// return nullo
    │ │ │ +00013f90: 7074 2e0a 0954 4f52 5245 4e54 5f45 5854  pt...TORRENT_EXT
    │ │ │ +00013fa0: 5241 5f45 5850 4f52 5420 7374 643a 3a6f  RA_EXPORT std::o
    │ │ │ +00013fb0: 7074 696f 6e61 6c26 6c74 3b61 6464 7265  ptional<addre
    │ │ │ +00013fc0: 7373 2667 743b 2067 6574 5f67 6174 6577  ss> get_gatew
    │ │ │ +00013fd0: 6179 280a 0909 6970 5f69 6e74 6572 6661  ay(...ip_interfa
    │ │ │ +00013fe0: 6365 2063 6f6e 7374 2661 6d70 3b20 6966  ce const& if
    │ │ │ +00013ff0: 6163 652c 2073 7061 6e26 6c74 3b69 705f  ace, span<ip_
    │ │ │ +00014000: 726f 7574 6520 636f 6e73 7426 6774 3b20  route const> 
    │ │ │ +00014010: 726f 7574 6573 293b 0a0a 092f 2f20 7265  routes);...// re
    │ │ │ +00014020: 7475 726e 7320 7768 6574 6865 7220 7468  turns whether th
    │ │ │ +00014030: 6572 6520 6973 2061 2072 6f75 7465 2074  ere is a route t
    │ │ │ +00014040: 6f20 7468 6520 7370 6563 6966 6965 6420  o the specified 
    │ │ │ +00014050: 6465 7669 6365 2066 6f72 2066 6f72 2061  device for for a
    │ │ │ +00014060: 6e79 2067 6c6f 6261 6c0a 092f 2f20 696e  ny global..// in
    │ │ │ +00014070: 7465 726e 6574 2061 6464 7265 7373 206f  ternet address o
    │ │ │ +00014080: 6620 7468 6520 7370 6563 6966 6965 6420  f the specified 
    │ │ │ +00014090: 6164 6472 6573 7320 6661 6d69 6c79 2e0a  address family..
    │ │ │ +000140a0: 0954 4f52 5245 4e54 5f45 5854 5241 5f45  .TORRENT_EXTRA_E
    │ │ │ +000140b0: 5850 4f52 5420 626f 6f6c 2068 6173 5f69  XPORT bool has_i
    │ │ │ +000140c0: 6e74 6572 6e65 745f 726f 7574 6528 7374  nternet_route(st
    │ │ │ +000140d0: 7269 6e67 5f76 6965 7720 6465 7669 6365  ring_view device
    │ │ │ +000140e0: 2c20 696e 7420 6661 6d69 6c79 0a09 092c  , int family...,
    │ │ │ +000140f0: 2073 7061 6e26 6c74 3b69 705f 726f 7574   span<ip_rout
    │ │ │ +00014100: 6520 636f 6e73 7426 6774 3b20 726f 7574  e const> rout
    │ │ │ +00014110: 6573 293b 0a0a 092f 2f20 7265 7475 726e  es);...// return
    │ │ │ +00014120: 7320 7768 6574 6865 7220 7468 6572 6520  s whether there 
    │ │ │ +00014130: 6172 6520 2a61 6e79 2a20 726f 7574 6573  are *any* routes
    │ │ │ +00014140: 2074 6f20 7468 6520 696e 7465 726e 6574   to the internet
    │ │ │ +00014150: 2069 6e20 7468 6520 726f 7574 696e 670a   in the routing.
    │ │ │ +00014160: 092f 2f20 7461 626c 652e 2054 6869 7320  .// table. This 
    │ │ │ +00014170: 6361 6e20 6265 2075 7365 6420 746f 2064  can be used to d
    │ │ │ +00014180: 6574 6572 6d69 6e65 2069 6620 7468 6520  etermine if the 
    │ │ │ +00014190: 726f 7574 696e 6720 7461 626c 6520 6973  routing table is
    │ │ │ +000141a0: 2066 756c 6c79 0a09 2f2f 2070 6f70 756c   fully..// popul
    │ │ │ +000141b0: 6174 6564 206f 7220 6e6f 742e 0a09 544f  ated or not...TO
    │ │ │ +000141c0: 5252 454e 545f 4558 5452 415f 4558 504f  RRENT_EXTRA_EXPO
    │ │ │ +000141d0: 5254 2062 6f6f 6c20 6861 735f 616e 795f  RT bool has_any_
    │ │ │ +000141e0: 696e 7465 726e 6574 5f72 6f75 7465 2873  internet_route(s
    │ │ │ +000141f0: 7061 6e26 6c74 3b69 705f 726f 7574 6520  pan<ip_route 
    │ │ │ +00014200: 636f 6e73 7426 6774 3b20 726f 7574 6573  const> routes
    │ │ │ +00014210: 293b 0a0a 092f 2f20 6174 7465 6d70 7420  );...// attempt 
    │ │ │ +00014220: 746f 2062 696e 6420 736f 636b 6574 2074  to bind socket t
    │ │ │ +00014230: 6f20 7468 6520 6465 7669 6365 2077 6974  o the device wit
    │ │ │ +00014240: 6820 7468 6520 7370 6563 6966 6965 6420  h the specified 
    │ │ │ +00014250: 6e61 6d65 2e20 466f 7220 7379 7374 656d  name. For system
    │ │ │ +00014260: 730a 092f 2f20 7468 6174 2064 6f6e 2774  s..// that don't
    │ │ │ +00014270: 2073 7570 706f 7274 2053 4f5f 4249 4e44   support SO_BIND
    │ │ │ +00014280: 544f 4445 5649 4345 2074 6865 2073 6f63  TODEVICE the soc
    │ │ │ +00014290: 6b65 7420 7769 6c6c 2062 6520 626f 756e  ket will be boun
    │ │ │ +000142a0: 6420 746f 206f 6e65 206f 6620 7468 650a  d to one of the.
    │ │ │ +000142b0: 092f 2f20 4950 2061 6464 7265 7373 6573  .// IP addresses
    │ │ │ +000142c0: 206f 6620 7468 6520 7370 6563 6966 6965   of the specifie
    │ │ │ +000142d0: 6420 6465 7669 6365 2e20 496e 2074 6869  d device. In thi
    │ │ │ +000142e0: 7320 6361 7365 2069 7420 6973 206e 6563  s case it is nec
    │ │ │ +000142f0: 6573 7361 7279 2074 6f0a 092f 2f20 7665  essary to..// ve
    │ │ │ +00014300: 7269 6679 2074 6865 206c 6f63 616c 2065  rify the local e
    │ │ │ +00014310: 6e64 706f 696e 7420 6f66 2074 6865 2073  ndpoint of the s
    │ │ │ +00014320: 6f63 6b65 7420 6f6e 6365 2074 6865 2063  ocket once the c
    │ │ │ +00014330: 6f6e 6e65 6374 696f 6e20 6973 2065 7374  onnection is est
    │ │ │ +00014340: 6162 6c69 7368 6564 2e0a 092f 2f20 7468  ablished...// th
    │ │ │ +00014350: 6520 7265 7475 726e 6564 2061 6464 7265  e returned addre
    │ │ │ +00014360: 7373 2069 7320 7468 6520 6970 2074 6865  ss is the ip the
    │ │ │ +00014370: 2073 6f63 6b65 7420 7761 7320 626f 756e   socket was boun
    │ │ │ +00014380: 6420 746f 2028 6f72 2061 6464 7265 7373  d to (or address
    │ │ │ +00014390: 5f76 343a 3a61 6e79 2829 0a09 2f2f 2069  _v4::any()..// i
    │ │ │ +000143a0: 6e20 6361 7365 2053 4f5f 4249 4e44 544f  n case SO_BINDTO
    │ │ │ +000143b0: 4445 5649 4345 2073 7563 6365 6564 6564  DEVICE succeeded
    │ │ │ +000143c0: 2061 6e64 2077 6520 646f 6e27 7420 6e65   and we don't ne
    │ │ │ +000143d0: 6564 2074 6f20 7665 7269 6679 2069 7429  ed to verify it)
    │ │ │ +000143e0: 2e0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00014410: 0974 656d 706c 6174 6520 266c 743b 636c .template <cl │ │ │ +00014420: 6173 7320 536f 636b 6574 2667 743b 0a3c ass Socket>.< │ │ │ +00014430: 2f64 6976 3e09 6164 6472 6573 7320 6269 /div>.address bi │ │ │ +00014440: 6e64 5f73 6f63 6b65 745f 746f 5f64 6576 nd_socket_to_dev │ │ │ +00014450: 6963 6528 696f 5f63 6f6e 7465 7874 2661 ice(io_context&a │ │ │ +00014460: 6d70 3b20 696f 732c 2053 6f63 6b65 7426 mp; ios, Socket& │ │ │ +00014470: 616d 703b 2073 6f63 6b0a 0909 2c20 7463 amp; sock..., tc │ │ │ +00014480: 7020 636f 6e73 7426 616d 703b 2070 726f p const& pro │ │ │ +00014490: 746f 636f 6c0a 0909 2c20 6368 6172 2063 tocol..., char c │ │ │ +000144a0: 6f6e 7374 2a20 6465 7669 6365 5f6e 616d onst* device_nam │ │ │ +000144b0: 652c 2069 6e74 2070 6f72 742c 2065 7272 e, int port, err │ │ │ +000144c0: 6f72 5f63 6f64 6526 616d 703b 2065 6329 or_code& ec) │ │ │ +000144d0: 0a09 7b0a 0909 7463 703a 3a65 6e64 706f ..{...tcp::endpo │ │ │ +000144e0: 696e 7420 6269 6e64 5f65 7028 6164 6472 int bind_ep(addr │ │ │ +000144f0: 6573 735f 7634 3a3a 616e 7928 292c 2073 ess_v4::any(), s │ │ │ +00014500: 7464 3a3a 7569 6e74 3136 5f74 2870 6f72 td::uint16_t(por │ │ │ +00014510: 7429 293b 0a0a 0909 6164 6472 6573 7320 t));....address │ │ │ +00014520: 6970 203d 206d 616b 655f 6164 6472 6573 ip = make_addres │ │ │ +00014530: 7328 6465 7669 6365 5f6e 616d 652c 2065 s(device_name, e │ │ │ +00014540: 6329 3b0a 0909 6966 2028 2165 6329 0a09 c);...if (!ec).. │ │ │ +00014550: 097b 0a09 0909 2f2f 2074 6869 7320 6973 .{....// this is │ │ │ +00014560: 2074 6f20 636f 7665 7220 7468 6520 6361 to cover the ca │ │ │ +00014570: 7365 2077 6865 7265 2022 302e 302e 302e se where "0.0.0. │ │ │ +00014580: 3022 2069 7320 636f 6e73 6964 6572 6564 0" is considered │ │ │ +00014590: 2061 6e79 2049 5076 3420 6f72 0a09 0909 any IPv4 or.... │ │ │ +000145a0: 2f2f 2049 5076 3620 6164 6472 6573 732e // IPv6 address. │ │ │ +000145b0: 2049 6620 7765 2772 6520 6173 6b69 6e67 If we're asking │ │ │ +000145c0: 2074 6f20 6265 2062 6f75 6e64 2074 6f20 to be bound to │ │ │ +000145d0: 616e 2049 5076 3620 6164 6472 6573 7320 an IPv6 address │ │ │ +000145e0: 616e 640a 0909 092f 2f20 7072 6f76 6964 and....// provid │ │ │ +000145f0: 696e 6720 302e 302e 302e 3020 6173 2074 ing 0.0.0.0 as t │ │ │ +00014600: 6865 2064 6576 6963 652c 2074 7572 6e20 he device, turn │ │ │ +00014610: 6974 2069 6e74 6f20 223a 3a22 0a09 0909 it into "::".... │ │ │ +00014620: 6966 2028 6970 203d 3d20 6164 6472 6573 if (ip == addres │ │ │ +00014630: 735f 7634 3a3a 616e 7928 2920 2661 6d70 s_v4::any() & │ │ │ +00014640: 3b26 616d 703b 2070 726f 746f 636f 6c20 ;& protocol │ │ │ +00014650: 3d3d 2062 6f6f 7374 3a3a 6173 696f 3a3a == boost::asio:: │ │ │ +00014660: 6970 3a3a 7463 703a 3a76 3628 2929 0a09 ip::tcp::v6()).. │ │ │ +00014670: 0909 0969 7020 3d20 6164 6472 6573 735f ...ip = address_ │ │ │ +00014680: 7636 3a3a 616e 7928 293b 0a09 0909 6269 v6::any();....bi │ │ │ +00014690: 6e64 5f65 702e 6164 6472 6573 7328 6970 nd_ep.address(ip │ │ │ +000146a0: 293b 0a09 0909 2f2f 2069 7420 6170 7065 );....// it appe │ │ │ +000146b0: 6172 7320 746f 2062 6520 616e 2049 502e ars to be an IP. │ │ │ +000146c0: 204a 7573 7420 6269 6e64 2074 6f20 7468 Just bind to th │ │ │ +000146d0: 6174 2061 6464 7265 7373 0a09 0909 736f at address....so │ │ │ +000146e0: 636b 2e62 696e 6428 6269 6e64 5f65 702c ck.bind(bind_ep, │ │ │ +000146f0: 2065 6329 3b0a 0909 0972 6574 7572 6e20 ec);....return │ │ │ +00014700: 6269 6e64 5f65 702e 6164 6472 6573 7328 bind_ep.address( │ │ │ +00014710: 293b 0a09 097d 0a0a 0909 6563 2e63 6c65 );...}....ec.cle │ │ │ +00014720: 6172 2829 3b0a 0a23 6966 2054 4f52 5245 ar();..#if TORRE │ │ │ +00014730: 4e54 5f48 4153 5f42 494e 4454 4f44 4556 NT_HAS_BINDTODEV │ │ │ +00014740: 4943 450a 0909 2f2f 2074 7279 2074 6f20 ICE...// try to │ │ │ +00014750: 7573 6520 534f 5f42 494e 4454 4f44 4556 use SO_BINDTODEV │ │ │ +00014760: 4943 4520 6865 7265 2c20 6966 2074 6861 ICE here, if tha │ │ │ +00014770: 7420 6578 6973 7473 2e20 4966 2069 7420 t exists. If it │ │ │ +00014780: 6661 696c 732c 0a09 092f 2f20 6661 6c6c fails,...// fall │ │ │ +00014790: 2062 6163 6b20 746f 2074 6865 206d 6563 back to the mec │ │ │ +000147a0: 6861 6e69 736d 2077 6520 6861 7665 2062 hanism we have b │ │ │ +000147b0: 656c 6f77 0a09 0961 7578 3a3a 6269 6e64 elow...aux::bind │ │ │ +000147c0: 5f64 6576 6963 6528 736f 636b 2c20 6465 _device(sock, de │ │ │ +000147d0: 7669 6365 5f6e 616d 652c 2065 6329 3b0a vice_name, ec);. │ │ │ +000147e0: 0909 6966 2028 6563 290a 2365 6e64 6966 ..if (ec).#endif │ │ │ +000147f0: 0a09 097b 0a09 0909 6563 2e63 6c65 6172 ...{....ec.clear │ │ │ +00014800: 2829 3b0a 3c2f 7072 653e 3c2f 7464 3e3c ();.
    < │ │ │ 00014810: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ 00014840: 6273 703b 323c 2f74 643e 3c74 643e 3c61 bsp;2.. │ │ │ -00014870: 2f74 6573 742f 7465 7374 5f64 6874 2e63 /test/test_dht.c │ │ │ -00014880: 7070 3a31 3633 373c 2f61 3e3c 2f74 643e pp:1637 │ │ │ -00014890: 3c74 643e 7465 7374 206e 756d 5f67 6c6f test num_glo │ │ │ -000148a0: 6261 6c5f 6e6f 6465 733c 2f74 643e 3c2f bal_nodes

    test num_g │ │ │ -00014900: 6c6f 6261 6c5f 6e6f 6465 733c 2f68 323e lobal_nodes

    │ │ │ -00014910: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00014920: 5f64 6874 2e63 7070 3a31 3633 373c 2f68 _dht.cpp:1637
    rel
    │ │ │ -000149a0: 6576 616e 6365 266e 6273 703b 323c 2f74  evance 2../test/te
    │ │ │ -000149e0: 7374 5f64 6874 2e63 7070 3a31 3633 383c  st_dht.cpp:1638<
    │ │ │ -000149f0: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374  /a>test
    │ │ │ -00014a00: 206e 6565 645f 7265 6672 6573 683c 2f74   need_refresh

    test n │ │ │ -00014a60: 6565 645f 7265 6672 6573 683c 2f68 323e eed_refresh

    │ │ │ -00014a70: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00014a80: 5f64 6874 2e63 7070 3a31 3633 383c 2f68 _dht.cpp:1638
    ..s.
    │ │ │ -00014ad0: 7365 745f 626f 6f6c 2873 6574 7469 6e67  set_bool(setting
    │ │ │ -00014ae0: 735f 7061 636b 3a3a 6468 745f 7265 7374  s_pack::dht_rest
    │ │ │ -00014af0: 7269 6374 5f72 6f75 7469 6e67 5f69 7073  rict_routing_ips
    │ │ │ -00014b00: 2c20 6661 6c73 6529 3b0a 0a09 7b0a 0909  , false);...{...
    │ │ │ -00014b10: 6175 746f 2063 6f6e 7374 2065 7020 3d20  auto const ep = 
    │ │ │ -00014b20: 7261 6e64 5f75 6470 5f65 7028 7261 6e64  rand_udp_ep(rand
    │ │ │ -00014b30: 5f61 6464 7229 3b0a 0909 6175 746f 2063  _addr);...auto c
    │ │ │ -00014b40: 6f6e 7374 2069 6420 3d20 6765 6e65 7261  onst id = genera
    │ │ │ -00014b50: 7465 5f69 645f 696d 706c 2865 702e 6164  te_id_impl(ep.ad
    │ │ │ -00014b60: 6472 6573 7328 292c 2032 293b 0a09 0974  dress(), 2);...t
    │ │ │ -00014b70: 6162 6c65 2e6e 6f64 655f 7365 656e 2869  able.node_seen(i
    │ │ │ -00014b80: 642c 2065 702c 2031 3029 3b0a 097d 0a0a  d, ep, 10);..}..
    │ │ │ -00014b90: 096e 6f64 6573 2e63 6c65 6172 2829 3b0a  .nodes.clear();.
    │ │ │ -00014ba0: 0966 6f72 2028 696e 7420 6920 3d20 303b  .for (int i = 0;
    │ │ │ -00014bb0: 2069 2026 6c74 3b20 3130 3030 303b 202b   i < 10000; +
    │ │ │ -00014bc0: 2b69 290a 097b 0a09 0961 7574 6f20 636f  +i)..{...auto co
    │ │ │ -00014bd0: 6e73 7420 6570 203d 2072 616e 645f 7564  nst ep = rand_ud
    │ │ │ -00014be0: 705f 6570 2872 616e 645f 6164 6472 293b  p_ep(rand_addr);
    │ │ │ -00014bf0: 0a09 0961 7574 6f20 636f 6e73 7420 6964  ...auto const id
    │ │ │ -00014c00: 203d 2067 656e 6572 6174 655f 6964 5f69   = generate_id_i
    │ │ │ -00014c10: 6d70 6c28 6570 2e61 6464 7265 7373 2829  mpl(ep.address()
    │ │ │ -00014c20: 2c20 3629 3b0a 0909 7461 626c 652e 6e6f  , 6);...table.no
    │ │ │ -00014c30: 6465 5f73 6565 6e28 6964 2c20 6570 2c20  de_seen(id, ep, 
    │ │ │ -00014c40: 3230 202b 2028 6964 5b31 395d 2026 616d  20 + (id[19] &am
    │ │ │ -00014c50: 703b 2030 7866 6629 293b 0a09 7d0a 0973  p; 0xff));..}..s
    │ │ │ -00014c60: 7464 3a3a 7072 696e 7466 2822 6163 7469  td::printf("acti
    │ │ │ -00014c70: 7665 2062 7563 6b65 7473 3a20 2564 5c6e  ve buckets: %d\n
    │ │ │ -00014c80: 222c 2074 6162 6c65 2e6e 756d 5f61 6374  ", table.num_act
    │ │ │ -00014c90: 6976 655f 6275 636b 6574 7328 2929 3b0a  ive_buckets());.
    │ │ │ -00014ca0: 0954 4553 545f 4348 4543 4b28 7461 626c  .TEST_CHECK(tabl
    │ │ │ -00014cb0: 652e 6e75 6d5f 6163 7469 7665 5f62 7563  e.num_active_buc
    │ │ │ -00014cc0: 6b65 7473 2829 203d 3d20 3131 0a09 097c  kets() == 11...|
    │ │ │ -00014cd0: 7c20 7461 626c 652e 6e75 6d5f 6163 7469  | table.num_acti
    │ │ │ -00014ce0: 7665 5f62 7563 6b65 7473 2829 203d 3d20  ve_buckets() == 
    │ │ │ -00014cf0: 3132 293b 0a09 5445 5354 5f43 4845 434b  12);..TEST_CHECK
    │ │ │ -00014d00: 2873 7464 3a3a 6765 7426 6c74 3b30 2667  (std::get<0&g
    │ │ │ -00014d10: 743b 2874 6162 6c65 2e73 697a 6528 2929  t;(table.size())
    │ │ │ -00014d20: 2026 6774 3b3d 2062 7563 6b65 745f 7369   >= bucket_si
    │ │ │ -00014d30: 7a65 202a 2031 3029 3b0a 3c64 6976 2073  ze * 10);.
    .
    . │ │ │ -00014d70: 7072 696e 745f 7374 6174 6528 7374 643a print_state(std: │ │ │ -00014d80: 3a63 6f75 742c 2074 6162 6c65 293b 0a0a :cout, table);.. │ │ │ -00014d90: 0974 6162 6c65 2e66 6f72 5f65 6163 685f .table.for_each_ │ │ │ -00014da0: 6e6f 6465 2873 7464 3a3a 6269 6e64 286e node(std::bind(n │ │ │ -00014db0: 6f64 655f 7075 7368 5f62 6163 6b2c 2026 ode_push_back, & │ │ │ -00014dc0: 616d 703b 6e6f 6465 732c 205f 3129 2c20 amp;nodes, _1), │ │ │ -00014dd0: 6e75 6c6c 7074 7229 3b0a 0a09 7374 643a nullptr);...std: │ │ │ -00014de0: 3a70 7269 6e74 6628 226e 6f64 6573 3a20 :printf("nodes: │ │ │ -00014df0: 2564 5c6e 222c 2069 6e74 286e 6f64 6573 %d\n", int(nodes │ │ │ -00014e00: 2e73 697a 6528 2929 293b 0a0a 0a09 7b0a .size()));....{. │ │ │ -00014e10: 0909 6e6f 6465 5f69 6420 636f 6e73 7420 ..node_id const │ │ │ -00014e20: 6964 203d 2067 656e 6572 6174 655f 7261 id = generate_ra │ │ │ -00014e30: 6e64 6f6d 5f69 6428 293b 0a09 0973 7464 ndom_id();...std │ │ │ -00014e40: 3a3a 7665 6374 6f72 266c 743b 6e6f 6465 ::vector<node │ │ │ -00014e50: 5f65 6e74 7279 2667 743b 2074 656d 7020 _entry> temp │ │ │ -00014e60: 3d20 7461 626c 652e 6669 6e64 5f6e 6f64 = table.find_nod │ │ │ -00014e70: 6528 6964 2c20 7b7d 2c20 696e 7428 6e6f e(id, {}, int(no │ │ │ -00014e80: 6465 732e 7369 7a65 2829 2920 2a20 3229 des.size()) * 2) │ │ │ -00014e90: 3b0a 0909 7374 643a 3a70 7269 6e74 6628 ;...std::printf( │ │ │ -00014ea0: 2272 6574 7572 6e65 642d 616c 6c3a 2025 "returned-all: % │ │ │ -00014eb0: 645c 6e22 2c20 696e 7428 7465 6d70 2e73 d\n", int(temp.s │ │ │ -00014ec0: 697a 6528 2929 293b 0a09 0954 4553 545f ize()));...TEST_ │ │ │ -00014ed0: 4551 5541 4c28 7465 6d70 2e73 697a 6528 EQUAL(temp.size( │ │ │ -00014ee0: 292c 206e 6f64 6573 2e73 697a 6528 2929 ), nodes.size()) │ │ │ -00014ef0: 3b0a 097d 0a0a 092f 2f20 5468 6973 206d ;..}...// This m │ │ │ -00014f00: 616b 6573 2073 7572 6520 656e 6f75 6768 akes sure enough │ │ │ -00014f10: 206f 6620 7468 6520 6e6f 6465 7320 7265 of the nodes re │ │ │ -00014f20: 7475 726e 6564 2061 7265 2061 6374 7561 turned are actua │ │ │ -00014f30: 6c6c 790a 092f 2f20 7061 7274 206f 6620 lly..// part of │ │ │ -00014f40: 7468 6520 636c 6f73 6573 7420 6e6f 6465 the closest node │ │ │ -00014f50: 730a 0973 7464 3a3a 7365 7426 6c74 3b6e s..std::set<n │ │ │ -00014f60: 6f64 655f 6964 2667 743b 2064 7570 6c69 ode_id> dupli │ │ │ -00014f70: 6361 7465 733b 0a0a 0963 6f6e 7374 2069 cates;...const i │ │ │ -00014f80: 6e74 2072 6570 7320 3d20 3530 3b0a 0a09 nt reps = 50;... │ │ │ -00014f90: 666f 7220 2869 6e74 2072 203d 2030 3b20 for (int r = 0; │ │ │ -00014fa0: 7220 266c 743b 2072 6570 733b 202b 2b72 r < reps; ++r │ │ │ -00014fb0: 290a 097b 0a09 096e 6f64 655f 6964 2063 )..{...node_id c │ │ │ -00014fc0: 6f6e 7374 2069 6420 3d20 6765 6e65 7261 onst id = genera │ │ │ -00014fd0: 7465 5f72 616e 646f 6d5f 6964 2829 3b0a te_random_id();. │ │ │ -00014fe0: 0909 7374 643a 3a76 6563 746f 7226 6c74 ..std::vector< │ │ │ -00014ff0: 3b6e 6f64 655f 656e 7472 7926 6774 3b20 ;node_entry> │ │ │ -00015000: 7465 6d70 203d 2074 6162 6c65 2e66 696e temp = table.fin │ │ │ -00015010: 645f 6e6f 6465 2869 642c 207b 7d2c 2062 d_node(id, {}, b │ │ │ -00015020: 7563 6b65 745f 7369 7a65 202a 2032 293b ucket_size * 2); │ │ │ -00015030: 0a09 0954 4553 545f 4551 5541 4c28 696e ...TEST_EQUAL(in │ │ │ -00015040: 7428 7465 6d70 2e73 697a 6528 2929 2c20 t(temp.size()), │ │ │ -00015050: 7374 643a 3a6d 696e 2862 7563 6b65 745f std::min(bucket_ │ │ │ -00015060: 7369 7a65 202a 2032 2c20 696e 7428 6e6f size * 2, int(no │ │ │ -00015070: 6465 732e 7369 7a65 2829 2929 293b 0a0a des.size())));.. │ │ │ -00015080: 0909 7374 643a 3a73 6f72 7428 6e6f 6465 ..std::sort(node │ │ │ -00015090: 732e 6265 6769 6e28 292c 206e 6f64 6573 s.begin(), nodes │ │ │ -000150a0: 2e65 6e64 2829 2c20 7374 643a 3a62 696e .end(), std::bin │ │ │ -000150b0: 6428 2661 6d70 3b63 6f6d 7061 7265 5f72 d(&compare_r │ │ │ -000150c0: 6566 0a09 0909 092c 2073 7464 3a3a 6269 ef....., std::bi │ │ │ -000150d0: 6e64 2826 616d 703b 6e6f 6465 5f65 6e74 nd(&node_ent │ │ │ -000150e0: 7279 3a3a 6964 2c20 5f31 290a 0909 0909 ry::id, _1)..... │ │ │ -000150f0: 2c20 7374 643a 3a62 696e 6428 2661 6d70 , std::bind(& │ │ │ -00015100: 3b6e 6f64 655f 656e 7472 793a 3a69 642c ;node_entry::id, │ │ │ -00015110: 205f 3229 2c20 6964 2929 3b0a 0a3c 2f70 _2), id));..

    re │ │ │ -00015150: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2
    ../test/t │ │ │ -00015190: 6573 745f 6468 742e 6370 703a 3238 3233 est_dht.cpp:2823 │ │ │ -000151a0: 3c2f 613e 3c2f 7464 3e3c 7464 3e73 706c spl │ │ │ -000151b0: 6974 2074 6869 7320 7570 2069 6e74 6f20 it this up into │ │ │ -000151c0: 736d 616c 6c65 7220 7465 7374 2063 6173 smaller test cas │ │ │ -000151d0: 6573 3c2f 7464 3e3c 2f74 723e 3c74 7220 es

    s │ │ │ -00015220: 706c 6974 2074 6869 7320 7570 2069 6e74 plit this up int │ │ │ -00015230: 6f20 736d 616c 6c65 7220 7465 7374 2063 o smaller test c │ │ │ -00015240: 6173 6573 3c2f 6832 3e3c 6834 3e2e 2e2f ases

    ../ │ │ │ -00015250: 7465 7374 2f74 6573 745f 6468 742e 6370 test/test_dht.cp │ │ │ -00015260: 703a 3238 3233 3c2f 6834 3e3c 7072 6520 p:2823

    ..TEST_EQUA
    │ │ │ -000152b0: 4c28 6175 783a 3a74 6f5f 6865 7828 7369  L(aux::to_hex(si
    │ │ │ -000152c0: 672e 6279 7465 7329 0a09 092c 2022 3638  g.bytes)..., "68
    │ │ │ -000152d0: 3334 3238 3462 3662 3234 6333 3230 3465  34284b6b24c3204e
    │ │ │ -000152e0: 6232 6665 6138 3234 6438 3266 3838 3838  b2fea824d82f8888
    │ │ │ -000152f0: 3361 3364 3935 6538 6234 6132 3162 3863  3a3d95e8b4a21b8c
    │ │ │ -00015300: 3064 6564 3535 3364 3137 6431 3764 220a  0ded553d17d17d".
    │ │ │ -00015310: 0909 2264 6639 6138 6137 3130 3462 3132  .."df9a8a7104b12
    │ │ │ -00015320: 3538 6633 3062 6564 3337 3837 6536 6362  58f30bed3787e6cb
    │ │ │ -00015330: 3839 3666 6361 3738 6335 3866 3865 3033  896fca78c58f8e03
    │ │ │ -00015340: 6235 6631 3866 3134 3935 3161 3837 6439  b5f18f14951a87d9
    │ │ │ -00015350: 6130 3822 293b 0a0a 0973 6861 315f 6861  a08");...sha1_ha
    │ │ │ -00015360: 7368 2074 6172 6765 745f 6964 203d 2069  sh target_id = i
    │ │ │ -00015370: 7465 6d5f 7461 7267 6574 5f69 6428 7465  tem_target_id(te
    │ │ │ -00015380: 7374 5f73 616c 742c 2070 6b29 3b0a 0954  st_salt, pk);..T
    │ │ │ -00015390: 4553 545f 4551 5541 4c28 6175 783a 3a74  EST_EQUAL(aux::t
    │ │ │ -000153a0: 6f5f 6865 7828 7461 7267 6574 5f69 6429  o_hex(target_id)
    │ │ │ -000153b0: 2c20 2234 3131 6562 6137 3362 3666 3038  , "411eba73b6f08
    │ │ │ -000153c0: 3763 6135 3161 3337 3935 6439 6338 6339  7ca51a3795d9c8c9
    │ │ │ -000153d0: 3338 6433 3635 6533 3263 3122 293b 0a7d  38d365e32c1");.}
    │ │ │ -000153e0: 0a0a 544f 5252 454e 545f 5445 5354 2873  ..TORRENT_TEST(s
    │ │ │ -000153f0: 6967 6e69 6e67 5f74 6573 7433 290a 7b0a  igning_test3).{.
    │ │ │ -00015400: 092f 2f20 7465 7374 2076 6563 746f 7220  .// test vector 
    │ │ │ -00015410: 330a 0a09 2f2f 2074 6573 7420 636f 6e74  3...// test cont
    │ │ │ -00015420: 656e 740a 0973 7061 6e26 6c74 3b63 6861  ent..span<cha
    │ │ │ -00015430: 7220 636f 6e73 7426 6774 3b20 7465 7374  r const> test
    │ │ │ -00015440: 5f63 6f6e 7465 6e74 2822 3132 3a48 656c  _content("12:Hel
    │ │ │ -00015450: 6c6f 2057 6f72 6c64 2122 2c20 3135 293b  lo World!", 15);
    │ │ │ -00015460: 0a0a 0973 6861 315f 6861 7368 2074 6172  ...sha1_hash tar
    │ │ │ -00015470: 6765 745f 6964 203d 2069 7465 6d5f 7461  get_id = item_ta
    │ │ │ -00015480: 7267 6574 5f69 6428 7465 7374 5f63 6f6e  rget_id(test_con
    │ │ │ -00015490: 7465 6e74 293b 0a09 5445 5354 5f45 5155  tent);..TEST_EQU
    │ │ │ -000154a0: 414c 2861 7578 3a3a 746f 5f68 6578 2874  AL(aux::to_hex(t
    │ │ │ -000154b0: 6172 6765 745f 6964 292c 2022 6535 6639  arget_id), "e5f9
    │ │ │ -000154c0: 3666 3666 3338 3332 3066 3066 3333 3935  6f6f38320f0f3395
    │ │ │ -000154d0: 3963 6234 6433 6436 3536 3435 3231 3137  9cb4d3d656452117
    │ │ │ -000154e0: 6161 6462 2229 3b0a 7d0a 0a3c 6469 7620  aadb");.}..
    TORRENT │ │ │ -00015520: 5f54 4553 5428 7665 7269 6679 5f6d 6573 _TEST(verify_mes │ │ │ -00015530: 7361 6765 290a 3c2f 6469 763e 7b0a 0963 sage).
    {..c │ │ │ -00015540: 6861 7220 6572 726f 725f 7374 7269 6e67 har error_string │ │ │ -00015550: 5b32 3030 5d3b 0a0a 092f 2f20 7465 7374 [200];...// test │ │ │ -00015560: 2076 6572 6966 795f 6d65 7373 6167 650a verify_message. │ │ │ -00015570: 0973 7461 7469 6320 636f 6e73 7420 6b65 .static const ke │ │ │ -00015580: 795f 6465 7363 5f74 206d 7367 5f64 6573 y_desc_t msg_des │ │ │ -00015590: 635b 5d20 3d20 7b0a 0909 7b22 4122 2c20 c[] = {...{"A", │ │ │ -000155a0: 6264 6563 6f64 655f 6e6f 6465 3a3a 7374 bdecode_node::st │ │ │ -000155b0: 7269 6e67 5f74 2c20 342c 2030 7d2c 0a09 ring_t, 4, 0},.. │ │ │ -000155c0: 097b 2242 222c 2062 6465 636f 6465 5f6e .{"B", bdecode_n │ │ │ -000155d0: 6f64 653a 3a64 6963 745f 742c 2030 2c20 ode::dict_t, 0, │ │ │ -000155e0: 6b65 795f 6465 7363 5f74 3a3a 6f70 7469 key_desc_t::opti │ │ │ -000155f0: 6f6e 616c 207c 206b 6579 5f64 6573 635f onal | key_desc_ │ │ │ -00015600: 743a 3a70 6172 7365 5f63 6869 6c64 7265 t::parse_childre │ │ │ -00015610: 6e7d 2c0a 0909 097b 2242 3122 2c20 6264 n},....{"B1", bd │ │ │ -00015620: 6563 6f64 655f 6e6f 6465 3a3a 7374 7269 ecode_node::stri │ │ │ -00015630: 6e67 5f74 2c20 302c 2030 7d2c 0a09 0909 ng_t, 0, 0},.... │ │ │ -00015640: 7b22 4232 222c 2062 6465 636f 6465 5f6e {"B2", bdecode_n │ │ │ -00015650: 6f64 653a 3a73 7472 696e 675f 742c 2030 ode::string_t, 0 │ │ │ -00015660: 2c20 6b65 795f 6465 7363 5f74 3a3a 6c61 , key_desc_t::la │ │ │ -00015670: 7374 5f63 6869 6c64 7d2c 0a09 097b 2243 st_child},...{"C │ │ │ -00015680: 222c 2062 6465 636f 6465 5f6e 6f64 653a ", bdecode_node: │ │ │ -00015690: 3a64 6963 745f 742c 2030 2c20 6b65 795f :dict_t, 0, key_ │ │ │ -000156a0: 6465 7363 5f74 3a3a 6f70 7469 6f6e 616c desc_t::optional │ │ │ -000156b0: 207c 206b 6579 5f64 6573 635f 743a 3a70 | key_desc_t::p │ │ │ -000156c0: 6172 7365 5f63 6869 6c64 7265 6e7d 2c0a arse_children},. │ │ │ -000156d0: 0909 097b 2243 3122 2c20 6264 6563 6f64 ...{"C1", bdecod │ │ │ -000156e0: 655f 6e6f 6465 3a3a 7374 7269 6e67 5f74 e_node::string_t │ │ │ -000156f0: 2c20 302c 2030 7d2c 0a09 0909 7b22 4332 , 0, 0},....{"C2 │ │ │ -00015700: 222c 2062 6465 636f 6465 5f6e 6f64 653a ", bdecode_node: │ │ │ -00015710: 3a73 7472 696e 675f 742c 2030 2c20 6b65 :string_t, 0, ke │ │ │ -00015720: 795f 6465 7363 5f74 3a3a 6c61 7374 5f63 y_desc_t::last_c │ │ │ -00015730: 6869 6c64 7d2c 0a09 7d3b 0a0a 0962 6465 hild},..};...bde │ │ │ -00015740: 636f 6465 5f6e 6f64 6520 6d73 675f 6b65 code_node msg_ke │ │ │ -00015750: 7973 5b37 5d3b 0a0a 0962 6465 636f 6465 ys[7];...bdecode │ │ │ -00015760: 5f6e 6f64 6520 656e 743b 0a0a 0965 7272 _node ent;...err │ │ │ -00015770: 6f72 5f63 6f64 6520 6563 3b0a 0963 6861 or_code ec;..cha │ │ │ -00015780: 7220 636f 6e73 7420 7465 7374 5f6d 7367 r const test_msg │ │ │ -00015790: 5b5d 203d 2022 6431 3a41 343a 7465 7374 [] = "d1:A4:test │ │ │ -000157a0: 313a 4264 323a 4231 353a 7465 7374 3232 1:Bd2:B15:test22 │ │ │ -000157b0: 3a42 3235 3a74 6573 7433 6565 223b 0a09 :B25:test3ee";.. │ │ │ -000157c0: 6264 6563 6f64 6528 7465 7374 5f6d 7367 bdecode(test_msg │ │ │ -000157d0: 2c20 7465 7374 5f6d 7367 202b 2073 697a , test_msg + siz │ │ │ -000157e0: 656f 6628 7465 7374 5f6d 7367 292d 312c eof(test_msg)-1, │ │ │ -000157f0: 2065 6e74 2c20 6563 293b 0a09 7374 643a ent, ec);..std: │ │ │ -00015800: 3a70 7269 6e74 6628 2225 735c 6e22 2c20 :printf("%s\n", │ │ │ -00015810: 7072 696e 745f 656e 7472 7928 656e 7429 print_entry(ent) │ │ │ -00015820: 2e63 5f73 7472 2829 293b 0a0a 0962 6f6f .c_str());...boo │ │ │ -00015830: 6c20 7265 7420 3d20 7665 7269 6679 5f6d l ret = verify_m │ │ │ -00015840: 6573 7361 6765 2865 6e74 2c20 6d73 675f essage(ent, msg_ │ │ │ -00015850: 6465 7363 2c20 6d73 675f 6b65 7973 2c20 desc, msg_keys, │ │ │ -00015860: 6572 726f 725f 7374 7269 6e67 293b 0a09 error_string);.. │ │ │ -00015870: 5445 5354 5f43 4845 434b 2872 6574 293b TEST_CHECK(ret); │ │ │ -00015880: 0a09 5445 5354 5f43 4845 434b 286d 7367 ..TEST_CHECK(msg │ │ │ -00015890: 5f6b 6579 735b 305d 293b 0a09 6966 2028 _keys[0]);..if ( │ │ │ -000158a0: 6d73 675f 6b65 7973 5b30 5d29 2054 4553 msg_keys[0]) TES │ │ │ -000158b0: 545f 4551 5541 4c28 6d73 675f 6b65 7973 T_EQUAL(msg_keys │ │ │ -000158c0: 5b30 5d2e 7374 7269 6e67 5f76 616c 7565 [0].string_value │ │ │ -000158d0: 2829 2c20 2274 6573 7422 293b 0a09 5445 (), "test");..TE │ │ │ -000158e0: 5354 5f43 4845 434b 286d 7367 5f6b 6579 ST_CHECK(msg_key │ │ │ -000158f0: 735b 315d 293b 0a09 5445 5354 5f43 4845 s[1]);..TEST_CHE │ │ │ -00015900: 434b 286d 7367 5f6b 6579 735b 325d 293b CK(msg_keys[2]); │ │ │ -00015910: 0a09 6966 2028 6d73 675f 6b65 7973 5b32 ..if (msg_keys[2 │ │ │ -00015920: 5d29 2054 4553 545f 4551 5541 4c28 6d73 ]) TEST_EQUAL(ms │ │ │ -00015930: 675f 6b65 7973 5b32 5d2e 7374 7269 6e67 g_keys[2].string │ │ │ -00015940: 5f76 616c 7565 2829 2c20 2274 6573 7432 _value(), "test2 │ │ │ -00015950: 2229 3b0a 3c2f 7072 653e 3c2f 7464 3e3c ");.
    < │ │ │ -00015960: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00015990: 6273 703b 323c 2f74 643e 3c74 643e 3c61 bsp;2.. │ │ │ -000159c0: 2f74 6573 742f 7465 7374 5f73 746f 7261 /test/test_stora │ │ │ -000159d0: 6765 2e63 7070 3a38 3234 3c2f 613e 3c2f ge.cpp:824split thi │ │ │ -000159f0: 7320 7465 7374 2075 7020 696e 746f 2073 s test up into s │ │ │ -00015a00: 6d61 6c6c 6572 2070 6172 7473 3c2f 7464 maller parts

    split t │ │ │ -00015a60: 6869 7320 7465 7374 2075 7020 696e 746f his test up into │ │ │ -00015a70: 2073 6d61 6c6c 6572 2070 6172 7473 3c2f smaller parts

    ../test/t │ │ │ -00015a90: 6573 745f 7374 6f72 6167 652e 6370 703a est_storage.cpp: │ │ │ -00015aa0: 3832 343c 2f68 343e 3c70 7265 2073 7479 824

    ..0_piece,...{
    │ │ │ -00015af0: 7d2c 0a09 0964 6973 6b5f 696e 7465 7266  },...disk_interf
    │ │ │ -00015b00: 6163 653a 3a73 6571 7565 6e74 6961 6c5f  ace::sequential_
    │ │ │ -00015b10: 6163 6365 7373 207c 2064 6973 6b5f 696e  access | disk_in
    │ │ │ -00015b20: 7465 7266 6163 653a 3a76 6f6c 6174 696c  terface::volatil
    │ │ │ -00015b30: 655f 7265 6164 207c 2064 6973 6b5f 696e  e_read | disk_in
    │ │ │ -00015b40: 7465 7266 6163 653a 3a76 315f 6861 7368  terface::v1_hash
    │ │ │ -00015b50: 2c0a 0909 6861 7368 5f68 616e 646c 6572  ,...hash_handler
    │ │ │ -00015b60: 293b 0a09 696f 2d26 6774 3b73 7562 6d69  );..io->submi
    │ │ │ -00015b70: 745f 6a6f 6273 2829 3b0a 0a09 7469 6d65  t_jobs();...time
    │ │ │ -00015b80: 5f70 6f69 6e74 2063 6f6e 7374 2065 6e64  _point const end
    │ │ │ -00015b90: 5f74 696d 6520 3d20 636c 6f63 6b5f 7479  _time = clock_ty
    │ │ │ -00015ba0: 7065 3a3a 6e6f 7728 2920 2b20 7365 636f  pe::now() + seco
    │ │ │ -00015bb0: 6e64 7328 3130 293b 0a09 7768 696c 6520  nds(10);..while 
    │ │ │ -00015bc0: 286f 7574 7374 616e 6469 6e67 2026 6774  (outstanding >
    │ │ │ -00015bd0: 3b20 3020 2661 6d70 3b26 616d 703b 2063  ; 0 && c
    │ │ │ -00015be0: 6c6f 636b 5f74 7970 653a 3a6e 6f77 2829  lock_type::now()
    │ │ │ -00015bf0: 2026 6c74 3b20 656e 645f 7469 6d65 290a   < end_time).
    │ │ │ -00015c00: 097b 0a09 0969 6f73 2e72 756e 5f6f 6e65  .{...ios.run_one
    │ │ │ -00015c10: 5f66 6f72 286d 696c 6c69 7365 636f 6e64  _for(millisecond
    │ │ │ -00015c20: 7328 3130 3029 293b 0a09 0969 6f73 2e72  s(100));...ios.r
    │ │ │ -00015c30: 6573 7461 7274 2829 3b0a 097d 0a0a 0954  estart();..}...T
    │ │ │ -00015c40: 4553 545f 4551 5541 4c28 6f75 7473 7461  EST_EQUAL(outsta
    │ │ │ -00015c50: 6e64 696e 672c 2030 293b 0a09 5445 5354  nding, 0);..TEST
    │ │ │ -00015c60: 5f45 5155 414c 2868 6173 6865 735f 646f  _EQUAL(hashes_do
    │ │ │ -00015c70: 6e65 2c20 3229 3b0a 0954 4553 545f 4348  ne, 2);..TEST_CH
    │ │ │ -00015c80: 4543 4b28 7265 6c65 6173 655f 646f 6e65  ECK(release_done
    │ │ │ -00015c90: 293b 0a0a 0969 6f2d 2667 743b 6162 6f72  );...io->abor
    │ │ │ -00015ca0: 7428 7472 7565 293b 0a7d 0a0a 3c64 6976  t(true);.}..
    templa │ │ │ -00015ce0: 7465 2026 6c74 3b74 7970 656e 616d 6520 te <typename │ │ │ -00015cf0: 5374 6f72 6167 6554 7970 6526 6774 3b0a StorageType>. │ │ │ -00015d00: 3c2f 6469 763e 766f 6964 2072 756e 5f74
    void run_t │ │ │ -00015d10: 6573 7428 290a 7b0a 0973 7464 3a3a 7374 est().{..std::st │ │ │ -00015d20: 7269 6e67 2063 6f6e 7374 2074 6573 745f ring const test_ │ │ │ -00015d30: 7061 7468 203d 2063 7572 7265 6e74 5f77 path = current_w │ │ │ -00015d40: 6f72 6b69 6e67 5f64 6972 6563 746f 7279 orking_directory │ │ │ -00015d50: 2829 3b0a 0973 7464 3a3a 636f 7574 2026 ();..std::cout & │ │ │ -00015d60: 6c74 3b26 6c74 3b20 225c 6e3d 3d3d 2022 lt;< "\n=== " │ │ │ -00015d70: 2026 6c74 3b26 6c74 3b20 7465 7374 5f70 << test_p │ │ │ -00015d80: 6174 6820 266c 743b 266c 743b 2022 203d ath << " = │ │ │ -00015d90: 3d3d 5c6e 2220 266c 743b 266c 743b 2073 ==\n" << s │ │ │ -00015da0: 7464 3a3a 656e 646c 3b0a 0a09 7374 643a td::endl;...std: │ │ │ -00015db0: 3a76 6563 746f 7226 6c74 3b63 6861 7226 :vector<char& │ │ │ -00015dc0: 6774 3b20 7069 6563 6530 203d 206e 6577 gt; piece0 = new │ │ │ -00015dd0: 5f70 6965 6365 2870 6965 6365 5f73 697a _piece(piece_siz │ │ │ -00015de0: 6529 3b0a 0973 7464 3a3a 7665 6374 6f72 e);..std::vector │ │ │ -00015df0: 266c 743b 6368 6172 2667 743b 2070 6965 <char> pie │ │ │ -00015e00: 6365 3120 3d20 6e65 775f 7069 6563 6528 ce1 = new_piece( │ │ │ -00015e10: 7069 6563 655f 7369 7a65 293b 0a09 7374 piece_size);..st │ │ │ -00015e20: 643a 3a76 6563 746f 7226 6c74 3b63 6861 d::vector<cha │ │ │ -00015e30: 7226 6774 3b20 7069 6563 6532 203d 206e r> piece2 = n │ │ │ -00015e40: 6577 5f70 6965 6365 2870 6965 6365 5f73 ew_piece(piece_s │ │ │ -00015e50: 697a 6529 3b0a 0973 7464 3a3a 7665 6374 ize);..std::vect │ │ │ -00015e60: 6f72 266c 743b 6368 6172 2667 743b 2070 or<char> p │ │ │ -00015e70: 6965 6365 3320 3d20 6e65 775f 7069 6563 iece3 = new_piec │ │ │ -00015e80: 6528 7069 6563 655f 7369 7a65 293b 0a0a e(piece_size);.. │ │ │ -00015e90: 0964 656c 6574 655f 6469 7273 2822 7465 .delete_dirs("te │ │ │ -00015ea0: 6d70 5f73 746f 7261 6765 2229 3b0a 0a09 mp_storage");... │ │ │ -00015eb0: 7374 643a 3a76 6563 746f 7226 6c74 3b6c std::vector<l │ │ │ -00015ec0: 743a 3a63 7265 6174 655f 6669 6c65 5f65 t::create_file_e │ │ │ -00015ed0: 6e74 7279 2667 743b 2066 733b 0a09 6673 ntry> fs;..fs │ │ │ -00015ee0: 2e65 6d70 6c61 6365 5f62 6163 6b28 2274 .emplace_back("t │ │ │ -00015ef0: 656d 705f 7374 6f72 6167 652f 7465 7374 emp_storage/test │ │ │ -00015f00: 312e 746d 7022 2c20 3137 293b 0a09 6673 1.tmp", 17);..fs │ │ │ -00015f10: 2e65 6d70 6c61 6365 5f62 6163 6b28 2274 .emplace_back("t │ │ │ -00015f20: 656d 705f 7374 6f72 6167 652f 7465 7374 emp_storage/test │ │ │ -00015f30: 322e 746d 7022 2c20 3631 3229 3b0a 0966 2.tmp", 612);..f │ │ │ -00015f40: 732e 656d 706c 6163 655f 6261 636b 2822 s.emplace_back(" │ │ │ -00015f50: 7465 6d70 5f73 746f 7261 6765 2f74 6573 temp_storage/tes │ │ │ -00015f60: 7433 2e74 6d70 222c 2030 293b 0a09 6673 t3.tmp", 0);..fs │ │ │ -00015f70: 2e65 6d70 6c61 6365 5f62 6163 6b28 2274 .emplace_back("t │ │ │ -00015f80: 656d 705f 7374 6f72 6167 652f 7465 7374 emp_storage/test │ │ │ -00015f90: 342e 746d 7022 2c20 3029 3b0a 0966 732e 4.tmp", 0);..fs. │ │ │ -00015fa0: 656d 706c 6163 655f 6261 636b 2822 7465 emplace_back("te │ │ │ -00015fb0: 6d70 5f73 746f 7261 6765 2f74 6573 7435 mp_storage/test5 │ │ │ -00015fc0: 2e74 6d70 222c 2033 3235 3329 3b0a 0966 .tmp", 3253);..f │ │ │ -00015fd0: 732e 656d 706c 6163 655f 6261 636b 2822 s.emplace_back(" │ │ │ -00015fe0: 7465 6d70 5f73 746f 7261 6765 2f74 6573 temp_storage/tes │ │ │ -00015ff0: 7436 2e74 6d70 222c 2038 3431 293b 0a09 t6.tmp", 841);.. │ │ │ -00016000: 696e 7420 636f 6e73 7420 6c61 7374 5f66 int const last_f │ │ │ -00016010: 696c 655f 7369 7a65 203d 2034 202a 2069 ile_size = 4 * i │ │ │ -00016020: 6e74 2870 6965 6365 5f73 697a 6529 202d nt(piece_size) - │ │ │ -00016030: 2028 3137 202b 2036 3132 202b 2033 3235 (17 + 612 + 325 │ │ │ -00016040: 3320 2b20 3834 3129 3b0a 0966 732e 656d 3 + 841);..fs.em │ │ │ -00016050: 706c 6163 655f 6261 636b 2822 7465 6d70 place_back("temp │ │ │ -00016060: 5f73 746f 7261 6765 2f74 6573 7437 2e74 _storage/test7.t │ │ │ -00016070: 6d70 222c 206c 6173 745f 6669 6c65 5f73 mp", last_file_s │ │ │ -00016080: 697a 6529 3b0a 0a09 2f2f 2046 696c 6520 ize);...// File │ │ │ -00016090: 6c61 796f 7574 0a09 2f2f 202b 2d2b 2d2d layout..// +-+-- │ │ │ -000160a0: 2b2b 2b2d 2d2d 2d2d 2d2d 2b2d 2d2d 2d2d +++-------+----- │ │ │ -000160b0: 2d2d 2b2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d --+------------- │ │ │ -000160c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000160d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000160e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000160f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00016100: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2b 0a09 2f2f -----------+..// │ │ │ -00016110: 207c 317c 2032 7c7c 7c20 6669 6c65 3520 |1| 2||| file5 │ │ │ -00016120: 7c20 6669 6c65 3620 7c20 6669 6c65 3720 | file6 | file7 │ │ │ -00016130: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016140: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016150: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016160: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016170: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016180: 207c 0a09 2f2f 202b 2d2b 2d2d 2b2b 2b2d |..// +-+--+++- │ │ │ -00016190: 2d2d 2d2d 2d2d 2b2d 2d2d 2d2d 2d2d 2b2d ------+-------+- │ │ │ -000161a0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000161b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000161c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000161d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000161e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -000161f0: 2d2d 2d2d 2d2d 2d2b 0a09 2f2f 207c 2020 -------+..// | │ │ │ -00016200: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016210: 2020 2020 2020 2020 207c 2020 2020 2020 | │ │ │ -00016220: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016230: 2020 2020 207c 2020 2020 2020 2020 2020 | │ │ │ -00016240: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -00016250: 207c 2020 2020 2020 2020 2020 2020 2020 | │ │ │ -00016260: 2020 2020 2020 2020 2020 2020 207c 0a09 |.. │ │ │ -00016270: 2f2f 207c 2070 6965 6365 2030 2020 2020 // | piece 0 │ │ │ -00016280: 2020 2020 2020 2020 2020 2020 2020 207c | │ │ │ -00016290: 2070 6965 6365 2031 2020 2020 2020 2020 piece 1 │ │ │ -000162a0: 2020 2020 2020 2020 2020 207c 2070 6965 | pie │ │ │ -000162b0: 6365 2032 2020 2020 2020 2020 2020 2020 ce 2 │ │ │ -000162c0: 2020 2020 2020 207c 2070 6965 6365 2033 | piece 3 │ │ │ -000162d0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -000162e0: 2020 207c 0a0a 096c 743a 3a63 7265 6174 |...lt::creat │ │ │ -000162f0: 655f 746f 7272 656e 7420 7428 7374 643a e_torrent t(std: │ │ │ -00016300: 3a6d 6f76 6528 6673 292c 2070 6965 6365 :move(fs), piece │ │ │ -00016310: 5f73 697a 652c 2063 7265 6174 655f 746f _size, create_to │ │ │ -00016320: 7272 656e 743a 3a76 315f 6f6e 6c79 293b rrent::v1_only); │ │ │ -00016330: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00016370: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../te │ │ │ -000163a0: 7374 2f74 6573 745f 7069 6563 655f 7069 st/test_piece_pi │ │ │ -000163b0: 636b 6572 2e63 7070 3a33 3037 353c 2f61 cker.cpp:3075test p │ │ │ -000163d0: 6963 6b69 6e67 2077 6974 6820 7061 7274 icking with part │ │ │ -000163e0: 6961 6c20 7069 6563 6573 2061 6e64 206f ial pieces and o │ │ │ -000163f0: 7468 6572 2070 6565 7273 2070 7265 7365 ther peers prese │ │ │ -00016400: 6e74 2073 6f20 7468 6174 2062 6f74 6820 nt so that both │ │ │ -00016410: 6261 636b 7570 5f70 6965 6365 7320 616e backup_pieces an │ │ │ -00016420: 6420 6261 636b 7570 5f70 6965 6365 7332 d backup_pieces2 │ │ │ -00016430: 2061 7265 2075 7365 643c 2f74 643e 3c2f are used

    test picki │ │ │ -00016490: 6e67 2077 6974 6820 7061 7274 6961 6c20 ng with partial │ │ │ -000164a0: 7069 6563 6573 2061 6e64 206f 7468 6572 pieces and other │ │ │ -000164b0: 2070 6565 7273 2070 7265 7365 6e74 2073 peers present s │ │ │ -000164c0: 6f20 7468 6174 2062 6f74 680a 6261 636b o that both.back │ │ │ -000164d0: 7570 5f70 6965 6365 7320 616e 6420 6261 up_pieces and ba │ │ │ -000164e0: 636b 7570 5f70 6965 6365 7332 2061 7265 ckup_pieces2 are │ │ │ -000164f0: 2075 7365 643c 2f68 323e 3c68 343e 2e2e used

    .. │ │ │ -00016500: 2f74 6573 742f 7465 7374 5f70 6965 6365 /test/test_piece │ │ │ -00016510: 5f70 6963 6b65 722e 6370 703a 3330 3735 _picker.cpp:3075 │ │ │ -00016520: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +00014870: 2f74 6573 742f 7465 7374 5f73 746f 7261  /test/test_stora
    │ │ │ +00014880: 6765 2e63 7070 3a38 3234 3c2f 613e 3c2f  ge.cpp:824split thi
    │ │ │ +000148a0: 7320 7465 7374 2075 7020 696e 746f 2073  s test up into s
    │ │ │ +000148b0: 6d61 6c6c 6572 2070 6172 7473 3c2f 7464  maller parts

    split t │ │ │ +00014910: 6869 7320 7465 7374 2075 7020 696e 746f his test up into │ │ │ +00014920: 2073 6d61 6c6c 6572 2070 6172 7473 3c2f smaller parts

    ../test/t │ │ │ +00014940: 6573 745f 7374 6f72 6167 652e 6370 703a est_storage.cpp: │ │ │ +00014950: 3832 343c 2f68 343e 3c70 7265 2073 7479 824

    ..0_piece,...{
    │ │ │ +000149a0: 7d2c 0a09 0964 6973 6b5f 696e 7465 7266  },...disk_interf
    │ │ │ +000149b0: 6163 653a 3a73 6571 7565 6e74 6961 6c5f  ace::sequential_
    │ │ │ +000149c0: 6163 6365 7373 207c 2064 6973 6b5f 696e  access | disk_in
    │ │ │ +000149d0: 7465 7266 6163 653a 3a76 6f6c 6174 696c  terface::volatil
    │ │ │ +000149e0: 655f 7265 6164 207c 2064 6973 6b5f 696e  e_read | disk_in
    │ │ │ +000149f0: 7465 7266 6163 653a 3a76 315f 6861 7368  terface::v1_hash
    │ │ │ +00014a00: 2c0a 0909 6861 7368 5f68 616e 646c 6572  ,...hash_handler
    │ │ │ +00014a10: 293b 0a09 696f 2d26 6774 3b73 7562 6d69  );..io->submi
    │ │ │ +00014a20: 745f 6a6f 6273 2829 3b0a 0a09 7469 6d65  t_jobs();...time
    │ │ │ +00014a30: 5f70 6f69 6e74 2063 6f6e 7374 2065 6e64  _point const end
    │ │ │ +00014a40: 5f74 696d 6520 3d20 636c 6f63 6b5f 7479  _time = clock_ty
    │ │ │ +00014a50: 7065 3a3a 6e6f 7728 2920 2b20 7365 636f  pe::now() + seco
    │ │ │ +00014a60: 6e64 7328 3130 293b 0a09 7768 696c 6520  nds(10);..while 
    │ │ │ +00014a70: 286f 7574 7374 616e 6469 6e67 2026 6774  (outstanding >
    │ │ │ +00014a80: 3b20 3020 2661 6d70 3b26 616d 703b 2063  ; 0 && c
    │ │ │ +00014a90: 6c6f 636b 5f74 7970 653a 3a6e 6f77 2829  lock_type::now()
    │ │ │ +00014aa0: 2026 6c74 3b20 656e 645f 7469 6d65 290a   < end_time).
    │ │ │ +00014ab0: 097b 0a09 0969 6f73 2e72 756e 5f6f 6e65  .{...ios.run_one
    │ │ │ +00014ac0: 5f66 6f72 286d 696c 6c69 7365 636f 6e64  _for(millisecond
    │ │ │ +00014ad0: 7328 3130 3029 293b 0a09 0969 6f73 2e72  s(100));...ios.r
    │ │ │ +00014ae0: 6573 7461 7274 2829 3b0a 097d 0a0a 0954  estart();..}...T
    │ │ │ +00014af0: 4553 545f 4551 5541 4c28 6f75 7473 7461  EST_EQUAL(outsta
    │ │ │ +00014b00: 6e64 696e 672c 2030 293b 0a09 5445 5354  nding, 0);..TEST
    │ │ │ +00014b10: 5f45 5155 414c 2868 6173 6865 735f 646f  _EQUAL(hashes_do
    │ │ │ +00014b20: 6e65 2c20 3229 3b0a 0954 4553 545f 4348  ne, 2);..TEST_CH
    │ │ │ +00014b30: 4543 4b28 7265 6c65 6173 655f 646f 6e65  ECK(release_done
    │ │ │ +00014b40: 293b 0a0a 0969 6f2d 2667 743b 6162 6f72  );...io->abor
    │ │ │ +00014b50: 7428 7472 7565 293b 0a7d 0a0a 3c64 6976  t(true);.}..
    templa │ │ │ +00014b90: 7465 2026 6c74 3b74 7970 656e 616d 6520 te <typename │ │ │ +00014ba0: 5374 6f72 6167 6554 7970 6526 6774 3b0a StorageType>. │ │ │ +00014bb0: 3c2f 6469 763e 766f 6964 2072 756e 5f74
    void run_t │ │ │ +00014bc0: 6573 7428 290a 7b0a 0973 7464 3a3a 7374 est().{..std::st │ │ │ +00014bd0: 7269 6e67 2063 6f6e 7374 2074 6573 745f ring const test_ │ │ │ +00014be0: 7061 7468 203d 2063 7572 7265 6e74 5f77 path = current_w │ │ │ +00014bf0: 6f72 6b69 6e67 5f64 6972 6563 746f 7279 orking_directory │ │ │ +00014c00: 2829 3b0a 0973 7464 3a3a 636f 7574 2026 ();..std::cout & │ │ │ +00014c10: 6c74 3b26 6c74 3b20 225c 6e3d 3d3d 2022 lt;< "\n=== " │ │ │ +00014c20: 2026 6c74 3b26 6c74 3b20 7465 7374 5f70 << test_p │ │ │ +00014c30: 6174 6820 266c 743b 266c 743b 2022 203d ath << " = │ │ │ +00014c40: 3d3d 5c6e 2220 266c 743b 266c 743b 2073 ==\n" << s │ │ │ +00014c50: 7464 3a3a 656e 646c 3b0a 0a09 7374 643a td::endl;...std: │ │ │ +00014c60: 3a76 6563 746f 7226 6c74 3b63 6861 7226 :vector<char& │ │ │ +00014c70: 6774 3b20 7069 6563 6530 203d 206e 6577 gt; piece0 = new │ │ │ +00014c80: 5f70 6965 6365 2870 6965 6365 5f73 697a _piece(piece_siz │ │ │ +00014c90: 6529 3b0a 0973 7464 3a3a 7665 6374 6f72 e);..std::vector │ │ │ +00014ca0: 266c 743b 6368 6172 2667 743b 2070 6965 <char> pie │ │ │ +00014cb0: 6365 3120 3d20 6e65 775f 7069 6563 6528 ce1 = new_piece( │ │ │ +00014cc0: 7069 6563 655f 7369 7a65 293b 0a09 7374 piece_size);..st │ │ │ +00014cd0: 643a 3a76 6563 746f 7226 6c74 3b63 6861 d::vector<cha │ │ │ +00014ce0: 7226 6774 3b20 7069 6563 6532 203d 206e r> piece2 = n │ │ │ +00014cf0: 6577 5f70 6965 6365 2870 6965 6365 5f73 ew_piece(piece_s │ │ │ +00014d00: 697a 6529 3b0a 0973 7464 3a3a 7665 6374 ize);..std::vect │ │ │ +00014d10: 6f72 266c 743b 6368 6172 2667 743b 2070 or<char> p │ │ │ +00014d20: 6965 6365 3320 3d20 6e65 775f 7069 6563 iece3 = new_piec │ │ │ +00014d30: 6528 7069 6563 655f 7369 7a65 293b 0a0a e(piece_size);.. │ │ │ +00014d40: 0964 656c 6574 655f 6469 7273 2822 7465 .delete_dirs("te │ │ │ +00014d50: 6d70 5f73 746f 7261 6765 2229 3b0a 0a09 mp_storage");... │ │ │ +00014d60: 7374 643a 3a76 6563 746f 7226 6c74 3b6c std::vector<l │ │ │ +00014d70: 743a 3a63 7265 6174 655f 6669 6c65 5f65 t::create_file_e │ │ │ +00014d80: 6e74 7279 2667 743b 2066 733b 0a09 6673 ntry> fs;..fs │ │ │ +00014d90: 2e65 6d70 6c61 6365 5f62 6163 6b28 2274 .emplace_back("t │ │ │ +00014da0: 656d 705f 7374 6f72 6167 652f 7465 7374 emp_storage/test │ │ │ +00014db0: 312e 746d 7022 2c20 3137 293b 0a09 6673 1.tmp", 17);..fs │ │ │ +00014dc0: 2e65 6d70 6c61 6365 5f62 6163 6b28 2274 .emplace_back("t │ │ │ +00014dd0: 656d 705f 7374 6f72 6167 652f 7465 7374 emp_storage/test │ │ │ +00014de0: 322e 746d 7022 2c20 3631 3229 3b0a 0966 2.tmp", 612);..f │ │ │ +00014df0: 732e 656d 706c 6163 655f 6261 636b 2822 s.emplace_back(" │ │ │ +00014e00: 7465 6d70 5f73 746f 7261 6765 2f74 6573 temp_storage/tes │ │ │ +00014e10: 7433 2e74 6d70 222c 2030 293b 0a09 6673 t3.tmp", 0);..fs │ │ │ +00014e20: 2e65 6d70 6c61 6365 5f62 6163 6b28 2274 .emplace_back("t │ │ │ +00014e30: 656d 705f 7374 6f72 6167 652f 7465 7374 emp_storage/test │ │ │ +00014e40: 342e 746d 7022 2c20 3029 3b0a 0966 732e 4.tmp", 0);..fs. │ │ │ +00014e50: 656d 706c 6163 655f 6261 636b 2822 7465 emplace_back("te │ │ │ +00014e60: 6d70 5f73 746f 7261 6765 2f74 6573 7435 mp_storage/test5 │ │ │ +00014e70: 2e74 6d70 222c 2033 3235 3329 3b0a 0966 .tmp", 3253);..f │ │ │ +00014e80: 732e 656d 706c 6163 655f 6261 636b 2822 s.emplace_back(" │ │ │ +00014e90: 7465 6d70 5f73 746f 7261 6765 2f74 6573 temp_storage/tes │ │ │ +00014ea0: 7436 2e74 6d70 222c 2038 3431 293b 0a09 t6.tmp", 841);.. │ │ │ +00014eb0: 696e 7420 636f 6e73 7420 6c61 7374 5f66 int const last_f │ │ │ +00014ec0: 696c 655f 7369 7a65 203d 2034 202a 2069 ile_size = 4 * i │ │ │ +00014ed0: 6e74 2870 6965 6365 5f73 697a 6529 202d nt(piece_size) - │ │ │ +00014ee0: 2028 3137 202b 2036 3132 202b 2033 3235 (17 + 612 + 325 │ │ │ +00014ef0: 3320 2b20 3834 3129 3b0a 0966 732e 656d 3 + 841);..fs.em │ │ │ +00014f00: 706c 6163 655f 6261 636b 2822 7465 6d70 place_back("temp │ │ │ +00014f10: 5f73 746f 7261 6765 2f74 6573 7437 2e74 _storage/test7.t │ │ │ +00014f20: 6d70 222c 206c 6173 745f 6669 6c65 5f73 mp", last_file_s │ │ │ +00014f30: 697a 6529 3b0a 0a09 2f2f 2046 696c 6520 ize);...// File │ │ │ +00014f40: 6c61 796f 7574 0a09 2f2f 202b 2d2b 2d2d layout..// +-+-- │ │ │ +00014f50: 2b2b 2b2d 2d2d 2d2d 2d2d 2b2d 2d2d 2d2d +++-------+----- │ │ │ +00014f60: 2d2d 2b2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d --+------------- │ │ │ +00014f70: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00014f80: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00014f90: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00014fa0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00014fb0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2b 0a09 2f2f -----------+..// │ │ │ +00014fc0: 207c 317c 2032 7c7c 7c20 6669 6c65 3520 |1| 2||| file5 │ │ │ +00014fd0: 7c20 6669 6c65 3620 7c20 6669 6c65 3720 | file6 | file7 │ │ │ +00014fe0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +00014ff0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +00015000: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +00015010: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +00015020: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +00015030: 207c 0a09 2f2f 202b 2d2b 2d2d 2b2b 2b2d |..// +-+--+++- │ │ │ +00015040: 2d2d 2d2d 2d2d 2b2d 2d2d 2d2d 2d2d 2b2d ------+-------+- │ │ │ +00015050: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00015060: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00015070: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00015080: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00015090: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000150a0: 2d2d 2d2d 2d2d 2d2b 0a09 2f2f 207c 2020 -------+..// | │ │ │ +000150b0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +000150c0: 2020 2020 2020 2020 207c 2020 2020 2020 | │ │ │ +000150d0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +000150e0: 2020 2020 207c 2020 2020 2020 2020 2020 | │ │ │ +000150f0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +00015100: 207c 2020 2020 2020 2020 2020 2020 2020 | │ │ │ +00015110: 2020 2020 2020 2020 2020 2020 207c 0a09 |.. │ │ │ +00015120: 2f2f 207c 2070 6965 6365 2030 2020 2020 // | piece 0 │ │ │ +00015130: 2020 2020 2020 2020 2020 2020 2020 207c | │ │ │ +00015140: 2070 6965 6365 2031 2020 2020 2020 2020 piece 1 │ │ │ +00015150: 2020 2020 2020 2020 2020 207c 2070 6965 | pie │ │ │ +00015160: 6365 2032 2020 2020 2020 2020 2020 2020 ce 2 │ │ │ +00015170: 2020 2020 2020 207c 2070 6965 6365 2033 | piece 3 │ │ │ +00015180: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ +00015190: 2020 207c 0a0a 096c 743a 3a63 7265 6174 |...lt::creat │ │ │ +000151a0: 655f 746f 7272 656e 7420 7428 7374 643a e_torrent t(std: │ │ │ +000151b0: 3a6d 6f76 6528 6673 292c 2070 6965 6365 :move(fs), piece │ │ │ +000151c0: 5f73 697a 652c 2063 7265 6174 655f 746f _size, create_to │ │ │ +000151d0: 7272 656e 743a 3a76 315f 6f6e 6c79 293b rrent::v1_only); │ │ │ +000151e0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +00015220: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../te │ │ │ +00015250: 7374 2f74 6573 745f 7069 6563 655f 7069 st/test_piece_pi │ │ │ +00015260: 636b 6572 2e63 7070 3a33 3037 353c 2f61 cker.cpp:3075test p │ │ │ +00015280: 6963 6b69 6e67 2077 6974 6820 7061 7274 icking with part │ │ │ +00015290: 6961 6c20 7069 6563 6573 2061 6e64 206f ial pieces and o │ │ │ +000152a0: 7468 6572 2070 6565 7273 2070 7265 7365 ther peers prese │ │ │ +000152b0: 6e74 2073 6f20 7468 6174 2062 6f74 6820 nt so that both │ │ │ +000152c0: 6261 636b 7570 5f70 6965 6365 7320 616e backup_pieces an │ │ │ +000152d0: 6420 6261 636b 7570 5f70 6965 6365 7332 d backup_pieces2 │ │ │ +000152e0: 2061 7265 2075 7365 643c 2f74 643e 3c2f are used

    test picki │ │ │ +00015340: 6e67 2077 6974 6820 7061 7274 6961 6c20 ng with partial │ │ │ +00015350: 7069 6563 6573 2061 6e64 206f 7468 6572 pieces and other │ │ │ +00015360: 2070 6565 7273 2070 7265 7365 6e74 2073 peers present s │ │ │ +00015370: 6f20 7468 6174 2062 6f74 680a 6261 636b o that both.back │ │ │ +00015380: 7570 5f70 6965 6365 7320 616e 6420 6261 up_pieces and ba │ │ │ +00015390: 636b 7570 5f70 6965 6365 7332 2061 7265 ckup_pieces2 are │ │ │ +000153a0: 2075 7365 643c 2f68 323e 3c68 343e 2e2e used

    .. │ │ │ +000153b0: 2f74 6573 742f 7465 7374 5f70 6965 6365 /test/test_piece │ │ │ +000153c0: 5f70 6963 6b65 722e 6370 703a 3330 3735 _picker.cpp:3075 │ │ │ +000153d0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +00015410: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +00015420: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +00015430: 6f75 6e64 3a20 2363 6663 223e 3c74 643e  ound: #cfc">
    │ │ │ +00015440: 7265 6c65 7661 6e63 6526 6e62 7370 3b32  relevance 2
    │ │ │ +00015450: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../test
    │ │ │ +00015480: 2f74 6573 745f 6468 742e 6370 703a 3136  /test_dht.cpp:16
    │ │ │ +00015490: 3337 3c2f 613e 3c2f 7464 3e3c 7464 3e74  37t
    │ │ │ +000154a0: 6573 7420 6e75 6d5f 676c 6f62 616c 5f6e  est num_global_n
    │ │ │ +000154b0: 6f64 6573 3c2f 7464 3e3c 2f74 723e 3c74  odes

    test num_global │ │ │ +00015510: 5f6e 6f64 6573 3c2f 6832 3e3c 6834 3e2e _nodes

    . │ │ │ +00015520: 2e2f 7465 7374 2f74 6573 745f 6468 742e ./test/test_dht. │ │ │ +00015530: 6370 703a 3136 3337 3c2f 6834 3e3c 7072 cpp:1637

    relevanc │ │ │ +000155b0: 6526 6e62 7370 3b32 3c2f 7464 3e3c 7464 e 2../test/test_dh │ │ │ +000155f0: 742e 6370 703a 3136 3338 3c2f 613e 3c2f t.cpp:1638test need │ │ │ +00015610: 5f72 6566 7265 7368 3c2f 7464 3e3c 2f74 _refresh

    test need_r │ │ │ +00015670: 6566 7265 7368 3c2f 6832 3e3c 6834 3e2e efresh

    . │ │ │ +00015680: 2e2f 7465 7374 2f74 6573 745f 6468 742e ./test/test_dht. │ │ │ +00015690: 6370 703a 3136 3338 3c2f 6834 3e3c 7072 cpp:1638

    ..s.set_b │ │ │ +000156e0: 6f6f 6c28 7365 7474 696e 6773 5f70 6163 ool(settings_pac │ │ │ +000156f0: 6b3a 3a64 6874 5f72 6573 7472 6963 745f k::dht_restrict_ │ │ │ +00015700: 726f 7574 696e 675f 6970 732c 2066 616c routing_ips, fal │ │ │ +00015710: 7365 293b 0a0a 097b 0a09 0961 7574 6f20 se);...{...auto │ │ │ +00015720: 636f 6e73 7420 6570 203d 2072 616e 645f const ep = rand_ │ │ │ +00015730: 7564 705f 6570 2872 616e 645f 6164 6472 udp_ep(rand_addr │ │ │ +00015740: 293b 0a09 0961 7574 6f20 636f 6e73 7420 );...auto const │ │ │ +00015750: 6964 203d 2067 656e 6572 6174 655f 6964 id = generate_id │ │ │ +00015760: 5f69 6d70 6c28 6570 2e61 6464 7265 7373 _impl(ep.address │ │ │ +00015770: 2829 2c20 3229 3b0a 0909 7461 626c 652e (), 2);...table. │ │ │ +00015780: 6e6f 6465 5f73 6565 6e28 6964 2c20 6570 node_seen(id, ep │ │ │ +00015790: 2c20 3130 293b 0a09 7d0a 0a09 6e6f 6465 , 10);..}...node │ │ │ +000157a0: 732e 636c 6561 7228 293b 0a09 666f 7220 s.clear();..for │ │ │ +000157b0: 2869 6e74 2069 203d 2030 3b20 6920 266c (int i = 0; i &l │ │ │ +000157c0: 743b 2031 3030 3030 3b20 2b2b 6929 0a09 t; 10000; ++i).. │ │ │ +000157d0: 7b0a 0909 6175 746f 2063 6f6e 7374 2065 {...auto const e │ │ │ +000157e0: 7020 3d20 7261 6e64 5f75 6470 5f65 7028 p = rand_udp_ep( │ │ │ +000157f0: 7261 6e64 5f61 6464 7229 3b0a 0909 6175 rand_addr);...au │ │ │ +00015800: 746f 2063 6f6e 7374 2069 6420 3d20 6765 to const id = ge │ │ │ +00015810: 6e65 7261 7465 5f69 645f 696d 706c 2865 nerate_id_impl(e │ │ │ +00015820: 702e 6164 6472 6573 7328 292c 2036 293b p.address(), 6); │ │ │ +00015830: 0a09 0974 6162 6c65 2e6e 6f64 655f 7365 ...table.node_se │ │ │ +00015840: 656e 2869 642c 2065 702c 2032 3020 2b20 en(id, ep, 20 + │ │ │ +00015850: 2869 645b 3139 5d20 2661 6d70 3b20 3078 (id[19] & 0x │ │ │ +00015860: 6666 2929 3b0a 097d 0a09 7374 643a 3a70 ff));..}..std::p │ │ │ +00015870: 7269 6e74 6628 2261 6374 6976 6520 6275 rintf("active bu │ │ │ +00015880: 636b 6574 733a 2025 645c 6e22 2c20 7461 ckets: %d\n", ta │ │ │ +00015890: 626c 652e 6e75 6d5f 6163 7469 7665 5f62 ble.num_active_b │ │ │ +000158a0: 7563 6b65 7473 2829 293b 0a09 5445 5354 uckets());..TEST │ │ │ +000158b0: 5f43 4845 434b 2874 6162 6c65 2e6e 756d _CHECK(table.num │ │ │ +000158c0: 5f61 6374 6976 655f 6275 636b 6574 7328 _active_buckets( │ │ │ +000158d0: 2920 3d3d 2031 310a 0909 7c7c 2074 6162 ) == 11...|| tab │ │ │ +000158e0: 6c65 2e6e 756d 5f61 6374 6976 655f 6275 le.num_active_bu │ │ │ +000158f0: 636b 6574 7328 2920 3d3d 2031 3229 3b0a ckets() == 12);. │ │ │ +00015900: 0954 4553 545f 4348 4543 4b28 7374 643a .TEST_CHECK(std: │ │ │ +00015910: 3a67 6574 266c 743b 3026 6774 3b28 7461 :get<0>(ta │ │ │ +00015920: 626c 652e 7369 7a65 2829 2920 2667 743b ble.size()) > │ │ │ +00015930: 3d20 6275 636b 6574 5f73 697a 6520 2a20 = bucket_size * │ │ │ +00015940: 3130 293b 0a3c 6469 7620 7374 796c 653d 10);.
    .
    .print │ │ │ +00015980: 5f73 7461 7465 2873 7464 3a3a 636f 7574 _state(std::cout │ │ │ +00015990: 2c20 7461 626c 6529 3b0a 0a09 7461 626c , table);...tabl │ │ │ +000159a0: 652e 666f 725f 6561 6368 5f6e 6f64 6528 e.for_each_node( │ │ │ +000159b0: 7374 643a 3a62 696e 6428 6e6f 6465 5f70 std::bind(node_p │ │ │ +000159c0: 7573 685f 6261 636b 2c20 2661 6d70 3b6e ush_back, &n │ │ │ +000159d0: 6f64 6573 2c20 5f31 292c 206e 756c 6c70 odes, _1), nullp │ │ │ +000159e0: 7472 293b 0a0a 0973 7464 3a3a 7072 696e tr);...std::prin │ │ │ +000159f0: 7466 2822 6e6f 6465 733a 2025 645c 6e22 tf("nodes: %d\n" │ │ │ +00015a00: 2c20 696e 7428 6e6f 6465 732e 7369 7a65 , int(nodes.size │ │ │ +00015a10: 2829 2929 3b0a 0a0a 097b 0a09 096e 6f64 ()));....{...nod │ │ │ +00015a20: 655f 6964 2063 6f6e 7374 2069 6420 3d20 e_id const id = │ │ │ +00015a30: 6765 6e65 7261 7465 5f72 616e 646f 6d5f generate_random_ │ │ │ +00015a40: 6964 2829 3b0a 0909 7374 643a 3a76 6563 id();...std::vec │ │ │ +00015a50: 746f 7226 6c74 3b6e 6f64 655f 656e 7472 tor<node_entr │ │ │ +00015a60: 7926 6774 3b20 7465 6d70 203d 2074 6162 y> temp = tab │ │ │ +00015a70: 6c65 2e66 696e 645f 6e6f 6465 2869 642c le.find_node(id, │ │ │ +00015a80: 207b 7d2c 2069 6e74 286e 6f64 6573 2e73 {}, int(nodes.s │ │ │ +00015a90: 697a 6528 2929 202a 2032 293b 0a09 0973 ize()) * 2);...s │ │ │ +00015aa0: 7464 3a3a 7072 696e 7466 2822 7265 7475 td::printf("retu │ │ │ +00015ab0: 726e 6564 2d61 6c6c 3a20 2564 5c6e 222c rned-all: %d\n", │ │ │ +00015ac0: 2069 6e74 2874 656d 702e 7369 7a65 2829 int(temp.size() │ │ │ +00015ad0: 2929 3b0a 0909 5445 5354 5f45 5155 414c ));...TEST_EQUAL │ │ │ +00015ae0: 2874 656d 702e 7369 7a65 2829 2c20 6e6f (temp.size(), no │ │ │ +00015af0: 6465 732e 7369 7a65 2829 293b 0a09 7d0a des.size());..}. │ │ │ +00015b00: 0a09 2f2f 2054 6869 7320 6d61 6b65 7320 ..// This makes │ │ │ +00015b10: 7375 7265 2065 6e6f 7567 6820 6f66 2074 sure enough of t │ │ │ +00015b20: 6865 206e 6f64 6573 2072 6574 7572 6e65 he nodes returne │ │ │ +00015b30: 6420 6172 6520 6163 7475 616c 6c79 0a09 d are actually.. │ │ │ +00015b40: 2f2f 2070 6172 7420 6f66 2074 6865 2063 // part of the c │ │ │ +00015b50: 6c6f 7365 7374 206e 6f64 6573 0a09 7374 losest nodes..st │ │ │ +00015b60: 643a 3a73 6574 266c 743b 6e6f 6465 5f69 d::set<node_i │ │ │ +00015b70: 6426 6774 3b20 6475 706c 6963 6174 6573 d> duplicates │ │ │ +00015b80: 3b0a 0a09 636f 6e73 7420 696e 7420 7265 ;...const int re │ │ │ +00015b90: 7073 203d 2035 303b 0a0a 0966 6f72 2028 ps = 50;...for ( │ │ │ +00015ba0: 696e 7420 7220 3d20 303b 2072 2026 6c74 int r = 0; r < │ │ │ +00015bb0: 3b20 7265 7073 3b20 2b2b 7229 0a09 7b0a ; reps; ++r)..{. │ │ │ +00015bc0: 0909 6e6f 6465 5f69 6420 636f 6e73 7420 ..node_id const │ │ │ +00015bd0: 6964 203d 2067 656e 6572 6174 655f 7261 id = generate_ra │ │ │ +00015be0: 6e64 6f6d 5f69 6428 293b 0a09 0973 7464 ndom_id();...std │ │ │ +00015bf0: 3a3a 7665 6374 6f72 266c 743b 6e6f 6465 ::vector<node │ │ │ +00015c00: 5f65 6e74 7279 2667 743b 2074 656d 7020 _entry> temp │ │ │ +00015c10: 3d20 7461 626c 652e 6669 6e64 5f6e 6f64 = table.find_nod │ │ │ +00015c20: 6528 6964 2c20 7b7d 2c20 6275 636b 6574 e(id, {}, bucket │ │ │ +00015c30: 5f73 697a 6520 2a20 3229 3b0a 0909 5445 _size * 2);...TE │ │ │ +00015c40: 5354 5f45 5155 414c 2869 6e74 2874 656d ST_EQUAL(int(tem │ │ │ +00015c50: 702e 7369 7a65 2829 292c 2073 7464 3a3a p.size()), std:: │ │ │ +00015c60: 6d69 6e28 6275 636b 6574 5f73 697a 6520 min(bucket_size │ │ │ +00015c70: 2a20 322c 2069 6e74 286e 6f64 6573 2e73 * 2, int(nodes.s │ │ │ +00015c80: 697a 6528 2929 2929 3b0a 0a09 0973 7464 ize())));....std │ │ │ +00015c90: 3a3a 736f 7274 286e 6f64 6573 2e62 6567 ::sort(nodes.beg │ │ │ +00015ca0: 696e 2829 2c20 6e6f 6465 732e 656e 6428 in(), nodes.end( │ │ │ +00015cb0: 292c 2073 7464 3a3a 6269 6e64 2826 616d ), std::bind(&am │ │ │ +00015cc0: 703b 636f 6d70 6172 655f 7265 660a 0909 p;compare_ref... │ │ │ +00015cd0: 0909 2c20 7374 643a 3a62 696e 6428 2661 .., std::bind(&a │ │ │ +00015ce0: 6d70 3b6e 6f64 655f 656e 7472 793a 3a69 mp;node_entry::i │ │ │ +00015cf0: 642c 205f 3129 0a09 0909 092c 2073 7464 d, _1)....., std │ │ │ +00015d00: 3a3a 6269 6e64 2826 616d 703b 6e6f 6465 ::bind(&node │ │ │ +00015d10: 5f65 6e74 7279 3a3a 6964 2c20 5f32 292c _entry::id, _2), │ │ │ +00015d20: 2069 6429 293b 0a0a 3c2f 7072 653e 3c2f id));..
    relevan │ │ │ +00015d60: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2../test/test_d │ │ │ +00015da0: 6874 2e63 7070 3a32 3832 333c 2f61 3e3c ht.cpp:2823< │ │ │ +00015db0: 2f74 643e 3c74 643e 7370 6c69 7420 7468 /td>split th │ │ │ +00015dc0: 6973 2075 7020 696e 746f 2073 6d61 6c6c is up into small │ │ │ +00015dd0: 6572 2074 6573 7420 6361 7365 733c 2f74 er test cases

    split │ │ │ +00015e30: 7468 6973 2075 7020 696e 746f 2073 6d61 this up into sma │ │ │ +00015e40: 6c6c 6572 2074 6573 7420 6361 7365 733c ller test cases< │ │ │ +00015e50: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +00015e60: 7465 7374 5f64 6874 2e63 7070 3a32 3832 test_dht.cpp:282 │ │ │ +00015e70: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ +00015eb0: 0a09 5445 5354 5f45 5155 414c 2861 7578  ..TEST_EQUAL(aux
    │ │ │ +00015ec0: 3a3a 746f 5f68 6578 2873 6967 2e62 7974  ::to_hex(sig.byt
    │ │ │ +00015ed0: 6573 290a 0909 2c20 2236 3833 3432 3834  es)..., "6834284
    │ │ │ +00015ee0: 6236 6232 3463 3332 3034 6562 3266 6561  b6b24c3204eb2fea
    │ │ │ +00015ef0: 3832 3464 3832 6638 3838 3833 6133 6439  824d82f88883a3d9
    │ │ │ +00015f00: 3565 3862 3461 3231 6238 6330 6465 6435  5e8b4a21b8c0ded5
    │ │ │ +00015f10: 3533 6431 3764 3137 6422 0a09 0922 6466  53d17d17d"..."df
    │ │ │ +00015f20: 3961 3861 3731 3034 6231 3235 3866 3330  9a8a7104b1258f30
    │ │ │ +00015f30: 6265 6433 3738 3765 3663 6238 3936 6663  bed3787e6cb896fc
    │ │ │ +00015f40: 6137 3863 3538 6638 6530 3362 3566 3138  a78c58f8e03b5f18
    │ │ │ +00015f50: 6631 3439 3531 6138 3764 3961 3038 2229  f14951a87d9a08")
    │ │ │ +00015f60: 3b0a 0a09 7368 6131 5f68 6173 6820 7461  ;...sha1_hash ta
    │ │ │ +00015f70: 7267 6574 5f69 6420 3d20 6974 656d 5f74  rget_id = item_t
    │ │ │ +00015f80: 6172 6765 745f 6964 2874 6573 745f 7361  arget_id(test_sa
    │ │ │ +00015f90: 6c74 2c20 706b 293b 0a09 5445 5354 5f45  lt, pk);..TEST_E
    │ │ │ +00015fa0: 5155 414c 2861 7578 3a3a 746f 5f68 6578  QUAL(aux::to_hex
    │ │ │ +00015fb0: 2874 6172 6765 745f 6964 292c 2022 3431  (target_id), "41
    │ │ │ +00015fc0: 3165 6261 3733 6236 6630 3837 6361 3531  1eba73b6f087ca51
    │ │ │ +00015fd0: 6133 3739 3564 3963 3863 3933 3864 3336  a3795d9c8c938d36
    │ │ │ +00015fe0: 3565 3332 6331 2229 3b0a 7d0a 0a54 4f52  5e32c1");.}..TOR
    │ │ │ +00015ff0: 5245 4e54 5f54 4553 5428 7369 676e 696e  RENT_TEST(signin
    │ │ │ +00016000: 675f 7465 7374 3329 0a7b 0a09 2f2f 2074  g_test3).{..// t
    │ │ │ +00016010: 6573 7420 7665 6374 6f72 2033 0a0a 092f  est vector 3.../
    │ │ │ +00016020: 2f20 7465 7374 2063 6f6e 7465 6e74 0a09  / test content..
    │ │ │ +00016030: 7370 616e 266c 743b 6368 6172 2063 6f6e  span<char con
    │ │ │ +00016040: 7374 2667 743b 2074 6573 745f 636f 6e74  st> test_cont
    │ │ │ +00016050: 656e 7428 2231 323a 4865 6c6c 6f20 576f  ent("12:Hello Wo
    │ │ │ +00016060: 726c 6421 222c 2031 3529 3b0a 0a09 7368  rld!", 15);...sh
    │ │ │ +00016070: 6131 5f68 6173 6820 7461 7267 6574 5f69  a1_hash target_i
    │ │ │ +00016080: 6420 3d20 6974 656d 5f74 6172 6765 745f  d = item_target_
    │ │ │ +00016090: 6964 2874 6573 745f 636f 6e74 656e 7429  id(test_content)
    │ │ │ +000160a0: 3b0a 0954 4553 545f 4551 5541 4c28 6175  ;..TEST_EQUAL(au
    │ │ │ +000160b0: 783a 3a74 6f5f 6865 7828 7461 7267 6574  x::to_hex(target
    │ │ │ +000160c0: 5f69 6429 2c20 2265 3566 3936 6636 6633  _id), "e5f96f6f3
    │ │ │ +000160d0: 3833 3230 6630 6633 3339 3539 6362 3464  8320f0f33959cb4d
    │ │ │ +000160e0: 3364 3635 3634 3532 3131 3761 6164 6222  3d656452117aadb"
    │ │ │ +000160f0: 293b 0a7d 0a0a 3c64 6976 2073 7479 6c65  );.}..
    TORRENT_TEST │ │ │ +00016130: 2876 6572 6966 795f 6d65 7373 6167 6529 (verify_message) │ │ │ +00016140: 0a3c 2f64 6976 3e7b 0a09 6368 6172 2065 .
    {..char e │ │ │ +00016150: 7272 6f72 5f73 7472 696e 675b 3230 305d rror_string[200] │ │ │ +00016160: 3b0a 0a09 2f2f 2074 6573 7420 7665 7269 ;...// test veri │ │ │ +00016170: 6679 5f6d 6573 7361 6765 0a09 7374 6174 fy_message..stat │ │ │ +00016180: 6963 2063 6f6e 7374 206b 6579 5f64 6573 ic const key_des │ │ │ +00016190: 635f 7420 6d73 675f 6465 7363 5b5d 203d c_t msg_desc[] = │ │ │ +000161a0: 207b 0a09 097b 2241 222c 2062 6465 636f {...{"A", bdeco │ │ │ +000161b0: 6465 5f6e 6f64 653a 3a73 7472 696e 675f de_node::string_ │ │ │ +000161c0: 742c 2034 2c20 307d 2c0a 0909 7b22 4222 t, 4, 0},...{"B" │ │ │ +000161d0: 2c20 6264 6563 6f64 655f 6e6f 6465 3a3a , bdecode_node:: │ │ │ +000161e0: 6469 6374 5f74 2c20 302c 206b 6579 5f64 dict_t, 0, key_d │ │ │ +000161f0: 6573 635f 743a 3a6f 7074 696f 6e61 6c20 esc_t::optional │ │ │ +00016200: 7c20 6b65 795f 6465 7363 5f74 3a3a 7061 | key_desc_t::pa │ │ │ +00016210: 7273 655f 6368 696c 6472 656e 7d2c 0a09 rse_children},.. │ │ │ +00016220: 0909 7b22 4231 222c 2062 6465 636f 6465 ..{"B1", bdecode │ │ │ +00016230: 5f6e 6f64 653a 3a73 7472 696e 675f 742c _node::string_t, │ │ │ +00016240: 2030 2c20 307d 2c0a 0909 097b 2242 3222 0, 0},....{"B2" │ │ │ +00016250: 2c20 6264 6563 6f64 655f 6e6f 6465 3a3a , bdecode_node:: │ │ │ +00016260: 7374 7269 6e67 5f74 2c20 302c 206b 6579 string_t, 0, key │ │ │ +00016270: 5f64 6573 635f 743a 3a6c 6173 745f 6368 _desc_t::last_ch │ │ │ +00016280: 696c 647d 2c0a 0909 7b22 4322 2c20 6264 ild},...{"C", bd │ │ │ +00016290: 6563 6f64 655f 6e6f 6465 3a3a 6469 6374 ecode_node::dict │ │ │ +000162a0: 5f74 2c20 302c 206b 6579 5f64 6573 635f _t, 0, key_desc_ │ │ │ +000162b0: 743a 3a6f 7074 696f 6e61 6c20 7c20 6b65 t::optional | ke │ │ │ +000162c0: 795f 6465 7363 5f74 3a3a 7061 7273 655f y_desc_t::parse_ │ │ │ +000162d0: 6368 696c 6472 656e 7d2c 0a09 0909 7b22 children},....{" │ │ │ +000162e0: 4331 222c 2062 6465 636f 6465 5f6e 6f64 C1", bdecode_nod │ │ │ +000162f0: 653a 3a73 7472 696e 675f 742c 2030 2c20 e::string_t, 0, │ │ │ +00016300: 307d 2c0a 0909 097b 2243 3222 2c20 6264 0},....{"C2", bd │ │ │ +00016310: 6563 6f64 655f 6e6f 6465 3a3a 7374 7269 ecode_node::stri │ │ │ +00016320: 6e67 5f74 2c20 302c 206b 6579 5f64 6573 ng_t, 0, key_des │ │ │ +00016330: 635f 743a 3a6c 6173 745f 6368 696c 647d c_t::last_child} │ │ │ +00016340: 2c0a 097d 3b0a 0a09 6264 6563 6f64 655f ,..};...bdecode_ │ │ │ +00016350: 6e6f 6465 206d 7367 5f6b 6579 735b 375d node msg_keys[7] │ │ │ +00016360: 3b0a 0a09 6264 6563 6f64 655f 6e6f 6465 ;...bdecode_node │ │ │ +00016370: 2065 6e74 3b0a 0a09 6572 726f 725f 636f ent;...error_co │ │ │ +00016380: 6465 2065 633b 0a09 6368 6172 2063 6f6e de ec;..char con │ │ │ +00016390: 7374 2074 6573 745f 6d73 675b 5d20 3d20 st test_msg[] = │ │ │ +000163a0: 2264 313a 4134 3a74 6573 7431 3a42 6432 "d1:A4:test1:Bd2 │ │ │ +000163b0: 3a42 3135 3a74 6573 7432 323a 4232 353a :B15:test22:B25: │ │ │ +000163c0: 7465 7374 3365 6522 3b0a 0962 6465 636f test3ee";..bdeco │ │ │ +000163d0: 6465 2874 6573 745f 6d73 672c 2074 6573 de(test_msg, tes │ │ │ +000163e0: 745f 6d73 6720 2b20 7369 7a65 6f66 2874 t_msg + sizeof(t │ │ │ +000163f0: 6573 745f 6d73 6729 2d31 2c20 656e 742c est_msg)-1, ent, │ │ │ +00016400: 2065 6329 3b0a 0973 7464 3a3a 7072 696e ec);..std::prin │ │ │ +00016410: 7466 2822 2573 5c6e 222c 2070 7269 6e74 tf("%s\n", print │ │ │ +00016420: 5f65 6e74 7279 2865 6e74 292e 635f 7374 _entry(ent).c_st │ │ │ +00016430: 7228 2929 3b0a 0a09 626f 6f6c 2072 6574 r());...bool ret │ │ │ +00016440: 203d 2076 6572 6966 795f 6d65 7373 6167 = verify_messag │ │ │ +00016450: 6528 656e 742c 206d 7367 5f64 6573 632c e(ent, msg_desc, │ │ │ +00016460: 206d 7367 5f6b 6579 732c 2065 7272 6f72 msg_keys, error │ │ │ +00016470: 5f73 7472 696e 6729 3b0a 0954 4553 545f _string);..TEST_ │ │ │ +00016480: 4348 4543 4b28 7265 7429 3b0a 0954 4553 CHECK(ret);..TES │ │ │ +00016490: 545f 4348 4543 4b28 6d73 675f 6b65 7973 T_CHECK(msg_keys │ │ │ +000164a0: 5b30 5d29 3b0a 0969 6620 286d 7367 5f6b [0]);..if (msg_k │ │ │ +000164b0: 6579 735b 305d 2920 5445 5354 5f45 5155 eys[0]) TEST_EQU │ │ │ +000164c0: 414c 286d 7367 5f6b 6579 735b 305d 2e73 AL(msg_keys[0].s │ │ │ +000164d0: 7472 696e 675f 7661 6c75 6528 292c 2022 tring_value(), " │ │ │ +000164e0: 7465 7374 2229 3b0a 0954 4553 545f 4348 test");..TEST_CH │ │ │ +000164f0: 4543 4b28 6d73 675f 6b65 7973 5b31 5d29 ECK(msg_keys[1]) │ │ │ +00016500: 3b0a 0954 4553 545f 4348 4543 4b28 6d73 ;..TEST_CHECK(ms │ │ │ +00016510: 675f 6b65 7973 5b32 5d29 3b0a 0969 6620 g_keys[2]);..if │ │ │ +00016520: 286d 7367 5f6b 6579 735b 325d 2920 5445 (msg_keys[2]) TE │ │ │ +00016530: 5354 5f45 5155 414c 286d 7367 5f6b 6579 ST_EQUAL(msg_key │ │ │ +00016540: 735b 325d 2e73 7472 696e 675f 7661 6c75 s[2].string_valu │ │ │ +00016550: 6528 292c 2022 7465 7374 3222 293b 0a3c e(), "test2");.< │ │ │ 00016560: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ 00016570: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ 00016580: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ 00016590: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ 000165a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ -000165d0: 7472 6163 6b65 725f 6d61 6e61 6765 722e tracker_manager. │ │ │ -000165e0: 6370 703a 3430 343c 2f61 3e3c 2f74 643e cpp:404 │ │ │ -000165f0: 3c74 643e 696d 706c 656d 656e 743c 2f74 implement

    implem │ │ │ -00016650: 656e 743c 2f68 323e 3c68 343e 2e2e 2f73 ent

    ../s │ │ │ -00016660: 7263 2f74 7261 636b 6572 5f6d 616e 6167 rc/tracker_manag │ │ │ -00016670: 6572 2e63 7070 3a34 3034 3c2f 6834 3e3c er.cpp:404

    < │ │ │ -00016680: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00016690: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000166a0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -000166b0: 7820 2364 6464 3b22 3e23 6966 6e64 6566 x #ddd;">#ifndef │ │ │ -000166c0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -000166d0: 5f4c 4f47 4749 4e47 0a09 0909 6966 2028 _LOGGING....if ( │ │ │ -000166e0: 6d5f 7365 732e 7368 6f75 6c64 5f6c 6f67 m_ses.should_log │ │ │ -000166f0: 2829 290a 0909 097b 0a09 0909 096d 5f73 ())....{.....m_s │ │ │ -00016700: 6573 2e73 6573 7369 6f6e 5f6c 6f67 2822 es.session_log(" │ │ │ -00016710: 696e 636f 6d69 6e67 2055 4450 2074 7261 incoming UDP tra │ │ │ -00016720: 636b 6572 2070 6163 6b65 7420 6672 6f6d cker packet from │ │ │ -00016730: 2025 7320 6861 7320 696e 7661 6c69 6420 %s has invalid │ │ │ -00016740: 220a 0909 0909 0922 7472 616e 7361 6374 "......"transact │ │ │ -00016750: 696f 6e20 4944 2028 2578 2922 2c20 7072 ion ID (%x)", pr │ │ │ -00016760: 696e 745f 656e 6470 6f69 6e74 2865 7029 int_endpoint(ep) │ │ │ -00016770: 2e63 5f73 7472 2829 0a09 0909 0909 2c20 .c_str()......, │ │ │ -00016780: 7472 616e 7361 6374 696f 6e29 3b0a 0909 transaction);... │ │ │ -00016790: 097d 0a23 656e 6469 660a 0909 0972 6574 .}.#endif....ret │ │ │ -000167a0: 7572 6e20 6661 6c73 653b 0a09 097d 0a0a urn false;...}.. │ │ │ -000167b0: 0909 6175 746f 2063 6f6e 7374 2070 203d ..auto const p = │ │ │ -000167c0: 2069 2d26 6774 3b73 6563 6f6e 643b 0a09 i->second;.. │ │ │ -000167d0: 092f 2f20 6f6e 5f72 6563 6569 7665 2829 .// on_receive() │ │ │ -000167e0: 206d 6179 2072 656d 6f76 6520 7468 6520 may remove the │ │ │ -000167f0: 7472 6163 6b65 7220 636f 6e6e 6563 7469 tracker connecti │ │ │ -00016800: 6f6e 2066 726f 6d20 7468 6520 6c69 7374 on from the list │ │ │ -00016810: 0a09 0972 6574 7572 6e20 702d 2667 743b ...return p-> │ │ │ -00016820: 6f6e 5f72 6563 6569 7665 2865 702c 2062 on_receive(ep, b │ │ │ -00016830: 7566 293b 0a09 7d0a 0a09 766f 6964 2074 uf);..}...void t │ │ │ -00016840: 7261 636b 6572 5f6d 616e 6167 6572 3a3a racker_manager:: │ │ │ -00016850: 696e 636f 6d69 6e67 5f65 7272 6f72 2865 incoming_error(e │ │ │ -00016860: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ -00016870: 616d 703b 0a09 092c 2075 6470 3a3a 656e amp;..., udp::en │ │ │ -00016880: 6470 6f69 6e74 2063 6f6e 7374 2661 6d70 dpoint const& │ │ │ -00016890: 3b29 0a09 7b0a 0909 544f 5252 454e 545f ;)..{...TORRENT_ │ │ │ -000168a0: 4153 5345 5254 2869 735f 7369 6e67 6c65 ASSERT(is_single │ │ │ -000168b0: 5f74 6872 6561 6428 2929 3b0a 3c64 6976 _thread());.
    .}...bool tracke │ │ │ -00016900: 725f 6d61 6e61 6765 723a 3a69 6e63 6f6d r_manager::incom │ │ │ -00016910: 696e 675f 7061 636b 6574 2873 7472 696e ing_packet(strin │ │ │ -00016920: 675f 7669 6577 2063 6f6e 7374 2068 6f73 g_view const hos │ │ │ -00016930: 746e 616d 650a 0909 2c20 7370 616e 266c tname..., span&l │ │ │ -00016940: 743b 6368 6172 2063 6f6e 7374 2667 743b t;char const> │ │ │ -00016950: 2063 6f6e 7374 2062 7566 290a 097b 0a09 const buf)..{.. │ │ │ -00016960: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -00016970: 6973 5f73 696e 676c 655f 7468 7265 6164 is_single_thread │ │ │ -00016980: 2829 293b 0a09 092f 2f20 6967 6e6f 7265 ());...// ignore │ │ │ -00016990: 2070 6163 6b65 7473 2073 6d61 6c6c 6572 packets smaller │ │ │ -000169a0: 2074 6861 6e20 3820 6279 7465 730a 0909 than 8 bytes... │ │ │ -000169b0: 6966 2028 6275 662e 7369 7a65 2829 2026 if (buf.size() & │ │ │ -000169c0: 6c74 3b20 3136 2920 7265 7475 726e 2066 lt; 16) return f │ │ │ -000169d0: 616c 7365 3b0a 0a09 092f 2f20 7468 6520 alse;....// the │ │ │ -000169e0: 6669 7273 7420 776f 7264 2069 7320 7468 first word is th │ │ │ -000169f0: 6520 6163 7469 6f6e 2c20 6966 2069 7427 e action, if it' │ │ │ -00016a00: 7320 6e6f 7420 5b30 2c20 335d 0a09 092f s not [0, 3].../ │ │ │ -00016a10: 2f20 6974 2773 206e 6f74 2061 2076 616c / it's not a val │ │ │ -00016a20: 6964 2075 6470 2074 7261 636b 6572 2072 id udp tracker r │ │ │ -00016a30: 6573 706f 6e73 650a 0909 7370 616e 266c esponse...span&l │ │ │ -00016a40: 743b 636f 6e73 7420 6368 6172 2667 743b t;const char> │ │ │ -00016a50: 2070 7472 203d 2062 7566 3b0a 0909 7374 ptr = buf;...st │ │ │ -00016a60: 643a 3a75 696e 7433 325f 7420 636f 6e73 d::uint32_t cons │ │ │ -00016a70: 7420 6163 7469 6f6e 203d 2061 7578 3a3a t action = aux:: │ │ │ -00016a80: 7265 6164 5f75 696e 7433 3228 7074 7229 read_uint32(ptr) │ │ │ -00016a90: 3b0a 0909 6966 2028 6163 7469 6f6e 2026 ;...if (action & │ │ │ -00016aa0: 6774 3b20 3329 2072 6574 7572 6e20 6661 gt; 3) return fa │ │ │ -00016ab0: 6c73 653b 0a0a 0909 7374 643a 3a75 696e lse;....std::uin │ │ │ -00016ac0: 7433 325f 7420 636f 6e73 7420 7472 616e t32_t const tran │ │ │ -00016ad0: 7361 6374 696f 6e20 3d20 6175 783a 3a72 saction = aux::r │ │ │ -00016ae0: 6561 645f 7569 6e74 3332 2870 7472 293b ead_uint32(ptr); │ │ │ -00016af0: 0a09 0961 7574 6f20 636f 6e73 7420 6920 ...auto const i │ │ │ -00016b00: 3d20 6d5f 7564 705f 636f 6e6e 732e 6669 = m_udp_conns.fi │ │ │ -00016b10: 6e64 2874 7261 6e73 6163 7469 6f6e 293b nd(transaction); │ │ │ -00016b20: 0a0a 0909 6966 2028 6920 3d3d 206d 5f75 ....if (i == m_u │ │ │ -00016b30: 6470 5f63 6f6e 6e73 2e65 6e64 2829 290a dp_conns.end()). │ │ │ -00016b40: 0909 7b0a 2369 666e 6465 6620 544f 5252 ..{.#ifndef TORR │ │ │ -00016b50: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ -00016b60: 494e 470a 0909 092f 2f20 6e6f 772c 2074 ING....// now, t │ │ │ -00016b70: 6869 7320 6d61 7920 6e6f 7420 6861 7665 his may not have │ │ │ -00016b80: 2062 6565 6e20 6d65 616e 7420 746f 2062 been meant to b │ │ │ -00016b90: 6520 6120 7472 6163 6b65 7220 7265 7370 e a tracker resp │ │ │ -00016ba0: 6f6e 7365 2c0a 0909 092f 2f20 6275 7420 onse,....// but │ │ │ -00016bb0: 6368 616e 6365 7320 6172 6520 7072 6574 chances are pret │ │ │ -00016bc0: 7479 2067 6f6f 642c 2073 6f20 6974 2773 ty good, so it's │ │ │ -00016bd0: 2070 726f 6261 626c 7920 776f 7274 6820 probably worth │ │ │ -00016be0: 6c6f 6767 696e 670a 0909 096d 5f73 6573 logging....m_ses │ │ │ -00016bf0: 2e73 6573 7369 6f6e 5f6c 6f67 2822 696e .session_log("in │ │ │ -00016c00: 636f 6d69 6e67 2055 4450 2074 7261 636b coming UDP track │ │ │ -00016c10: 6572 2070 6163 6b65 7420 6672 6f6d 2025 er packet from % │ │ │ -00016c20: 7320 6861 7320 696e 7661 6c69 6420 220a s has invalid ". │ │ │ -00016c30: 0909 0909 2274 7261 6e73 6163 7469 6f6e ...."transaction │ │ │ -00016c40: 2049 4420 2825 7829 222c 2073 7464 3a3a ID (%x)", std:: │ │ │ -00016c50: 7374 7269 6e67 2868 6f73 746e 616d 6529 string(hostname) │ │ │ -00016c60: 2e63 5f73 7472 2829 2c20 7472 616e 7361 .c_str(), transa │ │ │ -00016c70: 6374 696f 6e29 3b0a 2365 6e64 6966 0a09 ction);.#endif.. │ │ │ -00016c80: 0909 7265 7475 726e 2066 616c 7365 3b0a ..return false;. │ │ │ -00016c90: 0909 7d0a 0a09 0961 7574 6f20 636f 6e73 ..}....auto cons │ │ │ -00016ca0: 7420 7020 3d20 692d 2667 743b 7365 636f t p = i->seco │ │ │ -00016cb0: 6e64 3b0a 0909 2f2f 206f 6e5f 7265 6365 nd;...// on_rece │ │ │ -00016cc0: 6976 6528 2920 6d61 7920 7265 6d6f 7665 ive() may remove │ │ │ -00016cd0: 2074 6865 2074 7261 636b 6572 2063 6f6e the tracker con │ │ │ -00016ce0: 6e65 6374 696f 6e20 6672 6f6d 2074 6865 nection from the │ │ │ -00016cf0: 206c 6973 740a 3c2f 7072 653e 3c2f 7464 list.
    relevance │ │ │ -00016d30: 266e 6273 703b 323c 2f74 643e 3c74 643e  2 │ │ │ -00016d40: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ -00016d60: 2e2e 2f73 7263 2f61 6c65 7274 2e63 7070 ../src/alert.cpp │ │ │ -00016d70: 3a31 3937 353c 2f61 3e3c 2f74 643e 3c74 :1975the salt here │ │ │ -00016d90: 6973 2061 6c6c 6f63 6174 6564 206f 6e20 is allocated on │ │ │ -00016da0: 7468 6520 6865 6170 2e20 4974 2077 6f75 the heap. It wou │ │ │ -00016db0: 6c64 2062 6520 6e69 6365 2074 6f20 616c ld be nice to al │ │ │ -00016dc0: 6c6f 6361 7465 2069 6e20 7468 6520 7374 locate in the st │ │ │ -00016dd0: 6163 6b5f 616c 6c6f 6361 746f 723c 2f74 ack_allocator

    the sa │ │ │ -00016e30: 6c74 2068 6572 6520 6973 2061 6c6c 6f63 lt here is alloc │ │ │ -00016e40: 6174 6564 206f 6e20 7468 6520 6865 6170 ated on the heap │ │ │ -00016e50: 2e20 4974 2077 6f75 6c64 2062 6520 6e69 . It would be ni │ │ │ -00016e60: 6365 2074 6f0a 616c 6c6f 6361 7465 2069 ce to.allocate i │ │ │ -00016e70: 6e20 7468 6520 7374 6163 6b5f 616c 6c6f n the stack_allo │ │ │ -00016e80: 6361 746f 723c 2f68 323e 3c68 343e 2e2e cator

    .. │ │ │ -00016e90: 2f73 7263 2f61 6c65 7274 2e63 7070 3a31 /src/alert.cpp:1 │ │ │ -00016ea0: 3937 353c 2f68 343e 3c70 7265 2073 7479 975

    .}...dht_immut
    │ │ │ -00016ef0: 6162 6c65 5f69 7465 6d5f 616c 6572 743a  able_item_alert:
    │ │ │ -00016f00: 3a64 6874 5f69 6d6d 7574 6162 6c65 5f69  :dht_immutable_i
    │ │ │ -00016f10: 7465 6d5f 616c 6572 7428 6175 783a 3a73  tem_alert(aux::s
    │ │ │ -00016f20: 7461 636b 5f61 6c6c 6f63 6174 6f72 2661  tack_allocator&a
    │ │ │ -00016f30: 6d70 3b0a 0909 2c20 7368 6131 5f68 6173  mp;..., sha1_has
    │ │ │ -00016f40: 6820 636f 6e73 7426 616d 703b 2074 2c20  h const& t, 
    │ │ │ -00016f50: 656e 7472 7920 6929 0a09 093a 2074 6172  entry i)...: tar
    │ │ │ -00016f60: 6765 7428 7429 2c20 6974 656d 2873 7464  get(t), item(std
    │ │ │ -00016f70: 3a3a 6d6f 7665 2869 2929 0a09 7b7d 0a0a  ::move(i))..{}..
    │ │ │ -00016f80: 0973 7464 3a3a 7374 7269 6e67 2064 6874  .std::string dht
    │ │ │ -00016f90: 5f69 6d6d 7574 6162 6c65 5f69 7465 6d5f  _immutable_item_
    │ │ │ -00016fa0: 616c 6572 743a 3a6d 6573 7361 6765 2829  alert::message()
    │ │ │ -00016fb0: 2063 6f6e 7374 0a09 7b0a 2369 6664 6566   const..{.#ifdef
    │ │ │ -00016fc0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ -00016fd0: 5f41 4c45 5254 5f4d 5347 0a09 0972 6574  _ALERT_MSG...ret
    │ │ │ -00016fe0: 7572 6e20 7b7d 3b0a 2365 6c73 650a 0909  urn {};.#else...
    │ │ │ -00016ff0: 6368 6172 206d 7367 5b31 3035 305d 3b0a  char msg[1050];.
    │ │ │ -00017000: 0909 7374 643a 3a73 6e70 7269 6e74 6628  ..std::snprintf(
    │ │ │ -00017010: 6d73 672c 2073 697a 656f 6628 6d73 6729  msg, sizeof(msg)
    │ │ │ -00017020: 2c20 2244 4854 2069 6d6d 7574 6162 6c65  , "DHT immutable
    │ │ │ -00017030: 2069 7465 6d20 2573 205b 2025 7320 5d22   item %s [ %s ]"
    │ │ │ -00017040: 0a09 0909 2c20 6175 783a 3a74 6f5f 6865  ...., aux::to_he
    │ │ │ -00017050: 7828 7461 7267 6574 292e 635f 7374 7228  x(target).c_str(
    │ │ │ -00017060: 290a 0909 092c 2069 7465 6d2e 746f 5f73  )...., item.to_s
    │ │ │ -00017070: 7472 696e 6728 292e 635f 7374 7228 2929  tring().c_str())
    │ │ │ -00017080: 3b0a 0909 7265 7475 726e 206d 7367 3b0a  ;...return msg;.
    │ │ │ -00017090: 2365 6e64 6966 0a09 7d0a 0a3c 6469 7620  #endif..}..
    .dht_mu │ │ │ -000170d0: 7461 626c 655f 6974 656d 5f61 6c65 7274 table_item_alert │ │ │ -000170e0: 3a3a 6468 745f 6d75 7461 626c 655f 6974 ::dht_mutable_it │ │ │ -000170f0: 656d 5f61 6c65 7274 2861 7578 3a3a 7374 em_alert(aux::st │ │ │ -00017100: 6163 6b5f 616c 6c6f 6361 746f 7226 616d ack_allocator&am │ │ │ -00017110: 703b 0a3c 2f64 6976 3e09 092c 2073 7464 p;.
    .., std │ │ │ -00017120: 3a3a 6172 7261 7926 6c74 3b63 6861 722c ::array<char, │ │ │ -00017130: 2033 3226 6774 3b20 636f 6e73 7426 616d 32> const&am │ │ │ -00017140: 703b 206b 0a09 092c 2073 7464 3a3a 6172 p; k..., std::ar │ │ │ -00017150: 7261 7926 6c74 3b63 6861 722c 2036 3426 ray<char, 64& │ │ │ -00017160: 6774 3b20 636f 6e73 7426 616d 703b 2073 gt; const& s │ │ │ -00017170: 6967 0a09 092c 2073 7464 3a3a 696e 7436 ig..., std::int6 │ │ │ -00017180: 345f 7420 7365 7175 656e 6365 0a09 092c 4_t sequence..., │ │ │ -00017190: 2073 7472 696e 675f 7669 6577 2073 0a09 string_view s.. │ │ │ -000171a0: 092c 2065 6e74 7279 2069 0a09 092c 2062 ., entry i..., b │ │ │ -000171b0: 6f6f 6c20 6129 0a09 093a 206b 6579 286b ool a)...: key(k │ │ │ -000171c0: 292c 2073 6967 6e61 7475 7265 2873 6967 ), signature(sig │ │ │ -000171d0: 292c 2073 6571 2873 6571 7565 6e63 6529 ), seq(sequence) │ │ │ -000171e0: 2c20 7361 6c74 2873 292c 2069 7465 6d28 , salt(s), item( │ │ │ -000171f0: 7374 643a 3a6d 6f76 6528 6929 292c 2061 std::move(i)), a │ │ │ -00017200: 7574 686f 7269 7461 7469 7665 2861 290a uthoritative(a). │ │ │ -00017210: 097b 7d0a 0a09 7374 643a 3a73 7472 696e .{}...std::strin │ │ │ -00017220: 6720 6468 745f 6d75 7461 626c 655f 6974 g dht_mutable_it │ │ │ -00017230: 656d 5f61 6c65 7274 3a3a 6d65 7373 6167 em_alert::messag │ │ │ -00017240: 6528 2920 636f 6e73 740a 097b 0a23 6966 e() const..{.#if │ │ │ -00017250: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -00017260: 424c 455f 414c 4552 545f 4d53 470a 0909 BLE_ALERT_MSG... │ │ │ -00017270: 7265 7475 726e 207b 7d3b 0a23 656c 7365 return {};.#else │ │ │ -00017280: 0a09 0963 6861 7220 6d73 675b 3130 3530 ...char msg[1050 │ │ │ -00017290: 5d3b 0a09 0973 7464 3a3a 736e 7072 696e ];...std::snprin │ │ │ -000172a0: 7466 286d 7367 2c20 7369 7a65 6f66 286d tf(msg, sizeof(m │ │ │ -000172b0: 7367 292c 2022 4448 5420 6d75 7461 626c sg), "DHT mutabl │ │ │ -000172c0: 6520 6974 656d 2028 6b65 793d 2573 2073 e item (key=%s s │ │ │ -000172d0: 616c 743d 2573 2073 6571 3d25 2220 5052 alt=%s seq=%" PR │ │ │ -000172e0: 4964 3634 2022 2025 7329 205b 2025 7320 Id64 " %s) [ %s │ │ │ -000172f0: 5d22 0a09 0909 2c20 6175 783a 3a74 6f5f ]"...., aux::to_ │ │ │ -00017300: 6865 7828 6b65 7929 2e63 5f73 7472 2829 hex(key).c_str() │ │ │ -00017310: 0a09 0909 2c20 7361 6c74 2e63 5f73 7472 ...., salt.c_str │ │ │ -00017320: 2829 0a09 0909 2c20 7365 710a 0909 092c ()...., seq...., │ │ │ -00017330: 2061 7574 686f 7269 7461 7469 7665 203f authoritative ? │ │ │ -00017340: 2022 6175 7468 2220 3a20 226e 6f6e 2d61 "auth" : "non-a │ │ │ -00017350: 7574 6822 0a09 0909 2c20 6974 656d 2e74 uth"...., item.t │ │ │ -00017360: 6f5f 7374 7269 6e67 2829 2e63 5f73 7472 o_string().c_str │ │ │ -00017370: 2829 293b 0a09 0972 6574 7572 6e20 6d73 ());...return ms │ │ │ -00017380: 673b 0a23 656e 6469 660a 097d 0a0a 0964 g;.#endif..}...d │ │ │ -00017390: 6874 5f70 7574 5f61 6c65 7274 3a3a 6468 ht_put_alert::dh │ │ │ -000173a0: 745f 7075 745f 616c 6572 7428 6175 783a t_put_alert(aux: │ │ │ -000173b0: 3a73 7461 636b 5f61 6c6c 6f63 6174 6f72 :stack_allocator │ │ │ -000173c0: 2661 6d70 3b2c 2073 6861 315f 6861 7368 &, sha1_hash │ │ │ -000173d0: 2063 6f6e 7374 2661 6d70 3b20 742c 2069 const& t, i │ │ │ -000173e0: 6e74 206e 290a 0909 3a20 7461 7267 6574 nt n)...: target │ │ │ -000173f0: 2874 290a 0909 2c20 7075 626c 6963 5f6b (t)..., public_k │ │ │ -00017400: 6579 2829 0a09 092c 2073 6967 6e61 7475 ey()..., signatu │ │ │ -00017410: 7265 2829 0a09 092c 2073 6571 2830 290a re()..., seq(0). │ │ │ -00017420: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00017430: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00017460: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ -00017490: 2f75 6470 5f74 7261 636b 6572 5f63 6f6e /udp_tracker_con │ │ │ -000174a0: 6e65 6374 696f 6e2e 6370 703a 3539 3c2f nection.cpp:59suppo │ │ │ -000174c0: 7274 2061 7574 6865 6e74 6963 6174 696f rt authenticatio │ │ │ -000174d0: 6e20 6865 7265 2e20 7472 6163 6b65 725f n here. tracker_ │ │ │ -000174e0: 7265 7128 292e 6175 7468 3c2f 7464 3e3c req().auth< │ │ │ -000174f0: 2f74 723e 3c74 7220 6964 3d22 3436 2220 /tr>

    support a │ │ │ -00017540: 7574 6865 6e74 6963 6174 696f 6e20 6865 uthentication he │ │ │ -00017550: 7265 2e20 7472 6163 6b65 725f 7265 7128 re. tracker_req( │ │ │ -00017560: 292e 6175 7468 3c2f 6832 3e3c 6834 3e2e ).auth

    . │ │ │ -00017570: 2e2f 7372 632f 7564 705f 7472 6163 6b65 ./src/udp_tracke │ │ │ -00017580: 725f 636f 6e6e 6563 7469 6f6e 2e63 7070 r_connection.cpp │ │ │ -00017590: 3a35 393c 2f68 343e 3c70 7265 2073 7479 :59

    ..udp_tracker_
    │ │ │ -000175e0: 636f 6e6e 6563 7469 6f6e 3a3a 6d5f 636f  connection::m_co
    │ │ │ -000175f0: 6e6e 6563 7469 6f6e 5f63 6163 6865 3b0a  nnection_cache;.
    │ │ │ -00017600: 0a09 7374 643a 3a6d 7574 6578 2075 6470  ..std::mutex udp
    │ │ │ -00017610: 5f74 7261 636b 6572 5f63 6f6e 6e65 6374  _tracker_connect
    │ │ │ -00017620: 696f 6e3a 3a6d 5f63 6163 6865 5f6d 7574  ion::m_cache_mut
    │ │ │ -00017630: 6578 3b0a 0a09 7564 705f 7472 6163 6b65  ex;...udp_tracke
    │ │ │ -00017640: 725f 636f 6e6e 6563 7469 6f6e 3a3a 7564  r_connection::ud
    │ │ │ -00017650: 705f 7472 6163 6b65 725f 636f 6e6e 6563  p_tracker_connec
    │ │ │ -00017660: 7469 6f6e 280a 0909 696f 5f63 6f6e 7465  tion(...io_conte
    │ │ │ -00017670: 7874 2661 6d70 3b20 696f 730a 0909 2c20  xt& ios..., 
    │ │ │ -00017680: 7472 6163 6b65 725f 6d61 6e61 6765 7226  tracker_manager&
    │ │ │ -00017690: 616d 703b 206d 616e 0a09 092c 2074 7261  amp; man..., tra
    │ │ │ -000176a0: 636b 6572 5f72 6571 7565 7374 2063 6f6e  cker_request con
    │ │ │ -000176b0: 7374 2661 6d70 3b20 7265 710a 0909 2c20  st& req..., 
    │ │ │ -000176c0: 7374 643a 3a77 6561 6b5f 7074 7226 6c74  std::weak_ptr<
    │ │ │ -000176d0: 3b72 6571 7565 7374 5f63 616c 6c62 6163  ;request_callbac
    │ │ │ -000176e0: 6b26 6774 3b20 6329 0a09 093a 2074 7261  k> c)...: tra
    │ │ │ -000176f0: 636b 6572 5f63 6f6e 6e65 6374 696f 6e28  cker_connection(
    │ │ │ -00017700: 6d61 6e2c 2072 6571 2c20 696f 732c 2073  man, req, ios, s
    │ │ │ -00017710: 7464 3a3a 6d6f 7665 2863 2929 0a09 092c  td::move(c))...,
    │ │ │ -00017720: 206d 5f74 7261 6e73 6163 7469 6f6e 5f69   m_transaction_i
    │ │ │ -00017730: 6428 3029 0a09 092c 206d 5f61 7474 656d  d(0)..., m_attem
    │ │ │ -00017740: 7074 7328 3029 0a09 092c 206d 5f73 7461  pts(0)..., m_sta
    │ │ │ -00017750: 7465 2861 6374 696f 6e5f 743a 3a65 7272  te(action_t::err
    │ │ │ -00017760: 6f72 290a 0909 2c20 6d5f 6162 6f72 7428  or)..., m_abort(
    │ │ │ -00017770: 6661 6c73 6529 0a09 7b0a 0909 7570 6461  false)..{...upda
    │ │ │ -00017780: 7465 5f74 7261 6e73 6163 7469 6f6e 5f69  te_transaction_i
    │ │ │ -00017790: 6428 293b 0a09 7d0a 0a09 766f 6964 2075  d();..}...void u
    │ │ │ -000177a0: 6470 5f74 7261 636b 6572 5f63 6f6e 6e65  dp_tracker_conne
    │ │ │ -000177b0: 6374 696f 6e3a 3a73 7461 7274 2829 0a09  ction::start()..
    │ │ │ -000177c0: 7b0a 3c64 6976 2073 7479 6c65 3d22 6261  {.
    │ │ │ -000177f0: 0909 7374 643a 3a73 7472 696e 6720 686f ..std::string ho │ │ │ -00017800: 7374 6e61 6d65 3b0a 3c2f 6469 763e 0909 stname;.
    .. │ │ │ -00017810: 7374 643a 3a73 7472 696e 6720 7072 6f74 std::string prot │ │ │ -00017820: 6f63 6f6c 3b0a 0909 696e 7420 706f 7274 ocol;...int port │ │ │ -00017830: 3b0a 0909 6572 726f 725f 636f 6465 2065 ;...error_code e │ │ │ -00017840: 633b 0a0a 0909 7374 643a 3a74 6965 2870 c;....std::tie(p │ │ │ -00017850: 726f 746f 636f 6c2c 2073 7464 3a3a 6967 rotocol, std::ig │ │ │ -00017860: 6e6f 7265 2c20 686f 7374 6e61 6d65 2c20 nore, hostname, │ │ │ -00017870: 706f 7274 2c20 7374 643a 3a69 676e 6f72 port, std::ignor │ │ │ -00017880: 6529 0a09 0909 3d20 7061 7273 655f 7572 e)....= parse_ur │ │ │ -00017890: 6c5f 636f 6d70 6f6e 656e 7473 2874 7261 l_components(tra │ │ │ -000178a0: 636b 6572 5f72 6571 2829 2e75 726c 2c20 cker_req().url, │ │ │ -000178b0: 6563 293b 0a09 0969 6620 2870 6f72 7420 ec);...if (port │ │ │ -000178c0: 3d3d 202d 3129 2070 6f72 7420 3d20 7072 == -1) port = pr │ │ │ -000178d0: 6f74 6f63 6f6c 203d 3d20 2268 7474 7022 otocol == "http" │ │ │ -000178e0: 203f 2038 3020 3a20 3434 333b 0a0a 0909 ? 80 : 443;.... │ │ │ -000178f0: 6966 2028 6563 290a 0909 7b0a 0909 0974 if (ec)...{....t │ │ │ -00017900: 7261 636b 6572 5f63 6f6e 6e65 6374 696f racker_connectio │ │ │ -00017910: 6e3a 3a66 6169 6c28 6563 2c20 6f70 6572 n::fail(ec, oper │ │ │ -00017920: 6174 696f 6e5f 743a 3a70 6172 7365 5f61 ation_t::parse_a │ │ │ -00017930: 6464 7265 7373 293b 0a09 0909 7265 7475 ddress);....retu │ │ │ -00017940: 726e 3b0a 0909 7d0a 0a09 0961 7578 3a3a rn;...}....aux:: │ │ │ -00017950: 7365 7373 696f 6e5f 7365 7474 696e 6773 session_settings │ │ │ -00017960: 2063 6f6e 7374 2661 6d70 3b20 7365 7474 const& sett │ │ │ -00017970: 696e 6773 203d 206d 5f6d 616e 2e73 6574 ings = m_man.set │ │ │ -00017980: 7469 6e67 7328 293b 0a0a 0909 696e 7420 tings();....int │ │ │ -00017990: 636f 6e73 7420 7072 6f78 795f 7479 7065 const proxy_type │ │ │ -000179a0: 203d 2073 6574 7469 6e67 732e 6765 745f = settings.get_ │ │ │ -000179b0: 696e 7428 7365 7474 696e 6773 5f70 6163 int(settings_pac │ │ │ -000179c0: 6b3a 3a70 726f 7879 5f74 7970 6529 3b0a k::proxy_type);. │ │ │ -000179d0: 0a09 0969 6620 2873 6574 7469 6e67 732e ...if (settings. │ │ │ -000179e0: 6765 745f 626f 6f6c 2873 6574 7469 6e67 get_bool(setting │ │ │ -000179f0: 735f 7061 636b 3a3a 7072 6f78 795f 686f s_pack::proxy_ho │ │ │ -00017a00: 7374 6e61 6d65 7329 0a09 0909 2661 6d70 stnames)....& │ │ │ -00017a10: 3b26 616d 703b 2028 7072 6f78 795f 7479 ;& (proxy_ty │ │ │ -00017a20: 7065 203d 3d20 7365 7474 696e 6773 5f70 pe == settings_p │ │ │ -00017a30: 6163 6b3a 3a73 6f63 6b73 350a 0909 0909 ack::socks5..... │ │ │ -00017a40: 7c7c 2070 726f 7879 5f74 7970 6520 3d3d || proxy_type == │ │ │ -00017a50: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ -00017a60: 736f 636b 7335 5f70 7729 290a 0909 7b0a socks5_pw))...{. │ │ │ -00017a70: 0909 096d 5f68 6f73 746e 616d 6520 3d20 ...m_hostname = │ │ │ -00017a80: 686f 7374 6e61 6d65 3b0a 0909 096d 5f74 hostname;....m_t │ │ │ -00017a90: 6172 6765 742e 706f 7274 2873 7464 3a3a arget.port(std:: │ │ │ -00017aa0: 7569 6e74 3136 5f74 2870 6f72 7429 293b uint16_t(port)); │ │ │ -00017ab0: 0a09 0909 7374 6172 745f 616e 6e6f 756e ....start_announ │ │ │ -00017ac0: 6365 2829 3b0a 0909 7d0a 0909 656c 7365 ce();...}...else │ │ │ -00017ad0: 0a09 097b 0a09 0909 7573 696e 6720 6e61 ...{....using na │ │ │ -00017ae0: 6d65 7370 6163 6520 7374 643a 3a70 6c61 mespace std::pla │ │ │ -00017af0: 6365 686f 6c64 6572 733b 0a09 0909 4144 ceholders;....AD │ │ │ -00017b00: 445f 4f55 5453 5441 4e44 494e 475f 4153 D_OUTSTANDING_AS │ │ │ -00017b10: 594e 4328 2275 6470 5f74 7261 636b 6572 YNC("udp_tracker │ │ │ -00017b20: 5f63 6f6e 6e65 6374 696f 6e3a 3a6e 616d _connection::nam │ │ │ -00017b30: 655f 6c6f 6f6b 7570 2229 3b0a 3c2f 7072 e_lookup");.rel │ │ │ -00017b70: 6576 616e 6365 266e 6273 703b 323c 2f74 evance 2
    ../src/pat │ │ │ -00017bb0: 682e 6370 703a 3431 303c 2f61 3e3c 2f74 h.cpp:410test this │ │ │ -00017bd0: 6f6e 2061 2046 4154 2076 6f6c 756d 6520 on a FAT volume │ │ │ -00017be0: 746f 2073 6565 2077 6861 7420 6572 726f to see what erro │ │ │ -00017bf0: 7220 7765 2067 6574 213c 2f74 643e 3c2f r we get!

    test this │ │ │ -00017c50: 6f6e 2061 2046 4154 2076 6f6c 756d 6520 on a FAT volume │ │ │ -00017c60: 746f 2073 6565 2077 6861 7420 6572 726f to see what erro │ │ │ -00017c70: 7220 7765 2067 6574 213c 2f68 323e 3c68 r we get!

    ../src/path.cp │ │ │ -00017c90: 703a 3431 303c 2f68 343e 3c70 7265 2073 p:410

    ...// it's p
    │ │ │ -00017ce0: 6f73 7369 626c 6520 4372 6561 7465 4861  ossible CreateHa
    │ │ │ -00017cf0: 7264 4c69 6e6b 2077 696c 6c20 636f 7079  rdLink will copy
    │ │ │ -00017d00: 2074 6865 2066 696c 6520 696e 7465 726e   the file intern
    │ │ │ -00017d10: 616c 6c79 2074 6f6f 2c0a 0909 092f 2f20  ally too,....// 
    │ │ │ -00017d20: 6966 2074 6865 2066 696c 6573 7973 7465  if the filesyste
    │ │ │ -00017d30: 6d20 646f 6573 206e 6f74 2073 7570 706f  m does not suppo
    │ │ │ -00017d40: 7274 2069 742e 0a09 0909 6563 2e61 7373  rt it.....ec.ass
    │ │ │ -00017d50: 6967 6e28 4765 744c 6173 7445 7272 6f72  ign(GetLastError
    │ │ │ -00017d60: 2829 2c20 7379 7374 656d 5f63 6174 6567  (), system_categ
    │ │ │ -00017d70: 6f72 7928 2929 3b0a 0909 0972 6574 7572  ory());....retur
    │ │ │ -00017d80: 6e3b 0a09 097d 0a0a 0909 2f2f 2066 616c  n;...}....// fal
    │ │ │ -00017d90: 6c20 6261 636b 2074 6f20 6d61 6b69 6e67  l back to making
    │ │ │ -00017da0: 2061 2063 6f70 790a 2365 6e64 6966 0a23   a copy.#endif.#
    │ │ │ -00017db0: 656c 7365 0a09 092f 2f20 6173 7375 6d65  else...// assume
    │ │ │ -00017dc0: 2070 6f73 6978 2773 206c 696e 6b28 2920   posix's link() 
    │ │ │ -00017dd0: 6675 6e63 7469 6f6e 2065 7869 7374 730a  function exists.
    │ │ │ -00017de0: 0909 696e 7420 7265 7420 3d20 3a3a 6c69  ..int ret = ::li
    │ │ │ -00017df0: 6e6b 286e 5f65 7869 7374 2e63 5f73 7472  nk(n_exist.c_str
    │ │ │ -00017e00: 2829 2c20 6e5f 6c69 6e6b 2e63 5f73 7472  (), n_link.c_str
    │ │ │ -00017e10: 2829 293b 0a0a 0909 6966 2028 7265 7420  ());....if (ret 
    │ │ │ -00017e20: 3d3d 2030 290a 0909 7b0a 0909 0965 632e  == 0)...{....ec.
    │ │ │ -00017e30: 636c 6561 7228 293b 0a09 0909 7265 7475  clear();....retu
    │ │ │ -00017e40: 726e 3b0a 0909 7d0a 0a09 092f 2f20 6d6f  rn;...}....// mo
    │ │ │ -00017e50: 7374 2065 7272 6f72 7320 6172 6520 7061  st errors are pa
    │ │ │ -00017e60: 7373 6564 2074 6872 6f75 6768 2c20 6578  ssed through, ex
    │ │ │ -00017e70: 6365 7074 2066 6f72 2074 6865 206f 6e65  cept for the one
    │ │ │ -00017e80: 7320 7468 6174 2069 6e64 6963 6174 6520  s that indicate 
    │ │ │ -00017e90: 7468 6174 0a09 092f 2f20 6861 7264 206c  that...// hard l
    │ │ │ -00017ea0: 696e 6b73 2061 7265 206e 6f74 2073 7570  inks are not sup
    │ │ │ -00017eb0: 706f 7274 6564 2061 6e64 2072 6571 7569  ported and requi
    │ │ │ -00017ec0: 7265 2061 2063 6f70 792e 0a3c 6469 7620  re a copy..
    ..if (e │ │ │ -00017f00: 7272 6e6f 2021 3d20 454d 4c49 4e4b 0a3c rrno != EMLINK.< │ │ │ -00017f10: 2f64 6976 3e09 0909 2661 6d70 3b26 616d /div>...&&am │ │ │ -00017f20: 703b 2065 7272 6e6f 2021 3d20 4558 4445 p; errno != EXDE │ │ │ -00017f30: 560a 2369 6664 6566 2054 4f52 5245 4e54 V.#ifdef TORRENT │ │ │ -00017f40: 5f42 454f 530a 0909 092f 2f20 6861 696b _BEOS....// haik │ │ │ -00017f50: 7520 7265 7475 726e 7320 4550 4552 4d20 u returns EPERM │ │ │ -00017f60: 7768 656e 2074 6865 2066 696c 6573 7973 when the filesys │ │ │ -00017f70: 7465 6d20 646f 6573 6e27 7420 7375 7070 tem doesn't supp │ │ │ -00017f80: 6f72 7420 6861 7264 206c 696e 6b0a 0909 ort hard link... │ │ │ -00017f90: 0926 616d 703b 2661 6d70 3b20 6572 726e .&& errn │ │ │ -00017fa0: 6f20 213d 2045 5045 524d 0a23 656e 6469 o != EPERM.#endi │ │ │ -00017fb0: 660a 0909 0929 0a09 097b 0a09 0909 2f2f f....)...{....// │ │ │ -00017fc0: 2073 6f6d 6520 6572 726f 7220 6861 7070 some error happ │ │ │ -00017fd0: 656e 6564 2c20 7265 706f 7274 2075 7020 ened, report up │ │ │ -00017fe0: 746f 2074 6865 2063 616c 6c65 720a 0909 to the caller... │ │ │ -00017ff0: 0965 632e 6173 7369 676e 2865 7272 6e6f .ec.assign(errno │ │ │ -00018000: 2c20 7379 7374 656d 5f63 6174 6567 6f72 , system_categor │ │ │ -00018010: 7928 2929 3b0a 0909 0972 6574 7572 6e3b y());....return; │ │ │ -00018020: 0a09 097d 0a0a 0909 2f2f 2066 616c 6c20 ...}....// fall │ │ │ -00018030: 6261 636b 2074 6f20 6d61 6b69 6e67 2061 back to making a │ │ │ -00018040: 2063 6f70 790a 0a23 656e 6469 660a 0a09 copy..#endif... │ │ │ -00018050: 092f 2f20 6966 2077 6520 6765 7420 6865 .// if we get he │ │ │ -00018060: 7265 2c20 7765 2073 686f 756c 6420 636f re, we should co │ │ │ -00018070: 7079 2074 6865 2066 696c 650a 0909 7374 py the file...st │ │ │ -00018080: 6f72 6167 655f 6572 726f 7220 7365 3b0a orage_error se;. │ │ │ -00018090: 0909 6175 783a 3a63 6f70 795f 6669 6c65 ..aux::copy_file │ │ │ -000180a0: 2866 696c 652c 206c 696e 6b2c 2073 6529 (file, link, se) │ │ │ -000180b0: 3b0a 0909 6563 203d 2073 652e 6563 3b0a ;...ec = se.ec;. │ │ │ -000180c0: 097d 0a0a 0962 6f6f 6c20 6973 5f64 6972 .}...bool is_dir │ │ │ -000180d0: 6563 746f 7279 2873 7464 3a3a 7374 7269 ectory(std::stri │ │ │ -000180e0: 6e67 2063 6f6e 7374 2661 6d70 3b20 662c ng const& f, │ │ │ -000180f0: 2065 7272 6f72 5f63 6f64 6526 616d 703b error_code& │ │ │ -00018100: 2065 6329 0a09 7b0a 0909 6563 2e63 6c65 ec)..{...ec.cle │ │ │ -00018110: 6172 2829 3b0a 0909 6572 726f 725f 636f ar();...error_co │ │ │ -00018120: 6465 2065 3b0a 0909 6669 6c65 5f73 7461 de e;...file_sta │ │ │ -00018130: 7475 7320 733b 0a09 0973 7461 745f 6669 tus s;...stat_fi │ │ │ -00018140: 6c65 2866 2c20 2661 6d70 3b73 2c20 6529 le(f, &s, e) │ │ │ -00018150: 3b0a 0909 6966 2028 2165 2026 616d 703b ;...if (!e & │ │ │ -00018160: 2661 6d70 3b20 732e 6d6f 6465 2026 616d & s.mode &am │ │ │ -00018170: 703b 2066 696c 655f 7374 6174 7573 3a3a p; file_status:: │ │ │ -00018180: 6469 7265 6374 6f72 7929 2072 6574 7572 directory) retur │ │ │ -00018190: 6e20 7472 7565 3b0a 0909 6563 203d 2065 n true;...ec = e │ │ │ -000181a0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ -000181d0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000181e0: 703b 323c 2f74 643e 3c74 643e 3c61 2068 p;2../s │ │ │ -00018210: 7263 2f61 6c65 7274 5f6d 616e 6167 6572 rc/alert_manager │ │ │ -00018220: 2e63 7070 3a35 323c 2f61 3e3c 2f74 643e .cpp:52 │ │ │ -00018230: 3c74 643e 6b65 6570 2061 2063 6f75 6e74 keep a count │ │ │ -00018240: 206f 6620 7468 6520 6e75 6d62 6572 206f of the number o │ │ │ -00018250: 6620 7468 7265 6164 7320 7761 6974 696e f threads waitin │ │ │ -00018260: 672e 204f 6e6c 7920 6966 2069 7427 7320 g. Only if it's │ │ │ -00018270: 3e20 3020 6e6f 7469 6679 2074 6865 6d3c > 0 notify them< │ │ │ -00018280: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    keep │ │ │ -000182d0: 2061 2063 6f75 6e74 206f 6620 7468 6520 a count of the │ │ │ -000182e0: 6e75 6d62 6572 206f 6620 7468 7265 6164 number of thread │ │ │ -000182f0: 7320 7761 6974 696e 672e 204f 6e6c 7920 s waiting. Only │ │ │ -00018300: 6966 2069 7427 730a 3e20 3020 6e6f 7469 if it's.> 0 noti │ │ │ -00018310: 6679 2074 6865 6d3c 2f68 323e 3c68 343e fy them

    │ │ │ -00018320: 2e2e 2f73 7263 2f61 6c65 7274 5f6d 616e ../src/alert_man │ │ │ -00018330: 6167 6572 2e63 7070 3a35 323c 2f68 343e ager.cpp:52

    │ │ │ -00018340: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .{...s
    │ │ │ -00018380: 7464 3a3a 756e 6971 7565 5f6c 6f63 6b26  td::unique_lock&
    │ │ │ -00018390: 6c74 3b73 7464 3a3a 7265 6375 7273 6976  lt;std::recursiv
    │ │ │ -000183a0: 655f 6d75 7465 7826 6774 3b20 6c6f 636b  e_mutex> lock
    │ │ │ -000183b0: 286d 5f6d 7574 6578 293b 0a0a 0909 6966  (m_mutex);....if
    │ │ │ -000183c0: 2028 216d 5f61 6c65 7274 735b 6d5f 6765   (!m_alerts[m_ge
    │ │ │ -000183d0: 6e65 7261 7469 6f6e 2026 616d 703b 2031  neration & 1
    │ │ │ -000183e0: 5d2e 656d 7074 7928 2929 2072 6574 7572  ].empty()) retur
    │ │ │ -000183f0: 6e20 7472 7565 3b0a 0a09 092f 2f20 7468  n true;....// th
    │ │ │ -00018400: 6973 2063 616c 6c20 6361 6e20 6265 2069  is call can be i
    │ │ │ -00018410: 6e74 6572 7275 7074 6564 2070 7265 6d61  nterrupted prema
    │ │ │ -00018420: 7475 7265 6c79 2062 7920 6f74 6865 7220  turely by other 
    │ │ │ -00018430: 7369 676e 616c 730a 0909 6d5f 636f 6e64  signals...m_cond
    │ │ │ -00018440: 6974 696f 6e2e 7761 6974 5f66 6f72 286c  ition.wait_for(l
    │ │ │ -00018450: 6f63 6b2c 206d 6178 5f77 6169 7429 3b0a  ock, max_wait);.
    │ │ │ -00018460: 0909 7265 7475 726e 2021 6d5f 616c 6572  ..return !m_aler
    │ │ │ -00018470: 7473 5b6d 5f67 656e 6572 6174 696f 6e20  ts[m_generation 
    │ │ │ -00018480: 2661 6d70 3b20 315d 2e65 6d70 7479 2829  & 1].empty()
    │ │ │ -00018490: 3b0a 097d 0a0a 0976 6f69 6420 616c 6572  ;..}...void aler
    │ │ │ -000184a0: 745f 6d61 6e61 6765 723a 3a6d 6179 6265  t_manager::maybe
    │ │ │ -000184b0: 5f6e 6f74 6966 7928 616c 6572 742a 2061  _notify(alert* a
    │ │ │ -000184c0: 290a 097b 0a09 0969 6620 286d 5f61 6c65  )..{...if (m_ale
    │ │ │ -000184d0: 7274 735b 6d5f 6765 6e65 7261 7469 6f6e  rts[m_generation
    │ │ │ -000184e0: 2026 616d 703b 2031 5d2e 7369 7a65 2829   & 1].size()
    │ │ │ -000184f0: 203d 3d20 3129 0a09 097b 0a09 0909 2f2f   == 1)...{....//
    │ │ │ -00018500: 2077 6520 6a75 7374 2070 6f73 7465 6420   we just posted 
    │ │ │ -00018510: 746f 2061 6e20 656d 7074 7920 7175 6575  to an empty queu
    │ │ │ -00018520: 652e 2049 6620 616e 796f 6e65 2069 7320  e. If anyone is 
    │ │ │ -00018530: 7761 6974 696e 6720 666f 720a 0909 092f  waiting for..../
    │ │ │ -00018540: 2f20 616c 6572 7473 2c20 7765 206e 6565  / alerts, we nee
    │ │ │ -00018550: 6420 746f 206e 6f74 6966 7920 7468 656d  d to notify them
    │ │ │ -00018560: 2e20 416c 736f 2028 706f 7465 6e74 6961  . Also (potentia
    │ │ │ -00018570: 6c6c 7929 2063 616c 6c20 7468 650a 0909  lly) call the...
    │ │ │ -00018580: 092f 2f20 7573 6572 2073 7570 706c 6965  .// user supplie
    │ │ │ -00018590: 6420 6d5f 6e6f 7469 6679 2063 616c 6c62  d m_notify callb
    │ │ │ -000185a0: 6163 6b20 746f 206c 6574 2074 6865 2063  ack to let the c
    │ │ │ -000185b0: 6c69 656e 7420 7761 6b65 2075 7020 6974  lient wake up it
    │ │ │ -000185c0: 730a 0909 092f 2f20 6d65 7373 6167 6520  s....// message 
    │ │ │ -000185d0: 6c6f 6f70 2074 6f20 706f 6c6c 2066 6f72  loop to poll for
    │ │ │ -000185e0: 2061 6c65 7274 732e 0a09 0909 6966 2028   alerts.....if (
    │ │ │ -000185f0: 6d5f 6e6f 7469 6679 2920 6d5f 6e6f 7469  m_notify) m_noti
    │ │ │ -00018600: 6679 2829 3b0a 0a3c 6469 7620 7374 796c  fy();..
    ...m_condit │ │ │ -00018640: 696f 6e2e 6e6f 7469 6679 5f61 6c6c 2829 ion.notify_all() │ │ │ -00018650: 3b0a 3c2f 6469 763e 0909 7d0a 0a23 6966 ;.
    ..}..#if │ │ │ -00018660: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -00018670: 4142 4c45 5f45 5854 454e 5349 4f4e 530a ABLE_EXTENSIONS. │ │ │ -00018680: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ -00018690: 2065 203a 206d 5f73 6573 5f65 7874 656e e : m_ses_exten │ │ │ -000186a0: 7369 6f6e 7329 0a09 0909 652d 2667 743b sions)....e-> │ │ │ -000186b0: 6f6e 5f61 6c65 7274 2861 293b 0a23 656c on_alert(a);.#el │ │ │ -000186c0: 7365 0a09 0954 4f52 5245 4e54 5f55 4e55 se...TORRENT_UNU │ │ │ -000186d0: 5345 4428 6129 3b0a 2365 6e64 6966 0a09 SED(a);.#endif.. │ │ │ -000186e0: 7d0a 0a09 766f 6964 2061 6c65 7274 5f6d }...void alert_m │ │ │ -000186f0: 616e 6167 6572 3a3a 7365 745f 6e6f 7469 anager::set_noti │ │ │ -00018700: 6679 5f66 756e 6374 696f 6e28 7374 643a fy_function(std: │ │ │ -00018710: 3a66 756e 6374 696f 6e26 6c74 3b76 6f69 :function<voi │ │ │ -00018720: 6428 2926 6774 3b20 636f 6e73 7426 616d d()> const&am │ │ │ -00018730: 703b 2066 756e 290a 097b 0a09 0973 7464 p; fun)..{...std │ │ │ -00018740: 3a3a 756e 6971 7565 5f6c 6f63 6b26 6c74 ::unique_lock< │ │ │ -00018750: 3b73 7464 3a3a 7265 6375 7273 6976 655f ;std::recursive_ │ │ │ -00018760: 6d75 7465 7826 6774 3b20 6c6f 636b 286d mutex> lock(m │ │ │ -00018770: 5f6d 7574 6578 293b 0a09 096d 5f6e 6f74 _mutex);...m_not │ │ │ -00018780: 6966 7920 3d20 6675 6e3b 0a09 0969 6620 ify = fun;...if │ │ │ -00018790: 2821 6d5f 616c 6572 7473 5b6d 5f67 656e (!m_alerts[m_gen │ │ │ -000187a0: 6572 6174 696f 6e20 2661 6d70 3b20 315d eration & 1] │ │ │ -000187b0: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ -000187c0: 0969 6620 286d 5f6e 6f74 6966 7929 206d .if (m_notify) m │ │ │ -000187d0: 5f6e 6f74 6966 7928 293b 0a09 097d 0a09 _notify();...}.. │ │ │ -000187e0: 7d0a 0a23 6966 6e64 6566 2054 4f52 5245 }..#ifndef TORRE │ │ │ -000187f0: 4e54 5f44 4953 4142 4c45 5f45 5854 454e NT_DISABLE_EXTEN │ │ │ -00018800: 5349 4f4e 530a 0976 6f69 6420 616c 6572 SIONS..void aler │ │ │ -00018810: 745f 6d61 6e61 6765 723a 3a61 6464 5f65 t_manager::add_e │ │ │ -00018820: 7874 656e 7369 6f6e 2873 7464 3a3a 7368 xtension(std::sh │ │ │ -00018830: 6172 6564 5f70 7472 266c 743b 706c 7567 ared_ptr<plug │ │ │ -00018840: 696e 2667 743b 2065 7874 290a 097b 0a09 in> ext)..{.. │ │ │ -00018850: 096d 5f73 6573 5f65 7874 656e 7369 6f6e .m_ses_extension │ │ │ -00018860: 732e 7075 7368 5f62 6163 6b28 7374 643a s.push_back(std: │ │ │ -00018870: 3a6d 6f76 6528 6578 7429 293b 0a09 7d0a :move(ext));..}. │ │ │ -00018880: 2365 6e64 6966 0a0a 0976 6f69 6420 616c #endif...void al │ │ │ -00018890: 6572 745f 6d61 6e61 6765 723a 3a67 6574 ert_manager::get │ │ │ -000188a0: 5f61 6c6c 2873 7464 3a3a 7665 6374 6f72 _all(std::vector │ │ │ -000188b0: 266c 743b 616c 6572 742a 2667 743b 2661 <alert*>&a │ │ │ -000188c0: 6d70 3b20 616c 6572 7473 290a 097b 0a09 mp; alerts)..{.. │ │ │ -000188d0: 0973 7464 3a3a 6c6f 636b 5f67 7561 7264 .std::lock_guard │ │ │ -000188e0: 266c 743b 7374 643a 3a72 6563 7572 7369 <std::recursi │ │ │ -000188f0: 7665 5f6d 7574 6578 2667 743b 206c 6f63 ve_mutex> loc │ │ │ -00018900: 6b28 6d5f 6d75 7465 7829 3b0a 3c2f 7072 k(m_mutex);.rel │ │ │ -00018940: 6576 616e 6365 266e 6273 703b 323c 2f74 evance 2../src/ins │ │ │ -00018980: 7461 6e74 6961 7465 5f63 6f6e 6e65 6374 tantiate_connect │ │ │ -00018990: 696f 6e2e 6370 703a 3231 3c2f 613e 3c2f ion.cpp:21peer_conn │ │ │ -000189b0: 6563 7469 6f6e 2061 6e64 2074 7261 636b ection and track │ │ │ -000189c0: 6572 5f63 6f6e 6e65 6374 696f 6e20 7368 er_connection sh │ │ │ -000189d0: 6f75 6c64 2070 726f 6261 626c 7920 6265 ould probably be │ │ │ -000189e0: 2066 6c61 6773 3c2f 7464 3e3c 2f74 723e flags │ │ │ -000189f0: 3c74 7220 6964 3d22 3439 2220 7374 796c < │ │ │ -00018a20: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00018a30: 6832 3e70 6565 725f 636f 6e6e 6563 7469 h2>peer_connecti │ │ │ -00018a40: 6f6e 2061 6e64 2074 7261 636b 6572 5f63 on and tracker_c │ │ │ -00018a50: 6f6e 6e65 6374 696f 6e20 7368 6f75 6c64 onnection should │ │ │ -00018a60: 2070 726f 6261 626c 7920 6265 2066 6c61 probably be fla │ │ │ -00018a70: 6773 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 gs

    ../sr │ │ │ -00018a80: 632f 696e 7374 616e 7469 6174 655f 636f c/instantiate_co │ │ │ -00018a90: 6e6e 6563 7469 6f6e 2e63 7070 3a32 313c nnection.cpp:21< │ │ │ -00018aa0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    /*
    │ │ │ -00018ae0: 0a0a 436f 7079 7269 6768 7420 2863 2920  ..Copyright (c) 
    │ │ │ -00018af0: 3230 3037 2c20 3230 3130 2d32 3031 312c  2007, 2010-2011,
    │ │ │ -00018b00: 2032 3031 342d 3230 3231 2c20 4172 7669   2014-2021, Arvi
    │ │ │ -00018b10: 6420 4e6f 7262 6572 670a 436f 7079 7269  d Norberg.Copyri
    │ │ │ -00018b20: 6768 7420 2863 2920 3230 3138 2c20 3230  ght (c) 2018, 20
    │ │ │ -00018b30: 3231 2c20 416c 6465 6e20 546f 7272 6573  21, Alden Torres
    │ │ │ -00018b40: 0a43 6f70 7972 6967 6874 2028 6329 2032  .Copyright (c) 2
    │ │ │ -00018b50: 3032 302c 2050 6175 6c2d 4c6f 7569 7320  020, Paul-Louis 
    │ │ │ -00018b60: 4167 656e 6561 750a 416c 6c20 7269 6768  Ageneau.All righ
    │ │ │ -00018b70: 7473 2072 6573 6572 7665 642e 0a0a 596f  ts reserved...Yo
    │ │ │ -00018b80: 7520 6d61 7920 7573 652c 2064 6973 7472  u may use, distr
    │ │ │ -00018b90: 6962 7574 6520 616e 6420 6d6f 6469 6679  ibute and modify
    │ │ │ -00018ba0: 2074 6869 7320 636f 6465 2075 6e64 6572   this code under
    │ │ │ -00018bb0: 2074 6865 2074 6572 6d73 206f 6620 7468   the terms of th
    │ │ │ -00018bc0: 6520 4253 4420 6c69 6365 6e73 652c 0a73  e BSD license,.s
    │ │ │ -00018bd0: 6565 204c 4943 454e 5345 2066 696c 652e  ee LICENSE file.
    │ │ │ -00018be0: 0a2a 2f0a 0a23 696e 636c 7564 6520 226c  .*/..#include "l
    │ │ │ -00018bf0: 6962 746f 7272 656e 742f 736f 636b 6574  ibtorrent/socket
    │ │ │ -00018c00: 2e68 7070 220a 2369 6e63 6c75 6465 2022  .hpp".#include "
    │ │ │ -00018c10: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f  libtorrent/aux_/
    │ │ │ -00018c20: 736f 636b 6574 5f74 7970 652e 6870 7022  socket_type.hpp"
    │ │ │ -00018c30: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ -00018c40: 7272 656e 742f 6175 785f 2f75 7470 5f73  rrent/aux_/utp_s
    │ │ │ -00018c50: 6f63 6b65 745f 6d61 6e61 6765 722e 6870  ocket_manager.hp
    │ │ │ -00018c60: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ -00018c70: 746f 7272 656e 742f 6175 785f 2f69 6e73  torrent/aux_/ins
    │ │ │ -00018c80: 7461 6e74 6961 7465 5f63 6f6e 6e65 6374  tantiate_connect
    │ │ │ -00018c90: 696f 6e2e 6870 7022 0a23 696e 636c 7564  ion.hpp".#includ
    │ │ │ -00018ca0: 6520 226c 6962 746f 7272 656e 742f 6175  e "libtorrent/au
    │ │ │ -00018cb0: 785f 2f75 7470 5f73 7472 6561 6d2e 6870  x_/utp_stream.hp
    │ │ │ -00018cc0: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ -00018cd0: 746f 7272 656e 742f 6175 785f 2f73 736c  torrent/aux_/ssl
    │ │ │ -00018ce0: 5f73 7472 6561 6d2e 6870 7022 0a0a 6e61  _stream.hpp"..na
    │ │ │ -00018cf0: 6d65 7370 6163 6520 6c69 6274 6f72 7265  mespace libtorre
    │ │ │ -00018d00: 6e74 3a3a 6175 7820 7b0a 0a3c 6469 7620  nt::aux {..
    .aux::s │ │ │ -00018d40: 6f63 6b65 745f 7479 7065 2069 6e73 7461 ocket_type insta │ │ │ -00018d50: 6e74 6961 7465 5f63 6f6e 6e65 6374 696f ntiate_connectio │ │ │ -00018d60: 6e28 696f 5f63 6f6e 7465 7874 2661 6d70 n(io_context& │ │ │ -00018d70: 3b20 696f 730a 3c2f 6469 763e 0909 2c20 ; ios.
    .., │ │ │ -00018d80: 6175 783a 3a70 726f 7879 5f73 6574 7469 aux::proxy_setti │ │ │ -00018d90: 6e67 7320 636f 6e73 7426 616d 703b 2070 ngs const& p │ │ │ -00018da0: 730a 0909 2c20 766f 6964 2a20 7373 6c5f s..., void* ssl_ │ │ │ -00018db0: 636f 6e74 6578 740a 0909 2c20 7574 705f context..., utp_ │ │ │ -00018dc0: 736f 636b 6574 5f6d 616e 6167 6572 2a20 socket_manager* │ │ │ -00018dd0: 736d 0a09 092c 2062 6f6f 6c20 7065 6572 sm..., bool peer │ │ │ -00018de0: 5f63 6f6e 6e65 6374 696f 6e0a 0909 2c20 _connection..., │ │ │ -00018df0: 626f 6f6c 2074 7261 636b 6572 5f63 6f6e bool tracker_con │ │ │ -00018e00: 6e65 6374 696f 6e29 0a09 7b0a 2369 6620 nection)..{.#if │ │ │ -00018e10: 2154 4f52 5245 4e54 5f55 5345 5f53 534c !TORRENT_USE_SSL │ │ │ -00018e20: 0a09 0954 4f52 5245 4e54 5f55 4e55 5345 ...TORRENT_UNUSE │ │ │ -00018e30: 4428 7373 6c5f 636f 6e74 6578 7429 3b0a D(ssl_context);. │ │ │ -00018e40: 2365 6e64 6966 0a0a 0909 6966 2028 736d #endif....if (sm │ │ │ -00018e50: 290a 0909 7b0a 2369 6620 544f 5252 454e )...{.#if TORREN │ │ │ -00018e60: 545f 5553 455f 5353 4c0a 0909 0969 6620 T_USE_SSL....if │ │ │ -00018e70: 2873 736c 5f63 6f6e 7465 7874 290a 0909 (ssl_context)... │ │ │ -00018e80: 097b 0a09 0909 0973 736c 5f73 7472 6561 .{.....ssl_strea │ │ │ -00018e90: 6d26 6c74 3b75 7470 5f73 7472 6561 6d26 m<utp_stream& │ │ │ -00018ea0: 6774 3b20 7328 696f 732c 202a 7374 6174 gt; s(ios, *stat │ │ │ -00018eb0: 6963 5f63 6173 7426 6c74 3b73 736c 3a3a ic_cast<ssl:: │ │ │ -00018ec0: 636f 6e74 6578 742a 2667 743b 2873 736c context*>(ssl │ │ │ -00018ed0: 5f63 6f6e 7465 7874 2929 3b0a 0909 0909 _context));..... │ │ │ -00018ee0: 732e 6e65 7874 5f6c 6179 6572 2829 2e73 s.next_layer().s │ │ │ -00018ef0: 6574 5f69 6d70 6c28 736d 2d26 6774 3b6e et_impl(sm->n │ │ │ -00018f00: 6577 5f75 7470 5f73 6f63 6b65 7428 2661 ew_utp_socket(&a │ │ │ -00018f10: 6d70 3b73 2e6e 6578 745f 6c61 7965 7228 mp;s.next_layer( │ │ │ -00018f20: 2929 293b 0a09 0909 0972 6574 7572 6e20 )));.....return │ │ │ -00018f30: 736f 636b 6574 5f74 7970 6528 7374 643a socket_type(std: │ │ │ -00018f40: 3a6d 6f76 6528 7329 293b 0a09 0909 7d0a :move(s));....}. │ │ │ -00018f50: 0909 0965 6c73 650a 2365 6e64 6966 0a09 ...else.#endif.. │ │ │ -00018f60: 0909 7b0a 0909 0909 7574 705f 7374 7265 ..{.....utp_stre │ │ │ -00018f70: 616d 2073 2869 6f73 293b 0a09 0909 0973 am s(ios);.....s │ │ │ -00018f80: 2e73 6574 5f69 6d70 6c28 736d 2d26 6774 .set_impl(sm-> │ │ │ -00018f90: 3b6e 6577 5f75 7470 5f73 6f63 6b65 7428 ;new_utp_socket( │ │ │ -00018fa0: 2661 6d70 3b73 2929 3b0a 0909 0909 7265 &s));.....re │ │ │ -00018fb0: 7475 726e 2073 6f63 6b65 745f 7479 7065 turn socket_type │ │ │ -00018fc0: 2873 7464 3a3a 6d6f 7665 2873 2929 3b0a (std::move(s));. │ │ │ -00018fd0: 0909 097d 0a09 097d 0a23 6966 2054 4f52 ...}...}.#if TOR │ │ │ -00018fe0: 5245 4e54 5f55 5345 5f49 3250 0a09 0965 RENT_USE_I2P...e │ │ │ -00018ff0: 6c73 6520 6966 2028 7073 2e74 7970 6520 lse if (ps.type │ │ │ -00019000: 3d3d 2073 6574 7469 6e67 735f 7061 636b == settings_pack │ │ │ -00019010: 3a3a 6932 705f 7072 6f78 7929 0a09 097b ::i2p_proxy)...{ │ │ │ -00019020: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00019060: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../sr │ │ │ -00019090: 632f 7765 625f 7065 6572 5f63 6f6e 6e65 c/web_peer_conne │ │ │ -000190a0: 6374 696f 6e2e 6370 703a 3631 323c 2f61 ction.cpp:612just m │ │ │ -000190c0: 616b 6520 7468 6973 2070 6565 7220 6e6f ake this peer no │ │ │ -000190d0: 7420 6861 7665 2074 6865 2070 6965 6365 t have the piece │ │ │ -000190e0: 7320 6173 736f 6369 6174 6564 2077 6974 s associated wit │ │ │ -000190f0: 6820 7468 6520 6669 6c65 2077 6520 6a75 h the file we ju │ │ │ -00019100: 7374 2072 6571 7565 7374 6564 2e20 4f6e st requested. On │ │ │ -00019110: 6c79 2077 6865 6e20 6974 2064 6f65 736e ly when it doesn │ │ │ -00019120: 2774 2068 6176 6520 616e 7920 6f66 2074 't have any of t │ │ │ -00019130: 6865 2066 696c 6520 646f 2074 6865 2066 he file do the f │ │ │ -00019140: 6f6c 6c6f 7769 6e67 2070 6164 2066 696c ollowing pad fil │ │ │ -00019150: 6573 2077 696c 6c20 6d61 6b65 2069 7420 es will make it │ │ │ -00019160: 636f 6d70 6c69 6361 7465 643c 2f74 643e complicated │ │ │ -00019170: 3c2f 7472 3e3c 7472 2069 643d 2235 3022

    just mak │ │ │ -000191c0: 6520 7468 6973 2070 6565 7220 6e6f 7420 e this peer not │ │ │ -000191d0: 6861 7665 2074 6865 2070 6965 6365 730a have the pieces. │ │ │ -000191e0: 6173 736f 6369 6174 6564 2077 6974 6820 associated with │ │ │ -000191f0: 7468 6520 6669 6c65 2077 6520 6a75 7374 the file we just │ │ │ -00019200: 2072 6571 7565 7374 6564 2e20 4f6e 6c79 requested. Only │ │ │ -00019210: 0a77 6865 6e20 6974 2064 6f65 736e 2774 .when it doesn't │ │ │ -00019220: 2068 6176 6520 616e 7920 6f66 2074 6865 have any of the │ │ │ -00019230: 2066 696c 6520 646f 2074 6865 2066 6f6c file do the fol │ │ │ -00019240: 6c6f 7769 6e67 0a70 6164 2066 696c 6573 lowing.pad files │ │ │ -00019250: 2077 696c 6c20 6d61 6b65 2069 7420 636f will make it co │ │ │ -00019260: 6d70 6c69 6361 7465 643c 2f68 323e 3c68 mplicated

    ../src/web_pee │ │ │ -00019280: 725f 636f 6e6e 6563 7469 6f6e 2e63 7070 r_connection.cpp │ │ │ -00019290: 3a36 3132 3c2f 6834 3e3c 7072 6520 7374 :612

    ..peer_connec
    │ │ │ -000192e0: 7469 6f6e 3a3a 7265 6365 6976 6564 5f69  tion::received_i
    │ │ │ -000192f0: 6e76 616c 6964 5f64 6174 6128 696e 6465  nvalid_data(inde
    │ │ │ -00019300: 782c 2073 696e 676c 655f 7065 6572 293b  x, single_peer);
    │ │ │ -00019310: 0a0a 092f 2f20 6966 2077 6520 646f 6e27  ...// if we don'
    │ │ │ -00019320: 7420 7468 696e 6b20 7765 2068 6176 6520  t think we have 
    │ │ │ -00019330: 616e 7920 6f66 2074 6865 2066 696c 6573  any of the files
    │ │ │ -00019340: 2c20 616c 6c6f 7720 6261 6e6e 696e 6720  , allow banning 
    │ │ │ -00019350: 7468 6520 7765 6220 7365 6564 0a09 6966  the web seed..if
    │ │ │ -00019360: 2028 6e75 6d5f 6861 7665 5f70 6965 6365   (num_have_piece
    │ │ │ -00019370: 7328 2920 3d3d 2030 2920 7265 7475 726e  s() == 0) return
    │ │ │ -00019380: 2074 7275 653b 0a0a 092f 2f20 646f 6e27   true;...// don'
    │ │ │ -00019390: 7420 6469 7363 6f6e 6e65 6374 2c20 7765  t disconnect, we
    │ │ │ -000193a0: 2077 6f6e 2774 2072 6571 7565 7374 2061   won't request a
    │ │ │ -000193b0: 6e79 7468 696e 6720 6672 6f6d 2074 6869  nything from thi
    │ │ │ -000193c0: 7320 6669 6c65 2061 6761 696e 0a09 7265  s file again..re
    │ │ │ -000193d0: 7475 726e 2066 616c 7365 3b0a 7d0a 0a76  turn false;.}..v
    │ │ │ -000193e0: 6f69 6420 7765 625f 7065 6572 5f63 6f6e  oid web_peer_con
    │ │ │ -000193f0: 6e65 6374 696f 6e3a 3a6f 6e5f 7265 6365  nection::on_rece
    │ │ │ -00019400: 6976 655f 7061 6466 696c 6528 290a 7b0a  ive_padfile().{.
    │ │ │ -00019410: 0968 616e 646c 655f 7061 6466 696c 6528  .handle_padfile(
    │ │ │ -00019420: 293b 0a7d 0a0a 766f 6964 2077 6562 5f70  );.}..void web_p
    │ │ │ -00019430: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ -00019440: 6861 6e64 6c65 5f65 7272 6f72 2869 6e74  handle_error(int
    │ │ │ -00019450: 2063 6f6e 7374 2062 7974 6573 5f6c 6566   const bytes_lef
    │ │ │ -00019460: 7429 0a7b 0a09 6175 746f 2074 203d 2061  t).{..auto t = a
    │ │ │ -00019470: 7373 6f63 6961 7465 645f 746f 7272 656e  ssociated_torren
    │ │ │ -00019480: 7428 292e 6c6f 636b 2829 3b0a 0954 4f52  t().lock();..TOR
    │ │ │ -00019490: 5245 4e54 5f41 5353 4552 5428 7429 3b0a  RENT_ASSERT(t);.
    │ │ │ -000194a0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -000194d0: 3c2f 6469 763e 092f 2f20 7465 6d70 6f72
    .// tempor │ │ │ -000194e0: 6172 696c 7920 756e 6176 6169 6c61 626c arily unavailabl │ │ │ -000194f0: 652c 2072 6574 7279 206c 6174 6572 0a09 e, retry later.. │ │ │ -00019500: 742d 2667 743b 7265 7472 795f 7765 625f t->retry_web_ │ │ │ -00019510: 7365 6564 2874 6869 732c 206d 5f70 6172 seed(this, m_par │ │ │ -00019520: 7365 722e 6865 6164 6572 5f64 7572 6174 ser.header_durat │ │ │ -00019530: 696f 6e28 2272 6574 7279 2d61 6674 6572 ion("retry-after │ │ │ -00019540: 2229 293b 0a09 6966 2028 742d 2667 743b "));..if (t-> │ │ │ -00019550: 616c 6572 7473 2829 2e73 686f 756c 645f alerts().should_ │ │ │ -00019560: 706f 7374 266c 743b 7572 6c5f 7365 6564 post<url_seed │ │ │ -00019570: 5f61 6c65 7274 2667 743b 2829 290a 097b _alert>())..{ │ │ │ -00019580: 0a09 0973 7464 3a3a 7374 7269 6e67 2063 ...std::string c │ │ │ -00019590: 6f6e 7374 2065 7272 6f72 5f6d 7367 203d onst error_msg = │ │ │ -000195a0: 2074 6f5f 7374 7269 6e67 286d 5f70 6172 to_string(m_par │ │ │ -000195b0: 7365 722e 7374 6174 7573 5f63 6f64 6528 ser.status_code( │ │ │ -000195c0: 2929 2e64 6174 6128 290a 0909 092b 2028 )).data()....+ ( │ │ │ -000195d0: 2220 2220 2b20 6d5f 7061 7273 6572 2e6d " " + m_parser.m │ │ │ -000195e0: 6573 7361 6765 2829 293b 0a09 0974 2d26 essage());...t-& │ │ │ -000195f0: 6774 3b61 6c65 7274 7328 292e 656d 706c gt;alerts().empl │ │ │ -00019600: 6163 655f 616c 6572 7426 6c74 3b75 726c ace_alert<url │ │ │ -00019610: 5f73 6565 645f 616c 6572 7426 6774 3b28 _seed_alert>( │ │ │ -00019620: 742d 2667 743b 6765 745f 6861 6e64 6c65 t->get_handle │ │ │ -00019630: 2829 2c20 6d5f 7572 6c0a 0909 092c 2065 (), m_url...., e │ │ │ -00019640: 7272 6f72 5f6d 7367 293b 0a09 7d0a 0972 rror_msg);..}..r │ │ │ -00019650: 6563 6569 7665 645f 6279 7465 7328 302c eceived_bytes(0, │ │ │ -00019660: 2062 7974 6573 5f6c 6566 7429 3b0a 0964 bytes_left);..d │ │ │ -00019670: 6973 636f 6e6e 6563 7428 6572 726f 725f isconnect(error_ │ │ │ -00019680: 636f 6465 286d 5f70 6172 7365 722e 7374 code(m_parser.st │ │ │ -00019690: 6174 7573 5f63 6f64 6528 292c 2068 7474 atus_code(), htt │ │ │ -000196a0: 705f 6361 7465 676f 7279 2829 292c 206f p_category()), o │ │ │ -000196b0: 7065 7261 7469 6f6e 5f74 3a3a 6269 7474 peration_t::bitt │ │ │ -000196c0: 6f72 7265 6e74 2c20 6661 696c 7572 6529 orrent, failure) │ │ │ -000196d0: 3b0a 7d0a 0a76 6f69 6420 7765 625f 7065 ;.}..void web_pe │ │ │ -000196e0: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a64 er_connection::d │ │ │ -000196f0: 6973 6162 6c65 2865 7272 6f72 5f63 6f64 isable(error_cod │ │ │ -00019700: 6520 636f 6e73 7426 616d 703b 2065 6329 e const& ec) │ │ │ -00019710: 0a7b 0a09 2f2f 2077 6520 7368 6f75 6c64 .{..// we should │ │ │ -00019720: 206e 6f74 2074 7279 2074 6869 7320 7365 not try this se │ │ │ -00019730: 7276 6572 2061 6761 696e 2e0a 096d 5f77 rver again...m_w │ │ │ -00019740: 6562 2d26 6774 3b64 6973 6162 6c65 6420 eb->disabled │ │ │ -00019750: 3d20 7472 7565 3b0a 0962 6f6f 6c20 636f = true;..bool co │ │ │ -00019760: 6e73 7420 6570 6865 6d65 7261 6c20 3d20 nst ephemeral = │ │ │ -00019770: 6d5f 7765 622d 2667 743b 6570 6865 6d65 m_web->epheme │ │ │ -00019780: 7261 6c3b 0a09 6175 783a 3a77 6562 5f73 ral;..aux::web_s │ │ │ -00019790: 6565 645f 742a 2063 6f6e 7374 2077 6562 eed_t* const web │ │ │ -000197a0: 203d 206d 5f77 6562 3b0a 0964 6973 636f = m_web;..disco │ │ │ -000197b0: 6e6e 6563 7428 6563 2c20 6f70 6572 6174 nnect(ec, operat │ │ │ -000197c0: 696f 6e5f 743a 3a62 6974 746f 7272 656e ion_t::bittorren │ │ │ -000197d0: 742c 2070 6565 725f 6572 726f 7229 3b0a t, peer_error);. │ │ │ -000197e0: 0969 6620 2865 7068 656d 6572 616c 290a .if (ephemeral). │ │ │ -000197f0: 097b 0a09 0973 7464 3a3a 7368 6172 6564 .{...std::shared │ │ │ -00019800: 5f70 7472 266c 743b 746f 7272 656e 7426 _ptr<torrent& │ │ │ -00019810: 6774 3b20 7420 3d20 6173 736f 6369 6174 gt; t = associat │ │ │ -00019820: 6564 5f74 6f72 7265 6e74 2829 2e6c 6f63 ed_torrent().loc │ │ │ -00019830: 6b28 293b 0a09 0954 4f52 5245 4e54 5f41 k();...TORRENT_A │ │ │ -00019840: 5353 4552 5428 7429 3b0a 0909 742d 2667 SSERT(t);...t-&g │ │ │ -00019850: 743b 7265 6d6f 7665 5f77 6562 5f73 6565 t;remove_web_see │ │ │ -00019860: 645f 636f 6e6e 2877 6562 293b 0a09 7d0a d_conn(web);..}. │ │ │ -00019870: 096d 5f77 6562 203d 206e 756c 6c70 7472 .m_web = nullptr │ │ │ -00019880: 3b0a 0954 4f52 5245 4e54 5f41 5353 4552 ;..TORRENT_ASSER │ │ │ -00019890: 5428 6973 5f64 6973 636f 6e6e 6563 7469 T(is_disconnecti │ │ │ -000198a0: 6e67 2829 293b 0a7d 0a0a 3c2f 7072 653e ng());.}..
    │ │ │ -000198b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -000198e0: 616e 6365 266e 6273 703b 323c 2f74 643e ance 2 │ │ │ -000198f0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/piece │ │ │ -00019920: 5f70 6963 6b65 722e 6370 703a 3139 3833 _picker.cpp:1983 │ │ │ -00019930: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 616b mak │ │ │ -00019940: 6520 7468 6520 3230 3438 206c 696d 6974 e the 2048 limit │ │ │ -00019950: 2063 6f6e 6669 6775 7261 626c 653c 2f74 configurable

    make t │ │ │ -000199b0: 6865 2032 3034 3820 6c69 6d69 7420 636f he 2048 limit co │ │ │ -000199c0: 6e66 6967 7572 6162 6c65 3c2f 6832 3e3c nfigurable

    < │ │ │ -000199d0: 6834 3e2e 2e2f 7372 632f 7069 6563 655f h4>../src/piece_ │ │ │ -000199e0: 7069 636b 6572 2e63 7070 3a31 3938 333c picker.cpp:1983< │ │ │ -000199f0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ./
    │ │ │ -00019a30: 2f20 696e 6469 6361 7469 6e67 2077 6869  / indicating whi
    │ │ │ -00019a40: 6368 2070 6174 6820 7468 6f75 6768 7420  ch path thought 
    │ │ │ -00019a50: 7468 6520 7069 636b 6572 2077 6520 746f  the picker we to
    │ │ │ -00019a60: 6f6b 2074 6f20 6172 7269 7665 2061 7420  ok to arrive at 
    │ │ │ -00019a70: 7468 650a 092f 2f20 7265 7475 726e 6564  the..// returned
    │ │ │ -00019a80: 2062 6c6f 636b 2070 6963 6b73 2e0a 0970   block picks...p
    │ │ │ -00019a90: 6963 6b65 725f 666c 6167 735f 7420 7069  icker_flags_t pi
    │ │ │ -00019aa0: 6563 655f 7069 636b 6572 3a3a 7069 636b  ece_picker::pick
    │ │ │ -00019ab0: 5f70 6965 6365 7328 7479 7065 645f 6269  _pieces(typed_bi
    │ │ │ -00019ac0: 7466 6965 6c64 266c 743b 7069 6563 655f  tfield<piece_
    │ │ │ -00019ad0: 696e 6465 785f 7426 6774 3b20 636f 6e73  index_t> cons
    │ │ │ -00019ae0: 7426 616d 703b 2070 6965 6365 730a 0909  t& pieces...
    │ │ │ -00019af0: 2c20 7374 643a 3a76 6563 746f 7226 6c74  , std::vector<
    │ │ │ -00019b00: 3b70 6965 6365 5f62 6c6f 636b 2667 743b  ;piece_block>
    │ │ │ -00019b10: 2661 6d70 3b20 696e 7465 7265 7374 696e  & interestin
    │ │ │ -00019b20: 675f 626c 6f63 6b73 2c20 696e 7420 6e75  g_blocks, int nu
    │ │ │ -00019b30: 6d5f 626c 6f63 6b73 0a09 092c 2069 6e74  m_blocks..., int
    │ │ │ -00019b40: 2070 7265 6665 725f 636f 6e74 6967 756f   prefer_contiguo
    │ │ │ -00019b50: 7573 5f62 6c6f 636b 732c 2061 7578 3a3a  us_blocks, aux::
    │ │ │ -00019b60: 746f 7272 656e 745f 7065 6572 2a20 7065  torrent_peer* pe
    │ │ │ -00019b70: 6572 0a09 092c 2070 6963 6b65 725f 6f70  er..., picker_op
    │ │ │ -00019b80: 7469 6f6e 735f 7420 6f70 7469 6f6e 732c  tions_t options,
    │ │ │ -00019b90: 2073 7464 3a3a 7665 6374 6f72 266c 743b   std::vector<
    │ │ │ -00019ba0: 7069 6563 655f 696e 6465 785f 7426 6774  piece_index_t>
    │ │ │ -00019bb0: 3b20 636f 6e73 7426 616d 703b 2073 7567  ; const& sug
    │ │ │ -00019bc0: 6765 7374 6564 5f70 6965 6365 730a 0909  gested_pieces...
    │ │ │ -00019bd0: 2c20 696e 7420 6e75 6d5f 7065 6572 730a  , int num_peers.
    │ │ │ -00019be0: 0909 2c20 636f 756e 7465 7273 2661 6d70  .., counters&
    │ │ │ -00019bf0: 3b20 7063 0a09 0929 2063 6f6e 7374 0a09  ; pc...) const..
    │ │ │ -00019c00: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ -00019c10: 5254 2870 6565 7220 3d3d 206e 756c 6c70  RT(peer == nullp
    │ │ │ -00019c20: 7472 207c 7c20 7065 6572 2d26 6774 3b69  tr || peer->i
    │ │ │ -00019c30: 6e5f 7573 6529 3b0a 0909 7069 636b 6572  n_use);...picker
    │ │ │ -00019c40: 5f66 6c61 6773 5f74 2072 6574 3b0a 0a09  _flags_t ret;...
    │ │ │ -00019c50: 092f 2f20 7072 6576 656e 7420 7468 6520  .// prevent the 
    │ │ │ -00019c60: 6e75 6d62 6572 206f 6620 7061 7274 6961  number of partia
    │ │ │ -00019c70: 6c20 7069 6563 6573 2074 6f20 6772 6f77  l pieces to grow
    │ │ │ -00019c80: 2069 6e64 6566 696e 6974 656c 790a 0909   indefinitely...
    │ │ │ -00019c90: 2f2f 206d 616b 6520 7468 6973 2073 6361  // make this sca
    │ │ │ -00019ca0: 6c65 2062 7920 7468 6520 6e75 6d62 6572  le by the number
    │ │ │ -00019cb0: 206f 6620 7065 6572 7320 7765 2068 6176   of peers we hav
    │ │ │ -00019cc0: 652e 2046 6f72 206c 6172 6765 0a09 092f  e. For large.../
    │ │ │ -00019cd0: 2f20 7363 616c 6520 636c 6965 6e74 732c  / scale clients,
    │ │ │ -00019ce0: 2077 6520 776f 756c 6420 6861 7665 206d   we would have m
    │ │ │ -00019cf0: 6f72 6520 7065 6572 732c 2061 6e64 2061  ore peers, and a
    │ │ │ -00019d00: 6c6c 6f77 2061 2068 6967 6865 720a 0909  llow a higher...
    │ │ │ -00019d10: 2f2f 2074 6872 6573 686f 6c64 2066 6f72  // threshold for
    │ │ │ -00019d20: 2074 6865 206e 756d 6265 7220 6f66 2070   the number of p
    │ │ │ -00019d30: 6172 7469 616c 730a 0909 2f2f 2074 6865  artials...// the
    │ │ │ -00019d40: 2073 6563 6f6e 6420 636f 6e64 6974 696f   second conditio
    │ │ │ -00019d50: 6e20 6973 2074 6f20 6d61 6b65 2073 7572  n is to make sur
    │ │ │ -00019d60: 6520 7765 2063 6170 2074 6865 206e 756d  e we cap the num
    │ │ │ -00019d70: 6265 7220 6f66 2070 6172 7469 616c 0a09  ber of partial..
    │ │ │ -00019d80: 092f 2f20 5f62 7974 6573 5f2e 2054 6865  .// _bytes_. The
    │ │ │ -00019d90: 206c 6172 6765 7220 7468 6520 7069 6563   larger the piec
    │ │ │ -00019da0: 6573 2061 7265 2c20 7468 6520 6665 7765  es are, the fewe
    │ │ │ -00019db0: 7220 7061 7274 6961 6c20 7069 6563 6573  r partial pieces
    │ │ │ -00019dc0: 2077 6520 7761 6e74 2e0a 0909 2f2f 2032   we want....// 2
    │ │ │ -00019dd0: 3034 3820 636f 7272 6573 706f 6e64 7320  048 corresponds 
    │ │ │ -00019de0: 746f 2033 3220 4d69 420a 3c64 6976 2073  to 32 MiB.
    ..const │ │ │ -00019e20: 696e 7420 6e75 6d5f 7061 7274 6961 6c73 int num_partials │ │ │ -00019e30: 203d 2069 6e74 286d 5f64 6f77 6e6c 6f61 = int(m_downloa │ │ │ -00019e40: 6473 5b70 6965 6365 5f70 6f73 3a3a 7069 ds[piece_pos::pi │ │ │ -00019e50: 6563 655f 646f 776e 6c6f 6164 696e 675d ece_downloading] │ │ │ -00019e60: 2e73 697a 6528 2929 3b0a 3c2f 6469 763e .size());.
    │ │ │ -00019e70: 0909 6966 2028 6e75 6d5f 7061 7274 6961 ..if (num_partia │ │ │ -00019e80: 6c73 2026 6774 3b20 6e75 6d5f 7065 6572 ls > num_peer │ │ │ -00019e90: 7320 2a20 3320 2f20 320a 0909 097c 7c20 s * 3 / 2....|| │ │ │ -00019ea0: 6e75 6d5f 7061 7274 6961 6c73 202a 2062 num_partials * b │ │ │ -00019eb0: 6c6f 636b 735f 7065 725f 7069 6563 6528 locks_per_piece( │ │ │ -00019ec0: 2920 2667 743b 2032 3034 3829 0a09 097b ) > 2048)...{ │ │ │ -00019ed0: 0a09 0909 2f2f 2069 6620 7765 2068 6176 ....// if we hav │ │ │ -00019ee0: 6520 746f 6f20 6d61 6e79 2070 6172 7469 e too many parti │ │ │ -00019ef0: 616c 2070 6965 6365 732c 2070 7269 6f72 al pieces, prior │ │ │ -00019f00: 6974 697a 6520 636f 6d70 6c65 7469 6e67 itize completing │ │ │ -00019f10: 0a09 0909 2f2f 2074 6865 6d2e 2049 6e20 ....// them. In │ │ │ -00019f20: 6f72 6465 7220 666f 7220 7468 6973 2074 order for this t │ │ │ -00019f30: 6f20 6861 7665 2061 6e20 6166 6665 6374 o have an affect │ │ │ -00019f40: 2c20 616c 736f 2064 6973 6162 6c65 0a09 , also disable.. │ │ │ -00019f50: 0909 2f2f 2070 7265 6665 7220 7768 6f6c ..// prefer whol │ │ │ -00019f60: 6520 7069 6563 6573 2028 6f74 6865 7277 e pieces (otherw │ │ │ -00019f70: 6973 6520 7061 7274 6961 6c20 7069 6563 ise partial piec │ │ │ -00019f80: 6573 2077 6f75 6c64 2062 6520 6465 2d70 es would be de-p │ │ │ -00019f90: 7269 6f72 6974 697a 6564 290a 0909 096f rioritized)....o │ │ │ -00019fa0: 7074 696f 6e73 207c 3d20 7072 696f 7269 ptions |= priori │ │ │ -00019fb0: 7469 7a65 5f70 6172 7469 616c 733b 0a09 tize_partials;.. │ │ │ -00019fc0: 0909 7072 6566 6572 5f63 6f6e 7469 6775 ..prefer_contigu │ │ │ -00019fd0: 6f75 735f 626c 6f63 6b73 203d 2030 3b0a ous_blocks = 0;. │ │ │ -00019fe0: 0a09 0909 7265 7420 7c3d 2070 6963 6b65 ....ret |= picke │ │ │ -00019ff0: 725f 6c6f 675f 616c 6572 743a 3a70 6172 r_log_alert::par │ │ │ -0001a000: 7469 616c 5f72 6174 696f 3b0a 0909 7d0a tial_ratio;...}. │ │ │ -0001a010: 0a09 0969 6620 2870 7265 6665 725f 636f ...if (prefer_co │ │ │ -0001a020: 6e74 6967 756f 7573 5f62 6c6f 636b 7329 ntiguous_blocks) │ │ │ -0001a030: 2072 6574 207c 3d20 7069 636b 6572 5f6c ret |= picker_l │ │ │ -0001a040: 6f67 5f61 6c65 7274 3a3a 7072 6566 6572 og_alert::prefer │ │ │ -0001a050: 5f63 6f6e 7469 6775 6f75 733b 0a0a 0909 _contiguous;.... │ │ │ -0001a060: 2f2f 206f 6e6c 7920 6f6e 6520 6f66 2072 // only one of r │ │ │ -0001a070: 6172 6573 745f 6669 7273 7420 616e 6420 arest_first and │ │ │ -0001a080: 7365 7175 656e 7469 616c 2063 616e 2062 sequential can b │ │ │ -0001a090: 6520 7365 742e 0a09 0954 4f52 5245 4e54 e set....TORRENT │ │ │ -0001a0a0: 5f41 5353 4552 5428 2828 6f70 7469 6f6e _ASSERT(((option │ │ │ -0001a0b0: 7320 2661 6d70 3b20 7261 7265 7374 5f66 s & rarest_f │ │ │ -0001a0c0: 6972 7374 2920 3f20 3120 3a20 3029 0a09 irst) ? 1 : 0).. │ │ │ -0001a0d0: 0909 2b20 2828 6f70 7469 6f6e 7320 2661 ..+ ((options &a │ │ │ -0001a0e0: 6d70 3b20 7365 7175 656e 7469 616c 2920 mp; sequential) │ │ │ -0001a0f0: 3f20 3120 3a20 3029 2026 6c74 3b3d 2031 ? 1 : 0) <= 1 │ │ │ -0001a100: 293b 0a23 6966 6465 6620 544f 5252 454e );.#ifdef TORREN │ │ │ -0001a110: 545f 4558 5045 4e53 4956 455f 494e 5641 T_EXPENSIVE_INVA │ │ │ -0001a120: 5249 414e 545f 4348 4543 4b53 0a09 0949 RIANT_CHECKS...I │ │ │ -0001a130: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a NVARIANT_CHECK;. │ │ │ -0001a140: 2365 6e64 6966 0a09 0954 4f52 5245 4e54 #endif...TORRENT │ │ │ -0001a150: 5f41 5353 4552 5428 6e75 6d5f 626c 6f63 _ASSERT(num_bloc │ │ │ -0001a160: 6b73 2026 6774 3b20 3029 3b0a 0909 544f ks > 0);...TO │ │ │ -0001a170: 5252 454e 545f 4153 5345 5254 2870 6965 RRENT_ASSERT(pie │ │ │ -0001a180: 6365 732e 7369 7a65 2829 203d 3d20 696e ces.size() == in │ │ │ -0001a190: 7428 6d5f 7069 6563 655f 6d61 702e 7369 t(m_piece_map.si │ │ │ -0001a1a0: 7a65 2829 2929 3b0a 0a09 0954 4f52 5245 ze()));....TORRE │ │ │ -0001a1b0: 4e54 5f41 5353 4552 5428 216d 5f70 7269 NT_ASSERT(!m_pri │ │ │ -0001a1c0: 6f72 6974 795f 626f 756e 6461 7269 6573 ority_boundaries │ │ │ -0001a1d0: 2e65 6d70 7479 2829 207c 7c20 6d5f 6469 .empty() || m_di │ │ │ -0001a1e0: 7274 7929 3b0a 0a09 092f 2f20 7468 6973 rty);....// this │ │ │ -0001a1f0: 2077 696c 6c20 6265 2066 696c 6c65 6420 will be filled │ │ │ -0001a200: 7769 7468 2062 6c6f 636b 7320 7468 6174 with blocks that │ │ │ -0001a210: 2077 6520 7368 6f75 6c64 206e 6f74 2072 we should not r │ │ │ -0001a220: 6571 7565 7374 0a09 092f 2f20 756e 6c65 equest...// unle │ │ │ -0001a230: 7373 2077 6520 6361 6e27 7420 6669 6e64 ss we can't find │ │ │ -0001a240: 206e 756d 5f62 6c6f 636b 7320 616d 6f6e num_blocks amon │ │ │ -0001a250: 6720 7468 6520 6f74 6865 7220 6f6e 6573 g the other ones │ │ │ -0001a260: 2e0a 0909 7374 643a 3a76 6563 746f 7226 ....std::vector& │ │ │ -0001a270: 6c74 3b70 6965 6365 5f62 6c6f 636b 2667 lt;piece_block&g │ │ │ -0001a280: 743b 2062 6163 6b75 705f 626c 6f63 6b73 t; backup_blocks │ │ │ -0001a290: 3b0a 0909 7374 643a 3a76 6563 746f 7226 ;...std::vector& │ │ │ -0001a2a0: 6c74 3b70 6965 6365 5f69 6e64 6578 5f74 lt;piece_index_t │ │ │ -0001a2b0: 2667 743b 2069 676e 6f72 6564 5f70 6965 > ignored_pie │ │ │ -0001a2c0: 6365 733b 0a0a 3c2f 7072 653e 3c2f 7464 ces;..
    relevance │ │ │ -0001a300: 266e 6273 703b 323c 2f74 643e 3c74 643e  2 │ │ │ -0001a310: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ -0001a330: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ -0001a340: 6b65 722e 6370 703a 3235 3735 3c2f 613e ker.cpp:2575 │ │ │ -0001a350: 3c2f 7464 3e3c 7464 3e74 6865 2066 6972 the fir │ │ │ -0001a360: 7374 5f62 6c6f 636b 2072 6574 7572 6e65 st_block returne │ │ │ -0001a370: 6420 6865 7265 2069 7320 7468 6520 6c61 d here is the la │ │ │ -0001a380: 7267 6573 7420 6672 6565 2072 616e 6765 rgest free range │ │ │ -0001a390: 2c20 6e6f 7420 7468 6520 6669 7273 742d , not the first- │ │ │ -0001a3a0: 6669 7420 7261 6e67 652c 2077 6869 6368 fit range, which │ │ │ -0001a3b0: 2077 6f75 6c64 2062 6520 6265 7474 6572 would be better │ │ │ -0001a3c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    the │ │ │ -0001a410: 2066 6972 7374 5f62 6c6f 636b 2072 6574 first_block ret │ │ │ -0001a420: 7572 6e65 6420 6865 7265 2069 7320 7468 urned here is th │ │ │ -0001a430: 6520 6c61 7267 6573 7420 6672 6565 2072 e largest free r │ │ │ -0001a440: 616e 6765 2c20 6e6f 740a 7468 6520 6669 ange, not.the fi │ │ │ -0001a450: 7273 742d 6669 7420 7261 6e67 652c 2077 rst-fit range, w │ │ │ -0001a460: 6869 6368 2077 6f75 6c64 2062 6520 6265 hich would be be │ │ │ -0001a470: 7474 6572 3c2f 6832 3e3c 6834 3e2e 2e2f tter

    ../ │ │ │ -0001a480: 7372 632f 7069 6563 655f 7069 636b 6572 src/piece_picker │ │ │ -0001a490: 2e63 7070 3a32 3537 353c 2f68 343e 3c70 .cpp:2575

    .{...for │ │ │ -0001a4e0: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ -0001a4f0: 3b20 6220 3a20 6d5f 626c 6f63 6b5f 696e ; b : m_block_in │ │ │ -0001a500: 666f 290a 0909 7b0a 0909 0954 4f52 5245 fo)...{....TORRE │ │ │ -0001a510: 4e54 5f41 5353 4552 5428 622e 7065 6572 NT_ASSERT(b.peer │ │ │ -0001a520: 203d 3d20 6e75 6c6c 7074 7220 7c7c 2073 == nullptr || s │ │ │ -0001a530: 7461 7469 635f 6361 7374 266c 743b 6175 tatic_cast<au │ │ │ -0001a540: 783a 3a74 6f72 7265 6e74 5f70 6565 722a x::torrent_peer* │ │ │ -0001a550: 2667 743b 2862 2e70 6565 7229 2d26 6774 >(b.peer)-> │ │ │ -0001a560: 3b69 6e5f 7573 6529 3b0a 0909 7d0a 097d ;in_use);...}..} │ │ │ -0001a570: 0a23 656e 6469 660a 0a09 766f 6964 2070 .#endif...void p │ │ │ -0001a580: 6965 6365 5f70 6963 6b65 723a 3a63 6c65 iece_picker::cle │ │ │ -0001a590: 6172 5f70 6565 7228 6175 783a 3a74 6f72 ar_peer(aux::tor │ │ │ -0001a5a0: 7265 6e74 5f70 6565 722a 2070 6565 7229 rent_peer* peer) │ │ │ -0001a5b0: 0a09 7b0a 0909 666f 7220 2861 7574 6f26 ..{...for (auto& │ │ │ -0001a5c0: 616d 703b 2062 203a 206d 5f62 6c6f 636b amp; b : m_block │ │ │ -0001a5d0: 5f69 6e66 6f29 0a09 097b 0a09 0909 6966 _info)...{....if │ │ │ -0001a5e0: 2028 622e 7065 6572 203d 3d20 7065 6572 (b.peer == peer │ │ │ -0001a5f0: 2920 622e 7065 6572 203d 206e 756c 6c70 ) b.peer = nullp │ │ │ -0001a600: 7472 3b0a 0909 7d0a 097d 0a0a 092f 2f20 tr;...}..}...// │ │ │ -0001a610: 7468 6520 6669 7273 7420 626f 6f6c 2069 the first bool i │ │ │ -0001a620: 7320 7472 7565 2069 6620 7468 6973 2069 s true if this i │ │ │ -0001a630: 7320 7468 6520 6f6e 6c79 2070 6565 7220 s the only peer │ │ │ -0001a640: 7468 6174 2068 6173 2072 6571 7565 7374 that has request │ │ │ -0001a650: 6564 2061 6e64 2064 6f77 6e6c 6f61 6465 ed and downloade │ │ │ -0001a660: 640a 092f 2f20 626c 6f63 6b73 2066 726f d..// blocks fro │ │ │ -0001a670: 6d20 7468 6973 2070 6965 6365 2e0a 092f m this piece.../ │ │ │ -0001a680: 2f20 7468 6520 7365 636f 6e64 2062 6f6f / the second boo │ │ │ -0001a690: 6c20 6973 2074 7275 6520 6966 2074 6869 l is true if thi │ │ │ -0001a6a0: 7320 6973 2074 6865 206f 6e6c 7920 6163 s is the only ac │ │ │ -0001a6b0: 7469 7665 2070 6565 7220 7468 6174 2069 tive peer that i │ │ │ -0001a6c0: 7320 7265 7175 6573 7469 6e67 0a09 2f2f s requesting..// │ │ │ -0001a6d0: 2061 6e64 2064 6f77 6e6c 6f61 6469 6e67 and downloading │ │ │ -0001a6e0: 2062 6c6f 636b 7320 6672 6f6d 2074 6869 blocks from thi │ │ │ -0001a6f0: 7320 7069 6563 652e 2041 6374 6976 6520 s piece. Active │ │ │ -0001a700: 6d65 616e 7320 6861 7669 6e67 2061 2063 means having a c │ │ │ -0001a710: 6f6e 6e65 6374 696f 6e2e 0a3c 6469 7620 onnection..

    .std::t │ │ │ -0001a750: 7570 6c65 266c 743b 626f 6f6c 2c20 626f uple<bool, bo │ │ │ -0001a760: 6f6c 2c20 696e 742c 2069 6e74 2667 743b ol, int, int> │ │ │ -0001a770: 2070 6965 6365 5f70 6963 6b65 723a 3a72 piece_picker::r │ │ │ -0001a780: 6571 7565 7374 6564 5f66 726f 6d28 0a3c equested_from(.< │ │ │ -0001a790: 2f64 6976 3e09 0970 6965 6365 5f70 6963 /div>..piece_pic │ │ │ -0001a7a0: 6b65 723a 3a64 6f77 6e6c 6f61 6469 6e67 ker::downloading │ │ │ -0001a7b0: 5f70 6965 6365 2063 6f6e 7374 2661 6d70 _piece const& │ │ │ -0001a7c0: 3b20 700a 0909 2c20 696e 7420 636f 6e73 ; p..., int cons │ │ │ -0001a7d0: 7420 6e75 6d5f 626c 6f63 6b73 5f69 6e5f t num_blocks_in_ │ │ │ -0001a7e0: 7069 6563 652c 2061 7578 3a3a 746f 7272 piece, aux::torr │ │ │ -0001a7f0: 656e 745f 7065 6572 2a20 7065 6572 2920 ent_peer* peer) │ │ │ -0001a800: 636f 6e73 740a 097b 0a09 0962 6f6f 6c20 const..{...bool │ │ │ -0001a810: 6578 636c 7573 6976 6520 3d20 7472 7565 exclusive = true │ │ │ -0001a820: 3b0a 0909 626f 6f6c 2065 7863 6c75 7369 ;...bool exclusi │ │ │ -0001a830: 7665 5f61 6374 6976 6520 3d20 7472 7565 ve_active = true │ │ │ -0001a840: 3b0a 0909 696e 7420 636f 6e74 6967 756f ;...int contiguo │ │ │ -0001a850: 7573 5f62 6c6f 636b 7320 3d20 303b 0a09 us_blocks = 0;.. │ │ │ -0001a860: 0969 6e74 206d 6178 5f63 6f6e 7469 6775 .int max_contigu │ │ │ -0001a870: 6f75 7320 3d20 303b 0a09 0969 6e74 2066 ous = 0;...int f │ │ │ -0001a880: 6972 7374 5f62 6c6f 636b 203d 2030 3b0a irst_block = 0;. │ │ │ -0001a890: 0909 696e 7420 6964 7820 3d20 2d31 3b0a ..int idx = -1;. │ │ │ -0001a8a0: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -0001a8b0: 7426 616d 703b 2069 6e66 6f20 3a20 626c t& info : bl │ │ │ -0001a8c0: 6f63 6b73 5f66 6f72 5f70 6965 6365 2870 ocks_for_piece(p │ │ │ -0001a8d0: 2929 0a09 097b 0a09 0909 2b2b 6964 783b ))...{....++idx; │ │ │ -0001a8e0: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -0001a8f0: 5254 2869 6e66 6f2e 7065 6572 203d 3d20 RT(info.peer == │ │ │ -0001a900: 6e75 6c6c 7074 7220 7c7c 2069 6e66 6f2e nullptr || info. │ │ │ -0001a910: 7065 6572 2d26 6774 3b69 6e5f 7573 6529 peer->in_use) │ │ │ -0001a920: 3b0a 0909 0954 4f52 5245 4e54 5f41 5353 ;....TORRENT_ASS │ │ │ -0001a930: 4552 5428 696e 666f 2e70 6965 6365 5f69 ERT(info.piece_i │ │ │ -0001a940: 6e64 6578 203d 3d20 702e 696e 6465 7829 ndex == p.index) │ │ │ -0001a950: 3b0a 0909 0969 6620 2869 6e66 6f2e 7374 ;....if (info.st │ │ │ -0001a960: 6174 6520 3d3d 2070 6965 6365 5f70 6963 ate == piece_pic │ │ │ -0001a970: 6b65 723a 3a62 6c6f 636b 5f69 6e66 6f3a ker::block_info: │ │ │ -0001a980: 3a73 7461 7465 5f6e 6f6e 6529 0a09 0909 :state_none).... │ │ │ -0001a990: 7b0a 0909 0909 2b2b 636f 6e74 6967 756f {.....++contiguo │ │ │ -0001a9a0: 7573 5f62 6c6f 636b 733b 0a09 0909 0963 us_blocks;.....c │ │ │ -0001a9b0: 6f6e 7469 6e75 653b 0a09 0909 7d0a 0909 ontinue;....}... │ │ │ -0001a9c0: 0969 6620 2863 6f6e 7469 6775 6f75 735f .if (contiguous_ │ │ │ -0001a9d0: 626c 6f63 6b73 2026 6774 3b20 6d61 785f blocks > max_ │ │ │ -0001a9e0: 636f 6e74 6967 756f 7573 290a 0909 097b contiguous)....{ │ │ │ -0001a9f0: 0a09 0909 096d 6178 5f63 6f6e 7469 6775 .....max_contigu │ │ │ -0001aa00: 6f75 7320 3d20 636f 6e74 6967 756f 7573 ous = contiguous │ │ │ -0001aa10: 5f62 6c6f 636b 733b 0a09 0909 0966 6972 _blocks;.....fir │ │ │ -0001aa20: 7374 5f62 6c6f 636b 203d 2069 6478 202d st_block = idx - │ │ │ -0001aa30: 2063 6f6e 7469 6775 6f75 735f 626c 6f63 contiguous_bloc │ │ │ -0001aa40: 6b73 3b0a 0909 097d 0a09 0909 636f 6e74 ks;....}....cont │ │ │ -0001aa50: 6967 756f 7573 5f62 6c6f 636b 7320 3d20 iguous_blocks = │ │ │ -0001aa60: 303b 0a09 0909 6966 2028 696e 666f 2e70 0;....if (info.p │ │ │ -0001aa70: 6565 7220 213d 2070 6565 7229 0a09 0909 eer != peer).... │ │ │ -0001aa80: 7b0a 0909 0909 6578 636c 7573 6976 6520 {.....exclusive │ │ │ -0001aa90: 3d20 6661 6c73 653b 0a09 0909 0969 6620 = false;.....if │ │ │ -0001aaa0: 2869 6e66 6f2e 7374 6174 6520 3d3d 2070 (info.state == p │ │ │ -0001aab0: 6965 6365 5f70 6963 6b65 723a 3a62 6c6f iece_picker::blo │ │ │ -0001aac0: 636b 5f69 6e66 6f3a 3a73 7461 7465 5f72 ck_info::state_r │ │ │ -0001aad0: 6571 7565 7374 6564 0a09 0909 0909 2661 equested......&a │ │ │ -0001aae0: 6d70 3b26 616d 703b 2069 6e66 6f2e 7065 mp;& info.pe │ │ │ -0001aaf0: 6572 2021 3d20 6e75 6c6c 7074 7229 0a3c er != nullptr).< │ │ │ -0001ab00: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0001ab10: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0001ab20: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ -0001ab30: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ -0001ab40: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ -0001ab70: 7069 6563 655f 7069 636b 6572 2e63 7070 piece_picker.cpp │ │ │ -0001ab80: 3a33 3435 333c 2f61 3e3c 2f74 643e 3c74 :3453it would be ni │ │ │ -0001aba0: 6365 2069 6620 7468 6973 2063 6f75 6c64 ce if this could │ │ │ -0001abb0: 2062 6520 666f 6c64 6564 2069 6e74 6f20 be folded into │ │ │ -0001abc0: 6c6f 636b 5f70 6965 6365 2829 2074 6865 lock_piece() the │ │ │ -0001abd0: 206d 6169 6e20 6469 7374 696e 6374 696f main distinctio │ │ │ -0001abe0: 6e20 6973 2074 6861 7420 7468 6973 2061 n is that this a │ │ │ -0001abf0: 6c73 6f20 6d61 696e 7461 696e 7320 7468 lso maintains th │ │ │ -0001ac00: 6520 6d5f 6e75 6d5f 6861 7665 2063 6f75 e m_num_have cou │ │ │ -0001ac10: 6e74 6572 2061 6e64 2074 6865 2070 6173 nter and the pas │ │ │ -0001ac20: 7365 645f 6861 7368 5f63 6865 636b 206d sed_hash_check m │ │ │ -0001ac30: 656d 6265 7220 4973 2074 6865 7265 2065 ember Is there e │ │ │ -0001ac40: 7665 7220 6120 6361 7365 2077 6865 7265 ver a case where │ │ │ -0001ac50: 2077 6520 6361 6c6c 2077 7269 7465 2066 we call write f │ │ │ -0001ac60: 6169 6c65 6420 7769 7468 6f75 7420 616c ailed without al │ │ │ -0001ac70: 736f 206c 6f63 6b69 6e67 2074 6865 2070 so locking the p │ │ │ -0001ac80: 6965 6365 3f20 5065 7268 6170 7320 7772 iece? Perhaps wr │ │ │ -0001ac90: 6974 655f 6661 696c 6564 2829 2073 686f ite_failed() sho │ │ │ -0001aca0: 756c 6420 696d 706c 7920 6c6f 636b 696e uld imply lockin │ │ │ -0001acb0: 6720 6974 2e3c 2f74 643e 3c2f 7472 3e3c g it.< │ │ │ -0001acc0: 7472 2069 643d 2235 3322 2073 7479 6c65 tr id="53" style │ │ │ -0001acd0: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ -0001ace0: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">it would be ni │ │ │ -0001ad10: 6365 2069 6620 7468 6973 2063 6f75 6c64 ce if this could │ │ │ -0001ad20: 2062 6520 666f 6c64 6564 2069 6e74 6f20 be folded into │ │ │ -0001ad30: 6c6f 636b 5f70 6965 6365 2829 0a74 6865 lock_piece().the │ │ │ -0001ad40: 206d 6169 6e20 6469 7374 696e 6374 696f main distinctio │ │ │ -0001ad50: 6e20 6973 2074 6861 7420 7468 6973 2061 n is that this a │ │ │ -0001ad60: 6c73 6f20 6d61 696e 7461 696e 7320 7468 lso maintains th │ │ │ -0001ad70: 6520 6d5f 6e75 6d5f 6861 7665 0a63 6f75 e m_num_have.cou │ │ │ -0001ad80: 6e74 6572 2061 6e64 2074 6865 2070 6173 nter and the pas │ │ │ -0001ad90: 7365 645f 6861 7368 5f63 6865 636b 206d sed_hash_check m │ │ │ -0001ada0: 656d 6265 720a 4973 2074 6865 7265 2065 ember.Is there e │ │ │ -0001adb0: 7665 7220 6120 6361 7365 2077 6865 7265 ver a case where │ │ │ -0001adc0: 2077 6520 6361 6c6c 2077 7269 7465 2066 we call write f │ │ │ -0001add0: 6169 6c65 6420 7769 7468 6f75 7420 616c ailed without al │ │ │ -0001ade0: 736f 206c 6f63 6b69 6e67 0a74 6865 2070 so locking.the p │ │ │ -0001adf0: 6965 6365 3f20 5065 7268 6170 7320 7772 iece? Perhaps wr │ │ │ -0001ae00: 6974 655f 6661 696c 6564 2829 2073 686f ite_failed() sho │ │ │ -0001ae10: 756c 6420 696d 706c 7920 6c6f 636b 696e uld imply lockin │ │ │ -0001ae20: 6720 6974 2e3c 2f68 323e 3c68 343e 2e2e g it.

    .. │ │ │ -0001ae30: 2f73 7263 2f70 6965 6365 5f70 6963 6b65 /src/piece_picke │ │ │ -0001ae40: 722e 6370 703a 3334 3533 3c2f 6834 3e3c r.cpp:3453

    < │ │ │ -0001ae50: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0001ae60: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0001ae70: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0001ae80: 7820 2364 6464 3b22 3e0a 0909 6175 746f x #ddd;">...auto │ │ │ -0001ae90: 2063 6f6e 7374 2073 7461 7465 203d 206d const state = m │ │ │ -0001aea0: 5f70 6965 6365 5f6d 6170 5b70 6965 6365 _piece_map[piece │ │ │ -0001aeb0: 5d2e 646f 776e 6c6f 6164 5f71 7565 7565 ].download_queue │ │ │ -0001aec0: 2829 3b0a 0909 6966 2028 7374 6174 6520 ();...if (state │ │ │ -0001aed0: 3d3d 2070 6965 6365 5f70 6f73 3a3a 7069 == piece_pos::pi │ │ │ -0001aee0: 6563 655f 6f70 656e 2920 7265 7475 726e ece_open) return │ │ │ -0001aef0: 3b0a 0909 6175 746f 2063 6f6e 7374 2069 ;...auto const i │ │ │ -0001af00: 203d 2066 696e 645f 646c 5f70 6965 6365 = find_dl_piece │ │ │ -0001af10: 2873 7461 7465 2c20 7069 6563 6529 3b0a (state, piece);. │ │ │ -0001af20: 0909 6966 2028 6920 3d3d 206d 5f64 6f77 ..if (i == m_dow │ │ │ -0001af30: 6e6c 6f61 6473 5b73 7461 7465 5d2e 656e nloads[state].en │ │ │ -0001af40: 6428 2929 2072 6574 7572 6e3b 0a0a 0909 d()) return;.... │ │ │ -0001af50: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ -0001af60: 2d26 6774 3b70 6173 7365 645f 6861 7368 ->passed_hash │ │ │ -0001af70: 5f63 6865 636b 203d 3d20 6661 6c73 6529 _check == false) │ │ │ -0001af80: 3b0a 0909 6966 2028 692d 2667 743b 7061 ;...if (i->pa │ │ │ -0001af90: 7373 6564 5f68 6173 685f 6368 6563 6b29 ssed_hash_check) │ │ │ -0001afa0: 0a09 097b 0a09 0909 2f2f 2069 7427 7320 ...{....// it's │ │ │ -0001afb0: 6e6f 7420 636c 6561 7220 7768 7920 7468 not clear why th │ │ │ -0001afc0: 6973 2077 6f75 6c64 2068 6170 7065 6e2c is would happen, │ │ │ -0001afd0: 0a09 0909 2f2f 2062 7574 2069 7420 7365 ....// but it se │ │ │ -0001afe0: 656d 7320 7265 6173 6f6e 6162 6c65 2074 ems reasonable t │ │ │ -0001aff0: 6f20 6e6f 7420 6272 6561 6b20 7468 650a o not break the. │ │ │ -0001b000: 0909 092f 2f20 6163 636f 756e 7469 6e67 ...// accounting │ │ │ -0001b010: 206f 7665 7220 6974 2e0a 0909 0969 2d26 over it.....i-& │ │ │ -0001b020: 6774 3b70 6173 7365 645f 6861 7368 5f63 gt;passed_hash_c │ │ │ -0001b030: 6865 636b 203d 2066 616c 7365 3b0a 0909 heck = false;... │ │ │ -0001b040: 0961 6363 6f75 6e74 5f6c 6f73 7428 7069 .account_lost(pi │ │ │ -0001b050: 6563 6529 3b0a 0909 7d0a 0a09 092f 2f20 ece);...}....// │ │ │ -0001b060: 7072 6576 656e 7420 7468 6973 2070 6965 prevent this pie │ │ │ -0001b070: 6365 2066 726f 6d20 6265 696e 6720 7069 ce from being pi │ │ │ -0001b080: 636b 6564 2075 6e74 696c 2069 7427 7320 cked until it's │ │ │ -0001b090: 7265 7374 6f72 6564 0a09 0969 2d26 6774 restored...i-> │ │ │ -0001b0a0: 3b6c 6f63 6b65 6420 3d20 7472 7565 3b0a ;locked = true;. │ │ │ -0001b0b0: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22 .}..
    .void piece_pi │ │ │ -0001b0f0: 636b 6572 3a3a 7772 6974 655f 6661 696c cker::write_fail │ │ │ -0001b100: 6564 2870 6965 6365 5f62 6c6f 636b 2063 ed(piece_block c │ │ │ -0001b110: 6f6e 7374 2062 6c6f 636b 290a 3c2f 6469 onst block)..{...INVARIANT │ │ │ -0001b130: 5f43 4845 434b 3b0a 0a23 6966 2054 4f52 _CHECK;..#if TOR │ │ │ -0001b140: 5245 4e54 5f55 5345 5f49 4e56 4152 4941 RENT_USE_INVARIA │ │ │ -0001b150: 4e54 5f43 4845 434b 530a 0909 6368 6563 NT_CHECKS...chec │ │ │ -0001b160: 6b5f 7069 6563 655f 7374 6174 6528 293b k_piece_state(); │ │ │ -0001b170: 0a23 656e 6469 660a 0a23 6966 6465 6620 .#endif..#ifdef │ │ │ -0001b180: 544f 5252 454e 545f 5049 434b 4552 5f4c TORRENT_PICKER_L │ │ │ -0001b190: 4f47 0a09 0973 7464 3a3a 6365 7272 2026 OG...std::cerr & │ │ │ -0001b1a0: 6c74 3b26 6c74 3b20 225b 2220 266c 743b lt;< "[" < │ │ │ -0001b1b0: 266c 743b 2074 6869 7320 266c 743b 266c < this <&l │ │ │ -0001b1c0: 743b 2022 5d20 2220 266c 743b 266c 743b t; "] " << │ │ │ -0001b1d0: 2022 7772 6974 655f 6661 696c 6564 2820 "write_failed( │ │ │ -0001b1e0: 7b22 2026 6c74 3b26 6c74 3b20 626c 6f63 {" << bloc │ │ │ -0001b1f0: 6b2e 7069 6563 655f 696e 6465 7820 266c k.piece_index &l │ │ │ -0001b200: 743b 266c 743b 2022 2c20 2220 266c 743b t;< ", " < │ │ │ -0001b210: 266c 743b 2062 6c6f 636b 2e62 6c6f 636b < block.block │ │ │ -0001b220: 5f69 6e64 6578 2026 6c74 3b26 6c74 3b20 _index << │ │ │ -0001b230: 227d 2029 2220 266c 743b 266c 743b 2073 "} )" << s │ │ │ -0001b240: 7464 3a3a 656e 646c 3b0a 2365 6e64 6966 td::endl;.#endif │ │ │ -0001b250: 0a0a 0909 6175 746f 2063 6f6e 7374 2073 ....auto const s │ │ │ -0001b260: 7461 7465 203d 206d 5f70 6965 6365 5f6d tate = m_piece_m │ │ │ -0001b270: 6170 5b62 6c6f 636b 2e70 6965 6365 5f69 ap[block.piece_i │ │ │ -0001b280: 6e64 6578 5d2e 646f 776e 6c6f 6164 5f71 ndex].download_q │ │ │ -0001b290: 7565 7565 2829 3b0a 0909 6966 2028 7374 ueue();...if (st │ │ │ -0001b2a0: 6174 6520 3d3d 2070 6965 6365 5f70 6f73 ate == piece_pos │ │ │ -0001b2b0: 3a3a 7069 6563 655f 6f70 656e 2920 7265 ::piece_open) re │ │ │ -0001b2c0: 7475 726e 3b0a 0909 6175 746f 2069 203d turn;...auto i = │ │ │ -0001b2d0: 2066 696e 645f 646c 5f70 6965 6365 2873 find_dl_piece(s │ │ │ -0001b2e0: 7461 7465 2c20 626c 6f63 6b2e 7069 6563 tate, block.piec │ │ │ -0001b2f0: 655f 696e 6465 7829 3b0a 0909 6966 2028 e_index);...if ( │ │ │ -0001b300: 6920 3d3d 206d 5f64 6f77 6e6c 6f61 6473 i == m_downloads │ │ │ -0001b310: 5b73 7461 7465 5d2e 656e 6428 2929 2072 [state].end()) r │ │ │ -0001b320: 6574 7572 6e3b 0a0a 0909 6175 746f 2063 eturn;....auto c │ │ │ -0001b330: 6f6e 7374 2062 696e 666f 203d 206d 7574 onst binfo = mut │ │ │ -0001b340: 6162 6c65 5f62 6c6f 636b 735f 666f 725f able_blocks_for_ │ │ │ -0001b350: 7069 6563 6528 2a69 293b 0a09 0962 6c6f piece(*i);...blo │ │ │ -0001b360: 636b 5f69 6e66 6f26 616d 703b 2069 6e66 ck_info& inf │ │ │ -0001b370: 6f20 3d20 6269 6e66 6f5b 626c 6f63 6b2e o = binfo[block. │ │ │ -0001b380: 626c 6f63 6b5f 696e 6465 785d 3b0a 0909 block_index];... │ │ │ -0001b390: 544f 5252 454e 545f 4153 5345 5254 2826 TORRENT_ASSERT(& │ │ │ -0001b3a0: 616d 703b 696e 666f 2026 6774 3b3d 2026 amp;info >= & │ │ │ -0001b3b0: 616d 703b 6d5f 626c 6f63 6b5f 696e 666f amp;m_block_info │ │ │ -0001b3c0: 5b30 5d29 3b0a 0909 544f 5252 454e 545f [0]);...TORRENT_ │ │ │ -0001b3d0: 4153 5345 5254 2826 616d 703b 696e 666f ASSERT(&info │ │ │ -0001b3e0: 2026 6c74 3b20 2661 6d70 3b6d 5f62 6c6f < &m_blo │ │ │ -0001b3f0: 636b 5f69 6e66 6f5b 305d 202b 206d 5f62 ck_info[0] + m_b │ │ │ -0001b400: 6c6f 636b 5f69 6e66 6f2e 7369 7a65 2829 lock_info.size() │ │ │ -0001b410: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ -0001b420: 4552 5428 696e 666f 2e70 6965 6365 5f69 ERT(info.piece_i │ │ │ -0001b430: 6e64 6578 203d 3d20 626c 6f63 6b2e 7069 ndex == block.pi │ │ │ -0001b440: 6563 655f 696e 6465 7829 3b0a 0909 544f ece_index);...TO │ │ │ -0001b450: 5252 454e 545f 4153 5345 5254 2869 6e66 RRENT_ASSERT(inf │ │ │ -0001b460: 6f2e 7374 6174 6520 3d3d 2062 6c6f 636b o.state == block │ │ │ -0001b470: 5f69 6e66 6f3a 3a73 7461 7465 5f77 7269 _info::state_wri │ │ │ -0001b480: 7469 6e67 293b 0a09 0954 4f52 5245 4e54 ting);...TORRENT │ │ │ -0001b490: 5f41 5353 4552 5428 696e 666f 2e6e 756d _ASSERT(info.num │ │ │ -0001b4a0: 5f70 6565 7273 203d 3d20 3029 3b0a 0a09 _peers == 0);... │ │ │ -0001b4b0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0001b4c0: 692d 2667 743b 7772 6974 696e 6720 2667 i->writing &g │ │ │ -0001b4d0: 743b 2030 293b 0a09 0954 4f52 5245 4e54 t; 0);...TORRENT │ │ │ -0001b4e0: 5f41 5353 4552 5428 696e 666f 2e73 7461 _ASSERT(info.sta │ │ │ -0001b4f0: 7465 203d 3d20 626c 6f63 6b5f 696e 666f te == block_info │ │ │ -0001b500: 3a3a 7374 6174 655f 7772 6974 696e 6729 ::state_writing) │ │ │ -0001b510: 3b0a 0a09 0969 6620 2869 6e66 6f2e 7374 ;....if (info.st │ │ │ -0001b520: 6174 6520 3d3d 2062 6c6f 636b 5f69 6e66 ate == block_inf │ │ │ -0001b530: 6f3a 3a73 7461 7465 5f66 696e 6973 6865 o::state_finishe │ │ │ -0001b540: 6429 2072 6574 7572 6e3b 0a09 0969 6620 d) return;...if │ │ │ -0001b550: 2869 6e66 6f2e 7374 6174 6520 3d3d 2062 (info.state == b │ │ │ -0001b560: 6c6f 636b 5f69 6e66 6f3a 3a73 7461 7465 lock_info::state │ │ │ -0001b570: 5f77 7269 7469 6e67 2920 2d2d 692d 2667 _writing) --i-&g │ │ │ -0001b580: 743b 7772 6974 696e 673b 0a0a 3c2f 7072 t;writing;..rel │ │ │ -0001b5c0: 6576 616e 6365 266e 6273 703b 323c 2f74 evance 2../src/sto │ │ │ -0001b600: 7261 6765 5f75 7469 6c73 2e63 7070 3a31 rage_utils.cpp:1 │ │ │ -0001b610: 3837 3c2f 613e 3c2f 7464 3e3c 7464 3e74 87t │ │ │ -0001b620: 6563 686e 6963 616c 6c79 2c20 7468 6973 echnically, this │ │ │ -0001b630: 2069 7320 7768 6572 6520 7468 6520 7472 is where the tr │ │ │ -0001b640: 616e 7361 6374 696f 6e20 6f66 206d 6f76 ansaction of mov │ │ │ -0001b650: 696e 6720 7468 6520 6669 6c65 7320 6973 ing the files is │ │ │ -0001b660: 2063 6f6d 706c 6574 6564 2e20 5468 6973 completed. This │ │ │ -0001b670: 2069 7320 7768 6572 6520 7468 6520 6e65 is where the ne │ │ │ -0001b680: 7720 7361 7665 5f70 6174 6820 7368 6f75 w save_path shou │ │ │ -0001b690: 6c64 2062 6520 636f 6d6d 6974 7465 642e ld be committed. │ │ │ -0001b6a0: 2049 6620 7468 6572 6520 6973 2061 6e20 If there is an │ │ │ -0001b6b0: 6572 726f 7220 696e 2074 6865 2063 6f64 error in the cod │ │ │ -0001b6c0: 6520 6265 6c6f 772c 2074 6861 7420 7368 e below, that sh │ │ │ -0001b6d0: 6f75 6c64 206e 6f74 2070 7265 7665 6e74 ould not prevent │ │ │ -0001b6e0: 2074 6865 206e 6577 2073 6176 6520 7061 the new save pa │ │ │ -0001b6f0: 7468 2074 6f20 6265 2073 6574 2e20 4d61 th to be set. Ma │ │ │ -0001b700: 7962 6520 6974 2077 6f75 6c64 206d 616b ybe it would mak │ │ │ -0001b710: 6520 7365 6e73 6520 746f 206d 616b 6520 e sense to make │ │ │ -0001b720: 7468 6520 7361 7665 5f70 6174 6820 616e the save_path an │ │ │ -0001b730: 2069 6e2d 6f75 7420 7061 7261 6d65 7465 in-out paramete │ │ │ -0001b740: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    te │ │ │ -0001b790: 6368 6e69 6361 6c6c 792c 2074 6869 7320 chnically, this │ │ │ -0001b7a0: 6973 2077 6865 7265 2074 6865 2074 7261 is where the tra │ │ │ -0001b7b0: 6e73 6163 7469 6f6e 206f 6620 6d6f 7669 nsaction of movi │ │ │ -0001b7c0: 6e67 2074 6865 2066 696c 6573 0a69 7320 ng the files.is │ │ │ -0001b7d0: 636f 6d70 6c65 7465 642e 2054 6869 7320 completed. This │ │ │ -0001b7e0: 6973 2077 6865 7265 2074 6865 206e 6577 is where the new │ │ │ -0001b7f0: 2073 6176 655f 7061 7468 2073 686f 756c save_path shoul │ │ │ -0001b800: 6420 6265 2063 6f6d 6d69 7474 6564 2e20 d be committed. │ │ │ -0001b810: 4966 0a74 6865 7265 2069 7320 616e 2065 If.there is an e │ │ │ -0001b820: 7272 6f72 2069 6e20 7468 6520 636f 6465 rror in the code │ │ │ -0001b830: 2062 656c 6f77 2c20 7468 6174 2073 686f below, that sho │ │ │ -0001b840: 756c 6420 6e6f 7420 7072 6576 656e 7420 uld not prevent │ │ │ -0001b850: 7468 6520 6e65 770a 7361 7665 2070 6174 the new.save pat │ │ │ -0001b860: 6820 746f 2062 6520 7365 742e 204d 6179 h to be set. May │ │ │ -0001b870: 6265 2069 7420 776f 756c 6420 6d61 6b65 be it would make │ │ │ -0001b880: 2073 656e 7365 2074 6f20 6d61 6b65 2074 sense to make t │ │ │ -0001b890: 6865 2073 6176 655f 7061 7468 0a61 6e20 he save_path.an │ │ │ -0001b8a0: 696e 2d6f 7574 2070 6172 616d 6574 6572 in-out parameter │ │ │ -0001b8b0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0001b8c0: 7374 6f72 6167 655f 7574 696c 732e 6370 storage_utils.cp │ │ │ -0001b8d0: 703a 3138 373c 2f68 343e 3c70 7265 2073 p:187

    ...while (--
    │ │ │ -0001b920: 6669 6c65 5f69 6e64 6578 2026 6774 3b3d  file_index >=
    │ │ │ -0001b930: 2066 696c 655f 696e 6465 785f 7428 3029   file_index_t(0)
    │ │ │ -0001b940: 290a 0909 097b 0a09 0909 092f 2f20 6669  )....{.....// fi
    │ │ │ -0001b950: 6c65 7320 6d6f 7665 6420 6f75 7420 746f  les moved out to
    │ │ │ -0001b960: 2061 6273 6f6c 7574 6520 7061 7468 7320   absolute paths 
    │ │ │ -0001b970: 6172 6520 6e6f 7420 6d6f 7665 640a 0909  are not moved...
    │ │ │ -0001b980: 0909 6966 2028 662e 6669 6c65 5f61 6273  ..if (f.file_abs
    │ │ │ -0001b990: 6f6c 7574 655f 7061 7468 2866 696c 655f  olute_path(file_
    │ │ │ -0001b9a0: 696e 6465 7829 2920 636f 6e74 696e 7565  index)) continue
    │ │ │ -0001b9b0: 3b0a 0a09 0909 092f 2f20 6966 2077 6520  ;......// if we 
    │ │ │ -0001b9c0: 656e 6465 6420 7570 2063 6f70 7969 6e67  ended up copying
    │ │ │ -0001b9d0: 2074 6865 2066 696c 652c 2064 6f6e 2774   the file, don't
    │ │ │ -0001b9e0: 2064 6f20 616e 7974 6869 6e67 2064 7572   do anything dur
    │ │ │ -0001b9f0: 696e 670a 0909 0909 2f2f 2072 6f6c 6c2d  ing.....// roll-
    │ │ │ -0001ba00: 6261 636b 0a09 0909 0969 6620 2863 6f70  back.....if (cop
    │ │ │ -0001ba10: 6965 645f 6669 6c65 735b 6669 6c65 5f69  ied_files[file_i
    │ │ │ -0001ba20: 6e64 6578 5d29 2063 6f6e 7469 6e75 653b  ndex]) continue;
    │ │ │ -0001ba30: 0a0a 0909 0909 7374 643a 3a73 7472 696e  ......std::strin
    │ │ │ -0001ba40: 6720 636f 6e73 7420 6f6c 645f 7061 7468  g const old_path
    │ │ │ -0001ba50: 203d 2063 6f6d 6269 6e65 5f70 6174 6828   = combine_path(
    │ │ │ -0001ba60: 7361 7665 5f70 6174 682c 2066 2e66 696c  save_path, f.fil
    │ │ │ -0001ba70: 655f 7061 7468 2866 696c 655f 696e 6465  e_path(file_inde
    │ │ │ -0001ba80: 7829 293b 0a09 0909 0973 7464 3a3a 7374  x));.....std::st
    │ │ │ -0001ba90: 7269 6e67 2063 6f6e 7374 206e 6577 5f70  ring const new_p
    │ │ │ -0001baa0: 6174 6820 3d20 636f 6d62 696e 655f 7061  ath = combine_pa
    │ │ │ -0001bab0: 7468 286e 6577 5f73 6176 655f 7061 7468  th(new_save_path
    │ │ │ -0001bac0: 2c20 662e 6669 6c65 5f70 6174 6828 6669  , f.file_path(fi
    │ │ │ -0001bad0: 6c65 5f69 6e64 6578 2929 3b0a 0a09 0909  le_index));.....
    │ │ │ -0001bae0: 092f 2f20 6967 6e6f 7265 2065 7272 6f72  .// ignore error
    │ │ │ -0001baf0: 7320 7768 656e 2072 6f6c 6c69 6e67 2062  s when rolling b
    │ │ │ -0001bb00: 6163 6b0a 0909 0909 7374 6f72 6167 655f  ack.....storage_
    │ │ │ -0001bb10: 6572 726f 7220 6967 6e6f 7265 3b0a 0909  error ignore;...
    │ │ │ -0001bb20: 0909 6d6f 7665 5f66 696c 6528 6e65 775f  ..move_file(new_
    │ │ │ -0001bb30: 7061 7468 2c20 6f6c 645f 7061 7468 2c20  path, old_path, 
    │ │ │ -0001bb40: 6967 6e6f 7265 293b 0a09 0909 7d0a 0a09  ignore);....}...
    │ │ │ -0001bb50: 0909 7265 7475 726e 207b 2064 6973 6b5f  ..return { disk_
    │ │ │ -0001bb60: 7374 6174 7573 3a3a 6661 7461 6c5f 6469  status::fatal_di
    │ │ │ -0001bb70: 736b 5f65 7272 6f72 2c20 7361 7665 5f70  sk_error, save_p
    │ │ │ -0001bb80: 6174 6820 7d3b 0a09 097d 0a0a 3c64 6976  ath };...}..
    .
    ..std::set<s │ │ │ -0001bbd0: 7464 3a3a 7374 7269 6e67 2667 743b 2073 td::string> s │ │ │ -0001bbe0: 7562 6469 7273 3b0a 0909 666f 7220 2861 ubdirs;...for (a │ │ │ -0001bbf0: 7574 6f20 636f 6e73 7420 6920 3a20 662e uto const i : f. │ │ │ -0001bc00: 6669 6c65 5f72 616e 6765 2829 290a 0909 file_range())... │ │ │ -0001bc10: 7b0a 0909 092f 2f20 6669 6c65 7320 6d6f {....// files mo │ │ │ -0001bc20: 7665 6420 6f75 7420 746f 2061 6273 6f6c ved out to absol │ │ │ -0001bc30: 7574 6520 7061 7468 7320 6172 6520 6e6f ute paths are no │ │ │ -0001bc40: 7420 6d6f 7665 640a 0909 0969 6620 2866 t moved....if (f │ │ │ -0001bc50: 2e66 696c 655f 6162 736f 6c75 7465 5f70 .file_absolute_p │ │ │ -0001bc60: 6174 6828 6929 2920 636f 6e74 696e 7565 ath(i)) continue │ │ │ -0001bc70: 3b0a 0a09 0909 6966 2028 6861 735f 7061 ;.....if (has_pa │ │ │ -0001bc80: 7265 6e74 5f70 6174 6828 662e 6669 6c65 rent_path(f.file │ │ │ -0001bc90: 5f70 6174 6828 6929 2929 0a09 0909 0973 _path(i))).....s │ │ │ -0001bca0: 7562 6469 7273 2e69 6e73 6572 7428 7061 ubdirs.insert(pa │ │ │ -0001bcb0: 7265 6e74 5f70 6174 6828 662e 6669 6c65 rent_path(f.file │ │ │ -0001bcc0: 5f70 6174 6828 6929 2929 3b0a 0a09 0909 _path(i)));..... │ │ │ -0001bcd0: 2f2f 2069 6620 7765 2065 6e64 6564 2075 // if we ended u │ │ │ -0001bce0: 7020 7265 6e61 6d69 6e67 2074 6865 2066 p renaming the f │ │ │ -0001bcf0: 696c 6520 696e 7374 6561 6420 6f66 206d ile instead of m │ │ │ -0001bd00: 6f76 696e 6720 6974 2c20 7468 6572 6527 oving it, there' │ │ │ -0001bd10: 7320 6e6f 0a09 0909 2f2f 206e 6565 6420 s no....// need │ │ │ -0001bd20: 746f 2064 656c 6574 6520 7468 6520 736f to delete the so │ │ │ -0001bd30: 7572 6365 2e0a 0909 0969 6620 2863 6f70 urce.....if (cop │ │ │ -0001bd40: 6965 645f 6669 6c65 735b 695d 203d 3d20 ied_files[i] == │ │ │ -0001bd50: 6661 6c73 6529 2063 6f6e 7469 6e75 653b false) continue; │ │ │ -0001bd60: 0a0a 0909 0973 7464 3a3a 7374 7269 6e67 .....std::string │ │ │ -0001bd70: 2063 6f6e 7374 206f 6c64 5f70 6174 6820 const old_path │ │ │ -0001bd80: 3d20 636f 6d62 696e 655f 7061 7468 2873 = combine_path(s │ │ │ -0001bd90: 6176 655f 7061 7468 2c20 662e 6669 6c65 ave_path, f.file │ │ │ -0001bda0: 5f70 6174 6828 6929 293b 0a0a 0909 092f _path(i));...../ │ │ │ -0001bdb0: 2f20 7765 206d 6179 2073 7469 6c6c 2068 / we may still h │ │ │ -0001bdc0: 6176 6520 736f 6d65 2066 696c 6573 2069 ave some files i │ │ │ -0001bdd0: 6e20 6f6c 6420 7361 7665 5f70 6174 680a n old save_path. │ │ │ -0001bde0: 0909 092f 2f20 6567 2e20 6966 2028 666c ...// eg. if (fl │ │ │ -0001bdf0: 6167 7320 3d3d 2064 6f6e 745f 7265 706c ags == dont_repl │ │ │ -0001be00: 6163 6520 2661 6d70 3b26 616d 703b 2065 ace && e │ │ │ -0001be10: 7869 7374 7328 6e65 775f 7061 7468 2929 xists(new_path)) │ │ │ -0001be20: 0a09 0909 2f2f 2069 676e 6f72 6520 6572 ....// ignore er │ │ │ -0001be30: 726f 7273 2077 6865 6e20 7265 6d6f 7669 rors when removi │ │ │ -0001be40: 6e67 0a09 0909 6572 726f 725f 636f 6465 ng....error_code │ │ │ -0001be50: 2069 676e 6f72 653b 0a09 0909 7265 6d6f ignore;....remo │ │ │ -0001be60: 7665 286f 6c64 5f70 6174 682c 2069 676e ve(old_path, ign │ │ │ -0001be70: 6f72 6529 3b0a 0909 7d0a 0a09 0966 6f72 ore);...}....for │ │ │ -0001be80: 2028 7374 643a 3a73 7472 696e 6720 636f (std::string co │ │ │ -0001be90: 6e73 7426 616d 703b 2073 203a 2073 7562 nst& s : sub │ │ │ -0001bea0: 6469 7273 290a 0909 7b0a 0909 0965 7272 dirs)...{....err │ │ │ -0001beb0: 6f72 5f63 6f64 6520 6572 723b 0a09 0909 or_code err;.... │ │ │ -0001bec0: 7374 643a 3a73 7472 696e 6720 7375 6264 std::string subd │ │ │ -0001bed0: 6972 203d 2063 6f6d 6269 6e65 5f70 6174 ir = combine_pat │ │ │ -0001bee0: 6828 7361 7665 5f70 6174 682c 2073 293b h(save_path, s); │ │ │ -0001bef0: 0a0a 0909 0977 6869 6c65 2028 2170 6174 .....while (!pat │ │ │ -0001bf00: 685f 6571 7561 6c28 7375 6264 6972 2c20 h_equal(subdir, │ │ │ -0001bf10: 7361 7665 5f70 6174 6829 2026 616d 703b save_path) & │ │ │ -0001bf20: 2661 6d70 3b20 2165 7272 290a 0909 097b & !err)....{ │ │ │ -0001bf30: 0a09 0909 0972 656d 6f76 6528 7375 6264 .....remove(subd │ │ │ -0001bf40: 6972 2c20 6572 7229 3b0a 3c2f 7072 653e ir, err);.
    │ │ │ -0001bf50: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0001bf80: 616e 6365 266e 6273 703b 323c 2f74 643e ance 2 │ │ │ -0001bf90: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/stora │ │ │ -0001bfc0: 6765 5f75 7469 6c73 2e63 7070 3a33 3739 ge_utils.cpp:379 │ │ │ -0001bfd0: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 7320 is │ │ │ -0001bfe0: 7468 6973 2072 6973 6b79 3f20 5468 6520 this risky? The │ │ │ -0001bff0: 7570 7065 7220 6c61 7965 7220 7769 6c6c upper layer will │ │ │ -0001c000: 2061 7373 756d 6520 7765 2068 6176 6520 assume we have │ │ │ -0001c010: 7468 6520 7768 6f6c 6520 6669 6c65 2e20 the whole file. │ │ │ -0001c020: 5065 7268 6170 7320 7765 2073 686f 756c Perhaps we shoul │ │ │ -0001c030: 6420 7665 7269 6679 2074 6861 7420 6174 d verify that at │ │ │ -0001c040: 206c 6561 7374 2074 6865 2073 697a 6520 least the size │ │ │ -0001c050: 6f66 2074 6865 2066 696c 6520 6973 2063 of the file is c │ │ │ -0001c060: 6f72 7265 6374 3c2f 7464 3e3c 2f74 723e orrect │ │ │ -0001c070: 3c74 7220 6964 3d22 3535 2220 7374 796c < │ │ │ -0001c0a0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0001c0b0: 6832 3e69 7320 7468 6973 2072 6973 6b79 h2>is this risky │ │ │ -0001c0c0: 3f20 5468 6520 7570 7065 7220 6c61 7965 ? The upper laye │ │ │ -0001c0d0: 7220 7769 6c6c 2061 7373 756d 6520 7765 r will assume we │ │ │ -0001c0e0: 2068 6176 6520 7468 650a 7768 6f6c 6520 have the.whole │ │ │ -0001c0f0: 6669 6c65 2e20 5065 7268 6170 7320 7765 file. Perhaps we │ │ │ -0001c100: 2073 686f 756c 6420 7665 7269 6679 2074 should verify t │ │ │ -0001c110: 6861 7420 6174 206c 6561 7374 2074 6865 hat at least the │ │ │ -0001c120: 2073 697a 650a 6f66 2074 6865 2066 696c size.of the fil │ │ │ -0001c130: 6520 6973 2063 6f72 7265 6374 3c2f 6832 e is correct

    ../src/stor │ │ │ -0001c150: 6167 655f 7574 696c 732e 6370 703a 3337 age_utils.cpp:37 │ │ │ -0001c160: 393c 2f68 343e 3c70 7265 2073 7479 6c65 9

    │ │ │ -0001c1a0: 0909 0909 7b0a 0909 0909 092f 2f20 7765  ....{......// we
    │ │ │ -0001c1b0: 2063 7265 6174 6520 6469 7265 6374 6f72   create director
    │ │ │ -0001c1c0: 6965 7320 6c61 7a69 6c79 2c20 736f 2069  ies lazily, so i
    │ │ │ -0001c1d0: 7427 7320 706f 7373 6962 6c65 2069 7420  t's possible it 
    │ │ │ -0001c1e0: 6861 736e 2774 0a09 0909 0909 2f2f 2062  hasn't......// b
    │ │ │ -0001c1f0: 6565 6e20 6372 6561 7465 6420 7965 742e  een created yet.
    │ │ │ -0001c200: 2043 7265 6174 6520 7468 6520 6469 7265   Create the dire
    │ │ │ -0001c210: 6374 6f72 6965 7320 6e6f 7720 616e 6420  ctories now and 
    │ │ │ -0001c220: 7472 790a 0909 0909 092f 2f20 6167 6169  try......// agai
    │ │ │ -0001c230: 6e0a 0909 0909 0963 7265 6174 655f 6469  n......create_di
    │ │ │ -0001c240: 7265 6374 6f72 6965 7328 7061 7265 6e74  rectories(parent
    │ │ │ -0001c250: 5f70 6174 6828 6669 6c65 5f70 6174 6829  _path(file_path)
    │ │ │ -0001c260: 2c20 6572 7229 3b0a 0a09 0909 0909 6966  , err);.......if
    │ │ │ -0001c270: 2028 6572 7229 0a09 0909 0909 7b0a 0909   (err)......{...
    │ │ │ -0001c280: 0909 0909 6563 2e66 696c 6528 6964 7829  ....ec.file(idx)
    │ │ │ -0001c290: 3b0a 0909 0909 0909 6563 2e6f 7065 7261  ;.......ec.opera
    │ │ │ -0001c2a0: 7469 6f6e 203d 206f 7065 7261 7469 6f6e  tion = operation
    │ │ │ -0001c2b0: 5f74 3a3a 6d6b 6469 723b 0a09 0909 0909  _t::mkdir;......
    │ │ │ -0001c2c0: 0972 6574 7572 6e20 6661 6c73 653b 0a09  .return false;..
    │ │ │ -0001c2d0: 0909 0909 7d0a 0a09 0909 0909 6861 7264  ....}.......hard
    │ │ │ -0001c2e0: 5f6c 696e 6b28 732c 2066 696c 655f 7061  _link(s, file_pa
    │ │ │ -0001c2f0: 7468 2c20 6572 7229 3b0a 0909 0909 7d0a  th, err);.....}.
    │ │ │ -0001c300: 0a09 0909 092f 2f20 6966 2074 6865 2066  .....// if the f
    │ │ │ -0001c310: 696c 6520 616c 7265 6164 7920 6578 6973  ile already exis
    │ │ │ -0001c320: 7473 2c20 7468 6174 2773 206e 6f74 2061  ts, that's not a
    │ │ │ -0001c330: 6e20 6572 726f 720a 0909 0909 6966 2028  n error.....if (
    │ │ │ -0001c340: 6572 7220 3d3d 2062 6f6f 7374 3a3a 7379  err == boost::sy
    │ │ │ -0001c350: 7374 656d 3a3a 6572 7263 3a3a 6669 6c65  stem::errc::file
    │ │ │ -0001c360: 5f65 7869 7374 7329 0a09 0909 0909 636f  _exists)......co
    │ │ │ -0001c370: 6e74 696e 7565 3b0a 0a3c 6469 7620 7374  ntinue;..
    ....if (e │ │ │ -0001c3b0: 7272 290a 3c2f 6469 763e 0909 0909 7b0a rr).
    ....{. │ │ │ -0001c3c0: 0909 0909 0965 632e 6563 203d 2065 7272 .....ec.ec = err │ │ │ -0001c3d0: 3b0a 0909 0909 0965 632e 6669 6c65 2869 ;......ec.file(i │ │ │ -0001c3e0: 6478 293b 0a09 0909 0909 6563 2e6f 7065 dx);......ec.ope │ │ │ -0001c3f0: 7261 7469 6f6e 203d 206f 7065 7261 7469 ration = operati │ │ │ -0001c400: 6f6e 5f74 3a3a 6669 6c65 5f68 6172 645f on_t::file_hard_ │ │ │ -0001c410: 6c69 6e6b 3b0a 0909 0909 0972 6574 7572 link;......retur │ │ │ -0001c420: 6e20 6661 6c73 653b 0a09 0909 097d 0a09 n false;.....}.. │ │ │ -0001c430: 0909 0961 6464 6564 5f66 696c 6573 203d ...added_files = │ │ │ -0001c440: 2074 7275 653b 0a09 0909 0973 7461 742e true;.....stat. │ │ │ -0001c450: 7365 745f 6469 7274 7928 6964 7829 3b0a set_dirty(idx);. │ │ │ -0001c460: 0909 097d 0a09 097d 0a23 656e 6469 6620 ...}...}.#endif │ │ │ -0001c470: 2f2f 2054 4f52 5245 4e54 5f44 4953 4142 // TORRENT_DISAB │ │ │ -0001c480: 4c45 5f4d 5554 4142 4c45 5f54 4f52 5245 LE_MUTABLE_TORRE │ │ │ -0001c490: 4e54 530a 0a09 0962 6f6f 6c20 636f 6e73 NTS....bool cons │ │ │ -0001c4a0: 7420 7365 6564 203d 2028 7264 2e68 6176 t seed = (rd.hav │ │ │ -0001c4b0: 655f 7069 6563 6573 2e73 697a 6528 2920 e_pieces.size() │ │ │ -0001c4c0: 2667 743b 3d20 6673 2e6e 756d 5f70 6965 >= fs.num_pie │ │ │ -0001c4d0: 6365 7328 290a 0909 0926 616d 703b 2661 ces()....&&a │ │ │ -0001c4e0: 6d70 3b20 7264 2e68 6176 655f 7069 6563 mp; rd.have_piec │ │ │ -0001c4f0: 6573 2e61 6c6c 5f73 6574 2829 290a 0909 es.all_set())... │ │ │ -0001c500: 097c 7c20 2872 642e 666c 6167 7320 2661 .|| (rd.flags &a │ │ │ -0001c510: 6d70 3b20 746f 7272 656e 745f 666c 6167 mp; torrent_flag │ │ │ -0001c520: 733a 3a73 6565 645f 6d6f 6465 293b 0a0a s::seed_mode);.. │ │ │ -0001c530: 0909 6966 2028 7365 6564 290a 0909 7b0a ..if (seed)...{. │ │ │ -0001c540: 0909 0966 6f72 2028 6669 6c65 5f69 6e64 ...for (file_ind │ │ │ -0001c550: 6578 5f74 2063 6f6e 7374 2066 696c 655f ex_t const file_ │ │ │ -0001c560: 696e 6465 7820 3a20 6673 2e66 696c 655f index : fs.file_ │ │ │ -0001c570: 7261 6e67 6528 2929 0a09 0909 7b0a 0909 range())....{... │ │ │ -0001c580: 0909 6966 2028 6673 2e70 6164 5f66 696c ..if (fs.pad_fil │ │ │ -0001c590: 655f 6174 2866 696c 655f 696e 6465 7829 e_at(file_index) │ │ │ -0001c5a0: 2920 636f 6e74 696e 7565 3b0a 0a09 0909 ) continue;..... │ │ │ -0001c5b0: 092f 2f20 6669 6c65 7320 7769 7468 2070 .// files with p │ │ │ -0001c5c0: 7269 6f72 6974 7920 7a65 726f 206d 6179 riority zero may │ │ │ -0001c5d0: 206e 6f74 2068 6176 6520 6265 656e 2073 not have been s │ │ │ -0001c5e0: 6176 6564 2074 6f20 6469 736b 2061 7420 aved to disk at │ │ │ -0001c5f0: 7468 6569 720a 0909 0909 2f2f 2065 7870 their.....// exp │ │ │ -0001c600: 6563 7465 6420 6c6f 6361 7469 6f6e 2c20 ected location, │ │ │ -0001c610: 6275 7420 6973 206c 696b 656c 7920 746f but is likely to │ │ │ -0001c620: 2062 6520 696e 2061 2070 6172 7466 696c be in a partfil │ │ │ -0001c630: 652e 204a 7573 7420 6578 656d 7074 2069 e. Just exempt i │ │ │ -0001c640: 740a 0909 0909 2f2f 2066 726f 6d20 6368 t.....// from ch │ │ │ -0001c650: 6563 6b69 6e67 0a09 0909 0969 6620 2866 ecking.....if (f │ │ │ -0001c660: 696c 655f 696e 6465 7820 266c 743b 2066 ile_index < f │ │ │ -0001c670: 696c 655f 7072 696f 7269 7479 2e65 6e64 ile_priority.end │ │ │ -0001c680: 5f69 6e64 6578 2829 0a09 0909 0909 2661 _index()......&a │ │ │ -0001c690: 6d70 3b26 616d 703b 2066 696c 655f 7072 mp;& file_pr │ │ │ -0001c6a0: 696f 7269 7479 5b66 696c 655f 696e 6465 iority[file_inde │ │ │ -0001c6b0: 785d 203d 3d20 646f 6e74 5f64 6f77 6e6c x] == dont_downl │ │ │ -0001c6c0: 6f61 640a 0909 0909 0926 616d 703b 2661 oad......&&a │ │ │ -0001c6d0: 6d70 3b20 2128 7264 2e66 6c61 6773 2026 mp; !(rd.flags & │ │ │ -0001c6e0: 616d 703b 2074 6f72 7265 6e74 5f66 6c61 amp; torrent_fla │ │ │ -0001c6f0: 6773 3a3a 7365 6564 5f6d 6f64 6529 290a gs::seed_mode)). │ │ │ -0001c700: 0909 0909 0963 6f6e 7469 6e75 653b 0a0a .....continue;.. │ │ │ -0001c710: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0001c720: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0001c750: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ -0001c780: 2f65 7363 6170 655f 7374 7269 6e67 2e63 /escape_string.c │ │ │ -0001c790: 7070 3a31 3731 3c2f 613e 3c2f 7464 3e3c pp:171< │ │ │ -0001c7a0: 7464 3e74 6869 7320 7368 6f75 6c64 2070 td>this should p │ │ │ -0001c7b0: 726f 6261 626c 7920 6265 206d 6f76 6564 robably be moved │ │ │ -0001c7c0: 2069 6e74 6f20 7374 7269 6e67 5f75 7469 into string_uti │ │ │ -0001c7d0: 6c2e 6370 703c 2f74 643e 3c2f 7472 3e3c l.cpp< │ │ │ -0001c7e0: 7472 2069 643d 2235 3622 2073 7479 6c65 tr id="56" style │ │ │ -0001c7f0: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ -0001c800: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">this should pr │ │ │ -0001c830: 6f62 6162 6c79 2062 6520 6d6f 7665 6420 obably be moved │ │ │ -0001c840: 696e 746f 2073 7472 696e 675f 7574 696c into string_util │ │ │ -0001c850: 2e63 7070 3c2f 6832 3e3c 6834 3e2e 2e2f .cpp

    ../ │ │ │ -0001c860: 7372 632f 6573 6361 7065 5f73 7472 696e src/escape_strin │ │ │ -0001c870: 672e 6370 703a 3137 313c 2f68 343e 3c70 g.cpp:171

    .{...ret │ │ │ -0001c8c0: 7572 6e20 6573 6361 7065 5f73 7472 696e urn escape_strin │ │ │ -0001c8d0: 675f 696d 706c 2873 7472 2e64 6174 6128 g_impl(str.data( │ │ │ -0001c8e0: 292c 2069 6e74 2873 7472 2e73 697a 6528 ), int(str.size( │ │ │ -0001c8f0: 2929 2c20 3130 293b 0a09 7d0a 0a09 626f )), 10);..}...bo │ │ │ -0001c900: 6f6c 206e 6565 645f 656e 636f 6469 6e67 ol need_encoding │ │ │ -0001c910: 2863 6861 7220 636f 6e73 742a 2073 7472 (char const* str │ │ │ -0001c920: 2c20 696e 7420 636f 6e73 7420 6c65 6e29 , int const len) │ │ │ -0001c930: 0a09 7b0a 0909 666f 7220 2869 6e74 2069 ..{...for (int i │ │ │ -0001c940: 203d 2030 3b20 6920 266c 743b 206c 656e = 0; i < len │ │ │ -0001c950: 3b20 2b2b 6929 0a09 097b 0a09 0909 6966 ; ++i)...{....if │ │ │ -0001c960: 2028 7374 643a 3a73 7472 6368 7228 756e (std::strchr(un │ │ │ -0001c970: 7265 7365 7276 6564 5f63 6861 7273 2c20 reserved_chars, │ │ │ -0001c980: 2a73 7472 2920 3d3d 206e 756c 6c70 7472 *str) == nullptr │ │ │ -0001c990: 207c 7c20 2a73 7472 203d 3d20 3029 0a09 || *str == 0).. │ │ │ -0001c9a0: 0909 0972 6574 7572 6e20 7472 7565 3b0a ...return true;. │ │ │ -0001c9b0: 0909 092b 2b73 7472 3b0a 0909 7d0a 0909 ...++str;...}... │ │ │ -0001c9c0: 7265 7475 726e 2066 616c 7365 3b0a 097d return false;..} │ │ │ -0001c9d0: 0a0a 0976 6f69 6420 636f 6e76 6572 745f ...void convert_ │ │ │ -0001c9e0: 7061 7468 5f74 6f5f 706f 7369 7828 7374 path_to_posix(st │ │ │ -0001c9f0: 643a 3a73 7472 696e 6726 616d 703b 2070 d::string& p │ │ │ -0001ca00: 6174 6829 0a09 7b0a 0909 7374 643a 3a72 ath)..{...std::r │ │ │ -0001ca10: 6570 6c61 6365 2870 6174 682e 6265 6769 eplace(path.begi │ │ │ -0001ca20: 6e28 292c 2070 6174 682e 656e 6428 292c n(), path.end(), │ │ │ -0001ca30: 2027 5c5c 272c 2027 2f27 293b 0a09 7d0a '\\', '/');..}. │ │ │ -0001ca40: 0a3c 6469 7620 7374 796c 653d 2262 6163 .

    . │ │ │ -0001ca70: 7374 643a 3a73 7472 696e 6720 7265 6164 std::string read │ │ │ -0001ca80: 5f75 6e74 696c 2863 6861 7220 636f 6e73 _until(char cons │ │ │ -0001ca90: 742a 2661 6d70 3b20 7374 722c 2063 6861 t*& str, cha │ │ │ -0001caa0: 7220 636f 6e73 7420 6465 6c69 6d2c 2063 r const delim, c │ │ │ -0001cab0: 6861 7220 636f 6e73 742a 2065 6e64 290a har const* end). │ │ │ -0001cac0: 3c2f 6469 763e 097b 0a09 0954 4f52 5245
    .{...TORRE │ │ │ -0001cad0: 4e54 5f41 5353 4552 5428 7374 7220 266c NT_ASSERT(str &l │ │ │ -0001cae0: 743b 3d20 656e 6429 3b0a 0a09 0973 7464 t;= end);....std │ │ │ -0001caf0: 3a3a 7374 7269 6e67 2072 6574 3b0a 0909 ::string ret;... │ │ │ -0001cb00: 7768 696c 6520 2873 7472 2021 3d20 656e while (str != en │ │ │ -0001cb10: 6420 2661 6d70 3b26 616d 703b 202a 7374 d && *st │ │ │ -0001cb20: 7220 213d 2064 656c 696d 290a 0909 7b0a r != delim)...{. │ │ │ -0001cb30: 0909 0972 6574 202b 3d20 2a73 7472 3b0a ...ret += *str;. │ │ │ -0001cb40: 0909 092b 2b73 7472 3b0a 0909 7d0a 0909 ...++str;...}... │ │ │ -0001cb50: 2f2f 2073 6b69 7020 7468 6520 6465 6c69 // skip the deli │ │ │ -0001cb60: 6d69 7465 7220 6173 2077 656c 6c0a 0909 miter as well... │ │ │ -0001cb70: 7768 696c 6520 2873 7472 2021 3d20 656e while (str != en │ │ │ -0001cb80: 6420 2661 6d70 3b26 616d 703b 202a 7374 d && *st │ │ │ -0001cb90: 7220 3d3d 2064 656c 696d 2920 2b2b 7374 r == delim) ++st │ │ │ -0001cba0: 723b 0a09 0972 6574 7572 6e20 7265 743b r;...return ret; │ │ │ -0001cbb0: 0a09 7d0a 0a09 7374 643a 3a73 7472 696e ..}...std::strin │ │ │ -0001cbc0: 6720 6d61 7962 655f 7572 6c5f 656e 636f g maybe_url_enco │ │ │ -0001cbd0: 6465 2873 7472 696e 675f 7669 6577 2075 de(string_view u │ │ │ -0001cbe0: 726c 290a 097b 0a09 0965 7272 6f72 5f63 rl)..{...error_c │ │ │ -0001cbf0: 6f64 6520 6563 3b0a 0909 6175 746f 2063 ode ec;...auto c │ │ │ -0001cc00: 6f6e 7374 205b 7072 6f74 6f63 6f6c 2c20 onst [protocol, │ │ │ -0001cc10: 6175 7468 2c20 686f 7374 2c20 706f 7274 auth, host, port │ │ │ -0001cc20: 2c20 7061 7468 5d20 3d20 6175 783a 3a70 , path] = aux::p │ │ │ -0001cc30: 6172 7365 5f75 726c 5f63 6f6d 706f 6e65 arse_url_compone │ │ │ -0001cc40: 6e74 7328 7572 6c2c 2065 6329 3b0a 0909 nts(url, ec);... │ │ │ -0001cc50: 6966 2028 6563 2920 7265 7475 726e 2073 if (ec) return s │ │ │ -0001cc60: 7464 3a3a 7374 7269 6e67 2875 726c 293b td::string(url); │ │ │ -0001cc70: 0a0a 0909 2f2f 2066 6972 7374 2066 6967 ....// first fig │ │ │ -0001cc80: 7572 6520 6f75 7420 6966 2074 6869 7320 ure out if this │ │ │ -0001cc90: 7572 6c20 636f 6e74 6169 6e73 2075 6e65 url contains une │ │ │ -0001cca0: 6e63 6f64 6564 2063 6861 7261 6374 6572 ncoded character │ │ │ -0001ccb0: 730a 0909 6966 2028 216e 6565 645f 656e s...if (!need_en │ │ │ -0001ccc0: 636f 6469 6e67 2870 6174 682e 635f 7374 coding(path.c_st │ │ │ -0001ccd0: 7228 292c 2069 6e74 2870 6174 682e 7369 r(), int(path.si │ │ │ -0001cce0: 7a65 2829 2929 290a 0909 0972 6574 7572 ze())))....retur │ │ │ -0001ccf0: 6e20 7374 643a 3a73 7472 696e 6728 7572 n std::string(ur │ │ │ -0001cd00: 6c29 3b0a 0a09 0973 7464 3a3a 7374 7269 l);....std::stri │ │ │ -0001cd10: 6e67 206d 7367 3b0a 0909 7374 643a 3a73 ng msg;...std::s │ │ │ -0001cd20: 7472 696e 6720 6573 6361 7065 645f 7061 tring escaped_pa │ │ │ -0001cd30: 7468 207b 2065 7363 6170 655f 7061 7468 th { escape_path │ │ │ -0001cd40: 2870 6174 6829 207d 3b0a 0909 2f2f 2072 (path) };...// r │ │ │ -0001cd50: 6573 6572 7665 2065 6e6f 7567 6820 7370 eserve enough sp │ │ │ -0001cd60: 6163 6520 736f 2066 7572 7468 6572 2061 ace so further a │ │ │ -0001cd70: 7070 656e 6420 7769 6c6c 0a09 092f 2f20 ppend will...// │ │ │ -0001cd80: 6f6e 6c79 2063 6f70 7920 7661 6c75 6573 only copy values │ │ │ -0001cd90: 2074 6f20 6578 6973 7469 6e67 206c 6f63 to existing loc │ │ │ -0001cda0: 6174 696f 6e0a 0909 6d73 672e 7265 7365 ation...msg.rese │ │ │ -0001cdb0: 7276 6528 7072 6f74 6f63 6f6c 2e73 697a rve(protocol.siz │ │ │ -0001cdc0: 6528 2920 2b20 3320 2b20 2f2f 2070 726f e() + 3 + // pro │ │ │ -0001cdd0: 746f 636f 6c20 7061 7274 0a09 0909 6175 tocol part....au │ │ │ -0001cde0: 7468 2e73 697a 6528 2920 2b20 3120 2b20 th.size() + 1 + │ │ │ -0001cdf0: 2f2f 2061 7574 6820 7061 7274 0a3c 2f70 // auth part.

    re │ │ │ -0001ce30: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/pe │ │ │ -0001ce70: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ -0001ce80: 703a 3235 3434 3c2f 613e 3c2f 7464 3e3c p:2544< │ │ │ -0001ce90: 7464 3e74 6869 7320 7368 6f75 6c64 2070 td>this should p │ │ │ -0001cea0: 726f 6261 626c 7920 6265 2062 6173 6564 robably be based │ │ │ -0001ceb0: 206f 6e20 7469 6d65 2069 6e73 7465 6164 on time instead │ │ │ -0001cec0: 206f 6620 6e75 6d62 6572 206f 6620 7265 of number of re │ │ │ -0001ced0: 7175 6573 7420 6d65 7373 6167 6573 2e20 quest messages. │ │ │ -0001cee0: 466f 7220 6120 7665 7279 2068 6967 6820 For a very high │ │ │ -0001cef0: 7468 726f 7567 6870 7574 2063 6f6e 6e65 throughput conne │ │ │ -0001cf00: 6374 696f 6e2c 2033 3030 206d 6179 2062 ction, 300 may b │ │ │ -0001cf10: 6520 6120 6c65 6769 7469 6d61 7465 206e e a legitimate n │ │ │ -0001cf20: 756d 6265 7220 6f66 2072 6571 7565 7374 umber of request │ │ │ -0001cf30: 7320 746f 2068 6176 6520 696e 2066 6c69 s to have in fli │ │ │ -0001cf40: 6768 7420 7768 656e 2067 6574 7469 6e67 ght when getting │ │ │ -0001cf50: 2063 686f 6b65 643c 2f74 643e 3c2f 7472 choked │ │ │ -0001cf90: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0001cfa0: 3c68 323e 7468 6973 2073 686f 756c 6420

    this should │ │ │ -0001cfb0: 7072 6f62 6162 6c79 2062 6520 6261 7365 probably be base │ │ │ -0001cfc0: 6420 6f6e 2074 696d 6520 696e 7374 6561 d on time instea │ │ │ -0001cfd0: 6420 6f66 206e 756d 6265 720a 6f66 2072 d of number.of r │ │ │ -0001cfe0: 6571 7565 7374 206d 6573 7361 6765 732e equest messages. │ │ │ -0001cff0: 2046 6f72 2061 2076 6572 7920 6869 6768 For a very high │ │ │ -0001d000: 2074 6872 6f75 6768 7075 7420 636f 6e6e throughput conn │ │ │ -0001d010: 6563 7469 6f6e 2c20 3330 300a 6d61 7920 ection, 300.may │ │ │ -0001d020: 6265 2061 206c 6567 6974 696d 6174 6520 be a legitimate │ │ │ -0001d030: 6e75 6d62 6572 206f 6620 7265 7175 6573 number of reques │ │ │ -0001d040: 7473 2074 6f20 6861 7665 2069 6e20 666c ts to have in fl │ │ │ -0001d050: 6967 6874 2077 6865 6e0a 6765 7474 696e ight when.gettin │ │ │ -0001d060: 6720 6368 6f6b 6564 3c2f 6832 3e3c 6834 g choked

    ../src/peer_con │ │ │ -0001d080: 6e65 6374 696f 6e2e 6370 703a 3235 3434 nection.cpp:2544 │ │ │ -0001d090: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0001d0d0: 0909 7d0a 2365 6e64 6966 0a0a 0909 0977  ..}.#endif.....w
    │ │ │ -0001d0e0: 7269 7465 5f72 656a 6563 745f 7265 7175  rite_reject_requ
    │ │ │ -0001d0f0: 6573 7428 7229 3b0a 0909 0969 6620 286d  est(r);....if (m
    │ │ │ -0001d100: 5f6e 756d 5f69 6e76 616c 6964 5f72 6571  _num_invalid_req
    │ │ │ -0001d110: 7565 7374 7320 266c 743b 2073 7464 3a3a  uests < std::
    │ │ │ -0001d120: 6e75 6d65 7269 635f 6c69 6d69 7473 266c  numeric_limits&l
    │ │ │ -0001d130: 743b 6465 636c 7479 7065 286d 5f6e 756d  t;decltype(m_num
    │ │ │ -0001d140: 5f69 6e76 616c 6964 5f72 6571 7565 7374  _invalid_request
    │ │ │ -0001d150: 7329 2667 743b 3a3a 6d61 7828 2929 0a09  s)>::max())..
    │ │ │ -0001d160: 0909 092b 2b6d 5f6e 756d 5f69 6e76 616c  ...++m_num_inval
    │ │ │ -0001d170: 6964 5f72 6571 7565 7374 733b 0a0a 0909  id_requests;....
    │ │ │ -0001d180: 0969 6620 2874 2d26 6774 3b61 6c65 7274  .if (t->alert
    │ │ │ -0001d190: 7328 292e 7368 6f75 6c64 5f70 6f73 7426  s().should_post&
    │ │ │ -0001d1a0: 6c74 3b69 6e76 616c 6964 5f72 6571 7565  lt;invalid_reque
    │ │ │ -0001d1b0: 7374 5f61 6c65 7274 2667 743b 2829 290a  st_alert>()).
    │ │ │ -0001d1c0: 0909 097b 0a09 0909 092f 2f20 6d73 7663  ...{.....// msvc
    │ │ │ -0001d1d0: 2031 3220 6170 7065 6172 7320 746f 2064   12 appears to d
    │ │ │ -0001d1e0: 6564 7563 6520 7468 6520 7276 616c 7565  educe the rvalue
    │ │ │ -0001d1f0: 2072 6566 6572 656e 6365 2074 656d 706c   reference templ
    │ │ │ -0001d200: 6174 650a 0909 0909 2f2f 2069 6e63 6f72  ate.....// incor
    │ │ │ -0001d210: 7265 6374 6c79 2066 6f72 2062 6f6f 6c20  rectly for bool 
    │ │ │ -0001d220: 7465 6d70 6f72 6172 6965 732e 2053 6f2c  temporaries. So,
    │ │ │ -0001d230: 2063 7265 6174 6520 6120 6475 6d6d 7920   create a dummy 
    │ │ │ -0001d240: 696e 7374 616e 6365 0a09 0909 0962 6f6f  instance.....boo
    │ │ │ -0001d250: 6c20 636f 6e73 7420 7065 6572 5f69 6e74  l const peer_int
    │ │ │ -0001d260: 6572 6573 7465 6420 3d20 626f 6f6c 286d  erested = bool(m
    │ │ │ -0001d270: 5f70 6565 725f 696e 7465 7265 7374 6564  _peer_interested
    │ │ │ -0001d280: 293b 0a09 0909 0974 2d26 6774 3b61 6c65  );.....t->ale
    │ │ │ -0001d290: 7274 7328 292e 656d 706c 6163 655f 616c  rts().emplace_al
    │ │ │ -0001d2a0: 6572 7426 6c74 3b69 6e76 616c 6964 5f72  ert<invalid_r
    │ │ │ -0001d2b0: 6571 7565 7374 5f61 6c65 7274 2667 743b  equest_alert>
    │ │ │ -0001d2c0: 280a 0909 0909 0974 2d26 6774 3b67 6574  (......t->get
    │ │ │ -0001d2d0: 5f68 616e 646c 6528 292c 2072 656d 6f74  _handle(), remot
    │ │ │ -0001d2e0: 655f 656e 6470 6f69 6e74 2829 2c20 6d5f  e_endpoint(), m_
    │ │ │ -0001d2f0: 7065 6572 5f69 642c 2072 0a09 0909 0909  peer_id, r......
    │ │ │ -0001d300: 2c20 742d 2667 743b 7573 6572 5f68 6176  , t->user_hav
    │ │ │ -0001d310: 655f 7069 6563 6528 722e 7069 6563 6529  e_piece(r.piece)
    │ │ │ -0001d320: 2c20 7065 6572 5f69 6e74 6572 6573 7465  , peer_intereste
    │ │ │ -0001d330: 642c 2066 616c 7365 293b 0a09 0909 7d0a  d, false);....}.
    │ │ │ -0001d340: 0a09 0909 2f2f 2065 7665 7279 2074 656e  ....// every ten
    │ │ │ -0001d350: 2069 6e76 616c 6964 2072 6571 7565 7374   invalid request
    │ │ │ -0001d360: 2c20 7265 6d69 6e64 2074 6865 2070 6565  , remind the pee
    │ │ │ -0001d370: 7220 7468 6174 2069 7427 7320 6368 6f6b  r that it's chok
    │ │ │ -0001d380: 6564 0a09 0909 6966 2028 216d 5f70 6565  ed....if (!m_pee
    │ │ │ -0001d390: 725f 696e 7465 7265 7374 6564 2026 616d  r_interested &am
    │ │ │ -0001d3a0: 703b 2661 6d70 3b20 6d5f 6e75 6d5f 696e  p;& m_num_in
    │ │ │ -0001d3b0: 7661 6c69 645f 7265 7175 6573 7473 2025  valid_requests %
    │ │ │ -0001d3c0: 2031 3020 3d3d 2030 2026 616d 703b 2661   10 == 0 &&a
    │ │ │ -0001d3d0: 6d70 3b20 6d5f 6368 6f6b 6564 290a 0909  mp; m_choked)...
    │ │ │ -0001d3e0: 097b 0a3c 6469 7620 7374 796c 653d 2262  .{.
    ....if (m_num_i │ │ │ -0001d420: 6e76 616c 6964 5f72 6571 7565 7374 7320 nvalid_requests │ │ │ -0001d430: 2667 743b 2033 3030 2026 616d 703b 2661 > 300 &&a │ │ │ -0001d440: 6d70 3b20 216d 5f70 6565 725f 6368 6f6b mp; !m_peer_chok │ │ │ -0001d450: 6564 0a3c 2f64 6976 3e09 0909 0909 2661 ed.
    .....&a │ │ │ -0001d460: 6d70 3b26 616d 703b 2063 616e 5f64 6973 mp;& can_dis │ │ │ -0001d470: 636f 6e6e 6563 7428 6572 726f 7273 3a3a connect(errors:: │ │ │ -0001d480: 746f 6f5f 6d61 6e79 5f72 6571 7565 7374 too_many_request │ │ │ -0001d490: 735f 7768 656e 5f63 686f 6b65 6429 290a s_when_choked)). │ │ │ -0001d4a0: 0909 0909 7b0a 0909 0909 0964 6973 636f ....{......disco │ │ │ -0001d4b0: 6e6e 6563 7428 6572 726f 7273 3a3a 746f nnect(errors::to │ │ │ -0001d4c0: 6f5f 6d61 6e79 5f72 6571 7565 7374 735f o_many_requests_ │ │ │ -0001d4d0: 7768 656e 5f63 686f 6b65 642c 206f 7065 when_choked, ope │ │ │ -0001d4e0: 7261 7469 6f6e 5f74 3a3a 6269 7474 6f72 ration_t::bittor │ │ │ -0001d4f0: 7265 6e74 2c20 7065 6572 5f65 7272 6f72 rent, peer_error │ │ │ -0001d500: 293b 0a09 0909 0909 7265 7475 726e 3b0a );......return;. │ │ │ -0001d510: 0909 0909 7d0a 2369 666e 6465 6620 544f ....}.#ifndef TO │ │ │ -0001d520: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ -0001d530: 4747 494e 470a 0909 0909 7065 6572 5f6c GGING.....peer_l │ │ │ -0001d540: 6f67 2870 6565 725f 6c6f 675f 616c 6572 og(peer_log_aler │ │ │ -0001d550: 743a 3a6f 7574 676f 696e 675f 6d65 7373 t::outgoing_mess │ │ │ -0001d560: 6167 652c 2070 6565 725f 6c6f 675f 616c age, peer_log_al │ │ │ -0001d570: 6572 743a 3a63 686f 6b65 293b 0a23 656e ert::choke);.#en │ │ │ -0001d580: 6469 660a 0909 0909 7772 6974 655f 6368 dif.....write_ch │ │ │ -0001d590: 6f6b 6528 293b 0a09 0909 7d0a 0a09 0909 oke();....}..... │ │ │ -0001d5a0: 7265 7475 726e 3b0a 0909 7d0a 0a09 092f return;...}..../ │ │ │ -0001d5b0: 2f20 6966 2077 6520 6861 7665 2063 686f / if we have cho │ │ │ -0001d5c0: 6b65 6420 7468 6520 636c 6965 6e74 0a09 ked the client.. │ │ │ -0001d5d0: 092f 2f20 6967 6e6f 7265 2074 6865 2072 .// ignore the r │ │ │ -0001d5e0: 6571 7565 7374 0a09 0969 6e74 2063 6f6e equest...int con │ │ │ -0001d5f0: 7374 2062 6c6f 636b 735f 7065 725f 7069 st blocks_per_pi │ │ │ -0001d600: 6563 6520 3d0a 0909 0928 7469 2e70 6965 ece =....(ti.pie │ │ │ -0001d610: 6365 5f6c 656e 6774 6828 2920 2b20 742d ce_length() + t- │ │ │ -0001d620: 2667 743b 626c 6f63 6b5f 7369 7a65 2829 >block_size() │ │ │ -0001d630: 202d 2031 2920 2f20 742d 2667 743b 626c - 1) / t->bl │ │ │ -0001d640: 6f63 6b5f 7369 7a65 2829 3b0a 0a09 092f ock_size();..../ │ │ │ -0001d650: 2f20 6469 7363 6f6e 6e65 6374 2070 6565 / disconnect pee │ │ │ -0001d660: 7273 2074 6861 7420 646f 776e 6c6f 6164 rs that download │ │ │ -0001d670: 7320 6d6f 7265 2074 6861 6e20 666f 6f20 s more than foo │ │ │ -0001d680: 7469 6d65 7320 616e 2061 6c6c 6f77 6564 times an allowed │ │ │ -0001d690: 0a09 092f 2f20 6661 7374 2070 6965 6365 ...// fast piece │ │ │ -0001d6a0: 0a09 0969 6620 286d 5f63 686f 6b65 6420 ...if (m_choked │ │ │ -0001d6b0: 2661 6d70 3b26 616d 703b 2066 6173 745f && fast_ │ │ │ -0001d6c0: 6964 7820 213d 202d 3120 2661 6d70 3b26 idx != -1 && │ │ │ -0001d6d0: 616d 703b 206d 5f61 6363 6570 745f 6661 amp; m_accept_fa │ │ │ -0001d6e0: 7374 5f70 6965 6365 5f63 6e74 5b66 6173 st_piece_cnt[fas │ │ │ -0001d6f0: 745f 6964 785d 2026 6774 3b3d 2033 202a t_idx] >= 3 * │ │ │ -0001d700: 2062 6c6f 636b 735f 7065 725f 7069 6563 blocks_per_piec │ │ │ -0001d710: 650a 0909 0926 616d 703b 2661 6d70 3b20 e....&& │ │ │ -0001d720: 6361 6e5f 6469 7363 6f6e 6e65 6374 2865 can_disconnect(e │ │ │ -0001d730: 7272 6f72 733a 3a74 6f6f 5f6d 616e 795f rrors::too_many_ │ │ │ -0001d740: 7265 7175 6573 7473 5f77 6865 6e5f 6368 requests_when_ch │ │ │ -0001d750: 6f6b 6564 2929 0a09 097b 0a09 0909 6469 oked))...{....di │ │ │ -0001d760: 7363 6f6e 6e65 6374 2865 7272 6f72 733a sconnect(errors: │ │ │ -0001d770: 3a74 6f6f 5f6d 616e 795f 7265 7175 6573 :too_many_reques │ │ │ -0001d780: 7473 5f77 6865 6e5f 6368 6f6b 6564 2c20 ts_when_choked, │ │ │ -0001d790: 6f70 6572 6174 696f 6e5f 743a 3a62 6974 operation_t::bit │ │ │ -0001d7a0: 746f 7272 656e 742c 2070 6565 725f 6572 torrent, peer_er │ │ │ -0001d7b0: 726f 7229 3b0a 0909 0972 6574 7572 6e3b ror);....return; │ │ │ -0001d7c0: 0a09 097d 0a0a 0909 6966 2028 6d5f 6368 ...}....if (m_ch │ │ │ -0001d7d0: 6f6b 6564 2026 616d 703b 2661 6d70 3b20 oked && │ │ │ -0001d7e0: 6661 7374 5f69 6478 203d 3d20 2d31 290a fast_idx == -1). │ │ │ -0001d7f0: 0909 7b0a 3c2f 7072 653e 3c2f 7464 3e3c ..{.
    < │ │ │ -0001d800: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0001d830: 6273 703b 323c 2f74 643e 3c74 643e 3c61 bsp;2.. │ │ │ -0001d860: 2f73 7263 2f70 6565 725f 636f 6e6e 6563 /src/peer_connec │ │ │ -0001d870: 7469 6f6e 2e63 7070 3a33 3330 373c 2f61 tion.cpp:3307since │ │ │ -0001d890: 7765 2074 6872 6f77 2061 7761 7920 7468 we throw away th │ │ │ -0001d8a0: 6520 7175 6575 6520 656e 7472 7920 6f6e e queue entry on │ │ │ -0001d8b0: 6365 2077 6520 6973 7375 6520 7468 6520 ce we issue the │ │ │ -0001d8c0: 6469 736b 206a 6f62 2c20 7468 6973 206d disk job, this m │ │ │ -0001d8d0: 6179 2068 6170 7065 6e2e 2049 6e73 7465 ay happen. Inste │ │ │ -0001d8e0: 6164 2c20 7765 2073 686f 756c 6420 6b65 ad, we should ke │ │ │ -0001d8f0: 6570 2074 6865 2071 7565 7565 2065 6e74 ep the queue ent │ │ │ -0001d900: 7279 2061 726f 756e 642c 206d 6172 6b20 ry around, mark │ │ │ -0001d910: 6974 2061 7320 6861 7669 6e67 2062 6565 it as having bee │ │ │ -0001d920: 6e20 7265 7175 6573 7465 6420 6672 6f6d n requested from │ │ │ -0001d930: 2064 6973 6b20 616e 6420 6f6e 6365 2074 disk and once t │ │ │ -0001d940: 6865 2064 6973 6b20 6a6f 6220 636f 6d65 he disk job come │ │ │ -0001d950: 7320 6261 636b 2c20 6469 7363 6172 6420 s back, discard │ │ │ -0001d960: 6974 2069 6620 6974 2068 6173 2062 6565 it if it has bee │ │ │ -0001d970: 6e20 6361 6e63 656c 6c65 642e 204d 6179 n cancelled. May │ │ │ -0001d980: 6265 2065 7665 6e20 6265 2061 626c 6520 be even be able │ │ │ -0001d990: 746f 2063 616e 6365 6c20 6469 736b 206a to cancel disk j │ │ │ -0001d9a0: 6f62 733f 3c2f 7464 3e3c 2f74 723e 3c74 obs?

    since we throw │ │ │ -0001da00: 6177 6179 2074 6865 2071 7565 7565 2065 away the queue e │ │ │ -0001da10: 6e74 7279 206f 6e63 6520 7765 2069 7373 ntry once we iss │ │ │ -0001da20: 7565 0a74 6865 2064 6973 6b20 6a6f 622c ue.the disk job, │ │ │ -0001da30: 2074 6869 7320 6d61 7920 6861 7070 656e this may happen │ │ │ -0001da40: 2e20 496e 7374 6561 642c 2077 6520 7368 . Instead, we sh │ │ │ -0001da50: 6f75 6c64 206b 6565 7020 7468 650a 7175 ould keep the.qu │ │ │ -0001da60: 6575 6520 656e 7472 7920 6172 6f75 6e64 eue entry around │ │ │ -0001da70: 2c20 6d61 726b 2069 7420 6173 2068 6176 , mark it as hav │ │ │ -0001da80: 696e 6720 6265 656e 2072 6571 7565 7374 ing been request │ │ │ -0001da90: 6564 2066 726f 6d0a 6469 736b 2061 6e64 ed from.disk and │ │ │ -0001daa0: 206f 6e63 6520 7468 6520 6469 736b 206a once the disk j │ │ │ -0001dab0: 6f62 2063 6f6d 6573 2062 6163 6b2c 2064 ob comes back, d │ │ │ -0001dac0: 6973 6361 7264 2069 7420 6966 2069 7420 iscard it if it │ │ │ -0001dad0: 6861 730a 6265 656e 2063 616e 6365 6c6c has.been cancell │ │ │ -0001dae0: 6564 2e20 4d61 7962 6520 6576 656e 2062 ed. Maybe even b │ │ │ -0001daf0: 6520 6162 6c65 2074 6f20 6361 6e63 656c e able to cancel │ │ │ -0001db00: 2064 6973 6b20 6a6f 6273 3f3c 2f68 323e disk jobs?

    │ │ │ -0001db10: 3c68 343e 2e2e 2f73 7263 2f70 6565 725f

    ../src/peer_ │ │ │ -0001db20: 636f 6e6e 6563 7469 6f6e 2e63 7070 3a33 connection.cpp:3 │ │ │ -0001db30: 3330 373c 2f68 343e 3c70 7265 2073 7479 307

    ..{....if (e-&
    │ │ │ -0001db80: 6774 3b6f 6e5f 6361 6e63 656c 2872 2929  gt;on_cancel(r))
    │ │ │ -0001db90: 2072 6574 7572 6e3b 0a09 097d 0a23 656e   return;...}.#en
    │ │ │ -0001dba0: 6469 660a 0909 6966 2028 6973 5f64 6973  dif...if (is_dis
    │ │ │ -0001dbb0: 636f 6e6e 6563 7469 6e67 2829 2920 7265  connecting()) re
    │ │ │ -0001dbc0: 7475 726e 3b0a 0a09 0961 7574 6f20 636f  turn;....auto co
    │ │ │ -0001dbd0: 6e73 7420 6920 3d20 7374 643a 3a66 696e  nst i = std::fin
    │ │ │ -0001dbe0: 6428 6d5f 7265 7175 6573 7473 2e62 6567  d(m_requests.beg
    │ │ │ -0001dbf0: 696e 2829 2c20 6d5f 7265 7175 6573 7473  in(), m_requests
    │ │ │ -0001dc00: 2e65 6e64 2829 2c20 7229 3b0a 0a09 0969  .end(), r);....i
    │ │ │ -0001dc10: 6620 2869 2021 3d20 6d5f 7265 7175 6573  f (i != m_reques
    │ │ │ -0001dc20: 7473 2e65 6e64 2829 290a 0909 7b0a 0909  ts.end())...{...
    │ │ │ -0001dc30: 096d 5f63 6f75 6e74 6572 732e 696e 635f  .m_counters.inc_
    │ │ │ -0001dc40: 7374 6174 735f 636f 756e 7465 7228 636f  stats_counter(co
    │ │ │ -0001dc50: 756e 7465 7273 3a3a 6361 6e63 656c 6c65  unters::cancelle
    │ │ │ -0001dc60: 645f 7069 6563 655f 7265 7175 6573 7473  d_piece_requests
    │ │ │ -0001dc70: 293b 0a09 0909 6d5f 7265 7175 6573 7473  );....m_requests
    │ │ │ -0001dc80: 2e65 7261 7365 2869 293b 0a0a 0909 0969  .erase(i);.....i
    │ │ │ -0001dc90: 6620 286d 5f72 6571 7565 7374 732e 656d  f (m_requests.em
    │ │ │ -0001dca0: 7074 7928 2929 0a09 0909 096d 5f63 6f75  pty()).....m_cou
    │ │ │ -0001dcb0: 6e74 6572 732e 696e 635f 7374 6174 735f  nters.inc_stats_
    │ │ │ -0001dcc0: 636f 756e 7465 7228 636f 756e 7465 7273  counter(counters
    │ │ │ -0001dcd0: 3a3a 6e75 6d5f 7065 6572 735f 7570 5f72  ::num_peers_up_r
    │ │ │ -0001dce0: 6571 7565 7374 732c 202d 3129 3b0a 0a09  equests, -1);...
    │ │ │ -0001dcf0: 0909 7772 6974 655f 7265 6a65 6374 5f72  ..write_reject_r
    │ │ │ -0001dd00: 6571 7565 7374 2872 293b 0a09 097d 0a09  equest(r);...}..
    │ │ │ -0001dd10: 0965 6c73 650a 0909 7b0a 3c64 6976 2073  .else...{.
    #ifndef │ │ │ -0001dd50: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -0001dd60: 4c4f 4747 494e 470a 3c2f 6469 763e 0909 LOGGING.
    .. │ │ │ -0001dd70: 0970 6565 725f 6c6f 6728 7065 6572 5f6c .peer_log(peer_l │ │ │ -0001dd80: 6f67 5f61 6c65 7274 3a3a 696e 666f 2c20 og_alert::info, │ │ │ -0001dd90: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a peer_log_alert:: │ │ │ -0001dda0: 696e 7661 6c69 645f 6361 6e63 656c 2c20 invalid_cancel, │ │ │ -0001ddb0: 2267 6f74 2063 616e 6365 6c20 6e6f 7420 "got cancel not │ │ │ -0001ddc0: 696e 2074 6865 2071 7565 7565 2229 3b0a in the queue");. │ │ │ -0001ddd0: 2365 6e64 6966 0a09 097d 0a09 7d0a 0a09 #endif...}..}... │ │ │ -0001dde0: 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d // ------------- │ │ │ -0001ddf0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0001de00: 0a09 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2044 ..// --------- D │ │ │ -0001de10: 4854 2050 4f52 5420 2d2d 2d2d 2d2d 2d2d HT PORT -------- │ │ │ -0001de20: 2d2d 0a09 2f2f 202d 2d2d 2d2d 2d2d 2d2d --..// --------- │ │ │ -0001de30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0001de40: 2d2d 2d2d 0a0a 0976 6f69 6420 7065 6572 ----...void peer │ │ │ -0001de50: 5f63 6f6e 6e65 6374 696f 6e3a 3a69 6e63 _connection::inc │ │ │ -0001de60: 6f6d 696e 675f 6468 745f 706f 7274 2869 oming_dht_port(i │ │ │ -0001de70: 6e74 2063 6f6e 7374 206c 6973 7465 6e5f nt const listen_ │ │ │ -0001de80: 706f 7274 290a 097b 0a09 0954 4f52 5245 port)..{...TORRE │ │ │ -0001de90: 4e54 5f41 5353 4552 5428 6973 5f73 696e NT_ASSERT(is_sin │ │ │ -0001dea0: 676c 655f 7468 7265 6164 2829 293b 0a09 gle_thread());.. │ │ │ -0001deb0: 0949 4e56 4152 4941 4e54 5f43 4845 434b .INVARIANT_CHECK │ │ │ -0001dec0: 3b0a 0a23 6966 6e64 6566 2054 4f52 5245 ;..#ifndef TORRE │ │ │ -0001ded0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ -0001dee0: 4e47 0a09 0970 6565 725f 6c6f 6728 7065 NG...peer_log(pe │ │ │ -0001def0: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 696e er_log_alert::in │ │ │ -0001df00: 636f 6d69 6e67 5f6d 6573 7361 6765 2c20 coming_message, │ │ │ -0001df10: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a peer_log_alert:: │ │ │ -0001df20: 6468 745f 706f 7274 2c20 2270 3a20 2564 dht_port, "p: %d │ │ │ -0001df30: 222c 206c 6973 7465 6e5f 706f 7274 293b ", listen_port); │ │ │ -0001df40: 0a23 656e 6469 660a 2369 666e 6465 6620 .#endif.#ifndef │ │ │ -0001df50: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -0001df60: 4448 540a 0909 6d5f 7365 732e 6164 645f DHT...m_ses.add_ │ │ │ -0001df70: 6468 745f 6e6f 6465 287b 6d5f 7265 6d6f dht_node({m_remo │ │ │ -0001df80: 7465 2e61 6464 7265 7373 2829 2c20 7374 te.address(), st │ │ │ -0001df90: 643a 3a75 696e 7431 365f 7428 6c69 7374 d::uint16_t(list │ │ │ -0001dfa0: 656e 5f70 6f72 7429 7d29 3b0a 2365 6c73 en_port)});.#els │ │ │ -0001dfb0: 650a 0909 544f 5252 454e 545f 554e 5553 e...TORRENT_UNUS │ │ │ -0001dfc0: 4544 286c 6973 7465 6e5f 706f 7274 293b ED(listen_port); │ │ │ -0001dfd0: 0a23 656e 6469 660a 097d 0a0a 092f 2f20 .#endif..}...// │ │ │ -0001dfe0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0001dff0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 092f -------------../ │ │ │ -0001e000: 2f20 2d2d 2d2d 2d2d 2d2d 2d20 4841 5645 / --------- HAVE │ │ │ -0001e010: 2041 4c4c 202d 2d2d 2d2d 2d2d 2d2d 2d0a ALL ----------. │ │ │ -0001e020: 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d .// ------------ │ │ │ -0001e030: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0001e040: 2d0a 0a09 766f 6964 2070 6565 725f 636f -...void peer_co │ │ │ -0001e050: 6e6e 6563 7469 6f6e 3a3a 696e 636f 6d69 nnection::incomi │ │ │ -0001e060: 6e67 5f68 6176 655f 616c 6c28 290a 097b ng_have_all()..{ │ │ │ -0001e070: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0001e0b0: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../sr │ │ │ -0001e0e0: 632f 7065 6572 5f63 6f6e 6e65 6374 696f c/peer_connectio │ │ │ -0001e0f0: 6e2e 6370 703a 3439 3531 3c2f 613e 3c2f n.cpp:4951use a dea │ │ │ -0001e110: 646c 696e 655f 7469 6d65 7220 666f 7220 dline_timer for │ │ │ -0001e120: 7469 6d65 6f75 7473 2e20 446f 6e27 7420 timeouts. Don't │ │ │ -0001e130: 7265 6c79 206f 6e20 7365 636f 6e64 5f74 rely on second_t │ │ │ -0001e140: 6963 6b28 2921 2048 6f6f 6b20 7468 6973 ick()! Hook this │ │ │ -0001e150: 2075 7020 746f 2063 6f6e 6e65 6374 2074 up to connect t │ │ │ -0001e160: 696d 656f 7574 2061 7320 7765 6c6c 2e20 imeout as well. │ │ │ -0001e170: 5468 6973 2077 6f75 6c64 2069 6d70 726f This would impro │ │ │ -0001e180: 7665 2070 6572 666f 726d 616e 6365 2062 ve performance b │ │ │ -0001e190: 6563 6175 7365 206f 6620 6c65 7373 2077 ecause of less w │ │ │ -0001e1a0: 6f72 6b20 696e 2073 6563 6f6e 645f 7469 ork in second_ti │ │ │ -0001e1b0: 636b 2829 2c20 616e 6420 6d69 6768 7420 ck(), and might │ │ │ -0001e1c0: 6c65 7420 7573 6520 7265 6d6f 7665 2074 let use remove t │ │ │ -0001e1d0: 6963 6b69 6e67 2065 6e74 6972 656c 7920 icking entirely │ │ │ -0001e1e0: 6576 656e 7475 616c 6c79 3c2f 7464 3e3c eventually< │ │ │ -0001e1f0: 2f74 723e 3c74 7220 6964 3d22 3539 2220 /tr>

    use a dea │ │ │ -0001e240: 646c 696e 655f 7469 6d65 7220 666f 7220 dline_timer for │ │ │ -0001e250: 7469 6d65 6f75 7473 2e20 446f 6e27 7420 timeouts. Don't │ │ │ -0001e260: 7265 6c79 206f 6e20 7365 636f 6e64 5f74 rely on second_t │ │ │ -0001e270: 6963 6b28 2921 0a48 6f6f 6b20 7468 6973 ick()!.Hook this │ │ │ -0001e280: 2075 7020 746f 2063 6f6e 6e65 6374 2074 up to connect t │ │ │ -0001e290: 696d 656f 7574 2061 7320 7765 6c6c 2e20 imeout as well. │ │ │ -0001e2a0: 5468 6973 2077 6f75 6c64 2069 6d70 726f This would impro │ │ │ -0001e2b0: 7665 2070 6572 666f 726d 616e 6365 0a62 ve performance.b │ │ │ -0001e2c0: 6563 6175 7365 206f 6620 6c65 7373 2077 ecause of less w │ │ │ -0001e2d0: 6f72 6b20 696e 2073 6563 6f6e 645f 7469 ork in second_ti │ │ │ -0001e2e0: 636b 2829 2c20 616e 6420 6d69 6768 7420 ck(), and might │ │ │ -0001e2f0: 6c65 7420 7573 6520 7265 6d6f 7665 2074 let use remove t │ │ │ -0001e300: 6963 6b69 6e67 0a65 6e74 6972 656c 7920 icking.entirely │ │ │ -0001e310: 6576 656e 7475 616c 6c79 3c2f 6832 3e3c eventually

    < │ │ │ -0001e320: 6834 3e2e 2e2f 7372 632f 7065 6572 5f63 h4>../src/peer_c │ │ │ -0001e330: 6f6e 6e65 6374 696f 6e2e 6370 703a 3439 onnection.cpp:49 │ │ │ -0001e340: 3531 3c2f 6834 3e3c 7072 6520 7374 796c 51
    ...if (d > s
    │ │ │ -0001e390: 6563 6f6e 6473 2863 6f6e 6e65 6374 5f74  econds(connect_t
    │ │ │ -0001e3a0: 696d 656f 7574 290a 0909 0909 2661 6d70  imeout).....&
    │ │ │ -0001e3b0: 3b26 616d 703b 2063 616e 5f64 6973 636f  ;& can_disco
    │ │ │ -0001e3c0: 6e6e 6563 7428 6572 726f 7273 3a3a 7469  nnect(errors::ti
    │ │ │ -0001e3d0: 6d65 645f 6f75 7429 290a 0909 097b 0a23  med_out))....{.#
    │ │ │ -0001e3e0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -0001e3f0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ -0001e400: 0909 0970 6565 725f 6c6f 6728 7065 6572  ...peer_log(peer
    │ │ │ -0001e410: 5f6c 6f67 5f61 6c65 7274 3a3a 696e 666f  _log_alert::info
    │ │ │ -0001e420: 2c20 7065 6572 5f6c 6f67 5f61 6c65 7274  , peer_log_alert
    │ │ │ -0001e430: 3a3a 636f 6e6e 6563 745f 6661 696c 6564  ::connect_failed
    │ │ │ -0001e440: 2c20 2277 6169 7465 6420 2564 2073 6563  , "waited %d sec
    │ │ │ -0001e450: 6f6e 6473 220a 0909 0909 092c 2069 6e74  onds"......, int
    │ │ │ -0001e460: 2874 6f74 616c 5f73 6563 6f6e 6473 2864  (total_seconds(d
    │ │ │ -0001e470: 2929 293b 0a23 656e 6469 660a 0909 0909  )));.#endif.....
    │ │ │ -0001e480: 636f 6e6e 6563 745f 6661 696c 6564 2865  connect_failed(e
    │ │ │ -0001e490: 7272 6f72 733a 3a74 696d 6564 5f6f 7574  rrors::timed_out
    │ │ │ -0001e4a0: 293b 0a09 0909 0972 6574 7572 6e3b 0a09  );.....return;..
    │ │ │ -0001e4b0: 0909 7d0a 0909 7d0a 0a09 092f 2f20 6966  ..}...}....// if
    │ │ │ -0001e4c0: 2074 6865 2062 775f 6e65 7477 6f72 6b20   the bw_network 
    │ │ │ -0001e4d0: 666c 6167 2069 736e 2774 2073 6574 2c20  flag isn't set, 
    │ │ │ -0001e4e0: 6974 206d 6561 6e73 2077 6520 6172 6520  it means we are 
    │ │ │ -0001e4f0: 6e6f 7420 6576 656e 2074 7279 696e 6720  not even trying 
    │ │ │ -0001e500: 746f 0a09 092f 2f20 7265 6164 2066 726f  to...// read fro
    │ │ │ -0001e510: 6d20 7468 6973 2070 6565 7227 7320 736f  m this peer's so
    │ │ │ -0001e520: 636b 6574 2e20 4d6f 7374 206c 696b 656c  cket. Most likel
    │ │ │ -0001e530: 7920 6265 6361 7573 6520 7765 2772 6520  y because we're 
    │ │ │ -0001e540: 6170 706c 7969 6e67 2061 0a09 092f 2f20  applying a...// 
    │ │ │ -0001e550: 7261 7465 206c 696d 6974 2e20 4966 2074  rate limit. If t
    │ │ │ -0001e560: 6865 2070 6565 7220 6973 2022 736c 6f77  he peer is "slow
    │ │ │ -0001e570: 2220 6265 6361 7573 6520 7765 2061 7265  " because we are
    │ │ │ -0001e580: 2072 6174 6520 6c69 6d69 7469 6e67 2069   rate limiting i
    │ │ │ -0001e590: 742c 0a09 092f 2f20 646f 6e27 7420 656e  t,...// don't en
    │ │ │ -0001e5a0: 666f 7263 6520 7469 6d65 6f75 7473 2e20  force timeouts. 
    │ │ │ -0001e5b0: 486f 7765 7665 722c 2061 7320 736f 6f6e  However, as soon
    │ │ │ -0001e5c0: 2061 7320 7765 202a 646f 2a20 7265 6164   as we *do* read
    │ │ │ -0001e5d0: 2066 726f 6d20 7468 650a 0909 2f2f 2073   from the...// s
    │ │ │ -0001e5e0: 6f63 6b65 742c 2077 6520 6578 7065 6374  ocket, we expect
    │ │ │ -0001e5f0: 2074 6f20 7265 6365 6976 6520 6461 7461   to receive data
    │ │ │ -0001e600: 2c20 616e 6420 6e6f 7420 6861 7665 2074  , and not have t
    │ │ │ -0001e610: 696d 6564 206f 7574 2e20 5468 656e 2077  imed out. Then w
    │ │ │ -0001e620: 650a 0909 2f2f 2063 616e 2065 6e66 6f72  e...// can enfor
    │ │ │ -0001e630: 6365 2074 6865 2074 696d 656f 7574 732e  ce the timeouts.
    │ │ │ -0001e640: 0a09 0962 6f6f 6c20 636f 6e73 7420 7265  ...bool const re
    │ │ │ -0001e650: 6164 696e 675f 736f 636b 6574 203d 2062  ading_socket = b
    │ │ │ -0001e660: 6f6f 6c28 6d5f 6368 616e 6e65 6c5f 7374  ool(m_channel_st
    │ │ │ -0001e670: 6174 655b 646f 776e 6c6f 6164 5f63 6861  ate[download_cha
    │ │ │ -0001e680: 6e6e 656c 5d20 2661 6d70 3b20 7065 6572  nnel] & peer
    │ │ │ -0001e690: 5f69 6e66 6f3a 3a62 775f 6e65 7477 6f72  _info::bw_networ
    │ │ │ -0001e6a0: 6b29 3b0a 0a3c 6469 7620 7374 796c 653d  k);..
    ..if (reading │ │ │ -0001e6e0: 5f73 6f63 6b65 7420 2661 6d70 3b26 616d _socket &&am │ │ │ -0001e6f0: 703b 2064 2026 6774 3b20 7365 636f 6e64 p; d > second │ │ │ -0001e700: 7328 7469 6d65 6f75 7428 2929 2026 616d s(timeout()) &am │ │ │ -0001e710: 703b 2661 6d70 3b20 216d 5f63 6f6e 6e65 p;& !m_conne │ │ │ -0001e720: 6374 696e 6720 2661 6d70 3b26 616d 703b cting && │ │ │ -0001e730: 206d 5f72 6561 6469 6e67 5f62 7974 6573 m_reading_bytes │ │ │ -0001e740: 203d 3d20 300a 3c2f 6469 763e 0909 0926 == 0.
    ...& │ │ │ -0001e750: 616d 703b 2661 6d70 3b20 6361 6e5f 6469 amp;& can_di │ │ │ -0001e760: 7363 6f6e 6e65 6374 2865 7272 6f72 733a sconnect(errors: │ │ │ -0001e770: 3a74 696d 6564 5f6f 7574 5f69 6e61 6374 :timed_out_inact │ │ │ -0001e780: 6976 6974 7929 290a 0909 7b0a 2369 666e ivity))...{.#ifn │ │ │ -0001e790: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -0001e7a0: 424c 455f 4c4f 4747 494e 470a 0909 0970 BLE_LOGGING....p │ │ │ -0001e7b0: 6565 725f 6c6f 6728 7065 6572 5f6c 6f67 eer_log(peer_log │ │ │ -0001e7c0: 5f61 6c65 7274 3a3a 696e 666f 2c20 7065 _alert::info, pe │ │ │ -0001e7d0: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 6c61 er_log_alert::la │ │ │ -0001e7e0: 7374 5f61 6374 6976 6974 792c 2022 2564 st_activity, "%d │ │ │ -0001e7f0: 2073 6563 6f6e 6473 2061 676f 220a 0909 seconds ago"... │ │ │ -0001e800: 0909 2c20 696e 7428 746f 7461 6c5f 7365 .., int(total_se │ │ │ -0001e810: 636f 6e64 7328 6429 2929 3b0a 2365 6e64 conds(d)));.#end │ │ │ -0001e820: 6966 0a09 0909 6469 7363 6f6e 6e65 6374 if....disconnect │ │ │ -0001e830: 2865 7272 6f72 733a 3a74 696d 6564 5f6f (errors::timed_o │ │ │ -0001e840: 7574 5f69 6e61 6374 6976 6974 792c 206f ut_inactivity, o │ │ │ -0001e850: 7065 7261 7469 6f6e 5f74 3a3a 6269 7474 peration_t::bitt │ │ │ -0001e860: 6f72 7265 6e74 293b 0a09 0909 7265 7475 orrent);....retu │ │ │ -0001e870: 726e 3b0a 0909 7d0a 0a09 092f 2f20 646f rn;...}....// do │ │ │ -0001e880: 206e 6f74 2073 7461 6c6c 2077 6169 7469 not stall waiti │ │ │ -0001e890: 6e67 2066 6f72 2061 2068 616e 6473 6861 ng for a handsha │ │ │ -0001e8a0: 6b65 0a09 0969 6e74 2074 696d 656f 7574 ke...int timeout │ │ │ -0001e8b0: 203d 206d 5f73 6574 7469 6e67 732e 6765 = m_settings.ge │ │ │ -0001e8c0: 745f 696e 7420 2873 6574 7469 6e67 735f t_int (settings_ │ │ │ -0001e8d0: 7061 636b 3a3a 6861 6e64 7368 616b 655f pack::handshake_ │ │ │ -0001e8e0: 7469 6d65 6f75 7429 3b0a 2369 6620 544f timeout);.#if TO │ │ │ -0001e8f0: 5252 454e 545f 5553 455f 4932 500a 0909 RRENT_USE_I2P... │ │ │ -0001e900: 7469 6d65 6f75 7420 2a3d 2069 735f 6932 timeout *= is_i2 │ │ │ -0001e910: 7028 6d5f 736f 636b 6574 2920 3f20 3420 p(m_socket) ? 4 │ │ │ -0001e920: 3a20 313b 0a23 656e 6469 660a 0909 6966 : 1;.#endif...if │ │ │ -0001e930: 2028 7265 6164 696e 675f 736f 636b 6574 (reading_socket │ │ │ -0001e940: 0a09 0909 2661 6d70 3b26 616d 703b 2021 ....&& ! │ │ │ -0001e950: 6d5f 636f 6e6e 6563 7469 6e67 0a09 0909 m_connecting.... │ │ │ -0001e960: 2661 6d70 3b26 616d 703b 2069 6e5f 6861 && in_ha │ │ │ -0001e970: 6e64 7368 616b 6528 290a 0909 0926 616d ndshake()....&am │ │ │ -0001e980: 703b 2661 6d70 3b20 6420 2667 743b 2073 p;& d > s │ │ │ -0001e990: 6563 6f6e 6473 2874 696d 656f 7574 2929 econds(timeout)) │ │ │ -0001e9a0: 0a09 097b 0a23 6966 6e64 6566 2054 4f52 ...{.#ifndef TOR │ │ │ -0001e9b0: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ -0001e9c0: 4749 4e47 0a09 0909 7065 6572 5f6c 6f67 GING....peer_log │ │ │ -0001e9d0: 2870 6565 725f 6c6f 675f 616c 6572 743a (peer_log_alert: │ │ │ -0001e9e0: 3a69 6e66 6f2c 2070 6565 725f 6c6f 675f :info, peer_log_ │ │ │ -0001e9f0: 616c 6572 743a 3a6e 6f5f 6861 6e64 7368 alert::no_handsh │ │ │ -0001ea00: 616b 652c 2022 7761 6974 6564 2025 6420 ake, "waited %d │ │ │ -0001ea10: 7365 636f 6e64 7322 0a09 0909 092c 2069 seconds"....., i │ │ │ -0001ea20: 6e74 2874 6f74 616c 5f73 6563 6f6e 6473 nt(total_seconds │ │ │ -0001ea30: 2864 2929 293b 0a23 656e 6469 660a 0909 (d)));.#endif... │ │ │ -0001ea40: 0964 6973 636f 6e6e 6563 7428 6572 726f .disconnect(erro │ │ │ -0001ea50: 7273 3a3a 7469 6d65 645f 6f75 745f 6e6f rs::timed_out_no │ │ │ -0001ea60: 5f68 616e 6473 6861 6b65 2c20 6f70 6572 _handshake, oper │ │ │ -0001ea70: 6174 696f 6e5f 743a 3a62 6974 746f 7272 ation_t::bittorr │ │ │ -0001ea80: 656e 7429 3b0a 0909 0972 6574 7572 6e3b ent);....return; │ │ │ -0001ea90: 0a09 097d 0a0a 0909 2f2f 2064 6973 636f ...}....// disco │ │ │ -0001eaa0: 6e6e 6563 7420 7065 6572 7320 7468 6174 nnect peers that │ │ │ -0001eab0: 2077 6520 756e 6368 6f6b 6564 2c20 6275 we unchoked, bu │ │ │ -0001eac0: 7420 7468 6579 2064 6964 6e27 7420 7365 t they didn't se │ │ │ -0001ead0: 6e64 2061 2072 6571 7565 7374 2069 6e0a nd a request in. │ │ │ -0001eae0: 0909 2f2f 2074 6865 206c 6173 7420 3630 ..// the last 60 │ │ │ -0001eaf0: 2073 6563 6f6e 6473 2c20 616e 6420 7765 seconds, and we │ │ │ -0001eb00: 2068 6176 656e 2774 2062 6565 6e20 776f haven't been wo │ │ │ -0001eb10: 726b 696e 6720 6f6e 2073 6572 7669 6369 rking on servici │ │ │ -0001eb20: 6e67 2061 2072 6571 7565 7374 0a3c 2f70 ng a request.

    re │ │ │ -0001eb60: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/se │ │ │ -0001eba0: 7373 696f 6e5f 696d 706c 2e63 7070 3a35 ssion_impl.cpp:5 │ │ │ -0001ebb0: 3636 3c2f 613e 3c2f 7464 3e3c 7464 3e69 66i │ │ │ -0001ebc0: 7320 7468 6572 6520 6120 7265 6173 6f6e s there a reason │ │ │ -0001ebd0: 206e 6f74 2074 6f20 6d6f 7665 2061 6c6c not to move all │ │ │ -0001ebe0: 206f 6620 7468 6973 2069 6e74 6f20 696e of this into in │ │ │ -0001ebf0: 6974 2829 3f20 616e 6420 6a75 7374 2070 it()? and just p │ │ │ -0001ec00: 6f73 7420 6974 2074 6f20 7468 6520 696f ost it to the io │ │ │ -0001ec10: 5f63 6f6e 7465 7874 3f3c 2f74 643e 3c2f _context?

    is there a │ │ │ -0001ec70: 2072 6561 736f 6e20 6e6f 7420 746f 206d reason not to m │ │ │ -0001ec80: 6f76 6520 616c 6c20 6f66 2074 6869 7320 ove all of this │ │ │ -0001ec90: 696e 746f 2069 6e69 7428 293f 2061 6e64 into init()? and │ │ │ -0001eca0: 206a 7573 740a 706f 7374 2069 7420 746f just.post it to │ │ │ -0001ecb0: 2074 6865 2069 6f5f 636f 6e74 6578 743f the io_context? │ │ │ -0001ecc0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0001ecd0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -0001ece0: 3a35 3636 3c2f 6834 3e3c 7072 6520 7374 :566

    .try.#endif..
    │ │ │ -0001ed30: 7b0a 0909 2874 6869 732d 2667 743b 2a66  {...(this->*f
    │ │ │ -0001ed40: 2928 7374 643a 3a66 6f72 7761 7264 266c  )(std::forward&l
    │ │ │ -0001ed50: 743b 4172 6773 2667 743b 2861 292e 2e2e  t;Args>(a)...
    │ │ │ -0001ed60: 293b 0a09 7d0a 2369 666e 6465 6620 424f  );..}.#ifndef BO
    │ │ │ -0001ed70: 4f53 545f 4e4f 5f45 5843 4550 5449 4f4e  OST_NO_EXCEPTION
    │ │ │ -0001ed80: 530a 0963 6174 6368 2028 7379 7374 656d  S..catch (system
    │ │ │ -0001ed90: 5f65 7272 6f72 2063 6f6e 7374 2661 6d70  _error const&
    │ │ │ -0001eda0: 3b20 6529 207b 0a09 0961 6c65 7274 7328  ; e) {...alerts(
    │ │ │ -0001edb0: 292e 656d 706c 6163 655f 616c 6572 7426  ).emplace_alert&
    │ │ │ -0001edc0: 6c74 3b73 6573 7369 6f6e 5f65 7272 6f72  lt;session_error
    │ │ │ -0001edd0: 5f61 6c65 7274 2667 743b 2865 2e63 6f64  _alert>(e.cod
    │ │ │ -0001ede0: 6528 292c 2065 2e77 6861 7428 2929 3b0a  e(), e.what());.
    │ │ │ -0001edf0: 0909 7061 7573 6528 293b 0a09 7d20 6361  ..pause();..} ca
    │ │ │ -0001ee00: 7463 6820 2873 7464 3a3a 6578 6365 7074  tch (std::except
    │ │ │ -0001ee10: 696f 6e20 636f 6e73 7426 616d 703b 2065  ion const& e
    │ │ │ -0001ee20: 2920 7b0a 0909 616c 6572 7473 2829 2e65  ) {...alerts().e
    │ │ │ -0001ee30: 6d70 6c61 6365 5f61 6c65 7274 266c 743b  mplace_alert<
    │ │ │ -0001ee40: 7365 7373 696f 6e5f 6572 726f 725f 616c  session_error_al
    │ │ │ -0001ee50: 6572 7426 6774 3b28 6572 726f 725f 636f  ert>(error_co
    │ │ │ -0001ee60: 6465 2829 2c20 652e 7768 6174 2829 293b  de(), e.what());
    │ │ │ -0001ee70: 0a09 0970 6175 7365 2829 3b0a 097d 2063  ...pause();..} c
    │ │ │ -0001ee80: 6174 6368 2028 2e2e 2e29 207b 0a09 0961  atch (...) {...a
    │ │ │ -0001ee90: 6c65 7274 7328 292e 656d 706c 6163 655f  lerts().emplace_
    │ │ │ -0001eea0: 616c 6572 7426 6c74 3b73 6573 7369 6f6e  alert<session
    │ │ │ -0001eeb0: 5f65 7272 6f72 5f61 6c65 7274 2667 743b  _error_alert>
    │ │ │ -0001eec0: 2865 7272 6f72 5f63 6f64 6528 292c 2022  (error_code(), "
    │ │ │ -0001eed0: 756e 6b6e 6f77 6e20 6572 726f 7222 293b  unknown error");
    │ │ │ -0001eee0: 0a09 0970 6175 7365 2829 3b0a 097d 0a23  ...pause();..}.#
    │ │ │ -0001eef0: 656e 6469 660a 0a09 2f2f 2054 6869 7320  endif...// This 
    │ │ │ -0001ef00: 6675 6e63 7469 6f6e 2069 7320 6361 6c6c  function is call
    │ │ │ -0001ef10: 6564 2062 7920 7468 6520 6372 6561 7469  ed by the creati
    │ │ │ -0001ef20: 6e67 2074 6872 6561 642c 206e 6f74 2069  ng thread, not i
    │ │ │ -0001ef30: 6e20 7468 6520 6d65 7373 6167 6520 6c6f  n the message lo
    │ │ │ -0001ef40: 6f70 2773 0a09 2f2f 2069 6f5f 636f 6e74  op's..// io_cont
    │ │ │ -0001ef50: 6578 7420 7468 7265 6164 2e0a 3c64 6976  ext thread..
    .void │ │ │ -0001ef90: 7365 7373 696f 6e5f 696d 706c 3a3a 7374 session_impl::st │ │ │ -0001efa0: 6172 745f 7365 7373 696f 6e28 290a 3c2f art_session()..{.#ifndef T │ │ │ -0001efc0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ -0001efd0: 4f47 4749 4e47 0a09 0973 6573 7369 6f6e OGGING...session │ │ │ -0001efe0: 5f6c 6f67 2822 7374 6172 7420 7365 7373 _log("start sess │ │ │ -0001eff0: 696f 6e22 293b 0a23 656e 6469 660a 0a23 ion");.#endif..# │ │ │ -0001f000: 6966 2054 4f52 5245 4e54 5f55 5345 5f53 if TORRENT_USE_S │ │ │ -0001f010: 534c 0a09 0965 7272 6f72 5f63 6f64 6520 SL...error_code │ │ │ -0001f020: 6563 3b0a 0909 6d5f 7373 6c5f 6374 782e ec;...m_ssl_ctx. │ │ │ -0001f030: 7365 745f 6465 6661 756c 745f 7665 7269 set_default_veri │ │ │ -0001f040: 6679 5f70 6174 6873 2865 6329 3b0a 2369 fy_paths(ec);.#i │ │ │ -0001f050: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ -0001f060: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ -0001f070: 6966 2028 6563 2920 7365 7373 696f 6e5f if (ec) session_ │ │ │ -0001f080: 6c6f 6728 2253 534c 2073 6574 5f64 6566 log("SSL set_def │ │ │ -0001f090: 6175 6c74 2076 6572 6966 795f 7061 7468 ault verify_path │ │ │ -0001f0a0: 7320 6661 696c 6564 3a20 2573 222c 2065 s failed: %s", e │ │ │ -0001f0b0: 632e 6d65 7373 6167 6528 292e 635f 7374 c.message().c_st │ │ │ -0001f0c0: 7228 2929 3b0a 0909 6563 2e63 6c65 6172 r());...ec.clear │ │ │ -0001f0d0: 2829 3b0a 2365 6e64 6966 0a23 6966 2064 ();.#endif.#if d │ │ │ -0001f0e0: 6566 696e 6564 2054 4f52 5245 4e54 5f57 efined TORRENT_W │ │ │ -0001f0f0: 494e 444f 5753 2026 616d 703b 2661 6d70 INDOWS && │ │ │ -0001f100: 3b20 6465 6669 6e65 6420 544f 5252 454e ; defined TORREN │ │ │ -0001f110: 545f 5553 455f 4f50 454e 5353 4c20 2661 T_USE_OPENSSL &a │ │ │ -0001f120: 6d70 3b26 616d 703b 2021 6465 6669 6e65 mp;& !define │ │ │ -0001f130: 6420 544f 5252 454e 545f 5749 4e52 540a d TORRENT_WINRT. │ │ │ -0001f140: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0001f150: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0001f180: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ -0001f1b0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0001f1c0: 703a 3733 333c 2f61 3e3c 2f74 643e 3c74 p:733the ip filter │ │ │ -0001f1e0: 7368 6f75 6c64 2070 726f 6261 626c 7920 should probably │ │ │ -0001f1f0: 6265 2073 6176 6564 2068 6572 6520 746f be saved here to │ │ │ -0001f200: 6f3c 2f74 643e 3c2f 7472 3e3c 7472 2069 o

    th │ │ │ -0001f250: 6520 6970 2066 696c 7465 7220 7368 6f75 e ip filter shou │ │ │ -0001f260: 6c64 2070 726f 6261 626c 7920 6265 2073 ld probably be s │ │ │ -0001f270: 6176 6564 2068 6572 6520 746f 6f3c 2f68 aved here too

    ../src/ses │ │ │ -0001f290: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3733 sion_impl.cpp:73 │ │ │ -0001f2a0: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -0001f2e0: 2365 6e64 6966 0a09 0970 6f73 7428 6d5f  #endif...post(m_
    │ │ │ -0001f2f0: 696f 5f63 6f6e 7465 7874 2c20 5b74 6869  io_context, [thi
    │ │ │ -0001f300: 735d 7b20 7772 6170 2826 616d 703b 7365  s]{ wrap(&se
    │ │ │ -0001f310: 7373 696f 6e5f 696d 706c 3a3a 6f6e 5f74  ssion_impl::on_t
    │ │ │ -0001f320: 6963 6b2c 2065 7272 6f72 5f63 6f64 6528  ick, error_code(
    │ │ │ -0001f330: 2929 3b20 7d29 3b0a 0a23 6966 6e64 6566  )); });..#ifndef
    │ │ │ -0001f340: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ -0001f350: 5f4c 4f47 4749 4e47 0a09 0973 6573 7369  _LOGGING...sessi
    │ │ │ -0001f360: 6f6e 5f6c 6f67 2822 2064 6f6e 6520 7374  on_log(" done st
    │ │ │ -0001f370: 6172 7469 6e67 2073 6573 7369 6f6e 2229  arting session")
    │ │ │ -0001f380: 3b0a 2365 6e64 6966 0a0a 0909 2f2f 2074  ;.#endif....// t
    │ │ │ -0001f390: 6869 7320 6170 706c 6965 7320 756e 6368  his applies unch
    │ │ │ -0001f3a0: 6f6b 6520 7365 7474 696e 6773 2066 726f  oke settings fro
    │ │ │ -0001f3b0: 6d20 6d5f 7365 7474 696e 6773 0a09 0972  m m_settings...r
    │ │ │ -0001f3c0: 6563 616c 6375 6c61 7465 5f75 6e63 686f  ecalculate_uncho
    │ │ │ -0001f3d0: 6b65 5f73 6c6f 7473 2829 3b0a 0a09 092f  ke_slots();..../
    │ │ │ -0001f3e0: 2f20 6170 706c 7920 616c 6c20 6d5f 7365  / apply all m_se
    │ │ │ -0001f3f0: 7474 696e 6773 2074 6f20 7468 6973 2073  ttings to this s
    │ │ │ -0001f400: 6573 7369 6f6e 0a09 0972 756e 5f61 6c6c  ession...run_all
    │ │ │ -0001f410: 5f75 7064 6174 6573 282a 7468 6973 293b  _updates(*this);
    │ │ │ -0001f420: 0a09 0972 656f 7065 6e5f 6c69 7374 656e  ...reopen_listen
    │ │ │ -0001f430: 5f73 6f63 6b65 7473 2866 616c 7365 293b  _sockets(false);
    │ │ │ -0001f440: 0a0a 2369 6620 544f 5252 454e 545f 5553  ..#if TORRENT_US
    │ │ │ -0001f450: 455f 494e 5641 5249 414e 545f 4348 4543  E_INVARIANT_CHEC
    │ │ │ -0001f460: 4b53 0a09 0963 6865 636b 5f69 6e76 6172  KS...check_invar
    │ │ │ -0001f470: 6961 6e74 2829 3b0a 2365 6e64 6966 0a09  iant();.#endif..
    │ │ │ -0001f480: 7d0a 0a23 6966 2054 4f52 5245 4e54 5f41  }..#if TORRENT_A
    │ │ │ -0001f490: 4249 5f56 4552 5349 4f4e 2026 6c74 3b3d  BI_VERSION <=
    │ │ │ -0001f4a0: 2032 0a3c 6469 7620 7374 796c 653d 2262   2.
    .void session_i │ │ │ -0001f4e0: 6d70 6c3a 3a73 6176 655f 7374 6174 6528 mpl::save_state( │ │ │ -0001f4f0: 656e 7472 792a 2065 7074 722c 2073 6176 entry* eptr, sav │ │ │ -0001f500: 655f 7374 6174 655f 666c 6167 735f 7420 e_state_flags_t │ │ │ -0001f510: 636f 6e73 7420 666c 6167 7329 2063 6f6e const flags) con │ │ │ -0001f520: 7374 0a3c 2f64 6976 3e09 7b0a 0909 544f st.
    .{...TO │ │ │ -0001f530: 5252 454e 545f 4153 5345 5254 2869 735f RRENT_ASSERT(is_ │ │ │ -0001f540: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ -0001f550: 3b0a 0a09 0965 6e74 7279 2661 6d70 3b20 ;....entry& │ │ │ -0001f560: 6520 3d20 2a65 7074 723b 0a09 092f 2f20 e = *eptr;...// │ │ │ -0001f570: 6d61 6b65 2069 7420 6120 6469 6374 0a09 make it a dict.. │ │ │ -0001f580: 0965 2e64 6963 7428 293b 0a0a 0909 6966 .e.dict();....if │ │ │ -0001f590: 2028 666c 6167 7320 2661 6d70 3b20 7365 (flags & se │ │ │ -0001f5a0: 7373 696f 6e3a 3a73 6176 655f 7365 7474 ssion::save_sett │ │ │ -0001f5b0: 696e 6773 290a 0909 7b0a 0909 0965 6e74 ings)...{....ent │ │ │ -0001f5c0: 7279 3a3a 6469 6374 696f 6e61 7279 5f74 ry::dictionary_t │ │ │ -0001f5d0: 7970 6526 616d 703b 2073 6574 7420 3d20 ype& sett = │ │ │ -0001f5e0: 655b 2273 6574 7469 6e67 7322 5d2e 6469 e["settings"].di │ │ │ -0001f5f0: 6374 2829 3b0a 0909 0973 6176 655f 7365 ct();....save_se │ │ │ -0001f600: 7474 696e 6773 5f74 6f5f 6469 6374 286e ttings_to_dict(n │ │ │ -0001f610: 6f6e 5f64 6566 6175 6c74 5f73 6574 7469 on_default_setti │ │ │ -0001f620: 6e67 7328 6d5f 7365 7474 696e 6773 292c ngs(m_settings), │ │ │ -0001f630: 2073 6574 7429 3b0a 0909 7d0a 0a23 6966 sett);...}..#if │ │ │ -0001f640: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -0001f650: 4142 4c45 5f44 4854 0a09 0969 6620 2866 ABLE_DHT...if (f │ │ │ -0001f660: 6c61 6773 2026 616d 703b 2073 6573 7369 lags & sessi │ │ │ -0001f670: 6f6e 3a3a 7361 7665 5f64 6874 5f73 6574 on::save_dht_set │ │ │ -0001f680: 7469 6e67 7329 0a09 097b 0a09 0909 655b tings)...{....e[ │ │ │ -0001f690: 2264 6874 225d 203d 2064 6874 3a3a 7361 "dht"] = dht::sa │ │ │ -0001f6a0: 7665 5f64 6874 5f73 6574 7469 6e67 7328 ve_dht_settings( │ │ │ -0001f6b0: 6765 745f 6468 745f 7365 7474 696e 6773 get_dht_settings │ │ │ -0001f6c0: 2829 293b 0a09 097d 0a0a 0909 6966 2028 ());...}....if ( │ │ │ -0001f6d0: 6d5f 6468 7420 2661 6d70 3b26 616d 703b m_dht && │ │ │ -0001f6e0: 2028 666c 6167 7320 2661 6d70 3b20 7365 (flags & se │ │ │ -0001f6f0: 7373 696f 6e3a 3a73 6176 655f 6468 745f ssion::save_dht_ │ │ │ -0001f700: 7374 6174 6529 290a 0909 7b0a 0909 0965 state))...{....e │ │ │ -0001f710: 5b22 6468 7420 7374 6174 6522 5d20 3d20 ["dht state"] = │ │ │ -0001f720: 6468 743a 3a73 6176 655f 6468 745f 7374 dht::save_dht_st │ │ │ -0001f730: 6174 6528 6d5f 6468 742d 2667 743b 7374 ate(m_dht->st │ │ │ -0001f740: 6174 6528 2929 3b0a 0909 7d0a 2365 6e64 ate());...}.#end │ │ │ -0001f750: 6966 0a0a 2369 666e 6465 6620 544f 5252 if..#ifndef TORR │ │ │ -0001f760: 454e 545f 4449 5341 424c 455f 4558 5445 ENT_DISABLE_EXTE │ │ │ -0001f770: 4e53 494f 4e53 0a09 0966 6f72 2028 6175 NSIONS...for (au │ │ │ -0001f780: 746f 2063 6f6e 7374 2661 6d70 3b20 6578 to const& ex │ │ │ -0001f790: 7420 3a20 6d5f 7365 735f 6578 7465 6e73 t : m_ses_extens │ │ │ -0001f7a0: 696f 6e73 5b70 6c75 6769 6e73 5f61 6c6c ions[plugins_all │ │ │ -0001f7b0: 5f69 6478 5d29 0a09 097b 0a09 0909 6578 _idx])...{....ex │ │ │ -0001f7c0: 742d 2667 743b 7361 7665 5f73 7461 7465 t->save_state │ │ │ -0001f7d0: 282a 6570 7472 293b 0a09 097d 0a3c 2f70 (*eptr);...}.

    re │ │ │ -0001f810: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/se │ │ │ -0001f850: 7373 696f 6e5f 696d 706c 2e63 7070 3a33 ssion_impl.cpp:3 │ │ │ -0001f860: 3938 303c 2f61 3e3c 2f74 643e 3c74 643e 980 │ │ │ -0001f870: 6d61 6b65 2061 206c 6973 7420 666f 7220 make a list for │ │ │ -0001f880: 746f 7272 656e 7473 2074 6861 7420 7761 torrents that wa │ │ │ -0001f890: 6e74 2074 6f20 6265 2061 6e6e 6f75 6e63 nt to be announc │ │ │ -0001f8a0: 6564 206f 6e20 7468 6520 4448 5420 736f ed on the DHT so │ │ │ -0001f8b0: 2077 6520 646f 6e27 7420 6861 7665 2074 we don't have t │ │ │ -0001f8c0: 6f20 6c6f 6f70 206f 7665 7220 616c 6c20 o loop over all │ │ │ -0001f8d0: 746f 7272 656e 7473 2c20 6a75 7374 2074 torrents, just t │ │ │ -0001f8e0: 6f20 6669 6e64 2074 6865 206f 6e65 7320 o find the ones │ │ │ -0001f8f0: 7468 6174 2077 616e 7420 746f 2061 6e6e that want to ann │ │ │ -0001f900: 6f75 6e63 653c 2f74 643e 3c2f 7472 3e3c ounce< │ │ │ -0001f910: 7472 2069 643d 2236 3222 2073 7479 6c65 tr id="62" style │ │ │ -0001f920: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ -0001f930: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">make a list fo │ │ │ -0001f960: 7220 746f 7272 656e 7473 2074 6861 7420 r torrents that │ │ │ -0001f970: 7761 6e74 2074 6f20 6265 2061 6e6e 6f75 want to be annou │ │ │ -0001f980: 6e63 6564 206f 6e20 7468 6520 4448 5420 nced on the DHT │ │ │ -0001f990: 736f 2077 650a 646f 6e27 7420 6861 7665 so we.don't have │ │ │ -0001f9a0: 2074 6f20 6c6f 6f70 206f 7665 7220 616c to loop over al │ │ │ -0001f9b0: 6c20 746f 7272 656e 7473 2c20 6a75 7374 l torrents, just │ │ │ -0001f9c0: 2074 6f20 6669 6e64 2074 6865 206f 6e65 to find the one │ │ │ -0001f9d0: 7320 7468 6174 2077 616e 7420 746f 2061 s that want to a │ │ │ -0001f9e0: 6e6e 6f75 6e63 653c 2f68 323e 3c68 343e nnounce

    │ │ │ -0001f9f0: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0001fa00: 6d70 6c2e 6370 703a 3339 3830 3c2f 6834 mpl.cpp:3980

    ..if 
    │ │ │ -0001fa50: 2821 6d5f 6468 745f 746f 7272 656e 7473  (!m_dht_torrents
    │ │ │ -0001fa60: 2e65 6d70 7479 2829 290a 0909 7b0a 0909  .empty())...{...
    │ │ │ -0001fa70: 0973 7464 3a3a 7368 6172 6564 5f70 7472  .std::shared_ptr
    │ │ │ -0001fa80: 266c 743b 746f 7272 656e 7426 6774 3b20  <torrent> 
    │ │ │ -0001fa90: 743b 0a09 0909 646f 0a09 0909 7b0a 0909  t;....do....{...
    │ │ │ -0001faa0: 0909 7420 3d20 6d5f 6468 745f 746f 7272  ..t = m_dht_torr
    │ │ │ -0001fab0: 656e 7473 2e66 726f 6e74 2829 2e6c 6f63  ents.front().loc
    │ │ │ -0001fac0: 6b28 293b 0a09 0909 096d 5f64 6874 5f74  k();.....m_dht_t
    │ │ │ -0001fad0: 6f72 7265 6e74 732e 706f 705f 6672 6f6e  orrents.pop_fron
    │ │ │ -0001fae0: 7428 293b 0a09 0909 7d20 7768 696c 6520  t();....} while 
    │ │ │ -0001faf0: 2821 7420 2661 6d70 3b26 616d 703b 2021  (!t && !
    │ │ │ -0001fb00: 6d5f 6468 745f 746f 7272 656e 7473 2e65  m_dht_torrents.e
    │ │ │ -0001fb10: 6d70 7479 2829 293b 0a0a 0909 0969 6620  mpty());.....if 
    │ │ │ -0001fb20: 2874 290a 0909 097b 0a09 0909 0974 2d26  (t)....{.....t-&
    │ │ │ -0001fb30: 6774 3b64 6874 5f61 6e6e 6f75 6e63 6528  gt;dht_announce(
    │ │ │ -0001fb40: 293b 0a09 0909 0972 6574 7572 6e3b 0a09  );.....return;..
    │ │ │ -0001fb50: 0909 7d0a 0909 7d0a 0909 6966 2028 6d5f  ..}...}...if (m_
    │ │ │ -0001fb60: 746f 7272 656e 7473 2e65 6d70 7479 2829  torrents.empty()
    │ │ │ -0001fb70: 2920 7265 7475 726e 3b0a 0a09 0969 6620  ) return;....if 
    │ │ │ -0001fb80: 286d 5f6e 6578 745f 6468 745f 746f 7272  (m_next_dht_torr
    │ │ │ -0001fb90: 656e 7420 2667 743b 3d20 6d5f 746f 7272  ent >= m_torr
    │ │ │ -0001fba0: 656e 7473 2e73 697a 6528 2929 0a09 0909  ents.size())....
    │ │ │ -0001fbb0: 6d5f 6e65 7874 5f64 6874 5f74 6f72 7265  m_next_dht_torre
    │ │ │ -0001fbc0: 6e74 203d 2030 3b0a 0909 6d5f 746f 7272  nt = 0;...m_torr
    │ │ │ -0001fbd0: 656e 7473 5b6d 5f6e 6578 745f 6468 745f  ents[m_next_dht_
    │ │ │ -0001fbe0: 746f 7272 656e 745d 2d26 6774 3b64 6874  torrent]->dht
    │ │ │ -0001fbf0: 5f61 6e6e 6f75 6e63 6528 293b 0a3c 6469  _announce();...++m
    │ │ │ -0001fc30: 5f6e 6578 745f 6468 745f 746f 7272 656e  _next_dht_torren
    │ │ │ -0001fc40: 743b 0a3c 2f64 6976 3e09 0969 6620 286d  t;.
    ..if (m │ │ │ -0001fc50: 5f6e 6578 745f 6468 745f 746f 7272 656e _next_dht_torren │ │ │ -0001fc60: 7420 2667 743b 3d20 6d5f 746f 7272 656e t >= m_torren │ │ │ -0001fc70: 7473 2e73 697a 6528 2929 0a09 0909 6d5f ts.size())....m_ │ │ │ -0001fc80: 6e65 7874 5f64 6874 5f74 6f72 7265 6e74 next_dht_torrent │ │ │ -0001fc90: 203d 2030 3b0a 097d 0a23 656e 6469 660a = 0;..}.#endif. │ │ │ -0001fca0: 0a09 766f 6964 2073 6573 7369 6f6e 5f69 ..void session_i │ │ │ -0001fcb0: 6d70 6c3a 3a6f 6e5f 6c73 645f 616e 6e6f mpl::on_lsd_anno │ │ │ -0001fcc0: 756e 6365 2865 7272 6f72 5f63 6f64 6520 unce(error_code │ │ │ -0001fcd0: 636f 6e73 7426 616d 703b 2065 290a 097b const& e)..{ │ │ │ -0001fce0: 0a09 0943 4f4d 504c 4554 455f 4153 594e ...COMPLETE_ASYN │ │ │ -0001fcf0: 4328 2273 6573 7369 6f6e 5f69 6d70 6c3a C("session_impl: │ │ │ -0001fd00: 3a6f 6e5f 6c73 645f 616e 6e6f 756e 6365 :on_lsd_announce │ │ │ -0001fd10: 2229 3b0a 0909 6d5f 7374 6174 735f 636f ");...m_stats_co │ │ │ -0001fd20: 756e 7465 7273 2e69 6e63 5f73 7461 7473 unters.inc_stats │ │ │ -0001fd30: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572 _counter(counter │ │ │ -0001fd40: 733a 3a6f 6e5f 6c73 645f 636f 756e 7465 s::on_lsd_counte │ │ │ -0001fd50: 7229 3b0a 0909 544f 5252 454e 545f 4153 r);...TORRENT_AS │ │ │ -0001fd60: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ -0001fd70: 6872 6561 6428 2929 3b0a 0909 6966 2028 hread());...if ( │ │ │ -0001fd80: 6529 2072 6574 7572 6e3b 0a0a 0909 6966 e) return;....if │ │ │ -0001fd90: 2028 6d5f 6162 6f72 7429 2072 6574 7572 (m_abort) retur │ │ │ -0001fda0: 6e3b 0a0a 0909 7570 6461 7465 5f6c 7364 n;....update_lsd │ │ │ -0001fdb0: 5f61 6e6e 6f75 6e63 655f 696e 7465 7276 _announce_interv │ │ │ -0001fdc0: 616c 2829 3b0a 0a09 0969 6620 2821 6d5f al();....if (!m_ │ │ │ -0001fdd0: 6c73 645f 746f 7272 656e 7473 2e65 6d70 lsd_torrents.emp │ │ │ -0001fde0: 7479 2829 290a 0909 7b0a 0909 0973 7464 ty())...{....std │ │ │ -0001fdf0: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ -0001fe00: 746f 7272 656e 7426 6774 3b20 743b 0a09 torrent> t;.. │ │ │ -0001fe10: 0909 646f 0a09 0909 7b0a 0909 0909 7420 ..do....{.....t │ │ │ -0001fe20: 3d20 6d5f 6c73 645f 746f 7272 656e 7473 = m_lsd_torrents │ │ │ -0001fe30: 2e66 726f 6e74 2829 2e6c 6f63 6b28 293b .front().lock(); │ │ │ -0001fe40: 0a09 0909 096d 5f6c 7364 5f74 6f72 7265 .....m_lsd_torre │ │ │ -0001fe50: 6e74 732e 706f 705f 6672 6f6e 7428 293b nts.pop_front(); │ │ │ -0001fe60: 0a09 0909 7d20 7768 696c 6520 2821 7420 ....} while (!t │ │ │ -0001fe70: 2661 6d70 3b26 616d 703b 2021 6d5f 6c73 && !m_ls │ │ │ -0001fe80: 645f 746f 7272 656e 7473 2e65 6d70 7479 d_torrents.empty │ │ │ -0001fe90: 2829 293b 0a0a 0909 0969 6620 2874 290a ());.....if (t). │ │ │ -0001fea0: 0909 097b 0a09 0909 0974 2d26 6774 3b6c ...{.....t->l │ │ │ -0001feb0: 7364 5f61 6e6e 6f75 6e63 6528 293b 0a09 sd_announce();.. │ │ │ -0001fec0: 0909 0972 6574 7572 6e3b 0a09 0909 7d0a ...return;....}. │ │ │ -0001fed0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e │ │ │ -0001fee0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0001ff10: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ -0001ff40: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0001ff50: 703a 3536 3936 3c2f 613e 3c2f 7464 3e3c p:5696< │ │ │ -0001ff60: 7464 3e74 6869 7320 6675 6e63 7469 6f6e td>this function │ │ │ -0001ff70: 2073 686f 756c 6420 6265 2072 656d 6f76 should be remov │ │ │ -0001ff80: 6564 2061 6e64 2075 7365 7273 206e 6565 ed and users nee │ │ │ -0001ff90: 6420 746f 2064 6561 6c20 7769 7468 2074 d to deal with t │ │ │ -0001ffa0: 6865 206d 6f72 6520 6765 6e65 7269 6320 he more generic │ │ │ -0001ffb0: 6361 7365 206f 6620 6861 7669 6e67 206d case of having m │ │ │ -0001ffc0: 756c 7469 706c 6520 6c69 7374 656e 2070 ultiple listen p │ │ │ -0001ffd0: 6f72 7473 3c2f 7464 3e3c 2f74 723e 3c74 orts

    this function s │ │ │ -00020030: 686f 756c 6420 6265 2072 656d 6f76 6564 hould be removed │ │ │ -00020040: 2061 6e64 2075 7365 7273 206e 6565 6420 and users need │ │ │ -00020050: 746f 2064 6561 6c20 7769 7468 2074 6865 to deal with the │ │ │ -00020060: 0a6d 6f72 6520 6765 6e65 7269 6320 6361 .more generic ca │ │ │ -00020070: 7365 206f 6620 6861 7669 6e67 206d 756c se of having mul │ │ │ -00020080: 7469 706c 6520 6c69 7374 656e 2070 6f72 tiple listen por │ │ │ -00020090: 7473 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ts

    ../sr │ │ │ -000200a0: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -000200b0: 7070 3a35 3639 363c 2f68 343e 3c70 7265 pp:5696

    #ifndef TO
    │ │ │ -00020100: 5252 454e 545f 4449 5341 424c 455f 4c4f  RRENT_DISABLE_LO
    │ │ │ -00020110: 4747 494e 470a 0909 6966 2028 216e 6f64  GGING...if (!nod
    │ │ │ -00020120: 655f 6c69 7374 2e65 6d70 7479 2829 2026  e_list.empty() &
    │ │ │ -00020130: 616d 703b 2661 6d70 3b20 6e6f 6465 732e  amp;& nodes.
    │ │ │ -00020140: 656d 7074 7928 2929 0a09 097b 0a09 0909  empty())...{....
    │ │ │ -00020150: 7365 7373 696f 6e5f 6c6f 6728 2245 5252  session_log("ERR
    │ │ │ -00020160: 4f52 3a20 6661 696c 6564 2074 6f20 7061  OR: failed to pa
    │ │ │ -00020170: 7273 6520 4448 5420 626f 6f74 7374 7261  rse DHT bootstra
    │ │ │ -00020180: 7020 6c69 7374 3a20 2573 222c 206e 6f64  p list: %s", nod
    │ │ │ -00020190: 655f 6c69 7374 2e63 5f73 7472 2829 293b  e_list.c_str());
    │ │ │ -000201a0: 0a09 097d 0a23 656e 6469 660a 0909 666f  ...}.#endif...fo
    │ │ │ -000201b0: 7220 2861 7574 6f20 636f 6e73 7426 616d  r (auto const&am
    │ │ │ -000201c0: 703b 206e 203a 206e 6f64 6573 290a 0909  p; n : nodes)...
    │ │ │ -000201d0: 0961 6464 5f64 6874 5f72 6f75 7465 7228  .add_dht_router(
    │ │ │ -000201e0: 6e29 3b0a 2365 6e64 6966 0a09 7d0a 0a09  n);.#endif..}...
    │ │ │ -000201f0: 766f 6964 2073 6573 7369 6f6e 5f69 6d70  void session_imp
    │ │ │ -00020200: 6c3a 3a75 7064 6174 655f 636f 756e 745f  l::update_count_
    │ │ │ -00020210: 736c 6f77 2829 0a09 7b0a 0909 6572 726f  slow()..{...erro
    │ │ │ -00020220: 725f 636f 6465 2065 633b 0a09 0966 6f72  r_code ec;...for
    │ │ │ -00020230: 2028 6175 746f 2063 6f6e 7374 2661 6d70   (auto const&
    │ │ │ -00020240: 3b20 7470 203a 206d 5f74 6f72 7265 6e74  ; tp : m_torrent
    │ │ │ -00020250: 7329 0a09 097b 0a09 0909 7470 2d26 6774  s)...{....tp->
    │ │ │ -00020260: 3b6f 6e5f 696e 6163 7469 7669 7479 5f74  ;on_inactivity_t
    │ │ │ -00020270: 6963 6b28 6563 293b 0a09 097d 0a09 7d0a  ick(ec);...}..}.
    │ │ │ -00020280: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -000202b0: 7374 643a 3a75 696e 7431 365f 7420 7365 std::uint16_t se │ │ │ -000202c0: 7373 696f 6e5f 696d 706c 3a3a 6c69 7374 ssion_impl::list │ │ │ -000202d0: 656e 5f70 6f72 7428 2920 636f 6e73 740a en_port() const. │ │ │ -000202e0: 3c2f 6469 763e 097b 0a09 0972 6574 7572
    .{...retur │ │ │ -000202f0: 6e20 6c69 7374 656e 5f70 6f72 7428 6e75 n listen_port(nu │ │ │ -00020300: 6c6c 7074 7229 3b0a 097d 0a0a 0973 7464 llptr);..}...std │ │ │ -00020310: 3a3a 7569 6e74 3136 5f74 2073 6573 7369 ::uint16_t sessi │ │ │ -00020320: 6f6e 5f69 6d70 6c3a 3a6c 6973 7465 6e5f on_impl::listen_ │ │ │ -00020330: 706f 7274 286c 6973 7465 6e5f 736f 636b port(listen_sock │ │ │ -00020340: 6574 5f74 2a20 736f 636b 2920 636f 6e73 et_t* sock) cons │ │ │ -00020350: 740a 097b 0a09 0969 6620 286d 5f6c 6973 t..{...if (m_lis │ │ │ -00020360: 7465 6e5f 736f 636b 6574 732e 656d 7074 ten_sockets.empt │ │ │ -00020370: 7928 2929 2072 6574 7572 6e20 303b 0a09 y()) return 0;.. │ │ │ -00020380: 0969 6620 2873 6f63 6b29 0a09 097b 0a09 .if (sock)...{.. │ │ │ -00020390: 0909 2f2f 2069 6620 7765 2772 6520 7573 ..// if we're us │ │ │ -000203a0: 696e 6720 6120 7072 6f78 792c 2077 6520 ing a proxy, we │ │ │ -000203b0: 776f 6e27 7420 6265 2061 626c 6520 746f won't be able to │ │ │ -000203c0: 2061 6363 6570 7420 616e 7920 5443 500a accept any TCP. │ │ │ -000203d0: 0909 092f 2f20 636f 6e6e 6563 7469 6f6e ...// connection │ │ │ -000203e0: 732e 204e 6f74 2065 7665 6e20 7554 5020 s. Not even uTP │ │ │ -000203f0: 636f 6e6e 6563 7469 6f6e 7320 7669 6120 connections via │ │ │ -00020400: 7468 6520 706f 7274 2077 6520 6b6e 6f77 the port we know │ │ │ -00020410: 2061 626f 7574 2e0a 0909 092f 2f20 5468 about.....// Th │ │ │ -00020420: 6520 4448 5420 6d61 7920 7573 6520 7468 e DHT may use th │ │ │ -00020430: 6520 696d 706c 6965 6420 706f 7274 2074 e implied port t │ │ │ -00020440: 6f20 6d61 6b65 2069 7420 776f 726b 2c20 o make it work, │ │ │ -00020450: 6275 7420 7468 6520 706f 7274 2077 650a but the port we. │ │ │ -00020460: 0909 092f 2f20 616e 6e6f 756e 6365 2068 ...// announce h │ │ │ -00020470: 6572 6520 6861 7320 6e6f 2072 656c 6576 ere has no relev │ │ │ -00020480: 616e 6365 2066 6f72 2074 6861 742e 0a09 ance for that... │ │ │ -00020490: 0909 6966 2028 736f 636b 2d26 6774 3b66 ..if (sock->f │ │ │ -000204a0: 6c61 6773 2026 616d 703b 206c 6973 7465 lags & liste │ │ │ -000204b0: 6e5f 736f 636b 6574 5f74 3a3a 7072 6f78 n_socket_t::prox │ │ │ -000204c0: 7929 0a09 0909 0972 6574 7572 6e20 303b y).....return 0; │ │ │ -000204d0: 0a0a 0909 0969 6620 2821 2873 6f63 6b2d .....if (!(sock- │ │ │ -000204e0: 2667 743b 666c 6167 7320 2661 6d70 3b20 >flags & │ │ │ -000204f0: 6c69 7374 656e 5f73 6f63 6b65 745f 743a listen_socket_t: │ │ │ -00020500: 3a61 6363 6570 745f 696e 636f 6d69 6e67 :accept_incoming │ │ │ -00020510: 2929 0a09 0909 0972 6574 7572 6e20 303b )).....return 0; │ │ │ -00020520: 0a0a 0909 0972 6574 7572 6e20 7374 643a .....return std: │ │ │ -00020530: 3a75 696e 7431 365f 7428 736f 636b 2d26 :uint16_t(sock-& │ │ │ -00020540: 6774 3b74 6370 5f65 7874 6572 6e61 6c5f gt;tcp_external_ │ │ │ -00020550: 706f 7274 2829 293b 0a09 097d 0a0a 2369 port());...}..#i │ │ │ -00020560: 6664 6566 2054 4f52 5245 4e54 5f53 534c fdef TORRENT_SSL │ │ │ -00020570: 5f50 4545 5253 0a09 0966 6f72 2028 6175 _PEERS...for (au │ │ │ -00020580: 746f 2063 6f6e 7374 2661 6d70 3b20 7320 to const& s │ │ │ -00020590: 3a20 6d5f 6c69 7374 656e 5f73 6f63 6b65 : m_listen_socke │ │ │ -000205a0: 7473 290a 0909 7b0a 0909 0969 6620 2821 ts)...{....if (! │ │ │ -000205b0: 2873 2d26 6774 3b66 6c61 6773 2026 616d (s->flags &am │ │ │ -000205c0: 703b 206c 6973 7465 6e5f 736f 636b 6574 p; listen_socket │ │ │ -000205d0: 5f74 3a3a 6163 6365 7074 5f69 6e63 6f6d _t::accept_incom │ │ │ -000205e0: 696e 6729 2920 636f 6e74 696e 7565 3b0a ing)) continue;. │ │ │ -000205f0: 0909 0969 6620 2873 2d26 6774 3b73 736c ...if (s->ssl │ │ │ -00020600: 203d 3d20 7472 616e 7370 6f72 743a 3a70 == transport::p │ │ │ -00020610: 6c61 696e 7465 7874 290a 0909 0909 7265 laintext).....re │ │ │ -00020620: 7475 726e 2073 7464 3a3a 7569 6e74 3136 turn std::uint16 │ │ │ -00020630: 5f74 2873 2d26 6774 3b74 6370 5f65 7874 _t(s->tcp_ext │ │ │ -00020640: 6572 6e61 6c5f 706f 7274 2829 293b 0a09 ernal_port());.. │ │ │ -00020650: 097d 0a09 0972 6574 7572 6e20 303b 0a3c .}...return 0;.< │ │ │ -00020660: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00020670: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00020680: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ -00020690: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ -000206a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ -000206d0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -000206e0: 3a35 3733 363c 2f61 3e3c 2f74 643e 3c74 :5736this function │ │ │ -00020700: 7368 6f75 6c64 2062 6520 7265 6d6f 7665 should be remove │ │ │ -00020710: 6420 616e 6420 7573 6572 7320 6e65 6564 d and users need │ │ │ -00020720: 2074 6f20 6465 616c 2077 6974 6820 7468 to deal with th │ │ │ -00020730: 6520 6d6f 7265 2067 656e 6572 6963 2063 e more generic c │ │ │ -00020740: 6173 6520 6f66 2068 6176 696e 6720 6d75 ase of having mu │ │ │ -00020750: 6c74 6970 6c65 2073 736c 2070 6f72 7473 ltiple ssl ports │ │ │ -00020760: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    thi │ │ │ -000207b0: 7320 6675 6e63 7469 6f6e 2073 686f 756c s function shoul │ │ │ -000207c0: 6420 6265 2072 656d 6f76 6564 2061 6e64 d be removed and │ │ │ -000207d0: 2075 7365 7273 206e 6565 6420 746f 2064 users need to d │ │ │ -000207e0: 6561 6c20 7769 7468 2074 6865 0a6d 6f72 eal with the.mor │ │ │ -000207f0: 6520 6765 6e65 7269 6320 6361 7365 206f e generic case o │ │ │ -00020800: 6620 6861 7669 6e67 206d 756c 7469 706c f having multipl │ │ │ -00020810: 6520 7373 6c20 706f 7274 733c 2f68 323e e ssl ports

    │ │ │ -00020820: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ -00020830: 6f6e 5f69 6d70 6c2e 6370 703a 3537 3336 on_impl.cpp:5736 │ │ │ -00020840: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00020880: 0909 0972 6574 7572 6e20 303b 0a0a 0909  ...return 0;....
    │ │ │ -00020890: 0972 6574 7572 6e20 7374 643a 3a75 696e  .return std::uin
    │ │ │ -000208a0: 7431 365f 7428 736f 636b 2d26 6774 3b74  t16_t(sock->t
    │ │ │ -000208b0: 6370 5f65 7874 6572 6e61 6c5f 706f 7274  cp_external_port
    │ │ │ -000208c0: 2829 293b 0a09 097d 0a0a 2369 6664 6566  ());...}..#ifdef
    │ │ │ -000208d0: 2054 4f52 5245 4e54 5f53 534c 5f50 4545   TORRENT_SSL_PEE
    │ │ │ -000208e0: 5253 0a09 0966 6f72 2028 6175 746f 2063  RS...for (auto c
    │ │ │ -000208f0: 6f6e 7374 2661 6d70 3b20 7320 3a20 6d5f  onst& s : m_
    │ │ │ -00020900: 6c69 7374 656e 5f73 6f63 6b65 7473 290a  listen_sockets).
    │ │ │ -00020910: 0909 7b0a 0909 0969 6620 2821 2873 2d26  ..{....if (!(s-&
    │ │ │ -00020920: 6774 3b66 6c61 6773 2026 616d 703b 206c  gt;flags & l
    │ │ │ -00020930: 6973 7465 6e5f 736f 636b 6574 5f74 3a3a  isten_socket_t::
    │ │ │ -00020940: 6163 6365 7074 5f69 6e63 6f6d 696e 6729  accept_incoming)
    │ │ │ -00020950: 2920 636f 6e74 696e 7565 3b0a 0909 0969  ) continue;....i
    │ │ │ -00020960: 6620 2873 2d26 6774 3b73 736c 203d 3d20  f (s->ssl == 
    │ │ │ -00020970: 7472 616e 7370 6f72 743a 3a70 6c61 696e  transport::plain
    │ │ │ -00020980: 7465 7874 290a 0909 0909 7265 7475 726e  text).....return
    │ │ │ -00020990: 2073 7464 3a3a 7569 6e74 3136 5f74 2873   std::uint16_t(s
    │ │ │ -000209a0: 2d26 6774 3b74 6370 5f65 7874 6572 6e61  ->tcp_externa
    │ │ │ -000209b0: 6c5f 706f 7274 2829 293b 0a09 097d 0a09  l_port());...}..
    │ │ │ -000209c0: 0972 6574 7572 6e20 303b 0a23 656c 7365  .return 0;.#else
    │ │ │ -000209d0: 0a09 0973 6f63 6b20 3d20 6d5f 6c69 7374  ...sock = m_list
    │ │ │ -000209e0: 656e 5f73 6f63 6b65 7473 2e66 726f 6e74  en_sockets.front
    │ │ │ -000209f0: 2829 2e67 6574 2829 3b0a 0909 6966 2028  ().get();...if (
    │ │ │ -00020a00: 2128 736f 636b 2d26 6774 3b66 6c61 6773  !(sock->flags
    │ │ │ -00020a10: 2026 616d 703b 206c 6973 7465 6e5f 736f   & listen_so
    │ │ │ -00020a20: 636b 6574 5f74 3a3a 6163 6365 7074 5f69  cket_t::accept_i
    │ │ │ -00020a30: 6e63 6f6d 696e 6729 2920 7265 7475 726e  ncoming)) return
    │ │ │ -00020a40: 2030 3b0a 0909 7265 7475 726e 2073 7464   0;...return std
    │ │ │ -00020a50: 3a3a 7569 6e74 3136 5f74 2873 6f63 6b2d  ::uint16_t(sock-
    │ │ │ -00020a60: 2667 743b 7463 705f 6578 7465 726e 616c  >tcp_external
    │ │ │ -00020a70: 5f70 6f72 7428 2929 3b0a 2365 6e64 6966  _port());.#endif
    │ │ │ -00020a80: 0a09 7d0a 0a3c 6469 7620 7374 796c 653d  ..}..
    .std::uint16_ │ │ │ -00020ac0: 7420 7365 7373 696f 6e5f 696d 706c 3a3a t session_impl:: │ │ │ -00020ad0: 7373 6c5f 6c69 7374 656e 5f70 6f72 7428 ssl_listen_port( │ │ │ -00020ae0: 2920 636f 6e73 740a 3c2f 6469 763e 097b ) const.
    .{ │ │ │ -00020af0: 0a09 0972 6574 7572 6e20 7373 6c5f 6c69 ...return ssl_li │ │ │ -00020b00: 7374 656e 5f70 6f72 7428 6e75 6c6c 7074 sten_port(nullpt │ │ │ -00020b10: 7229 3b0a 097d 0a0a 0973 7464 3a3a 7569 r);..}...std::ui │ │ │ -00020b20: 6e74 3136 5f74 2073 6573 7369 6f6e 5f69 nt16_t session_i │ │ │ -00020b30: 6d70 6c3a 3a73 736c 5f6c 6973 7465 6e5f mpl::ssl_listen_ │ │ │ -00020b40: 706f 7274 286c 6973 7465 6e5f 736f 636b port(listen_sock │ │ │ -00020b50: 6574 5f74 2a20 736f 636b 2920 636f 6e73 et_t* sock) cons │ │ │ -00020b60: 740a 097b 0a23 6966 6465 6620 544f 5252 t..{.#ifdef TORR │ │ │ -00020b70: 454e 545f 5353 4c5f 5045 4552 530a 0909 ENT_SSL_PEERS... │ │ │ -00020b80: 6966 2028 736f 636b 290a 0909 7b0a 0909 if (sock)...{... │ │ │ -00020b90: 0969 6620 2821 2873 6f63 6b2d 2667 743b .if (!(sock-> │ │ │ -00020ba0: 666c 6167 7320 2661 6d70 3b20 6c69 7374 flags & list │ │ │ -00020bb0: 656e 5f73 6f63 6b65 745f 743a 3a61 6363 en_socket_t::acc │ │ │ -00020bc0: 6570 745f 696e 636f 6d69 6e67 2929 2072 ept_incoming)) r │ │ │ -00020bd0: 6574 7572 6e20 303b 0a09 0909 7265 7475 eturn 0;....retu │ │ │ -00020be0: 726e 2073 7464 3a3a 7569 6e74 3136 5f74 rn std::uint16_t │ │ │ -00020bf0: 2873 6f63 6b2d 2667 743b 7463 705f 6578 (sock->tcp_ex │ │ │ -00020c00: 7465 726e 616c 5f70 6f72 7428 2929 3b0a ternal_port());. │ │ │ -00020c10: 0909 7d0a 0a09 0969 6620 286d 5f73 6574 ..}....if (m_set │ │ │ -00020c20: 7469 6e67 732e 6765 745f 696e 7428 7365 tings.get_int(se │ │ │ -00020c30: 7474 696e 6773 5f70 6163 6b3a 3a70 726f ttings_pack::pro │ │ │ -00020c40: 7879 5f74 7970 6529 2021 3d20 7365 7474 xy_type) != sett │ │ │ -00020c50: 696e 6773 5f70 6163 6b3a 3a6e 6f6e 650a ings_pack::none. │ │ │ -00020c60: 0909 0926 616d 703b 2661 6d70 3b20 6d5f ...&& m_ │ │ │ -00020c70: 7365 7474 696e 6773 2e67 6574 5f62 6f6f settings.get_boo │ │ │ -00020c80: 6c28 7365 7474 696e 6773 5f70 6163 6b3a l(settings_pack: │ │ │ -00020c90: 3a70 726f 7879 5f70 6565 725f 636f 6e6e :proxy_peer_conn │ │ │ -00020ca0: 6563 7469 6f6e 7329 290a 0909 0972 6574 ections))....ret │ │ │ -00020cb0: 7572 6e20 303b 0a0a 0909 666f 7220 2861 urn 0;....for (a │ │ │ -00020cc0: 7574 6f20 636f 6e73 7426 616d 703b 2073 uto const& s │ │ │ -00020cd0: 203a 206d 5f6c 6973 7465 6e5f 736f 636b : m_listen_sock │ │ │ -00020ce0: 6574 7329 0a09 097b 0a09 0909 6966 2028 ets)...{....if ( │ │ │ -00020cf0: 2128 732d 2667 743b 666c 6167 7320 2661 !(s->flags &a │ │ │ -00020d00: 6d70 3b20 6c69 7374 656e 5f73 6f63 6b65 mp; listen_socke │ │ │ -00020d10: 745f 743a 3a61 6363 6570 745f 696e 636f t_t::accept_inco │ │ │ -00020d20: 6d69 6e67 2929 2063 6f6e 7469 6e75 653b ming)) continue; │ │ │ -00020d30: 0a09 0909 6966 2028 732d 2667 743b 7373 ....if (s->ss │ │ │ -00020d40: 6c20 3d3d 2074 7261 6e73 706f 7274 3a3a l == transport:: │ │ │ -00020d50: 7373 6c29 0a09 0909 0972 6574 7572 6e20 ssl).....return │ │ │ -00020d60: 7374 643a 3a75 696e 7431 365f 7428 732d std::uint16_t(s- │ │ │ -00020d70: 2667 743b 7463 705f 6578 7465 726e 616c >tcp_external │ │ │ -00020d80: 5f70 6f72 7428 2929 3b0a 0909 7d0a 2365 _port());...}.#e │ │ │ -00020d90: 6c73 650a 0909 544f 5252 454e 545f 554e lse...TORRENT_UN │ │ │ -00020da0: 5553 4544 2873 6f63 6b29 3b0a 2365 6e64 USED(sock);.#end │ │ │ -00020db0: 6966 0a09 0972 6574 7572 6e20 303b 0a09 if...return 0;.. │ │ │ -00020dc0: 7d0a 0a09 696e 7420 7365 7373 696f 6e5f }...int session_ │ │ │ -00020dd0: 696d 706c 3a3a 6765 745f 6c69 7374 656e impl::get_listen │ │ │ -00020de0: 5f70 6f72 7428 7472 616e 7370 6f72 7420 _port(transport │ │ │ -00020df0: 636f 6e73 7420 7373 6c2c 2061 7578 3a3a const ssl, aux:: │ │ │ -00020e00: 6c69 7374 656e 5f73 6f63 6b65 745f 6861 listen_socket_ha │ │ │ -00020e10: 6e64 6c65 2063 6f6e 7374 2661 6d70 3b20 ndle const& │ │ │ -00020e20: 7329 2063 6f6e 7374 0a3c 2f70 7265 3e3c s) const.
    < │ │ │ -00020e30: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00020e60: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ -00020e70: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/sessio │ │ │ -00020ea0: 6e5f 696d 706c 2e63 7070 3a36 3537 363c n_impl.cpp:6576< │ │ │ -00020eb0: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ -00020ec0: 2073 686f 756c 6420 6265 2066 6163 746f should be facto │ │ │ -00020ed0: 7265 6420 696e 746f 2074 6865 2075 6470 red into the udp │ │ │ -00020ee0: 2073 6f63 6b65 742c 2073 6f20 7765 206f socket, so we o │ │ │ -00020ef0: 6e6c 7920 6861 7665 2074 6865 2063 6f64 nly have the cod │ │ │ -00020f00: 6520 6f6e 6365 3c2f 7464 3e3c 2f74 723e e once │ │ │ -00020f10: 3c74 7220 6964 3d22 3635 2220 7374 796c < │ │ │ -00020f40: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00020f50: 6832 3e74 6869 7320 7368 6f75 6c64 2062 h2>this should b │ │ │ -00020f60: 6520 6661 6374 6f72 6564 2069 6e74 6f20 e factored into │ │ │ -00020f70: 7468 6520 7564 7020 736f 636b 6574 2c20 the udp socket, │ │ │ -00020f80: 736f 2077 6520 6f6e 6c79 2068 6176 6520 so we only have │ │ │ -00020f90: 7468 650a 636f 6465 206f 6e63 653c 2f68 the.code once

    ../src/ses │ │ │ -00020fb0: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3635 sion_impl.cpp:65 │ │ │ -00020fc0: 3736 3c2f 6834 3e3c 7072 6520 7374 796c 76

    ..return upload
    │ │ │ -00021010: 5f72 6174 655f 6c69 6d69 7428 6d5f 6c6f  _rate_limit(m_lo
    │ │ │ -00021020: 6361 6c5f 7065 6572 5f63 6c61 7373 293b  cal_peer_class);
    │ │ │ -00021030: 0a09 7d0a 0a09 696e 7420 7365 7373 696f  ..}...int sessio
    │ │ │ -00021040: 6e5f 696d 706c 3a3a 6c6f 6361 6c5f 646f  n_impl::local_do
    │ │ │ -00021050: 776e 6c6f 6164 5f72 6174 655f 6c69 6d69  wnload_rate_limi
    │ │ │ -00021060: 7428 2920 636f 6e73 740a 097b 0a09 0972  t() const..{...r
    │ │ │ -00021070: 6574 7572 6e20 646f 776e 6c6f 6164 5f72  eturn download_r
    │ │ │ -00021080: 6174 655f 6c69 6d69 7428 6d5f 6c6f 6361  ate_limit(m_loca
    │ │ │ -00021090: 6c5f 7065 6572 5f63 6c61 7373 293b 0a09  l_peer_class);..
    │ │ │ -000210a0: 7d0a 0a09 696e 7420 7365 7373 696f 6e5f  }...int session_
    │ │ │ -000210b0: 696d 706c 3a3a 7570 6c6f 6164 5f72 6174  impl::upload_rat
    │ │ │ -000210c0: 655f 6c69 6d69 745f 6465 7072 2829 2063  e_limit_depr() c
    │ │ │ -000210d0: 6f6e 7374 0a09 7b0a 0909 7265 7475 726e  onst..{...return
    │ │ │ -000210e0: 2075 706c 6f61 645f 7261 7465 5f6c 696d   upload_rate_lim
    │ │ │ -000210f0: 6974 286d 5f67 6c6f 6261 6c5f 636c 6173  it(m_global_clas
    │ │ │ -00021100: 7329 3b0a 097d 0a0a 0969 6e74 2073 6573  s);..}...int ses
    │ │ │ -00021110: 7369 6f6e 5f69 6d70 6c3a 3a64 6f77 6e6c  sion_impl::downl
    │ │ │ -00021120: 6f61 645f 7261 7465 5f6c 696d 6974 5f64  oad_rate_limit_d
    │ │ │ -00021130: 6570 7228 2920 636f 6e73 740a 097b 0a09  epr() const..{..
    │ │ │ -00021140: 0972 6574 7572 6e20 646f 776e 6c6f 6164  .return download
    │ │ │ -00021150: 5f72 6174 655f 6c69 6d69 7428 6d5f 676c  _rate_limit(m_gl
    │ │ │ -00021160: 6f62 616c 5f63 6c61 7373 293b 0a09 7d0a  obal_class);..}.
    │ │ │ -00021170: 2365 6e64 6966 202f 2f20 4445 5052 4543  #endif // DEPREC
    │ │ │ -00021180: 4154 450a 0a0a 3c64 6976 2073 7479 6c65  ATE...
    .void sessio │ │ │ -000211c0: 6e5f 696d 706c 3a3a 7570 6461 7465 5f70 n_impl::update_p │ │ │ -000211d0: 6565 725f 6473 6370 2829 0a3c 2f64 6976 eer_dscp().
    .{...int const │ │ │ -000211f0: 7661 6c75 6520 3d20 6d5f 7365 7474 696e value = m_settin │ │ │ -00021200: 6773 2e67 6574 5f69 6e74 2873 6574 7469 gs.get_int(setti │ │ │ -00021210: 6e67 735f 7061 636b 3a3a 7065 6572 5f64 ngs_pack::peer_d │ │ │ -00021220: 7363 7029 3b0a 0909 666f 7220 2861 7574 scp);...for (aut │ │ │ -00021230: 6f20 636f 6e73 7426 616d 703b 206c 203a o const& l : │ │ │ -00021240: 206d 5f6c 6973 7465 6e5f 736f 636b 6574 m_listen_socket │ │ │ -00021250: 7329 0a09 097b 0a09 0909 6966 2028 6c2d s)...{....if (l- │ │ │ -00021260: 2667 743b 736f 636b 290a 0909 097b 0a09 >sock)....{.. │ │ │ -00021270: 0909 0965 7272 6f72 5f63 6f64 6520 6563 ...error_code ec │ │ │ -00021280: 3b0a 0909 0909 7365 745f 7472 6166 6669 ;.....set_traffi │ │ │ -00021290: 635f 636c 6173 7328 2a6c 2d26 6774 3b73 c_class(*l->s │ │ │ -000212a0: 6f63 6b2c 2076 616c 7565 2c20 6563 293b ock, value, ec); │ │ │ -000212b0: 0a0a 2369 666e 6465 6620 544f 5252 454e ..#ifndef TORREN │ │ │ -000212c0: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ -000212d0: 470a 0909 0909 6966 2028 7368 6f75 6c64 G.....if (should │ │ │ -000212e0: 5f6c 6f67 2829 290a 0909 0909 7b0a 0909 _log()).....{... │ │ │ -000212f0: 0909 0973 6573 7369 6f6e 5f6c 6f67 2822 ...session_log(" │ │ │ -00021300: 2667 743b 2667 743b 2667 743b 2053 4554 >>> SET │ │ │ -00021310: 5f44 5343 5020 5b20 7463 7020 2825 7320 _DSCP [ tcp (%s │ │ │ -00021320: 2564 2920 7661 6c75 653a 2025 7820 653a %d) value: %x e: │ │ │ -00021330: 2025 7320 5d22 0a09 0909 0909 092c 206c %s ]"......., l │ │ │ -00021340: 2d26 6774 3b73 6f63 6b2d 2667 743b 6c6f ->sock->lo │ │ │ -00021350: 6361 6c5f 656e 6470 6f69 6e74 2829 2e61 cal_endpoint().a │ │ │ -00021360: 6464 7265 7373 2829 2e74 6f5f 7374 7269 ddress().to_stri │ │ │ -00021370: 6e67 2829 2e63 5f73 7472 2829 0a09 0909 ng().c_str().... │ │ │ -00021380: 0909 092c 206c 2d26 6774 3b73 6f63 6b2d ..., l->sock- │ │ │ -00021390: 2667 743b 6c6f 6361 6c5f 656e 6470 6f69 >local_endpoi │ │ │ -000213a0: 6e74 2829 2e70 6f72 7428 292c 2073 7464 nt().port(), std │ │ │ -000213b0: 3a3a 7569 6e74 3332 5f74 2876 616c 7565 ::uint32_t(value │ │ │ -000213c0: 292c 2065 632e 6d65 7373 6167 6528 292e ), ec.message(). │ │ │ -000213d0: 635f 7374 7228 2929 3b0a 0909 0909 7d0a c_str());.....}. │ │ │ -000213e0: 2365 6e64 6966 0a09 0909 7d0a 0a09 0909 #endif....}..... │ │ │ -000213f0: 6966 2028 6c2d 2667 743b 7564 705f 736f if (l->udp_so │ │ │ -00021400: 636b 290a 0909 097b 0a09 0909 0965 7272 ck)....{.....err │ │ │ -00021410: 6f72 5f63 6f64 6520 6563 3b0a 0909 0909 or_code ec;..... │ │ │ -00021420: 7365 745f 7472 6166 6669 635f 636c 6173 set_traffic_clas │ │ │ -00021430: 7328 6c2d 2667 743b 7564 705f 736f 636b s(l->udp_sock │ │ │ -00021440: 2d26 6774 3b73 6f63 6b2c 2076 616c 7565 ->sock, value │ │ │ -00021450: 2c20 6563 293b 0a0a 2369 666e 6465 6620 , ec);..#ifndef │ │ │ -00021460: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00021470: 4c4f 4747 494e 470a 0909 0909 6966 2028 LOGGING.....if ( │ │ │ -00021480: 7368 6f75 6c64 5f6c 6f67 2829 290a 0909 should_log())... │ │ │ -00021490: 0909 7b0a 0909 0909 0973 6573 7369 6f6e ..{......session │ │ │ -000214a0: 5f6c 6f67 2822 2667 743b 2667 743b 2667 _log(">>&g │ │ │ -000214b0: 743b 2053 4554 5f44 5343 5020 5b20 7564 t; SET_DSCP [ ud │ │ │ -000214c0: 7020 2825 7320 2564 2920 7661 6c75 653a p (%s %d) value: │ │ │ -000214d0: 2025 7820 653a 2025 7320 5d22 0a09 0909 %x e: %s ]".... │ │ │ -000214e0: 0909 092c 206c 2d26 6774 3b75 6470 5f73 ..., l->udp_s │ │ │ -000214f0: 6f63 6b2d 2667 743b 736f 636b 2e6c 6f63 ock->sock.loc │ │ │ -00021500: 616c 5f65 6e64 706f 696e 7428 292e 6164 al_endpoint().ad │ │ │ -00021510: 6472 6573 7328 292e 746f 5f73 7472 696e dress().to_strin │ │ │ -00021520: 6728 292e 635f 7374 7228 290a 0909 0909 g().c_str()..... │ │ │ -00021530: 0909 2c20 6c2d 2667 743b 7564 705f 736f .., l->udp_so │ │ │ -00021540: 636b 2d26 6774 3b73 6f63 6b2e 6c6f 6361 ck->sock.loca │ │ │ -00021550: 6c5f 706f 7274 2829 0a3c 2f70 7265 3e3c l_port().
    < │ │ │ -00021560: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00021590: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ -000215a0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../src/bdecod │ │ │ -000215d0: 652e 6370 703a 3831 333c 2f61 3e3c 2f74 e.cpp:813
    attempt to │ │ │ -000215f0: 2073 696d 706c 6966 7920 7468 6973 2069 simplify this i │ │ │ -00021600: 6d70 6c65 6d65 6e74 6174 696f 6e20 6279 mplementation by │ │ │ -00021610: 2065 6d62 7261 6369 6e67 2074 6865 2073 embracing the s │ │ │ -00021620: 7061 6e3c 2f74 643e 3c2f 7472 3e3c 7472 pan

    │ │ │ -00021670: 6174 7465 6d70 7420 746f 2073 696d 706c attempt to simpl │ │ │ -00021680: 6966 7920 7468 6973 2069 6d70 6c65 6d65 ify this impleme │ │ │ -00021690: 6e74 6174 696f 6e20 6279 2065 6d62 7261 ntation by embra │ │ │ -000216a0: 6369 6e67 2074 6865 2073 7061 6e3c 2f68 cing the span

    ../src/bde │ │ │ -000216c0: 636f 6465 2e63 7070 3a38 3133 3c2f 6834 code.cpp:813

    .}...
    │ │ │ -00021710: 6264 6563 6f64 655f 6e6f 6465 2062 6465  bdecode_node bde
    │ │ │ -00021720: 636f 6465 2873 7061 6e26 6c74 3b63 6861  code(span<cha
    │ │ │ -00021730: 7220 636f 6e73 7426 6774 3b20 6275 6666  r const> buff
    │ │ │ -00021740: 6572 0a09 092c 2065 7272 6f72 5f63 6f64  er..., error_cod
    │ │ │ -00021750: 6526 616d 703b 2065 632c 2069 6e74 2a20  e& ec, int* 
    │ │ │ -00021760: 6572 726f 725f 706f 732c 2069 6e74 2064  error_pos, int d
    │ │ │ -00021770: 6570 7468 5f6c 696d 6974 2c20 696e 7420  epth_limit, int 
    │ │ │ -00021780: 746f 6b65 6e5f 6c69 6d69 7429 0a09 7b0a  token_limit)..{.
    │ │ │ -00021790: 0909 6264 6563 6f64 655f 6e6f 6465 2072  ..bdecode_node r
    │ │ │ -000217a0: 6574 3b0a 0909 6563 2e63 6c65 6172 2829  et;...ec.clear()
    │ │ │ -000217b0: 3b0a 0a09 0969 6620 2862 7566 6665 722e  ;....if (buffer.
    │ │ │ -000217c0: 7369 7a65 2829 2026 6774 3b20 6264 6563  size() > bdec
    │ │ │ -000217d0: 6f64 655f 746f 6b65 6e3a 3a6d 6178 5f6f  ode_token::max_o
    │ │ │ -000217e0: 6666 7365 7429 0a09 097b 0a09 0909 6966  ffset)...{....if
    │ │ │ -000217f0: 2028 6572 726f 725f 706f 7329 202a 6572   (error_pos) *er
    │ │ │ -00021800: 726f 725f 706f 7320 3d20 303b 0a09 0909  ror_pos = 0;....
    │ │ │ -00021810: 6563 203d 2062 6465 636f 6465 5f65 7272  ec = bdecode_err
    │ │ │ -00021820: 6f72 733a 3a6c 696d 6974 5f65 7863 6565  ors::limit_excee
    │ │ │ -00021830: 6465 643b 0a09 0909 7265 7475 726e 2072  ded;....return r
    │ │ │ -00021840: 6574 3b0a 0909 7d0a 0a09 092f 2f20 7468  et;...}....// th
    │ │ │ -00021850: 6973 2069 7320 7468 6520 7374 6163 6b20  is is the stack 
    │ │ │ -00021860: 6f66 2062 6465 636f 6465 5f74 6f6b 656e  of bdecode_token
    │ │ │ -00021870: 2069 6e64 6963 6573 2c20 696e 746f 206d   indices, into m
    │ │ │ -00021880: 5f74 6f6b 656e 732e 0a09 092f 2f20 7370  _tokens....// sp
    │ │ │ -00021890: 2069 7320 7468 6520 7374 6163 6b20 706f   is the stack po
    │ │ │ -000218a0: 696e 7465 722c 2061 7320 696e 6465 7820  inter, as index 
    │ │ │ -000218b0: 696e 746f 2074 6865 2061 7272 6179 2c20  into the array, 
    │ │ │ -000218c0: 7374 6163 6b0a 0909 696e 7420 7370 203d  stack...int sp =
    │ │ │ -000218d0: 2030 3b0a 0909 544f 5252 454e 545f 414c   0;...TORRENT_AL
    │ │ │ -000218e0: 4c4f 4341 2873 7461 636b 2c20 7374 6163  LOCA(stack, stac
    │ │ │ -000218f0: 6b5f 6672 616d 652c 2064 6570 7468 5f6c  k_frame, depth_l
    │ │ │ -00021900: 696d 6974 293b 0a0a 3c64 6976 2073 7479  imit);..
    ..char con │ │ │ -00021940: 7374 2a20 7374 6172 7420 3d20 6275 6666 st* start = buff │ │ │ -00021950: 6572 2e64 6174 6128 293b 0a3c 2f64 6976 er.data();.
    ..char const* e │ │ │ -00021970: 6e64 203d 2073 7461 7274 202b 2062 7566 nd = start + buf │ │ │ -00021980: 6665 722e 7369 7a65 2829 3b0a 0909 6368 fer.size();...ch │ │ │ -00021990: 6172 2063 6f6e 7374 2a20 636f 6e73 7420 ar const* const │ │ │ -000219a0: 6f72 6967 5f73 7461 7274 203d 2073 7461 orig_start = sta │ │ │ -000219b0: 7274 3b0a 0a09 0969 6620 2873 7461 7274 rt;....if (start │ │ │ -000219c0: 203d 3d20 656e 6429 0a09 0909 544f 5252 == end)....TORR │ │ │ -000219d0: 454e 545f 4641 494c 5f42 4445 434f 4445 ENT_FAIL_BDECODE │ │ │ -000219e0: 2862 6465 636f 6465 5f65 7272 6f72 733a (bdecode_errors: │ │ │ -000219f0: 3a75 6e65 7870 6563 7465 645f 656f 6629 :unexpected_eof) │ │ │ -00021a00: 3b0a 0a09 0977 6869 6c65 2028 7374 6172 ;....while (star │ │ │ -00021a10: 7420 266c 743b 3d20 656e 6429 0a09 097b t <= end)...{ │ │ │ -00021a20: 0a09 0909 6966 2028 7374 6172 7420 2667 ....if (start &g │ │ │ -00021a30: 743b 3d20 656e 6429 2054 4f52 5245 4e54 t;= end) TORRENT │ │ │ -00021a40: 5f46 4149 4c5f 4244 4543 4f44 4528 6264 _FAIL_BDECODE(bd │ │ │ -00021a50: 6563 6f64 655f 6572 726f 7273 3a3a 756e ecode_errors::un │ │ │ -00021a60: 6578 7065 6374 6564 5f65 6f66 293b 0a0a expected_eof);.. │ │ │ -00021a70: 0909 0969 6620 2873 7020 2667 743b 3d20 ...if (sp >= │ │ │ -00021a80: 6465 7074 685f 6c69 6d69 7429 0a09 0909 depth_limit).... │ │ │ -00021a90: 0954 4f52 5245 4e54 5f46 4149 4c5f 4244 .TORRENT_FAIL_BD │ │ │ -00021aa0: 4543 4f44 4528 6264 6563 6f64 655f 6572 ECODE(bdecode_er │ │ │ -00021ab0: 726f 7273 3a3a 6465 7074 685f 6578 6365 rors::depth_exce │ │ │ -00021ac0: 6564 6564 293b 0a0a 0909 092d 2d74 6f6b eded);.....--tok │ │ │ -00021ad0: 656e 5f6c 696d 6974 3b0a 0909 0969 6620 en_limit;....if │ │ │ -00021ae0: 2874 6f6b 656e 5f6c 696d 6974 2026 6c74 (token_limit < │ │ │ -00021af0: 3b20 3029 0a09 0909 0954 4f52 5245 4e54 ; 0).....TORRENT │ │ │ -00021b00: 5f46 4149 4c5f 4244 4543 4f44 4528 6264 _FAIL_BDECODE(bd │ │ │ -00021b10: 6563 6f64 655f 6572 726f 7273 3a3a 6c69 ecode_errors::li │ │ │ -00021b20: 6d69 745f 6578 6365 6564 6564 293b 0a0a mit_exceeded);.. │ │ │ -00021b30: 0909 092f 2f20 6c6f 6f6b 2066 6f72 2061 ...// look for a │ │ │ -00021b40: 206e 6577 2074 6f6b 656e 0a09 0909 6368 new token....ch │ │ │ -00021b50: 6172 2063 6f6e 7374 2074 203d 202a 7374 ar const t = *st │ │ │ -00021b60: 6172 743b 0a0a 0909 0969 6e74 2063 6f6e art;.....int con │ │ │ -00021b70: 7374 2063 7572 7265 6e74 5f66 7261 6d65 st current_frame │ │ │ -00021b80: 203d 2073 703b 0a0a 0909 092f 2f20 6966 = sp;.....// if │ │ │ -00021b90: 2077 6527 7265 2063 7572 7265 6e74 6c79 we're currently │ │ │ -00021ba0: 2070 6172 7369 6e67 2061 2064 6963 7469 parsing a dicti │ │ │ -00021bb0: 6f6e 6172 792c 2061 7373 6572 7420 7468 onary, assert th │ │ │ -00021bc0: 6174 0a09 0909 2f2f 2065 7665 7279 206f at....// every o │ │ │ -00021bd0: 7468 6572 206e 6f64 6520 6973 2061 2073 ther node is a s │ │ │ -00021be0: 7472 696e 672e 0a09 0909 6966 2028 6375 tring.....if (cu │ │ │ -00021bf0: 7272 656e 745f 6672 616d 6520 2667 743b rrent_frame > │ │ │ -00021c00: 2030 0a09 0909 0926 616d 703b 2661 6d70 0.....&& │ │ │ -00021c10: 3b20 7265 742e 6d5f 746f 6b65 6e73 5b73 ; ret.m_tokens[s │ │ │ -00021c20: 7461 636b 5b63 7572 7265 6e74 5f66 7261 tack[current_fra │ │ │ -00021c30: 6d65 202d 2031 5d2e 746f 6b65 6e5d 2e74 me - 1].token].t │ │ │ -00021c40: 7970 6520 3d3d 2062 6465 636f 6465 5f74 ype == bdecode_t │ │ │ -00021c50: 6f6b 656e 3a3a 6469 6374 290a 0909 097b oken::dict)....{ │ │ │ -00021c60: 0a09 0909 0969 6620 2873 7461 636b 5b63 .....if (stack[c │ │ │ -00021c70: 7572 7265 6e74 5f66 7261 6d65 202d 2031 urrent_frame - 1 │ │ │ -00021c80: 5d2e 7374 6174 6520 3d3d 2030 290a 0909 ].state == 0)... │ │ │ -00021c90: 0909 7b0a 0909 0909 092f 2f20 7468 6520 ..{......// the │ │ │ -00021ca0: 6375 7272 656e 7420 7061 7265 6e74 2069 current parent i │ │ │ -00021cb0: 7320 6120 6469 6374 2061 6e64 2077 6520 s a dict and we │ │ │ -00021cc0: 6172 6520 7061 7273 696e 6720 6120 6b65 are parsing a ke │ │ │ -00021cd0: 792e 0a3c 2f70 7265 3e3c 2f74 643e 3c2f y..
    │ │ │ -00021d00: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00021d10: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ -00021d40: 7372 632f 7570 6e70 2e63 7070 3a39 333c src/upnp.cpp:93< │ │ │ -00021d50: 2f61 3e3c 2f74 643e 3c74 643e 7573 6520 /a>use │ │ │ -00021d60: 626f 6f73 743a 3a61 7369 6f3a 3a69 703a boost::asio::ip: │ │ │ -00021d70: 3a6e 6574 776f 726b 2069 6e73 7465 6164 :network instead │ │ │ -00021d80: 206f 6620 6e65 746d 6173 6b3c 2f74 643e of netmask │ │ │ -00021d90: 3c2f 7472 3e3c 7472 2069 643d 2236 3722

    use boos │ │ │ -00021de0: 743a 3a61 7369 6f3a 3a69 703a 3a6e 6574 t::asio::ip::net │ │ │ -00021df0: 776f 726b 2069 6e73 7465 6164 206f 6620 work instead of │ │ │ -00021e00: 6e65 746d 6173 6b3c 2f68 323e 3c68 343e netmask

    │ │ │ -00021e10: 2e2e 2f73 7263 2f75 706e 702e 6370 703a ../src/upnp.cpp: │ │ │ -00021e20: 3933 3c2f 6834 3e3c 7072 6520 7374 796c 93

    ..|| string_equ
    │ │ │ -00021e70: 616c 5f6e 6f5f 6361 7365 2863 6f6e 7465  al_no_case(conte
    │ │ │ -00021e80: 6e74 5f74 7970 652c 2022 6170 706c 6963  nt_type, "applic
    │ │ │ -00021e90: 6174 696f 6e2f 736f 6170 2b78 6d6c 225f  ation/soap+xml"_
    │ │ │ -00021ea0: 7376 293b 0a7d 0a0a 7570 6e70 3a3a 726f  sv);.}..upnp::ro
    │ │ │ -00021eb0: 6f74 6465 7669 6365 3a3a 726f 6f74 6465  otdevice::rootde
    │ │ │ -00021ec0: 7669 6365 2829 203d 2064 6566 6175 6c74  vice() = default
    │ │ │ -00021ed0: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f55  ;..#if TORRENT_U
    │ │ │ -00021ee0: 5345 5f41 5353 4552 5453 0a75 706e 703a  SE_ASSERTS.upnp:
    │ │ │ -00021ef0: 3a72 6f6f 7464 6576 6963 653a 3a7e 726f  :rootdevice::~ro
    │ │ │ -00021f00: 6f74 6465 7669 6365 2829 0a7b 0a09 544f  otdevice().{..TO
    │ │ │ -00021f10: 5252 454e 545f 4153 5345 5254 286d 6167  RRENT_ASSERT(mag
    │ │ │ -00021f20: 6963 203d 3d20 3133 3337 293b 0a09 6d61  ic == 1337);..ma
    │ │ │ -00021f30: 6769 6320 3d20 303b 0a7d 0a23 656c 7365  gic = 0;.}.#else
    │ │ │ -00021f40: 0a75 706e 703a 3a72 6f6f 7464 6576 6963  .upnp::rootdevic
    │ │ │ -00021f50: 653a 3a7e 726f 6f74 6465 7669 6365 2829  e::~rootdevice()
    │ │ │ -00021f60: 203d 2064 6566 6175 6c74 3b0a 2365 6e64   = default;.#end
    │ │ │ -00021f70: 6966 0a0a 7570 6e70 3a3a 726f 6f74 6465  if..upnp::rootde
    │ │ │ -00021f80: 7669 6365 3a3a 726f 6f74 6465 7669 6365  vice::rootdevice
    │ │ │ -00021f90: 2872 6f6f 7464 6576 6963 6520 636f 6e73  (rootdevice cons
    │ │ │ -00021fa0: 7426 616d 703b 2920 3d20 6465 6661 756c  t&) = defaul
    │ │ │ -00021fb0: 743b 0a75 706e 703a 3a72 6f6f 7464 6576  t;.upnp::rootdev
    │ │ │ -00021fc0: 6963 6526 616d 703b 2075 706e 703a 3a72  ice& upnp::r
    │ │ │ -00021fd0: 6f6f 7464 6576 6963 653a 3a6f 7065 7261  ootdevice::opera
    │ │ │ -00021fe0: 746f 723d 2872 6f6f 7464 6576 6963 6520  tor=(rootdevice 
    │ │ │ -00021ff0: 636f 6e73 7426 616d 703b 2920 2661 6d70  const&) &
    │ │ │ -00022000: 3b20 3d20 6465 6661 756c 743b 0a75 706e  ; = default;.upn
    │ │ │ -00022010: 703a 3a72 6f6f 7464 6576 6963 653a 3a72  p::rootdevice::r
    │ │ │ -00022020: 6f6f 7464 6576 6963 6528 726f 6f74 6465  ootdevice(rootde
    │ │ │ -00022030: 7669 6365 2661 6d70 3b26 616d 703b 2920  vice&&) 
    │ │ │ -00022040: 6e6f 6578 6365 7074 203d 2064 6566 6175  noexcept = defau
    │ │ │ -00022050: 6c74 3b0a 7570 6e70 3a3a 726f 6f74 6465  lt;.upnp::rootde
    │ │ │ -00022060: 7669 6365 2661 6d70 3b20 7570 6e70 3a3a  vice& upnp::
    │ │ │ -00022070: 726f 6f74 6465 7669 6365 3a3a 6f70 6572  rootdevice::oper
    │ │ │ -00022080: 6174 6f72 3d28 726f 6f74 6465 7669 6365  ator=(rootdevice
    │ │ │ -00022090: 2661 6d70 3b26 616d 703b 2920 2661 6d70  &&) &
    │ │ │ -000220a0: 3b20 3d20 6465 6661 756c 743b 0a0a 3c64  ; = default;..upnp
    │ │ │ -000220e0: 3a3a 7570 6e70 2869 6f5f 636f 6e74 6578  ::upnp(io_contex
    │ │ │ -000220f0: 7426 616d 703b 2069 6f73 0a3c 2f64 6976  t& ios.
    ., aux::session │ │ │ -00022110: 5f73 6574 7469 6e67 7320 636f 6e73 7426 _settings const& │ │ │ -00022120: 616d 703b 2073 6574 7469 6e67 730a 092c amp; settings.., │ │ │ -00022130: 2061 7578 3a3a 706f 7274 6d61 705f 6361 aux::portmap_ca │ │ │ -00022140: 6c6c 6261 636b 2661 6d70 3b20 6362 0a09 llback& cb.. │ │ │ -00022150: 2c20 6164 6472 6573 735f 7634 2063 6f6e , address_v4 con │ │ │ -00022160: 7374 206c 6973 7465 6e5f 6164 6472 6573 st listen_addres │ │ │ -00022170: 730a 092c 2061 6464 7265 7373 5f76 3420 s.., address_v4 │ │ │ -00022180: 636f 6e73 7420 6e65 746d 6173 6b0a 092c const netmask.., │ │ │ -00022190: 2073 7464 3a3a 7374 7269 6e67 206c 6973 std::string lis │ │ │ -000221a0: 7465 6e5f 6465 7669 6365 0a09 2c20 6c69 ten_device.., li │ │ │ -000221b0: 7374 656e 5f73 6f63 6b65 745f 6861 6e64 sten_socket_hand │ │ │ -000221c0: 6c65 206c 7329 0a09 3a20 6d5f 7365 7474 le ls)..: m_sett │ │ │ -000221d0: 696e 6773 2873 6574 7469 6e67 7329 0a09 ings(settings).. │ │ │ -000221e0: 2c20 6d5f 6361 6c6c 6261 636b 2863 6229 , m_callback(cb) │ │ │ -000221f0: 0a09 2c20 6d5f 696f 5f73 6572 7669 6365 .., m_io_service │ │ │ -00022200: 2869 6f73 290a 092c 206d 5f72 6573 6f6c (ios).., m_resol │ │ │ -00022210: 7665 7228 696f 7329 0a09 2c20 6d5f 6d75 ver(ios).., m_mu │ │ │ -00022220: 6c74 6963 6173 7428 696f 7329 0a09 2c20 lticast(ios).., │ │ │ -00022230: 6d5f 756e 6963 6173 7428 696f 7329 0a09 m_unicast(ios).. │ │ │ -00022240: 2c20 6d5f 6272 6f61 6463 6173 745f 7469 , m_broadcast_ti │ │ │ -00022250: 6d65 7228 696f 7329 0a09 2c20 6d5f 7265 mer(ios).., m_re │ │ │ -00022260: 6672 6573 685f 7469 6d65 7228 696f 7329 fresh_timer(ios) │ │ │ -00022270: 0a09 2c20 6d5f 6d61 705f 7469 6d65 7228 .., m_map_timer( │ │ │ -00022280: 696f 7329 0a09 2c20 6d5f 6c69 7374 656e ios).., m_listen │ │ │ -00022290: 5f61 6464 7265 7373 286c 6973 7465 6e5f _address(listen_ │ │ │ -000222a0: 6164 6472 6573 7329 0a09 2c20 6d5f 6e65 address).., m_ne │ │ │ -000222b0: 746d 6173 6b28 6e65 746d 6173 6b29 0a09 tmask(netmask).. │ │ │ -000222c0: 2c20 6d5f 6465 7669 6365 2873 7464 3a3a , m_device(std:: │ │ │ -000222d0: 6d6f 7665 286c 6973 7465 6e5f 6465 7669 move(listen_devi │ │ │ -000222e0: 6365 2929 0a23 6966 2054 4f52 5245 4e54 ce)).#if TORRENT │ │ │ -000222f0: 5f55 5345 5f53 534c 0a09 2c20 6d5f 7373 _USE_SSL.., m_ss │ │ │ -00022300: 6c5f 6374 7828 7373 6c3a 3a63 6f6e 7465 l_ctx(ssl::conte │ │ │ -00022310: 7874 3a3a 7373 6c76 3233 5f63 6c69 656e xt::sslv23_clien │ │ │ -00022320: 7429 0a23 656e 6469 660a 092c 206d 5f6c t).#endif.., m_l │ │ │ -00022330: 6973 7465 6e5f 6861 6e64 6c65 2873 7464 isten_handle(std │ │ │ -00022340: 3a3a 6d6f 7665 286c 7329 290a 7b0a 2369 ::move(ls)).{.#i │ │ │ -00022350: 6620 544f 5252 454e 545f 5553 455f 5353 f TORRENT_USE_SS │ │ │ -00022360: 4c0a 096d 5f73 736c 5f63 7478 2e73 6574 L..m_ssl_ctx.set │ │ │ -00022370: 5f76 6572 6966 795f 6d6f 6465 2861 7578 _verify_mode(aux │ │ │ -00022380: 3a3a 7373 6c3a 3a63 6f6e 7465 7874 3a3a ::ssl::context:: │ │ │ -00022390: 7665 7269 6679 5f6e 6f6e 6529 3b0a 2365 verify_none);.#e │ │ │ -000223a0: 6e64 6966 0a7d 0a0a 766f 6964 2075 706e ndif.}..void upn │ │ │ -000223b0: 703a 3a73 7461 7274 2829 0a7b 0a3c 2f70 p::start().{.

    re │ │ │ -000223f0: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2
    ../src/pe │ │ │ -00022430: 6572 5f6c 6973 742e 6370 703a 3531 353c er_list.cpp:515< │ │ │ -00022440: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ -00022450: 6f75 6c64 2062 6520 6e69 6365 2069 6620 ould be nice if │ │ │ -00022460: 7468 6572 6520 7761 7320 6120 7761 7920 there was a way │ │ │ -00022470: 746f 2069 7465 7261 7465 206f 7665 7220 to iterate over │ │ │ -00022480: 7468 6573 6520 746f 7272 656e 745f 7065 these torrent_pe │ │ │ -00022490: 6572 206f 626a 6563 7473 2069 6e20 7468 er objects in th │ │ │ -000224a0: 6520 6f72 6465 7220 7468 6579 2061 7265 e order they are │ │ │ -000224b0: 2061 6c6c 6f63 6174 6564 2069 6e20 7468 allocated in th │ │ │ -000224c0: 6520 706f 6f6c 2069 6e73 7465 6164 2e20 e pool instead. │ │ │ -000224d0: 4974 2077 6f75 6c64 2070 726f 6261 626c It would probabl │ │ │ -000224e0: 7920 6265 206d 6f72 6520 6566 6669 6369 y be more effici │ │ │ -000224f0: 656e 743c 2f74 643e 3c2f 7472 3e3c 7472 ent

    │ │ │ -00022540: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ -00022550: 2069 6620 7468 6572 6520 7761 7320 6120 if there was a │ │ │ -00022560: 7761 7920 746f 2069 7465 7261 7465 206f way to iterate o │ │ │ -00022570: 7665 7220 7468 6573 650a 746f 7272 656e ver these.torren │ │ │ -00022580: 745f 7065 6572 206f 626a 6563 7473 2069 t_peer objects i │ │ │ -00022590: 6e20 7468 6520 6f72 6465 7220 7468 6579 n the order they │ │ │ -000225a0: 2061 7265 2061 6c6c 6f63 6174 6564 2069 are allocated i │ │ │ -000225b0: 6e20 7468 6520 706f 6f6c 0a69 6e73 7465 n the pool.inste │ │ │ -000225c0: 6164 2e20 4974 2077 6f75 6c64 2070 726f ad. It would pro │ │ │ -000225d0: 6261 626c 7920 6265 206d 6f72 6520 6566 bably be more ef │ │ │ -000225e0: 6669 6369 656e 743c 2f68 323e 3c68 343e ficient

    │ │ │ -000225f0: 2e2e 2f73 7263 2f70 6565 725f 6c69 7374 ../src/peer_list │ │ │ -00022600: 2e63 7070 3a35 3135 3c2f 6834 3e3c 7072 .cpp:515

    .., int s │ │ │ -00022650: 6573 7369 6f6e 5f74 696d 652c 2074 6f72 ession_time, tor │ │ │ -00022660: 7265 6e74 5f73 7461 7465 2a20 7374 6174 rent_state* stat │ │ │ -00022670: 6529 0a09 7b0a 0909 544f 5252 454e 545f e)..{...TORRENT_ │ │ │ -00022680: 4153 5345 5254 2869 735f 7369 6e67 6c65 ASSERT(is_single │ │ │ -00022690: 5f74 6872 6561 6428 2929 3b0a 0909 494e _thread());...IN │ │ │ -000226a0: 5641 5249 414e 545f 4348 4543 4b3b 0a0a VARIANT_CHECK;.. │ │ │ -000226b0: 0909 636f 6e73 7420 696e 7420 6361 6e64 ..const int cand │ │ │ -000226c0: 6964 6174 655f 636f 756e 7420 3d20 3130 idate_count = 10 │ │ │ -000226d0: 3b0a 0909 7065 6572 732e 7265 7365 7276 ;...peers.reserv │ │ │ -000226e0: 6528 6361 6e64 6964 6174 655f 636f 756e e(candidate_coun │ │ │ -000226f0: 7429 3b0a 0a09 0969 6e74 2065 7261 7365 t);....int erase │ │ │ -00022700: 5f63 616e 6469 6461 7465 203d 202d 313b _candidate = -1; │ │ │ -00022710: 0a0a 0909 6966 2028 626f 6f6c 286d 5f66 ....if (bool(m_f │ │ │ -00022720: 696e 6973 6865 6429 2021 3d20 7374 6174 inished) != stat │ │ │ -00022730: 652d 2667 743b 6973 5f66 696e 6973 6865 e->is_finishe │ │ │ -00022740: 6429 0a09 0909 7265 6361 6c63 756c 6174 d)....recalculat │ │ │ -00022750: 655f 636f 6e6e 6563 745f 6361 6e64 6964 e_connect_candid │ │ │ -00022760: 6174 6573 2873 7461 7465 293b 0a0a 0909 ates(state);.... │ │ │ -00022770: 6175 783a 3a65 7874 6572 6e61 6c5f 6970 aux::external_ip │ │ │ -00022780: 2063 6f6e 7374 2661 6d70 3b20 6578 7465 const& exte │ │ │ -00022790: 726e 616c 203d 2073 7461 7465 2d26 6774 rnal = state-> │ │ │ -000227a0: 3b69 703b 0a09 0969 6e74 2065 7874 6572 ;ip;...int exter │ │ │ -000227b0: 6e61 6c5f 706f 7274 203d 2073 7461 7465 nal_port = state │ │ │ -000227c0: 2d26 6774 3b70 6f72 743b 0a0a 0909 6966 ->port;....if │ │ │ -000227d0: 2028 6d5f 726f 756e 645f 726f 6269 6e20 (m_round_robin │ │ │ -000227e0: 2667 743b 3d20 696e 7428 6d5f 7065 6572 >= int(m_peer │ │ │ -000227f0: 732e 7369 7a65 2829 2929 206d 5f72 6f75 s.size())) m_rou │ │ │ -00022800: 6e64 5f72 6f62 696e 203d 2030 3b0a 0a09 nd_robin = 0;... │ │ │ -00022810: 0969 6e74 206d 6178 5f70 6565 726c 6973 .int max_peerlis │ │ │ -00022820: 745f 7369 7a65 203d 2073 7461 7465 2d26 t_size = state-& │ │ │ -00022830: 6774 3b6d 6178 5f70 6565 726c 6973 745f gt;max_peerlist_ │ │ │ -00022840: 7369 7a65 3b0a 0a3c 6469 7620 7374 796c size;..
    ..for (int │ │ │ -00022880: 6974 6572 6174 696f 6e73 203d 2073 7464 iterations = std │ │ │ -00022890: 3a3a 6d69 6e28 696e 7428 6d5f 7065 6572 ::min(int(m_peer │ │ │ -000228a0: 732e 7369 7a65 2829 292c 2033 3030 293b s.size()), 300); │ │ │ -000228b0: 0a3c 2f64 6976 3e09 0909 6974 6572 6174 .
    ...iterat │ │ │ -000228c0: 696f 6e73 2026 6774 3b20 303b 202d 2d69 ions > 0; --i │ │ │ -000228d0: 7465 7261 7469 6f6e 7329 0a09 097b 0a09 terations)...{.. │ │ │ -000228e0: 0909 2b2b 7374 6174 652d 2667 743b 6c6f ..++state->lo │ │ │ -000228f0: 6f70 5f63 6f75 6e74 6572 3b0a 0a09 0909 op_counter;..... │ │ │ -00022900: 6966 2028 6d5f 726f 756e 645f 726f 6269 if (m_round_robi │ │ │ -00022910: 6e20 2667 743b 3d20 696e 7428 6d5f 7065 n >= int(m_pe │ │ │ -00022920: 6572 732e 7369 7a65 2829 2929 206d 5f72 ers.size())) m_r │ │ │ -00022930: 6f75 6e64 5f72 6f62 696e 203d 2030 3b0a ound_robin = 0;. │ │ │ -00022940: 0a09 0909 746f 7272 656e 745f 7065 6572 ....torrent_peer │ │ │ -00022950: 2661 6d70 3b20 7065 203d 202a 6d5f 7065 & pe = *m_pe │ │ │ -00022960: 6572 735b 6d5f 726f 756e 645f 726f 6269 ers[m_round_robi │ │ │ -00022970: 6e5d 3b0a 0909 0954 4f52 5245 4e54 5f41 n];....TORRENT_A │ │ │ -00022980: 5353 4552 5428 7065 2e69 6e5f 7573 6529 SSERT(pe.in_use) │ │ │ -00022990: 3b0a 0909 0969 6e74 2063 7572 7265 6e74 ;....int current │ │ │ -000229a0: 203d 206d 5f72 6f75 6e64 5f72 6f62 696e = m_round_robin │ │ │ -000229b0: 3b0a 0a09 0909 2f2f 2069 6620 7468 6520 ;.....// if the │ │ │ -000229c0: 6e75 6d62 6572 206f 6620 7065 6572 7320 number of peers │ │ │ -000229d0: 6973 2067 726f 7769 6e67 206c 6172 6765 is growing large │ │ │ -000229e0: 0a09 0909 2f2f 2077 6520 6e65 6564 2074 ....// we need t │ │ │ -000229f0: 6f20 7374 6172 7420 7765 6564 696e 672e o start weeding. │ │ │ -00022a00: 0a0a 0909 0969 6620 2869 6e74 286d 5f70 .....if (int(m_p │ │ │ -00022a10: 6565 7273 2e73 697a 6528 2929 2026 6774 eers.size()) > │ │ │ -00022a20: 3b3d 206d 6178 5f70 6565 726c 6973 745f ;= max_peerlist_ │ │ │ -00022a30: 7369 7a65 202a 2030 2e39 350a 0909 0909 size * 0.95..... │ │ │ -00022a40: 2661 6d70 3b26 616d 703b 206d 6178 5f70 && max_p │ │ │ -00022a50: 6565 726c 6973 745f 7369 7a65 2026 6774 eerlist_size > │ │ │ -00022a60: 3b20 3029 0a09 0909 7b0a 0909 0909 6966 ; 0)....{.....if │ │ │ -00022a70: 2028 6973 5f65 7261 7365 5f63 616e 6469 (is_erase_candi │ │ │ -00022a80: 6461 7465 2870 6529 0a09 0909 0909 2661 date(pe)......&a │ │ │ -00022a90: 6d70 3b26 616d 703b 2028 6572 6173 655f mp;& (erase_ │ │ │ -00022aa0: 6361 6e64 6964 6174 6520 3d3d 202d 310a candidate == -1. │ │ │ -00022ab0: 0909 0909 0909 7c7c 2021 636f 6d70 6172 ......|| !compar │ │ │ -00022ac0: 655f 7065 6572 5f65 7261 7365 282a 6d5f e_peer_erase(*m_ │ │ │ -00022ad0: 7065 6572 735b 6572 6173 655f 6361 6e64 peers[erase_cand │ │ │ -00022ae0: 6964 6174 655d 2c20 7065 2929 290a 0909 idate], pe)))... │ │ │ -00022af0: 0909 7b0a 0909 0909 0969 6620 2873 686f ..{......if (sho │ │ │ -00022b00: 756c 645f 6572 6173 655f 696d 6d65 6469 uld_erase_immedi │ │ │ -00022b10: 6174 656c 7928 7065 2929 0a09 0909 0909 ately(pe))...... │ │ │ -00022b20: 7b0a 0909 0909 0909 6966 2028 6572 6173 {.......if (eras │ │ │ -00022b30: 655f 6361 6e64 6964 6174 6520 2667 743b e_candidate > │ │ │ -00022b40: 2063 7572 7265 6e74 2920 2d2d 6572 6173 current) --eras │ │ │ -00022b50: 655f 6361 6e64 6964 6174 653b 0a09 0909 e_candidate;.... │ │ │ -00022b60: 0909 0965 7261 7365 5f70 6565 7228 6d5f ...erase_peer(m_ │ │ │ -00022b70: 7065 6572 732e 6265 6769 6e28 2920 2b20 peers.begin() + │ │ │ -00022b80: 6375 7272 656e 742c 2073 7461 7465 293b current, state); │ │ │ -00022b90: 0a09 0909 0909 0963 6f6e 7469 6e75 653b .......continue; │ │ │ -00022ba0: 0a09 0909 0909 7d0a 0909 0909 0965 6c73 ......}......els │ │ │ -00022bb0: 650a 0909 0909 097b 0a09 0909 0909 0965 e......{.......e │ │ │ -00022bc0: 7261 7365 5f63 616e 6469 6461 7465 203d rase_candidate = │ │ │ -00022bd0: 2063 7572 7265 6e74 3b0a 0909 0909 097d current;......} │ │ │ -00022be0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ -00022c20: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2
    ../sr │ │ │ -00022c50: 632f 6874 7470 5f74 7261 636b 6572 5f63 c/http_tracker_c │ │ │ -00022c60: 6f6e 6e65 6374 696f 6e2e 6370 703a 3436 onnection.cpp:46 │ │ │ -00022c70: 393c 2f61 3e3c 2f74 643e 3c74 643e 7265 9re │ │ │ -00022c80: 7475 726e 696e 6720 6120 626f 6f6c 2068 turning a bool h │ │ │ -00022c90: 6572 6520 6973 2072 6564 756e 6461 6e74 ere is redundant │ │ │ -00022ca0: 2e20 496e 7374 6561 6420 7468 6973 2066 . Instead this f │ │ │ -00022cb0: 756e 6374 696f 6e20 7368 6f75 6c64 2072 unction should r │ │ │ -00022cc0: 6574 7572 6e20 7468 6520 7065 6572 5f65 eturn the peer_e │ │ │ -00022cd0: 6e74 7279 3c2f 7464 3e3c 2f74 723e 3c74 ntry

    returning a boo │ │ │ -00022d30: 6c20 6865 7265 2069 7320 7265 6475 6e64 l here is redund │ │ │ -00022d40: 616e 742e 2049 6e73 7465 6164 2074 6869 ant. Instead thi │ │ │ -00022d50: 7320 6675 6e63 7469 6f6e 2073 686f 756c s function shoul │ │ │ -00022d60: 640a 7265 7475 726e 2074 6865 2070 6565 d.return the pee │ │ │ -00022d70: 725f 656e 7472 793c 2f68 323e 3c68 343e r_entry

    │ │ │ -00022d80: 2e2e 2f73 7263 2f68 7474 705f 7472 6163 ../src/http_trac │ │ │ -00022d90: 6b65 725f 636f 6e6e 6563 7469 6f6e 2e63 ker_connection.c │ │ │ -00022da0: 7070 3a34 3639 3c2f 6834 3e3c 7072 6520 pp:469

    ..{....cb-&
    │ │ │ -00022df0: 6774 3b74 7261 636b 6572 5f73 6372 6170  gt;tracker_scrap
    │ │ │ -00022e00: 655f 7265 7370 6f6e 7365 2874 7261 636b  e_response(track
    │ │ │ -00022e10: 6572 5f72 6571 2829 2c20 7265 7370 2e63  er_req(), resp.c
    │ │ │ -00022e20: 6f6d 706c 6574 650a 0909 0909 2c20 7265  omplete....., re
    │ │ │ -00022e30: 7370 2e69 6e63 6f6d 706c 6574 652c 2072  sp.incomplete, r
    │ │ │ -00022e40: 6573 702e 646f 776e 6c6f 6164 6564 2c20  esp.downloaded, 
    │ │ │ -00022e50: 7265 7370 2e64 6f77 6e6c 6f61 6465 7273  resp.downloaders
    │ │ │ -00022e60: 293b 0a09 097d 0a09 0965 6c73 650a 0909  );...}...else...
    │ │ │ -00022e70: 7b0a 0909 0973 7464 3a3a 6c69 7374 266c  {....std::list&l
    │ │ │ -00022e80: 743b 6164 6472 6573 7326 6774 3b20 6970  t;address> ip
    │ │ │ -00022e90: 5f6c 6973 743b 0a09 0909 6966 2028 6d5f  _list;....if (m_
    │ │ │ -00022ea0: 7472 6163 6b65 725f 636f 6e6e 6563 7469  tracker_connecti
    │ │ │ -00022eb0: 6f6e 290a 0909 097b 0a09 0909 0966 6f72  on)....{.....for
    │ │ │ -00022ec0: 2028 6175 746f 2063 6f6e 7374 2661 6d70   (auto const&
    │ │ │ -00022ed0: 3b20 656e 6470 203a 206d 5f74 7261 636b  ; endp : m_track
    │ │ │ -00022ee0: 6572 5f63 6f6e 6e65 6374 696f 6e2d 2667  er_connection-&g
    │ │ │ -00022ef0: 743b 656e 6470 6f69 6e74 7328 2929 0a09  t;endpoints())..
    │ │ │ -00022f00: 0909 097b 0a09 0909 0909 6970 5f6c 6973  ...{......ip_lis
    │ │ │ -00022f10: 742e 7075 7368 5f62 6163 6b28 656e 6470  t.push_back(endp
    │ │ │ -00022f20: 2e61 6464 7265 7373 2829 293b 0a09 0909  .address());....
    │ │ │ -00022f30: 097d 0a09 0909 7d0a 0a09 0909 6362 2d26  .}....}.....cb-&
    │ │ │ -00022f40: 6774 3b74 7261 636b 6572 5f72 6573 706f  gt;tracker_respo
    │ │ │ -00022f50: 6e73 6528 7472 6163 6b65 725f 7265 7128  nse(tracker_req(
    │ │ │ -00022f60: 292c 206d 5f74 7261 636b 6572 5f69 702c  ), m_tracker_ip,
    │ │ │ -00022f70: 2069 705f 6c69 7374 2c20 7265 7370 293b   ip_list, resp);
    │ │ │ -00022f80: 0a09 097d 0a09 0963 6c6f 7365 2829 3b0a  ...}...close();.
    │ │ │ -00022f90: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    .bool extract_ │ │ │ -00022fd0: 7065 6572 5f69 6e66 6f28 6264 6563 6f64 peer_info(bdecod │ │ │ -00022fe0: 655f 6e6f 6465 2063 6f6e 7374 2661 6d70 e_node const& │ │ │ -00022ff0: 3b20 696e 666f 2c20 7065 6572 5f65 6e74 ; info, peer_ent │ │ │ -00023000: 7279 2661 6d70 3b20 7265 742c 2065 7272 ry& ret, err │ │ │ -00023010: 6f72 5f63 6f64 6526 616d 703b 2065 6329 or_code& ec) │ │ │ -00023020: 0a3c 2f64 6976 3e09 7b0a 0909 2f2f 2065 .
    .{...// e │ │ │ -00023030: 7874 7261 6374 2070 6565 7220 6964 2028 xtract peer id ( │ │ │ -00023040: 6966 2061 6e79 290a 0909 6966 2028 696e if any)...if (in │ │ │ -00023050: 666f 2e74 7970 6528 2920 213d 2062 6465 fo.type() != bde │ │ │ -00023060: 636f 6465 5f6e 6f64 653a 3a64 6963 745f code_node::dict_ │ │ │ -00023070: 7429 0a09 097b 0a09 0909 6563 203d 2065 t)...{....ec = e │ │ │ -00023080: 7272 6f72 733a 3a69 6e76 616c 6964 5f70 rrors::invalid_p │ │ │ -00023090: 6565 725f 6469 6374 3b0a 0909 0972 6574 eer_dict;....ret │ │ │ -000230a0: 7572 6e20 6661 6c73 653b 0a09 097d 0a09 urn false;...}.. │ │ │ -000230b0: 0962 6465 636f 6465 5f6e 6f64 6520 6920 .bdecode_node i │ │ │ -000230c0: 3d20 696e 666f 2e64 6963 745f 6669 6e64 = info.dict_find │ │ │ -000230d0: 5f73 7472 696e 6728 2270 6565 7220 6964 _string("peer id │ │ │ -000230e0: 2229 3b0a 0909 6966 2028 6920 2661 6d70 ");...if (i & │ │ │ -000230f0: 3b26 616d 703b 2069 2e73 7472 696e 675f ;& i.string_ │ │ │ -00023100: 6c65 6e67 7468 2829 203d 3d20 3230 290a length() == 20). │ │ │ -00023110: 0909 7b0a 0909 0973 7464 3a3a 636f 7079 ..{....std::copy │ │ │ -00023120: 2869 2e73 7472 696e 675f 7074 7228 292c (i.string_ptr(), │ │ │ -00023130: 2069 2e73 7472 696e 675f 7074 7228 2920 i.string_ptr() │ │ │ -00023140: 2b20 3230 2c20 7265 742e 7069 642e 6265 + 20, ret.pid.be │ │ │ -00023150: 6769 6e28 2929 3b0a 0909 7d0a 0909 656c gin());...}...el │ │ │ -00023160: 7365 0a09 097b 0a09 0909 2f2f 2069 6620 se...{....// if │ │ │ -00023170: 7468 6572 6527 7320 6e6f 2070 6565 725f there's no peer_ │ │ │ -00023180: 6964 2c20 6a75 7374 2069 6e69 7469 616c id, just initial │ │ │ -00023190: 697a 6520 6974 2074 6f20 6120 6275 6e63 ize it to a bunc │ │ │ -000231a0: 6820 6f66 207a 6572 6f65 730a 0909 0972 h of zeroes....r │ │ │ -000231b0: 6574 2e70 6964 2e63 6c65 6172 2829 3b0a et.pid.clear();. │ │ │ -000231c0: 0909 7d0a 0a09 092f 2f20 6578 7472 6163 ..}....// extrac │ │ │ -000231d0: 7420 6970 0a09 0969 203d 2069 6e66 6f2e t ip...i = info. │ │ │ -000231e0: 6469 6374 5f66 696e 645f 7374 7269 6e67 dict_find_string │ │ │ -000231f0: 2822 6970 2229 3b0a 0909 6966 2028 2169 ("ip");...if (!i │ │ │ -00023200: 290a 0909 7b0a 0909 0965 6320 3d20 6572 )...{....ec = er │ │ │ -00023210: 726f 7273 3a3a 696e 7661 6c69 645f 7472 rors::invalid_tr │ │ │ -00023220: 6163 6b65 725f 7265 7370 6f6e 7365 3b0a acker_response;. │ │ │ -00023230: 0909 0972 6574 7572 6e20 6661 6c73 653b ...return false; │ │ │ -00023240: 0a09 097d 0a09 0972 6574 2e68 6f73 746e ...}...ret.hostn │ │ │ -00023250: 616d 6520 3d20 692e 7374 7269 6e67 5f76 ame = i.string_v │ │ │ -00023260: 616c 7565 2829 3b0a 0a09 092f 2f20 6578 alue();....// ex │ │ │ -00023270: 7472 6163 7420 706f 7274 0a09 0969 203d tract port...i = │ │ │ -00023280: 2069 6e66 6f2e 6469 6374 5f66 696e 645f info.dict_find_ │ │ │ -00023290: 696e 7428 2270 6f72 7422 293b 0a09 0969 int("port");...i │ │ │ -000232a0: 6620 2821 6929 0a3c 2f70 7265 3e3c 2f74 f (!i).
    relevanc │ │ │ -000232e0: 6526 6e62 7370 3b32 3c2f 7464 3e3c 7464 e 2../src/torrent. │ │ │ -00023320: 6370 703a 3534 323c 2f61 3e3c 2f74 643e cpp:542 │ │ │ -00023330: 3c74 643e 706f 7374 2061 6c65 7274 3c2f post alert

    post │ │ │ -00023390: 616c 6572 743c 2f68 323e 3c68 343e 2e2e alert

    .. │ │ │ -000233a0: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -000233b0: 3a35 3432 3c2f 6834 3e3c 7072 6520 7374 :542

    ..if (m_curre
    │ │ │ -00023400: 6e74 5f67 6175 6765 5f73 7461 7465 2021  nt_gauge_state !
    │ │ │ -00023410: 3d20 6e6f 5f67 6175 6765 5f73 7461 7465  = no_gauge_state
    │ │ │ -00023420: 290a 0909 0969 6e63 5f73 7461 7473 5f63  )....inc_stats_c
    │ │ │ -00023430: 6f75 6e74 6572 286d 5f63 7572 7265 6e74  ounter(m_current
    │ │ │ -00023440: 5f67 6175 6765 5f73 7461 7465 202b 2063  _gauge_state + c
    │ │ │ -00023450: 6f75 6e74 6572 733a 3a6e 756d 5f63 6865  ounters::num_che
    │ │ │ -00023460: 636b 696e 675f 746f 7272 656e 7473 2c20  cking_torrents, 
    │ │ │ -00023470: 2d31 293b 0a09 0969 6620 286e 6577 5f67  -1);...if (new_g
    │ │ │ -00023480: 6175 6765 5f73 7461 7465 2021 3d20 6e6f  auge_state != no
    │ │ │ -00023490: 5f67 6175 6765 5f73 7461 7465 290a 0909  _gauge_state)...
    │ │ │ -000234a0: 0969 6e63 5f73 7461 7473 5f63 6f75 6e74  .inc_stats_count
    │ │ │ -000234b0: 6572 286e 6577 5f67 6175 6765 5f73 7461  er(new_gauge_sta
    │ │ │ -000234c0: 7465 202b 2063 6f75 6e74 6572 733a 3a6e  te + counters::n
    │ │ │ -000234d0: 756d 5f63 6865 636b 696e 675f 746f 7272  um_checking_torr
    │ │ │ -000234e0: 656e 7473 2c20 3129 3b0a 0a09 0954 4f52  ents, 1);....TOR
    │ │ │ -000234f0: 5245 4e54 5f41 5353 4552 5428 6e65 775f  RENT_ASSERT(new_
    │ │ │ -00023500: 6761 7567 655f 7374 6174 6520 2667 743b  gauge_state >
    │ │ │ -00023510: 3d20 3029 3b0a 0909 544f 5252 454e 545f  = 0);...TORRENT_
    │ │ │ -00023520: 4153 5345 5254 286e 6577 5f67 6175 6765  ASSERT(new_gauge
    │ │ │ -00023530: 5f73 7461 7465 2026 6c74 3b3d 206e 6f5f  _state <= no_
    │ │ │ -00023540: 6761 7567 655f 7374 6174 6529 3b0a 0909  gauge_state);...
    │ │ │ -00023550: 6d5f 6375 7272 656e 745f 6761 7567 655f  m_current_gauge_
    │ │ │ -00023560: 7374 6174 6520 3d20 7374 6174 6963 5f63  state = static_c
    │ │ │ -00023570: 6173 7426 6c74 3b73 7464 3a3a 7569 6e74  ast<std::uint
    │ │ │ -00023580: 3332 5f74 2667 743b 286e 6577 5f67 6175  32_t>(new_gau
    │ │ │ -00023590: 6765 5f73 7461 7465 293b 0a09 7d0a 0a09  ge_state);..}...
    │ │ │ -000235a0: 766f 6964 2074 6f72 7265 6e74 3a3a 6c65  void torrent::le
    │ │ │ -000235b0: 6176 655f 7365 6564 5f6d 6f64 6528 7365  ave_seed_mode(se
    │ │ │ -000235c0: 6564 5f6d 6f64 655f 7420 636f 6e73 7420  ed_mode_t const 
    │ │ │ -000235d0: 6368 6563 6b69 6e67 290a 097b 0a09 0969  checking)..{...i
    │ │ │ -000235e0: 6620 2821 6d5f 7365 6564 5f6d 6f64 6529  f (!m_seed_mode)
    │ │ │ -000235f0: 2072 6574 7572 6e3b 0a0a 0909 6966 2028   return;....if (
    │ │ │ -00023600: 6368 6563 6b69 6e67 203d 3d20 7365 6564  checking == seed
    │ │ │ -00023610: 5f6d 6f64 655f 743a 3a63 6865 636b 5f66  _mode_t::check_f
    │ │ │ -00023620: 696c 6573 290a 0909 7b0a 0909 092f 2f20  iles)...{....// 
    │ │ │ -00023630: 7468 6973 206d 6561 6e73 2074 6865 2075  this means the u
    │ │ │ -00023640: 7365 7220 7072 6f6d 6973 6564 2077 6520  ser promised we 
    │ │ │ -00023650: 6861 6420 616c 6c20 7468 650a 0909 092f  had all the..../
    │ │ │ -00023660: 2f20 6669 6c65 732c 2062 7574 2069 7420  / files, but it 
    │ │ │ -00023670: 7475 726e 6564 206f 7574 2077 6520 6469  turned out we di
    │ │ │ -00023680: 646e 2774 2e20 5468 6973 2069 730a 0909  dn't. This is...
    │ │ │ -00023690: 092f 2f20 616e 2065 7272 6f72 2e0a 0a3c  .// an error...<
    │ │ │ -000236a0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -000236b0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -000236c0: 7769 6474 683d 2231 3030 2522 3e0a 3c2f  width="100%">.#ifndef TORR
    │ │ │ -000236e0: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ -000236f0: 494e 470a 0909 0964 6562 7567 5f6c 6f67  ING....debug_log
    │ │ │ -00023700: 2822 2a2a 2a20 4641 494c 4544 2053 4545  ("*** FAILED SEE
    │ │ │ -00023710: 4420 4d4f 4445 2c20 7265 6368 6563 6b69  D MODE, rechecki
    │ │ │ -00023720: 6e67 2229 3b0a 2365 6e64 6966 0a09 097d  ng");.#endif...}
    │ │ │ -00023730: 0a0a 2369 666e 6465 6620 544f 5252 454e  ..#ifndef TORREN
    │ │ │ -00023740: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ -00023750: 470a 0909 6465 6275 675f 6c6f 6728 222a  G...debug_log("*
    │ │ │ -00023760: 2a2a 204c 4541 5649 4e47 2053 4545 4420  ** LEAVING SEED 
    │ │ │ -00023770: 4d4f 4445 2028 2573 2922 0a09 0909 2c20  MODE (%s)"...., 
    │ │ │ -00023780: 6368 6563 6b69 6e67 203d 3d20 7365 6564  checking == seed
    │ │ │ -00023790: 5f6d 6f64 655f 743a 3a73 6b69 705f 6368  _mode_t::skip_ch
    │ │ │ -000237a0: 6563 6b69 6e67 203f 2022 6173 2073 6565  ecking ? "as see
    │ │ │ -000237b0: 6422 203a 2022 6173 206e 6f6e 2d73 6565  d" : "as non-see
    │ │ │ -000237c0: 6422 293b 0a23 656e 6469 660a 0909 6d5f  d");.#endif...m_
    │ │ │ -000237d0: 7365 6564 5f6d 6f64 6520 3d20 6661 6c73  seed_mode = fals
    │ │ │ -000237e0: 653b 0a09 092f 2f20 7365 6564 2069 7320  e;...// seed is 
    │ │ │ -000237f0: 6661 6c73 6520 6966 2077 6520 7475 726e  false if we turn
    │ │ │ -00023800: 6564 206f 7574 206e 6f74 0a09 092f 2f20  ed out not...// 
    │ │ │ -00023810: 746f 2062 6520 6120 7365 6564 2061 6674  to be a seed aft
    │ │ │ -00023820: 6572 2061 6c6c 0a09 0969 6620 2863 6865  er all...if (che
    │ │ │ -00023830: 636b 696e 6720 3d3d 2073 6565 645f 6d6f  cking == seed_mo
    │ │ │ -00023840: 6465 5f74 3a3a 6368 6563 6b5f 6669 6c65  de_t::check_file
    │ │ │ -00023850: 730a 0909 0926 616d 703b 2661 6d70 3b20  s....&& 
    │ │ │ -00023860: 7374 6174 6528 2920 213d 2074 6f72 7265  state() != torre
    │ │ │ -00023870: 6e74 5f73 7461 7475 733a 3a63 6865 636b  nt_status::check
    │ │ │ -00023880: 696e 675f 7265 7375 6d65 5f64 6174 6129  ing_resume_data)
    │ │ │ -00023890: 0a09 097b 0a09 0909 6d5f 6861 7665 5f61  ...{....m_have_a
    │ │ │ -000238a0: 6c6c 203d 2066 616c 7365 3b0a 0909 0973  ll = false;....s
    │ │ │ -000238b0: 6574 5f73 7461 7465 2874 6f72 7265 6e74  et_state(torrent
    │ │ │ -000238c0: 5f73 7461 7475 733a 3a64 6f77 6e6c 6f61  _status::downloa
    │ │ │ -000238d0: 6469 6e67 293b 0a09 0909 666f 7263 655f  ding);....force_
    │ │ │ -000238e0: 7265 6368 6563 6b28 293b 0a09 097d 0a09  recheck();...}..
    │ │ │ -000238f0: 096d 5f6e 756d 5f76 6572 6966 6965 6420  .m_num_verified 
    │ │ │ -00023900: 3d20 303b 0a09 096d 5f76 6572 6966 6965  = 0;...m_verifie
    │ │ │ -00023910: 642e 636c 6561 7228 293b 0a09 096d 5f76  d.clear();...m_v
    │ │ │ -00023920: 6572 6966 7969 6e67 2e63 6c65 6172 2829  erifying.clear()
    │ │ │ -00023930: 3b0a 0a09 0973 6574 5f6e 6565 645f 7361  ;....set_need_sa
    │ │ │ -00023940: 7665 5f72 6573 756d 6528 746f 7272 656e  ve_resume(torren
    │ │ │ -00023950: 745f 6861 6e64 6c65 3a3a 6966 5f73 7461  t_handle::if_sta
    │ │ │ -00023960: 7465 5f63 6861 6e67 6564 293b 0a09 7d0a  te_changed);..}.
    │ │ │ -00023970: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a  ..void torrent::
    │ │ │ -00023980: 7665 7269 6669 6564 2870 6965 6365 5f69  verified(piece_i
    │ │ │ -00023990: 6e64 6578 5f74 2063 6f6e 7374 2070 6965  ndex_t const pie
    │ │ │ -000239a0: 6365 290a 097b 0a09 0954 4f52 5245 4e54  ce)..{...TORRENT
    │ │ │ -000239b0: 5f41 5353 4552 5428 216d 5f76 6572 6966  _ASSERT(!m_verif
    │ │ │ -000239c0: 6965 642e 6765 745f 6269 7428 7069 6563  ied.get_bit(piec
    │ │ │ -000239d0: 6529 293b 0a09 092b 2b6d 5f6e 756d 5f76  e));...++m_num_v
    │ │ │ -000239e0: 6572 6966 6965 643b 0a3c 2f70 7265 3e3c  erified;.
    < │ │ │ -000239f0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00023a20: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ -00023a30: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torren │ │ │ -00023a60: 742e 6370 703a 3139 3935 3c2f 613e 3c2f t.cpp:1995add a uni │ │ │ -00023a80: 7420 7465 7374 2077 6865 7265 2077 6520 t test where we │ │ │ -00023a90: 646f 6e27 7420 6861 7665 206d 6574 6164 don't have metad │ │ │ -00023aa0: 6174 612c 2063 6f6e 6e65 6374 2074 6f20 ata, connect to │ │ │ -00023ab0: 6120 7065 6572 2074 6861 7420 7365 6e64 a peer that send │ │ │ -00023ac0: 7320 6120 6269 7466 6965 6c64 2074 6861 s a bitfield tha │ │ │ -00023ad0: 7427 7320 746f 6f20 6c61 7267 652c 2074 t's too large, t │ │ │ -00023ae0: 6865 6e20 7765 2067 6574 2074 6865 206d hen we get the m │ │ │ -00023af0: 6574 6164 6174 613c 2f74 643e 3c2f 7472 etadata │ │ │ -00023b30: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00023b40: 3c68 323e 6164 6420 6120 756e 6974 2074

    add a unit t │ │ │ -00023b50: 6573 7420 7768 6572 6520 7765 2064 6f6e est where we don │ │ │ -00023b60: 2774 2068 6176 6520 6d65 7461 6461 7461 't have metadata │ │ │ -00023b70: 2c20 636f 6e6e 6563 7420 746f 2061 2070 , connect to a p │ │ │ -00023b80: 6565 720a 7468 6174 2073 656e 6473 2061 eer.that sends a │ │ │ -00023b90: 2062 6974 6669 656c 6420 7468 6174 2773 bitfield that's │ │ │ -00023ba0: 2074 6f6f 206c 6172 6765 2c20 7468 656e too large, then │ │ │ -00023bb0: 2077 6520 6765 7420 7468 6520 6d65 7461 we get the meta │ │ │ -00023bc0: 6461 7461 3c2f 6832 3e3c 6834 3e2e 2e2f data

    ../ │ │ │ -00023bd0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00023be0: 3139 3935 3c2f 6834 3e3c 7072 6520 7374 1995

    ..file_storag
    │ │ │ -00023c30: 6520 636f 6e73 7426 616d 703b 2066 7320  e const& fs 
    │ │ │ -00023c40: 3d20 6d5f 746f 7272 656e 745f 6669 6c65  = m_torrent_file
    │ │ │ -00023c50: 2d26 6774 3b6c 6179 6f75 7428 293b 0a09  ->layout();..
    │ │ │ -00023c60: 0969 6620 286d 5f61 6464 5f74 6f72 7265  .if (m_add_torre
    │ │ │ -00023c70: 6e74 5f70 6172 616d 7329 0a09 097b 0a09  nt_params)...{..
    │ │ │ -00023c80: 0909 6d5f 7265 6e61 6d65 645f 6669 6c65  ..m_renamed_file
    │ │ │ -00023c90: 732e 696d 706f 7274 5f66 696c 656e 616d  s.import_filenam
    │ │ │ -00023ca0: 6573 286d 5f74 6f72 7265 6e74 5f66 696c  es(m_torrent_fil
    │ │ │ -00023cb0: 652d 2667 743b 6c61 796f 7574 2829 0a09  e->layout()..
    │ │ │ -00023cc0: 0909 092c 206d 5f61 6464 5f74 6f72 7265  ..., m_add_torre
    │ │ │ -00023cd0: 6e74 5f70 6172 616d 732d 2667 743b 7265  nt_params->re
    │ │ │ -00023ce0: 6e61 6d65 645f 6669 6c65 7329 3b0a 0909  named_files);...
    │ │ │ -00023cf0: 7d0a 0a09 0963 6f6e 7374 7275 6374 5f73  }....construct_s
    │ │ │ -00023d00: 746f 7261 6765 2829 3b0a 0a23 6966 6e64  torage();..#ifnd
    │ │ │ -00023d10: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ -00023d20: 4c45 5f53 4841 5245 5f4d 4f44 450a 0909  LE_SHARE_MODE...
    │ │ │ -00023d30: 6966 2028 6d5f 7368 6172 655f 6d6f 6465  if (m_share_mode
    │ │ │ -00023d40: 2026 616d 703b 2661 6d70 3b20 7661 6c69   && vali
    │ │ │ -00023d50: 645f 6d65 7461 6461 7461 2829 290a 0909  d_metadata())...
    │ │ │ -00023d60: 7b0a 0909 092f 2f20 696e 2073 6861 7265  {....// in share
    │ │ │ -00023d70: 206d 6f64 652c 2061 6c6c 2070 6965 6365   mode, all piece
    │ │ │ -00023d80: 7320 6861 7665 2074 6865 6972 2070 7269  s have their pri
    │ │ │ -00023d90: 6f72 6974 6965 7320 696e 6974 6961 6c69  orities initiali
    │ │ │ -00023da0: 7a65 6420 746f 2030 0a09 0909 6d5f 6669  zed to 0....m_fi
    │ │ │ -00023db0: 6c65 5f70 7269 6f72 6974 792e 636c 6561  le_priority.clea
    │ │ │ -00023dc0: 7228 293b 0a09 0909 6d5f 6669 6c65 5f70  r();....m_file_p
    │ │ │ -00023dd0: 7269 6f72 6974 792e 7265 7369 7a65 286d  riority.resize(m
    │ │ │ -00023de0: 5f74 6f72 7265 6e74 5f66 696c 652d 2667  _torrent_file-&g
    │ │ │ -00023df0: 743b 6e75 6d5f 6669 6c65 7328 292c 2064  t;num_files(), d
    │ │ │ -00023e00: 6f6e 745f 646f 776e 6c6f 6164 293b 0a09  ont_download);..
    │ │ │ -00023e10: 097d 0a23 656e 6469 660a 0a09 092f 2f20  .}.#endif....// 
    │ │ │ -00023e20: 6974 2773 2069 6d70 6f72 7461 6e74 2074  it's important t
    │ │ │ -00023e30: 6f20 696e 6974 6961 6c69 7a65 2074 6865  o initialize the
    │ │ │ -00023e40: 2070 6565 7273 2065 6172 6c79 2c20 6265   peers early, be
    │ │ │ -00023e50: 6361 7573 6520 7468 6973 2069 7320 7768  cause this is wh
    │ │ │ -00023e60: 6174 2077 696c 6c0a 0909 2f2f 2066 6978  at will...// fix
    │ │ │ -00023e70: 2075 7020 7468 6569 7220 6861 7665 2d62   up their have-b
    │ │ │ -00023e80: 6974 6d61 736b 7320 746f 2068 6176 6520  itmasks to have 
    │ │ │ -00023e90: 7468 6520 636f 7272 6563 7420 7369 7a65  the correct size
    │ │ │ -00023ea0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00023ed0: 0969 6620 2821 6d5f 636f 6e6e 6563 7469 .if (!m_connecti │ │ │ -00023ee0: 6f6e 735f 696e 6974 6961 6c69 7a65 6429 ons_initialized) │ │ │ -00023ef0: 0a3c 2f64 6976 3e09 097b 0a09 0909 6d5f .
    ..{....m_ │ │ │ -00023f00: 636f 6e6e 6563 7469 6f6e 735f 696e 6974 connections_init │ │ │ -00023f10: 6961 6c69 7a65 6420 3d20 7472 7565 3b0a ialized = true;. │ │ │ -00023f20: 0909 092f 2f20 616c 6c20 7065 6572 2063 ...// all peer c │ │ │ -00023f30: 6f6e 6e65 6374 696f 6e73 2068 6176 6520 onnections have │ │ │ -00023f40: 746f 2069 6e69 7469 616c 697a 6520 7468 to initialize th │ │ │ -00023f50: 656d 7365 6c76 6573 206e 6f77 2074 6861 emselves now tha │ │ │ -00023f60: 7420 7468 6520 6d65 7461 6461 7461 0a09 t the metadata.. │ │ │ -00023f70: 0909 2f2f 2069 7320 6176 6169 6c61 626c ..// is availabl │ │ │ -00023f80: 650a 0909 092f 2f20 636f 7079 2074 6865 e....// copy the │ │ │ -00023f90: 2070 6565 7220 6c69 7374 2073 696e 6365 peer list since │ │ │ -00023fa0: 2070 6565 7273 206d 6179 2064 6973 636f peers may disco │ │ │ -00023fb0: 6e6e 6563 7420 616e 6420 696e 7661 6c69 nnect and invali │ │ │ -00023fc0: 6461 7465 0a09 0909 2f2f 206d 5f63 6f6e date....// m_con │ │ │ -00023fd0: 6e65 6374 696f 6e73 2061 7320 7765 2069 nections as we i │ │ │ -00023fe0: 6e69 7469 616c 697a 6520 7468 656d 0a09 nitialize them.. │ │ │ -00023ff0: 0909 666f 7220 2861 7574 6f2a 2063 6f6e ..for (auto* con │ │ │ -00024000: 7374 2063 203a 206d 5f63 6f6e 6e65 6374 st c : m_connect │ │ │ -00024010: 696f 6e73 290a 0909 097b 0a09 0909 0961 ions)....{.....a │ │ │ -00024020: 7574 6f20 7063 203d 2063 2d26 6774 3b73 uto pc = c->s │ │ │ -00024030: 656c 6628 293b 0a09 0909 0969 6620 2870 elf();.....if (p │ │ │ -00024040: 632d 2667 743b 6973 5f64 6973 636f 6e6e c->is_disconn │ │ │ -00024050: 6563 7469 6e67 2829 2920 636f 6e74 696e ecting()) contin │ │ │ -00024060: 7565 3b0a 0909 0909 7063 2d26 6774 3b6f ue;.....pc->o │ │ │ -00024070: 6e5f 6d65 7461 6461 7461 5f69 6d70 6c28 n_metadata_impl( │ │ │ -00024080: 293b 0a09 0909 0969 6620 2870 632d 2667 );.....if (pc-&g │ │ │ -00024090: 743b 6973 5f64 6973 636f 6e6e 6563 7469 t;is_disconnecti │ │ │ -000240a0: 6e67 2829 2920 636f 6e74 696e 7565 3b0a ng()) continue;. │ │ │ -000240b0: 0909 0909 7063 2d26 6774 3b69 6e69 7428 ....pc->init( │ │ │ -000240c0: 293b 0a09 0909 7d0a 0909 7d0a 0a09 092f );....}...}..../ │ │ │ -000240d0: 2f20 696e 2063 6173 6520 6669 6c65 2070 / in case file p │ │ │ -000240e0: 7269 6f72 6974 6965 7320 7765 7265 2070 riorities were p │ │ │ -000240f0: 6173 7365 6420 696e 2076 6961 2074 6865 assed in via the │ │ │ -00024100: 2061 6464 5f74 6f72 7265 6e74 5f70 6172 add_torrent_par │ │ │ -00024110: 616d 730a 0909 2f2f 2061 6e64 2061 6c73 ams...// and als │ │ │ -00024120: 6f20 696e 2074 6865 2063 6173 6520 6f66 o in the case of │ │ │ -00024130: 2073 6861 7265 206d 6f64 652c 2077 6520 share mode, we │ │ │ -00024140: 6e65 6564 2074 6f20 7570 6461 7465 2074 need to update t │ │ │ -00024150: 6865 2070 7269 6f72 6974 6965 730a 0909 he priorities... │ │ │ -00024160: 2f2f 2074 6869 7320 6861 7320 746f 2062 // this has to b │ │ │ -00024170: 6520 6170 706c 6965 6420 6265 666f 7265 e applied before │ │ │ -00024180: 2070 6965 6365 2070 7269 6f72 6974 790a piece priority. │ │ │ -00024190: 0909 6966 2028 216d 5f66 696c 655f 7072 ..if (!m_file_pr │ │ │ -000241a0: 696f 7269 7479 2e65 6d70 7479 2829 290a iority.empty()). │ │ │ -000241b0: 0909 7b0a 0909 092f 2f20 6d5f 6669 6c65 ..{....// m_file │ │ │ -000241c0: 5f70 7269 6f72 6974 7920 7761 7320 6c6f _priority was lo │ │ │ -000241d0: 6164 6564 2066 726f 6d20 7468 6520 7265 aded from the re │ │ │ -000241e0: 7375 6d65 2064 6174 612c 2074 6869 7320 sume data, this │ │ │ -000241f0: 646f 6573 6e27 740a 0909 092f 2f20 616c doesn't....// al │ │ │ -00024200: 7465 7220 616e 7920 7374 6174 6520 7468 ter any state th │ │ │ -00024210: 6174 206e 6565 6473 2074 6f20 6265 2073 at needs to be s │ │ │ -00024220: 6176 6564 2069 6e20 7468 6520 7265 7375 aved in the resu │ │ │ -00024230: 6d65 2064 6174 610a 0909 0961 7574 6f20 me data....auto │ │ │ -00024240: 636f 6e73 7420 6e73 203d 206d 5f6e 6565 const ns = m_nee │ │ │ -00024250: 645f 7361 7665 5f72 6573 756d 655f 6461 d_save_resume_da │ │ │ -00024260: 7461 3b0a 0909 0975 7064 6174 655f 7069 ta;....update_pi │ │ │ -00024270: 6563 655f 7072 696f 7269 7469 6573 286d ece_priorities(m │ │ │ -00024280: 5f66 696c 655f 7072 696f 7269 7479 293b _file_priority); │ │ │ -00024290: 0a09 0909 6d5f 6e65 6564 5f73 6176 655f ....m_need_save_ │ │ │ -000242a0: 7265 7375 6d65 5f64 6174 6120 3d20 6e73 resume_data = ns │ │ │ -000242b0: 3b0a 0909 7d0a 0a09 0969 6620 286d 5f61 ;...}....if (m_a │ │ │ -000242c0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -000242d0: 7329 0a09 097b 0a3c 2f70 7265 3e3c 2f74 s)...{.
    relevanc │ │ │ -00024310: 6526 6e62 7370 3b32 3c2f 7464 3e3c 7464 e 2../src/torrent. │ │ │ -00024350: 6370 703a 3533 3032 3c2f 613e 3c2f 7464 cpp:5302abort looku │ │ │ -00024370: 7073 2074 6869 7320 746f 7272 656e 7420 ps this torrent │ │ │ -00024380: 6861 7320 6d61 6465 2076 6961 2074 6865 has made via the │ │ │ -00024390: 2073 6573 7369 6f6e 2068 6f73 7420 7265 session host re │ │ │ -000243a0: 736f 6c76 6572 2069 6e74 6572 6661 6365 solver interface │ │ │ -000243b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    abo │ │ │ -00024400: 7274 206c 6f6f 6b75 7073 2074 6869 7320 rt lookups this │ │ │ -00024410: 746f 7272 656e 7420 6861 7320 6d61 6465 torrent has made │ │ │ -00024420: 2076 6961 2074 6865 0a73 6573 7369 6f6e via the.session │ │ │ -00024430: 2068 6f73 7420 7265 736f 6c76 6572 2069 host resolver i │ │ │ -00024440: 6e74 6572 6661 6365 3c2f 6832 3e3c 6834 nterface

    ../src/torrent. │ │ │ -00024460: 6370 703a 3533 3032 3c2f 6834 3e3c 7072 cpp:5302

    ....TORRE │ │ │ -000244b0: 4e54 5f55 4e55 5345 4428 6529 3b0a 0909 NT_UNUSED(e);... │ │ │ -000244c0: 0909 6d5f 7374 6f72 6167 652e 7265 7365 ..m_storage.rese │ │ │ -000244d0: 7428 293b 0a23 6966 6e64 6566 2054 4f52 t();.#ifndef TOR │ │ │ -000244e0: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ -000244f0: 4749 4e47 0a09 0909 0964 6562 7567 5f6c GING.....debug_l │ │ │ -00024500: 6f67 2822 4661 696c 6564 2074 6f20 666c og("Failed to fl │ │ │ -00024510: 7573 6820 6469 736b 2063 6163 6865 3a20 ush disk cache: │ │ │ -00024520: 2573 222c 2065 2e77 6861 7428 2929 3b0a %s", e.what());. │ │ │ -00024530: 2365 6e64 6966 0a09 0909 092f 2f20 636c #endif.....// cl │ │ │ -00024540: 6965 6e74 7320 6d61 7920 7265 6c79 206f ients may rely o │ │ │ -00024550: 6e20 7468 6973 2061 6c65 7274 2074 6f20 n this alert to │ │ │ -00024560: 6265 2070 6f73 7465 642c 2073 6f20 6974 be posted, so it │ │ │ -00024570: 2773 2070 726f 6261 626c 7920 610a 0909 's probably a... │ │ │ -00024580: 0909 2f2f 2067 6f6f 6420 6964 6561 2074 ..// good idea t │ │ │ -00024590: 6f20 706f 7374 2069 7420 6865 7265 2c20 o post it here, │ │ │ -000245a0: 6576 656e 2074 686f 7567 6820 7765 2066 even though we f │ │ │ -000245b0: 6169 6c65 640a 0909 0909 6966 2028 616c ailed.....if (al │ │ │ -000245c0: 6572 7473 2829 2e73 686f 756c 645f 706f erts().should_po │ │ │ -000245d0: 7374 266c 743b 6361 6368 655f 666c 7573 st<cache_flus │ │ │ -000245e0: 6865 645f 616c 6572 7426 6774 3b28 2929 hed_alert>()) │ │ │ -000245f0: 0a09 0909 0909 616c 6572 7473 2829 2e65 ......alerts().e │ │ │ -00024600: 6d70 6c61 6365 5f61 6c65 7274 266c 743b mplace_alert< │ │ │ -00024610: 6361 6368 655f 666c 7573 6865 645f 616c cache_flushed_al │ │ │ -00024620: 6572 7426 6774 3b28 6765 745f 6861 6e64 ert>(get_hand │ │ │ -00024630: 6c65 2829 293b 0a09 0909 7d0a 0909 096d le());....}....m │ │ │ -00024640: 5f73 6573 2e64 6566 6572 7265 645f 7375 _ses.deferred_su │ │ │ -00024650: 626d 6974 5f6a 6f62 7328 293b 0a09 097d bmit_jobs();...} │ │ │ -00024660: 0a09 0965 6c73 650a 0909 7b0a 0909 0969 ...else...{....i │ │ │ -00024670: 6620 2861 6c65 7274 7328 292e 7368 6f75 f (alerts().shou │ │ │ -00024680: 6c64 5f70 6f73 7426 6c74 3b63 6163 6865 ld_post<cache │ │ │ -00024690: 5f66 6c75 7368 6564 5f61 6c65 7274 2667 _flushed_alert&g │ │ │ -000246a0: 743b 2829 290a 0909 0909 616c 6572 7473 t;()).....alerts │ │ │ -000246b0: 2829 2e65 6d70 6c61 6365 5f61 6c65 7274 ().emplace_alert │ │ │ -000246c0: 266c 743b 6361 6368 655f 666c 7573 6865 <cache_flushe │ │ │ -000246d0: 645f 616c 6572 7426 6774 3b28 6765 745f d_alert>(get_ │ │ │ -000246e0: 6861 6e64 6c65 2829 293b 0a09 0909 616c handle());....al │ │ │ -000246f0: 6572 7473 2829 2e65 6d70 6c61 6365 5f61 erts().emplace_a │ │ │ -00024700: 6c65 7274 266c 743b 746f 7272 656e 745f lert<torrent_ │ │ │ -00024710: 7265 6d6f 7665 645f 616c 6572 7426 6774 removed_alert> │ │ │ -00024720: 3b28 6765 745f 6861 6e64 6c65 2829 0a09 ;(get_handle().. │ │ │ -00024730: 0909 092c 2069 6e66 6f5f 6861 7368 2829 ..., info_hash() │ │ │ -00024740: 2c20 6765 745f 7573 6572 6461 7461 2829 , get_userdata() │ │ │ -00024750: 293b 0a09 097d 0a0a 3c64 6976 2073 7479 );...}..
    .
    ..i │ │ │ -00024790: 6620 2821 6d5f 6170 706c 795f 6970 5f66 f (!m_apply_ip_f │ │ │ -000247a0: 696c 7465 7229 0a09 097b 0a09 0909 696e ilter)...{....in │ │ │ -000247b0: 635f 7374 6174 735f 636f 756e 7465 7228 c_stats_counter( │ │ │ -000247c0: 636f 756e 7465 7273 3a3a 6e6f 6e5f 6669 counters::non_fi │ │ │ -000247d0: 6c74 6572 5f74 6f72 7265 6e74 732c 202d lter_torrents, - │ │ │ -000247e0: 3129 3b0a 0909 096d 5f61 7070 6c79 5f69 1);....m_apply_i │ │ │ -000247f0: 705f 6669 6c74 6572 203d 2074 7275 653b p_filter = true; │ │ │ -00024800: 0a09 097d 0a0a 2369 6620 544f 5252 454e ...}..#if TORREN │ │ │ -00024810: 545f 5553 455f 5254 430a 0909 6966 286d T_USE_RTC...if(m │ │ │ -00024820: 5f72 7463 5f73 6967 6e61 6c69 6e67 290a _rtc_signaling). │ │ │ -00024830: 0909 096d 5f72 7463 5f73 6967 6e61 6c69 ...m_rtc_signali │ │ │ -00024840: 6e67 2d26 6774 3b63 6c6f 7365 2829 3b0a ng->close();. │ │ │ -00024850: 2365 6e64 6966 0a09 7d0a 0a09 2f2f 2074 #endif..}...// t │ │ │ -00024860: 6869 7320 6973 2063 616c 6c65 6420 7768 his is called wh │ │ │ -00024870: 656e 2077 6527 7265 2064 6573 7472 7563 en we're destruc │ │ │ -00024880: 7469 6e67 206e 6f6e 2d67 7261 6365 6675 ting non-gracefu │ │ │ -00024890: 6c6c 792e 2069 2e65 2e20 7765 2772 6520 lly. i.e. we're │ │ │ -000248a0: 5f6a 7573 745f 0a09 2f2f 2064 6573 7472 _just_..// destr │ │ │ -000248b0: 7563 7469 6e67 2065 7665 7279 7468 696e ucting everythin │ │ │ -000248c0: 672e 0a09 766f 6964 2074 6f72 7265 6e74 g...void torrent │ │ │ -000248d0: 3a3a 7061 6e69 6328 290a 097b 0a09 096d ::panic()..{...m │ │ │ -000248e0: 5f73 746f 7261 6765 2e72 6573 6574 2829 _storage.reset() │ │ │ -000248f0: 3b0a 0909 2f2f 2069 6620 7468 6572 6520 ;...// if there │ │ │ -00024900: 6172 6520 616e 7920 6f74 6865 7220 7065 are any other pe │ │ │ -00024910: 6572 7320 616c 6c6f 6361 7465 6420 7374 ers allocated st │ │ │ -00024920: 696c 6c2c 2077 6520 6e65 6564 2074 6f20 ill, we need to │ │ │ -00024930: 636c 6561 7220 7468 656d 0a09 092f 2f20 clear them...// │ │ │ -00024940: 6e6f 772e 2054 6865 7920 6361 6e27 7420 now. They can't │ │ │ -00024950: 6265 2063 6c65 6172 6564 206c 6174 6572 be cleared later │ │ │ -00024960: 2062 6563 6175 7365 2074 6865 2061 6c6c because the all │ │ │ -00024970: 6f63 6174 6f72 2077 696c 6c20 616c 7265 ocator will alre │ │ │ -00024980: 6164 790a 0909 2f2f 2068 6176 6520 6265 ady...// have be │ │ │ -00024990: 656e 2064 6573 7472 7563 7465 640a 0909 en destructed... │ │ │ -000249a0: 6966 2028 6d5f 7065 6572 5f6c 6973 7429 if (m_peer_list) │ │ │ -000249b0: 206d 5f70 6565 725f 6c69 7374 2d26 6774 m_peer_list-> │ │ │ -000249c0: 3b63 6c65 6172 2829 3b0a 0909 6d5f 636f ;clear();...m_co │ │ │ -000249d0: 6e6e 6563 7469 6f6e 732e 636c 6561 7228 nnections.clear( │ │ │ -000249e0: 293b 0a09 096d 5f6f 7574 676f 696e 675f );...m_outgoing_ │ │ │ -000249f0: 7069 6473 2e63 6c65 6172 2829 3b0a 0909 pids.clear();... │ │ │ -00024a00: 6d5f 7065 6572 735f 746f 5f64 6973 636f m_peers_to_disco │ │ │ -00024a10: 6e6e 6563 742e 636c 6561 7228 293b 0a09 nnect.clear();.. │ │ │ -00024a20: 096d 5f6e 756d 5f75 706c 6f61 6473 203d .m_num_uploads = │ │ │ -00024a30: 2030 3b0a 0909 6d5f 6e75 6d5f 636f 6e6e 0;...m_num_conn │ │ │ -00024a40: 6563 7469 6e67 203d 2030 3b0a 0909 6d5f ecting = 0;...m_ │ │ │ -00024a50: 6e75 6d5f 636f 6e6e 6563 7469 6e67 5f73 num_connecting_s │ │ │ -00024a60: 6565 6473 203d 2030 3b0a 097d 0a0a 2369 eeds = 0;..}..#i │ │ │ -00024a70: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ -00024a80: 5341 424c 455f 5355 5045 5253 4545 4449 SABLE_SUPERSEEDI │ │ │ -00024a90: 4e47 0a3c 2f70 7265 3e3c 2f74 643e 3c2f NG. │ │ │ -00024ac0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00024ad0: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ -00024b00: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00024b10: 3834 3537 3c2f 613e 3c2f 7464 3e3c 7464 8457if peer is a re │ │ │ -00024b30: 616c 6c79 2067 6f6f 6420 7065 6572 2c20 ally good peer, │ │ │ -00024b40: 6d61 7962 6520 7765 2073 686f 756c 646e maybe we shouldn │ │ │ -00024b50: 2774 2064 6973 636f 6e6e 6563 7420 6974 't disconnect it │ │ │ -00024b60: 2070 6572 6861 7073 2074 6869 7320 6c6f perhaps this lo │ │ │ -00024b70: 6769 6320 7368 6f75 6c64 2062 6520 6469 gic should be di │ │ │ -00024b80: 7361 626c 6564 2069 6620 7765 2068 6176 sabled if we hav │ │ │ -00024b90: 6520 746f 6f20 6d61 6e79 2069 646c 6520 e too many idle │ │ │ -00024ba0: 7065 6572 7320 2877 6974 6820 736f 6d65 peers (with some │ │ │ -00024bb0: 2064 6566 696e 6974 696f 6e20 6f66 2069 definition of i │ │ │ -00024bc0: 646c 6529 3c2f 7464 3e3c 2f74 723e 3c74 dle)

    if peer is a re │ │ │ -00024c20: 616c 6c79 2067 6f6f 6420 7065 6572 2c20 ally good peer, │ │ │ -00024c30: 6d61 7962 6520 7765 2073 686f 756c 646e maybe we shouldn │ │ │ -00024c40: 2774 2064 6973 636f 6e6e 6563 7420 6974 't disconnect it │ │ │ -00024c50: 0a70 6572 6861 7073 2074 6869 7320 6c6f .perhaps this lo │ │ │ -00024c60: 6769 6320 7368 6f75 6c64 2062 6520 6469 gic should be di │ │ │ -00024c70: 7361 626c 6564 2069 6620 7765 2068 6176 sabled if we hav │ │ │ -00024c80: 6520 746f 6f20 6d61 6e79 2069 646c 6520 e too many idle │ │ │ -00024c90: 7065 6572 730a 2877 6974 6820 736f 6d65 peers.(with some │ │ │ -00024ca0: 2064 6566 696e 6974 696f 6e20 6f66 2069 definition of i │ │ │ -00024cb0: 646c 6529 3c2f 6832 3e3c 6834 3e2e 2e2f dle)

    ../ │ │ │ -00024cc0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00024cd0: 3834 3537 3c2f 6834 3e3c 7072 6520 7374 8457

    ...m_peers_to
    │ │ │ -00024d20: 5f64 6973 636f 6e6e 6563 742e 7265 7365  _disconnect.rese
    │ │ │ -00024d30: 7276 6528 6d5f 636f 6e6e 6563 7469 6f6e  rve(m_connection
    │ │ │ -00024d40: 732e 7369 7a65 2829 202b 2031 293b 0a09  s.size() + 1);..
    │ │ │ -00024d50: 096d 5f63 6f6e 6e65 6374 696f 6e73 2e72  .m_connections.r
    │ │ │ -00024d60: 6573 6572 7665 286d 5f63 6f6e 6e65 6374  eserve(m_connect
    │ │ │ -00024d70: 696f 6e73 2e73 697a 6528 2920 2b20 3129  ions.size() + 1)
    │ │ │ -00024d80: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f55  ;..#if TORRENT_U
    │ │ │ -00024d90: 5345 5f41 5353 4552 5453 0a09 0965 7272  SE_ASSERTS...err
    │ │ │ -00024da0: 6f72 5f63 6f64 6520 6563 3b0a 0909 544f  or_code ec;...TO
    │ │ │ -00024db0: 5252 454e 545f 4153 5345 5254 2870 2d26  RRENT_ASSERT(p-&
    │ │ │ -00024dc0: 6774 3b72 656d 6f74 6528 2920 3d3d 2070  gt;remote() == p
    │ │ │ -00024dd0: 2d26 6774 3b67 6574 5f73 6f63 6b65 7428  ->get_socket(
    │ │ │ -00024de0: 292e 7265 6d6f 7465 5f65 6e64 706f 696e  ).remote_endpoin
    │ │ │ -00024df0: 7428 6563 2920 7c7c 2065 6329 3b0a 2365  t(ec) || ec);.#e
    │ │ │ -00024e00: 6e64 6966 0a0a 0909 544f 5252 454e 545f  ndif....TORRENT_
    │ │ │ -00024e10: 4153 5345 5254 2870 2d26 6774 3b70 6565  ASSERT(p->pee
    │ │ │ -00024e20: 725f 696e 666f 5f73 7472 7563 7428 2920  r_info_struct() 
    │ │ │ -00024e30: 213d 206e 756c 6c70 7472 293b 0a0a 0909  != nullptr);....
    │ │ │ -00024e40: 2f2f 2077 6520 6e65 6564 2074 6f20 646f  // we need to do
    │ │ │ -00024e50: 2074 6869 7320 6166 7465 7220 7765 2776   this after we'v
    │ │ │ -00024e60: 6520 6164 6465 6420 7468 6520 7065 6572  e added the peer
    │ │ │ -00024e70: 2074 6f20 7468 6520 7065 6572 5f6c 6973   to the peer_lis
    │ │ │ -00024e80: 740a 0909 2f2f 2073 696e 6365 2074 6861  t...// since tha
    │ │ │ -00024e90: 7427 7320 7768 656e 2074 6865 2070 6565  t's when the pee
    │ │ │ -00024ea0: 7220 6973 2061 7373 6967 6e65 6420 6974  r is assigned it
    │ │ │ -00024eb0: 7320 7065 6572 5f69 6e66 6f20 6f62 6a65  s peer_info obje
    │ │ │ -00024ec0: 6374 2c0a 0909 2f2f 2077 6869 6368 2068  ct,...// which h
    │ │ │ -00024ed0: 6f6c 6473 2074 6865 2072 616e 6b0a 0909  olds the rank...
    │ │ │ -00024ee0: 6966 2028 6d61 7962 655f 7265 706c 6163  if (maybe_replac
    │ │ │ -00024ef0: 655f 7065 6572 290a 0909 7b0a 0909 092f  e_peer)...{..../
    │ │ │ -00024f00: 2f20 6e6f 772c 2066 696e 6420 7468 6520  / now, find the 
    │ │ │ -00024f10: 6c6f 7765 7374 2072 616e 6b20 7065 6572  lowest rank peer
    │ │ │ -00024f20: 2061 6e64 2064 6973 636f 6e6e 6563 7420   and disconnect 
    │ │ │ -00024f30: 7468 6174 0a09 0909 2f2f 2069 6620 6974  that....// if it
    │ │ │ -00024f40: 2773 206c 6f77 6572 2072 616e 6b20 7468  's lower rank th
    │ │ │ -00024f50: 616e 2074 6865 2069 6e63 6f6d 696e 6720  an the incoming 
    │ │ │ -00024f60: 636f 6e6e 6563 7469 6f6e 0a09 0909 7065  connection....pe
    │ │ │ -00024f70: 6572 5f63 6f6e 6e65 6374 696f 6e2a 2070  er_connection* p
    │ │ │ -00024f80: 6565 7220 3d20 6669 6e64 5f6c 6f77 6573  eer = find_lowes
    │ │ │ -00024f90: 745f 7261 6e6b 696e 675f 7065 6572 2829  t_ranking_peer()
    │ │ │ -00024fa0: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ...if (peer != │ │ │ -00024fe0: 6e75 6c6c 7074 7220 2661 6d70 3b26 616d nullptr &&am │ │ │ -00024ff0: 703b 2070 6565 722d 2667 743b 7065 6572 p; peer->peer │ │ │ -00025000: 5f72 616e 6b28 2920 266c 743b 2070 2d26 _rank() < p-& │ │ │ -00025010: 6774 3b70 6565 725f 7261 6e6b 2829 290a gt;peer_rank()). │ │ │ -00025020: 3c2f 6469 763e 0909 097b 0a23 6966 6e64
    ...{.#ifnd │ │ │ -00025030: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ -00025040: 4c45 5f4c 4f47 4749 4e47 0a09 0909 0969 LE_LOGGING.....i │ │ │ -00025050: 6620 2873 686f 756c 645f 6c6f 6728 2929 f (should_log()) │ │ │ -00025060: 0a09 0909 097b 0a09 0909 0909 6465 6275 .....{......debu │ │ │ -00025070: 675f 6c6f 6728 2243 4c4f 5349 4e47 2043 g_log("CLOSING C │ │ │ -00025080: 4f4e 4e45 4354 494f 4e20 5c22 2573 5c22 ONNECTION \"%s\" │ │ │ -00025090: 2070 6565 7220 6c69 7374 2066 756c 6c20 peer list full │ │ │ -000250a0: 286c 6f77 2070 6565 7220 7261 6e6b 2920 (low peer rank) │ │ │ -000250b0: 220a 0909 0909 0909 2263 6f6e 6e65 6374 "......."connect │ │ │ -000250c0: 696f 6e73 3a20 2564 206c 696d 6974 3a20 ions: %d limit: │ │ │ -000250d0: 2564 220a 0909 0909 0909 2c20 7072 696e %d"......., prin │ │ │ -000250e0: 745f 656e 6470 6f69 6e74 2870 6565 722d t_endpoint(peer- │ │ │ -000250f0: 2667 743b 7265 6d6f 7465 2829 292e 635f >remote()).c_ │ │ │ -00025100: 7374 7228 290a 0909 0909 0909 2c20 6e75 str()......., nu │ │ │ -00025110: 6d5f 7065 6572 7328 290a 0909 0909 0909 m_peers()....... │ │ │ -00025120: 2c20 6d5f 6d61 785f 636f 6e6e 6563 7469 , m_max_connecti │ │ │ -00025130: 6f6e 7329 3b0a 0909 0909 7d0a 2365 6e64 ons);.....}.#end │ │ │ -00025140: 6966 0a09 0909 0970 6565 722d 2667 743b if.....peer-> │ │ │ -00025150: 6469 7363 6f6e 6e65 6374 2865 7272 6f72 disconnect(error │ │ │ -00025160: 733a 3a74 6f6f 5f6d 616e 795f 636f 6e6e s::too_many_conn │ │ │ -00025170: 6563 7469 6f6e 732c 206f 7065 7261 7469 ections, operati │ │ │ -00025180: 6f6e 5f74 3a3a 6269 7474 6f72 7265 6e74 on_t::bittorrent │ │ │ -00025190: 293b 0a09 0909 0970 2d26 6774 3b70 6565 );.....p->pee │ │ │ -000251a0: 725f 6469 7363 6f6e 6e65 6374 6564 5f6f r_disconnected_o │ │ │ -000251b0: 7468 6572 2829 3b0a 0909 097d 0a09 0909 ther();....}.... │ │ │ -000251c0: 656c 7365 0a09 0909 7b0a 2369 666e 6465 else....{.#ifnde │ │ │ -000251d0: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ -000251e0: 455f 4c4f 4747 494e 470a 0909 0909 6966 E_LOGGING.....if │ │ │ -000251f0: 2028 7368 6f75 6c64 5f6c 6f67 2829 290a (should_log()). │ │ │ -00025200: 0909 0909 7b0a 0909 0909 0964 6562 7567 ....{......debug │ │ │ -00025210: 5f6c 6f67 2822 434c 4f53 494e 4720 434f _log("CLOSING CO │ │ │ -00025220: 4e4e 4543 5449 4f4e 205c 2225 735c 2220 NNECTION \"%s\" │ │ │ -00025230: 7065 6572 206c 6973 7420 6675 6c6c 2028 peer list full ( │ │ │ -00025240: 6c6f 7720 7065 6572 2072 616e 6b29 2022 low peer rank) " │ │ │ -00025250: 0a09 0909 0909 0922 636f 6e6e 6563 7469 ......."connecti │ │ │ -00025260: 6f6e 733a 2025 6420 6c69 6d69 743a 2025 ons: %d limit: % │ │ │ -00025270: 6422 0a09 0909 0909 092c 2070 7269 6e74 d"......., print │ │ │ -00025280: 5f65 6e64 706f 696e 7428 702d 2667 743b _endpoint(p-> │ │ │ -00025290: 7265 6d6f 7465 2829 292e 635f 7374 7228 remote()).c_str( │ │ │ -000252a0: 290a 0909 0909 0909 2c20 6e75 6d5f 7065 )......., num_pe │ │ │ -000252b0: 6572 7328 290a 0909 0909 0909 2c20 6d5f ers()......., m_ │ │ │ -000252c0: 6d61 785f 636f 6e6e 6563 7469 6f6e 7329 max_connections) │ │ │ -000252d0: 3b0a 0909 0909 7d0a 2365 6e64 6966 0a09 ;.....}.#endif.. │ │ │ -000252e0: 0909 0970 2d26 6774 3b64 6973 636f 6e6e ...p->disconn │ │ │ -000252f0: 6563 7428 6572 726f 7273 3a3a 746f 6f5f ect(errors::too_ │ │ │ -00025300: 6d61 6e79 5f63 6f6e 6e65 6374 696f 6e73 many_connections │ │ │ -00025310: 2c20 6f70 6572 6174 696f 6e5f 743a 3a62 , operation_t::b │ │ │ -00025320: 6974 746f 7272 656e 7429 3b0a 0909 0909 ittorrent);..... │ │ │ -00025330: 2f2f 2077 6520 6861 7665 2074 6f20 646f // we have to do │ │ │ -00025340: 2074 6869 7320 6865 7265 2062 6563 6175 this here becau │ │ │ -00025350: 7365 2066 726f 6d20 7468 6520 7065 6572 se from the peer │ │ │ -00025360: 2773 2070 6f69 6e74 206f 6620 7669 6577 's point of view │ │ │ -00025370: 0a09 0909 092f 2f20 6974 2077 6173 6e27 .....// it wasn' │ │ │ -00025380: 7420 7265 616c 6c79 2061 7474 6163 6865 t really attache │ │ │ -00025390: 6420 746f 2074 6865 2074 6f72 7265 6e74 d to the torrent │ │ │ -000253a0: 2c20 6275 7420 7765 2064 6f20 6e65 6564 , but we do need │ │ │ -000253b0: 0a09 0909 092f 2f20 746f 206c 6574 2070 .....// to let p │ │ │ -000253c0: 6565 725f 6c69 7374 206b 6e6f 7720 7765 eer_list know we │ │ │ -000253d0: 2772 6520 7265 6d6f 7669 6e67 2069 740a 're removing it. │ │ │ +000165d0: 6573 6361 7065 5f73 7472 696e 672e 6370 escape_string.cp │ │ │ +000165e0: 703a 3137 313c 2f61 3e3c 2f74 643e 3c74 p:171this should pr │ │ │ +00016600: 6f62 6162 6c79 2062 6520 6d6f 7665 6420 obably be moved │ │ │ +00016610: 696e 746f 2073 7472 696e 675f 7574 696c into string_util │ │ │ +00016620: 2e63 7070 3c2f 7464 3e3c 2f74 723e 3c74 .cpp

    this should pro │ │ │ +00016680: 6261 626c 7920 6265 206d 6f76 6564 2069 bably be moved i │ │ │ +00016690: 6e74 6f20 7374 7269 6e67 5f75 7469 6c2e nto string_util. │ │ │ +000166a0: 6370 703c 2f68 323e 3c68 343e 2e2e 2f73 cpp

    ../s │ │ │ +000166b0: 7263 2f65 7363 6170 655f 7374 7269 6e67 rc/escape_string │ │ │ +000166c0: 2e63 7070 3a31 3731 3c2f 6834 3e3c 7072 .cpp:171

    .{...retu │ │ │ +00016710: 726e 2065 7363 6170 655f 7374 7269 6e67 rn escape_string │ │ │ +00016720: 5f69 6d70 6c28 7374 722e 6461 7461 2829 _impl(str.data() │ │ │ +00016730: 2c20 696e 7428 7374 722e 7369 7a65 2829 , int(str.size() │ │ │ +00016740: 292c 2031 3029 3b0a 097d 0a0a 0962 6f6f ), 10);..}...boo │ │ │ +00016750: 6c20 6e65 6564 5f65 6e63 6f64 696e 6728 l need_encoding( │ │ │ +00016760: 6368 6172 2063 6f6e 7374 2a20 7374 722c char const* str, │ │ │ +00016770: 2069 6e74 2063 6f6e 7374 206c 656e 290a int const len). │ │ │ +00016780: 097b 0a09 0966 6f72 2028 696e 7420 6920 .{...for (int i │ │ │ +00016790: 3d20 303b 2069 2026 6c74 3b20 6c65 6e3b = 0; i < len; │ │ │ +000167a0: 202b 2b69 290a 0909 7b0a 0909 0969 6620 ++i)...{....if │ │ │ +000167b0: 2873 7464 3a3a 7374 7263 6872 2875 6e72 (std::strchr(unr │ │ │ +000167c0: 6573 6572 7665 645f 6368 6172 732c 202a eserved_chars, * │ │ │ +000167d0: 7374 7229 203d 3d20 6e75 6c6c 7074 7220 str) == nullptr │ │ │ +000167e0: 7c7c 202a 7374 7220 3d3d 2030 290a 0909 || *str == 0)... │ │ │ +000167f0: 0909 7265 7475 726e 2074 7275 653b 0a09 ..return true;.. │ │ │ +00016800: 0909 2b2b 7374 723b 0a09 097d 0a09 0972 ..++str;...}...r │ │ │ +00016810: 6574 7572 6e20 6661 6c73 653b 0a09 7d0a eturn false;..}. │ │ │ +00016820: 0a09 766f 6964 2063 6f6e 7665 7274 5f70 ..void convert_p │ │ │ +00016830: 6174 685f 746f 5f70 6f73 6978 2873 7464 ath_to_posix(std │ │ │ +00016840: 3a3a 7374 7269 6e67 2661 6d70 3b20 7061 ::string& pa │ │ │ +00016850: 7468 290a 097b 0a09 0973 7464 3a3a 7265 th)..{...std::re │ │ │ +00016860: 706c 6163 6528 7061 7468 2e62 6567 696e place(path.begin │ │ │ +00016870: 2829 2c20 7061 7468 2e65 6e64 2829 2c20 (), path.end(), │ │ │ +00016880: 275c 5c27 2c20 272f 2729 3b0a 097d 0a0a '\\', '/');..}.. │ │ │ +00016890: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .s │ │ │ +000168c0: 7464 3a3a 7374 7269 6e67 2072 6561 645f td::string read_ │ │ │ +000168d0: 756e 7469 6c28 6368 6172 2063 6f6e 7374 until(char const │ │ │ +000168e0: 2a26 616d 703b 2073 7472 2c20 6368 6172 *& str, char │ │ │ +000168f0: 2063 6f6e 7374 2064 656c 696d 2c20 6368 const delim, ch │ │ │ +00016900: 6172 2063 6f6e 7374 2a20 656e 6429 0a3c ar const* end).< │ │ │ +00016910: 2f64 6976 3e09 7b0a 0909 544f 5252 454e /div>.{...TORREN │ │ │ +00016920: 545f 4153 5345 5254 2873 7472 2026 6c74 T_ASSERT(str < │ │ │ +00016930: 3b3d 2065 6e64 293b 0a0a 0909 7374 643a ;= end);....std: │ │ │ +00016940: 3a73 7472 696e 6720 7265 743b 0a09 0977 :string ret;...w │ │ │ +00016950: 6869 6c65 2028 7374 7220 213d 2065 6e64 hile (str != end │ │ │ +00016960: 2026 616d 703b 2661 6d70 3b20 2a73 7472 && *str │ │ │ +00016970: 2021 3d20 6465 6c69 6d29 0a09 097b 0a09 != delim)...{.. │ │ │ +00016980: 0909 7265 7420 2b3d 202a 7374 723b 0a09 ..ret += *str;.. │ │ │ +00016990: 0909 2b2b 7374 723b 0a09 097d 0a09 092f ..++str;...}.../ │ │ │ +000169a0: 2f20 736b 6970 2074 6865 2064 656c 696d / skip the delim │ │ │ +000169b0: 6974 6572 2061 7320 7765 6c6c 0a09 0977 iter as well...w │ │ │ +000169c0: 6869 6c65 2028 7374 7220 213d 2065 6e64 hile (str != end │ │ │ +000169d0: 2026 616d 703b 2661 6d70 3b20 2a73 7472 && *str │ │ │ +000169e0: 203d 3d20 6465 6c69 6d29 202b 2b73 7472 == delim) ++str │ │ │ +000169f0: 3b0a 0909 7265 7475 726e 2072 6574 3b0a ;...return ret;. │ │ │ +00016a00: 097d 0a0a 0973 7464 3a3a 7374 7269 6e67 .}...std::string │ │ │ +00016a10: 206d 6179 6265 5f75 726c 5f65 6e63 6f64 maybe_url_encod │ │ │ +00016a20: 6528 7374 7269 6e67 5f76 6965 7720 7572 e(string_view ur │ │ │ +00016a30: 6c29 0a09 7b0a 0909 6572 726f 725f 636f l)..{...error_co │ │ │ +00016a40: 6465 2065 633b 0a09 0961 7574 6f20 636f de ec;...auto co │ │ │ +00016a50: 6e73 7420 5b70 726f 746f 636f 6c2c 2061 nst [protocol, a │ │ │ +00016a60: 7574 682c 2068 6f73 742c 2070 6f72 742c uth, host, port, │ │ │ +00016a70: 2070 6174 685d 203d 2061 7578 3a3a 7061 path] = aux::pa │ │ │ +00016a80: 7273 655f 7572 6c5f 636f 6d70 6f6e 656e rse_url_componen │ │ │ +00016a90: 7473 2875 726c 2c20 6563 293b 0a09 0969 ts(url, ec);...i │ │ │ +00016aa0: 6620 2865 6329 2072 6574 7572 6e20 7374 f (ec) return st │ │ │ +00016ab0: 643a 3a73 7472 696e 6728 7572 6c29 3b0a d::string(url);. │ │ │ +00016ac0: 0a09 092f 2f20 6669 7273 7420 6669 6775 ...// first figu │ │ │ +00016ad0: 7265 206f 7574 2069 6620 7468 6973 2075 re out if this u │ │ │ +00016ae0: 726c 2063 6f6e 7461 696e 7320 756e 656e rl contains unen │ │ │ +00016af0: 636f 6465 6420 6368 6172 6163 7465 7273 coded characters │ │ │ +00016b00: 0a09 0969 6620 2821 6e65 6564 5f65 6e63 ...if (!need_enc │ │ │ +00016b10: 6f64 696e 6728 7061 7468 2e63 5f73 7472 oding(path.c_str │ │ │ +00016b20: 2829 2c20 696e 7428 7061 7468 2e73 697a (), int(path.siz │ │ │ +00016b30: 6528 2929 2929 0a09 0909 7265 7475 726e e())))....return │ │ │ +00016b40: 2073 7464 3a3a 7374 7269 6e67 2875 726c std::string(url │ │ │ +00016b50: 293b 0a0a 0909 7374 643a 3a73 7472 696e );....std::strin │ │ │ +00016b60: 6720 6d73 673b 0a09 0973 7464 3a3a 7374 g msg;...std::st │ │ │ +00016b70: 7269 6e67 2065 7363 6170 6564 5f70 6174 ring escaped_pat │ │ │ +00016b80: 6820 7b20 6573 6361 7065 5f70 6174 6828 h { escape_path( │ │ │ +00016b90: 7061 7468 2920 7d3b 0a09 092f 2f20 7265 path) };...// re │ │ │ +00016ba0: 7365 7276 6520 656e 6f75 6768 2073 7061 serve enough spa │ │ │ +00016bb0: 6365 2073 6f20 6675 7274 6865 7220 6170 ce so further ap │ │ │ +00016bc0: 7065 6e64 2077 696c 6c0a 0909 2f2f 206f pend will...// o │ │ │ +00016bd0: 6e6c 7920 636f 7079 2076 616c 7565 7320 nly copy values │ │ │ +00016be0: 746f 2065 7869 7374 696e 6720 6c6f 6361 to existing loca │ │ │ +00016bf0: 7469 6f6e 0a09 096d 7367 2e72 6573 6572 tion...msg.reser │ │ │ +00016c00: 7665 2870 726f 746f 636f 6c2e 7369 7a65 ve(protocol.size │ │ │ +00016c10: 2829 202b 2033 202b 202f 2f20 7072 6f74 () + 3 + // prot │ │ │ +00016c20: 6f63 6f6c 2070 6172 740a 0909 0961 7574 ocol part....aut │ │ │ +00016c30: 682e 7369 7a65 2829 202b 2031 202b 202f h.size() + 1 + / │ │ │ +00016c40: 2f20 6175 7468 2070 6172 740a 3c2f 7072 / auth part.rel │ │ │ +00016c80: 6576 616e 6365 266e 6273 703b 323c 2f74 evance 2../src/ses │ │ │ +00016cc0: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3536 sion_impl.cpp:56 │ │ │ +00016cd0: 363c 2f61 3e3c 2f74 643e 3c74 643e 6973 6is │ │ │ +00016ce0: 2074 6865 7265 2061 2072 6561 736f 6e20 there a reason │ │ │ +00016cf0: 6e6f 7420 746f 206d 6f76 6520 616c 6c20 not to move all │ │ │ +00016d00: 6f66 2074 6869 7320 696e 746f 2069 6e69 of this into ini │ │ │ +00016d10: 7428 293f 2061 6e64 206a 7573 7420 706f t()? and just po │ │ │ +00016d20: 7374 2069 7420 746f 2074 6865 2069 6f5f st it to the io_ │ │ │ +00016d30: 636f 6e74 6578 743f 3c2f 7464 3e3c 2f74 context?

    is there a │ │ │ +00016d90: 7265 6173 6f6e 206e 6f74 2074 6f20 6d6f reason not to mo │ │ │ +00016da0: 7665 2061 6c6c 206f 6620 7468 6973 2069 ve all of this i │ │ │ +00016db0: 6e74 6f20 696e 6974 2829 3f20 616e 6420 nto init()? and │ │ │ +00016dc0: 6a75 7374 0a70 6f73 7420 6974 2074 6f20 just.post it to │ │ │ +00016dd0: 7468 6520 696f 5f63 6f6e 7465 7874 3f3c the io_context?< │ │ │ +00016de0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ +00016df0: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ +00016e00: 3536 363c 2f68 343e 3c70 7265 2073 7479 566

    .try.#endif..{
    │ │ │ +00016e50: 0a09 0928 7468 6973 2d26 6774 3b2a 6629  ...(this->*f)
    │ │ │ +00016e60: 2873 7464 3a3a 666f 7277 6172 6426 6c74  (std::forward<
    │ │ │ +00016e70: 3b41 7267 7326 6774 3b28 6129 2e2e 2e29  ;Args>(a)...)
    │ │ │ +00016e80: 3b0a 097d 0a23 6966 6e64 6566 2042 4f4f  ;..}.#ifndef BOO
    │ │ │ +00016e90: 5354 5f4e 4f5f 4558 4345 5054 494f 4e53  ST_NO_EXCEPTIONS
    │ │ │ +00016ea0: 0a09 6361 7463 6820 2873 7973 7465 6d5f  ..catch (system_
    │ │ │ +00016eb0: 6572 726f 7220 636f 6e73 7426 616d 703b  error const&
    │ │ │ +00016ec0: 2065 2920 7b0a 0909 616c 6572 7473 2829   e) {...alerts()
    │ │ │ +00016ed0: 2e65 6d70 6c61 6365 5f61 6c65 7274 266c  .emplace_alert&l
    │ │ │ +00016ee0: 743b 7365 7373 696f 6e5f 6572 726f 725f  t;session_error_
    │ │ │ +00016ef0: 616c 6572 7426 6774 3b28 652e 636f 6465  alert>(e.code
    │ │ │ +00016f00: 2829 2c20 652e 7768 6174 2829 293b 0a09  (), e.what());..
    │ │ │ +00016f10: 0970 6175 7365 2829 3b0a 097d 2063 6174  .pause();..} cat
    │ │ │ +00016f20: 6368 2028 7374 643a 3a65 7863 6570 7469  ch (std::excepti
    │ │ │ +00016f30: 6f6e 2063 6f6e 7374 2661 6d70 3b20 6529  on const& e)
    │ │ │ +00016f40: 207b 0a09 0961 6c65 7274 7328 292e 656d   {...alerts().em
    │ │ │ +00016f50: 706c 6163 655f 616c 6572 7426 6c74 3b73  place_alert<s
    │ │ │ +00016f60: 6573 7369 6f6e 5f65 7272 6f72 5f61 6c65  ession_error_ale
    │ │ │ +00016f70: 7274 2667 743b 2865 7272 6f72 5f63 6f64  rt>(error_cod
    │ │ │ +00016f80: 6528 292c 2065 2e77 6861 7428 2929 3b0a  e(), e.what());.
    │ │ │ +00016f90: 0909 7061 7573 6528 293b 0a09 7d20 6361  ..pause();..} ca
    │ │ │ +00016fa0: 7463 6820 282e 2e2e 2920 7b0a 0909 616c  tch (...) {...al
    │ │ │ +00016fb0: 6572 7473 2829 2e65 6d70 6c61 6365 5f61  erts().emplace_a
    │ │ │ +00016fc0: 6c65 7274 266c 743b 7365 7373 696f 6e5f  lert<session_
    │ │ │ +00016fd0: 6572 726f 725f 616c 6572 7426 6774 3b28  error_alert>(
    │ │ │ +00016fe0: 6572 726f 725f 636f 6465 2829 2c20 2275  error_code(), "u
    │ │ │ +00016ff0: 6e6b 6e6f 776e 2065 7272 6f72 2229 3b0a  nknown error");.
    │ │ │ +00017000: 0909 7061 7573 6528 293b 0a09 7d0a 2365  ..pause();..}.#e
    │ │ │ +00017010: 6e64 6966 0a0a 092f 2f20 5468 6973 2066  ndif...// This f
    │ │ │ +00017020: 756e 6374 696f 6e20 6973 2063 616c 6c65  unction is calle
    │ │ │ +00017030: 6420 6279 2074 6865 2063 7265 6174 696e  d by the creatin
    │ │ │ +00017040: 6720 7468 7265 6164 2c20 6e6f 7420 696e  g thread, not in
    │ │ │ +00017050: 2074 6865 206d 6573 7361 6765 206c 6f6f   the message loo
    │ │ │ +00017060: 7027 730a 092f 2f20 696f 5f63 6f6e 7465  p's..// io_conte
    │ │ │ +00017070: 7874 2074 6872 6561 642e 0a3c 6469 7620  xt thread..
    .void s │ │ │ +000170b0: 6573 7369 6f6e 5f69 6d70 6c3a 3a73 7461 ession_impl::sta │ │ │ +000170c0: 7274 5f73 6573 7369 6f6e 2829 0a3c 2f64 rt_session()..{.#ifndef TO │ │ │ +000170e0: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ +000170f0: 4747 494e 470a 0909 7365 7373 696f 6e5f GGING...session_ │ │ │ +00017100: 6c6f 6728 2273 7461 7274 2073 6573 7369 log("start sessi │ │ │ +00017110: 6f6e 2229 3b0a 2365 6e64 6966 0a0a 2369 on");.#endif..#i │ │ │ +00017120: 6620 544f 5252 454e 545f 5553 455f 5353 f TORRENT_USE_SS │ │ │ +00017130: 4c0a 0909 6572 726f 725f 636f 6465 2065 L...error_code e │ │ │ +00017140: 633b 0a09 096d 5f73 736c 5f63 7478 2e73 c;...m_ssl_ctx.s │ │ │ +00017150: 6574 5f64 6566 6175 6c74 5f76 6572 6966 et_default_verif │ │ │ +00017160: 795f 7061 7468 7328 6563 293b 0a23 6966 y_paths(ec);.#if │ │ │ +00017170: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +00017180: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0969 ABLE_LOGGING...i │ │ │ +00017190: 6620 2865 6329 2073 6573 7369 6f6e 5f6c f (ec) session_l │ │ │ +000171a0: 6f67 2822 5353 4c20 7365 745f 6465 6661 og("SSL set_defa │ │ │ +000171b0: 756c 7420 7665 7269 6679 5f70 6174 6873 ult verify_paths │ │ │ +000171c0: 2066 6169 6c65 643a 2025 7322 2c20 6563 failed: %s", ec │ │ │ +000171d0: 2e6d 6573 7361 6765 2829 2e63 5f73 7472 .message().c_str │ │ │ +000171e0: 2829 293b 0a09 0965 632e 636c 6561 7228 ());...ec.clear( │ │ │ +000171f0: 293b 0a23 656e 6469 660a 2369 6620 6465 );.#endif.#if de │ │ │ +00017200: 6669 6e65 6420 544f 5252 454e 545f 5749 fined TORRENT_WI │ │ │ +00017210: 4e44 4f57 5320 2661 6d70 3b26 616d 703b NDOWS && │ │ │ +00017220: 2064 6566 696e 6564 2054 4f52 5245 4e54 defined TORRENT │ │ │ +00017230: 5f55 5345 5f4f 5045 4e53 534c 2026 616d _USE_OPENSSL &am │ │ │ +00017240: 703b 2661 6d70 3b20 2164 6566 696e 6564 p;& !defined │ │ │ +00017250: 2054 4f52 5245 4e54 5f57 494e 5254 0a3c TORRENT_WINRT.< │ │ │ +00017260: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00017270: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00017280: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +00017290: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +000172a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ +000172d0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +000172e0: 3a37 3333 3c2f 613e 3c2f 7464 3e3c 7464 :733the ip filter s │ │ │ +00017300: 686f 756c 6420 7072 6f62 6162 6c79 2062 hould probably b │ │ │ +00017310: 6520 7361 7665 6420 6865 7265 2074 6f6f e saved here too │ │ │ +00017320: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    the │ │ │ +00017370: 2069 7020 6669 6c74 6572 2073 686f 756c ip filter shoul │ │ │ +00017380: 6420 7072 6f62 6162 6c79 2062 6520 7361 d probably be sa │ │ │ +00017390: 7665 6420 6865 7265 2074 6f6f 3c2f 6832 ved here too

    ../src/sess │ │ │ +000173b0: 696f 6e5f 696d 706c 2e63 7070 3a37 3333 ion_impl.cpp:733 │ │ │ +000173c0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ +00017400: 656e 6469 660a 0909 706f 7374 286d 5f69  endif...post(m_i
    │ │ │ +00017410: 6f5f 636f 6e74 6578 742c 205b 7468 6973  o_context, [this
    │ │ │ +00017420: 5d7b 2077 7261 7028 2661 6d70 3b73 6573  ]{ wrap(&ses
    │ │ │ +00017430: 7369 6f6e 5f69 6d70 6c3a 3a6f 6e5f 7469  sion_impl::on_ti
    │ │ │ +00017440: 636b 2c20 6572 726f 725f 636f 6465 2829  ck, error_code()
    │ │ │ +00017450: 293b 207d 293b 0a0a 2369 666e 6465 6620  ); });..#ifndef 
    │ │ │ +00017460: 544f 5252 454e 545f 4449 5341 424c 455f  TORRENT_DISABLE_
    │ │ │ +00017470: 4c4f 4747 494e 470a 0909 7365 7373 696f  LOGGING...sessio
    │ │ │ +00017480: 6e5f 6c6f 6728 2220 646f 6e65 2073 7461  n_log(" done sta
    │ │ │ +00017490: 7274 696e 6720 7365 7373 696f 6e22 293b  rting session");
    │ │ │ +000174a0: 0a23 656e 6469 660a 0a09 092f 2f20 7468  .#endif....// th
    │ │ │ +000174b0: 6973 2061 7070 6c69 6573 2075 6e63 686f  is applies uncho
    │ │ │ +000174c0: 6b65 2073 6574 7469 6e67 7320 6672 6f6d  ke settings from
    │ │ │ +000174d0: 206d 5f73 6574 7469 6e67 730a 0909 7265   m_settings...re
    │ │ │ +000174e0: 6361 6c63 756c 6174 655f 756e 6368 6f6b  calculate_unchok
    │ │ │ +000174f0: 655f 736c 6f74 7328 293b 0a0a 0909 2f2f  e_slots();....//
    │ │ │ +00017500: 2061 7070 6c79 2061 6c6c 206d 5f73 6574   apply all m_set
    │ │ │ +00017510: 7469 6e67 7320 746f 2074 6869 7320 7365  tings to this se
    │ │ │ +00017520: 7373 696f 6e0a 0909 7275 6e5f 616c 6c5f  ssion...run_all_
    │ │ │ +00017530: 7570 6461 7465 7328 2a74 6869 7329 3b0a  updates(*this);.
    │ │ │ +00017540: 0909 7265 6f70 656e 5f6c 6973 7465 6e5f  ..reopen_listen_
    │ │ │ +00017550: 736f 636b 6574 7328 6661 6c73 6529 3b0a  sockets(false);.
    │ │ │ +00017560: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +00017570: 5f49 4e56 4152 4941 4e54 5f43 4845 434b  _INVARIANT_CHECK
    │ │ │ +00017580: 530a 0909 6368 6563 6b5f 696e 7661 7269  S...check_invari
    │ │ │ +00017590: 616e 7428 293b 0a23 656e 6469 660a 097d  ant();.#endif..}
    │ │ │ +000175a0: 0a0a 2369 6620 544f 5252 454e 545f 4142  ..#if TORRENT_AB
    │ │ │ +000175b0: 495f 5645 5253 494f 4e20 266c 743b 3d20  I_VERSION <= 
    │ │ │ +000175c0: 320a 3c64 6976 2073 7479 6c65 3d22 6261  2.
    │ │ │ +000175f0: 0976 6f69 6420 7365 7373 696f 6e5f 696d .void session_im │ │ │ +00017600: 706c 3a3a 7361 7665 5f73 7461 7465 2865 pl::save_state(e │ │ │ +00017610: 6e74 7279 2a20 6570 7472 2c20 7361 7665 ntry* eptr, save │ │ │ +00017620: 5f73 7461 7465 5f66 6c61 6773 5f74 2063 _state_flags_t c │ │ │ +00017630: 6f6e 7374 2066 6c61 6773 2920 636f 6e73 onst flags) cons │ │ │ +00017640: 740a 3c2f 6469 763e 097b 0a09 0954 4f52 t.
    .{...TOR │ │ │ +00017650: 5245 4e54 5f41 5353 4552 5428 6973 5f73 RENT_ASSERT(is_s │ │ │ +00017660: 696e 676c 655f 7468 7265 6164 2829 293b ingle_thread()); │ │ │ +00017670: 0a0a 0909 656e 7472 7926 616d 703b 2065 ....entry& e │ │ │ +00017680: 203d 202a 6570 7472 3b0a 0909 2f2f 206d = *eptr;...// m │ │ │ +00017690: 616b 6520 6974 2061 2064 6963 740a 0909 ake it a dict... │ │ │ +000176a0: 652e 6469 6374 2829 3b0a 0a09 0969 6620 e.dict();....if │ │ │ +000176b0: 2866 6c61 6773 2026 616d 703b 2073 6573 (flags & ses │ │ │ +000176c0: 7369 6f6e 3a3a 7361 7665 5f73 6574 7469 sion::save_setti │ │ │ +000176d0: 6e67 7329 0a09 097b 0a09 0909 656e 7472 ngs)...{....entr │ │ │ +000176e0: 793a 3a64 6963 7469 6f6e 6172 795f 7479 y::dictionary_ty │ │ │ +000176f0: 7065 2661 6d70 3b20 7365 7474 203d 2065 pe& sett = e │ │ │ +00017700: 5b22 7365 7474 696e 6773 225d 2e64 6963 ["settings"].dic │ │ │ +00017710: 7428 293b 0a09 0909 7361 7665 5f73 6574 t();....save_set │ │ │ +00017720: 7469 6e67 735f 746f 5f64 6963 7428 6e6f tings_to_dict(no │ │ │ +00017730: 6e5f 6465 6661 756c 745f 7365 7474 696e n_default_settin │ │ │ +00017740: 6773 286d 5f73 6574 7469 6e67 7329 2c20 gs(m_settings), │ │ │ +00017750: 7365 7474 293b 0a09 097d 0a0a 2369 666e sett);...}..#ifn │ │ │ +00017760: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +00017770: 424c 455f 4448 540a 0909 6966 2028 666c BLE_DHT...if (fl │ │ │ +00017780: 6167 7320 2661 6d70 3b20 7365 7373 696f ags & sessio │ │ │ +00017790: 6e3a 3a73 6176 655f 6468 745f 7365 7474 n::save_dht_sett │ │ │ +000177a0: 696e 6773 290a 0909 7b0a 0909 0965 5b22 ings)...{....e[" │ │ │ +000177b0: 6468 7422 5d20 3d20 6468 743a 3a73 6176 dht"] = dht::sav │ │ │ +000177c0: 655f 6468 745f 7365 7474 696e 6773 2867 e_dht_settings(g │ │ │ +000177d0: 6574 5f64 6874 5f73 6574 7469 6e67 7328 et_dht_settings( │ │ │ +000177e0: 2929 3b0a 0909 7d0a 0a09 0969 6620 286d ));...}....if (m │ │ │ +000177f0: 5f64 6874 2026 616d 703b 2661 6d70 3b20 _dht && │ │ │ +00017800: 2866 6c61 6773 2026 616d 703b 2073 6573 (flags & ses │ │ │ +00017810: 7369 6f6e 3a3a 7361 7665 5f64 6874 5f73 sion::save_dht_s │ │ │ +00017820: 7461 7465 2929 0a09 097b 0a09 0909 655b tate))...{....e[ │ │ │ +00017830: 2264 6874 2073 7461 7465 225d 203d 2064 "dht state"] = d │ │ │ +00017840: 6874 3a3a 7361 7665 5f64 6874 5f73 7461 ht::save_dht_sta │ │ │ +00017850: 7465 286d 5f64 6874 2d26 6774 3b73 7461 te(m_dht->sta │ │ │ +00017860: 7465 2829 293b 0a09 097d 0a23 656e 6469 te());...}.#endi │ │ │ +00017870: 660a 0a23 6966 6e64 6566 2054 4f52 5245 f..#ifndef TORRE │ │ │ +00017880: 4e54 5f44 4953 4142 4c45 5f45 5854 454e NT_DISABLE_EXTEN │ │ │ +00017890: 5349 4f4e 530a 0909 666f 7220 2861 7574 SIONS...for (aut │ │ │ +000178a0: 6f20 636f 6e73 7426 616d 703b 2065 7874 o const& ext │ │ │ +000178b0: 203a 206d 5f73 6573 5f65 7874 656e 7369 : m_ses_extensi │ │ │ +000178c0: 6f6e 735b 706c 7567 696e 735f 616c 6c5f ons[plugins_all_ │ │ │ +000178d0: 6964 785d 290a 0909 7b0a 0909 0965 7874 idx])...{....ext │ │ │ +000178e0: 2d26 6774 3b73 6176 655f 7374 6174 6528 ->save_state( │ │ │ +000178f0: 2a65 7074 7229 3b0a 0909 7d0a 3c2f 7072 *eptr);...}.rel │ │ │ +00017930: 6576 616e 6365 266e 6273 703b 323c 2f74 evance 2../src/ses │ │ │ +00017970: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3339 sion_impl.cpp:39 │ │ │ +00017980: 3830 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 80m │ │ │ +00017990: 616b 6520 6120 6c69 7374 2066 6f72 2074 ake a list for t │ │ │ +000179a0: 6f72 7265 6e74 7320 7468 6174 2077 616e orrents that wan │ │ │ +000179b0: 7420 746f 2062 6520 616e 6e6f 756e 6365 t to be announce │ │ │ +000179c0: 6420 6f6e 2074 6865 2044 4854 2073 6f20 d on the DHT so │ │ │ +000179d0: 7765 2064 6f6e 2774 2068 6176 6520 746f we don't have to │ │ │ +000179e0: 206c 6f6f 7020 6f76 6572 2061 6c6c 2074 loop over all t │ │ │ +000179f0: 6f72 7265 6e74 732c 206a 7573 7420 746f orrents, just to │ │ │ +00017a00: 2066 696e 6420 7468 6520 6f6e 6573 2074 find the ones t │ │ │ +00017a10: 6861 7420 7761 6e74 2074 6f20 616e 6e6f hat want to anno │ │ │ +00017a20: 756e 6365 3c2f 7464 3e3c 2f74 723e 3c74 unce

    make a list for │ │ │ +00017a80: 2074 6f72 7265 6e74 7320 7468 6174 2077 torrents that w │ │ │ +00017a90: 616e 7420 746f 2062 6520 616e 6e6f 756e ant to be announ │ │ │ +00017aa0: 6365 6420 6f6e 2074 6865 2044 4854 2073 ced on the DHT s │ │ │ +00017ab0: 6f20 7765 0a64 6f6e 2774 2068 6176 6520 o we.don't have │ │ │ +00017ac0: 746f 206c 6f6f 7020 6f76 6572 2061 6c6c to loop over all │ │ │ +00017ad0: 2074 6f72 7265 6e74 732c 206a 7573 7420 torrents, just │ │ │ +00017ae0: 746f 2066 696e 6420 7468 6520 6f6e 6573 to find the ones │ │ │ +00017af0: 2074 6861 7420 7761 6e74 2074 6f20 616e that want to an │ │ │ +00017b00: 6e6f 756e 6365 3c2f 6832 3e3c 6834 3e2e nounce

    . │ │ │ +00017b10: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00017b20: 706c 2e63 7070 3a33 3938 303c 2f68 343e pl.cpp:3980

    │ │ │ +00017b30: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..if (
    │ │ │ +00017b70: 216d 5f64 6874 5f74 6f72 7265 6e74 732e  !m_dht_torrents.
    │ │ │ +00017b80: 656d 7074 7928 2929 0a09 097b 0a09 0909  empty())...{....
    │ │ │ +00017b90: 7374 643a 3a73 6861 7265 645f 7074 7226  std::shared_ptr&
    │ │ │ +00017ba0: 6c74 3b74 6f72 7265 6e74 2667 743b 2074  lt;torrent> t
    │ │ │ +00017bb0: 3b0a 0909 0964 6f0a 0909 097b 0a09 0909  ;....do....{....
    │ │ │ +00017bc0: 0974 203d 206d 5f64 6874 5f74 6f72 7265  .t = m_dht_torre
    │ │ │ +00017bd0: 6e74 732e 6672 6f6e 7428 292e 6c6f 636b  nts.front().lock
    │ │ │ +00017be0: 2829 3b0a 0909 0909 6d5f 6468 745f 746f  ();.....m_dht_to
    │ │ │ +00017bf0: 7272 656e 7473 2e70 6f70 5f66 726f 6e74  rrents.pop_front
    │ │ │ +00017c00: 2829 3b0a 0909 097d 2077 6869 6c65 2028  ();....} while (
    │ │ │ +00017c10: 2174 2026 616d 703b 2661 6d70 3b20 216d  !t && !m
    │ │ │ +00017c20: 5f64 6874 5f74 6f72 7265 6e74 732e 656d  _dht_torrents.em
    │ │ │ +00017c30: 7074 7928 2929 3b0a 0a09 0909 6966 2028  pty());.....if (
    │ │ │ +00017c40: 7429 0a09 0909 7b0a 0909 0909 742d 2667  t)....{.....t-&g
    │ │ │ +00017c50: 743b 6468 745f 616e 6e6f 756e 6365 2829  t;dht_announce()
    │ │ │ +00017c60: 3b0a 0909 0909 7265 7475 726e 3b0a 0909  ;.....return;...
    │ │ │ +00017c70: 097d 0a09 097d 0a09 0969 6620 286d 5f74  .}...}...if (m_t
    │ │ │ +00017c80: 6f72 7265 6e74 732e 656d 7074 7928 2929  orrents.empty())
    │ │ │ +00017c90: 2072 6574 7572 6e3b 0a0a 0909 6966 2028   return;....if (
    │ │ │ +00017ca0: 6d5f 6e65 7874 5f64 6874 5f74 6f72 7265  m_next_dht_torre
    │ │ │ +00017cb0: 6e74 2026 6774 3b3d 206d 5f74 6f72 7265  nt >= m_torre
    │ │ │ +00017cc0: 6e74 732e 7369 7a65 2829 290a 0909 096d  nts.size())....m
    │ │ │ +00017cd0: 5f6e 6578 745f 6468 745f 746f 7272 656e  _next_dht_torren
    │ │ │ +00017ce0: 7420 3d20 303b 0a09 096d 5f74 6f72 7265  t = 0;...m_torre
    │ │ │ +00017cf0: 6e74 735b 6d5f 6e65 7874 5f64 6874 5f74  nts[m_next_dht_t
    │ │ │ +00017d00: 6f72 7265 6e74 5d2d 2667 743b 6468 745f  orrent]->dht_
    │ │ │ +00017d10: 616e 6e6f 756e 6365 2829 3b0a 3c64 6976  announce();.
    ..++m_ │ │ │ +00017d50: 6e65 7874 5f64 6874 5f74 6f72 7265 6e74 next_dht_torrent │ │ │ +00017d60: 3b0a 3c2f 6469 763e 0909 6966 2028 6d5f ;.
    ..if (m_ │ │ │ +00017d70: 6e65 7874 5f64 6874 5f74 6f72 7265 6e74 next_dht_torrent │ │ │ +00017d80: 2026 6774 3b3d 206d 5f74 6f72 7265 6e74 >= m_torrent │ │ │ +00017d90: 732e 7369 7a65 2829 290a 0909 096d 5f6e s.size())....m_n │ │ │ +00017da0: 6578 745f 6468 745f 746f 7272 656e 7420 ext_dht_torrent │ │ │ +00017db0: 3d20 303b 0a09 7d0a 2365 6e64 6966 0a0a = 0;..}.#endif.. │ │ │ +00017dc0: 0976 6f69 6420 7365 7373 696f 6e5f 696d .void session_im │ │ │ +00017dd0: 706c 3a3a 6f6e 5f6c 7364 5f61 6e6e 6f75 pl::on_lsd_annou │ │ │ +00017de0: 6e63 6528 6572 726f 725f 636f 6465 2063 nce(error_code c │ │ │ +00017df0: 6f6e 7374 2661 6d70 3b20 6529 0a09 7b0a onst& e)..{. │ │ │ +00017e00: 0909 434f 4d50 4c45 5445 5f41 5359 4e43 ..COMPLETE_ASYNC │ │ │ +00017e10: 2822 7365 7373 696f 6e5f 696d 706c 3a3a ("session_impl:: │ │ │ +00017e20: 6f6e 5f6c 7364 5f61 6e6e 6f75 6e63 6522 on_lsd_announce" │ │ │ +00017e30: 293b 0a09 096d 5f73 7461 7473 5f63 6f75 );...m_stats_cou │ │ │ +00017e40: 6e74 6572 732e 696e 635f 7374 6174 735f nters.inc_stats_ │ │ │ +00017e50: 636f 756e 7465 7228 636f 756e 7465 7273 counter(counters │ │ │ +00017e60: 3a3a 6f6e 5f6c 7364 5f63 6f75 6e74 6572 ::on_lsd_counter │ │ │ +00017e70: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ +00017e80: 4552 5428 6973 5f73 696e 676c 655f 7468 ERT(is_single_th │ │ │ +00017e90: 7265 6164 2829 293b 0a09 0969 6620 2865 read());...if (e │ │ │ +00017ea0: 2920 7265 7475 726e 3b0a 0a09 0969 6620 ) return;....if │ │ │ +00017eb0: 286d 5f61 626f 7274 2920 7265 7475 726e (m_abort) return │ │ │ +00017ec0: 3b0a 0a09 0975 7064 6174 655f 6c73 645f ;....update_lsd_ │ │ │ +00017ed0: 616e 6e6f 756e 6365 5f69 6e74 6572 7661 announce_interva │ │ │ +00017ee0: 6c28 293b 0a0a 0909 6966 2028 216d 5f6c l();....if (!m_l │ │ │ +00017ef0: 7364 5f74 6f72 7265 6e74 732e 656d 7074 sd_torrents.empt │ │ │ +00017f00: 7928 2929 0a09 097b 0a09 0909 7374 643a y())...{....std: │ │ │ +00017f10: 3a73 6861 7265 645f 7074 7226 6c74 3b74 :shared_ptr<t │ │ │ +00017f20: 6f72 7265 6e74 2667 743b 2074 3b0a 0909 orrent> t;... │ │ │ +00017f30: 0964 6f0a 0909 097b 0a09 0909 0974 203d .do....{.....t = │ │ │ +00017f40: 206d 5f6c 7364 5f74 6f72 7265 6e74 732e m_lsd_torrents. │ │ │ +00017f50: 6672 6f6e 7428 292e 6c6f 636b 2829 3b0a front().lock();. │ │ │ +00017f60: 0909 0909 6d5f 6c73 645f 746f 7272 656e ....m_lsd_torren │ │ │ +00017f70: 7473 2e70 6f70 5f66 726f 6e74 2829 3b0a ts.pop_front();. │ │ │ +00017f80: 0909 097d 2077 6869 6c65 2028 2174 2026 ...} while (!t & │ │ │ +00017f90: 616d 703b 2661 6d70 3b20 216d 5f6c 7364 amp;& !m_lsd │ │ │ +00017fa0: 5f74 6f72 7265 6e74 732e 656d 7074 7928 _torrents.empty( │ │ │ +00017fb0: 2929 3b0a 0a09 0909 6966 2028 7429 0a09 ));.....if (t).. │ │ │ +00017fc0: 0909 7b0a 0909 0909 742d 2667 743b 6c73 ..{.....t->ls │ │ │ +00017fd0: 645f 616e 6e6f 756e 6365 2829 3b0a 0909 d_announce();... │ │ │ +00017fe0: 0909 7265 7475 726e 3b0a 0909 097d 0a3c ..return;....}.< │ │ │ +00017ff0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00018000: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00018010: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +00018020: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +00018030: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ +00018060: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +00018070: 3a35 3639 363c 2f61 3e3c 2f74 643e 3c74 :5696this function │ │ │ +00018090: 7368 6f75 6c64 2062 6520 7265 6d6f 7665 should be remove │ │ │ +000180a0: 6420 616e 6420 7573 6572 7320 6e65 6564 d and users need │ │ │ +000180b0: 2074 6f20 6465 616c 2077 6974 6820 7468 to deal with th │ │ │ +000180c0: 6520 6d6f 7265 2067 656e 6572 6963 2063 e more generic c │ │ │ +000180d0: 6173 6520 6f66 2068 6176 696e 6720 6d75 ase of having mu │ │ │ +000180e0: 6c74 6970 6c65 206c 6973 7465 6e20 706f ltiple listen po │ │ │ +000180f0: 7274 733c 2f74 643e 3c2f 7472 3e3c 7472 rts

    │ │ │ +00018140: 7468 6973 2066 756e 6374 696f 6e20 7368 this function sh │ │ │ +00018150: 6f75 6c64 2062 6520 7265 6d6f 7665 6420 ould be removed │ │ │ +00018160: 616e 6420 7573 6572 7320 6e65 6564 2074 and users need t │ │ │ +00018170: 6f20 6465 616c 2077 6974 6820 7468 650a o deal with the. │ │ │ +00018180: 6d6f 7265 2067 656e 6572 6963 2063 6173 more generic cas │ │ │ +00018190: 6520 6f66 2068 6176 696e 6720 6d75 6c74 e of having mult │ │ │ +000181a0: 6970 6c65 206c 6973 7465 6e20 706f 7274 iple listen port │ │ │ +000181b0: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ +000181c0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +000181d0: 703a 3536 3936 3c2f 6834 3e3c 7072 6520 p:5696

    #ifndef TOR
    │ │ │ +00018220: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ +00018230: 4749 4e47 0a09 0969 6620 2821 6e6f 6465  GING...if (!node
    │ │ │ +00018240: 5f6c 6973 742e 656d 7074 7928 2920 2661  _list.empty() &a
    │ │ │ +00018250: 6d70 3b26 616d 703b 206e 6f64 6573 2e65  mp;& nodes.e
    │ │ │ +00018260: 6d70 7479 2829 290a 0909 7b0a 0909 0973  mpty())...{....s
    │ │ │ +00018270: 6573 7369 6f6e 5f6c 6f67 2822 4552 524f  ession_log("ERRO
    │ │ │ +00018280: 523a 2066 6169 6c65 6420 746f 2070 6172  R: failed to par
    │ │ │ +00018290: 7365 2044 4854 2062 6f6f 7473 7472 6170  se DHT bootstrap
    │ │ │ +000182a0: 206c 6973 743a 2025 7322 2c20 6e6f 6465   list: %s", node
    │ │ │ +000182b0: 5f6c 6973 742e 635f 7374 7228 2929 3b0a  _list.c_str());.
    │ │ │ +000182c0: 0909 7d0a 2365 6e64 6966 0a09 0966 6f72  ..}.#endif...for
    │ │ │ +000182d0: 2028 6175 746f 2063 6f6e 7374 2661 6d70   (auto const&
    │ │ │ +000182e0: 3b20 6e20 3a20 6e6f 6465 7329 0a09 0909  ; n : nodes)....
    │ │ │ +000182f0: 6164 645f 6468 745f 726f 7574 6572 286e  add_dht_router(n
    │ │ │ +00018300: 293b 0a23 656e 6469 660a 097d 0a0a 0976  );.#endif..}...v
    │ │ │ +00018310: 6f69 6420 7365 7373 696f 6e5f 696d 706c  oid session_impl
    │ │ │ +00018320: 3a3a 7570 6461 7465 5f63 6f75 6e74 5f73  ::update_count_s
    │ │ │ +00018330: 6c6f 7728 290a 097b 0a09 0965 7272 6f72  low()..{...error
    │ │ │ +00018340: 5f63 6f64 6520 6563 3b0a 0909 666f 7220  _code ec;...for 
    │ │ │ +00018350: 2861 7574 6f20 636f 6e73 7426 616d 703b  (auto const&
    │ │ │ +00018360: 2074 7020 3a20 6d5f 746f 7272 656e 7473   tp : m_torrents
    │ │ │ +00018370: 290a 0909 7b0a 0909 0974 702d 2667 743b  )...{....tp->
    │ │ │ +00018380: 6f6e 5f69 6e61 6374 6976 6974 795f 7469  on_inactivity_ti
    │ │ │ +00018390: 636b 2865 6329 3b0a 0909 7d0a 097d 0a0a  ck(ec);...}..}..
    │ │ │ +000183a0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .s │ │ │ +000183d0: 7464 3a3a 7569 6e74 3136 5f74 2073 6573 td::uint16_t ses │ │ │ +000183e0: 7369 6f6e 5f69 6d70 6c3a 3a6c 6973 7465 sion_impl::liste │ │ │ +000183f0: 6e5f 706f 7274 2829 2063 6f6e 7374 0a3c n_port() const.< │ │ │ +00018400: 2f64 6976 3e09 7b0a 0909 7265 7475 726e /div>.{...return │ │ │ +00018410: 206c 6973 7465 6e5f 706f 7274 286e 756c listen_port(nul │ │ │ +00018420: 6c70 7472 293b 0a09 7d0a 0a09 7374 643a lptr);..}...std: │ │ │ +00018430: 3a75 696e 7431 365f 7420 7365 7373 696f :uint16_t sessio │ │ │ +00018440: 6e5f 696d 706c 3a3a 6c69 7374 656e 5f70 n_impl::listen_p │ │ │ +00018450: 6f72 7428 6c69 7374 656e 5f73 6f63 6b65 ort(listen_socke │ │ │ +00018460: 745f 742a 2073 6f63 6b29 2063 6f6e 7374 t_t* sock) const │ │ │ +00018470: 0a09 7b0a 0909 6966 2028 6d5f 6c69 7374 ..{...if (m_list │ │ │ +00018480: 656e 5f73 6f63 6b65 7473 2e65 6d70 7479 en_sockets.empty │ │ │ +00018490: 2829 2920 7265 7475 726e 2030 3b0a 0909 ()) return 0;... │ │ │ +000184a0: 6966 2028 736f 636b 290a 0909 7b0a 0909 if (sock)...{... │ │ │ +000184b0: 092f 2f20 6966 2077 6527 7265 2075 7369 .// if we're usi │ │ │ +000184c0: 6e67 2061 2070 726f 7879 2c20 7765 2077 ng a proxy, we w │ │ │ +000184d0: 6f6e 2774 2062 6520 6162 6c65 2074 6f20 on't be able to │ │ │ +000184e0: 6163 6365 7074 2061 6e79 2054 4350 0a09 accept any TCP.. │ │ │ +000184f0: 0909 2f2f 2063 6f6e 6e65 6374 696f 6e73 ..// connections │ │ │ +00018500: 2e20 4e6f 7420 6576 656e 2075 5450 2063 . Not even uTP c │ │ │ +00018510: 6f6e 6e65 6374 696f 6e73 2076 6961 2074 onnections via t │ │ │ +00018520: 6865 2070 6f72 7420 7765 206b 6e6f 7720 he port we know │ │ │ +00018530: 6162 6f75 742e 0a09 0909 2f2f 2054 6865 about.....// The │ │ │ +00018540: 2044 4854 206d 6179 2075 7365 2074 6865 DHT may use the │ │ │ +00018550: 2069 6d70 6c69 6564 2070 6f72 7420 746f implied port to │ │ │ +00018560: 206d 616b 6520 6974 2077 6f72 6b2c 2062 make it work, b │ │ │ +00018570: 7574 2074 6865 2070 6f72 7420 7765 0a09 ut the port we.. │ │ │ +00018580: 0909 2f2f 2061 6e6e 6f75 6e63 6520 6865 ..// announce he │ │ │ +00018590: 7265 2068 6173 206e 6f20 7265 6c65 7661 re has no releva │ │ │ +000185a0: 6e63 6520 666f 7220 7468 6174 2e0a 0909 nce for that.... │ │ │ +000185b0: 0969 6620 2873 6f63 6b2d 2667 743b 666c .if (sock->fl │ │ │ +000185c0: 6167 7320 2661 6d70 3b20 6c69 7374 656e ags & listen │ │ │ +000185d0: 5f73 6f63 6b65 745f 743a 3a70 726f 7879 _socket_t::proxy │ │ │ +000185e0: 290a 0909 0909 7265 7475 726e 2030 3b0a ).....return 0;. │ │ │ +000185f0: 0a09 0909 6966 2028 2128 736f 636b 2d26 ....if (!(sock-& │ │ │ +00018600: 6774 3b66 6c61 6773 2026 616d 703b 206c gt;flags & l │ │ │ +00018610: 6973 7465 6e5f 736f 636b 6574 5f74 3a3a isten_socket_t:: │ │ │ +00018620: 6163 6365 7074 5f69 6e63 6f6d 696e 6729 accept_incoming) │ │ │ +00018630: 290a 0909 0909 7265 7475 726e 2030 3b0a ).....return 0;. │ │ │ +00018640: 0a09 0909 7265 7475 726e 2073 7464 3a3a ....return std:: │ │ │ +00018650: 7569 6e74 3136 5f74 2873 6f63 6b2d 2667 uint16_t(sock-&g │ │ │ +00018660: 743b 7463 705f 6578 7465 726e 616c 5f70 t;tcp_external_p │ │ │ +00018670: 6f72 7428 2929 3b0a 0909 7d0a 0a23 6966 ort());...}..#if │ │ │ +00018680: 6465 6620 544f 5252 454e 545f 5353 4c5f def TORRENT_SSL_ │ │ │ +00018690: 5045 4552 530a 0909 666f 7220 2861 7574 PEERS...for (aut │ │ │ +000186a0: 6f20 636f 6e73 7426 616d 703b 2073 203a o const& s : │ │ │ +000186b0: 206d 5f6c 6973 7465 6e5f 736f 636b 6574 m_listen_socket │ │ │ +000186c0: 7329 0a09 097b 0a09 0909 6966 2028 2128 s)...{....if (!( │ │ │ +000186d0: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ +000186e0: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f ; listen_socket_ │ │ │ +000186f0: 743a 3a61 6363 6570 745f 696e 636f 6d69 t::accept_incomi │ │ │ +00018700: 6e67 2929 2063 6f6e 7469 6e75 653b 0a09 ng)) continue;.. │ │ │ +00018710: 0909 6966 2028 732d 2667 743b 7373 6c20 ..if (s->ssl │ │ │ +00018720: 3d3d 2074 7261 6e73 706f 7274 3a3a 706c == transport::pl │ │ │ +00018730: 6169 6e74 6578 7429 0a09 0909 0972 6574 aintext).....ret │ │ │ +00018740: 7572 6e20 7374 643a 3a75 696e 7431 365f urn std::uint16_ │ │ │ +00018750: 7428 732d 2667 743b 7463 705f 6578 7465 t(s->tcp_exte │ │ │ +00018760: 726e 616c 5f70 6f72 7428 2929 3b0a 0909 rnal_port());... │ │ │ +00018770: 7d0a 0909 7265 7475 726e 2030 3b0a 3c2f }...return 0;.r │ │ │ +000187b0: 656c 6576 616e 6365 266e 6273 703b 323c elevance 2< │ │ │ +000187c0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/s │ │ │ +000187f0: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ +00018800: 3537 3336 3c2f 613e 3c2f 7464 3e3c 7464 5736this function s │ │ │ +00018820: 686f 756c 6420 6265 2072 656d 6f76 6564 hould be removed │ │ │ +00018830: 2061 6e64 2075 7365 7273 206e 6565 6420 and users need │ │ │ +00018840: 746f 2064 6561 6c20 7769 7468 2074 6865 to deal with the │ │ │ +00018850: 206d 6f72 6520 6765 6e65 7269 6320 6361 more generic ca │ │ │ +00018860: 7365 206f 6620 6861 7669 6e67 206d 756c se of having mul │ │ │ +00018870: 7469 706c 6520 7373 6c20 706f 7274 733c tiple ssl ports< │ │ │ +00018880: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    this │ │ │ +000188d0: 2066 756e 6374 696f 6e20 7368 6f75 6c64 function should │ │ │ +000188e0: 2062 6520 7265 6d6f 7665 6420 616e 6420 be removed and │ │ │ +000188f0: 7573 6572 7320 6e65 6564 2074 6f20 6465 users need to de │ │ │ +00018900: 616c 2077 6974 6820 7468 650a 6d6f 7265 al with the.more │ │ │ +00018910: 2067 656e 6572 6963 2063 6173 6520 6f66 generic case of │ │ │ +00018920: 2068 6176 696e 6720 6d75 6c74 6970 6c65 having multiple │ │ │ +00018930: 2073 736c 2070 6f72 7473 3c2f 6832 3e3c ssl ports

    < │ │ │ +00018940: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ +00018950: 6e5f 696d 706c 2e63 7070 3a35 3733 363c n_impl.cpp:5736< │ │ │ +00018960: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +000189a0: 0909 7265 7475 726e 2030 3b0a 0a09 0909  ..return 0;.....
    │ │ │ +000189b0: 7265 7475 726e 2073 7464 3a3a 7569 6e74  return std::uint
    │ │ │ +000189c0: 3136 5f74 2873 6f63 6b2d 2667 743b 7463  16_t(sock->tc
    │ │ │ +000189d0: 705f 6578 7465 726e 616c 5f70 6f72 7428  p_external_port(
    │ │ │ +000189e0: 2929 3b0a 0909 7d0a 0a23 6966 6465 6620  ));...}..#ifdef 
    │ │ │ +000189f0: 544f 5252 454e 545f 5353 4c5f 5045 4552  TORRENT_SSL_PEER
    │ │ │ +00018a00: 530a 0909 666f 7220 2861 7574 6f20 636f  S...for (auto co
    │ │ │ +00018a10: 6e73 7426 616d 703b 2073 203a 206d 5f6c  nst& s : m_l
    │ │ │ +00018a20: 6973 7465 6e5f 736f 636b 6574 7329 0a09  isten_sockets)..
    │ │ │ +00018a30: 097b 0a09 0909 6966 2028 2128 732d 2667  .{....if (!(s-&g
    │ │ │ +00018a40: 743b 666c 6167 7320 2661 6d70 3b20 6c69  t;flags & li
    │ │ │ +00018a50: 7374 656e 5f73 6f63 6b65 745f 743a 3a61  sten_socket_t::a
    │ │ │ +00018a60: 6363 6570 745f 696e 636f 6d69 6e67 2929  ccept_incoming))
    │ │ │ +00018a70: 2063 6f6e 7469 6e75 653b 0a09 0909 6966   continue;....if
    │ │ │ +00018a80: 2028 732d 2667 743b 7373 6c20 3d3d 2074   (s->ssl == t
    │ │ │ +00018a90: 7261 6e73 706f 7274 3a3a 706c 6169 6e74  ransport::plaint
    │ │ │ +00018aa0: 6578 7429 0a09 0909 0972 6574 7572 6e20  ext).....return 
    │ │ │ +00018ab0: 7374 643a 3a75 696e 7431 365f 7428 732d  std::uint16_t(s-
    │ │ │ +00018ac0: 2667 743b 7463 705f 6578 7465 726e 616c  >tcp_external
    │ │ │ +00018ad0: 5f70 6f72 7428 2929 3b0a 0909 7d0a 0909  _port());...}...
    │ │ │ +00018ae0: 7265 7475 726e 2030 3b0a 2365 6c73 650a  return 0;.#else.
    │ │ │ +00018af0: 0909 736f 636b 203d 206d 5f6c 6973 7465  ..sock = m_liste
    │ │ │ +00018b00: 6e5f 736f 636b 6574 732e 6672 6f6e 7428  n_sockets.front(
    │ │ │ +00018b10: 292e 6765 7428 293b 0a09 0969 6620 2821  ).get();...if (!
    │ │ │ +00018b20: 2873 6f63 6b2d 2667 743b 666c 6167 7320  (sock->flags 
    │ │ │ +00018b30: 2661 6d70 3b20 6c69 7374 656e 5f73 6f63  & listen_soc
    │ │ │ +00018b40: 6b65 745f 743a 3a61 6363 6570 745f 696e  ket_t::accept_in
    │ │ │ +00018b50: 636f 6d69 6e67 2929 2072 6574 7572 6e20  coming)) return 
    │ │ │ +00018b60: 303b 0a09 0972 6574 7572 6e20 7374 643a  0;...return std:
    │ │ │ +00018b70: 3a75 696e 7431 365f 7428 736f 636b 2d26  :uint16_t(sock-&
    │ │ │ +00018b80: 6774 3b74 6370 5f65 7874 6572 6e61 6c5f  gt;tcp_external_
    │ │ │ +00018b90: 706f 7274 2829 293b 0a23 656e 6469 660a  port());.#endif.
    │ │ │ +00018ba0: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    .std::uint16_t │ │ │ +00018be0: 2073 6573 7369 6f6e 5f69 6d70 6c3a 3a73 session_impl::s │ │ │ +00018bf0: 736c 5f6c 6973 7465 6e5f 706f 7274 2829 sl_listen_port() │ │ │ +00018c00: 2063 6f6e 7374 0a3c 2f64 6976 3e09 7b0a const.
    .{. │ │ │ +00018c10: 0909 7265 7475 726e 2073 736c 5f6c 6973 ..return ssl_lis │ │ │ +00018c20: 7465 6e5f 706f 7274 286e 756c 6c70 7472 ten_port(nullptr │ │ │ +00018c30: 293b 0a09 7d0a 0a09 7374 643a 3a75 696e );..}...std::uin │ │ │ +00018c40: 7431 365f 7420 7365 7373 696f 6e5f 696d t16_t session_im │ │ │ +00018c50: 706c 3a3a 7373 6c5f 6c69 7374 656e 5f70 pl::ssl_listen_p │ │ │ +00018c60: 6f72 7428 6c69 7374 656e 5f73 6f63 6b65 ort(listen_socke │ │ │ +00018c70: 745f 742a 2073 6f63 6b29 2063 6f6e 7374 t_t* sock) const │ │ │ +00018c80: 0a09 7b0a 2369 6664 6566 2054 4f52 5245 ..{.#ifdef TORRE │ │ │ +00018c90: 4e54 5f53 534c 5f50 4545 5253 0a09 0969 NT_SSL_PEERS...i │ │ │ +00018ca0: 6620 2873 6f63 6b29 0a09 097b 0a09 0909 f (sock)...{.... │ │ │ +00018cb0: 6966 2028 2128 736f 636b 2d26 6774 3b66 if (!(sock->f │ │ │ +00018cc0: 6c61 6773 2026 616d 703b 206c 6973 7465 lags & liste │ │ │ +00018cd0: 6e5f 736f 636b 6574 5f74 3a3a 6163 6365 n_socket_t::acce │ │ │ +00018ce0: 7074 5f69 6e63 6f6d 696e 6729 2920 7265 pt_incoming)) re │ │ │ +00018cf0: 7475 726e 2030 3b0a 0909 0972 6574 7572 turn 0;....retur │ │ │ +00018d00: 6e20 7374 643a 3a75 696e 7431 365f 7428 n std::uint16_t( │ │ │ +00018d10: 736f 636b 2d26 6774 3b74 6370 5f65 7874 sock->tcp_ext │ │ │ +00018d20: 6572 6e61 6c5f 706f 7274 2829 293b 0a09 ernal_port());.. │ │ │ +00018d30: 097d 0a0a 0909 6966 2028 6d5f 7365 7474 .}....if (m_sett │ │ │ +00018d40: 696e 6773 2e67 6574 5f69 6e74 2873 6574 ings.get_int(set │ │ │ +00018d50: 7469 6e67 735f 7061 636b 3a3a 7072 6f78 tings_pack::prox │ │ │ +00018d60: 795f 7479 7065 2920 213d 2073 6574 7469 y_type) != setti │ │ │ +00018d70: 6e67 735f 7061 636b 3a3a 6e6f 6e65 0a09 ngs_pack::none.. │ │ │ +00018d80: 0909 2661 6d70 3b26 616d 703b 206d 5f73 ..&& m_s │ │ │ +00018d90: 6574 7469 6e67 732e 6765 745f 626f 6f6c ettings.get_bool │ │ │ +00018da0: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ +00018db0: 7072 6f78 795f 7065 6572 5f63 6f6e 6e65 proxy_peer_conne │ │ │ +00018dc0: 6374 696f 6e73 2929 0a09 0909 7265 7475 ctions))....retu │ │ │ +00018dd0: 726e 2030 3b0a 0a09 0966 6f72 2028 6175 rn 0;....for (au │ │ │ +00018de0: 746f 2063 6f6e 7374 2661 6d70 3b20 7320 to const& s │ │ │ +00018df0: 3a20 6d5f 6c69 7374 656e 5f73 6f63 6b65 : m_listen_socke │ │ │ +00018e00: 7473 290a 0909 7b0a 0909 0969 6620 2821 ts)...{....if (! │ │ │ +00018e10: 2873 2d26 6774 3b66 6c61 6773 2026 616d (s->flags &am │ │ │ +00018e20: 703b 206c 6973 7465 6e5f 736f 636b 6574 p; listen_socket │ │ │ +00018e30: 5f74 3a3a 6163 6365 7074 5f69 6e63 6f6d _t::accept_incom │ │ │ +00018e40: 696e 6729 2920 636f 6e74 696e 7565 3b0a ing)) continue;. │ │ │ +00018e50: 0909 0969 6620 2873 2d26 6774 3b73 736c ...if (s->ssl │ │ │ +00018e60: 203d 3d20 7472 616e 7370 6f72 743a 3a73 == transport::s │ │ │ +00018e70: 736c 290a 0909 0909 7265 7475 726e 2073 sl).....return s │ │ │ +00018e80: 7464 3a3a 7569 6e74 3136 5f74 2873 2d26 td::uint16_t(s-& │ │ │ +00018e90: 6774 3b74 6370 5f65 7874 6572 6e61 6c5f gt;tcp_external_ │ │ │ +00018ea0: 706f 7274 2829 293b 0a09 097d 0a23 656c port());...}.#el │ │ │ +00018eb0: 7365 0a09 0954 4f52 5245 4e54 5f55 4e55 se...TORRENT_UNU │ │ │ +00018ec0: 5345 4428 736f 636b 293b 0a23 656e 6469 SED(sock);.#endi │ │ │ +00018ed0: 660a 0909 7265 7475 726e 2030 3b0a 097d f...return 0;..} │ │ │ +00018ee0: 0a0a 0969 6e74 2073 6573 7369 6f6e 5f69 ...int session_i │ │ │ +00018ef0: 6d70 6c3a 3a67 6574 5f6c 6973 7465 6e5f mpl::get_listen_ │ │ │ +00018f00: 706f 7274 2874 7261 6e73 706f 7274 2063 port(transport c │ │ │ +00018f10: 6f6e 7374 2073 736c 2c20 6175 783a 3a6c onst ssl, aux::l │ │ │ +00018f20: 6973 7465 6e5f 736f 636b 6574 5f68 616e isten_socket_han │ │ │ +00018f30: 646c 6520 636f 6e73 7426 616d 703b 2073 dle const& s │ │ │ +00018f40: 2920 636f 6e73 740a 3c2f 7072 653e 3c2f ) const.
    relevan │ │ │ +00018f80: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2../src/session │ │ │ +00018fc0: 5f69 6d70 6c2e 6370 703a 3635 3736 3c2f _impl.cpp:6576this │ │ │ +00018fe0: 7368 6f75 6c64 2062 6520 6661 6374 6f72 should be factor │ │ │ +00018ff0: 6564 2069 6e74 6f20 7468 6520 7564 7020 ed into the udp │ │ │ +00019000: 736f 636b 6574 2c20 736f 2077 6520 6f6e socket, so we on │ │ │ +00019010: 6c79 2068 6176 6520 7468 6520 636f 6465 ly have the code │ │ │ +00019020: 206f 6e63 653c 2f74 643e 3c2f 7472 3e3c once< │ │ │ +00019030: 7472 2069 643d 2235 3022 2073 7479 6c65 tr id="50" style │ │ │ +00019040: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ +00019050: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">this should be │ │ │ +00019080: 2066 6163 746f 7265 6420 696e 746f 2074 factored into t │ │ │ +00019090: 6865 2075 6470 2073 6f63 6b65 742c 2073 he udp socket, s │ │ │ +000190a0: 6f20 7765 206f 6e6c 7920 6861 7665 2074 o we only have t │ │ │ +000190b0: 6865 0a63 6f64 6520 6f6e 6365 3c2f 6832 he.code once

    ../src/sess │ │ │ +000190d0: 696f 6e5f 696d 706c 2e63 7070 3a36 3537 ion_impl.cpp:657 │ │ │ +000190e0: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ +00019120: 0909 7265 7475 726e 2075 706c 6f61 645f  ..return upload_
    │ │ │ +00019130: 7261 7465 5f6c 696d 6974 286d 5f6c 6f63  rate_limit(m_loc
    │ │ │ +00019140: 616c 5f70 6565 725f 636c 6173 7329 3b0a  al_peer_class);.
    │ │ │ +00019150: 097d 0a0a 0969 6e74 2073 6573 7369 6f6e  .}...int session
    │ │ │ +00019160: 5f69 6d70 6c3a 3a6c 6f63 616c 5f64 6f77  _impl::local_dow
    │ │ │ +00019170: 6e6c 6f61 645f 7261 7465 5f6c 696d 6974  nload_rate_limit
    │ │ │ +00019180: 2829 2063 6f6e 7374 0a09 7b0a 0909 7265  () const..{...re
    │ │ │ +00019190: 7475 726e 2064 6f77 6e6c 6f61 645f 7261  turn download_ra
    │ │ │ +000191a0: 7465 5f6c 696d 6974 286d 5f6c 6f63 616c  te_limit(m_local
    │ │ │ +000191b0: 5f70 6565 725f 636c 6173 7329 3b0a 097d  _peer_class);..}
    │ │ │ +000191c0: 0a0a 0969 6e74 2073 6573 7369 6f6e 5f69  ...int session_i
    │ │ │ +000191d0: 6d70 6c3a 3a75 706c 6f61 645f 7261 7465  mpl::upload_rate
    │ │ │ +000191e0: 5f6c 696d 6974 5f64 6570 7228 2920 636f  _limit_depr() co
    │ │ │ +000191f0: 6e73 740a 097b 0a09 0972 6574 7572 6e20  nst..{...return 
    │ │ │ +00019200: 7570 6c6f 6164 5f72 6174 655f 6c69 6d69  upload_rate_limi
    │ │ │ +00019210: 7428 6d5f 676c 6f62 616c 5f63 6c61 7373  t(m_global_class
    │ │ │ +00019220: 293b 0a09 7d0a 0a09 696e 7420 7365 7373  );..}...int sess
    │ │ │ +00019230: 696f 6e5f 696d 706c 3a3a 646f 776e 6c6f  ion_impl::downlo
    │ │ │ +00019240: 6164 5f72 6174 655f 6c69 6d69 745f 6465  ad_rate_limit_de
    │ │ │ +00019250: 7072 2829 2063 6f6e 7374 0a09 7b0a 0909  pr() const..{...
    │ │ │ +00019260: 7265 7475 726e 2064 6f77 6e6c 6f61 645f  return download_
    │ │ │ +00019270: 7261 7465 5f6c 696d 6974 286d 5f67 6c6f  rate_limit(m_glo
    │ │ │ +00019280: 6261 6c5f 636c 6173 7329 3b0a 097d 0a23  bal_class);..}.#
    │ │ │ +00019290: 656e 6469 6620 2f2f 2044 4550 5245 4341  endif // DEPRECA
    │ │ │ +000192a0: 5445 0a0a 0a3c 6469 7620 7374 796c 653d  TE...
    .void session │ │ │ +000192e0: 5f69 6d70 6c3a 3a75 7064 6174 655f 7065 _impl::update_pe │ │ │ +000192f0: 6572 5f64 7363 7028 290a 3c2f 6469 763e er_dscp().
    │ │ │ +00019300: 097b 0a09 0969 6e74 2063 6f6e 7374 2076 .{...int const v │ │ │ +00019310: 616c 7565 203d 206d 5f73 6574 7469 6e67 alue = m_setting │ │ │ +00019320: 732e 6765 745f 696e 7428 7365 7474 696e s.get_int(settin │ │ │ +00019330: 6773 5f70 6163 6b3a 3a70 6565 725f 6473 gs_pack::peer_ds │ │ │ +00019340: 6370 293b 0a09 0966 6f72 2028 6175 746f cp);...for (auto │ │ │ +00019350: 2063 6f6e 7374 2661 6d70 3b20 6c20 3a20 const& l : │ │ │ +00019360: 6d5f 6c69 7374 656e 5f73 6f63 6b65 7473 m_listen_sockets │ │ │ +00019370: 290a 0909 7b0a 0909 0969 6620 286c 2d26 )...{....if (l-& │ │ │ +00019380: 6774 3b73 6f63 6b29 0a09 0909 7b0a 0909 gt;sock)....{... │ │ │ +00019390: 0909 6572 726f 725f 636f 6465 2065 633b ..error_code ec; │ │ │ +000193a0: 0a09 0909 0973 6574 5f74 7261 6666 6963 .....set_traffic │ │ │ +000193b0: 5f63 6c61 7373 282a 6c2d 2667 743b 736f _class(*l->so │ │ │ +000193c0: 636b 2c20 7661 6c75 652c 2065 6329 3b0a ck, value, ec);. │ │ │ +000193d0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ +000193e0: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ +000193f0: 0a09 0909 0969 6620 2873 686f 756c 645f .....if (should_ │ │ │ +00019400: 6c6f 6728 2929 0a09 0909 097b 0a09 0909 log()).....{.... │ │ │ +00019410: 0909 7365 7373 696f 6e5f 6c6f 6728 2226 ..session_log("& │ │ │ +00019420: 6774 3b26 6774 3b26 6774 3b20 5345 545f gt;>> SET_ │ │ │ +00019430: 4453 4350 205b 2074 6370 2028 2573 2025 DSCP [ tcp (%s % │ │ │ +00019440: 6429 2076 616c 7565 3a20 2578 2065 3a20 d) value: %x e: │ │ │ +00019450: 2573 205d 220a 0909 0909 0909 2c20 6c2d %s ]"......., l- │ │ │ +00019460: 2667 743b 736f 636b 2d26 6774 3b6c 6f63 >sock->loc │ │ │ +00019470: 616c 5f65 6e64 706f 696e 7428 292e 6164 al_endpoint().ad │ │ │ +00019480: 6472 6573 7328 292e 746f 5f73 7472 696e dress().to_strin │ │ │ +00019490: 6728 292e 635f 7374 7228 290a 0909 0909 g().c_str()..... │ │ │ +000194a0: 0909 2c20 6c2d 2667 743b 736f 636b 2d26 .., l->sock-& │ │ │ +000194b0: 6774 3b6c 6f63 616c 5f65 6e64 706f 696e gt;local_endpoin │ │ │ +000194c0: 7428 292e 706f 7274 2829 2c20 7374 643a t().port(), std: │ │ │ +000194d0: 3a75 696e 7433 325f 7428 7661 6c75 6529 :uint32_t(value) │ │ │ +000194e0: 2c20 6563 2e6d 6573 7361 6765 2829 2e63 , ec.message().c │ │ │ +000194f0: 5f73 7472 2829 293b 0a09 0909 097d 0a23 _str());.....}.# │ │ │ +00019500: 656e 6469 660a 0909 097d 0a0a 0909 0969 endif....}.....i │ │ │ +00019510: 6620 286c 2d26 6774 3b75 6470 5f73 6f63 f (l->udp_soc │ │ │ +00019520: 6b29 0a09 0909 7b0a 0909 0909 6572 726f k)....{.....erro │ │ │ +00019530: 725f 636f 6465 2065 633b 0a09 0909 0973 r_code ec;.....s │ │ │ +00019540: 6574 5f74 7261 6666 6963 5f63 6c61 7373 et_traffic_class │ │ │ +00019550: 286c 2d26 6774 3b75 6470 5f73 6f63 6b2d (l->udp_sock- │ │ │ +00019560: 2667 743b 736f 636b 2c20 7661 6c75 652c >sock, value, │ │ │ +00019570: 2065 6329 3b0a 0a23 6966 6e64 6566 2054 ec);..#ifndef T │ │ │ +00019580: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ +00019590: 4f47 4749 4e47 0a09 0909 0969 6620 2873 OGGING.....if (s │ │ │ +000195a0: 686f 756c 645f 6c6f 6728 2929 0a09 0909 hould_log()).... │ │ │ +000195b0: 097b 0a09 0909 0909 7365 7373 696f 6e5f .{......session_ │ │ │ +000195c0: 6c6f 6728 2226 6774 3b26 6774 3b26 6774 log(">>> │ │ │ +000195d0: 3b20 5345 545f 4453 4350 205b 2075 6470 ; SET_DSCP [ udp │ │ │ +000195e0: 2028 2573 2025 6429 2076 616c 7565 3a20 (%s %d) value: │ │ │ +000195f0: 2578 2065 3a20 2573 205d 220a 0909 0909 %x e: %s ]"..... │ │ │ +00019600: 0909 2c20 6c2d 2667 743b 7564 705f 736f .., l->udp_so │ │ │ +00019610: 636b 2d26 6774 3b73 6f63 6b2e 6c6f 6361 ck->sock.loca │ │ │ +00019620: 6c5f 656e 6470 6f69 6e74 2829 2e61 6464 l_endpoint().add │ │ │ +00019630: 7265 7373 2829 2e74 6f5f 7374 7269 6e67 ress().to_string │ │ │ +00019640: 2829 2e63 5f73 7472 2829 0a09 0909 0909 ().c_str()...... │ │ │ +00019650: 092c 206c 2d26 6774 3b75 6470 5f73 6f63 ., l->udp_soc │ │ │ +00019660: 6b2d 2667 743b 736f 636b 2e6c 6f63 616c k->sock.local │ │ │ +00019670: 5f70 6f72 7428 290a 3c2f 7072 653e 3c2f _port().
    relevan │ │ │ +000196b0: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2
    ../src/web_pee │ │ │ +000196f0: 725f 636f 6e6e 6563 7469 6f6e 2e63 7070 r_connection.cpp │ │ │ +00019700: 3a36 3132 3c2f 613e 3c2f 7464 3e3c 7464 :612just make this │ │ │ +00019720: 7065 6572 206e 6f74 2068 6176 6520 7468 peer not have th │ │ │ +00019730: 6520 7069 6563 6573 2061 7373 6f63 6961 e pieces associa │ │ │ +00019740: 7465 6420 7769 7468 2074 6865 2066 696c ted with the fil │ │ │ +00019750: 6520 7765 206a 7573 7420 7265 7175 6573 e we just reques │ │ │ +00019760: 7465 642e 204f 6e6c 7920 7768 656e 2069 ted. Only when i │ │ │ +00019770: 7420 646f 6573 6e27 7420 6861 7665 2061 t doesn't have a │ │ │ +00019780: 6e79 206f 6620 7468 6520 6669 6c65 2064 ny of the file d │ │ │ +00019790: 6f20 7468 6520 666f 6c6c 6f77 696e 6720 o the following │ │ │ +000197a0: 7061 6420 6669 6c65 7320 7769 6c6c 206d pad files will m │ │ │ +000197b0: 616b 6520 6974 2063 6f6d 706c 6963 6174 ake it complicat │ │ │ +000197c0: 6564 3c2f 7464 3e3c 2f74 723e 3c74 7220 ed

    j │ │ │ +00019810: 7573 7420 6d61 6b65 2074 6869 7320 7065 ust make this pe │ │ │ +00019820: 6572 206e 6f74 2068 6176 6520 7468 6520 er not have the │ │ │ +00019830: 7069 6563 6573 0a61 7373 6f63 6961 7465 pieces.associate │ │ │ +00019840: 6420 7769 7468 2074 6865 2066 696c 6520 d with the file │ │ │ +00019850: 7765 206a 7573 7420 7265 7175 6573 7465 we just requeste │ │ │ +00019860: 642e 204f 6e6c 790a 7768 656e 2069 7420 d. Only.when it │ │ │ +00019870: 646f 6573 6e27 7420 6861 7665 2061 6e79 doesn't have any │ │ │ +00019880: 206f 6620 7468 6520 6669 6c65 2064 6f20 of the file do │ │ │ +00019890: 7468 6520 666f 6c6c 6f77 696e 670a 7061 the following.pa │ │ │ +000198a0: 6420 6669 6c65 7320 7769 6c6c 206d 616b d files will mak │ │ │ +000198b0: 6520 6974 2063 6f6d 706c 6963 6174 6564 e it complicated │ │ │ +000198c0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +000198d0: 7765 625f 7065 6572 5f63 6f6e 6e65 6374 web_peer_connect │ │ │ +000198e0: 696f 6e2e 6370 703a 3631 323c 2f68 343e ion.cpp:612

    │ │ │ +000198f0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..peer
    │ │ │ +00019930: 5f63 6f6e 6e65 6374 696f 6e3a 3a72 6563  _connection::rec
    │ │ │ +00019940: 6569 7665 645f 696e 7661 6c69 645f 6461  eived_invalid_da
    │ │ │ +00019950: 7461 2869 6e64 6578 2c20 7369 6e67 6c65  ta(index, single
    │ │ │ +00019960: 5f70 6565 7229 3b0a 0a09 2f2f 2069 6620  _peer);...// if 
    │ │ │ +00019970: 7765 2064 6f6e 2774 2074 6869 6e6b 2077  we don't think w
    │ │ │ +00019980: 6520 6861 7665 2061 6e79 206f 6620 7468  e have any of th
    │ │ │ +00019990: 6520 6669 6c65 732c 2061 6c6c 6f77 2062  e files, allow b
    │ │ │ +000199a0: 616e 6e69 6e67 2074 6865 2077 6562 2073  anning the web s
    │ │ │ +000199b0: 6565 640a 0969 6620 286e 756d 5f68 6176  eed..if (num_hav
    │ │ │ +000199c0: 655f 7069 6563 6573 2829 203d 3d20 3029  e_pieces() == 0)
    │ │ │ +000199d0: 2072 6574 7572 6e20 7472 7565 3b0a 0a09   return true;...
    │ │ │ +000199e0: 2f2f 2064 6f6e 2774 2064 6973 636f 6e6e  // don't disconn
    │ │ │ +000199f0: 6563 742c 2077 6520 776f 6e27 7420 7265  ect, we won't re
    │ │ │ +00019a00: 7175 6573 7420 616e 7974 6869 6e67 2066  quest anything f
    │ │ │ +00019a10: 726f 6d20 7468 6973 2066 696c 6520 6167  rom this file ag
    │ │ │ +00019a20: 6169 6e0a 0972 6574 7572 6e20 6661 6c73  ain..return fals
    │ │ │ +00019a30: 653b 0a7d 0a0a 766f 6964 2077 6562 5f70  e;.}..void web_p
    │ │ │ +00019a40: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ +00019a50: 6f6e 5f72 6563 6569 7665 5f70 6164 6669  on_receive_padfi
    │ │ │ +00019a60: 6c65 2829 0a7b 0a09 6861 6e64 6c65 5f70  le().{..handle_p
    │ │ │ +00019a70: 6164 6669 6c65 2829 3b0a 7d0a 0a76 6f69  adfile();.}..voi
    │ │ │ +00019a80: 6420 7765 625f 7065 6572 5f63 6f6e 6e65  d web_peer_conne
    │ │ │ +00019a90: 6374 696f 6e3a 3a68 616e 646c 655f 6572  ction::handle_er
    │ │ │ +00019aa0: 726f 7228 696e 7420 636f 6e73 7420 6279  ror(int const by
    │ │ │ +00019ab0: 7465 735f 6c65 6674 290a 7b0a 0961 7574  tes_left).{..aut
    │ │ │ +00019ac0: 6f20 7420 3d20 6173 736f 6369 6174 6564  o t = associated
    │ │ │ +00019ad0: 5f74 6f72 7265 6e74 2829 2e6c 6f63 6b28  _torrent().lock(
    │ │ │ +00019ae0: 293b 0a09 544f 5252 454e 545f 4153 5345  );..TORRENT_ASSE
    │ │ │ +00019af0: 5254 2874 293b 0a0a 3c64 6976 2073 7479  RT(t);..
    .
    .// │ │ │ +00019b30: 2074 656d 706f 7261 7269 6c79 2075 6e61 temporarily una │ │ │ +00019b40: 7661 696c 6162 6c65 2c20 7265 7472 7920 vailable, retry │ │ │ +00019b50: 6c61 7465 720a 0974 2d26 6774 3b72 6574 later..t->ret │ │ │ +00019b60: 7279 5f77 6562 5f73 6565 6428 7468 6973 ry_web_seed(this │ │ │ +00019b70: 2c20 6d5f 7061 7273 6572 2e68 6561 6465 , m_parser.heade │ │ │ +00019b80: 725f 6475 7261 7469 6f6e 2822 7265 7472 r_duration("retr │ │ │ +00019b90: 792d 6166 7465 7222 2929 3b0a 0969 6620 y-after"));..if │ │ │ +00019ba0: 2874 2d26 6774 3b61 6c65 7274 7328 292e (t->alerts(). │ │ │ +00019bb0: 7368 6f75 6c64 5f70 6f73 7426 6c74 3b75 should_post<u │ │ │ +00019bc0: 726c 5f73 6565 645f 616c 6572 7426 6774 rl_seed_alert> │ │ │ +00019bd0: 3b28 2929 0a09 7b0a 0909 7374 643a 3a73 ;())..{...std::s │ │ │ +00019be0: 7472 696e 6720 636f 6e73 7420 6572 726f tring const erro │ │ │ +00019bf0: 725f 6d73 6720 3d20 746f 5f73 7472 696e r_msg = to_strin │ │ │ +00019c00: 6728 6d5f 7061 7273 6572 2e73 7461 7475 g(m_parser.statu │ │ │ +00019c10: 735f 636f 6465 2829 292e 6461 7461 2829 s_code()).data() │ │ │ +00019c20: 0a09 0909 2b20 2822 2022 202b 206d 5f70 ....+ (" " + m_p │ │ │ +00019c30: 6172 7365 722e 6d65 7373 6167 6528 2929 arser.message()) │ │ │ +00019c40: 3b0a 0909 742d 2667 743b 616c 6572 7473 ;...t->alerts │ │ │ +00019c50: 2829 2e65 6d70 6c61 6365 5f61 6c65 7274 ().emplace_alert │ │ │ +00019c60: 266c 743b 7572 6c5f 7365 6564 5f61 6c65 <url_seed_ale │ │ │ +00019c70: 7274 2667 743b 2874 2d26 6774 3b67 6574 rt>(t->get │ │ │ +00019c80: 5f68 616e 646c 6528 292c 206d 5f75 726c _handle(), m_url │ │ │ +00019c90: 0a09 0909 2c20 6572 726f 725f 6d73 6729 ...., error_msg) │ │ │ +00019ca0: 3b0a 097d 0a09 7265 6365 6976 6564 5f62 ;..}..received_b │ │ │ +00019cb0: 7974 6573 2830 2c20 6279 7465 735f 6c65 ytes(0, bytes_le │ │ │ +00019cc0: 6674 293b 0a09 6469 7363 6f6e 6e65 6374 ft);..disconnect │ │ │ +00019cd0: 2865 7272 6f72 5f63 6f64 6528 6d5f 7061 (error_code(m_pa │ │ │ +00019ce0: 7273 6572 2e73 7461 7475 735f 636f 6465 rser.status_code │ │ │ +00019cf0: 2829 2c20 6874 7470 5f63 6174 6567 6f72 (), http_categor │ │ │ +00019d00: 7928 2929 2c20 6f70 6572 6174 696f 6e5f y()), operation_ │ │ │ +00019d10: 743a 3a62 6974 746f 7272 656e 742c 2066 t::bittorrent, f │ │ │ +00019d20: 6169 6c75 7265 293b 0a7d 0a0a 766f 6964 ailure);.}..void │ │ │ +00019d30: 2077 6562 5f70 6565 725f 636f 6e6e 6563 web_peer_connec │ │ │ +00019d40: 7469 6f6e 3a3a 6469 7361 626c 6528 6572 tion::disable(er │ │ │ +00019d50: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ +00019d60: 6d70 3b20 6563 290a 7b0a 092f 2f20 7765 mp; ec).{..// we │ │ │ +00019d70: 2073 686f 756c 6420 6e6f 7420 7472 7920 should not try │ │ │ +00019d80: 7468 6973 2073 6572 7665 7220 6167 6169 this server agai │ │ │ +00019d90: 6e2e 0a09 6d5f 7765 622d 2667 743b 6469 n...m_web->di │ │ │ +00019da0: 7361 626c 6564 203d 2074 7275 653b 0a09 sabled = true;.. │ │ │ +00019db0: 626f 6f6c 2063 6f6e 7374 2065 7068 656d bool const ephem │ │ │ +00019dc0: 6572 616c 203d 206d 5f77 6562 2d26 6774 eral = m_web-> │ │ │ +00019dd0: 3b65 7068 656d 6572 616c 3b0a 0961 7578 ;ephemeral;..aux │ │ │ +00019de0: 3a3a 7765 625f 7365 6564 5f74 2a20 636f ::web_seed_t* co │ │ │ +00019df0: 6e73 7420 7765 6220 3d20 6d5f 7765 623b nst web = m_web; │ │ │ +00019e00: 0a09 6469 7363 6f6e 6e65 6374 2865 632c ..disconnect(ec, │ │ │ +00019e10: 206f 7065 7261 7469 6f6e 5f74 3a3a 6269 operation_t::bi │ │ │ +00019e20: 7474 6f72 7265 6e74 2c20 7065 6572 5f65 ttorrent, peer_e │ │ │ +00019e30: 7272 6f72 293b 0a09 6966 2028 6570 6865 rror);..if (ephe │ │ │ +00019e40: 6d65 7261 6c29 0a09 7b0a 0909 7374 643a meral)..{...std: │ │ │ +00019e50: 3a73 6861 7265 645f 7074 7226 6c74 3b74 :shared_ptr<t │ │ │ +00019e60: 6f72 7265 6e74 2667 743b 2074 203d 2061 orrent> t = a │ │ │ +00019e70: 7373 6f63 6961 7465 645f 746f 7272 656e ssociated_torren │ │ │ +00019e80: 7428 292e 6c6f 636b 2829 3b0a 0909 544f t().lock();...TO │ │ │ +00019e90: 5252 454e 545f 4153 5345 5254 2874 293b RRENT_ASSERT(t); │ │ │ +00019ea0: 0a09 0974 2d26 6774 3b72 656d 6f76 655f ...t->remove_ │ │ │ +00019eb0: 7765 625f 7365 6564 5f63 6f6e 6e28 7765 web_seed_conn(we │ │ │ +00019ec0: 6229 3b0a 097d 0a09 6d5f 7765 6220 3d20 b);..}..m_web = │ │ │ +00019ed0: 6e75 6c6c 7074 723b 0a09 544f 5252 454e nullptr;..TORREN │ │ │ +00019ee0: 545f 4153 5345 5254 2869 735f 6469 7363 T_ASSERT(is_disc │ │ │ +00019ef0: 6f6e 6e65 6374 696e 6728 2929 3b0a 7d0a onnecting());.}. │ │ │ +00019f00: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +00019f40: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../sr │ │ │ +00019f70: 632f 7065 6572 5f63 6f6e 6e65 6374 696f c/peer_connectio │ │ │ +00019f80: 6e2e 6370 703a 3235 3434 3c2f 613e 3c2f n.cpp:2544this shou │ │ │ +00019fa0: 6c64 2070 726f 6261 626c 7920 6265 2062 ld probably be b │ │ │ +00019fb0: 6173 6564 206f 6e20 7469 6d65 2069 6e73 ased on time ins │ │ │ +00019fc0: 7465 6164 206f 6620 6e75 6d62 6572 206f tead of number o │ │ │ +00019fd0: 6620 7265 7175 6573 7420 6d65 7373 6167 f request messag │ │ │ +00019fe0: 6573 2e20 466f 7220 6120 7665 7279 2068 es. For a very h │ │ │ +00019ff0: 6967 6820 7468 726f 7567 6870 7574 2063 igh throughput c │ │ │ +0001a000: 6f6e 6e65 6374 696f 6e2c 2033 3030 206d onnection, 300 m │ │ │ +0001a010: 6179 2062 6520 6120 6c65 6769 7469 6d61 ay be a legitima │ │ │ +0001a020: 7465 206e 756d 6265 7220 6f66 2072 6571 te number of req │ │ │ +0001a030: 7565 7374 7320 746f 2068 6176 6520 696e uests to have in │ │ │ +0001a040: 2066 6c69 6768 7420 7768 656e 2067 6574 flight when get │ │ │ +0001a050: 7469 6e67 2063 686f 6b65 643c 2f74 643e ting choked │ │ │ +0001a060: 3c2f 7472 3e3c 7472 2069 643d 2235 3222

    this sho │ │ │ +0001a0b0: 756c 6420 7072 6f62 6162 6c79 2062 6520 uld probably be │ │ │ +0001a0c0: 6261 7365 6420 6f6e 2074 696d 6520 696e based on time in │ │ │ +0001a0d0: 7374 6561 6420 6f66 206e 756d 6265 720a stead of number. │ │ │ +0001a0e0: 6f66 2072 6571 7565 7374 206d 6573 7361 of request messa │ │ │ +0001a0f0: 6765 732e 2046 6f72 2061 2076 6572 7920 ges. For a very │ │ │ +0001a100: 6869 6768 2074 6872 6f75 6768 7075 7420 high throughput │ │ │ +0001a110: 636f 6e6e 6563 7469 6f6e 2c20 3330 300a connection, 300. │ │ │ +0001a120: 6d61 7920 6265 2061 206c 6567 6974 696d may be a legitim │ │ │ +0001a130: 6174 6520 6e75 6d62 6572 206f 6620 7265 ate number of re │ │ │ +0001a140: 7175 6573 7473 2074 6f20 6861 7665 2069 quests to have i │ │ │ +0001a150: 6e20 666c 6967 6874 2077 6865 6e0a 6765 n flight when.ge │ │ │ +0001a160: 7474 696e 6720 6368 6f6b 6564 3c2f 6832 tting choked

    ../src/peer │ │ │ +0001a180: 5f63 6f6e 6e65 6374 696f 6e2e 6370 703a _connection.cpp: │ │ │ +0001a190: 3235 3434 3c2f 6834 3e3c 7072 6520 7374 2544

    ...}.#endif..
    │ │ │ +0001a1e0: 0909 0977 7269 7465 5f72 656a 6563 745f  ...write_reject_
    │ │ │ +0001a1f0: 7265 7175 6573 7428 7229 3b0a 0909 0969  request(r);....i
    │ │ │ +0001a200: 6620 286d 5f6e 756d 5f69 6e76 616c 6964  f (m_num_invalid
    │ │ │ +0001a210: 5f72 6571 7565 7374 7320 266c 743b 2073  _requests < s
    │ │ │ +0001a220: 7464 3a3a 6e75 6d65 7269 635f 6c69 6d69  td::numeric_limi
    │ │ │ +0001a230: 7473 266c 743b 6465 636c 7479 7065 286d  ts<decltype(m
    │ │ │ +0001a240: 5f6e 756d 5f69 6e76 616c 6964 5f72 6571  _num_invalid_req
    │ │ │ +0001a250: 7565 7374 7329 2667 743b 3a3a 6d61 7828  uests)>::max(
    │ │ │ +0001a260: 2929 0a09 0909 092b 2b6d 5f6e 756d 5f69  )).....++m_num_i
    │ │ │ +0001a270: 6e76 616c 6964 5f72 6571 7565 7374 733b  nvalid_requests;
    │ │ │ +0001a280: 0a0a 0909 0969 6620 2874 2d26 6774 3b61  .....if (t->a
    │ │ │ +0001a290: 6c65 7274 7328 292e 7368 6f75 6c64 5f70  lerts().should_p
    │ │ │ +0001a2a0: 6f73 7426 6c74 3b69 6e76 616c 6964 5f72  ost<invalid_r
    │ │ │ +0001a2b0: 6571 7565 7374 5f61 6c65 7274 2667 743b  equest_alert>
    │ │ │ +0001a2c0: 2829 290a 0909 097b 0a09 0909 092f 2f20  ())....{.....// 
    │ │ │ +0001a2d0: 6d73 7663 2031 3220 6170 7065 6172 7320  msvc 12 appears 
    │ │ │ +0001a2e0: 746f 2064 6564 7563 6520 7468 6520 7276  to deduce the rv
    │ │ │ +0001a2f0: 616c 7565 2072 6566 6572 656e 6365 2074  alue reference t
    │ │ │ +0001a300: 656d 706c 6174 650a 0909 0909 2f2f 2069  emplate.....// i
    │ │ │ +0001a310: 6e63 6f72 7265 6374 6c79 2066 6f72 2062  ncorrectly for b
    │ │ │ +0001a320: 6f6f 6c20 7465 6d70 6f72 6172 6965 732e  ool temporaries.
    │ │ │ +0001a330: 2053 6f2c 2063 7265 6174 6520 6120 6475   So, create a du
    │ │ │ +0001a340: 6d6d 7920 696e 7374 616e 6365 0a09 0909  mmy instance....
    │ │ │ +0001a350: 0962 6f6f 6c20 636f 6e73 7420 7065 6572  .bool const peer
    │ │ │ +0001a360: 5f69 6e74 6572 6573 7465 6420 3d20 626f  _interested = bo
    │ │ │ +0001a370: 6f6c 286d 5f70 6565 725f 696e 7465 7265  ol(m_peer_intere
    │ │ │ +0001a380: 7374 6564 293b 0a09 0909 0974 2d26 6774  sted);.....t->
    │ │ │ +0001a390: 3b61 6c65 7274 7328 292e 656d 706c 6163  ;alerts().emplac
    │ │ │ +0001a3a0: 655f 616c 6572 7426 6c74 3b69 6e76 616c  e_alert<inval
    │ │ │ +0001a3b0: 6964 5f72 6571 7565 7374 5f61 6c65 7274  id_request_alert
    │ │ │ +0001a3c0: 2667 743b 280a 0909 0909 0974 2d26 6774  >(......t->
    │ │ │ +0001a3d0: 3b67 6574 5f68 616e 646c 6528 292c 2072  ;get_handle(), r
    │ │ │ +0001a3e0: 656d 6f74 655f 656e 6470 6f69 6e74 2829  emote_endpoint()
    │ │ │ +0001a3f0: 2c20 6d5f 7065 6572 5f69 642c 2072 0a09  , m_peer_id, r..
    │ │ │ +0001a400: 0909 0909 2c20 742d 2667 743b 7573 6572  ...., t->user
    │ │ │ +0001a410: 5f68 6176 655f 7069 6563 6528 722e 7069  _have_piece(r.pi
    │ │ │ +0001a420: 6563 6529 2c20 7065 6572 5f69 6e74 6572  ece), peer_inter
    │ │ │ +0001a430: 6573 7465 642c 2066 616c 7365 293b 0a09  ested, false);..
    │ │ │ +0001a440: 0909 7d0a 0a09 0909 2f2f 2065 7665 7279  ..}.....// every
    │ │ │ +0001a450: 2074 656e 2069 6e76 616c 6964 2072 6571   ten invalid req
    │ │ │ +0001a460: 7565 7374 2c20 7265 6d69 6e64 2074 6865  uest, remind the
    │ │ │ +0001a470: 2070 6565 7220 7468 6174 2069 7427 7320   peer that it's 
    │ │ │ +0001a480: 6368 6f6b 6564 0a09 0909 6966 2028 216d  choked....if (!m
    │ │ │ +0001a490: 5f70 6565 725f 696e 7465 7265 7374 6564  _peer_interested
    │ │ │ +0001a4a0: 2026 616d 703b 2661 6d70 3b20 6d5f 6e75   && m_nu
    │ │ │ +0001a4b0: 6d5f 696e 7661 6c69 645f 7265 7175 6573  m_invalid_reques
    │ │ │ +0001a4c0: 7473 2025 2031 3020 3d3d 2030 2026 616d  ts % 10 == 0 &am
    │ │ │ +0001a4d0: 703b 2661 6d70 3b20 6d5f 6368 6f6b 6564  p;& m_choked
    │ │ │ +0001a4e0: 290a 0909 097b 0a3c 6469 7620 7374 796c  )....{.
    ....if (m_n │ │ │ +0001a520: 756d 5f69 6e76 616c 6964 5f72 6571 7565 um_invalid_reque │ │ │ +0001a530: 7374 7320 2667 743b 2033 3030 2026 616d sts > 300 &am │ │ │ +0001a540: 703b 2661 6d70 3b20 216d 5f70 6565 725f p;& !m_peer_ │ │ │ +0001a550: 6368 6f6b 6564 0a3c 2f64 6976 3e09 0909 choked.
    ... │ │ │ +0001a560: 0909 2661 6d70 3b26 616d 703b 2063 616e ..&& can │ │ │ +0001a570: 5f64 6973 636f 6e6e 6563 7428 6572 726f _disconnect(erro │ │ │ +0001a580: 7273 3a3a 746f 6f5f 6d61 6e79 5f72 6571 rs::too_many_req │ │ │ +0001a590: 7565 7374 735f 7768 656e 5f63 686f 6b65 uests_when_choke │ │ │ +0001a5a0: 6429 290a 0909 0909 7b0a 0909 0909 0964 d)).....{......d │ │ │ +0001a5b0: 6973 636f 6e6e 6563 7428 6572 726f 7273 isconnect(errors │ │ │ +0001a5c0: 3a3a 746f 6f5f 6d61 6e79 5f72 6571 7565 ::too_many_reque │ │ │ +0001a5d0: 7374 735f 7768 656e 5f63 686f 6b65 642c sts_when_choked, │ │ │ +0001a5e0: 206f 7065 7261 7469 6f6e 5f74 3a3a 6269 operation_t::bi │ │ │ +0001a5f0: 7474 6f72 7265 6e74 2c20 7065 6572 5f65 ttorrent, peer_e │ │ │ +0001a600: 7272 6f72 293b 0a09 0909 0909 7265 7475 rror);......retu │ │ │ +0001a610: 726e 3b0a 0909 0909 7d0a 2369 666e 6465 rn;.....}.#ifnde │ │ │ +0001a620: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +0001a630: 455f 4c4f 4747 494e 470a 0909 0909 7065 E_LOGGING.....pe │ │ │ +0001a640: 6572 5f6c 6f67 2870 6565 725f 6c6f 675f er_log(peer_log_ │ │ │ +0001a650: 616c 6572 743a 3a6f 7574 676f 696e 675f alert::outgoing_ │ │ │ +0001a660: 6d65 7373 6167 652c 2070 6565 725f 6c6f message, peer_lo │ │ │ +0001a670: 675f 616c 6572 743a 3a63 686f 6b65 293b g_alert::choke); │ │ │ +0001a680: 0a23 656e 6469 660a 0909 0909 7772 6974 .#endif.....writ │ │ │ +0001a690: 655f 6368 6f6b 6528 293b 0a09 0909 7d0a e_choke();....}. │ │ │ +0001a6a0: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a ....return;...}. │ │ │ +0001a6b0: 0a09 092f 2f20 6966 2077 6520 6861 7665 ...// if we have │ │ │ +0001a6c0: 2063 686f 6b65 6420 7468 6520 636c 6965 choked the clie │ │ │ +0001a6d0: 6e74 0a09 092f 2f20 6967 6e6f 7265 2074 nt...// ignore t │ │ │ +0001a6e0: 6865 2072 6571 7565 7374 0a09 0969 6e74 he request...int │ │ │ +0001a6f0: 2063 6f6e 7374 2062 6c6f 636b 735f 7065 const blocks_pe │ │ │ +0001a700: 725f 7069 6563 6520 3d0a 0909 0928 7469 r_piece =....(ti │ │ │ +0001a710: 2e70 6965 6365 5f6c 656e 6774 6828 2920 .piece_length() │ │ │ +0001a720: 2b20 742d 2667 743b 626c 6f63 6b5f 7369 + t->block_si │ │ │ +0001a730: 7a65 2829 202d 2031 2920 2f20 742d 2667 ze() - 1) / t-&g │ │ │ +0001a740: 743b 626c 6f63 6b5f 7369 7a65 2829 3b0a t;block_size();. │ │ │ +0001a750: 0a09 092f 2f20 6469 7363 6f6e 6e65 6374 ...// disconnect │ │ │ +0001a760: 2070 6565 7273 2074 6861 7420 646f 776e peers that down │ │ │ +0001a770: 6c6f 6164 7320 6d6f 7265 2074 6861 6e20 loads more than │ │ │ +0001a780: 666f 6f20 7469 6d65 7320 616e 2061 6c6c foo times an all │ │ │ +0001a790: 6f77 6564 0a09 092f 2f20 6661 7374 2070 owed...// fast p │ │ │ +0001a7a0: 6965 6365 0a09 0969 6620 286d 5f63 686f iece...if (m_cho │ │ │ +0001a7b0: 6b65 6420 2661 6d70 3b26 616d 703b 2066 ked && f │ │ │ +0001a7c0: 6173 745f 6964 7820 213d 202d 3120 2661 ast_idx != -1 &a │ │ │ +0001a7d0: 6d70 3b26 616d 703b 206d 5f61 6363 6570 mp;& m_accep │ │ │ +0001a7e0: 745f 6661 7374 5f70 6965 6365 5f63 6e74 t_fast_piece_cnt │ │ │ +0001a7f0: 5b66 6173 745f 6964 785d 2026 6774 3b3d [fast_idx] >= │ │ │ +0001a800: 2033 202a 2062 6c6f 636b 735f 7065 725f 3 * blocks_per_ │ │ │ +0001a810: 7069 6563 650a 0909 0926 616d 703b 2661 piece....&&a │ │ │ +0001a820: 6d70 3b20 6361 6e5f 6469 7363 6f6e 6e65 mp; can_disconne │ │ │ +0001a830: 6374 2865 7272 6f72 733a 3a74 6f6f 5f6d ct(errors::too_m │ │ │ +0001a840: 616e 795f 7265 7175 6573 7473 5f77 6865 any_requests_whe │ │ │ +0001a850: 6e5f 6368 6f6b 6564 2929 0a09 097b 0a09 n_choked))...{.. │ │ │ +0001a860: 0909 6469 7363 6f6e 6e65 6374 2865 7272 ..disconnect(err │ │ │ +0001a870: 6f72 733a 3a74 6f6f 5f6d 616e 795f 7265 ors::too_many_re │ │ │ +0001a880: 7175 6573 7473 5f77 6865 6e5f 6368 6f6b quests_when_chok │ │ │ +0001a890: 6564 2c20 6f70 6572 6174 696f 6e5f 743a ed, operation_t: │ │ │ +0001a8a0: 3a62 6974 746f 7272 656e 742c 2070 6565 :bittorrent, pee │ │ │ +0001a8b0: 725f 6572 726f 7229 3b0a 0909 0972 6574 r_error);....ret │ │ │ +0001a8c0: 7572 6e3b 0a09 097d 0a0a 0909 6966 2028 urn;...}....if ( │ │ │ +0001a8d0: 6d5f 6368 6f6b 6564 2026 616d 703b 2661 m_choked &&a │ │ │ +0001a8e0: 6d70 3b20 6661 7374 5f69 6478 203d 3d20 mp; fast_idx == │ │ │ +0001a8f0: 2d31 290a 0909 7b0a 3c2f 7072 653e 3c2f -1)...{.
    relevan │ │ │ +0001a930: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2../src/peer_co │ │ │ +0001a970: 6e6e 6563 7469 6f6e 2e63 7070 3a33 3330 nnection.cpp:330 │ │ │ +0001a980: 373c 2f61 3e3c 2f74 643e 3c74 643e 7369 7si │ │ │ +0001a990: 6e63 6520 7765 2074 6872 6f77 2061 7761 nce we throw awa │ │ │ +0001a9a0: 7920 7468 6520 7175 6575 6520 656e 7472 y the queue entr │ │ │ +0001a9b0: 7920 6f6e 6365 2077 6520 6973 7375 6520 y once we issue │ │ │ +0001a9c0: 7468 6520 6469 736b 206a 6f62 2c20 7468 the disk job, th │ │ │ +0001a9d0: 6973 206d 6179 2068 6170 7065 6e2e 2049 is may happen. I │ │ │ +0001a9e0: 6e73 7465 6164 2c20 7765 2073 686f 756c nstead, we shoul │ │ │ +0001a9f0: 6420 6b65 6570 2074 6865 2071 7565 7565 d keep the queue │ │ │ +0001aa00: 2065 6e74 7279 2061 726f 756e 642c 206d entry around, m │ │ │ +0001aa10: 6172 6b20 6974 2061 7320 6861 7669 6e67 ark it as having │ │ │ +0001aa20: 2062 6565 6e20 7265 7175 6573 7465 6420 been requested │ │ │ +0001aa30: 6672 6f6d 2064 6973 6b20 616e 6420 6f6e from disk and on │ │ │ +0001aa40: 6365 2074 6865 2064 6973 6b20 6a6f 6220 ce the disk job │ │ │ +0001aa50: 636f 6d65 7320 6261 636b 2c20 6469 7363 comes back, disc │ │ │ +0001aa60: 6172 6420 6974 2069 6620 6974 2068 6173 ard it if it has │ │ │ +0001aa70: 2062 6565 6e20 6361 6e63 656c 6c65 642e been cancelled. │ │ │ +0001aa80: 204d 6179 6265 2065 7665 6e20 6265 2061 Maybe even be a │ │ │ +0001aa90: 626c 6520 746f 2063 616e 6365 6c20 6469 ble to cancel di │ │ │ +0001aaa0: 736b 206a 6f62 733f 3c2f 7464 3e3c 2f74 sk jobs?

    since we th │ │ │ +0001ab00: 726f 7720 6177 6179 2074 6865 2071 7565 row away the que │ │ │ +0001ab10: 7565 2065 6e74 7279 206f 6e63 6520 7765 ue entry once we │ │ │ +0001ab20: 2069 7373 7565 0a74 6865 2064 6973 6b20 issue.the disk │ │ │ +0001ab30: 6a6f 622c 2074 6869 7320 6d61 7920 6861 job, this may ha │ │ │ +0001ab40: 7070 656e 2e20 496e 7374 6561 642c 2077 ppen. Instead, w │ │ │ +0001ab50: 6520 7368 6f75 6c64 206b 6565 7020 7468 e should keep th │ │ │ +0001ab60: 650a 7175 6575 6520 656e 7472 7920 6172 e.queue entry ar │ │ │ +0001ab70: 6f75 6e64 2c20 6d61 726b 2069 7420 6173 ound, mark it as │ │ │ +0001ab80: 2068 6176 696e 6720 6265 656e 2072 6571 having been req │ │ │ +0001ab90: 7565 7374 6564 2066 726f 6d0a 6469 736b uested from.disk │ │ │ +0001aba0: 2061 6e64 206f 6e63 6520 7468 6520 6469 and once the di │ │ │ +0001abb0: 736b 206a 6f62 2063 6f6d 6573 2062 6163 sk job comes bac │ │ │ +0001abc0: 6b2c 2064 6973 6361 7264 2069 7420 6966 k, discard it if │ │ │ +0001abd0: 2069 7420 6861 730a 6265 656e 2063 616e it has.been can │ │ │ +0001abe0: 6365 6c6c 6564 2e20 4d61 7962 6520 6576 celled. Maybe ev │ │ │ +0001abf0: 656e 2062 6520 6162 6c65 2074 6f20 6361 en be able to ca │ │ │ +0001ac00: 6e63 656c 2064 6973 6b20 6a6f 6273 3f3c ncel disk jobs?< │ │ │ +0001ac10: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +0001ac20: 6565 725f 636f 6e6e 6563 7469 6f6e 2e63 eer_connection.c │ │ │ +0001ac30: 7070 3a33 3330 373c 2f68 343e 3c70 7265 pp:3307

    ..{....if 
    │ │ │ +0001ac80: 2865 2d26 6774 3b6f 6e5f 6361 6e63 656c  (e->on_cancel
    │ │ │ +0001ac90: 2872 2929 2072 6574 7572 6e3b 0a09 097d  (r)) return;...}
    │ │ │ +0001aca0: 0a23 656e 6469 660a 0909 6966 2028 6973  .#endif...if (is
    │ │ │ +0001acb0: 5f64 6973 636f 6e6e 6563 7469 6e67 2829  _disconnecting()
    │ │ │ +0001acc0: 2920 7265 7475 726e 3b0a 0a09 0961 7574  ) return;....aut
    │ │ │ +0001acd0: 6f20 636f 6e73 7420 6920 3d20 7374 643a  o const i = std:
    │ │ │ +0001ace0: 3a66 696e 6428 6d5f 7265 7175 6573 7473  :find(m_requests
    │ │ │ +0001acf0: 2e62 6567 696e 2829 2c20 6d5f 7265 7175  .begin(), m_requ
    │ │ │ +0001ad00: 6573 7473 2e65 6e64 2829 2c20 7229 3b0a  ests.end(), r);.
    │ │ │ +0001ad10: 0a09 0969 6620 2869 2021 3d20 6d5f 7265  ...if (i != m_re
    │ │ │ +0001ad20: 7175 6573 7473 2e65 6e64 2829 290a 0909  quests.end())...
    │ │ │ +0001ad30: 7b0a 0909 096d 5f63 6f75 6e74 6572 732e  {....m_counters.
    │ │ │ +0001ad40: 696e 635f 7374 6174 735f 636f 756e 7465  inc_stats_counte
    │ │ │ +0001ad50: 7228 636f 756e 7465 7273 3a3a 6361 6e63  r(counters::canc
    │ │ │ +0001ad60: 656c 6c65 645f 7069 6563 655f 7265 7175  elled_piece_requ
    │ │ │ +0001ad70: 6573 7473 293b 0a09 0909 6d5f 7265 7175  ests);....m_requ
    │ │ │ +0001ad80: 6573 7473 2e65 7261 7365 2869 293b 0a0a  ests.erase(i);..
    │ │ │ +0001ad90: 0909 0969 6620 286d 5f72 6571 7565 7374  ...if (m_request
    │ │ │ +0001ada0: 732e 656d 7074 7928 2929 0a09 0909 096d  s.empty()).....m
    │ │ │ +0001adb0: 5f63 6f75 6e74 6572 732e 696e 635f 7374  _counters.inc_st
    │ │ │ +0001adc0: 6174 735f 636f 756e 7465 7228 636f 756e  ats_counter(coun
    │ │ │ +0001add0: 7465 7273 3a3a 6e75 6d5f 7065 6572 735f  ters::num_peers_
    │ │ │ +0001ade0: 7570 5f72 6571 7565 7374 732c 202d 3129  up_requests, -1)
    │ │ │ +0001adf0: 3b0a 0a09 0909 7772 6974 655f 7265 6a65  ;.....write_reje
    │ │ │ +0001ae00: 6374 5f72 6571 7565 7374 2872 293b 0a09  ct_request(r);..
    │ │ │ +0001ae10: 097d 0a09 0965 6c73 650a 0909 7b0a 3c64  .}...else...{.#ifn
    │ │ │ +0001ae50: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0001ae60: 424c 455f 4c4f 4747 494e 470a 3c2f 6469  BLE_LOGGING....peer_log(pe
    │ │ │ +0001ae80: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 696e  er_log_alert::in
    │ │ │ +0001ae90: 666f 2c20 7065 6572 5f6c 6f67 5f61 6c65  fo, peer_log_ale
    │ │ │ +0001aea0: 7274 3a3a 696e 7661 6c69 645f 6361 6e63  rt::invalid_canc
    │ │ │ +0001aeb0: 656c 2c20 2267 6f74 2063 616e 6365 6c20  el, "got cancel 
    │ │ │ +0001aec0: 6e6f 7420 696e 2074 6865 2071 7565 7565  not in the queue
    │ │ │ +0001aed0: 2229 3b0a 2365 6e64 6966 0a09 097d 0a09  ");.#endif...}..
    │ │ │ +0001aee0: 7d0a 0a09 2f2f 202d 2d2d 2d2d 2d2d 2d2d  }...// ---------
    │ │ │ +0001aef0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +0001af00: 2d2d 2d2d 0a09 2f2f 202d 2d2d 2d2d 2d2d  ----..// -------
    │ │ │ +0001af10: 2d2d 2044 4854 2050 4f52 5420 2d2d 2d2d  -- DHT PORT ----
    │ │ │ +0001af20: 2d2d 2d2d 2d2d 0a09 2f2f 202d 2d2d 2d2d  ------..// -----
    │ │ │ +0001af30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +0001af40: 2d2d 2d2d 2d2d 2d2d 0a0a 0976 6f69 6420  --------...void 
    │ │ │ +0001af50: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ +0001af60: 3a69 6e63 6f6d 696e 675f 6468 745f 706f  :incoming_dht_po
    │ │ │ +0001af70: 7274 2869 6e74 2063 6f6e 7374 206c 6973  rt(int const lis
    │ │ │ +0001af80: 7465 6e5f 706f 7274 290a 097b 0a09 0954  ten_port)..{...T
    │ │ │ +0001af90: 4f52 5245 4e54 5f41 5353 4552 5428 6973  ORRENT_ASSERT(is
    │ │ │ +0001afa0: 5f73 696e 676c 655f 7468 7265 6164 2829  _single_thread()
    │ │ │ +0001afb0: 293b 0a09 0949 4e56 4152 4941 4e54 5f43  );...INVARIANT_C
    │ │ │ +0001afc0: 4845 434b 3b0a 0a23 6966 6e64 6566 2054  HECK;..#ifndef T
    │ │ │ +0001afd0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c  ORRENT_DISABLE_L
    │ │ │ +0001afe0: 4f47 4749 4e47 0a09 0970 6565 725f 6c6f  OGGING...peer_lo
    │ │ │ +0001aff0: 6728 7065 6572 5f6c 6f67 5f61 6c65 7274  g(peer_log_alert
    │ │ │ +0001b000: 3a3a 696e 636f 6d69 6e67 5f6d 6573 7361  ::incoming_messa
    │ │ │ +0001b010: 6765 2c20 7065 6572 5f6c 6f67 5f61 6c65  ge, peer_log_ale
    │ │ │ +0001b020: 7274 3a3a 6468 745f 706f 7274 2c20 2270  rt::dht_port, "p
    │ │ │ +0001b030: 3a20 2564 222c 206c 6973 7465 6e5f 706f  : %d", listen_po
    │ │ │ +0001b040: 7274 293b 0a23 656e 6469 660a 2369 666e  rt);.#endif.#ifn
    │ │ │ +0001b050: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0001b060: 424c 455f 4448 540a 0909 6d5f 7365 732e  BLE_DHT...m_ses.
    │ │ │ +0001b070: 6164 645f 6468 745f 6e6f 6465 287b 6d5f  add_dht_node({m_
    │ │ │ +0001b080: 7265 6d6f 7465 2e61 6464 7265 7373 2829  remote.address()
    │ │ │ +0001b090: 2c20 7374 643a 3a75 696e 7431 365f 7428  , std::uint16_t(
    │ │ │ +0001b0a0: 6c69 7374 656e 5f70 6f72 7429 7d29 3b0a  listen_port)});.
    │ │ │ +0001b0b0: 2365 6c73 650a 0909 544f 5252 454e 545f  #else...TORRENT_
    │ │ │ +0001b0c0: 554e 5553 4544 286c 6973 7465 6e5f 706f  UNUSED(listen_po
    │ │ │ +0001b0d0: 7274 293b 0a23 656e 6469 660a 097d 0a0a  rt);.#endif..}..
    │ │ │ +0001b0e0: 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  .// ------------
    │ │ │ +0001b0f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +0001b100: 2d0a 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d20  -..// --------- 
    │ │ │ +0001b110: 4841 5645 2041 4c4c 202d 2d2d 2d2d 2d2d  HAVE ALL -------
    │ │ │ +0001b120: 2d2d 2d0a 092f 2f20 2d2d 2d2d 2d2d 2d2d  ---..// --------
    │ │ │ +0001b130: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +0001b140: 2d2d 2d2d 2d0a 0a09 766f 6964 2070 6565  -----...void pee
    │ │ │ +0001b150: 725f 636f 6e6e 6563 7469 6f6e 3a3a 696e  r_connection::in
    │ │ │ +0001b160: 636f 6d69 6e67 5f68 6176 655f 616c 6c28  coming_have_all(
    │ │ │ +0001b170: 290a 097b 0a3c 2f70 7265 3e3c 2f74 643e  )..{.
    │ │ │ +0001b180: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +0001b1b0: 6e62 7370 3b32 3c2f 7464 3e3c 7464 3e3c nbsp;2< │ │ │ +0001b1c0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +0001b1d0: 7074 3a65 7870 616e 6428 3534 2922 3e2e pt:expand(54)">. │ │ │ +0001b1e0: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ +0001b1f0: 6374 696f 6e2e 6370 703a 3439 3531 3c2f ction.cpp:4951use a │ │ │ +0001b210: 2064 6561 646c 696e 655f 7469 6d65 7220 deadline_timer │ │ │ +0001b220: 666f 7220 7469 6d65 6f75 7473 2e20 446f for timeouts. Do │ │ │ +0001b230: 6e27 7420 7265 6c79 206f 6e20 7365 636f n't rely on seco │ │ │ +0001b240: 6e64 5f74 6963 6b28 2921 2048 6f6f 6b20 nd_tick()! Hook │ │ │ +0001b250: 7468 6973 2075 7020 746f 2063 6f6e 6e65 this up to conne │ │ │ +0001b260: 6374 2074 696d 656f 7574 2061 7320 7765 ct timeout as we │ │ │ +0001b270: 6c6c 2e20 5468 6973 2077 6f75 6c64 2069 ll. This would i │ │ │ +0001b280: 6d70 726f 7665 2070 6572 666f 726d 616e mprove performan │ │ │ +0001b290: 6365 2062 6563 6175 7365 206f 6620 6c65 ce because of le │ │ │ +0001b2a0: 7373 2077 6f72 6b20 696e 2073 6563 6f6e ss work in secon │ │ │ +0001b2b0: 645f 7469 636b 2829 2c20 616e 6420 6d69 d_tick(), and mi │ │ │ +0001b2c0: 6768 7420 6c65 7420 7573 6520 7265 6d6f ght let use remo │ │ │ +0001b2d0: 7665 2074 6963 6b69 6e67 2065 6e74 6972 ve ticking entir │ │ │ +0001b2e0: 656c 7920 6576 656e 7475 616c 6c79 3c2f ely eventually

    use a │ │ │ +0001b340: 2064 6561 646c 696e 655f 7469 6d65 7220 deadline_timer │ │ │ +0001b350: 666f 7220 7469 6d65 6f75 7473 2e20 446f for timeouts. Do │ │ │ +0001b360: 6e27 7420 7265 6c79 206f 6e20 7365 636f n't rely on seco │ │ │ +0001b370: 6e64 5f74 6963 6b28 2921 0a48 6f6f 6b20 nd_tick()!.Hook │ │ │ +0001b380: 7468 6973 2075 7020 746f 2063 6f6e 6e65 this up to conne │ │ │ +0001b390: 6374 2074 696d 656f 7574 2061 7320 7765 ct timeout as we │ │ │ +0001b3a0: 6c6c 2e20 5468 6973 2077 6f75 6c64 2069 ll. This would i │ │ │ +0001b3b0: 6d70 726f 7665 2070 6572 666f 726d 616e mprove performan │ │ │ +0001b3c0: 6365 0a62 6563 6175 7365 206f 6620 6c65 ce.because of le │ │ │ +0001b3d0: 7373 2077 6f72 6b20 696e 2073 6563 6f6e ss work in secon │ │ │ +0001b3e0: 645f 7469 636b 2829 2c20 616e 6420 6d69 d_tick(), and mi │ │ │ +0001b3f0: 6768 7420 6c65 7420 7573 6520 7265 6d6f ght let use remo │ │ │ +0001b400: 7665 2074 6963 6b69 6e67 0a65 6e74 6972 ve ticking.entir │ │ │ +0001b410: 656c 7920 6576 656e 7475 616c 6c79 3c2f ely eventually

    ../src/pe │ │ │ +0001b430: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ +0001b440: 703a 3439 3531 3c2f 6834 3e3c 7072 6520 p:4951

    ...if (d &g
    │ │ │ +0001b490: 743b 2073 6563 6f6e 6473 2863 6f6e 6e65  t; seconds(conne
    │ │ │ +0001b4a0: 6374 5f74 696d 656f 7574 290a 0909 0909  ct_timeout).....
    │ │ │ +0001b4b0: 2661 6d70 3b26 616d 703b 2063 616e 5f64  && can_d
    │ │ │ +0001b4c0: 6973 636f 6e6e 6563 7428 6572 726f 7273  isconnect(errors
    │ │ │ +0001b4d0: 3a3a 7469 6d65 645f 6f75 7429 290a 0909  ::timed_out))...
    │ │ │ +0001b4e0: 097b 0a23 6966 6e64 6566 2054 4f52 5245  .{.#ifndef TORRE
    │ │ │ +0001b4f0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749  NT_DISABLE_LOGGI
    │ │ │ +0001b500: 4e47 0a09 0909 0970 6565 725f 6c6f 6728  NG.....peer_log(
    │ │ │ +0001b510: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a  peer_log_alert::
    │ │ │ +0001b520: 696e 666f 2c20 7065 6572 5f6c 6f67 5f61  info, peer_log_a
    │ │ │ +0001b530: 6c65 7274 3a3a 636f 6e6e 6563 745f 6661  lert::connect_fa
    │ │ │ +0001b540: 696c 6564 2c20 2277 6169 7465 6420 2564  iled, "waited %d
    │ │ │ +0001b550: 2073 6563 6f6e 6473 220a 0909 0909 092c   seconds"......,
    │ │ │ +0001b560: 2069 6e74 2874 6f74 616c 5f73 6563 6f6e   int(total_secon
    │ │ │ +0001b570: 6473 2864 2929 293b 0a23 656e 6469 660a  ds(d)));.#endif.
    │ │ │ +0001b580: 0909 0909 636f 6e6e 6563 745f 6661 696c  ....connect_fail
    │ │ │ +0001b590: 6564 2865 7272 6f72 733a 3a74 696d 6564  ed(errors::timed
    │ │ │ +0001b5a0: 5f6f 7574 293b 0a09 0909 0972 6574 7572  _out);.....retur
    │ │ │ +0001b5b0: 6e3b 0a09 0909 7d0a 0909 7d0a 0a09 092f  n;....}...}..../
    │ │ │ +0001b5c0: 2f20 6966 2074 6865 2062 775f 6e65 7477  / if the bw_netw
    │ │ │ +0001b5d0: 6f72 6b20 666c 6167 2069 736e 2774 2073  ork flag isn't s
    │ │ │ +0001b5e0: 6574 2c20 6974 206d 6561 6e73 2077 6520  et, it means we 
    │ │ │ +0001b5f0: 6172 6520 6e6f 7420 6576 656e 2074 7279  are not even try
    │ │ │ +0001b600: 696e 6720 746f 0a09 092f 2f20 7265 6164  ing to...// read
    │ │ │ +0001b610: 2066 726f 6d20 7468 6973 2070 6565 7227   from this peer'
    │ │ │ +0001b620: 7320 736f 636b 6574 2e20 4d6f 7374 206c  s socket. Most l
    │ │ │ +0001b630: 696b 656c 7920 6265 6361 7573 6520 7765  ikely because we
    │ │ │ +0001b640: 2772 6520 6170 706c 7969 6e67 2061 0a09  're applying a..
    │ │ │ +0001b650: 092f 2f20 7261 7465 206c 696d 6974 2e20  .// rate limit. 
    │ │ │ +0001b660: 4966 2074 6865 2070 6565 7220 6973 2022  If the peer is "
    │ │ │ +0001b670: 736c 6f77 2220 6265 6361 7573 6520 7765  slow" because we
    │ │ │ +0001b680: 2061 7265 2072 6174 6520 6c69 6d69 7469   are rate limiti
    │ │ │ +0001b690: 6e67 2069 742c 0a09 092f 2f20 646f 6e27  ng it,...// don'
    │ │ │ +0001b6a0: 7420 656e 666f 7263 6520 7469 6d65 6f75  t enforce timeou
    │ │ │ +0001b6b0: 7473 2e20 486f 7765 7665 722c 2061 7320  ts. However, as 
    │ │ │ +0001b6c0: 736f 6f6e 2061 7320 7765 202a 646f 2a20  soon as we *do* 
    │ │ │ +0001b6d0: 7265 6164 2066 726f 6d20 7468 650a 0909  read from the...
    │ │ │ +0001b6e0: 2f2f 2073 6f63 6b65 742c 2077 6520 6578  // socket, we ex
    │ │ │ +0001b6f0: 7065 6374 2074 6f20 7265 6365 6976 6520  pect to receive 
    │ │ │ +0001b700: 6461 7461 2c20 616e 6420 6e6f 7420 6861  data, and not ha
    │ │ │ +0001b710: 7665 2074 696d 6564 206f 7574 2e20 5468  ve timed out. Th
    │ │ │ +0001b720: 656e 2077 650a 0909 2f2f 2063 616e 2065  en we...// can e
    │ │ │ +0001b730: 6e66 6f72 6365 2074 6865 2074 696d 656f  nforce the timeo
    │ │ │ +0001b740: 7574 732e 0a09 0962 6f6f 6c20 636f 6e73  uts....bool cons
    │ │ │ +0001b750: 7420 7265 6164 696e 675f 736f 636b 6574  t reading_socket
    │ │ │ +0001b760: 203d 2062 6f6f 6c28 6d5f 6368 616e 6e65   = bool(m_channe
    │ │ │ +0001b770: 6c5f 7374 6174 655b 646f 776e 6c6f 6164  l_state[download
    │ │ │ +0001b780: 5f63 6861 6e6e 656c 5d20 2661 6d70 3b20  _channel] & 
    │ │ │ +0001b790: 7065 6572 5f69 6e66 6f3a 3a62 775f 6e65  peer_info::bw_ne
    │ │ │ +0001b7a0: 7477 6f72 6b29 3b0a 0a3c 6469 7620 7374  twork);..
    ..if (rea │ │ │ +0001b7e0: 6469 6e67 5f73 6f63 6b65 7420 2661 6d70 ding_socket & │ │ │ +0001b7f0: 3b26 616d 703b 2064 2026 6774 3b20 7365 ;& d > se │ │ │ +0001b800: 636f 6e64 7328 7469 6d65 6f75 7428 2929 conds(timeout()) │ │ │ +0001b810: 2026 616d 703b 2661 6d70 3b20 216d 5f63 && !m_c │ │ │ +0001b820: 6f6e 6e65 6374 696e 6720 2661 6d70 3b26 onnecting && │ │ │ +0001b830: 616d 703b 206d 5f72 6561 6469 6e67 5f62 amp; m_reading_b │ │ │ +0001b840: 7974 6573 203d 3d20 300a 3c2f 6469 763e ytes == 0.
    │ │ │ +0001b850: 0909 0926 616d 703b 2661 6d70 3b20 6361 ...&& ca │ │ │ +0001b860: 6e5f 6469 7363 6f6e 6e65 6374 2865 7272 n_disconnect(err │ │ │ +0001b870: 6f72 733a 3a74 696d 6564 5f6f 7574 5f69 ors::timed_out_i │ │ │ +0001b880: 6e61 6374 6976 6974 7929 290a 0909 7b0a nactivity))...{. │ │ │ +0001b890: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +0001b8a0: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ +0001b8b0: 0909 0970 6565 725f 6c6f 6728 7065 6572 ...peer_log(peer │ │ │ +0001b8c0: 5f6c 6f67 5f61 6c65 7274 3a3a 696e 666f _log_alert::info │ │ │ +0001b8d0: 2c20 7065 6572 5f6c 6f67 5f61 6c65 7274 , peer_log_alert │ │ │ +0001b8e0: 3a3a 6c61 7374 5f61 6374 6976 6974 792c ::last_activity, │ │ │ +0001b8f0: 2022 2564 2073 6563 6f6e 6473 2061 676f "%d seconds ago │ │ │ +0001b900: 220a 0909 0909 2c20 696e 7428 746f 7461 "....., int(tota │ │ │ +0001b910: 6c5f 7365 636f 6e64 7328 6429 2929 3b0a l_seconds(d)));. │ │ │ +0001b920: 2365 6e64 6966 0a09 0909 6469 7363 6f6e #endif....discon │ │ │ +0001b930: 6e65 6374 2865 7272 6f72 733a 3a74 696d nect(errors::tim │ │ │ +0001b940: 6564 5f6f 7574 5f69 6e61 6374 6976 6974 ed_out_inactivit │ │ │ +0001b950: 792c 206f 7065 7261 7469 6f6e 5f74 3a3a y, operation_t:: │ │ │ +0001b960: 6269 7474 6f72 7265 6e74 293b 0a09 0909 bittorrent);.... │ │ │ +0001b970: 7265 7475 726e 3b0a 0909 7d0a 0a09 092f return;...}..../ │ │ │ +0001b980: 2f20 646f 206e 6f74 2073 7461 6c6c 2077 / do not stall w │ │ │ +0001b990: 6169 7469 6e67 2066 6f72 2061 2068 616e aiting for a han │ │ │ +0001b9a0: 6473 6861 6b65 0a09 0969 6e74 2074 696d dshake...int tim │ │ │ +0001b9b0: 656f 7574 203d 206d 5f73 6574 7469 6e67 eout = m_setting │ │ │ +0001b9c0: 732e 6765 745f 696e 7420 2873 6574 7469 s.get_int (setti │ │ │ +0001b9d0: 6e67 735f 7061 636b 3a3a 6861 6e64 7368 ngs_pack::handsh │ │ │ +0001b9e0: 616b 655f 7469 6d65 6f75 7429 3b0a 2369 ake_timeout);.#i │ │ │ +0001b9f0: 6620 544f 5252 454e 545f 5553 455f 4932 f TORRENT_USE_I2 │ │ │ +0001ba00: 500a 0909 7469 6d65 6f75 7420 2a3d 2069 P...timeout *= i │ │ │ +0001ba10: 735f 6932 7028 6d5f 736f 636b 6574 2920 s_i2p(m_socket) │ │ │ +0001ba20: 3f20 3420 3a20 313b 0a23 656e 6469 660a ? 4 : 1;.#endif. │ │ │ +0001ba30: 0909 6966 2028 7265 6164 696e 675f 736f ..if (reading_so │ │ │ +0001ba40: 636b 6574 0a09 0909 2661 6d70 3b26 616d cket....&&am │ │ │ +0001ba50: 703b 2021 6d5f 636f 6e6e 6563 7469 6e67 p; !m_connecting │ │ │ +0001ba60: 0a09 0909 2661 6d70 3b26 616d 703b 2069 ....&& i │ │ │ +0001ba70: 6e5f 6861 6e64 7368 616b 6528 290a 0909 n_handshake()... │ │ │ +0001ba80: 0926 616d 703b 2661 6d70 3b20 6420 2667 .&& d &g │ │ │ +0001ba90: 743b 2073 6563 6f6e 6473 2874 696d 656f t; seconds(timeo │ │ │ +0001baa0: 7574 2929 0a09 097b 0a23 6966 6e64 6566 ut))...{.#ifndef │ │ │ +0001bab0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +0001bac0: 5f4c 4f47 4749 4e47 0a09 0909 7065 6572 _LOGGING....peer │ │ │ +0001bad0: 5f6c 6f67 2870 6565 725f 6c6f 675f 616c _log(peer_log_al │ │ │ +0001bae0: 6572 743a 3a69 6e66 6f2c 2070 6565 725f ert::info, peer_ │ │ │ +0001baf0: 6c6f 675f 616c 6572 743a 3a6e 6f5f 6861 log_alert::no_ha │ │ │ +0001bb00: 6e64 7368 616b 652c 2022 7761 6974 6564 ndshake, "waited │ │ │ +0001bb10: 2025 6420 7365 636f 6e64 7322 0a09 0909 %d seconds".... │ │ │ +0001bb20: 092c 2069 6e74 2874 6f74 616c 5f73 6563 ., int(total_sec │ │ │ +0001bb30: 6f6e 6473 2864 2929 293b 0a23 656e 6469 onds(d)));.#endi │ │ │ +0001bb40: 660a 0909 0964 6973 636f 6e6e 6563 7428 f....disconnect( │ │ │ +0001bb50: 6572 726f 7273 3a3a 7469 6d65 645f 6f75 errors::timed_ou │ │ │ +0001bb60: 745f 6e6f 5f68 616e 6473 6861 6b65 2c20 t_no_handshake, │ │ │ +0001bb70: 6f70 6572 6174 696f 6e5f 743a 3a62 6974 operation_t::bit │ │ │ +0001bb80: 746f 7272 656e 7429 3b0a 0909 0972 6574 torrent);....ret │ │ │ +0001bb90: 7572 6e3b 0a09 097d 0a0a 0909 2f2f 2064 urn;...}....// d │ │ │ +0001bba0: 6973 636f 6e6e 6563 7420 7065 6572 7320 isconnect peers │ │ │ +0001bbb0: 7468 6174 2077 6520 756e 6368 6f6b 6564 that we unchoked │ │ │ +0001bbc0: 2c20 6275 7420 7468 6579 2064 6964 6e27 , but they didn' │ │ │ +0001bbd0: 7420 7365 6e64 2061 2072 6571 7565 7374 t send a request │ │ │ +0001bbe0: 2069 6e0a 0909 2f2f 2074 6865 206c 6173 in...// the las │ │ │ +0001bbf0: 7420 3630 2073 6563 6f6e 6473 2c20 616e t 60 seconds, an │ │ │ +0001bc00: 6420 7765 2068 6176 656e 2774 2062 6565 d we haven't bee │ │ │ +0001bc10: 6e20 776f 726b 696e 6720 6f6e 2073 6572 n working on ser │ │ │ +0001bc20: 7669 6369 6e67 2061 2072 6571 7565 7374 vicing a request │ │ │ +0001bc30: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0001bc70: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../sr │ │ │ +0001bca0: 632f 746f 7272 656e 742e 6370 703a 3534 c/torrent.cpp:54 │ │ │ +0001bcb0: 323c 2f61 3e3c 2f74 643e 3c74 643e 706f 2po │ │ │ +0001bcc0: 7374 2061 6c65 7274 3c2f 7464 3e3c 2f74 st alert

    post alert< │ │ │ +0001bd20: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ +0001bd30: 6f72 7265 6e74 2e63 7070 3a35 3432 3c2f orrent.cpp:542
    ..i
    │ │ │ +0001bd80: 6620 286d 5f63 7572 7265 6e74 5f67 6175  f (m_current_gau
    │ │ │ +0001bd90: 6765 5f73 7461 7465 2021 3d20 6e6f 5f67  ge_state != no_g
    │ │ │ +0001bda0: 6175 6765 5f73 7461 7465 290a 0909 0969  auge_state)....i
    │ │ │ +0001bdb0: 6e63 5f73 7461 7473 5f63 6f75 6e74 6572  nc_stats_counter
    │ │ │ +0001bdc0: 286d 5f63 7572 7265 6e74 5f67 6175 6765  (m_current_gauge
    │ │ │ +0001bdd0: 5f73 7461 7465 202b 2063 6f75 6e74 6572  _state + counter
    │ │ │ +0001bde0: 733a 3a6e 756d 5f63 6865 636b 696e 675f  s::num_checking_
    │ │ │ +0001bdf0: 746f 7272 656e 7473 2c20 2d31 293b 0a09  torrents, -1);..
    │ │ │ +0001be00: 0969 6620 286e 6577 5f67 6175 6765 5f73  .if (new_gauge_s
    │ │ │ +0001be10: 7461 7465 2021 3d20 6e6f 5f67 6175 6765  tate != no_gauge
    │ │ │ +0001be20: 5f73 7461 7465 290a 0909 0969 6e63 5f73  _state)....inc_s
    │ │ │ +0001be30: 7461 7473 5f63 6f75 6e74 6572 286e 6577  tats_counter(new
    │ │ │ +0001be40: 5f67 6175 6765 5f73 7461 7465 202b 2063  _gauge_state + c
    │ │ │ +0001be50: 6f75 6e74 6572 733a 3a6e 756d 5f63 6865  ounters::num_che
    │ │ │ +0001be60: 636b 696e 675f 746f 7272 656e 7473 2c20  cking_torrents, 
    │ │ │ +0001be70: 3129 3b0a 0a09 0954 4f52 5245 4e54 5f41  1);....TORRENT_A
    │ │ │ +0001be80: 5353 4552 5428 6e65 775f 6761 7567 655f  SSERT(new_gauge_
    │ │ │ +0001be90: 7374 6174 6520 2667 743b 3d20 3029 3b0a  state >= 0);.
    │ │ │ +0001bea0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +0001beb0: 286e 6577 5f67 6175 6765 5f73 7461 7465  (new_gauge_state
    │ │ │ +0001bec0: 2026 6c74 3b3d 206e 6f5f 6761 7567 655f   <= no_gauge_
    │ │ │ +0001bed0: 7374 6174 6529 3b0a 0909 6d5f 6375 7272  state);...m_curr
    │ │ │ +0001bee0: 656e 745f 6761 7567 655f 7374 6174 6520  ent_gauge_state 
    │ │ │ +0001bef0: 3d20 7374 6174 6963 5f63 6173 7426 6c74  = static_cast<
    │ │ │ +0001bf00: 3b73 7464 3a3a 7569 6e74 3332 5f74 2667  ;std::uint32_t&g
    │ │ │ +0001bf10: 743b 286e 6577 5f67 6175 6765 5f73 7461  t;(new_gauge_sta
    │ │ │ +0001bf20: 7465 293b 0a09 7d0a 0a09 766f 6964 2074  te);..}...void t
    │ │ │ +0001bf30: 6f72 7265 6e74 3a3a 6c65 6176 655f 7365  orrent::leave_se
    │ │ │ +0001bf40: 6564 5f6d 6f64 6528 7365 6564 5f6d 6f64  ed_mode(seed_mod
    │ │ │ +0001bf50: 655f 7420 636f 6e73 7420 6368 6563 6b69  e_t const checki
    │ │ │ +0001bf60: 6e67 290a 097b 0a09 0969 6620 2821 6d5f  ng)..{...if (!m_
    │ │ │ +0001bf70: 7365 6564 5f6d 6f64 6529 2072 6574 7572  seed_mode) retur
    │ │ │ +0001bf80: 6e3b 0a0a 0909 6966 2028 6368 6563 6b69  n;....if (checki
    │ │ │ +0001bf90: 6e67 203d 3d20 7365 6564 5f6d 6f64 655f  ng == seed_mode_
    │ │ │ +0001bfa0: 743a 3a63 6865 636b 5f66 696c 6573 290a  t::check_files).
    │ │ │ +0001bfb0: 0909 7b0a 0909 092f 2f20 7468 6973 206d  ..{....// this m
    │ │ │ +0001bfc0: 6561 6e73 2074 6865 2075 7365 7220 7072  eans the user pr
    │ │ │ +0001bfd0: 6f6d 6973 6564 2077 6520 6861 6420 616c  omised we had al
    │ │ │ +0001bfe0: 6c20 7468 650a 0909 092f 2f20 6669 6c65  l the....// file
    │ │ │ +0001bff0: 732c 2062 7574 2069 7420 7475 726e 6564  s, but it turned
    │ │ │ +0001c000: 206f 7574 2077 6520 6469 646e 2774 2e20   out we didn't. 
    │ │ │ +0001c010: 5468 6973 2069 730a 0909 092f 2f20 616e  This is....// an
    │ │ │ +0001c020: 2065 7272 6f72 2e0a 0a3c 6469 7620 7374   error...
    .
    #i │ │ │ +0001c060: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +0001c070: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ +0001c080: 0964 6562 7567 5f6c 6f67 2822 2a2a 2a20 .debug_log("*** │ │ │ +0001c090: 4641 494c 4544 2053 4545 4420 4d4f 4445 FAILED SEED MODE │ │ │ +0001c0a0: 2c20 7265 6368 6563 6b69 6e67 2229 3b0a , rechecking");. │ │ │ +0001c0b0: 2365 6e64 6966 0a09 097d 0a0a 2369 666e #endif...}..#ifn │ │ │ +0001c0c0: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +0001c0d0: 424c 455f 4c4f 4747 494e 470a 0909 6465 BLE_LOGGING...de │ │ │ +0001c0e0: 6275 675f 6c6f 6728 222a 2a2a 204c 4541 bug_log("*** LEA │ │ │ +0001c0f0: 5649 4e47 2053 4545 4420 4d4f 4445 2028 VING SEED MODE ( │ │ │ +0001c100: 2573 2922 0a09 0909 2c20 6368 6563 6b69 %s)"...., checki │ │ │ +0001c110: 6e67 203d 3d20 7365 6564 5f6d 6f64 655f ng == seed_mode_ │ │ │ +0001c120: 743a 3a73 6b69 705f 6368 6563 6b69 6e67 t::skip_checking │ │ │ +0001c130: 203f 2022 6173 2073 6565 6422 203a 2022 ? "as seed" : " │ │ │ +0001c140: 6173 206e 6f6e 2d73 6565 6422 293b 0a23 as non-seed");.# │ │ │ +0001c150: 656e 6469 660a 0909 6d5f 7365 6564 5f6d endif...m_seed_m │ │ │ +0001c160: 6f64 6520 3d20 6661 6c73 653b 0a09 092f ode = false;.../ │ │ │ +0001c170: 2f20 7365 6564 2069 7320 6661 6c73 6520 / seed is false │ │ │ +0001c180: 6966 2077 6520 7475 726e 6564 206f 7574 if we turned out │ │ │ +0001c190: 206e 6f74 0a09 092f 2f20 746f 2062 6520 not...// to be │ │ │ +0001c1a0: 6120 7365 6564 2061 6674 6572 2061 6c6c a seed after all │ │ │ +0001c1b0: 0a09 0969 6620 2863 6865 636b 696e 6720 ...if (checking │ │ │ +0001c1c0: 3d3d 2073 6565 645f 6d6f 6465 5f74 3a3a == seed_mode_t:: │ │ │ +0001c1d0: 6368 6563 6b5f 6669 6c65 730a 0909 0926 check_files....& │ │ │ +0001c1e0: 616d 703b 2661 6d70 3b20 7374 6174 6528 amp;& state( │ │ │ +0001c1f0: 2920 213d 2074 6f72 7265 6e74 5f73 7461 ) != torrent_sta │ │ │ +0001c200: 7475 733a 3a63 6865 636b 696e 675f 7265 tus::checking_re │ │ │ +0001c210: 7375 6d65 5f64 6174 6129 0a09 097b 0a09 sume_data)...{.. │ │ │ +0001c220: 0909 6d5f 6861 7665 5f61 6c6c 203d 2066 ..m_have_all = f │ │ │ +0001c230: 616c 7365 3b0a 0909 0973 6574 5f73 7461 alse;....set_sta │ │ │ +0001c240: 7465 2874 6f72 7265 6e74 5f73 7461 7475 te(torrent_statu │ │ │ +0001c250: 733a 3a64 6f77 6e6c 6f61 6469 6e67 293b s::downloading); │ │ │ +0001c260: 0a09 0909 666f 7263 655f 7265 6368 6563 ....force_rechec │ │ │ +0001c270: 6b28 293b 0a09 097d 0a09 096d 5f6e 756d k();...}...m_num │ │ │ +0001c280: 5f76 6572 6966 6965 6420 3d20 303b 0a09 _verified = 0;.. │ │ │ +0001c290: 096d 5f76 6572 6966 6965 642e 636c 6561 .m_verified.clea │ │ │ +0001c2a0: 7228 293b 0a09 096d 5f76 6572 6966 7969 r();...m_verifyi │ │ │ +0001c2b0: 6e67 2e63 6c65 6172 2829 3b0a 0a09 0973 ng.clear();....s │ │ │ +0001c2c0: 6574 5f6e 6565 645f 7361 7665 5f72 6573 et_need_save_res │ │ │ +0001c2d0: 756d 6528 746f 7272 656e 745f 6861 6e64 ume(torrent_hand │ │ │ +0001c2e0: 6c65 3a3a 6966 5f73 7461 7465 5f63 6861 le::if_state_cha │ │ │ +0001c2f0: 6e67 6564 293b 0a09 7d0a 0a09 766f 6964 nged);..}...void │ │ │ +0001c300: 2074 6f72 7265 6e74 3a3a 7665 7269 6669 torrent::verifi │ │ │ +0001c310: 6564 2870 6965 6365 5f69 6e64 6578 5f74 ed(piece_index_t │ │ │ +0001c320: 2063 6f6e 7374 2070 6965 6365 290a 097b const piece)..{ │ │ │ +0001c330: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0001c340: 5428 216d 5f76 6572 6966 6965 642e 6765 T(!m_verified.ge │ │ │ +0001c350: 745f 6269 7428 7069 6563 6529 293b 0a09 t_bit(piece));.. │ │ │ +0001c360: 092b 2b6d 5f6e 756d 5f76 6572 6966 6965 .++m_num_verifie │ │ │ +0001c370: 643b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f d;.
    │ │ │ +0001c3a0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0001c3b0: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ +0001c3e0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0001c3f0: 3139 3935 3c2f 613e 3c2f 7464 3e3c 7464 1995add a unit test │ │ │ +0001c410: 2077 6865 7265 2077 6520 646f 6e27 7420 where we don't │ │ │ +0001c420: 6861 7665 206d 6574 6164 6174 612c 2063 have metadata, c │ │ │ +0001c430: 6f6e 6e65 6374 2074 6f20 6120 7065 6572 onnect to a peer │ │ │ +0001c440: 2074 6861 7420 7365 6e64 7320 6120 6269 that sends a bi │ │ │ +0001c450: 7466 6965 6c64 2074 6861 7427 7320 746f tfield that's to │ │ │ +0001c460: 6f20 6c61 7267 652c 2074 6865 6e20 7765 o large, then we │ │ │ +0001c470: 2067 6574 2074 6865 206d 6574 6164 6174 get the metadat │ │ │ +0001c480: 613c 2f74 643e 3c2f 7472 3e3c 7472 2069 a

    ad │ │ │ +0001c4d0: 6420 6120 756e 6974 2074 6573 7420 7768 d a unit test wh │ │ │ +0001c4e0: 6572 6520 7765 2064 6f6e 2774 2068 6176 ere we don't hav │ │ │ +0001c4f0: 6520 6d65 7461 6461 7461 2c20 636f 6e6e e metadata, conn │ │ │ +0001c500: 6563 7420 746f 2061 2070 6565 720a 7468 ect to a peer.th │ │ │ +0001c510: 6174 2073 656e 6473 2061 2062 6974 6669 at sends a bitfi │ │ │ +0001c520: 656c 6420 7468 6174 2773 2074 6f6f 206c eld that's too l │ │ │ +0001c530: 6172 6765 2c20 7468 656e 2077 6520 6765 arge, then we ge │ │ │ +0001c540: 7420 7468 6520 6d65 7461 6461 7461 3c2f t the metadata

    ../src/to │ │ │ +0001c560: 7272 656e 742e 6370 703a 3139 3935 3c2f rrent.cpp:1995
    ..f
    │ │ │ +0001c5b0: 696c 655f 7374 6f72 6167 6520 636f 6e73  ile_storage cons
    │ │ │ +0001c5c0: 7426 616d 703b 2066 7320 3d20 6d5f 746f  t& fs = m_to
    │ │ │ +0001c5d0: 7272 656e 745f 6669 6c65 2d26 6774 3b6c  rrent_file->l
    │ │ │ +0001c5e0: 6179 6f75 7428 293b 0a09 0969 6620 286d  ayout();...if (m
    │ │ │ +0001c5f0: 5f61 6464 5f74 6f72 7265 6e74 5f70 6172  _add_torrent_par
    │ │ │ +0001c600: 616d 7329 0a09 097b 0a09 0909 6d5f 7265  ams)...{....m_re
    │ │ │ +0001c610: 6e61 6d65 645f 6669 6c65 732e 696d 706f  named_files.impo
    │ │ │ +0001c620: 7274 5f66 696c 656e 616d 6573 286d 5f74  rt_filenames(m_t
    │ │ │ +0001c630: 6f72 7265 6e74 5f66 696c 652d 2667 743b  orrent_file->
    │ │ │ +0001c640: 6c61 796f 7574 2829 0a09 0909 092c 206d  layout()....., m
    │ │ │ +0001c650: 5f61 6464 5f74 6f72 7265 6e74 5f70 6172  _add_torrent_par
    │ │ │ +0001c660: 616d 732d 2667 743b 7265 6e61 6d65 645f  ams->renamed_
    │ │ │ +0001c670: 6669 6c65 7329 3b0a 0909 7d0a 0a09 0963  files);...}....c
    │ │ │ +0001c680: 6f6e 7374 7275 6374 5f73 746f 7261 6765  onstruct_storage
    │ │ │ +0001c690: 2829 3b0a 0a23 6966 6e64 6566 2054 4f52  ();..#ifndef TOR
    │ │ │ +0001c6a0: 5245 4e54 5f44 4953 4142 4c45 5f53 4841  RENT_DISABLE_SHA
    │ │ │ +0001c6b0: 5245 5f4d 4f44 450a 0909 6966 2028 6d5f  RE_MODE...if (m_
    │ │ │ +0001c6c0: 7368 6172 655f 6d6f 6465 2026 616d 703b  share_mode &
    │ │ │ +0001c6d0: 2661 6d70 3b20 7661 6c69 645f 6d65 7461  & valid_meta
    │ │ │ +0001c6e0: 6461 7461 2829 290a 0909 7b0a 0909 092f  data())...{..../
    │ │ │ +0001c6f0: 2f20 696e 2073 6861 7265 206d 6f64 652c  / in share mode,
    │ │ │ +0001c700: 2061 6c6c 2070 6965 6365 7320 6861 7665   all pieces have
    │ │ │ +0001c710: 2074 6865 6972 2070 7269 6f72 6974 6965   their prioritie
    │ │ │ +0001c720: 7320 696e 6974 6961 6c69 7a65 6420 746f  s initialized to
    │ │ │ +0001c730: 2030 0a09 0909 6d5f 6669 6c65 5f70 7269   0....m_file_pri
    │ │ │ +0001c740: 6f72 6974 792e 636c 6561 7228 293b 0a09  ority.clear();..
    │ │ │ +0001c750: 0909 6d5f 6669 6c65 5f70 7269 6f72 6974  ..m_file_priorit
    │ │ │ +0001c760: 792e 7265 7369 7a65 286d 5f74 6f72 7265  y.resize(m_torre
    │ │ │ +0001c770: 6e74 5f66 696c 652d 2667 743b 6e75 6d5f  nt_file->num_
    │ │ │ +0001c780: 6669 6c65 7328 292c 2064 6f6e 745f 646f  files(), dont_do
    │ │ │ +0001c790: 776e 6c6f 6164 293b 0a09 097d 0a23 656e  wnload);...}.#en
    │ │ │ +0001c7a0: 6469 660a 0a09 092f 2f20 6974 2773 2069  dif....// it's i
    │ │ │ +0001c7b0: 6d70 6f72 7461 6e74 2074 6f20 696e 6974  mportant to init
    │ │ │ +0001c7c0: 6961 6c69 7a65 2074 6865 2070 6565 7273  ialize the peers
    │ │ │ +0001c7d0: 2065 6172 6c79 2c20 6265 6361 7573 6520   early, because 
    │ │ │ +0001c7e0: 7468 6973 2069 7320 7768 6174 2077 696c  this is what wil
    │ │ │ +0001c7f0: 6c0a 0909 2f2f 2066 6978 2075 7020 7468  l...// fix up th
    │ │ │ +0001c800: 6569 7220 6861 7665 2d62 6974 6d61 736b  eir have-bitmask
    │ │ │ +0001c810: 7320 746f 2068 6176 6520 7468 6520 636f  s to have the co
    │ │ │ +0001c820: 7272 6563 7420 7369 7a65 0a3c 6469 7620  rrect size.
    ..if (! │ │ │ +0001c860: 6d5f 636f 6e6e 6563 7469 6f6e 735f 696e m_connections_in │ │ │ +0001c870: 6974 6961 6c69 7a65 6429 0a3c 2f64 6976 itialized).
    ..{....m_connec │ │ │ +0001c890: 7469 6f6e 735f 696e 6974 6961 6c69 7a65 tions_initialize │ │ │ +0001c8a0: 6420 3d20 7472 7565 3b0a 0909 092f 2f20 d = true;....// │ │ │ +0001c8b0: 616c 6c20 7065 6572 2063 6f6e 6e65 6374 all peer connect │ │ │ +0001c8c0: 696f 6e73 2068 6176 6520 746f 2069 6e69 ions have to ini │ │ │ +0001c8d0: 7469 616c 697a 6520 7468 656d 7365 6c76 tialize themselv │ │ │ +0001c8e0: 6573 206e 6f77 2074 6861 7420 7468 6520 es now that the │ │ │ +0001c8f0: 6d65 7461 6461 7461 0a09 0909 2f2f 2069 metadata....// i │ │ │ +0001c900: 7320 6176 6169 6c61 626c 650a 0909 092f s available..../ │ │ │ +0001c910: 2f20 636f 7079 2074 6865 2070 6565 7220 / copy the peer │ │ │ +0001c920: 6c69 7374 2073 696e 6365 2070 6565 7273 list since peers │ │ │ +0001c930: 206d 6179 2064 6973 636f 6e6e 6563 7420 may disconnect │ │ │ +0001c940: 616e 6420 696e 7661 6c69 6461 7465 0a09 and invalidate.. │ │ │ +0001c950: 0909 2f2f 206d 5f63 6f6e 6e65 6374 696f ..// m_connectio │ │ │ +0001c960: 6e73 2061 7320 7765 2069 6e69 7469 616c ns as we initial │ │ │ +0001c970: 697a 6520 7468 656d 0a09 0909 666f 7220 ize them....for │ │ │ +0001c980: 2861 7574 6f2a 2063 6f6e 7374 2063 203a (auto* const c : │ │ │ +0001c990: 206d 5f63 6f6e 6e65 6374 696f 6e73 290a m_connections). │ │ │ +0001c9a0: 0909 097b 0a09 0909 0961 7574 6f20 7063 ...{.....auto pc │ │ │ +0001c9b0: 203d 2063 2d26 6774 3b73 656c 6628 293b = c->self(); │ │ │ +0001c9c0: 0a09 0909 0969 6620 2870 632d 2667 743b .....if (pc-> │ │ │ +0001c9d0: 6973 5f64 6973 636f 6e6e 6563 7469 6e67 is_disconnecting │ │ │ +0001c9e0: 2829 2920 636f 6e74 696e 7565 3b0a 0909 ()) continue;... │ │ │ +0001c9f0: 0909 7063 2d26 6774 3b6f 6e5f 6d65 7461 ..pc->on_meta │ │ │ +0001ca00: 6461 7461 5f69 6d70 6c28 293b 0a09 0909 data_impl();.... │ │ │ +0001ca10: 0969 6620 2870 632d 2667 743b 6973 5f64 .if (pc->is_d │ │ │ +0001ca20: 6973 636f 6e6e 6563 7469 6e67 2829 2920 isconnecting()) │ │ │ +0001ca30: 636f 6e74 696e 7565 3b0a 0909 0909 7063 continue;.....pc │ │ │ +0001ca40: 2d26 6774 3b69 6e69 7428 293b 0a09 0909 ->init();.... │ │ │ +0001ca50: 7d0a 0909 7d0a 0a09 092f 2f20 696e 2063 }...}....// in c │ │ │ +0001ca60: 6173 6520 6669 6c65 2070 7269 6f72 6974 ase file priorit │ │ │ +0001ca70: 6965 7320 7765 7265 2070 6173 7365 6420 ies were passed │ │ │ +0001ca80: 696e 2076 6961 2074 6865 2061 6464 5f74 in via the add_t │ │ │ +0001ca90: 6f72 7265 6e74 5f70 6172 616d 730a 0909 orrent_params... │ │ │ +0001caa0: 2f2f 2061 6e64 2061 6c73 6f20 696e 2074 // and also in t │ │ │ +0001cab0: 6865 2063 6173 6520 6f66 2073 6861 7265 he case of share │ │ │ +0001cac0: 206d 6f64 652c 2077 6520 6e65 6564 2074 mode, we need t │ │ │ +0001cad0: 6f20 7570 6461 7465 2074 6865 2070 7269 o update the pri │ │ │ +0001cae0: 6f72 6974 6965 730a 0909 2f2f 2074 6869 orities...// thi │ │ │ +0001caf0: 7320 6861 7320 746f 2062 6520 6170 706c s has to be appl │ │ │ +0001cb00: 6965 6420 6265 666f 7265 2070 6965 6365 ied before piece │ │ │ +0001cb10: 2070 7269 6f72 6974 790a 0909 6966 2028 priority...if ( │ │ │ +0001cb20: 216d 5f66 696c 655f 7072 696f 7269 7479 !m_file_priority │ │ │ +0001cb30: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ +0001cb40: 092f 2f20 6d5f 6669 6c65 5f70 7269 6f72 .// m_file_prior │ │ │ +0001cb50: 6974 7920 7761 7320 6c6f 6164 6564 2066 ity was loaded f │ │ │ +0001cb60: 726f 6d20 7468 6520 7265 7375 6d65 2064 rom the resume d │ │ │ +0001cb70: 6174 612c 2074 6869 7320 646f 6573 6e27 ata, this doesn' │ │ │ +0001cb80: 740a 0909 092f 2f20 616c 7465 7220 616e t....// alter an │ │ │ +0001cb90: 7920 7374 6174 6520 7468 6174 206e 6565 y state that nee │ │ │ +0001cba0: 6473 2074 6f20 6265 2073 6176 6564 2069 ds to be saved i │ │ │ +0001cbb0: 6e20 7468 6520 7265 7375 6d65 2064 6174 n the resume dat │ │ │ +0001cbc0: 610a 0909 0961 7574 6f20 636f 6e73 7420 a....auto const │ │ │ +0001cbd0: 6e73 203d 206d 5f6e 6565 645f 7361 7665 ns = m_need_save │ │ │ +0001cbe0: 5f72 6573 756d 655f 6461 7461 3b0a 0909 _resume_data;... │ │ │ +0001cbf0: 0975 7064 6174 655f 7069 6563 655f 7072 .update_piece_pr │ │ │ +0001cc00: 696f 7269 7469 6573 286d 5f66 696c 655f iorities(m_file_ │ │ │ +0001cc10: 7072 696f 7269 7479 293b 0a09 0909 6d5f priority);....m_ │ │ │ +0001cc20: 6e65 6564 5f73 6176 655f 7265 7375 6d65 need_save_resume │ │ │ +0001cc30: 5f64 6174 6120 3d20 6e73 3b0a 0909 7d0a _data = ns;...}. │ │ │ +0001cc40: 0a09 0969 6620 286d 5f61 6464 5f74 6f72 ...if (m_add_tor │ │ │ +0001cc50: 7265 6e74 5f70 6172 616d 7329 0a09 097b rent_params)...{ │ │ │ +0001cc60: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0001cca0: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../sr │ │ │ +0001ccd0: 632f 746f 7272 656e 742e 6370 703a 3533 c/torrent.cpp:53 │ │ │ +0001cce0: 3032 3c2f 613e 3c2f 7464 3e3c 7464 3e61 02a │ │ │ +0001ccf0: 626f 7274 206c 6f6f 6b75 7073 2074 6869 bort lookups thi │ │ │ +0001cd00: 7320 746f 7272 656e 7420 6861 7320 6d61 s torrent has ma │ │ │ +0001cd10: 6465 2076 6961 2074 6865 2073 6573 7369 de via the sessi │ │ │ +0001cd20: 6f6e 2068 6f73 7420 7265 736f 6c76 6572 on host resolver │ │ │ +0001cd30: 2069 6e74 6572 6661 6365 3c2f 7464 3e3c interface< │ │ │ +0001cd40: 2f74 723e 3c74 7220 6964 3d22 3537 2220 /tr>

    abort loo │ │ │ +0001cd90: 6b75 7073 2074 6869 7320 746f 7272 656e kups this torren │ │ │ +0001cda0: 7420 6861 7320 6d61 6465 2076 6961 2074 t has made via t │ │ │ +0001cdb0: 6865 0a73 6573 7369 6f6e 2068 6f73 7420 he.session host │ │ │ +0001cdc0: 7265 736f 6c76 6572 2069 6e74 6572 6661 resolver interfa │ │ │ +0001cdd0: 6365 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ce

    ../sr │ │ │ +0001cde0: 632f 746f 7272 656e 742e 6370 703a 3533 c/torrent.cpp:53 │ │ │ +0001cdf0: 3032 3c2f 6834 3e3c 7072 6520 7374 796c 02

    ....TORRENT_UNU
    │ │ │ +0001ce40: 5345 4428 6529 3b0a 0909 0909 6d5f 7374  SED(e);.....m_st
    │ │ │ +0001ce50: 6f72 6167 652e 7265 7365 7428 293b 0a23  orage.reset();.#
    │ │ │ +0001ce60: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ +0001ce70: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ +0001ce80: 0909 0964 6562 7567 5f6c 6f67 2822 4661  ...debug_log("Fa
    │ │ │ +0001ce90: 696c 6564 2074 6f20 666c 7573 6820 6469  iled to flush di
    │ │ │ +0001cea0: 736b 2063 6163 6865 3a20 2573 222c 2065  sk cache: %s", e
    │ │ │ +0001ceb0: 2e77 6861 7428 2929 3b0a 2365 6e64 6966  .what());.#endif
    │ │ │ +0001cec0: 0a09 0909 092f 2f20 636c 6965 6e74 7320  .....// clients 
    │ │ │ +0001ced0: 6d61 7920 7265 6c79 206f 6e20 7468 6973  may rely on this
    │ │ │ +0001cee0: 2061 6c65 7274 2074 6f20 6265 2070 6f73   alert to be pos
    │ │ │ +0001cef0: 7465 642c 2073 6f20 6974 2773 2070 726f  ted, so it's pro
    │ │ │ +0001cf00: 6261 626c 7920 610a 0909 0909 2f2f 2067  bably a.....// g
    │ │ │ +0001cf10: 6f6f 6420 6964 6561 2074 6f20 706f 7374  ood idea to post
    │ │ │ +0001cf20: 2069 7420 6865 7265 2c20 6576 656e 2074   it here, even t
    │ │ │ +0001cf30: 686f 7567 6820 7765 2066 6169 6c65 640a  hough we failed.
    │ │ │ +0001cf40: 0909 0909 6966 2028 616c 6572 7473 2829  ....if (alerts()
    │ │ │ +0001cf50: 2e73 686f 756c 645f 706f 7374 266c 743b  .should_post<
    │ │ │ +0001cf60: 6361 6368 655f 666c 7573 6865 645f 616c  cache_flushed_al
    │ │ │ +0001cf70: 6572 7426 6774 3b28 2929 0a09 0909 0909  ert>())......
    │ │ │ +0001cf80: 616c 6572 7473 2829 2e65 6d70 6c61 6365  alerts().emplace
    │ │ │ +0001cf90: 5f61 6c65 7274 266c 743b 6361 6368 655f  _alert<cache_
    │ │ │ +0001cfa0: 666c 7573 6865 645f 616c 6572 7426 6774  flushed_alert>
    │ │ │ +0001cfb0: 3b28 6765 745f 6861 6e64 6c65 2829 293b  ;(get_handle());
    │ │ │ +0001cfc0: 0a09 0909 7d0a 0909 096d 5f73 6573 2e64  ....}....m_ses.d
    │ │ │ +0001cfd0: 6566 6572 7265 645f 7375 626d 6974 5f6a  eferred_submit_j
    │ │ │ +0001cfe0: 6f62 7328 293b 0a09 097d 0a09 0965 6c73  obs();...}...els
    │ │ │ +0001cff0: 650a 0909 7b0a 0909 0969 6620 2861 6c65  e...{....if (ale
    │ │ │ +0001d000: 7274 7328 292e 7368 6f75 6c64 5f70 6f73  rts().should_pos
    │ │ │ +0001d010: 7426 6c74 3b63 6163 6865 5f66 6c75 7368  t<cache_flush
    │ │ │ +0001d020: 6564 5f61 6c65 7274 2667 743b 2829 290a  ed_alert>()).
    │ │ │ +0001d030: 0909 0909 616c 6572 7473 2829 2e65 6d70  ....alerts().emp
    │ │ │ +0001d040: 6c61 6365 5f61 6c65 7274 266c 743b 6361  lace_alert<ca
    │ │ │ +0001d050: 6368 655f 666c 7573 6865 645f 616c 6572  che_flushed_aler
    │ │ │ +0001d060: 7426 6774 3b28 6765 745f 6861 6e64 6c65  t>(get_handle
    │ │ │ +0001d070: 2829 293b 0a09 0909 616c 6572 7473 2829  ());....alerts()
    │ │ │ +0001d080: 2e65 6d70 6c61 6365 5f61 6c65 7274 266c  .emplace_alert&l
    │ │ │ +0001d090: 743b 746f 7272 656e 745f 7265 6d6f 7665  t;torrent_remove
    │ │ │ +0001d0a0: 645f 616c 6572 7426 6774 3b28 6765 745f  d_alert>(get_
    │ │ │ +0001d0b0: 6861 6e64 6c65 2829 0a09 0909 092c 2069  handle()....., i
    │ │ │ +0001d0c0: 6e66 6f5f 6861 7368 2829 2c20 6765 745f  nfo_hash(), get_
    │ │ │ +0001d0d0: 7573 6572 6461 7461 2829 293b 0a09 097d  userdata());...}
    │ │ │ +0001d0e0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +0001d110: 0a3c 2f64 6976 3e09 0969 6620 2821 6d5f .
    ..if (!m_ │ │ │ +0001d120: 6170 706c 795f 6970 5f66 696c 7465 7229 apply_ip_filter) │ │ │ +0001d130: 0a09 097b 0a09 0909 696e 635f 7374 6174 ...{....inc_stat │ │ │ +0001d140: 735f 636f 756e 7465 7228 636f 756e 7465 s_counter(counte │ │ │ +0001d150: 7273 3a3a 6e6f 6e5f 6669 6c74 6572 5f74 rs::non_filter_t │ │ │ +0001d160: 6f72 7265 6e74 732c 202d 3129 3b0a 0909 orrents, -1);... │ │ │ +0001d170: 096d 5f61 7070 6c79 5f69 705f 6669 6c74 .m_apply_ip_filt │ │ │ +0001d180: 6572 203d 2074 7275 653b 0a09 097d 0a0a er = true;...}.. │ │ │ +0001d190: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ +0001d1a0: 5254 430a 0909 6966 286d 5f72 7463 5f73 RTC...if(m_rtc_s │ │ │ +0001d1b0: 6967 6e61 6c69 6e67 290a 0909 096d 5f72 ignaling)....m_r │ │ │ +0001d1c0: 7463 5f73 6967 6e61 6c69 6e67 2d26 6774 tc_signaling-> │ │ │ +0001d1d0: 3b63 6c6f 7365 2829 3b0a 2365 6e64 6966 ;close();.#endif │ │ │ +0001d1e0: 0a09 7d0a 0a09 2f2f 2074 6869 7320 6973 ..}...// this is │ │ │ +0001d1f0: 2063 616c 6c65 6420 7768 656e 2077 6527 called when we' │ │ │ +0001d200: 7265 2064 6573 7472 7563 7469 6e67 206e re destructing n │ │ │ +0001d210: 6f6e 2d67 7261 6365 6675 6c6c 792e 2069 on-gracefully. i │ │ │ +0001d220: 2e65 2e20 7765 2772 6520 5f6a 7573 745f .e. we're _just_ │ │ │ +0001d230: 0a09 2f2f 2064 6573 7472 7563 7469 6e67 ..// destructing │ │ │ +0001d240: 2065 7665 7279 7468 696e 672e 0a09 766f everything...vo │ │ │ +0001d250: 6964 2074 6f72 7265 6e74 3a3a 7061 6e69 id torrent::pani │ │ │ +0001d260: 6328 290a 097b 0a09 096d 5f73 746f 7261 c()..{...m_stora │ │ │ +0001d270: 6765 2e72 6573 6574 2829 3b0a 0909 2f2f ge.reset();...// │ │ │ +0001d280: 2069 6620 7468 6572 6520 6172 6520 616e if there are an │ │ │ +0001d290: 7920 6f74 6865 7220 7065 6572 7320 616c y other peers al │ │ │ +0001d2a0: 6c6f 6361 7465 6420 7374 696c 6c2c 2077 located still, w │ │ │ +0001d2b0: 6520 6e65 6564 2074 6f20 636c 6561 7220 e need to clear │ │ │ +0001d2c0: 7468 656d 0a09 092f 2f20 6e6f 772e 2054 them...// now. T │ │ │ +0001d2d0: 6865 7920 6361 6e27 7420 6265 2063 6c65 hey can't be cle │ │ │ +0001d2e0: 6172 6564 206c 6174 6572 2062 6563 6175 ared later becau │ │ │ +0001d2f0: 7365 2074 6865 2061 6c6c 6f63 6174 6f72 se the allocator │ │ │ +0001d300: 2077 696c 6c20 616c 7265 6164 790a 0909 will already... │ │ │ +0001d310: 2f2f 2068 6176 6520 6265 656e 2064 6573 // have been des │ │ │ +0001d320: 7472 7563 7465 640a 0909 6966 2028 6d5f tructed...if (m_ │ │ │ +0001d330: 7065 6572 5f6c 6973 7429 206d 5f70 6565 peer_list) m_pee │ │ │ +0001d340: 725f 6c69 7374 2d26 6774 3b63 6c65 6172 r_list->clear │ │ │ +0001d350: 2829 3b0a 0909 6d5f 636f 6e6e 6563 7469 ();...m_connecti │ │ │ +0001d360: 6f6e 732e 636c 6561 7228 293b 0a09 096d ons.clear();...m │ │ │ +0001d370: 5f6f 7574 676f 696e 675f 7069 6473 2e63 _outgoing_pids.c │ │ │ +0001d380: 6c65 6172 2829 3b0a 0909 6d5f 7065 6572 lear();...m_peer │ │ │ +0001d390: 735f 746f 5f64 6973 636f 6e6e 6563 742e s_to_disconnect. │ │ │ +0001d3a0: 636c 6561 7228 293b 0a09 096d 5f6e 756d clear();...m_num │ │ │ +0001d3b0: 5f75 706c 6f61 6473 203d 2030 3b0a 0909 _uploads = 0;... │ │ │ +0001d3c0: 6d5f 6e75 6d5f 636f 6e6e 6563 7469 6e67 m_num_connecting │ │ │ +0001d3d0: 203d 2030 3b0a 0909 6d5f 6e75 6d5f 636f = 0;...m_num_co │ │ │ +0001d3e0: 6e6e 6563 7469 6e67 5f73 6565 6473 203d nnecting_seeds = │ │ │ +0001d3f0: 2030 3b0a 097d 0a0a 2369 666e 6465 6620 0;..}..#ifndef │ │ │ +0001d400: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +0001d410: 5355 5045 5253 4545 4449 4e47 0a3c 2f70 SUPERSEEDING.

    re │ │ │ +0001d450: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/to │ │ │ +0001d490: 7272 656e 742e 6370 703a 3834 3537 3c2f rrent.cpp:8457if pe │ │ │ +0001d4b0: 6572 2069 7320 6120 7265 616c 6c79 2067 er is a really g │ │ │ +0001d4c0: 6f6f 6420 7065 6572 2c20 6d61 7962 6520 ood peer, maybe │ │ │ +0001d4d0: 7765 2073 686f 756c 646e 2774 2064 6973 we shouldn't dis │ │ │ +0001d4e0: 636f 6e6e 6563 7420 6974 2070 6572 6861 connect it perha │ │ │ +0001d4f0: 7073 2074 6869 7320 6c6f 6769 6320 7368 ps this logic sh │ │ │ +0001d500: 6f75 6c64 2062 6520 6469 7361 626c 6564 ould be disabled │ │ │ +0001d510: 2069 6620 7765 2068 6176 6520 746f 6f20 if we have too │ │ │ +0001d520: 6d61 6e79 2069 646c 6520 7065 6572 7320 many idle peers │ │ │ +0001d530: 2877 6974 6820 736f 6d65 2064 6566 696e (with some defin │ │ │ +0001d540: 6974 696f 6e20 6f66 2069 646c 6529 3c2f ition of idle)

    if pe │ │ │ +0001d5a0: 6572 2069 7320 6120 7265 616c 6c79 2067 er is a really g │ │ │ +0001d5b0: 6f6f 6420 7065 6572 2c20 6d61 7962 6520 ood peer, maybe │ │ │ +0001d5c0: 7765 2073 686f 756c 646e 2774 2064 6973 we shouldn't dis │ │ │ +0001d5d0: 636f 6e6e 6563 7420 6974 0a70 6572 6861 connect it.perha │ │ │ +0001d5e0: 7073 2074 6869 7320 6c6f 6769 6320 7368 ps this logic sh │ │ │ +0001d5f0: 6f75 6c64 2062 6520 6469 7361 626c 6564 ould be disabled │ │ │ +0001d600: 2069 6620 7765 2068 6176 6520 746f 6f20 if we have too │ │ │ +0001d610: 6d61 6e79 2069 646c 6520 7065 6572 730a many idle peers. │ │ │ +0001d620: 2877 6974 6820 736f 6d65 2064 6566 696e (with some defin │ │ │ +0001d630: 6974 696f 6e20 6f66 2069 646c 6529 3c2f ition of idle)

    ../src/to │ │ │ +0001d650: 7272 656e 742e 6370 703a 3834 3537 3c2f rrent.cpp:8457
    ...
    │ │ │ +0001d6a0: 6d5f 7065 6572 735f 746f 5f64 6973 636f  m_peers_to_disco
    │ │ │ +0001d6b0: 6e6e 6563 742e 7265 7365 7276 6528 6d5f  nnect.reserve(m_
    │ │ │ +0001d6c0: 636f 6e6e 6563 7469 6f6e 732e 7369 7a65  connections.size
    │ │ │ +0001d6d0: 2829 202b 2031 293b 0a09 096d 5f63 6f6e  () + 1);...m_con
    │ │ │ +0001d6e0: 6e65 6374 696f 6e73 2e72 6573 6572 7665  nections.reserve
    │ │ │ +0001d6f0: 286d 5f63 6f6e 6e65 6374 696f 6e73 2e73  (m_connections.s
    │ │ │ +0001d700: 697a 6528 2920 2b20 3129 3b0a 0a23 6966  ize() + 1);..#if
    │ │ │ +0001d710: 2054 4f52 5245 4e54 5f55 5345 5f41 5353   TORRENT_USE_ASS
    │ │ │ +0001d720: 4552 5453 0a09 0965 7272 6f72 5f63 6f64  ERTS...error_cod
    │ │ │ +0001d730: 6520 6563 3b0a 0909 544f 5252 454e 545f  e ec;...TORRENT_
    │ │ │ +0001d740: 4153 5345 5254 2870 2d26 6774 3b72 656d  ASSERT(p->rem
    │ │ │ +0001d750: 6f74 6528 2920 3d3d 2070 2d26 6774 3b67  ote() == p->g
    │ │ │ +0001d760: 6574 5f73 6f63 6b65 7428 292e 7265 6d6f  et_socket().remo
    │ │ │ +0001d770: 7465 5f65 6e64 706f 696e 7428 6563 2920  te_endpoint(ec) 
    │ │ │ +0001d780: 7c7c 2065 6329 3b0a 2365 6e64 6966 0a0a  || ec);.#endif..
    │ │ │ +0001d790: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +0001d7a0: 2870 2d26 6774 3b70 6565 725f 696e 666f  (p->peer_info
    │ │ │ +0001d7b0: 5f73 7472 7563 7428 2920 213d 206e 756c  _struct() != nul
    │ │ │ +0001d7c0: 6c70 7472 293b 0a0a 0909 2f2f 2077 6520  lptr);....// we 
    │ │ │ +0001d7d0: 6e65 6564 2074 6f20 646f 2074 6869 7320  need to do this 
    │ │ │ +0001d7e0: 6166 7465 7220 7765 2776 6520 6164 6465  after we've adde
    │ │ │ +0001d7f0: 6420 7468 6520 7065 6572 2074 6f20 7468  d the peer to th
    │ │ │ +0001d800: 6520 7065 6572 5f6c 6973 740a 0909 2f2f  e peer_list...//
    │ │ │ +0001d810: 2073 696e 6365 2074 6861 7427 7320 7768   since that's wh
    │ │ │ +0001d820: 656e 2074 6865 2070 6565 7220 6973 2061  en the peer is a
    │ │ │ +0001d830: 7373 6967 6e65 6420 6974 7320 7065 6572  ssigned its peer
    │ │ │ +0001d840: 5f69 6e66 6f20 6f62 6a65 6374 2c0a 0909  _info object,...
    │ │ │ +0001d850: 2f2f 2077 6869 6368 2068 6f6c 6473 2074  // which holds t
    │ │ │ +0001d860: 6865 2072 616e 6b0a 0909 6966 2028 6d61  he rank...if (ma
    │ │ │ +0001d870: 7962 655f 7265 706c 6163 655f 7065 6572  ybe_replace_peer
    │ │ │ +0001d880: 290a 0909 7b0a 0909 092f 2f20 6e6f 772c  )...{....// now,
    │ │ │ +0001d890: 2066 696e 6420 7468 6520 6c6f 7765 7374   find the lowest
    │ │ │ +0001d8a0: 2072 616e 6b20 7065 6572 2061 6e64 2064   rank peer and d
    │ │ │ +0001d8b0: 6973 636f 6e6e 6563 7420 7468 6174 0a09  isconnect that..
    │ │ │ +0001d8c0: 0909 2f2f 2069 6620 6974 2773 206c 6f77  ..// if it's low
    │ │ │ +0001d8d0: 6572 2072 616e 6b20 7468 616e 2074 6865  er rank than the
    │ │ │ +0001d8e0: 2069 6e63 6f6d 696e 6720 636f 6e6e 6563   incoming connec
    │ │ │ +0001d8f0: 7469 6f6e 0a09 0909 7065 6572 5f63 6f6e  tion....peer_con
    │ │ │ +0001d900: 6e65 6374 696f 6e2a 2070 6565 7220 3d20  nection* peer = 
    │ │ │ +0001d910: 6669 6e64 5f6c 6f77 6573 745f 7261 6e6b  find_lowest_rank
    │ │ │ +0001d920: 696e 675f 7065 6572 2829 3b0a 0a3c 6469  ing_peer();.....if
    │ │ │ +0001d960: 2028 7065 6572 2021 3d20 6e75 6c6c 7074   (peer != nullpt
    │ │ │ +0001d970: 7220 2661 6d70 3b26 616d 703b 2070 6565  r && pee
    │ │ │ +0001d980: 722d 2667 743b 7065 6572 5f72 616e 6b28  r->peer_rank(
    │ │ │ +0001d990: 2920 266c 743b 2070 2d26 6774 3b70 6565  ) < p->pee
    │ │ │ +0001d9a0: 725f 7261 6e6b 2829 290a 3c2f 6469 763e  r_rank()).

    │ │ │ +0001d9b0: 0909 097b 0a23 6966 6e64 6566 2054 4f52 ...{.#ifndef TOR │ │ │ +0001d9c0: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ +0001d9d0: 4749 4e47 0a09 0909 0969 6620 2873 686f GING.....if (sho │ │ │ +0001d9e0: 756c 645f 6c6f 6728 2929 0a09 0909 097b uld_log()).....{ │ │ │ +0001d9f0: 0a09 0909 0909 6465 6275 675f 6c6f 6728 ......debug_log( │ │ │ +0001da00: 2243 4c4f 5349 4e47 2043 4f4e 4e45 4354 "CLOSING CONNECT │ │ │ +0001da10: 494f 4e20 5c22 2573 5c22 2070 6565 7220 ION \"%s\" peer │ │ │ +0001da20: 6c69 7374 2066 756c 6c20 286c 6f77 2070 list full (low p │ │ │ +0001da30: 6565 7220 7261 6e6b 2920 220a 0909 0909 eer rank) "..... │ │ │ +0001da40: 0909 2263 6f6e 6e65 6374 696f 6e73 3a20 .."connections: │ │ │ +0001da50: 2564 206c 696d 6974 3a20 2564 220a 0909 %d limit: %d"... │ │ │ +0001da60: 0909 0909 2c20 7072 696e 745f 656e 6470 ...., print_endp │ │ │ +0001da70: 6f69 6e74 2870 6565 722d 2667 743b 7265 oint(peer->re │ │ │ +0001da80: 6d6f 7465 2829 292e 635f 7374 7228 290a mote()).c_str(). │ │ │ +0001da90: 0909 0909 0909 2c20 6e75 6d5f 7065 6572 ......, num_peer │ │ │ +0001daa0: 7328 290a 0909 0909 0909 2c20 6d5f 6d61 s()......., m_ma │ │ │ +0001dab0: 785f 636f 6e6e 6563 7469 6f6e 7329 3b0a x_connections);. │ │ │ +0001dac0: 0909 0909 7d0a 2365 6e64 6966 0a09 0909 ....}.#endif.... │ │ │ +0001dad0: 0970 6565 722d 2667 743b 6469 7363 6f6e .peer->discon │ │ │ +0001dae0: 6e65 6374 2865 7272 6f72 733a 3a74 6f6f nect(errors::too │ │ │ +0001daf0: 5f6d 616e 795f 636f 6e6e 6563 7469 6f6e _many_connection │ │ │ +0001db00: 732c 206f 7065 7261 7469 6f6e 5f74 3a3a s, operation_t:: │ │ │ +0001db10: 6269 7474 6f72 7265 6e74 293b 0a09 0909 bittorrent);.... │ │ │ +0001db20: 0970 2d26 6774 3b70 6565 725f 6469 7363 .p->peer_disc │ │ │ +0001db30: 6f6e 6e65 6374 6564 5f6f 7468 6572 2829 onnected_other() │ │ │ +0001db40: 3b0a 0909 097d 0a09 0909 656c 7365 0a09 ;....}....else.. │ │ │ +0001db50: 0909 7b0a 2369 666e 6465 6620 544f 5252 ..{.#ifndef TORR │ │ │ +0001db60: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ +0001db70: 494e 470a 0909 0909 6966 2028 7368 6f75 ING.....if (shou │ │ │ +0001db80: 6c64 5f6c 6f67 2829 290a 0909 0909 7b0a ld_log()).....{. │ │ │ +0001db90: 0909 0909 0964 6562 7567 5f6c 6f67 2822 .....debug_log(" │ │ │ +0001dba0: 434c 4f53 494e 4720 434f 4e4e 4543 5449 CLOSING CONNECTI │ │ │ +0001dbb0: 4f4e 205c 2225 735c 2220 7065 6572 206c ON \"%s\" peer l │ │ │ +0001dbc0: 6973 7420 6675 6c6c 2028 6c6f 7720 7065 ist full (low pe │ │ │ +0001dbd0: 6572 2072 616e 6b29 2022 0a09 0909 0909 er rank) "...... │ │ │ +0001dbe0: 0922 636f 6e6e 6563 7469 6f6e 733a 2025 ."connections: % │ │ │ +0001dbf0: 6420 6c69 6d69 743a 2025 6422 0a09 0909 d limit: %d".... │ │ │ +0001dc00: 0909 092c 2070 7269 6e74 5f65 6e64 706f ..., print_endpo │ │ │ +0001dc10: 696e 7428 702d 2667 743b 7265 6d6f 7465 int(p->remote │ │ │ +0001dc20: 2829 292e 635f 7374 7228 290a 0909 0909 ()).c_str()..... │ │ │ +0001dc30: 0909 2c20 6e75 6d5f 7065 6572 7328 290a .., num_peers(). │ │ │ +0001dc40: 0909 0909 0909 2c20 6d5f 6d61 785f 636f ......, m_max_co │ │ │ +0001dc50: 6e6e 6563 7469 6f6e 7329 3b0a 0909 0909 nnections);..... │ │ │ +0001dc60: 7d0a 2365 6e64 6966 0a09 0909 0970 2d26 }.#endif.....p-& │ │ │ +0001dc70: 6774 3b64 6973 636f 6e6e 6563 7428 6572 gt;disconnect(er │ │ │ +0001dc80: 726f 7273 3a3a 746f 6f5f 6d61 6e79 5f63 rors::too_many_c │ │ │ +0001dc90: 6f6e 6e65 6374 696f 6e73 2c20 6f70 6572 onnections, oper │ │ │ +0001dca0: 6174 696f 6e5f 743a 3a62 6974 746f 7272 ation_t::bittorr │ │ │ +0001dcb0: 656e 7429 3b0a 0909 0909 2f2f 2077 6520 ent);.....// we │ │ │ +0001dcc0: 6861 7665 2074 6f20 646f 2074 6869 7320 have to do this │ │ │ +0001dcd0: 6865 7265 2062 6563 6175 7365 2066 726f here because fro │ │ │ +0001dce0: 6d20 7468 6520 7065 6572 2773 2070 6f69 m the peer's poi │ │ │ +0001dcf0: 6e74 206f 6620 7669 6577 0a09 0909 092f nt of view...../ │ │ │ +0001dd00: 2f20 6974 2077 6173 6e27 7420 7265 616c / it wasn't real │ │ │ +0001dd10: 6c79 2061 7474 6163 6865 6420 746f 2074 ly attached to t │ │ │ +0001dd20: 6865 2074 6f72 7265 6e74 2c20 6275 7420 he torrent, but │ │ │ +0001dd30: 7765 2064 6f20 6e65 6564 0a09 0909 092f we do need...../ │ │ │ +0001dd40: 2f20 746f 206c 6574 2070 6565 725f 6c69 / to let peer_li │ │ │ +0001dd50: 7374 206b 6e6f 7720 7765 2772 6520 7265 st know we're re │ │ │ +0001dd60: 6d6f 7669 6e67 2069 740a 3c2f 7072 653e moving it.
    │ │ │ +0001dd70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0001dda0: 616e 6365 266e 6273 703b 323c 2f74 643e ance 2 │ │ │ +0001ddb0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/stora │ │ │ +0001dde0: 6765 5f75 7469 6c73 2e63 7070 3a31 3837 ge_utils.cpp:187 │ │ │ +0001ddf0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6563 tec │ │ │ +0001de00: 686e 6963 616c 6c79 2c20 7468 6973 2069 hnically, this i │ │ │ +0001de10: 7320 7768 6572 6520 7468 6520 7472 616e s where the tran │ │ │ +0001de20: 7361 6374 696f 6e20 6f66 206d 6f76 696e saction of movin │ │ │ +0001de30: 6720 7468 6520 6669 6c65 7320 6973 2063 g the files is c │ │ │ +0001de40: 6f6d 706c 6574 6564 2e20 5468 6973 2069 ompleted. This i │ │ │ +0001de50: 7320 7768 6572 6520 7468 6520 6e65 7720 s where the new │ │ │ +0001de60: 7361 7665 5f70 6174 6820 7368 6f75 6c64 save_path should │ │ │ +0001de70: 2062 6520 636f 6d6d 6974 7465 642e 2049 be committed. I │ │ │ +0001de80: 6620 7468 6572 6520 6973 2061 6e20 6572 f there is an er │ │ │ +0001de90: 726f 7220 696e 2074 6865 2063 6f64 6520 ror in the code │ │ │ +0001dea0: 6265 6c6f 772c 2074 6861 7420 7368 6f75 below, that shou │ │ │ +0001deb0: 6c64 206e 6f74 2070 7265 7665 6e74 2074 ld not prevent t │ │ │ +0001dec0: 6865 206e 6577 2073 6176 6520 7061 7468 he new save path │ │ │ +0001ded0: 2074 6f20 6265 2073 6574 2e20 4d61 7962 to be set. Mayb │ │ │ +0001dee0: 6520 6974 2077 6f75 6c64 206d 616b 6520 e it would make │ │ │ +0001def0: 7365 6e73 6520 746f 206d 616b 6520 7468 sense to make th │ │ │ +0001df00: 6520 7361 7665 5f70 6174 6820 616e 2069 e save_path an i │ │ │ +0001df10: 6e2d 6f75 7420 7061 7261 6d65 7465 723c n-out parameter< │ │ │ +0001df20: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    tech │ │ │ +0001df70: 6e69 6361 6c6c 792c 2074 6869 7320 6973 nically, this is │ │ │ +0001df80: 2077 6865 7265 2074 6865 2074 7261 6e73 where the trans │ │ │ +0001df90: 6163 7469 6f6e 206f 6620 6d6f 7669 6e67 action of moving │ │ │ +0001dfa0: 2074 6865 2066 696c 6573 0a69 7320 636f the files.is co │ │ │ +0001dfb0: 6d70 6c65 7465 642e 2054 6869 7320 6973 mpleted. This is │ │ │ +0001dfc0: 2077 6865 7265 2074 6865 206e 6577 2073 where the new s │ │ │ +0001dfd0: 6176 655f 7061 7468 2073 686f 756c 6420 ave_path should │ │ │ +0001dfe0: 6265 2063 6f6d 6d69 7474 6564 2e20 4966 be committed. If │ │ │ +0001dff0: 0a74 6865 7265 2069 7320 616e 2065 7272 .there is an err │ │ │ +0001e000: 6f72 2069 6e20 7468 6520 636f 6465 2062 or in the code b │ │ │ +0001e010: 656c 6f77 2c20 7468 6174 2073 686f 756c elow, that shoul │ │ │ +0001e020: 6420 6e6f 7420 7072 6576 656e 7420 7468 d not prevent th │ │ │ +0001e030: 6520 6e65 770a 7361 7665 2070 6174 6820 e new.save path │ │ │ +0001e040: 746f 2062 6520 7365 742e 204d 6179 6265 to be set. Maybe │ │ │ +0001e050: 2069 7420 776f 756c 6420 6d61 6b65 2073 it would make s │ │ │ +0001e060: 656e 7365 2074 6f20 6d61 6b65 2074 6865 ense to make the │ │ │ +0001e070: 2073 6176 655f 7061 7468 0a61 6e20 696e save_path.an in │ │ │ +0001e080: 2d6f 7574 2070 6172 616d 6574 6572 3c2f -out parameter

    ../src/st │ │ │ +0001e0a0: 6f72 6167 655f 7574 696c 732e 6370 703a orage_utils.cpp: │ │ │ +0001e0b0: 3138 373c 2f68 343e 3c70 7265 2073 7479 187

    ...while (--fi
    │ │ │ +0001e100: 6c65 5f69 6e64 6578 2026 6774 3b3d 2066  le_index >= f
    │ │ │ +0001e110: 696c 655f 696e 6465 785f 7428 3029 290a  ile_index_t(0)).
    │ │ │ +0001e120: 0909 097b 0a09 0909 092f 2f20 6669 6c65  ...{.....// file
    │ │ │ +0001e130: 7320 6d6f 7665 6420 6f75 7420 746f 2061  s moved out to a
    │ │ │ +0001e140: 6273 6f6c 7574 6520 7061 7468 7320 6172  bsolute paths ar
    │ │ │ +0001e150: 6520 6e6f 7420 6d6f 7665 640a 0909 0909  e not moved.....
    │ │ │ +0001e160: 6966 2028 662e 6669 6c65 5f61 6273 6f6c  if (f.file_absol
    │ │ │ +0001e170: 7574 655f 7061 7468 2866 696c 655f 696e  ute_path(file_in
    │ │ │ +0001e180: 6465 7829 2920 636f 6e74 696e 7565 3b0a  dex)) continue;.
    │ │ │ +0001e190: 0a09 0909 092f 2f20 6966 2077 6520 656e  .....// if we en
    │ │ │ +0001e1a0: 6465 6420 7570 2063 6f70 7969 6e67 2074  ded up copying t
    │ │ │ +0001e1b0: 6865 2066 696c 652c 2064 6f6e 2774 2064  he file, don't d
    │ │ │ +0001e1c0: 6f20 616e 7974 6869 6e67 2064 7572 696e  o anything durin
    │ │ │ +0001e1d0: 670a 0909 0909 2f2f 2072 6f6c 6c2d 6261  g.....// roll-ba
    │ │ │ +0001e1e0: 636b 0a09 0909 0969 6620 2863 6f70 6965  ck.....if (copie
    │ │ │ +0001e1f0: 645f 6669 6c65 735b 6669 6c65 5f69 6e64  d_files[file_ind
    │ │ │ +0001e200: 6578 5d29 2063 6f6e 7469 6e75 653b 0a0a  ex]) continue;..
    │ │ │ +0001e210: 0909 0909 7374 643a 3a73 7472 696e 6720  ....std::string 
    │ │ │ +0001e220: 636f 6e73 7420 6f6c 645f 7061 7468 203d  const old_path =
    │ │ │ +0001e230: 2063 6f6d 6269 6e65 5f70 6174 6828 7361   combine_path(sa
    │ │ │ +0001e240: 7665 5f70 6174 682c 2066 2e66 696c 655f  ve_path, f.file_
    │ │ │ +0001e250: 7061 7468 2866 696c 655f 696e 6465 7829  path(file_index)
    │ │ │ +0001e260: 293b 0a09 0909 0973 7464 3a3a 7374 7269  );.....std::stri
    │ │ │ +0001e270: 6e67 2063 6f6e 7374 206e 6577 5f70 6174  ng const new_pat
    │ │ │ +0001e280: 6820 3d20 636f 6d62 696e 655f 7061 7468  h = combine_path
    │ │ │ +0001e290: 286e 6577 5f73 6176 655f 7061 7468 2c20  (new_save_path, 
    │ │ │ +0001e2a0: 662e 6669 6c65 5f70 6174 6828 6669 6c65  f.file_path(file
    │ │ │ +0001e2b0: 5f69 6e64 6578 2929 3b0a 0a09 0909 092f  _index));....../
    │ │ │ +0001e2c0: 2f20 6967 6e6f 7265 2065 7272 6f72 7320  / ignore errors 
    │ │ │ +0001e2d0: 7768 656e 2072 6f6c 6c69 6e67 2062 6163  when rolling bac
    │ │ │ +0001e2e0: 6b0a 0909 0909 7374 6f72 6167 655f 6572  k.....storage_er
    │ │ │ +0001e2f0: 726f 7220 6967 6e6f 7265 3b0a 0909 0909  ror ignore;.....
    │ │ │ +0001e300: 6d6f 7665 5f66 696c 6528 6e65 775f 7061  move_file(new_pa
    │ │ │ +0001e310: 7468 2c20 6f6c 645f 7061 7468 2c20 6967  th, old_path, ig
    │ │ │ +0001e320: 6e6f 7265 293b 0a09 0909 7d0a 0a09 0909  nore);....}.....
    │ │ │ +0001e330: 7265 7475 726e 207b 2064 6973 6b5f 7374  return { disk_st
    │ │ │ +0001e340: 6174 7573 3a3a 6661 7461 6c5f 6469 736b  atus::fatal_disk
    │ │ │ +0001e350: 5f65 7272 6f72 2c20 7361 7665 5f70 6174  _error, save_pat
    │ │ │ +0001e360: 6820 7d3b 0a09 097d 0a0a 3c64 6976 2073  h };...}..
    .
    . │ │ │ +0001e3a0: 0973 7464 3a3a 7365 7426 6c74 3b73 7464 .std::set<std │ │ │ +0001e3b0: 3a3a 7374 7269 6e67 2667 743b 2073 7562 ::string> sub │ │ │ +0001e3c0: 6469 7273 3b0a 0909 666f 7220 2861 7574 dirs;...for (aut │ │ │ +0001e3d0: 6f20 636f 6e73 7420 6920 3a20 662e 6669 o const i : f.fi │ │ │ +0001e3e0: 6c65 5f72 616e 6765 2829 290a 0909 7b0a le_range())...{. │ │ │ +0001e3f0: 0909 092f 2f20 6669 6c65 7320 6d6f 7665 ...// files move │ │ │ +0001e400: 6420 6f75 7420 746f 2061 6273 6f6c 7574 d out to absolut │ │ │ +0001e410: 6520 7061 7468 7320 6172 6520 6e6f 7420 e paths are not │ │ │ +0001e420: 6d6f 7665 640a 0909 0969 6620 2866 2e66 moved....if (f.f │ │ │ +0001e430: 696c 655f 6162 736f 6c75 7465 5f70 6174 ile_absolute_pat │ │ │ +0001e440: 6828 6929 2920 636f 6e74 696e 7565 3b0a h(i)) continue;. │ │ │ +0001e450: 0a09 0909 6966 2028 6861 735f 7061 7265 ....if (has_pare │ │ │ +0001e460: 6e74 5f70 6174 6828 662e 6669 6c65 5f70 nt_path(f.file_p │ │ │ +0001e470: 6174 6828 6929 2929 0a09 0909 0973 7562 ath(i))).....sub │ │ │ +0001e480: 6469 7273 2e69 6e73 6572 7428 7061 7265 dirs.insert(pare │ │ │ +0001e490: 6e74 5f70 6174 6828 662e 6669 6c65 5f70 nt_path(f.file_p │ │ │ +0001e4a0: 6174 6828 6929 2929 3b0a 0a09 0909 2f2f ath(i)));.....// │ │ │ +0001e4b0: 2069 6620 7765 2065 6e64 6564 2075 7020 if we ended up │ │ │ +0001e4c0: 7265 6e61 6d69 6e67 2074 6865 2066 696c renaming the fil │ │ │ +0001e4d0: 6520 696e 7374 6561 6420 6f66 206d 6f76 e instead of mov │ │ │ +0001e4e0: 696e 6720 6974 2c20 7468 6572 6527 7320 ing it, there's │ │ │ +0001e4f0: 6e6f 0a09 0909 2f2f 206e 6565 6420 746f no....// need to │ │ │ +0001e500: 2064 656c 6574 6520 7468 6520 736f 7572 delete the sour │ │ │ +0001e510: 6365 2e0a 0909 0969 6620 2863 6f70 6965 ce.....if (copie │ │ │ +0001e520: 645f 6669 6c65 735b 695d 203d 3d20 6661 d_files[i] == fa │ │ │ +0001e530: 6c73 6529 2063 6f6e 7469 6e75 653b 0a0a lse) continue;.. │ │ │ +0001e540: 0909 0973 7464 3a3a 7374 7269 6e67 2063 ...std::string c │ │ │ +0001e550: 6f6e 7374 206f 6c64 5f70 6174 6820 3d20 onst old_path = │ │ │ +0001e560: 636f 6d62 696e 655f 7061 7468 2873 6176 combine_path(sav │ │ │ +0001e570: 655f 7061 7468 2c20 662e 6669 6c65 5f70 e_path, f.file_p │ │ │ +0001e580: 6174 6828 6929 293b 0a0a 0909 092f 2f20 ath(i));.....// │ │ │ +0001e590: 7765 206d 6179 2073 7469 6c6c 2068 6176 we may still hav │ │ │ +0001e5a0: 6520 736f 6d65 2066 696c 6573 2069 6e20 e some files in │ │ │ +0001e5b0: 6f6c 6420 7361 7665 5f70 6174 680a 0909 old save_path... │ │ │ +0001e5c0: 092f 2f20 6567 2e20 6966 2028 666c 6167 .// eg. if (flag │ │ │ +0001e5d0: 7320 3d3d 2064 6f6e 745f 7265 706c 6163 s == dont_replac │ │ │ +0001e5e0: 6520 2661 6d70 3b26 616d 703b 2065 7869 e && exi │ │ │ +0001e5f0: 7374 7328 6e65 775f 7061 7468 2929 0a09 sts(new_path)).. │ │ │ +0001e600: 0909 2f2f 2069 676e 6f72 6520 6572 726f ..// ignore erro │ │ │ +0001e610: 7273 2077 6865 6e20 7265 6d6f 7669 6e67 rs when removing │ │ │ +0001e620: 0a09 0909 6572 726f 725f 636f 6465 2069 ....error_code i │ │ │ +0001e630: 676e 6f72 653b 0a09 0909 7265 6d6f 7665 gnore;....remove │ │ │ +0001e640: 286f 6c64 5f70 6174 682c 2069 676e 6f72 (old_path, ignor │ │ │ +0001e650: 6529 3b0a 0909 7d0a 0a09 0966 6f72 2028 e);...}....for ( │ │ │ +0001e660: 7374 643a 3a73 7472 696e 6720 636f 6e73 std::string cons │ │ │ +0001e670: 7426 616d 703b 2073 203a 2073 7562 6469 t& s : subdi │ │ │ +0001e680: 7273 290a 0909 7b0a 0909 0965 7272 6f72 rs)...{....error │ │ │ +0001e690: 5f63 6f64 6520 6572 723b 0a09 0909 7374 _code err;....st │ │ │ +0001e6a0: 643a 3a73 7472 696e 6720 7375 6264 6972 d::string subdir │ │ │ +0001e6b0: 203d 2063 6f6d 6269 6e65 5f70 6174 6828 = combine_path( │ │ │ +0001e6c0: 7361 7665 5f70 6174 682c 2073 293b 0a0a save_path, s);.. │ │ │ +0001e6d0: 0909 0977 6869 6c65 2028 2170 6174 685f ...while (!path_ │ │ │ +0001e6e0: 6571 7561 6c28 7375 6264 6972 2c20 7361 equal(subdir, sa │ │ │ +0001e6f0: 7665 5f70 6174 6829 2026 616d 703b 2661 ve_path) &&a │ │ │ +0001e700: 6d70 3b20 2165 7272 290a 0909 097b 0a09 mp; !err)....{.. │ │ │ +0001e710: 0909 0972 656d 6f76 6528 7375 6264 6972 ...remove(subdir │ │ │ +0001e720: 2c20 6572 7229 3b0a 3c2f 7072 653e 3c2f , err);.
    relevan │ │ │ +0001e760: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2../src/storage │ │ │ +0001e7a0: 5f75 7469 6c73 2e63 7070 3a33 3739 3c2f _utils.cpp:379is th │ │ │ +0001e7c0: 6973 2072 6973 6b79 3f20 5468 6520 7570 is risky? The up │ │ │ +0001e7d0: 7065 7220 6c61 7965 7220 7769 6c6c 2061 per layer will a │ │ │ +0001e7e0: 7373 756d 6520 7765 2068 6176 6520 7468 ssume we have th │ │ │ +0001e7f0: 6520 7768 6f6c 6520 6669 6c65 2e20 5065 e whole file. Pe │ │ │ +0001e800: 7268 6170 7320 7765 2073 686f 756c 6420 rhaps we should │ │ │ +0001e810: 7665 7269 6679 2074 6861 7420 6174 206c verify that at l │ │ │ +0001e820: 6561 7374 2074 6865 2073 697a 6520 6f66 east the size of │ │ │ +0001e830: 2074 6865 2066 696c 6520 6973 2063 6f72 the file is cor │ │ │ +0001e840: 7265 6374 3c2f 7464 3e3c 2f74 723e 3c74 rect

    is this risky? │ │ │ +0001e8a0: 5468 6520 7570 7065 7220 6c61 7965 7220 The upper layer │ │ │ +0001e8b0: 7769 6c6c 2061 7373 756d 6520 7765 2068 will assume we h │ │ │ +0001e8c0: 6176 6520 7468 650a 7768 6f6c 6520 6669 ave the.whole fi │ │ │ +0001e8d0: 6c65 2e20 5065 7268 6170 7320 7765 2073 le. Perhaps we s │ │ │ +0001e8e0: 686f 756c 6420 7665 7269 6679 2074 6861 hould verify tha │ │ │ +0001e8f0: 7420 6174 206c 6561 7374 2074 6865 2073 t at least the s │ │ │ +0001e900: 697a 650a 6f66 2074 6865 2066 696c 6520 ize.of the file │ │ │ +0001e910: 6973 2063 6f72 7265 6374 3c2f 6832 3e3c is correct

    < │ │ │ +0001e920: 6834 3e2e 2e2f 7372 632f 7374 6f72 6167 h4>../src/storag │ │ │ +0001e930: 655f 7574 696c 732e 6370 703a 3337 393c e_utils.cpp:379< │ │ │ +0001e940: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0001e980: 0909 7b0a 0909 0909 092f 2f20 7765 2063  ..{......// we c
    │ │ │ +0001e990: 7265 6174 6520 6469 7265 6374 6f72 6965  reate directorie
    │ │ │ +0001e9a0: 7320 6c61 7a69 6c79 2c20 736f 2069 7427  s lazily, so it'
    │ │ │ +0001e9b0: 7320 706f 7373 6962 6c65 2069 7420 6861  s possible it ha
    │ │ │ +0001e9c0: 736e 2774 0a09 0909 0909 2f2f 2062 6565  sn't......// bee
    │ │ │ +0001e9d0: 6e20 6372 6561 7465 6420 7965 742e 2043  n created yet. C
    │ │ │ +0001e9e0: 7265 6174 6520 7468 6520 6469 7265 6374  reate the direct
    │ │ │ +0001e9f0: 6f72 6965 7320 6e6f 7720 616e 6420 7472  ories now and tr
    │ │ │ +0001ea00: 790a 0909 0909 092f 2f20 6167 6169 6e0a  y......// again.
    │ │ │ +0001ea10: 0909 0909 0963 7265 6174 655f 6469 7265  .....create_dire
    │ │ │ +0001ea20: 6374 6f72 6965 7328 7061 7265 6e74 5f70  ctories(parent_p
    │ │ │ +0001ea30: 6174 6828 6669 6c65 5f70 6174 6829 2c20  ath(file_path), 
    │ │ │ +0001ea40: 6572 7229 3b0a 0a09 0909 0909 6966 2028  err);.......if (
    │ │ │ +0001ea50: 6572 7229 0a09 0909 0909 7b0a 0909 0909  err)......{.....
    │ │ │ +0001ea60: 0909 6563 2e66 696c 6528 6964 7829 3b0a  ..ec.file(idx);.
    │ │ │ +0001ea70: 0909 0909 0909 6563 2e6f 7065 7261 7469  ......ec.operati
    │ │ │ +0001ea80: 6f6e 203d 206f 7065 7261 7469 6f6e 5f74  on = operation_t
    │ │ │ +0001ea90: 3a3a 6d6b 6469 723b 0a09 0909 0909 0972  ::mkdir;.......r
    │ │ │ +0001eaa0: 6574 7572 6e20 6661 6c73 653b 0a09 0909  eturn false;....
    │ │ │ +0001eab0: 0909 7d0a 0a09 0909 0909 6861 7264 5f6c  ..}.......hard_l
    │ │ │ +0001eac0: 696e 6b28 732c 2066 696c 655f 7061 7468  ink(s, file_path
    │ │ │ +0001ead0: 2c20 6572 7229 3b0a 0909 0909 7d0a 0a09  , err);.....}...
    │ │ │ +0001eae0: 0909 092f 2f20 6966 2074 6865 2066 696c  ...// if the fil
    │ │ │ +0001eaf0: 6520 616c 7265 6164 7920 6578 6973 7473  e already exists
    │ │ │ +0001eb00: 2c20 7468 6174 2773 206e 6f74 2061 6e20  , that's not an 
    │ │ │ +0001eb10: 6572 726f 720a 0909 0909 6966 2028 6572  error.....if (er
    │ │ │ +0001eb20: 7220 3d3d 2062 6f6f 7374 3a3a 7379 7374  r == boost::syst
    │ │ │ +0001eb30: 656d 3a3a 6572 7263 3a3a 6669 6c65 5f65  em::errc::file_e
    │ │ │ +0001eb40: 7869 7374 7329 0a09 0909 0909 636f 6e74  xists)......cont
    │ │ │ +0001eb50: 696e 7565 3b0a 0a3c 6469 7620 7374 796c  inue;..
    ....if (err │ │ │ +0001eb90: 290a 3c2f 6469 763e 0909 0909 7b0a 0909 ).
    ....{... │ │ │ +0001eba0: 0909 0965 632e 6563 203d 2065 7272 3b0a ...ec.ec = err;. │ │ │ +0001ebb0: 0909 0909 0965 632e 6669 6c65 2869 6478 .....ec.file(idx │ │ │ +0001ebc0: 293b 0a09 0909 0909 6563 2e6f 7065 7261 );......ec.opera │ │ │ +0001ebd0: 7469 6f6e 203d 206f 7065 7261 7469 6f6e tion = operation │ │ │ +0001ebe0: 5f74 3a3a 6669 6c65 5f68 6172 645f 6c69 _t::file_hard_li │ │ │ +0001ebf0: 6e6b 3b0a 0909 0909 0972 6574 7572 6e20 nk;......return │ │ │ +0001ec00: 6661 6c73 653b 0a09 0909 097d 0a09 0909 false;.....}.... │ │ │ +0001ec10: 0961 6464 6564 5f66 696c 6573 203d 2074 .added_files = t │ │ │ +0001ec20: 7275 653b 0a09 0909 0973 7461 742e 7365 rue;.....stat.se │ │ │ +0001ec30: 745f 6469 7274 7928 6964 7829 3b0a 0909 t_dirty(idx);... │ │ │ +0001ec40: 097d 0a09 097d 0a23 656e 6469 6620 2f2f .}...}.#endif // │ │ │ +0001ec50: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +0001ec60: 5f4d 5554 4142 4c45 5f54 4f52 5245 4e54 _MUTABLE_TORRENT │ │ │ +0001ec70: 530a 0a09 0962 6f6f 6c20 636f 6e73 7420 S....bool const │ │ │ +0001ec80: 7365 6564 203d 2028 7264 2e68 6176 655f seed = (rd.have_ │ │ │ +0001ec90: 7069 6563 6573 2e73 697a 6528 2920 2667 pieces.size() &g │ │ │ +0001eca0: 743b 3d20 6673 2e6e 756d 5f70 6965 6365 t;= fs.num_piece │ │ │ +0001ecb0: 7328 290a 0909 0926 616d 703b 2661 6d70 s()....&& │ │ │ +0001ecc0: 3b20 7264 2e68 6176 655f 7069 6563 6573 ; rd.have_pieces │ │ │ +0001ecd0: 2e61 6c6c 5f73 6574 2829 290a 0909 097c .all_set())....| │ │ │ +0001ece0: 7c20 2872 642e 666c 6167 7320 2661 6d70 | (rd.flags & │ │ │ +0001ecf0: 3b20 746f 7272 656e 745f 666c 6167 733a ; torrent_flags: │ │ │ +0001ed00: 3a73 6565 645f 6d6f 6465 293b 0a0a 0909 :seed_mode);.... │ │ │ +0001ed10: 6966 2028 7365 6564 290a 0909 7b0a 0909 if (seed)...{... │ │ │ +0001ed20: 0966 6f72 2028 6669 6c65 5f69 6e64 6578 .for (file_index │ │ │ +0001ed30: 5f74 2063 6f6e 7374 2066 696c 655f 696e _t const file_in │ │ │ +0001ed40: 6465 7820 3a20 6673 2e66 696c 655f 7261 dex : fs.file_ra │ │ │ +0001ed50: 6e67 6528 2929 0a09 0909 7b0a 0909 0909 nge())....{..... │ │ │ +0001ed60: 6966 2028 6673 2e70 6164 5f66 696c 655f if (fs.pad_file_ │ │ │ +0001ed70: 6174 2866 696c 655f 696e 6465 7829 2920 at(file_index)) │ │ │ +0001ed80: 636f 6e74 696e 7565 3b0a 0a09 0909 092f continue;....../ │ │ │ +0001ed90: 2f20 6669 6c65 7320 7769 7468 2070 7269 / files with pri │ │ │ +0001eda0: 6f72 6974 7920 7a65 726f 206d 6179 206e ority zero may n │ │ │ +0001edb0: 6f74 2068 6176 6520 6265 656e 2073 6176 ot have been sav │ │ │ +0001edc0: 6564 2074 6f20 6469 736b 2061 7420 7468 ed to disk at th │ │ │ +0001edd0: 6569 720a 0909 0909 2f2f 2065 7870 6563 eir.....// expec │ │ │ +0001ede0: 7465 6420 6c6f 6361 7469 6f6e 2c20 6275 ted location, bu │ │ │ +0001edf0: 7420 6973 206c 696b 656c 7920 746f 2062 t is likely to b │ │ │ +0001ee00: 6520 696e 2061 2070 6172 7466 696c 652e e in a partfile. │ │ │ +0001ee10: 204a 7573 7420 6578 656d 7074 2069 740a Just exempt it. │ │ │ +0001ee20: 0909 0909 2f2f 2066 726f 6d20 6368 6563 ....// from chec │ │ │ +0001ee30: 6b69 6e67 0a09 0909 0969 6620 2866 696c king.....if (fil │ │ │ +0001ee40: 655f 696e 6465 7820 266c 743b 2066 696c e_index < fil │ │ │ +0001ee50: 655f 7072 696f 7269 7479 2e65 6e64 5f69 e_priority.end_i │ │ │ +0001ee60: 6e64 6578 2829 0a09 0909 0909 2661 6d70 ndex()......& │ │ │ +0001ee70: 3b26 616d 703b 2066 696c 655f 7072 696f ;& file_prio │ │ │ +0001ee80: 7269 7479 5b66 696c 655f 696e 6465 785d rity[file_index] │ │ │ +0001ee90: 203d 3d20 646f 6e74 5f64 6f77 6e6c 6f61 == dont_downloa │ │ │ +0001eea0: 640a 0909 0909 0926 616d 703b 2661 6d70 d......&& │ │ │ +0001eeb0: 3b20 2128 7264 2e66 6c61 6773 2026 616d ; !(rd.flags &am │ │ │ +0001eec0: 703b 2074 6f72 7265 6e74 5f66 6c61 6773 p; torrent_flags │ │ │ +0001eed0: 3a3a 7365 6564 5f6d 6f64 6529 290a 0909 ::seed_mode))... │ │ │ +0001eee0: 0909 0963 6f6e 7469 6e75 653b 0a0a 3c2f ...continue;..r │ │ │ +0001ef20: 656c 6576 616e 6365 266e 6273 703b 323c elevance 2< │ │ │ +0001ef30: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>
    ../src/p │ │ │ +0001ef60: 6174 682e 6370 703a 3431 303c 2f61 3e3c ath.cpp:410< │ │ │ +0001ef70: 2f74 643e 3c74 643e 7465 7374 2074 6869 /td>test thi │ │ │ +0001ef80: 7320 6f6e 2061 2046 4154 2076 6f6c 756d s on a FAT volum │ │ │ +0001ef90: 6520 746f 2073 6565 2077 6861 7420 6572 e to see what er │ │ │ +0001efa0: 726f 7220 7765 2067 6574 213c 2f74 643e ror we get! │ │ │ +0001efb0: 3c2f 7472 3e3c 7472 2069 643d 2236 3122

    test thi │ │ │ +0001f000: 7320 6f6e 2061 2046 4154 2076 6f6c 756d s on a FAT volum │ │ │ +0001f010: 6520 746f 2073 6565 2077 6861 7420 6572 e to see what er │ │ │ +0001f020: 726f 7220 7765 2067 6574 213c 2f68 323e ror we get!

    │ │ │ +0001f030: 3c68 343e 2e2e 2f73 7263 2f70 6174 682e

    ../src/path. │ │ │ +0001f040: 6370 703a 3431 303c 2f68 343e 3c70 7265 cpp:410

    ...// it's
    │ │ │ +0001f090: 2070 6f73 7369 626c 6520 4372 6561 7465   possible Create
    │ │ │ +0001f0a0: 4861 7264 4c69 6e6b 2077 696c 6c20 636f  HardLink will co
    │ │ │ +0001f0b0: 7079 2074 6865 2066 696c 6520 696e 7465  py the file inte
    │ │ │ +0001f0c0: 726e 616c 6c79 2074 6f6f 2c0a 0909 092f  rnally too,..../
    │ │ │ +0001f0d0: 2f20 6966 2074 6865 2066 696c 6573 7973  / if the filesys
    │ │ │ +0001f0e0: 7465 6d20 646f 6573 206e 6f74 2073 7570  tem does not sup
    │ │ │ +0001f0f0: 706f 7274 2069 742e 0a09 0909 6563 2e61  port it.....ec.a
    │ │ │ +0001f100: 7373 6967 6e28 4765 744c 6173 7445 7272  ssign(GetLastErr
    │ │ │ +0001f110: 6f72 2829 2c20 7379 7374 656d 5f63 6174  or(), system_cat
    │ │ │ +0001f120: 6567 6f72 7928 2929 3b0a 0909 0972 6574  egory());....ret
    │ │ │ +0001f130: 7572 6e3b 0a09 097d 0a0a 0909 2f2f 2066  urn;...}....// f
    │ │ │ +0001f140: 616c 6c20 6261 636b 2074 6f20 6d61 6b69  all back to maki
    │ │ │ +0001f150: 6e67 2061 2063 6f70 790a 2365 6e64 6966  ng a copy.#endif
    │ │ │ +0001f160: 0a23 656c 7365 0a09 092f 2f20 6173 7375  .#else...// assu
    │ │ │ +0001f170: 6d65 2070 6f73 6978 2773 206c 696e 6b28  me posix's link(
    │ │ │ +0001f180: 2920 6675 6e63 7469 6f6e 2065 7869 7374  ) function exist
    │ │ │ +0001f190: 730a 0909 696e 7420 7265 7420 3d20 3a3a  s...int ret = ::
    │ │ │ +0001f1a0: 6c69 6e6b 286e 5f65 7869 7374 2e63 5f73  link(n_exist.c_s
    │ │ │ +0001f1b0: 7472 2829 2c20 6e5f 6c69 6e6b 2e63 5f73  tr(), n_link.c_s
    │ │ │ +0001f1c0: 7472 2829 293b 0a0a 0909 6966 2028 7265  tr());....if (re
    │ │ │ +0001f1d0: 7420 3d3d 2030 290a 0909 7b0a 0909 0965  t == 0)...{....e
    │ │ │ +0001f1e0: 632e 636c 6561 7228 293b 0a09 0909 7265  c.clear();....re
    │ │ │ +0001f1f0: 7475 726e 3b0a 0909 7d0a 0a09 092f 2f20  turn;...}....// 
    │ │ │ +0001f200: 6d6f 7374 2065 7272 6f72 7320 6172 6520  most errors are 
    │ │ │ +0001f210: 7061 7373 6564 2074 6872 6f75 6768 2c20  passed through, 
    │ │ │ +0001f220: 6578 6365 7074 2066 6f72 2074 6865 206f  except for the o
    │ │ │ +0001f230: 6e65 7320 7468 6174 2069 6e64 6963 6174  nes that indicat
    │ │ │ +0001f240: 6520 7468 6174 0a09 092f 2f20 6861 7264  e that...// hard
    │ │ │ +0001f250: 206c 696e 6b73 2061 7265 206e 6f74 2073   links are not s
    │ │ │ +0001f260: 7570 706f 7274 6564 2061 6e64 2072 6571  upported and req
    │ │ │ +0001f270: 7569 7265 2061 2063 6f70 792e 0a3c 6469  uire a copy....if 
    │ │ │ +0001f2b0: 2865 7272 6e6f 2021 3d20 454d 4c49 4e4b  (errno != EMLINK
    │ │ │ +0001f2c0: 0a3c 2f64 6976 3e09 0909 2661 6d70 3b26  .
    ...&& │ │ │ +0001f2d0: 616d 703b 2065 7272 6e6f 2021 3d20 4558 amp; errno != EX │ │ │ +0001f2e0: 4445 560a 2369 6664 6566 2054 4f52 5245 DEV.#ifdef TORRE │ │ │ +0001f2f0: 4e54 5f42 454f 530a 0909 092f 2f20 6861 NT_BEOS....// ha │ │ │ +0001f300: 696b 7520 7265 7475 726e 7320 4550 4552 iku returns EPER │ │ │ +0001f310: 4d20 7768 656e 2074 6865 2066 696c 6573 M when the files │ │ │ +0001f320: 7973 7465 6d20 646f 6573 6e27 7420 7375 ystem doesn't su │ │ │ +0001f330: 7070 6f72 7420 6861 7264 206c 696e 6b0a pport hard link. │ │ │ +0001f340: 0909 0926 616d 703b 2661 6d70 3b20 6572 ...&& er │ │ │ +0001f350: 726e 6f20 213d 2045 5045 524d 0a23 656e rno != EPERM.#en │ │ │ +0001f360: 6469 660a 0909 0929 0a09 097b 0a09 0909 dif....)...{.... │ │ │ +0001f370: 2f2f 2073 6f6d 6520 6572 726f 7220 6861 // some error ha │ │ │ +0001f380: 7070 656e 6564 2c20 7265 706f 7274 2075 ppened, report u │ │ │ +0001f390: 7020 746f 2074 6865 2063 616c 6c65 720a p to the caller. │ │ │ +0001f3a0: 0909 0965 632e 6173 7369 676e 2865 7272 ...ec.assign(err │ │ │ +0001f3b0: 6e6f 2c20 7379 7374 656d 5f63 6174 6567 no, system_categ │ │ │ +0001f3c0: 6f72 7928 2929 3b0a 0909 0972 6574 7572 ory());....retur │ │ │ +0001f3d0: 6e3b 0a09 097d 0a0a 0909 2f2f 2066 616c n;...}....// fal │ │ │ +0001f3e0: 6c20 6261 636b 2074 6f20 6d61 6b69 6e67 l back to making │ │ │ +0001f3f0: 2061 2063 6f70 790a 0a23 656e 6469 660a a copy..#endif. │ │ │ +0001f400: 0a09 092f 2f20 6966 2077 6520 6765 7420 ...// if we get │ │ │ +0001f410: 6865 7265 2c20 7765 2073 686f 756c 6420 here, we should │ │ │ +0001f420: 636f 7079 2074 6865 2066 696c 650a 0909 copy the file... │ │ │ +0001f430: 7374 6f72 6167 655f 6572 726f 7220 7365 storage_error se │ │ │ +0001f440: 3b0a 0909 6175 783a 3a63 6f70 795f 6669 ;...aux::copy_fi │ │ │ +0001f450: 6c65 2866 696c 652c 206c 696e 6b2c 2073 le(file, link, s │ │ │ +0001f460: 6529 3b0a 0909 6563 203d 2073 652e 6563 e);...ec = se.ec │ │ │ +0001f470: 3b0a 097d 0a0a 0962 6f6f 6c20 6973 5f64 ;..}...bool is_d │ │ │ +0001f480: 6972 6563 746f 7279 2873 7464 3a3a 7374 irectory(std::st │ │ │ +0001f490: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ +0001f4a0: 662c 2065 7272 6f72 5f63 6f64 6526 616d f, error_code&am │ │ │ +0001f4b0: 703b 2065 6329 0a09 7b0a 0909 6563 2e63 p; ec)..{...ec.c │ │ │ +0001f4c0: 6c65 6172 2829 3b0a 0909 6572 726f 725f lear();...error_ │ │ │ +0001f4d0: 636f 6465 2065 3b0a 0909 6669 6c65 5f73 code e;...file_s │ │ │ +0001f4e0: 7461 7475 7320 733b 0a09 0973 7461 745f tatus s;...stat_ │ │ │ +0001f4f0: 6669 6c65 2866 2c20 2661 6d70 3b73 2c20 file(f, &s, │ │ │ +0001f500: 6529 3b0a 0909 6966 2028 2165 2026 616d e);...if (!e &am │ │ │ +0001f510: 703b 2661 6d70 3b20 732e 6d6f 6465 2026 p;& s.mode & │ │ │ +0001f520: 616d 703b 2066 696c 655f 7374 6174 7573 amp; file_status │ │ │ +0001f530: 3a3a 6469 7265 6374 6f72 7929 2072 6574 ::directory) ret │ │ │ +0001f540: 7572 6e20 7472 7565 3b0a 0909 6563 203d urn true;...ec = │ │ │ +0001f550: 2065 3b0a 3c2f 7072 653e 3c2f 7464 3e3c e;.
    < │ │ │ +0001f560: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0001f590: 6273 703b 323c 2f74 643e 3c74 643e 3c61 bsp;2.. │ │ │ +0001f5c0: 2f73 7263 2f68 7474 705f 7472 6163 6b65 /src/http_tracke │ │ │ +0001f5d0: 725f 636f 6e6e 6563 7469 6f6e 2e63 7070 r_connection.cpp │ │ │ +0001f5e0: 3a34 3639 3c2f 613e 3c2f 7464 3e3c 7464 :469returning a boo │ │ │ +0001f600: 6c20 6865 7265 2069 7320 7265 6475 6e64 l here is redund │ │ │ +0001f610: 616e 742e 2049 6e73 7465 6164 2074 6869 ant. Instead thi │ │ │ +0001f620: 7320 6675 6e63 7469 6f6e 2073 686f 756c s function shoul │ │ │ +0001f630: 6420 7265 7475 726e 2074 6865 2070 6565 d return the pee │ │ │ +0001f640: 725f 656e 7472 793c 2f74 643e 3c2f 7472 r_entry │ │ │ +0001f680: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0001f690: 3c68 323e 7265 7475 726e 696e 6720 6120

    returning a │ │ │ +0001f6a0: 626f 6f6c 2068 6572 6520 6973 2072 6564 bool here is red │ │ │ +0001f6b0: 756e 6461 6e74 2e20 496e 7374 6561 6420 undant. Instead │ │ │ +0001f6c0: 7468 6973 2066 756e 6374 696f 6e20 7368 this function sh │ │ │ +0001f6d0: 6f75 6c64 0a72 6574 7572 6e20 7468 6520 ould.return the │ │ │ +0001f6e0: 7065 6572 5f65 6e74 7279 3c2f 6832 3e3c peer_entry

    < │ │ │ +0001f6f0: 6834 3e2e 2e2f 7372 632f 6874 7470 5f74 h4>../src/http_t │ │ │ +0001f700: 7261 636b 6572 5f63 6f6e 6e65 6374 696f racker_connectio │ │ │ +0001f710: 6e2e 6370 703a 3436 393c 2f68 343e 3c70 n.cpp:469

    ..{....c │ │ │ +0001f760: 622d 2667 743b 7472 6163 6b65 725f 7363 b->tracker_sc │ │ │ +0001f770: 7261 7065 5f72 6573 706f 6e73 6528 7472 rape_response(tr │ │ │ +0001f780: 6163 6b65 725f 7265 7128 292c 2072 6573 acker_req(), res │ │ │ +0001f790: 702e 636f 6d70 6c65 7465 0a09 0909 092c p.complete....., │ │ │ +0001f7a0: 2072 6573 702e 696e 636f 6d70 6c65 7465 resp.incomplete │ │ │ +0001f7b0: 2c20 7265 7370 2e64 6f77 6e6c 6f61 6465 , resp.downloade │ │ │ +0001f7c0: 642c 2072 6573 702e 646f 776e 6c6f 6164 d, resp.download │ │ │ +0001f7d0: 6572 7329 3b0a 0909 7d0a 0909 656c 7365 ers);...}...else │ │ │ +0001f7e0: 0a09 097b 0a09 0909 7374 643a 3a6c 6973 ...{....std::lis │ │ │ +0001f7f0: 7426 6c74 3b61 6464 7265 7373 2667 743b t<address> │ │ │ +0001f800: 2069 705f 6c69 7374 3b0a 0909 0969 6620 ip_list;....if │ │ │ +0001f810: 286d 5f74 7261 636b 6572 5f63 6f6e 6e65 (m_tracker_conne │ │ │ +0001f820: 6374 696f 6e29 0a09 0909 7b0a 0909 0909 ction)....{..... │ │ │ +0001f830: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ +0001f840: 616d 703b 2065 6e64 7020 3a20 6d5f 7472 amp; endp : m_tr │ │ │ +0001f850: 6163 6b65 725f 636f 6e6e 6563 7469 6f6e acker_connection │ │ │ +0001f860: 2d26 6774 3b65 6e64 706f 696e 7473 2829 ->endpoints() │ │ │ +0001f870: 290a 0909 0909 7b0a 0909 0909 0969 705f ).....{......ip_ │ │ │ +0001f880: 6c69 7374 2e70 7573 685f 6261 636b 2865 list.push_back(e │ │ │ +0001f890: 6e64 702e 6164 6472 6573 7328 2929 3b0a ndp.address());. │ │ │ +0001f8a0: 0909 0909 7d0a 0909 097d 0a0a 0909 0963 ....}....}.....c │ │ │ +0001f8b0: 622d 2667 743b 7472 6163 6b65 725f 7265 b->tracker_re │ │ │ +0001f8c0: 7370 6f6e 7365 2874 7261 636b 6572 5f72 sponse(tracker_r │ │ │ +0001f8d0: 6571 2829 2c20 6d5f 7472 6163 6b65 725f eq(), m_tracker_ │ │ │ +0001f8e0: 6970 2c20 6970 5f6c 6973 742c 2072 6573 ip, ip_list, res │ │ │ +0001f8f0: 7029 3b0a 0909 7d0a 0909 636c 6f73 6528 p);...}...close( │ │ │ +0001f900: 293b 0a09 7d0a 0a3c 6469 7620 7374 796c );..}..

    .bool extra │ │ │ +0001f940: 6374 5f70 6565 725f 696e 666f 2862 6465 ct_peer_info(bde │ │ │ +0001f950: 636f 6465 5f6e 6f64 6520 636f 6e73 7426 code_node const& │ │ │ +0001f960: 616d 703b 2069 6e66 6f2c 2070 6565 725f amp; info, peer_ │ │ │ +0001f970: 656e 7472 7926 616d 703b 2072 6574 2c20 entry& ret, │ │ │ +0001f980: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ +0001f990: 6563 290a 3c2f 6469 763e 097b 0a09 092f ec).
    .{.../ │ │ │ +0001f9a0: 2f20 6578 7472 6163 7420 7065 6572 2069 / extract peer i │ │ │ +0001f9b0: 6420 2869 6620 616e 7929 0a09 0969 6620 d (if any)...if │ │ │ +0001f9c0: 2869 6e66 6f2e 7479 7065 2829 2021 3d20 (info.type() != │ │ │ +0001f9d0: 6264 6563 6f64 655f 6e6f 6465 3a3a 6469 bdecode_node::di │ │ │ +0001f9e0: 6374 5f74 290a 0909 7b0a 0909 0965 6320 ct_t)...{....ec │ │ │ +0001f9f0: 3d20 6572 726f 7273 3a3a 696e 7661 6c69 = errors::invali │ │ │ +0001fa00: 645f 7065 6572 5f64 6963 743b 0a09 0909 d_peer_dict;.... │ │ │ +0001fa10: 7265 7475 726e 2066 616c 7365 3b0a 0909 return false;... │ │ │ +0001fa20: 7d0a 0909 6264 6563 6f64 655f 6e6f 6465 }...bdecode_node │ │ │ +0001fa30: 2069 203d 2069 6e66 6f2e 6469 6374 5f66 i = info.dict_f │ │ │ +0001fa40: 696e 645f 7374 7269 6e67 2822 7065 6572 ind_string("peer │ │ │ +0001fa50: 2069 6422 293b 0a09 0969 6620 2869 2026 id");...if (i & │ │ │ +0001fa60: 616d 703b 2661 6d70 3b20 692e 7374 7269 amp;& i.stri │ │ │ +0001fa70: 6e67 5f6c 656e 6774 6828 2920 3d3d 2032 ng_length() == 2 │ │ │ +0001fa80: 3029 0a09 097b 0a09 0909 7374 643a 3a63 0)...{....std::c │ │ │ +0001fa90: 6f70 7928 692e 7374 7269 6e67 5f70 7472 opy(i.string_ptr │ │ │ +0001faa0: 2829 2c20 692e 7374 7269 6e67 5f70 7472 (), i.string_ptr │ │ │ +0001fab0: 2829 202b 2032 302c 2072 6574 2e70 6964 () + 20, ret.pid │ │ │ +0001fac0: 2e62 6567 696e 2829 293b 0a09 097d 0a09 .begin());...}.. │ │ │ +0001fad0: 0965 6c73 650a 0909 7b0a 0909 092f 2f20 .else...{....// │ │ │ +0001fae0: 6966 2074 6865 7265 2773 206e 6f20 7065 if there's no pe │ │ │ +0001faf0: 6572 5f69 642c 206a 7573 7420 696e 6974 er_id, just init │ │ │ +0001fb00: 6961 6c69 7a65 2069 7420 746f 2061 2062 ialize it to a b │ │ │ +0001fb10: 756e 6368 206f 6620 7a65 726f 6573 0a09 unch of zeroes.. │ │ │ +0001fb20: 0909 7265 742e 7069 642e 636c 6561 7228 ..ret.pid.clear( │ │ │ +0001fb30: 293b 0a09 097d 0a0a 0909 2f2f 2065 7874 );...}....// ext │ │ │ +0001fb40: 7261 6374 2069 700a 0909 6920 3d20 696e ract ip...i = in │ │ │ +0001fb50: 666f 2e64 6963 745f 6669 6e64 5f73 7472 fo.dict_find_str │ │ │ +0001fb60: 696e 6728 2269 7022 293b 0a09 0969 6620 ing("ip");...if │ │ │ +0001fb70: 2821 6929 0a09 097b 0a09 0909 6563 203d (!i)...{....ec = │ │ │ +0001fb80: 2065 7272 6f72 733a 3a69 6e76 616c 6964 errors::invalid │ │ │ +0001fb90: 5f74 7261 636b 6572 5f72 6573 706f 6e73 _tracker_respons │ │ │ +0001fba0: 653b 0a09 0909 7265 7475 726e 2066 616c e;....return fal │ │ │ +0001fbb0: 7365 3b0a 0909 7d0a 0909 7265 742e 686f se;...}...ret.ho │ │ │ +0001fbc0: 7374 6e61 6d65 203d 2069 2e73 7472 696e stname = i.strin │ │ │ +0001fbd0: 675f 7661 6c75 6528 293b 0a0a 0909 2f2f g_value();....// │ │ │ +0001fbe0: 2065 7874 7261 6374 2070 6f72 740a 0909 extract port... │ │ │ +0001fbf0: 6920 3d20 696e 666f 2e64 6963 745f 6669 i = info.dict_fi │ │ │ +0001fc00: 6e64 5f69 6e74 2822 706f 7274 2229 3b0a nd_int("port");. │ │ │ +0001fc10: 0909 6966 2028 2169 290a 3c2f 7072 653e ..if (!i).
    │ │ │ +0001fc20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0001fc50: 616e 6365 266e 6273 703b 323c 2f74 643e ance 2 │ │ │ +0001fc60: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/insta │ │ │ +0001fc90: 6e74 6961 7465 5f63 6f6e 6e65 6374 696f ntiate_connectio │ │ │ +0001fca0: 6e2e 6370 703a 3231 3c2f 613e 3c2f 7464 n.cpp:21peer_connec │ │ │ +0001fcc0: 7469 6f6e 2061 6e64 2074 7261 636b 6572 tion and tracker │ │ │ +0001fcd0: 5f63 6f6e 6e65 6374 696f 6e20 7368 6f75 _connection shou │ │ │ +0001fce0: 6c64 2070 726f 6261 626c 7920 6265 2066 ld probably be f │ │ │ +0001fcf0: 6c61 6773 3c2f 7464 3e3c 2f74 723e 3c74 lags

    peer_connection │ │ │ +0001fd50: 2061 6e64 2074 7261 636b 6572 5f63 6f6e and tracker_con │ │ │ +0001fd60: 6e65 6374 696f 6e20 7368 6f75 6c64 2070 nection should p │ │ │ +0001fd70: 726f 6261 626c 7920 6265 2066 6c61 6773 robably be flags │ │ │ +0001fd80: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0001fd90: 696e 7374 616e 7469 6174 655f 636f 6e6e instantiate_conn │ │ │ +0001fda0: 6563 7469 6f6e 2e63 7070 3a32 313c 2f68 ection.cpp:21
    /*..
    │ │ │ +0001fdf0: 436f 7079 7269 6768 7420 2863 2920 3230  Copyright (c) 20
    │ │ │ +0001fe00: 3037 2c20 3230 3130 2d32 3031 312c 2032  07, 2010-2011, 2
    │ │ │ +0001fe10: 3031 342d 3230 3231 2c20 4172 7669 6420  014-2021, Arvid 
    │ │ │ +0001fe20: 4e6f 7262 6572 670a 436f 7079 7269 6768  Norberg.Copyrigh
    │ │ │ +0001fe30: 7420 2863 2920 3230 3138 2c20 3230 3231  t (c) 2018, 2021
    │ │ │ +0001fe40: 2c20 416c 6465 6e20 546f 7272 6573 0a43  , Alden Torres.C
    │ │ │ +0001fe50: 6f70 7972 6967 6874 2028 6329 2032 3032  opyright (c) 202
    │ │ │ +0001fe60: 302c 2050 6175 6c2d 4c6f 7569 7320 4167  0, Paul-Louis Ag
    │ │ │ +0001fe70: 656e 6561 750a 416c 6c20 7269 6768 7473  eneau.All rights
    │ │ │ +0001fe80: 2072 6573 6572 7665 642e 0a0a 596f 7520   reserved...You 
    │ │ │ +0001fe90: 6d61 7920 7573 652c 2064 6973 7472 6962  may use, distrib
    │ │ │ +0001fea0: 7574 6520 616e 6420 6d6f 6469 6679 2074  ute and modify t
    │ │ │ +0001feb0: 6869 7320 636f 6465 2075 6e64 6572 2074  his code under t
    │ │ │ +0001fec0: 6865 2074 6572 6d73 206f 6620 7468 6520  he terms of the 
    │ │ │ +0001fed0: 4253 4420 6c69 6365 6e73 652c 0a73 6565  BSD license,.see
    │ │ │ +0001fee0: 204c 4943 454e 5345 2066 696c 652e 0a2a   LICENSE file..*
    │ │ │ +0001fef0: 2f0a 0a23 696e 636c 7564 6520 226c 6962  /..#include "lib
    │ │ │ +0001ff00: 746f 7272 656e 742f 736f 636b 6574 2e68  torrent/socket.h
    │ │ │ +0001ff10: 7070 220a 2369 6e63 6c75 6465 2022 6c69  pp".#include "li
    │ │ │ +0001ff20: 6274 6f72 7265 6e74 2f61 7578 5f2f 736f  btorrent/aux_/so
    │ │ │ +0001ff30: 636b 6574 5f74 7970 652e 6870 7022 0a23  cket_type.hpp".#
    │ │ │ +0001ff40: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +0001ff50: 656e 742f 6175 785f 2f75 7470 5f73 6f63  ent/aux_/utp_soc
    │ │ │ +0001ff60: 6b65 745f 6d61 6e61 6765 722e 6870 7022  ket_manager.hpp"
    │ │ │ +0001ff70: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ +0001ff80: 7272 656e 742f 6175 785f 2f69 6e73 7461  rrent/aux_/insta
    │ │ │ +0001ff90: 6e74 6961 7465 5f63 6f6e 6e65 6374 696f  ntiate_connectio
    │ │ │ +0001ffa0: 6e2e 6870 7022 0a23 696e 636c 7564 6520  n.hpp".#include 
    │ │ │ +0001ffb0: 226c 6962 746f 7272 656e 742f 6175 785f  "libtorrent/aux_
    │ │ │ +0001ffc0: 2f75 7470 5f73 7472 6561 6d2e 6870 7022  /utp_stream.hpp"
    │ │ │ +0001ffd0: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ +0001ffe0: 7272 656e 742f 6175 785f 2f73 736c 5f73  rrent/aux_/ssl_s
    │ │ │ +0001fff0: 7472 6561 6d2e 6870 7022 0a0a 6e61 6d65  tream.hpp"..name
    │ │ │ +00020000: 7370 6163 6520 6c69 6274 6f72 7265 6e74  space libtorrent
    │ │ │ +00020010: 3a3a 6175 7820 7b0a 0a3c 6469 7620 7374  ::aux {..
    .aux::soc │ │ │ +00020050: 6b65 745f 7479 7065 2069 6e73 7461 6e74 ket_type instant │ │ │ +00020060: 6961 7465 5f63 6f6e 6e65 6374 696f 6e28 iate_connection( │ │ │ +00020070: 696f 5f63 6f6e 7465 7874 2661 6d70 3b20 io_context& │ │ │ +00020080: 696f 730a 3c2f 6469 763e 0909 2c20 6175 ios.
    .., au │ │ │ +00020090: 783a 3a70 726f 7879 5f73 6574 7469 6e67 x::proxy_setting │ │ │ +000200a0: 7320 636f 6e73 7426 616d 703b 2070 730a s const& ps. │ │ │ +000200b0: 0909 2c20 766f 6964 2a20 7373 6c5f 636f .., void* ssl_co │ │ │ +000200c0: 6e74 6578 740a 0909 2c20 7574 705f 736f ntext..., utp_so │ │ │ +000200d0: 636b 6574 5f6d 616e 6167 6572 2a20 736d cket_manager* sm │ │ │ +000200e0: 0a09 092c 2062 6f6f 6c20 7065 6572 5f63 ..., bool peer_c │ │ │ +000200f0: 6f6e 6e65 6374 696f 6e0a 0909 2c20 626f onnection..., bo │ │ │ +00020100: 6f6c 2074 7261 636b 6572 5f63 6f6e 6e65 ol tracker_conne │ │ │ +00020110: 6374 696f 6e29 0a09 7b0a 2369 6620 2154 ction)..{.#if !T │ │ │ +00020120: 4f52 5245 4e54 5f55 5345 5f53 534c 0a09 ORRENT_USE_SSL.. │ │ │ +00020130: 0954 4f52 5245 4e54 5f55 4e55 5345 4428 .TORRENT_UNUSED( │ │ │ +00020140: 7373 6c5f 636f 6e74 6578 7429 3b0a 2365 ssl_context);.#e │ │ │ +00020150: 6e64 6966 0a0a 0909 6966 2028 736d 290a ndif....if (sm). │ │ │ +00020160: 0909 7b0a 2369 6620 544f 5252 454e 545f ..{.#if TORRENT_ │ │ │ +00020170: 5553 455f 5353 4c0a 0909 0969 6620 2873 USE_SSL....if (s │ │ │ +00020180: 736c 5f63 6f6e 7465 7874 290a 0909 097b sl_context)....{ │ │ │ +00020190: 0a09 0909 0973 736c 5f73 7472 6561 6d26 .....ssl_stream& │ │ │ +000201a0: 6c74 3b75 7470 5f73 7472 6561 6d26 6774 lt;utp_stream> │ │ │ +000201b0: 3b20 7328 696f 732c 202a 7374 6174 6963 ; s(ios, *static │ │ │ +000201c0: 5f63 6173 7426 6c74 3b73 736c 3a3a 636f _cast<ssl::co │ │ │ +000201d0: 6e74 6578 742a 2667 743b 2873 736c 5f63 ntext*>(ssl_c │ │ │ +000201e0: 6f6e 7465 7874 2929 3b0a 0909 0909 732e ontext));.....s. │ │ │ +000201f0: 6e65 7874 5f6c 6179 6572 2829 2e73 6574 next_layer().set │ │ │ +00020200: 5f69 6d70 6c28 736d 2d26 6774 3b6e 6577 _impl(sm->new │ │ │ +00020210: 5f75 7470 5f73 6f63 6b65 7428 2661 6d70 _utp_socket(& │ │ │ +00020220: 3b73 2e6e 6578 745f 6c61 7965 7228 2929 ;s.next_layer()) │ │ │ +00020230: 293b 0a09 0909 0972 6574 7572 6e20 736f );.....return so │ │ │ +00020240: 636b 6574 5f74 7970 6528 7374 643a 3a6d cket_type(std::m │ │ │ +00020250: 6f76 6528 7329 293b 0a09 0909 7d0a 0909 ove(s));....}... │ │ │ +00020260: 0965 6c73 650a 2365 6e64 6966 0a09 0909 .else.#endif.... │ │ │ +00020270: 7b0a 0909 0909 7574 705f 7374 7265 616d {.....utp_stream │ │ │ +00020280: 2073 2869 6f73 293b 0a09 0909 0973 2e73 s(ios);.....s.s │ │ │ +00020290: 6574 5f69 6d70 6c28 736d 2d26 6774 3b6e et_impl(sm->n │ │ │ +000202a0: 6577 5f75 7470 5f73 6f63 6b65 7428 2661 ew_utp_socket(&a │ │ │ +000202b0: 6d70 3b73 2929 3b0a 0909 0909 7265 7475 mp;s));.....retu │ │ │ +000202c0: 726e 2073 6f63 6b65 745f 7479 7065 2873 rn socket_type(s │ │ │ +000202d0: 7464 3a3a 6d6f 7665 2873 2929 3b0a 0909 td::move(s));... │ │ │ +000202e0: 097d 0a09 097d 0a23 6966 2054 4f52 5245 .}...}.#if TORRE │ │ │ +000202f0: 4e54 5f55 5345 5f49 3250 0a09 0965 6c73 NT_USE_I2P...els │ │ │ +00020300: 6520 6966 2028 7073 2e74 7970 6520 3d3d e if (ps.type == │ │ │ +00020310: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ +00020320: 6932 705f 7072 6f78 7929 0a09 097b 0a3c i2p_proxy)...{.< │ │ │ +00020330: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00020340: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00020350: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +00020360: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +00020370: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ +000203a0: 616c 6572 745f 6d61 6e61 6765 722e 6370 alert_manager.cp │ │ │ +000203b0: 703a 3532 3c2f 613e 3c2f 7464 3e3c 7464 p:52keep a count of │ │ │ +000203d0: 2074 6865 206e 756d 6265 7220 6f66 2074 the number of t │ │ │ +000203e0: 6872 6561 6473 2077 6169 7469 6e67 2e20 hreads waiting. │ │ │ +000203f0: 4f6e 6c79 2069 6620 6974 2773 203e 2030 Only if it's > 0 │ │ │ +00020400: 206e 6f74 6966 7920 7468 656d 3c2f 7464 notify them

    keep a │ │ │ +00020460: 636f 756e 7420 6f66 2074 6865 206e 756d count of the num │ │ │ +00020470: 6265 7220 6f66 2074 6872 6561 6473 2077 ber of threads w │ │ │ +00020480: 6169 7469 6e67 2e20 4f6e 6c79 2069 6620 aiting. Only if │ │ │ +00020490: 6974 2773 0a3e 2030 206e 6f74 6966 7920 it's.> 0 notify │ │ │ +000204a0: 7468 656d 3c2f 6832 3e3c 6834 3e2e 2e2f them

    ../ │ │ │ +000204b0: 7372 632f 616c 6572 745f 6d61 6e61 6765 src/alert_manage │ │ │ +000204c0: 722e 6370 703a 3532 3c2f 6834 3e3c 7072 r.cpp:52

    .{...std: │ │ │ +00020510: 3a75 6e69 7175 655f 6c6f 636b 266c 743b :unique_lock< │ │ │ +00020520: 7374 643a 3a72 6563 7572 7369 7665 5f6d std::recursive_m │ │ │ +00020530: 7574 6578 2667 743b 206c 6f63 6b28 6d5f utex> lock(m_ │ │ │ +00020540: 6d75 7465 7829 3b0a 0a09 0969 6620 2821 mutex);....if (! │ │ │ +00020550: 6d5f 616c 6572 7473 5b6d 5f67 656e 6572 m_alerts[m_gener │ │ │ +00020560: 6174 696f 6e20 2661 6d70 3b20 315d 2e65 ation & 1].e │ │ │ +00020570: 6d70 7479 2829 2920 7265 7475 726e 2074 mpty()) return t │ │ │ +00020580: 7275 653b 0a0a 0909 2f2f 2074 6869 7320 rue;....// this │ │ │ +00020590: 6361 6c6c 2063 616e 2062 6520 696e 7465 call can be inte │ │ │ +000205a0: 7272 7570 7465 6420 7072 656d 6174 7572 rrupted prematur │ │ │ +000205b0: 656c 7920 6279 206f 7468 6572 2073 6967 ely by other sig │ │ │ +000205c0: 6e61 6c73 0a09 096d 5f63 6f6e 6469 7469 nals...m_conditi │ │ │ +000205d0: 6f6e 2e77 6169 745f 666f 7228 6c6f 636b on.wait_for(lock │ │ │ +000205e0: 2c20 6d61 785f 7761 6974 293b 0a09 0972 , max_wait);...r │ │ │ +000205f0: 6574 7572 6e20 216d 5f61 6c65 7274 735b eturn !m_alerts[ │ │ │ +00020600: 6d5f 6765 6e65 7261 7469 6f6e 2026 616d m_generation &am │ │ │ +00020610: 703b 2031 5d2e 656d 7074 7928 293b 0a09 p; 1].empty();.. │ │ │ +00020620: 7d0a 0a09 766f 6964 2061 6c65 7274 5f6d }...void alert_m │ │ │ +00020630: 616e 6167 6572 3a3a 6d61 7962 655f 6e6f anager::maybe_no │ │ │ +00020640: 7469 6679 2861 6c65 7274 2a20 6129 0a09 tify(alert* a).. │ │ │ +00020650: 7b0a 0909 6966 2028 6d5f 616c 6572 7473 {...if (m_alerts │ │ │ +00020660: 5b6d 5f67 656e 6572 6174 696f 6e20 2661 [m_generation &a │ │ │ +00020670: 6d70 3b20 315d 2e73 697a 6528 2920 3d3d mp; 1].size() == │ │ │ +00020680: 2031 290a 0909 7b0a 0909 092f 2f20 7765 1)...{....// we │ │ │ +00020690: 206a 7573 7420 706f 7374 6564 2074 6f20 just posted to │ │ │ +000206a0: 616e 2065 6d70 7479 2071 7565 7565 2e20 an empty queue. │ │ │ +000206b0: 4966 2061 6e79 6f6e 6520 6973 2077 6169 If anyone is wai │ │ │ +000206c0: 7469 6e67 2066 6f72 0a09 0909 2f2f 2061 ting for....// a │ │ │ +000206d0: 6c65 7274 732c 2077 6520 6e65 6564 2074 lerts, we need t │ │ │ +000206e0: 6f20 6e6f 7469 6679 2074 6865 6d2e 2041 o notify them. A │ │ │ +000206f0: 6c73 6f20 2870 6f74 656e 7469 616c 6c79 lso (potentially │ │ │ +00020700: 2920 6361 6c6c 2074 6865 0a09 0909 2f2f ) call the....// │ │ │ +00020710: 2075 7365 7220 7375 7070 6c69 6564 206d user supplied m │ │ │ +00020720: 5f6e 6f74 6966 7920 6361 6c6c 6261 636b _notify callback │ │ │ +00020730: 2074 6f20 6c65 7420 7468 6520 636c 6965 to let the clie │ │ │ +00020740: 6e74 2077 616b 6520 7570 2069 7473 0a09 nt wake up its.. │ │ │ +00020750: 0909 2f2f 206d 6573 7361 6765 206c 6f6f ..// message loo │ │ │ +00020760: 7020 746f 2070 6f6c 6c20 666f 7220 616c p to poll for al │ │ │ +00020770: 6572 7473 2e0a 0909 0969 6620 286d 5f6e erts.....if (m_n │ │ │ +00020780: 6f74 6966 7929 206d 5f6e 6f74 6966 7928 otify) m_notify( │ │ │ +00020790: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22 );..
    ...m_condition │ │ │ +000207d0: 2e6e 6f74 6966 795f 616c 6c28 293b 0a3c .notify_all();.< │ │ │ +000207e0: 2f64 6976 3e09 097d 0a0a 2369 666e 6465 /div>..}..#ifnde │ │ │ +000207f0: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +00020800: 455f 4558 5445 4e53 494f 4e53 0a09 0966 E_EXTENSIONS...f │ │ │ +00020810: 6f72 2028 6175 746f 2661 6d70 3b20 6520 or (auto& e │ │ │ +00020820: 3a20 6d5f 7365 735f 6578 7465 6e73 696f : m_ses_extensio │ │ │ +00020830: 6e73 290a 0909 0965 2d26 6774 3b6f 6e5f ns)....e->on_ │ │ │ +00020840: 616c 6572 7428 6129 3b0a 2365 6c73 650a alert(a);.#else. │ │ │ +00020850: 0909 544f 5252 454e 545f 554e 5553 4544 ..TORRENT_UNUSED │ │ │ +00020860: 2861 293b 0a23 656e 6469 660a 097d 0a0a (a);.#endif..}.. │ │ │ +00020870: 0976 6f69 6420 616c 6572 745f 6d61 6e61 .void alert_mana │ │ │ +00020880: 6765 723a 3a73 6574 5f6e 6f74 6966 795f ger::set_notify_ │ │ │ +00020890: 6675 6e63 7469 6f6e 2873 7464 3a3a 6675 function(std::fu │ │ │ +000208a0: 6e63 7469 6f6e 266c 743b 766f 6964 2829 nction<void() │ │ │ +000208b0: 2667 743b 2063 6f6e 7374 2661 6d70 3b20 > const& │ │ │ +000208c0: 6675 6e29 0a09 7b0a 0909 7374 643a 3a75 fun)..{...std::u │ │ │ +000208d0: 6e69 7175 655f 6c6f 636b 266c 743b 7374 nique_lock<st │ │ │ +000208e0: 643a 3a72 6563 7572 7369 7665 5f6d 7574 d::recursive_mut │ │ │ +000208f0: 6578 2667 743b 206c 6f63 6b28 6d5f 6d75 ex> lock(m_mu │ │ │ +00020900: 7465 7829 3b0a 0909 6d5f 6e6f 7469 6679 tex);...m_notify │ │ │ +00020910: 203d 2066 756e 3b0a 0909 6966 2028 216d = fun;...if (!m │ │ │ +00020920: 5f61 6c65 7274 735b 6d5f 6765 6e65 7261 _alerts[m_genera │ │ │ +00020930: 7469 6f6e 2026 616d 703b 2031 5d2e 656d tion & 1].em │ │ │ +00020940: 7074 7928 2929 0a09 097b 0a09 0909 6966 pty())...{....if │ │ │ +00020950: 2028 6d5f 6e6f 7469 6679 2920 6d5f 6e6f (m_notify) m_no │ │ │ +00020960: 7469 6679 2829 3b0a 0909 7d0a 097d 0a0a tify();...}..}.. │ │ │ +00020970: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +00020980: 4449 5341 424c 455f 4558 5445 4e53 494f DISABLE_EXTENSIO │ │ │ +00020990: 4e53 0a09 766f 6964 2061 6c65 7274 5f6d NS..void alert_m │ │ │ +000209a0: 616e 6167 6572 3a3a 6164 645f 6578 7465 anager::add_exte │ │ │ +000209b0: 6e73 696f 6e28 7374 643a 3a73 6861 7265 nsion(std::share │ │ │ +000209c0: 645f 7074 7226 6c74 3b70 6c75 6769 6e26 d_ptr<plugin& │ │ │ +000209d0: 6774 3b20 6578 7429 0a09 7b0a 0909 6d5f gt; ext)..{...m_ │ │ │ +000209e0: 7365 735f 6578 7465 6e73 696f 6e73 2e70 ses_extensions.p │ │ │ +000209f0: 7573 685f 6261 636b 2873 7464 3a3a 6d6f ush_back(std::mo │ │ │ +00020a00: 7665 2865 7874 2929 3b0a 097d 0a23 656e ve(ext));..}.#en │ │ │ +00020a10: 6469 660a 0a09 766f 6964 2061 6c65 7274 dif...void alert │ │ │ +00020a20: 5f6d 616e 6167 6572 3a3a 6765 745f 616c _manager::get_al │ │ │ +00020a30: 6c28 7374 643a 3a76 6563 746f 7226 6c74 l(std::vector< │ │ │ +00020a40: 3b61 6c65 7274 2a26 6774 3b26 616d 703b ;alert*>& │ │ │ +00020a50: 2061 6c65 7274 7329 0a09 7b0a 0909 7374 alerts)..{...st │ │ │ +00020a60: 643a 3a6c 6f63 6b5f 6775 6172 6426 6c74 d::lock_guard< │ │ │ +00020a70: 3b73 7464 3a3a 7265 6375 7273 6976 655f ;std::recursive_ │ │ │ +00020a80: 6d75 7465 7826 6774 3b20 6c6f 636b 286d mutex> lock(m │ │ │ +00020a90: 5f6d 7574 6578 293b 0a3c 2f70 7265 3e3c _mutex);.
    < │ │ │ +00020aa0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00020ad0: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ +00020ae0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/peer_l │ │ │ +00020b10: 6973 742e 6370 703a 3531 353c 2f61 3e3c ist.cpp:515< │ │ │ +00020b20: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ +00020b30: 2062 6520 6e69 6365 2069 6620 7468 6572 be nice if ther │ │ │ +00020b40: 6520 7761 7320 6120 7761 7920 746f 2069 e was a way to i │ │ │ +00020b50: 7465 7261 7465 206f 7665 7220 7468 6573 terate over thes │ │ │ +00020b60: 6520 746f 7272 656e 745f 7065 6572 206f e torrent_peer o │ │ │ +00020b70: 626a 6563 7473 2069 6e20 7468 6520 6f72 bjects in the or │ │ │ +00020b80: 6465 7220 7468 6579 2061 7265 2061 6c6c der they are all │ │ │ +00020b90: 6f63 6174 6564 2069 6e20 7468 6520 706f ocated in the po │ │ │ +00020ba0: 6f6c 2069 6e73 7465 6164 2e20 4974 2077 ol instead. It w │ │ │ +00020bb0: 6f75 6c64 2070 726f 6261 626c 7920 6265 ould probably be │ │ │ +00020bc0: 206d 6f72 6520 6566 6669 6369 656e 743c more efficient< │ │ │ +00020bd0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it w │ │ │ +00020c20: 6f75 6c64 2062 6520 6e69 6365 2069 6620 ould be nice if │ │ │ +00020c30: 7468 6572 6520 7761 7320 6120 7761 7920 there was a way │ │ │ +00020c40: 746f 2069 7465 7261 7465 206f 7665 7220 to iterate over │ │ │ +00020c50: 7468 6573 650a 746f 7272 656e 745f 7065 these.torrent_pe │ │ │ +00020c60: 6572 206f 626a 6563 7473 2069 6e20 7468 er objects in th │ │ │ +00020c70: 6520 6f72 6465 7220 7468 6579 2061 7265 e order they are │ │ │ +00020c80: 2061 6c6c 6f63 6174 6564 2069 6e20 7468 allocated in th │ │ │ +00020c90: 6520 706f 6f6c 0a69 6e73 7465 6164 2e20 e pool.instead. │ │ │ +00020ca0: 4974 2077 6f75 6c64 2070 726f 6261 626c It would probabl │ │ │ +00020cb0: 7920 6265 206d 6f72 6520 6566 6669 6369 y be more effici │ │ │ +00020cc0: 656e 743c 2f68 323e 3c68 343e 2e2e 2f73 ent

    ../s │ │ │ +00020cd0: 7263 2f70 6565 725f 6c69 7374 2e63 7070 rc/peer_list.cpp │ │ │ +00020ce0: 3a35 3135 3c2f 6834 3e3c 7072 6520 7374 :515

    .., int sessi
    │ │ │ +00020d30: 6f6e 5f74 696d 652c 2074 6f72 7265 6e74  on_time, torrent
    │ │ │ +00020d40: 5f73 7461 7465 2a20 7374 6174 6529 0a09  _state* state)..
    │ │ │ +00020d50: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ +00020d60: 5254 2869 735f 7369 6e67 6c65 5f74 6872  RT(is_single_thr
    │ │ │ +00020d70: 6561 6428 2929 3b0a 0909 494e 5641 5249  ead());...INVARI
    │ │ │ +00020d80: 414e 545f 4348 4543 4b3b 0a0a 0909 636f  ANT_CHECK;....co
    │ │ │ +00020d90: 6e73 7420 696e 7420 6361 6e64 6964 6174  nst int candidat
    │ │ │ +00020da0: 655f 636f 756e 7420 3d20 3130 3b0a 0909  e_count = 10;...
    │ │ │ +00020db0: 7065 6572 732e 7265 7365 7276 6528 6361  peers.reserve(ca
    │ │ │ +00020dc0: 6e64 6964 6174 655f 636f 756e 7429 3b0a  ndidate_count);.
    │ │ │ +00020dd0: 0a09 0969 6e74 2065 7261 7365 5f63 616e  ...int erase_can
    │ │ │ +00020de0: 6469 6461 7465 203d 202d 313b 0a0a 0909  didate = -1;....
    │ │ │ +00020df0: 6966 2028 626f 6f6c 286d 5f66 696e 6973  if (bool(m_finis
    │ │ │ +00020e00: 6865 6429 2021 3d20 7374 6174 652d 2667  hed) != state-&g
    │ │ │ +00020e10: 743b 6973 5f66 696e 6973 6865 6429 0a09  t;is_finished)..
    │ │ │ +00020e20: 0909 7265 6361 6c63 756c 6174 655f 636f  ..recalculate_co
    │ │ │ +00020e30: 6e6e 6563 745f 6361 6e64 6964 6174 6573  nnect_candidates
    │ │ │ +00020e40: 2873 7461 7465 293b 0a0a 0909 6175 783a  (state);....aux:
    │ │ │ +00020e50: 3a65 7874 6572 6e61 6c5f 6970 2063 6f6e  :external_ip con
    │ │ │ +00020e60: 7374 2661 6d70 3b20 6578 7465 726e 616c  st& external
    │ │ │ +00020e70: 203d 2073 7461 7465 2d26 6774 3b69 703b   = state->ip;
    │ │ │ +00020e80: 0a09 0969 6e74 2065 7874 6572 6e61 6c5f  ...int external_
    │ │ │ +00020e90: 706f 7274 203d 2073 7461 7465 2d26 6774  port = state->
    │ │ │ +00020ea0: 3b70 6f72 743b 0a0a 0909 6966 2028 6d5f  ;port;....if (m_
    │ │ │ +00020eb0: 726f 756e 645f 726f 6269 6e20 2667 743b  round_robin >
    │ │ │ +00020ec0: 3d20 696e 7428 6d5f 7065 6572 732e 7369  = int(m_peers.si
    │ │ │ +00020ed0: 7a65 2829 2929 206d 5f72 6f75 6e64 5f72  ze())) m_round_r
    │ │ │ +00020ee0: 6f62 696e 203d 2030 3b0a 0a09 0969 6e74  obin = 0;....int
    │ │ │ +00020ef0: 206d 6178 5f70 6565 726c 6973 745f 7369   max_peerlist_si
    │ │ │ +00020f00: 7a65 203d 2073 7461 7465 2d26 6774 3b6d  ze = state->m
    │ │ │ +00020f10: 6178 5f70 6565 726c 6973 745f 7369 7a65  ax_peerlist_size
    │ │ │ +00020f20: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ..for (int iter │ │ │ +00020f60: 6174 696f 6e73 203d 2073 7464 3a3a 6d69 ations = std::mi │ │ │ +00020f70: 6e28 696e 7428 6d5f 7065 6572 732e 7369 n(int(m_peers.si │ │ │ +00020f80: 7a65 2829 292c 2033 3030 293b 0a3c 2f64 ze()), 300);....iterations │ │ │ +00020fa0: 2026 6774 3b20 303b 202d 2d69 7465 7261 > 0; --itera │ │ │ +00020fb0: 7469 6f6e 7329 0a09 097b 0a09 0909 2b2b tions)...{....++ │ │ │ +00020fc0: 7374 6174 652d 2667 743b 6c6f 6f70 5f63 state->loop_c │ │ │ +00020fd0: 6f75 6e74 6572 3b0a 0a09 0909 6966 2028 ounter;.....if ( │ │ │ +00020fe0: 6d5f 726f 756e 645f 726f 6269 6e20 2667 m_round_robin &g │ │ │ +00020ff0: 743b 3d20 696e 7428 6d5f 7065 6572 732e t;= int(m_peers. │ │ │ +00021000: 7369 7a65 2829 2929 206d 5f72 6f75 6e64 size())) m_round │ │ │ +00021010: 5f72 6f62 696e 203d 2030 3b0a 0a09 0909 _robin = 0;..... │ │ │ +00021020: 746f 7272 656e 745f 7065 6572 2661 6d70 torrent_peer& │ │ │ +00021030: 3b20 7065 203d 202a 6d5f 7065 6572 735b ; pe = *m_peers[ │ │ │ +00021040: 6d5f 726f 756e 645f 726f 6269 6e5d 3b0a m_round_robin];. │ │ │ +00021050: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00021060: 5428 7065 2e69 6e5f 7573 6529 3b0a 0909 T(pe.in_use);... │ │ │ +00021070: 0969 6e74 2063 7572 7265 6e74 203d 206d .int current = m │ │ │ +00021080: 5f72 6f75 6e64 5f72 6f62 696e 3b0a 0a09 _round_robin;... │ │ │ +00021090: 0909 2f2f 2069 6620 7468 6520 6e75 6d62 ..// if the numb │ │ │ +000210a0: 6572 206f 6620 7065 6572 7320 6973 2067 er of peers is g │ │ │ +000210b0: 726f 7769 6e67 206c 6172 6765 0a09 0909 rowing large.... │ │ │ +000210c0: 2f2f 2077 6520 6e65 6564 2074 6f20 7374 // we need to st │ │ │ +000210d0: 6172 7420 7765 6564 696e 672e 0a0a 0909 art weeding..... │ │ │ +000210e0: 0969 6620 2869 6e74 286d 5f70 6565 7273 .if (int(m_peers │ │ │ +000210f0: 2e73 697a 6528 2929 2026 6774 3b3d 206d .size()) >= m │ │ │ +00021100: 6178 5f70 6565 726c 6973 745f 7369 7a65 ax_peerlist_size │ │ │ +00021110: 202a 2030 2e39 350a 0909 0909 2661 6d70 * 0.95.....& │ │ │ +00021120: 3b26 616d 703b 206d 6178 5f70 6565 726c ;& max_peerl │ │ │ +00021130: 6973 745f 7369 7a65 2026 6774 3b20 3029 ist_size > 0) │ │ │ +00021140: 0a09 0909 7b0a 0909 0909 6966 2028 6973 ....{.....if (is │ │ │ +00021150: 5f65 7261 7365 5f63 616e 6469 6461 7465 _erase_candidate │ │ │ +00021160: 2870 6529 0a09 0909 0909 2661 6d70 3b26 (pe)......&& │ │ │ +00021170: 616d 703b 2028 6572 6173 655f 6361 6e64 amp; (erase_cand │ │ │ +00021180: 6964 6174 6520 3d3d 202d 310a 0909 0909 idate == -1..... │ │ │ +00021190: 0909 7c7c 2021 636f 6d70 6172 655f 7065 ..|| !compare_pe │ │ │ +000211a0: 6572 5f65 7261 7365 282a 6d5f 7065 6572 er_erase(*m_peer │ │ │ +000211b0: 735b 6572 6173 655f 6361 6e64 6964 6174 s[erase_candidat │ │ │ +000211c0: 655d 2c20 7065 2929 290a 0909 0909 7b0a e], pe))).....{. │ │ │ +000211d0: 0909 0909 0969 6620 2873 686f 756c 645f .....if (should_ │ │ │ +000211e0: 6572 6173 655f 696d 6d65 6469 6174 656c erase_immediatel │ │ │ +000211f0: 7928 7065 2929 0a09 0909 0909 7b0a 0909 y(pe))......{... │ │ │ +00021200: 0909 0909 6966 2028 6572 6173 655f 6361 ....if (erase_ca │ │ │ +00021210: 6e64 6964 6174 6520 2667 743b 2063 7572 ndidate > cur │ │ │ +00021220: 7265 6e74 2920 2d2d 6572 6173 655f 6361 rent) --erase_ca │ │ │ +00021230: 6e64 6964 6174 653b 0a09 0909 0909 0965 ndidate;.......e │ │ │ +00021240: 7261 7365 5f70 6565 7228 6d5f 7065 6572 rase_peer(m_peer │ │ │ +00021250: 732e 6265 6769 6e28 2920 2b20 6375 7272 s.begin() + curr │ │ │ +00021260: 656e 742c 2073 7461 7465 293b 0a09 0909 ent, state);.... │ │ │ +00021270: 0909 0963 6f6e 7469 6e75 653b 0a09 0909 ...continue;.... │ │ │ +00021280: 0909 7d0a 0909 0909 0965 6c73 650a 0909 ..}......else... │ │ │ +00021290: 0909 097b 0a09 0909 0909 0965 7261 7365 ...{.......erase │ │ │ +000212a0: 5f63 616e 6469 6461 7465 203d 2063 7572 _candidate = cur │ │ │ +000212b0: 7265 6e74 3b0a 0909 0909 097d 0a3c 2f70 rent;......}.

    re │ │ │ +000212f0: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/tr │ │ │ +00021330: 6163 6b65 725f 6d61 6e61 6765 722e 6370 acker_manager.cp │ │ │ +00021340: 703a 3430 343c 2f61 3e3c 2f74 643e 3c74 p:404implement │ │ │ +00021360: 3c2f 7472 3e3c 7472 2069 643d 2236 3622

    implemen │ │ │ +000213b0: 743c 2f68 323e 3c68 343e 2e2e 2f73 7263 t

    ../src │ │ │ +000213c0: 2f74 7261 636b 6572 5f6d 616e 6167 6572 /tracker_manager │ │ │ +000213d0: 2e63 7070 3a34 3034 3c2f 6834 3e3c 7072 .cpp:404

    #ifndef T │ │ │ +00021420: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ +00021430: 4f47 4749 4e47 0a09 0909 6966 2028 6d5f OGGING....if (m_ │ │ │ +00021440: 7365 732e 7368 6f75 6c64 5f6c 6f67 2829 ses.should_log() │ │ │ +00021450: 290a 0909 097b 0a09 0909 096d 5f73 6573 )....{.....m_ses │ │ │ +00021460: 2e73 6573 7369 6f6e 5f6c 6f67 2822 696e .session_log("in │ │ │ +00021470: 636f 6d69 6e67 2055 4450 2074 7261 636b coming UDP track │ │ │ +00021480: 6572 2070 6163 6b65 7420 6672 6f6d 2025 er packet from % │ │ │ +00021490: 7320 6861 7320 696e 7661 6c69 6420 220a s has invalid ". │ │ │ +000214a0: 0909 0909 0922 7472 616e 7361 6374 696f ....."transactio │ │ │ +000214b0: 6e20 4944 2028 2578 2922 2c20 7072 696e n ID (%x)", prin │ │ │ +000214c0: 745f 656e 6470 6f69 6e74 2865 7029 2e63 t_endpoint(ep).c │ │ │ +000214d0: 5f73 7472 2829 0a09 0909 0909 2c20 7472 _str()......, tr │ │ │ +000214e0: 616e 7361 6374 696f 6e29 3b0a 0909 097d ansaction);....} │ │ │ +000214f0: 0a23 656e 6469 660a 0909 0972 6574 7572 .#endif....retur │ │ │ +00021500: 6e20 6661 6c73 653b 0a09 097d 0a0a 0909 n false;...}.... │ │ │ +00021510: 6175 746f 2063 6f6e 7374 2070 203d 2069 auto const p = i │ │ │ +00021520: 2d26 6774 3b73 6563 6f6e 643b 0a09 092f ->second;.../ │ │ │ +00021530: 2f20 6f6e 5f72 6563 6569 7665 2829 206d / on_receive() m │ │ │ +00021540: 6179 2072 656d 6f76 6520 7468 6520 7472 ay remove the tr │ │ │ +00021550: 6163 6b65 7220 636f 6e6e 6563 7469 6f6e acker connection │ │ │ +00021560: 2066 726f 6d20 7468 6520 6c69 7374 0a09 from the list.. │ │ │ +00021570: 0972 6574 7572 6e20 702d 2667 743b 6f6e .return p->on │ │ │ +00021580: 5f72 6563 6569 7665 2865 702c 2062 7566 _receive(ep, buf │ │ │ +00021590: 293b 0a09 7d0a 0a09 766f 6964 2074 7261 );..}...void tra │ │ │ +000215a0: 636b 6572 5f6d 616e 6167 6572 3a3a 696e cker_manager::in │ │ │ +000215b0: 636f 6d69 6e67 5f65 7272 6f72 2865 7272 coming_error(err │ │ │ +000215c0: 6f72 5f63 6f64 6520 636f 6e73 7426 616d or_code const&am │ │ │ +000215d0: 703b 0a09 092c 2075 6470 3a3a 656e 6470 p;..., udp::endp │ │ │ +000215e0: 6f69 6e74 2063 6f6e 7374 2661 6d70 3b29 oint const&) │ │ │ +000215f0: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ +00021600: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ +00021610: 6872 6561 6428 2929 3b0a 3c64 6976 2073 hread());.
    .}.
    ..bool tracker_ │ │ │ +00021660: 6d61 6e61 6765 723a 3a69 6e63 6f6d 696e manager::incomin │ │ │ +00021670: 675f 7061 636b 6574 2873 7472 696e 675f g_packet(string_ │ │ │ +00021680: 7669 6577 2063 6f6e 7374 2068 6f73 746e view const hostn │ │ │ +00021690: 616d 650a 0909 2c20 7370 616e 266c 743b ame..., span< │ │ │ +000216a0: 6368 6172 2063 6f6e 7374 2667 743b 2063 char const> c │ │ │ +000216b0: 6f6e 7374 2062 7566 290a 097b 0a09 0954 onst buf)..{...T │ │ │ +000216c0: 4f52 5245 4e54 5f41 5353 4552 5428 6973 ORRENT_ASSERT(is │ │ │ +000216d0: 5f73 696e 676c 655f 7468 7265 6164 2829 _single_thread() │ │ │ +000216e0: 293b 0a09 092f 2f20 6967 6e6f 7265 2070 );...// ignore p │ │ │ +000216f0: 6163 6b65 7473 2073 6d61 6c6c 6572 2074 ackets smaller t │ │ │ +00021700: 6861 6e20 3820 6279 7465 730a 0909 6966 han 8 bytes...if │ │ │ +00021710: 2028 6275 662e 7369 7a65 2829 2026 6c74 (buf.size() < │ │ │ +00021720: 3b20 3136 2920 7265 7475 726e 2066 616c ; 16) return fal │ │ │ +00021730: 7365 3b0a 0a09 092f 2f20 7468 6520 6669 se;....// the fi │ │ │ +00021740: 7273 7420 776f 7264 2069 7320 7468 6520 rst word is the │ │ │ +00021750: 6163 7469 6f6e 2c20 6966 2069 7427 7320 action, if it's │ │ │ +00021760: 6e6f 7420 5b30 2c20 335d 0a09 092f 2f20 not [0, 3]...// │ │ │ +00021770: 6974 2773 206e 6f74 2061 2076 616c 6964 it's not a valid │ │ │ +00021780: 2075 6470 2074 7261 636b 6572 2072 6573 udp tracker res │ │ │ +00021790: 706f 6e73 650a 0909 7370 616e 266c 743b ponse...span< │ │ │ +000217a0: 636f 6e73 7420 6368 6172 2667 743b 2070 const char> p │ │ │ +000217b0: 7472 203d 2062 7566 3b0a 0909 7374 643a tr = buf;...std: │ │ │ +000217c0: 3a75 696e 7433 325f 7420 636f 6e73 7420 :uint32_t const │ │ │ +000217d0: 6163 7469 6f6e 203d 2061 7578 3a3a 7265 action = aux::re │ │ │ +000217e0: 6164 5f75 696e 7433 3228 7074 7229 3b0a ad_uint32(ptr);. │ │ │ +000217f0: 0909 6966 2028 6163 7469 6f6e 2026 6774 ..if (action > │ │ │ +00021800: 3b20 3329 2072 6574 7572 6e20 6661 6c73 ; 3) return fals │ │ │ +00021810: 653b 0a0a 0909 7374 643a 3a75 696e 7433 e;....std::uint3 │ │ │ +00021820: 325f 7420 636f 6e73 7420 7472 616e 7361 2_t const transa │ │ │ +00021830: 6374 696f 6e20 3d20 6175 783a 3a72 6561 ction = aux::rea │ │ │ +00021840: 645f 7569 6e74 3332 2870 7472 293b 0a09 d_uint32(ptr);.. │ │ │ +00021850: 0961 7574 6f20 636f 6e73 7420 6920 3d20 .auto const i = │ │ │ +00021860: 6d5f 7564 705f 636f 6e6e 732e 6669 6e64 m_udp_conns.find │ │ │ +00021870: 2874 7261 6e73 6163 7469 6f6e 293b 0a0a (transaction);.. │ │ │ +00021880: 0909 6966 2028 6920 3d3d 206d 5f75 6470 ..if (i == m_udp │ │ │ +00021890: 5f63 6f6e 6e73 2e65 6e64 2829 290a 0909 _conns.end())... │ │ │ +000218a0: 7b0a 2369 666e 6465 6620 544f 5252 454e {.#ifndef TORREN │ │ │ +000218b0: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ +000218c0: 470a 0909 092f 2f20 6e6f 772c 2074 6869 G....// now, thi │ │ │ +000218d0: 7320 6d61 7920 6e6f 7420 6861 7665 2062 s may not have b │ │ │ +000218e0: 6565 6e20 6d65 616e 7420 746f 2062 6520 een meant to be │ │ │ +000218f0: 6120 7472 6163 6b65 7220 7265 7370 6f6e a tracker respon │ │ │ +00021900: 7365 2c0a 0909 092f 2f20 6275 7420 6368 se,....// but ch │ │ │ +00021910: 616e 6365 7320 6172 6520 7072 6574 7479 ances are pretty │ │ │ +00021920: 2067 6f6f 642c 2073 6f20 6974 2773 2070 good, so it's p │ │ │ +00021930: 726f 6261 626c 7920 776f 7274 6820 6c6f robably worth lo │ │ │ +00021940: 6767 696e 670a 0909 096d 5f73 6573 2e73 gging....m_ses.s │ │ │ +00021950: 6573 7369 6f6e 5f6c 6f67 2822 696e 636f ession_log("inco │ │ │ +00021960: 6d69 6e67 2055 4450 2074 7261 636b 6572 ming UDP tracker │ │ │ +00021970: 2070 6163 6b65 7420 6672 6f6d 2025 7320 packet from %s │ │ │ +00021980: 6861 7320 696e 7661 6c69 6420 220a 0909 has invalid "... │ │ │ +00021990: 0909 2274 7261 6e73 6163 7469 6f6e 2049 .."transaction I │ │ │ +000219a0: 4420 2825 7829 222c 2073 7464 3a3a 7374 D (%x)", std::st │ │ │ +000219b0: 7269 6e67 2868 6f73 746e 616d 6529 2e63 ring(hostname).c │ │ │ +000219c0: 5f73 7472 2829 2c20 7472 616e 7361 6374 _str(), transact │ │ │ +000219d0: 696f 6e29 3b0a 2365 6e64 6966 0a09 0909 ion);.#endif.... │ │ │ +000219e0: 7265 7475 726e 2066 616c 7365 3b0a 0909 return false;... │ │ │ +000219f0: 7d0a 0a09 0961 7574 6f20 636f 6e73 7420 }....auto const │ │ │ +00021a00: 7020 3d20 692d 2667 743b 7365 636f 6e64 p = i->second │ │ │ +00021a10: 3b0a 0909 2f2f 206f 6e5f 7265 6365 6976 ;...// on_receiv │ │ │ +00021a20: 6528 2920 6d61 7920 7265 6d6f 7665 2074 e() may remove t │ │ │ +00021a30: 6865 2074 7261 636b 6572 2063 6f6e 6e65 he tracker conne │ │ │ +00021a40: 6374 696f 6e20 6672 6f6d 2074 6865 206c ction from the l │ │ │ +00021a50: 6973 740a 3c2f 7072 653e 3c2f 7464 3e3c ist.
    < │ │ │ +00021a60: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00021a90: 6273 703b 323c 2f74 643e 3c74 643e 3c61 bsp;2.. │ │ │ +00021ac0: 2f73 7263 2f70 6965 6365 5f70 6963 6b65 /src/piece_picke │ │ │ +00021ad0: 722e 6370 703a 3139 3833 3c2f 613e 3c2f r.cpp:1983make the │ │ │ +00021af0: 3230 3438 206c 696d 6974 2063 6f6e 6669 2048 limit confi │ │ │ +00021b00: 6775 7261 626c 653c 2f74 643e 3c2f 7472 gurable │ │ │ +00021b40: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00021b50: 3c68 323e 6d61 6b65 2074 6865 2032 3034

    make the 204 │ │ │ +00021b60: 3820 6c69 6d69 7420 636f 6e66 6967 7572 8 limit configur │ │ │ +00021b70: 6162 6c65 3c2f 6832 3e3c 6834 3e2e 2e2f able

    ../ │ │ │ +00021b80: 7372 632f 7069 6563 655f 7069 636b 6572 src/piece_picker │ │ │ +00021b90: 2e63 7070 3a31 3938 333c 2f68 343e 3c70 .cpp:1983

    .// indi │ │ │ +00021be0: 6361 7469 6e67 2077 6869 6368 2070 6174 cating which pat │ │ │ +00021bf0: 6820 7468 6f75 6768 7420 7468 6520 7069 h thought the pi │ │ │ +00021c00: 636b 6572 2077 6520 746f 6f6b 2074 6f20 cker we took to │ │ │ +00021c10: 6172 7269 7665 2061 7420 7468 650a 092f arrive at the../ │ │ │ +00021c20: 2f20 7265 7475 726e 6564 2062 6c6f 636b / returned block │ │ │ +00021c30: 2070 6963 6b73 2e0a 0970 6963 6b65 725f picks...picker_ │ │ │ +00021c40: 666c 6167 735f 7420 7069 6563 655f 7069 flags_t piece_pi │ │ │ +00021c50: 636b 6572 3a3a 7069 636b 5f70 6965 6365 cker::pick_piece │ │ │ +00021c60: 7328 7479 7065 645f 6269 7466 6965 6c64 s(typed_bitfield │ │ │ +00021c70: 266c 743b 7069 6563 655f 696e 6465 785f <piece_index_ │ │ │ +00021c80: 7426 6774 3b20 636f 6e73 7426 616d 703b t> const& │ │ │ +00021c90: 2070 6965 6365 730a 0909 2c20 7374 643a pieces..., std: │ │ │ +00021ca0: 3a76 6563 746f 7226 6c74 3b70 6965 6365 :vector<piece │ │ │ +00021cb0: 5f62 6c6f 636b 2667 743b 2661 6d70 3b20 _block>& │ │ │ +00021cc0: 696e 7465 7265 7374 696e 675f 626c 6f63 interesting_bloc │ │ │ +00021cd0: 6b73 2c20 696e 7420 6e75 6d5f 626c 6f63 ks, int num_bloc │ │ │ +00021ce0: 6b73 0a09 092c 2069 6e74 2070 7265 6665 ks..., int prefe │ │ │ +00021cf0: 725f 636f 6e74 6967 756f 7573 5f62 6c6f r_contiguous_blo │ │ │ +00021d00: 636b 732c 2061 7578 3a3a 746f 7272 656e cks, aux::torren │ │ │ +00021d10: 745f 7065 6572 2a20 7065 6572 0a09 092c t_peer* peer..., │ │ │ +00021d20: 2070 6963 6b65 725f 6f70 7469 6f6e 735f picker_options_ │ │ │ +00021d30: 7420 6f70 7469 6f6e 732c 2073 7464 3a3a t options, std:: │ │ │ +00021d40: 7665 6374 6f72 266c 743b 7069 6563 655f vector<piece_ │ │ │ +00021d50: 696e 6465 785f 7426 6774 3b20 636f 6e73 index_t> cons │ │ │ +00021d60: 7426 616d 703b 2073 7567 6765 7374 6564 t& suggested │ │ │ +00021d70: 5f70 6965 6365 730a 0909 2c20 696e 7420 _pieces..., int │ │ │ +00021d80: 6e75 6d5f 7065 6572 730a 0909 2c20 636f num_peers..., co │ │ │ +00021d90: 756e 7465 7273 2661 6d70 3b20 7063 0a09 unters& pc.. │ │ │ +00021da0: 0929 2063 6f6e 7374 0a09 7b0a 0909 544f .) const..{...TO │ │ │ +00021db0: 5252 454e 545f 4153 5345 5254 2870 6565 RRENT_ASSERT(pee │ │ │ +00021dc0: 7220 3d3d 206e 756c 6c70 7472 207c 7c20 r == nullptr || │ │ │ +00021dd0: 7065 6572 2d26 6774 3b69 6e5f 7573 6529 peer->in_use) │ │ │ +00021de0: 3b0a 0909 7069 636b 6572 5f66 6c61 6773 ;...picker_flags │ │ │ +00021df0: 5f74 2072 6574 3b0a 0a09 092f 2f20 7072 _t ret;....// pr │ │ │ +00021e00: 6576 656e 7420 7468 6520 6e75 6d62 6572 event the number │ │ │ +00021e10: 206f 6620 7061 7274 6961 6c20 7069 6563 of partial piec │ │ │ +00021e20: 6573 2074 6f20 6772 6f77 2069 6e64 6566 es to grow indef │ │ │ +00021e30: 696e 6974 656c 790a 0909 2f2f 206d 616b initely...// mak │ │ │ +00021e40: 6520 7468 6973 2073 6361 6c65 2062 7920 e this scale by │ │ │ +00021e50: 7468 6520 6e75 6d62 6572 206f 6620 7065 the number of pe │ │ │ +00021e60: 6572 7320 7765 2068 6176 652e 2046 6f72 ers we have. For │ │ │ +00021e70: 206c 6172 6765 0a09 092f 2f20 7363 616c large...// scal │ │ │ +00021e80: 6520 636c 6965 6e74 732c 2077 6520 776f e clients, we wo │ │ │ +00021e90: 756c 6420 6861 7665 206d 6f72 6520 7065 uld have more pe │ │ │ +00021ea0: 6572 732c 2061 6e64 2061 6c6c 6f77 2061 ers, and allow a │ │ │ +00021eb0: 2068 6967 6865 720a 0909 2f2f 2074 6872 higher...// thr │ │ │ +00021ec0: 6573 686f 6c64 2066 6f72 2074 6865 206e eshold for the n │ │ │ +00021ed0: 756d 6265 7220 6f66 2070 6172 7469 616c umber of partial │ │ │ +00021ee0: 730a 0909 2f2f 2074 6865 2073 6563 6f6e s...// the secon │ │ │ +00021ef0: 6420 636f 6e64 6974 696f 6e20 6973 2074 d condition is t │ │ │ +00021f00: 6f20 6d61 6b65 2073 7572 6520 7765 2063 o make sure we c │ │ │ +00021f10: 6170 2074 6865 206e 756d 6265 7220 6f66 ap the number of │ │ │ +00021f20: 2070 6172 7469 616c 0a09 092f 2f20 5f62 partial...// _b │ │ │ +00021f30: 7974 6573 5f2e 2054 6865 206c 6172 6765 ytes_. The large │ │ │ +00021f40: 7220 7468 6520 7069 6563 6573 2061 7265 r the pieces are │ │ │ +00021f50: 2c20 7468 6520 6665 7765 7220 7061 7274 , the fewer part │ │ │ +00021f60: 6961 6c20 7069 6563 6573 2077 6520 7761 ial pieces we wa │ │ │ +00021f70: 6e74 2e0a 0909 2f2f 2032 3034 3820 636f nt....// 2048 co │ │ │ +00021f80: 7272 6573 706f 6e64 7320 746f 2033 3220 rresponds to 32 │ │ │ +00021f90: 4d69 420a 3c64 6976 2073 7479 6c65 3d22 MiB.

    ..const int nu │ │ │ +00021fd0: 6d5f 7061 7274 6961 6c73 203d 2069 6e74 m_partials = int │ │ │ +00021fe0: 286d 5f64 6f77 6e6c 6f61 6473 5b70 6965 (m_downloads[pie │ │ │ +00021ff0: 6365 5f70 6f73 3a3a 7069 6563 655f 646f ce_pos::piece_do │ │ │ +00022000: 776e 6c6f 6164 696e 675d 2e73 697a 6528 wnloading].size( │ │ │ +00022010: 2929 3b0a 3c2f 6469 763e 0909 6966 2028 ));.
    ..if ( │ │ │ +00022020: 6e75 6d5f 7061 7274 6961 6c73 2026 6774 num_partials > │ │ │ +00022030: 3b20 6e75 6d5f 7065 6572 7320 2a20 3320 ; num_peers * 3 │ │ │ +00022040: 2f20 320a 0909 097c 7c20 6e75 6d5f 7061 / 2....|| num_pa │ │ │ +00022050: 7274 6961 6c73 202a 2062 6c6f 636b 735f rtials * blocks_ │ │ │ +00022060: 7065 725f 7069 6563 6528 2920 2667 743b per_piece() > │ │ │ +00022070: 2032 3034 3829 0a09 097b 0a09 0909 2f2f 2048)...{....// │ │ │ +00022080: 2069 6620 7765 2068 6176 6520 746f 6f20 if we have too │ │ │ +00022090: 6d61 6e79 2070 6172 7469 616c 2070 6965 many partial pie │ │ │ +000220a0: 6365 732c 2070 7269 6f72 6974 697a 6520 ces, prioritize │ │ │ +000220b0: 636f 6d70 6c65 7469 6e67 0a09 0909 2f2f completing....// │ │ │ +000220c0: 2074 6865 6d2e 2049 6e20 6f72 6465 7220 them. In order │ │ │ +000220d0: 666f 7220 7468 6973 2074 6f20 6861 7665 for this to have │ │ │ +000220e0: 2061 6e20 6166 6665 6374 2c20 616c 736f an affect, also │ │ │ +000220f0: 2064 6973 6162 6c65 0a09 0909 2f2f 2070 disable....// p │ │ │ +00022100: 7265 6665 7220 7768 6f6c 6520 7069 6563 refer whole piec │ │ │ +00022110: 6573 2028 6f74 6865 7277 6973 6520 7061 es (otherwise pa │ │ │ +00022120: 7274 6961 6c20 7069 6563 6573 2077 6f75 rtial pieces wou │ │ │ +00022130: 6c64 2062 6520 6465 2d70 7269 6f72 6974 ld be de-priorit │ │ │ +00022140: 697a 6564 290a 0909 096f 7074 696f 6e73 ized)....options │ │ │ +00022150: 207c 3d20 7072 696f 7269 7469 7a65 5f70 |= prioritize_p │ │ │ +00022160: 6172 7469 616c 733b 0a09 0909 7072 6566 artials;....pref │ │ │ +00022170: 6572 5f63 6f6e 7469 6775 6f75 735f 626c er_contiguous_bl │ │ │ +00022180: 6f63 6b73 203d 2030 3b0a 0a09 0909 7265 ocks = 0;.....re │ │ │ +00022190: 7420 7c3d 2070 6963 6b65 725f 6c6f 675f t |= picker_log_ │ │ │ +000221a0: 616c 6572 743a 3a70 6172 7469 616c 5f72 alert::partial_r │ │ │ +000221b0: 6174 696f 3b0a 0909 7d0a 0a09 0969 6620 atio;...}....if │ │ │ +000221c0: 2870 7265 6665 725f 636f 6e74 6967 756f (prefer_contiguo │ │ │ +000221d0: 7573 5f62 6c6f 636b 7329 2072 6574 207c us_blocks) ret | │ │ │ +000221e0: 3d20 7069 636b 6572 5f6c 6f67 5f61 6c65 = picker_log_ale │ │ │ +000221f0: 7274 3a3a 7072 6566 6572 5f63 6f6e 7469 rt::prefer_conti │ │ │ +00022200: 6775 6f75 733b 0a0a 0909 2f2f 206f 6e6c guous;....// onl │ │ │ +00022210: 7920 6f6e 6520 6f66 2072 6172 6573 745f y one of rarest_ │ │ │ +00022220: 6669 7273 7420 616e 6420 7365 7175 656e first and sequen │ │ │ +00022230: 7469 616c 2063 616e 2062 6520 7365 742e tial can be set. │ │ │ +00022240: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00022250: 5428 2828 6f70 7469 6f6e 7320 2661 6d70 T(((options & │ │ │ +00022260: 3b20 7261 7265 7374 5f66 6972 7374 2920 ; rarest_first) │ │ │ +00022270: 3f20 3120 3a20 3029 0a09 0909 2b20 2828 ? 1 : 0)....+ (( │ │ │ +00022280: 6f70 7469 6f6e 7320 2661 6d70 3b20 7365 options & se │ │ │ +00022290: 7175 656e 7469 616c 2920 3f20 3120 3a20 quential) ? 1 : │ │ │ +000222a0: 3029 2026 6c74 3b3d 2031 293b 0a23 6966 0) <= 1);.#if │ │ │ +000222b0: 6465 6620 544f 5252 454e 545f 4558 5045 def TORRENT_EXPE │ │ │ +000222c0: 4e53 4956 455f 494e 5641 5249 414e 545f NSIVE_INVARIANT_ │ │ │ +000222d0: 4348 4543 4b53 0a09 0949 4e56 4152 4941 CHECKS...INVARIA │ │ │ +000222e0: 4e54 5f43 4845 434b 3b0a 2365 6e64 6966 NT_CHECK;.#endif │ │ │ +000222f0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00022300: 5428 6e75 6d5f 626c 6f63 6b73 2026 6774 T(num_blocks > │ │ │ +00022310: 3b20 3029 3b0a 0909 544f 5252 454e 545f ; 0);...TORRENT_ │ │ │ +00022320: 4153 5345 5254 2870 6965 6365 732e 7369 ASSERT(pieces.si │ │ │ +00022330: 7a65 2829 203d 3d20 696e 7428 6d5f 7069 ze() == int(m_pi │ │ │ +00022340: 6563 655f 6d61 702e 7369 7a65 2829 2929 ece_map.size())) │ │ │ +00022350: 3b0a 0a09 0954 4f52 5245 4e54 5f41 5353 ;....TORRENT_ASS │ │ │ +00022360: 4552 5428 216d 5f70 7269 6f72 6974 795f ERT(!m_priority_ │ │ │ +00022370: 626f 756e 6461 7269 6573 2e65 6d70 7479 boundaries.empty │ │ │ +00022380: 2829 207c 7c20 6d5f 6469 7274 7929 3b0a () || m_dirty);. │ │ │ +00022390: 0a09 092f 2f20 7468 6973 2077 696c 6c20 ...// this will │ │ │ +000223a0: 6265 2066 696c 6c65 6420 7769 7468 2062 be filled with b │ │ │ +000223b0: 6c6f 636b 7320 7468 6174 2077 6520 7368 locks that we sh │ │ │ +000223c0: 6f75 6c64 206e 6f74 2072 6571 7565 7374 ould not request │ │ │ +000223d0: 0a09 092f 2f20 756e 6c65 7373 2077 6520 ...// unless we │ │ │ +000223e0: 6361 6e27 7420 6669 6e64 206e 756d 5f62 can't find num_b │ │ │ +000223f0: 6c6f 636b 7320 616d 6f6e 6720 7468 6520 locks among the │ │ │ +00022400: 6f74 6865 7220 6f6e 6573 2e0a 0909 7374 other ones....st │ │ │ +00022410: 643a 3a76 6563 746f 7226 6c74 3b70 6965 d::vector<pie │ │ │ +00022420: 6365 5f62 6c6f 636b 2667 743b 2062 6163 ce_block> bac │ │ │ +00022430: 6b75 705f 626c 6f63 6b73 3b0a 0909 7374 kup_blocks;...st │ │ │ +00022440: 643a 3a76 6563 746f 7226 6c74 3b70 6965 d::vector<pie │ │ │ +00022450: 6365 5f69 6e64 6578 5f74 2667 743b 2069 ce_index_t> i │ │ │ +00022460: 676e 6f72 6564 5f70 6965 6365 733b 0a0a gnored_pieces;.. │ │ │ +00022470: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e │ │ │ +00022480: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +000224b0: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ +000224e0: 2f70 6965 6365 5f70 6963 6b65 722e 6370 /piece_picker.cp │ │ │ +000224f0: 703a 3235 3735 3c2f 613e 3c2f 7464 3e3c p:2575< │ │ │ +00022500: 7464 3e74 6865 2066 6972 7374 5f62 6c6f td>the first_blo │ │ │ +00022510: 636b 2072 6574 7572 6e65 6420 6865 7265 ck returned here │ │ │ +00022520: 2069 7320 7468 6520 6c61 7267 6573 7420 is the largest │ │ │ +00022530: 6672 6565 2072 616e 6765 2c20 6e6f 7420 free range, not │ │ │ +00022540: 7468 6520 6669 7273 742d 6669 7420 7261 the first-fit ra │ │ │ +00022550: 6e67 652c 2077 6869 6368 2077 6f75 6c64 nge, which would │ │ │ +00022560: 2062 6520 6265 7474 6572 3c2f 7464 3e3c be better< │ │ │ +00022570: 2f74 723e 3c74 7220 6964 3d22 3638 2220 /tr>

    the first │ │ │ +000225c0: 5f62 6c6f 636b 2072 6574 7572 6e65 6420 _block returned │ │ │ +000225d0: 6865 7265 2069 7320 7468 6520 6c61 7267 here is the larg │ │ │ +000225e0: 6573 7420 6672 6565 2072 616e 6765 2c20 est free range, │ │ │ +000225f0: 6e6f 740a 7468 6520 6669 7273 742d 6669 not.the first-fi │ │ │ +00022600: 7420 7261 6e67 652c 2077 6869 6368 2077 t range, which w │ │ │ +00022610: 6f75 6c64 2062 6520 6265 7474 6572 3c2f ould be better

    ../src/pi │ │ │ +00022630: 6563 655f 7069 636b 6572 2e63 7070 3a32 ece_picker.cpp:2 │ │ │ +00022640: 3537 353c 2f68 343e 3c70 7265 2073 7479 575

    .{...for (auto
    │ │ │ +00022690: 2063 6f6e 7374 2661 6d70 3b20 6220 3a20   const& b : 
    │ │ │ +000226a0: 6d5f 626c 6f63 6b5f 696e 666f 290a 0909  m_block_info)...
    │ │ │ +000226b0: 7b0a 0909 0954 4f52 5245 4e54 5f41 5353  {....TORRENT_ASS
    │ │ │ +000226c0: 4552 5428 622e 7065 6572 203d 3d20 6e75  ERT(b.peer == nu
    │ │ │ +000226d0: 6c6c 7074 7220 7c7c 2073 7461 7469 635f  llptr || static_
    │ │ │ +000226e0: 6361 7374 266c 743b 6175 783a 3a74 6f72  cast<aux::tor
    │ │ │ +000226f0: 7265 6e74 5f70 6565 722a 2667 743b 2862  rent_peer*>(b
    │ │ │ +00022700: 2e70 6565 7229 2d26 6774 3b69 6e5f 7573  .peer)->in_us
    │ │ │ +00022710: 6529 3b0a 0909 7d0a 097d 0a23 656e 6469  e);...}..}.#endi
    │ │ │ +00022720: 660a 0a09 766f 6964 2070 6965 6365 5f70  f...void piece_p
    │ │ │ +00022730: 6963 6b65 723a 3a63 6c65 6172 5f70 6565  icker::clear_pee
    │ │ │ +00022740: 7228 6175 783a 3a74 6f72 7265 6e74 5f70  r(aux::torrent_p
    │ │ │ +00022750: 6565 722a 2070 6565 7229 0a09 7b0a 0909  eer* peer)..{...
    │ │ │ +00022760: 666f 7220 2861 7574 6f26 616d 703b 2062  for (auto& b
    │ │ │ +00022770: 203a 206d 5f62 6c6f 636b 5f69 6e66 6f29   : m_block_info)
    │ │ │ +00022780: 0a09 097b 0a09 0909 6966 2028 622e 7065  ...{....if (b.pe
    │ │ │ +00022790: 6572 203d 3d20 7065 6572 2920 622e 7065  er == peer) b.pe
    │ │ │ +000227a0: 6572 203d 206e 756c 6c70 7472 3b0a 0909  er = nullptr;...
    │ │ │ +000227b0: 7d0a 097d 0a0a 092f 2f20 7468 6520 6669  }..}...// the fi
    │ │ │ +000227c0: 7273 7420 626f 6f6c 2069 7320 7472 7565  rst bool is true
    │ │ │ +000227d0: 2069 6620 7468 6973 2069 7320 7468 6520   if this is the 
    │ │ │ +000227e0: 6f6e 6c79 2070 6565 7220 7468 6174 2068  only peer that h
    │ │ │ +000227f0: 6173 2072 6571 7565 7374 6564 2061 6e64  as requested and
    │ │ │ +00022800: 2064 6f77 6e6c 6f61 6465 640a 092f 2f20   downloaded..// 
    │ │ │ +00022810: 626c 6f63 6b73 2066 726f 6d20 7468 6973  blocks from this
    │ │ │ +00022820: 2070 6965 6365 2e0a 092f 2f20 7468 6520   piece...// the 
    │ │ │ +00022830: 7365 636f 6e64 2062 6f6f 6c20 6973 2074  second bool is t
    │ │ │ +00022840: 7275 6520 6966 2074 6869 7320 6973 2074  rue if this is t
    │ │ │ +00022850: 6865 206f 6e6c 7920 6163 7469 7665 2070  he only active p
    │ │ │ +00022860: 6565 7220 7468 6174 2069 7320 7265 7175  eer that is requ
    │ │ │ +00022870: 6573 7469 6e67 0a09 2f2f 2061 6e64 2064  esting..// and d
    │ │ │ +00022880: 6f77 6e6c 6f61 6469 6e67 2062 6c6f 636b  ownloading block
    │ │ │ +00022890: 7320 6672 6f6d 2074 6869 7320 7069 6563  s from this piec
    │ │ │ +000228a0: 652e 2041 6374 6976 6520 6d65 616e 7320  e. Active means 
    │ │ │ +000228b0: 6861 7669 6e67 2061 2063 6f6e 6e65 6374  having a connect
    │ │ │ +000228c0: 696f 6e2e 0a3c 6469 7620 7374 796c 653d  ion..
    .std::tuple&l │ │ │ +00022900: 743b 626f 6f6c 2c20 626f 6f6c 2c20 696e t;bool, bool, in │ │ │ +00022910: 742c 2069 6e74 2667 743b 2070 6965 6365 t, int> piece │ │ │ +00022920: 5f70 6963 6b65 723a 3a72 6571 7565 7374 _picker::request │ │ │ +00022930: 6564 5f66 726f 6d28 0a3c 2f64 6976 3e09 ed_from(.
    . │ │ │ +00022940: 0970 6965 6365 5f70 6963 6b65 723a 3a64 .piece_picker::d │ │ │ +00022950: 6f77 6e6c 6f61 6469 6e67 5f70 6965 6365 ownloading_piece │ │ │ +00022960: 2063 6f6e 7374 2661 6d70 3b20 700a 0909 const& p... │ │ │ +00022970: 2c20 696e 7420 636f 6e73 7420 6e75 6d5f , int const num_ │ │ │ +00022980: 626c 6f63 6b73 5f69 6e5f 7069 6563 652c blocks_in_piece, │ │ │ +00022990: 2061 7578 3a3a 746f 7272 656e 745f 7065 aux::torrent_pe │ │ │ +000229a0: 6572 2a20 7065 6572 2920 636f 6e73 740a er* peer) const. │ │ │ +000229b0: 097b 0a09 0962 6f6f 6c20 6578 636c 7573 .{...bool exclus │ │ │ +000229c0: 6976 6520 3d20 7472 7565 3b0a 0909 626f ive = true;...bo │ │ │ +000229d0: 6f6c 2065 7863 6c75 7369 7665 5f61 6374 ol exclusive_act │ │ │ +000229e0: 6976 6520 3d20 7472 7565 3b0a 0909 696e ive = true;...in │ │ │ +000229f0: 7420 636f 6e74 6967 756f 7573 5f62 6c6f t contiguous_blo │ │ │ +00022a00: 636b 7320 3d20 303b 0a09 0969 6e74 206d cks = 0;...int m │ │ │ +00022a10: 6178 5f63 6f6e 7469 6775 6f75 7320 3d20 ax_contiguous = │ │ │ +00022a20: 303b 0a09 0969 6e74 2066 6972 7374 5f62 0;...int first_b │ │ │ +00022a30: 6c6f 636b 203d 2030 3b0a 0909 696e 7420 lock = 0;...int │ │ │ +00022a40: 6964 7820 3d20 2d31 3b0a 0909 666f 7220 idx = -1;...for │ │ │ +00022a50: 2861 7574 6f20 636f 6e73 7426 616d 703b (auto const& │ │ │ +00022a60: 2069 6e66 6f20 3a20 626c 6f63 6b73 5f66 info : blocks_f │ │ │ +00022a70: 6f72 5f70 6965 6365 2870 2929 0a09 097b or_piece(p))...{ │ │ │ +00022a80: 0a09 0909 2b2b 6964 783b 0a09 0909 544f ....++idx;....TO │ │ │ +00022a90: 5252 454e 545f 4153 5345 5254 2869 6e66 RRENT_ASSERT(inf │ │ │ +00022aa0: 6f2e 7065 6572 203d 3d20 6e75 6c6c 7074 o.peer == nullpt │ │ │ +00022ab0: 7220 7c7c 2069 6e66 6f2e 7065 6572 2d26 r || info.peer-& │ │ │ +00022ac0: 6774 3b69 6e5f 7573 6529 3b0a 0909 0954 gt;in_use);....T │ │ │ +00022ad0: 4f52 5245 4e54 5f41 5353 4552 5428 696e ORRENT_ASSERT(in │ │ │ +00022ae0: 666f 2e70 6965 6365 5f69 6e64 6578 203d fo.piece_index = │ │ │ +00022af0: 3d20 702e 696e 6465 7829 3b0a 0909 0969 = p.index);....i │ │ │ +00022b00: 6620 2869 6e66 6f2e 7374 6174 6520 3d3d f (info.state == │ │ │ +00022b10: 2070 6965 6365 5f70 6963 6b65 723a 3a62 piece_picker::b │ │ │ +00022b20: 6c6f 636b 5f69 6e66 6f3a 3a73 7461 7465 lock_info::state │ │ │ +00022b30: 5f6e 6f6e 6529 0a09 0909 7b0a 0909 0909 _none)....{..... │ │ │ +00022b40: 2b2b 636f 6e74 6967 756f 7573 5f62 6c6f ++contiguous_blo │ │ │ +00022b50: 636b 733b 0a09 0909 0963 6f6e 7469 6e75 cks;.....continu │ │ │ +00022b60: 653b 0a09 0909 7d0a 0909 0969 6620 2863 e;....}....if (c │ │ │ +00022b70: 6f6e 7469 6775 6f75 735f 626c 6f63 6b73 ontiguous_blocks │ │ │ +00022b80: 2026 6774 3b20 6d61 785f 636f 6e74 6967 > max_contig │ │ │ +00022b90: 756f 7573 290a 0909 097b 0a09 0909 096d uous)....{.....m │ │ │ +00022ba0: 6178 5f63 6f6e 7469 6775 6f75 7320 3d20 ax_contiguous = │ │ │ +00022bb0: 636f 6e74 6967 756f 7573 5f62 6c6f 636b contiguous_block │ │ │ +00022bc0: 733b 0a09 0909 0966 6972 7374 5f62 6c6f s;.....first_blo │ │ │ +00022bd0: 636b 203d 2069 6478 202d 2063 6f6e 7469 ck = idx - conti │ │ │ +00022be0: 6775 6f75 735f 626c 6f63 6b73 3b0a 0909 guous_blocks;... │ │ │ +00022bf0: 097d 0a09 0909 636f 6e74 6967 756f 7573 .}....contiguous │ │ │ +00022c00: 5f62 6c6f 636b 7320 3d20 303b 0a09 0909 _blocks = 0;.... │ │ │ +00022c10: 6966 2028 696e 666f 2e70 6565 7220 213d if (info.peer != │ │ │ +00022c20: 2070 6565 7229 0a09 0909 7b0a 0909 0909 peer)....{..... │ │ │ +00022c30: 6578 636c 7573 6976 6520 3d20 6661 6c73 exclusive = fals │ │ │ +00022c40: 653b 0a09 0909 0969 6620 2869 6e66 6f2e e;.....if (info. │ │ │ +00022c50: 7374 6174 6520 3d3d 2070 6965 6365 5f70 state == piece_p │ │ │ +00022c60: 6963 6b65 723a 3a62 6c6f 636b 5f69 6e66 icker::block_inf │ │ │ +00022c70: 6f3a 3a73 7461 7465 5f72 6571 7565 7374 o::state_request │ │ │ +00022c80: 6564 0a09 0909 0909 2661 6d70 3b26 616d ed......&&am │ │ │ +00022c90: 703b 2069 6e66 6f2e 7065 6572 2021 3d20 p; info.peer != │ │ │ +00022ca0: 6e75 6c6c 7074 7229 0a3c 2f70 7265 3e3c nullptr).
    < │ │ │ +00022cb0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00022ce0: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ +00022cf0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/piece_ │ │ │ +00022d20: 7069 636b 6572 2e63 7070 3a33 3435 333c picker.cpp:3453< │ │ │ +00022d30: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ +00022d40: 6f75 6c64 2062 6520 6e69 6365 2069 6620 ould be nice if │ │ │ +00022d50: 7468 6973 2063 6f75 6c64 2062 6520 666f this could be fo │ │ │ +00022d60: 6c64 6564 2069 6e74 6f20 6c6f 636b 5f70 lded into lock_p │ │ │ +00022d70: 6965 6365 2829 2074 6865 206d 6169 6e20 iece() the main │ │ │ +00022d80: 6469 7374 696e 6374 696f 6e20 6973 2074 distinction is t │ │ │ +00022d90: 6861 7420 7468 6973 2061 6c73 6f20 6d61 hat this also ma │ │ │ +00022da0: 696e 7461 696e 7320 7468 6520 6d5f 6e75 intains the m_nu │ │ │ +00022db0: 6d5f 6861 7665 2063 6f75 6e74 6572 2061 m_have counter a │ │ │ +00022dc0: 6e64 2074 6865 2070 6173 7365 645f 6861 nd the passed_ha │ │ │ +00022dd0: 7368 5f63 6865 636b 206d 656d 6265 7220 sh_check member │ │ │ +00022de0: 4973 2074 6865 7265 2065 7665 7220 6120 Is there ever a │ │ │ +00022df0: 6361 7365 2077 6865 7265 2077 6520 6361 case where we ca │ │ │ +00022e00: 6c6c 2077 7269 7465 2066 6169 6c65 6420 ll write failed │ │ │ +00022e10: 7769 7468 6f75 7420 616c 736f 206c 6f63 without also loc │ │ │ +00022e20: 6b69 6e67 2074 6865 2070 6965 6365 3f20 king the piece? │ │ │ +00022e30: 5065 7268 6170 7320 7772 6974 655f 6661 Perhaps write_fa │ │ │ +00022e40: 696c 6564 2829 2073 686f 756c 6420 696d iled() should im │ │ │ +00022e50: 706c 7920 6c6f 636b 696e 6720 6974 2e3c ply locking it.< │ │ │ +00022e60: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it w │ │ │ +00022eb0: 6f75 6c64 2062 6520 6e69 6365 2069 6620 ould be nice if │ │ │ +00022ec0: 7468 6973 2063 6f75 6c64 2062 6520 666f this could be fo │ │ │ +00022ed0: 6c64 6564 2069 6e74 6f20 6c6f 636b 5f70 lded into lock_p │ │ │ +00022ee0: 6965 6365 2829 0a74 6865 206d 6169 6e20 iece().the main │ │ │ +00022ef0: 6469 7374 696e 6374 696f 6e20 6973 2074 distinction is t │ │ │ +00022f00: 6861 7420 7468 6973 2061 6c73 6f20 6d61 hat this also ma │ │ │ +00022f10: 696e 7461 696e 7320 7468 6520 6d5f 6e75 intains the m_nu │ │ │ +00022f20: 6d5f 6861 7665 0a63 6f75 6e74 6572 2061 m_have.counter a │ │ │ +00022f30: 6e64 2074 6865 2070 6173 7365 645f 6861 nd the passed_ha │ │ │ +00022f40: 7368 5f63 6865 636b 206d 656d 6265 720a sh_check member. │ │ │ +00022f50: 4973 2074 6865 7265 2065 7665 7220 6120 Is there ever a │ │ │ +00022f60: 6361 7365 2077 6865 7265 2077 6520 6361 case where we ca │ │ │ +00022f70: 6c6c 2077 7269 7465 2066 6169 6c65 6420 ll write failed │ │ │ +00022f80: 7769 7468 6f75 7420 616c 736f 206c 6f63 without also loc │ │ │ +00022f90: 6b69 6e67 0a74 6865 2070 6965 6365 3f20 king.the piece? │ │ │ +00022fa0: 5065 7268 6170 7320 7772 6974 655f 6661 Perhaps write_fa │ │ │ +00022fb0: 696c 6564 2829 2073 686f 756c 6420 696d iled() should im │ │ │ +00022fc0: 706c 7920 6c6f 636b 696e 6720 6974 2e3c ply locking it.< │ │ │ +00022fd0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00022fe0: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ +00022ff0: 3334 3533 3c2f 6834 3e3c 7072 6520 7374 3453

    ...auto const
    │ │ │ +00023040: 2073 7461 7465 203d 206d 5f70 6965 6365   state = m_piece
    │ │ │ +00023050: 5f6d 6170 5b70 6965 6365 5d2e 646f 776e  _map[piece].down
    │ │ │ +00023060: 6c6f 6164 5f71 7565 7565 2829 3b0a 0909  load_queue();...
    │ │ │ +00023070: 6966 2028 7374 6174 6520 3d3d 2070 6965  if (state == pie
    │ │ │ +00023080: 6365 5f70 6f73 3a3a 7069 6563 655f 6f70  ce_pos::piece_op
    │ │ │ +00023090: 656e 2920 7265 7475 726e 3b0a 0909 6175  en) return;...au
    │ │ │ +000230a0: 746f 2063 6f6e 7374 2069 203d 2066 696e  to const i = fin
    │ │ │ +000230b0: 645f 646c 5f70 6965 6365 2873 7461 7465  d_dl_piece(state
    │ │ │ +000230c0: 2c20 7069 6563 6529 3b0a 0909 6966 2028  , piece);...if (
    │ │ │ +000230d0: 6920 3d3d 206d 5f64 6f77 6e6c 6f61 6473  i == m_downloads
    │ │ │ +000230e0: 5b73 7461 7465 5d2e 656e 6428 2929 2072  [state].end()) r
    │ │ │ +000230f0: 6574 7572 6e3b 0a0a 0909 544f 5252 454e  eturn;....TORREN
    │ │ │ +00023100: 545f 4153 5345 5254 2869 2d26 6774 3b70  T_ASSERT(i->p
    │ │ │ +00023110: 6173 7365 645f 6861 7368 5f63 6865 636b  assed_hash_check
    │ │ │ +00023120: 203d 3d20 6661 6c73 6529 3b0a 0909 6966   == false);...if
    │ │ │ +00023130: 2028 692d 2667 743b 7061 7373 6564 5f68   (i->passed_h
    │ │ │ +00023140: 6173 685f 6368 6563 6b29 0a09 097b 0a09  ash_check)...{..
    │ │ │ +00023150: 0909 2f2f 2069 7427 7320 6e6f 7420 636c  ..// it's not cl
    │ │ │ +00023160: 6561 7220 7768 7920 7468 6973 2077 6f75  ear why this wou
    │ │ │ +00023170: 6c64 2068 6170 7065 6e2c 0a09 0909 2f2f  ld happen,....//
    │ │ │ +00023180: 2062 7574 2069 7420 7365 656d 7320 7265   but it seems re
    │ │ │ +00023190: 6173 6f6e 6162 6c65 2074 6f20 6e6f 7420  asonable to not 
    │ │ │ +000231a0: 6272 6561 6b20 7468 650a 0909 092f 2f20  break the....// 
    │ │ │ +000231b0: 6163 636f 756e 7469 6e67 206f 7665 7220  accounting over 
    │ │ │ +000231c0: 6974 2e0a 0909 0969 2d26 6774 3b70 6173  it.....i->pas
    │ │ │ +000231d0: 7365 645f 6861 7368 5f63 6865 636b 203d  sed_hash_check =
    │ │ │ +000231e0: 2066 616c 7365 3b0a 0909 0961 6363 6f75   false;....accou
    │ │ │ +000231f0: 6e74 5f6c 6f73 7428 7069 6563 6529 3b0a  nt_lost(piece);.
    │ │ │ +00023200: 0909 7d0a 0a09 092f 2f20 7072 6576 656e  ..}....// preven
    │ │ │ +00023210: 7420 7468 6973 2070 6965 6365 2066 726f  t this piece fro
    │ │ │ +00023220: 6d20 6265 696e 6720 7069 636b 6564 2075  m being picked u
    │ │ │ +00023230: 6e74 696c 2069 7427 7320 7265 7374 6f72  ntil it's restor
    │ │ │ +00023240: 6564 0a09 0969 2d26 6774 3b6c 6f63 6b65  ed...i->locke
    │ │ │ +00023250: 6420 3d20 7472 7565 3b0a 097d 0a0a 3c64  d = true;..}...voi
    │ │ │ +00023290: 6420 7069 6563 655f 7069 636b 6572 3a3a  d piece_picker::
    │ │ │ +000232a0: 7772 6974 655f 6661 696c 6564 2870 6965  write_failed(pie
    │ │ │ +000232b0: 6365 5f62 6c6f 636b 2063 6f6e 7374 2062  ce_block const b
    │ │ │ +000232c0: 6c6f 636b 290a 3c2f 6469 763e 097b 0a09  lock).
    .{.. │ │ │ +000232d0: 0949 4e56 4152 4941 4e54 5f43 4845 434b .INVARIANT_CHECK │ │ │ +000232e0: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f55 ;..#if TORRENT_U │ │ │ +000232f0: 5345 5f49 4e56 4152 4941 4e54 5f43 4845 SE_INVARIANT_CHE │ │ │ +00023300: 434b 530a 0909 6368 6563 6b5f 7069 6563 CKS...check_piec │ │ │ +00023310: 655f 7374 6174 6528 293b 0a23 656e 6469 e_state();.#endi │ │ │ +00023320: 660a 0a23 6966 6465 6620 544f 5252 454e f..#ifdef TORREN │ │ │ +00023330: 545f 5049 434b 4552 5f4c 4f47 0a09 0973 T_PICKER_LOG...s │ │ │ +00023340: 7464 3a3a 6365 7272 2026 6c74 3b26 6c74 td::cerr << │ │ │ +00023350: 3b20 225b 2220 266c 743b 266c 743b 2074 ; "[" << t │ │ │ +00023360: 6869 7320 266c 743b 266c 743b 2022 5d20 his << "] │ │ │ +00023370: 2220 266c 743b 266c 743b 2022 7772 6974 " << "writ │ │ │ +00023380: 655f 6661 696c 6564 2820 7b22 2026 6c74 e_failed( {" < │ │ │ +00023390: 3b26 6c74 3b20 626c 6f63 6b2e 7069 6563 ;< block.piec │ │ │ +000233a0: 655f 696e 6465 7820 266c 743b 266c 743b e_index << │ │ │ +000233b0: 2022 2c20 2220 266c 743b 266c 743b 2062 ", " << b │ │ │ +000233c0: 6c6f 636b 2e62 6c6f 636b 5f69 6e64 6578 lock.block_index │ │ │ +000233d0: 2026 6c74 3b26 6c74 3b20 227d 2029 2220 << "} )" │ │ │ +000233e0: 266c 743b 266c 743b 2073 7464 3a3a 656e << std::en │ │ │ +000233f0: 646c 3b0a 2365 6e64 6966 0a0a 0909 6175 dl;.#endif....au │ │ │ +00023400: 746f 2063 6f6e 7374 2073 7461 7465 203d to const state = │ │ │ +00023410: 206d 5f70 6965 6365 5f6d 6170 5b62 6c6f m_piece_map[blo │ │ │ +00023420: 636b 2e70 6965 6365 5f69 6e64 6578 5d2e ck.piece_index]. │ │ │ +00023430: 646f 776e 6c6f 6164 5f71 7565 7565 2829 download_queue() │ │ │ +00023440: 3b0a 0909 6966 2028 7374 6174 6520 3d3d ;...if (state == │ │ │ +00023450: 2070 6965 6365 5f70 6f73 3a3a 7069 6563 piece_pos::piec │ │ │ +00023460: 655f 6f70 656e 2920 7265 7475 726e 3b0a e_open) return;. │ │ │ +00023470: 0909 6175 746f 2069 203d 2066 696e 645f ..auto i = find_ │ │ │ +00023480: 646c 5f70 6965 6365 2873 7461 7465 2c20 dl_piece(state, │ │ │ +00023490: 626c 6f63 6b2e 7069 6563 655f 696e 6465 block.piece_inde │ │ │ +000234a0: 7829 3b0a 0909 6966 2028 6920 3d3d 206d x);...if (i == m │ │ │ +000234b0: 5f64 6f77 6e6c 6f61 6473 5b73 7461 7465 _downloads[state │ │ │ +000234c0: 5d2e 656e 6428 2929 2072 6574 7572 6e3b ].end()) return; │ │ │ +000234d0: 0a0a 0909 6175 746f 2063 6f6e 7374 2062 ....auto const b │ │ │ +000234e0: 696e 666f 203d 206d 7574 6162 6c65 5f62 info = mutable_b │ │ │ +000234f0: 6c6f 636b 735f 666f 725f 7069 6563 6528 locks_for_piece( │ │ │ +00023500: 2a69 293b 0a09 0962 6c6f 636b 5f69 6e66 *i);...block_inf │ │ │ +00023510: 6f26 616d 703b 2069 6e66 6f20 3d20 6269 o& info = bi │ │ │ +00023520: 6e66 6f5b 626c 6f63 6b2e 626c 6f63 6b5f nfo[block.block_ │ │ │ +00023530: 696e 6465 785d 3b0a 0909 544f 5252 454e index];...TORREN │ │ │ +00023540: 545f 4153 5345 5254 2826 616d 703b 696e T_ASSERT(&in │ │ │ +00023550: 666f 2026 6774 3b3d 2026 616d 703b 6d5f fo >= &m_ │ │ │ +00023560: 626c 6f63 6b5f 696e 666f 5b30 5d29 3b0a block_info[0]);. │ │ │ +00023570: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00023580: 2826 616d 703b 696e 666f 2026 6c74 3b20 (&info < │ │ │ +00023590: 2661 6d70 3b6d 5f62 6c6f 636b 5f69 6e66 &m_block_inf │ │ │ +000235a0: 6f5b 305d 202b 206d 5f62 6c6f 636b 5f69 o[0] + m_block_i │ │ │ +000235b0: 6e66 6f2e 7369 7a65 2829 293b 0a09 0954 nfo.size());...T │ │ │ +000235c0: 4f52 5245 4e54 5f41 5353 4552 5428 696e ORRENT_ASSERT(in │ │ │ +000235d0: 666f 2e70 6965 6365 5f69 6e64 6578 203d fo.piece_index = │ │ │ +000235e0: 3d20 626c 6f63 6b2e 7069 6563 655f 696e = block.piece_in │ │ │ +000235f0: 6465 7829 3b0a 0909 544f 5252 454e 545f dex);...TORRENT_ │ │ │ +00023600: 4153 5345 5254 2869 6e66 6f2e 7374 6174 ASSERT(info.stat │ │ │ +00023610: 6520 3d3d 2062 6c6f 636b 5f69 6e66 6f3a e == block_info: │ │ │ +00023620: 3a73 7461 7465 5f77 7269 7469 6e67 293b :state_writing); │ │ │ +00023630: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00023640: 5428 696e 666f 2e6e 756d 5f70 6565 7273 T(info.num_peers │ │ │ +00023650: 203d 3d20 3029 3b0a 0a09 0954 4f52 5245 == 0);....TORRE │ │ │ +00023660: 4e54 5f41 5353 4552 5428 692d 2667 743b NT_ASSERT(i-> │ │ │ +00023670: 7772 6974 696e 6720 2667 743b 2030 293b writing > 0); │ │ │ +00023680: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00023690: 5428 696e 666f 2e73 7461 7465 203d 3d20 T(info.state == │ │ │ +000236a0: 626c 6f63 6b5f 696e 666f 3a3a 7374 6174 block_info::stat │ │ │ +000236b0: 655f 7772 6974 696e 6729 3b0a 0a09 0969 e_writing);....i │ │ │ +000236c0: 6620 2869 6e66 6f2e 7374 6174 6520 3d3d f (info.state == │ │ │ +000236d0: 2062 6c6f 636b 5f69 6e66 6f3a 3a73 7461 block_info::sta │ │ │ +000236e0: 7465 5f66 696e 6973 6865 6429 2072 6574 te_finished) ret │ │ │ +000236f0: 7572 6e3b 0a09 0969 6620 2869 6e66 6f2e urn;...if (info. │ │ │ +00023700: 7374 6174 6520 3d3d 2062 6c6f 636b 5f69 state == block_i │ │ │ +00023710: 6e66 6f3a 3a73 7461 7465 5f77 7269 7469 nfo::state_writi │ │ │ +00023720: 6e67 2920 2d2d 692d 2667 743b 7772 6974 ng) --i->writ │ │ │ +00023730: 696e 673b 0a0a 3c2f 7072 653e 3c2f 7464 ing;..relevance │ │ │ +00023770: 266e 6273 703b 323c 2f74 643e 3c74 643e  2 │ │ │ +00023780: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ +000237a0: 2e2e 2f73 7263 2f75 706e 702e 6370 703a ../src/upnp.cpp: │ │ │ +000237b0: 3933 3c2f 613e 3c2f 7464 3e3c 7464 3e75 93u │ │ │ +000237c0: 7365 2062 6f6f 7374 3a3a 6173 696f 3a3a se boost::asio:: │ │ │ +000237d0: 6970 3a3a 6e65 7477 6f72 6b20 696e 7374 ip::network inst │ │ │ +000237e0: 6561 6420 6f66 206e 6574 6d61 736b 3c2f ead of netmask

    use b │ │ │ +00023840: 6f6f 7374 3a3a 6173 696f 3a3a 6970 3a3a oost::asio::ip:: │ │ │ +00023850: 6e65 7477 6f72 6b20 696e 7374 6561 6420 network instead │ │ │ +00023860: 6f66 206e 6574 6d61 736b 3c2f 6832 3e3c of netmask

    < │ │ │ +00023870: 6834 3e2e 2e2f 7372 632f 7570 6e70 2e63 h4>../src/upnp.c │ │ │ +00023880: 7070 3a39 333c 2f68 343e 3c70 7265 2073 pp:93
    ..|| string_
    │ │ │ +000238d0: 6571 7561 6c5f 6e6f 5f63 6173 6528 636f  equal_no_case(co
    │ │ │ +000238e0: 6e74 656e 745f 7479 7065 2c20 2261 7070  ntent_type, "app
    │ │ │ +000238f0: 6c69 6361 7469 6f6e 2f73 6f61 702b 786d  lication/soap+xm
    │ │ │ +00023900: 6c22 5f73 7629 3b0a 7d0a 0a75 706e 703a  l"_sv);.}..upnp:
    │ │ │ +00023910: 3a72 6f6f 7464 6576 6963 653a 3a72 6f6f  :rootdevice::roo
    │ │ │ +00023920: 7464 6576 6963 6528 2920 3d20 6465 6661  tdevice() = defa
    │ │ │ +00023930: 756c 743b 0a0a 2369 6620 544f 5252 454e  ult;..#if TORREN
    │ │ │ +00023940: 545f 5553 455f 4153 5345 5254 530a 7570  T_USE_ASSERTS.up
    │ │ │ +00023950: 6e70 3a3a 726f 6f74 6465 7669 6365 3a3a  np::rootdevice::
    │ │ │ +00023960: 7e72 6f6f 7464 6576 6963 6528 290a 7b0a  ~rootdevice().{.
    │ │ │ +00023970: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +00023980: 6d61 6769 6320 3d3d 2031 3333 3729 3b0a  magic == 1337);.
    │ │ │ +00023990: 096d 6167 6963 203d 2030 3b0a 7d0a 2365  .magic = 0;.}.#e
    │ │ │ +000239a0: 6c73 650a 7570 6e70 3a3a 726f 6f74 6465  lse.upnp::rootde
    │ │ │ +000239b0: 7669 6365 3a3a 7e72 6f6f 7464 6576 6963  vice::~rootdevic
    │ │ │ +000239c0: 6528 2920 3d20 6465 6661 756c 743b 0a23  e() = default;.#
    │ │ │ +000239d0: 656e 6469 660a 0a75 706e 703a 3a72 6f6f  endif..upnp::roo
    │ │ │ +000239e0: 7464 6576 6963 653a 3a72 6f6f 7464 6576  tdevice::rootdev
    │ │ │ +000239f0: 6963 6528 726f 6f74 6465 7669 6365 2063  ice(rootdevice c
    │ │ │ +00023a00: 6f6e 7374 2661 6d70 3b29 203d 2064 6566  onst&) = def
    │ │ │ +00023a10: 6175 6c74 3b0a 7570 6e70 3a3a 726f 6f74  ault;.upnp::root
    │ │ │ +00023a20: 6465 7669 6365 2661 6d70 3b20 7570 6e70  device& upnp
    │ │ │ +00023a30: 3a3a 726f 6f74 6465 7669 6365 3a3a 6f70  ::rootdevice::op
    │ │ │ +00023a40: 6572 6174 6f72 3d28 726f 6f74 6465 7669  erator=(rootdevi
    │ │ │ +00023a50: 6365 2063 6f6e 7374 2661 6d70 3b29 2026  ce const&) &
    │ │ │ +00023a60: 616d 703b 203d 2064 6566 6175 6c74 3b0a  amp; = default;.
    │ │ │ +00023a70: 7570 6e70 3a3a 726f 6f74 6465 7669 6365  upnp::rootdevice
    │ │ │ +00023a80: 3a3a 726f 6f74 6465 7669 6365 2872 6f6f  ::rootdevice(roo
    │ │ │ +00023a90: 7464 6576 6963 6526 616d 703b 2661 6d70  tdevice&&
    │ │ │ +00023aa0: 3b29 206e 6f65 7863 6570 7420 3d20 6465  ;) noexcept = de
    │ │ │ +00023ab0: 6661 756c 743b 0a75 706e 703a 3a72 6f6f  fault;.upnp::roo
    │ │ │ +00023ac0: 7464 6576 6963 6526 616d 703b 2075 706e  tdevice& upn
    │ │ │ +00023ad0: 703a 3a72 6f6f 7464 6576 6963 653a 3a6f  p::rootdevice::o
    │ │ │ +00023ae0: 7065 7261 746f 723d 2872 6f6f 7464 6576  perator=(rootdev
    │ │ │ +00023af0: 6963 6526 616d 703b 2661 6d70 3b29 2026  ice&&) &
    │ │ │ +00023b00: 616d 703b 203d 2064 6566 6175 6c74 3b0a  amp; = default;.
    │ │ │ +00023b10: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    u │ │ │ +00023b40: 706e 703a 3a75 706e 7028 696f 5f63 6f6e pnp::upnp(io_con │ │ │ +00023b50: 7465 7874 2661 6d70 3b20 696f 730a 3c2f text& ios.., aux::sess │ │ │ +00023b70: 696f 6e5f 7365 7474 696e 6773 2063 6f6e ion_settings con │ │ │ +00023b80: 7374 2661 6d70 3b20 7365 7474 696e 6773 st& settings │ │ │ +00023b90: 0a09 2c20 6175 783a 3a70 6f72 746d 6170 .., aux::portmap │ │ │ +00023ba0: 5f63 616c 6c62 6163 6b26 616d 703b 2063 _callback& c │ │ │ +00023bb0: 620a 092c 2061 6464 7265 7373 5f76 3420 b.., address_v4 │ │ │ +00023bc0: 636f 6e73 7420 6c69 7374 656e 5f61 6464 const listen_add │ │ │ +00023bd0: 7265 7373 0a09 2c20 6164 6472 6573 735f ress.., address_ │ │ │ +00023be0: 7634 2063 6f6e 7374 206e 6574 6d61 736b v4 const netmask │ │ │ +00023bf0: 0a09 2c20 7374 643a 3a73 7472 696e 6720 .., std::string │ │ │ +00023c00: 6c69 7374 656e 5f64 6576 6963 650a 092c listen_device.., │ │ │ +00023c10: 206c 6973 7465 6e5f 736f 636b 6574 5f68 listen_socket_h │ │ │ +00023c20: 616e 646c 6520 6c73 290a 093a 206d 5f73 andle ls)..: m_s │ │ │ +00023c30: 6574 7469 6e67 7328 7365 7474 696e 6773 ettings(settings │ │ │ +00023c40: 290a 092c 206d 5f63 616c 6c62 6163 6b28 ).., m_callback( │ │ │ +00023c50: 6362 290a 092c 206d 5f69 6f5f 7365 7276 cb).., m_io_serv │ │ │ +00023c60: 6963 6528 696f 7329 0a09 2c20 6d5f 7265 ice(ios).., m_re │ │ │ +00023c70: 736f 6c76 6572 2869 6f73 290a 092c 206d solver(ios).., m │ │ │ +00023c80: 5f6d 756c 7469 6361 7374 2869 6f73 290a _multicast(ios). │ │ │ +00023c90: 092c 206d 5f75 6e69 6361 7374 2869 6f73 ., m_unicast(ios │ │ │ +00023ca0: 290a 092c 206d 5f62 726f 6164 6361 7374 ).., m_broadcast │ │ │ +00023cb0: 5f74 696d 6572 2869 6f73 290a 092c 206d _timer(ios).., m │ │ │ +00023cc0: 5f72 6566 7265 7368 5f74 696d 6572 2869 _refresh_timer(i │ │ │ +00023cd0: 6f73 290a 092c 206d 5f6d 6170 5f74 696d os).., m_map_tim │ │ │ +00023ce0: 6572 2869 6f73 290a 092c 206d 5f6c 6973 er(ios).., m_lis │ │ │ +00023cf0: 7465 6e5f 6164 6472 6573 7328 6c69 7374 ten_address(list │ │ │ +00023d00: 656e 5f61 6464 7265 7373 290a 092c 206d en_address).., m │ │ │ +00023d10: 5f6e 6574 6d61 736b 286e 6574 6d61 736b _netmask(netmask │ │ │ +00023d20: 290a 092c 206d 5f64 6576 6963 6528 7374 ).., m_device(st │ │ │ +00023d30: 643a 3a6d 6f76 6528 6c69 7374 656e 5f64 d::move(listen_d │ │ │ +00023d40: 6576 6963 6529 290a 2369 6620 544f 5252 evice)).#if TORR │ │ │ +00023d50: 454e 545f 5553 455f 5353 4c0a 092c 206d ENT_USE_SSL.., m │ │ │ +00023d60: 5f73 736c 5f63 7478 2873 736c 3a3a 636f _ssl_ctx(ssl::co │ │ │ +00023d70: 6e74 6578 743a 3a73 736c 7632 335f 636c ntext::sslv23_cl │ │ │ +00023d80: 6965 6e74 290a 2365 6e64 6966 0a09 2c20 ient).#endif.., │ │ │ +00023d90: 6d5f 6c69 7374 656e 5f68 616e 646c 6528 m_listen_handle( │ │ │ +00023da0: 7374 643a 3a6d 6f76 6528 6c73 2929 0a7b std::move(ls)).{ │ │ │ +00023db0: 0a23 6966 2054 4f52 5245 4e54 5f55 5345 .#if TORRENT_USE │ │ │ +00023dc0: 5f53 534c 0a09 6d5f 7373 6c5f 6374 782e _SSL..m_ssl_ctx. │ │ │ +00023dd0: 7365 745f 7665 7269 6679 5f6d 6f64 6528 set_verify_mode( │ │ │ +00023de0: 6175 783a 3a73 736c 3a3a 636f 6e74 6578 aux::ssl::contex │ │ │ +00023df0: 743a 3a76 6572 6966 795f 6e6f 6e65 293b t::verify_none); │ │ │ +00023e00: 0a23 656e 6469 660a 7d0a 0a76 6f69 6420 .#endif.}..void │ │ │ +00023e10: 7570 6e70 3a3a 7374 6172 7428 290a 7b0a upnp::start().{. │ │ │ +00023e20: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00023e30: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00023e60: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ +00023e90: 2f62 6465 636f 6465 2e63 7070 3a38 3133 /bdecode.cpp:813 │ │ │ +00023ea0: 3c2f 613e 3c2f 7464 3e3c 7464 3e61 7474 att │ │ │ +00023eb0: 656d 7074 2074 6f20 7369 6d70 6c69 6679 empt to simplify │ │ │ +00023ec0: 2074 6869 7320 696d 706c 656d 656e 7461 this implementa │ │ │ +00023ed0: 7469 6f6e 2062 7920 656d 6272 6163 696e tion by embracin │ │ │ +00023ee0: 6720 7468 6520 7370 616e 3c2f 7464 3e3c g the span< │ │ │ +00023ef0: 2f74 723e 3c74 7220 6964 3d22 3731 2220 /tr>

    attempt t │ │ │ +00023f40: 6f20 7369 6d70 6c69 6679 2074 6869 7320 o simplify this │ │ │ +00023f50: 696d 706c 656d 656e 7461 7469 6f6e 2062 implementation b │ │ │ +00023f60: 7920 656d 6272 6163 696e 6720 7468 6520 y embracing the │ │ │ +00023f70: 7370 616e 3c2f 6832 3e3c 6834 3e2e 2e2f span

    ../ │ │ │ +00023f80: 7372 632f 6264 6563 6f64 652e 6370 703a src/bdecode.cpp: │ │ │ +00023f90: 3831 333c 2f68 343e 3c70 7265 2073 7479 813

    .}...bdecode_n
    │ │ │ +00023fe0: 6f64 6520 6264 6563 6f64 6528 7370 616e  ode bdecode(span
    │ │ │ +00023ff0: 266c 743b 6368 6172 2063 6f6e 7374 2667  <char const&g
    │ │ │ +00024000: 743b 2062 7566 6665 720a 0909 2c20 6572  t; buffer..., er
    │ │ │ +00024010: 726f 725f 636f 6465 2661 6d70 3b20 6563  ror_code& ec
    │ │ │ +00024020: 2c20 696e 742a 2065 7272 6f72 5f70 6f73  , int* error_pos
    │ │ │ +00024030: 2c20 696e 7420 6465 7074 685f 6c69 6d69  , int depth_limi
    │ │ │ +00024040: 742c 2069 6e74 2074 6f6b 656e 5f6c 696d  t, int token_lim
    │ │ │ +00024050: 6974 290a 097b 0a09 0962 6465 636f 6465  it)..{...bdecode
    │ │ │ +00024060: 5f6e 6f64 6520 7265 743b 0a09 0965 632e  _node ret;...ec.
    │ │ │ +00024070: 636c 6561 7228 293b 0a0a 0909 6966 2028  clear();....if (
    │ │ │ +00024080: 6275 6666 6572 2e73 697a 6528 2920 2667  buffer.size() &g
    │ │ │ +00024090: 743b 2062 6465 636f 6465 5f74 6f6b 656e  t; bdecode_token
    │ │ │ +000240a0: 3a3a 6d61 785f 6f66 6673 6574 290a 0909  ::max_offset)...
    │ │ │ +000240b0: 7b0a 0909 0969 6620 2865 7272 6f72 5f70  {....if (error_p
    │ │ │ +000240c0: 6f73 2920 2a65 7272 6f72 5f70 6f73 203d  os) *error_pos =
    │ │ │ +000240d0: 2030 3b0a 0909 0965 6320 3d20 6264 6563   0;....ec = bdec
    │ │ │ +000240e0: 6f64 655f 6572 726f 7273 3a3a 6c69 6d69  ode_errors::limi
    │ │ │ +000240f0: 745f 6578 6365 6564 6564 3b0a 0909 0972  t_exceeded;....r
    │ │ │ +00024100: 6574 7572 6e20 7265 743b 0a09 097d 0a0a  eturn ret;...}..
    │ │ │ +00024110: 0909 2f2f 2074 6869 7320 6973 2074 6865  ..// this is the
    │ │ │ +00024120: 2073 7461 636b 206f 6620 6264 6563 6f64   stack of bdecod
    │ │ │ +00024130: 655f 746f 6b65 6e20 696e 6469 6365 732c  e_token indices,
    │ │ │ +00024140: 2069 6e74 6f20 6d5f 746f 6b65 6e73 2e0a   into m_tokens..
    │ │ │ +00024150: 0909 2f2f 2073 7020 6973 2074 6865 2073  ..// sp is the s
    │ │ │ +00024160: 7461 636b 2070 6f69 6e74 6572 2c20 6173  tack pointer, as
    │ │ │ +00024170: 2069 6e64 6578 2069 6e74 6f20 7468 6520   index into the 
    │ │ │ +00024180: 6172 7261 792c 2073 7461 636b 0a09 0969  array, stack...i
    │ │ │ +00024190: 6e74 2073 7020 3d20 303b 0a09 0954 4f52  nt sp = 0;...TOR
    │ │ │ +000241a0: 5245 4e54 5f41 4c4c 4f43 4128 7374 6163  RENT_ALLOCA(stac
    │ │ │ +000241b0: 6b2c 2073 7461 636b 5f66 7261 6d65 2c20  k, stack_frame, 
    │ │ │ +000241c0: 6465 7074 685f 6c69 6d69 7429 3b0a 0a3c  depth_limit);..<
    │ │ │ +000241d0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +000241e0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +000241f0: 7769 6474 683d 2231 3030 2522 3e09 0963  width="100%">..c
    │ │ │ +00024200: 6861 7220 636f 6e73 742a 2073 7461 7274  har const* start
    │ │ │ +00024210: 203d 2062 7566 6665 722e 6461 7461 2829   = buffer.data()
    │ │ │ +00024220: 3b0a 3c2f 6469 763e 0909 6368 6172 2063  ;.
    ..char c │ │ │ +00024230: 6f6e 7374 2a20 656e 6420 3d20 7374 6172 onst* end = star │ │ │ +00024240: 7420 2b20 6275 6666 6572 2e73 697a 6528 t + buffer.size( │ │ │ +00024250: 293b 0a09 0963 6861 7220 636f 6e73 742a );...char const* │ │ │ +00024260: 2063 6f6e 7374 206f 7269 675f 7374 6172 const orig_star │ │ │ +00024270: 7420 3d20 7374 6172 743b 0a0a 0909 6966 t = start;....if │ │ │ +00024280: 2028 7374 6172 7420 3d3d 2065 6e64 290a (start == end). │ │ │ +00024290: 0909 0954 4f52 5245 4e54 5f46 4149 4c5f ...TORRENT_FAIL_ │ │ │ +000242a0: 4244 4543 4f44 4528 6264 6563 6f64 655f BDECODE(bdecode_ │ │ │ +000242b0: 6572 726f 7273 3a3a 756e 6578 7065 6374 errors::unexpect │ │ │ +000242c0: 6564 5f65 6f66 293b 0a0a 0909 7768 696c ed_eof);....whil │ │ │ +000242d0: 6520 2873 7461 7274 2026 6c74 3b3d 2065 e (start <= e │ │ │ +000242e0: 6e64 290a 0909 7b0a 0909 0969 6620 2873 nd)...{....if (s │ │ │ +000242f0: 7461 7274 2026 6774 3b3d 2065 6e64 2920 tart >= end) │ │ │ +00024300: 544f 5252 454e 545f 4641 494c 5f42 4445 TORRENT_FAIL_BDE │ │ │ +00024310: 434f 4445 2862 6465 636f 6465 5f65 7272 CODE(bdecode_err │ │ │ +00024320: 6f72 733a 3a75 6e65 7870 6563 7465 645f ors::unexpected_ │ │ │ +00024330: 656f 6629 3b0a 0a09 0909 6966 2028 7370 eof);.....if (sp │ │ │ +00024340: 2026 6774 3b3d 2064 6570 7468 5f6c 696d >= depth_lim │ │ │ +00024350: 6974 290a 0909 0909 544f 5252 454e 545f it).....TORRENT_ │ │ │ +00024360: 4641 494c 5f42 4445 434f 4445 2862 6465 FAIL_BDECODE(bde │ │ │ +00024370: 636f 6465 5f65 7272 6f72 733a 3a64 6570 code_errors::dep │ │ │ +00024380: 7468 5f65 7863 6565 6465 6429 3b0a 0a09 th_exceeded);... │ │ │ +00024390: 0909 2d2d 746f 6b65 6e5f 6c69 6d69 743b ..--token_limit; │ │ │ +000243a0: 0a09 0909 6966 2028 746f 6b65 6e5f 6c69 ....if (token_li │ │ │ +000243b0: 6d69 7420 266c 743b 2030 290a 0909 0909 mit < 0)..... │ │ │ +000243c0: 544f 5252 454e 545f 4641 494c 5f42 4445 TORRENT_FAIL_BDE │ │ │ +000243d0: 434f 4445 2862 6465 636f 6465 5f65 7272 CODE(bdecode_err │ │ │ +000243e0: 6f72 733a 3a6c 696d 6974 5f65 7863 6565 ors::limit_excee │ │ │ +000243f0: 6465 6429 3b0a 0a09 0909 2f2f 206c 6f6f ded);.....// loo │ │ │ +00024400: 6b20 666f 7220 6120 6e65 7720 746f 6b65 k for a new toke │ │ │ +00024410: 6e0a 0909 0963 6861 7220 636f 6e73 7420 n....char const │ │ │ +00024420: 7420 3d20 2a73 7461 7274 3b0a 0a09 0909 t = *start;..... │ │ │ +00024430: 696e 7420 636f 6e73 7420 6375 7272 656e int const curren │ │ │ +00024440: 745f 6672 616d 6520 3d20 7370 3b0a 0a09 t_frame = sp;... │ │ │ +00024450: 0909 2f2f 2069 6620 7765 2772 6520 6375 ..// if we're cu │ │ │ +00024460: 7272 656e 746c 7920 7061 7273 696e 6720 rrently parsing │ │ │ +00024470: 6120 6469 6374 696f 6e61 7279 2c20 6173 a dictionary, as │ │ │ +00024480: 7365 7274 2074 6861 740a 0909 092f 2f20 sert that....// │ │ │ +00024490: 6576 6572 7920 6f74 6865 7220 6e6f 6465 every other node │ │ │ +000244a0: 2069 7320 6120 7374 7269 6e67 2e0a 0909 is a string.... │ │ │ +000244b0: 0969 6620 2863 7572 7265 6e74 5f66 7261 .if (current_fra │ │ │ +000244c0: 6d65 2026 6774 3b20 300a 0909 0909 2661 me > 0.....&a │ │ │ +000244d0: 6d70 3b26 616d 703b 2072 6574 2e6d 5f74 mp;& ret.m_t │ │ │ +000244e0: 6f6b 656e 735b 7374 6163 6b5b 6375 7272 okens[stack[curr │ │ │ +000244f0: 656e 745f 6672 616d 6520 2d20 315d 2e74 ent_frame - 1].t │ │ │ +00024500: 6f6b 656e 5d2e 7479 7065 203d 3d20 6264 oken].type == bd │ │ │ +00024510: 6563 6f64 655f 746f 6b65 6e3a 3a64 6963 ecode_token::dic │ │ │ +00024520: 7429 0a09 0909 7b0a 0909 0909 6966 2028 t)....{.....if ( │ │ │ +00024530: 7374 6163 6b5b 6375 7272 656e 745f 6672 stack[current_fr │ │ │ +00024540: 616d 6520 2d20 315d 2e73 7461 7465 203d ame - 1].state = │ │ │ +00024550: 3d20 3029 0a09 0909 097b 0a09 0909 0909 = 0).....{...... │ │ │ +00024560: 2f2f 2074 6865 2063 7572 7265 6e74 2070 // the current p │ │ │ +00024570: 6172 656e 7420 6973 2061 2064 6963 7420 arent is a dict │ │ │ +00024580: 616e 6420 7765 2061 7265 2070 6172 7369 and we are parsi │ │ │ +00024590: 6e67 2061 206b 6579 2e0a 3c2f 7072 653e ng a key.. │ │ │ +000245a0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +000245d0: 616e 6365 266e 6273 703b 323c 2f74 643e ance 2 │ │ │ +000245e0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/udp_t │ │ │ +00024610: 7261 636b 6572 5f63 6f6e 6e65 6374 696f racker_connectio │ │ │ +00024620: 6e2e 6370 703a 3539 3c2f 613e 3c2f 7464 n.cpp:59support aut │ │ │ +00024640: 6865 6e74 6963 6174 696f 6e20 6865 7265 hentication here │ │ │ +00024650: 2e20 7472 6163 6b65 725f 7265 7128 292e . tracker_req(). │ │ │ +00024660: 6175 7468 3c2f 7464 3e3c 2f74 723e 3c74 auth

    support authent │ │ │ +000246c0: 6963 6174 696f 6e20 6865 7265 2e20 7472 ication here. tr │ │ │ +000246d0: 6163 6b65 725f 7265 7128 292e 6175 7468 acker_req().auth │ │ │ +000246e0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +000246f0: 7564 705f 7472 6163 6b65 725f 636f 6e6e udp_tracker_conn │ │ │ +00024700: 6563 7469 6f6e 2e63 7070 3a35 393c 2f68 ection.cpp:59
    ..ud
    │ │ │ +00024750: 705f 7472 6163 6b65 725f 636f 6e6e 6563  p_tracker_connec
    │ │ │ +00024760: 7469 6f6e 3a3a 6d5f 636f 6e6e 6563 7469  tion::m_connecti
    │ │ │ +00024770: 6f6e 5f63 6163 6865 3b0a 0a09 7374 643a  on_cache;...std:
    │ │ │ +00024780: 3a6d 7574 6578 2075 6470 5f74 7261 636b  :mutex udp_track
    │ │ │ +00024790: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a6d  er_connection::m
    │ │ │ +000247a0: 5f63 6163 6865 5f6d 7574 6578 3b0a 0a09  _cache_mutex;...
    │ │ │ +000247b0: 7564 705f 7472 6163 6b65 725f 636f 6e6e  udp_tracker_conn
    │ │ │ +000247c0: 6563 7469 6f6e 3a3a 7564 705f 7472 6163  ection::udp_trac
    │ │ │ +000247d0: 6b65 725f 636f 6e6e 6563 7469 6f6e 280a  ker_connection(.
    │ │ │ +000247e0: 0909 696f 5f63 6f6e 7465 7874 2661 6d70  ..io_context&
    │ │ │ +000247f0: 3b20 696f 730a 0909 2c20 7472 6163 6b65  ; ios..., tracke
    │ │ │ +00024800: 725f 6d61 6e61 6765 7226 616d 703b 206d  r_manager& m
    │ │ │ +00024810: 616e 0a09 092c 2074 7261 636b 6572 5f72  an..., tracker_r
    │ │ │ +00024820: 6571 7565 7374 2063 6f6e 7374 2661 6d70  equest const&
    │ │ │ +00024830: 3b20 7265 710a 0909 2c20 7374 643a 3a77  ; req..., std::w
    │ │ │ +00024840: 6561 6b5f 7074 7226 6c74 3b72 6571 7565  eak_ptr<reque
    │ │ │ +00024850: 7374 5f63 616c 6c62 6163 6b26 6774 3b20  st_callback> 
    │ │ │ +00024860: 6329 0a09 093a 2074 7261 636b 6572 5f63  c)...: tracker_c
    │ │ │ +00024870: 6f6e 6e65 6374 696f 6e28 6d61 6e2c 2072  onnection(man, r
    │ │ │ +00024880: 6571 2c20 696f 732c 2073 7464 3a3a 6d6f  eq, ios, std::mo
    │ │ │ +00024890: 7665 2863 2929 0a09 092c 206d 5f74 7261  ve(c))..., m_tra
    │ │ │ +000248a0: 6e73 6163 7469 6f6e 5f69 6428 3029 0a09  nsaction_id(0)..
    │ │ │ +000248b0: 092c 206d 5f61 7474 656d 7074 7328 3029  ., m_attempts(0)
    │ │ │ +000248c0: 0a09 092c 206d 5f73 7461 7465 2861 6374  ..., m_state(act
    │ │ │ +000248d0: 696f 6e5f 743a 3a65 7272 6f72 290a 0909  ion_t::error)...
    │ │ │ +000248e0: 2c20 6d5f 6162 6f72 7428 6661 6c73 6529  , m_abort(false)
    │ │ │ +000248f0: 0a09 7b0a 0909 7570 6461 7465 5f74 7261  ..{...update_tra
    │ │ │ +00024900: 6e73 6163 7469 6f6e 5f69 6428 293b 0a09  nsaction_id();..
    │ │ │ +00024910: 7d0a 0a09 766f 6964 2075 6470 5f74 7261  }...void udp_tra
    │ │ │ +00024920: 636b 6572 5f63 6f6e 6e65 6374 696f 6e3a  cker_connection:
    │ │ │ +00024930: 3a73 7461 7274 2829 0a09 7b0a 3c64 6976  :start()..{.
    ..std: │ │ │ +00024970: 3a73 7472 696e 6720 686f 7374 6e61 6d65 :string hostname │ │ │ +00024980: 3b0a 3c2f 6469 763e 0909 7374 643a 3a73 ;.
    ..std::s │ │ │ +00024990: 7472 696e 6720 7072 6f74 6f63 6f6c 3b0a tring protocol;. │ │ │ +000249a0: 0909 696e 7420 706f 7274 3b0a 0909 6572 ..int port;...er │ │ │ +000249b0: 726f 725f 636f 6465 2065 633b 0a0a 0909 ror_code ec;.... │ │ │ +000249c0: 7374 643a 3a74 6965 2870 726f 746f 636f std::tie(protoco │ │ │ +000249d0: 6c2c 2073 7464 3a3a 6967 6e6f 7265 2c20 l, std::ignore, │ │ │ +000249e0: 686f 7374 6e61 6d65 2c20 706f 7274 2c20 hostname, port, │ │ │ +000249f0: 7374 643a 3a69 676e 6f72 6529 0a09 0909 std::ignore).... │ │ │ +00024a00: 3d20 7061 7273 655f 7572 6c5f 636f 6d70 = parse_url_comp │ │ │ +00024a10: 6f6e 656e 7473 2874 7261 636b 6572 5f72 onents(tracker_r │ │ │ +00024a20: 6571 2829 2e75 726c 2c20 6563 293b 0a09 eq().url, ec);.. │ │ │ +00024a30: 0969 6620 2870 6f72 7420 3d3d 202d 3129 .if (port == -1) │ │ │ +00024a40: 2070 6f72 7420 3d20 7072 6f74 6f63 6f6c port = protocol │ │ │ +00024a50: 203d 3d20 2268 7474 7022 203f 2038 3020 == "http" ? 80 │ │ │ +00024a60: 3a20 3434 333b 0a0a 0909 6966 2028 6563 : 443;....if (ec │ │ │ +00024a70: 290a 0909 7b0a 0909 0974 7261 636b 6572 )...{....tracker │ │ │ +00024a80: 5f63 6f6e 6e65 6374 696f 6e3a 3a66 6169 _connection::fai │ │ │ +00024a90: 6c28 6563 2c20 6f70 6572 6174 696f 6e5f l(ec, operation_ │ │ │ +00024aa0: 743a 3a70 6172 7365 5f61 6464 7265 7373 t::parse_address │ │ │ +00024ab0: 293b 0a09 0909 7265 7475 726e 3b0a 0909 );....return;... │ │ │ +00024ac0: 7d0a 0a09 0961 7578 3a3a 7365 7373 696f }....aux::sessio │ │ │ +00024ad0: 6e5f 7365 7474 696e 6773 2063 6f6e 7374 n_settings const │ │ │ +00024ae0: 2661 6d70 3b20 7365 7474 696e 6773 203d & settings = │ │ │ +00024af0: 206d 5f6d 616e 2e73 6574 7469 6e67 7328 m_man.settings( │ │ │ +00024b00: 293b 0a0a 0909 696e 7420 636f 6e73 7420 );....int const │ │ │ +00024b10: 7072 6f78 795f 7479 7065 203d 2073 6574 proxy_type = set │ │ │ +00024b20: 7469 6e67 732e 6765 745f 696e 7428 7365 tings.get_int(se │ │ │ +00024b30: 7474 696e 6773 5f70 6163 6b3a 3a70 726f ttings_pack::pro │ │ │ +00024b40: 7879 5f74 7970 6529 3b0a 0a09 0969 6620 xy_type);....if │ │ │ +00024b50: 2873 6574 7469 6e67 732e 6765 745f 626f (settings.get_bo │ │ │ +00024b60: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ +00024b70: 3a3a 7072 6f78 795f 686f 7374 6e61 6d65 ::proxy_hostname │ │ │ +00024b80: 7329 0a09 0909 2661 6d70 3b26 616d 703b s)....&& │ │ │ +00024b90: 2028 7072 6f78 795f 7479 7065 203d 3d20 (proxy_type == │ │ │ +00024ba0: 7365 7474 696e 6773 5f70 6163 6b3a 3a73 settings_pack::s │ │ │ +00024bb0: 6f63 6b73 350a 0909 0909 7c7c 2070 726f ocks5.....|| pro │ │ │ +00024bc0: 7879 5f74 7970 6520 3d3d 2073 6574 7469 xy_type == setti │ │ │ +00024bd0: 6e67 735f 7061 636b 3a3a 736f 636b 7335 ngs_pack::socks5 │ │ │ +00024be0: 5f70 7729 290a 0909 7b0a 0909 096d 5f68 _pw))...{....m_h │ │ │ +00024bf0: 6f73 746e 616d 6520 3d20 686f 7374 6e61 ostname = hostna │ │ │ +00024c00: 6d65 3b0a 0909 096d 5f74 6172 6765 742e me;....m_target. │ │ │ +00024c10: 706f 7274 2873 7464 3a3a 7569 6e74 3136 port(std::uint16 │ │ │ +00024c20: 5f74 2870 6f72 7429 293b 0a09 0909 7374 _t(port));....st │ │ │ +00024c30: 6172 745f 616e 6e6f 756e 6365 2829 3b0a art_announce();. │ │ │ +00024c40: 0909 7d0a 0909 656c 7365 0a09 097b 0a09 ..}...else...{.. │ │ │ +00024c50: 0909 7573 696e 6720 6e61 6d65 7370 6163 ..using namespac │ │ │ +00024c60: 6520 7374 643a 3a70 6c61 6365 686f 6c64 e std::placehold │ │ │ +00024c70: 6572 733b 0a09 0909 4144 445f 4f55 5453 ers;....ADD_OUTS │ │ │ +00024c80: 5441 4e44 494e 475f 4153 594e 4328 2275 TANDING_ASYNC("u │ │ │ +00024c90: 6470 5f74 7261 636b 6572 5f63 6f6e 6e65 dp_tracker_conne │ │ │ +00024ca0: 6374 696f 6e3a 3a6e 616d 655f 6c6f 6f6b ction::name_look │ │ │ +00024cb0: 7570 2229 3b0a 3c2f 7072 653e 3c2f 7464 up");.
    relevance │ │ │ +00024cf0: 266e 6273 703b 323c 2f74 643e 3c74 643e  2 │ │ │ +00024d00: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ +00024d20: 2e2e 2f73 7263 2f61 6c65 7274 2e63 7070 ../src/alert.cpp │ │ │ +00024d30: 3a31 3937 353c 2f61 3e3c 2f74 643e 3c74 :1975the salt here │ │ │ +00024d50: 6973 2061 6c6c 6f63 6174 6564 206f 6e20 is allocated on │ │ │ +00024d60: 7468 6520 6865 6170 2e20 4974 2077 6f75 the heap. It wou │ │ │ +00024d70: 6c64 2062 6520 6e69 6365 2074 6f20 616c ld be nice to al │ │ │ +00024d80: 6c6f 6361 7465 2069 6e20 7468 6520 7374 locate in the st │ │ │ +00024d90: 6163 6b5f 616c 6c6f 6361 746f 723c 2f74 ack_allocator

    the sa │ │ │ +00024df0: 6c74 2068 6572 6520 6973 2061 6c6c 6f63 lt here is alloc │ │ │ +00024e00: 6174 6564 206f 6e20 7468 6520 6865 6170 ated on the heap │ │ │ +00024e10: 2e20 4974 2077 6f75 6c64 2062 6520 6e69 . It would be ni │ │ │ +00024e20: 6365 2074 6f0a 616c 6c6f 6361 7465 2069 ce to.allocate i │ │ │ +00024e30: 6e20 7468 6520 7374 6163 6b5f 616c 6c6f n the stack_allo │ │ │ +00024e40: 6361 746f 723c 2f68 323e 3c68 343e 2e2e cator

    .. │ │ │ +00024e50: 2f73 7263 2f61 6c65 7274 2e63 7070 3a31 /src/alert.cpp:1 │ │ │ +00024e60: 3937 353c 2f68 343e 3c70 7265 2073 7479 975

    .}...dht_immut
    │ │ │ +00024eb0: 6162 6c65 5f69 7465 6d5f 616c 6572 743a  able_item_alert:
    │ │ │ +00024ec0: 3a64 6874 5f69 6d6d 7574 6162 6c65 5f69  :dht_immutable_i
    │ │ │ +00024ed0: 7465 6d5f 616c 6572 7428 6175 783a 3a73  tem_alert(aux::s
    │ │ │ +00024ee0: 7461 636b 5f61 6c6c 6f63 6174 6f72 2661  tack_allocator&a
    │ │ │ +00024ef0: 6d70 3b0a 0909 2c20 7368 6131 5f68 6173  mp;..., sha1_has
    │ │ │ +00024f00: 6820 636f 6e73 7426 616d 703b 2074 2c20  h const& t, 
    │ │ │ +00024f10: 656e 7472 7920 6929 0a09 093a 2074 6172  entry i)...: tar
    │ │ │ +00024f20: 6765 7428 7429 2c20 6974 656d 2873 7464  get(t), item(std
    │ │ │ +00024f30: 3a3a 6d6f 7665 2869 2929 0a09 7b7d 0a0a  ::move(i))..{}..
    │ │ │ +00024f40: 0973 7464 3a3a 7374 7269 6e67 2064 6874  .std::string dht
    │ │ │ +00024f50: 5f69 6d6d 7574 6162 6c65 5f69 7465 6d5f  _immutable_item_
    │ │ │ +00024f60: 616c 6572 743a 3a6d 6573 7361 6765 2829  alert::message()
    │ │ │ +00024f70: 2063 6f6e 7374 0a09 7b0a 2369 6664 6566   const..{.#ifdef
    │ │ │ +00024f80: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ +00024f90: 5f41 4c45 5254 5f4d 5347 0a09 0972 6574  _ALERT_MSG...ret
    │ │ │ +00024fa0: 7572 6e20 7b7d 3b0a 2365 6c73 650a 0909  urn {};.#else...
    │ │ │ +00024fb0: 6368 6172 206d 7367 5b31 3035 305d 3b0a  char msg[1050];.
    │ │ │ +00024fc0: 0909 7374 643a 3a73 6e70 7269 6e74 6628  ..std::snprintf(
    │ │ │ +00024fd0: 6d73 672c 2073 697a 656f 6628 6d73 6729  msg, sizeof(msg)
    │ │ │ +00024fe0: 2c20 2244 4854 2069 6d6d 7574 6162 6c65  , "DHT immutable
    │ │ │ +00024ff0: 2069 7465 6d20 2573 205b 2025 7320 5d22   item %s [ %s ]"
    │ │ │ +00025000: 0a09 0909 2c20 6175 783a 3a74 6f5f 6865  ...., aux::to_he
    │ │ │ +00025010: 7828 7461 7267 6574 292e 635f 7374 7228  x(target).c_str(
    │ │ │ +00025020: 290a 0909 092c 2069 7465 6d2e 746f 5f73  )...., item.to_s
    │ │ │ +00025030: 7472 696e 6728 292e 635f 7374 7228 2929  tring().c_str())
    │ │ │ +00025040: 3b0a 0909 7265 7475 726e 206d 7367 3b0a  ;...return msg;.
    │ │ │ +00025050: 2365 6e64 6966 0a09 7d0a 0a3c 6469 7620  #endif..}..
    .dht_mu │ │ │ +00025090: 7461 626c 655f 6974 656d 5f61 6c65 7274 table_item_alert │ │ │ +000250a0: 3a3a 6468 745f 6d75 7461 626c 655f 6974 ::dht_mutable_it │ │ │ +000250b0: 656d 5f61 6c65 7274 2861 7578 3a3a 7374 em_alert(aux::st │ │ │ +000250c0: 6163 6b5f 616c 6c6f 6361 746f 7226 616d ack_allocator&am │ │ │ +000250d0: 703b 0a3c 2f64 6976 3e09 092c 2073 7464 p;.
    .., std │ │ │ +000250e0: 3a3a 6172 7261 7926 6c74 3b63 6861 722c ::array<char, │ │ │ +000250f0: 2033 3226 6774 3b20 636f 6e73 7426 616d 32> const&am │ │ │ +00025100: 703b 206b 0a09 092c 2073 7464 3a3a 6172 p; k..., std::ar │ │ │ +00025110: 7261 7926 6c74 3b63 6861 722c 2036 3426 ray<char, 64& │ │ │ +00025120: 6774 3b20 636f 6e73 7426 616d 703b 2073 gt; const& s │ │ │ +00025130: 6967 0a09 092c 2073 7464 3a3a 696e 7436 ig..., std::int6 │ │ │ +00025140: 345f 7420 7365 7175 656e 6365 0a09 092c 4_t sequence..., │ │ │ +00025150: 2073 7472 696e 675f 7669 6577 2073 0a09 string_view s.. │ │ │ +00025160: 092c 2065 6e74 7279 2069 0a09 092c 2062 ., entry i..., b │ │ │ +00025170: 6f6f 6c20 6129 0a09 093a 206b 6579 286b ool a)...: key(k │ │ │ +00025180: 292c 2073 6967 6e61 7475 7265 2873 6967 ), signature(sig │ │ │ +00025190: 292c 2073 6571 2873 6571 7565 6e63 6529 ), seq(sequence) │ │ │ +000251a0: 2c20 7361 6c74 2873 292c 2069 7465 6d28 , salt(s), item( │ │ │ +000251b0: 7374 643a 3a6d 6f76 6528 6929 292c 2061 std::move(i)), a │ │ │ +000251c0: 7574 686f 7269 7461 7469 7665 2861 290a uthoritative(a). │ │ │ +000251d0: 097b 7d0a 0a09 7374 643a 3a73 7472 696e .{}...std::strin │ │ │ +000251e0: 6720 6468 745f 6d75 7461 626c 655f 6974 g dht_mutable_it │ │ │ +000251f0: 656d 5f61 6c65 7274 3a3a 6d65 7373 6167 em_alert::messag │ │ │ +00025200: 6528 2920 636f 6e73 740a 097b 0a23 6966 e() const..{.#if │ │ │ +00025210: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +00025220: 424c 455f 414c 4552 545f 4d53 470a 0909 BLE_ALERT_MSG... │ │ │ +00025230: 7265 7475 726e 207b 7d3b 0a23 656c 7365 return {};.#else │ │ │ +00025240: 0a09 0963 6861 7220 6d73 675b 3130 3530 ...char msg[1050 │ │ │ +00025250: 5d3b 0a09 0973 7464 3a3a 736e 7072 696e ];...std::snprin │ │ │ +00025260: 7466 286d 7367 2c20 7369 7a65 6f66 286d tf(msg, sizeof(m │ │ │ +00025270: 7367 292c 2022 4448 5420 6d75 7461 626c sg), "DHT mutabl │ │ │ +00025280: 6520 6974 656d 2028 6b65 793d 2573 2073 e item (key=%s s │ │ │ +00025290: 616c 743d 2573 2073 6571 3d25 2220 5052 alt=%s seq=%" PR │ │ │ +000252a0: 4964 3634 2022 2025 7329 205b 2025 7320 Id64 " %s) [ %s │ │ │ +000252b0: 5d22 0a09 0909 2c20 6175 783a 3a74 6f5f ]"...., aux::to_ │ │ │ +000252c0: 6865 7828 6b65 7929 2e63 5f73 7472 2829 hex(key).c_str() │ │ │ +000252d0: 0a09 0909 2c20 7361 6c74 2e63 5f73 7472 ...., salt.c_str │ │ │ +000252e0: 2829 0a09 0909 2c20 7365 710a 0909 092c ()...., seq...., │ │ │ +000252f0: 2061 7574 686f 7269 7461 7469 7665 203f authoritative ? │ │ │ +00025300: 2022 6175 7468 2220 3a20 226e 6f6e 2d61 "auth" : "non-a │ │ │ +00025310: 7574 6822 0a09 0909 2c20 6974 656d 2e74 uth"...., item.t │ │ │ +00025320: 6f5f 7374 7269 6e67 2829 2e63 5f73 7472 o_string().c_str │ │ │ +00025330: 2829 293b 0a09 0972 6574 7572 6e20 6d73 ());...return ms │ │ │ +00025340: 673b 0a23 656e 6469 660a 097d 0a0a 0964 g;.#endif..}...d │ │ │ +00025350: 6874 5f70 7574 5f61 6c65 7274 3a3a 6468 ht_put_alert::dh │ │ │ +00025360: 745f 7075 745f 616c 6572 7428 6175 783a t_put_alert(aux: │ │ │ +00025370: 3a73 7461 636b 5f61 6c6c 6f63 6174 6f72 :stack_allocator │ │ │ +00025380: 2661 6d70 3b2c 2073 6861 315f 6861 7368 &, sha1_hash │ │ │ +00025390: 2063 6f6e 7374 2661 6d70 3b20 742c 2069 const& t, i │ │ │ +000253a0: 6e74 206e 290a 0909 3a20 7461 7267 6574 nt n)...: target │ │ │ +000253b0: 2874 290a 0909 2c20 7075 626c 6963 5f6b (t)..., public_k │ │ │ +000253c0: 6579 2829 0a09 092c 2073 6967 6e61 7475 ey()..., signatu │ │ │ +000253d0: 7265 2829 0a09 092c 2073 6571 2830 290a re()..., seq(0). │ │ │ 000253e0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ 000253f0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ 00025420: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ @@ -10199,1094 +10199,1094 @@ │ │ │ 00027d60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ 00027d90: 616e 6365 266e 6273 703b 323c 2f74 643e ance 2 │ │ │ 00027da0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/l │ │ │ -00027dd0: 6962 746f 7272 656e 742f 6175 785f 2f63 ibtorrent/aux_/c │ │ │ -00027de0: 6861 696e 6564 5f62 7566 6665 722e 6870 hained_buffer.hp │ │ │ -00027df0: 703a 3337 3c2f 613e 3c2f 7464 3e3c 7464 p:37this type shoul │ │ │ -00027e10: 6420 7072 6f62 6162 6c79 2062 6520 7265 d probably be re │ │ │ -00027e20: 6e61 6d65 6420 746f 2073 656e 645f 6275 named to send_bu │ │ │ -00027e30: 6666 6572 3c2f 7464 3e3c 2f74 723e 3c74 ffer

    this type shoul │ │ │ -00027e90: 6420 7072 6f62 6162 6c79 2062 6520 7265 d probably be re │ │ │ -00027ea0: 6e61 6d65 6420 746f 2073 656e 645f 6275 named to send_bu │ │ │ -00027eb0: 6666 6572 3c2f 6832 3e3c 6834 3e2e 2e2f ffer

    ../ │ │ │ -00027ec0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00027ed0: 6e74 2f61 7578 5f2f 6368 6169 6e65 645f nt/aux_/chained_ │ │ │ -00027ee0: 6275 6666 6572 2e68 7070 3a33 373c 2f68 buffer.hpp:37
    .#in
    │ │ │ -00027f30: 636c 7564 6520 266c 743b 6465 7175 6526  clude <deque&
    │ │ │ -00027f40: 6774 3b0a 2369 6e63 6c75 6465 2026 6c74  gt;.#include <
    │ │ │ -00027f50: 3b74 7970 655f 7472 6169 7473 2667 743b  ;type_traits>
    │ │ │ -00027f60: 0a23 696e 636c 7564 6520 266c 743b 7574  .#include <ut
    │ │ │ -00027f70: 696c 6974 7926 6774 3b0a 2369 6e63 6c75  ility>.#inclu
    │ │ │ -00027f80: 6465 2026 6c74 3b76 6563 746f 7226 6774  de <vector>
    │ │ │ -00027f90: 3b0a 0a23 696e 636c 7564 6520 226c 6962  ;..#include "lib
    │ │ │ -00027fa0: 746f 7272 656e 742f 6175 785f 2f64 6973  torrent/aux_/dis
    │ │ │ -00027fb0: 6162 6c65 5f77 6172 6e69 6e67 735f 7075  able_warnings_pu
    │ │ │ -00027fc0: 7368 2e68 7070 220a 2369 6e63 6c75 6465  sh.hpp".#include
    │ │ │ -00027fd0: 2026 6c74 3b62 6f6f 7374 2f61 7369 6f2f   <boost/asio/
    │ │ │ -00027fe0: 6275 6666 6572 2e68 7070 2667 743b 0a23  buffer.hpp>.#
    │ │ │ -00027ff0: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00028000: 656e 742f 6175 785f 2f64 6973 6162 6c65  ent/aux_/disable
    │ │ │ -00028010: 5f77 6172 6e69 6e67 735f 706f 702e 6870  _warnings_pop.hp
    │ │ │ -00028020: 7022 0a0a 2369 6664 6566 205f 4d53 435f  p"..#ifdef _MSC_
    │ │ │ -00028030: 5645 520a 2f2f 2076 6973 7561 6c20 7374  VER.// visual st
    │ │ │ -00028040: 7564 696f 2072 6571 7569 7265 7320 7468  udio requires th
    │ │ │ -00028050: 6520 7661 6c75 6520 696e 2061 2064 6571  e value in a deq
    │ │ │ -00028060: 7565 2074 6f20 6265 2063 6f70 7961 626c  ue to be copyabl
    │ │ │ -00028070: 652e 2043 2b2b 3131 0a2f 2f20 6861 7320  e. C++11.// has 
    │ │ │ -00028080: 6c6f 6f73 6572 2072 6571 7569 7265 6d65  looser requireme
    │ │ │ -00028090: 6e74 7320 6465 7065 6e64 696e 6720 6f6e  nts depending on
    │ │ │ -000280a0: 2077 6869 6368 2066 756e 6374 696f 6e73   which functions
    │ │ │ -000280b0: 2061 7265 2061 6374 7561 6c6c 7920 7573   are actually us
    │ │ │ -000280c0: 6564 2e0a 2364 6566 696e 6520 544f 5252  ed..#define TORR
    │ │ │ -000280d0: 454e 545f 4350 5039 385f 4445 5155 4520  ENT_CPP98_DEQUE 
    │ │ │ -000280e0: 310a 2365 6c73 650a 2364 6566 696e 6520  1.#else.#define 
    │ │ │ -000280f0: 544f 5252 454e 545f 4350 5039 385f 4445  TORRENT_CPP98_DE
    │ │ │ -00028100: 5155 4520 300a 2365 6e64 6966 0a0a 6e61  QUE 0.#endif..na
    │ │ │ -00028110: 6d65 7370 6163 6520 6c69 6274 6f72 7265  mespace libtorre
    │ │ │ -00028120: 6e74 3a3a 6175 7820 7b0a 0a3c 6469 7620  nt::aux {..
    .struct │ │ │ -00028160: 2054 4f52 5245 4e54 5f45 5854 5241 5f45 TORRENT_EXTRA_E │ │ │ -00028170: 5850 4f52 5420 6368 6169 6e65 645f 6275 XPORT chained_bu │ │ │ -00028180: 6666 6572 203a 2070 7269 7661 7465 2073 ffer : private s │ │ │ -00028190: 696e 676c 655f 7468 7265 6164 6564 0a3c ingle_threaded.< │ │ │ -000281a0: 2f64 6976 3e09 7b0a 0909 6368 6169 6e65 /div>.{...chaine │ │ │ -000281b0: 645f 6275 6666 6572 2829 3a20 6d5f 6279 d_buffer(): m_by │ │ │ -000281c0: 7465 7328 3029 2c20 6d5f 6361 7061 6369 tes(0), m_capaci │ │ │ -000281d0: 7479 2830 290a 0909 7b0a 0909 0974 6872 ty(0)...{....thr │ │ │ -000281e0: 6561 645f 7374 6172 7465 6428 293b 0a23 ead_started();.# │ │ │ -000281f0: 6966 2054 4f52 5245 4e54 5f55 5345 5f41 if TORRENT_USE_A │ │ │ -00028200: 5353 4552 5453 0a09 0909 6d5f 6465 7374 SSERTS....m_dest │ │ │ -00028210: 7275 6374 6564 203d 2066 616c 7365 3b0a ructed = false;. │ │ │ -00028220: 2365 6e64 6966 0a09 097d 0a0a 0970 7269 #endif...}...pri │ │ │ -00028230: 7661 7465 3a0a 0a09 092f 2f20 6465 7374 vate:....// dest │ │ │ -00028240: 7275 6374 732f 6672 6565 7320 7468 6520 ructs/frees the │ │ │ -00028250: 686f 6c64 6572 206f 626a 6563 740a 0909 holder object... │ │ │ -00028260: 7573 696e 6720 6465 7374 7275 6374 5f68 using destruct_h │ │ │ -00028270: 6f6c 6465 725f 6675 6e20 3d20 766f 6964 older_fun = void │ │ │ -00028280: 2028 2a29 2876 6f69 642a 293b 0a09 0975 (*)(void*);...u │ │ │ -00028290: 7369 6e67 206d 6f76 655f 636f 6e73 7472 sing move_constr │ │ │ -000282a0: 7563 745f 686f 6c64 6572 5f66 756e 203d uct_holder_fun = │ │ │ -000282b0: 2076 6f69 6420 282a 2928 766f 6964 2a2c void (*)(void*, │ │ │ -000282c0: 2076 6f69 642a 293b 0a0a 0909 7374 7275 void*);....stru │ │ │ -000282d0: 6374 2062 7566 6665 725f 740a 0909 7b0a ct buffer_t...{. │ │ │ -000282e0: 0909 0962 7566 6665 725f 7428 2920 7b7d ...buffer_t() {} │ │ │ -000282f0: 0a23 6966 2054 4f52 5245 4e54 5f43 5050 .#if TORRENT_CPP │ │ │ -00028300: 3938 5f44 4551 5545 0a09 0909 6275 6666 98_DEQUE....buff │ │ │ -00028310: 6572 5f74 2862 7566 6665 725f 7426 616d er_t(buffer_t&am │ │ │ -00028320: 703b 2661 6d70 3b20 7268 7329 206e 6f65 p;& rhs) noe │ │ │ -00028330: 7863 6570 740a 0909 097b 0a09 0909 0964 xcept....{.....d │ │ │ -00028340: 6573 7472 7563 745f 686f 6c64 6572 203d estruct_holder = │ │ │ -00028350: 2072 6873 2e64 6573 7472 7563 745f 686f rhs.destruct_ho │ │ │ -00028360: 6c64 6572 3b0a 0909 0909 6d6f 7665 5f68 lder;.....move_h │ │ │ -00028370: 6f6c 6465 7220 3d20 7268 732e 6d6f 7665 older = rhs.move │ │ │ -00028380: 5f68 6f6c 6465 723b 0a09 0909 0962 7566 _holder;.....buf │ │ │ -00028390: 203d 2072 6873 2e62 7566 3b0a 0909 0909 = rhs.buf;..... │ │ │ -000283a0: 7369 7a65 203d 2072 6873 2e73 697a 653b size = rhs.size; │ │ │ -000283b0: 0a09 0909 0975 7365 645f 7369 7a65 203d .....used_size = │ │ │ -000283c0: 2072 6873 2e75 7365 645f 7369 7a65 3b0a rhs.used_size;. │ │ │ -000283d0: 0909 0909 6d6f 7665 5f68 6f6c 6465 7228 ....move_holder( │ │ │ -000283e0: 2661 6d70 3b68 6f6c 6465 722c 2026 616d &holder, &am │ │ │ -000283f0: 703b 7268 732e 686f 6c64 6572 293b 0a09 p;rhs.holder);.. │ │ │ -00028400: 0909 7d0a 0909 0962 7566 6665 725f 7426 ..}....buffer_t& │ │ │ -00028410: 616d 703b 206f 7065 7261 746f 723d 2862 amp; operator=(b │ │ │ -00028420: 7566 6665 725f 7426 616d 703b 2661 6d70 uffer_t&& │ │ │ -00028430: 3b20 7268 7329 2026 616d 703b 206e 6f65 ; rhs) & noe │ │ │ -00028440: 7863 6570 740a 0909 097b 0a3c 2f70 7265 xcept....{.
    rele │ │ │ -00028480: 7661 6e63 6526 6e62 7370 3b32 3c2f 7464 vance 2../include/ │ │ │ -000284c0: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -000284d0: 7072 6f78 795f 6261 7365 2e68 7070 3a33 proxy_base.hpp:3 │ │ │ -000284e0: 3035 3c2f 613e 3c2f 7464 3e3c 7464 3e75 05u │ │ │ -000284f0: 7365 2074 6865 2072 6573 6f6c 7665 7220 se the resolver │ │ │ -00028500: 696e 7465 7266 6163 6520 7468 6174 2068 interface that h │ │ │ -00028510: 6173 2061 2062 7569 6c74 2d69 6e20 6361 as a built-in ca │ │ │ -00028520: 6368 653c 2f74 643e 3c2f 7472 3e3c 7472 che

    │ │ │ -00028570: 7573 6520 7468 6520 7265 736f 6c76 6572 use the resolver │ │ │ -00028580: 2069 6e74 6572 6661 6365 2074 6861 7420 interface that │ │ │ -00028590: 6861 7320 6120 6275 696c 742d 696e 2063 has a built-in c │ │ │ -000285a0: 6163 6865 3c2f 6832 3e3c 6834 3e2e 2e2f ache

    ../ │ │ │ -000285b0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -000285c0: 6e74 2f61 7578 5f2f 7072 6f78 795f 6261 nt/aux_/proxy_ba │ │ │ -000285d0: 7365 2e68 7070 3a33 3035 3c2f 6834 3e3c se.hpp:305

    < │ │ │ -000285e0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000285f0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00028600: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00028610: 7820 2364 6464 3b22 3e09 2f2f 2054 6865 x #ddd;">.// The │ │ │ -00028620: 2068 616e 646c 6572 206d 7573 7420 6265 handler must be │ │ │ -00028630: 2074 616b 656e 2061 7320 6c76 616c 7565 taken as lvalue │ │ │ -00028640: 2072 6566 6572 656e 6365 2068 6572 6520 reference here │ │ │ -00028650: 7369 6e63 6520 7765 206d 6179 206e 6f74 since we may not │ │ │ -00028660: 2063 616c 6c0a 092f 2f20 6974 2e20 4275 call..// it. Bu │ │ │ -00028670: 7420 6966 2077 6520 646f 2c20 7765 2077 t if we do, we w │ │ │ -00028680: 616e 7420 7468 6520 6361 6c6c 206f 7065 ant the call ope │ │ │ -00028690: 7261 746f 7220 746f 206f 776e 2074 6865 rator to own the │ │ │ -000286a0: 2066 756e 6374 696f 6e20 6f62 6a65 6374 function object │ │ │ -000286b0: 2e0a 0974 656d 706c 6174 6520 266c 743b ...template < │ │ │ -000286c0: 7479 7065 6e61 6d65 2048 616e 646c 6572 typename Handler │ │ │ -000286d0: 2667 743b 0a09 626f 6f6c 2068 616e 646c >..bool handl │ │ │ -000286e0: 655f 6572 726f 7228 6572 726f 725f 636f e_error(error_co │ │ │ -000286f0: 6465 2065 2c20 4861 6e64 6c65 7226 616d de e, Handler&am │ │ │ -00028700: 703b 2661 6d70 3b20 6829 0a09 7b0a 0909 p;& h)..{... │ │ │ -00028710: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ -00028720: 5f6d 6167 6963 203d 3d20 3078 3133 3337 _magic == 0x1337 │ │ │ -00028730: 293b 0a09 0969 6620 2821 6529 2072 6574 );...if (!e) ret │ │ │ -00028740: 7572 6e20 6661 6c73 653b 0a09 0965 7272 urn false;...err │ │ │ -00028750: 6f72 5f63 6f64 6520 6563 3b0a 0909 2f2f or_code ec;...// │ │ │ -00028760: 2070 7265 7665 6e74 206c 6966 6574 696d prevent lifetim │ │ │ -00028770: 6520 6d61 6e61 6765 6d65 6e74 2075 7365 e management use │ │ │ -00028780: 2d61 6674 6572 2d66 7265 650a 0909 636c -after-free...cl │ │ │ -00028790: 6f73 6528 6563 293b 202f 2f20 636c 6f73 ose(ec); // clos │ │ │ -000287a0: 6520 6669 7273 740a 0909 7374 643a 3a6d e first...std::m │ │ │ -000287b0: 6f76 6528 6829 2865 293b 202f 2f20 636f ove(h)(e); // co │ │ │ -000287c0: 6e73 756d 650a 0909 7265 7475 726e 2074 nsume...return t │ │ │ -000287d0: 7275 653b 0a09 7d0a 0a09 6175 783a 3a6e rue;..}...aux::n │ │ │ -000287e0: 6f65 7863 6570 745f 6d6f 7661 626c 6526 oexcept_movable& │ │ │ -000287f0: 6c74 3b74 6370 3a3a 736f 636b 6574 2667 lt;tcp::socket&g │ │ │ -00028800: 743b 206d 5f73 6f63 6b3b 0a09 7374 643a t; m_sock;..std: │ │ │ -00028810: 3a73 7472 696e 6720 6d5f 686f 7374 6e61 :string m_hostna │ │ │ -00028820: 6d65 3b20 2f2f 2070 726f 7879 2068 6f73 me; // proxy hos │ │ │ -00028830: 740a 0969 6e74 206d 5f70 6f72 7420 3d20 t..int m_port = │ │ │ -00028840: 303b 2020 2020 2020 2020 202f 2f20 7072 0; // pr │ │ │ -00028850: 6f78 7920 706f 7274 0a0a 0961 7578 3a3a oxy port...aux:: │ │ │ -00028860: 6e6f 6578 6365 7074 5f6d 6f76 6162 6c65 noexcept_movable │ │ │ -00028870: 266c 743b 656e 6470 6f69 6e74 5f74 7970 <endpoint_typ │ │ │ -00028880: 6526 6774 3b20 6d5f 7265 6d6f 7465 5f65 e> m_remote_e │ │ │ -00028890: 6e64 706f 696e 743b 0a0a 3c64 6976 2073 ndpoint;..
    .aux::no │ │ │ -000288d0: 6578 6365 7074 5f6d 6f76 655f 6f6e 6c79 except_move_only │ │ │ -000288e0: 266c 743b 7463 703a 3a72 6573 6f6c 7665 <tcp::resolve │ │ │ -000288f0: 7226 6774 3b20 6d5f 7265 736f 6c76 6572 r> m_resolver │ │ │ -00028900: 3b0a 3c2f 6469 763e 0a23 6966 2054 4f52 ;.
    .#if TOR │ │ │ -00028910: 5245 4e54 5f55 5345 5f41 5353 4552 5453 RENT_USE_ASSERTS │ │ │ -00028920: 0a09 696e 7420 6d5f 6d61 6769 6320 3d20 ..int m_magic = │ │ │ -00028930: 3078 3133 3337 3b0a 2365 6e64 6966 0a7d 0x1337;.#endif.} │ │ │ -00028940: 3b0a 0a74 656d 706c 6174 6520 266c 743b ;..template < │ │ │ -00028950: 7479 7065 6e61 6d65 2048 616e 646c 6572 typename Handler │ │ │ -00028960: 2c20 7479 7065 6e61 6d65 2055 6e64 6572 , typename Under │ │ │ -00028970: 6c79 696e 6748 616e 646c 6572 2667 743b lyingHandler> │ │ │ -00028980: 0a73 7472 7563 7420 7772 6170 5f61 6c6c .struct wrap_all │ │ │ -00028990: 6f63 6174 6f72 5f74 0a7b 0a09 7772 6170 ocator_t.{..wrap │ │ │ -000289a0: 5f61 6c6c 6f63 6174 6f72 5f74 2848 616e _allocator_t(Han │ │ │ -000289b0: 646c 6572 2068 2c20 556e 6465 726c 7969 dler h, Underlyi │ │ │ -000289c0: 6e67 4861 6e64 6c65 7220 7568 290a 0909 ngHandler uh)... │ │ │ -000289d0: 3a20 6d5f 6861 6e64 6c65 7228 7374 643a : m_handler(std: │ │ │ -000289e0: 3a6d 6f76 6528 6829 290a 0909 2c20 6d5f :move(h))..., m_ │ │ │ -000289f0: 756e 6465 726c 7969 6e67 5f68 616e 646c underlying_handl │ │ │ -00028a00: 6572 2873 7464 3a3a 6d6f 7665 2875 6829 er(std::move(uh) │ │ │ -00028a10: 290a 097b 7d0a 0a09 7772 6170 5f61 6c6c )..{}...wrap_all │ │ │ -00028a20: 6f63 6174 6f72 5f74 2877 7261 705f 616c ocator_t(wrap_al │ │ │ -00028a30: 6c6f 6361 746f 725f 7420 636f 6e73 7426 locator_t const& │ │ │ -00028a40: 616d 703b 2920 3d20 6465 6661 756c 743b amp;) = default; │ │ │ -00028a50: 0a09 7772 6170 5f61 6c6c 6f63 6174 6f72 ..wrap_allocator │ │ │ -00028a60: 5f74 2877 7261 705f 616c 6c6f 6361 746f _t(wrap_allocato │ │ │ -00028a70: 725f 7426 616d 703b 2661 6d70 3b29 203d r_t&&) = │ │ │ -00028a80: 2064 6566 6175 6c74 3b0a 0a09 7465 6d70 default;...temp │ │ │ -00028a90: 6c61 7465 2026 6c74 3b63 6c61 7373 2e2e late <class.. │ │ │ -00028aa0: 2e20 4126 6774 3b0a 0976 6f69 6420 6f70 . A>..void op │ │ │ -00028ab0: 6572 6174 6f72 2829 2841 2661 6d70 3b26 erator()(A&& │ │ │ -00028ac0: 616d 703b 2e2e 2e20 6129 0a09 7b0a 0909 amp;... a)..{... │ │ │ -00028ad0: 6d5f 6861 6e64 6c65 7228 7374 643a 3a66 m_handler(std::f │ │ │ -00028ae0: 6f72 7761 7264 266c 743b 4126 6774 3b28 orward<A>( │ │ │ -00028af0: 6129 2e2e 2e2c 2073 7464 3a3a 6d6f 7665 a)..., std::move │ │ │ -00028b00: 286d 5f75 6e64 6572 6c79 696e 675f 6861 (m_underlying_ha │ │ │ -00028b10: 6e64 6c65 7229 293b 0a09 7d0a 0a09 7573 ndler));..}...us │ │ │ -00028b20: 696e 6720 616c 6c6f 6361 746f 725f 7479 ing allocator_ty │ │ │ -00028b30: 7065 203d 2074 7970 656e 616d 6520 626f pe = typename bo │ │ │ -00028b40: 6f73 743a 3a61 7369 6f3a 3a61 7373 6f63 ost::asio::assoc │ │ │ -00028b50: 6961 7465 645f 616c 6c6f 6361 746f 7226 iated_allocator& │ │ │ -00028b60: 6c74 3b55 6e64 6572 6c79 696e 6748 616e lt;UnderlyingHan │ │ │ -00028b70: 646c 6572 2667 743b 3a3a 7479 7065 3b0a dler>::type;. │ │ │ -00028b80: 0975 7369 6e67 2065 7865 6375 746f 725f .using executor_ │ │ │ -00028b90: 7479 7065 203d 2074 7970 656e 616d 6520 type = typename │ │ │ -00028ba0: 626f 6f73 743a 3a61 7369 6f3a 3a61 7373 boost::asio::ass │ │ │ -00028bb0: 6f63 6961 7465 645f 6578 6563 7574 6f72 ociated_executor │ │ │ -00028bc0: 266c 743b 556e 6465 726c 7969 6e67 4861 <UnderlyingHa │ │ │ -00028bd0: 6e64 6c65 7226 6774 3b3a 3a74 7970 653b ndler>::type; │ │ │ -00028be0: 0a0a 0961 6c6c 6f63 6174 6f72 5f74 7970 ...allocator_typ │ │ │ -00028bf0: 6520 6765 745f 616c 6c6f 6361 746f 7228 e get_allocator( │ │ │ -00028c00: 2920 636f 6e73 7420 6e6f 6578 6365 7074 ) const noexcept │ │ │ -00028c10: 0a09 7b20 7265 7475 726e 2062 6f6f 7374 ..{ return boost │ │ │ -00028c20: 3a3a 6173 696f 3a3a 6765 745f 6173 736f ::asio::get_asso │ │ │ -00028c30: 6369 6174 6564 5f61 6c6c 6f63 6174 6f72 ciated_allocator │ │ │ -00028c40: 286d 5f75 6e64 6572 6c79 696e 675f 6861 (m_underlying_ha │ │ │ -00028c50: 6e64 6c65 7229 3b20 7d0a 0a09 6578 6563 ndler); }...exec │ │ │ -00028c60: 7574 6f72 5f74 7970 6520 6765 745f 6578 utor_type get_ex │ │ │ -00028c70: 6563 7574 6f72 2829 2063 6f6e 7374 206e ecutor() const n │ │ │ -00028c80: 6f65 7863 6570 740a 3c2f 7072 653e 3c2f oexcept.relevan │ │ │ -00028cc0: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2../include/lib │ │ │ -00028d00: 746f 7272 656e 742f 6175 785f 2f73 6573 torrent/aux_/ses │ │ │ -00028d10: 7369 6f6e 5f69 6e74 6572 6661 6365 2e68 sion_interface.h │ │ │ -00028d20: 7070 3a31 3033 3c2f 613e 3c2f 7464 3e3c pp:103< │ │ │ -00028d30: 7464 3e6d 616b 6520 7468 6973 2069 6e74 td>make this int │ │ │ -00028d40: 6572 6661 6365 2061 206c 6f74 2073 6d61 erface a lot sma │ │ │ -00028d50: 6c6c 6572 2e20 4974 2063 6f75 6c64 2062 ller. It could b │ │ │ -00028d60: 6520 7370 6c69 7420 7570 2069 6e74 6f20 e split up into │ │ │ -00028d70: 7365 7665 7261 6c20 736d 616c 6c65 7220 several smaller │ │ │ -00028d80: 696e 7465 7266 6163 6573 2e20 4561 6368 interfaces. Each │ │ │ -00028d90: 2073 7562 7379 7374 656d 2063 6f75 6c64 subsystem could │ │ │ -00028da0: 2074 6865 6e20 6c69 6d69 7420 7468 6520 then limit the │ │ │ -00028db0: 7369 7a65 206f 6620 7468 6520 6d6f 636b size of the mock │ │ │ -00028dc0: 206f 626a 6563 7420 746f 2074 6573 7420 object to test │ │ │ -00028dd0: 6974 2e3c 2f74 643e 3c2f 7472 3e3c 7472 it.

    │ │ │ -00028e20: 6d61 6b65 2074 6869 7320 696e 7465 7266 make this interf │ │ │ -00028e30: 6163 6520 6120 6c6f 7420 736d 616c 6c65 ace a lot smalle │ │ │ -00028e40: 722e 2049 7420 636f 756c 6420 6265 2073 r. It could be s │ │ │ -00028e50: 706c 6974 2075 7020 696e 746f 0a73 6576 plit up into.sev │ │ │ -00028e60: 6572 616c 2073 6d61 6c6c 6572 2069 6e74 eral smaller int │ │ │ -00028e70: 6572 6661 6365 732e 2045 6163 6820 7375 erfaces. Each su │ │ │ -00028e80: 6273 7973 7465 6d20 636f 756c 6420 7468 bsystem could th │ │ │ -00028e90: 656e 206c 696d 6974 2074 6865 2073 697a en limit the siz │ │ │ -00028ea0: 650a 6f66 2074 6865 206d 6f63 6b20 6f62 e.of the mock ob │ │ │ -00028eb0: 6a65 6374 2074 6f20 7465 7374 2069 742e ject to test it. │ │ │ -00028ec0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -00028ed0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00028ee0: 7578 5f2f 7365 7373 696f 6e5f 696e 7465 ux_/session_inte │ │ │ -00028ef0: 7266 6163 652e 6870 703a 3130 333c 2f68 rface.hpp:103
    .// 
    │ │ │ -00028f40: 6120 7265 6c65 6173 6520 6275 696c 6420  a release build 
    │ │ │ -00028f50: 7769 7468 206c 6f67 6769 6e67 2064 6973  with logging dis
    │ │ │ -00028f60: 6162 6c65 6420 2877 6869 6368 2069 7320  abled (which is 
    │ │ │ -00028f70: 7468 6520 6465 6661 756c 7429 2077 696c  the default) wil
    │ │ │ -00028f80: 6c0a 092f 2f20 6e6f 7420 6861 7665 2074  l..// not have t
    │ │ │ -00028f90: 6869 7320 636c 6173 7320 6174 2061 6c6c  his class at all
    │ │ │ -00028fa0: 0a09 7374 7275 6374 2054 4f52 5245 4e54  ..struct TORRENT
    │ │ │ -00028fb0: 5f45 5854 5241 5f45 5850 4f52 5420 7365  _EXTRA_EXPORT se
    │ │ │ -00028fc0: 7373 696f 6e5f 6c6f 6767 6572 0a09 7b0a  ssion_logger..{.
    │ │ │ -00028fd0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -00028fe0: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ -00028ff0: 0909 7669 7274 7561 6c20 626f 6f6c 2073  ..virtual bool s
    │ │ │ -00029000: 686f 756c 645f 6c6f 6728 2920 636f 6e73  hould_log() cons
    │ │ │ -00029010: 7420 3d20 303b 0a09 0976 6972 7475 616c  t = 0;...virtual
    │ │ │ -00029020: 2076 6f69 6420 7365 7373 696f 6e5f 6c6f   void session_lo
    │ │ │ -00029030: 6728 6368 6172 2063 6f6e 7374 2a20 666d  g(char const* fm
    │ │ │ -00029040: 742c 202e 2e2e 2920 636f 6e73 7420 544f  t, ...) const TO
    │ │ │ -00029050: 5252 454e 545f 464f 524d 4154 2832 2c33  RRENT_FORMAT(2,3
    │ │ │ -00029060: 2920 3d20 303b 0a23 656e 6469 660a 0a23  ) = 0;.#endif..#
    │ │ │ -00029070: 6966 2054 4f52 5245 4e54 5f55 5345 5f41  if TORRENT_USE_A
    │ │ │ -00029080: 5353 4552 5453 0a09 0976 6972 7475 616c  SSERTS...virtual
    │ │ │ -00029090: 2062 6f6f 6c20 6973 5f73 696e 676c 655f   bool is_single_
    │ │ │ -000290a0: 7468 7265 6164 2829 2063 6f6e 7374 203d  thread() const =
    │ │ │ -000290b0: 2030 3b0a 0909 7669 7274 7561 6c20 626f   0;...virtual bo
    │ │ │ -000290c0: 6f6c 2068 6173 5f70 6565 7228 6175 783a  ol has_peer(aux:
    │ │ │ -000290d0: 3a70 6565 725f 636f 6e6e 6563 7469 6f6e  :peer_connection
    │ │ │ -000290e0: 2063 6f6e 7374 2a20 7029 2063 6f6e 7374   const* p) const
    │ │ │ -000290f0: 203d 2030 3b0a 0909 7669 7274 7561 6c20   = 0;...virtual 
    │ │ │ -00029100: 626f 6f6c 2061 6e79 5f74 6f72 7265 6e74  bool any_torrent
    │ │ │ -00029110: 5f68 6173 5f70 6565 7228 6175 783a 3a70  _has_peer(aux::p
    │ │ │ -00029120: 6565 725f 636f 6e6e 6563 7469 6f6e 2063  eer_connection c
    │ │ │ -00029130: 6f6e 7374 2a20 7029 2063 6f6e 7374 203d  onst* p) const =
    │ │ │ -00029140: 2030 3b0a 0909 7669 7274 7561 6c20 626f   0;...virtual bo
    │ │ │ -00029150: 6f6c 2069 735f 706f 7374 696e 675f 746f  ol is_posting_to
    │ │ │ -00029160: 7272 656e 745f 7570 6461 7465 7328 2920  rrent_updates() 
    │ │ │ -00029170: 636f 6e73 7420 3d20 303b 0a23 656e 6469  const = 0;.#endi
    │ │ │ -00029180: 660a 0970 726f 7465 6374 6564 3a0a 0909  f..protected:...
    │ │ │ -00029190: 7e73 6573 7369 6f6e 5f6c 6f67 6765 7228  ~session_logger(
    │ │ │ -000291a0: 2920 7b7d 0a09 7d3b 0a23 656e 6469 6620  ) {}..};.#endif 
    │ │ │ -000291b0: 2f2f 2054 4f52 5245 4e54 5f44 4953 4142  // TORRENT_DISAB
    │ │ │ -000291c0: 4c45 5f4c 4f47 4749 4e47 207c 7c20 544f  LE_LOGGING || TO
    │ │ │ -000291d0: 5252 454e 545f 5553 455f 4153 5345 5254  RRENT_USE_ASSERT
    │ │ │ -000291e0: 530a 0a3c 6469 7620 7374 796c 653d 2262  S..
    .struct TORRENT │ │ │ -00029220: 5f45 5854 5241 5f45 5850 4f52 5420 7365 _EXTRA_EXPORT se │ │ │ -00029230: 7373 696f 6e5f 696e 7465 7266 6163 650a ssion_interface. │ │ │ -00029240: 3c2f 6469 763e 2369 6620 2164 6566 696e
    #if !defin │ │ │ -00029250: 6564 2054 4f52 5245 4e54 5f44 4953 4142 ed TORRENT_DISAB │ │ │ -00029260: 4c45 5f4c 4f47 4749 4e47 207c 7c20 544f LE_LOGGING || TO │ │ │ -00029270: 5252 454e 545f 5553 455f 4153 5345 5254 RRENT_USE_ASSERT │ │ │ -00029280: 530a 0909 3a20 7365 7373 696f 6e5f 6c6f S...: session_lo │ │ │ -00029290: 6767 6572 0a23 656e 6469 660a 097b 0a0a gger.#endif..{.. │ │ │ -000292a0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -000292b0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -000292e0: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../inc │ │ │ -00029310: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00029320: 6175 785f 2f73 6573 7369 6f6e 5f69 6e74 aux_/session_int │ │ │ -00029330: 6572 6661 6365 2e68 7070 3a31 3132 3c2f erface.hpp:112the I │ │ │ -00029350: 5020 766f 7469 6e67 206d 6563 6861 6e69 P voting mechani │ │ │ -00029360: 736d 2073 686f 756c 6420 6265 2066 6163 sm should be fac │ │ │ -00029370: 746f 7265 6420 6f75 7420 746f 2069 7473 tored out to its │ │ │ -00029380: 206f 776e 2063 6c61 7373 2c20 6e6f 7420 own class, not │ │ │ -00029390: 7061 7274 206f 6620 7468 6520 7365 7373 part of the sess │ │ │ -000293a0: 696f 6e20 616e 6420 7468 6573 6520 636f ion and these co │ │ │ -000293b0: 6e73 7461 6e74 7320 7368 6f75 6c64 206d nstants should m │ │ │ -000293c0: 6f76 6520 746f 6f3c 2f74 643e 3c2f 7472 ove too │ │ │ -00029400: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00029410: 3c68 323e 7468 6520 4950 2076 6f74 696e

    the IP votin │ │ │ -00029420: 6720 6d65 6368 616e 6973 6d20 7368 6f75 g mechanism shou │ │ │ -00029430: 6c64 2062 6520 6661 6374 6f72 6564 206f ld be factored o │ │ │ -00029440: 7574 0a74 6f20 6974 7320 6f77 6e20 636c ut.to its own cl │ │ │ -00029450: 6173 732c 206e 6f74 2070 6172 7420 6f66 ass, not part of │ │ │ -00029460: 2074 6865 2073 6573 7369 6f6e 0a61 6e64 the session.and │ │ │ -00029470: 2074 6865 7365 2063 6f6e 7374 616e 7473 these constants │ │ │ -00029480: 2073 686f 756c 6420 6d6f 7665 2074 6f6f should move too │ │ │ -00029490: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -000294a0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -000294b0: 7578 5f2f 7365 7373 696f 6e5f 696e 7465 ux_/session_inte │ │ │ -000294c0: 7266 6163 652e 6870 703a 3131 323c 2f68 rface.hpp:112
    ..vi
    │ │ │ -00029510: 7274 7561 6c20 766f 6964 2073 6573 7369  rtual void sessi
    │ │ │ -00029520: 6f6e 5f6c 6f67 2863 6861 7220 636f 6e73  on_log(char cons
    │ │ │ -00029530: 742a 2066 6d74 2c20 2e2e 2e29 2063 6f6e  t* fmt, ...) con
    │ │ │ -00029540: 7374 2054 4f52 5245 4e54 5f46 4f52 4d41  st TORRENT_FORMA
    │ │ │ -00029550: 5428 322c 3329 203d 2030 3b0a 2365 6e64  T(2,3) = 0;.#end
    │ │ │ -00029560: 6966 0a0a 2369 6620 544f 5252 454e 545f  if..#if TORRENT_
    │ │ │ -00029570: 5553 455f 4153 5345 5254 530a 0909 7669  USE_ASSERTS...vi
    │ │ │ -00029580: 7274 7561 6c20 626f 6f6c 2069 735f 7369  rtual bool is_si
    │ │ │ -00029590: 6e67 6c65 5f74 6872 6561 6428 2920 636f  ngle_thread() co
    │ │ │ -000295a0: 6e73 7420 3d20 303b 0a09 0976 6972 7475  nst = 0;...virtu
    │ │ │ -000295b0: 616c 2062 6f6f 6c20 6861 735f 7065 6572  al bool has_peer
    │ │ │ -000295c0: 2861 7578 3a3a 7065 6572 5f63 6f6e 6e65  (aux::peer_conne
    │ │ │ -000295d0: 6374 696f 6e20 636f 6e73 742a 2070 2920  ction const* p) 
    │ │ │ -000295e0: 636f 6e73 7420 3d20 303b 0a09 0976 6972  const = 0;...vir
    │ │ │ -000295f0: 7475 616c 2062 6f6f 6c20 616e 795f 746f  tual bool any_to
    │ │ │ -00029600: 7272 656e 745f 6861 735f 7065 6572 2861  rrent_has_peer(a
    │ │ │ -00029610: 7578 3a3a 7065 6572 5f63 6f6e 6e65 6374  ux::peer_connect
    │ │ │ -00029620: 696f 6e20 636f 6e73 742a 2070 2920 636f  ion const* p) co
    │ │ │ -00029630: 6e73 7420 3d20 303b 0a09 0976 6972 7475  nst = 0;...virtu
    │ │ │ -00029640: 616c 2062 6f6f 6c20 6973 5f70 6f73 7469  al bool is_posti
    │ │ │ -00029650: 6e67 5f74 6f72 7265 6e74 5f75 7064 6174  ng_torrent_updat
    │ │ │ -00029660: 6573 2829 2063 6f6e 7374 203d 2030 3b0a  es() const = 0;.
    │ │ │ -00029670: 2365 6e64 6966 0a09 7072 6f74 6563 7465  #endif..protecte
    │ │ │ -00029680: 643a 0a09 097e 7365 7373 696f 6e5f 6c6f  d:...~session_lo
    │ │ │ -00029690: 6767 6572 2829 207b 7d0a 097d 3b0a 2365  gger() {}..};.#e
    │ │ │ -000296a0: 6e64 6966 202f 2f20 544f 5252 454e 545f  ndif // TORRENT_
    │ │ │ -000296b0: 4449 5341 424c 455f 4c4f 4747 494e 4720  DISABLE_LOGGING 
    │ │ │ -000296c0: 7c7c 2054 4f52 5245 4e54 5f55 5345 5f41  || TORRENT_USE_A
    │ │ │ -000296d0: 5353 4552 5453 0a0a 0973 7472 7563 7420  SSERTS...struct 
    │ │ │ -000296e0: 544f 5252 454e 545f 4558 5452 415f 4558  TORRENT_EXTRA_EX
    │ │ │ -000296f0: 504f 5254 2073 6573 7369 6f6e 5f69 6e74  PORT session_int
    │ │ │ -00029700: 6572 6661 6365 0a23 6966 2021 6465 6669  erface.#if !defi
    │ │ │ -00029710: 6e65 6420 544f 5252 454e 545f 4449 5341  ned TORRENT_DISA
    │ │ │ -00029720: 424c 455f 4c4f 4747 494e 4720 7c7c 2054  BLE_LOGGING || T
    │ │ │ -00029730: 4f52 5245 4e54 5f55 5345 5f41 5353 4552  ORRENT_USE_ASSER
    │ │ │ -00029740: 5453 0a09 093a 2073 6573 7369 6f6e 5f6c  TS...: session_l
    │ │ │ -00029750: 6f67 6765 720a 2365 6e64 6966 0a09 7b0a  ogger.#endif..{.
    │ │ │ -00029760: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00029790: 3c2f 6469 763e 0909 2f2f 2074 6865 206c
    ..// the l │ │ │ -000297a0: 6f67 6963 2069 6e20 6970 5f76 6f74 6572 ogic in ip_voter │ │ │ -000297b0: 2072 656c 6965 7320 6f6e 206d 6f72 6520 relies on more │ │ │ -000297c0: 7265 6c69 6162 6c65 2073 6f75 7263 6573 reliable sources │ │ │ -000297d0: 2061 7265 2072 6570 7265 7365 6e74 6564 are represented │ │ │ -000297e0: 0a09 092f 2f20 6279 206d 6f72 6520 7369 ...// by more si │ │ │ -000297f0: 676e 6966 6963 616e 7420 6269 7473 0a09 gnificant bits.. │ │ │ -00029800: 0973 7461 7469 6320 696e 6c69 6e65 2063 .static inline c │ │ │ -00029810: 6f6e 7374 6578 7072 2069 705f 736f 7572 onstexpr ip_sour │ │ │ -00029820: 6365 5f74 2073 6f75 7263 655f 6468 7420 ce_t source_dht │ │ │ -00029830: 3d20 315f 6269 743b 0a09 0973 7461 7469 = 1_bit;...stati │ │ │ -00029840: 6320 696e 6c69 6e65 2063 6f6e 7374 6578 c inline constex │ │ │ -00029850: 7072 2069 705f 736f 7572 6365 5f74 2073 pr ip_source_t s │ │ │ -00029860: 6f75 7263 655f 7065 6572 203d 2032 5f62 ource_peer = 2_b │ │ │ -00029870: 6974 3b0a 0909 7374 6174 6963 2069 6e6c it;...static inl │ │ │ -00029880: 696e 6520 636f 6e73 7465 7870 7220 6970 ine constexpr ip │ │ │ -00029890: 5f73 6f75 7263 655f 7420 736f 7572 6365 _source_t source │ │ │ -000298a0: 5f74 7261 636b 6572 203d 2033 5f62 6974 _tracker = 3_bit │ │ │ -000298b0: 3b0a 0909 7374 6174 6963 2069 6e6c 696e ;...static inlin │ │ │ -000298c0: 6520 636f 6e73 7465 7870 7220 6970 5f73 e constexpr ip_s │ │ │ -000298d0: 6f75 7263 655f 7420 736f 7572 6365 5f72 ource_t source_r │ │ │ -000298e0: 6f75 7465 7220 3d20 345f 6269 743b 0a0a outer = 4_bit;.. │ │ │ -000298f0: 0909 7669 7274 7561 6c20 766f 6964 2073 ..virtual void s │ │ │ -00029900: 6574 5f65 7874 6572 6e61 6c5f 6164 6472 et_external_addr │ │ │ -00029910: 6573 7328 7463 703a 3a65 6e64 706f 696e ess(tcp::endpoin │ │ │ -00029920: 7420 636f 6e73 7426 616d 703b 206c 6f63 t const& loc │ │ │ -00029930: 616c 5f65 6e64 706f 696e 740a 0909 092c al_endpoint...., │ │ │ -00029940: 2061 6464 7265 7373 2063 6f6e 7374 2661 address const&a │ │ │ -00029950: 6d70 3b20 6970 0a09 0909 2c20 6970 5f73 mp; ip...., ip_s │ │ │ -00029960: 6f75 7263 655f 7420 736f 7572 6365 5f74 ource_t source_t │ │ │ -00029970: 7970 652c 2061 6464 7265 7373 2063 6f6e ype, address con │ │ │ -00029980: 7374 2661 6d70 3b20 736f 7572 6365 2920 st& source) │ │ │ -00029990: 3d20 303b 0a09 0976 6972 7475 616c 2061 = 0;...virtual a │ │ │ -000299a0: 7578 3a3a 6578 7465 726e 616c 5f69 7020 ux::external_ip │ │ │ -000299b0: 6578 7465 726e 616c 5f61 6464 7265 7373 external_address │ │ │ -000299c0: 2829 2063 6f6e 7374 203d 2030 3b0a 0a09 () const = 0;... │ │ │ -000299d0: 0976 6972 7475 616c 2064 6973 6b5f 696e .virtual disk_in │ │ │ -000299e0: 7465 7266 6163 6526 616d 703b 2064 6973 terface& dis │ │ │ -000299f0: 6b5f 7468 7265 6164 2829 203d 2030 3b0a k_thread() = 0;. │ │ │ -00029a00: 0a09 0976 6972 7475 616c 2061 6c65 7274 ...virtual alert │ │ │ -00029a10: 5f6d 616e 6167 6572 2661 6d70 3b20 616c _manager& al │ │ │ -00029a20: 6572 7473 2829 203d 2030 3b0a 0a09 0976 erts() = 0;....v │ │ │ -00029a30: 6972 7475 616c 2074 6f72 7265 6e74 5f70 irtual torrent_p │ │ │ -00029a40: 6565 725f 616c 6c6f 6361 746f 725f 696e eer_allocator_in │ │ │ -00029a50: 7465 7266 6163 6526 616d 703b 2067 6574 terface& get │ │ │ -00029a60: 5f70 6565 725f 616c 6c6f 6361 746f 7228 _peer_allocator( │ │ │ -00029a70: 2920 3d20 303b 0a09 0976 6972 7475 616c ) = 0;...virtual │ │ │ -00029a80: 2069 6f5f 636f 6e74 6578 7426 616d 703b io_context& │ │ │ -00029a90: 2067 6574 5f63 6f6e 7465 7874 2829 203d get_context() = │ │ │ -00029aa0: 2030 3b0a 0909 7669 7274 7561 6c20 6175 0;...virtual au │ │ │ -00029ab0: 783a 3a72 6573 6f6c 7665 725f 696e 7465 x::resolver_inte │ │ │ -00029ac0: 7266 6163 6526 616d 703b 2067 6574 5f72 rface& get_r │ │ │ -00029ad0: 6573 6f6c 7665 7228 2920 3d20 303b 0a0a esolver() = 0;.. │ │ │ -00029ae0: 0909 7669 7274 7561 6c20 626f 6f6c 2068 ..virtual bool h │ │ │ -00029af0: 6173 5f63 6f6e 6e65 6374 696f 6e28 7065 as_connection(pe │ │ │ -00029b00: 6572 5f63 6f6e 6e65 6374 696f 6e2a 2070 er_connection* p │ │ │ -00029b10: 2920 636f 6e73 7420 3d20 303b 0a09 0976 ) const = 0;...v │ │ │ -00029b20: 6972 7475 616c 2076 6f69 6420 696e 7365 irtual void inse │ │ │ -00029b30: 7274 5f70 6565 7228 7374 643a 3a73 6861 rt_peer(std::sha │ │ │ -00029b40: 7265 645f 7074 7226 6c74 3b70 6565 725f red_ptr<peer_ │ │ │ -00029b50: 636f 6e6e 6563 7469 6f6e 2667 743b 2063 connection> c │ │ │ -00029b60: 6f6e 7374 2661 6d70 3b20 6329 203d 2030 onst& c) = 0 │ │ │ -00029b70: 3b0a 0a09 0976 6972 7475 616c 2076 6f69 ;....virtual voi │ │ │ -00029b80: 6420 7265 6d6f 7665 5f74 6f72 7265 6e74 d remove_torrent │ │ │ -00029b90: 2874 6f72 7265 6e74 5f68 616e 646c 6520 (torrent_handle │ │ │ -00029ba0: 636f 6e73 7426 616d 703b 2068 2c20 7265 const& h, re │ │ │ -00029bb0: 6d6f 7665 5f66 6c61 6773 5f74 206f 7074 move_flags_t opt │ │ │ -00029bc0: 696f 6e73 203d 207b 7d29 203d 2030 3b0a ions = {}) = 0;. │ │ │ -00029bd0: 0909 7669 7274 7561 6c20 766f 6964 2072 ..virtual void r │ │ │ -00029be0: 656d 6f76 655f 746f 7272 656e 745f 696d emove_torrent_im │ │ │ -00029bf0: 706c 2873 7464 3a3a 7368 6172 6564 5f70 pl(std::shared_p │ │ │ -00029c00: 7472 266c 743b 746f 7272 656e 7426 6774 tr<torrent> │ │ │ -00029c10: 3b20 7470 7472 2c20 7265 6d6f 7665 5f66 ; tptr, remove_f │ │ │ -00029c20: 6c61 6773 5f74 206f 7074 696f 6e73 2920 lags_t options) │ │ │ -00029c30: 3d20 303b 0a0a 0909 2f2f 2070 6f72 7420 = 0;....// port │ │ │ -00029c40: 6669 6c74 6572 0a09 0976 6972 7475 616c filter...virtual │ │ │ -00029c50: 2070 6f72 745f 6669 6c74 6572 2063 6f6e port_filter con │ │ │ -00029c60: 7374 2661 6d70 3b20 6765 745f 706f 7274 st& get_port │ │ │ -00029c70: 5f66 696c 7465 7228 2920 636f 6e73 7420 _filter() const │ │ │ -00029c80: 3d20 303b 0a09 0976 6972 7475 616c 2076 = 0;...virtual v │ │ │ -00029c90: 6f69 6420 6261 6e5f 6970 2861 6464 7265 oid ban_ip(addre │ │ │ -00029ca0: 7373 2061 6464 7229 203d 2030 3b0a 0a3c ss addr) = 0;..< │ │ │ -00029cb0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00029cc0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00029cd0: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ -00029ce0: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ -00029cf0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../incl │ │ │ -00029d20: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00029d30: 7578 5f2f 656e 756d 5f6e 6574 2e68 7070 ux_/enum_net.hpp │ │ │ -00029d40: 3a31 3733 3c2f 613e 3c2f 7464 3e3c 7464 :173this could be d │ │ │ -00029d60: 6f6e 6520 6d6f 7265 2065 6666 6963 6965 one more efficie │ │ │ -00029d70: 6e74 6c79 2062 7920 6a75 7374 206c 6f6f ntly by just loo │ │ │ -00029d80: 6b69 6e67 2075 7020 7468 6520 696e 7465 king up the inte │ │ │ -00029d90: 7266 6163 6520 7769 7468 2074 6865 2067 rface with the g │ │ │ -00029da0: 6976 656e 206e 616d 652c 206d 6179 6265 iven name, maybe │ │ │ -00029db0: 2065 7665 6e20 7769 7468 2069 665f 6e61 even with if_na │ │ │ -00029dc0: 6d65 746f 696e 6465 7828 293c 2f74 643e metoindex() │ │ │ -00029dd0: 3c2f 7472 3e3c 7472 2069 643d 2238 3422

    this cou │ │ │ -00029e20: 6c64 2062 6520 646f 6e65 206d 6f72 6520 ld be done more │ │ │ -00029e30: 6566 6669 6369 656e 746c 7920 6279 206a efficiently by j │ │ │ -00029e40: 7573 7420 6c6f 6f6b 696e 6720 7570 0a74 ust looking up.t │ │ │ -00029e50: 6865 2069 6e74 6572 6661 6365 2077 6974 he interface wit │ │ │ -00029e60: 6820 7468 6520 6769 7665 6e20 6e61 6d65 h the given name │ │ │ -00029e70: 2c20 6d61 7962 6520 6576 656e 2077 6974 , maybe even wit │ │ │ -00029e80: 6820 6966 5f6e 616d 6574 6f69 6e64 6578 h if_nametoindex │ │ │ -00029e90: 2829 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ()

    ../in │ │ │ -00029ea0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00029eb0: 2f61 7578 5f2f 656e 756d 5f6e 6574 2e68 /aux_/enum_net.h │ │ │ -00029ec0: 7070 3a31 3733 3c2f 6834 3e3c 7072 6520 pp:173

    ...// IPv6 
    │ │ │ -00029f10: 6164 6472 6573 732e 2049 6620 7765 2772  address. If we'r
    │ │ │ -00029f20: 6520 6173 6b69 6e67 2074 6f20 6265 2062  e asking to be b
    │ │ │ -00029f30: 6f75 6e64 2074 6f20 616e 2049 5076 3620  ound to an IPv6 
    │ │ │ -00029f40: 6164 6472 6573 7320 616e 640a 0909 092f  address and..../
    │ │ │ -00029f50: 2f20 7072 6f76 6964 696e 6720 302e 302e  / providing 0.0.
    │ │ │ -00029f60: 302e 3020 6173 2074 6865 2064 6576 6963  0.0 as the devic
    │ │ │ -00029f70: 652c 2074 7572 6e20 6974 2069 6e74 6f20  e, turn it into 
    │ │ │ -00029f80: 223a 3a22 0a09 0909 6966 2028 6970 203d  "::"....if (ip =
    │ │ │ -00029f90: 3d20 6164 6472 6573 735f 7634 3a3a 616e  = address_v4::an
    │ │ │ -00029fa0: 7928 2920 2661 6d70 3b26 616d 703b 2070  y() && p
    │ │ │ -00029fb0: 726f 746f 636f 6c20 3d3d 2062 6f6f 7374  rotocol == boost
    │ │ │ -00029fc0: 3a3a 6173 696f 3a3a 6970 3a3a 7463 703a  ::asio::ip::tcp:
    │ │ │ -00029fd0: 3a76 3628 2929 0a09 0909 0969 7020 3d20  :v6()).....ip = 
    │ │ │ -00029fe0: 6164 6472 6573 735f 7636 3a3a 616e 7928  address_v6::any(
    │ │ │ -00029ff0: 293b 0a09 0909 6269 6e64 5f65 702e 6164  );....bind_ep.ad
    │ │ │ -0002a000: 6472 6573 7328 6970 293b 0a09 0909 2f2f  dress(ip);....//
    │ │ │ -0002a010: 2069 7420 6170 7065 6172 7320 746f 2062   it appears to b
    │ │ │ -0002a020: 6520 616e 2049 502e 204a 7573 7420 6269  e an IP. Just bi
    │ │ │ -0002a030: 6e64 2074 6f20 7468 6174 2061 6464 7265  nd to that addre
    │ │ │ -0002a040: 7373 0a09 0909 736f 636b 2e62 696e 6428  ss....sock.bind(
    │ │ │ -0002a050: 6269 6e64 5f65 702c 2065 6329 3b0a 0909  bind_ep, ec);...
    │ │ │ -0002a060: 0972 6574 7572 6e20 6269 6e64 5f65 702e  .return bind_ep.
    │ │ │ -0002a070: 6164 6472 6573 7328 293b 0a09 097d 0a0a  address();...}..
    │ │ │ -0002a080: 0909 6563 2e63 6c65 6172 2829 3b0a 0a23  ..ec.clear();..#
    │ │ │ -0002a090: 6966 2054 4f52 5245 4e54 5f48 4153 5f42  if TORRENT_HAS_B
    │ │ │ -0002a0a0: 494e 4454 4f44 4556 4943 450a 0909 2f2f  INDTODEVICE...//
    │ │ │ -0002a0b0: 2074 7279 2074 6f20 7573 6520 534f 5f42   try to use SO_B
    │ │ │ -0002a0c0: 494e 4454 4f44 4556 4943 4520 6865 7265  INDTODEVICE here
    │ │ │ -0002a0d0: 2c20 6966 2074 6861 7420 6578 6973 7473  , if that exists
    │ │ │ -0002a0e0: 2e20 4966 2069 7420 6661 696c 732c 0a09  . If it fails,..
    │ │ │ -0002a0f0: 092f 2f20 6661 6c6c 2062 6163 6b20 746f  .// fall back to
    │ │ │ -0002a100: 2074 6865 206d 6563 6861 6e69 736d 2077   the mechanism w
    │ │ │ -0002a110: 6520 6861 7665 2062 656c 6f77 0a09 0961  e have below...a
    │ │ │ -0002a120: 7578 3a3a 6269 6e64 5f64 6576 6963 6528  ux::bind_device(
    │ │ │ -0002a130: 736f 636b 2c20 6465 7669 6365 5f6e 616d  sock, device_nam
    │ │ │ -0002a140: 652c 2065 6329 3b0a 0909 6966 2028 6563  e, ec);...if (ec
    │ │ │ -0002a150: 290a 2365 6e64 6966 0a09 097b 0a09 0909  ).#endif...{....
    │ │ │ -0002a160: 6563 2e63 6c65 6172 2829 3b0a 3c64 6976  ec.clear();.
    ...std │ │ │ -0002a1a0: 3a3a 7665 6374 6f72 266c 743b 6970 5f69 ::vector<ip_i │ │ │ -0002a1b0: 6e74 6572 6661 6365 2667 743b 2069 6673 nterface> ifs │ │ │ -0002a1c0: 203d 2065 6e75 6d5f 6e65 745f 696e 7465 = enum_net_inte │ │ │ -0002a1d0: 7266 6163 6573 2869 6f73 2c20 6563 293b rfaces(ios, ec); │ │ │ -0002a1e0: 0a3c 2f64 6976 3e09 0909 6966 2028 6563 .
    ...if (ec │ │ │ -0002a1f0: 2920 7265 7475 726e 2062 696e 645f 6570 ) return bind_ep │ │ │ -0002a200: 2e61 6464 7265 7373 2829 3b0a 0a09 0909 .address();..... │ │ │ -0002a210: 626f 6f6c 2066 6f75 6e64 203d 2066 616c bool found = fal │ │ │ -0002a220: 7365 3b0a 0a09 0909 666f 7220 2861 7574 se;.....for (aut │ │ │ -0002a230: 6f20 636f 6e73 7426 616d 703b 2069 6661 o const& ifa │ │ │ -0002a240: 6365 203a 2069 6673 290a 0909 097b 0a09 ce : ifs)....{.. │ │ │ -0002a250: 0909 092f 2f20 7765 2772 6520 6c6f 6f6b ...// we're look │ │ │ -0002a260: 696e 6720 666f 7220 6120 7370 6563 6966 ing for a specif │ │ │ -0002a270: 6963 2069 6e74 6572 6661 6365 2c20 616e ic interface, an │ │ │ -0002a280: 6420 6974 7320 6164 6472 6573 730a 0909 d its address... │ │ │ -0002a290: 0909 2f2f 2028 7768 6963 6820 6d75 7374 ..// (which must │ │ │ -0002a2a0: 2062 6520 6f66 2074 6865 2073 616d 6520 be of the same │ │ │ -0002a2b0: 6661 6d69 6c79 2061 7320 7468 6520 6164 family as the ad │ │ │ -0002a2c0: 6472 6573 7320 7765 2772 650a 0909 0909 dress we're..... │ │ │ -0002a2d0: 2f2f 2063 6f6e 6e65 6374 696e 6720 746f // connecting to │ │ │ -0002a2e0: 290a 0909 0909 6966 2028 7374 643a 3a73 ).....if (std::s │ │ │ -0002a2f0: 7472 636d 7028 6966 6163 652e 6e61 6d65 trcmp(iface.name │ │ │ -0002a300: 2c20 6465 7669 6365 5f6e 616d 6529 2021 , device_name) ! │ │ │ -0002a310: 3d20 3029 2063 6f6e 7469 6e75 653b 0a09 = 0) continue;.. │ │ │ -0002a320: 0909 0969 6620 2869 6661 6365 2e69 6e74 ...if (iface.int │ │ │ -0002a330: 6572 6661 6365 5f61 6464 7265 7373 2e69 erface_address.i │ │ │ -0002a340: 735f 7634 2829 2021 3d20 2870 726f 746f s_v4() != (proto │ │ │ -0002a350: 636f 6c20 3d3d 2062 6f6f 7374 3a3a 6173 col == boost::as │ │ │ -0002a360: 696f 3a3a 6970 3a3a 7463 703a 3a76 3428 io::ip::tcp::v4( │ │ │ -0002a370: 2929 290a 0909 0909 0963 6f6e 7469 6e75 )))......continu │ │ │ -0002a380: 653b 0a0a 0909 0909 6269 6e64 5f65 702e e;......bind_ep. │ │ │ -0002a390: 6164 6472 6573 7328 6966 6163 652e 696e address(iface.in │ │ │ -0002a3a0: 7465 7266 6163 655f 6164 6472 6573 7329 terface_address) │ │ │ -0002a3b0: 3b0a 0909 0909 666f 756e 6420 3d20 7472 ;.....found = tr │ │ │ -0002a3c0: 7565 3b0a 0909 0909 6272 6561 6b3b 0a09 ue;.....break;.. │ │ │ -0002a3d0: 0909 7d0a 0a09 0909 6966 2028 2166 6f75 ..}.....if (!fou │ │ │ -0002a3e0: 6e64 290a 0909 097b 0a09 0909 0965 6320 nd)....{.....ec │ │ │ -0002a3f0: 3d20 6572 726f 725f 636f 6465 2862 6f6f = error_code(boo │ │ │ -0002a400: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ -0002a410: 3a3a 6e6f 5f73 7563 685f 6465 7669 6365 ::no_such_device │ │ │ -0002a420: 2c20 6765 6e65 7269 635f 6361 7465 676f , generic_catego │ │ │ -0002a430: 7279 2829 293b 0a09 0909 0972 6574 7572 ry());.....retur │ │ │ -0002a440: 6e20 6269 6e64 5f65 702e 6164 6472 6573 n bind_ep.addres │ │ │ -0002a450: 7328 293b 0a09 0909 7d0a 0909 7d0a 0909 s();....}...}... │ │ │ -0002a460: 736f 636b 2e62 696e 6428 6269 6e64 5f65 sock.bind(bind_e │ │ │ -0002a470: 702c 2065 6329 3b0a 0909 7265 7475 726e p, ec);...return │ │ │ -0002a480: 2062 696e 645f 6570 2e61 6464 7265 7373 bind_ep.address │ │ │ -0002a490: 2829 3b0a 097d 0a0a 092f 2f20 7265 7475 ();..}...// retu │ │ │ -0002a4a0: 726e 7320 7468 6520 6465 7669 6365 206e rns the device n │ │ │ -0002a4b0: 616d 6520 7768 6f73 6520 6c6f 6361 6c20 ame whose local │ │ │ -0002a4c0: 6164 6472 6573 7320 6973 2060 6061 6464 address is ``add │ │ │ -0002a4d0: 7260 602e 2049 660a 092f 2f20 6e6f 2073 r``. If..// no s │ │ │ -0002a4e0: 7563 6820 6465 7669 6365 2069 7320 666f uch device is fo │ │ │ -0002a4f0: 756e 642c 2061 6e20 656d 7074 7920 7374 und, an empty st │ │ │ -0002a500: 7269 6e67 2069 7320 7265 7475 726e 6564 ring is returned │ │ │ -0002a510: 2e0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..
    < │ │ │ -0002a540: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0002a550: 703b 323c 2f74 643e 3c74 643e 3c61 2068 p;2../i │ │ │ -0002a580: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0002a590: 742f 6175 785f 2f70 6965 6365 5f70 6963 t/aux_/piece_pic │ │ │ -0002a5a0: 6b65 722e 6870 703a 3634 393c 2f61 3e3c ker.hpp:649< │ │ │ -0002a5b0: 2f74 643e 3c74 643e 6861 7669 6e67 2038 /td>having 8 │ │ │ -0002a5c0: 2070 7269 6f72 6974 7920 6c65 7665 6c73 priority levels │ │ │ -0002a5d0: 2069 7320 7072 6f62 6162 6c79 2065 7863 is probably exc │ │ │ -0002a5e0: 6573 7369 7665 2e20 4974 2073 686f 756c essive. It shoul │ │ │ -0002a5f0: 6420 7072 6f62 6162 6c79 2062 6520 6368 d probably be ch │ │ │ -0002a600: 616e 6765 6420 746f 2033 206c 6576 656c anged to 3 level │ │ │ -0002a610: 7320 2b20 646f 6e74 2d64 6f77 6e6c 6f61 s + dont-downloa │ │ │ -0002a620: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    ha │ │ │ -0002a670: 7669 6e67 2038 2070 7269 6f72 6974 7920 ving 8 priority │ │ │ -0002a680: 6c65 7665 6c73 2069 7320 7072 6f62 6162 levels is probab │ │ │ -0002a690: 6c79 2065 7863 6573 7369 7665 2e20 4974 ly excessive. It │ │ │ -0002a6a0: 2073 686f 756c 640a 7072 6f62 6162 6c79 should.probably │ │ │ -0002a6b0: 2062 6520 6368 616e 6765 6420 746f 2033 be changed to 3 │ │ │ -0002a6c0: 206c 6576 656c 7320 2b20 646f 6e74 2d64 levels + dont-d │ │ │ -0002a6d0: 6f77 6e6c 6f61 643c 2f68 323e 3c68 343e ownload

    │ │ │ -0002a6e0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0002a6f0: 7272 656e 742f 6175 785f 2f70 6965 6365 rrent/aux_/piece │ │ │ -0002a700: 5f70 6963 6b65 722e 6870 703a 3634 393c _picker.hpp:649< │ │ │ -0002a710: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0002a750: 0909 656c 7365 2069 6620 2873 7461 7465  ..else if (state
    │ │ │ -0002a760: 2829 203d 3d20 7069 6563 655f 6675 6c6c  () == piece_full
    │ │ │ -0002a770: 290a 0909 0909 0909 7374 6174 6528 7069  ).......state(pi
    │ │ │ -0002a780: 6563 655f 6675 6c6c 5f72 6576 6572 7365  ece_full_reverse
    │ │ │ -0002a790: 293b 0a09 0909 7d0a 0a09 0909 2f2f 2074  );....}.....// t
    │ │ │ -0002a7a0: 6865 206e 756d 6265 7220 6f66 2070 6565  he number of pee
    │ │ │ -0002a7b0: 7273 2074 6861 7420 6861 7320 7468 6973  rs that has this
    │ │ │ -0002a7c0: 2070 6965 6365 0a09 0909 2f2f 2028 6176   piece....// (av
    │ │ │ -0002a7d0: 6169 6c61 6269 6c69 7479 290a 0909 0973  ailability)....s
    │ │ │ -0002a7e0: 7464 3a3a 7569 6e74 3332 5f74 2070 6565  td::uint32_t pee
    │ │ │ -0002a7f0: 725f 636f 756e 7420 3a20 3236 3b0a 0a09  r_count : 26;...
    │ │ │ -0002a800: 0909 2f2f 206f 6e65 206f 6620 7468 6520  ..// one of the 
    │ │ │ -0002a810: 646f 776e 6c6f 6164 5f71 7565 7565 5f74  download_queue_t
    │ │ │ -0002a820: 2076 616c 7565 732e 2054 6869 7320 696e   values. This in
    │ │ │ -0002a830: 6469 6361 7465 7320 7768 6574 6865 7220  dicates whether 
    │ │ │ -0002a840: 7468 6973 2070 6965 6365 0a09 0909 2f2f  this piece....//
    │ │ │ -0002a850: 2069 7320 6375 7272 656e 746c 7920 6265   is currently be
    │ │ │ -0002a860: 696e 6720 646f 776e 6c6f 6164 6564 206f  ing downloaded o
    │ │ │ -0002a870: 7220 6e6f 742c 2061 6e64 2077 6861 7420  r not, and what 
    │ │ │ -0002a880: 7374 6174 6520 6974 2773 2069 6e20 6966  state it's in if
    │ │ │ -0002a890: 0a09 0909 2f2f 2069 7420 6973 2e20 5370  ....// it is. Sp
    │ │ │ -0002a8a0: 6563 6966 6963 616c 6c79 2c20 6173 2061  ecifically, as a
    │ │ │ -0002a8b0: 6e20 6f70 7469 6d69 7a61 7469 6f6e 2c20  n optimization, 
    │ │ │ -0002a8c0: 7069 6563 6573 2074 6861 7420 6861 7665  pieces that have
    │ │ │ -0002a8d0: 2061 6c6c 2062 6c6f 636b 730a 0909 092f   all blocks..../
    │ │ │ -0002a8e0: 2f20 7265 7175 6573 7465 6420 6672 6f6d  / requested from
    │ │ │ -0002a8f0: 2074 6865 6d20 6172 6520 7365 7061 7261   them are separa
    │ │ │ -0002a900: 7465 6420 6f75 7420 696e 746f 2073 6570  ted out into sep
    │ │ │ -0002a910: 6172 6174 6520 6c69 7374 7320 746f 206d  arate lists to m
    │ │ │ -0002a920: 616b 650a 0909 092f 2f20 6c6f 6f6b 7570  ake....// lookup
    │ │ │ -0002a930: 7320 7175 6963 6b65 722e 2054 6865 206d  s quicker. The m
    │ │ │ -0002a940: 6169 6e20 6f64 6469 7479 2069 7320 7468  ain oddity is th
    │ │ │ -0002a950: 6174 2077 6865 7468 6572 2061 2064 6f77  at whether a dow
    │ │ │ -0002a960: 6e6c 6f61 6469 6e67 2070 6965 6365 0a09  nloading piece..
    │ │ │ -0002a970: 0909 2f2f 2068 6173 206f 6e6c 7920 6265  ..// has only be
    │ │ │ -0002a980: 656e 2072 6571 7565 7374 6564 2066 726f  en requested fro
    │ │ │ -0002a990: 6d20 7065 6572 7320 7468 6174 2061 7265  m peers that are
    │ │ │ -0002a9a0: 2072 6576 6572 7365 2c20 7468 6174 2773   reverse, that's
    │ │ │ -0002a9b0: 0a09 0909 2f2f 2072 6563 6f72 6465 6420  ....// recorded 
    │ │ │ -0002a9c0: 6173 2070 6965 6365 5f64 6f77 6e6c 6f61  as piece_downloa
    │ │ │ -0002a9d0: 6469 6e67 5f72 6576 6572 7365 2c20 7768  ding_reverse, wh
    │ │ │ -0002a9e0: 6963 6820 7265 616c 6c79 206d 6561 6e73  ich really means
    │ │ │ -0002a9f0: 2074 6865 2073 616d 650a 0909 092f 2f20   the same....// 
    │ │ │ -0002aa00: 6173 2070 6965 6365 5f64 6f77 6e6c 6f61  as piece_downloa
    │ │ │ -0002aa10: 6469 6e67 2c20 6974 206a 7573 7420 7361  ding, it just sa
    │ │ │ -0002aa20: 7665 7320 7370 6163 6520 746f 2061 6c73  ves space to als
    │ │ │ -0002aa30: 6f20 696e 6469 6361 7465 2074 6861 7420  o indicate that 
    │ │ │ -0002aa40: 6974 0a09 0909 2f2f 2068 6173 2061 2062  it....// has a b
    │ │ │ -0002aa50: 6974 206c 6f77 6572 2070 7269 6f72 6974  it lower priorit
    │ │ │ -0002aa60: 792e 2054 6865 2072 6576 6572 7365 2062  y. The reverse b
    │ │ │ -0002aa70: 6974 2069 7320 6f6e 6c79 2072 656c 6576  it is only relev
    │ │ │ -0002aa80: 616e 7420 6966 2074 6865 0a09 0909 2f2f  ant if the....//
    │ │ │ -0002aa90: 2073 7461 7465 2069 7320 7069 6563 655f   state is piece_
    │ │ │ -0002aaa0: 646f 776e 6c6f 6164 696e 672e 0a09 0909  downloading.....
    │ │ │ -0002aab0: 7374 643a 3a75 696e 7433 325f 7420 646f  std::uint32_t do
    │ │ │ -0002aac0: 776e 6c6f 6164 5f73 7461 7465 203a 2033  wnload_state : 3
    │ │ │ -0002aad0: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    .
    ...// is │ │ │ -0002ab10: 2030 2069 6620 7468 6520 7069 6563 6520 0 if the piece │ │ │ -0002ab20: 6973 2066 696c 7465 7265 6420 286e 6f74 is filtered (not │ │ │ -0002ab30: 2074 6f20 6265 2064 6f77 6e6c 6f61 6465 to be downloade │ │ │ -0002ab40: 6429 0a09 0909 2f2f 2031 2069 7320 6c6f d)....// 1 is lo │ │ │ -0002ab50: 7720 7072 696f 7269 7479 0a09 0909 2f2f w priority....// │ │ │ -0002ab60: 2032 2069 7320 6c6f 7720 7072 696f 7269 2 is low priori │ │ │ -0002ab70: 7479 0a09 0909 2f2f 2033 2069 7320 6d69 ty....// 3 is mi │ │ │ -0002ab80: 6420 7072 696f 7269 7479 0a09 0909 2f2f d priority....// │ │ │ -0002ab90: 2034 2069 7320 6465 6661 756c 7420 7072 4 is default pr │ │ │ -0002aba0: 696f 7269 7479 0a09 0909 2f2f 2035 2069 iority....// 5 i │ │ │ -0002abb0: 7320 6d69 6420 7072 696f 7269 7479 0a09 s mid priority.. │ │ │ -0002abc0: 0909 2f2f 2036 2069 7320 6869 6768 2070 ..// 6 is high p │ │ │ -0002abd0: 7269 6f72 6974 790a 0909 092f 2f20 3720 riority....// 7 │ │ │ -0002abe0: 6973 2068 6967 6820 7072 696f 7269 7479 is high priority │ │ │ -0002abf0: 0a09 0909 7374 643a 3a75 696e 7433 325f ....std::uint32_ │ │ │ -0002ac00: 7420 7069 6563 655f 7072 696f 7269 7479 t piece_priority │ │ │ -0002ac10: 203a 2033 3b0a 0a09 0909 2f2f 2069 6e64 : 3;.....// ind │ │ │ -0002ac20: 6578 2069 6e20 746f 2074 6865 2070 6965 ex in to the pie │ │ │ -0002ac30: 6365 5f69 6e66 6f20 7665 6374 6f72 0a09 ce_info vector.. │ │ │ -0002ac40: 0909 7072 696f 5f69 6e64 6578 5f74 2069 ..prio_index_t i │ │ │ -0002ac50: 6e64 6578 3b0a 0a23 6966 6465 6620 544f ndex;..#ifdef TO │ │ │ -0002ac60: 5252 454e 545f 4445 4255 475f 5245 4643 RRENT_DEBUG_REFC │ │ │ -0002ac70: 4f55 4e54 530a 0909 092f 2f20 616c 6c20 OUNTS....// all │ │ │ -0002ac80: 7468 6520 7065 6572 7320 7468 6174 2068 the peers that h │ │ │ -0002ac90: 6176 6520 7468 6973 2070 6965 6365 0a09 ave this piece.. │ │ │ -0002aca0: 0909 7374 643a 3a73 6574 266c 743b 636f ..std::set<co │ │ │ -0002acb0: 6e73 7420 6175 783a 3a74 6f72 7265 6e74 nst aux::torrent │ │ │ -0002acc0: 5f70 6565 722a 2667 743b 2068 6176 655f _peer*> have_ │ │ │ -0002acd0: 7065 6572 733b 0a23 656e 6469 660a 0a09 peers;.#endif... │ │ │ -0002ace0: 0909 2f2f 2069 6e64 6578 2069 7320 7365 ..// index is se │ │ │ -0002acf0: 7420 746f 2074 6869 7320 746f 2069 6e64 t to this to ind │ │ │ -0002ad00: 6963 6174 6520 7468 6174 2074 6869 7320 icate that this │ │ │ -0002ad10: 7069 6563 6520 6861 7320 6265 656e 0a09 piece has been.. │ │ │ -0002ad20: 0909 2f2f 2066 6c75 7368 6564 2028 692e ..// flushed (i. │ │ │ -0002ad30: 652e 2074 6865 2070 6963 6b65 7220 6861 e. the picker ha │ │ │ -0002ad40: 7320 6669 6e61 6c69 7a65 6420 6163 636f s finalized acco │ │ │ -0002ad50: 756e 7469 6e67 2066 6f72 2069 740a 0909 unting for it... │ │ │ -0002ad60: 092f 2f20 616e 6420 7265 6d6f 7665 6420 .// and removed │ │ │ -0002ad70: 6974 2066 726f 6d20 7468 6520 7072 696f it from the prio │ │ │ -0002ad80: 7269 7479 2062 7563 6b65 7473 292e 2054 rity buckets). T │ │ │ -0002ad90: 6865 2066 6c75 7368 6564 2066 6c61 670a he flushed flag. │ │ │ -0002ada0: 0909 092f 2f20 6973 2074 6865 2073 7472 ...// is the str │ │ │ -0002adb0: 6963 7420 6e6f 7469 6f6e 206f 6620 2268 ict notion of "h │ │ │ -0002adc0: 6164 223a 2070 6965 6365 5f70 6963 6b65 ad": piece_picke │ │ │ -0002add0: 723a 3a68 6176 655f 7069 6563 6528 290a r::have_piece(). │ │ │ -0002ade0: 0909 092f 2f20 6973 2074 6865 206c 6f6f ...// is the loo │ │ │ -0002adf0: 7365 206e 6f74 696f 6e20 2870 6173 7365 se notion (passe │ │ │ -0002ae00: 645f 6861 7368 5f63 6865 636b 204f 5220 d_hash_check OR │ │ │ -0002ae10: 666c 7573 6865 6429 2e20 4d6f 7374 0a09 flushed). Most.. │ │ │ -0002ae20: 0909 2f2f 2069 6e74 6572 6e61 6c20 636f ..// internal co │ │ │ -0002ae30: 6465 2077 616e 7473 2074 6865 2073 7472 de wants the str │ │ │ -0002ae40: 6963 7420 6e6f 7469 6f6e 2028 652e 672e ict notion (e.g. │ │ │ -0002ae50: 2063 7572 736f 7220 6164 7661 6e63 650a cursor advance. │ │ │ -0002ae60: 0909 092f 2f20 6973 2064 7269 7665 6e20 ...// is driven │ │ │ -0002ae70: 6279 2070 6965 6365 5f66 6c75 7368 6564 by piece_flushed │ │ │ -0002ae80: 2829 292e 0a09 0909 7374 6174 6963 2069 ()).....static i │ │ │ -0002ae90: 6e6c 696e 6520 636f 6e73 7465 7870 7220 nline constexpr │ │ │ -0002aea0: 7072 696f 5f69 6e64 6578 5f74 2066 6c75 prio_index_t flu │ │ │ -0002aeb0: 7368 6564 5f69 6e64 6578 7b2d 317d 3b0a shed_index{-1};. │ │ │ -0002aec0: 0a09 0909 2f2f 2074 6865 2070 7269 6f72 ....// the prior │ │ │ -0002aed0: 6974 7920 7661 6c75 6520 7468 6174 206d ity value that m │ │ │ -0002aee0: 6561 6e73 2074 6865 2070 6965 6365 2069 eans the piece i │ │ │ -0002aef0: 7320 6669 6c74 6572 6564 0a09 0909 7374 s filtered....st │ │ │ -0002af00: 6174 6963 2063 6f6e 7374 6578 7072 2073 atic constexpr s │ │ │ -0002af10: 7464 3a3a 7569 6e74 3332 5f74 2066 696c td::uint32_t fil │ │ │ -0002af20: 7465 725f 7072 696f 7269 7479 203d 2030 ter_priority = 0 │ │ │ -0002af30: 3b0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ;..
    │ │ │ -0002af60: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0002af70: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ -0002afa0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0002afb0: 6e74 2f61 7578 5f2f 7065 6572 5f63 6f6e nt/aux_/peer_con │ │ │ -0002afc0: 6e65 6374 696f 6e2e 6870 703a 3937 303c nection.hpp:970< │ │ │ -0002afd0: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ -0002afe0: 2073 686f 756c 6420 7265 616c 6c79 2062 should really b │ │ │ -0002aff0: 6520 6120 6369 7263 756c 6172 2062 7566 e a circular buf │ │ │ -0002b000: 6665 723c 2f74 643e 3c2f 7472 3e3c 7472 fer

    │ │ │ -0002b050: 7468 6973 2073 686f 756c 6420 7265 616c this should real │ │ │ -0002b060: 6c79 2062 6520 6120 6369 7263 756c 6172 ly be a circular │ │ │ -0002b070: 2062 7566 6665 723c 2f68 323e 3c68 343e buffer

    │ │ │ -0002b080: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0002b090: 7272 656e 742f 6175 785f 2f70 6565 725f rrent/aux_/peer_ │ │ │ -0002b0a0: 636f 6e6e 6563 7469 6f6e 2e68 7070 3a39 connection.hpp:9 │ │ │ -0002b0b0: 3730 3c2f 6834 3e3c 7072 6520 7374 796c 70

    ..// it just se
    │ │ │ -0002b100: 7276 6573 2061 7320 6120 7175 6575 6520  rves as a queue 
    │ │ │ -0002b110: 746f 2072 656d 656d 6265 7220 7768 6174  to remember what
    │ │ │ -0002b120: 2077 6527 7665 2073 656e 742c 2074 6f20   we've sent, to 
    │ │ │ -0002b130: 6176 6f69 640a 0909 2f2f 2072 652d 7365  avoid...// re-se
    │ │ │ -0002b140: 6e64 696e 6720 7375 6767 6573 7473 2066  nding suggests f
    │ │ │ -0002b150: 6f72 2074 6865 2073 616d 6520 7069 6563  or the same piec
    │ │ │ -0002b160: 650a 0909 2f2f 2069 2e65 2e20 6f75 7467  e...// i.e. outg
    │ │ │ -0002b170: 6f69 6e67 2073 7567 6765 7374 2070 6965  oing suggest pie
    │ │ │ -0002b180: 6365 730a 0909 6175 783a 3a76 6563 746f  ces...aux::vecto
    │ │ │ -0002b190: 7226 6c74 3b70 6965 6365 5f69 6e64 6578  r<piece_index
    │ │ │ -0002b1a0: 5f74 2667 743b 206d 5f73 7567 6765 7374  _t> m_suggest
    │ │ │ -0002b1b0: 5f70 6965 6365 733b 0a0a 0909 2f2f 2074  _pieces;....// t
    │ │ │ -0002b1c0: 6865 2070 6965 6365 7320 7765 2077 696c  he pieces we wil
    │ │ │ -0002b1d0: 6c20 7365 6e64 2074 6f20 7468 6520 7065  l send to the pe
    │ │ │ -0002b1e0: 6572 0a09 092f 2f20 6966 2072 6571 7565  er...// if reque
    │ │ │ -0002b1f0: 7374 6564 2028 7265 6761 7264 6c65 7373  sted (regardless
    │ │ │ -0002b200: 206f 6620 6368 6f6b 6520 7374 6174 6529   of choke state)
    │ │ │ -0002b210: 0a09 0973 7464 3a3a 7665 6374 6f72 266c  ...std::vector&l
    │ │ │ -0002b220: 743b 7069 6563 655f 696e 6465 785f 7426  t;piece_index_t&
    │ │ │ -0002b230: 6774 3b20 6d5f 6163 6365 7074 5f66 6173  gt; m_accept_fas
    │ │ │ -0002b240: 743b 0a0a 0909 2f2f 2061 2073 656e 742d  t;....// a sent-
    │ │ │ -0002b250: 7069 6563 6520 636f 756e 7465 7220 666f  piece counter fo
    │ │ │ -0002b260: 7220 7468 6520 616c 6c6f 7765 6420 6661  r the allowed fa
    │ │ │ -0002b270: 7374 2073 6574 0a09 092f 2f20 746f 2061  st set...// to a
    │ │ │ -0002b280: 766f 6964 2065 7870 6c6f 6974 6174 696f  void exploitatio
    │ │ │ -0002b290: 6e2e 2045 6163 6820 736c 6f74 2069 7320  n. Each slot is 
    │ │ │ -0002b2a0: 6120 636f 756e 7465 720a 0909 2f2f 2066  a counter...// f
    │ │ │ -0002b2b0: 6f72 206f 6e65 206f 6620 7468 6520 7069  or one of the pi
    │ │ │ -0002b2c0: 6563 6573 2066 726f 6d20 7468 6520 616c  eces from the al
    │ │ │ -0002b2d0: 6c6f 7765 642d 6661 7374 2073 6574 0a09  lowed-fast set..
    │ │ │ -0002b2e0: 0961 7578 3a3a 7665 6374 6f72 266c 743b  .aux::vector<
    │ │ │ -0002b2f0: 7374 643a 3a75 696e 7431 365f 7426 6774  std::uint16_t>
    │ │ │ -0002b300: 3b20 6d5f 6163 6365 7074 5f66 6173 745f  ; m_accept_fast_
    │ │ │ -0002b310: 7069 6563 655f 636e 743b 0a0a 0909 2f2f  piece_cnt;....//
    │ │ │ -0002b320: 2074 6865 2070 6965 6365 7320 7468 6520   the pieces the 
    │ │ │ -0002b330: 7065 6572 2077 696c 6c20 7365 6e64 2075  peer will send u
    │ │ │ -0002b340: 7320 6966 0a09 092f 2f20 7265 7175 6573  s if...// reques
    │ │ │ -0002b350: 7465 6420 2872 6567 6172 646c 6573 7320  ted (regardless 
    │ │ │ -0002b360: 6f66 2063 686f 6b65 2073 7461 7465 290a  of choke state).
    │ │ │ -0002b370: 0909 7374 643a 3a76 6563 746f 7226 6c74  ..std::vector<
    │ │ │ -0002b380: 3b70 6965 6365 5f69 6e64 6578 5f74 2667  ;piece_index_t&g
    │ │ │ -0002b390: 743b 206d 5f61 6c6c 6f77 6564 5f66 6173  t; m_allowed_fas
    │ │ │ -0002b3a0: 743b 0a0a 0909 2f2f 2070 6965 6365 7320  t;....// pieces 
    │ │ │ -0002b3b0: 7468 6174 2068 6173 2062 6565 6e20 7375  that has been su
    │ │ │ -0002b3c0: 6767 6573 7465 6420 746f 2062 6520 646f  ggested to be do
    │ │ │ -0002b3d0: 776e 6c6f 6164 6564 2066 726f 6d20 7468  wnloaded from th
    │ │ │ -0002b3e0: 6973 2070 6565 720a 0909 2f2f 2069 2e65  is peer...// i.e
    │ │ │ -0002b3f0: 2e20 696e 636f 6d69 6e67 2073 7567 6765  . incoming sugge
    │ │ │ -0002b400: 7374 696f 6e73 0a3c 6469 7620 7374 796c  stions.
    ..aux::vect │ │ │ -0002b440: 6f72 266c 743b 7069 6563 655f 696e 6465 or<piece_inde │ │ │ -0002b450: 785f 7426 6774 3b20 6d5f 7375 6767 6573 x_t> m_sugges │ │ │ -0002b460: 7465 645f 7069 6563 6573 3b0a 3c2f 6469 ted_pieces;....// the time │ │ │ -0002b480: 2077 6865 6e20 7468 6973 2070 6565 7220 when this peer │ │ │ -0002b490: 6c61 7374 2073 6177 2061 2063 6f6d 706c last saw a compl │ │ │ -0002b4a0: 6574 6520 636f 7079 0a09 092f 2f20 6f66 ete copy...// of │ │ │ -0002b4b0: 2074 6869 7320 746f 7272 656e 740a 0909 this torrent... │ │ │ -0002b4c0: 7469 6d65 5f74 206d 5f6c 6173 745f 7365 time_t m_last_se │ │ │ -0002b4d0: 656e 5f63 6f6d 706c 6574 6520 3d20 303b en_complete = 0; │ │ │ -0002b4e0: 0a0a 0909 2f2f 2074 6865 2062 6c6f 636b ....// the block │ │ │ -0002b4f0: 2077 6527 7265 2063 7572 7265 6e74 6c79 we're currently │ │ │ -0002b500: 2072 6563 6569 7669 6e67 2e20 4f72 0a09 receiving. Or.. │ │ │ -0002b510: 092f 2f20 282d 312c 202d 3129 2069 6620 .// (-1, -1) if │ │ │ -0002b520: 7765 2772 6520 6e6f 7420 7265 6365 6976 we're not receiv │ │ │ -0002b530: 696e 6720 6f6e 650a 0909 7069 6563 655f ing one...piece_ │ │ │ -0002b540: 626c 6f63 6b20 6d5f 7265 6365 6976 696e block m_receivin │ │ │ -0002b550: 675f 626c 6f63 6b20 3d20 7069 6563 655f g_block = piece_ │ │ │ -0002b560: 626c 6f63 6b3a 3a69 6e76 616c 6964 3b0a block::invalid;. │ │ │ -0002b570: 0a09 092f 2f20 7468 6520 6c6f 6361 6c20 ...// the local │ │ │ -0002b580: 656e 6470 6f69 6e74 2066 6f72 2074 6869 endpoint for thi │ │ │ -0002b590: 7320 7065 6572 2c20 692e 652e 206f 7572 s peer, i.e. our │ │ │ -0002b5a0: 2061 6464 7265 7373 0a09 092f 2f20 616e address...// an │ │ │ -0002b5b0: 6420 6f75 7220 706f 7274 2e20 4966 2074 d our port. If t │ │ │ -0002b5c0: 6869 7320 6973 2073 6574 2066 6f72 206f his is set for o │ │ │ -0002b5d0: 7574 676f 696e 6720 636f 6e6e 6563 7469 utgoing connecti │ │ │ -0002b5e0: 6f6e 730a 0909 2f2f 2062 6566 6f72 6520 ons...// before │ │ │ -0002b5f0: 7468 6520 636f 6e6e 6563 7469 6f6e 2063 the connection c │ │ │ -0002b600: 6f6d 706c 6574 6573 2c20 6974 206d 6561 ompletes, it mea │ │ │ -0002b610: 6e73 2077 6520 7761 6e74 2074 6f0a 0909 ns we want to... │ │ │ -0002b620: 2f2f 2066 6f72 6365 2074 6865 2063 6f6e // force the con │ │ │ -0002b630: 6e65 6374 696f 6e20 746f 2062 6520 626f nection to be bo │ │ │ -0002b640: 756e 6420 746f 2074 6865 2073 7065 6369 und to the speci │ │ │ -0002b650: 6669 6564 2069 6e74 6572 6661 6365 2e0a fied interface.. │ │ │ -0002b660: 0909 2f2f 2069 6620 6974 2065 6e64 7320 ..// if it ends │ │ │ -0002b670: 7570 2062 6569 6e67 2062 6f75 6e64 2074 up being bound t │ │ │ -0002b680: 6f20 6120 6469 6666 6572 656e 7420 6c6f o a different lo │ │ │ -0002b690: 6361 6c20 4950 2c20 7468 6520 636f 6e6e cal IP, the conn │ │ │ -0002b6a0: 6563 7469 6f6e 0a09 092f 2f20 6973 2063 ection...// is c │ │ │ -0002b6b0: 6c6f 7365 642e 0a09 0974 6370 3a3a 656e losed....tcp::en │ │ │ -0002b6c0: 6470 6f69 6e74 206d 5f6c 6f63 616c 3b0a dpoint m_local;. │ │ │ -0002b6d0: 0a09 092f 2f20 7265 6d6f 7465 2070 6565 ...// remote pee │ │ │ -0002b6e0: 7227 7320 6964 0a09 0970 6565 725f 6964 r's id...peer_id │ │ │ -0002b6f0: 206d 5f70 6565 725f 6964 3b0a 0a09 7072 m_peer_id;...pr │ │ │ -0002b700: 6f74 6563 7465 643a 0a0a 0909 7465 6d70 otected:....temp │ │ │ -0002b710: 6c61 7465 2026 6c74 3b74 7970 656e 616d late <typenam │ │ │ -0002b720: 6520 4675 6e2c 2074 7970 656e 616d 652e e Fun, typename. │ │ │ -0002b730: 2e2e 2041 7267 7326 6774 3b0a 0909 766f .. Args>...vo │ │ │ -0002b740: 6964 2077 7261 7028 4675 6e20 662c 2041 id wrap(Fun f, A │ │ │ -0002b750: 7267 7326 616d 703b 2661 6d70 3b2e 2e2e rgs&&... │ │ │ -0002b760: 2061 293b 0a0a 0909 2f2f 2073 7461 7469 a);....// stati │ │ │ -0002b770: 7374 6963 7320 6162 6f75 7420 7570 6c6f stics about uplo │ │ │ -0002b780: 6164 2061 6e64 2064 6f77 6e6c 6f61 6420 ad and download │ │ │ -0002b790: 7370 6565 6473 0a09 092f 2f20 616e 6420 speeds...// and │ │ │ -0002b7a0: 746f 7461 6c20 616d 6f75 6e74 206f 6620 total amount of │ │ │ -0002b7b0: 7570 6c6f 6164 7320 616e 6420 646f 776e uploads and down │ │ │ -0002b7c0: 6c6f 6164 7320 666f 720a 0909 2f2f 2074 loads for...// t │ │ │ -0002b7d0: 6869 7320 7065 6572 0a3c 2f70 7265 3e3c his peer.
    < │ │ │ -0002b7e0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0002b810: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ -0002b820: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../include/li │ │ │ -0002b850: 6274 6f72 7265 6e74 2f61 7578 5f2f 7065 btorrent/aux_/pe │ │ │ -0002b860: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6870 er_connection.hp │ │ │ -0002b870: 703a 3130 3630 3c2f 613e 3c2f 7464 3e3c p:1060< │ │ │ -0002b880: 7464 3e72 656e 616d 6520 7468 6973 2074 td>rename this t │ │ │ -0002b890: 6172 6765 7420 7175 6575 6520 7369 7a65 arget queue size │ │ │ -0002b8a0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ren │ │ │ -0002b8f0: 616d 6520 7468 6973 2074 6172 6765 7420 ame this target │ │ │ -0002b900: 7175 6575 6520 7369 7a65 3c2f 6832 3e3c queue size

    < │ │ │ -0002b910: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -0002b920: 6274 6f72 7265 6e74 2f61 7578 5f2f 7065 btorrent/aux_/pe │ │ │ -0002b930: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6870 er_connection.hp │ │ │ -0002b940: 703a 3130 3630 3c2f 6834 3e3c 7072 6520 p:1060

    ..// this i
    │ │ │ -0002b990: 7320 7468 6520 7069 6563 6520 7468 6174  s the piece that
    │ │ │ -0002b9a0: 2069 7320 6176 6169 6c61 626c 6520 746f   is available to
    │ │ │ -0002b9b0: 2074 6869 7320 7065 6572 2e20 4f6e 6c79   this peer. Only
    │ │ │ -0002b9c0: 0a09 092f 2f20 7468 6573 6520 7477 6f20  ...// these two 
    │ │ │ -0002b9d0: 7069 6563 6573 2063 616e 2062 6520 646f  pieces can be do
    │ │ │ -0002b9e0: 776e 6c6f 6164 6564 2066 726f 6d20 7573  wnloaded from us
    │ │ │ -0002b9f0: 2062 7920 7468 6973 2070 6565 722e 0a09   by this peer...
    │ │ │ -0002ba00: 092f 2f20 5468 6973 2077 696c 6c20 7265  .// This will re
    │ │ │ -0002ba10: 6d61 696e 2074 6865 2063 7572 7265 6e74  main the current
    │ │ │ -0002ba20: 2070 6965 6365 2066 6f72 2074 6869 7320   piece for this 
    │ │ │ -0002ba30: 7065 6572 2075 6e74 696c 0a09 092f 2f20  peer until...// 
    │ │ │ -0002ba40: 616e 6f74 6865 7220 7065 6572 2073 656e  another peer sen
    │ │ │ -0002ba50: 6473 2075 7320 6120 6861 7665 206d 6573  ds us a have mes
    │ │ │ -0002ba60: 7361 6765 2066 6f72 2074 6869 7320 7069  sage for this pi
    │ │ │ -0002ba70: 6563 650a 0909 7374 643a 3a61 7272 6179  ece...std::array
    │ │ │ -0002ba80: 266c 743b 7069 6563 655f 696e 6465 785f  <piece_index_
    │ │ │ -0002ba90: 742c 2032 2667 743b 206d 5f73 7570 6572  t, 2> m_super
    │ │ │ -0002baa0: 7365 6564 5f70 6965 6365 203d 207b 7b70  seed_piece = {{p
    │ │ │ -0002bab0: 6965 6365 5f69 6e64 6578 5f74 282d 3129  iece_index_t(-1)
    │ │ │ -0002bac0: 2c20 7069 6563 655f 696e 6465 785f 7428  , piece_index_t(
    │ │ │ -0002bad0: 2d31 297d 7d3b 0a23 656e 6469 660a 0a09  -1)}};.#endif...
    │ │ │ -0002bae0: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -0002baf0: 6620 6279 7465 7320 7365 6e64 2074 6f20  f bytes send to 
    │ │ │ -0002bb00: 7468 6520 6469 736b 2d69 6f0a 0909 2f2f  the disk-io...//
    │ │ │ -0002bb10: 2074 6872 6561 6420 7468 6174 2068 6173   thread that has
    │ │ │ -0002bb20: 6e27 7420 7965 7420 6265 656e 2063 6f6d  n't yet been com
    │ │ │ -0002bb30: 706c 6574 656c 7920 7772 6974 7465 6e2e  pletely written.
    │ │ │ -0002bb40: 0a09 0969 6e74 206d 5f6f 7574 7374 616e  ...int m_outstan
    │ │ │ -0002bb50: 6469 6e67 5f77 7269 7469 6e67 5f62 7974  ding_writing_byt
    │ │ │ -0002bb60: 6573 203d 2030 3b0a 0a09 092f 2f20 6d61  es = 0;....// ma
    │ │ │ -0002bb70: 7820 7472 616e 7366 6572 2072 6174 6573  x transfer rates
    │ │ │ -0002bb80: 2073 6565 6e20 6f6e 2074 6869 7320 7065   seen on this pe
    │ │ │ -0002bb90: 6572 0a09 0969 6e74 206d 5f64 6f77 6e6c  er...int m_downl
    │ │ │ -0002bba0: 6f61 645f 7261 7465 5f70 6561 6b20 3d20  oad_rate_peak = 
    │ │ │ -0002bbb0: 303b 0a09 0969 6e74 206d 5f75 706c 6f61  0;...int m_uploa
    │ │ │ -0002bbc0: 645f 7261 7465 5f70 6561 6b20 3d20 303b  d_rate_peak = 0;
    │ │ │ -0002bbd0: 0a0a 0909 2f2f 2073 746f 7020 7365 6e64  ....// stop send
    │ │ │ -0002bbe0: 696e 6720 6461 7461 2061 6674 6572 2074  ing data after t
    │ │ │ -0002bbf0: 6869 7320 6d61 6e79 2062 7974 6573 2c20  his many bytes, 
    │ │ │ -0002bc00: 494e 545f 4d41 5820 3d20 696e 660a 0909  INT_MAX = inf...
    │ │ │ -0002bc10: 696e 7420 6d5f 7365 6e64 5f62 6172 7269  int m_send_barri
    │ │ │ -0002bc20: 6572 203d 2049 4e54 5f4d 4158 3b0a 0a09  er = INT_MAX;...
    │ │ │ -0002bc30: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -0002bc40: 6620 7265 7175 6573 7420 7765 2073 686f  f request we sho
    │ │ │ -0002bc50: 756c 6420 7175 6575 6520 7570 0a09 092f  uld queue up.../
    │ │ │ -0002bc60: 2f20 6174 2074 6865 2072 656d 6f74 6520  / at the remote 
    │ │ │ -0002bc70: 656e 642e 0a3c 6469 7620 7374 796c 653d  end..
    ..std::uint16 │ │ │ -0002bcb0: 5f74 206d 5f64 6573 6972 6564 5f71 7565 _t m_desired_que │ │ │ -0002bcc0: 7565 5f73 697a 6520 3d20 343b 0a3c 2f64 ue_size = 4;....// if set │ │ │ -0002bce0: 746f 206e 6f6e 2d7a 6572 6f2c 2074 6869 to non-zero, thi │ │ │ -0002bcf0: 7320 7065 6572 2077 696c 6c20 616c 7761 s peer will alwa │ │ │ -0002bd00: 7973 2070 7265 6665 720a 0909 2f2f 2074 ys prefer...// t │ │ │ -0002bd10: 6f20 7265 7175 6573 7420 656e 7469 7265 o request entire │ │ │ -0002bd20: 206e 2070 6965 6365 732c 2072 6174 6865 n pieces, rathe │ │ │ -0002bd30: 7220 7468 616e 2062 6c6f 636b 732e 0a09 r than blocks... │ │ │ -0002bd40: 092f 2f20 7768 6572 6520 6e20 6973 2074 .// where n is t │ │ │ -0002bd50: 6865 2076 616c 7565 206f 6620 7468 6973 he value of this │ │ │ -0002bd60: 2076 6172 6961 626c 652e 0a09 092f 2f20 variable....// │ │ │ -0002bd70: 6966 2069 7420 6973 2030 2c20 7468 6520 if it is 0, the │ │ │ -0002bd80: 646f 776e 6c6f 6164 2072 6174 6520 6c69 download rate li │ │ │ -0002bd90: 6d69 7420 7365 7474 696e 670a 0909 2f2f mit setting...// │ │ │ -0002bda0: 2077 696c 6c20 6265 2075 7365 6420 746f will be used to │ │ │ -0002bdb0: 2064 6574 6572 6d69 6e65 2069 6620 7768 determine if wh │ │ │ -0002bdc0: 6f6c 6520 7069 6563 6573 0a09 092f 2f20 ole pieces...// │ │ │ -0002bdd0: 6172 6520 7072 6566 6572 7265 642e 0a09 are preferred... │ │ │ -0002bde0: 0973 7464 3a3a 7569 6e74 3136 5f74 206d .std::uint16_t m │ │ │ -0002bdf0: 5f70 7265 6665 725f 636f 6e74 6967 756f _prefer_contiguo │ │ │ -0002be00: 7573 5f62 6c6f 636b 7320 3d20 303b 0a0a us_blocks = 0;.. │ │ │ -0002be10: 0909 2f2f 2074 6869 7320 6973 2074 6865 ..// this is the │ │ │ -0002be20: 206e 756d 6265 7220 6f66 2074 696d 6573 number of times │ │ │ -0002be30: 2074 6869 7320 7065 6572 2068 6173 2068 this peer has h │ │ │ -0002be40: 6164 0a09 092f 2f20 6120 7265 7175 6573 ad...// a reques │ │ │ -0002be50: 7420 7265 6a65 6374 6564 2062 6563 6175 t rejected becau │ │ │ -0002be60: 7365 206f 6620 6120 6469 736b 2049 2f4f se of a disk I/O │ │ │ -0002be70: 2066 6169 6c75 7265 2e0a 0909 2f2f 206f failure....// o │ │ │ -0002be80: 6e63 6520 7468 6973 2072 6561 6368 6573 nce this reaches │ │ │ -0002be90: 2061 2063 6572 7461 696e 2074 6872 6573 a certain thres │ │ │ -0002bea0: 686f 6c64 2c20 7468 650a 0909 2f2f 2070 hold, the...// p │ │ │ -0002beb0: 6565 7220 6973 2064 6973 636f 6e6e 6563 eer is disconnec │ │ │ -0002bec0: 7465 6420 696e 206f 7264 6572 2074 6f20 ted in order to │ │ │ -0002bed0: 6176 6f69 6420 696e 6669 6e69 7465 0a09 avoid infinite.. │ │ │ -0002bee0: 092f 2f20 6c6f 6f70 7320 6f66 2063 6f6e .// loops of con │ │ │ -0002bef0: 7369 7374 656e 7420 6661 696c 7572 6573 sistent failures │ │ │ -0002bf00: 0a09 0973 7464 3a3a 7569 6e74 385f 7420 ...std::uint8_t │ │ │ -0002bf10: 6d5f 6469 736b 5f72 6561 645f 6661 696c m_disk_read_fail │ │ │ -0002bf20: 7572 6573 203d 2030 3b0a 0a09 092f 2f20 ures = 0;....// │ │ │ -0002bf30: 7468 6973 2069 7320 7573 6564 2069 6e20 this is used in │ │ │ -0002bf40: 7365 6564 206d 6f64 6520 7768 656e 6576 seed mode whenev │ │ │ -0002bf50: 6572 2077 6520 7472 6967 6765 7220 6120 er we trigger a │ │ │ -0002bf60: 6861 7368 2063 6865 636b 0a09 092f 2f20 hash check...// │ │ │ -0002bf70: 666f 7220 6120 7069 6563 652c 2062 6566 for a piece, bef │ │ │ -0002bf80: 6f72 6520 7765 2072 6561 6420 6974 2e20 ore we read it. │ │ │ -0002bf90: 4974 2773 2075 7365 6420 746f 2074 6872 It's used to thr │ │ │ -0002bfa0: 6f74 746c 650a 0909 2f2f 2074 6865 2068 ottle...// the h │ │ │ -0002bfb0: 6173 6820 6368 6563 6b73 2074 6f20 6a75 ash checks to ju │ │ │ -0002bfc0: 7374 2061 2066 6577 2070 6572 2070 6565 st a few per pee │ │ │ -0002bfd0: 7220 6174 2061 2074 696d 652e 0a09 0973 r at a time....s │ │ │ -0002bfe0: 7464 3a3a 7569 6e74 385f 7420 6d5f 6f75 td::uint8_t m_ou │ │ │ -0002bff0: 7473 7461 6e64 696e 675f 7069 6563 655f tstanding_piece_ │ │ │ -0002c000: 7665 7269 6669 6361 7469 6f6e 3a33 3b0a verification:3;. │ │ │ -0002c010: 0a09 092f 2f20 6973 2074 7275 6520 6966 ...// is true if │ │ │ -0002c020: 2069 7420 7761 7320 7765 2074 6861 7420 it was we that │ │ │ -0002c030: 636f 6e6e 6563 7465 6420 746f 2074 6865 connected to the │ │ │ -0002c040: 2070 6565 720a 0909 2f2f 2061 6e64 2066 peer...// and f │ │ │ -0002c050: 616c 7365 2069 6620 7765 2067 6f74 2061 alse if we got a │ │ │ -0002c060: 6e20 696e 636f 6d69 6e67 2063 6f6e 6e65 n incoming conne │ │ │ -0002c070: 6374 696f 6e0a 0909 2f2f 2063 6f75 6c64 ction...// could │ │ │ -0002c080: 2062 6520 636f 6e73 6964 6572 6564 3a20 be considered: │ │ │ -0002c090: 7472 7565 203d 206c 6f63 616c 2c20 6661 true = local, fa │ │ │ -0002c0a0: 6c73 6520 3d20 7265 6d6f 7465 0a09 0962 lse = remote...b │ │ │ -0002c0b0: 6f6f 6c20 6d5f 6f75 7467 6f69 6e67 3a31 ool m_outgoing:1 │ │ │ -0002c0c0: 3b0a 0a09 092f 2f20 6973 2074 7275 6520 ;....// is true │ │ │ -0002c0d0: 6966 2077 6520 6c65 6172 6e20 7468 6520 if we learn the │ │ │ -0002c0e0: 696e 636f 6d69 6e67 2063 6f6e 6e65 6374 incoming connect │ │ │ -0002c0f0: 696f 6e73 206c 6973 7465 6e69 6e67 0a09 ions listening.. │ │ │ -0002c100: 092f 2f20 6475 7269 6e67 2074 6865 2065 .// during the e │ │ │ -0002c110: 7874 656e 6465 6420 6861 6e64 7368 616b xtended handshak │ │ │ -0002c120: 650a 0909 626f 6f6c 206d 5f72 6563 6569 e...bool m_recei │ │ │ -0002c130: 7665 645f 6c69 7374 656e 5f70 6f72 743a ved_listen_port: │ │ │ -0002c140: 313b 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 1;..
    < │ │ │ +00027dd0: 6962 746f 7272 656e 742f 6175 785f 2f70 ibtorrent/aux_/p │ │ │ +00027de0: 726f 7879 5f62 6173 652e 6870 703a 3330 roxy_base.hpp:30 │ │ │ +00027df0: 353c 2f61 3e3c 2f74 643e 3c74 643e 7573 5us │ │ │ +00027e00: 6520 7468 6520 7265 736f 6c76 6572 2069 e the resolver i │ │ │ +00027e10: 6e74 6572 6661 6365 2074 6861 7420 6861 nterface that ha │ │ │ +00027e20: 7320 6120 6275 696c 742d 696e 2063 6163 s a built-in cac │ │ │ +00027e30: 6865 3c2f 7464 3e3c 2f74 723e 3c74 7220 he

    u │ │ │ +00027e80: 7365 2074 6865 2072 6573 6f6c 7665 7220 se the resolver │ │ │ +00027e90: 696e 7465 7266 6163 6520 7468 6174 2068 interface that h │ │ │ +00027ea0: 6173 2061 2062 7569 6c74 2d69 6e20 6361 as a built-in ca │ │ │ +00027eb0: 6368 653c 2f68 323e 3c68 343e 2e2e 2f69 che

    ../i │ │ │ +00027ec0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ +00027ed0: 742f 6175 785f 2f70 726f 7879 5f62 6173 t/aux_/proxy_bas │ │ │ +00027ee0: 652e 6870 703a 3330 353c 2f68 343e 3c70 e.hpp:305

    .// The │ │ │ +00027f30: 6861 6e64 6c65 7220 6d75 7374 2062 6520 handler must be │ │ │ +00027f40: 7461 6b65 6e20 6173 206c 7661 6c75 6520 taken as lvalue │ │ │ +00027f50: 7265 6665 7265 6e63 6520 6865 7265 2073 reference here s │ │ │ +00027f60: 696e 6365 2077 6520 6d61 7920 6e6f 7420 ince we may not │ │ │ +00027f70: 6361 6c6c 0a09 2f2f 2069 742e 2042 7574 call..// it. But │ │ │ +00027f80: 2069 6620 7765 2064 6f2c 2077 6520 7761 if we do, we wa │ │ │ +00027f90: 6e74 2074 6865 2063 616c 6c20 6f70 6572 nt the call oper │ │ │ +00027fa0: 6174 6f72 2074 6f20 6f77 6e20 7468 6520 ator to own the │ │ │ +00027fb0: 6675 6e63 7469 6f6e 206f 626a 6563 742e function object. │ │ │ +00027fc0: 0a09 7465 6d70 6c61 7465 2026 6c74 3b74 ..template <t │ │ │ +00027fd0: 7970 656e 616d 6520 4861 6e64 6c65 7226 ypename Handler& │ │ │ +00027fe0: 6774 3b0a 0962 6f6f 6c20 6861 6e64 6c65 gt;..bool handle │ │ │ +00027ff0: 5f65 7272 6f72 2865 7272 6f72 5f63 6f64 _error(error_cod │ │ │ +00028000: 6520 652c 2048 616e 646c 6572 2661 6d70 e e, Handler& │ │ │ +00028010: 3b26 616d 703b 2068 290a 097b 0a09 0954 ;& h)..{...T │ │ │ +00028020: 4f52 5245 4e54 5f41 5353 4552 5428 6d5f ORRENT_ASSERT(m_ │ │ │ +00028030: 6d61 6769 6320 3d3d 2030 7831 3333 3729 magic == 0x1337) │ │ │ +00028040: 3b0a 0909 6966 2028 2165 2920 7265 7475 ;...if (!e) retu │ │ │ +00028050: 726e 2066 616c 7365 3b0a 0909 6572 726f rn false;...erro │ │ │ +00028060: 725f 636f 6465 2065 633b 0a09 092f 2f20 r_code ec;...// │ │ │ +00028070: 7072 6576 656e 7420 6c69 6665 7469 6d65 prevent lifetime │ │ │ +00028080: 206d 616e 6167 656d 656e 7420 7573 652d management use- │ │ │ +00028090: 6166 7465 722d 6672 6565 0a09 0963 6c6f after-free...clo │ │ │ +000280a0: 7365 2865 6329 3b20 2f2f 2063 6c6f 7365 se(ec); // close │ │ │ +000280b0: 2066 6972 7374 0a09 0973 7464 3a3a 6d6f first...std::mo │ │ │ +000280c0: 7665 2868 2928 6529 3b20 2f2f 2063 6f6e ve(h)(e); // con │ │ │ +000280d0: 7375 6d65 0a09 0972 6574 7572 6e20 7472 sume...return tr │ │ │ +000280e0: 7565 3b0a 097d 0a0a 0961 7578 3a3a 6e6f ue;..}...aux::no │ │ │ +000280f0: 6578 6365 7074 5f6d 6f76 6162 6c65 266c except_movable&l │ │ │ +00028100: 743b 7463 703a 3a73 6f63 6b65 7426 6774 t;tcp::socket> │ │ │ +00028110: 3b20 6d5f 736f 636b 3b0a 0973 7464 3a3a ; m_sock;..std:: │ │ │ +00028120: 7374 7269 6e67 206d 5f68 6f73 746e 616d string m_hostnam │ │ │ +00028130: 653b 202f 2f20 7072 6f78 7920 686f 7374 e; // proxy host │ │ │ +00028140: 0a09 696e 7420 6d5f 706f 7274 203d 2030 ..int m_port = 0 │ │ │ +00028150: 3b20 2020 2020 2020 2020 2f2f 2070 726f ; // pro │ │ │ +00028160: 7879 2070 6f72 740a 0a09 6175 783a 3a6e xy port...aux::n │ │ │ +00028170: 6f65 7863 6570 745f 6d6f 7661 626c 6526 oexcept_movable& │ │ │ +00028180: 6c74 3b65 6e64 706f 696e 745f 7479 7065 lt;endpoint_type │ │ │ +00028190: 2667 743b 206d 5f72 656d 6f74 655f 656e > m_remote_en │ │ │ +000281a0: 6470 6f69 6e74 3b0a 0a3c 6469 7620 7374 dpoint;..

    .aux::noe │ │ │ +000281e0: 7863 6570 745f 6d6f 7665 5f6f 6e6c 7926 xcept_move_only& │ │ │ +000281f0: 6c74 3b74 6370 3a3a 7265 736f 6c76 6572 lt;tcp::resolver │ │ │ +00028200: 2667 743b 206d 5f72 6573 6f6c 7665 723b > m_resolver; │ │ │ +00028210: 0a3c 2f64 6976 3e0a 2369 6620 544f 5252 .
    .#if TORR │ │ │ +00028220: 454e 545f 5553 455f 4153 5345 5254 530a ENT_USE_ASSERTS. │ │ │ +00028230: 0969 6e74 206d 5f6d 6167 6963 203d 2030 .int m_magic = 0 │ │ │ +00028240: 7831 3333 373b 0a23 656e 6469 660a 7d3b x1337;.#endif.}; │ │ │ +00028250: 0a0a 7465 6d70 6c61 7465 2026 6c74 3b74 ..template <t │ │ │ +00028260: 7970 656e 616d 6520 4861 6e64 6c65 722c ypename Handler, │ │ │ +00028270: 2074 7970 656e 616d 6520 556e 6465 726c typename Underl │ │ │ +00028280: 7969 6e67 4861 6e64 6c65 7226 6774 3b0a yingHandler>. │ │ │ +00028290: 7374 7275 6374 2077 7261 705f 616c 6c6f struct wrap_allo │ │ │ +000282a0: 6361 746f 725f 740a 7b0a 0977 7261 705f cator_t.{..wrap_ │ │ │ +000282b0: 616c 6c6f 6361 746f 725f 7428 4861 6e64 allocator_t(Hand │ │ │ +000282c0: 6c65 7220 682c 2055 6e64 6572 6c79 696e ler h, Underlyin │ │ │ +000282d0: 6748 616e 646c 6572 2075 6829 0a09 093a gHandler uh)...: │ │ │ +000282e0: 206d 5f68 616e 646c 6572 2873 7464 3a3a m_handler(std:: │ │ │ +000282f0: 6d6f 7665 2868 2929 0a09 092c 206d 5f75 move(h))..., m_u │ │ │ +00028300: 6e64 6572 6c79 696e 675f 6861 6e64 6c65 nderlying_handle │ │ │ +00028310: 7228 7374 643a 3a6d 6f76 6528 7568 2929 r(std::move(uh)) │ │ │ +00028320: 0a09 7b7d 0a0a 0977 7261 705f 616c 6c6f ..{}...wrap_allo │ │ │ +00028330: 6361 746f 725f 7428 7772 6170 5f61 6c6c cator_t(wrap_all │ │ │ +00028340: 6f63 6174 6f72 5f74 2063 6f6e 7374 2661 ocator_t const&a │ │ │ +00028350: 6d70 3b29 203d 2064 6566 6175 6c74 3b0a mp;) = default;. │ │ │ +00028360: 0977 7261 705f 616c 6c6f 6361 746f 725f .wrap_allocator_ │ │ │ +00028370: 7428 7772 6170 5f61 6c6c 6f63 6174 6f72 t(wrap_allocator │ │ │ +00028380: 5f74 2661 6d70 3b26 616d 703b 2920 3d20 _t&&) = │ │ │ +00028390: 6465 6661 756c 743b 0a0a 0974 656d 706c default;...templ │ │ │ +000283a0: 6174 6520 266c 743b 636c 6173 732e 2e2e ate <class... │ │ │ +000283b0: 2041 2667 743b 0a09 766f 6964 206f 7065 A>..void ope │ │ │ +000283c0: 7261 746f 7228 2928 4126 616d 703b 2661 rator()(A&&a │ │ │ +000283d0: 6d70 3b2e 2e2e 2061 290a 097b 0a09 096d mp;... a)..{...m │ │ │ +000283e0: 5f68 616e 646c 6572 2873 7464 3a3a 666f _handler(std::fo │ │ │ +000283f0: 7277 6172 6426 6c74 3b41 2667 743b 2861 rward<A>(a │ │ │ +00028400: 292e 2e2e 2c20 7374 643a 3a6d 6f76 6528 )..., std::move( │ │ │ +00028410: 6d5f 756e 6465 726c 7969 6e67 5f68 616e m_underlying_han │ │ │ +00028420: 646c 6572 2929 3b0a 097d 0a0a 0975 7369 dler));..}...usi │ │ │ +00028430: 6e67 2061 6c6c 6f63 6174 6f72 5f74 7970 ng allocator_typ │ │ │ +00028440: 6520 3d20 7479 7065 6e61 6d65 2062 6f6f e = typename boo │ │ │ +00028450: 7374 3a3a 6173 696f 3a3a 6173 736f 6369 st::asio::associ │ │ │ +00028460: 6174 6564 5f61 6c6c 6f63 6174 6f72 266c ated_allocator&l │ │ │ +00028470: 743b 556e 6465 726c 7969 6e67 4861 6e64 t;UnderlyingHand │ │ │ +00028480: 6c65 7226 6774 3b3a 3a74 7970 653b 0a09 ler>::type;.. │ │ │ +00028490: 7573 696e 6720 6578 6563 7574 6f72 5f74 using executor_t │ │ │ +000284a0: 7970 6520 3d20 7479 7065 6e61 6d65 2062 ype = typename b │ │ │ +000284b0: 6f6f 7374 3a3a 6173 696f 3a3a 6173 736f oost::asio::asso │ │ │ +000284c0: 6369 6174 6564 5f65 7865 6375 746f 7226 ciated_executor& │ │ │ +000284d0: 6c74 3b55 6e64 6572 6c79 696e 6748 616e lt;UnderlyingHan │ │ │ +000284e0: 646c 6572 2667 743b 3a3a 7479 7065 3b0a dler>::type;. │ │ │ +000284f0: 0a09 616c 6c6f 6361 746f 725f 7479 7065 ..allocator_type │ │ │ +00028500: 2067 6574 5f61 6c6c 6f63 6174 6f72 2829 get_allocator() │ │ │ +00028510: 2063 6f6e 7374 206e 6f65 7863 6570 740a const noexcept. │ │ │ +00028520: 097b 2072 6574 7572 6e20 626f 6f73 743a .{ return boost: │ │ │ +00028530: 3a61 7369 6f3a 3a67 6574 5f61 7373 6f63 :asio::get_assoc │ │ │ +00028540: 6961 7465 645f 616c 6c6f 6361 746f 7228 iated_allocator( │ │ │ +00028550: 6d5f 756e 6465 726c 7969 6e67 5f68 616e m_underlying_han │ │ │ +00028560: 646c 6572 293b 207d 0a0a 0965 7865 6375 dler); }...execu │ │ │ +00028570: 746f 725f 7479 7065 2067 6574 5f65 7865 tor_type get_exe │ │ │ +00028580: 6375 746f 7228 2920 636f 6e73 7420 6e6f cutor() const no │ │ │ +00028590: 6578 6365 7074 0a3c 2f70 7265 3e3c 2f74 except.
    relevanc │ │ │ +000285d0: 6526 6e62 7370 3b32 3c2f 7464 3e3c 7464 e 2../include/libt │ │ │ +00028610: 6f72 7265 6e74 2f61 7578 5f2f 7065 6572 orrent/aux_/peer │ │ │ +00028620: 5f63 6f6e 6e65 6374 696f 6e2e 6870 703a _connection.hpp: │ │ │ +00028630: 3937 303c 2f61 3e3c 2f74 643e 3c74 643e 970 │ │ │ +00028640: 7468 6973 2073 686f 756c 6420 7265 616c this should real │ │ │ +00028650: 6c79 2062 6520 6120 6369 7263 756c 6172 ly be a circular │ │ │ +00028660: 2062 7566 6665 723c 2f74 643e 3c2f 7472 buffer │ │ │ +000286a0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +000286b0: 3c68 323e 7468 6973 2073 686f 756c 6420

    this should │ │ │ +000286c0: 7265 616c 6c79 2062 6520 6120 6369 7263 really be a circ │ │ │ +000286d0: 756c 6172 2062 7566 6665 723c 2f68 323e ular buffer

    │ │ │ +000286e0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ +000286f0: 6962 746f 7272 656e 742f 6175 785f 2f70 ibtorrent/aux_/p │ │ │ +00028700: 6565 725f 636f 6e6e 6563 7469 6f6e 2e68 eer_connection.h │ │ │ +00028710: 7070 3a39 3730 3c2f 6834 3e3c 7072 6520 pp:970

    ..// it jus
    │ │ │ +00028760: 7420 7365 7276 6573 2061 7320 6120 7175  t serves as a qu
    │ │ │ +00028770: 6575 6520 746f 2072 656d 656d 6265 7220  eue to remember 
    │ │ │ +00028780: 7768 6174 2077 6527 7665 2073 656e 742c  what we've sent,
    │ │ │ +00028790: 2074 6f20 6176 6f69 640a 0909 2f2f 2072   to avoid...// r
    │ │ │ +000287a0: 652d 7365 6e64 696e 6720 7375 6767 6573  e-sending sugges
    │ │ │ +000287b0: 7473 2066 6f72 2074 6865 2073 616d 6520  ts for the same 
    │ │ │ +000287c0: 7069 6563 650a 0909 2f2f 2069 2e65 2e20  piece...// i.e. 
    │ │ │ +000287d0: 6f75 7467 6f69 6e67 2073 7567 6765 7374  outgoing suggest
    │ │ │ +000287e0: 2070 6965 6365 730a 0909 6175 783a 3a76   pieces...aux::v
    │ │ │ +000287f0: 6563 746f 7226 6c74 3b70 6965 6365 5f69  ector<piece_i
    │ │ │ +00028800: 6e64 6578 5f74 2667 743b 206d 5f73 7567  ndex_t> m_sug
    │ │ │ +00028810: 6765 7374 5f70 6965 6365 733b 0a0a 0909  gest_pieces;....
    │ │ │ +00028820: 2f2f 2074 6865 2070 6965 6365 7320 7765  // the pieces we
    │ │ │ +00028830: 2077 696c 6c20 7365 6e64 2074 6f20 7468   will send to th
    │ │ │ +00028840: 6520 7065 6572 0a09 092f 2f20 6966 2072  e peer...// if r
    │ │ │ +00028850: 6571 7565 7374 6564 2028 7265 6761 7264  equested (regard
    │ │ │ +00028860: 6c65 7373 206f 6620 6368 6f6b 6520 7374  less of choke st
    │ │ │ +00028870: 6174 6529 0a09 0973 7464 3a3a 7665 6374  ate)...std::vect
    │ │ │ +00028880: 6f72 266c 743b 7069 6563 655f 696e 6465  or<piece_inde
    │ │ │ +00028890: 785f 7426 6774 3b20 6d5f 6163 6365 7074  x_t> m_accept
    │ │ │ +000288a0: 5f66 6173 743b 0a0a 0909 2f2f 2061 2073  _fast;....// a s
    │ │ │ +000288b0: 656e 742d 7069 6563 6520 636f 756e 7465  ent-piece counte
    │ │ │ +000288c0: 7220 666f 7220 7468 6520 616c 6c6f 7765  r for the allowe
    │ │ │ +000288d0: 6420 6661 7374 2073 6574 0a09 092f 2f20  d fast set...// 
    │ │ │ +000288e0: 746f 2061 766f 6964 2065 7870 6c6f 6974  to avoid exploit
    │ │ │ +000288f0: 6174 696f 6e2e 2045 6163 6820 736c 6f74  ation. Each slot
    │ │ │ +00028900: 2069 7320 6120 636f 756e 7465 720a 0909   is a counter...
    │ │ │ +00028910: 2f2f 2066 6f72 206f 6e65 206f 6620 7468  // for one of th
    │ │ │ +00028920: 6520 7069 6563 6573 2066 726f 6d20 7468  e pieces from th
    │ │ │ +00028930: 6520 616c 6c6f 7765 642d 6661 7374 2073  e allowed-fast s
    │ │ │ +00028940: 6574 0a09 0961 7578 3a3a 7665 6374 6f72  et...aux::vector
    │ │ │ +00028950: 266c 743b 7374 643a 3a75 696e 7431 365f  <std::uint16_
    │ │ │ +00028960: 7426 6774 3b20 6d5f 6163 6365 7074 5f66  t> m_accept_f
    │ │ │ +00028970: 6173 745f 7069 6563 655f 636e 743b 0a0a  ast_piece_cnt;..
    │ │ │ +00028980: 0909 2f2f 2074 6865 2070 6965 6365 7320  ..// the pieces 
    │ │ │ +00028990: 7468 6520 7065 6572 2077 696c 6c20 7365  the peer will se
    │ │ │ +000289a0: 6e64 2075 7320 6966 0a09 092f 2f20 7265  nd us if...// re
    │ │ │ +000289b0: 7175 6573 7465 6420 2872 6567 6172 646c  quested (regardl
    │ │ │ +000289c0: 6573 7320 6f66 2063 686f 6b65 2073 7461  ess of choke sta
    │ │ │ +000289d0: 7465 290a 0909 7374 643a 3a76 6563 746f  te)...std::vecto
    │ │ │ +000289e0: 7226 6c74 3b70 6965 6365 5f69 6e64 6578  r<piece_index
    │ │ │ +000289f0: 5f74 2667 743b 206d 5f61 6c6c 6f77 6564  _t> m_allowed
    │ │ │ +00028a00: 5f66 6173 743b 0a0a 0909 2f2f 2070 6965  _fast;....// pie
    │ │ │ +00028a10: 6365 7320 7468 6174 2068 6173 2062 6565  ces that has bee
    │ │ │ +00028a20: 6e20 7375 6767 6573 7465 6420 746f 2062  n suggested to b
    │ │ │ +00028a30: 6520 646f 776e 6c6f 6164 6564 2066 726f  e downloaded fro
    │ │ │ +00028a40: 6d20 7468 6973 2070 6565 720a 0909 2f2f  m this peer...//
    │ │ │ +00028a50: 2069 2e65 2e20 696e 636f 6d69 6e67 2073   i.e. incoming s
    │ │ │ +00028a60: 7567 6765 7374 696f 6e73 0a3c 6469 7620  uggestions.
    ..aux:: │ │ │ +00028aa0: 7665 6374 6f72 266c 743b 7069 6563 655f vector<piece_ │ │ │ +00028ab0: 696e 6465 785f 7426 6774 3b20 6d5f 7375 index_t> m_su │ │ │ +00028ac0: 6767 6573 7465 645f 7069 6563 6573 3b0a ggested_pieces;. │ │ │ +00028ad0: 3c2f 6469 763e 0a09 092f 2f20 7468 6520
    ...// the │ │ │ +00028ae0: 7469 6d65 2077 6865 6e20 7468 6973 2070 time when this p │ │ │ +00028af0: 6565 7220 6c61 7374 2073 6177 2061 2063 eer last saw a c │ │ │ +00028b00: 6f6d 706c 6574 6520 636f 7079 0a09 092f omplete copy.../ │ │ │ +00028b10: 2f20 6f66 2074 6869 7320 746f 7272 656e / of this torren │ │ │ +00028b20: 740a 0909 7469 6d65 5f74 206d 5f6c 6173 t...time_t m_las │ │ │ +00028b30: 745f 7365 656e 5f63 6f6d 706c 6574 6520 t_seen_complete │ │ │ +00028b40: 3d20 303b 0a0a 0909 2f2f 2074 6865 2062 = 0;....// the b │ │ │ +00028b50: 6c6f 636b 2077 6527 7265 2063 7572 7265 lock we're curre │ │ │ +00028b60: 6e74 6c79 2072 6563 6569 7669 6e67 2e20 ntly receiving. │ │ │ +00028b70: 4f72 0a09 092f 2f20 282d 312c 202d 3129 Or...// (-1, -1) │ │ │ +00028b80: 2069 6620 7765 2772 6520 6e6f 7420 7265 if we're not re │ │ │ +00028b90: 6365 6976 696e 6720 6f6e 650a 0909 7069 ceiving one...pi │ │ │ +00028ba0: 6563 655f 626c 6f63 6b20 6d5f 7265 6365 ece_block m_rece │ │ │ +00028bb0: 6976 696e 675f 626c 6f63 6b20 3d20 7069 iving_block = pi │ │ │ +00028bc0: 6563 655f 626c 6f63 6b3a 3a69 6e76 616c ece_block::inval │ │ │ +00028bd0: 6964 3b0a 0a09 092f 2f20 7468 6520 6c6f id;....// the lo │ │ │ +00028be0: 6361 6c20 656e 6470 6f69 6e74 2066 6f72 cal endpoint for │ │ │ +00028bf0: 2074 6869 7320 7065 6572 2c20 692e 652e this peer, i.e. │ │ │ +00028c00: 206f 7572 2061 6464 7265 7373 0a09 092f our address.../ │ │ │ +00028c10: 2f20 616e 6420 6f75 7220 706f 7274 2e20 / and our port. │ │ │ +00028c20: 4966 2074 6869 7320 6973 2073 6574 2066 If this is set f │ │ │ +00028c30: 6f72 206f 7574 676f 696e 6720 636f 6e6e or outgoing conn │ │ │ +00028c40: 6563 7469 6f6e 730a 0909 2f2f 2062 6566 ections...// bef │ │ │ +00028c50: 6f72 6520 7468 6520 636f 6e6e 6563 7469 ore the connecti │ │ │ +00028c60: 6f6e 2063 6f6d 706c 6574 6573 2c20 6974 on completes, it │ │ │ +00028c70: 206d 6561 6e73 2077 6520 7761 6e74 2074 means we want t │ │ │ +00028c80: 6f0a 0909 2f2f 2066 6f72 6365 2074 6865 o...// force the │ │ │ +00028c90: 2063 6f6e 6e65 6374 696f 6e20 746f 2062 connection to b │ │ │ +00028ca0: 6520 626f 756e 6420 746f 2074 6865 2073 e bound to the s │ │ │ +00028cb0: 7065 6369 6669 6564 2069 6e74 6572 6661 pecified interfa │ │ │ +00028cc0: 6365 2e0a 0909 2f2f 2069 6620 6974 2065 ce....// if it e │ │ │ +00028cd0: 6e64 7320 7570 2062 6569 6e67 2062 6f75 nds up being bou │ │ │ +00028ce0: 6e64 2074 6f20 6120 6469 6666 6572 656e nd to a differen │ │ │ +00028cf0: 7420 6c6f 6361 6c20 4950 2c20 7468 6520 t local IP, the │ │ │ +00028d00: 636f 6e6e 6563 7469 6f6e 0a09 092f 2f20 connection...// │ │ │ +00028d10: 6973 2063 6c6f 7365 642e 0a09 0974 6370 is closed....tcp │ │ │ +00028d20: 3a3a 656e 6470 6f69 6e74 206d 5f6c 6f63 ::endpoint m_loc │ │ │ +00028d30: 616c 3b0a 0a09 092f 2f20 7265 6d6f 7465 al;....// remote │ │ │ +00028d40: 2070 6565 7227 7320 6964 0a09 0970 6565 peer's id...pee │ │ │ +00028d50: 725f 6964 206d 5f70 6565 725f 6964 3b0a r_id m_peer_id;. │ │ │ +00028d60: 0a09 7072 6f74 6563 7465 643a 0a0a 0909 ..protected:.... │ │ │ +00028d70: 7465 6d70 6c61 7465 2026 6c74 3b74 7970 template <typ │ │ │ +00028d80: 656e 616d 6520 4675 6e2c 2074 7970 656e ename Fun, typen │ │ │ +00028d90: 616d 652e 2e2e 2041 7267 7326 6774 3b0a ame... Args>. │ │ │ +00028da0: 0909 766f 6964 2077 7261 7028 4675 6e20 ..void wrap(Fun │ │ │ +00028db0: 662c 2041 7267 7326 616d 703b 2661 6d70 f, Args&& │ │ │ +00028dc0: 3b2e 2e2e 2061 293b 0a0a 0909 2f2f 2073 ;... a);....// s │ │ │ +00028dd0: 7461 7469 7374 6963 7320 6162 6f75 7420 tatistics about │ │ │ +00028de0: 7570 6c6f 6164 2061 6e64 2064 6f77 6e6c upload and downl │ │ │ +00028df0: 6f61 6420 7370 6565 6473 0a09 092f 2f20 oad speeds...// │ │ │ +00028e00: 616e 6420 746f 7461 6c20 616d 6f75 6e74 and total amount │ │ │ +00028e10: 206f 6620 7570 6c6f 6164 7320 616e 6420 of uploads and │ │ │ +00028e20: 646f 776e 6c6f 6164 7320 666f 720a 0909 downloads for... │ │ │ +00028e30: 2f2f 2074 6869 7320 7065 6572 0a3c 2f70 // this peer.

    re │ │ │ +00028e70: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../includ │ │ │ +00028eb0: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ +00028ec0: 5f2f 7065 6572 5f63 6f6e 6e65 6374 696f _/peer_connectio │ │ │ +00028ed0: 6e2e 6870 703a 3130 3630 3c2f 613e 3c2f n.hpp:1060rename th │ │ │ +00028ef0: 6973 2074 6172 6765 7420 7175 6575 6520 is target queue │ │ │ +00028f00: 7369 7a65 3c2f 7464 3e3c 2f74 723e 3c74 size

    rename this tar │ │ │ +00028f60: 6765 7420 7175 6575 6520 7369 7a65 3c2f get queue size

    ../includ │ │ │ +00028f80: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ +00028f90: 5f2f 7065 6572 5f63 6f6e 6e65 6374 696f _/peer_connectio │ │ │ +00028fa0: 6e2e 6870 703a 3130 3630 3c2f 6834 3e3c n.hpp:1060

    < │ │ │ +00028fb0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00028fc0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00028fd0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00028fe0: 7820 2364 6464 3b22 3e09 092f 2f20 7468 x #ddd;">..// th │ │ │ +00028ff0: 6973 2069 7320 7468 6520 7069 6563 6520 is is the piece │ │ │ +00029000: 7468 6174 2069 7320 6176 6169 6c61 626c that is availabl │ │ │ +00029010: 6520 746f 2074 6869 7320 7065 6572 2e20 e to this peer. │ │ │ +00029020: 4f6e 6c79 0a09 092f 2f20 7468 6573 6520 Only...// these │ │ │ +00029030: 7477 6f20 7069 6563 6573 2063 616e 2062 two pieces can b │ │ │ +00029040: 6520 646f 776e 6c6f 6164 6564 2066 726f e downloaded fro │ │ │ +00029050: 6d20 7573 2062 7920 7468 6973 2070 6565 m us by this pee │ │ │ +00029060: 722e 0a09 092f 2f20 5468 6973 2077 696c r....// This wil │ │ │ +00029070: 6c20 7265 6d61 696e 2074 6865 2063 7572 l remain the cur │ │ │ +00029080: 7265 6e74 2070 6965 6365 2066 6f72 2074 rent piece for t │ │ │ +00029090: 6869 7320 7065 6572 2075 6e74 696c 0a09 his peer until.. │ │ │ +000290a0: 092f 2f20 616e 6f74 6865 7220 7065 6572 .// another peer │ │ │ +000290b0: 2073 656e 6473 2075 7320 6120 6861 7665 sends us a have │ │ │ +000290c0: 206d 6573 7361 6765 2066 6f72 2074 6869 message for thi │ │ │ +000290d0: 7320 7069 6563 650a 0909 7374 643a 3a61 s piece...std::a │ │ │ +000290e0: 7272 6179 266c 743b 7069 6563 655f 696e rray<piece_in │ │ │ +000290f0: 6465 785f 742c 2032 2667 743b 206d 5f73 dex_t, 2> m_s │ │ │ +00029100: 7570 6572 7365 6564 5f70 6965 6365 203d uperseed_piece = │ │ │ +00029110: 207b 7b70 6965 6365 5f69 6e64 6578 5f74 {{piece_index_t │ │ │ +00029120: 282d 3129 2c20 7069 6563 655f 696e 6465 (-1), piece_inde │ │ │ +00029130: 785f 7428 2d31 297d 7d3b 0a23 656e 6469 x_t(-1)}};.#endi │ │ │ +00029140: 660a 0a09 092f 2f20 7468 6520 6e75 6d62 f....// the numb │ │ │ +00029150: 6572 206f 6620 6279 7465 7320 7365 6e64 er of bytes send │ │ │ +00029160: 2074 6f20 7468 6520 6469 736b 2d69 6f0a to the disk-io. │ │ │ +00029170: 0909 2f2f 2074 6872 6561 6420 7468 6174 ..// thread that │ │ │ +00029180: 2068 6173 6e27 7420 7965 7420 6265 656e hasn't yet been │ │ │ +00029190: 2063 6f6d 706c 6574 656c 7920 7772 6974 completely writ │ │ │ +000291a0: 7465 6e2e 0a09 0969 6e74 206d 5f6f 7574 ten....int m_out │ │ │ +000291b0: 7374 616e 6469 6e67 5f77 7269 7469 6e67 standing_writing │ │ │ +000291c0: 5f62 7974 6573 203d 2030 3b0a 0a09 092f _bytes = 0;..../ │ │ │ +000291d0: 2f20 6d61 7820 7472 616e 7366 6572 2072 / max transfer r │ │ │ +000291e0: 6174 6573 2073 6565 6e20 6f6e 2074 6869 ates seen on thi │ │ │ +000291f0: 7320 7065 6572 0a09 0969 6e74 206d 5f64 s peer...int m_d │ │ │ +00029200: 6f77 6e6c 6f61 645f 7261 7465 5f70 6561 ownload_rate_pea │ │ │ +00029210: 6b20 3d20 303b 0a09 0969 6e74 206d 5f75 k = 0;...int m_u │ │ │ +00029220: 706c 6f61 645f 7261 7465 5f70 6561 6b20 pload_rate_peak │ │ │ +00029230: 3d20 303b 0a0a 0909 2f2f 2073 746f 7020 = 0;....// stop │ │ │ +00029240: 7365 6e64 696e 6720 6461 7461 2061 6674 sending data aft │ │ │ +00029250: 6572 2074 6869 7320 6d61 6e79 2062 7974 er this many byt │ │ │ +00029260: 6573 2c20 494e 545f 4d41 5820 3d20 696e es, INT_MAX = in │ │ │ +00029270: 660a 0909 696e 7420 6d5f 7365 6e64 5f62 f...int m_send_b │ │ │ +00029280: 6172 7269 6572 203d 2049 4e54 5f4d 4158 arrier = INT_MAX │ │ │ +00029290: 3b0a 0a09 092f 2f20 7468 6520 6e75 6d62 ;....// the numb │ │ │ +000292a0: 6572 206f 6620 7265 7175 6573 7420 7765 er of request we │ │ │ +000292b0: 2073 686f 756c 6420 7175 6575 6520 7570 should queue up │ │ │ +000292c0: 0a09 092f 2f20 6174 2074 6865 2072 656d ...// at the rem │ │ │ +000292d0: 6f74 6520 656e 642e 0a3c 6469 7620 7374 ote end..
    ..std::ui │ │ │ +00029310: 6e74 3136 5f74 206d 5f64 6573 6972 6564 nt16_t m_desired │ │ │ +00029320: 5f71 7565 7565 5f73 697a 6520 3d20 343b _queue_size = 4; │ │ │ +00029330: 0a3c 2f64 6976 3e0a 0909 2f2f 2069 6620 .
    ...// if │ │ │ +00029340: 7365 7420 746f 206e 6f6e 2d7a 6572 6f2c set to non-zero, │ │ │ +00029350: 2074 6869 7320 7065 6572 2077 696c 6c20 this peer will │ │ │ +00029360: 616c 7761 7973 2070 7265 6665 720a 0909 always prefer... │ │ │ +00029370: 2f2f 2074 6f20 7265 7175 6573 7420 656e // to request en │ │ │ +00029380: 7469 7265 206e 2070 6965 6365 732c 2072 tire n pieces, r │ │ │ +00029390: 6174 6865 7220 7468 616e 2062 6c6f 636b ather than block │ │ │ +000293a0: 732e 0a09 092f 2f20 7768 6572 6520 6e20 s....// where n │ │ │ +000293b0: 6973 2074 6865 2076 616c 7565 206f 6620 is the value of │ │ │ +000293c0: 7468 6973 2076 6172 6961 626c 652e 0a09 this variable... │ │ │ +000293d0: 092f 2f20 6966 2069 7420 6973 2030 2c20 .// if it is 0, │ │ │ +000293e0: 7468 6520 646f 776e 6c6f 6164 2072 6174 the download rat │ │ │ +000293f0: 6520 6c69 6d69 7420 7365 7474 696e 670a e limit setting. │ │ │ +00029400: 0909 2f2f 2077 696c 6c20 6265 2075 7365 ..// will be use │ │ │ +00029410: 6420 746f 2064 6574 6572 6d69 6e65 2069 d to determine i │ │ │ +00029420: 6620 7768 6f6c 6520 7069 6563 6573 0a09 f whole pieces.. │ │ │ +00029430: 092f 2f20 6172 6520 7072 6566 6572 7265 .// are preferre │ │ │ +00029440: 642e 0a09 0973 7464 3a3a 7569 6e74 3136 d....std::uint16 │ │ │ +00029450: 5f74 206d 5f70 7265 6665 725f 636f 6e74 _t m_prefer_cont │ │ │ +00029460: 6967 756f 7573 5f62 6c6f 636b 7320 3d20 iguous_blocks = │ │ │ +00029470: 303b 0a0a 0909 2f2f 2074 6869 7320 6973 0;....// this is │ │ │ +00029480: 2074 6865 206e 756d 6265 7220 6f66 2074 the number of t │ │ │ +00029490: 696d 6573 2074 6869 7320 7065 6572 2068 imes this peer h │ │ │ +000294a0: 6173 2068 6164 0a09 092f 2f20 6120 7265 as had...// a re │ │ │ +000294b0: 7175 6573 7420 7265 6a65 6374 6564 2062 quest rejected b │ │ │ +000294c0: 6563 6175 7365 206f 6620 6120 6469 736b ecause of a disk │ │ │ +000294d0: 2049 2f4f 2066 6169 6c75 7265 2e0a 0909 I/O failure.... │ │ │ +000294e0: 2f2f 206f 6e63 6520 7468 6973 2072 6561 // once this rea │ │ │ +000294f0: 6368 6573 2061 2063 6572 7461 696e 2074 ches a certain t │ │ │ +00029500: 6872 6573 686f 6c64 2c20 7468 650a 0909 hreshold, the... │ │ │ +00029510: 2f2f 2070 6565 7220 6973 2064 6973 636f // peer is disco │ │ │ +00029520: 6e6e 6563 7465 6420 696e 206f 7264 6572 nnected in order │ │ │ +00029530: 2074 6f20 6176 6f69 6420 696e 6669 6e69 to avoid infini │ │ │ +00029540: 7465 0a09 092f 2f20 6c6f 6f70 7320 6f66 te...// loops of │ │ │ +00029550: 2063 6f6e 7369 7374 656e 7420 6661 696c consistent fail │ │ │ +00029560: 7572 6573 0a09 0973 7464 3a3a 7569 6e74 ures...std::uint │ │ │ +00029570: 385f 7420 6d5f 6469 736b 5f72 6561 645f 8_t m_disk_read_ │ │ │ +00029580: 6661 696c 7572 6573 203d 2030 3b0a 0a09 failures = 0;... │ │ │ +00029590: 092f 2f20 7468 6973 2069 7320 7573 6564 .// this is used │ │ │ +000295a0: 2069 6e20 7365 6564 206d 6f64 6520 7768 in seed mode wh │ │ │ +000295b0: 656e 6576 6572 2077 6520 7472 6967 6765 enever we trigge │ │ │ +000295c0: 7220 6120 6861 7368 2063 6865 636b 0a09 r a hash check.. │ │ │ +000295d0: 092f 2f20 666f 7220 6120 7069 6563 652c .// for a piece, │ │ │ +000295e0: 2062 6566 6f72 6520 7765 2072 6561 6420 before we read │ │ │ +000295f0: 6974 2e20 4974 2773 2075 7365 6420 746f it. It's used to │ │ │ +00029600: 2074 6872 6f74 746c 650a 0909 2f2f 2074 throttle...// t │ │ │ +00029610: 6865 2068 6173 6820 6368 6563 6b73 2074 he hash checks t │ │ │ +00029620: 6f20 6a75 7374 2061 2066 6577 2070 6572 o just a few per │ │ │ +00029630: 2070 6565 7220 6174 2061 2074 696d 652e peer at a time. │ │ │ +00029640: 0a09 0973 7464 3a3a 7569 6e74 385f 7420 ...std::uint8_t │ │ │ +00029650: 6d5f 6f75 7473 7461 6e64 696e 675f 7069 m_outstanding_pi │ │ │ +00029660: 6563 655f 7665 7269 6669 6361 7469 6f6e ece_verification │ │ │ +00029670: 3a33 3b0a 0a09 092f 2f20 6973 2074 7275 :3;....// is tru │ │ │ +00029680: 6520 6966 2069 7420 7761 7320 7765 2074 e if it was we t │ │ │ +00029690: 6861 7420 636f 6e6e 6563 7465 6420 746f hat connected to │ │ │ +000296a0: 2074 6865 2070 6565 720a 0909 2f2f 2061 the peer...// a │ │ │ +000296b0: 6e64 2066 616c 7365 2069 6620 7765 2067 nd false if we g │ │ │ +000296c0: 6f74 2061 6e20 696e 636f 6d69 6e67 2063 ot an incoming c │ │ │ +000296d0: 6f6e 6e65 6374 696f 6e0a 0909 2f2f 2063 onnection...// c │ │ │ +000296e0: 6f75 6c64 2062 6520 636f 6e73 6964 6572 ould be consider │ │ │ +000296f0: 6564 3a20 7472 7565 203d 206c 6f63 616c ed: true = local │ │ │ +00029700: 2c20 6661 6c73 6520 3d20 7265 6d6f 7465 , false = remote │ │ │ +00029710: 0a09 0962 6f6f 6c20 6d5f 6f75 7467 6f69 ...bool m_outgoi │ │ │ +00029720: 6e67 3a31 3b0a 0a09 092f 2f20 6973 2074 ng:1;....// is t │ │ │ +00029730: 7275 6520 6966 2077 6520 6c65 6172 6e20 rue if we learn │ │ │ +00029740: 7468 6520 696e 636f 6d69 6e67 2063 6f6e the incoming con │ │ │ +00029750: 6e65 6374 696f 6e73 206c 6973 7465 6e69 nections listeni │ │ │ +00029760: 6e67 0a09 092f 2f20 6475 7269 6e67 2074 ng...// during t │ │ │ +00029770: 6865 2065 7874 656e 6465 6420 6861 6e64 he extended hand │ │ │ +00029780: 7368 616b 650a 0909 626f 6f6c 206d 5f72 shake...bool m_r │ │ │ +00029790: 6563 6569 7665 645f 6c69 7374 656e 5f70 eceived_listen_p │ │ │ +000297a0: 6f72 743a 313b 0a0a 3c2f 7072 653e 3c2f ort:1;..
    relevan │ │ │ +000297e0: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2../include/lib │ │ │ +00029820: 746f 7272 656e 742f 6175 785f 2f73 6573 torrent/aux_/ses │ │ │ +00029830: 7369 6f6e 5f69 6e74 6572 6661 6365 2e68 sion_interface.h │ │ │ +00029840: 7070 3a31 3033 3c2f 613e 3c2f 7464 3e3c pp:103< │ │ │ +00029850: 7464 3e6d 616b 6520 7468 6973 2069 6e74 td>make this int │ │ │ +00029860: 6572 6661 6365 2061 206c 6f74 2073 6d61 erface a lot sma │ │ │ +00029870: 6c6c 6572 2e20 4974 2063 6f75 6c64 2062 ller. It could b │ │ │ +00029880: 6520 7370 6c69 7420 7570 2069 6e74 6f20 e split up into │ │ │ +00029890: 7365 7665 7261 6c20 736d 616c 6c65 7220 several smaller │ │ │ +000298a0: 696e 7465 7266 6163 6573 2e20 4561 6368 interfaces. Each │ │ │ +000298b0: 2073 7562 7379 7374 656d 2063 6f75 6c64 subsystem could │ │ │ +000298c0: 2074 6865 6e20 6c69 6d69 7420 7468 6520 then limit the │ │ │ +000298d0: 7369 7a65 206f 6620 7468 6520 6d6f 636b size of the mock │ │ │ +000298e0: 206f 626a 6563 7420 746f 2074 6573 7420 object to test │ │ │ +000298f0: 6974 2e3c 2f74 643e 3c2f 7472 3e3c 7472 it.

    │ │ │ +00029940: 6d61 6b65 2074 6869 7320 696e 7465 7266 make this interf │ │ │ +00029950: 6163 6520 6120 6c6f 7420 736d 616c 6c65 ace a lot smalle │ │ │ +00029960: 722e 2049 7420 636f 756c 6420 6265 2073 r. It could be s │ │ │ +00029970: 706c 6974 2075 7020 696e 746f 0a73 6576 plit up into.sev │ │ │ +00029980: 6572 616c 2073 6d61 6c6c 6572 2069 6e74 eral smaller int │ │ │ +00029990: 6572 6661 6365 732e 2045 6163 6820 7375 erfaces. Each su │ │ │ +000299a0: 6273 7973 7465 6d20 636f 756c 6420 7468 bsystem could th │ │ │ +000299b0: 656e 206c 696d 6974 2074 6865 2073 697a en limit the siz │ │ │ +000299c0: 650a 6f66 2074 6865 206d 6f63 6b20 6f62 e.of the mock ob │ │ │ +000299d0: 6a65 6374 2074 6f20 7465 7374 2069 742e ject to test it. │ │ │ +000299e0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ +000299f0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ +00029a00: 7578 5f2f 7365 7373 696f 6e5f 696e 7465 ux_/session_inte │ │ │ +00029a10: 7266 6163 652e 6870 703a 3130 333c 2f68 rface.hpp:103
    .// 
    │ │ │ +00029a60: 6120 7265 6c65 6173 6520 6275 696c 6420  a release build 
    │ │ │ +00029a70: 7769 7468 206c 6f67 6769 6e67 2064 6973  with logging dis
    │ │ │ +00029a80: 6162 6c65 6420 2877 6869 6368 2069 7320  abled (which is 
    │ │ │ +00029a90: 7468 6520 6465 6661 756c 7429 2077 696c  the default) wil
    │ │ │ +00029aa0: 6c0a 092f 2f20 6e6f 7420 6861 7665 2074  l..// not have t
    │ │ │ +00029ab0: 6869 7320 636c 6173 7320 6174 2061 6c6c  his class at all
    │ │ │ +00029ac0: 0a09 7374 7275 6374 2054 4f52 5245 4e54  ..struct TORRENT
    │ │ │ +00029ad0: 5f45 5854 5241 5f45 5850 4f52 5420 7365  _EXTRA_EXPORT se
    │ │ │ +00029ae0: 7373 696f 6e5f 6c6f 6767 6572 0a09 7b0a  ssion_logger..{.
    │ │ │ +00029af0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +00029b00: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +00029b10: 0909 7669 7274 7561 6c20 626f 6f6c 2073  ..virtual bool s
    │ │ │ +00029b20: 686f 756c 645f 6c6f 6728 2920 636f 6e73  hould_log() cons
    │ │ │ +00029b30: 7420 3d20 303b 0a09 0976 6972 7475 616c  t = 0;...virtual
    │ │ │ +00029b40: 2076 6f69 6420 7365 7373 696f 6e5f 6c6f   void session_lo
    │ │ │ +00029b50: 6728 6368 6172 2063 6f6e 7374 2a20 666d  g(char const* fm
    │ │ │ +00029b60: 742c 202e 2e2e 2920 636f 6e73 7420 544f  t, ...) const TO
    │ │ │ +00029b70: 5252 454e 545f 464f 524d 4154 2832 2c33  RRENT_FORMAT(2,3
    │ │ │ +00029b80: 2920 3d20 303b 0a23 656e 6469 660a 0a23  ) = 0;.#endif..#
    │ │ │ +00029b90: 6966 2054 4f52 5245 4e54 5f55 5345 5f41  if TORRENT_USE_A
    │ │ │ +00029ba0: 5353 4552 5453 0a09 0976 6972 7475 616c  SSERTS...virtual
    │ │ │ +00029bb0: 2062 6f6f 6c20 6973 5f73 696e 676c 655f   bool is_single_
    │ │ │ +00029bc0: 7468 7265 6164 2829 2063 6f6e 7374 203d  thread() const =
    │ │ │ +00029bd0: 2030 3b0a 0909 7669 7274 7561 6c20 626f   0;...virtual bo
    │ │ │ +00029be0: 6f6c 2068 6173 5f70 6565 7228 6175 783a  ol has_peer(aux:
    │ │ │ +00029bf0: 3a70 6565 725f 636f 6e6e 6563 7469 6f6e  :peer_connection
    │ │ │ +00029c00: 2063 6f6e 7374 2a20 7029 2063 6f6e 7374   const* p) const
    │ │ │ +00029c10: 203d 2030 3b0a 0909 7669 7274 7561 6c20   = 0;...virtual 
    │ │ │ +00029c20: 626f 6f6c 2061 6e79 5f74 6f72 7265 6e74  bool any_torrent
    │ │ │ +00029c30: 5f68 6173 5f70 6565 7228 6175 783a 3a70  _has_peer(aux::p
    │ │ │ +00029c40: 6565 725f 636f 6e6e 6563 7469 6f6e 2063  eer_connection c
    │ │ │ +00029c50: 6f6e 7374 2a20 7029 2063 6f6e 7374 203d  onst* p) const =
    │ │ │ +00029c60: 2030 3b0a 0909 7669 7274 7561 6c20 626f   0;...virtual bo
    │ │ │ +00029c70: 6f6c 2069 735f 706f 7374 696e 675f 746f  ol is_posting_to
    │ │ │ +00029c80: 7272 656e 745f 7570 6461 7465 7328 2920  rrent_updates() 
    │ │ │ +00029c90: 636f 6e73 7420 3d20 303b 0a23 656e 6469  const = 0;.#endi
    │ │ │ +00029ca0: 660a 0970 726f 7465 6374 6564 3a0a 0909  f..protected:...
    │ │ │ +00029cb0: 7e73 6573 7369 6f6e 5f6c 6f67 6765 7228  ~session_logger(
    │ │ │ +00029cc0: 2920 7b7d 0a09 7d3b 0a23 656e 6469 6620  ) {}..};.#endif 
    │ │ │ +00029cd0: 2f2f 2054 4f52 5245 4e54 5f44 4953 4142  // TORRENT_DISAB
    │ │ │ +00029ce0: 4c45 5f4c 4f47 4749 4e47 207c 7c20 544f  LE_LOGGING || TO
    │ │ │ +00029cf0: 5252 454e 545f 5553 455f 4153 5345 5254  RRENT_USE_ASSERT
    │ │ │ +00029d00: 530a 0a3c 6469 7620 7374 796c 653d 2262  S..
    .struct TORRENT │ │ │ +00029d40: 5f45 5854 5241 5f45 5850 4f52 5420 7365 _EXTRA_EXPORT se │ │ │ +00029d50: 7373 696f 6e5f 696e 7465 7266 6163 650a ssion_interface. │ │ │ +00029d60: 3c2f 6469 763e 2369 6620 2164 6566 696e
    #if !defin │ │ │ +00029d70: 6564 2054 4f52 5245 4e54 5f44 4953 4142 ed TORRENT_DISAB │ │ │ +00029d80: 4c45 5f4c 4f47 4749 4e47 207c 7c20 544f LE_LOGGING || TO │ │ │ +00029d90: 5252 454e 545f 5553 455f 4153 5345 5254 RRENT_USE_ASSERT │ │ │ +00029da0: 530a 0909 3a20 7365 7373 696f 6e5f 6c6f S...: session_lo │ │ │ +00029db0: 6767 6572 0a23 656e 6469 660a 097b 0a0a gger.#endif..{.. │ │ │ +00029dc0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00029dd0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00029e00: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../inc │ │ │ +00029e30: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ +00029e40: 6175 785f 2f73 6573 7369 6f6e 5f69 6e74 aux_/session_int │ │ │ +00029e50: 6572 6661 6365 2e68 7070 3a31 3132 3c2f erface.hpp:112the I │ │ │ +00029e70: 5020 766f 7469 6e67 206d 6563 6861 6e69 P voting mechani │ │ │ +00029e80: 736d 2073 686f 756c 6420 6265 2066 6163 sm should be fac │ │ │ +00029e90: 746f 7265 6420 6f75 7420 746f 2069 7473 tored out to its │ │ │ +00029ea0: 206f 776e 2063 6c61 7373 2c20 6e6f 7420 own class, not │ │ │ +00029eb0: 7061 7274 206f 6620 7468 6520 7365 7373 part of the sess │ │ │ +00029ec0: 696f 6e20 616e 6420 7468 6573 6520 636f ion and these co │ │ │ +00029ed0: 6e73 7461 6e74 7320 7368 6f75 6c64 206d nstants should m │ │ │ +00029ee0: 6f76 6520 746f 6f3c 2f74 643e 3c2f 7472 ove too │ │ │ +00029f20: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00029f30: 3c68 323e 7468 6520 4950 2076 6f74 696e

    the IP votin │ │ │ +00029f40: 6720 6d65 6368 616e 6973 6d20 7368 6f75 g mechanism shou │ │ │ +00029f50: 6c64 2062 6520 6661 6374 6f72 6564 206f ld be factored o │ │ │ +00029f60: 7574 0a74 6f20 6974 7320 6f77 6e20 636c ut.to its own cl │ │ │ +00029f70: 6173 732c 206e 6f74 2070 6172 7420 6f66 ass, not part of │ │ │ +00029f80: 2074 6865 2073 6573 7369 6f6e 0a61 6e64 the session.and │ │ │ +00029f90: 2074 6865 7365 2063 6f6e 7374 616e 7473 these constants │ │ │ +00029fa0: 2073 686f 756c 6420 6d6f 7665 2074 6f6f should move too │ │ │ +00029fb0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ +00029fc0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ +00029fd0: 7578 5f2f 7365 7373 696f 6e5f 696e 7465 ux_/session_inte │ │ │ +00029fe0: 7266 6163 652e 6870 703a 3131 323c 2f68 rface.hpp:112
    ..vi
    │ │ │ +0002a030: 7274 7561 6c20 766f 6964 2073 6573 7369  rtual void sessi
    │ │ │ +0002a040: 6f6e 5f6c 6f67 2863 6861 7220 636f 6e73  on_log(char cons
    │ │ │ +0002a050: 742a 2066 6d74 2c20 2e2e 2e29 2063 6f6e  t* fmt, ...) con
    │ │ │ +0002a060: 7374 2054 4f52 5245 4e54 5f46 4f52 4d41  st TORRENT_FORMA
    │ │ │ +0002a070: 5428 322c 3329 203d 2030 3b0a 2365 6e64  T(2,3) = 0;.#end
    │ │ │ +0002a080: 6966 0a0a 2369 6620 544f 5252 454e 545f  if..#if TORRENT_
    │ │ │ +0002a090: 5553 455f 4153 5345 5254 530a 0909 7669  USE_ASSERTS...vi
    │ │ │ +0002a0a0: 7274 7561 6c20 626f 6f6c 2069 735f 7369  rtual bool is_si
    │ │ │ +0002a0b0: 6e67 6c65 5f74 6872 6561 6428 2920 636f  ngle_thread() co
    │ │ │ +0002a0c0: 6e73 7420 3d20 303b 0a09 0976 6972 7475  nst = 0;...virtu
    │ │ │ +0002a0d0: 616c 2062 6f6f 6c20 6861 735f 7065 6572  al bool has_peer
    │ │ │ +0002a0e0: 2861 7578 3a3a 7065 6572 5f63 6f6e 6e65  (aux::peer_conne
    │ │ │ +0002a0f0: 6374 696f 6e20 636f 6e73 742a 2070 2920  ction const* p) 
    │ │ │ +0002a100: 636f 6e73 7420 3d20 303b 0a09 0976 6972  const = 0;...vir
    │ │ │ +0002a110: 7475 616c 2062 6f6f 6c20 616e 795f 746f  tual bool any_to
    │ │ │ +0002a120: 7272 656e 745f 6861 735f 7065 6572 2861  rrent_has_peer(a
    │ │ │ +0002a130: 7578 3a3a 7065 6572 5f63 6f6e 6e65 6374  ux::peer_connect
    │ │ │ +0002a140: 696f 6e20 636f 6e73 742a 2070 2920 636f  ion const* p) co
    │ │ │ +0002a150: 6e73 7420 3d20 303b 0a09 0976 6972 7475  nst = 0;...virtu
    │ │ │ +0002a160: 616c 2062 6f6f 6c20 6973 5f70 6f73 7469  al bool is_posti
    │ │ │ +0002a170: 6e67 5f74 6f72 7265 6e74 5f75 7064 6174  ng_torrent_updat
    │ │ │ +0002a180: 6573 2829 2063 6f6e 7374 203d 2030 3b0a  es() const = 0;.
    │ │ │ +0002a190: 2365 6e64 6966 0a09 7072 6f74 6563 7465  #endif..protecte
    │ │ │ +0002a1a0: 643a 0a09 097e 7365 7373 696f 6e5f 6c6f  d:...~session_lo
    │ │ │ +0002a1b0: 6767 6572 2829 207b 7d0a 097d 3b0a 2365  gger() {}..};.#e
    │ │ │ +0002a1c0: 6e64 6966 202f 2f20 544f 5252 454e 545f  ndif // TORRENT_
    │ │ │ +0002a1d0: 4449 5341 424c 455f 4c4f 4747 494e 4720  DISABLE_LOGGING 
    │ │ │ +0002a1e0: 7c7c 2054 4f52 5245 4e54 5f55 5345 5f41  || TORRENT_USE_A
    │ │ │ +0002a1f0: 5353 4552 5453 0a0a 0973 7472 7563 7420  SSERTS...struct 
    │ │ │ +0002a200: 544f 5252 454e 545f 4558 5452 415f 4558  TORRENT_EXTRA_EX
    │ │ │ +0002a210: 504f 5254 2073 6573 7369 6f6e 5f69 6e74  PORT session_int
    │ │ │ +0002a220: 6572 6661 6365 0a23 6966 2021 6465 6669  erface.#if !defi
    │ │ │ +0002a230: 6e65 6420 544f 5252 454e 545f 4449 5341  ned TORRENT_DISA
    │ │ │ +0002a240: 424c 455f 4c4f 4747 494e 4720 7c7c 2054  BLE_LOGGING || T
    │ │ │ +0002a250: 4f52 5245 4e54 5f55 5345 5f41 5353 4552  ORRENT_USE_ASSER
    │ │ │ +0002a260: 5453 0a09 093a 2073 6573 7369 6f6e 5f6c  TS...: session_l
    │ │ │ +0002a270: 6f67 6765 720a 2365 6e64 6966 0a09 7b0a  ogger.#endif..{.
    │ │ │ +0002a280: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0002a2b0: 3c2f 6469 763e 0909 2f2f 2074 6865 206c
    ..// the l │ │ │ +0002a2c0: 6f67 6963 2069 6e20 6970 5f76 6f74 6572 ogic in ip_voter │ │ │ +0002a2d0: 2072 656c 6965 7320 6f6e 206d 6f72 6520 relies on more │ │ │ +0002a2e0: 7265 6c69 6162 6c65 2073 6f75 7263 6573 reliable sources │ │ │ +0002a2f0: 2061 7265 2072 6570 7265 7365 6e74 6564 are represented │ │ │ +0002a300: 0a09 092f 2f20 6279 206d 6f72 6520 7369 ...// by more si │ │ │ +0002a310: 676e 6966 6963 616e 7420 6269 7473 0a09 gnificant bits.. │ │ │ +0002a320: 0973 7461 7469 6320 696e 6c69 6e65 2063 .static inline c │ │ │ +0002a330: 6f6e 7374 6578 7072 2069 705f 736f 7572 onstexpr ip_sour │ │ │ +0002a340: 6365 5f74 2073 6f75 7263 655f 6468 7420 ce_t source_dht │ │ │ +0002a350: 3d20 315f 6269 743b 0a09 0973 7461 7469 = 1_bit;...stati │ │ │ +0002a360: 6320 696e 6c69 6e65 2063 6f6e 7374 6578 c inline constex │ │ │ +0002a370: 7072 2069 705f 736f 7572 6365 5f74 2073 pr ip_source_t s │ │ │ +0002a380: 6f75 7263 655f 7065 6572 203d 2032 5f62 ource_peer = 2_b │ │ │ +0002a390: 6974 3b0a 0909 7374 6174 6963 2069 6e6c it;...static inl │ │ │ +0002a3a0: 696e 6520 636f 6e73 7465 7870 7220 6970 ine constexpr ip │ │ │ +0002a3b0: 5f73 6f75 7263 655f 7420 736f 7572 6365 _source_t source │ │ │ +0002a3c0: 5f74 7261 636b 6572 203d 2033 5f62 6974 _tracker = 3_bit │ │ │ +0002a3d0: 3b0a 0909 7374 6174 6963 2069 6e6c 696e ;...static inlin │ │ │ +0002a3e0: 6520 636f 6e73 7465 7870 7220 6970 5f73 e constexpr ip_s │ │ │ +0002a3f0: 6f75 7263 655f 7420 736f 7572 6365 5f72 ource_t source_r │ │ │ +0002a400: 6f75 7465 7220 3d20 345f 6269 743b 0a0a outer = 4_bit;.. │ │ │ +0002a410: 0909 7669 7274 7561 6c20 766f 6964 2073 ..virtual void s │ │ │ +0002a420: 6574 5f65 7874 6572 6e61 6c5f 6164 6472 et_external_addr │ │ │ +0002a430: 6573 7328 7463 703a 3a65 6e64 706f 696e ess(tcp::endpoin │ │ │ +0002a440: 7420 636f 6e73 7426 616d 703b 206c 6f63 t const& loc │ │ │ +0002a450: 616c 5f65 6e64 706f 696e 740a 0909 092c al_endpoint...., │ │ │ +0002a460: 2061 6464 7265 7373 2063 6f6e 7374 2661 address const&a │ │ │ +0002a470: 6d70 3b20 6970 0a09 0909 2c20 6970 5f73 mp; ip...., ip_s │ │ │ +0002a480: 6f75 7263 655f 7420 736f 7572 6365 5f74 ource_t source_t │ │ │ +0002a490: 7970 652c 2061 6464 7265 7373 2063 6f6e ype, address con │ │ │ +0002a4a0: 7374 2661 6d70 3b20 736f 7572 6365 2920 st& source) │ │ │ +0002a4b0: 3d20 303b 0a09 0976 6972 7475 616c 2061 = 0;...virtual a │ │ │ +0002a4c0: 7578 3a3a 6578 7465 726e 616c 5f69 7020 ux::external_ip │ │ │ +0002a4d0: 6578 7465 726e 616c 5f61 6464 7265 7373 external_address │ │ │ +0002a4e0: 2829 2063 6f6e 7374 203d 2030 3b0a 0a09 () const = 0;... │ │ │ +0002a4f0: 0976 6972 7475 616c 2064 6973 6b5f 696e .virtual disk_in │ │ │ +0002a500: 7465 7266 6163 6526 616d 703b 2064 6973 terface& dis │ │ │ +0002a510: 6b5f 7468 7265 6164 2829 203d 2030 3b0a k_thread() = 0;. │ │ │ +0002a520: 0a09 0976 6972 7475 616c 2061 6c65 7274 ...virtual alert │ │ │ +0002a530: 5f6d 616e 6167 6572 2661 6d70 3b20 616c _manager& al │ │ │ +0002a540: 6572 7473 2829 203d 2030 3b0a 0a09 0976 erts() = 0;....v │ │ │ +0002a550: 6972 7475 616c 2074 6f72 7265 6e74 5f70 irtual torrent_p │ │ │ +0002a560: 6565 725f 616c 6c6f 6361 746f 725f 696e eer_allocator_in │ │ │ +0002a570: 7465 7266 6163 6526 616d 703b 2067 6574 terface& get │ │ │ +0002a580: 5f70 6565 725f 616c 6c6f 6361 746f 7228 _peer_allocator( │ │ │ +0002a590: 2920 3d20 303b 0a09 0976 6972 7475 616c ) = 0;...virtual │ │ │ +0002a5a0: 2069 6f5f 636f 6e74 6578 7426 616d 703b io_context& │ │ │ +0002a5b0: 2067 6574 5f63 6f6e 7465 7874 2829 203d get_context() = │ │ │ +0002a5c0: 2030 3b0a 0909 7669 7274 7561 6c20 6175 0;...virtual au │ │ │ +0002a5d0: 783a 3a72 6573 6f6c 7665 725f 696e 7465 x::resolver_inte │ │ │ +0002a5e0: 7266 6163 6526 616d 703b 2067 6574 5f72 rface& get_r │ │ │ +0002a5f0: 6573 6f6c 7665 7228 2920 3d20 303b 0a0a esolver() = 0;.. │ │ │ +0002a600: 0909 7669 7274 7561 6c20 626f 6f6c 2068 ..virtual bool h │ │ │ +0002a610: 6173 5f63 6f6e 6e65 6374 696f 6e28 7065 as_connection(pe │ │ │ +0002a620: 6572 5f63 6f6e 6e65 6374 696f 6e2a 2070 er_connection* p │ │ │ +0002a630: 2920 636f 6e73 7420 3d20 303b 0a09 0976 ) const = 0;...v │ │ │ +0002a640: 6972 7475 616c 2076 6f69 6420 696e 7365 irtual void inse │ │ │ +0002a650: 7274 5f70 6565 7228 7374 643a 3a73 6861 rt_peer(std::sha │ │ │ +0002a660: 7265 645f 7074 7226 6c74 3b70 6565 725f red_ptr<peer_ │ │ │ +0002a670: 636f 6e6e 6563 7469 6f6e 2667 743b 2063 connection> c │ │ │ +0002a680: 6f6e 7374 2661 6d70 3b20 6329 203d 2030 onst& c) = 0 │ │ │ +0002a690: 3b0a 0a09 0976 6972 7475 616c 2076 6f69 ;....virtual voi │ │ │ +0002a6a0: 6420 7265 6d6f 7665 5f74 6f72 7265 6e74 d remove_torrent │ │ │ +0002a6b0: 2874 6f72 7265 6e74 5f68 616e 646c 6520 (torrent_handle │ │ │ +0002a6c0: 636f 6e73 7426 616d 703b 2068 2c20 7265 const& h, re │ │ │ +0002a6d0: 6d6f 7665 5f66 6c61 6773 5f74 206f 7074 move_flags_t opt │ │ │ +0002a6e0: 696f 6e73 203d 207b 7d29 203d 2030 3b0a ions = {}) = 0;. │ │ │ +0002a6f0: 0909 7669 7274 7561 6c20 766f 6964 2072 ..virtual void r │ │ │ +0002a700: 656d 6f76 655f 746f 7272 656e 745f 696d emove_torrent_im │ │ │ +0002a710: 706c 2873 7464 3a3a 7368 6172 6564 5f70 pl(std::shared_p │ │ │ +0002a720: 7472 266c 743b 746f 7272 656e 7426 6774 tr<torrent> │ │ │ +0002a730: 3b20 7470 7472 2c20 7265 6d6f 7665 5f66 ; tptr, remove_f │ │ │ +0002a740: 6c61 6773 5f74 206f 7074 696f 6e73 2920 lags_t options) │ │ │ +0002a750: 3d20 303b 0a0a 0909 2f2f 2070 6f72 7420 = 0;....// port │ │ │ +0002a760: 6669 6c74 6572 0a09 0976 6972 7475 616c filter...virtual │ │ │ +0002a770: 2070 6f72 745f 6669 6c74 6572 2063 6f6e port_filter con │ │ │ +0002a780: 7374 2661 6d70 3b20 6765 745f 706f 7274 st& get_port │ │ │ +0002a790: 5f66 696c 7465 7228 2920 636f 6e73 7420 _filter() const │ │ │ +0002a7a0: 3d20 303b 0a09 0976 6972 7475 616c 2076 = 0;...virtual v │ │ │ +0002a7b0: 6f69 6420 6261 6e5f 6970 2861 6464 7265 oid ban_ip(addre │ │ │ +0002a7c0: 7373 2061 6464 7229 203d 2030 3b0a 0a3c ss addr) = 0;..< │ │ │ +0002a7d0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0002a7e0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0002a7f0: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +0002a800: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +0002a810: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../incl │ │ │ +0002a840: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ +0002a850: 7578 5f2f 7069 6563 655f 7069 636b 6572 ux_/piece_picker │ │ │ +0002a860: 2e68 7070 3a36 3439 3c2f 613e 3c2f 7464 .hpp:649having 8 pr │ │ │ +0002a880: 696f 7269 7479 206c 6576 656c 7320 6973 iority levels is │ │ │ +0002a890: 2070 726f 6261 626c 7920 6578 6365 7373 probably excess │ │ │ +0002a8a0: 6976 652e 2049 7420 7368 6f75 6c64 2070 ive. It should p │ │ │ +0002a8b0: 726f 6261 626c 7920 6265 2063 6861 6e67 robably be chang │ │ │ +0002a8c0: 6564 2074 6f20 3320 6c65 7665 6c73 202b ed to 3 levels + │ │ │ +0002a8d0: 2064 6f6e 742d 646f 776e 6c6f 6164 3c2f dont-download

    havin │ │ │ +0002a930: 6720 3820 7072 696f 7269 7479 206c 6576 g 8 priority lev │ │ │ +0002a940: 656c 7320 6973 2070 726f 6261 626c 7920 els is probably │ │ │ +0002a950: 6578 6365 7373 6976 652e 2049 7420 7368 excessive. It sh │ │ │ +0002a960: 6f75 6c64 0a70 726f 6261 626c 7920 6265 ould.probably be │ │ │ +0002a970: 2063 6861 6e67 6564 2074 6f20 3320 6c65 changed to 3 le │ │ │ +0002a980: 7665 6c73 202b 2064 6f6e 742d 646f 776e vels + dont-down │ │ │ +0002a990: 6c6f 6164 3c2f 6832 3e3c 6834 3e2e 2e2f load

    ../ │ │ │ +0002a9a0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ +0002a9b0: 6e74 2f61 7578 5f2f 7069 6563 655f 7069 nt/aux_/piece_pi │ │ │ +0002a9c0: 636b 6572 2e68 7070 3a36 3439 3c2f 6834 cker.hpp:649

    ....e
    │ │ │ +0002aa10: 6c73 6520 6966 2028 7374 6174 6528 2920  lse if (state() 
    │ │ │ +0002aa20: 3d3d 2070 6965 6365 5f66 756c 6c29 0a09  == piece_full)..
    │ │ │ +0002aa30: 0909 0909 0973 7461 7465 2870 6965 6365  .....state(piece
    │ │ │ +0002aa40: 5f66 756c 6c5f 7265 7665 7273 6529 3b0a  _full_reverse);.
    │ │ │ +0002aa50: 0909 097d 0a0a 0909 092f 2f20 7468 6520  ...}.....// the 
    │ │ │ +0002aa60: 6e75 6d62 6572 206f 6620 7065 6572 7320  number of peers 
    │ │ │ +0002aa70: 7468 6174 2068 6173 2074 6869 7320 7069  that has this pi
    │ │ │ +0002aa80: 6563 650a 0909 092f 2f20 2861 7661 696c  ece....// (avail
    │ │ │ +0002aa90: 6162 696c 6974 7929 0a09 0909 7374 643a  ability)....std:
    │ │ │ +0002aaa0: 3a75 696e 7433 325f 7420 7065 6572 5f63  :uint32_t peer_c
    │ │ │ +0002aab0: 6f75 6e74 203a 2032 363b 0a0a 0909 092f  ount : 26;...../
    │ │ │ +0002aac0: 2f20 6f6e 6520 6f66 2074 6865 2064 6f77  / one of the dow
    │ │ │ +0002aad0: 6e6c 6f61 645f 7175 6575 655f 7420 7661  nload_queue_t va
    │ │ │ +0002aae0: 6c75 6573 2e20 5468 6973 2069 6e64 6963  lues. This indic
    │ │ │ +0002aaf0: 6174 6573 2077 6865 7468 6572 2074 6869  ates whether thi
    │ │ │ +0002ab00: 7320 7069 6563 650a 0909 092f 2f20 6973  s piece....// is
    │ │ │ +0002ab10: 2063 7572 7265 6e74 6c79 2062 6569 6e67   currently being
    │ │ │ +0002ab20: 2064 6f77 6e6c 6f61 6465 6420 6f72 206e   downloaded or n
    │ │ │ +0002ab30: 6f74 2c20 616e 6420 7768 6174 2073 7461  ot, and what sta
    │ │ │ +0002ab40: 7465 2069 7427 7320 696e 2069 660a 0909  te it's in if...
    │ │ │ +0002ab50: 092f 2f20 6974 2069 732e 2053 7065 6369  .// it is. Speci
    │ │ │ +0002ab60: 6669 6361 6c6c 792c 2061 7320 616e 206f  fically, as an o
    │ │ │ +0002ab70: 7074 696d 697a 6174 696f 6e2c 2070 6965  ptimization, pie
    │ │ │ +0002ab80: 6365 7320 7468 6174 2068 6176 6520 616c  ces that have al
    │ │ │ +0002ab90: 6c20 626c 6f63 6b73 0a09 0909 2f2f 2072  l blocks....// r
    │ │ │ +0002aba0: 6571 7565 7374 6564 2066 726f 6d20 7468  equested from th
    │ │ │ +0002abb0: 656d 2061 7265 2073 6570 6172 6174 6564  em are separated
    │ │ │ +0002abc0: 206f 7574 2069 6e74 6f20 7365 7061 7261   out into separa
    │ │ │ +0002abd0: 7465 206c 6973 7473 2074 6f20 6d61 6b65  te lists to make
    │ │ │ +0002abe0: 0a09 0909 2f2f 206c 6f6f 6b75 7073 2071  ....// lookups q
    │ │ │ +0002abf0: 7569 636b 6572 2e20 5468 6520 6d61 696e  uicker. The main
    │ │ │ +0002ac00: 206f 6464 6974 7920 6973 2074 6861 7420   oddity is that 
    │ │ │ +0002ac10: 7768 6574 6865 7220 6120 646f 776e 6c6f  whether a downlo
    │ │ │ +0002ac20: 6164 696e 6720 7069 6563 650a 0909 092f  ading piece..../
    │ │ │ +0002ac30: 2f20 6861 7320 6f6e 6c79 2062 6565 6e20  / has only been 
    │ │ │ +0002ac40: 7265 7175 6573 7465 6420 6672 6f6d 2070  requested from p
    │ │ │ +0002ac50: 6565 7273 2074 6861 7420 6172 6520 7265  eers that are re
    │ │ │ +0002ac60: 7665 7273 652c 2074 6861 7427 730a 0909  verse, that's...
    │ │ │ +0002ac70: 092f 2f20 7265 636f 7264 6564 2061 7320  .// recorded as 
    │ │ │ +0002ac80: 7069 6563 655f 646f 776e 6c6f 6164 696e  piece_downloadin
    │ │ │ +0002ac90: 675f 7265 7665 7273 652c 2077 6869 6368  g_reverse, which
    │ │ │ +0002aca0: 2072 6561 6c6c 7920 6d65 616e 7320 7468   really means th
    │ │ │ +0002acb0: 6520 7361 6d65 0a09 0909 2f2f 2061 7320  e same....// as 
    │ │ │ +0002acc0: 7069 6563 655f 646f 776e 6c6f 6164 696e  piece_downloadin
    │ │ │ +0002acd0: 672c 2069 7420 6a75 7374 2073 6176 6573  g, it just saves
    │ │ │ +0002ace0: 2073 7061 6365 2074 6f20 616c 736f 2069   space to also i
    │ │ │ +0002acf0: 6e64 6963 6174 6520 7468 6174 2069 740a  ndicate that it.
    │ │ │ +0002ad00: 0909 092f 2f20 6861 7320 6120 6269 7420  ...// has a bit 
    │ │ │ +0002ad10: 6c6f 7765 7220 7072 696f 7269 7479 2e20  lower priority. 
    │ │ │ +0002ad20: 5468 6520 7265 7665 7273 6520 6269 7420  The reverse bit 
    │ │ │ +0002ad30: 6973 206f 6e6c 7920 7265 6c65 7661 6e74  is only relevant
    │ │ │ +0002ad40: 2069 6620 7468 650a 0909 092f 2f20 7374   if the....// st
    │ │ │ +0002ad50: 6174 6520 6973 2070 6965 6365 5f64 6f77  ate is piece_dow
    │ │ │ +0002ad60: 6e6c 6f61 6469 6e67 2e0a 0909 0973 7464  nloading.....std
    │ │ │ +0002ad70: 3a3a 7569 6e74 3332 5f74 2064 6f77 6e6c  ::uint32_t downl
    │ │ │ +0002ad80: 6f61 645f 7374 6174 6520 3a20 333b 0a0a  oad_state : 3;..
    │ │ │ +0002ad90: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ +0002adc0: 2f64 6976 3e09 0909 2f2f 2069 7320 3020 /div>...// is 0 │ │ │ +0002add0: 6966 2074 6865 2070 6965 6365 2069 7320 if the piece is │ │ │ +0002ade0: 6669 6c74 6572 6564 2028 6e6f 7420 746f filtered (not to │ │ │ +0002adf0: 2062 6520 646f 776e 6c6f 6164 6564 290a be downloaded). │ │ │ +0002ae00: 0909 092f 2f20 3120 6973 206c 6f77 2070 ...// 1 is low p │ │ │ +0002ae10: 7269 6f72 6974 790a 0909 092f 2f20 3220 riority....// 2 │ │ │ +0002ae20: 6973 206c 6f77 2070 7269 6f72 6974 790a is low priority. │ │ │ +0002ae30: 0909 092f 2f20 3320 6973 206d 6964 2070 ...// 3 is mid p │ │ │ +0002ae40: 7269 6f72 6974 790a 0909 092f 2f20 3420 riority....// 4 │ │ │ +0002ae50: 6973 2064 6566 6175 6c74 2070 7269 6f72 is default prior │ │ │ +0002ae60: 6974 790a 0909 092f 2f20 3520 6973 206d ity....// 5 is m │ │ │ +0002ae70: 6964 2070 7269 6f72 6974 790a 0909 092f id priority..../ │ │ │ +0002ae80: 2f20 3620 6973 2068 6967 6820 7072 696f / 6 is high prio │ │ │ +0002ae90: 7269 7479 0a09 0909 2f2f 2037 2069 7320 rity....// 7 is │ │ │ +0002aea0: 6869 6768 2070 7269 6f72 6974 790a 0909 high priority... │ │ │ +0002aeb0: 0973 7464 3a3a 7569 6e74 3332 5f74 2070 .std::uint32_t p │ │ │ +0002aec0: 6965 6365 5f70 7269 6f72 6974 7920 3a20 iece_priority : │ │ │ +0002aed0: 333b 0a0a 0909 092f 2f20 696e 6465 7820 3;.....// index │ │ │ +0002aee0: 696e 2074 6f20 7468 6520 7069 6563 655f in to the piece_ │ │ │ +0002aef0: 696e 666f 2076 6563 746f 720a 0909 0970 info vector....p │ │ │ +0002af00: 7269 6f5f 696e 6465 785f 7420 696e 6465 rio_index_t inde │ │ │ +0002af10: 783b 0a0a 2369 6664 6566 2054 4f52 5245 x;..#ifdef TORRE │ │ │ +0002af20: 4e54 5f44 4542 5547 5f52 4546 434f 554e NT_DEBUG_REFCOUN │ │ │ +0002af30: 5453 0a09 0909 2f2f 2061 6c6c 2074 6865 TS....// all the │ │ │ +0002af40: 2070 6565 7273 2074 6861 7420 6861 7665 peers that have │ │ │ +0002af50: 2074 6869 7320 7069 6563 650a 0909 0973 this piece....s │ │ │ +0002af60: 7464 3a3a 7365 7426 6c74 3b63 6f6e 7374 td::set<const │ │ │ +0002af70: 2061 7578 3a3a 746f 7272 656e 745f 7065 aux::torrent_pe │ │ │ +0002af80: 6572 2a26 6774 3b20 6861 7665 5f70 6565 er*> have_pee │ │ │ +0002af90: 7273 3b0a 2365 6e64 6966 0a0a 0909 092f rs;.#endif...../ │ │ │ +0002afa0: 2f20 696e 6465 7820 6973 2073 6574 2074 / index is set t │ │ │ +0002afb0: 6f20 7468 6973 2074 6f20 696e 6469 6361 o this to indica │ │ │ +0002afc0: 7465 2074 6861 7420 7468 6973 2070 6965 te that this pie │ │ │ +0002afd0: 6365 2068 6173 2062 6565 6e0a 0909 092f ce has been..../ │ │ │ +0002afe0: 2f20 666c 7573 6865 6420 2869 2e65 2e20 / flushed (i.e. │ │ │ +0002aff0: 7468 6520 7069 636b 6572 2068 6173 2066 the picker has f │ │ │ +0002b000: 696e 616c 697a 6564 2061 6363 6f75 6e74 inalized account │ │ │ +0002b010: 696e 6720 666f 7220 6974 0a09 0909 2f2f ing for it....// │ │ │ +0002b020: 2061 6e64 2072 656d 6f76 6564 2069 7420 and removed it │ │ │ +0002b030: 6672 6f6d 2074 6865 2070 7269 6f72 6974 from the priorit │ │ │ +0002b040: 7920 6275 636b 6574 7329 2e20 5468 6520 y buckets). The │ │ │ +0002b050: 666c 7573 6865 6420 666c 6167 0a09 0909 flushed flag.... │ │ │ +0002b060: 2f2f 2069 7320 7468 6520 7374 7269 6374 // is the strict │ │ │ +0002b070: 206e 6f74 696f 6e20 6f66 2022 6861 6422 notion of "had" │ │ │ +0002b080: 3a20 7069 6563 655f 7069 636b 6572 3a3a : piece_picker:: │ │ │ +0002b090: 6861 7665 5f70 6965 6365 2829 0a09 0909 have_piece().... │ │ │ +0002b0a0: 2f2f 2069 7320 7468 6520 6c6f 6f73 6520 // is the loose │ │ │ +0002b0b0: 6e6f 7469 6f6e 2028 7061 7373 6564 5f68 notion (passed_h │ │ │ +0002b0c0: 6173 685f 6368 6563 6b20 4f52 2066 6c75 ash_check OR flu │ │ │ +0002b0d0: 7368 6564 292e 204d 6f73 740a 0909 092f shed). Most..../ │ │ │ +0002b0e0: 2f20 696e 7465 726e 616c 2063 6f64 6520 / internal code │ │ │ +0002b0f0: 7761 6e74 7320 7468 6520 7374 7269 6374 wants the strict │ │ │ +0002b100: 206e 6f74 696f 6e20 2865 2e67 2e20 6375 notion (e.g. cu │ │ │ +0002b110: 7273 6f72 2061 6476 616e 6365 0a09 0909 rsor advance.... │ │ │ +0002b120: 2f2f 2069 7320 6472 6976 656e 2062 7920 // is driven by │ │ │ +0002b130: 7069 6563 655f 666c 7573 6865 6428 2929 piece_flushed()) │ │ │ +0002b140: 2e0a 0909 0973 7461 7469 6320 696e 6c69 .....static inli │ │ │ +0002b150: 6e65 2063 6f6e 7374 6578 7072 2070 7269 ne constexpr pri │ │ │ +0002b160: 6f5f 696e 6465 785f 7420 666c 7573 6865 o_index_t flushe │ │ │ +0002b170: 645f 696e 6465 787b 2d31 7d3b 0a0a 0909 d_index{-1};.... │ │ │ +0002b180: 092f 2f20 7468 6520 7072 696f 7269 7479 .// the priority │ │ │ +0002b190: 2076 616c 7565 2074 6861 7420 6d65 616e value that mean │ │ │ +0002b1a0: 7320 7468 6520 7069 6563 6520 6973 2066 s the piece is f │ │ │ +0002b1b0: 696c 7465 7265 640a 0909 0973 7461 7469 iltered....stati │ │ │ +0002b1c0: 6320 636f 6e73 7465 7870 7220 7374 643a c constexpr std: │ │ │ +0002b1d0: 3a75 696e 7433 325f 7420 6669 6c74 6572 :uint32_t filter │ │ │ +0002b1e0: 5f70 7269 6f72 6974 7920 3d20 303b 0a0a _priority = 0;.. │ │ │ +0002b1f0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0002b200: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0002b230: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../inc │ │ │ +0002b260: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ +0002b270: 6175 785f 2f63 6861 696e 6564 5f62 7566 aux_/chained_buf │ │ │ +0002b280: 6665 722e 6870 703a 3337 3c2f 613e 3c2f fer.hpp:37this type │ │ │ +0002b2a0: 2073 686f 756c 6420 7072 6f62 6162 6c79 should probably │ │ │ +0002b2b0: 2062 6520 7265 6e61 6d65 6420 746f 2073 be renamed to s │ │ │ +0002b2c0: 656e 645f 6275 6666 6572 3c2f 7464 3e3c end_buffer< │ │ │ +0002b2d0: 2f74 723e 3c74 7220 6964 3d22 3836 2220 /tr>

    this type │ │ │ +0002b320: 2073 686f 756c 6420 7072 6f62 6162 6c79 should probably │ │ │ +0002b330: 2062 6520 7265 6e61 6d65 6420 746f 2073 be renamed to s │ │ │ +0002b340: 656e 645f 6275 6666 6572 3c2f 6832 3e3c end_buffer

    < │ │ │ +0002b350: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ +0002b360: 6274 6f72 7265 6e74 2f61 7578 5f2f 6368 btorrent/aux_/ch │ │ │ +0002b370: 6169 6e65 645f 6275 6666 6572 2e68 7070 ained_buffer.hpp │ │ │ +0002b380: 3a33 373c 2f68 343e 3c70 7265 2073 7479 :37

    .#include <
    │ │ │ +0002b3d0: 6465 7175 6526 6774 3b0a 2369 6e63 6c75  deque>.#inclu
    │ │ │ +0002b3e0: 6465 2026 6c74 3b74 7970 655f 7472 6169  de <type_trai
    │ │ │ +0002b3f0: 7473 2667 743b 0a23 696e 636c 7564 6520  ts>.#include 
    │ │ │ +0002b400: 266c 743b 7574 696c 6974 7926 6774 3b0a  <utility>.
    │ │ │ +0002b410: 2369 6e63 6c75 6465 2026 6c74 3b76 6563  #include <vec
    │ │ │ +0002b420: 746f 7226 6774 3b0a 0a23 696e 636c 7564  tor>..#includ
    │ │ │ +0002b430: 6520 226c 6962 746f 7272 656e 742f 6175  e "libtorrent/au
    │ │ │ +0002b440: 785f 2f64 6973 6162 6c65 5f77 6172 6e69  x_/disable_warni
    │ │ │ +0002b450: 6e67 735f 7075 7368 2e68 7070 220a 2369  ngs_push.hpp".#i
    │ │ │ +0002b460: 6e63 6c75 6465 2026 6c74 3b62 6f6f 7374  nclude <boost
    │ │ │ +0002b470: 2f61 7369 6f2f 6275 6666 6572 2e68 7070  /asio/buffer.hpp
    │ │ │ +0002b480: 2667 743b 0a23 696e 636c 7564 6520 226c  >.#include "l
    │ │ │ +0002b490: 6962 746f 7272 656e 742f 6175 785f 2f64  ibtorrent/aux_/d
    │ │ │ +0002b4a0: 6973 6162 6c65 5f77 6172 6e69 6e67 735f  isable_warnings_
    │ │ │ +0002b4b0: 706f 702e 6870 7022 0a0a 2369 6664 6566  pop.hpp"..#ifdef
    │ │ │ +0002b4c0: 205f 4d53 435f 5645 520a 2f2f 2076 6973   _MSC_VER.// vis
    │ │ │ +0002b4d0: 7561 6c20 7374 7564 696f 2072 6571 7569  ual studio requi
    │ │ │ +0002b4e0: 7265 7320 7468 6520 7661 6c75 6520 696e  res the value in
    │ │ │ +0002b4f0: 2061 2064 6571 7565 2074 6f20 6265 2063   a deque to be c
    │ │ │ +0002b500: 6f70 7961 626c 652e 2043 2b2b 3131 0a2f  opyable. C++11./
    │ │ │ +0002b510: 2f20 6861 7320 6c6f 6f73 6572 2072 6571  / has looser req
    │ │ │ +0002b520: 7569 7265 6d65 6e74 7320 6465 7065 6e64  uirements depend
    │ │ │ +0002b530: 696e 6720 6f6e 2077 6869 6368 2066 756e  ing on which fun
    │ │ │ +0002b540: 6374 696f 6e73 2061 7265 2061 6374 7561  ctions are actua
    │ │ │ +0002b550: 6c6c 7920 7573 6564 2e0a 2364 6566 696e  lly used..#defin
    │ │ │ +0002b560: 6520 544f 5252 454e 545f 4350 5039 385f  e TORRENT_CPP98_
    │ │ │ +0002b570: 4445 5155 4520 310a 2365 6c73 650a 2364  DEQUE 1.#else.#d
    │ │ │ +0002b580: 6566 696e 6520 544f 5252 454e 545f 4350  efine TORRENT_CP
    │ │ │ +0002b590: 5039 385f 4445 5155 4520 300a 2365 6e64  P98_DEQUE 0.#end
    │ │ │ +0002b5a0: 6966 0a0a 6e61 6d65 7370 6163 6520 6c69  if..namespace li
    │ │ │ +0002b5b0: 6274 6f72 7265 6e74 3a3a 6175 7820 7b0a  btorrent::aux {.
    │ │ │ +0002b5c0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0002b5f0: 7374 7275 6374 2054 4f52 5245 4e54 5f45 struct TORRENT_E │ │ │ +0002b600: 5854 5241 5f45 5850 4f52 5420 6368 6169 XTRA_EXPORT chai │ │ │ +0002b610: 6e65 645f 6275 6666 6572 203a 2070 7269 ned_buffer : pri │ │ │ +0002b620: 7661 7465 2073 696e 676c 655f 7468 7265 vate single_thre │ │ │ +0002b630: 6164 6564 0a3c 2f64 6976 3e09 7b0a 0909 aded.
    .{... │ │ │ +0002b640: 6368 6169 6e65 645f 6275 6666 6572 2829 chained_buffer() │ │ │ +0002b650: 3a20 6d5f 6279 7465 7328 3029 2c20 6d5f : m_bytes(0), m_ │ │ │ +0002b660: 6361 7061 6369 7479 2830 290a 0909 7b0a capacity(0)...{. │ │ │ +0002b670: 0909 0974 6872 6561 645f 7374 6172 7465 ...thread_starte │ │ │ +0002b680: 6428 293b 0a23 6966 2054 4f52 5245 4e54 d();.#if TORRENT │ │ │ +0002b690: 5f55 5345 5f41 5353 4552 5453 0a09 0909 _USE_ASSERTS.... │ │ │ +0002b6a0: 6d5f 6465 7374 7275 6374 6564 203d 2066 m_destructed = f │ │ │ +0002b6b0: 616c 7365 3b0a 2365 6e64 6966 0a09 097d alse;.#endif...} │ │ │ +0002b6c0: 0a0a 0970 7269 7661 7465 3a0a 0a09 092f ...private:..../ │ │ │ +0002b6d0: 2f20 6465 7374 7275 6374 732f 6672 6565 / destructs/free │ │ │ +0002b6e0: 7320 7468 6520 686f 6c64 6572 206f 626a s the holder obj │ │ │ +0002b6f0: 6563 740a 0909 7573 696e 6720 6465 7374 ect...using dest │ │ │ +0002b700: 7275 6374 5f68 6f6c 6465 725f 6675 6e20 ruct_holder_fun │ │ │ +0002b710: 3d20 766f 6964 2028 2a29 2876 6f69 642a = void (*)(void* │ │ │ +0002b720: 293b 0a09 0975 7369 6e67 206d 6f76 655f );...using move_ │ │ │ +0002b730: 636f 6e73 7472 7563 745f 686f 6c64 6572 construct_holder │ │ │ +0002b740: 5f66 756e 203d 2076 6f69 6420 282a 2928 _fun = void (*)( │ │ │ +0002b750: 766f 6964 2a2c 2076 6f69 642a 293b 0a0a void*, void*);.. │ │ │ +0002b760: 0909 7374 7275 6374 2062 7566 6665 725f ..struct buffer_ │ │ │ +0002b770: 740a 0909 7b0a 0909 0962 7566 6665 725f t...{....buffer_ │ │ │ +0002b780: 7428 2920 7b7d 0a23 6966 2054 4f52 5245 t() {}.#if TORRE │ │ │ +0002b790: 4e54 5f43 5050 3938 5f44 4551 5545 0a09 NT_CPP98_DEQUE.. │ │ │ +0002b7a0: 0909 6275 6666 6572 5f74 2862 7566 6665 ..buffer_t(buffe │ │ │ +0002b7b0: 725f 7426 616d 703b 2661 6d70 3b20 7268 r_t&& rh │ │ │ +0002b7c0: 7329 206e 6f65 7863 6570 740a 0909 097b s) noexcept....{ │ │ │ +0002b7d0: 0a09 0909 0964 6573 7472 7563 745f 686f .....destruct_ho │ │ │ +0002b7e0: 6c64 6572 203d 2072 6873 2e64 6573 7472 lder = rhs.destr │ │ │ +0002b7f0: 7563 745f 686f 6c64 6572 3b0a 0909 0909 uct_holder;..... │ │ │ +0002b800: 6d6f 7665 5f68 6f6c 6465 7220 3d20 7268 move_holder = rh │ │ │ +0002b810: 732e 6d6f 7665 5f68 6f6c 6465 723b 0a09 s.move_holder;.. │ │ │ +0002b820: 0909 0962 7566 203d 2072 6873 2e62 7566 ...buf = rhs.buf │ │ │ +0002b830: 3b0a 0909 0909 7369 7a65 203d 2072 6873 ;.....size = rhs │ │ │ +0002b840: 2e73 697a 653b 0a09 0909 0975 7365 645f .size;.....used_ │ │ │ +0002b850: 7369 7a65 203d 2072 6873 2e75 7365 645f size = rhs.used_ │ │ │ +0002b860: 7369 7a65 3b0a 0909 0909 6d6f 7665 5f68 size;.....move_h │ │ │ +0002b870: 6f6c 6465 7228 2661 6d70 3b68 6f6c 6465 older(&holde │ │ │ +0002b880: 722c 2026 616d 703b 7268 732e 686f 6c64 r, &rhs.hold │ │ │ +0002b890: 6572 293b 0a09 0909 7d0a 0909 0962 7566 er);....}....buf │ │ │ +0002b8a0: 6665 725f 7426 616d 703b 206f 7065 7261 fer_t& opera │ │ │ +0002b8b0: 746f 723d 2862 7566 6665 725f 7426 616d tor=(buffer_t&am │ │ │ +0002b8c0: 703b 2661 6d70 3b20 7268 7329 2026 616d p;& rhs) &am │ │ │ +0002b8d0: 703b 206e 6f65 7863 6570 740a 0909 097b p; noexcept....{ │ │ │ +0002b8e0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0002b920: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../in │ │ │ +0002b950: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ +0002b960: 2f61 7578 5f2f 656e 756d 5f6e 6574 2e68 /aux_/enum_net.h │ │ │ +0002b970: 7070 3a31 3733 3c2f 613e 3c2f 7464 3e3c pp:173< │ │ │ +0002b980: 7464 3e74 6869 7320 636f 756c 6420 6265 td>this could be │ │ │ +0002b990: 2064 6f6e 6520 6d6f 7265 2065 6666 6963 done more effic │ │ │ +0002b9a0: 6965 6e74 6c79 2062 7920 6a75 7374 206c iently by just l │ │ │ +0002b9b0: 6f6f 6b69 6e67 2075 7020 7468 6520 696e ooking up the in │ │ │ +0002b9c0: 7465 7266 6163 6520 7769 7468 2074 6865 terface with the │ │ │ +0002b9d0: 2067 6976 656e 206e 616d 652c 206d 6179 given name, may │ │ │ +0002b9e0: 6265 2065 7665 6e20 7769 7468 2069 665f be even with if_ │ │ │ +0002b9f0: 6e61 6d65 746f 696e 6465 7828 293c 2f74 nametoindex()

    this c │ │ │ +0002ba50: 6f75 6c64 2062 6520 646f 6e65 206d 6f72 ould be done mor │ │ │ +0002ba60: 6520 6566 6669 6369 656e 746c 7920 6279 e efficiently by │ │ │ +0002ba70: 206a 7573 7420 6c6f 6f6b 696e 6720 7570 just looking up │ │ │ +0002ba80: 0a74 6865 2069 6e74 6572 6661 6365 2077 .the interface w │ │ │ +0002ba90: 6974 6820 7468 6520 6769 7665 6e20 6e61 ith the given na │ │ │ +0002baa0: 6d65 2c20 6d61 7962 6520 6576 656e 2077 me, maybe even w │ │ │ +0002bab0: 6974 6820 6966 5f6e 616d 6574 6f69 6e64 ith if_nametoind │ │ │ +0002bac0: 6578 2829 3c2f 6832 3e3c 6834 3e2e 2e2f ex()

    ../ │ │ │ +0002bad0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ +0002bae0: 6e74 2f61 7578 5f2f 656e 756d 5f6e 6574 nt/aux_/enum_net │ │ │ +0002baf0: 2e68 7070 3a31 3733 3c2f 6834 3e3c 7072 .hpp:173

    ...// IPv │ │ │ +0002bb40: 3620 6164 6472 6573 732e 2049 6620 7765 6 address. If we │ │ │ +0002bb50: 2772 6520 6173 6b69 6e67 2074 6f20 6265 're asking to be │ │ │ +0002bb60: 2062 6f75 6e64 2074 6f20 616e 2049 5076 bound to an IPv │ │ │ +0002bb70: 3620 6164 6472 6573 7320 616e 640a 0909 6 address and... │ │ │ +0002bb80: 092f 2f20 7072 6f76 6964 696e 6720 302e .// providing 0. │ │ │ +0002bb90: 302e 302e 3020 6173 2074 6865 2064 6576 0.0.0 as the dev │ │ │ +0002bba0: 6963 652c 2074 7572 6e20 6974 2069 6e74 ice, turn it int │ │ │ +0002bbb0: 6f20 223a 3a22 0a09 0909 6966 2028 6970 o "::"....if (ip │ │ │ +0002bbc0: 203d 3d20 6164 6472 6573 735f 7634 3a3a == address_v4:: │ │ │ +0002bbd0: 616e 7928 2920 2661 6d70 3b26 616d 703b any() && │ │ │ +0002bbe0: 2070 726f 746f 636f 6c20 3d3d 2062 6f6f protocol == boo │ │ │ +0002bbf0: 7374 3a3a 6173 696f 3a3a 6970 3a3a 7463 st::asio::ip::tc │ │ │ +0002bc00: 703a 3a76 3628 2929 0a09 0909 0969 7020 p::v6()).....ip │ │ │ +0002bc10: 3d20 6164 6472 6573 735f 7636 3a3a 616e = address_v6::an │ │ │ +0002bc20: 7928 293b 0a09 0909 6269 6e64 5f65 702e y();....bind_ep. │ │ │ +0002bc30: 6164 6472 6573 7328 6970 293b 0a09 0909 address(ip);.... │ │ │ +0002bc40: 2f2f 2069 7420 6170 7065 6172 7320 746f // it appears to │ │ │ +0002bc50: 2062 6520 616e 2049 502e 204a 7573 7420 be an IP. Just │ │ │ +0002bc60: 6269 6e64 2074 6f20 7468 6174 2061 6464 bind to that add │ │ │ +0002bc70: 7265 7373 0a09 0909 736f 636b 2e62 696e ress....sock.bin │ │ │ +0002bc80: 6428 6269 6e64 5f65 702c 2065 6329 3b0a d(bind_ep, ec);. │ │ │ +0002bc90: 0909 0972 6574 7572 6e20 6269 6e64 5f65 ...return bind_e │ │ │ +0002bca0: 702e 6164 6472 6573 7328 293b 0a09 097d p.address();...} │ │ │ +0002bcb0: 0a0a 0909 6563 2e63 6c65 6172 2829 3b0a ....ec.clear();. │ │ │ +0002bcc0: 0a23 6966 2054 4f52 5245 4e54 5f48 4153 .#if TORRENT_HAS │ │ │ +0002bcd0: 5f42 494e 4454 4f44 4556 4943 450a 0909 _BINDTODEVICE... │ │ │ +0002bce0: 2f2f 2074 7279 2074 6f20 7573 6520 534f // try to use SO │ │ │ +0002bcf0: 5f42 494e 4454 4f44 4556 4943 4520 6865 _BINDTODEVICE he │ │ │ +0002bd00: 7265 2c20 6966 2074 6861 7420 6578 6973 re, if that exis │ │ │ +0002bd10: 7473 2e20 4966 2069 7420 6661 696c 732c ts. If it fails, │ │ │ +0002bd20: 0a09 092f 2f20 6661 6c6c 2062 6163 6b20 ...// fall back │ │ │ +0002bd30: 746f 2074 6865 206d 6563 6861 6e69 736d to the mechanism │ │ │ +0002bd40: 2077 6520 6861 7665 2062 656c 6f77 0a09 we have below.. │ │ │ +0002bd50: 0961 7578 3a3a 6269 6e64 5f64 6576 6963 .aux::bind_devic │ │ │ +0002bd60: 6528 736f 636b 2c20 6465 7669 6365 5f6e e(sock, device_n │ │ │ +0002bd70: 616d 652c 2065 6329 3b0a 0909 6966 2028 ame, ec);...if ( │ │ │ +0002bd80: 6563 290a 2365 6e64 6966 0a09 097b 0a09 ec).#endif...{.. │ │ │ +0002bd90: 0909 6563 2e63 6c65 6172 2829 3b0a 3c64 ..ec.clear();....s │ │ │ +0002bdd0: 7464 3a3a 7665 6374 6f72 266c 743b 6970 td::vector<ip │ │ │ +0002bde0: 5f69 6e74 6572 6661 6365 2667 743b 2069 _interface> i │ │ │ +0002bdf0: 6673 203d 2065 6e75 6d5f 6e65 745f 696e fs = enum_net_in │ │ │ +0002be00: 7465 7266 6163 6573 2869 6f73 2c20 6563 terfaces(ios, ec │ │ │ +0002be10: 293b 0a3c 2f64 6976 3e09 0909 6966 2028 );.
    ...if ( │ │ │ +0002be20: 6563 2920 7265 7475 726e 2062 696e 645f ec) return bind_ │ │ │ +0002be30: 6570 2e61 6464 7265 7373 2829 3b0a 0a09 ep.address();... │ │ │ +0002be40: 0909 626f 6f6c 2066 6f75 6e64 203d 2066 ..bool found = f │ │ │ +0002be50: 616c 7365 3b0a 0a09 0909 666f 7220 2861 alse;.....for (a │ │ │ +0002be60: 7574 6f20 636f 6e73 7426 616d 703b 2069 uto const& i │ │ │ +0002be70: 6661 6365 203a 2069 6673 290a 0909 097b face : ifs)....{ │ │ │ +0002be80: 0a09 0909 092f 2f20 7765 2772 6520 6c6f .....// we're lo │ │ │ +0002be90: 6f6b 696e 6720 666f 7220 6120 7370 6563 oking for a spec │ │ │ +0002bea0: 6966 6963 2069 6e74 6572 6661 6365 2c20 ific interface, │ │ │ +0002beb0: 616e 6420 6974 7320 6164 6472 6573 730a and its address. │ │ │ +0002bec0: 0909 0909 2f2f 2028 7768 6963 6820 6d75 ....// (which mu │ │ │ +0002bed0: 7374 2062 6520 6f66 2074 6865 2073 616d st be of the sam │ │ │ +0002bee0: 6520 6661 6d69 6c79 2061 7320 7468 6520 e family as the │ │ │ +0002bef0: 6164 6472 6573 7320 7765 2772 650a 0909 address we're... │ │ │ +0002bf00: 0909 2f2f 2063 6f6e 6e65 6374 696e 6720 ..// connecting │ │ │ +0002bf10: 746f 290a 0909 0909 6966 2028 7374 643a to).....if (std: │ │ │ +0002bf20: 3a73 7472 636d 7028 6966 6163 652e 6e61 :strcmp(iface.na │ │ │ +0002bf30: 6d65 2c20 6465 7669 6365 5f6e 616d 6529 me, device_name) │ │ │ +0002bf40: 2021 3d20 3029 2063 6f6e 7469 6e75 653b != 0) continue; │ │ │ +0002bf50: 0a09 0909 0969 6620 2869 6661 6365 2e69 .....if (iface.i │ │ │ +0002bf60: 6e74 6572 6661 6365 5f61 6464 7265 7373 nterface_address │ │ │ +0002bf70: 2e69 735f 7634 2829 2021 3d20 2870 726f .is_v4() != (pro │ │ │ +0002bf80: 746f 636f 6c20 3d3d 2062 6f6f 7374 3a3a tocol == boost:: │ │ │ +0002bf90: 6173 696f 3a3a 6970 3a3a 7463 703a 3a76 asio::ip::tcp::v │ │ │ +0002bfa0: 3428 2929 290a 0909 0909 0963 6f6e 7469 4()))......conti │ │ │ +0002bfb0: 6e75 653b 0a0a 0909 0909 6269 6e64 5f65 nue;......bind_e │ │ │ +0002bfc0: 702e 6164 6472 6573 7328 6966 6163 652e p.address(iface. │ │ │ +0002bfd0: 696e 7465 7266 6163 655f 6164 6472 6573 interface_addres │ │ │ +0002bfe0: 7329 3b0a 0909 0909 666f 756e 6420 3d20 s);.....found = │ │ │ +0002bff0: 7472 7565 3b0a 0909 0909 6272 6561 6b3b true;.....break; │ │ │ +0002c000: 0a09 0909 7d0a 0a09 0909 6966 2028 2166 ....}.....if (!f │ │ │ +0002c010: 6f75 6e64 290a 0909 097b 0a09 0909 0965 ound)....{.....e │ │ │ +0002c020: 6320 3d20 6572 726f 725f 636f 6465 2862 c = error_code(b │ │ │ +0002c030: 6f6f 7374 3a3a 7379 7374 656d 3a3a 6572 oost::system::er │ │ │ +0002c040: 7263 3a3a 6e6f 5f73 7563 685f 6465 7669 rc::no_such_devi │ │ │ +0002c050: 6365 2c20 6765 6e65 7269 635f 6361 7465 ce, generic_cate │ │ │ +0002c060: 676f 7279 2829 293b 0a09 0909 0972 6574 gory());.....ret │ │ │ +0002c070: 7572 6e20 6269 6e64 5f65 702e 6164 6472 urn bind_ep.addr │ │ │ +0002c080: 6573 7328 293b 0a09 0909 7d0a 0909 7d0a ess();....}...}. │ │ │ +0002c090: 0909 736f 636b 2e62 696e 6428 6269 6e64 ..sock.bind(bind │ │ │ +0002c0a0: 5f65 702c 2065 6329 3b0a 0909 7265 7475 _ep, ec);...retu │ │ │ +0002c0b0: 726e 2062 696e 645f 6570 2e61 6464 7265 rn bind_ep.addre │ │ │ +0002c0c0: 7373 2829 3b0a 097d 0a0a 092f 2f20 7265 ss();..}...// re │ │ │ +0002c0d0: 7475 726e 7320 7468 6520 6465 7669 6365 turns the device │ │ │ +0002c0e0: 206e 616d 6520 7768 6f73 6520 6c6f 6361 name whose loca │ │ │ +0002c0f0: 6c20 6164 6472 6573 7320 6973 2060 6061 l address is ``a │ │ │ +0002c100: 6464 7260 602e 2049 660a 092f 2f20 6e6f ddr``. If..// no │ │ │ +0002c110: 2073 7563 6820 6465 7669 6365 2069 7320 such device is │ │ │ +0002c120: 666f 756e 642c 2061 6e20 656d 7074 7920 found, an empty │ │ │ +0002c130: 7374 7269 6e67 2069 7320 7265 7475 726e string is return │ │ │ +0002c140: 6564 2e0a 3c2f 7072 653e 3c2f 7464 3e3c ed..< │ │ │ 0002c150: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ 0002c180: 6273 703b 313c 2f74 643e 3c74 643e 3c61 bsp;1.. │ │ │ 0002c1b0: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ @@ -11844,22375 +11844,22375 @@ │ │ │ 0002e430: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ 0002e460: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ 0002e470: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../test/test │ │ │ -0002e4a0: 5f64 6874 2e63 7070 3a34 3637 3c2f 613e _dht.cpp:467 │ │ │ -0002e4b0: 3c2f 7464 3e3c 7464 3e63 6865 636b 2074 check t │ │ │ -0002e4c0: 6f20 6d61 6b65 2073 7572 6520 7468 6520 o make sure the │ │ │ -0002e4d0: 2262 6573 7422 2069 7465 6d73 2061 7265 "best" items are │ │ │ -0002e4e0: 2073 746f 7265 643c 2f74 643e 3c2f 7472 stored │ │ │ -0002e520: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0002e530: 3c68 323e 6368 6563 6b20 746f 206d 616b

    check to mak │ │ │ -0002e540: 6520 7375 7265 2074 6865 2022 6265 7374 e sure the "best │ │ │ -0002e550: 2220 6974 656d 7320 6172 6520 7374 6f72 " items are stor │ │ │ -0002e560: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ed

    ../te │ │ │ -0002e570: 7374 2f74 6573 745f 6468 742e 6370 703a st/test_dht.cpp: │ │ │ -0002e580: 3436 373c 2f68 343e 3c70 7265 2073 7479 467

    ..., msg_args(
    │ │ │ -0002e5d0: 292e 7461 7267 6574 2869 7465 6d73 5b6a  ).target(items[j
    │ │ │ -0002e5e0: 5d2e 7461 7267 6574 2929 3b0a 0a09 096b  ].target));....k
    │ │ │ -0002e5f0: 6579 5f64 6573 635f 7420 636f 6e73 7420  ey_desc_t const 
    │ │ │ -0002e600: 6465 7363 5b5d 203d 0a09 097b 0a09 0909  desc[] =...{....
    │ │ │ -0002e610: 7b20 2272 222c 2062 6465 636f 6465 5f6e  { "r", bdecode_n
    │ │ │ -0002e620: 6f64 653a 3a64 6963 745f 742c 2030 2c20  ode::dict_t, 0, 
    │ │ │ -0002e630: 6b65 795f 6465 7363 5f74 3a3a 7061 7273  key_desc_t::pars
    │ │ │ -0002e640: 655f 6368 696c 6472 656e 207d 2c0a 0909  e_children },...
    │ │ │ -0002e650: 0909 7b20 2276 222c 2062 6465 636f 6465  ..{ "v", bdecode
    │ │ │ -0002e660: 5f6e 6f64 653a 3a64 6963 745f 742c 2030  _node::dict_t, 0
    │ │ │ -0002e670: 2c20 307d 2c0a 0909 0909 7b20 2269 6422  , 0},.....{ "id"
    │ │ │ -0002e680: 2c20 6264 6563 6f64 655f 6e6f 6465 3a3a  , bdecode_node::
    │ │ │ -0002e690: 7374 7269 6e67 5f74 2c20 3230 2c20 6b65  string_t, 20, ke
    │ │ │ -0002e6a0: 795f 6465 7363 5f74 3a3a 6c61 7374 5f63  y_desc_t::last_c
    │ │ │ -0002e6b0: 6869 6c64 7d2c 0a09 0909 7b20 2279 222c  hild},....{ "y",
    │ │ │ -0002e6c0: 2062 6465 636f 6465 5f6e 6f64 653a 3a73   bdecode_node::s
    │ │ │ -0002e6d0: 7472 696e 675f 742c 2031 2c20 307d 2c0a  tring_t, 1, 0},.
    │ │ │ -0002e6e0: 0909 7d3b 0a0a 0909 6264 6563 6f64 655f  ..};....bdecode_
    │ │ │ -0002e6f0: 6e6f 6465 2070 6172 7365 645b 345d 3b0a  node parsed[4];.
    │ │ │ -0002e700: 0909 6368 6172 2065 7272 6f72 5f73 7472  ..char error_str
    │ │ │ -0002e710: 696e 675b 3230 305d 3b0a 0a09 0969 6e74  ing[200];....int
    │ │ │ -0002e720: 2072 6574 203d 2076 6572 6966 795f 6d65   ret = verify_me
    │ │ │ -0002e730: 7373 6167 6528 7265 7370 6f6e 7365 2c20  ssage(response, 
    │ │ │ -0002e740: 6465 7363 2c20 7061 7273 6564 2c20 6572  desc, parsed, er
    │ │ │ -0002e750: 726f 725f 7374 7269 6e67 293b 0a09 0969  ror_string);...i
    │ │ │ -0002e760: 6620 2872 6574 290a 0909 7b0a 0909 0969  f (ret)...{....i
    │ │ │ -0002e770: 7465 6d73 5f6e 756d 2e69 6e73 6572 7428  tems_num.insert(
    │ │ │ -0002e780: 6974 656d 735f 6e75 6d2e 6265 6769 6e28  items_num.begin(
    │ │ │ -0002e790: 292c 206a 293b 0a09 097d 0a09 7d0a 0a3c  ), j);...}..}..<
    │ │ │ -0002e7a0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0002e7b0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0002e7c0: 7769 6474 683d 2231 3030 2522 3e09 5445  width="100%">.TE
    │ │ │ -0002e7d0: 5354 5f45 5155 414c 2869 7465 6d73 5f6e  ST_EQUAL(items_n
    │ │ │ -0002e7e0: 756d 2e73 697a 6528 292c 2034 293b 0a3c  um.size(), 4);.<
    │ │ │ -0002e7f0: 2f64 6976 3e7d 0a0a 696e 7420 7375 6d5f  /div>}..int sum_
    │ │ │ -0002e800: 6469 7374 616e 6365 5f65 7870 2869 6e74  distance_exp(int
    │ │ │ -0002e810: 2073 2c20 6e6f 6465 5f65 6e74 7279 2063   s, node_entry c
    │ │ │ -0002e820: 6f6e 7374 2661 6d70 3b20 652c 206e 6f64  onst& e, nod
    │ │ │ -0002e830: 655f 6964 2063 6f6e 7374 2661 6d70 3b20  e_id const& 
    │ │ │ -0002e840: 7265 6629 0a7b 0a09 7265 7475 726e 2073  ref).{..return s
    │ │ │ -0002e850: 202b 2064 6973 7461 6e63 655f 6578 7028   + distance_exp(
    │ │ │ -0002e860: 652e 6964 2c20 7265 6629 3b0a 7d0a 0a73  e.id, ref);.}..s
    │ │ │ -0002e870: 7464 3a3a 7665 6374 6f72 266c 743b 7463  td::vector<tc
    │ │ │ -0002e880: 703a 3a65 6e64 706f 696e 7426 6774 3b20  p::endpoint> 
    │ │ │ -0002e890: 675f 676f 745f 7065 6572 733b 0a0a 766f  g_got_peers;..vo
    │ │ │ -0002e8a0: 6964 2067 6574 5f70 6565 7273 5f63 6228  id get_peers_cb(
    │ │ │ -0002e8b0: 7374 643a 3a76 6563 746f 7226 6c74 3b74  std::vector<t
    │ │ │ -0002e8c0: 6370 3a3a 656e 6470 6f69 6e74 2667 743b  cp::endpoint>
    │ │ │ -0002e8d0: 2063 6f6e 7374 2661 6d70 3b20 7065 6572   const& peer
    │ │ │ -0002e8e0: 7329 0a7b 0a09 675f 676f 745f 7065 6572  s).{..g_got_peer
    │ │ │ -0002e8f0: 732e 696e 7365 7274 2867 5f67 6f74 5f70  s.insert(g_got_p
    │ │ │ -0002e900: 6565 7273 2e65 6e64 2829 2c20 7065 6572  eers.end(), peer
    │ │ │ -0002e910: 732e 6265 6769 6e28 292c 2070 6565 7273  s.begin(), peers
    │ │ │ -0002e920: 2e65 6e64 2829 293b 0a7d 0a0a 7374 643a  .end());.}..std:
    │ │ │ -0002e930: 3a76 6563 746f 7226 6c74 3b64 6874 3a3a  :vector<dht::
    │ │ │ -0002e940: 6974 656d 2667 743b 2067 5f67 6f74 5f69  item> g_got_i
    │ │ │ -0002e950: 7465 6d73 3b0a 6468 743a 3a69 7465 6d20  tems;.dht::item 
    │ │ │ -0002e960: 675f 7075 745f 6974 656d 3b0a 696e 7420  g_put_item;.int 
    │ │ │ -0002e970: 675f 7075 745f 636f 756e 743b 0a0a 766f  g_put_count;..vo
    │ │ │ -0002e980: 6964 2067 6574 5f6d 7574 6162 6c65 5f69  id get_mutable_i
    │ │ │ -0002e990: 7465 6d5f 6362 2864 6874 3a3a 6974 656d  tem_cb(dht::item
    │ │ │ -0002e9a0: 2063 6f6e 7374 2661 6d70 3b20 692c 2062   const& i, b
    │ │ │ -0002e9b0: 6f6f 6c20 6129 0a7b 0a09 6966 2028 2161  ool a).{..if (!a
    │ │ │ -0002e9c0: 2920 7265 7475 726e 3b0a 0969 6620 2821  ) return;..if (!
    │ │ │ -0002e9d0: 692e 656d 7074 7928 2929 0a09 0967 5f67  i.empty())...g_g
    │ │ │ -0002e9e0: 6f74 5f69 7465 6d73 2e70 7573 685f 6261  ot_items.push_ba
    │ │ │ -0002e9f0: 636b 2869 293b 0a7d 0a0a 766f 6964 2070  ck(i);.}..void p
    │ │ │ -0002ea00: 7574 5f6d 7574 6162 6c65 5f69 7465 6d5f  ut_mutable_item_
    │ │ │ -0002ea10: 6461 7461 5f63 6228 6468 743a 3a69 7465  data_cb(dht::ite
    │ │ │ -0002ea20: 6d26 616d 703b 2069 290a 7b0a 0969 6620  m& i).{..if 
    │ │ │ -0002ea30: 2821 692e 656d 7074 7928 2929 0a09 0967  (!i.empty())...g
    │ │ │ -0002ea40: 5f67 6f74 5f69 7465 6d73 2e70 7573 685f  _got_items.push_
    │ │ │ -0002ea50: 6261 636b 2869 293b 0a0a 3c2f 7072 653e  back(i);..
    │ │ │ -0002ea60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0002ea90: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0002eaa0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../test/test │ │ │ -0002ead0: 5f64 6874 2e63 7070 3a33 3231 383c 2f61 _dht.cpp:3218this w │ │ │ -0002eaf0: 6f6e 2774 2077 6f72 6b20 6265 6361 7573 on't work becaus │ │ │ -0002eb00: 6520 7468 6520 7365 636f 6e64 206e 6f64 e the second nod │ │ │ -0002eb10: 6520 6973 6e27 7420 7069 6e67 6564 2073 e isn't pinged s │ │ │ -0002eb20: 6f20 6974 2077 6f6e 7420 6265 2061 6464 o it wont be add │ │ │ -0002eb30: 6564 2074 6f20 7468 6520 726f 7574 696e ed to the routin │ │ │ -0002eb40: 6720 7461 626c 653c 2f74 643e 3c2f 7472 g table │ │ │ -0002eb80: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0002eb90: 3c68 323e 7468 6973 2077 6f6e 2774 2077

    this won't w │ │ │ -0002eba0: 6f72 6b20 6265 6361 7573 6520 7468 6520 ork because the │ │ │ -0002ebb0: 7365 636f 6e64 206e 6f64 6520 6973 6e27 second node isn' │ │ │ -0002ebc0: 7420 7069 6e67 6564 2073 6f20 6974 2077 t pinged so it w │ │ │ -0002ebd0: 6f6e 740a 6265 2061 6464 6564 2074 6f20 ont.be added to │ │ │ -0002ebe0: 7468 6520 726f 7574 696e 6720 7461 626c the routing tabl │ │ │ -0002ebf0: 653c 2f68 323e 3c68 343e 2e2e 2f74 6573 e

    ../tes │ │ │ -0002ec00: 742f 7465 7374 5f64 6874 2e63 7070 3a33 t/test_dht.cpp:3 │ │ │ -0002ec10: 3231 383c 2f68 343e 3c70 7265 2073 7479 218

    .bool ret = ve
    │ │ │ -0002ec60: 7269 6679 5f6d 6573 7361 6765 2872 6571  rify_message(req
    │ │ │ -0002ec70: 7565 7374 2c20 6765 745f 6974 656d 5f64  uest, get_item_d
    │ │ │ -0002ec80: 6573 635f 726f 2c20 7061 7273 6564 2c20  esc_ro, parsed, 
    │ │ │ -0002ec90: 6572 726f 725f 7374 7269 6e67 293b 0a0a  error_string);..
    │ │ │ -0002eca0: 0954 4553 545f 4348 4543 4b28 7265 7429  .TEST_CHECK(ret)
    │ │ │ -0002ecb0: 3b0a 0954 4553 545f 4551 5541 4c28 7061  ;..TEST_EQUAL(pa
    │ │ │ -0002ecc0: 7273 6564 5b33 5d2e 696e 745f 7661 6c75  rsed[3].int_valu
    │ │ │ -0002ecd0: 6528 292c 2031 293b 0a0a 092f 2f20 7368  e(), 1);...// sh
    │ │ │ -0002ece0: 6f75 6c64 2068 6176 6520 6f6e 6520 6e6f  ould have one no
    │ │ │ -0002ecf0: 6465 206e 6f77 2c20 7768 6963 6820 6973  de now, which is
    │ │ │ -0002ed00: 2034 2e34 2e34 2e34 3a31 3233 340a 0954   4.4.4.4:1234..T
    │ │ │ -0002ed10: 4553 545f 4551 5541 4c28 7374 643a 3a67  EST_EQUAL(std::g
    │ │ │ -0002ed20: 6574 266c 743b 3026 6774 3b28 6e6f 6465  et<0>(node
    │ │ │ -0002ed30: 2e73 697a 6528 2929 2c20 3129 3b0a 092f  .size()), 1);../
    │ │ │ -0002ed40: 2f20 616e 6420 6e6f 2072 6570 6c61 6365  / and no replace
    │ │ │ -0002ed50: 6d65 6e74 206e 6f64 6573 0a09 5445 5354  ment nodes..TEST
    │ │ │ -0002ed60: 5f45 5155 414c 2873 7464 3a3a 6765 7426  _EQUAL(std::get&
    │ │ │ -0002ed70: 6c74 3b31 2667 743b 286e 6f64 652e 7369  lt;1>(node.si
    │ │ │ -0002ed80: 7a65 2829 292c 2030 293b 0a0a 092f 2f20  ze()), 0);...// 
    │ │ │ -0002ed90: 6e6f 772c 2064 6973 6162 6c65 2072 6561  now, disable rea
    │ │ │ -0002eda0: 645f 6f6e 6c79 2c20 7472 7920 6167 6169  d_only, try agai
    │ │ │ -0002edb0: 6e2e 0a09 675f 7365 6e74 5f70 6163 6b65  n...g_sent_packe
    │ │ │ -0002edc0: 7473 2e63 6c65 6172 2829 3b0a 0973 6574  ts.clear();..set
    │ │ │ -0002edd0: 742e 7365 745f 626f 6f6c 2873 6574 7469  t.set_bool(setti
    │ │ │ -0002ede0: 6e67 735f 7061 636b 3a3a 6468 745f 7265  ngs_pack::dht_re
    │ │ │ -0002edf0: 6164 5f6f 6e6c 792c 2066 616c 7365 293b  ad_only, false);
    │ │ │ -0002ee00: 0a0a 0973 656e 645f 6468 745f 7265 7175  ...send_dht_requ
    │ │ │ -0002ee10: 6573 7428 6e6f 6465 2c20 2267 6574 222c  est(node, "get",
    │ │ │ -0002ee20: 2073 6f75 7263 652c 2026 616d 703b 7265   source, &re
    │ │ │ -0002ee30: 7370 6f6e 7365 293b 0a09 2f2f 2073 656e  sponse);..// sen
    │ │ │ -0002ee40: 6465 7220 7368 6f75 6c64 2062 6520 6164  der should be ad
    │ │ │ -0002ee50: 6465 6420 746f 2072 6570 6c61 6365 6d65  ded to replaceme
    │ │ │ -0002ee60: 6e74 2062 7563 6b65 740a 0954 4553 545f  nt bucket..TEST_
    │ │ │ -0002ee70: 4551 5541 4c28 7374 643a 3a67 6574 266c  EQUAL(std::get&l
    │ │ │ -0002ee80: 743b 3126 6774 3b28 6e6f 6465 2e73 697a  t;1>(node.siz
    │ │ │ -0002ee90: 6528 2929 2c20 3129 3b0a 0a09 675f 7365  e()), 1);...g_se
    │ │ │ -0002eea0: 6e74 5f70 6163 6b65 7473 2e63 6c65 6172  nt_packets.clear
    │ │ │ -0002eeb0: 2829 3b0a 2369 6620 300a 3c64 6976 2073  ();.#if 0.
    .target │ │ │ -0002eef0: 3d20 6765 6e65 7261 7465 5f6e 6578 7428 = generate_next( │ │ │ -0002ef00: 293b 0a3c 2f64 6976 3e09 6e6f 6465 2e67 );.
    .node.g │ │ │ -0002ef10: 6574 5f69 7465 6d28 7461 7267 6574 2c20 et_item(target, │ │ │ -0002ef20: 6765 745f 696d 6d75 7461 626c 655f 6974 get_immutable_it │ │ │ -0002ef30: 656d 5f63 6229 3b0a 0a09 2f2f 2073 696e em_cb);...// sin │ │ │ -0002ef40: 6365 2077 6520 6861 7665 2032 206e 6f64 ce we have 2 nod │ │ │ -0002ef50: 6573 2c20 7765 2073 686f 756c 6420 6861 es, we should ha │ │ │ -0002ef60: 7665 2074 776f 2070 6163 6b65 7473 2e0a ve two packets.. │ │ │ -0002ef70: 0954 4553 545f 4551 5541 4c28 675f 7365 .TEST_EQUAL(g_se │ │ │ -0002ef80: 6e74 5f70 6163 6b65 7473 2e73 697a 6528 nt_packets.size( │ │ │ -0002ef90: 292c 2032 293b 0a0a 092f 2f20 626f 7468 ), 2);...// both │ │ │ -0002efa0: 206f 6620 7468 656d 2073 686f 756c 646e of them shouldn │ │ │ -0002efb0: 2774 2068 6176 6520 6120 2772 6f27 206b 't have a 'ro' k │ │ │ -0002efc0: 6579 2e0a 096e 6f64 655f 6672 6f6d 5f65 ey...node_from_e │ │ │ -0002efd0: 6e74 7279 2867 5f73 656e 745f 7061 636b ntry(g_sent_pack │ │ │ -0002efe0: 6574 732e 6672 6f6e 7428 292e 7365 636f ets.front().seco │ │ │ -0002eff0: 6e64 2c20 7265 7175 6573 7429 3b0a 0972 nd, request);..r │ │ │ -0002f000: 6574 203d 2076 6572 6966 795f 6d65 7373 et = verify_mess │ │ │ -0002f010: 6167 6528 7265 7175 6573 742c 2067 6574 age(request, get │ │ │ -0002f020: 5f69 7465 6d5f 6465 7363 5f72 6f2c 2070 _item_desc_ro, p │ │ │ -0002f030: 6172 7365 642c 2065 7272 6f72 5f73 7472 arsed, error_str │ │ │ -0002f040: 696e 6729 3b0a 0a09 5445 5354 5f43 4845 ing);...TEST_CHE │ │ │ -0002f050: 434b 2872 6574 293b 0a09 5445 5354 5f43 CK(ret);..TEST_C │ │ │ -0002f060: 4845 434b 2821 7061 7273 6564 5b33 5d29 HECK(!parsed[3]) │ │ │ -0002f070: 3b0a 0a09 6e6f 6465 5f66 726f 6d5f 656e ;...node_from_en │ │ │ -0002f080: 7472 7928 675f 7365 6e74 5f70 6163 6b65 try(g_sent_packe │ │ │ -0002f090: 7473 2e62 6163 6b28 292e 7365 636f 6e64 ts.back().second │ │ │ -0002f0a0: 2c20 7265 7175 6573 7429 3b0a 0972 6574 , request);..ret │ │ │ -0002f0b0: 203d 2076 6572 6966 795f 6d65 7373 6167 = verify_messag │ │ │ -0002f0c0: 6528 7265 7175 6573 742c 2067 6574 5f69 e(request, get_i │ │ │ -0002f0d0: 7465 6d5f 6465 7363 5f72 6f2c 2070 6172 tem_desc_ro, par │ │ │ -0002f0e0: 7365 642c 2065 7272 6f72 5f73 7472 696e sed, error_strin │ │ │ -0002f0f0: 6729 3b0a 0a09 5445 5354 5f43 4845 434b g);...TEST_CHECK │ │ │ -0002f100: 2872 6574 293b 0a09 5445 5354 5f43 4845 (ret);..TEST_CHE │ │ │ -0002f110: 434b 2821 7061 7273 6564 5b33 5d29 3b0a CK(!parsed[3]);. │ │ │ -0002f120: 2365 6e64 6966 0a7d 0a0a 544f 5252 454e #endif.}..TORREN │ │ │ -0002f130: 545f 5445 5354 2872 7063 5f72 6570 6c79 T_TEST(rpc_reply │ │ │ -0002f140: 5f69 676e 6f72 6573 5f77 726f 6e67 5f70 _ignores_wrong_p │ │ │ -0002f150: 6f72 7429 0a7b 0a09 6175 746f 2073 6574 ort).{..auto set │ │ │ -0002f160: 7420 3d20 7465 7374 5f73 6574 7469 6e67 t = test_setting │ │ │ -0002f170: 7328 293b 0a09 6d6f 636b 5f73 6f63 6b65 s();..mock_socke │ │ │ -0002f180: 7420 733b 0a09 6175 746f 206c 7320 3d20 t s;..auto ls = │ │ │ -0002f190: 6475 6d6d 795f 6c69 7374 656e 5f73 6f63 dummy_listen_soc │ │ │ -0002f1a0: 6b65 7434 2829 3b0a 096f 6273 206f 6273 ket4();..obs obs │ │ │ -0002f1b0: 6572 7665 723b 0a09 636f 756e 7465 7273 erver;..counters │ │ │ -0002f1c0: 2063 6e74 3b0a 0a09 6468 743a 3a72 6f75 cnt;...dht::rou │ │ │ -0002f1d0: 7469 6e67 5f74 6162 6c65 2074 6162 6c65 ting_table table │ │ │ -0002f1e0: 286e 6f64 655f 6964 2829 2c20 7564 703a (node_id(), udp: │ │ │ -0002f1f0: 3a76 3428 292c 2038 2c20 7365 7474 2c20 :v4(), 8, sett, │ │ │ -0002f200: 2661 6d70 3b6f 6273 6572 7665 7229 3b0a &observer);. │ │ │ -0002f210: 0964 6874 3a3a 7270 635f 6d61 6e61 6765 .dht::rpc_manage │ │ │ -0002f220: 7220 7270 6328 6e6f 6465 5f69 6428 292c r rpc(node_id(), │ │ │ -0002f230: 2073 6574 742c 2074 6162 6c65 2c20 6c73 sett, table, ls │ │ │ -0002f240: 2c20 2661 6d70 3b73 2c20 2661 6d70 3b6f , &s, &o │ │ │ -0002f250: 6273 6572 7665 7229 3b0a 3c2f 7072 653e bserver);.
    │ │ │ -0002f260: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0002f290: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0002f2a0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../test/test │ │ │ -0002f2d0: 5f64 6874 2e63 7070 3a34 3132 383c 2f61 _dht.cpp:4128test o │ │ │ -0002f2f0: 6266 7573 6361 7465 645f 6765 745f 7065 bfuscated_get_pe │ │ │ -0002f300: 6572 733c 2f74 643e 3c2f 7472 3e3c 7472 ers

    │ │ │ -0002f350: 7465 7374 206f 6266 7573 6361 7465 645f test obfuscated_ │ │ │ -0002f360: 6765 745f 7065 6572 733c 2f68 323e 3c68 get_peers

    ../test/test_d │ │ │ -0002f380: 6874 2e63 7070 3a34 3132 383c 2f68 343e ht.cpp:4128 │ │ │ -0002f390: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..TEST
    │ │ │ -0002f3d0: 5f43 4845 434b 2873 6d2e 6861 735f 7175  _CHECK(sm.has_qu
    │ │ │ -0002f3e0: 6f74 6128 2929 3b0a 097d 293b 0a7d 0a0a  ota());..});.}..
    │ │ │ -0002f3f0: 544f 5252 454e 545f 5445 5354 2872 6174  TORRENT_TEST(rat
    │ │ │ -0002f400: 655f 6c69 6d69 745f 6163 6372 7565 5f6c  e_limit_accrue_l
    │ │ │ -0002f410: 696d 6974 290a 7b0a 0961 7578 3a3a 7365  imit).{..aux::se
    │ │ │ -0002f420: 7373 696f 6e5f 7365 7474 696e 6773 2073  ssion_settings s
    │ │ │ -0002f430: 6574 743b 0a09 7365 7474 2e73 6574 5f69  ett;..sett.set_i
    │ │ │ -0002f440: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ -0002f450: 3a3a 6468 745f 7570 6c6f 6164 5f72 6174  ::dht_upload_rat
    │ │ │ -0002f460: 655f 6c69 6d69 742c 2073 7464 3a3a 6e75  e_limit, std::nu
    │ │ │ -0002f470: 6d65 7269 635f 6c69 6d69 7473 266c 743b  meric_limits<
    │ │ │ -0002f480: 696e 7426 6774 3b3a 3a6d 6178 2829 293b  int>::max());
    │ │ │ -0002f490: 0a0a 0974 6573 745f 7261 7465 5f6c 696d  ...test_rate_lim
    │ │ │ -0002f4a0: 6974 2873 6574 742c 205b 5d28 6c74 3a3a  it(sett, [](lt::
    │ │ │ -0002f4b0: 6468 743a 3a73 6f63 6b65 745f 6d61 6e61  dht::socket_mana
    │ │ │ -0002f4c0: 6765 7226 616d 703b 2073 6d29 207b 0a09  ger& sm) {..
    │ │ │ -0002f4d0: 0954 4553 545f 4348 4543 4b28 736d 2e68  .TEST_CHECK(sm.h
    │ │ │ -0002f4e0: 6173 5f71 756f 7461 2829 293b 0a09 0966  as_quota());...f
    │ │ │ -0002f4f0: 6f72 2028 696e 7420 6920 3d20 303b 2069  or (int i = 0; i
    │ │ │ -0002f500: 2026 6c74 3b20 3130 3b20 2b2b 6929 0a09   < 10; ++i)..
    │ │ │ -0002f510: 097b 0a09 0909 7374 643a 3a74 6869 735f  .{....std::this_
    │ │ │ -0002f520: 7468 7265 6164 3a3a 736c 6565 705f 666f  thread::sleep_fo
    │ │ │ -0002f530: 7228 6d69 6c6c 6973 6563 6f6e 6473 2835  r(milliseconds(5
    │ │ │ -0002f540: 3030 2929 3b0a 0909 0954 4553 545f 4348  00));....TEST_CH
    │ │ │ -0002f550: 4543 4b28 736d 2e68 6173 5f71 756f 7461  ECK(sm.has_quota
    │ │ │ -0002f560: 2829 293b 0a09 097d 0a09 7d29 3b0a 7d0a  ());...}..});.}.
    │ │ │ -0002f570: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0002f5a0: 0a3c 2f64 6976 3e23 656c 7365 0a54 4f52 .
    #else.TOR │ │ │ -0002f5b0: 5245 4e54 5f54 4553 5428 6468 7429 0a7b RENT_TEST(dht).{ │ │ │ -0002f5c0: 0a09 2f2f 2064 756d 6d79 2064 6874 2074 ..// dummy dht t │ │ │ -0002f5d0: 6573 740a 0954 4553 545f 4348 4543 4b28 est..TEST_CHECK( │ │ │ -0002f5e0: 7472 7565 293b 0a7d 0a0a 2365 6e64 6966 true);.}..#endif │ │ │ -0002f5f0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0002f630: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../te │ │ │ -0002f660: 7374 2f74 6573 745f 7472 6163 6b65 722e st/test_tracker. │ │ │ -0002f670: 6370 703a 3431 3c2f 613e 3c2f 7464 3e3c cpp:41< │ │ │ -0002f680: 7464 3e74 6573 7420 7363 7261 7065 2072 td>test scrape r │ │ │ -0002f690: 6571 7565 7374 733c 2f74 643e 3c2f 7472 equests │ │ │ -0002f6d0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0002f6e0: 3c68 323e 7465 7374 2073 6372 6170 6520

    test scrape │ │ │ -0002f6f0: 7265 7175 6573 7473 3c2f 6832 3e3c 6834 requests

    ../test/test_tr │ │ │ -0002f710: 6163 6b65 722e 6370 703a 3431 3c2f 6834 acker.cpp:41

    rele
    │ │ │ -0002f790: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/tes
    │ │ │ -0002f7d0: 745f 7472 6163 6b65 722e 6370 703a 3432  t_tracker.cpp:42
    │ │ │ -0002f7e0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573  tes
    │ │ │ -0002f7f0: 7420 7061 7273 6520 7472 6163 6b65 722d  t parse tracker-
    │ │ │ -0002f800: 6964 3c2f 7464 3e3c 2f74 723e 3c74 7220  id

    t │ │ │ -0002f850: 6573 7420 7061 7273 6520 7472 6163 6b65 est parse tracke │ │ │ -0002f860: 722d 6964 3c2f 6832 3e3c 6834 3e2e 2e2f r-id

    ../ │ │ │ -0002f870: 7465 7374 2f74 6573 745f 7472 6163 6b65 test/test_tracke │ │ │ -0002f880: 722e 6370 703a 3432 3c2f 6834 3e3c 7072 r.cpp:42

    relevanc │ │ │ -0002f900: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_tr │ │ │ -0002f940: 6163 6b65 722e 6370 703a 3433 3c2f 613e acker.cpp:43 │ │ │ -0002f950: 3c2f 7464 3e3c 7464 3e74 6573 7420 7061 test pa │ │ │ -0002f960: 7273 6520 6661 696c 7572 652d 7265 6173 rse failure-reas │ │ │ -0002f970: 6f6e 3c2f 7464 3e3c 2f74 723e 3c74 7220 on

    t │ │ │ -0002f9c0: 6573 7420 7061 7273 6520 6661 696c 7572 est parse failur │ │ │ -0002f9d0: 652d 7265 6173 6f6e 3c2f 6832 3e3c 6834 e-reason

    ../test/test_tr │ │ │ -0002f9f0: 6163 6b65 722e 6370 703a 3433 3c2f 6834 acker.cpp:43

    rele
    │ │ │ -0002fa70: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/tes
    │ │ │ -0002fab0: 745f 7472 6163 6b65 722e 6370 703a 3434  t_tracker.cpp:44
    │ │ │ -0002fac0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573  tes
    │ │ │ -0002fad0: 7420 616c 6c20 6661 696c 7572 6520 7061  t all failure pa
    │ │ │ -0002fae0: 7468 732c 2069 6e63 6c75 6469 6e67 2069  ths, including i
    │ │ │ -0002faf0: 6e76 616c 6964 2062 656e 636f 6469 6e67  nvalid bencoding
    │ │ │ -0002fb00: 206e 6f74 2061 2064 6963 7469 6f6e 6172   not a dictionar
    │ │ │ -0002fb10: 7920 6e6f 2066 696c 6573 2065 6e74 7279  y no files entry
    │ │ │ -0002fb20: 2069 6e20 7363 7261 7065 2072 6573 706f   in scrape respo
    │ │ │ -0002fb30: 6e73 6520 6e6f 2069 6e66 6f2d 6861 7368  nse no info-hash
    │ │ │ -0002fb40: 2065 6e74 7279 2069 6e20 7363 7261 7065   entry in scrape
    │ │ │ -0002fb50: 2072 6573 706f 6e73 6520 6d61 6c66 6f72   response malfor
    │ │ │ -0002fb60: 6d65 6420 7065 6572 7320 696e 2070 6565  med peers in pee
    │ │ │ -0002fb70: 7220 6c69 7374 206f 6620 6469 6374 696f  r list of dictio
    │ │ │ -0002fb80: 6e61 7269 6573 2075 6e65 7665 6e20 6e75  naries uneven nu
    │ │ │ -0002fb90: 6d62 6572 206f 6620 6279 7465 7320 696e  mber of bytes in
    │ │ │ -0002fba0: 2070 6565 7273 2061 6e64 2070 6565 7273   peers and peers
    │ │ │ -0002fbb0: 3620 7374 7269 6e67 2072 6573 706f 6e73  6 string respons
    │ │ │ -0002fbc0: 6573 3c2f 7464 3e3c 2f74 723e 3c74 7220  es

    t │ │ │ -0002fc10: 6573 7420 616c 6c20 6661 696c 7572 6520 est all failure │ │ │ -0002fc20: 7061 7468 732c 2069 6e63 6c75 6469 6e67 paths, including │ │ │ -0002fc30: 0a69 6e76 616c 6964 2062 656e 636f 6469 .invalid bencodi │ │ │ -0002fc40: 6e67 0a6e 6f74 2061 2064 6963 7469 6f6e ng.not a diction │ │ │ -0002fc50: 6172 790a 6e6f 2066 696c 6573 2065 6e74 ary.no files ent │ │ │ -0002fc60: 7279 2069 6e20 7363 7261 7065 2072 6573 ry in scrape res │ │ │ -0002fc70: 706f 6e73 650a 6e6f 2069 6e66 6f2d 6861 ponse.no info-ha │ │ │ -0002fc80: 7368 2065 6e74 7279 2069 6e20 7363 7261 sh entry in scra │ │ │ -0002fc90: 7065 2072 6573 706f 6e73 650a 6d61 6c66 pe response.malf │ │ │ -0002fca0: 6f72 6d65 6420 7065 6572 7320 696e 2070 ormed peers in p │ │ │ -0002fcb0: 6565 7220 6c69 7374 206f 6620 6469 6374 eer list of dict │ │ │ -0002fcc0: 696f 6e61 7269 6573 0a75 6e65 7665 6e20 ionaries.uneven │ │ │ -0002fcd0: 6e75 6d62 6572 206f 6620 6279 7465 7320 number of bytes │ │ │ -0002fce0: 696e 2070 6565 7273 2061 6e64 2070 6565 in peers and pee │ │ │ -0002fcf0: 7273 3620 7374 7269 6e67 2072 6573 706f rs6 string respo │ │ │ -0002fd00: 6e73 6573 3c2f 6832 3e3c 6834 3e2e 2e2f nses

    ../ │ │ │ -0002fd10: 7465 7374 2f74 6573 745f 7472 6163 6b65 test/test_tracke │ │ │ -0002fd20: 722e 6370 703a 3434 3c2f 6834 3e3c 7072 r.cpp:44

    #include │ │ │ -0002fd70: 2274 6573 745f 7574 696c 732e 6870 7022 "test_utils.hpp" │ │ │ -0002fd80: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ -0002fd90: 7272 656e 742f 616c 6572 742e 6870 7022 rrent/alert.hpp" │ │ │ -0002fda0: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ -0002fdb0: 7272 656e 742f 7065 6572 5f69 6e66 6f2e rrent/peer_info. │ │ │ -0002fdc0: 6870 7022 202f 2f20 666f 7220 7065 6572 hpp" // for peer │ │ │ -0002fdd0: 5f6c 6973 745f 656e 7472 790a 2369 6e63 _list_entry.#inc │ │ │ -0002fde0: 6c75 6465 2022 6c69 6274 6f72 7265 6e74 lude "libtorrent │ │ │ -0002fdf0: 2f61 6c65 7274 5f74 7970 6573 2e68 7070 /alert_types.hpp │ │ │ -0002fe00: 220a 2369 6e63 6c75 6465 2022 6c69 6274 ".#include "libt │ │ │ -0002fe10: 6f72 7265 6e74 2f73 6573 7369 6f6e 2e68 orrent/session.h │ │ │ -0002fe20: 7070 220a 2369 6e63 6c75 6465 2022 6c69 pp".#include "li │ │ │ -0002fe30: 6274 6f72 7265 6e74 2f73 6573 7369 6f6e btorrent/session │ │ │ -0002fe40: 5f70 6172 616d 732e 6870 7022 0a23 696e _params.hpp".#in │ │ │ -0002fe50: 636c 7564 6520 226c 6962 746f 7272 656e clude "libtorren │ │ │ -0002fe60: 742f 6572 726f 725f 636f 6465 2e68 7070 t/error_code.hpp │ │ │ -0002fe70: 220a 2369 6e63 6c75 6465 2022 6c69 6274 ".#include "libt │ │ │ -0002fe80: 6f72 7265 6e74 2f61 7578 5f2f 7472 6163 orrent/aux_/trac │ │ │ -0002fe90: 6b65 725f 6d61 6e61 6765 722e 6870 7022 ker_manager.hpp" │ │ │ -0002fea0: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ -0002feb0: 7272 656e 742f 6175 785f 2f68 7474 705f rrent/aux_/http_ │ │ │ -0002fec0: 7472 6163 6b65 725f 636f 6e6e 6563 7469 tracker_connecti │ │ │ -0002fed0: 6f6e 2e68 7070 2220 2f2f 2066 6f72 2070 on.hpp" // for p │ │ │ -0002fee0: 6172 7365 5f74 7261 636b 6572 5f72 6573 arse_tracker_res │ │ │ -0002fef0: 706f 6e73 650a 2369 6e63 6c75 6465 2022 ponse.#include " │ │ │ -0002ff00: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0002ff10: 7765 6273 6f63 6b65 745f 7472 6163 6b65 websocket_tracke │ │ │ -0002ff20: 725f 636f 6e6e 6563 7469 6f6e 2e68 7070 r_connection.hpp │ │ │ -0002ff30: 2220 2f2f 2066 6f72 2070 6172 7365 5f77 " // for parse_w │ │ │ -0002ff40: 6562 736f 636b 6574 5f74 7261 636b 6572 ebsocket_tracker │ │ │ -0002ff50: 5f72 6573 706f 6e73 650a 2369 6e63 6c75 _response.#inclu │ │ │ -0002ff60: 6465 2022 6c69 6274 6f72 7265 6e74 2f74 de "libtorrent/t │ │ │ -0002ff70: 6f72 7265 6e74 5f69 6e66 6f2e 6870 7022 orrent_info.hpp" │ │ │ -0002ff80: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ -0002ff90: 7272 656e 742f 616e 6e6f 756e 6365 5f65 rrent/announce_e │ │ │ -0002ffa0: 6e74 7279 2e68 7070 220a 2369 6e63 6c75 ntry.hpp".#inclu │ │ │ -0002ffb0: 6465 2022 6c69 6274 6f72 7265 6e74 2f61 de "libtorrent/a │ │ │ -0002ffc0: 7578 5f2f 7061 7468 2e68 7070 220a 2369 ux_/path.hpp".#i │ │ │ -0002ffd0: 6e63 6c75 6465 2022 6c69 6274 6f72 7265 nclude "libtorre │ │ │ -0002ffe0: 6e74 2f61 7578 5f2f 736f 636b 6574 5f69 nt/aux_/socket_i │ │ │ -0002fff0: 6f2e 6870 7022 0a0a 2369 6e63 6c75 6465 o.hpp"..#include │ │ │ -00030000: 2026 6c74 3b61 7272 6179 2667 743b 0a23 <array>.# │ │ │ -00030010: 696e 636c 7564 6520 266c 743b 696f 7374 include <iost │ │ │ -00030020: 7265 616d 2667 743b 0a0a 7573 696e 6720 ream>..using │ │ │ -00030030: 6e61 6d65 7370 6163 6520 6c74 3b0a 0a3c namespace lt;..< │ │ │ -00030040: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -00030050: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -00030060: 7769 6474 683d 2231 3030 2522 3e0a 3c2f width="100%">.TORRENT_TEST │ │ │ -00030080: 2870 6172 7365 5f68 6f73 746e 616d 655f (parse_hostname_ │ │ │ -00030090: 7065 6572 7329 0a7b 0a09 6368 6172 2063 peers).{..char c │ │ │ -000300a0: 6f6e 7374 2072 6573 706f 6e73 655b 5d20 onst response[] │ │ │ -000300b0: 3d20 2264 353a 7065 6572 736c 6437 3a70 = "d5:peersld7:p │ │ │ -000300c0: 6565 7220 6964 3230 3a61 6161 6161 6161 eer id20:aaaaaaa │ │ │ -000300d0: 6161 6161 6161 6161 6161 6161 6122 0a09 aaaaaaaaaaaaa".. │ │ │ -000300e0: 0922 323a 6970 3133 3a74 6573 745f 686f ."2:ip13:test_ho │ │ │ -000300f0: 7374 6e61 6d65 343a 706f 7274 6931 3030 stname4:porti100 │ │ │ -00030100: 3065 6564 220a 0909 2237 3a70 6565 7220 0eed"..."7:peer │ │ │ -00030110: 6964 3230 3a62 6262 6261 6261 6162 6162 id20:bbbbabaabab │ │ │ -00030120: 6162 6162 6162 6162 6132 3a69 7031 323a ababababa2:ip12: │ │ │ -00030130: 616e 6f74 6865 725f 686f 7374 343a 706f another_host4:po │ │ │ -00030140: 7274 6931 3030 3165 6565 6522 3b0a 0965 rti1001eeee";..e │ │ │ -00030150: 7272 6f72 5f63 6f64 6520 6563 3b0a 0961 rror_code ec;..a │ │ │ -00030160: 7578 3a3a 7472 6163 6b65 725f 7265 7370 ux::tracker_resp │ │ │ -00030170: 6f6e 7365 2072 6573 7020 3d20 6175 783a onse resp = aux: │ │ │ -00030180: 3a70 6172 7365 5f74 7261 636b 6572 5f72 :parse_tracker_r │ │ │ -00030190: 6573 706f 6e73 6528 7265 7370 6f6e 7365 esponse(response │ │ │ -000301a0: 0a09 092c 2065 632c 207b 7d2c 2073 6861 ..., ec, {}, sha │ │ │ -000301b0: 315f 6861 7368 2829 293b 0a0a 0954 4553 1_hash());...TES │ │ │ -000301c0: 545f 4551 5541 4c28 6563 2c20 6572 726f T_EQUAL(ec, erro │ │ │ -000301d0: 725f 636f 6465 2829 293b 0a09 5445 5354 r_code());..TEST │ │ │ -000301e0: 5f45 5155 414c 2872 6573 702e 7065 6572 _EQUAL(resp.peer │ │ │ -000301f0: 732e 7369 7a65 2829 2c20 3229 3b0a 0969 s.size(), 2);..i │ │ │ -00030200: 6620 2872 6573 702e 7065 6572 732e 7369 f (resp.peers.si │ │ │ -00030210: 7a65 2829 203d 3d20 3229 0a09 7b0a 0909 ze() == 2)..{... │ │ │ -00030220: 6175 783a 3a70 6565 725f 656e 7472 7920 aux::peer_entry │ │ │ -00030230: 636f 6e73 7426 616d 703b 2065 3020 3d20 const& e0 = │ │ │ -00030240: 7265 7370 2e70 6565 7273 5b30 5d3b 0a09 resp.peers[0];.. │ │ │ -00030250: 0961 7578 3a3a 7065 6572 5f65 6e74 7279 .aux::peer_entry │ │ │ -00030260: 2063 6f6e 7374 2661 6d70 3b20 6531 203d const& e1 = │ │ │ -00030270: 2072 6573 702e 7065 6572 735b 315d 3b0a resp.peers[1];. │ │ │ -00030280: 0909 5445 5354 5f45 5155 414c 2865 302e ..TEST_EQUAL(e0. │ │ │ -00030290: 686f 7374 6e61 6d65 2c20 2274 6573 745f hostname, "test_ │ │ │ -000302a0: 686f 7374 6e61 6d65 2229 3b0a 0909 5445 hostname");...TE │ │ │ -000302b0: 5354 5f45 5155 414c 2865 302e 706f 7274 ST_EQUAL(e0.port │ │ │ -000302c0: 2c20 3130 3030 293b 0a09 0954 4553 545f , 1000);...TEST_ │ │ │ -000302d0: 4551 5541 4c28 6530 2e70 6964 2c20 7065 EQUAL(e0.pid, pe │ │ │ -000302e0: 6572 5f69 6428 2261 6161 6161 6161 6161 er_id("aaaaaaaaa │ │ │ -000302f0: 6161 6161 6161 6161 6161 6122 2929 3b0a aaaaaaaaaaa"));. │ │ │ -00030300: 0a09 0954 4553 545f 4551 5541 4c28 6531 ...TEST_EQUAL(e1 │ │ │ -00030310: 2e68 6f73 746e 616d 652c 2022 616e 6f74 .hostname, "anot │ │ │ -00030320: 6865 725f 686f 7374 2229 3b0a 0909 5445 her_host");...TE │ │ │ -00030330: 5354 5f45 5155 414c 2865 312e 706f 7274 ST_EQUAL(e1.port │ │ │ -00030340: 2c20 3130 3031 293b 0a09 0954 4553 545f , 1001);...TEST_ │ │ │ -00030350: 4551 5541 4c28 6531 2e70 6964 2c20 7065 EQUAL(e1.pid, pe │ │ │ -00030360: 6572 5f69 6428 2262 6262 6261 6261 6162 er_id("bbbbabaab │ │ │ -00030370: 6162 6162 6162 6162 6162 6122 2929 3b0a abababababa"));. │ │ │ -00030380: 097d 0a7d 0a0a 544f 5252 454e 545f 5445 .}.}..TORRENT_TE │ │ │ -00030390: 5354 2870 6172 7365 5f70 6565 7273 3429 ST(parse_peers4) │ │ │ -000303a0: 0a7b 0a09 6368 6172 2063 6f6e 7374 2072 .{..char const r │ │ │ -000303b0: 6573 706f 6e73 655b 5d20 3d20 2264 353a esponse[] = "d5: │ │ │ -000303c0: 7065 6572 7331 323a 5c78 3031 5c78 3032 peers12:\x01\x02 │ │ │ -000303d0: 5c78 3033 5c78 3034 5c78 3330 5c78 3130 \x03\x04\x30\x10 │ │ │ -000303e0: 220a 0909 225c 7830 395c 7830 385c 7830 "..."\x09\x08\x0 │ │ │ -000303f0: 375c 7830 365c 7832 305c 7831 3022 2022 7\x06\x20\x10" " │ │ │ -00030400: 6522 3b0a 0965 7272 6f72 5f63 6f64 6520 e";..error_code │ │ │ -00030410: 6563 3b0a 3c2f 7072 653e 3c2f 7464 3e3c ec;.< │ │ │ -00030420: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00030450: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0.. │ │ │ -00030480: 2f74 6573 742f 7465 7374 5f73 736c 2e63 /test/test_ssl.c │ │ │ -00030490: 7070 3a33 3834 3c2f 613e 3c2f 7464 3e3c pp:384< │ │ │ -000304a0: 7464 3e74 6573 7420 7573 696e 6720 6120 td>test using a │ │ │ -000304b0: 7369 676e 6564 2063 6572 7469 6669 6361 signed certifica │ │ │ -000304c0: 7465 2077 6974 6820 7468 6520 7772 6f6e te with the wron │ │ │ -000304d0: 6720 696e 666f 2d68 6173 6820 696e 2044 g info-hash in D │ │ │ -000304e0: 4e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 N

    te │ │ │ -00030530: 7374 2075 7369 6e67 2061 2073 6967 6e65 st using a signe │ │ │ -00030540: 6420 6365 7274 6966 6963 6174 6520 7769 d certificate wi │ │ │ -00030550: 7468 2074 6865 2077 726f 6e67 2069 6e66 th the wrong inf │ │ │ -00030560: 6f2d 6861 7368 2069 6e20 444e 3c2f 6832 o-hash in DN

    ../test/tes │ │ │ -00030580: 745f 7373 6c2e 6370 703a 3338 343c 2f68 t_ssl.cpp:384
    .// 
    │ │ │ -000305d0: 696e 2076 6572 6966 7969 6e67 2070 6565  in verifying pee
    │ │ │ -000305e0: 7273 0a09 6374 782e 7365 745f 7665 7269  rs..ctx.set_veri
    │ │ │ -000305f0: 6679 5f6d 6f64 6528 636f 6e74 6578 743a  fy_mode(context:
    │ │ │ -00030600: 3a76 6572 6966 795f 6e6f 6e65 2c20 6563  :verify_none, ec
    │ │ │ -00030610: 293b 0a09 6966 2028 6563 290a 097b 0a09  );..if (ec)..{..
    │ │ │ -00030620: 0973 7464 3a3a 7072 696e 7466 2822 4661  .std::printf("Fa
    │ │ │ -00030630: 696c 6564 2074 6f20 7365 7420 5353 4c20  iled to set SSL 
    │ │ │ -00030640: 7665 7269 6679 206d 6f64 653a 2025 735c  verify mode: %s\
    │ │ │ -00030650: 6e22 0a09 0909 2c20 6563 2e6d 6573 7361  n"...., ec.messa
    │ │ │ -00030660: 6765 2829 2e63 5f73 7472 2829 293b 0a09  ge().c_str());..
    │ │ │ -00030670: 0954 4553 545f 4348 4543 4b28 2165 6329  .TEST_CHECK(!ec)
    │ │ │ -00030680: 3b0a 0909 7265 7475 726e 2066 616c 7365  ;...return false
    │ │ │ -00030690: 3b0a 097d 0a0a 0973 7464 3a3a 7374 7269  ;..}...std::stri
    │ │ │ -000306a0: 6e67 2063 6572 7469 6669 6361 7465 203d  ng certificate =
    │ │ │ -000306b0: 2063 6f6d 6269 6e65 5f70 6174 6828 222e   combine_path(".
    │ │ │ -000306c0: 2e22 2c20 636f 6d62 696e 655f 7061 7468  .", combine_path
    │ │ │ -000306d0: 2822 7373 6c22 2c20 2270 6565 725f 6365  ("ssl", "peer_ce
    │ │ │ -000306e0: 7274 6966 6963 6174 652e 7065 6d22 2929  rtificate.pem"))
    │ │ │ -000306f0: 3b0a 0973 7464 3a3a 7374 7269 6e67 2070  ;..std::string p
    │ │ │ -00030700: 7269 7661 7465 5f6b 6579 203d 2063 6f6d  rivate_key = com
    │ │ │ -00030710: 6269 6e65 5f70 6174 6828 222e 2e22 2c20  bine_path("..", 
    │ │ │ -00030720: 636f 6d62 696e 655f 7061 7468 2822 7373  combine_path("ss
    │ │ │ -00030730: 6c22 2c20 2270 6565 725f 7072 6976 6174  l", "peer_privat
    │ │ │ -00030740: 655f 6b65 792e 7065 6d22 2929 3b0a 0973  e_key.pem"));..s
    │ │ │ -00030750: 7464 3a3a 7374 7269 6e67 2064 685f 7061  td::string dh_pa
    │ │ │ -00030760: 7261 6d73 203d 2063 6f6d 6269 6e65 5f70  rams = combine_p
    │ │ │ -00030770: 6174 6828 222e 2e22 2c20 636f 6d62 696e  ath("..", combin
    │ │ │ -00030780: 655f 7061 7468 2822 7373 6c22 2c20 2264  e_path("ssl", "d
    │ │ │ -00030790: 6870 6172 616d 732e 7065 6d22 2929 3b0a  hparams.pem"));.
    │ │ │ -000307a0: 0a09 6966 2028 666c 6167 7320 2661 6d70  ..if (flags &
    │ │ │ -000307b0: 3b20 696e 7661 6c69 645f 6365 7274 6966  ; invalid_certif
    │ │ │ -000307c0: 6963 6174 6529 0a09 7b0a 0909 6365 7274  icate)..{...cert
    │ │ │ -000307d0: 6966 6963 6174 6520 3d20 636f 6d62 696e  ificate = combin
    │ │ │ -000307e0: 655f 7061 7468 2822 2e2e 222c 2063 6f6d  e_path("..", com
    │ │ │ -000307f0: 6269 6e65 5f70 6174 6828 2273 736c 222c  bine_path("ssl",
    │ │ │ -00030800: 2022 696e 7661 6c69 645f 7065 6572 5f63   "invalid_peer_c
    │ │ │ -00030810: 6572 7469 6669 6361 7465 2e70 656d 2229  ertificate.pem")
    │ │ │ -00030820: 293b 0a09 0970 7269 7661 7465 5f6b 6579  );...private_key
    │ │ │ -00030830: 203d 2063 6f6d 6269 6e65 5f70 6174 6828   = combine_path(
    │ │ │ -00030840: 222e 2e22 2c20 636f 6d62 696e 655f 7061  "..", combine_pa
    │ │ │ -00030850: 7468 2822 7373 6c22 2c20 2269 6e76 616c  th("ssl", "inval
    │ │ │ -00030860: 6964 5f70 6565 725f 7072 6976 6174 655f  id_peer_private_
    │ │ │ -00030870: 6b65 792e 7065 6d22 2929 3b0a 097d 0a0a  key.pem"));..}..
    │ │ │ -00030880: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ -000308b0: 2f64 6976 3e09 6966 2028 666c 6167 7320 /div>.if (flags │ │ │ -000308c0: 2661 6d70 3b20 2876 616c 6964 5f63 6572 & (valid_cer │ │ │ -000308d0: 7469 6669 6361 7465 207c 2069 6e76 616c tificate | inval │ │ │ -000308e0: 6964 5f63 6572 7469 6669 6361 7465 2929 id_certificate)) │ │ │ -000308f0: 0a09 7b0a 0909 7374 643a 3a70 7269 6e74 ..{...std::print │ │ │ -00030900: 6628 2273 6574 5f70 6173 7377 6f72 645f f("set_password_ │ │ │ -00030910: 6361 6c6c 6261 636b 5c6e 2229 3b0a 0909 callback\n");... │ │ │ -00030920: 6374 782e 7365 745f 7061 7373 776f 7264 ctx.set_password │ │ │ -00030930: 5f63 616c 6c62 6163 6b28 0a09 0909 5b5d _callback(....[] │ │ │ -00030940: 2873 7464 3a3a 7369 7a65 5f74 2c20 636f (std::size_t, co │ │ │ -00030950: 6e74 6578 743a 3a70 6173 7377 6f72 645f ntext::password_ │ │ │ -00030960: 7075 7270 6f73 6529 207b 2072 6574 7572 purpose) { retur │ │ │ -00030970: 6e20 2274 6573 7422 3b20 7d0a 0909 092c n "test"; }...., │ │ │ -00030980: 2065 6329 3b0a 0909 6966 2028 6563 290a ec);...if (ec). │ │ │ -00030990: 0909 7b0a 0909 0973 7464 3a3a 7072 696e ..{....std::prin │ │ │ -000309a0: 7466 2822 4661 696c 6564 2074 6f20 7365 tf("Failed to se │ │ │ -000309b0: 7420 6365 7274 6966 6963 6174 6520 7061 t certificate pa │ │ │ -000309c0: 7373 7068 7261 7365 3a20 2573 5c6e 220a ssphrase: %s\n". │ │ │ -000309d0: 0909 0909 2c20 6563 2e6d 6573 7361 6765 ...., ec.message │ │ │ -000309e0: 2829 2e63 5f73 7472 2829 293b 0a09 0909 ().c_str());.... │ │ │ -000309f0: 5445 5354 5f43 4845 434b 2821 6563 293b TEST_CHECK(!ec); │ │ │ -00030a00: 0a09 0909 7265 7475 726e 2066 616c 7365 ....return false │ │ │ -00030a10: 3b0a 0909 7d0a 0909 7374 643a 3a70 7269 ;...}...std::pri │ │ │ -00030a20: 6e74 6628 2275 7365 5f63 6572 7469 6669 ntf("use_certifi │ │ │ -00030a30: 6361 7465 5f66 696c 6520 5c22 2573 5c22 cate_file \"%s\" │ │ │ -00030a40: 5c6e 222c 2063 6572 7469 6669 6361 7465 \n", certificate │ │ │ -00030a50: 2e63 5f73 7472 2829 293b 0a09 0963 7478 .c_str());...ctx │ │ │ -00030a60: 2e75 7365 5f63 6572 7469 6669 6361 7465 .use_certificate │ │ │ -00030a70: 5f66 696c 6528 6365 7274 6966 6963 6174 _file(certificat │ │ │ -00030a80: 652c 2063 6f6e 7465 7874 3a3a 7065 6d2c e, context::pem, │ │ │ -00030a90: 2065 6329 3b0a 0909 6966 2028 6563 290a ec);...if (ec). │ │ │ -00030aa0: 0909 7b0a 0909 0973 7464 3a3a 7072 696e ..{....std::prin │ │ │ -00030ab0: 7466 2822 4661 696c 6564 2074 6f20 7365 tf("Failed to se │ │ │ -00030ac0: 7420 6365 7274 6966 6963 6174 6520 6669 t certificate fi │ │ │ -00030ad0: 6c65 3a20 2573 5c6e 220a 0909 0909 2c20 le: %s\n"....., │ │ │ -00030ae0: 6563 2e6d 6573 7361 6765 2829 2e63 5f73 ec.message().c_s │ │ │ -00030af0: 7472 2829 293b 0a09 0909 5445 5354 5f43 tr());....TEST_C │ │ │ -00030b00: 4845 434b 2821 6563 293b 0a09 0909 7265 HECK(!ec);....re │ │ │ -00030b10: 7475 726e 2066 616c 7365 3b0a 0909 7d0a turn false;...}. │ │ │ -00030b20: 0909 7374 643a 3a70 7269 6e74 6628 2275 ..std::printf("u │ │ │ -00030b30: 7365 5f70 7269 7661 7465 5f6b 6579 5f66 se_private_key_f │ │ │ -00030b40: 696c 6520 5c22 2573 5c22 5c6e 222c 2070 ile \"%s\"\n", p │ │ │ -00030b50: 7269 7661 7465 5f6b 6579 2e63 5f73 7472 rivate_key.c_str │ │ │ -00030b60: 2829 293b 0a09 0963 7478 2e75 7365 5f70 ());...ctx.use_p │ │ │ -00030b70: 7269 7661 7465 5f6b 6579 5f66 696c 6528 rivate_key_file( │ │ │ -00030b80: 7072 6976 6174 655f 6b65 792c 2063 6f6e private_key, con │ │ │ -00030b90: 7465 7874 3a3a 7065 6d2c 2065 6329 3b0a text::pem, ec);. │ │ │ -00030ba0: 0909 6966 2028 6563 290a 0909 7b0a 0909 ..if (ec)...{... │ │ │ -00030bb0: 0973 7464 3a3a 7072 696e 7466 2822 4661 .std::printf("Fa │ │ │ -00030bc0: 696c 6564 2074 6f20 7365 7420 7072 6976 iled to set priv │ │ │ -00030bd0: 6174 6520 6b65 793a 2025 735c 6e22 0a09 ate key: %s\n".. │ │ │ -00030be0: 0909 092c 2065 632e 6d65 7373 6167 6528 ..., ec.message( │ │ │ -00030bf0: 292e 635f 7374 7228 2929 3b0a 0909 0954 ).c_str());....T │ │ │ -00030c00: 4553 545f 4348 4543 4b28 2165 6329 3b0a EST_CHECK(!ec);. │ │ │ -00030c10: 0909 0972 6574 7572 6e20 6661 6c73 653b ...return false; │ │ │ -00030c20: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00030c60: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../t │ │ │ -00030c90: 6573 742f 7465 7374 5f73 736c 2e63 7070 est/test_ssl.cpp │ │ │ -00030ca0: 3a34 3836 3c2f 613e 3c2f 7464 3e3c 7464 :486also test using │ │ │ -00030cc0: 2061 2068 6173 6820 7468 6174 2072 6566 a hash that ref │ │ │ -00030cd0: 6572 7320 746f 2061 2076 616c 6964 2074 ers to a valid t │ │ │ -00030ce0: 6f72 7265 6e74 2062 7574 2074 6861 7420 orrent but that │ │ │ -00030cf0: 6469 6666 6572 7320 6672 6f6d 2074 6865 differs from the │ │ │ -00030d00: 2053 4e49 2068 6173 683c 2f74 643e 3c2f SNI hash

    also test │ │ │ -00030d60: 2075 7369 6e67 2061 2068 6173 6820 7468 using a hash th │ │ │ -00030d70: 6174 2072 6566 6572 7320 746f 2061 2076 at refers to a v │ │ │ -00030d80: 616c 6964 2074 6f72 7265 6e74 0a62 7574 alid torrent.but │ │ │ -00030d90: 2074 6861 7420 6469 6666 6572 7320 6672 that differs fr │ │ │ -00030da0: 6f6d 2074 6865 2053 4e49 2068 6173 683c om the SNI hash< │ │ │ -00030db0: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ -00030dc0: 7465 7374 5f73 736c 2e63 7070 3a34 3836 test_ssl.cpp:486 │ │ │ -00030dd0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00030e10: 7072 696e 745f 616c 6572 7473 2873 6573  print_alerts(ses
    │ │ │ -00030e20: 312c 2022 7365 7331 222c 2074 7275 652c  1, "ses1", true,
    │ │ │ -00030e30: 2074 7275 652c 2026 616d 703b 6f6e 5f61   true, &on_a
    │ │ │ -00030e40: 6c65 7274 293b 0a09 6966 2028 6563 290a  lert);..if (ec).
    │ │ │ -00030e50: 097b 0a09 0973 7464 3a3a 7072 696e 7466  .{...std::printf
    │ │ │ -00030e60: 2822 4661 696c 6564 2053 534c 2068 616e  ("Failed SSL han
    │ │ │ -00030e70: 6473 6861 6b65 3a20 2573 5c6e 220a 0909  dshake: %s\n"...
    │ │ │ -00030e80: 092c 2065 632e 6d65 7373 6167 6528 292e  ., ec.message().
    │ │ │ -00030e90: 635f 7374 7228 2929 3b0a 0909 7265 7475  c_str());...retu
    │ │ │ -00030ea0: 726e 2066 616c 7365 3b0a 097d 0a0a 0963  rn false;..}...c
    │ │ │ -00030eb0: 6861 7220 6861 6e64 7368 616b 655b 5d20  har handshake[] 
    │ │ │ -00030ec0: 3d20 225c 7831 3322 2022 4269 7454 6f72  = "\x13" "BitTor
    │ │ │ -00030ed0: 7265 6e74 2070 726f 746f 636f 6c5c 305c  rent protocol\0\
    │ │ │ -00030ee0: 305c 305c 305c 305c 305c 305c 7830 3422  0\0\0\0\0\0\x04"
    │ │ │ -00030ef0: 0a09 0922 2020 2020 2020 2020 2020 2020  ..."            
    │ │ │ -00030f00: 2020 2020 2020 2020 2220 2f2f 2073 7061          " // spa
    │ │ │ -00030f10: 6365 2066 6f72 2069 6e66 6f2d 6861 7368  ce for info-hash
    │ │ │ -00030f20: 0a09 0922 6161 6161 6161 6161 6161 6161  ..."aaaaaaaaaaaa
    │ │ │ -00030f30: 6161 6161 6161 6161 2220 2f2f 2070 6565  aaaaaaaa" // pee
    │ │ │ -00030f40: 722d 6964 0a09 0922 5c30 5c30 5c30 5c78  r-id..."\0\0\0\x
    │ │ │ -00030f50: 3031 5c78 3032 223b 202f 2f20 696e 7465  01\x02"; // inte
    │ │ │ -00030f60: 7265 7374 6564 0a0a 092f 2f20 6669 6c6c  rested...// fill
    │ │ │ -00030f70: 2069 6e20 7468 6520 696e 666f 2d68 6173   in the info-has
    │ │ │ -00030f80: 680a 0969 6620 2866 6c61 6773 2026 616d  h..if (flags &am
    │ │ │ -00030f90: 703b 2076 616c 6964 5f62 6974 746f 7272  p; valid_bittorr
    │ │ │ -00030fa0: 656e 745f 6861 7368 290a 097b 0a09 0973  ent_hash)..{...s
    │ │ │ -00030fb0: 7464 3a3a 6d65 6d63 7079 2868 616e 6473  td::memcpy(hands
    │ │ │ -00030fc0: 6861 6b65 202b 2032 382c 2026 616d 703b  hake + 28, &
    │ │ │ -00030fd0: 742d 2667 743b 696e 666f 5f68 6173 6865  t->info_hashe
    │ │ │ -00030fe0: 7328 292e 7631 5b30 5d2c 2032 3029 3b0a  s().v1[0], 20);.
    │ │ │ -00030ff0: 097d 0a09 656c 7365 0a09 7b0a 3c64 6976  .}..else..{.
    ..std: │ │ │ -00031030: 3a67 656e 6572 6174 6528 6861 6e64 7368 :generate(handsh │ │ │ -00031040: 616b 6520 2b20 3238 2c20 6861 6e64 7368 ake + 28, handsh │ │ │ -00031050: 616b 6520 2b20 3438 2c20 5b5d 2829 7b20 ake + 48, [](){ │ │ │ -00031060: 7265 7475 726e 2063 6861 7228 7374 643a return char(std: │ │ │ -00031070: 3a72 616e 6428 2929 3b20 7d20 293b 0a3c :rand()); } );.< │ │ │ -00031080: 2f64 6976 3e09 7d0a 0a09 2f2f 2066 696c /div>.}...// fil │ │ │ -00031090: 6c20 696e 2074 6865 2070 6565 722d 6964 l in the peer-id │ │ │ -000310a0: 0a09 7374 643a 3a67 656e 6572 6174 6528 ..std::generate( │ │ │ -000310b0: 6861 6e64 7368 616b 6520 2b20 3438 2c20 handshake + 48, │ │ │ -000310c0: 6861 6e64 7368 616b 6520 2b20 3638 2c20 handshake + 68, │ │ │ -000310d0: 5b5d 2829 7b20 7265 7475 726e 2063 6861 [](){ return cha │ │ │ -000310e0: 7228 7374 643a 3a72 616e 6428 2929 3b20 r(std::rand()); │ │ │ -000310f0: 7d20 293b 0a0a 0973 7464 3a3a 7072 696e } );...std::prin │ │ │ -00031100: 7466 2822 6269 7474 6f72 7265 6e74 2068 tf("bittorrent h │ │ │ -00031110: 616e 6473 6861 6b65 5c6e 2229 3b0a 0962 andshake\n");..b │ │ │ -00031120: 6f6f 7374 3a3a 6173 696f 3a3a 7772 6974 oost::asio::writ │ │ │ -00031130: 6528 7373 6c5f 736f 636b 2c20 626f 6f73 e(ssl_sock, boos │ │ │ -00031140: 743a 3a61 7369 6f3a 3a62 7566 6665 7228 t::asio::buffer( │ │ │ -00031150: 6861 6e64 7368 616b 652c 2028 7369 7a65 handshake, (size │ │ │ -00031160: 6f66 2868 616e 6473 6861 6b65 2920 2d20 of(handshake) - │ │ │ -00031170: 3129 292c 2065 6329 3b0a 0970 7269 6e74 1)), ec);..print │ │ │ -00031180: 5f61 6c65 7274 7328 7365 7331 2c20 2273 _alerts(ses1, "s │ │ │ -00031190: 6573 3122 2c20 7472 7565 2c20 7472 7565 es1", true, true │ │ │ -000311a0: 2c20 2661 6d70 3b6f 6e5f 616c 6572 7429 , &on_alert) │ │ │ -000311b0: 3b0a 0969 6620 2865 6329 0a09 7b0a 0909 ;..if (ec)..{... │ │ │ -000311c0: 7374 643a 3a70 7269 6e74 6628 2266 6169 std::printf("fai │ │ │ -000311d0: 6c65 6420 746f 2077 7269 7465 2062 6974 led to write bit │ │ │ -000311e0: 746f 7272 656e 7420 6861 6e64 7368 616b torrent handshak │ │ │ -000311f0: 653a 2025 735c 6e22 0a09 0909 2c20 6563 e: %s\n"...., ec │ │ │ -00031200: 2e6d 6573 7361 6765 2829 2e63 5f73 7472 .message().c_str │ │ │ -00031210: 2829 293b 0a09 0972 6574 7572 6e20 6661 ());...return fa │ │ │ -00031220: 6c73 653b 0a09 7d0a 0a09 6368 6172 2062 lse;..}...char b │ │ │ -00031230: 7566 5b36 385d 3b0a 0973 7464 3a3a 7072 uf[68];..std::pr │ │ │ -00031240: 696e 7466 2822 7265 6164 2062 6974 746f intf("read bitto │ │ │ -00031250: 7272 656e 7420 6861 6e64 7368 616b 655c rrent handshake\ │ │ │ -00031260: 6e22 293b 0a09 626f 6f73 743a 3a61 7369 n");..boost::asi │ │ │ -00031270: 6f3a 3a72 6561 6428 7373 6c5f 736f 636b o::read(ssl_sock │ │ │ -00031280: 2c20 626f 6f73 743a 3a61 7369 6f3a 3a62 , boost::asio::b │ │ │ -00031290: 7566 6665 7228 6275 662c 2073 697a 656f uffer(buf, sizeo │ │ │ -000312a0: 6628 6275 6629 292c 2065 6329 3b0a 0970 f(buf)), ec);..p │ │ │ -000312b0: 7269 6e74 5f61 6c65 7274 7328 7365 7331 rint_alerts(ses1 │ │ │ -000312c0: 2c20 2273 6573 3122 2c20 7472 7565 2c20 , "ses1", true, │ │ │ -000312d0: 7472 7565 2c20 2661 6d70 3b6f 6e5f 616c true, &on_al │ │ │ -000312e0: 6572 7429 3b0a 0969 6620 2865 6329 0a09 ert);..if (ec).. │ │ │ -000312f0: 7b0a 0909 7374 643a 3a70 7269 6e74 6628 {...std::printf( │ │ │ -00031300: 2266 6169 6c65 6420 746f 2072 6561 6420 "failed to read │ │ │ -00031310: 6269 7474 6f72 7265 6e74 2068 616e 6473 bittorrent hands │ │ │ -00031320: 6861 6b65 3a20 2573 5c6e 220a 0909 092c hake: %s\n"...., │ │ │ -00031330: 2065 632e 6d65 7373 6167 6528 292e 635f ec.message().c_ │ │ │ -00031340: 7374 7228 2929 3b0a 0909 7265 7475 726e str());...return │ │ │ -00031350: 2066 616c 7365 3b0a 097d 0a0a 0969 6620 false;..}...if │ │ │ -00031360: 286d 656d 636d 7028 6275 662c 2022 5c78 (memcmp(buf, "\x │ │ │ -00031370: 3133 2220 2242 6974 546f 7272 656e 7420 13" "BitTorrent │ │ │ -00031380: 7072 6f74 6f63 6f6c 222c 2032 3029 2021 protocol", 20) ! │ │ │ -00031390: 3d20 3029 0a09 7b0a 0909 7374 643a 3a70 = 0)..{...std::p │ │ │ -000313a0: 7269 6e74 6628 2269 6e76 616c 6964 2062 rintf("invalid b │ │ │ -000313b0: 6974 746f 7272 656e 7420 6861 6e64 7368 ittorrent handsh │ │ │ -000313c0: 616b 655c 6e22 293b 0a09 0972 6574 7572 ake\n");...retur │ │ │ -000313d0: 6e20 6661 6c73 653b 0a3c 2f70 7265 3e3c n false;.
    < │ │ │ -000313e0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00031410: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00031420: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -00031450: 5f70 6565 725f 6c69 7374 2e63 7070 3a31 _peer_list.cpp:1 │ │ │ -00031460: 3236 393c 2f61 3e3c 2f74 643e 3c74 643e 269 │ │ │ -00031470: 7465 7374 2065 7261 7369 6e67 2070 6565 test erasing pee │ │ │ -00031480: 7273 3c2f 7464 3e3c 2f74 723e 3c74 7220 rs

    │ │ │ -000314d0: 7465 7374 2065 7261 7369 6e67 2070 6565 test erasing pee │ │ │ -000314e0: 7273 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 rs

    ../te │ │ │ -000314f0: 7374 2f74 6573 745f 7065 6572 5f6c 6973 st/test_peer_lis │ │ │ -00031500: 742e 6370 703a 3132 3639 3c2f 6834 3e3c t.cpp:1269

    < │ │ │ -00031510: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00031520: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00031530: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00031540: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">< │ │ │ -00031550: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00031580: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00031590: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -000315c0: 5f70 6565 725f 6c69 7374 2e63 7070 3a31 _peer_list.cpp:1 │ │ │ -000315d0: 3237 303c 2f61 3e3c 2f74 643e 3c74 643e 270 │ │ │ -000315e0: 7465 7374 2075 7064 6174 655f 7065 6572 test update_peer │ │ │ -000315f0: 5f70 6f72 7420 7769 7468 2061 6c6c 6f77 _port with allow │ │ │ -00031600: 5f6d 756c 7469 706c 655f 636f 6e6e 6563 _multiple_connec │ │ │ -00031610: 7469 6f6e 735f 7065 725f 6970 2061 6e64 tions_per_ip and │ │ │ -00031620: 2077 6974 686f 7574 3c2f 7464 3e3c 2f74 without

    test updat │ │ │ -00031680: 655f 7065 6572 5f70 6f72 7420 7769 7468 e_peer_port with │ │ │ -00031690: 2061 6c6c 6f77 5f6d 756c 7469 706c 655f allow_multiple_ │ │ │ -000316a0: 636f 6e6e 6563 7469 6f6e 735f 7065 725f connections_per_ │ │ │ -000316b0: 6970 2061 6e64 2077 6974 686f 7574 3c2f ip and without

    ../test/t │ │ │ -000316d0: 6573 745f 7065 6572 5f6c 6973 742e 6370 est_peer_list.cp │ │ │ -000316e0: 703a 3132 3730 3c2f 6834 3e3c 7072 6520 p:1270

    
    │ │ │ -00031730: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -00031760: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -00031770: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -00031780: 7074 3a65 7870 616e 6428 3130 3329 223e  pt:expand(103)">
    │ │ │ -00031790: 2e2e 2f74 6573 742f 7465 7374 5f70 6565  ../test/test_pee
    │ │ │ -000317a0: 725f 6c69 7374 2e63 7070 3a31 3237 313c  r_list.cpp:1271<
    │ │ │ -000317b0: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374  /a>test
    │ │ │ -000317c0: 2061 6464 2069 3270 2070 6565 7273 3c2f   add i2p peers

    test │ │ │ -00031820: 2061 6464 2069 3270 2070 6565 7273 3c2f add i2p peers

    ../test/t │ │ │ -00031840: 6573 745f 7065 6572 5f6c 6973 742e 6370 est_peer_list.cp │ │ │ -00031850: 703a 3132 3731 3c2f 6834 3e3c 7072 6520 p:1271

    
    │ │ │ -000318a0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -000318d0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -000318e0: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -000318f0: 7074 3a65 7870 616e 6428 3130 3429 223e  pt:expand(104)">
    │ │ │ -00031900: 2e2e 2f74 6573 742f 7465 7374 5f70 6565  ../test/test_pee
    │ │ │ -00031910: 725f 6c69 7374 2e63 7070 3a31 3237 323c  r_list.cpp:1272<
    │ │ │ -00031920: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374  /a>test
    │ │ │ -00031930: 2061 6c6c 6f77 5f69 3270 5f6d 6978 6564   allow_i2p_mixed
    │ │ │ -00031940: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964  

    te │ │ │ -00031990: 7374 2061 6c6c 6f77 5f69 3270 5f6d 6978 st allow_i2p_mix │ │ │ -000319a0: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ed

    ../te │ │ │ -000319b0: 7374 2f74 6573 745f 7065 6572 5f6c 6973 st/test_peer_lis │ │ │ -000319c0: 742e 6370 703a 3132 3732 3c2f 6834 3e3c t.cpp:1272

    < │ │ │ -000319d0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000319e0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000319f0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00031a00: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">< │ │ │ -00031a10: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00031a40: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00031a50: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -00031a80: 5f70 6565 725f 6c69 7374 2e63 7070 3a31 _peer_list.cpp:1 │ │ │ -00031a90: 3237 333c 2f61 3e3c 2f74 643e 3c74 643e 273 │ │ │ -00031aa0: 7465 7374 2069 6e73 6572 745f 7065 6572 test insert_peer │ │ │ -00031ab0: 2066 6169 6c69 6e67 2077 6974 6820 616c failing with al │ │ │ -00031ac0: 6c20 6572 726f 7220 636f 6e64 6974 696f l error conditio │ │ │ -00031ad0: 6e73 3c2f 7464 3e3c 2f74 723e 3c74 7220 ns

    │ │ │ -00031b20: 7465 7374 2069 6e73 6572 745f 7065 6572 test insert_peer │ │ │ -00031b30: 2066 6169 6c69 6e67 2077 6974 6820 616c failing with al │ │ │ -00031b40: 6c20 6572 726f 7220 636f 6e64 6974 696f l error conditio │ │ │ -00031b50: 6e73 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ns

    ../te │ │ │ -00031b60: 7374 2f74 6573 745f 7065 6572 5f6c 6973 st/test_peer_lis │ │ │ -00031b70: 742e 6370 703a 3132 3733 3c2f 6834 3e3c t.cpp:1273

    < │ │ │ -00031b80: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00031b90: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00031ba0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00031bb0: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">< │ │ │ -00031bc0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00031bf0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00031c00: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -00031c30: 5f70 6565 725f 6c69 7374 2e63 7070 3a31 _peer_list.cpp:1 │ │ │ -00031c40: 3237 343c 2f61 3e3c 2f74 643e 3c74 643e 274 │ │ │ -00031c50: 7465 7374 2049 5076 363c 2f74 643e 3c2f test IPv6

    test IPv6 │ │ │ -00031cb0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -00031cc0: 2f74 6573 745f 7065 6572 5f6c 6973 742e /test_peer_list. │ │ │ -00031cd0: 6370 703a 3132 3734 3c2f 6834 3e3c 7072 cpp:1274

    relevanc │ │ │ -00031d50: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_p │ │ │ -00031d90: 6565 725f 6c69 7374 2e63 7070 3a31 3237 eer_list.cpp:127 │ │ │ -00031da0: 353c 2f61 3e3c 2f74 643e 3c74 643e 7465 5te │ │ │ -00031db0: 7374 2063 6f6e 6e65 6374 5f74 6f5f 7065 st connect_to_pe │ │ │ -00031dc0: 6572 2829 2066 6169 6c69 6e67 3c2f 7464 er() failing

    test c │ │ │ -00031e20: 6f6e 6e65 6374 5f74 6f5f 7065 6572 2829 onnect_to_peer() │ │ │ -00031e30: 2066 6169 6c69 6e67 3c2f 6832 3e3c 6834 failing

    ../test/test_pe │ │ │ -00031e50: 6572 5f6c 6973 742e 6370 703a 3132 3735 er_list.cpp:1275 │ │ │ -00031e60: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -00031ea0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00031eb0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00031ec0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00031ed0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -00031ee0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -00031f10: 742f 7465 7374 5f70 6565 725f 6c69 7374  t/test_peer_list
    │ │ │ -00031f20: 2e63 7070 3a31 3237 363c 2f61 3e3c 2f74  .cpp:1276test conne
    │ │ │ -00031f40: 6374 696f 6e5f 636c 6f73 6564 3c2f 7464  ction_closed

    test c │ │ │ -00031fa0: 6f6e 6e65 6374 696f 6e5f 636c 6f73 6564 onnection_closed │ │ │ -00031fb0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -00031fc0: 2f74 6573 745f 7065 6572 5f6c 6973 742e /test_peer_list. │ │ │ -00031fd0: 6370 703a 3132 3736 3c2f 6834 3e3c 7072 cpp:1276

    relevanc │ │ │ -00032050: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_p │ │ │ -00032090: 6565 725f 6c69 7374 2e63 7070 3a31 3237 eer_list.cpp:127 │ │ │ -000320a0: 373c 2f61 3e3c 2f74 643e 3c74 643e 636f 7co │ │ │ -000320b0: 6e6e 6563 7420 6361 6e64 6964 6174 6573 nnect candidates │ │ │ -000320c0: 2072 6563 616c 6375 6c61 7469 6f6e 2077 recalculation w │ │ │ -000320d0: 6865 6e20 696e 6372 656d 656e 7469 6e67 hen incrementing │ │ │ -000320e0: 2066 6169 6c63 6f75 6e74 3c2f 7464 3e3c failcount< │ │ │ -000320f0: 2f74 723e 3c74 7220 6964 3d22 3130 3922 /tr>

    connect │ │ │ -00032140: 6361 6e64 6964 6174 6573 2072 6563 616c candidates recal │ │ │ -00032150: 6375 6c61 7469 6f6e 2077 6865 6e20 696e culation when in │ │ │ -00032160: 6372 656d 656e 7469 6e67 2066 6169 6c63 crementing failc │ │ │ -00032170: 6f75 6e74 3c2f 6832 3e3c 6834 3e2e 2e2f ount

    ../ │ │ │ -00032180: 7465 7374 2f74 6573 745f 7065 6572 5f6c test/test_peer_l │ │ │ -00032190: 6973 742e 6370 703a 3132 3737 3c2f 6834 ist.cpp:1277

    rele
    │ │ │ -00032210: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -00032250: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e  st_torrent_info.
    │ │ │ -00032260: 6370 703a 3437 373c 2f61 3e3c 2f74 643e  cpp:477
    │ │ │ -00032270: 3c74 643e 7465 7374 2072 656d 6170 5f66  test remap_f
    │ │ │ -00032280: 696c 6573 3c2f 7464 3e3c 2f74 723e 3c74  ilestest remap_fil
    │ │ │ -000322e0: 6573 3c2f 6832 3e3c 6834 3e2e 2e2f 7465  es

    ../te │ │ │ -000322f0: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ -00032300: 696e 666f 2e63 7070 3a34 3737 3c2f 6834 info.cpp:477

    rele
    │ │ │ -00032380: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -000323c0: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e  st_torrent_info.
    │ │ │ -000323d0: 6370 703a 3437 383c 2f61 3e3c 2f74 643e  cpp:478
    │ │ │ -000323e0: 3c74 643e 746f 7272 656e 7420 7769 7468  torrent with
    │ │ │ -000323f0: 2027 7027 2028 7061 6466 696c 6529 2061   'p' (padfile) a
    │ │ │ -00032400: 7474 7269 6275 7465 3c2f 7464 3e3c 2f74  ttribute

    torrent wi │ │ │ -00032460: 7468 2027 7027 2028 7061 6466 696c 6529 th 'p' (padfile) │ │ │ -00032470: 2061 7474 7269 6275 7465 3c2f 6832 3e3c attribute

    < │ │ │ -00032480: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ -00032490: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ -000324a0: 3a34 3738 3c2f 6834 3e3c 7072 6520 7374 :478
    
    │ │ │ -00032510: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ -00032520: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ -00032550: 2f74 6573 742f 7465 7374 5f74 6f72 7265  /test/test_torre
    │ │ │ -00032560: 6e74 5f69 6e66 6f2e 6370 703a 3437 393c  nt_info.cpp:479<
    │ │ │ -00032570: 2f61 3e3c 2f74 643e 3c74 643e 746f 7272  /a>torr
    │ │ │ -00032580: 656e 7420 7769 7468 2027 6827 2028 6869  ent with 'h' (hi
    │ │ │ -00032590: 6464 656e 2920 6174 7472 6962 7574 653c  dden) attribute<
    │ │ │ -000325a0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d  /td>

    tor │ │ │ -000325f0: 7265 6e74 2077 6974 6820 2768 2720 2868 rent with 'h' (h │ │ │ -00032600: 6964 6465 6e29 2061 7474 7269 6275 7465 idden) attribute │ │ │ -00032610: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -00032620: 2f74 6573 745f 746f 7272 656e 745f 696e /test_torrent_in │ │ │ -00032630: 666f 2e63 7070 3a34 3739 3c2f 6834 3e3c fo.cpp:479

    < │ │ │ -00032640: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00032650: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00032660: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00032670: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">< │ │ │ -00032680: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000326b0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000326c0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../test/test │ │ │ -000326f0: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ -00032700: 703a 3438 303c 2f61 3e3c 2f74 643e 3c74 p:480torrent with ' │ │ │ -00032720: 7827 2028 6578 6563 7574 6162 6c65 2920 x' (executable) │ │ │ -00032730: 6174 7472 6962 7574 653c 2f74 643e 3c2f attribute

    torrent w │ │ │ -00032790: 6974 6820 2778 2720 2865 7865 6375 7461 ith 'x' (executa │ │ │ -000327a0: 626c 6529 2061 7474 7269 6275 7465 3c2f ble) attribute

    ../test/t │ │ │ -000327c0: 6573 745f 746f 7272 656e 745f 696e 666f est_torrent_info │ │ │ -000327d0: 2e63 7070 3a34 3830 3c2f 6834 3e3c 7072 .cpp:480

    relevanc │ │ │ -00032850: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_t │ │ │ -00032890: 6f72 7265 6e74 5f69 6e66 6f2e 6370 703a orrent_info.cpp: │ │ │ -000328a0: 3438 313c 2f61 3e3c 2f74 643e 3c74 643e 481 │ │ │ -000328b0: 746f 7272 656e 7420 7769 7468 2027 6c27 torrent with 'l' │ │ │ -000328c0: 2028 7379 6d6c 696e 6b29 2061 7474 7269 (symlink) attri │ │ │ -000328d0: 6275 7465 3c2f 7464 3e3c 2f74 723e 3c74 butetorrent with ' │ │ │ -00032930: 6c27 2028 7379 6d6c 696e 6b29 2061 7474 l' (symlink) att │ │ │ -00032940: 7269 6275 7465 3c2f 6832 3e3c 6834 3e2e ribute

    . │ │ │ -00032950: 2e2f 7465 7374 2f74 6573 745f 746f 7272 ./test/test_torr │ │ │ -00032960: 656e 745f 696e 666f 2e63 7070 3a34 3831 ent_info.cpp:481 │ │ │ -00032970: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -000329b0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -000329c0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -000329d0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -000329e0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -000329f0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -00032a20: 742f 7465 7374 5f74 6f72 7265 6e74 5f69  t/test_torrent_i
    │ │ │ -00032a30: 6e66 6f2e 6370 703a 3438 323c 2f61 3e3c  nfo.cpp:482<
    │ │ │ -00032a40: 2f74 643e 3c74 643e 746f 7272 656e 7420  /td>torrent 
    │ │ │ -00032a50: 7769 7468 206d 756c 7469 706c 6520 7472  with multiple tr
    │ │ │ -00032a60: 6163 6b65 7273 2069 6e20 6d75 6c74 6970  ackers in multip
    │ │ │ -00032a70: 6c65 2074 6965 7273 2c20 6d61 6b69 6e67  le tiers, making
    │ │ │ -00032a80: 2073 7572 6520 7765 2073 6875 6666 6c65   sure we shuffle
    │ │ │ -00032a90: 2074 6865 6d20 2868 6f77 2064 6f20 796f   them (how do yo
    │ │ │ -00032aa0: 7520 7465 7374 2073 6875 6666 6c69 6e67  u test shuffling
    │ │ │ -00032ab0: 3f2c 206c 6f61 6420 6974 206d 756c 7469  ?, load it multi
    │ │ │ -00032ac0: 706c 6520 7469 6d65 7320 616e 6420 6d61  ple times and ma
    │ │ │ -00032ad0: 6b65 2073 7572 6520 6974 2773 2069 6e20  ke sure it's in 
    │ │ │ -00032ae0: 6469 6666 6572 656e 7420 6f72 6465 7220  different order 
    │ │ │ -00032af0: 6174 206c 6561 7374 206f 6e63 6529 3c2f  at least once)

    torr │ │ │ -00032b50: 656e 7420 7769 7468 206d 756c 7469 706c ent with multipl │ │ │ -00032b60: 6520 7472 6163 6b65 7273 2069 6e20 6d75 e trackers in mu │ │ │ -00032b70: 6c74 6970 6c65 2074 6965 7273 2c20 6d61 ltiple tiers, ma │ │ │ -00032b80: 6b69 6e67 2073 7572 6520 7765 0a73 6875 king sure we.shu │ │ │ -00032b90: 6666 6c65 2074 6865 6d20 2868 6f77 2064 ffle them (how d │ │ │ -00032ba0: 6f20 796f 7520 7465 7374 2073 6875 6666 o you test shuff │ │ │ -00032bb0: 6c69 6e67 3f2c 206c 6f61 6420 6974 206d ling?, load it m │ │ │ -00032bc0: 756c 7469 706c 6520 7469 6d65 7320 616e ultiple times an │ │ │ -00032bd0: 6420 6d61 6b65 0a73 7572 6520 6974 2773 d make.sure it's │ │ │ -00032be0: 2069 6e20 6469 6666 6572 656e 7420 6f72 in different or │ │ │ -00032bf0: 6465 7220 6174 206c 6561 7374 206f 6e63 der at least onc │ │ │ -00032c00: 6529 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 e)

    ../te │ │ │ -00032c10: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ -00032c20: 696e 666f 2e63 7070 3a34 3832 3c2f 6834 info.cpp:482

    rele
    │ │ │ -00032ca0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -00032ce0: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e  st_torrent_info.
    │ │ │ -00032cf0: 6370 703a 3438 353c 2f61 3e3c 2f74 643e  cpp:485
    │ │ │ -00032d00: 3c74 643e 746f 7272 656e 7473 2077 6974  torrents wit
    │ │ │ -00032d10: 6820 6120 7a65 726f 2d6c 656e 6774 6820  h a zero-length 
    │ │ │ -00032d20: 6e61 6d65 3c2f 7464 3e3c 2f74 723e 3c74  nametorrents with 
    │ │ │ -00032d80: 6120 7a65 726f 2d6c 656e 6774 6820 6e61  a zero-length na
    │ │ │ -00032d90: 6d65 3c2f 6832 3e3c 6834 3e2e 2e2f 7465  me

    ../te │ │ │ -00032da0: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ -00032db0: 696e 666f 2e63 7070 3a34 3835 3c2f 6834 info.cpp:485

    rele
    │ │ │ -00032e30: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -00032e70: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e  st_torrent_info.
    │ │ │ -00032e80: 6370 703a 3438 363c 2f61 3e3c 2f74 643e  cpp:486
    │ │ │ -00032e90: 3c74 643e 746f 7272 656e 7420 7769 7468  torrent with
    │ │ │ -00032ea0: 2061 206e 6f6e 2d64 6963 7469 6f6e 6172   a non-dictionar
    │ │ │ -00032eb0: 7920 696e 666f 2d73 6563 7469 6f6e 3c2f  y info-section

    torr │ │ │ -00032f10: 656e 7420 7769 7468 2061 206e 6f6e 2d64 ent with a non-d │ │ │ -00032f20: 6963 7469 6f6e 6172 7920 696e 666f 2d73 ictionary info-s │ │ │ -00032f30: 6563 7469 6f6e 3c2f 6832 3e3c 6834 3e2e ection

    . │ │ │ -00032f40: 2e2f 7465 7374 2f74 6573 745f 746f 7272 ./test/test_torr │ │ │ -00032f50: 656e 745f 696e 666f 2e63 7070 3a34 3836 ent_info.cpp:486 │ │ │ -00032f60: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -00032fa0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00032fb0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00032fc0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00032fd0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -00032fe0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -00033010: 742f 7465 7374 5f74 6f72 7265 6e74 5f69  t/test_torrent_i
    │ │ │ -00033020: 6e66 6f2e 6370 703a 3438 373c 2f61 3e3c  nfo.cpp:487<
    │ │ │ -00033030: 2f74 643e 3c74 643e 746f 7272 656e 7473  /td>torrents
    │ │ │ -00033040: 2077 6974 6820 4448 5420 6e6f 6465 733c   with DHT nodes<
    │ │ │ -00033050: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d  /td>

    tor │ │ │ -000330a0: 7265 6e74 7320 7769 7468 2044 4854 206e rents with DHT n │ │ │ -000330b0: 6f64 6573 3c2f 6832 3e3c 6834 3e2e 2e2f odes

    ../ │ │ │ -000330c0: 7465 7374 2f74 6573 745f 746f 7272 656e test/test_torren │ │ │ -000330d0: 745f 696e 666f 2e63 7070 3a34 3837 3c2f t_info.cpp:487

    re │ │ │ -00033150: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ -00033190: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ -000331a0: 6f2e 6370 703a 3438 383c 2f61 3e3c 2f74 o.cpp:488torrent wi │ │ │ -000331c0: 7468 2075 726c 2d6c 6973 7420 6173 2061 th url-list as a │ │ │ -000331d0: 2073 696e 676c 6520 7374 7269 6e67 3c2f single string

    torr │ │ │ -00033230: 656e 7420 7769 7468 2075 726c 2d6c 6973 ent with url-lis │ │ │ -00033240: 7420 6173 2061 2073 696e 676c 6520 7374 t as a single st │ │ │ -00033250: 7269 6e67 3c2f 6832 3e3c 6834 3e2e 2e2f ring

    ../ │ │ │ -00033260: 7465 7374 2f74 6573 745f 746f 7272 656e test/test_torren │ │ │ -00033270: 745f 696e 666f 2e63 7070 3a34 3838 3c2f t_info.cpp:488

    re │ │ │ -000332f0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ -00033330: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ -00033340: 6f2e 6370 703a 3438 393c 2f61 3e3c 2f74 o.cpp:489torrent wi │ │ │ -00033360: 7468 2068 7474 7020 7365 6564 2061 7320 th http seed as │ │ │ -00033370: 6120 7369 6e67 6c65 2073 7472 696e 673c a single string< │ │ │ -00033380: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    tor │ │ │ -000333d0: 7265 6e74 2077 6974 6820 6874 7470 2073 rent with http s │ │ │ -000333e0: 6565 6420 6173 2061 2073 696e 676c 6520 eed as a single │ │ │ -000333f0: 7374 7269 6e67 3c2f 6832 3e3c 6834 3e2e string

    . │ │ │ -00033400: 2e2f 7465 7374 2f74 6573 745f 746f 7272 ./test/test_torr │ │ │ -00033410: 656e 745f 696e 666f 2e63 7070 3a34 3839 ent_info.cpp:489 │ │ │ -00033420: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -00033460: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00033470: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00033480: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00033490: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -000334a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -000334d0: 742f 7465 7374 5f74 6f72 7265 6e74 5f69  t/test_torrent_i
    │ │ │ -000334e0: 6e66 6f2e 6370 703a 3439 303c 2f61 3e3c  nfo.cpp:490<
    │ │ │ -000334f0: 2f74 643e 3c74 643e 746f 7272 656e 7420  /td>torrent 
    │ │ │ -00033500: 7769 7468 2061 2063 6f6d 6d65 6e74 3c2f  with a comment

    torr │ │ │ -00033560: 656e 7420 7769 7468 2061 2063 6f6d 6d65 ent with a comme │ │ │ -00033570: 6e74 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 nt

    ../te │ │ │ -00033580: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ -00033590: 696e 666f 2e63 7070 3a34 3930 3c2f 6834 info.cpp:490

    rele
    │ │ │ -00033610: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -00033650: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e  st_torrent_info.
    │ │ │ -00033660: 6370 703a 3439 313c 2f61 3e3c 2f74 643e  cpp:491
    │ │ │ -00033670: 3c74 643e 746f 7272 656e 7420 7769 7468  torrent with
    │ │ │ -00033680: 2061 6e20 5353 4c20 6365 7274 3c2f 7464   an SSL cert

    torren │ │ │ -000336e0: 7420 7769 7468 2061 6e20 5353 4c20 6365 t with an SSL ce │ │ │ -000336f0: 7274 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 rt

    ../te │ │ │ -00033700: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ -00033710: 696e 666f 2e63 7070 3a34 3931 3c2f 6834 info.cpp:491

    rele
    │ │ │ -00033790: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -000337d0: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e  st_torrent_info.
    │ │ │ -000337e0: 6370 703a 3439 323c 2f61 3e3c 2f74 643e  cpp:492
    │ │ │ -000337f0: 3c74 643e 746f 7272 656e 7420 7769 7468  torrent with
    │ │ │ -00033800: 2061 7474 7269 6275 7465 7320 2865 7865   attributes (exe
    │ │ │ -00033810: 6375 7461 626c 6520 616e 6420 6869 6464  cutable and hidd
    │ │ │ -00033820: 656e 293c 2f74 643e 3c2f 7472 3e3c 7472  en)

    torrent with at │ │ │ -00033880: 7472 6962 7574 6573 2028 6578 6563 7574 tributes (execut │ │ │ -00033890: 6162 6c65 2061 6e64 2068 6964 6465 6e29 able and hidden) │ │ │ -000338a0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -000338b0: 2f74 6573 745f 746f 7272 656e 745f 696e /test_torrent_in │ │ │ -000338c0: 666f 2e63 7070 3a34 3932 3c2f 6834 3e3c fo.cpp:492

    < │ │ │ -000338d0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000338e0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000338f0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00033900: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ -00033910: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00033940: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00033950: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -00033980: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ -00033990: 703a 3439 333c 2f61 3e3c 2f74 643e 3c74 p:493torrent_info c │ │ │ -000339b0: 6f6e 7374 7275 6374 6f72 2074 6861 7420 onstructor that │ │ │ -000339c0: 7461 6b65 7320 616e 2069 6e76 616c 6964 takes an invalid │ │ │ -000339d0: 2062 656e 636f 6465 6420 6275 6666 6572 bencoded buffer │ │ │ -000339e0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    to │ │ │ -00033a30: 7272 656e 745f 696e 666f 2063 6f6e 7374 rrent_info const │ │ │ -00033a40: 7275 6374 6f72 2074 6861 7420 7461 6b65 ructor that take │ │ │ -00033a50: 7320 616e 2069 6e76 616c 6964 2062 656e s an invalid ben │ │ │ -00033a60: 636f 6465 6420 6275 6666 6572 3c2f 6832 coded buffer

    ../test/tes │ │ │ -00033a80: 745f 746f 7272 656e 745f 696e 666f 2e63 t_torrent_info.c │ │ │ -00033a90: 7070 3a34 3933 3c2f 6834 3e3c 7072 6520 pp:493

    
    │ │ │ -00033ae0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -00033b10: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -00033b20: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -00033b30: 7074 3a65 7870 616e 6428 3132 3529 223e  pt:expand(125)">
    │ │ │ -00033b40: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72  ../test/test_tor
    │ │ │ -00033b50: 7265 6e74 5f69 6e66 6f2e 6370 703a 3439  rent_info.cpp:49
    │ │ │ -00033b60: 343c 2f61 3e3c 2f74 643e 3c74 643e 7665  4ve
    │ │ │ -00033b70: 7269 6679 5f65 6e63 6f64 696e 6720 7769  rify_encoding wi
    │ │ │ -00033b80: 7468 2061 2073 7472 696e 6720 7468 6174  th a string that
    │ │ │ -00033b90: 2074 7269 6767 6572 7320 6368 6172 6163   triggers charac
    │ │ │ -00033ba0: 7465 7220 7265 706c 6163 656d 656e 743c  ter replacement<
    │ │ │ -00033bb0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d  /td>

    ver │ │ │ -00033c00: 6966 795f 656e 636f 6469 6e67 2077 6974 ify_encoding wit │ │ │ -00033c10: 6820 6120 7374 7269 6e67 2074 6861 7420 h a string that │ │ │ -00033c20: 7472 6967 6765 7273 2063 6861 7261 6374 triggers charact │ │ │ -00033c30: 6572 2072 6570 6c61 6365 6d65 6e74 3c2f er replacement

    ../test/t │ │ │ -00033c50: 6573 745f 746f 7272 656e 745f 696e 666f est_torrent_info │ │ │ -00033c60: 2e63 7070 3a34 3934 3c2f 6834 3e3c 7072 .cpp:494

    .{ "v2_in │ │ │ -00033cb0: 7661 6c69 645f 7069 6563 655f 6c61 7965 valid_piece_laye │ │ │ -00033cc0: 722e 746f 7272 656e 7422 2c20 6572 726f r.torrent", erro │ │ │ -00033cd0: 7273 3a3a 746f 7272 656e 745f 696e 7661 rs::torrent_inva │ │ │ -00033ce0: 6c69 645f 7069 6563 655f 6c61 7965 727d lid_piece_layer} │ │ │ -00033cf0: 2c0a 097b 2022 7632 5f69 6e76 616c 6964 ,..{ "v2_invalid │ │ │ -00033d00: 5f70 6965 6365 5f6c 6179 6572 5f72 6f6f _piece_layer_roo │ │ │ -00033d10: 742e 746f 7272 656e 7422 2c20 6572 726f t.torrent", erro │ │ │ -00033d20: 7273 3a3a 746f 7272 656e 745f 696e 7661 rs::torrent_inva │ │ │ -00033d30: 6c69 645f 7069 6563 655f 6c61 7965 727d lid_piece_layer} │ │ │ -00033d40: 2c0a 097b 2022 7632 5f75 6e6b 6e6f 776e ,..{ "v2_unknown │ │ │ -00033d50: 5f70 6965 6365 5f6c 6179 6572 5f65 6e74 _piece_layer_ent │ │ │ -00033d60: 7279 2e74 6f72 7265 6e74 222c 2065 7272 ry.torrent", err │ │ │ -00033d70: 6f72 733a 3a74 6f72 7265 6e74 5f69 6e76 ors::torrent_inv │ │ │ -00033d80: 616c 6964 5f70 6965 6365 5f6c 6179 6572 alid_piece_layer │ │ │ -00033d90: 7d2c 0a09 7b20 2276 325f 696e 7661 6c69 },..{ "v2_invali │ │ │ -00033da0: 645f 7069 6563 655f 6c61 7965 725f 7369 d_piece_layer_si │ │ │ -00033db0: 7a65 2e74 6f72 7265 6e74 222c 2065 7272 ze.torrent", err │ │ │ -00033dc0: 6f72 733a 3a74 6f72 7265 6e74 5f69 6e76 ors::torrent_inv │ │ │ -00033dd0: 616c 6964 5f70 6965 6365 5f6c 6179 6572 alid_piece_layer │ │ │ -00033de0: 7d2c 0a09 7b20 2276 325f 6261 645f 6669 },..{ "v2_bad_fi │ │ │ -00033df0: 6c65 5f61 6c69 676e 6d65 6e74 2e74 6f72 le_alignment.tor │ │ │ -00033e00: 7265 6e74 222c 2065 7272 6f72 733a 3a74 rent", errors::t │ │ │ -00033e10: 6f72 7265 6e74 5f69 6e63 6f6e 7369 7374 orrent_inconsist │ │ │ -00033e20: 656e 745f 6669 6c65 737d 2c0a 097b 2022 ent_files},..{ " │ │ │ -00033e30: 7632 5f75 6e6f 7264 6572 6564 5f66 696c v2_unordered_fil │ │ │ -00033e40: 6573 2e74 6f72 7265 6e74 222c 2065 7272 es.torrent", err │ │ │ -00033e50: 6f72 733a 3a69 6e76 616c 6964 5f62 656e ors::invalid_ben │ │ │ -00033e60: 636f 6469 6e67 7d2c 0a09 7b20 2276 325f coding},..{ "v2_ │ │ │ -00033e70: 6f76 6572 6c6f 6e67 5f69 6e74 6567 6572 overlong_integer │ │ │ -00033e80: 2e74 6f72 7265 6e74 222c 2065 7272 6f72 .torrent", error │ │ │ -00033e90: 733a 3a69 6e76 616c 6964 5f62 656e 636f s::invalid_benco │ │ │ -00033ea0: 6469 6e67 7d2c 0a09 7b20 2276 325f 6d69 ding},..{ "v2_mi │ │ │ -00033eb0: 7373 696e 675f 6669 6c65 5f72 6f6f 745f ssing_file_root_ │ │ │ -00033ec0: 696e 7661 6c69 645f 7379 6d6c 696e 6b2e invalid_symlink. │ │ │ -00033ed0: 746f 7272 656e 7422 2c20 6572 726f 7273 torrent", errors │ │ │ -00033ee0: 3a3a 746f 7272 656e 745f 6d69 7373 696e ::torrent_missin │ │ │ -00033ef0: 675f 7069 6563 6573 5f72 6f6f 747d 2c0a g_pieces_root},. │ │ │ -00033f00: 097b 2022 7632 5f6c 6172 6765 5f66 696c .{ "v2_large_fil │ │ │ -00033f10: 652e 746f 7272 656e 7422 2c20 6572 726f e.torrent", erro │ │ │ -00033f20: 7273 3a3a 746f 7272 656e 745f 696e 7661 rs::torrent_inva │ │ │ -00033f30: 6c69 645f 6c65 6e67 7468 7d2c 0a09 7b20 lid_length},..{ │ │ │ -00033f40: 2276 325f 6c61 7267 655f 6f66 6673 6574 "v2_large_offset │ │ │ -00033f50: 2e74 6f72 7265 6e74 222c 2065 7272 6f72 .torrent", error │ │ │ -00033f60: 733a 3a74 6f6f 5f6d 616e 795f 7069 6563 s::too_many_piec │ │ │ -00033f70: 6573 5f69 6e5f 746f 7272 656e 747d 2c0a es_in_torrent},. │ │ │ -00033f80: 097b 2022 7632 5f70 6965 6365 5f73 697a .{ "v2_piece_siz │ │ │ -00033f90: 652e 746f 7272 656e 7422 2c20 6572 726f e.torrent", erro │ │ │ -00033fa0: 7273 3a3a 746f 7272 656e 745f 6d69 7373 rs::torrent_miss │ │ │ -00033fb0: 696e 675f 7069 6563 655f 6c65 6e67 7468 ing_piece_length │ │ │ -00033fc0: 7d2c 0a09 7b20 2276 325f 696e 7661 6c69 },..{ "v2_invali │ │ │ -00033fd0: 645f 7061 645f 6669 6c65 2e74 6f72 7265 d_pad_file.torre │ │ │ -00033fe0: 6e74 222c 2065 7272 6f72 733a 3a74 6f72 nt", errors::tor │ │ │ -00033ff0: 7265 6e74 5f69 6e76 616c 6964 5f70 6164 rent_invalid_pad │ │ │ -00034000: 5f66 696c 657d 2c0a 097b 2022 7632 5f7a _file},..{ "v2_z │ │ │ -00034010: 6572 6f5f 726f 6f74 2e74 6f72 7265 6e74 ero_root.torrent │ │ │ -00034020: 222c 2065 7272 6f72 733a 3a74 6f72 7265 ", errors::torre │ │ │ -00034030: 6e74 5f6d 6973 7369 6e67 5f70 6965 6365 nt_missing_piece │ │ │ -00034040: 735f 726f 6f74 7d2c 0a09 7b20 2276 325f s_root},..{ "v2_ │ │ │ -00034050: 7a65 726f 5f72 6f6f 745f 736d 616c 6c2e zero_root_small. │ │ │ -00034060: 746f 7272 656e 7422 2c20 6572 726f 7273 torrent", errors │ │ │ -00034070: 3a3a 746f 7272 656e 745f 6d69 7373 696e ::torrent_missin │ │ │ -00034080: 675f 7069 6563 6573 5f72 6f6f 747d 2c0a g_pieces_root},. │ │ │ -00034090: 097b 2022 7632 5f65 6d70 7479 5f66 696c .{ "v2_empty_fil │ │ │ -000340a0: 656e 616d 652e 746f 7272 656e 7422 2c20 ename.torrent", │ │ │ -000340b0: 6572 726f 7273 3a3a 746f 7272 656e 745f errors::torrent_ │ │ │ -000340c0: 6669 6c65 5f70 6172 7365 5f66 6169 6c65 file_parse_faile │ │ │ -000340d0: 647d 2c0a 097b 2022 6475 706c 6963 6174 d},..{ "duplicat │ │ │ -000340e0: 655f 6669 6c65 7332 2e74 6f72 7265 6e74 e_files2.torrent │ │ │ -000340f0: 222c 2065 7272 6f72 733a 3a74 6f6f 5f6d ", errors::too_m │ │ │ -00034100: 616e 795f 6475 706c 6963 6174 655f 6669 any_duplicate_fi │ │ │ -00034110: 6c65 6e61 6d65 737d 2c0a 7d3b 0a0a 7d20 lenames},.};..} │ │ │ -00034120: 2f2f 2061 6e6f 6e79 6d6f 7573 206e 616d // anonymous nam │ │ │ -00034130: 6573 7061 6365 0a0a 3c64 6976 2073 7479 espace..
    .
    #if │ │ │ -00034170: 2054 4f52 5245 4e54 5f41 4249 5f56 4552 TORRENT_ABI_VER │ │ │ -00034180: 5349 4f4e 2026 6c74 3b20 340a 544f 5252 SION < 4.TORR │ │ │ -00034190: 454e 545f 5445 5354 2861 6464 5f74 7261 ENT_TEST(add_tra │ │ │ -000341a0: 636b 6572 290a 7b0a 0974 6f72 7265 6e74 cker).{..torrent │ │ │ -000341b0: 5f69 6e66 6f20 7469 2869 6e66 6f5f 6861 _info ti(info_ha │ │ │ -000341c0: 7368 5f74 2873 6861 315f 6861 7368 2822 sh_t(sha1_hash(" │ │ │ -000341d0: 2020 2020 2020 2020 2020 2020 2020 2020 │ │ │ -000341e0: 2020 2022 2929 293b 0a09 5445 5354 5f45 ")));..TEST_E │ │ │ -000341f0: 5155 414c 2874 692e 7472 6163 6b65 7273 QUAL(ti.trackers │ │ │ -00034200: 2829 2e73 697a 6528 292c 2030 293b 0a0a ().size(), 0);.. │ │ │ -00034210: 0974 692e 6164 645f 7472 6163 6b65 7228 .ti.add_tracker( │ │ │ -00034220: 2268 7474 703a 2f2f 7465 7374 2e63 6f6d "http://test.com │ │ │ -00034230: 2f61 6e6e 6f75 6e63 6522 293b 0a09 5445 /announce");..TE │ │ │ -00034240: 5354 5f45 5155 414c 2874 692e 7472 6163 ST_EQUAL(ti.trac │ │ │ -00034250: 6b65 7273 2829 2e73 697a 6528 292c 2031 kers().size(), 1 │ │ │ -00034260: 293b 0a0a 0961 6e6e 6f75 6e63 655f 656e );...announce_en │ │ │ -00034270: 7472 7920 6165 203d 2074 692e 7472 6163 try ae = ti.trac │ │ │ -00034280: 6b65 7273 2829 5b30 5d3b 0a09 5445 5354 kers()[0];..TEST │ │ │ -00034290: 5f45 5155 414c 2861 652e 7572 6c2c 2022 _EQUAL(ae.url, " │ │ │ -000342a0: 6874 7470 3a2f 2f74 6573 742e 636f 6d2f http://test.com/ │ │ │ -000342b0: 616e 6e6f 756e 6365 2229 3b0a 0a09 7469 announce");...ti │ │ │ -000342c0: 2e63 6c65 6172 5f74 7261 636b 6572 7328 .clear_trackers( │ │ │ -000342d0: 293b 0a09 5445 5354 5f45 5155 414c 2874 );..TEST_EQUAL(t │ │ │ -000342e0: 692e 7472 6163 6b65 7273 2829 2e73 697a i.trackers().siz │ │ │ -000342f0: 6528 292c 2030 293b 0a7d 0a0a 544f 5252 e(), 0);.}..TORR │ │ │ -00034300: 454e 545f 5445 5354 2875 726c 5f6c 6973 ENT_TEST(url_lis │ │ │ -00034310: 745f 6475 706c 6963 6174 6529 0a7b 0a09 t_duplicate).{.. │ │ │ -00034320: 656e 7472 7920 696e 666f 3b0a 0969 6e66 entry info;..inf │ │ │ -00034330: 6f5b 2270 6965 6365 7322 5d20 3d20 2261 o["pieces"] = "a │ │ │ -00034340: 6161 6161 6161 6161 6161 6161 6161 6161 aaaaaaaaaaaaaaaa │ │ │ -00034350: 6161 6122 3b0a 0969 6e66 6f5b 226e 616d aaa";..info["nam │ │ │ -00034360: 652e 7574 662d 3822 5d20 3d20 2274 6573 e.utf-8"] = "tes │ │ │ -00034370: 7431 223b 0a09 696e 666f 5b22 6e61 6d65 t1";..info["name │ │ │ -00034380: 225d 203d 2022 7465 7374 5f5f 223b 0a09 "] = "test__";.. │ │ │ -00034390: 696e 666f 5b22 7069 6563 6520 6c65 6e67 info["piece leng │ │ │ -000343a0: 7468 225d 203d 2031 3620 2a20 3130 3234 th"] = 16 * 1024 │ │ │ -000343b0: 3b0a 0969 6e66 6f5b 226c 656e 6774 6822 ;..info["length" │ │ │ -000343c0: 5d20 3d20 3332 3435 3b0a 0965 6e74 7279 ] = 3245;..entry │ │ │ -000343d0: 3a3a 6c69 7374 5f74 7970 6520 6c3b 0a09 ::list_type l;.. │ │ │ -000343e0: 6c2e 7075 7368 5f62 6163 6b28 656e 7472 l.push_back(entr │ │ │ -000343f0: 7928 2268 7474 703a 2f2f 666f 6f2e 636f y("http://foo.co │ │ │ -00034400: 6d2f 6261 7231 2229 293b 0a09 6c2e 7075 m/bar1"));..l.pu │ │ │ -00034410: 7368 5f62 6163 6b28 656e 7472 7928 2268 sh_back(entry("h │ │ │ -00034420: 7474 703a 2f2f 666f 6f2e 636f 6d2f 6261 ttp://foo.com/ba │ │ │ -00034430: 7231 2229 293b 202f 2f20 266c 743b 2d20 r1")); // <- │ │ │ -00034440: 6475 706c 6963 6174 650a 096c 2e70 7573 duplicate..l.pus │ │ │ -00034450: 685f 6261 636b 2865 6e74 7279 2822 6874 h_back(entry("ht │ │ │ -00034460: 7470 3a2f 2f66 6f6f 2e63 6f6d 2f62 6172 tp://foo.com/bar │ │ │ -00034470: 3222 2929 3b0a 0965 6e74 7279 2063 6f6e 2"));..entry con │ │ │ -00034480: 7374 2065 286c 293b 0a09 656e 7472 7920 st e(l);..entry │ │ │ -00034490: 746f 7272 656e 743b 0a3c 2f70 7265 3e3c torrent;.
    < │ │ │ -000344a0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000344d0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000344e0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -00034510: 5f74 696d 6573 7461 6d70 5f68 6973 746f _timestamp_histo │ │ │ -00034520: 7279 2e63 7070 3a33 313c 2f61 3e3c 2f74 ry.cpp:31test the c │ │ │ -00034540: 6173 6520 7768 6572 6520 7765 2068 6176 ase where we hav │ │ │ -00034550: 6520 3e20 3132 3020 7361 6d70 6c65 7320 e > 120 samples │ │ │ -00034560: 2861 6e64 2068 6176 6520 7468 6520 6261 (and have the ba │ │ │ -00034570: 7365 2064 656c 6179 2061 6374 7561 6c6c se delay actuall │ │ │ -00034580: 7920 6265 2075 7064 6174 6564 293c 2f74 y be updated)

    test │ │ │ -000345e0: 7468 6520 6361 7365 2077 6865 7265 2077 the case where w │ │ │ -000345f0: 6520 6861 7665 203e 2031 3230 2073 616d e have > 120 sam │ │ │ -00034600: 706c 6573 2028 616e 6420 6861 7665 2074 ples (and have t │ │ │ -00034610: 6865 2062 6173 6520 6465 6c61 7920 6163 he base delay ac │ │ │ -00034620: 7475 616c 6c79 2062 6520 7570 6461 7465 tually be update │ │ │ -00034630: 6429 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 d)

    ../te │ │ │ -00034640: 7374 2f74 6573 745f 7469 6d65 7374 616d st/test_timestam │ │ │ -00034650: 705f 6869 7374 6f72 792e 6370 703a 3331 p_history.cpp:31 │ │ │ -00034660: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -000346a0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -000346b0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -000346c0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -000346d0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -000346e0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -00034710: 742f 7465 7374 5f74 696d 6573 7461 6d70  t/test_timestamp
    │ │ │ -00034720: 5f68 6973 746f 7279 2e63 7070 3a33 323c  _history.cpp:32<
    │ │ │ -00034730: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374  /a>test
    │ │ │ -00034740: 2074 6865 2063 6173 6520 7768 6572 6520   the case where 
    │ │ │ -00034750: 6120 7361 6d70 6c65 2069 7320 6c6f 7765  a sample is lowe
    │ │ │ -00034760: 7220 7468 616e 2074 6865 2068 6973 746f  r than the histo
    │ │ │ -00034770: 7279 2065 6e74 7279 2062 7574 206e 6f74  ry entry but not
    │ │ │ -00034780: 206c 6f77 6572 2074 6861 6e20 7468 6520   lower than the 
    │ │ │ -00034790: 6261 7365 3c2f 7464 3e3c 2f74 723e 3c74  basetest the case 
    │ │ │ -000347f0: 7768 6572 6520 6120 7361 6d70 6c65 2069  where a sample i
    │ │ │ -00034800: 7320 6c6f 7765 7220 7468 616e 2074 6865  s lower than the
    │ │ │ -00034810: 2068 6973 746f 7279 2065 6e74 7279 2062   history entry b
    │ │ │ -00034820: 7574 206e 6f74 206c 6f77 6572 2074 6861  ut not lower tha
    │ │ │ -00034830: 6e20 7468 6520 6261 7365 3c2f 6832 3e3c  n the base

    < │ │ │ -00034840: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ -00034850: 7469 6d65 7374 616d 705f 6869 7374 6f72 timestamp_histor │ │ │ -00034860: 792e 6370 703a 3332 3c2f 6834 3e3c 7072 y.cpp:32#include │ │ │ -000348b0: 226c 6962 746f 7272 656e 742f 6175 785f "libtorrent/aux_ │ │ │ -000348c0: 2f74 696d 6573 7461 6d70 5f68 6973 746f /timestamp_histo │ │ │ -000348d0: 7279 2e68 7070 220a 0a54 4f52 5245 4e54 ry.hpp"..TORRENT │ │ │ -000348e0: 5f54 4553 5428 7469 6d65 7374 616d 705f _TEST(timestamp_ │ │ │ -000348f0: 6869 7374 6f72 7929 0a7b 0a09 7573 696e history).{..usin │ │ │ -00034900: 6720 6e61 6d65 7370 6163 6520 6c74 3b0a g namespace lt;. │ │ │ -00034910: 0a09 6175 783a 3a74 696d 6573 7461 6d70 ..aux::timestamp │ │ │ -00034920: 5f68 6973 746f 7279 2068 3b0a 0954 4553 _history h;..TES │ │ │ -00034930: 545f 4551 5541 4c28 682e 6164 645f 7361 T_EQUAL(h.add_sa │ │ │ -00034940: 6d70 6c65 2830 7833 322c 2066 616c 7365 mple(0x32, false │ │ │ -00034950: 292c 2030 293b 0a09 5445 5354 5f45 5155 ), 0);..TEST_EQU │ │ │ -00034960: 414c 2868 2e62 6173 6528 292c 2030 7833 AL(h.base(), 0x3 │ │ │ -00034970: 3229 3b0a 0954 4553 545f 4551 5541 4c28 2);..TEST_EQUAL( │ │ │ -00034980: 682e 6164 645f 7361 6d70 6c65 2830 7833 h.add_sample(0x3 │ │ │ -00034990: 332c 2066 616c 7365 292c 2030 7831 293b 3, false), 0x1); │ │ │ -000349a0: 0a09 5445 5354 5f45 5155 414c 2868 2e62 ..TEST_EQUAL(h.b │ │ │ -000349b0: 6173 6528 292c 2030 7833 3229 3b0a 0954 ase(), 0x32);..T │ │ │ -000349c0: 4553 545f 4551 5541 4c28 682e 6164 645f EST_EQUAL(h.add_ │ │ │ -000349d0: 7361 6d70 6c65 2830 7833 3433 332c 2066 sample(0x3433, f │ │ │ -000349e0: 616c 7365 292c 2030 7833 3430 3129 3b0a alse), 0x3401);. │ │ │ -000349f0: 0954 4553 545f 4551 5541 4c28 682e 6261 .TEST_EQUAL(h.ba │ │ │ -00034a00: 7365 2829 2c20 3078 3332 293b 0a09 5445 se(), 0x32);..TE │ │ │ -00034a10: 5354 5f45 5155 414c 2868 2e61 6464 5f73 ST_EQUAL(h.add_s │ │ │ -00034a20: 616d 706c 6528 3078 3330 2c20 6661 6c73 ample(0x30, fals │ │ │ -00034a30: 6529 2c20 3029 3b0a 0954 4553 545f 4551 e), 0);..TEST_EQ │ │ │ -00034a40: 5541 4c28 682e 6261 7365 2829 2c20 3078 UAL(h.base(), 0x │ │ │ -00034a50: 3330 293b 0a0a 092f 2f20 7465 7374 2074 30);...// test t │ │ │ -00034a60: 6861 7420 7772 6170 7069 6e67 206f 6620 hat wrapping of │ │ │ -00034a70: 7468 6520 7469 6d65 7374 616d 7020 6973 the timestamp is │ │ │ -00034a80: 2070 726f 7065 726c 7920 6861 6e64 6c65 properly handle │ │ │ -00034a90: 640a 0968 2e61 6464 5f73 616d 706c 6528 d..h.add_sample( │ │ │ -00034aa0: 3078 6666 6666 6666 6633 2c20 6661 6c73 0xfffffff3, fals │ │ │ -00034ab0: 6529 3b0a 0954 4553 545f 4551 5541 4c28 e);..TEST_EQUAL( │ │ │ -00034ac0: 682e 6261 7365 2829 2c20 3078 6666 6666 h.base(), 0xffff │ │ │ -00034ad0: 6666 6633 293b 0a0a 3c64 6976 2073 7479 fff3);..
    }.
    .< │ │ │ -00034b10: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00034b20: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00034b30: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00034b40: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00034b50: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../tes │ │ │ -00034b80: 742f 7465 7374 5f66 6173 745f 6578 7465 t/test_fast_exte │ │ │ -00034b90: 6e73 696f 6e2e 6370 703a 3131 3938 3c2f nsion.cpp:1198test │ │ │ -00034bb0: 7365 6e64 696e 6720 696e 7661 6c69 6420 sending invalid │ │ │ -00034bc0: 7265 7175 6573 7473 2028 6f75 7420 6f66 requests (out of │ │ │ -00034bd0: 2062 6f75 6e64 2070 6965 6365 2069 6e64 bound piece ind │ │ │ -00034be0: 6578 2c20 6f66 6673 6574 7320 616e 6420 ex, offsets and │ │ │ -00034bf0: 7369 7a65 7329 3c2f 7464 3e3c 2f74 723e sizes) │ │ │ -00034c00: 3c74 7220 6964 3d22 3132 3822 2073 7479 │ │ │ -00034c30: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00034c40: 3c68 323e 7465 7374 2073 656e 6469 6e67

    test sending │ │ │ -00034c50: 2069 6e76 616c 6964 2072 6571 7565 7374 invalid request │ │ │ -00034c60: 7320 286f 7574 206f 6620 626f 756e 6420 s (out of bound │ │ │ -00034c70: 7069 6563 6520 696e 6465 782c 206f 6666 piece index, off │ │ │ -00034c80: 7365 7473 2061 6e64 0a73 697a 6573 293c sets and.sizes)< │ │ │ -00034c90: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ -00034ca0: 7465 7374 5f66 6173 745f 6578 7465 6e73 test_fast_extens │ │ │ -00034cb0: 696f 6e2e 6370 703a 3131 3938 3c2f 6834 ion.cpp:1198

    rele
    │ │ │ -00034d30: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0
    ../test/te │ │ │ -00034d70: 7374 5f66 6c61 6773 2e63 7070 3a31 3332 st_flags.cpp:132 │ │ │ -00034d80: 3c2f 613e 3c2f 7464 3e3c 7464 3e63 6861 cha │ │ │ -00034d90: 6e67 6520 746f 2061 2064 6966 6665 7265 nge to a differe │ │ │ -00034da0: 6e74 2074 6573 7420 7365 7475 702e 2063 nt test setup. c │ │ │ -00034db0: 7572 7265 6e74 6c79 2061 6c77 6179 7320 urrently always │ │ │ -00034dc0: 7061 7573 6564 2e20 7465 7374 5f73 6574 paused. test_set │ │ │ -00034dd0: 5f61 6674 6572 5f61 6464 2874 6f72 7265 _after_add(torre │ │ │ -00034de0: 6e74 5f66 6c61 6773 3a3a 7061 7573 6564 nt_flags::paused │ │ │ -00034df0: 293b 2074 6573 745f 756e 7365 745f 6166 ); test_unset_af │ │ │ -00034e00: 7465 725f 6164 6428 746f 7272 656e 745f ter_add(torrent_ │ │ │ -00034e10: 666c 6167 733a 3a70 6175 7365 6429 3b3c flags::paused);< │ │ │ -00034e20: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    cha │ │ │ -00034e70: 6e67 6520 746f 2061 2064 6966 6665 7265 nge to a differe │ │ │ -00034e80: 6e74 2074 6573 7420 7365 7475 702e 2063 nt test setup. c │ │ │ -00034e90: 7572 7265 6e74 6c79 2061 6c77 6179 7320 urrently always │ │ │ -00034ea0: 7061 7573 6564 2e0a 7465 7374 5f73 6574 paused..test_set │ │ │ -00034eb0: 5f61 6674 6572 5f61 6464 2874 6f72 7265 _after_add(torre │ │ │ -00034ec0: 6e74 5f66 6c61 6773 3a3a 7061 7573 6564 nt_flags::paused │ │ │ -00034ed0: 293b 0a74 6573 745f 756e 7365 745f 6166 );.test_unset_af │ │ │ -00034ee0: 7465 725f 6164 6428 746f 7272 656e 745f ter_add(torrent_ │ │ │ -00034ef0: 666c 6167 733a 3a70 6175 7365 6429 3b3c flags::paused);< │ │ │ -00034f00: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ -00034f10: 7465 7374 5f66 6c61 6773 2e63 7070 3a31 test_flags.cpp:1 │ │ │ -00034f20: 3332 3c2f 6834 3e3c 7072 6520 7374 796c 32

    {..// share-mod
    │ │ │ -00034f70: 650a 0974 6573 745f 6164 645f 616e 645f  e..test_add_and_
    │ │ │ -00034f80: 6765 745f 666c 6167 7328 746f 7272 656e  get_flags(torren
    │ │ │ -00034f90: 745f 666c 6167 733a 3a73 6861 7265 5f6d  t_flags::share_m
    │ │ │ -00034fa0: 6f64 6529 3b0a 0974 6573 745f 7365 745f  ode);..test_set_
    │ │ │ -00034fb0: 6166 7465 725f 6164 6428 746f 7272 656e  after_add(torren
    │ │ │ -00034fc0: 745f 666c 6167 733a 3a73 6861 7265 5f6d  t_flags::share_m
    │ │ │ -00034fd0: 6f64 6529 3b0a 0974 6573 745f 756e 7365  ode);..test_unse
    │ │ │ -00034fe0: 745f 6166 7465 725f 6164 6428 746f 7272  t_after_add(torr
    │ │ │ -00034ff0: 656e 745f 666c 6167 733a 3a73 6861 7265  ent_flags::share
    │ │ │ -00035000: 5f6d 6f64 6529 3b0a 7d0a 2365 6e64 6966  _mode);.}.#endif
    │ │ │ -00035010: 0a0a 544f 5252 454e 545f 5445 5354 2866  ..TORRENT_TEST(f
    │ │ │ -00035020: 6c61 675f 6170 706c 795f 6970 5f66 696c  lag_apply_ip_fil
    │ │ │ -00035030: 7465 7229 0a7b 0a09 2f2f 2061 7070 6c79  ter).{..// apply
    │ │ │ -00035040: 2d69 702d 6669 6c74 6572 0a09 7465 7374  -ip-filter..test
    │ │ │ -00035050: 5f61 6464 5f61 6e64 5f67 6574 5f66 6c61  _add_and_get_fla
    │ │ │ -00035060: 6773 2874 6f72 7265 6e74 5f66 6c61 6773  gs(torrent_flags
    │ │ │ -00035070: 3a3a 6170 706c 795f 6970 5f66 696c 7465  ::apply_ip_filte
    │ │ │ -00035080: 7229 3b0a 0974 6573 745f 7365 745f 6166  r);..test_set_af
    │ │ │ -00035090: 7465 725f 6164 6428 746f 7272 656e 745f  ter_add(torrent_
    │ │ │ -000350a0: 666c 6167 733a 3a61 7070 6c79 5f69 705f  flags::apply_ip_
    │ │ │ -000350b0: 6669 6c74 6572 293b 0a09 7465 7374 5f75  filter);..test_u
    │ │ │ -000350c0: 6e73 6574 5f61 6674 6572 5f61 6464 2874  nset_after_add(t
    │ │ │ -000350d0: 6f72 7265 6e74 5f66 6c61 6773 3a3a 6170  orrent_flags::ap
    │ │ │ -000350e0: 706c 795f 6970 5f66 696c 7465 7229 3b0a  ply_ip_filter);.
    │ │ │ -000350f0: 7d0a 0a54 4f52 5245 4e54 5f54 4553 5428  }..TORRENT_TEST(
    │ │ │ -00035100: 666c 6167 5f70 6175 7365 6429 0a7b 0a09  flag_paused).{..
    │ │ │ -00035110: 2f2f 2070 6175 7365 640a 0974 6573 745f  // paused..test_
    │ │ │ -00035120: 6164 645f 616e 645f 6765 745f 666c 6167  add_and_get_flag
    │ │ │ -00035130: 7328 746f 7272 656e 745f 666c 6167 733a  s(torrent_flags:
    │ │ │ -00035140: 3a70 6175 7365 6429 3b0a 3c64 6976 2073  :paused);.
    }.
    │ │ │ -00035180: 0a54 4f52 5245 4e54 5f54 4553 5428 666c .TORRENT_TEST(fl │ │ │ -00035190: 6167 5f61 7574 6f5f 6d61 6e61 6765 6429 ag_auto_managed) │ │ │ -000351a0: 0a7b 0a09 2f2f 2061 7574 6f2d 6d61 6e61 .{..// auto-mana │ │ │ -000351b0: 6765 640a 0974 6573 745f 6164 645f 616e ged..test_add_an │ │ │ -000351c0: 645f 6765 745f 666c 6167 7328 746f 7272 d_get_flags(torr │ │ │ -000351d0: 656e 745f 666c 6167 733a 3a61 7574 6f5f ent_flags::auto_ │ │ │ -000351e0: 6d61 6e61 6765 6429 3b0a 0974 6573 745f managed);..test_ │ │ │ -000351f0: 7365 745f 6166 7465 725f 6164 6428 746f set_after_add(to │ │ │ -00035200: 7272 656e 745f 666c 6167 733a 3a61 7574 rrent_flags::aut │ │ │ -00035210: 6f5f 6d61 6e61 6765 6429 3b0a 0974 6573 o_managed);..tes │ │ │ -00035220: 745f 756e 7365 745f 6166 7465 725f 6164 t_unset_after_ad │ │ │ -00035230: 6428 746f 7272 656e 745f 666c 6167 733a d(torrent_flags: │ │ │ -00035240: 3a61 7574 6f5f 6d61 6e61 6765 6429 3b0a :auto_managed);. │ │ │ -00035250: 7d0a 0a2f 2f20 7375 7065 7220 7365 6564 }..// super seed │ │ │ -00035260: 696e 6720 6d6f 6465 2069 7320 6175 746f ing mode is auto │ │ │ -00035270: 6d61 7469 6361 6c6c 7920 7475 726e 6564 matically turned │ │ │ -00035280: 206f 6666 2069 6620 7765 2772 6520 6e6f off if we're no │ │ │ -00035290: 7420 6120 7365 6564 0a2f 2f20 7369 6e63 t a seed.// sinc │ │ │ -000352a0: 6520 7468 6520 706f 7369 785f 6469 736b e the posix_disk │ │ │ -000352b0: 5f69 6f20 6973 206e 6f74 2074 6872 6561 _io is not threa │ │ │ -000352c0: 6465 642c 2074 6869 7320 7769 6c6c 2068 ded, this will h │ │ │ -000352d0: 6170 7065 6e20 696d 6d65 6469 6174 656c appen immediatel │ │ │ -000352e0: 790a 2369 6620 544f 5252 454e 545f 4841 y.#if TORRENT_HA │ │ │ -000352f0: 5645 5f4d 4d41 500a 2369 666e 6465 6620 VE_MMAP.#ifndef │ │ │ -00035300: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00035310: 5355 5045 5253 4545 4449 4e47 0a54 4f52 SUPERSEEDING.TOR │ │ │ -00035320: 5245 4e54 5f54 4553 5428 666c 6167 5f73 RENT_TEST(flag_s │ │ │ -00035330: 7570 6572 5f73 6565 6469 6e67 290a 7b0a uper_seeding).{. │ │ │ -00035340: 092f 2f20 7375 7065 722d 7365 6564 696e .// super-seedin │ │ │ -00035350: 670a 0974 6573 745f 6164 645f 616e 645f g..test_add_and_ │ │ │ -00035360: 6765 745f 666c 6167 7328 746f 7272 656e get_flags(torren │ │ │ -00035370: 745f 666c 6167 733a 3a73 7570 6572 5f73 t_flags::super_s │ │ │ -00035380: 6565 6469 6e67 293b 0a09 7465 7374 5f75 eeding);..test_u │ │ │ -00035390: 6e73 6574 5f61 6674 6572 5f61 6464 2874 nset_after_add(t │ │ │ -000353a0: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7375 orrent_flags::su │ │ │ -000353b0: 7065 725f 7365 6564 696e 6729 3b0a 0974 per_seeding);..t │ │ │ -000353c0: 6573 745f 7365 745f 6166 7465 725f 6164 est_set_after_ad │ │ │ -000353d0: 6428 746f 7272 656e 745f 666c 6167 733a d(torrent_flags: │ │ │ -000353e0: 3a73 7570 6572 5f73 6565 6469 6e67 293b :super_seeding); │ │ │ -000353f0: 0a7d 0a23 656e 6469 660a 2365 6e64 6966 .}.#endif.#endif │ │ │ -00035400: 0a0a 544f 5252 454e 545f 5445 5354 2866 ..TORRENT_TEST(f │ │ │ -00035410: 6c61 675f 7365 7175 656e 7469 616c 5f64 lag_sequential_d │ │ │ -00035420: 6f77 6e6c 6f61 6429 0a7b 0a09 2f2f 2073 ownload).{..// s │ │ │ -00035430: 6571 7565 6e74 6961 6c2d 646f 776e 6c6f equential-downlo │ │ │ -00035440: 6164 0a09 7465 7374 5f61 6464 5f61 6e64 ad..test_add_and │ │ │ -00035450: 5f67 6574 5f66 6c61 6773 2874 6f72 7265 _get_flags(torre │ │ │ -00035460: 6e74 5f66 6c61 6773 3a3a 7365 7175 656e nt_flags::sequen │ │ │ -00035470: 7469 616c 5f64 6f77 6e6c 6f61 6429 3b0a tial_download);. │ │ │ -00035480: 0974 6573 745f 7365 745f 6166 7465 725f .test_set_after_ │ │ │ -00035490: 6164 6428 746f 7272 656e 745f 666c 6167 add(torrent_flag │ │ │ -000354a0: 733a 3a73 6571 7565 6e74 6961 6c5f 646f s::sequential_do │ │ │ -000354b0: 776e 6c6f 6164 293b 0a09 7465 7374 5f75 wnload);..test_u │ │ │ -000354c0: 6e73 6574 5f61 6674 6572 5f61 6464 2874 nset_after_add(t │ │ │ -000354d0: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7365 orrent_flags::se │ │ │ -000354e0: 7175 656e 7469 616c 5f64 6f77 6e6c 6f61 quential_downloa │ │ │ -000354f0: 6429 3b0a 7d0a 3c2f 7072 653e 3c2f 7464 d);.}.
    relevance │ │ │ -00035530: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00035540: 3c61 2068 7265 663d 226a 6176 6173 6372 ../test/test_re │ │ │ -00035570: 736f 6c76 655f 6c69 6e6b 732e 6370 703a solve_links.cpp: │ │ │ -00035580: 3733 3c2f 613e 3c2f 7464 3e3c 7464 3e74 73t │ │ │ -00035590: 6573 7420 6669 6c65 7320 7769 7468 2064 est files with d │ │ │ -000355a0: 6966 6665 7265 6e74 2070 6965 6365 2073 ifferent piece s │ │ │ -000355b0: 697a 6520 286e 6567 6174 6976 6520 7465 ize (negative te │ │ │ -000355c0: 7374 293c 2f74 643e 3c2f 7472 3e3c 7472 st)

    test files with │ │ │ -00035620: 2064 6966 6665 7265 6e74 2070 6965 6365 different piece │ │ │ -00035630: 2073 697a 6520 286e 6567 6174 6976 6520 size (negative │ │ │ -00035640: 7465 7374 293c 2f68 323e 3c68 343e 2e2e test)

    .. │ │ │ -00035650: 2f74 6573 742f 7465 7374 5f72 6573 6f6c /test/test_resol │ │ │ -00035660: 7665 5f6c 696e 6b73 2e63 7070 3a37 333c ve_links.cpp:73< │ │ │ -00035670: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .{
    │ │ │ -000356b0: 2022 7465 7374 3222 2c20 2274 6573 7431   "test2", "test1
    │ │ │ -000356c0: 5f70 6164 5f66 696c 6573 222c 2030 7d2c  _pad_files", 0},
    │ │ │ -000356d0: 0a09 7b20 2274 6573 7433 222c 2022 7465  ..{ "test3", "te
    │ │ │ -000356e0: 7374 315f 7061 645f 6669 6c65 7322 2c20  st1_pad_files", 
    │ │ │ -000356f0: 307d 2c0a 097b 2022 7465 7374 3222 2c20  0},..{ "test2", 
    │ │ │ -00035700: 2274 6573 7431 5f73 696e 676c 6522 2c20  "test1_single", 
    │ │ │ -00035710: 307d 2c0a 0a09 2f2f 2074 6865 7365 2061  0},...// these a
    │ │ │ -00035720: 7265 2061 6c6c 2070 6164 6465 642e 2054  re all padded. T
    │ │ │ -00035730: 6865 2066 6972 7374 2073 6d61 6c6c 2066  he first small f
    │ │ │ -00035740: 696c 6520 7769 6c6c 2061 6363 6964 656e  ile will acciden
    │ │ │ -00035750: 7461 6c6c 7920 616c 736f 0a09 2f2f 206d  tally also..// m
    │ │ │ -00035760: 6174 6368 2c20 6576 656e 2074 686f 7567  atch, even thoug
    │ │ │ -00035770: 6820 6974 2773 206e 6f74 2074 6169 6c20  h it's not tail 
    │ │ │ -00035780: 7061 6464 6564 2c20 7468 6520 666f 6c6c  padded, the foll
    │ │ │ -00035790: 6f77 696e 6720 6669 6c65 2069 7320 6964  owing file is id
    │ │ │ -000357a0: 656e 7469 6361 6c0a 097b 2022 7465 7374  entical..{ "test
    │ │ │ -000357b0: 325f 7061 645f 6669 6c65 7322 2c20 2274  2_pad_files", "t
    │ │ │ -000357c0: 6573 7431 5f70 6164 5f66 696c 6573 222c  est1_pad_files",
    │ │ │ -000357d0: 2032 7d2c 0a09 7b20 2274 6573 7433 5f70   2},..{ "test3_p
    │ │ │ -000357e0: 6164 5f66 696c 6573 222c 2022 7465 7374  ad_files", "test
    │ │ │ -000357f0: 315f 7061 645f 6669 6c65 7322 2c20 327d  1_pad_files", 2}
    │ │ │ -00035800: 2c0a 097b 2022 7465 7374 335f 7061 645f  ,..{ "test3_pad_
    │ │ │ -00035810: 6669 6c65 7322 2c20 2274 6573 7432 5f70  files", "test2_p
    │ │ │ -00035820: 6164 5f66 696c 6573 222c 2032 7d2c 0a09  ad_files", 2},..
    │ │ │ -00035830: 7b20 2274 6573 7431 5f70 6164 5f66 696c  { "test1_pad_fil
    │ │ │ -00035840: 6573 222c 2022 7465 7374 325f 7061 645f  es", "test2_pad_
    │ │ │ -00035850: 6669 6c65 7322 2c20 327d 2c0a 097b 2022  files", 2},..{ "
    │ │ │ -00035860: 7465 7374 315f 7061 645f 6669 6c65 7322  test1_pad_files"
    │ │ │ -00035870: 2c20 2274 6573 7433 5f70 6164 5f66 696c  , "test3_pad_fil
    │ │ │ -00035880: 6573 222c 2032 7d2c 0a09 7b20 2274 6573  es", 2},..{ "tes
    │ │ │ -00035890: 7432 5f70 6164 5f66 696c 6573 222c 2022  t2_pad_files", "
    │ │ │ -000358a0: 7465 7374 335f 7061 645f 6669 6c65 7322  test3_pad_files"
    │ │ │ -000358b0: 2c20 327d 2c0a 0a09 2f2f 206f 6e65 206d  , 2},...// one m
    │ │ │ -000358c0: 6967 6874 2065 7870 6563 7420 7468 6973  ight expect this
    │ │ │ -000358d0: 2074 6f20 776f 726b 2c20 6275 7420 7369   to work, but si
    │ │ │ -000358e0: 6e63 6520 7468 6520 7461 696c 206f 6620  nce the tail of 
    │ │ │ -000358f0: 7468 6520 7369 6e67 6c65 2066 696c 650a  the single file.
    │ │ │ -00035900: 092f 2f20 746f 7272 656e 7420 6973 206e  .// torrent is n
    │ │ │ -00035910: 6f74 2070 6164 6465 642c 2074 6865 206c  ot padded, the l
    │ │ │ -00035920: 6173 7420 7069 6563 6520 6861 7368 2077  ast piece hash w
    │ │ │ -00035930: 6f6e 2774 206d 6174 6368 0a09 7b20 2274  on't match..{ "t
    │ │ │ -00035940: 6573 7431 5f70 6164 5f66 696c 6573 222c  est1_pad_files",
    │ │ │ -00035950: 2022 7465 7374 315f 7369 6e67 6c65 222c   "test1_single",
    │ │ │ -00035960: 2030 7d2c 0a0a 092f 2f20 6966 2069 7427   0},...// if it'
    │ │ │ -00035970: 7320 7061 6464 6564 206f 6e20 7468 6520  s padded on the 
    │ │ │ -00035980: 6f74 6865 7220 6861 6e64 2c20 6974 2077  other hand, it w
    │ │ │ -00035990: 696c 6c20 776f 726b 0a09 7b20 2274 6573  ill work..{ "tes
    │ │ │ -000359a0: 7431 5f70 6164 5f66 696c 6573 222c 2022  t1_pad_files", "
    │ │ │ -000359b0: 7465 7374 315f 7369 6e67 6c65 5f70 6164  test1_single_pad
    │ │ │ -000359c0: 6465 6422 2c20 317d 2c0a 0a3c 6469 7620  ded", 1},..
    };..
    │ │ │ -00035a30: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00035a40: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00035a70: 2f74 6573 742f 7465 7374 5f72 6573 6f6c /test/test_resol │ │ │ -00035a80: 7665 5f6c 696e 6b73 2e63 7070 3a37 363c ve_links.cpp:76< │ │ │ -00035a90: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ -00035aa0: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ -00035ab0: 7465 7374 2072 6573 6f6c 7669 6e67 206f test resolving o │ │ │ -00035ac0: 6620 6d6f 7265 2074 6861 6e20 6a75 7374 f more than just │ │ │ -00035ad0: 2032 2066 696c 6573 2061 7320 7765 6c6c 2 files as well │ │ │ -00035ae0: 2e20 6c69 6b65 2033 2073 696e 676c 6520 . like 3 single │ │ │ -00035af0: 6669 6c65 2074 6f72 7265 6e74 7320 6d65 file torrents me │ │ │ -00035b00: 7267 6564 2069 6e74 6f20 6f6e 652c 2072 rged into one, r │ │ │ -00035b10: 6573 6f6c 7669 6e67 2061 6c6c 2033 2066 esolving all 3 f │ │ │ -00035b20: 696c 6573 2e3c 2f74 643e 3c2f 7472 3e3c iles.< │ │ │ -00035b30: 7472 2069 643d 2231 3331 2220 7374 796c tr id="131" styl │ │ │ -00035b40: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00035b50: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00035b60: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00035b70: 6832 3e69 7420 776f 756c 6420 6265 206e h2>it would be n │ │ │ -00035b80: 6963 6520 746f 2074 6573 7420 7265 736f ice to test reso │ │ │ -00035b90: 6c76 696e 6720 6f66 206d 6f72 6520 7468 lving of more th │ │ │ -00035ba0: 616e 206a 7573 7420 3220 6669 6c65 7320 an just 2 files │ │ │ -00035bb0: 6173 2077 656c 6c2e 0a6c 696b 6520 3320 as well..like 3 │ │ │ -00035bc0: 7369 6e67 6c65 2066 696c 6520 746f 7272 single file torr │ │ │ -00035bd0: 656e 7473 206d 6572 6765 6420 696e 746f ents merged into │ │ │ -00035be0: 206f 6e65 2c20 7265 736f 6c76 696e 6720 one, resolving │ │ │ -00035bf0: 616c 6c20 3320 6669 6c65 732e 3c2f 6832 all 3 files.

    ../test/tes │ │ │ -00035c10: 745f 7265 736f 6c76 655f 6c69 6e6b 732e t_resolve_links. │ │ │ -00035c20: 6370 703a 3736 3c2f 6834 3e3c 7072 6520 cpp:76

    .{ "test2",
    │ │ │ -00035c70: 2022 7465 7374 315f 7369 6e67 6c65 222c   "test1_single",
    │ │ │ -00035c80: 2030 7d2c 0a0a 092f 2f20 7468 6573 6520   0},...// these 
    │ │ │ -00035c90: 6172 6520 616c 6c20 7061 6464 6564 2e20  are all padded. 
    │ │ │ -00035ca0: 5468 6520 6669 7273 7420 736d 616c 6c20  The first small 
    │ │ │ -00035cb0: 6669 6c65 2077 696c 6c20 6163 6369 6465  file will accide
    │ │ │ -00035cc0: 6e74 616c 6c79 2061 6c73 6f0a 092f 2f20  ntally also..// 
    │ │ │ -00035cd0: 6d61 7463 682c 2065 7665 6e20 7468 6f75  match, even thou
    │ │ │ -00035ce0: 6768 2069 7427 7320 6e6f 7420 7461 696c  gh it's not tail
    │ │ │ -00035cf0: 2070 6164 6465 642c 2074 6865 2066 6f6c   padded, the fol
    │ │ │ -00035d00: 6c6f 7769 6e67 2066 696c 6520 6973 2069  lowing file is i
    │ │ │ -00035d10: 6465 6e74 6963 616c 0a09 7b20 2274 6573  dentical..{ "tes
    │ │ │ -00035d20: 7432 5f70 6164 5f66 696c 6573 222c 2022  t2_pad_files", "
    │ │ │ -00035d30: 7465 7374 315f 7061 645f 6669 6c65 7322  test1_pad_files"
    │ │ │ -00035d40: 2c20 327d 2c0a 097b 2022 7465 7374 335f  , 2},..{ "test3_
    │ │ │ -00035d50: 7061 645f 6669 6c65 7322 2c20 2274 6573  pad_files", "tes
    │ │ │ -00035d60: 7431 5f70 6164 5f66 696c 6573 222c 2032  t1_pad_files", 2
    │ │ │ -00035d70: 7d2c 0a09 7b20 2274 6573 7433 5f70 6164  },..{ "test3_pad
    │ │ │ -00035d80: 5f66 696c 6573 222c 2022 7465 7374 325f  _files", "test2_
    │ │ │ -00035d90: 7061 645f 6669 6c65 7322 2c20 327d 2c0a  pad_files", 2},.
    │ │ │ -00035da0: 097b 2022 7465 7374 315f 7061 645f 6669  .{ "test1_pad_fi
    │ │ │ -00035db0: 6c65 7322 2c20 2274 6573 7432 5f70 6164  les", "test2_pad
    │ │ │ -00035dc0: 5f66 696c 6573 222c 2032 7d2c 0a09 7b20  _files", 2},..{ 
    │ │ │ -00035dd0: 2274 6573 7431 5f70 6164 5f66 696c 6573  "test1_pad_files
    │ │ │ -00035de0: 222c 2022 7465 7374 335f 7061 645f 6669  ", "test3_pad_fi
    │ │ │ -00035df0: 6c65 7322 2c20 327d 2c0a 097b 2022 7465  les", 2},..{ "te
    │ │ │ -00035e00: 7374 325f 7061 645f 6669 6c65 7322 2c20  st2_pad_files", 
    │ │ │ -00035e10: 2274 6573 7433 5f70 6164 5f66 696c 6573  "test3_pad_files
    │ │ │ -00035e20: 222c 2032 7d2c 0a0a 092f 2f20 6f6e 6520  ", 2},...// one 
    │ │ │ -00035e30: 6d69 6768 7420 6578 7065 6374 2074 6869  might expect thi
    │ │ │ -00035e40: 7320 746f 2077 6f72 6b2c 2062 7574 2073  s to work, but s
    │ │ │ -00035e50: 696e 6365 2074 6865 2074 6169 6c20 6f66  ince the tail of
    │ │ │ -00035e60: 2074 6865 2073 696e 676c 6520 6669 6c65   the single file
    │ │ │ -00035e70: 0a09 2f2f 2074 6f72 7265 6e74 2069 7320  ..// torrent is 
    │ │ │ -00035e80: 6e6f 7420 7061 6464 6564 2c20 7468 6520  not padded, the 
    │ │ │ -00035e90: 6c61 7374 2070 6965 6365 2068 6173 6820  last piece hash 
    │ │ │ -00035ea0: 776f 6e27 7420 6d61 7463 680a 097b 2022  won't match..{ "
    │ │ │ -00035eb0: 7465 7374 315f 7061 645f 6669 6c65 7322  test1_pad_files"
    │ │ │ -00035ec0: 2c20 2274 6573 7431 5f73 696e 676c 6522  , "test1_single"
    │ │ │ -00035ed0: 2c20 307d 2c0a 0a09 2f2f 2069 6620 6974  , 0},...// if it
    │ │ │ -00035ee0: 2773 2070 6164 6465 6420 6f6e 2074 6865  's padded on the
    │ │ │ -00035ef0: 206f 7468 6572 2068 616e 642c 2069 7420   other hand, it 
    │ │ │ -00035f00: 7769 6c6c 2077 6f72 6b0a 097b 2022 7465  will work..{ "te
    │ │ │ -00035f10: 7374 315f 7061 645f 6669 6c65 7322 2c20  st1_pad_files", 
    │ │ │ -00035f20: 2274 6573 7431 5f73 696e 676c 655f 7061  "test1_single_pa
    │ │ │ -00035f30: 6464 6564 222c 2031 7d2c 0a0a 7d3b 0a0a  dded", 1},..};..
    │ │ │ -00035f40: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ -00035f70: 2f64 6976 3e54 4f52 5245 4e54 5f54 4553 /div>TORRENT_TES │ │ │ -00035f80: 5428 7265 736f 6c76 655f 6c69 6e6b 7329 T(resolve_links) │ │ │ -00035f90: 0a7b 0a09 7374 643a 3a73 7472 696e 6720 .{..std::string │ │ │ -00035fa0: 7061 7468 203d 2063 6f6d 6269 6e65 5f70 path = combine_p │ │ │ -00035fb0: 6174 6828 7061 7265 6e74 5f70 6174 6828 ath(parent_path( │ │ │ -00035fc0: 6375 7272 656e 745f 776f 726b 696e 675f current_working_ │ │ │ -00035fd0: 6469 7265 6374 6f72 7928 2929 0a09 092c directory())..., │ │ │ -00035fe0: 2022 6d75 7461 626c 655f 7465 7374 5f74 "mutable_test_t │ │ │ -00035ff0: 6f72 7265 6e74 7322 293b 0a0a 0966 6f72 orrents");...for │ │ │ -00036000: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ -00036010: 6c74 3b20 696e 7428 7369 7a65 6f66 2874 lt; int(sizeof(t │ │ │ -00036020: 6573 745f 746f 7272 656e 7473 292f 7369 est_torrents)/si │ │ │ -00036030: 7a65 6f66 2874 6573 745f 746f 7272 656e zeof(test_torren │ │ │ -00036040: 7473 5b30 5d29 293b 202b 2b69 290a 097b ts[0])); ++i)..{ │ │ │ -00036050: 0a09 0974 6573 745f 746f 7272 656e 745f ...test_torrent_ │ │ │ -00036060: 7420 636f 6e73 7426 616d 703b 2065 203d t const& e = │ │ │ -00036070: 2074 6573 745f 746f 7272 656e 7473 5b69 test_torrents[i │ │ │ -00036080: 5d3b 0a0a 0909 7374 643a 3a73 7472 696e ];....std::strin │ │ │ -00036090: 6720 7020 3d20 636f 6d62 696e 655f 7061 g p = combine_pa │ │ │ -000360a0: 7468 2870 6174 682c 2065 2e66 696c 656e th(path, e.filen │ │ │ -000360b0: 616d 6531 2920 2b20 222e 746f 7272 656e ame1) + ".torren │ │ │ -000360c0: 7422 3b0a 0909 7374 643a 3a70 7269 6e74 t";...std::print │ │ │ -000360d0: 6628 226c 6f61 6469 6e67 2025 735c 6e22 f("loading %s\n" │ │ │ -000360e0: 2c20 702e 635f 7374 7228 2929 3b0a 0909 , p.c_str());... │ │ │ -000360f0: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ -00036100: 6c74 3b74 6f72 7265 6e74 5f69 6e66 6f20 lt;torrent_info │ │ │ -00036110: 636f 6e73 7426 6774 3b20 7469 3120 3d20 const> ti1 = │ │ │ -00036120: 6c6f 6164 5f74 6f72 7265 6e74 5f66 696c load_torrent_fil │ │ │ -00036130: 6528 7029 2e74 693b 0a0a 0909 7020 3d20 e(p).ti;....p = │ │ │ -00036140: 636f 6d62 696e 655f 7061 7468 2870 6174 combine_path(pat │ │ │ -00036150: 682c 2065 2e66 696c 656e 616d 6532 2920 h, e.filename2) │ │ │ -00036160: 2b20 222e 746f 7272 656e 7422 3b0a 0909 + ".torrent";... │ │ │ -00036170: 7374 643a 3a70 7269 6e74 6628 226c 6f61 std::printf("loa │ │ │ -00036180: 6469 6e67 2025 735c 6e22 2c20 702e 635f ding %s\n", p.c_ │ │ │ -00036190: 7374 7228 2929 3b0a 0909 6175 746f 2061 str());...auto a │ │ │ -000361a0: 7470 3220 3d20 6c6f 6164 5f74 6f72 7265 tp2 = load_torre │ │ │ -000361b0: 6e74 5f66 696c 6528 7029 3b0a 0909 7265 nt_file(p);...re │ │ │ -000361c0: 6e61 6d65 645f 6669 6c65 7320 7266 3b0a named_files rf;. │ │ │ -000361d0: 0909 7266 2e69 6d70 6f72 745f 6669 6c65 ..rf.import_file │ │ │ -000361e0: 6e61 6d65 7328 6174 7032 2e74 692d 2667 names(atp2.ti-&g │ │ │ -000361f0: 743b 6c61 796f 7574 2829 2c20 6174 7032 t;layout(), atp2 │ │ │ -00036200: 2e72 656e 616d 6564 5f66 696c 6573 293b .renamed_files); │ │ │ -00036210: 0a0a 0909 7374 643a 3a70 7269 6e74 6628 ....std::printf( │ │ │ -00036220: 2272 6573 6f6c 7669 6e67 5c6e 2229 3b0a "resolving\n");. │ │ │ -00036230: 0909 6175 783a 3a72 6573 6f6c 7665 5f6c ..aux::resolve_l │ │ │ -00036240: 696e 6b73 206c 2874 6931 293b 0a09 096c inks l(ti1);...l │ │ │ -00036250: 2e6d 6174 6368 282a 6174 7032 2e74 692c .match(*atp2.ti, │ │ │ -00036260: 2066 696c 656e 616d 6573 2861 7470 322e filenames(atp2. │ │ │ -00036270: 7469 2d26 6774 3b6c 6179 6f75 7428 292c ti->layout(), │ │ │ -00036280: 2072 6629 2c20 222e 2229 3b0a 0a09 0961 rf), ".");....a │ │ │ -00036290: 7578 3a3a 7665 6374 6f72 266c 743b 7374 ux::vector<st │ │ │ -000362a0: 643a 3a73 7472 696e 672c 2066 696c 655f d::string, file_ │ │ │ -000362b0: 696e 6465 785f 7426 6774 3b20 636f 6e73 index_t> cons │ │ │ -000362c0: 7426 616d 703b 206c 696e 6b73 203d 206c t& links = l │ │ │ -000362d0: 2e67 6574 5f6c 696e 6b73 2829 3b0a 0a09 .get_links();... │ │ │ -000362e0: 0961 7574 6f20 636f 6e73 7420 6e75 6d5f .auto const num_ │ │ │ -000362f0: 6d61 7463 6865 7320 3d20 7374 643a 3a73 matches = std::s │ │ │ -00036300: 697a 655f 7428 7374 643a 3a63 6f75 6e74 ize_t(std::count │ │ │ -00036310: 5f69 6628 6c69 6e6b 732e 6265 6769 6e28 _if(links.begin( │ │ │ -00036320: 292c 206c 696e 6b73 2e65 6e64 2829 0a09 ), links.end().. │ │ │ -00036330: 0909 2c20 5b5d 2873 7464 3a3a 7374 7269 .., [](std::stri │ │ │ -00036340: 6e67 2063 6f6e 7374 2661 6d70 3b20 6c69 ng const& li │ │ │ -00036350: 6e6b 2920 7b20 7265 7475 726e 2021 6c69 nk) { return !li │ │ │ -00036360: 6e6b 2e65 6d70 7479 2829 3b20 7d29 293b nk.empty(); })); │ │ │ -00036370: 0a0a 0909 2f2f 2073 6f6d 6520 6465 6275 ....// some debu │ │ │ -00036380: 6720 6f75 7470 7574 2069 6e20 6361 7365 g output in case │ │ │ -00036390: 2074 6865 2074 6573 7420 6661 696c 730a the test fails. │ │ │ -000363a0: 0909 6966 2028 6e75 6d5f 6d61 7463 6865 ..if (num_matche │ │ │ -000363b0: 7320 2667 743b 2065 2e65 7870 6563 7465 s > e.expecte │ │ │ -000363c0: 645f 6d61 7463 6865 7329 0a3c 2f70 7265 d_matches).
    rele │ │ │ -00036400: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../test/te │ │ │ -00036440: 7374 5f73 746f 7261 6765 2e63 7070 3a31 st_storage.cpp:1 │ │ │ -00036450: 3336 393c 2f61 3e3c 2f74 643e 3c74 643e 369 │ │ │ -00036460: 7468 6973 2073 686f 756c 6420 7461 6b65 this should take │ │ │ -00036470: 2061 2073 7061 6e3c 2f74 643e 3c2f 7472 a span

    this should │ │ │ -000364d0: 2074 616b 6520 6120 7370 616e 3c2f 6832 take a span

    ../test/tes │ │ │ -000364f0: 745f 7374 6f72 6167 652e 6370 703a 3133 t_storage.cpp:13 │ │ │ -00036500: 3639 3c2f 6834 3e3c 7072 6520 7374 796c 69

    {..unsigned cha
    │ │ │ -00036550: 7220 636f 6e73 742a 2070 203d 2072 6569  r const* p = rei
    │ │ │ -00036560: 6e74 6572 7072 6574 5f63 6173 7426 6c74  nterpret_cast<
    │ │ │ -00036570: 3b75 6e73 6967 6e65 6420 6368 6172 2063  ;unsigned char c
    │ │ │ -00036580: 6f6e 7374 2a26 6774 3b28 6275 662e 6461  onst*>(buf.da
    │ │ │ -00036590: 7461 2829 293b 0a09 666f 7220 2869 6e74  ta());..for (int
    │ │ │ -000365a0: 206b 203d 2030 3b20 6b20 266c 743b 2069   k = 0; k < i
    │ │ │ -000365b0: 6e74 2862 7566 2e73 697a 6528 2929 3b20  nt(buf.size()); 
    │ │ │ -000365c0: 2b2b 6b29 0a09 7b0a 0909 6966 2028 705b  ++k)..{...if (p[
    │ │ │ -000365d0: 6b5d 2021 3d20 2863 6f75 6e74 6572 2026  k] != (counter &
    │ │ │ -000365e0: 616d 703b 2030 7866 6629 2920 7265 7475  amp; 0xff)) retu
    │ │ │ -000365f0: 726e 2066 616c 7365 3b0a 0909 2b2b 636f  rn false;...++co
    │ │ │ -00036600: 756e 7465 723b 0a09 7d0a 0972 6574 7572  unter;..}..retur
    │ │ │ -00036610: 6e20 7472 7565 3b0a 7d0a 0a74 656d 706c  n true;.}..templ
    │ │ │ -00036620: 6174 6520 266c 743b 7479 7065 6e61 6d65  ate <typename
    │ │ │ -00036630: 2043 6861 7226 6774 3b0a 766f 6964 2061   Char>.void a
    │ │ │ -00036640: 6c6c 6f63 5f69 6f76 2873 7061 6e26 6c74  lloc_iov(span<
    │ │ │ -00036650: 3b43 6861 7226 6774 3b2a 2069 6f76 2c20  ;Char>* iov, 
    │ │ │ -00036660: 696e 7420 6e75 6d5f 6275 6673 290a 7b0a  int num_bufs).{.
    │ │ │ -00036670: 0966 6f72 2028 7374 643a 3a73 697a 655f  .for (std::size_
    │ │ │ -00036680: 7420 6920 3d20 303b 2069 2026 6c74 3b20  t i = 0; i < 
    │ │ │ -00036690: 7374 6174 6963 5f63 6173 7426 6c74 3b73  static_cast<s
    │ │ │ -000366a0: 697a 655f 7426 6774 3b28 6e75 6d5f 6275  ize_t>(num_bu
    │ │ │ -000366b0: 6673 293b 202b 2b69 290a 097b 0a09 0973  fs); ++i)..{...s
    │ │ │ -000366c0: 7464 3a3a 7369 7a65 5f74 2063 6f6e 7374  td::size_t const
    │ │ │ -000366d0: 206c 656e 203d 2073 7461 7469 635f 6361   len = static_ca
    │ │ │ -000366e0: 7374 266c 743b 7374 643a 3a73 697a 655f  st<std::size_
    │ │ │ -000366f0: 7426 6774 3b28 6e75 6d5f 6275 6673 2920  t>(num_bufs) 
    │ │ │ -00036700: 2a20 2869 202b 2031 293b 0a09 0969 6f76  * (i + 1);...iov
    │ │ │ -00036710: 5b69 5d20 3d20 7b20 6e65 7720 6368 6172  [i] = { new char
    │ │ │ -00036720: 5b6c 656e 5d2c 2073 7461 7469 635f 6361  [len], static_ca
    │ │ │ -00036730: 7374 266c 743b 7374 643a 3a70 7472 6469  st<std::ptrdi
    │ │ │ -00036740: 6666 5f74 2667 743b 286c 656e 2920 7d3b  ff_t>(len) };
    │ │ │ -00036750: 0a09 7d0a 7d0a 0a3c 6469 7620 7374 796c  ..}.}..
    template &l │ │ │ -00036790: 743b 7479 7065 6e61 6d65 2043 6861 7226 t;typename Char& │ │ │ -000367a0: 6774 3b0a 3c2f 6469 763e 766f 6964 2066 gt;.
    void f │ │ │ -000367b0: 7265 655f 696f 7628 7370 616e 266c 743b ree_iov(span< │ │ │ -000367c0: 4368 6172 2667 743b 2a20 696f 762c 2069 Char>* iov, i │ │ │ -000367d0: 6e74 206e 756d 5f62 7566 7329 0a7b 0a09 nt num_bufs).{.. │ │ │ -000367e0: 666f 7220 2869 6e74 2069 203d 2030 3b20 for (int i = 0; │ │ │ -000367f0: 6920 266c 743b 206e 756d 5f62 7566 733b i < num_bufs; │ │ │ -00036800: 202b 2b69 290a 097b 0a09 0964 656c 6574 ++i)..{...delet │ │ │ -00036810: 655b 5d20 696f 765b 695d 2e64 6174 6128 e[] iov[i].data( │ │ │ -00036820: 293b 0a09 0969 6f76 5b69 5d20 3d20 7b20 );...iov[i] = { │ │ │ -00036830: 6e75 6c6c 7074 722c 2030 207d 3b0a 097d nullptr, 0 };..} │ │ │ -00036840: 0a7d 0a0a 7d20 2f2f 2061 6e6f 6e79 6d6f .}..} // anonymo │ │ │ -00036850: 7573 206e 616d 6573 7061 6365 0a0a 544f us namespace..TO │ │ │ -00036860: 5252 454e 545f 5445 5354 2869 6f76 6563 RRENT_TEST(iovec │ │ │ -00036870: 5f61 6476 616e 6365 5f62 7566 7329 0a7b _advance_bufs).{ │ │ │ -00036880: 0a09 7370 616e 266c 743b 6368 6172 2667 ..span<char&g │ │ │ -00036890: 743b 2069 6f76 315b 3130 5d3b 0a09 7370 t; iov1[10];..sp │ │ │ -000368a0: 616e 266c 743b 6368 6172 2063 6f6e 7374 an<char const │ │ │ -000368b0: 2667 743b 2069 6f76 325b 3130 5d3b 0a09 > iov2[10];.. │ │ │ -000368c0: 616c 6c6f 635f 696f 7628 696f 7631 2c20 alloc_iov(iov1, │ │ │ -000368d0: 3130 293b 0a09 6669 6c6c 5f70 6174 7465 10);..fill_patte │ │ │ -000368e0: 726e 287b 696f 7631 2c20 3130 7d29 3b0a rn({iov1, 10});. │ │ │ -000368f0: 0a09 6d65 6d63 7079 2869 6f76 322c 2069 ..memcpy(iov2, i │ │ │ -00036900: 6f76 312c 2073 697a 656f 6628 696f 7631 ov1, sizeof(iov1 │ │ │ -00036910: 2929 3b0a 0a09 7370 616e 266c 743b 7370 ));...span<sp │ │ │ -00036920: 616e 266c 743b 6368 6172 2063 6f6e 7374 an<char const │ │ │ -00036930: 2667 743b 2667 743b 2069 6f76 203d 2069 >> iov = i │ │ │ -00036940: 6f76 323b 0a0a 092f 2f20 6164 7661 6e63 ov2;...// advanc │ │ │ -00036950: 6520 696f 7620 3133 2062 7974 6573 2e20 e iov 13 bytes. │ │ │ -00036960: 4d61 6b65 2073 7572 6520 7768 6174 2773 Make sure what's │ │ │ -00036970: 206c 6566 7420 6669 7473 2070 6174 7465 left fits patte │ │ │ -00036980: 726e 2031 2073 6869 6674 6564 0a09 2f2f rn 1 shifted..// │ │ │ -00036990: 2031 3320 6279 7465 730a 0969 6f76 203d 13 bytes..iov = │ │ │ -000369a0: 2061 7578 3a3a 6164 7661 6e63 655f 6275 aux::advance_bu │ │ │ -000369b0: 6673 2869 6f76 2c20 3133 293b 0a0a 092f fs(iov, 13);.../ │ │ │ -000369c0: 2f20 6d61 6b65 2073 7572 6520 7768 6174 / make sure what │ │ │ -000369d0: 2773 2069 6e0a 0969 6e74 2063 6f75 6e74 's in..int count │ │ │ -000369e0: 6572 203d 2031 333b 0a09 666f 7220 2861 er = 13;..for (a │ │ │ -000369f0: 7574 6f20 6275 6620 3a20 696f 7629 0a09 uto buf : iov).. │ │ │ -00036a00: 7b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 {.
    < │ │ │ -00036a30: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00036a40: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00036a70: 7465 7374 2f74 6573 745f 6669 6c65 5f73 test/test_file_s │ │ │ -00036a80: 746f 7261 6765 2e63 7070 3a31 3338 383c torage.cpp:1388< │ │ │ -00036a90: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374 /a>test │ │ │ -00036aa0: 2066 696c 6520 6174 7472 6962 7574 6573 file attributes │ │ │ -00036ab0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    te │ │ │ -00036b00: 7374 2066 696c 6520 6174 7472 6962 7574 st file attribut │ │ │ -00036b10: 6573 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 es

    ../te │ │ │ -00036b20: 7374 2f74 6573 745f 6669 6c65 5f73 746f st/test_file_sto │ │ │ -00036b30: 7261 6765 2e63 7070 3a31 3338 383c 2f68 rage.cpp:1388
    rel
    │ │ │ -00036bb0: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../test/t
    │ │ │ -00036bf0: 6573 745f 6669 6c65 5f73 746f 7261 6765  est_file_storage
    │ │ │ -00036c00: 2e63 7070 3a31 3338 393c 2f61 3e3c 2f74  .cpp:1389test symli
    │ │ │ -00036c20: 6e6b 733c 2f74 643e 3c2f 7472 3e3c 7472  nks

    test symlinks

    ../test/t │ │ │ -00036c90: 6573 745f 6669 6c65 5f73 746f 7261 6765 est_file_storage │ │ │ -00036ca0: 2e63 7070 3a31 3338 393c 2f68 343e 3c70 .cpp:1389

    relevan │ │ │ -00036d20: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ -00036d60: 6d65 726b 6c65 5f74 7265 652e 6370 703a merkle_tree.cpp: │ │ │ -00036d70: 3937 313c 2f61 3e3c 2f74 643e 3c74 643e 971 │ │ │ -00036d80: 6164 6420 7465 7374 2066 6f72 206c 6f61 add test for loa │ │ │ -00036d90: 645f 7069 6563 655f 6c61 7965 7228 293c d_piece_layer()< │ │ │ -00036da0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    add │ │ │ -00036df0: 2074 6573 7420 666f 7220 6c6f 6164 5f70 test for load_p │ │ │ -00036e00: 6965 6365 5f6c 6179 6572 2829 3c2f 6832 iece_layer()

    ../test/tes │ │ │ -00036e20: 745f 6d65 726b 6c65 5f74 7265 652e 6370 t_merkle_tree.cp │ │ │ -00036e30: 703a 3937 313c 2f68 343e 3c70 7265 2073 p:971

    <
    │ │ │ -00036e80: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ -00036eb0: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ -00036ee0: 2e2f 7465 7374 2f74 6573 745f 6d65 726b  ./test/test_merk
    │ │ │ -00036ef0: 6c65 5f74 7265 652e 6370 703a 3937 323c  le_tree.cpp:972<
    │ │ │ -00036f00: 2f61 3e3c 2f74 643e 3c74 643e 6164 6420  /a>add 
    │ │ │ -00036f10: 7465 7374 2066 6f72 2061 6464 5f68 6173  test for add_has
    │ │ │ -00036f20: 6865 7328 2920 7769 7468 2061 6e20 6f64  hes() with an od
    │ │ │ -00036f30: 6420 6e75 6d62 6572 206f 6620 626c 6f63  d number of bloc
    │ │ │ -00036f40: 6b73 3c2f 7464 3e3c 2f74 723e 3c74 7220  ks

    │ │ │ -00036f90: 6164 6420 7465 7374 2066 6f72 2061 6464 add test for add │ │ │ -00036fa0: 5f68 6173 6865 7328 2920 7769 7468 2061 _hashes() with a │ │ │ -00036fb0: 6e20 6f64 6420 6e75 6d62 6572 206f 6620 n odd number of │ │ │ -00036fc0: 626c 6f63 6b73 3c2f 6832 3e3c 6834 3e2e blocks

    . │ │ │ -00036fd0: 2e2f 7465 7374 2f74 6573 745f 6d65 726b ./test/test_merk │ │ │ -00036fe0: 6c65 5f74 7265 652e 6370 703a 3937 323c le_tree.cpp:972< │ │ │ -00036ff0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ -00037060: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -00037070: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../test
    │ │ │ -000370a0: 2f74 6573 745f 6d65 726b 6c65 5f74 7265  /test_merkle_tre
    │ │ │ -000370b0: 652e 6370 703a 3937 333c 2f61 3e3c 2f74  e.cpp:973add test f
    │ │ │ -000370d0: 6f72 2073 6574 5f62 6c6f 636b 2829 2028  or set_block() (
    │ │ │ -000370e0: 7365 7474 696e 6720 7468 6520 6c61 7374  setting the last
    │ │ │ -000370f0: 2062 6c6f 636b 2920 7769 7468 2061 6e20   block) with an 
    │ │ │ -00037100: 6f64 6420 6e75 6d62 6572 206f 6620 626c  odd number of bl
    │ │ │ -00037110: 6f63 6b73 3c2f 7464 3e3c 2f74 723e 3c74  ocksadd test for s
    │ │ │ -00037170: 6574 5f62 6c6f 636b 2829 2028 7365 7474  et_block() (sett
    │ │ │ -00037180: 696e 6720 7468 6520 6c61 7374 2062 6c6f  ing the last blo
    │ │ │ -00037190: 636b 2920 7769 7468 2061 6e20 6f64 6420  ck) with an odd 
    │ │ │ -000371a0: 6e75 6d62 6572 206f 6620 626c 6f63 6b73  number of blocks
    │ │ │ -000371b0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374  

    ../test │ │ │ -000371c0: 2f74 6573 745f 6d65 726b 6c65 5f74 7265 /test_merkle_tre │ │ │ -000371d0: 652e 6370 703a 3937 333c 2f68 343e 3c70 e.cpp:973

    .TEST_CH │ │ │ -00037220: 4543 4b28 742e 6c6f 6164 5f70 6965 6365 ECK(t.load_piece │ │ │ -00037230: 5f6c 6179 6572 2870 6965 6365 5f6c 6179 _layer(piece_lay │ │ │ -00037240: 6572 5f62 7974 6573 2929 3b0a 0a09 2f2f er_bytes));...// │ │ │ -00037250: 2069 6e20 7069 6563 655f 6c61 7965 7220 in piece_layer │ │ │ -00037260: 6d6f 6465 2077 6974 6820 6270 7020 2667 mode with bpp &g │ │ │ -00037270: 743b 2031 2c20 6e6f 2062 6c6f 636b 7320 t; 1, no blocks │ │ │ -00037280: 7368 6f75 6c64 2072 6570 6f72 7420 6173 should report as │ │ │ -00037290: 2076 6572 6966 6965 640a 0954 4553 545f verified..TEST_ │ │ │ -000372a0: 4348 4543 4b28 742e 7665 7269 6669 6564 CHECK(t.verified │ │ │ -000372b0: 5f6c 6561 6673 2829 203d 3d20 6e6f 6e65 _leafs() == none │ │ │ -000372c0: 5f73 6574 286e 756d 5f62 6c6f 636b 7329 _set(num_blocks) │ │ │ -000372d0: 293b 0a0a 092f 2f20 6166 7465 7220 6c6f );...// after lo │ │ │ -000372e0: 6164 5f70 6965 6365 5f6c 6179 6572 2074 ad_piece_layer t │ │ │ -000372f0: 6865 2074 7265 6520 6973 2062 6163 6b20 he tree is back │ │ │ -00037300: 696e 2074 6865 2070 6965 6365 5f6c 6179 in the piece_lay │ │ │ -00037310: 6572 2d6f 6e6c 790a 092f 2f20 7374 6174 er-only..// stat │ │ │ -00037320: 652c 2073 6f20 6120 7369 6e67 6c65 2073 e, so a single s │ │ │ -00037330: 6574 5f62 6c6f 636b 2063 616e 2774 2079 et_block can't y │ │ │ -00037340: 6574 2076 6572 6966 7920 6167 6169 6e73 et verify agains │ │ │ -00037350: 7420 7468 6520 7369 626c 696e 672e 0a09 t the sibling... │ │ │ -00037360: 6175 746f 2063 6f6e 7374 2072 6573 756c auto const resul │ │ │ -00037370: 7420 3d20 742e 7365 745f 626c 6f63 6b28 t = t.set_block( │ │ │ -00037380: 302c 2066 5b35 3131 5d29 3b0a 0954 4553 0, f[511]);..TES │ │ │ -00037390: 545f 4348 4543 4b28 7374 643a 3a67 6574 T_CHECK(std::get │ │ │ -000373a0: 266c 743b 3026 6774 3b28 7265 7375 6c74 <0>(result │ │ │ -000373b0: 2920 3d3d 2061 7578 3a3a 6d65 726b 6c65 ) == aux::merkle │ │ │ -000373c0: 5f74 7265 653a 3a73 6574 5f62 6c6f 636b _tree::set_block │ │ │ -000373d0: 5f72 6573 756c 743a 3a75 6e6b 6e6f 776e _result::unknown │ │ │ -000373e0: 293b 0a0a 092f 2f20 7468 6520 7365 745f );...// the set_ │ │ │ -000373f0: 626c 6f63 6b20 6162 6f76 6520 7261 6e20 block above ran │ │ │ -00037400: 616c 6c6f 6361 7465 5f66 756c 6c28 292c allocate_full(), │ │ │ -00037410: 2062 7269 6e67 696e 6720 7573 2062 6163 bringing us bac │ │ │ -00037420: 6b20 746f 2066 756c 6c5f 7472 6565 0a09 k to full_tree.. │ │ │ -00037430: 2f2f 206d 6f64 6520 7768 6572 6520 7665 // mode where ve │ │ │ -00037440: 7269 6669 6564 5f6c 6561 6673 2829 2f62 rified_leafs()/b │ │ │ -00037450: 6c6f 636b 735f 7665 7269 6669 6564 2829 locks_verified() │ │ │ -00037460: 2063 6f6e 7375 6c74 206d 5f62 6c6f 636b consult m_block │ │ │ -00037470: 5f76 6572 6966 6965 640a 092f 2f20 6469 _verified..// di │ │ │ -00037480: 7265 6374 6c79 2028 696e 2070 6965 6365 rectly (in piece │ │ │ -00037490: 5f6c 6179 6572 206d 6f64 6520 7468 6579 _layer mode they │ │ │ -000374a0: 2069 676e 6f72 6520 6974 292e 2061 6c6c ignore it). all │ │ │ -000374b0: 6f63 6174 655f 6675 6c6c 2773 2072 6573 ocate_full's res │ │ │ -000374c0: 697a 650a 092f 2f20 7072 6573 6572 7665 ize..// preserve │ │ │ -000374d0: 7320 616e 7920 7072 652d 6578 6973 7469 s any pre-existi │ │ │ -000374e0: 6e67 2062 6974 732c 2073 6f20 6861 6420 ng bits, so had │ │ │ -000374f0: 6c6f 6164 5f70 6965 6365 5f6c 6179 6572 load_piece_layer │ │ │ -00037500: 2066 6169 6c65 6420 746f 0a09 2f2f 2063 failed to..// c │ │ │ -00037510: 6c65 6172 2074 6865 6d20 7468 6520 7374 lear them the st │ │ │ -00037520: 616c 6520 7069 6563 652d 3020 6269 7473 ale piece-0 bits │ │ │ -00037530: 2077 6f75 6c64 2072 6573 7572 6661 6365 would resurface │ │ │ -00037540: 2061 7320 2276 6572 6966 6965 6422 2068 as "verified" h │ │ │ -00037550: 6572 6520 2d2d 0a09 2f2f 2063 6174 6368 ere --..// catch │ │ │ -00037560: 696e 6720 7468 6520 6275 6720 6576 656e ing the bug even │ │ │ -00037570: 2069 6e20 6275 696c 6473 2063 6f6d 7069 in builds compi │ │ │ -00037580: 6c65 6420 7769 7468 6f75 7420 696e 7661 led without inva │ │ │ -00037590: 7269 616e 7420 6368 6563 6b73 2e0a 0954 riant checks...T │ │ │ -000375a0: 4553 545f 4348 4543 4b28 2174 2e62 6c6f EST_CHECK(!t.blo │ │ │ -000375b0: 636b 735f 7665 7269 6669 6564 2830 2c20 cks_verified(0, │ │ │ -000375c0: 626c 6f63 6b73 5f70 6572 5f70 6965 6365 blocks_per_piece │ │ │ -000375d0: 2929 3b0a 0954 4553 545f 4348 4543 4b28 ));..TEST_CHECK( │ │ │ -000375e0: 742e 7665 7269 6669 6564 5f6c 6561 6673 t.verified_leafs │ │ │ -000375f0: 2829 203d 3d20 6e6f 6e65 5f73 6574 286e () == none_set(n │ │ │ -00037600: 756d 5f62 6c6f 636b 7329 293b 0a7d 0a0a um_blocks));.}.. │ │ │ -00037610: 3c64 6976 2073 7479 6c65 3d22 6261 636b

    .< │ │ │ -00037640: 2f64 6976 3e3c 2f70 7265 3e3c 2f74 643e /div>

    │ │ │ -00037650: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00037680: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00037690: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -000376a0: 7074 3a65 7870 616e 6428 3133 3829 223e pt:expand(138)"> │ │ │ -000376b0: 2e2e 2f74 6573 742f 7465 7374 5f62 616e ../test/test_ban │ │ │ -000376c0: 6477 6964 7468 5f6c 696d 6974 6572 2e63 dwidth_limiter.c │ │ │ -000376d0: 7070 3a31 3430 3c2f 613e 3c2f 7464 3e3c pp:140< │ │ │ -000376e0: 7464 3e66 6978 2074 6865 7365 2077 6172 td>fix these war │ │ │ -000376f0: 6e69 6e67 733c 2f74 643e 3c2f 7472 3e3c nings< │ │ │ -00037700: 7472 2069 643d 2231 3338 2220 7374 796c tr id="138" styl │ │ │ -00037710: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00037720: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00037730: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00037740: 6832 3e66 6978 2074 6865 7365 2077 6172 h2>fix these war │ │ │ -00037750: 6e69 6e67 733c 2f68 323e 3c68 343e 2e2e nings

    .. │ │ │ -00037760: 2f74 6573 742f 7465 7374 5f62 616e 6477 /test/test_bandw │ │ │ -00037770: 6964 7468 5f6c 696d 6974 6572 2e63 7070 idth_limiter.cpp │ │ │ -00037780: 3a31 3430 3c2f 6834 3e3c 7072 6520 7374 :140

    }..void do_ch
    │ │ │ -000377d0: 616e 6765 5f70 6565 725f 7261 7465 2863  ange_peer_rate(c
    │ │ │ -000377e0: 6f6e 6e65 6374 696f 6e73 5f74 2661 6d70  onnections_t&
    │ │ │ -000377f0: 3b20 762c 2069 6e74 206c 696d 6974 290a  ; v, int limit).
    │ │ │ -00037800: 7b0a 0973 7461 7469 6320 696e 7420 636f  {..static int co
    │ │ │ -00037810: 756e 7420 3d20 3130 3b0a 092d 2d63 6f75  unt = 10;..--cou
    │ │ │ -00037820: 6e74 3b0a 0969 6620 2863 6f75 6e74 203d  nt;..if (count =
    │ │ │ -00037830: 3d20 3029 0a09 7b0a 0909 7374 643a 3a66  = 0)..{...std::f
    │ │ │ -00037840: 6f72 5f65 6163 6828 762e 6265 6769 6e28  or_each(v.begin(
    │ │ │ -00037850: 292c 2076 2e65 6e64 2829 0a09 0909 2c20  ), v.end()...., 
    │ │ │ -00037860: 7374 643a 3a62 696e 6428 2661 6d70 3b70  std::bind(&p
    │ │ │ -00037870: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ -00037880: 7468 726f 7474 6c65 2c20 5f31 2c20 6c69  throttle, _1, li
    │ │ │ -00037890: 6d69 7429 293b 0a09 0972 6574 7572 6e3b  mit));...return;
    │ │ │ -000378a0: 0a09 7d0a 0a09 696e 7420 6320 3d20 636f  ..}...int c = co
    │ │ │ -000378b0: 756e 743b 0a09 666f 7220 2863 6f6e 6e65  unt;..for (conne
    │ │ │ -000378c0: 6374 696f 6e73 5f74 3a3a 6974 6572 6174  ctions_t::iterat
    │ │ │ -000378d0: 6f72 2069 203d 2076 2e62 6567 696e 2829  or i = v.begin()
    │ │ │ -000378e0: 3b20 6920 213d 2076 2e65 6e64 2829 3b20  ; i != v.end(); 
    │ │ │ -000378f0: 2b2b 692c 202b 2b63 290a 0909 692d 2667  ++i, ++c)...i-&g
    │ │ │ -00037900: 743b 6765 7428 292d 2667 743b 7468 726f  t;get()->thro
    │ │ │ -00037910: 7474 6c65 286c 696d 6974 202b 206c 696d  ttle(limit + lim
    │ │ │ -00037920: 6974 202f 2032 202a 2028 2863 2026 616d  it / 2 * ((c &am
    │ │ │ -00037930: 703b 2031 293f 2d31 3a31 2929 3b0a 7d0a  p; 1)?-1:1));.}.
    │ │ │ -00037940: 0a73 7461 7469 6320 766f 6964 206e 6f70  .static void nop
    │ │ │ -00037950: 2829 207b 7d0a 0a3c 6469 7620 7374 796c  () {}..
    #if defined │ │ │ -00037990: 205f 5f63 6c61 6e67 5f5f 2026 616d 703b __clang__ & │ │ │ -000379a0: 2661 6d70 3b20 5f5f 636c 616e 675f 6d61 & __clang_ma │ │ │ -000379b0: 6a6f 725f 5f20 2667 743b 3d20 3130 0a3c jor__ >= 10.< │ │ │ -000379c0: 2f64 6976 3e23 7072 6167 6d61 2063 6c61 /div>#pragma cla │ │ │ -000379d0: 6e67 2064 6961 676e 6f73 7469 6320 7075 ng diagnostic pu │ │ │ -000379e0: 7368 0a23 7072 6167 6d61 2063 6c61 6e67 sh.#pragma clang │ │ │ -000379f0: 2064 6961 676e 6f73 7469 6320 6967 6e6f diagnostic igno │ │ │ -00037a00: 7265 6420 222d 5769 6d70 6c69 6369 742d red "-Wimplicit- │ │ │ -00037a10: 696e 742d 666c 6f61 742d 636f 6e76 6572 int-float-conver │ │ │ -00037a20: 7369 6f6e 220a 2365 6e64 6966 0a0a 766f sion".#endif..vo │ │ │ -00037a30: 6964 2072 756e 5f74 6573 7428 636f 6e6e id run_test(conn │ │ │ -00037a40: 6563 7469 6f6e 735f 7426 616d 703b 2076 ections_t& v │ │ │ -00037a50: 0a09 2c20 6175 783a 3a62 616e 6477 6964 .., aux::bandwid │ │ │ -00037a60: 7468 5f6d 616e 6167 6572 2661 6d70 3b20 th_manager& │ │ │ -00037a70: 6d61 6e61 6765 720a 092c 2073 7464 3a3a manager.., std:: │ │ │ -00037a80: 6675 6e63 7469 6f6e 266c 743b 766f 6964 function<void │ │ │ -00037a90: 2829 2667 743b 2066 203d 2026 616d 703b ()> f = & │ │ │ -00037aa0: 6e6f 7029 0a7b 0a09 7374 643a 3a63 6f75 nop).{..std::cou │ │ │ -00037ab0: 7420 266c 743b 266c 743b 2022 2d2d 2d2d t << "---- │ │ │ -00037ac0: 2d2d 2d2d 2d2d 2d2d 2d22 2026 6c74 3b26 ---------" <& │ │ │ -00037ad0: 6c74 3b20 7374 643a 3a65 6e64 6c3b 0a0a lt; std::endl;.. │ │ │ -00037ae0: 0973 7464 3a3a 666f 725f 6561 6368 2876 .std::for_each(v │ │ │ -00037af0: 2e62 6567 696e 2829 2c20 762e 656e 6428 .begin(), v.end( │ │ │ -00037b00: 290a 0909 2c20 7374 643a 3a62 696e 6428 )..., std::bind( │ │ │ -00037b10: 2661 6d70 3b70 6565 725f 636f 6e6e 6563 &peer_connec │ │ │ -00037b20: 7469 6f6e 3a3a 7374 6172 742c 205f 3129 tion::start, _1) │ │ │ -00037b30: 293b 0a0a 096c 743a 3a61 7578 3a3a 7365 );...lt::aux::se │ │ │ -00037b40: 7373 696f 6e5f 7365 7474 696e 6773 2073 ssion_settings s │ │ │ -00037b50: 3b0a 0969 6e74 2074 6963 6b5f 696e 7465 ;..int tick_inte │ │ │ -00037b60: 7276 616c 203d 2073 2e67 6574 5f69 6e74 rval = s.get_int │ │ │ -00037b70: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ -00037b80: 7469 636b 5f69 6e74 6572 7661 6c29 3b0a tick_interval);. │ │ │ -00037b90: 0a09 666f 7220 2869 6e74 2069 203d 2030 ..for (int i = 0 │ │ │ -00037ba0: 3b20 6920 266c 743b 2069 6e74 2873 616d ; i < int(sam │ │ │ -00037bb0: 706c 655f 7469 6d65 202a 2031 3030 3020 ple_time * 1000 │ │ │ -00037bc0: 2f20 7469 636b 5f69 6e74 6572 7661 6c29 / tick_interval) │ │ │ -00037bd0: 3b20 2b2b 6929 0a09 7b0a 0909 6d61 6e61 ; ++i)..{...mana │ │ │ -00037be0: 6765 722e 7570 6461 7465 5f71 756f 7461 ger.update_quota │ │ │ -00037bf0: 7328 6d69 6c6c 6973 6563 6f6e 6473 2874 s(milliseconds(t │ │ │ -00037c00: 6963 6b5f 696e 7465 7276 616c 2929 3b0a ick_interval));. │ │ │ -00037c10: 0909 6966 2028 2869 2025 2031 3529 203d ..if ((i % 15) = │ │ │ -00037c20: 3d20 3029 2066 2829 3b0a 097d 0a7d 0a0a = 0) f();..}.}.. │ │ │ -00037c30: 626f 6f6c 2063 6c6f 7365 5f74 6f28 666c bool close_to(fl │ │ │ -00037c40: 6f61 7420 636f 6e73 7420 7661 6c2c 2066 oat const val, f │ │ │ -00037c50: 6c6f 6174 2063 6f6e 7374 2063 6f6d 702c loat const comp, │ │ │ -00037c60: 2066 6c6f 6174 2063 6f6e 7374 2065 7272 float const err │ │ │ -00037c70: 290a 7b0a 0972 6574 7572 6e20 7374 643a ).{..return std: │ │ │ -00037c80: 3a61 6273 2876 616c 202d 2063 6f6d 7029 :abs(val - comp) │ │ │ -00037c90: 2026 6c74 3b3d 2065 7272 3b0a 7d0a 0a76 <= err;.}..v │ │ │ -00037ca0: 6f69 6420 7370 6177 6e5f 636f 6e6e 6563 oid spawn_connec │ │ │ -00037cb0: 7469 6f6e 7328 636f 6e6e 6563 7469 6f6e tions(connection │ │ │ -00037cc0: 735f 7426 616d 703b 2076 2c20 6175 783a s_t& v, aux: │ │ │ -00037cd0: 3a62 616e 6477 6964 7468 5f6d 616e 6167 :bandwidth_manag │ │ │ -00037ce0: 6572 2661 6d70 3b20 6277 6d0a 092c 2061 er& bwm.., a │ │ │ -00037cf0: 7578 3a3a 6261 6e64 7769 6474 685f 6368 ux::bandwidth_ch │ │ │ -00037d00: 616e 6e65 6c26 616d 703b 2062 7763 2c20 annel& bwc, │ │ │ -00037d10: 696e 7420 6e75 6d2c 2063 6861 7220 636f int num, char co │ │ │ -00037d20: 6e73 742a 2070 7265 6669 7829 0a3c 2f70 nst* prefix).

    re │ │ │ -00037d60: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ -00037da0: 7465 7374 5f74 7261 636b 6572 5f6c 6973 test_tracker_lis │ │ │ -00037db0: 742e 6370 703a 3436 373c 2f61 3e3c 2f74 t.cpp:467reset │ │ │ -00037dd0: 3c2f 7472 3e3c 7472 2069 643d 2231 3339

    reset

    ../test/t │ │ │ -00037e30: 6573 745f 7472 6163 6b65 725f 6c69 7374 est_tracker_list │ │ │ -00037e40: 2e63 7070 3a34 3637 3c2f 6834 3e3c 7072 .cpp:467

    relevanc │ │ │ -00037ec0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_t │ │ │ -00037f00: 7261 636b 6572 5f6c 6973 742e 6370 703a racker_list.cpp: │ │ │ -00037f10: 3436 383c 2f61 3e3c 2f74 643e 3c74 643e 468 │ │ │ -00037f20: 636f 6d70 6c65 7465 643c 2f74 643e 3c2f completed

    completed │ │ │ -00037f80: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -00037f90: 2f74 6573 745f 7472 6163 6b65 725f 6c69 /test_tracker_li │ │ │ -00037fa0: 7374 2e63 7070 3a34 3638 3c2f 6834 3e3c st.cpp:468

    < │ │ │ -00037fb0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00037fc0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00037fd0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00037fe0: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ -00037ff0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00038020: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00038030: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -00038060: 5f74 7261 636b 6572 5f6c 6973 742e 6370 _tracker_list.cp │ │ │ -00038070: 703a 3436 393c 2f61 3e3c 2f74 643e 3c74 p:469dont_try_again │ │ │ -00038090: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    do │ │ │ -000380e0: 6e74 5f74 7279 5f61 6761 696e 3c2f 6832 nt_try_again

    ../test/tes │ │ │ -00038100: 745f 7472 6163 6b65 725f 6c69 7374 2e63 t_tracker_list.c │ │ │ -00038110: 7070 3a34 3639 3c2f 6834 3e3c 7072 6520 pp:469

    
    │ │ │ -00038160: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -00038190: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -000381a0: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -000381b0: 7074 3a65 7870 616e 6428 3134 3229 223e  pt:expand(142)">
    │ │ │ -000381c0: 2e2e 2f74 6573 742f 7465 7374 5f75 706e  ../test/test_upn
    │ │ │ -000381d0: 702e 6370 703a 3133 333c 2f61 3e3c 2f74  p.cpp:133
    store the │ │ │ -000381f0: 6c6f 6720 616e 6420 7665 7269 6679 2074 log and verify t │ │ │ -00038200: 6861 7420 736f 6d65 206b 6579 206d 6573 hat some key mes │ │ │ -00038210: 7361 6765 7320 6172 6520 7468 6572 653c sages are there< │ │ │ -00038220: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    sto │ │ │ -00038270: 7265 2074 6865 206c 6f67 2061 6e64 2076 re the log and v │ │ │ -00038280: 6572 6966 7920 7468 6174 2073 6f6d 6520 erify that some │ │ │ -00038290: 6b65 7920 6d65 7373 6167 6573 2061 7265 key messages are │ │ │ -000382a0: 2074 6865 7265 3c2f 6832 3e3c 6834 3e2e there

    . │ │ │ -000382b0: 2e2f 7465 7374 2f74 6573 745f 7570 6e70 ./test/test_upnp │ │ │ -000382c0: 2e63 7070 3a31 3333 3c2f 6834 3e3c 7072 .cpp:133

    ..., port │ │ │ -00038310: 6d61 705f 7072 6f74 6f63 6f6c 2063 6f6e map_protocol con │ │ │ -00038320: 7374 2070 726f 746f 636f 6c2c 2065 7272 st protocol, err │ │ │ -00038330: 6f72 5f63 6f64 6520 636f 6e73 7426 616d or_code const&am │ │ │ -00038340: 703b 2065 7272 0a09 0909 2c20 706f 7274 p; err...., port │ │ │ -00038350: 6d61 705f 7472 616e 7370 6f72 742c 2061 map_transport, a │ │ │ -00038360: 7578 3a3a 6c69 7374 656e 5f73 6f63 6b65 ux::listen_socke │ │ │ -00038370: 745f 6861 6e64 6c65 2063 6f6e 7374 2661 t_handle const&a │ │ │ -00038380: 6d70 3b29 206f 7665 7272 6964 650a 0909 mp;) override... │ │ │ -00038390: 7b0a 0909 0963 616c 6c62 6163 6b5f 696e {....callback_in │ │ │ -000383a0: 666f 2069 6e66 6f20 3d20 7b6d 6170 7069 fo info = {mappi │ │ │ -000383b0: 6e67 2c20 706f 7274 2c20 6572 727d 3b0a ng, port, err};. │ │ │ -000383c0: 0909 0963 616c 6c62 6163 6b73 2e70 7573 ...callbacks.pus │ │ │ -000383d0: 685f 6261 636b 2869 6e66 6f29 3b0a 0909 h_back(info);... │ │ │ -000383e0: 0973 7464 3a3a 636f 7574 2026 6c74 3b26 .std::cout <& │ │ │ -000383f0: 6c74 3b20 226d 6170 7069 6e67 3a20 2220 lt; "mapping: " │ │ │ -00038400: 266c 743b 266c 743b 2073 7461 7469 635f << static_ │ │ │ -00038410: 6361 7374 266c 743b 696e 7426 6774 3b28 cast<int>( │ │ │ -00038420: 6d61 7070 696e 6729 0a09 0909 0926 6c74 mapping).....< │ │ │ -00038430: 3b26 6c74 3b20 222c 2070 6f72 743a 2022 ;< ", port: " │ │ │ -00038440: 2026 6c74 3b26 6c74 3b20 706f 7274 2026 << port & │ │ │ -00038450: 6c74 3b26 6c74 3b20 222c 2049 503a 2022 lt;< ", IP: " │ │ │ -00038460: 2026 6c74 3b26 6c74 3b20 6970 0a09 0909 << ip.... │ │ │ -00038470: 0926 6c74 3b26 6c74 3b20 222c 2070 726f .<< ", pro │ │ │ -00038480: 746f 3a20 2220 266c 743b 266c 743b 2073 to: " << s │ │ │ -00038490: 7461 7469 635f 6361 7374 266c 743b 696e tatic_cast<in │ │ │ -000384a0: 7426 6774 3b28 7072 6f74 6f63 6f6c 290a t>(protocol). │ │ │ -000384b0: 0909 0909 266c 743b 266c 743b 2022 2c20 ....<< ", │ │ │ -000384c0: 6572 726f 723a 205c 2222 2026 6c74 3b26 error: \"" <& │ │ │ -000384d0: 6c74 3b20 6572 722e 6d65 7373 6167 6528 lt; err.message( │ │ │ -000384e0: 2920 266c 743b 266c 743b 2022 5c22 5c6e ) << "\"\n │ │ │ -000384f0: 223b 0a09 097d 0a09 2369 666e 6465 6620 ";...}..#ifndef │ │ │ -00038500: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00038510: 4c4f 4747 494e 470a 0909 626f 6f6c 2073 LOGGING...bool s │ │ │ -00038520: 686f 756c 645f 6c6f 675f 706f 7274 6d61 hould_log_portma │ │ │ -00038530: 7028 706f 7274 6d61 705f 7472 616e 7370 p(portmap_transp │ │ │ -00038540: 6f72 7429 2063 6f6e 7374 206f 7665 7272 ort) const overr │ │ │ -00038550: 6964 650a 0909 7b0a 0909 0972 6574 7572 ide...{....retur │ │ │ -00038560: 6e20 7472 7565 3b0a 0909 7d0a 0a09 0976 n true;...}....v │ │ │ -00038570: 6f69 6420 6c6f 675f 706f 7274 6d61 7028 oid log_portmap( │ │ │ -00038580: 706f 7274 6d61 705f 7472 616e 7370 6f72 portmap_transpor │ │ │ -00038590: 742c 2063 6861 7220 636f 6e73 742a 206d t, char const* m │ │ │ -000385a0: 7367 0a09 0909 2c20 6175 783a 3a6c 6973 sg...., aux::lis │ │ │ -000385b0: 7465 6e5f 736f 636b 6574 5f68 616e 646c ten_socket_handl │ │ │ -000385c0: 6520 636f 6e73 7426 616d 703b 2920 636f e const&) co │ │ │ -000385d0: 6e73 7420 6f76 6572 7269 6465 0a09 097b nst override...{ │ │ │ -000385e0: 0a09 0909 7374 643a 3a63 6f75 7420 266c ....std::cout &l │ │ │ -000385f0: 743b 266c 743b 2022 5550 6e50 3a20 2220 t;< "UPnP: " │ │ │ -00038600: 266c 743b 266c 743b 206d 7367 2026 6c74 << msg < │ │ │ -00038610: 3b26 6c74 3b20 7374 643a 3a65 6e64 6c3b ;< std::endl; │ │ │ -00038620: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ -00038650: 097d 0a3c 2f64 6976 3e09 2365 6e64 6966 .}.
    .#endif │ │ │ -00038660: 0a09 7d3b 0a0a 6175 783a 3a69 705f 696e ..};..aux::ip_in │ │ │ -00038670: 7465 7266 6163 6520 7069 636b 5f75 706e terface pick_upn │ │ │ -00038680: 705f 696e 7465 7266 6163 6528 290a 7b0a p_interface().{. │ │ │ -00038690: 096c 743a 3a69 6f5f 636f 6e74 6578 7420 .lt::io_context │ │ │ -000386a0: 696f 733b 0a09 6572 726f 725f 636f 6465 ios;..error_code │ │ │ -000386b0: 2065 633b 0a09 6175 746f 2063 6f6e 7374 ec;..auto const │ │ │ -000386c0: 2072 6f75 7465 7320 3d20 6175 783a 3a65 routes = aux::e │ │ │ -000386d0: 6e75 6d5f 726f 7574 6573 2869 6f73 2c20 num_routes(ios, │ │ │ -000386e0: 6563 293b 0a09 6966 2028 6563 290a 097b ec);..if (ec)..{ │ │ │ -000386f0: 0a09 0973 7464 3a3a 6365 7272 2026 6c74 ...std::cerr < │ │ │ -00038700: 3b26 6c74 3b20 2266 6169 6c65 6420 746f ;< "failed to │ │ │ -00038710: 2065 6e75 6d65 7261 7465 2072 6f75 7465 enumerate route │ │ │ -00038720: 733a 2022 2026 6c74 3b26 6c74 3b20 6563 s: " << ec │ │ │ -00038730: 2e6d 6573 7361 6765 2829 2026 6c74 3b26 .message() <& │ │ │ -00038740: 6c74 3b20 275c 6e27 3b0a 0909 5445 5354 lt; '\n';...TEST │ │ │ -00038750: 5f43 4845 434b 2866 616c 7365 293b 0a09 _CHECK(false);.. │ │ │ -00038760: 0972 6574 7572 6e20 7b7d 3b0a 097d 0a09 .return {};..}.. │ │ │ -00038770: 6175 746f 2063 6f6e 7374 2069 6673 203d auto const ifs = │ │ │ -00038780: 2061 7578 3a3a 656e 756d 5f6e 6574 5f69 aux::enum_net_i │ │ │ -00038790: 6e74 6572 6661 6365 7328 696f 732c 2065 nterfaces(ios, e │ │ │ -000387a0: 6329 3b0a 0969 6620 2865 6329 0a09 7b0a c);..if (ec)..{. │ │ │ -000387b0: 0909 7374 643a 3a63 6572 7220 266c 743b ..std::cerr < │ │ │ -000387c0: 266c 743b 2022 6661 696c 6564 2074 6f20 < "failed to │ │ │ -000387d0: 656e 756d 6572 6174 6520 6e65 7477 6f72 enumerate networ │ │ │ -000387e0: 6b20 696e 7465 7266 6163 6573 3a20 2220 k interfaces: " │ │ │ -000387f0: 266c 743b 266c 743b 2065 632e 6d65 7373 << ec.mess │ │ │ -00038800: 6167 6528 2920 266c 743b 266c 743b 2027 age() << ' │ │ │ -00038810: 5c6e 273b 0a09 0954 4553 545f 4348 4543 \n';...TEST_CHEC │ │ │ -00038820: 4b28 6661 6c73 6529 3b0a 0909 7265 7475 K(false);...retu │ │ │ -00038830: 726e 207b 7d3b 0a09 7d0a 0969 6e74 2069 rn {};..}..int i │ │ │ -00038840: 6478 203d 2030 3b0a 0966 6f72 2028 6175 dx = 0;..for (au │ │ │ -00038850: 746f 2063 6f6e 7374 2661 6d70 3b20 6661 to const& fa │ │ │ -00038860: 6365 203a 2069 6673 290a 097b 0a09 0969 ce : ifs)..{...i │ │ │ -00038870: 6620 2821 6661 6365 2e69 6e74 6572 6661 f (!face.interfa │ │ │ -00038880: 6365 5f61 6464 7265 7373 2e69 735f 7634 ce_address.is_v4 │ │ │ -00038890: 2829 2920 636f 6e74 696e 7565 3b0a 0909 ()) continue;... │ │ │ -000388a0: 7374 643a 3a63 6f75 7420 266c 743b 266c std::cout <&l │ │ │ -000388b0: 743b 2022 202d 2022 2026 6c74 3b26 6c74 t; " - " << │ │ │ -000388c0: 3b20 6964 780a 0909 0926 6c74 3b26 6c74 ; idx....<< │ │ │ -000388d0: 3b20 2720 2720 266c 743b 266c 743b 2066 ; ' ' << f │ │ │ -000388e0: 6163 652e 696e 7465 7266 6163 655f 6164 ace.interface_ad │ │ │ -000388f0: 6472 6573 732e 746f 5f73 7472 696e 6728 dress.to_string( │ │ │ -00038900: 290a 0909 0926 6c74 3b26 6c74 3b20 2720 )....<< ' │ │ │ -00038910: 2720 266c 743b 266c 743b 2069 6e74 2873 ' << int(s │ │ │ -00038920: 7461 7469 635f 6361 7374 266c 743b 7374 tatic_cast<st │ │ │ -00038930: 643a 3a75 696e 7438 5f74 2667 743b 2866 d::uint8_t>(f │ │ │ -00038940: 6163 652e 7374 6174 6529 290a 0909 0926 ace.state))....& │ │ │ -00038950: 6c74 3b26 6c74 3b20 2720 2720 266c 743b lt;< ' ' < │ │ │ -00038960: 266c 743b 2073 7461 7469 635f 6361 7374 < static_cast │ │ │ -00038970: 266c 743b 7374 643a 3a75 696e 7433 325f <std::uint32_ │ │ │ -00038980: 7426 6774 3b28 6661 6365 2e66 6c61 6773 t>(face.flags │ │ │ -00038990: 290a 0909 0926 6c74 3b26 6c74 3b20 2720 )....<< ' │ │ │ -000389a0: 2720 266c 743b 266c 743b 2066 6163 652e ' << face. │ │ │ -000389b0: 6e61 6d65 2026 6c74 3b26 6c74 3b20 275c name << '\ │ │ │ -000389c0: 6e27 3b0a 3c2f 7072 653e 3c2f 7464 3e3c n';.< │ │ │ -000389d0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00038a00: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00038a30: 2e2f 7465 7374 2f74 6573 745f 7472 616e ./test/test_tran │ │ │ -00038a40: 7366 6572 2e63 7070 3a31 3633 3c2f 613e sfer.cpp:163 │ │ │ -00038a50: 3c2f 7464 3e3c 7464 3e74 6865 7365 2073 these s │ │ │ -00038a60: 6574 7469 6e67 735f 7061 636b 2074 6573 ettings_pack tes │ │ │ -00038a70: 7473 2062 656c 6f6e 6720 696e 2074 6865 ts belong in the │ │ │ -00038a80: 6972 206f 776e 2074 6573 743c 2f74 643e ir own test │ │ │ -00038a90: 3c2f 7472 3e3c 7472 2069 643d 2231 3433

    these s │ │ │ -00038ae0: 6574 7469 6e67 735f 7061 636b 2074 6573 ettings_pack tes │ │ │ -00038af0: 7473 2062 656c 6f6e 6720 696e 2074 6865 ts belong in the │ │ │ -00038b00: 6972 206f 776e 2074 6573 743c 2f68 323e ir own test

    │ │ │ -00038b10: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00038b20: 5f74 7261 6e73 6665 722e 6370 703a 3136 _transfer.cpp:16 │ │ │ -00038b30: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -00038b70: 092f 2f20 746f 2074 6865 2074 696d 6520  .// to the time 
    │ │ │ -00038b80: 6974 2077 696c 6c20 7461 6b65 2074 6f20  it will take to 
    │ │ │ -00038b90: 636f 6d70 6c65 7465 2074 6865 2074 6573  complete the tes
    │ │ │ -00038ba0: 740a 0970 6163 6b2e 7365 745f 696e 7428  t..pack.set_int(
    │ │ │ -00038bb0: 7365 7474 696e 6773 5f70 6163 6b3a 3a6d  settings_pack::m
    │ │ │ -00038bc0: 696e 5f72 6563 6f6e 6e65 6374 5f74 696d  in_reconnect_tim
    │ │ │ -00038bd0: 652c 2030 293b 0a09 7061 636b 2e73 6574  e, 0);..pack.set
    │ │ │ -00038be0: 5f69 6e74 2873 6574 7469 6e67 735f 7061  _int(settings_pa
    │ │ │ -00038bf0: 636b 3a3a 7374 6f70 5f74 7261 636b 6572  ck::stop_tracker
    │ │ │ -00038c00: 5f74 696d 656f 7574 2c20 3129 3b0a 0970  _timeout, 1);..p
    │ │ │ -00038c10: 6163 6b2e 7365 745f 626f 6f6c 2873 6574  ack.set_bool(set
    │ │ │ -00038c20: 7469 6e67 735f 7061 636b 3a3a 616e 6e6f  tings_pack::anno
    │ │ │ -00038c30: 756e 6365 5f74 6f5f 616c 6c5f 7472 6163  unce_to_all_trac
    │ │ │ -00038c40: 6b65 7273 2c20 7472 7565 293b 0a09 7061  kers, true);..pa
    │ │ │ -00038c50: 636b 2e73 6574 5f62 6f6f 6c28 7365 7474  ck.set_bool(sett
    │ │ │ -00038c60: 696e 6773 5f70 6163 6b3a 3a61 6e6e 6f75  ings_pack::annou
    │ │ │ -00038c70: 6e63 655f 746f 5f61 6c6c 5f74 6965 7273  nce_to_all_tiers
    │ │ │ -00038c80: 2c20 7472 7565 293b 0a0a 092f 2f20 6d61  , true);...// ma
    │ │ │ -00038c90: 6b65 2073 7572 6520 7765 2061 6e6e 6f75  ke sure we annou
    │ │ │ -00038ca0: 6e63 6520 746f 2062 6f74 6820 6874 7470  nce to both http
    │ │ │ -00038cb0: 2061 6e64 2075 6470 2074 7261 636b 6572   and udp tracker
    │ │ │ -00038cc0: 730a 0970 6163 6b2e 7365 745f 626f 6f6c  s..pack.set_bool
    │ │ │ -00038cd0: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ -00038ce0: 7072 6566 6572 5f75 6470 5f74 7261 636b  prefer_udp_track
    │ │ │ -00038cf0: 6572 732c 2066 616c 7365 293b 0a09 7061  ers, false);..pa
    │ │ │ -00038d00: 636b 2e73 6574 5f62 6f6f 6c28 7365 7474  ck.set_bool(sett
    │ │ │ -00038d10: 696e 6773 5f70 6163 6b3a 3a65 6e61 626c  ings_pack::enabl
    │ │ │ -00038d20: 655f 6f75 7467 6f69 6e67 5f75 7470 2c20  e_outgoing_utp, 
    │ │ │ -00038d30: 6661 6c73 6529 3b0a 0970 6163 6b2e 7365  false);..pack.se
    │ │ │ -00038d40: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ -00038d50: 7061 636b 3a3a 656e 6162 6c65 5f69 6e63  pack::enable_inc
    │ │ │ -00038d60: 6f6d 696e 675f 7574 702c 2066 616c 7365  oming_utp, false
    │ │ │ -00038d70: 293b 0a09 7061 636b 2e73 6574 5f62 6f6f  );..pack.set_boo
    │ │ │ -00038d80: 6c28 7365 7474 696e 6773 5f70 6163 6b3a  l(settings_pack:
    │ │ │ -00038d90: 3a65 6e61 626c 655f 6c73 642c 2066 616c  :enable_lsd, fal
    │ │ │ -00038da0: 7365 293b 0a09 7061 636b 2e73 6574 5f62  se);..pack.set_b
    │ │ │ -00038db0: 6f6f 6c28 7365 7474 696e 6773 5f70 6163  ool(settings_pac
    │ │ │ -00038dc0: 6b3a 3a65 6e61 626c 655f 6e61 7470 6d70  k::enable_natpmp
    │ │ │ -00038dd0: 2c20 6661 6c73 6529 3b0a 0970 6163 6b2e  , false);..pack.
    │ │ │ -00038de0: 7365 745f 626f 6f6c 2873 6574 7469 6e67  set_bool(setting
    │ │ │ -00038df0: 735f 7061 636b 3a3a 656e 6162 6c65 5f75  s_pack::enable_u
    │ │ │ -00038e00: 706e 702c 2066 616c 7365 293b 0a09 7061  pnp, false);..pa
    │ │ │ -00038e10: 636b 2e73 6574 5f62 6f6f 6c28 7365 7474  ck.set_bool(sett
    │ │ │ -00038e20: 696e 6773 5f70 6163 6b3a 3a65 6e61 626c  ings_pack::enabl
    │ │ │ -00038e30: 655f 6468 742c 2066 616c 7365 293b 0a0a  e_dht, false);..
    │ │ │ -00038e40: 0970 6163 6b2e 7365 745f 696e 7428 7365  .pack.set_int(se
    │ │ │ -00038e50: 7474 696e 6773 5f70 6163 6b3a 3a6f 7574  ttings_pack::out
    │ │ │ -00038e60: 5f65 6e63 5f70 6f6c 6963 792c 2073 6574  _enc_policy, set
    │ │ │ -00038e70: 7469 6e67 735f 7061 636b 3a3a 7065 5f64  tings_pack::pe_d
    │ │ │ -00038e80: 6973 6162 6c65 6429 3b0a 0970 6163 6b2e  isabled);..pack.
    │ │ │ -00038e90: 7365 745f 696e 7428 7365 7474 696e 6773  set_int(settings
    │ │ │ -00038ea0: 5f70 6163 6b3a 3a69 6e5f 656e 635f 706f  _pack::in_enc_po
    │ │ │ -00038eb0: 6c69 6379 2c20 7365 7474 696e 6773 5f70  licy, settings_p
    │ │ │ -00038ec0: 6163 6b3a 3a70 655f 6469 7361 626c 6564  ack::pe_disabled
    │ │ │ -00038ed0: 293b 0a0a 0970 6163 6b2e 7365 745f 626f  );...pack.set_bo
    │ │ │ -00038ee0: 6f6c 2873 6574 7469 6e67 735f 7061 636b  ol(settings_pack
    │ │ │ -00038ef0: 3a3a 616c 6c6f 775f 6d75 6c74 6970 6c65  ::allow_multiple
    │ │ │ -00038f00: 5f63 6f6e 6e65 6374 696f 6e73 5f70 6572  _connections_per
    │ │ │ -00038f10: 5f69 702c 2066 616c 7365 293b 0a0a 3c64  _ip, false);...pac
    │ │ │ -00038f50: 6b2e 7365 745f 696e 7428 7365 7474 696e  k.set_int(settin
    │ │ │ -00038f60: 6773 5f70 6163 6b3a 3a75 6e63 686f 6b65  gs_pack::unchoke
    │ │ │ -00038f70: 5f73 6c6f 7473 5f6c 696d 6974 2c20 3029  _slots_limit, 0)
    │ │ │ -00038f80: 3b0a 3c2f 6469 763e 0973 6573 312e 6170  ;.
    .ses1.ap │ │ │ -00038f90: 706c 795f 7365 7474 696e 6773 2870 6163 ply_settings(pac │ │ │ -00038fa0: 6b29 3b0a 0954 4553 545f 4348 4543 4b28 k);..TEST_CHECK( │ │ │ -00038fb0: 7365 7331 2e67 6574 5f73 6574 7469 6e67 ses1.get_setting │ │ │ -00038fc0: 7328 292e 6765 745f 696e 7428 7365 7474 s().get_int(sett │ │ │ -00038fd0: 696e 6773 5f70 6163 6b3a 3a75 6e63 686f ings_pack::uncho │ │ │ -00038fe0: 6b65 5f73 6c6f 7473 5f6c 696d 6974 2920 ke_slots_limit) │ │ │ -00038ff0: 3d3d 2030 293b 0a0a 0970 6163 6b2e 7365 == 0);...pack.se │ │ │ -00039000: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ -00039010: 6163 6b3a 3a75 6e63 686f 6b65 5f73 6c6f ack::unchoke_slo │ │ │ -00039020: 7473 5f6c 696d 6974 2c20 2d31 293b 0a09 ts_limit, -1);.. │ │ │ -00039030: 7365 7331 2e61 7070 6c79 5f73 6574 7469 ses1.apply_setti │ │ │ -00039040: 6e67 7328 7061 636b 293b 0a09 5445 5354 ngs(pack);..TEST │ │ │ -00039050: 5f43 4845 434b 2873 6573 312e 6765 745f _CHECK(ses1.get_ │ │ │ -00039060: 7365 7474 696e 6773 2829 2e67 6574 5f69 settings().get_i │ │ │ -00039070: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ -00039080: 3a3a 756e 6368 6f6b 655f 736c 6f74 735f ::unchoke_slots_ │ │ │ -00039090: 6c69 6d69 7429 203d 3d20 2d31 293b 0a0a limit) == -1);.. │ │ │ -000390a0: 0970 6163 6b2e 7365 745f 696e 7428 7365 .pack.set_int(se │ │ │ -000390b0: 7474 696e 6773 5f70 6163 6b3a 3a75 6e63 ttings_pack::unc │ │ │ -000390c0: 686f 6b65 5f73 6c6f 7473 5f6c 696d 6974 hoke_slots_limit │ │ │ -000390d0: 2c20 3829 3b0a 0973 6573 312e 6170 706c , 8);..ses1.appl │ │ │ -000390e0: 795f 7365 7474 696e 6773 2870 6163 6b29 y_settings(pack) │ │ │ -000390f0: 3b0a 0954 4553 545f 4348 4543 4b28 7365 ;..TEST_CHECK(se │ │ │ -00039100: 7331 2e67 6574 5f73 6574 7469 6e67 7328 s1.get_settings( │ │ │ -00039110: 292e 6765 745f 696e 7428 7365 7474 696e ).get_int(settin │ │ │ -00039120: 6773 5f70 6163 6b3a 3a75 6e63 686f 6b65 gs_pack::unchoke │ │ │ -00039130: 5f73 6c6f 7473 5f6c 696d 6974 2920 3d3d _slots_limit) == │ │ │ -00039140: 2038 293b 0a0a 0973 6573 322e 6170 706c 8);...ses2.appl │ │ │ -00039150: 795f 7365 7474 696e 6773 2870 6163 6b29 y_settings(pack) │ │ │ -00039160: 3b0a 0a09 746f 7272 656e 745f 6861 6e64 ;...torrent_hand │ │ │ -00039170: 6c65 2074 6f72 313b 0a09 746f 7272 656e le tor1;..torren │ │ │ -00039180: 745f 6861 6e64 6c65 2074 6f72 323b 0a0a t_handle tor2;.. │ │ │ -00039190: 0969 6e74 2070 6965 6365 5f73 697a 6520 .int piece_size │ │ │ -000391a0: 3d20 3332 202a 2031 3032 343b 0a09 696e = 32 * 1024;..in │ │ │ -000391b0: 7420 7469 6d65 6f75 7420 3d20 3130 3b0a t timeout = 10;. │ │ │ -000391c0: 0969 6620 2866 6c61 6773 2026 616d 703b .if (flags & │ │ │ -000391d0: 206c 6172 6765 5f70 6965 6365 5f73 697a large_piece_siz │ │ │ -000391e0: 6529 0a09 7b0a 0909 7069 6563 655f 7369 e)..{...piece_si │ │ │ -000391f0: 7a65 203d 2031 3032 3420 2a20 3130 3234 ze = 1024 * 1024 │ │ │ -00039200: 3b0a 0909 7469 6d65 6f75 7420 3d20 3930 ;...timeout = 90 │ │ │ -00039210: 3b0a 097d 0a0a 0963 7265 6174 655f 6469 ;..}...create_di │ │ │ -00039220: 7265 6374 6f72 7928 2274 6d70 315f 7472 rectory("tmp1_tr │ │ │ -00039230: 616e 7366 6572 222c 2065 6329 3b0a 0973 ansfer", ec);..s │ │ │ -00039240: 7464 3a3a 6f66 7374 7265 616d 2066 696c td::ofstream fil │ │ │ -00039250: 6528 2274 6d70 315f 7472 616e 7366 6572 e("tmp1_transfer │ │ │ -00039260: 2f74 656d 706f 7261 7279 2229 3b0a 0961 /temporary");..a │ │ │ -00039270: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -00039280: 7320 6174 7020 3d20 3a3a 6372 6561 7465 s atp = ::create │ │ │ -00039290: 5f74 6f72 7265 6e74 2826 616d 703b 6669 _torrent(&fi │ │ │ -000392a0: 6c65 2c20 2274 656d 706f 7261 7279 222c le, "temporary", │ │ │ -000392b0: 2070 6965 6365 5f73 697a 652c 2031 332c piece_size, 13, │ │ │ -000392c0: 2066 616c 7365 0a09 092c 207b 7d2c 2022 false..., {}, " │ │ │ -000392d0: 222c 2062 6f6f 6c28 666c 6167 7320 2661 ", bool(flags &a │ │ │ -000392e0: 6d70 3b20 6261 645f 7631 5f68 6173 6865 mp; bad_v1_hashe │ │ │ -000392f0: 7329 293b 0a09 6669 6c65 2e63 6c6f 7365 s));..file.close │ │ │ -00039300: 2829 3b0a 0a3c 2f70 7265 3e3c 2f74 643e ();.. │ │ │ -00039310: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00039340: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00039350: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00039360: 7074 3a65 7870 616e 6428 3134 3429 223e pt:expand(144)"> │ │ │ -00039370: 2e2e 2f74 6573 742f 7465 7374 5f62 6c6f ../test/test_blo │ │ │ -00039380: 6f6d 5f66 696c 7465 722e 6370 703a 3131 om_filter.cpp:11 │ │ │ -00039390: 323c 2f61 3e3c 2f74 643e 3c74 643e 7465 2te │ │ │ -000393a0: 7374 2073 697a 6528 293c 2f74 643e 3c2f st size()

    test size │ │ │ -00039400: 2829 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ()

    ../te │ │ │ -00039410: 7374 2f74 6573 745f 626c 6f6f 6d5f 6669 st/test_bloom_fi │ │ │ -00039420: 6c74 6572 2e63 7070 3a31 3132 3c2f 6834 lter.cpp:112

    rele
    │ │ │ -000394a0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -000394e0: 7374 5f62 6c6f 6f6d 5f66 696c 7465 722e  st_bloom_filter.
    │ │ │ -000394f0: 6370 703a 3131 333c 2f61 3e3c 2f74 643e  cpp:113
    │ │ │ -00039500: 3c74 643e 7465 7374 2063 6c65 6172 2829  test clear()
    │ │ │ -00039510: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964  

    te │ │ │ -00039560: 7374 2063 6c65 6172 2829 3c2f 6832 3e3c st clear()

    < │ │ │ -00039570: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ -00039580: 626c 6f6f 6d5f 6669 6c74 6572 2e63 7070 bloom_filter.cpp │ │ │ -00039590: 3a31 3133 3c2f 6834 3e3c 7072 6520 7374 :113
    .sha1_hash k(
    │ │ │ -000395e0: 225c 7830 315c 7830 305c 7830 325c 7830  "\x01\x00\x02\x0
    │ │ │ -000395f0: 3020 2020 2020 2020 2020 2020 2020 2020  0               
    │ │ │ -00039600: 2022 293b 0a09 5445 5354 5f43 4845 434b   ");..TEST_CHECK
    │ │ │ -00039610: 2821 6669 6c74 6572 2e66 696e 6428 6b29  (!filter.find(k)
    │ │ │ -00039620: 293b 0a09 6669 6c74 6572 2e73 6574 286b  );..filter.set(k
    │ │ │ -00039630: 293b 0a09 5445 5354 5f43 4845 434b 2866  );..TEST_CHECK(f
    │ │ │ -00039640: 696c 7465 722e 6669 6e64 286b 2929 3b0a  ilter.find(k));.
    │ │ │ -00039650: 0a09 7374 643a 3a75 696e 7438 5f74 2063  ..std::uint8_t c
    │ │ │ -00039660: 6f6d 7061 7265 5b34 5d20 3d20 7b20 3078  ompare[4] = { 0x
    │ │ │ -00039670: 3136 2c20 3078 6666 2c20 3078 3535 2c20  16, 0xff, 0x55, 
    │ │ │ -00039680: 3078 6161 7d3b 0a0a 0962 6974 735f 6f75  0xaa};...bits_ou
    │ │ │ -00039690: 7420 3d20 6669 6c74 6572 2e74 6f5f 7374  t = filter.to_st
    │ │ │ -000396a0: 7269 6e67 2829 3b0a 0954 4553 545f 4551  ring();..TEST_EQ
    │ │ │ -000396b0: 5541 4c28 6d65 6d63 6d70 2863 6f6d 7061  UAL(memcmp(compa
    │ │ │ -000396c0: 7265 2c20 6269 7473 5f6f 7574 2e63 5f73  re, bits_out.c_s
    │ │ │ -000396d0: 7472 2829 2c20 3429 2c20 3029 3b0a 7d0a  tr(), 4), 0);.}.
    │ │ │ -000396e0: 0a7d 202f 2f20 616e 6f6e 796d 6f75 7320  .} // anonymous 
    │ │ │ -000396f0: 6e61 6d65 7370 6163 650a 0a54 4f52 5245  namespace..TORRE
    │ │ │ -00039700: 4e54 5f54 4553 5428 626c 6f6f 6d5f 6669  NT_TEST(bloom_fi
    │ │ │ -00039710: 6c74 6572 290a 7b0a 0974 6573 745f 7365  lter).{..test_se
    │ │ │ -00039720: 745f 616e 645f 6765 7428 293b 0a09 7465  t_and_get();..te
    │ │ │ -00039730: 7374 5f73 6574 5f62 6974 7328 293b 0a09  st_set_bits();..
    │ │ │ -00039740: 7465 7374 5f63 6f75 6e74 5f7a 6572 6f65  test_count_zeroe
    │ │ │ -00039750: 7328 293b 0a09 7465 7374 5f74 6f5f 6672  s();..test_to_fr
    │ │ │ -00039760: 6f6d 5f73 7472 696e 6728 293b 0a0a 3c64  om_string();..}.
    < │ │ │ -000397b0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -000397e0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00039810: 2e2f 7465 7374 2f74 6573 745f 7265 7375 ./test/test_resu │ │ │ -00039820: 6d65 2e63 7070 3a35 3931 3c2f 613e 3c2f me.cpp:591test what │ │ │ -00039840: 2068 6170 7065 6e73 2077 6865 6e20 6c6f happens when lo │ │ │ -00039850: 6164 696e 6720 6120 7265 7375 6d65 2066 ading a resume f │ │ │ -00039860: 696c 6520 7769 7468 2062 6f74 6820 7069 ile with both pi │ │ │ -00039870: 6563 6520 7072 696f 7269 7469 6573 2061 ece priorities a │ │ │ -00039880: 6e64 2066 696c 6520 7072 696f 7269 7469 nd file prioriti │ │ │ -00039890: 6573 2028 6669 6c65 2070 7269 6f20 7368 es (file prio sh │ │ │ -000398a0: 6f75 6c64 2074 616b 6520 7072 6563 6564 ould take preced │ │ │ -000398b0: 656e 6365 293c 2f74 643e 3c2f 7472 3e3c ence)< │ │ │ -000398c0: 7472 2069 643d 2231 3436 2220 7374 796c tr id="146" styl │ │ │ -000398d0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000398e0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000398f0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00039900: 6832 3e74 6573 7420 7768 6174 2068 6170 h2>test what hap │ │ │ -00039910: 7065 6e73 2077 6865 6e20 6c6f 6164 696e pens when loadin │ │ │ -00039920: 6720 6120 7265 7375 6d65 2066 696c 6520 g a resume file │ │ │ -00039930: 7769 7468 2062 6f74 6820 7069 6563 6520 with both piece │ │ │ -00039940: 7072 696f 7269 7469 6573 0a61 6e64 2066 priorities.and f │ │ │ -00039950: 696c 6520 7072 696f 7269 7469 6573 2028 ile priorities ( │ │ │ -00039960: 6669 6c65 2070 7269 6f20 7368 6f75 6c64 file prio should │ │ │ -00039970: 2074 616b 6520 7072 6563 6564 656e 6365 take precedence │ │ │ -00039980: 293c 2f68 323e 3c68 343e 2e2e 2f74 6573 )

    ../tes │ │ │ -00039990: 742f 7465 7374 5f72 6573 756d 652e 6370 t/test_resume.cp │ │ │ -000399a0: 703a 3539 313c 2f68 343e 3c70 7265 2073 p:591

    ..{....TEST_
    │ │ │ -000399f0: 4551 5541 4c28 7069 6563 6573 5b69 5d2c  EQUAL(pieces[i],
    │ │ │ -00039a00: 2074 7275 6529 3b0a 0909 7d0a 097d 0a7d   true);...}..}.}
    │ │ │ -00039a10: 0a0a 7d20 2f2f 2061 6e6f 6e79 6d6f 7573  ..} // anonymous
    │ │ │ -00039a20: 206e 616d 6573 7061 6365 0a0a 544f 5252   namespace..TORR
    │ │ │ -00039a30: 454e 545f 5445 5354 2870 6965 6365 5f73  ENT_TEST(piece_s
    │ │ │ -00039a40: 6c6f 7473 5f73 6565 6429 0a7b 0a09 7465  lots_seed).{..te
    │ │ │ -00039a50: 7374 5f70 6965 6365 5f73 6c6f 7473 5f73  st_piece_slots_s
    │ │ │ -00039a60: 6565 6428 7365 7474 696e 6773 2829 293b  eed(settings());
    │ │ │ -00039a70: 0a7d 0a0a 544f 5252 454e 545f 5445 5354  .}..TORRENT_TEST
    │ │ │ -00039a80: 2870 6965 6365 5f73 6c6f 7473 5f73 6565  (piece_slots_see
    │ │ │ -00039a90: 645f 7375 6767 6573 745f 6361 6368 6529  d_suggest_cache)
    │ │ │ -00039aa0: 0a7b 0a09 7365 7474 696e 6773 5f70 6163  .{..settings_pac
    │ │ │ -00039ab0: 6b20 7365 7474 203d 2073 6574 7469 6e67  k sett = setting
    │ │ │ -00039ac0: 7328 293b 0a09 7365 7474 2e73 6574 5f69  s();..sett.set_i
    │ │ │ -00039ad0: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ -00039ae0: 3a3a 7375 6767 6573 745f 6d6f 6465 2c20  ::suggest_mode, 
    │ │ │ -00039af0: 7365 7474 696e 6773 5f70 6163 6b3a 3a73  settings_pack::s
    │ │ │ -00039b00: 7567 6765 7374 5f72 6561 645f 6361 6368  uggest_read_cach
    │ │ │ -00039b10: 6529 3b0a 0974 6573 745f 7069 6563 655f  e);..test_piece_
    │ │ │ -00039b20: 736c 6f74 735f 7365 6564 2873 6574 7429  slots_seed(sett)
    │ │ │ -00039b30: 3b0a 7d0a 0a3c 6469 7620 7374 796c 653d  ;.}..
    .
    │ │ │ -00039b70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00039ba0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00039bb0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../test/tes │ │ │ -00039be0: 745f 7265 7375 6d65 2e63 7070 3a35 3934 t_resume.cpp:594 │ │ │ -00039bf0: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 616b mak │ │ │ -00039c00: 6520 7375 7265 2061 2072 6573 756d 6520 e sure a resume │ │ │ -00039c10: 6669 6c65 206f 6e6c 7920 6576 6572 2063 file only ever c │ │ │ -00039c20: 6f6e 7461 696e 2066 696c 6520 7072 696f ontain file prio │ │ │ -00039c30: 7269 7469 6573 204f 5220 7069 6563 6520 rities OR piece │ │ │ -00039c40: 7072 696f 7269 7469 6573 2e20 4e65 7665 priorities. Neve │ │ │ -00039c50: 7220 626f 7468 2e3c 2f74 643e 3c2f 7472 r both.

    make sure a │ │ │ -00039cb0: 2072 6573 756d 6520 6669 6c65 206f 6e6c resume file onl │ │ │ -00039cc0: 7920 6576 6572 2063 6f6e 7461 696e 2066 y ever contain f │ │ │ -00039cd0: 696c 6520 7072 696f 7269 7469 6573 204f ile priorities O │ │ │ -00039ce0: 5220 7069 6563 650a 7072 696f 7269 7469 R piece.prioriti │ │ │ -00039cf0: 6573 2e20 4e65 7665 7220 626f 7468 2e3c es. Never both.< │ │ │ -00039d00: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ -00039d10: 7465 7374 5f72 6573 756d 652e 6370 703a test_resume.cpp: │ │ │ -00039d20: 3539 343c 2f68 343e 3c70 7265 2073 7479 594

    ...TEST_EQUAL(
    │ │ │ -00039d70: 7069 6563 6573 5b69 5d2c 2074 7275 6529  pieces[i], true)
    │ │ │ -00039d80: 3b0a 0909 7d0a 097d 0a7d 0a0a 7d20 2f2f  ;...}..}.}..} //
    │ │ │ -00039d90: 2061 6e6f 6e79 6d6f 7573 206e 616d 6573   anonymous names
    │ │ │ -00039da0: 7061 6365 0a0a 544f 5252 454e 545f 5445  pace..TORRENT_TE
    │ │ │ -00039db0: 5354 2870 6965 6365 5f73 6c6f 7473 5f73  ST(piece_slots_s
    │ │ │ -00039dc0: 6565 6429 0a7b 0a09 7465 7374 5f70 6965  eed).{..test_pie
    │ │ │ -00039dd0: 6365 5f73 6c6f 7473 5f73 6565 6428 7365  ce_slots_seed(se
    │ │ │ -00039de0: 7474 696e 6773 2829 293b 0a7d 0a0a 544f  ttings());.}..TO
    │ │ │ -00039df0: 5252 454e 545f 5445 5354 2870 6965 6365  RRENT_TEST(piece
    │ │ │ -00039e00: 5f73 6c6f 7473 5f73 6565 645f 7375 6767  _slots_seed_sugg
    │ │ │ -00039e10: 6573 745f 6361 6368 6529 0a7b 0a09 7365  est_cache).{..se
    │ │ │ -00039e20: 7474 696e 6773 5f70 6163 6b20 7365 7474  ttings_pack sett
    │ │ │ -00039e30: 203d 2073 6574 7469 6e67 7328 293b 0a09   = settings();..
    │ │ │ -00039e40: 7365 7474 2e73 6574 5f69 6e74 2873 6574  sett.set_int(set
    │ │ │ -00039e50: 7469 6e67 735f 7061 636b 3a3a 7375 6767  tings_pack::sugg
    │ │ │ -00039e60: 6573 745f 6d6f 6465 2c20 7365 7474 696e  est_mode, settin
    │ │ │ -00039e70: 6773 5f70 6163 6b3a 3a73 7567 6765 7374  gs_pack::suggest
    │ │ │ -00039e80: 5f72 6561 645f 6361 6368 6529 3b0a 0974  _read_cache);..t
    │ │ │ -00039e90: 6573 745f 7069 6563 655f 736c 6f74 735f  est_piece_slots_
    │ │ │ -00039ea0: 7365 6564 2873 6574 7429 3b0a 7d0a 0a0a  seed(sett);.}...
    │ │ │ -00039eb0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ -00039ee0: 2f64 6976 3e3c 2f70 7265 3e3c 2f74 643e /div>
    │ │ │ -00039ef0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00039f20: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00039f30: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00039f40: 7074 3a65 7870 616e 6428 3134 3829 223e pt:expand(148)"> │ │ │ -00039f50: 2e2e 2f74 6573 742f 7465 7374 5f72 6573 ../test/test_res │ │ │ -00039f60: 756d 652e 6370 703a 3539 373c 2f61 3e3c ume.cpp:597< │ │ │ -00039f70: 2f74 643e 3c74 643e 6765 6e65 7261 6c6c /td>generall │ │ │ -00039f80: 7920 7361 7665 3c2f 7464 3e3c 2f74 723e y save │ │ │ -00039f90: 3c74 7220 6964 3d22 3134 3822 2073 7479 │ │ │ -00039fc0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00039fd0: 3c68 323e 6765 6e65 7261 6c6c 7920 7361

    generally sa │ │ │ -00039fe0: 7665 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ve

    ../te │ │ │ -00039ff0: 7374 2f74 6573 745f 7265 7375 6d65 2e63 st/test_resume.c │ │ │ -0003a000: 7070 3a35 3937 3c2f 6834 3e3c 7072 6520 pp:597

    ..}..}.}..}
    │ │ │ -0003a050: 202f 2f20 616e 6f6e 796d 6f75 7320 6e61   // anonymous na
    │ │ │ -0003a060: 6d65 7370 6163 650a 0a54 4f52 5245 4e54  mespace..TORRENT
    │ │ │ -0003a070: 5f54 4553 5428 7069 6563 655f 736c 6f74  _TEST(piece_slot
    │ │ │ -0003a080: 735f 7365 6564 290a 7b0a 0974 6573 745f  s_seed).{..test_
    │ │ │ -0003a090: 7069 6563 655f 736c 6f74 735f 7365 6564  piece_slots_seed
    │ │ │ -0003a0a0: 2873 6574 7469 6e67 7328 2929 3b0a 7d0a  (settings());.}.
    │ │ │ -0003a0b0: 0a54 4f52 5245 4e54 5f54 4553 5428 7069  .TORRENT_TEST(pi
    │ │ │ -0003a0c0: 6563 655f 736c 6f74 735f 7365 6564 5f73  ece_slots_seed_s
    │ │ │ -0003a0d0: 7567 6765 7374 5f63 6163 6865 290a 7b0a  uggest_cache).{.
    │ │ │ -0003a0e0: 0973 6574 7469 6e67 735f 7061 636b 2073  .settings_pack s
    │ │ │ -0003a0f0: 6574 7420 3d20 7365 7474 696e 6773 2829  ett = settings()
    │ │ │ -0003a100: 3b0a 0973 6574 742e 7365 745f 696e 7428  ;..sett.set_int(
    │ │ │ -0003a110: 7365 7474 696e 6773 5f70 6163 6b3a 3a73  settings_pack::s
    │ │ │ -0003a120: 7567 6765 7374 5f6d 6f64 652c 2073 6574  uggest_mode, set
    │ │ │ -0003a130: 7469 6e67 735f 7061 636b 3a3a 7375 6767  tings_pack::sugg
    │ │ │ -0003a140: 6573 745f 7265 6164 5f63 6163 6865 293b  est_read_cache);
    │ │ │ -0003a150: 0a09 7465 7374 5f70 6965 6365 5f73 6c6f  ..test_piece_slo
    │ │ │ -0003a160: 7473 5f73 6565 6428 7365 7474 293b 0a7d  ts_seed(sett);.}
    │ │ │ -0003a170: 0a0a 0a0a 3c64 6976 2073 7479 6c65 3d22  ....
    .
    #if TOR │ │ │ -0003a1b0: 5245 4e54 5f41 4249 5f56 4552 5349 4f4e RENT_ABI_VERSION │ │ │ -0003a1c0: 203d 3d20 310a 544f 5252 454e 545f 5445 == 1.TORRENT_TE │ │ │ -0003a1d0: 5354 2866 696c 655f 7072 696f 7269 7469 ST(file_prioriti │ │ │ -0003a1e0: 6573 5f64 6566 6175 6c74 5f64 6570 7265 es_default_depre │ │ │ -0003a1f0: 6361 7465 6429 0a7b 0a09 6c74 3a3a 7365 cated).{..lt::se │ │ │ -0003a200: 7373 696f 6e20 7365 7328 7365 7474 696e ssion ses(settin │ │ │ -0003a210: 6773 2829 293b 0a09 7374 643a 3a76 6563 gs());..std::vec │ │ │ -0003a220: 746f 7226 6c74 3b64 6f77 6e6c 6f61 645f tor<download_ │ │ │ -0003a230: 7072 696f 7269 7479 5f74 2667 743b 2066 priority_t> f │ │ │ -0003a240: 696c 655f 7072 696f 7269 7469 6573 203d ile_priorities = │ │ │ -0003a250: 2074 6573 745f 7265 7375 6d65 5f66 6c61 test_resume_fla │ │ │ -0003a260: 6773 2873 6573 0a09 092c 207b 7d2c 2022 gs(ses..., {}, " │ │ │ -0003a270: 222c 2022 222c 2074 7275 6529 2e67 6574 ", "", true).get │ │ │ -0003a280: 5f66 696c 655f 7072 696f 7269 7469 6573 _file_priorities │ │ │ -0003a290: 2829 3b0a 0a09 5445 5354 5f45 5155 414c ();...TEST_EQUAL │ │ │ -0003a2a0: 2866 696c 655f 7072 696f 7269 7469 6573 (file_priorities │ │ │ -0003a2b0: 2e73 697a 6528 292c 2033 293b 0a09 5445 .size(), 3);..TE │ │ │ -0003a2c0: 5354 5f45 5155 414c 2866 696c 655f 7072 ST_EQUAL(file_pr │ │ │ -0003a2d0: 696f 7269 7469 6573 5b30 5d2c 2034 293b iorities[0], 4); │ │ │ -0003a2e0: 0a09 5445 5354 5f45 5155 414c 2866 696c ..TEST_EQUAL(fil │ │ │ -0003a2f0: 655f 7072 696f 7269 7469 6573 5b31 5d2c e_priorities[1], │ │ │ -0003a300: 2034 293b 0a09 5445 5354 5f45 5155 414c 4);..TEST_EQUAL │ │ │ -0003a310: 2866 696c 655f 7072 696f 7269 7469 6573 (file_priorities │ │ │ -0003a320: 5b32 5d2c 2034 293b 0a7d 0a0a 2f2f 2041 [2], 4);.}..// A │ │ │ -0003a330: 7320 6c6f 6e67 2061 7320 7468 6520 6164 s long as the ad │ │ │ -0003a340: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ -0003a350: 2070 7269 6f72 6974 6965 7320 6172 6520 priorities are │ │ │ -0003a360: 656d 7074 792c 2074 6865 2066 696c 655f empty, the file_ │ │ │ -0003a370: 7072 696f 7269 7469 6573 0a2f 2f20 6672 priorities.// fr │ │ │ -0003a380: 6f6d 2074 6865 2072 6573 756d 6520 6461 om the resume da │ │ │ -0003a390: 7461 2073 686f 756c 6420 7461 6b65 2065 ta should take e │ │ │ -0003a3a0: 6666 6563 740a 544f 5252 454e 545f 5445 ffect.TORRENT_TE │ │ │ -0003a3b0: 5354 2866 696c 655f 7072 696f 7269 7469 ST(file_prioriti │ │ │ -0003a3c0: 6573 5f69 6e5f 7265 7375 6d65 5f64 6570 es_in_resume_dep │ │ │ -0003a3d0: 7265 6361 7465 6429 0a7b 0a09 6c74 3a3a recated).{..lt:: │ │ │ -0003a3e0: 7365 7373 696f 6e20 7365 7328 7365 7474 session ses(sett │ │ │ -0003a3f0: 696e 6773 2829 293b 0a09 7374 643a 3a76 ings());..std::v │ │ │ -0003a400: 6563 746f 7226 6c74 3b64 6f77 6e6c 6f61 ector<downloa │ │ │ -0003a410: 645f 7072 696f 7269 7479 5f74 2667 743b d_priority_t> │ │ │ -0003a420: 2066 696c 655f 7072 696f 7269 7469 6573 file_priorities │ │ │ -0003a430: 203d 2074 6573 745f 7265 7375 6d65 5f66 = test_resume_f │ │ │ -0003a440: 6c61 6773 2873 6573 2c20 7b7d 2c20 2222 lags(ses, {}, "" │ │ │ -0003a450: 2c20 2231 3233 2229 2e67 6574 5f66 696c , "123").get_fil │ │ │ -0003a460: 655f 7072 696f 7269 7469 6573 2829 3b0a e_priorities();. │ │ │ -0003a470: 0a09 5445 5354 5f45 5155 414c 2866 696c ..TEST_EQUAL(fil │ │ │ -0003a480: 655f 7072 696f 7269 7469 6573 2e73 697a e_priorities.siz │ │ │ -0003a490: 6528 292c 2033 293b 0a09 5445 5354 5f45 e(), 3);..TEST_E │ │ │ -0003a4a0: 5155 414c 2866 696c 655f 7072 696f 7269 QUAL(file_priori │ │ │ -0003a4b0: 7469 6573 5b30 5d2c 2031 293b 0a09 5445 ties[0], 1);..TE │ │ │ -0003a4c0: 5354 5f45 5155 414c 2866 696c 655f 7072 ST_EQUAL(file_pr │ │ │ -0003a4d0: 696f 7269 7469 6573 5b31 5d2c 2032 293b iorities[1], 2); │ │ │ -0003a4e0: 0a09 5445 5354 5f45 5155 414c 2866 696c ..TEST_EQUAL(fil │ │ │ -0003a4f0: 655f 7072 696f 7269 7469 6573 5b32 5d2c e_priorities[2], │ │ │ -0003a500: 2033 293b 0a7d 0a0a 2f2f 2069 6620 626f 3);.}..// if bo │ │ │ -0003a510: 7468 2072 6573 756d 6520 6461 7461 2061 th resume data a │ │ │ -0003a520: 6e64 2061 6464 5f74 6f72 7265 6e74 5f70 nd add_torrent_p │ │ │ -0003a530: 6172 616d 7320 6861 7320 6669 6c65 5f70 arams has file_p │ │ │ -0003a540: 7269 6f72 6974 6965 732c 2074 6865 0a2f riorities, the./ │ │ │ -0003a550: 2f20 6164 645f 746f 7272 656e 745f 7061 / add_torrent_pa │ │ │ -0003a560: 7261 6d73 206f 6e65 2074 616b 6520 7072 rams one take pr │ │ │ -0003a570: 6563 6564 656e 6365 0a54 4f52 5245 4e54 ecedence.TORRENT │ │ │ -0003a580: 5f54 4553 5428 6669 6c65 5f70 7269 6f72 _TEST(file_prior │ │ │ -0003a590: 6974 6965 735f 696e 5f72 6573 756d 655f ities_in_resume_ │ │ │ -0003a5a0: 616e 645f 7061 7261 6d73 5f64 6570 7265 and_params_depre │ │ │ -0003a5b0: 6361 7465 6429 0a7b 0a3c 2f70 7265 3e3c cated).{.
    < │ │ │ -0003a5c0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0003a5f0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0003a600: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -0003a630: 5f72 6573 756d 652e 6370 703a 3932 303c _resume.cpp:920< │ │ │ -0003a640: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374 /a>test │ │ │ -0003a650: 2061 6c6c 206f 7468 6572 2072 6573 756d all other resum │ │ │ -0003a660: 6520 666c 6167 7320 6865 7265 2074 6f6f e flags here too │ │ │ -0003a670: 2e20 5468 6973 2077 6f75 6c64 2072 6571 . This would req │ │ │ -0003a680: 7569 7265 2072 6574 7572 6e69 6e67 206d uire returning m │ │ │ -0003a690: 6f72 6520 7468 616e 206a 7573 7420 7468 ore than just th │ │ │ -0003a6a0: 6520 746f 7272 656e 745f 7374 6174 7573 e torrent_status │ │ │ -0003a6b0: 2066 726f 6d20 7465 7374 5f72 6573 756d from test_resum │ │ │ -0003a6c0: 655f 666c 6167 732e 2041 6c73 6f20 6874 e_flags. Also ht │ │ │ -0003a6d0: 7470 2073 6565 6473 2061 6e64 2074 7261 tp seeds and tra │ │ │ -0003a6e0: 636b 6572 7320 666f 7220 696e 7374 616e ckers for instan │ │ │ -0003a6f0: 6365 3c2f 7464 3e3c 2f74 723e 3c74 7220 ce

    │ │ │ -0003a740: 7465 7374 2061 6c6c 206f 7468 6572 2072 test all other r │ │ │ -0003a750: 6573 756d 6520 666c 6167 7320 6865 7265 esume flags here │ │ │ -0003a760: 2074 6f6f 2e20 5468 6973 2077 6f75 6c64 too. This would │ │ │ -0003a770: 2072 6571 7569 7265 2072 6574 7572 6e69 require returni │ │ │ -0003a780: 6e67 0a6d 6f72 6520 7468 616e 206a 7573 ng.more than jus │ │ │ -0003a790: 7420 7468 6520 746f 7272 656e 745f 7374 t the torrent_st │ │ │ -0003a7a0: 6174 7573 2066 726f 6d20 7465 7374 5f72 atus from test_r │ │ │ -0003a7b0: 6573 756d 655f 666c 6167 732e 2041 6c73 esume_flags. Als │ │ │ -0003a7c0: 6f20 6874 7470 2073 6565 6473 0a61 6e64 o http seeds.and │ │ │ -0003a7d0: 2074 7261 636b 6572 7320 666f 7220 696e trackers for in │ │ │ -0003a7e0: 7374 616e 6365 3c2f 6832 3e3c 6834 3e2e stance

    . │ │ │ -0003a7f0: 2e2f 7465 7374 2f74 6573 745f 7265 7375 ./test/test_resu │ │ │ -0003a800: 6d65 2e63 7070 3a39 3230 3c2f 6834 3e3c me.cpp:920

    < │ │ │ -0003a810: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0003a820: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0003a830: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0003a840: 7820 2364 6464 3b22 3e09 5445 5354 5f45 x #ddd;">.TEST_E │ │ │ -0003a850: 5155 414c 2873 2e63 6f6e 6e65 6374 696f QUAL(s.connectio │ │ │ -0003a860: 6e73 5f6c 696d 6974 2c20 3133 3435 293b ns_limit, 1345); │ │ │ -0003a870: 0a09 5445 5354 5f45 5155 414c 2873 2e75 ..TEST_EQUAL(s.u │ │ │ -0003a880: 706c 6f61 6473 5f6c 696d 6974 2c20 3133 ploads_limit, 13 │ │ │ -0003a890: 3436 293b 0a7d 0a0a 544f 5252 454e 545f 46);.}..TORRENT_ │ │ │ -0003a8a0: 5445 5354 2870 6175 7365 645f 6465 7072 TEST(paused_depr │ │ │ -0003a8b0: 6563 6174 6564 290a 7b0a 096c 743a 3a73 ecated).{..lt::s │ │ │ -0003a8c0: 6573 7369 6f6e 2073 6573 2873 6574 7469 ession ses(setti │ │ │ -0003a8d0: 6e67 7328 2929 3b0a 092f 2f20 7265 7375 ngs());..// resu │ │ │ -0003a8e0: 6d65 2064 6174 6120 6f76 6572 7269 6465 me data override │ │ │ -0003a8f0: 7320 7468 6520 7061 7573 6564 2066 6c61 s the paused fla │ │ │ -0003a900: 670a 0961 7574 6f20 636f 6e73 7420 6e6f g..auto const no │ │ │ -0003a910: 7720 3d20 6c74 3a3a 636c 6f63 6b5f 7479 w = lt::clock_ty │ │ │ -0003a920: 7065 3a3a 6e6f 7728 293b 0a09 746f 7272 pe::now();..torr │ │ │ -0003a930: 656e 745f 7374 6174 7573 2073 203d 2074 ent_status s = t │ │ │ -0003a940: 6573 745f 7265 7375 6d65 5f66 6c61 6773 est_resume_flags │ │ │ -0003a950: 2873 6573 2c20 746f 7272 656e 745f 666c (ses, torrent_fl │ │ │ -0003a960: 6167 733a 3a70 6175 7365 642c 2022 222c ags::paused, "", │ │ │ -0003a970: 2022 222c 2074 7275 6529 2e73 7461 7475 "", true).statu │ │ │ -0003a980: 7328 293b 0a09 6465 6661 756c 745f 7465 s();..default_te │ │ │ -0003a990: 7374 7328 732c 206e 6f77 293b 0a23 6966 sts(s, now);.#if │ │ │ -0003a9a0: 6465 6620 544f 5252 454e 545f 5749 4e44 def TORRENT_WIND │ │ │ -0003a9b0: 4f57 530a 0954 4553 545f 4551 5541 4c28 OWS..TEST_EQUAL( │ │ │ -0003a9c0: 732e 7361 7665 5f70 6174 682c 2022 633a s.save_path, "c: │ │ │ -0003a9d0: 5c5c 6164 645f 746f 7272 656e 745f 7061 \\add_torrent_pa │ │ │ -0003a9e0: 7261 6d73 2073 6176 655f 7061 7468 2229 rams save_path") │ │ │ -0003a9f0: 3b0a 2365 6c73 650a 0954 4553 545f 4551 ;.#else..TEST_EQ │ │ │ -0003aa00: 5541 4c28 732e 7361 7665 5f70 6174 682c UAL(s.save_path, │ │ │ -0003aa10: 2022 2f61 6464 5f74 6f72 7265 6e74 5f70 "/add_torrent_p │ │ │ -0003aa20: 6172 616d 7320 7361 7665 5f70 6174 6822 arams save_path" │ │ │ -0003aa30: 293b 0a23 656e 6469 660a 0954 4553 545f );.#endif..TEST_ │ │ │ -0003aa40: 4551 5541 4c28 732e 666c 6167 7320 2661 EQUAL(s.flags &a │ │ │ -0003aa50: 6d70 3b20 666c 6167 735f 6d61 736b 2c20 mp; flags_mask, │ │ │ -0003aa60: 746f 7272 656e 745f 666c 6167 735f 747b torrent_flags_t{ │ │ │ -0003aa70: 7d29 3b0a 0954 4553 545f 4551 5541 4c28 });..TEST_EQUAL( │ │ │ -0003aa80: 732e 636f 6e6e 6563 7469 6f6e 735f 6c69 s.connections_li │ │ │ -0003aa90: 6d69 742c 2031 3334 3529 3b0a 0954 4553 mit, 1345);..TES │ │ │ -0003aaa0: 545f 4551 5541 4c28 732e 7570 6c6f 6164 T_EQUAL(s.upload │ │ │ -0003aab0: 735f 6c69 6d69 742c 2031 3334 3629 3b0a s_limit, 1346);. │ │ │ -0003aac0: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    } │ │ │ -0003aaf0: 0a3c 2f64 6976 3e0a 544f 5252 454e 545f .
    .TORRENT_ │ │ │ -0003ab00: 5445 5354 2875 726c 5f73 6565 645f 7265 TEST(url_seed_re │ │ │ -0003ab10: 7375 6d65 5f64 6174 615f 6465 7072 6563 sume_data_deprec │ │ │ -0003ab20: 6174 6564 290a 7b0a 092f 2f20 6d65 7267 ated).{..// merg │ │ │ -0003ab30: 6520 7572 6c20 7365 6564 7320 7769 7468 e url seeds with │ │ │ -0003ab40: 2072 6573 756d 6520 6461 7461 0a09 7374 resume data..st │ │ │ -0003ab50: 643a 3a70 7269 6e74 6628 2266 6c61 6773 d::printf("flags │ │ │ -0003ab60: 3a20 6d65 7267 655f 7265 7375 6d65 5f68 : merge_resume_h │ │ │ -0003ab70: 7474 705f 7365 6564 735c 6e22 293b 0a09 ttp_seeds\n");.. │ │ │ -0003ab80: 6c74 3a3a 7365 7373 696f 6e20 7365 7328 lt::session ses( │ │ │ -0003ab90: 7365 7474 696e 6773 2829 293b 0a09 746f settings());..to │ │ │ -0003aba0: 7272 656e 745f 6861 6e64 6c65 2068 203d rrent_handle h = │ │ │ -0003abb0: 2074 6573 745f 7265 7375 6d65 5f66 6c61 test_resume_fla │ │ │ -0003abc0: 6773 2873 6573 2c0a 0909 746f 7272 656e gs(ses,...torren │ │ │ -0003abd0: 745f 666c 6167 733a 3a6d 6572 6765 5f72 t_flags::merge_r │ │ │ -0003abe0: 6573 756d 655f 6874 7470 5f73 6565 6473 esume_http_seeds │ │ │ -0003abf0: 2c20 2222 2c20 2222 2c20 7472 7565 293b , "", "", true); │ │ │ -0003ac00: 0a09 7374 643a 3a73 6574 266c 743b 7374 ..std::set<st │ │ │ -0003ac10: 643a 3a73 7472 696e 6726 6774 3b20 7573 d::string> us │ │ │ -0003ac20: 203d 2068 2e75 726c 5f73 6565 6473 2829 = h.url_seeds() │ │ │ -0003ac30: 3b0a 0a09 5445 5354 5f45 5155 414c 2875 ;...TEST_EQUAL(u │ │ │ -0003ac40: 732e 7369 7a65 2829 2c20 3229 3b0a 0954 s.size(), 2);..T │ │ │ -0003ac50: 4553 545f 4551 5541 4c28 7374 643a 3a63 EST_EQUAL(std::c │ │ │ -0003ac60: 6f75 6e74 2875 732e 6265 6769 6e28 292c ount(us.begin(), │ │ │ -0003ac70: 2075 732e 656e 6428 292c 2022 6874 7470 us.end(), "http │ │ │ -0003ac80: 3a2f 2f61 6464 2d74 6f72 7265 6e74 2d70 ://add-torrent-p │ │ │ -0003ac90: 6172 616d 732d 7572 6c2d 7365 6564 2e63 arams-url-seed.c │ │ │ -0003aca0: 6f6d 2f22 292c 2031 293b 0a09 5445 5354 om/"), 1);..TEST │ │ │ -0003acb0: 5f45 5155 414c 2873 7464 3a3a 636f 756e _EQUAL(std::coun │ │ │ -0003acc0: 7428 7573 2e62 6567 696e 2829 2c20 7573 t(us.begin(), us │ │ │ -0003acd0: 2e65 6e64 2829 2c20 2268 7474 703a 2f2f .end(), "http:// │ │ │ -0003ace0: 7265 7375 6d65 2d64 6174 612d 7572 6c2d resume-data-url- │ │ │ -0003acf0: 7365 6564 2e63 6f6d 2f22 292c 2031 293b seed.com/"), 1); │ │ │ -0003ad00: 0a0a 092f 2f20 2268 7474 703a 2f2f 746f ...// "http://to │ │ │ -0003ad10: 7272 656e 742d 6669 6c65 2d75 726c 2d73 rrent-file-url-s │ │ │ -0003ad20: 6565 642e 636f 6d2f 2220 6973 206e 6f20 eed.com/" is no │ │ │ -0003ad30: 6c6f 6e67 6572 2070 6172 7420 6f66 2074 longer part of t │ │ │ -0003ad40: 6f72 7265 6e74 5f69 6e66 6f2c 0a09 2f2f orrent_info,..// │ │ │ -0003ad50: 2061 6e64 2073 6f20 6973 206e 6f20 6c6f and so is no lo │ │ │ -0003ad60: 6e67 6572 2069 6e63 6c75 6465 6420 7768 nger included wh │ │ │ -0003ad70: 656e 2074 6865 2074 6f72 7265 6e74 2069 en the torrent i │ │ │ -0003ad80: 7320 6164 6465 640a 7d0a 0a54 4f52 5245 s added.}..TORRE │ │ │ -0003ad90: 4e54 5f54 4553 5428 7265 7375 6d65 5f6f NT_TEST(resume_o │ │ │ -0003ada0: 7665 7272 6964 655f 746f 7272 656e 745f verride_torrent_ │ │ │ -0003adb0: 6465 7072 6563 6174 6564 290a 7b0a 092f deprecated).{../ │ │ │ -0003adc0: 2f20 7265 7375 6d65 2064 6174 6120 6f76 / resume data ov │ │ │ -0003add0: 6572 7269 6465 7320 7468 6520 2e74 6f72 errides the .tor │ │ │ -0003ade0: 7265 6e74 5f66 696c 650a 0973 7464 3a3a rent_file..std:: │ │ │ -0003adf0: 7072 696e 7466 2822 666c 6167 733a 206e printf("flags: n │ │ │ -0003ae00: 6f20 6d65 7267 655f 7265 7375 6d65 5f68 o merge_resume_h │ │ │ -0003ae10: 7474 705f 7365 6564 5c6e 2229 3b0a 096c ttp_seed\n");..l │ │ │ -0003ae20: 743a 3a73 6573 7369 6f6e 2073 6573 2873 t::session ses(s │ │ │ -0003ae30: 6574 7469 6e67 7328 2929 3b0a 0974 6f72 ettings());..tor │ │ │ -0003ae40: 7265 6e74 5f68 616e 646c 6520 6820 3d20 rent_handle h = │ │ │ -0003ae50: 7465 7374 5f72 6573 756d 655f 666c 6167 test_resume_flag │ │ │ -0003ae60: 7328 7365 732c 0a09 0974 6f72 7265 6e74 s(ses,...torrent │ │ │ -0003ae70: 5f66 6c61 6773 3a3a 6d65 7267 655f 7265 _flags::merge_re │ │ │ -0003ae80: 7375 6d65 5f74 7261 636b 6572 732c 2022 sume_trackers, " │ │ │ -0003ae90: 222c 2022 222c 2074 7275 6529 3b0a 0973 ", "", true);..s │ │ │ -0003aea0: 7464 3a3a 7365 7426 6c74 3b73 7464 3a3a td::set<std:: │ │ │ -0003aeb0: 7374 7269 6e67 2667 743b 2075 7320 3d20 string> us = │ │ │ -0003aec0: 682e 7572 6c5f 7365 6564 7328 293b 0a0a h.url_seeds();.. │ │ │ -0003aed0: 0954 4553 545f 4551 5541 4c28 7573 2e73 .TEST_EQUAL(us.s │ │ │ -0003aee0: 697a 6528 292c 2031 293b 0a09 5445 5354 ize(), 1);..TEST │ │ │ -0003aef0: 5f45 5155 414c 2873 7464 3a3a 636f 756e _EQUAL(std::coun │ │ │ -0003af00: 7428 7573 2e62 6567 696e 2829 2c20 7573 t(us.begin(), us │ │ │ -0003af10: 2e65 6e64 2829 2c20 2268 7474 703a 2f2f .end(), "http:// │ │ │ -0003af20: 7265 7375 6d65 2d64 6174 612d 7572 6c2d resume-data-url- │ │ │ -0003af30: 7365 6564 2e63 6f6d 2f22 292c 2031 293b seed.com/"), 1); │ │ │ -0003af40: 0a7d 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .}. │ │ │ -0003af70: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0003af80: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0
    .. │ │ │ -0003afb0: 2f74 6573 742f 7465 7374 5f72 6573 756d /test/test_resum │ │ │ -0003afc0: 652e 6370 703a 3136 3734 3c2f 613e 3c2f e.cpp:1674test all │ │ │ -0003afe0: 6f74 6865 7220 7265 7375 6d65 2066 6c61 other resume fla │ │ │ -0003aff0: 6773 2068 6572 6520 746f 6f2e 2054 6869 gs here too. Thi │ │ │ -0003b000: 7320 776f 756c 6420 7265 7175 6972 6520 s would require │ │ │ -0003b010: 7265 7475 726e 696e 6720 6d6f 7265 2074 returning more t │ │ │ -0003b020: 6861 6e20 6a75 7374 2074 6865 2074 6f72 han just the tor │ │ │ -0003b030: 7265 6e74 5f73 7461 7475 7320 6672 6f6d rent_status from │ │ │ -0003b040: 2074 6573 745f 7265 7375 6d65 5f66 6c61 test_resume_fla │ │ │ -0003b050: 6773 2e20 416c 736f 2068 7474 7020 7365 gs. Also http se │ │ │ -0003b060: 6564 7320 616e 6420 7472 6163 6b65 7273 eds and trackers │ │ │ -0003b070: 2066 6f72 2069 6e73 7461 6e63 653c 2f74 for instance

    test │ │ │ -0003b0d0: 616c 6c20 6f74 6865 7220 7265 7375 6d65 all other resume │ │ │ -0003b0e0: 2066 6c61 6773 2068 6572 6520 746f 6f2e flags here too. │ │ │ -0003b0f0: 2054 6869 7320 776f 756c 6420 7265 7175 This would requ │ │ │ -0003b100: 6972 6520 7265 7475 726e 696e 670a 6d6f ire returning.mo │ │ │ -0003b110: 7265 2074 6861 6e20 6a75 7374 2074 6865 re than just the │ │ │ -0003b120: 2074 6f72 7265 6e74 5f73 7461 7475 7320 torrent_status │ │ │ -0003b130: 6672 6f6d 2074 6573 745f 7265 7375 6d65 from test_resume │ │ │ -0003b140: 5f66 6c61 6773 2e20 416c 736f 2068 7474 _flags. Also htt │ │ │ -0003b150: 7020 7365 6564 730a 616e 6420 7472 6163 p seeds.and trac │ │ │ -0003b160: 6b65 7273 2066 6f72 2069 6e73 7461 6e63 kers for instanc │ │ │ -0003b170: 653c 2f68 323e 3c68 343e 2e2e 2f74 6573 e

    ../tes │ │ │ -0003b180: 742f 7465 7374 5f72 6573 756d 652e 6370 t/test_resume.cp │ │ │ -0003b190: 703a 3136 3734 3c2f 6834 3e3c 7072 6520 p:1674

    .TEST_EQUAL
    │ │ │ -0003b1e0: 2873 2e63 6f6e 6e65 6374 696f 6e73 5f6c  (s.connections_l
    │ │ │ -0003b1f0: 696d 6974 2c20 3133 3435 293b 0a09 5445  imit, 1345);..TE
    │ │ │ -0003b200: 5354 5f45 5155 414c 2873 2e75 706c 6f61  ST_EQUAL(s.uploa
    │ │ │ -0003b210: 6473 5f6c 696d 6974 2c20 3133 3436 293b  ds_limit, 1346);
    │ │ │ -0003b220: 0a7d 0a0a 544f 5252 454e 545f 5445 5354  .}..TORRENT_TEST
    │ │ │ -0003b230: 2870 6175 7365 6429 0a7b 0a09 6c74 3a3a  (paused).{..lt::
    │ │ │ -0003b240: 7365 7373 696f 6e20 7365 7328 7365 7474  session ses(sett
    │ │ │ -0003b250: 696e 6773 2829 293b 0a09 2f2f 2072 6573  ings());..// res
    │ │ │ -0003b260: 756d 6520 6461 7461 206f 7665 7272 6964  ume data overrid
    │ │ │ -0003b270: 6573 2074 6865 2070 6175 7365 6420 666c  es the paused fl
    │ │ │ -0003b280: 6167 0a09 6175 746f 2063 6f6e 7374 206e  ag..auto const n
    │ │ │ -0003b290: 6f77 203d 206c 743a 3a63 6c6f 636b 5f74  ow = lt::clock_t
    │ │ │ -0003b2a0: 7970 653a 3a6e 6f77 2829 3b0a 0974 6f72  ype::now();..tor
    │ │ │ -0003b2b0: 7265 6e74 5f73 7461 7475 7320 7320 3d20  rent_status s = 
    │ │ │ -0003b2c0: 7465 7374 5f72 6573 756d 655f 666c 6167  test_resume_flag
    │ │ │ -0003b2d0: 7328 7365 732c 2074 6f72 7265 6e74 5f66  s(ses, torrent_f
    │ │ │ -0003b2e0: 6c61 6773 3a3a 7061 7573 6564 292e 7374  lags::paused).st
    │ │ │ -0003b2f0: 6174 7573 2829 3b0a 0964 6566 6175 6c74  atus();..default
    │ │ │ -0003b300: 5f74 6573 7473 2873 2c20 6e6f 7729 3b0a  _tests(s, now);.
    │ │ │ -0003b310: 2369 6664 6566 2054 4f52 5245 4e54 5f57  #ifdef TORRENT_W
    │ │ │ -0003b320: 494e 444f 5753 0a09 5445 5354 5f45 5155  INDOWS..TEST_EQU
    │ │ │ -0003b330: 414c 2873 2e73 6176 655f 7061 7468 2c20  AL(s.save_path, 
    │ │ │ -0003b340: 2263 3a5c 5c61 6464 5f74 6f72 7265 6e74  "c:\\add_torrent
    │ │ │ -0003b350: 5f70 6172 616d 7320 7361 7665 5f70 6174  _params save_pat
    │ │ │ -0003b360: 6822 293b 0a23 656c 7365 0a09 5445 5354  h");.#else..TEST
    │ │ │ -0003b370: 5f45 5155 414c 2873 2e73 6176 655f 7061  _EQUAL(s.save_pa
    │ │ │ -0003b380: 7468 2c20 222f 6164 645f 746f 7272 656e  th, "/add_torren
    │ │ │ -0003b390: 745f 7061 7261 6d73 2073 6176 655f 7061  t_params save_pa
    │ │ │ -0003b3a0: 7468 2229 3b0a 2365 6e64 6966 0a09 5445  th");.#endif..TE
    │ │ │ -0003b3b0: 5354 5f45 5155 414c 2873 2e66 6c61 6773  ST_EQUAL(s.flags
    │ │ │ -0003b3c0: 2026 616d 703b 2066 6c61 6773 5f6d 6173   & flags_mas
    │ │ │ -0003b3d0: 6b2c 2074 6f72 7265 6e74 5f66 6c61 6773  k, torrent_flags
    │ │ │ -0003b3e0: 3a3a 7061 7573 6564 293b 0a09 5445 5354  ::paused);..TEST
    │ │ │ -0003b3f0: 5f45 5155 414c 2873 2e63 6f6e 6e65 6374  _EQUAL(s.connect
    │ │ │ -0003b400: 696f 6e73 5f6c 696d 6974 2c20 3133 3435  ions_limit, 1345
    │ │ │ -0003b410: 293b 0a09 5445 5354 5f45 5155 414c 2873  );..TEST_EQUAL(s
    │ │ │ -0003b420: 2e75 706c 6f61 6473 5f6c 696d 6974 2c20  .uploads_limit, 
    │ │ │ -0003b430: 3133 3436 293b 0a0a 3c64 6976 2073 7479  1346);..
    }.
    .T │ │ │ -0003b470: 4f52 5245 4e54 5f54 4553 5428 6e6f 5f6d ORRENT_TEST(no_m │ │ │ -0003b480: 6574 6164 6174 6129 0a7b 0a09 6c74 3a3a etadata).{..lt:: │ │ │ -0003b490: 7365 7373 696f 6e20 7365 7328 7365 7474 session ses(sett │ │ │ -0003b4a0: 696e 6773 2829 293b 0a0a 0961 6464 5f74 ings());...add_t │ │ │ -0003b4b0: 6f72 7265 6e74 5f70 6172 616d 7320 703b orrent_params p; │ │ │ -0003b4c0: 0a09 702e 696e 666f 5f68 6173 6865 732e ..p.info_hashes. │ │ │ -0003b4d0: 7631 203d 2073 6861 315f 6861 7368 2822 v1 = sha1_hash(" │ │ │ -0003b4e0: 6162 6162 6162 6162 6162 6162 6162 6162 abababababababab │ │ │ -0003b4f0: 6162 6162 2229 3b0a 0970 2e73 6176 655f abab");..p.save_ │ │ │ -0003b500: 7061 7468 203d 2022 2e22 3b0a 0970 2e6e path = ".";..p.n │ │ │ -0003b510: 616d 6520 3d20 2266 6f6f 6261 7222 3b0a ame = "foobar";. │ │ │ -0003b520: 0974 6f72 7265 6e74 5f68 616e 646c 6520 .torrent_handle │ │ │ -0003b530: 6820 3d20 7365 732e 6164 645f 746f 7272 h = ses.add_torr │ │ │ -0003b540: 656e 7428 7029 3b0a 0968 2e73 6176 655f ent(p);..h.save_ │ │ │ -0003b550: 7265 7375 6d65 5f64 6174 6128 746f 7272 resume_data(torr │ │ │ -0003b560: 656e 745f 6861 6e64 6c65 3a3a 7361 7665 ent_handle::save │ │ │ -0003b570: 5f69 6e66 6f5f 6469 6374 293b 0a09 616c _info_dict);..al │ │ │ -0003b580: 6572 7420 636f 6e73 742a 2061 203d 2077 ert const* a = w │ │ │ -0003b590: 6169 745f 666f 725f 616c 6572 7428 7365 ait_for_alert(se │ │ │ -0003b5a0: 732c 2073 6176 655f 7265 7375 6d65 5f64 s, save_resume_d │ │ │ -0003b5b0: 6174 615f 616c 6572 743a 3a61 6c65 7274 ata_alert::alert │ │ │ -0003b5c0: 5f74 7970 6529 3b0a 0954 4553 545f 4348 _type);..TEST_CH │ │ │ -0003b5d0: 4543 4b28 6129 3b0a 0973 6176 655f 7265 ECK(a);..save_re │ │ │ -0003b5e0: 7375 6d65 5f64 6174 615f 616c 6572 7420 sume_data_alert │ │ │ -0003b5f0: 636f 6e73 742a 2072 6120 3d20 616c 6572 const* ra = aler │ │ │ -0003b600: 745f 6361 7374 266c 743b 7361 7665 5f72 t_cast<save_r │ │ │ -0003b610: 6573 756d 655f 6461 7461 5f61 6c65 7274 esume_data_alert │ │ │ -0003b620: 2667 743b 2861 293b 0a09 5445 5354 5f43 >(a);..TEST_C │ │ │ -0003b630: 4845 434b 2872 6129 3b0a 0969 6620 2872 HECK(ra);..if (r │ │ │ -0003b640: 6129 0a09 7b0a 0909 6175 746f 2063 6f6e a)..{...auto con │ │ │ -0003b650: 7374 2661 6d70 3b20 6174 7020 3d20 7261 st& atp = ra │ │ │ -0003b660: 2d26 6774 3b70 6172 616d 733b 0a09 0954 ->params;...T │ │ │ -0003b670: 4553 545f 4551 5541 4c28 6174 702e 696e EST_EQUAL(atp.in │ │ │ -0003b680: 666f 5f68 6173 6865 732c 2070 2e69 6e66 fo_hashes, p.inf │ │ │ -0003b690: 6f5f 6861 7368 6573 293b 0a09 0954 4553 o_hashes);...TES │ │ │ -0003b6a0: 545f 4551 5541 4c28 6174 702e 6e61 6d65 T_EQUAL(atp.name │ │ │ -0003b6b0: 2c20 2266 6f6f 6261 7222 293b 0a09 7d0a , "foobar");..}. │ │ │ -0003b6c0: 7d0a 0a74 656d 706c 6174 6520 266c 743b }..template < │ │ │ -0003b6d0: 7479 7065 6e61 6d65 2046 756e 2667 743b typename Fun> │ │ │ -0003b6e0: 0a76 6f69 6420 7465 7374 5f75 6e66 696e .void test_unfin │ │ │ -0003b6f0: 6973 6865 645f 7069 6563 6573 2846 756e ished_pieces(Fun │ │ │ -0003b700: 2066 290a 7b0a 092f 2f20 6372 6561 7465 f).{..// create │ │ │ -0003b710: 2061 2074 6f72 7265 6e74 2061 6e64 2063 a torrent and c │ │ │ -0003b720: 6f6d 706c 6574 6520 6669 6c65 730a 0961 omplete files..a │ │ │ -0003b730: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -0003b740: 7320 7020 3d20 6765 6e65 7261 7465 5f74 s p = generate_t │ │ │ -0003b750: 6f72 7265 6e74 2874 7275 652c 2074 7275 orrent(true, tru │ │ │ -0003b760: 6529 3b0a 0961 7574 6f20 7469 203d 2070 e);..auto ti = p │ │ │ -0003b770: 2e74 693b 0a09 702e 6861 7665 5f70 6965 .ti;..p.have_pie │ │ │ -0003b780: 6365 732e 7265 7369 7a65 2874 692d 2667 ces.resize(ti-&g │ │ │ -0003b790: 743b 6e75 6d5f 7069 6563 6573 2829 2c20 t;num_pieces(), │ │ │ -0003b7a0: 7472 7565 293b 0a3c 2f70 7265 3e3c 2f74 true);.
    < │ │ │ +0002e4c0: 7464 3e74 6573 7420 6669 6c65 2061 7474 td>test file att │ │ │ +0002e4d0: 7269 6275 7465 733c 2f74 643e 3c2f 7472 ributes │ │ │ +0002e510: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0002e520: 3c68 323e 7465 7374 2066 696c 6520 6174

    test file at │ │ │ +0002e530: 7472 6962 7574 6573 3c2f 6832 3e3c 6834 tributes

    ../test/test_fi │ │ │ +0002e550: 6c65 5f73 746f 7261 6765 2e63 7070 3a31 le_storage.cpp:1 │ │ │ +0002e560: 3338 383c 2f68 343e 3c70 7265 2073 7479 388

    <
    │ │ │ +0002e5d0: 7464 3e72 656c 6576 616e 6365 266e 6273  td>relevance&nbs
    │ │ │ +0002e5e0: 703b 303c 2f74 643e 3c74 643e 3c61 2068  p;0../t
    │ │ │ +0002e610: 6573 742f 7465 7374 5f66 696c 655f 7374  est/test_file_st
    │ │ │ +0002e620: 6f72 6167 652e 6370 703a 3133 3839 3c2f  orage.cpp:1389test 
    │ │ │ +0002e640: 7379 6d6c 696e 6b73 3c2f 7464 3e3c 2f74  symlinks

    test symlin │ │ │ +0002e6a0: 6b73 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ks

    ../te │ │ │ +0002e6b0: 7374 2f74 6573 745f 6669 6c65 5f73 746f st/test_file_sto │ │ │ +0002e6c0: 7261 6765 2e63 7070 3a31 3338 393c 2f68 rage.cpp:1389
    rel
    │ │ │ +0002e740: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../test/te
    │ │ │ +0002e780: 7374 5f73 736c 2e63 7070 3a33 3834 3c2f  st_ssl.cpp:384test 
    │ │ │ +0002e7a0: 7573 696e 6720 6120 7369 676e 6564 2063  using a signed c
    │ │ │ +0002e7b0: 6572 7469 6669 6361 7465 2077 6974 6820  ertificate with 
    │ │ │ +0002e7c0: 7468 6520 7772 6f6e 6720 696e 666f 2d68  the wrong info-h
    │ │ │ +0002e7d0: 6173 6820 696e 2044 4e3c 2f74 643e 3c2f  ash in DN

    test using │ │ │ +0002e830: 2061 2073 6967 6e65 6420 6365 7274 6966 a signed certif │ │ │ +0002e840: 6963 6174 6520 7769 7468 2074 6865 2077 icate with the w │ │ │ +0002e850: 726f 6e67 2069 6e66 6f2d 6861 7368 2069 rong info-hash i │ │ │ +0002e860: 6e20 444e 3c2f 6832 3e3c 6834 3e2e 2e2f n DN

    ../ │ │ │ +0002e870: 7465 7374 2f74 6573 745f 7373 6c2e 6370 test/test_ssl.cp │ │ │ +0002e880: 703a 3338 343c 2f68 343e 3c70 7265 2073 p:384

    .// in verif
    │ │ │ +0002e8d0: 7969 6e67 2070 6565 7273 0a09 6374 782e  ying peers..ctx.
    │ │ │ +0002e8e0: 7365 745f 7665 7269 6679 5f6d 6f64 6528  set_verify_mode(
    │ │ │ +0002e8f0: 636f 6e74 6578 743a 3a76 6572 6966 795f  context::verify_
    │ │ │ +0002e900: 6e6f 6e65 2c20 6563 293b 0a09 6966 2028  none, ec);..if (
    │ │ │ +0002e910: 6563 290a 097b 0a09 0973 7464 3a3a 7072  ec)..{...std::pr
    │ │ │ +0002e920: 696e 7466 2822 4661 696c 6564 2074 6f20  intf("Failed to 
    │ │ │ +0002e930: 7365 7420 5353 4c20 7665 7269 6679 206d  set SSL verify m
    │ │ │ +0002e940: 6f64 653a 2025 735c 6e22 0a09 0909 2c20  ode: %s\n"...., 
    │ │ │ +0002e950: 6563 2e6d 6573 7361 6765 2829 2e63 5f73  ec.message().c_s
    │ │ │ +0002e960: 7472 2829 293b 0a09 0954 4553 545f 4348  tr());...TEST_CH
    │ │ │ +0002e970: 4543 4b28 2165 6329 3b0a 0909 7265 7475  ECK(!ec);...retu
    │ │ │ +0002e980: 726e 2066 616c 7365 3b0a 097d 0a0a 0973  rn false;..}...s
    │ │ │ +0002e990: 7464 3a3a 7374 7269 6e67 2063 6572 7469  td::string certi
    │ │ │ +0002e9a0: 6669 6361 7465 203d 2063 6f6d 6269 6e65  ficate = combine
    │ │ │ +0002e9b0: 5f70 6174 6828 222e 2e22 2c20 636f 6d62  _path("..", comb
    │ │ │ +0002e9c0: 696e 655f 7061 7468 2822 7373 6c22 2c20  ine_path("ssl", 
    │ │ │ +0002e9d0: 2270 6565 725f 6365 7274 6966 6963 6174  "peer_certificat
    │ │ │ +0002e9e0: 652e 7065 6d22 2929 3b0a 0973 7464 3a3a  e.pem"));..std::
    │ │ │ +0002e9f0: 7374 7269 6e67 2070 7269 7661 7465 5f6b  string private_k
    │ │ │ +0002ea00: 6579 203d 2063 6f6d 6269 6e65 5f70 6174  ey = combine_pat
    │ │ │ +0002ea10: 6828 222e 2e22 2c20 636f 6d62 696e 655f  h("..", combine_
    │ │ │ +0002ea20: 7061 7468 2822 7373 6c22 2c20 2270 6565  path("ssl", "pee
    │ │ │ +0002ea30: 725f 7072 6976 6174 655f 6b65 792e 7065  r_private_key.pe
    │ │ │ +0002ea40: 6d22 2929 3b0a 0973 7464 3a3a 7374 7269  m"));..std::stri
    │ │ │ +0002ea50: 6e67 2064 685f 7061 7261 6d73 203d 2063  ng dh_params = c
    │ │ │ +0002ea60: 6f6d 6269 6e65 5f70 6174 6828 222e 2e22  ombine_path(".."
    │ │ │ +0002ea70: 2c20 636f 6d62 696e 655f 7061 7468 2822  , combine_path("
    │ │ │ +0002ea80: 7373 6c22 2c20 2264 6870 6172 616d 732e  ssl", "dhparams.
    │ │ │ +0002ea90: 7065 6d22 2929 3b0a 0a09 6966 2028 666c  pem"));...if (fl
    │ │ │ +0002eaa0: 6167 7320 2661 6d70 3b20 696e 7661 6c69  ags & invali
    │ │ │ +0002eab0: 645f 6365 7274 6966 6963 6174 6529 0a09  d_certificate)..
    │ │ │ +0002eac0: 7b0a 0909 6365 7274 6966 6963 6174 6520  {...certificate 
    │ │ │ +0002ead0: 3d20 636f 6d62 696e 655f 7061 7468 2822  = combine_path("
    │ │ │ +0002eae0: 2e2e 222c 2063 6f6d 6269 6e65 5f70 6174  ..", combine_pat
    │ │ │ +0002eaf0: 6828 2273 736c 222c 2022 696e 7661 6c69  h("ssl", "invali
    │ │ │ +0002eb00: 645f 7065 6572 5f63 6572 7469 6669 6361  d_peer_certifica
    │ │ │ +0002eb10: 7465 2e70 656d 2229 293b 0a09 0970 7269  te.pem"));...pri
    │ │ │ +0002eb20: 7661 7465 5f6b 6579 203d 2063 6f6d 6269  vate_key = combi
    │ │ │ +0002eb30: 6e65 5f70 6174 6828 222e 2e22 2c20 636f  ne_path("..", co
    │ │ │ +0002eb40: 6d62 696e 655f 7061 7468 2822 7373 6c22  mbine_path("ssl"
    │ │ │ +0002eb50: 2c20 2269 6e76 616c 6964 5f70 6565 725f  , "invalid_peer_
    │ │ │ +0002eb60: 7072 6976 6174 655f 6b65 792e 7065 6d22  private_key.pem"
    │ │ │ +0002eb70: 2929 3b0a 097d 0a0a 3c64 6976 2073 7479  ));..}..
    .
    .if │ │ │ +0002ebb0: 2028 666c 6167 7320 2661 6d70 3b20 2876 (flags & (v │ │ │ +0002ebc0: 616c 6964 5f63 6572 7469 6669 6361 7465 alid_certificate │ │ │ +0002ebd0: 207c 2069 6e76 616c 6964 5f63 6572 7469 | invalid_certi │ │ │ +0002ebe0: 6669 6361 7465 2929 0a09 7b0a 0909 7374 ficate))..{...st │ │ │ +0002ebf0: 643a 3a70 7269 6e74 6628 2273 6574 5f70 d::printf("set_p │ │ │ +0002ec00: 6173 7377 6f72 645f 6361 6c6c 6261 636b assword_callback │ │ │ +0002ec10: 5c6e 2229 3b0a 0909 6374 782e 7365 745f \n");...ctx.set_ │ │ │ +0002ec20: 7061 7373 776f 7264 5f63 616c 6c62 6163 password_callbac │ │ │ +0002ec30: 6b28 0a09 0909 5b5d 2873 7464 3a3a 7369 k(....[](std::si │ │ │ +0002ec40: 7a65 5f74 2c20 636f 6e74 6578 743a 3a70 ze_t, context::p │ │ │ +0002ec50: 6173 7377 6f72 645f 7075 7270 6f73 6529 assword_purpose) │ │ │ +0002ec60: 207b 2072 6574 7572 6e20 2274 6573 7422 { return "test" │ │ │ +0002ec70: 3b20 7d0a 0909 092c 2065 6329 3b0a 0909 ; }...., ec);... │ │ │ +0002ec80: 6966 2028 6563 290a 0909 7b0a 0909 0973 if (ec)...{....s │ │ │ +0002ec90: 7464 3a3a 7072 696e 7466 2822 4661 696c td::printf("Fail │ │ │ +0002eca0: 6564 2074 6f20 7365 7420 6365 7274 6966 ed to set certif │ │ │ +0002ecb0: 6963 6174 6520 7061 7373 7068 7261 7365 icate passphrase │ │ │ +0002ecc0: 3a20 2573 5c6e 220a 0909 0909 2c20 6563 : %s\n"....., ec │ │ │ +0002ecd0: 2e6d 6573 7361 6765 2829 2e63 5f73 7472 .message().c_str │ │ │ +0002ece0: 2829 293b 0a09 0909 5445 5354 5f43 4845 ());....TEST_CHE │ │ │ +0002ecf0: 434b 2821 6563 293b 0a09 0909 7265 7475 CK(!ec);....retu │ │ │ +0002ed00: 726e 2066 616c 7365 3b0a 0909 7d0a 0909 rn false;...}... │ │ │ +0002ed10: 7374 643a 3a70 7269 6e74 6628 2275 7365 std::printf("use │ │ │ +0002ed20: 5f63 6572 7469 6669 6361 7465 5f66 696c _certificate_fil │ │ │ +0002ed30: 6520 5c22 2573 5c22 5c6e 222c 2063 6572 e \"%s\"\n", cer │ │ │ +0002ed40: 7469 6669 6361 7465 2e63 5f73 7472 2829 tificate.c_str() │ │ │ +0002ed50: 293b 0a09 0963 7478 2e75 7365 5f63 6572 );...ctx.use_cer │ │ │ +0002ed60: 7469 6669 6361 7465 5f66 696c 6528 6365 tificate_file(ce │ │ │ +0002ed70: 7274 6966 6963 6174 652c 2063 6f6e 7465 rtificate, conte │ │ │ +0002ed80: 7874 3a3a 7065 6d2c 2065 6329 3b0a 0909 xt::pem, ec);... │ │ │ +0002ed90: 6966 2028 6563 290a 0909 7b0a 0909 0973 if (ec)...{....s │ │ │ +0002eda0: 7464 3a3a 7072 696e 7466 2822 4661 696c td::printf("Fail │ │ │ +0002edb0: 6564 2074 6f20 7365 7420 6365 7274 6966 ed to set certif │ │ │ +0002edc0: 6963 6174 6520 6669 6c65 3a20 2573 5c6e icate file: %s\n │ │ │ +0002edd0: 220a 0909 0909 2c20 6563 2e6d 6573 7361 "....., ec.messa │ │ │ +0002ede0: 6765 2829 2e63 5f73 7472 2829 293b 0a09 ge().c_str());.. │ │ │ +0002edf0: 0909 5445 5354 5f43 4845 434b 2821 6563 ..TEST_CHECK(!ec │ │ │ +0002ee00: 293b 0a09 0909 7265 7475 726e 2066 616c );....return fal │ │ │ +0002ee10: 7365 3b0a 0909 7d0a 0909 7374 643a 3a70 se;...}...std::p │ │ │ +0002ee20: 7269 6e74 6628 2275 7365 5f70 7269 7661 rintf("use_priva │ │ │ +0002ee30: 7465 5f6b 6579 5f66 696c 6520 5c22 2573 te_key_file \"%s │ │ │ +0002ee40: 5c22 5c6e 222c 2070 7269 7661 7465 5f6b \"\n", private_k │ │ │ +0002ee50: 6579 2e63 5f73 7472 2829 293b 0a09 0963 ey.c_str());...c │ │ │ +0002ee60: 7478 2e75 7365 5f70 7269 7661 7465 5f6b tx.use_private_k │ │ │ +0002ee70: 6579 5f66 696c 6528 7072 6976 6174 655f ey_file(private_ │ │ │ +0002ee80: 6b65 792c 2063 6f6e 7465 7874 3a3a 7065 key, context::pe │ │ │ +0002ee90: 6d2c 2065 6329 3b0a 0909 6966 2028 6563 m, ec);...if (ec │ │ │ +0002eea0: 290a 0909 7b0a 0909 0973 7464 3a3a 7072 )...{....std::pr │ │ │ +0002eeb0: 696e 7466 2822 4661 696c 6564 2074 6f20 intf("Failed to │ │ │ +0002eec0: 7365 7420 7072 6976 6174 6520 6b65 793a set private key: │ │ │ +0002eed0: 2025 735c 6e22 0a09 0909 092c 2065 632e %s\n"....., ec. │ │ │ +0002eee0: 6d65 7373 6167 6528 292e 635f 7374 7228 message().c_str( │ │ │ +0002eef0: 2929 3b0a 0909 0954 4553 545f 4348 4543 ));....TEST_CHEC │ │ │ +0002ef00: 4b28 2165 6329 3b0a 0909 0972 6574 7572 K(!ec);....retur │ │ │ +0002ef10: 6e20 6661 6c73 653b 0a3c 2f70 7265 3e3c n false;.
    < │ │ │ +0002ef20: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0002ef50: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0002ef60: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../test/test_ │ │ │ +0002ef90: 7373 6c2e 6370 703a 3438 363c 2f61 3e3c ssl.cpp:486< │ │ │ +0002efa0: 2f74 643e 3c74 643e 616c 736f 2074 6573 /td>also tes │ │ │ +0002efb0: 7420 7573 696e 6720 6120 6861 7368 2074 t using a hash t │ │ │ +0002efc0: 6861 7420 7265 6665 7273 2074 6f20 6120 hat refers to a │ │ │ +0002efd0: 7661 6c69 6420 746f 7272 656e 7420 6275 valid torrent bu │ │ │ +0002efe0: 7420 7468 6174 2064 6966 6665 7273 2066 t that differs f │ │ │ +0002eff0: 726f 6d20 7468 6520 534e 4920 6861 7368 rom the SNI hash │ │ │ +0002f000: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    als │ │ │ +0002f050: 6f20 7465 7374 2075 7369 6e67 2061 2068 o test using a h │ │ │ +0002f060: 6173 6820 7468 6174 2072 6566 6572 7320 ash that refers │ │ │ +0002f070: 746f 2061 2076 616c 6964 2074 6f72 7265 to a valid torre │ │ │ +0002f080: 6e74 0a62 7574 2074 6861 7420 6469 6666 nt.but that diff │ │ │ +0002f090: 6572 7320 6672 6f6d 2074 6865 2053 4e49 ers from the SNI │ │ │ +0002f0a0: 2068 6173 683c 2f68 323e 3c68 343e 2e2e hash

    .. │ │ │ +0002f0b0: 2f74 6573 742f 7465 7374 5f73 736c 2e63 /test/test_ssl.c │ │ │ +0002f0c0: 7070 3a34 3836 3c2f 6834 3e3c 7072 6520 pp:486

    .print_aler
    │ │ │ +0002f110: 7473 2873 6573 312c 2022 7365 7331 222c  ts(ses1, "ses1",
    │ │ │ +0002f120: 2074 7275 652c 2074 7275 652c 2026 616d   true, true, &am
    │ │ │ +0002f130: 703b 6f6e 5f61 6c65 7274 293b 0a09 6966  p;on_alert);..if
    │ │ │ +0002f140: 2028 6563 290a 097b 0a09 0973 7464 3a3a   (ec)..{...std::
    │ │ │ +0002f150: 7072 696e 7466 2822 4661 696c 6564 2053  printf("Failed S
    │ │ │ +0002f160: 534c 2068 616e 6473 6861 6b65 3a20 2573  SL handshake: %s
    │ │ │ +0002f170: 5c6e 220a 0909 092c 2065 632e 6d65 7373  \n"...., ec.mess
    │ │ │ +0002f180: 6167 6528 292e 635f 7374 7228 2929 3b0a  age().c_str());.
    │ │ │ +0002f190: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ +0002f1a0: 097d 0a0a 0963 6861 7220 6861 6e64 7368  .}...char handsh
    │ │ │ +0002f1b0: 616b 655b 5d20 3d20 225c 7831 3322 2022  ake[] = "\x13" "
    │ │ │ +0002f1c0: 4269 7454 6f72 7265 6e74 2070 726f 746f  BitTorrent proto
    │ │ │ +0002f1d0: 636f 6c5c 305c 305c 305c 305c 305c 305c  col\0\0\0\0\0\0\
    │ │ │ +0002f1e0: 305c 7830 3422 0a09 0922 2020 2020 2020  0\x04"..."      
    │ │ │ +0002f1f0: 2020 2020 2020 2020 2020 2020 2020 2220                " 
    │ │ │ +0002f200: 2f2f 2073 7061 6365 2066 6f72 2069 6e66  // space for inf
    │ │ │ +0002f210: 6f2d 6861 7368 0a09 0922 6161 6161 6161  o-hash..."aaaaaa
    │ │ │ +0002f220: 6161 6161 6161 6161 6161 6161 6161 2220  aaaaaaaaaaaaaa" 
    │ │ │ +0002f230: 2f2f 2070 6565 722d 6964 0a09 0922 5c30  // peer-id..."\0
    │ │ │ +0002f240: 5c30 5c30 5c78 3031 5c78 3032 223b 202f  \0\0\x01\x02"; /
    │ │ │ +0002f250: 2f20 696e 7465 7265 7374 6564 0a0a 092f  / interested.../
    │ │ │ +0002f260: 2f20 6669 6c6c 2069 6e20 7468 6520 696e  / fill in the in
    │ │ │ +0002f270: 666f 2d68 6173 680a 0969 6620 2866 6c61  fo-hash..if (fla
    │ │ │ +0002f280: 6773 2026 616d 703b 2076 616c 6964 5f62  gs & valid_b
    │ │ │ +0002f290: 6974 746f 7272 656e 745f 6861 7368 290a  ittorrent_hash).
    │ │ │ +0002f2a0: 097b 0a09 0973 7464 3a3a 6d65 6d63 7079  .{...std::memcpy
    │ │ │ +0002f2b0: 2868 616e 6473 6861 6b65 202b 2032 382c  (handshake + 28,
    │ │ │ +0002f2c0: 2026 616d 703b 742d 2667 743b 696e 666f   &t->info
    │ │ │ +0002f2d0: 5f68 6173 6865 7328 292e 7631 5b30 5d2c  _hashes().v1[0],
    │ │ │ +0002f2e0: 2032 3029 3b0a 097d 0a09 656c 7365 0a09   20);..}..else..
    │ │ │ +0002f2f0: 7b0a 3c64 6976 2073 7479 6c65 3d22 6261  {.
    │ │ │ +0002f320: 0909 7374 643a 3a67 656e 6572 6174 6528 ..std::generate( │ │ │ +0002f330: 6861 6e64 7368 616b 6520 2b20 3238 2c20 handshake + 28, │ │ │ +0002f340: 6861 6e64 7368 616b 6520 2b20 3438 2c20 handshake + 48, │ │ │ +0002f350: 5b5d 2829 7b20 7265 7475 726e 2063 6861 [](){ return cha │ │ │ +0002f360: 7228 7374 643a 3a72 616e 6428 2929 3b20 r(std::rand()); │ │ │ +0002f370: 7d20 293b 0a3c 2f64 6976 3e09 7d0a 0a09 } );.
    .}... │ │ │ +0002f380: 2f2f 2066 696c 6c20 696e 2074 6865 2070 // fill in the p │ │ │ +0002f390: 6565 722d 6964 0a09 7374 643a 3a67 656e eer-id..std::gen │ │ │ +0002f3a0: 6572 6174 6528 6861 6e64 7368 616b 6520 erate(handshake │ │ │ +0002f3b0: 2b20 3438 2c20 6861 6e64 7368 616b 6520 + 48, handshake │ │ │ +0002f3c0: 2b20 3638 2c20 5b5d 2829 7b20 7265 7475 + 68, [](){ retu │ │ │ +0002f3d0: 726e 2063 6861 7228 7374 643a 3a72 616e rn char(std::ran │ │ │ +0002f3e0: 6428 2929 3b20 7d20 293b 0a0a 0973 7464 d()); } );...std │ │ │ +0002f3f0: 3a3a 7072 696e 7466 2822 6269 7474 6f72 ::printf("bittor │ │ │ +0002f400: 7265 6e74 2068 616e 6473 6861 6b65 5c6e rent handshake\n │ │ │ +0002f410: 2229 3b0a 0962 6f6f 7374 3a3a 6173 696f ");..boost::asio │ │ │ +0002f420: 3a3a 7772 6974 6528 7373 6c5f 736f 636b ::write(ssl_sock │ │ │ +0002f430: 2c20 626f 6f73 743a 3a61 7369 6f3a 3a62 , boost::asio::b │ │ │ +0002f440: 7566 6665 7228 6861 6e64 7368 616b 652c uffer(handshake, │ │ │ +0002f450: 2028 7369 7a65 6f66 2868 616e 6473 6861 (sizeof(handsha │ │ │ +0002f460: 6b65 2920 2d20 3129 292c 2065 6329 3b0a ke) - 1)), ec);. │ │ │ +0002f470: 0970 7269 6e74 5f61 6c65 7274 7328 7365 .print_alerts(se │ │ │ +0002f480: 7331 2c20 2273 6573 3122 2c20 7472 7565 s1, "ses1", true │ │ │ +0002f490: 2c20 7472 7565 2c20 2661 6d70 3b6f 6e5f , true, &on_ │ │ │ +0002f4a0: 616c 6572 7429 3b0a 0969 6620 2865 6329 alert);..if (ec) │ │ │ +0002f4b0: 0a09 7b0a 0909 7374 643a 3a70 7269 6e74 ..{...std::print │ │ │ +0002f4c0: 6628 2266 6169 6c65 6420 746f 2077 7269 f("failed to wri │ │ │ +0002f4d0: 7465 2062 6974 746f 7272 656e 7420 6861 te bittorrent ha │ │ │ +0002f4e0: 6e64 7368 616b 653a 2025 735c 6e22 0a09 ndshake: %s\n".. │ │ │ +0002f4f0: 0909 2c20 6563 2e6d 6573 7361 6765 2829 .., ec.message() │ │ │ +0002f500: 2e63 5f73 7472 2829 293b 0a09 0972 6574 .c_str());...ret │ │ │ +0002f510: 7572 6e20 6661 6c73 653b 0a09 7d0a 0a09 urn false;..}... │ │ │ +0002f520: 6368 6172 2062 7566 5b36 385d 3b0a 0973 char buf[68];..s │ │ │ +0002f530: 7464 3a3a 7072 696e 7466 2822 7265 6164 td::printf("read │ │ │ +0002f540: 2062 6974 746f 7272 656e 7420 6861 6e64 bittorrent hand │ │ │ +0002f550: 7368 616b 655c 6e22 293b 0a09 626f 6f73 shake\n");..boos │ │ │ +0002f560: 743a 3a61 7369 6f3a 3a72 6561 6428 7373 t::asio::read(ss │ │ │ +0002f570: 6c5f 736f 636b 2c20 626f 6f73 743a 3a61 l_sock, boost::a │ │ │ +0002f580: 7369 6f3a 3a62 7566 6665 7228 6275 662c sio::buffer(buf, │ │ │ +0002f590: 2073 697a 656f 6628 6275 6629 292c 2065 sizeof(buf)), e │ │ │ +0002f5a0: 6329 3b0a 0970 7269 6e74 5f61 6c65 7274 c);..print_alert │ │ │ +0002f5b0: 7328 7365 7331 2c20 2273 6573 3122 2c20 s(ses1, "ses1", │ │ │ +0002f5c0: 7472 7565 2c20 7472 7565 2c20 2661 6d70 true, true, & │ │ │ +0002f5d0: 3b6f 6e5f 616c 6572 7429 3b0a 0969 6620 ;on_alert);..if │ │ │ +0002f5e0: 2865 6329 0a09 7b0a 0909 7374 643a 3a70 (ec)..{...std::p │ │ │ +0002f5f0: 7269 6e74 6628 2266 6169 6c65 6420 746f rintf("failed to │ │ │ +0002f600: 2072 6561 6420 6269 7474 6f72 7265 6e74 read bittorrent │ │ │ +0002f610: 2068 616e 6473 6861 6b65 3a20 2573 5c6e handshake: %s\n │ │ │ +0002f620: 220a 0909 092c 2065 632e 6d65 7373 6167 "...., ec.messag │ │ │ +0002f630: 6528 292e 635f 7374 7228 2929 3b0a 0909 e().c_str());... │ │ │ +0002f640: 7265 7475 726e 2066 616c 7365 3b0a 097d return false;..} │ │ │ +0002f650: 0a0a 0969 6620 286d 656d 636d 7028 6275 ...if (memcmp(bu │ │ │ +0002f660: 662c 2022 5c78 3133 2220 2242 6974 546f f, "\x13" "BitTo │ │ │ +0002f670: 7272 656e 7420 7072 6f74 6f63 6f6c 222c rrent protocol", │ │ │ +0002f680: 2032 3029 2021 3d20 3029 0a09 7b0a 0909 20) != 0)..{... │ │ │ +0002f690: 7374 643a 3a70 7269 6e74 6628 2269 6e76 std::printf("inv │ │ │ +0002f6a0: 616c 6964 2062 6974 746f 7272 656e 7420 alid bittorrent │ │ │ +0002f6b0: 6861 6e64 7368 616b 655c 6e22 293b 0a09 handshake\n");.. │ │ │ +0002f6c0: 0972 6574 7572 6e20 6661 6c73 653b 0a3c .return false;.< │ │ │ +0002f6d0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0002f6e0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0002f6f0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +0002f700: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +0002f710: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../test │ │ │ +0002f740: 2f74 6573 745f 6661 7374 5f65 7874 656e /test_fast_exten │ │ │ +0002f750: 7369 6f6e 2e63 7070 3a31 3139 383c 2f61 sion.cpp:1198test s │ │ │ +0002f770: 656e 6469 6e67 2069 6e76 616c 6964 2072 ending invalid r │ │ │ +0002f780: 6571 7565 7374 7320 286f 7574 206f 6620 equests (out of │ │ │ +0002f790: 626f 756e 6420 7069 6563 6520 696e 6465 bound piece inde │ │ │ +0002f7a0: 782c 206f 6666 7365 7473 2061 6e64 2073 x, offsets and s │ │ │ +0002f7b0: 697a 6573 293c 2f74 643e 3c2f 7472 3e3c izes)< │ │ │ +0002f7c0: 7472 2069 643d 2239 3622 2073 7479 6c65 tr id="96" style │ │ │ +0002f7d0: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ +0002f7e0: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">test sending i │ │ │ +0002f810: 6e76 616c 6964 2072 6571 7565 7374 7320 nvalid requests │ │ │ +0002f820: 286f 7574 206f 6620 626f 756e 6420 7069 (out of bound pi │ │ │ +0002f830: 6563 6520 696e 6465 782c 206f 6666 7365 ece index, offse │ │ │ +0002f840: 7473 2061 6e64 0a73 697a 6573 293c 2f68 ts and.sizes)

    ../test/te │ │ │ +0002f860: 7374 5f66 6173 745f 6578 7465 6e73 696f st_fast_extensio │ │ │ +0002f870: 6e2e 6370 703a 3131 3938 3c2f 6834 3e3c n.cpp:1198

    < │ │ │ +0002f880: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0002f890: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0002f8a0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0002f8b0: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ +0002f8c0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0002f8f0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0002f900: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test_ │ │ │ +0002f930: 7374 6f72 6167 652e 6370 703a 3133 3639 storage.cpp:1369 │ │ │ +0002f940: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6869 thi │ │ │ +0002f950: 7320 7368 6f75 6c64 2074 616b 6520 6120 s should take a │ │ │ +0002f960: 7370 616e 3c2f 7464 3e3c 2f74 723e 3c74 span

    this should tak │ │ │ +0002f9c0: 6520 6120 7370 616e 3c2f 6832 3e3c 6834 e a span

    ../test/test_st │ │ │ +0002f9e0: 6f72 6167 652e 6370 703a 3133 3639 3c2f orage.cpp:1369
    {..
    │ │ │ +0002fa30: 756e 7369 676e 6564 2063 6861 7220 636f  unsigned char co
    │ │ │ +0002fa40: 6e73 742a 2070 203d 2072 6569 6e74 6572  nst* p = reinter
    │ │ │ +0002fa50: 7072 6574 5f63 6173 7426 6c74 3b75 6e73  pret_cast<uns
    │ │ │ +0002fa60: 6967 6e65 6420 6368 6172 2063 6f6e 7374  igned char const
    │ │ │ +0002fa70: 2a26 6774 3b28 6275 662e 6461 7461 2829  *>(buf.data()
    │ │ │ +0002fa80: 293b 0a09 666f 7220 2869 6e74 206b 203d  );..for (int k =
    │ │ │ +0002fa90: 2030 3b20 6b20 266c 743b 2069 6e74 2862   0; k < int(b
    │ │ │ +0002faa0: 7566 2e73 697a 6528 2929 3b20 2b2b 6b29  uf.size()); ++k)
    │ │ │ +0002fab0: 0a09 7b0a 0909 6966 2028 705b 6b5d 2021  ..{...if (p[k] !
    │ │ │ +0002fac0: 3d20 2863 6f75 6e74 6572 2026 616d 703b  = (counter &
    │ │ │ +0002fad0: 2030 7866 6629 2920 7265 7475 726e 2066   0xff)) return f
    │ │ │ +0002fae0: 616c 7365 3b0a 0909 2b2b 636f 756e 7465  alse;...++counte
    │ │ │ +0002faf0: 723b 0a09 7d0a 0972 6574 7572 6e20 7472  r;..}..return tr
    │ │ │ +0002fb00: 7565 3b0a 7d0a 0a74 656d 706c 6174 6520  ue;.}..template 
    │ │ │ +0002fb10: 266c 743b 7479 7065 6e61 6d65 2043 6861  <typename Cha
    │ │ │ +0002fb20: 7226 6774 3b0a 766f 6964 2061 6c6c 6f63  r>.void alloc
    │ │ │ +0002fb30: 5f69 6f76 2873 7061 6e26 6c74 3b43 6861  _iov(span<Cha
    │ │ │ +0002fb40: 7226 6774 3b2a 2069 6f76 2c20 696e 7420  r>* iov, int 
    │ │ │ +0002fb50: 6e75 6d5f 6275 6673 290a 7b0a 0966 6f72  num_bufs).{..for
    │ │ │ +0002fb60: 2028 7374 643a 3a73 697a 655f 7420 6920   (std::size_t i 
    │ │ │ +0002fb70: 3d20 303b 2069 2026 6c74 3b20 7374 6174  = 0; i < stat
    │ │ │ +0002fb80: 6963 5f63 6173 7426 6c74 3b73 697a 655f  ic_cast<size_
    │ │ │ +0002fb90: 7426 6774 3b28 6e75 6d5f 6275 6673 293b  t>(num_bufs);
    │ │ │ +0002fba0: 202b 2b69 290a 097b 0a09 0973 7464 3a3a   ++i)..{...std::
    │ │ │ +0002fbb0: 7369 7a65 5f74 2063 6f6e 7374 206c 656e  size_t const len
    │ │ │ +0002fbc0: 203d 2073 7461 7469 635f 6361 7374 266c   = static_cast&l
    │ │ │ +0002fbd0: 743b 7374 643a 3a73 697a 655f 7426 6774  t;std::size_t>
    │ │ │ +0002fbe0: 3b28 6e75 6d5f 6275 6673 2920 2a20 2869  ;(num_bufs) * (i
    │ │ │ +0002fbf0: 202b 2031 293b 0a09 0969 6f76 5b69 5d20   + 1);...iov[i] 
    │ │ │ +0002fc00: 3d20 7b20 6e65 7720 6368 6172 5b6c 656e  = { new char[len
    │ │ │ +0002fc10: 5d2c 2073 7461 7469 635f 6361 7374 266c  ], static_cast&l
    │ │ │ +0002fc20: 743b 7374 643a 3a70 7472 6469 6666 5f74  t;std::ptrdiff_t
    │ │ │ +0002fc30: 2667 743b 286c 656e 2920 7d3b 0a09 7d0a  >(len) };..}.
    │ │ │ +0002fc40: 7d0a 0a3c 6469 7620 7374 796c 653d 2262  }..
    template <ty │ │ │ +0002fc80: 7065 6e61 6d65 2043 6861 7226 6774 3b0a pename Char>. │ │ │ +0002fc90: 3c2f 6469 763e 766f 6964 2066 7265 655f
    void free_ │ │ │ +0002fca0: 696f 7628 7370 616e 266c 743b 4368 6172 iov(span<Char │ │ │ +0002fcb0: 2667 743b 2a20 696f 762c 2069 6e74 206e >* iov, int n │ │ │ +0002fcc0: 756d 5f62 7566 7329 0a7b 0a09 666f 7220 um_bufs).{..for │ │ │ +0002fcd0: 2869 6e74 2069 203d 2030 3b20 6920 266c (int i = 0; i &l │ │ │ +0002fce0: 743b 206e 756d 5f62 7566 733b 202b 2b69 t; num_bufs; ++i │ │ │ +0002fcf0: 290a 097b 0a09 0964 656c 6574 655b 5d20 )..{...delete[] │ │ │ +0002fd00: 696f 765b 695d 2e64 6174 6128 293b 0a09 iov[i].data();.. │ │ │ +0002fd10: 0969 6f76 5b69 5d20 3d20 7b20 6e75 6c6c .iov[i] = { null │ │ │ +0002fd20: 7074 722c 2030 207d 3b0a 097d 0a7d 0a0a ptr, 0 };..}.}.. │ │ │ +0002fd30: 7d20 2f2f 2061 6e6f 6e79 6d6f 7573 206e } // anonymous n │ │ │ +0002fd40: 616d 6573 7061 6365 0a0a 544f 5252 454e amespace..TORREN │ │ │ +0002fd50: 545f 5445 5354 2869 6f76 6563 5f61 6476 T_TEST(iovec_adv │ │ │ +0002fd60: 616e 6365 5f62 7566 7329 0a7b 0a09 7370 ance_bufs).{..sp │ │ │ +0002fd70: 616e 266c 743b 6368 6172 2667 743b 2069 an<char> i │ │ │ +0002fd80: 6f76 315b 3130 5d3b 0a09 7370 616e 266c ov1[10];..span&l │ │ │ +0002fd90: 743b 6368 6172 2063 6f6e 7374 2667 743b t;char const> │ │ │ +0002fda0: 2069 6f76 325b 3130 5d3b 0a09 616c 6c6f iov2[10];..allo │ │ │ +0002fdb0: 635f 696f 7628 696f 7631 2c20 3130 293b c_iov(iov1, 10); │ │ │ +0002fdc0: 0a09 6669 6c6c 5f70 6174 7465 726e 287b ..fill_pattern({ │ │ │ +0002fdd0: 696f 7631 2c20 3130 7d29 3b0a 0a09 6d65 iov1, 10});...me │ │ │ +0002fde0: 6d63 7079 2869 6f76 322c 2069 6f76 312c mcpy(iov2, iov1, │ │ │ +0002fdf0: 2073 697a 656f 6628 696f 7631 2929 3b0a sizeof(iov1));. │ │ │ +0002fe00: 0a09 7370 616e 266c 743b 7370 616e 266c ..span<span&l │ │ │ +0002fe10: 743b 6368 6172 2063 6f6e 7374 2667 743b t;char const> │ │ │ +0002fe20: 2667 743b 2069 6f76 203d 2069 6f76 323b > iov = iov2; │ │ │ +0002fe30: 0a0a 092f 2f20 6164 7661 6e63 6520 696f ...// advance io │ │ │ +0002fe40: 7620 3133 2062 7974 6573 2e20 4d61 6b65 v 13 bytes. Make │ │ │ +0002fe50: 2073 7572 6520 7768 6174 2773 206c 6566 sure what's lef │ │ │ +0002fe60: 7420 6669 7473 2070 6174 7465 726e 2031 t fits pattern 1 │ │ │ +0002fe70: 2073 6869 6674 6564 0a09 2f2f 2031 3320 shifted..// 13 │ │ │ +0002fe80: 6279 7465 730a 0969 6f76 203d 2061 7578 bytes..iov = aux │ │ │ +0002fe90: 3a3a 6164 7661 6e63 655f 6275 6673 2869 ::advance_bufs(i │ │ │ +0002fea0: 6f76 2c20 3133 293b 0a0a 092f 2f20 6d61 ov, 13);...// ma │ │ │ +0002feb0: 6b65 2073 7572 6520 7768 6174 2773 2069 ke sure what's i │ │ │ +0002fec0: 6e0a 0969 6e74 2063 6f75 6e74 6572 203d n..int counter = │ │ │ +0002fed0: 2031 333b 0a09 666f 7220 2861 7574 6f20 13;..for (auto │ │ │ +0002fee0: 6275 6620 3a20 696f 7629 0a09 7b0a 3c2f buf : iov)..{.r │ │ │ +0002ff20: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0002ff30: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../test/ │ │ │ +0002ff60: 7465 7374 5f72 6573 6f6c 7665 5f6c 696e test_resolve_lin │ │ │ +0002ff70: 6b73 2e63 7070 3a37 333c 2f61 3e3c 2f74 ks.cpp:73test files │ │ │ +0002ff90: 2077 6974 6820 6469 6666 6572 656e 7420 with different │ │ │ +0002ffa0: 7069 6563 6520 7369 7a65 2028 6e65 6761 piece size (nega │ │ │ +0002ffb0: 7469 7665 2074 6573 7429 3c2f 7464 3e3c tive test)< │ │ │ +0002ffc0: 2f74 723e 3c74 7220 6964 3d22 3938 2220 /tr>

    test file │ │ │ +00030010: 7320 7769 7468 2064 6966 6665 7265 6e74 s with different │ │ │ +00030020: 2070 6965 6365 2073 697a 6520 286e 6567 piece size (neg │ │ │ +00030030: 6174 6976 6520 7465 7374 293c 2f68 323e ative test)

    │ │ │ +00030040: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +00030050: 5f72 6573 6f6c 7665 5f6c 696e 6b73 2e63 _resolve_links.c │ │ │ +00030060: 7070 3a37 333c 2f68 343e 3c70 7265 2073 pp:73

    .{ "test2", 
    │ │ │ +000300b0: 2274 6573 7431 5f70 6164 5f66 696c 6573  "test1_pad_files
    │ │ │ +000300c0: 222c 2030 7d2c 0a09 7b20 2274 6573 7433  ", 0},..{ "test3
    │ │ │ +000300d0: 222c 2022 7465 7374 315f 7061 645f 6669  ", "test1_pad_fi
    │ │ │ +000300e0: 6c65 7322 2c20 307d 2c0a 097b 2022 7465  les", 0},..{ "te
    │ │ │ +000300f0: 7374 3222 2c20 2274 6573 7431 5f73 696e  st2", "test1_sin
    │ │ │ +00030100: 676c 6522 2c20 307d 2c0a 0a09 2f2f 2074  gle", 0},...// t
    │ │ │ +00030110: 6865 7365 2061 7265 2061 6c6c 2070 6164  hese are all pad
    │ │ │ +00030120: 6465 642e 2054 6865 2066 6972 7374 2073  ded. The first s
    │ │ │ +00030130: 6d61 6c6c 2066 696c 6520 7769 6c6c 2061  mall file will a
    │ │ │ +00030140: 6363 6964 656e 7461 6c6c 7920 616c 736f  ccidentally also
    │ │ │ +00030150: 0a09 2f2f 206d 6174 6368 2c20 6576 656e  ..// match, even
    │ │ │ +00030160: 2074 686f 7567 6820 6974 2773 206e 6f74   though it's not
    │ │ │ +00030170: 2074 6169 6c20 7061 6464 6564 2c20 7468   tail padded, th
    │ │ │ +00030180: 6520 666f 6c6c 6f77 696e 6720 6669 6c65  e following file
    │ │ │ +00030190: 2069 7320 6964 656e 7469 6361 6c0a 097b   is identical..{
    │ │ │ +000301a0: 2022 7465 7374 325f 7061 645f 6669 6c65   "test2_pad_file
    │ │ │ +000301b0: 7322 2c20 2274 6573 7431 5f70 6164 5f66  s", "test1_pad_f
    │ │ │ +000301c0: 696c 6573 222c 2032 7d2c 0a09 7b20 2274  iles", 2},..{ "t
    │ │ │ +000301d0: 6573 7433 5f70 6164 5f66 696c 6573 222c  est3_pad_files",
    │ │ │ +000301e0: 2022 7465 7374 315f 7061 645f 6669 6c65   "test1_pad_file
    │ │ │ +000301f0: 7322 2c20 327d 2c0a 097b 2022 7465 7374  s", 2},..{ "test
    │ │ │ +00030200: 335f 7061 645f 6669 6c65 7322 2c20 2274  3_pad_files", "t
    │ │ │ +00030210: 6573 7432 5f70 6164 5f66 696c 6573 222c  est2_pad_files",
    │ │ │ +00030220: 2032 7d2c 0a09 7b20 2274 6573 7431 5f70   2},..{ "test1_p
    │ │ │ +00030230: 6164 5f66 696c 6573 222c 2022 7465 7374  ad_files", "test
    │ │ │ +00030240: 325f 7061 645f 6669 6c65 7322 2c20 327d  2_pad_files", 2}
    │ │ │ +00030250: 2c0a 097b 2022 7465 7374 315f 7061 645f  ,..{ "test1_pad_
    │ │ │ +00030260: 6669 6c65 7322 2c20 2274 6573 7433 5f70  files", "test3_p
    │ │ │ +00030270: 6164 5f66 696c 6573 222c 2032 7d2c 0a09  ad_files", 2},..
    │ │ │ +00030280: 7b20 2274 6573 7432 5f70 6164 5f66 696c  { "test2_pad_fil
    │ │ │ +00030290: 6573 222c 2022 7465 7374 335f 7061 645f  es", "test3_pad_
    │ │ │ +000302a0: 6669 6c65 7322 2c20 327d 2c0a 0a09 2f2f  files", 2},...//
    │ │ │ +000302b0: 206f 6e65 206d 6967 6874 2065 7870 6563   one might expec
    │ │ │ +000302c0: 7420 7468 6973 2074 6f20 776f 726b 2c20  t this to work, 
    │ │ │ +000302d0: 6275 7420 7369 6e63 6520 7468 6520 7461  but since the ta
    │ │ │ +000302e0: 696c 206f 6620 7468 6520 7369 6e67 6c65  il of the single
    │ │ │ +000302f0: 2066 696c 650a 092f 2f20 746f 7272 656e   file..// torren
    │ │ │ +00030300: 7420 6973 206e 6f74 2070 6164 6465 642c  t is not padded,
    │ │ │ +00030310: 2074 6865 206c 6173 7420 7069 6563 6520   the last piece 
    │ │ │ +00030320: 6861 7368 2077 6f6e 2774 206d 6174 6368  hash won't match
    │ │ │ +00030330: 0a09 7b20 2274 6573 7431 5f70 6164 5f66  ..{ "test1_pad_f
    │ │ │ +00030340: 696c 6573 222c 2022 7465 7374 315f 7369  iles", "test1_si
    │ │ │ +00030350: 6e67 6c65 222c 2030 7d2c 0a0a 092f 2f20  ngle", 0},...// 
    │ │ │ +00030360: 6966 2069 7427 7320 7061 6464 6564 206f  if it's padded o
    │ │ │ +00030370: 6e20 7468 6520 6f74 6865 7220 6861 6e64  n the other hand
    │ │ │ +00030380: 2c20 6974 2077 696c 6c20 776f 726b 0a09  , it will work..
    │ │ │ +00030390: 7b20 2274 6573 7431 5f70 6164 5f66 696c  { "test1_pad_fil
    │ │ │ +000303a0: 6573 222c 2022 7465 7374 315f 7369 6e67  es", "test1_sing
    │ │ │ +000303b0: 6c65 5f70 6164 6465 6422 2c20 317d 2c0a  le_padded", 1},.
    │ │ │ +000303c0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    } │ │ │ +000303f0: 3b0a 3c2f 6469 763e 0a3c 2f70 7265 3e3c ;.
    .
    < │ │ │ +00030400: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00030430: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00030440: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test_ │ │ │ +00030470: 7265 736f 6c76 655f 6c69 6e6b 732e 6370 resolve_links.cp │ │ │ +00030480: 703a 3736 3c2f 613e 3c2f 7464 3e3c 7464 p:76it would be nic │ │ │ +000304a0: 6520 746f 2074 6573 7420 7265 736f 6c76 e to test resolv │ │ │ +000304b0: 696e 6720 6f66 206d 6f72 6520 7468 616e ing of more than │ │ │ +000304c0: 206a 7573 7420 3220 6669 6c65 7320 6173 just 2 files as │ │ │ +000304d0: 2077 656c 6c2e 206c 696b 6520 3320 7369 well. like 3 si │ │ │ +000304e0: 6e67 6c65 2066 696c 6520 746f 7272 656e ngle file torren │ │ │ +000304f0: 7473 206d 6572 6765 6420 696e 746f 206f ts merged into o │ │ │ +00030500: 6e65 2c20 7265 736f 6c76 696e 6720 616c ne, resolving al │ │ │ +00030510: 6c20 3320 6669 6c65 732e 3c2f 7464 3e3c l 3 files.< │ │ │ +00030520: 2f74 723e 3c74 7220 6964 3d22 3939 2220 /tr>

    it would │ │ │ +00030570: 6265 206e 6963 6520 746f 2074 6573 7420 be nice to test │ │ │ +00030580: 7265 736f 6c76 696e 6720 6f66 206d 6f72 resolving of mor │ │ │ +00030590: 6520 7468 616e 206a 7573 7420 3220 6669 e than just 2 fi │ │ │ +000305a0: 6c65 7320 6173 2077 656c 6c2e 0a6c 696b les as well..lik │ │ │ +000305b0: 6520 3320 7369 6e67 6c65 2066 696c 6520 e 3 single file │ │ │ +000305c0: 746f 7272 656e 7473 206d 6572 6765 6420 torrents merged │ │ │ +000305d0: 696e 746f 206f 6e65 2c20 7265 736f 6c76 into one, resolv │ │ │ +000305e0: 696e 6720 616c 6c20 3320 6669 6c65 732e ing all 3 files. │ │ │ +000305f0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ +00030600: 2f74 6573 745f 7265 736f 6c76 655f 6c69 /test_resolve_li │ │ │ +00030610: 6e6b 732e 6370 703a 3736 3c2f 6834 3e3c nks.cpp:76

    < │ │ │ +00030620: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00030630: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00030640: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00030650: 7820 2364 6464 3b22 3e09 7b20 2274 6573 x #ddd;">.{ "tes │ │ │ +00030660: 7432 222c 2022 7465 7374 315f 7369 6e67 t2", "test1_sing │ │ │ +00030670: 6c65 222c 2030 7d2c 0a0a 092f 2f20 7468 le", 0},...// th │ │ │ +00030680: 6573 6520 6172 6520 616c 6c20 7061 6464 ese are all padd │ │ │ +00030690: 6564 2e20 5468 6520 6669 7273 7420 736d ed. The first sm │ │ │ +000306a0: 616c 6c20 6669 6c65 2077 696c 6c20 6163 all file will ac │ │ │ +000306b0: 6369 6465 6e74 616c 6c79 2061 6c73 6f0a cidentally also. │ │ │ +000306c0: 092f 2f20 6d61 7463 682c 2065 7665 6e20 .// match, even │ │ │ +000306d0: 7468 6f75 6768 2069 7427 7320 6e6f 7420 though it's not │ │ │ +000306e0: 7461 696c 2070 6164 6465 642c 2074 6865 tail padded, the │ │ │ +000306f0: 2066 6f6c 6c6f 7769 6e67 2066 696c 6520 following file │ │ │ +00030700: 6973 2069 6465 6e74 6963 616c 0a09 7b20 is identical..{ │ │ │ +00030710: 2274 6573 7432 5f70 6164 5f66 696c 6573 "test2_pad_files │ │ │ +00030720: 222c 2022 7465 7374 315f 7061 645f 6669 ", "test1_pad_fi │ │ │ +00030730: 6c65 7322 2c20 327d 2c0a 097b 2022 7465 les", 2},..{ "te │ │ │ +00030740: 7374 335f 7061 645f 6669 6c65 7322 2c20 st3_pad_files", │ │ │ +00030750: 2274 6573 7431 5f70 6164 5f66 696c 6573 "test1_pad_files │ │ │ +00030760: 222c 2032 7d2c 0a09 7b20 2274 6573 7433 ", 2},..{ "test3 │ │ │ +00030770: 5f70 6164 5f66 696c 6573 222c 2022 7465 _pad_files", "te │ │ │ +00030780: 7374 325f 7061 645f 6669 6c65 7322 2c20 st2_pad_files", │ │ │ +00030790: 327d 2c0a 097b 2022 7465 7374 315f 7061 2},..{ "test1_pa │ │ │ +000307a0: 645f 6669 6c65 7322 2c20 2274 6573 7432 d_files", "test2 │ │ │ +000307b0: 5f70 6164 5f66 696c 6573 222c 2032 7d2c _pad_files", 2}, │ │ │ +000307c0: 0a09 7b20 2274 6573 7431 5f70 6164 5f66 ..{ "test1_pad_f │ │ │ +000307d0: 696c 6573 222c 2022 7465 7374 335f 7061 iles", "test3_pa │ │ │ +000307e0: 645f 6669 6c65 7322 2c20 327d 2c0a 097b d_files", 2},..{ │ │ │ +000307f0: 2022 7465 7374 325f 7061 645f 6669 6c65 "test2_pad_file │ │ │ +00030800: 7322 2c20 2274 6573 7433 5f70 6164 5f66 s", "test3_pad_f │ │ │ +00030810: 696c 6573 222c 2032 7d2c 0a0a 092f 2f20 iles", 2},...// │ │ │ +00030820: 6f6e 6520 6d69 6768 7420 6578 7065 6374 one might expect │ │ │ +00030830: 2074 6869 7320 746f 2077 6f72 6b2c 2062 this to work, b │ │ │ +00030840: 7574 2073 696e 6365 2074 6865 2074 6169 ut since the tai │ │ │ +00030850: 6c20 6f66 2074 6865 2073 696e 676c 6520 l of the single │ │ │ +00030860: 6669 6c65 0a09 2f2f 2074 6f72 7265 6e74 file..// torrent │ │ │ +00030870: 2069 7320 6e6f 7420 7061 6464 6564 2c20 is not padded, │ │ │ +00030880: 7468 6520 6c61 7374 2070 6965 6365 2068 the last piece h │ │ │ +00030890: 6173 6820 776f 6e27 7420 6d61 7463 680a ash won't match. │ │ │ +000308a0: 097b 2022 7465 7374 315f 7061 645f 6669 .{ "test1_pad_fi │ │ │ +000308b0: 6c65 7322 2c20 2274 6573 7431 5f73 696e les", "test1_sin │ │ │ +000308c0: 676c 6522 2c20 307d 2c0a 0a09 2f2f 2069 gle", 0},...// i │ │ │ +000308d0: 6620 6974 2773 2070 6164 6465 6420 6f6e f it's padded on │ │ │ +000308e0: 2074 6865 206f 7468 6572 2068 616e 642c the other hand, │ │ │ +000308f0: 2069 7420 7769 6c6c 2077 6f72 6b0a 097b it will work..{ │ │ │ +00030900: 2022 7465 7374 315f 7061 645f 6669 6c65 "test1_pad_file │ │ │ +00030910: 7322 2c20 2274 6573 7431 5f73 696e 676c s", "test1_singl │ │ │ +00030920: 655f 7061 6464 6564 222c 2031 7d2c 0a0a e_padded", 1},.. │ │ │ +00030930: 7d3b 0a0a 3c64 6976 2073 7479 6c65 3d22 };..
    .
    TORRENT │ │ │ +00030970: 5f54 4553 5428 7265 736f 6c76 655f 6c69 _TEST(resolve_li │ │ │ +00030980: 6e6b 7329 0a7b 0a09 7374 643a 3a73 7472 nks).{..std::str │ │ │ +00030990: 696e 6720 7061 7468 203d 2063 6f6d 6269 ing path = combi │ │ │ +000309a0: 6e65 5f70 6174 6828 7061 7265 6e74 5f70 ne_path(parent_p │ │ │ +000309b0: 6174 6828 6375 7272 656e 745f 776f 726b ath(current_work │ │ │ +000309c0: 696e 675f 6469 7265 6374 6f72 7928 2929 ing_directory()) │ │ │ +000309d0: 0a09 092c 2022 6d75 7461 626c 655f 7465 ..., "mutable_te │ │ │ +000309e0: 7374 5f74 6f72 7265 6e74 7322 293b 0a0a st_torrents");.. │ │ │ +000309f0: 0966 6f72 2028 696e 7420 6920 3d20 303b .for (int i = 0; │ │ │ +00030a00: 2069 2026 6c74 3b20 696e 7428 7369 7a65 i < int(size │ │ │ +00030a10: 6f66 2874 6573 745f 746f 7272 656e 7473 of(test_torrents │ │ │ +00030a20: 292f 7369 7a65 6f66 2874 6573 745f 746f )/sizeof(test_to │ │ │ +00030a30: 7272 656e 7473 5b30 5d29 293b 202b 2b69 rrents[0])); ++i │ │ │ +00030a40: 290a 097b 0a09 0974 6573 745f 746f 7272 )..{...test_torr │ │ │ +00030a50: 656e 745f 7420 636f 6e73 7426 616d 703b ent_t const& │ │ │ +00030a60: 2065 203d 2074 6573 745f 746f 7272 656e e = test_torren │ │ │ +00030a70: 7473 5b69 5d3b 0a0a 0909 7374 643a 3a73 ts[i];....std::s │ │ │ +00030a80: 7472 696e 6720 7020 3d20 636f 6d62 696e tring p = combin │ │ │ +00030a90: 655f 7061 7468 2870 6174 682c 2065 2e66 e_path(path, e.f │ │ │ +00030aa0: 696c 656e 616d 6531 2920 2b20 222e 746f ilename1) + ".to │ │ │ +00030ab0: 7272 656e 7422 3b0a 0909 7374 643a 3a70 rrent";...std::p │ │ │ +00030ac0: 7269 6e74 6628 226c 6f61 6469 6e67 2025 rintf("loading % │ │ │ +00030ad0: 735c 6e22 2c20 702e 635f 7374 7228 2929 s\n", p.c_str()) │ │ │ +00030ae0: 3b0a 0909 7374 643a 3a73 6861 7265 645f ;...std::shared_ │ │ │ +00030af0: 7074 7226 6c74 3b74 6f72 7265 6e74 5f69 ptr<torrent_i │ │ │ +00030b00: 6e66 6f20 636f 6e73 7426 6774 3b20 7469 nfo const> ti │ │ │ +00030b10: 3120 3d20 6c6f 6164 5f74 6f72 7265 6e74 1 = load_torrent │ │ │ +00030b20: 5f66 696c 6528 7029 2e74 693b 0a0a 0909 _file(p).ti;.... │ │ │ +00030b30: 7020 3d20 636f 6d62 696e 655f 7061 7468 p = combine_path │ │ │ +00030b40: 2870 6174 682c 2065 2e66 696c 656e 616d (path, e.filenam │ │ │ +00030b50: 6532 2920 2b20 222e 746f 7272 656e 7422 e2) + ".torrent" │ │ │ +00030b60: 3b0a 0909 7374 643a 3a70 7269 6e74 6628 ;...std::printf( │ │ │ +00030b70: 226c 6f61 6469 6e67 2025 735c 6e22 2c20 "loading %s\n", │ │ │ +00030b80: 702e 635f 7374 7228 2929 3b0a 0909 6175 p.c_str());...au │ │ │ +00030b90: 746f 2061 7470 3220 3d20 6c6f 6164 5f74 to atp2 = load_t │ │ │ +00030ba0: 6f72 7265 6e74 5f66 696c 6528 7029 3b0a orrent_file(p);. │ │ │ +00030bb0: 0909 7265 6e61 6d65 645f 6669 6c65 7320 ..renamed_files │ │ │ +00030bc0: 7266 3b0a 0909 7266 2e69 6d70 6f72 745f rf;...rf.import_ │ │ │ +00030bd0: 6669 6c65 6e61 6d65 7328 6174 7032 2e74 filenames(atp2.t │ │ │ +00030be0: 692d 2667 743b 6c61 796f 7574 2829 2c20 i->layout(), │ │ │ +00030bf0: 6174 7032 2e72 656e 616d 6564 5f66 696c atp2.renamed_fil │ │ │ +00030c00: 6573 293b 0a0a 0909 7374 643a 3a70 7269 es);....std::pri │ │ │ +00030c10: 6e74 6628 2272 6573 6f6c 7669 6e67 5c6e ntf("resolving\n │ │ │ +00030c20: 2229 3b0a 0909 6175 783a 3a72 6573 6f6c ");...aux::resol │ │ │ +00030c30: 7665 5f6c 696e 6b73 206c 2874 6931 293b ve_links l(ti1); │ │ │ +00030c40: 0a09 096c 2e6d 6174 6368 282a 6174 7032 ...l.match(*atp2 │ │ │ +00030c50: 2e74 692c 2066 696c 656e 616d 6573 2861 .ti, filenames(a │ │ │ +00030c60: 7470 322e 7469 2d26 6774 3b6c 6179 6f75 tp2.ti->layou │ │ │ +00030c70: 7428 292c 2072 6629 2c20 222e 2229 3b0a t(), rf), ".");. │ │ │ +00030c80: 0a09 0961 7578 3a3a 7665 6374 6f72 266c ...aux::vector&l │ │ │ +00030c90: 743b 7374 643a 3a73 7472 696e 672c 2066 t;std::string, f │ │ │ +00030ca0: 696c 655f 696e 6465 785f 7426 6774 3b20 ile_index_t> │ │ │ +00030cb0: 636f 6e73 7426 616d 703b 206c 696e 6b73 const& links │ │ │ +00030cc0: 203d 206c 2e67 6574 5f6c 696e 6b73 2829 = l.get_links() │ │ │ +00030cd0: 3b0a 0a09 0961 7574 6f20 636f 6e73 7420 ;....auto const │ │ │ +00030ce0: 6e75 6d5f 6d61 7463 6865 7320 3d20 7374 num_matches = st │ │ │ +00030cf0: 643a 3a73 697a 655f 7428 7374 643a 3a63 d::size_t(std::c │ │ │ +00030d00: 6f75 6e74 5f69 6628 6c69 6e6b 732e 6265 ount_if(links.be │ │ │ +00030d10: 6769 6e28 292c 206c 696e 6b73 2e65 6e64 gin(), links.end │ │ │ +00030d20: 2829 0a09 0909 2c20 5b5d 2873 7464 3a3a ()...., [](std:: │ │ │ +00030d30: 7374 7269 6e67 2063 6f6e 7374 2661 6d70 string const& │ │ │ +00030d40: 3b20 6c69 6e6b 2920 7b20 7265 7475 726e ; link) { return │ │ │ +00030d50: 2021 6c69 6e6b 2e65 6d70 7479 2829 3b20 !link.empty(); │ │ │ +00030d60: 7d29 293b 0a0a 0909 2f2f 2073 6f6d 6520 }));....// some │ │ │ +00030d70: 6465 6275 6720 6f75 7470 7574 2069 6e20 debug output in │ │ │ +00030d80: 6361 7365 2074 6865 2074 6573 7420 6661 case the test fa │ │ │ +00030d90: 696c 730a 0909 6966 2028 6e75 6d5f 6d61 ils...if (num_ma │ │ │ +00030da0: 7463 6865 7320 2667 743b 2065 2e65 7870 tches > e.exp │ │ │ +00030db0: 6563 7465 645f 6d61 7463 6865 7329 0a3c ected_matches).< │ │ │ +00030dc0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00030dd0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00030de0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00030df0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00030e00: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../tes │ │ │ +00030e30: 742f 7465 7374 5f62 6c6f 6f6d 5f66 696c t/test_bloom_fil │ │ │ +00030e40: 7465 722e 6370 703a 3131 323c 2f61 3e3c ter.cpp:112< │ │ │ +00030e50: 2f74 643e 3c74 643e 7465 7374 2073 697a /td>test siz │ │ │ +00030e60: 6528 293c 2f74 643e 3c2f 7472 3e3c 7472 e()

    test size()

    ../test/tes │ │ │ +00030ed0: 745f 626c 6f6f 6d5f 6669 6c74 6572 2e63 t_bloom_filter.c │ │ │ +00030ee0: 7070 3a31 3132 3c2f 6834 3e3c 7072 6520 pp:112

    
    │ │ │ +00030f30: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ +00030f60: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ +00030f70: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ +00030f80: 7074 3a65 7870 616e 6428 3130 3129 223e  pt:expand(101)">
    │ │ │ +00030f90: 2e2e 2f74 6573 742f 7465 7374 5f62 6c6f  ../test/test_blo
    │ │ │ +00030fa0: 6f6d 5f66 696c 7465 722e 6370 703a 3131  om_filter.cpp:11
    │ │ │ +00030fb0: 333c 2f61 3e3c 2f74 643e 3c74 643e 7465  3te
    │ │ │ +00030fc0: 7374 2063 6c65 6172 2829 3c2f 7464 3e3c  st clear()<
    │ │ │ +00030fd0: 2f74 723e 3c74 7220 6964 3d22 3130 3122  /tr>

    test cle │ │ │ +00031020: 6172 2829 3c2f 6832 3e3c 6834 3e2e 2e2f ar()

    ../ │ │ │ +00031030: 7465 7374 2f74 6573 745f 626c 6f6f 6d5f test/test_bloom_ │ │ │ +00031040: 6669 6c74 6572 2e63 7070 3a31 3133 3c2f filter.cpp:113
    .sh
    │ │ │ +00031090: 6131 5f68 6173 6820 6b28 225c 7830 315c  a1_hash k("\x01\
    │ │ │ +000310a0: 7830 305c 7830 325c 7830 3020 2020 2020  x00\x02\x00     
    │ │ │ +000310b0: 2020 2020 2020 2020 2020 2022 293b 0a09             ");..
    │ │ │ +000310c0: 5445 5354 5f43 4845 434b 2821 6669 6c74  TEST_CHECK(!filt
    │ │ │ +000310d0: 6572 2e66 696e 6428 6b29 293b 0a09 6669  er.find(k));..fi
    │ │ │ +000310e0: 6c74 6572 2e73 6574 286b 293b 0a09 5445  lter.set(k);..TE
    │ │ │ +000310f0: 5354 5f43 4845 434b 2866 696c 7465 722e  ST_CHECK(filter.
    │ │ │ +00031100: 6669 6e64 286b 2929 3b0a 0a09 7374 643a  find(k));...std:
    │ │ │ +00031110: 3a75 696e 7438 5f74 2063 6f6d 7061 7265  :uint8_t compare
    │ │ │ +00031120: 5b34 5d20 3d20 7b20 3078 3136 2c20 3078  [4] = { 0x16, 0x
    │ │ │ +00031130: 6666 2c20 3078 3535 2c20 3078 6161 7d3b  ff, 0x55, 0xaa};
    │ │ │ +00031140: 0a0a 0962 6974 735f 6f75 7420 3d20 6669  ...bits_out = fi
    │ │ │ +00031150: 6c74 6572 2e74 6f5f 7374 7269 6e67 2829  lter.to_string()
    │ │ │ +00031160: 3b0a 0954 4553 545f 4551 5541 4c28 6d65  ;..TEST_EQUAL(me
    │ │ │ +00031170: 6d63 6d70 2863 6f6d 7061 7265 2c20 6269  mcmp(compare, bi
    │ │ │ +00031180: 7473 5f6f 7574 2e63 5f73 7472 2829 2c20  ts_out.c_str(), 
    │ │ │ +00031190: 3429 2c20 3029 3b0a 7d0a 0a7d 202f 2f20  4), 0);.}..} // 
    │ │ │ +000311a0: 616e 6f6e 796d 6f75 7320 6e61 6d65 7370  anonymous namesp
    │ │ │ +000311b0: 6163 650a 0a54 4f52 5245 4e54 5f54 4553  ace..TORRENT_TES
    │ │ │ +000311c0: 5428 626c 6f6f 6d5f 6669 6c74 6572 290a  T(bloom_filter).
    │ │ │ +000311d0: 7b0a 0974 6573 745f 7365 745f 616e 645f  {..test_set_and_
    │ │ │ +000311e0: 6765 7428 293b 0a09 7465 7374 5f73 6574  get();..test_set
    │ │ │ +000311f0: 5f62 6974 7328 293b 0a09 7465 7374 5f63  _bits();..test_c
    │ │ │ +00031200: 6f75 6e74 5f7a 6572 6f65 7328 293b 0a09  ount_zeroes();..
    │ │ │ +00031210: 7465 7374 5f74 6f5f 6672 6f6d 5f73 7472  test_to_from_str
    │ │ │ +00031220: 696e 6728 293b 0a0a 3c64 6976 2073 7479  ing();..
    }.
    r │ │ │ +00031290: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +000312a0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../test │ │ │ +000312d0: 2f74 6573 745f 6468 742e 6370 703a 3436 /test_dht.cpp:46 │ │ │ +000312e0: 373c 2f61 3e3c 2f74 643e 3c74 643e 6368 7ch │ │ │ +000312f0: 6563 6b20 746f 206d 616b 6520 7375 7265 eck to make sure │ │ │ +00031300: 2074 6865 2022 6265 7374 2220 6974 656d the "best" item │ │ │ +00031310: 7320 6172 6520 7374 6f72 6564 3c2f 7464 s are stored

    check │ │ │ +00031370: 746f 206d 616b 6520 7375 7265 2074 6865 to make sure the │ │ │ +00031380: 2022 6265 7374 2220 6974 656d 7320 6172 "best" items ar │ │ │ +00031390: 6520 7374 6f72 6564 3c2f 6832 3e3c 6834 e stored

    ../test/test_dh │ │ │ +000313b0: 742e 6370 703a 3436 373c 2f68 343e 3c70 t.cpp:467

    ..., msg │ │ │ +00031400: 5f61 7267 7328 292e 7461 7267 6574 2869 _args().target(i │ │ │ +00031410: 7465 6d73 5b6a 5d2e 7461 7267 6574 2929 tems[j].target)) │ │ │ +00031420: 3b0a 0a09 096b 6579 5f64 6573 635f 7420 ;....key_desc_t │ │ │ +00031430: 636f 6e73 7420 6465 7363 5b5d 203d 0a09 const desc[] =.. │ │ │ +00031440: 097b 0a09 0909 7b20 2272 222c 2062 6465 .{....{ "r", bde │ │ │ +00031450: 636f 6465 5f6e 6f64 653a 3a64 6963 745f code_node::dict_ │ │ │ +00031460: 742c 2030 2c20 6b65 795f 6465 7363 5f74 t, 0, key_desc_t │ │ │ +00031470: 3a3a 7061 7273 655f 6368 696c 6472 656e ::parse_children │ │ │ +00031480: 207d 2c0a 0909 0909 7b20 2276 222c 2062 },.....{ "v", b │ │ │ +00031490: 6465 636f 6465 5f6e 6f64 653a 3a64 6963 decode_node::dic │ │ │ +000314a0: 745f 742c 2030 2c20 307d 2c0a 0909 0909 t_t, 0, 0},..... │ │ │ +000314b0: 7b20 2269 6422 2c20 6264 6563 6f64 655f { "id", bdecode_ │ │ │ +000314c0: 6e6f 6465 3a3a 7374 7269 6e67 5f74 2c20 node::string_t, │ │ │ +000314d0: 3230 2c20 6b65 795f 6465 7363 5f74 3a3a 20, key_desc_t:: │ │ │ +000314e0: 6c61 7374 5f63 6869 6c64 7d2c 0a09 0909 last_child},.... │ │ │ +000314f0: 7b20 2279 222c 2062 6465 636f 6465 5f6e { "y", bdecode_n │ │ │ +00031500: 6f64 653a 3a73 7472 696e 675f 742c 2031 ode::string_t, 1 │ │ │ +00031510: 2c20 307d 2c0a 0909 7d3b 0a0a 0909 6264 , 0},...};....bd │ │ │ +00031520: 6563 6f64 655f 6e6f 6465 2070 6172 7365 ecode_node parse │ │ │ +00031530: 645b 345d 3b0a 0909 6368 6172 2065 7272 d[4];...char err │ │ │ +00031540: 6f72 5f73 7472 696e 675b 3230 305d 3b0a or_string[200];. │ │ │ +00031550: 0a09 0969 6e74 2072 6574 203d 2076 6572 ...int ret = ver │ │ │ +00031560: 6966 795f 6d65 7373 6167 6528 7265 7370 ify_message(resp │ │ │ +00031570: 6f6e 7365 2c20 6465 7363 2c20 7061 7273 onse, desc, pars │ │ │ +00031580: 6564 2c20 6572 726f 725f 7374 7269 6e67 ed, error_string │ │ │ +00031590: 293b 0a09 0969 6620 2872 6574 290a 0909 );...if (ret)... │ │ │ +000315a0: 7b0a 0909 0969 7465 6d73 5f6e 756d 2e69 {....items_num.i │ │ │ +000315b0: 6e73 6572 7428 6974 656d 735f 6e75 6d2e nsert(items_num. │ │ │ +000315c0: 6265 6769 6e28 292c 206a 293b 0a09 097d begin(), j);...} │ │ │ +000315d0: 0a09 7d0a 0a3c 6469 7620 7374 796c 653d ..}..

    .TEST_EQUAL(i │ │ │ +00031610: 7465 6d73 5f6e 756d 2e73 697a 6528 292c tems_num.size(), │ │ │ +00031620: 2034 293b 0a3c 2f64 6976 3e7d 0a0a 696e 4);.
    }..in │ │ │ +00031630: 7420 7375 6d5f 6469 7374 616e 6365 5f65 t sum_distance_e │ │ │ +00031640: 7870 2869 6e74 2073 2c20 6e6f 6465 5f65 xp(int s, node_e │ │ │ +00031650: 6e74 7279 2063 6f6e 7374 2661 6d70 3b20 ntry const& │ │ │ +00031660: 652c 206e 6f64 655f 6964 2063 6f6e 7374 e, node_id const │ │ │ +00031670: 2661 6d70 3b20 7265 6629 0a7b 0a09 7265 & ref).{..re │ │ │ +00031680: 7475 726e 2073 202b 2064 6973 7461 6e63 turn s + distanc │ │ │ +00031690: 655f 6578 7028 652e 6964 2c20 7265 6629 e_exp(e.id, ref) │ │ │ +000316a0: 3b0a 7d0a 0a73 7464 3a3a 7665 6374 6f72 ;.}..std::vector │ │ │ +000316b0: 266c 743b 7463 703a 3a65 6e64 706f 696e <tcp::endpoin │ │ │ +000316c0: 7426 6774 3b20 675f 676f 745f 7065 6572 t> g_got_peer │ │ │ +000316d0: 733b 0a0a 766f 6964 2067 6574 5f70 6565 s;..void get_pee │ │ │ +000316e0: 7273 5f63 6228 7374 643a 3a76 6563 746f rs_cb(std::vecto │ │ │ +000316f0: 7226 6c74 3b74 6370 3a3a 656e 6470 6f69 r<tcp::endpoi │ │ │ +00031700: 6e74 2667 743b 2063 6f6e 7374 2661 6d70 nt> const& │ │ │ +00031710: 3b20 7065 6572 7329 0a7b 0a09 675f 676f ; peers).{..g_go │ │ │ +00031720: 745f 7065 6572 732e 696e 7365 7274 2867 t_peers.insert(g │ │ │ +00031730: 5f67 6f74 5f70 6565 7273 2e65 6e64 2829 _got_peers.end() │ │ │ +00031740: 2c20 7065 6572 732e 6265 6769 6e28 292c , peers.begin(), │ │ │ +00031750: 2070 6565 7273 2e65 6e64 2829 293b 0a7d peers.end());.} │ │ │ +00031760: 0a0a 7374 643a 3a76 6563 746f 7226 6c74 ..std::vector< │ │ │ +00031770: 3b64 6874 3a3a 6974 656d 2667 743b 2067 ;dht::item> g │ │ │ +00031780: 5f67 6f74 5f69 7465 6d73 3b0a 6468 743a _got_items;.dht: │ │ │ +00031790: 3a69 7465 6d20 675f 7075 745f 6974 656d :item g_put_item │ │ │ +000317a0: 3b0a 696e 7420 675f 7075 745f 636f 756e ;.int g_put_coun │ │ │ +000317b0: 743b 0a0a 766f 6964 2067 6574 5f6d 7574 t;..void get_mut │ │ │ +000317c0: 6162 6c65 5f69 7465 6d5f 6362 2864 6874 able_item_cb(dht │ │ │ +000317d0: 3a3a 6974 656d 2063 6f6e 7374 2661 6d70 ::item const& │ │ │ +000317e0: 3b20 692c 2062 6f6f 6c20 6129 0a7b 0a09 ; i, bool a).{.. │ │ │ +000317f0: 6966 2028 2161 2920 7265 7475 726e 3b0a if (!a) return;. │ │ │ +00031800: 0969 6620 2821 692e 656d 7074 7928 2929 .if (!i.empty()) │ │ │ +00031810: 0a09 0967 5f67 6f74 5f69 7465 6d73 2e70 ...g_got_items.p │ │ │ +00031820: 7573 685f 6261 636b 2869 293b 0a7d 0a0a ush_back(i);.}.. │ │ │ +00031830: 766f 6964 2070 7574 5f6d 7574 6162 6c65 void put_mutable │ │ │ +00031840: 5f69 7465 6d5f 6461 7461 5f63 6228 6468 _item_data_cb(dh │ │ │ +00031850: 743a 3a69 7465 6d26 616d 703b 2069 290a t::item& i). │ │ │ +00031860: 7b0a 0969 6620 2821 692e 656d 7074 7928 {..if (!i.empty( │ │ │ +00031870: 2929 0a09 0967 5f67 6f74 5f69 7465 6d73 ))...g_got_items │ │ │ +00031880: 2e70 7573 685f 6261 636b 2869 293b 0a0a .push_back(i);.. │ │ │ +00031890: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +000318a0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +000318d0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ +00031900: 7374 2f74 6573 745f 6468 742e 6370 703a st/test_dht.cpp: │ │ │ +00031910: 3332 3138 3c2f 613e 3c2f 7464 3e3c 7464 3218this won't work │ │ │ +00031930: 2062 6563 6175 7365 2074 6865 2073 6563 because the sec │ │ │ +00031940: 6f6e 6420 6e6f 6465 2069 736e 2774 2070 ond node isn't p │ │ │ +00031950: 696e 6765 6420 736f 2069 7420 776f 6e74 inged so it wont │ │ │ +00031960: 2062 6520 6164 6465 6420 746f 2074 6865 be added to the │ │ │ +00031970: 2072 6f75 7469 6e67 2074 6162 6c65 3c2f routing table

    this │ │ │ +000319d0: 2077 6f6e 2774 2077 6f72 6b20 6265 6361 won't work beca │ │ │ +000319e0: 7573 6520 7468 6520 7365 636f 6e64 206e use the second n │ │ │ +000319f0: 6f64 6520 6973 6e27 7420 7069 6e67 6564 ode isn't pinged │ │ │ +00031a00: 2073 6f20 6974 2077 6f6e 740a 6265 2061 so it wont.be a │ │ │ +00031a10: 6464 6564 2074 6f20 7468 6520 726f 7574 dded to the rout │ │ │ +00031a20: 696e 6720 7461 626c 653c 2f68 323e 3c68 ing table

    ../test/test_d │ │ │ +00031a40: 6874 2e63 7070 3a33 3231 383c 2f68 343e ht.cpp:3218

    │ │ │ +00031a50: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .bool 
    │ │ │ +00031a90: 7265 7420 3d20 7665 7269 6679 5f6d 6573  ret = verify_mes
    │ │ │ +00031aa0: 7361 6765 2872 6571 7565 7374 2c20 6765  sage(request, ge
    │ │ │ +00031ab0: 745f 6974 656d 5f64 6573 635f 726f 2c20  t_item_desc_ro, 
    │ │ │ +00031ac0: 7061 7273 6564 2c20 6572 726f 725f 7374  parsed, error_st
    │ │ │ +00031ad0: 7269 6e67 293b 0a0a 0954 4553 545f 4348  ring);...TEST_CH
    │ │ │ +00031ae0: 4543 4b28 7265 7429 3b0a 0954 4553 545f  ECK(ret);..TEST_
    │ │ │ +00031af0: 4551 5541 4c28 7061 7273 6564 5b33 5d2e  EQUAL(parsed[3].
    │ │ │ +00031b00: 696e 745f 7661 6c75 6528 292c 2031 293b  int_value(), 1);
    │ │ │ +00031b10: 0a0a 092f 2f20 7368 6f75 6c64 2068 6176  ...// should hav
    │ │ │ +00031b20: 6520 6f6e 6520 6e6f 6465 206e 6f77 2c20  e one node now, 
    │ │ │ +00031b30: 7768 6963 6820 6973 2034 2e34 2e34 2e34  which is 4.4.4.4
    │ │ │ +00031b40: 3a31 3233 340a 0954 4553 545f 4551 5541  :1234..TEST_EQUA
    │ │ │ +00031b50: 4c28 7374 643a 3a67 6574 266c 743b 3026  L(std::get<0&
    │ │ │ +00031b60: 6774 3b28 6e6f 6465 2e73 697a 6528 2929  gt;(node.size())
    │ │ │ +00031b70: 2c20 3129 3b0a 092f 2f20 616e 6420 6e6f  , 1);..// and no
    │ │ │ +00031b80: 2072 6570 6c61 6365 6d65 6e74 206e 6f64   replacement nod
    │ │ │ +00031b90: 6573 0a09 5445 5354 5f45 5155 414c 2873  es..TEST_EQUAL(s
    │ │ │ +00031ba0: 7464 3a3a 6765 7426 6c74 3b31 2667 743b  td::get<1>
    │ │ │ +00031bb0: 286e 6f64 652e 7369 7a65 2829 292c 2030  (node.size()), 0
    │ │ │ +00031bc0: 293b 0a0a 092f 2f20 6e6f 772c 2064 6973  );...// now, dis
    │ │ │ +00031bd0: 6162 6c65 2072 6561 645f 6f6e 6c79 2c20  able read_only, 
    │ │ │ +00031be0: 7472 7920 6167 6169 6e2e 0a09 675f 7365  try again...g_se
    │ │ │ +00031bf0: 6e74 5f70 6163 6b65 7473 2e63 6c65 6172  nt_packets.clear
    │ │ │ +00031c00: 2829 3b0a 0973 6574 742e 7365 745f 626f  ();..sett.set_bo
    │ │ │ +00031c10: 6f6c 2873 6574 7469 6e67 735f 7061 636b  ol(settings_pack
    │ │ │ +00031c20: 3a3a 6468 745f 7265 6164 5f6f 6e6c 792c  ::dht_read_only,
    │ │ │ +00031c30: 2066 616c 7365 293b 0a0a 0973 656e 645f   false);...send_
    │ │ │ +00031c40: 6468 745f 7265 7175 6573 7428 6e6f 6465  dht_request(node
    │ │ │ +00031c50: 2c20 2267 6574 222c 2073 6f75 7263 652c  , "get", source,
    │ │ │ +00031c60: 2026 616d 703b 7265 7370 6f6e 7365 293b   &response);
    │ │ │ +00031c70: 0a09 2f2f 2073 656e 6465 7220 7368 6f75  ..// sender shou
    │ │ │ +00031c80: 6c64 2062 6520 6164 6465 6420 746f 2072  ld be added to r
    │ │ │ +00031c90: 6570 6c61 6365 6d65 6e74 2062 7563 6b65  eplacement bucke
    │ │ │ +00031ca0: 740a 0954 4553 545f 4551 5541 4c28 7374  t..TEST_EQUAL(st
    │ │ │ +00031cb0: 643a 3a67 6574 266c 743b 3126 6774 3b28  d::get<1>(
    │ │ │ +00031cc0: 6e6f 6465 2e73 697a 6528 2929 2c20 3129  node.size()), 1)
    │ │ │ +00031cd0: 3b0a 0a09 675f 7365 6e74 5f70 6163 6b65  ;...g_sent_packe
    │ │ │ +00031ce0: 7473 2e63 6c65 6172 2829 3b0a 2369 6620  ts.clear();.#if 
    │ │ │ +00031cf0: 300a 3c64 6976 2073 7479 6c65 3d22 6261  0.
    │ │ │ +00031d20: 0974 6172 6765 7420 3d20 6765 6e65 7261 .target = genera │ │ │ +00031d30: 7465 5f6e 6578 7428 293b 0a3c 2f64 6976 te_next();.
    .node.get_item( │ │ │ +00031d50: 7461 7267 6574 2c20 6765 745f 696d 6d75 target, get_immu │ │ │ +00031d60: 7461 626c 655f 6974 656d 5f63 6229 3b0a table_item_cb);. │ │ │ +00031d70: 0a09 2f2f 2073 696e 6365 2077 6520 6861 ..// since we ha │ │ │ +00031d80: 7665 2032 206e 6f64 6573 2c20 7765 2073 ve 2 nodes, we s │ │ │ +00031d90: 686f 756c 6420 6861 7665 2074 776f 2070 hould have two p │ │ │ +00031da0: 6163 6b65 7473 2e0a 0954 4553 545f 4551 ackets...TEST_EQ │ │ │ +00031db0: 5541 4c28 675f 7365 6e74 5f70 6163 6b65 UAL(g_sent_packe │ │ │ +00031dc0: 7473 2e73 697a 6528 292c 2032 293b 0a0a ts.size(), 2);.. │ │ │ +00031dd0: 092f 2f20 626f 7468 206f 6620 7468 656d .// both of them │ │ │ +00031de0: 2073 686f 756c 646e 2774 2068 6176 6520 shouldn't have │ │ │ +00031df0: 6120 2772 6f27 206b 6579 2e0a 096e 6f64 a 'ro' key...nod │ │ │ +00031e00: 655f 6672 6f6d 5f65 6e74 7279 2867 5f73 e_from_entry(g_s │ │ │ +00031e10: 656e 745f 7061 636b 6574 732e 6672 6f6e ent_packets.fron │ │ │ +00031e20: 7428 292e 7365 636f 6e64 2c20 7265 7175 t().second, requ │ │ │ +00031e30: 6573 7429 3b0a 0972 6574 203d 2076 6572 est);..ret = ver │ │ │ +00031e40: 6966 795f 6d65 7373 6167 6528 7265 7175 ify_message(requ │ │ │ +00031e50: 6573 742c 2067 6574 5f69 7465 6d5f 6465 est, get_item_de │ │ │ +00031e60: 7363 5f72 6f2c 2070 6172 7365 642c 2065 sc_ro, parsed, e │ │ │ +00031e70: 7272 6f72 5f73 7472 696e 6729 3b0a 0a09 rror_string);... │ │ │ +00031e80: 5445 5354 5f43 4845 434b 2872 6574 293b TEST_CHECK(ret); │ │ │ +00031e90: 0a09 5445 5354 5f43 4845 434b 2821 7061 ..TEST_CHECK(!pa │ │ │ +00031ea0: 7273 6564 5b33 5d29 3b0a 0a09 6e6f 6465 rsed[3]);...node │ │ │ +00031eb0: 5f66 726f 6d5f 656e 7472 7928 675f 7365 _from_entry(g_se │ │ │ +00031ec0: 6e74 5f70 6163 6b65 7473 2e62 6163 6b28 nt_packets.back( │ │ │ +00031ed0: 292e 7365 636f 6e64 2c20 7265 7175 6573 ).second, reques │ │ │ +00031ee0: 7429 3b0a 0972 6574 203d 2076 6572 6966 t);..ret = verif │ │ │ +00031ef0: 795f 6d65 7373 6167 6528 7265 7175 6573 y_message(reques │ │ │ +00031f00: 742c 2067 6574 5f69 7465 6d5f 6465 7363 t, get_item_desc │ │ │ +00031f10: 5f72 6f2c 2070 6172 7365 642c 2065 7272 _ro, parsed, err │ │ │ +00031f20: 6f72 5f73 7472 696e 6729 3b0a 0a09 5445 or_string);...TE │ │ │ +00031f30: 5354 5f43 4845 434b 2872 6574 293b 0a09 ST_CHECK(ret);.. │ │ │ +00031f40: 5445 5354 5f43 4845 434b 2821 7061 7273 TEST_CHECK(!pars │ │ │ +00031f50: 6564 5b33 5d29 3b0a 2365 6e64 6966 0a7d ed[3]);.#endif.} │ │ │ +00031f60: 0a0a 544f 5252 454e 545f 5445 5354 2872 ..TORRENT_TEST(r │ │ │ +00031f70: 7063 5f72 6570 6c79 5f69 676e 6f72 6573 pc_reply_ignores │ │ │ +00031f80: 5f77 726f 6e67 5f70 6f72 7429 0a7b 0a09 _wrong_port).{.. │ │ │ +00031f90: 6175 746f 2073 6574 7420 3d20 7465 7374 auto sett = test │ │ │ +00031fa0: 5f73 6574 7469 6e67 7328 293b 0a09 6d6f _settings();..mo │ │ │ +00031fb0: 636b 5f73 6f63 6b65 7420 733b 0a09 6175 ck_socket s;..au │ │ │ +00031fc0: 746f 206c 7320 3d20 6475 6d6d 795f 6c69 to ls = dummy_li │ │ │ +00031fd0: 7374 656e 5f73 6f63 6b65 7434 2829 3b0a sten_socket4();. │ │ │ +00031fe0: 096f 6273 206f 6273 6572 7665 723b 0a09 .obs observer;.. │ │ │ +00031ff0: 636f 756e 7465 7273 2063 6e74 3b0a 0a09 counters cnt;... │ │ │ +00032000: 6468 743a 3a72 6f75 7469 6e67 5f74 6162 dht::routing_tab │ │ │ +00032010: 6c65 2074 6162 6c65 286e 6f64 655f 6964 le table(node_id │ │ │ +00032020: 2829 2c20 7564 703a 3a76 3428 292c 2038 (), udp::v4(), 8 │ │ │ +00032030: 2c20 7365 7474 2c20 2661 6d70 3b6f 6273 , sett, &obs │ │ │ +00032040: 6572 7665 7229 3b0a 0964 6874 3a3a 7270 erver);..dht::rp │ │ │ +00032050: 635f 6d61 6e61 6765 7220 7270 6328 6e6f c_manager rpc(no │ │ │ +00032060: 6465 5f69 6428 292c 2073 6574 742c 2074 de_id(), sett, t │ │ │ +00032070: 6162 6c65 2c20 6c73 2c20 2661 6d70 3b73 able, ls, &s │ │ │ +00032080: 2c20 2661 6d70 3b6f 6273 6572 7665 7229 , &observer) │ │ │ +00032090: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +000320c0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +000320d0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00032100: 7465 7374 2f74 6573 745f 6468 742e 6370 test/test_dht.cp │ │ │ +00032110: 703a 3431 3238 3c2f 613e 3c2f 7464 3e3c p:4128< │ │ │ +00032120: 7464 3e74 6573 7420 6f62 6675 7363 6174 td>test obfuscat │ │ │ +00032130: 6564 5f67 6574 5f70 6565 7273 3c2f 7464 ed_get_peers

    test o │ │ │ +00032190: 6266 7573 6361 7465 645f 6765 745f 7065 bfuscated_get_pe │ │ │ +000321a0: 6572 733c 2f68 323e 3c68 343e 2e2e 2f74 ers

    ../t │ │ │ +000321b0: 6573 742f 7465 7374 5f64 6874 2e63 7070 est/test_dht.cpp │ │ │ +000321c0: 3a34 3132 383c 2f68 343e 3c70 7265 2073 :4128

    ..TEST_CHECK
    │ │ │ +00032210: 2873 6d2e 6861 735f 7175 6f74 6128 2929  (sm.has_quota())
    │ │ │ +00032220: 3b0a 097d 293b 0a7d 0a0a 544f 5252 454e  ;..});.}..TORREN
    │ │ │ +00032230: 545f 5445 5354 2872 6174 655f 6c69 6d69  T_TEST(rate_limi
    │ │ │ +00032240: 745f 6163 6372 7565 5f6c 696d 6974 290a  t_accrue_limit).
    │ │ │ +00032250: 7b0a 0961 7578 3a3a 7365 7373 696f 6e5f  {..aux::session_
    │ │ │ +00032260: 7365 7474 696e 6773 2073 6574 743b 0a09  settings sett;..
    │ │ │ +00032270: 7365 7474 2e73 6574 5f69 6e74 2873 6574  sett.set_int(set
    │ │ │ +00032280: 7469 6e67 735f 7061 636b 3a3a 6468 745f  tings_pack::dht_
    │ │ │ +00032290: 7570 6c6f 6164 5f72 6174 655f 6c69 6d69  upload_rate_limi
    │ │ │ +000322a0: 742c 2073 7464 3a3a 6e75 6d65 7269 635f  t, std::numeric_
    │ │ │ +000322b0: 6c69 6d69 7473 266c 743b 696e 7426 6774  limits<int>
    │ │ │ +000322c0: 3b3a 3a6d 6178 2829 293b 0a0a 0974 6573  ;::max());...tes
    │ │ │ +000322d0: 745f 7261 7465 5f6c 696d 6974 2873 6574  t_rate_limit(set
    │ │ │ +000322e0: 742c 205b 5d28 6c74 3a3a 6468 743a 3a73  t, [](lt::dht::s
    │ │ │ +000322f0: 6f63 6b65 745f 6d61 6e61 6765 7226 616d  ocket_manager&am
    │ │ │ +00032300: 703b 2073 6d29 207b 0a09 0954 4553 545f  p; sm) {...TEST_
    │ │ │ +00032310: 4348 4543 4b28 736d 2e68 6173 5f71 756f  CHECK(sm.has_quo
    │ │ │ +00032320: 7461 2829 293b 0a09 0966 6f72 2028 696e  ta());...for (in
    │ │ │ +00032330: 7420 6920 3d20 303b 2069 2026 6c74 3b20  t i = 0; i < 
    │ │ │ +00032340: 3130 3b20 2b2b 6929 0a09 097b 0a09 0909  10; ++i)...{....
    │ │ │ +00032350: 7374 643a 3a74 6869 735f 7468 7265 6164  std::this_thread
    │ │ │ +00032360: 3a3a 736c 6565 705f 666f 7228 6d69 6c6c  ::sleep_for(mill
    │ │ │ +00032370: 6973 6563 6f6e 6473 2835 3030 2929 3b0a  iseconds(500));.
    │ │ │ +00032380: 0909 0954 4553 545f 4348 4543 4b28 736d  ...TEST_CHECK(sm
    │ │ │ +00032390: 2e68 6173 5f71 756f 7461 2829 293b 0a09  .has_quota());..
    │ │ │ +000323a0: 097d 0a09 7d29 3b0a 7d0a 0a0a 3c64 6976  .}..});.}...
    .
    #else.TORRENT_T │ │ │ +000323f0: 4553 5428 6468 7429 0a7b 0a09 2f2f 2064 EST(dht).{..// d │ │ │ +00032400: 756d 6d79 2064 6874 2074 6573 740a 0954 ummy dht test..T │ │ │ +00032410: 4553 545f 4348 4543 4b28 7472 7565 293b EST_CHECK(true); │ │ │ +00032420: 0a7d 0a0a 2365 6e64 6966 0a3c 2f70 7265 .}..#endif.
    rele │ │ │ +00032460: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../test/te │ │ │ +000324a0: 7374 5f74 7261 636b 6572 2e63 7070 3a34 st_tracker.cpp:4 │ │ │ +000324b0: 313c 2f61 3e3c 2f74 643e 3c74 643e 7465 1te │ │ │ +000324c0: 7374 2073 6372 6170 6520 7265 7175 6573 st scrape reques │ │ │ +000324d0: 7473 3c2f 7464 3e3c 2f74 723e 3c74 7220 ts

    │ │ │ +00032520: 7465 7374 2073 6372 6170 6520 7265 7175 test scrape requ │ │ │ +00032530: 6573 7473 3c2f 6832 3e3c 6834 3e2e 2e2f ests

    ../ │ │ │ +00032540: 7465 7374 2f74 6573 745f 7472 6163 6b65 test/test_tracke │ │ │ +00032550: 722e 6370 703a 3431 3c2f 6834 3e3c 7072 r.cpp:41

    relevanc │ │ │ +000325d0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_t │ │ │ +00032610: 7261 636b 6572 2e63 7070 3a34 323c 2f61 racker.cpp:42test p │ │ │ +00032630: 6172 7365 2074 7261 636b 6572 2d69 643c arse tracker-id< │ │ │ +00032640: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    tes │ │ │ +00032690: 7420 7061 7273 6520 7472 6163 6b65 722d t parse tracker- │ │ │ +000326a0: 6964 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 id

    ../te │ │ │ +000326b0: 7374 2f74 6573 745f 7472 6163 6b65 722e st/test_tracker. │ │ │ +000326c0: 6370 703a 3432 3c2f 6834 3e3c 7072 6520 cpp:42

    
    │ │ │ +00032710: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ +00032740: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ +00032750: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ +00032760: 7074 3a65 7870 616e 6428 3130 3729 223e  pt:expand(107)">
    │ │ │ +00032770: 2e2e 2f74 6573 742f 7465 7374 5f74 7261  ../test/test_tra
    │ │ │ +00032780: 636b 6572 2e63 7070 3a34 333c 2f61 3e3c  cker.cpp:43<
    │ │ │ +00032790: 2f74 643e 3c74 643e 7465 7374 2070 6172  /td>test par
    │ │ │ +000327a0: 7365 2066 6169 6c75 7265 2d72 6561 736f  se failure-reaso
    │ │ │ +000327b0: 6e3c 2f74 643e 3c2f 7472 3e3c 7472 2069  n

    t │ │ │ +00032800: 6573 7420 7061 7273 6520 6661 696c 7572 est parse failur │ │ │ +00032810: 652d 7265 6173 6f6e 3c2f 6832 3e3c 6834 e-reason

    ../test/test_tr │ │ │ +00032830: 6163 6b65 722e 6370 703a 3433 3c2f 6834 acker.cpp:43

    rele
    │ │ │ +000328b0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ +000328f0: 7374 5f74 7261 636b 6572 2e63 7070 3a34  st_tracker.cpp:4
    │ │ │ +00032900: 343c 2f61 3e3c 2f74 643e 3c74 643e 7465  4te
    │ │ │ +00032910: 7374 2061 6c6c 2066 6169 6c75 7265 2070  st all failure p
    │ │ │ +00032920: 6174 6873 2c20 696e 636c 7564 696e 6720  aths, including 
    │ │ │ +00032930: 696e 7661 6c69 6420 6265 6e63 6f64 696e  invalid bencodin
    │ │ │ +00032940: 6720 6e6f 7420 6120 6469 6374 696f 6e61  g not a dictiona
    │ │ │ +00032950: 7279 206e 6f20 6669 6c65 7320 656e 7472  ry no files entr
    │ │ │ +00032960: 7920 696e 2073 6372 6170 6520 7265 7370  y in scrape resp
    │ │ │ +00032970: 6f6e 7365 206e 6f20 696e 666f 2d68 6173  onse no info-has
    │ │ │ +00032980: 6820 656e 7472 7920 696e 2073 6372 6170  h entry in scrap
    │ │ │ +00032990: 6520 7265 7370 6f6e 7365 206d 616c 666f  e response malfo
    │ │ │ +000329a0: 726d 6564 2070 6565 7273 2069 6e20 7065  rmed peers in pe
    │ │ │ +000329b0: 6572 206c 6973 7420 6f66 2064 6963 7469  er list of dicti
    │ │ │ +000329c0: 6f6e 6172 6965 7320 756e 6576 656e 206e  onaries uneven n
    │ │ │ +000329d0: 756d 6265 7220 6f66 2062 7974 6573 2069  umber of bytes i
    │ │ │ +000329e0: 6e20 7065 6572 7320 616e 6420 7065 6572  n peers and peer
    │ │ │ +000329f0: 7336 2073 7472 696e 6720 7265 7370 6f6e  s6 string respon
    │ │ │ +00032a00: 7365 733c 2f74 643e 3c2f 7472 3e3c 7472  ses

    test all failur │ │ │ +00032a60: 6520 7061 7468 732c 2069 6e63 6c75 6469 e paths, includi │ │ │ +00032a70: 6e67 0a69 6e76 616c 6964 2062 656e 636f ng.invalid benco │ │ │ +00032a80: 6469 6e67 0a6e 6f74 2061 2064 6963 7469 ding.not a dicti │ │ │ +00032a90: 6f6e 6172 790a 6e6f 2066 696c 6573 2065 onary.no files e │ │ │ +00032aa0: 6e74 7279 2069 6e20 7363 7261 7065 2072 ntry in scrape r │ │ │ +00032ab0: 6573 706f 6e73 650a 6e6f 2069 6e66 6f2d esponse.no info- │ │ │ +00032ac0: 6861 7368 2065 6e74 7279 2069 6e20 7363 hash entry in sc │ │ │ +00032ad0: 7261 7065 2072 6573 706f 6e73 650a 6d61 rape response.ma │ │ │ +00032ae0: 6c66 6f72 6d65 6420 7065 6572 7320 696e lformed peers in │ │ │ +00032af0: 2070 6565 7220 6c69 7374 206f 6620 6469 peer list of di │ │ │ +00032b00: 6374 696f 6e61 7269 6573 0a75 6e65 7665 ctionaries.uneve │ │ │ +00032b10: 6e20 6e75 6d62 6572 206f 6620 6279 7465 n number of byte │ │ │ +00032b20: 7320 696e 2070 6565 7273 2061 6e64 2070 s in peers and p │ │ │ +00032b30: 6565 7273 3620 7374 7269 6e67 2072 6573 eers6 string res │ │ │ +00032b40: 706f 6e73 6573 3c2f 6832 3e3c 6834 3e2e ponses

    . │ │ │ +00032b50: 2e2f 7465 7374 2f74 6573 745f 7472 6163 ./test/test_trac │ │ │ +00032b60: 6b65 722e 6370 703a 3434 3c2f 6834 3e3c ker.cpp:44

    < │ │ │ +00032b70: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00032b80: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00032b90: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00032ba0: 7820 2364 6464 3b22 3e23 696e 636c 7564 x #ddd;">#includ │ │ │ +00032bb0: 6520 2274 6573 745f 7574 696c 732e 6870 e "test_utils.hp │ │ │ +00032bc0: 7022 0a23 696e 636c 7564 6520 226c 6962 p".#include "lib │ │ │ +00032bd0: 746f 7272 656e 742f 616c 6572 742e 6870 torrent/alert.hp │ │ │ +00032be0: 7022 0a23 696e 636c 7564 6520 226c 6962 p".#include "lib │ │ │ +00032bf0: 746f 7272 656e 742f 7065 6572 5f69 6e66 torrent/peer_inf │ │ │ +00032c00: 6f2e 6870 7022 202f 2f20 666f 7220 7065 o.hpp" // for pe │ │ │ +00032c10: 6572 5f6c 6973 745f 656e 7472 790a 2369 er_list_entry.#i │ │ │ +00032c20: 6e63 6c75 6465 2022 6c69 6274 6f72 7265 nclude "libtorre │ │ │ +00032c30: 6e74 2f61 6c65 7274 5f74 7970 6573 2e68 nt/alert_types.h │ │ │ +00032c40: 7070 220a 2369 6e63 6c75 6465 2022 6c69 pp".#include "li │ │ │ +00032c50: 6274 6f72 7265 6e74 2f73 6573 7369 6f6e btorrent/session │ │ │ +00032c60: 2e68 7070 220a 2369 6e63 6c75 6465 2022 .hpp".#include " │ │ │ +00032c70: 6c69 6274 6f72 7265 6e74 2f73 6573 7369 libtorrent/sessi │ │ │ +00032c80: 6f6e 5f70 6172 616d 732e 6870 7022 0a23 on_params.hpp".# │ │ │ +00032c90: 696e 636c 7564 6520 226c 6962 746f 7272 include "libtorr │ │ │ +00032ca0: 656e 742f 6572 726f 725f 636f 6465 2e68 ent/error_code.h │ │ │ +00032cb0: 7070 220a 2369 6e63 6c75 6465 2022 6c69 pp".#include "li │ │ │ +00032cc0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7472 btorrent/aux_/tr │ │ │ +00032cd0: 6163 6b65 725f 6d61 6e61 6765 722e 6870 acker_manager.hp │ │ │ +00032ce0: 7022 0a23 696e 636c 7564 6520 226c 6962 p".#include "lib │ │ │ +00032cf0: 746f 7272 656e 742f 6175 785f 2f68 7474 torrent/aux_/htt │ │ │ +00032d00: 705f 7472 6163 6b65 725f 636f 6e6e 6563 p_tracker_connec │ │ │ +00032d10: 7469 6f6e 2e68 7070 2220 2f2f 2066 6f72 tion.hpp" // for │ │ │ +00032d20: 2070 6172 7365 5f74 7261 636b 6572 5f72 parse_tracker_r │ │ │ +00032d30: 6573 706f 6e73 650a 2369 6e63 6c75 6465 esponse.#include │ │ │ +00032d40: 2022 6c69 6274 6f72 7265 6e74 2f61 7578 "libtorrent/aux │ │ │ +00032d50: 5f2f 7765 6273 6f63 6b65 745f 7472 6163 _/websocket_trac │ │ │ +00032d60: 6b65 725f 636f 6e6e 6563 7469 6f6e 2e68 ker_connection.h │ │ │ +00032d70: 7070 2220 2f2f 2066 6f72 2070 6172 7365 pp" // for parse │ │ │ +00032d80: 5f77 6562 736f 636b 6574 5f74 7261 636b _websocket_track │ │ │ +00032d90: 6572 5f72 6573 706f 6e73 650a 2369 6e63 er_response.#inc │ │ │ +00032da0: 6c75 6465 2022 6c69 6274 6f72 7265 6e74 lude "libtorrent │ │ │ +00032db0: 2f74 6f72 7265 6e74 5f69 6e66 6f2e 6870 /torrent_info.hp │ │ │ +00032dc0: 7022 0a23 696e 636c 7564 6520 226c 6962 p".#include "lib │ │ │ +00032dd0: 746f 7272 656e 742f 616e 6e6f 756e 6365 torrent/announce │ │ │ +00032de0: 5f65 6e74 7279 2e68 7070 220a 2369 6e63 _entry.hpp".#inc │ │ │ +00032df0: 6c75 6465 2022 6c69 6274 6f72 7265 6e74 lude "libtorrent │ │ │ +00032e00: 2f61 7578 5f2f 7061 7468 2e68 7070 220a /aux_/path.hpp". │ │ │ +00032e10: 2369 6e63 6c75 6465 2022 6c69 6274 6f72 #include "libtor │ │ │ +00032e20: 7265 6e74 2f61 7578 5f2f 736f 636b 6574 rent/aux_/socket │ │ │ +00032e30: 5f69 6f2e 6870 7022 0a0a 2369 6e63 6c75 _io.hpp"..#inclu │ │ │ +00032e40: 6465 2026 6c74 3b61 7272 6179 2667 743b de <array> │ │ │ +00032e50: 0a23 696e 636c 7564 6520 266c 743b 696f .#include <io │ │ │ +00032e60: 7374 7265 616d 2667 743b 0a0a 7573 696e stream>..usin │ │ │ +00032e70: 6720 6e61 6d65 7370 6163 6520 6c74 3b0a g namespace lt;. │ │ │ +00032e80: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ +00032eb0: 3c2f 6469 763e 544f 5252 454e 545f 5445
    TORRENT_TE │ │ │ +00032ec0: 5354 2870 6172 7365 5f68 6f73 746e 616d ST(parse_hostnam │ │ │ +00032ed0: 655f 7065 6572 7329 0a7b 0a09 6368 6172 e_peers).{..char │ │ │ +00032ee0: 2063 6f6e 7374 2072 6573 706f 6e73 655b const response[ │ │ │ +00032ef0: 5d20 3d20 2264 353a 7065 6572 736c 6437 ] = "d5:peersld7 │ │ │ +00032f00: 3a70 6565 7220 6964 3230 3a61 6161 6161 :peer id20:aaaaa │ │ │ +00032f10: 6161 6161 6161 6161 6161 6161 6161 6122 aaaaaaaaaaaaaaa" │ │ │ +00032f20: 0a09 0922 323a 6970 3133 3a74 6573 745f ..."2:ip13:test_ │ │ │ +00032f30: 686f 7374 6e61 6d65 343a 706f 7274 6931 hostname4:porti1 │ │ │ +00032f40: 3030 3065 6564 220a 0909 2237 3a70 6565 000eed"..."7:pee │ │ │ +00032f50: 7220 6964 3230 3a62 6262 6261 6261 6162 r id20:bbbbabaab │ │ │ +00032f60: 6162 6162 6162 6162 6162 6132 3a69 7031 abababababa2:ip1 │ │ │ +00032f70: 323a 616e 6f74 6865 725f 686f 7374 343a 2:another_host4: │ │ │ +00032f80: 706f 7274 6931 3030 3165 6565 6522 3b0a porti1001eeee";. │ │ │ +00032f90: 0965 7272 6f72 5f63 6f64 6520 6563 3b0a .error_code ec;. │ │ │ +00032fa0: 0961 7578 3a3a 7472 6163 6b65 725f 7265 .aux::tracker_re │ │ │ +00032fb0: 7370 6f6e 7365 2072 6573 7020 3d20 6175 sponse resp = au │ │ │ +00032fc0: 783a 3a70 6172 7365 5f74 7261 636b 6572 x::parse_tracker │ │ │ +00032fd0: 5f72 6573 706f 6e73 6528 7265 7370 6f6e _response(respon │ │ │ +00032fe0: 7365 0a09 092c 2065 632c 207b 7d2c 2073 se..., ec, {}, s │ │ │ +00032ff0: 6861 315f 6861 7368 2829 293b 0a0a 0954 ha1_hash());...T │ │ │ +00033000: 4553 545f 4551 5541 4c28 6563 2c20 6572 EST_EQUAL(ec, er │ │ │ +00033010: 726f 725f 636f 6465 2829 293b 0a09 5445 ror_code());..TE │ │ │ +00033020: 5354 5f45 5155 414c 2872 6573 702e 7065 ST_EQUAL(resp.pe │ │ │ +00033030: 6572 732e 7369 7a65 2829 2c20 3229 3b0a ers.size(), 2);. │ │ │ +00033040: 0969 6620 2872 6573 702e 7065 6572 732e .if (resp.peers. │ │ │ +00033050: 7369 7a65 2829 203d 3d20 3229 0a09 7b0a size() == 2)..{. │ │ │ +00033060: 0909 6175 783a 3a70 6565 725f 656e 7472 ..aux::peer_entr │ │ │ +00033070: 7920 636f 6e73 7426 616d 703b 2065 3020 y const& e0 │ │ │ +00033080: 3d20 7265 7370 2e70 6565 7273 5b30 5d3b = resp.peers[0]; │ │ │ +00033090: 0a09 0961 7578 3a3a 7065 6572 5f65 6e74 ...aux::peer_ent │ │ │ +000330a0: 7279 2063 6f6e 7374 2661 6d70 3b20 6531 ry const& e1 │ │ │ +000330b0: 203d 2072 6573 702e 7065 6572 735b 315d = resp.peers[1] │ │ │ +000330c0: 3b0a 0909 5445 5354 5f45 5155 414c 2865 ;...TEST_EQUAL(e │ │ │ +000330d0: 302e 686f 7374 6e61 6d65 2c20 2274 6573 0.hostname, "tes │ │ │ +000330e0: 745f 686f 7374 6e61 6d65 2229 3b0a 0909 t_hostname");... │ │ │ +000330f0: 5445 5354 5f45 5155 414c 2865 302e 706f TEST_EQUAL(e0.po │ │ │ +00033100: 7274 2c20 3130 3030 293b 0a09 0954 4553 rt, 1000);...TES │ │ │ +00033110: 545f 4551 5541 4c28 6530 2e70 6964 2c20 T_EQUAL(e0.pid, │ │ │ +00033120: 7065 6572 5f69 6428 2261 6161 6161 6161 peer_id("aaaaaaa │ │ │ +00033130: 6161 6161 6161 6161 6161 6161 6122 2929 aaaaaaaaaaaaa")) │ │ │ +00033140: 3b0a 0a09 0954 4553 545f 4551 5541 4c28 ;....TEST_EQUAL( │ │ │ +00033150: 6531 2e68 6f73 746e 616d 652c 2022 616e e1.hostname, "an │ │ │ +00033160: 6f74 6865 725f 686f 7374 2229 3b0a 0909 other_host");... │ │ │ +00033170: 5445 5354 5f45 5155 414c 2865 312e 706f TEST_EQUAL(e1.po │ │ │ +00033180: 7274 2c20 3130 3031 293b 0a09 0954 4553 rt, 1001);...TES │ │ │ +00033190: 545f 4551 5541 4c28 6531 2e70 6964 2c20 T_EQUAL(e1.pid, │ │ │ +000331a0: 7065 6572 5f69 6428 2262 6262 6261 6261 peer_id("bbbbaba │ │ │ +000331b0: 6162 6162 6162 6162 6162 6162 6122 2929 ababababababa")) │ │ │ +000331c0: 3b0a 097d 0a7d 0a0a 544f 5252 454e 545f ;..}.}..TORRENT_ │ │ │ +000331d0: 5445 5354 2870 6172 7365 5f70 6565 7273 TEST(parse_peers │ │ │ +000331e0: 3429 0a7b 0a09 6368 6172 2063 6f6e 7374 4).{..char const │ │ │ +000331f0: 2072 6573 706f 6e73 655b 5d20 3d20 2264 response[] = "d │ │ │ +00033200: 353a 7065 6572 7331 323a 5c78 3031 5c78 5:peers12:\x01\x │ │ │ +00033210: 3032 5c78 3033 5c78 3034 5c78 3330 5c78 02\x03\x04\x30\x │ │ │ +00033220: 3130 220a 0909 225c 7830 395c 7830 385c 10"..."\x09\x08\ │ │ │ +00033230: 7830 375c 7830 365c 7832 305c 7831 3022 x07\x06\x20\x10" │ │ │ +00033240: 2022 6522 3b0a 0965 7272 6f72 5f63 6f64 "e";..error_cod │ │ │ +00033250: 6520 6563 3b0a 3c2f 7072 653e 3c2f 7464 e ec;.relevance │ │ │ +00033290: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +000332a0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../test/test_tr │ │ │ +000332d0: 616e 7366 6572 2e63 7070 3a31 3633 3c2f ansfer.cpp:163these │ │ │ +000332f0: 2073 6574 7469 6e67 735f 7061 636b 2074 settings_pack t │ │ │ +00033300: 6573 7473 2062 656c 6f6e 6720 696e 2074 ests belong in t │ │ │ +00033310: 6865 6972 206f 776e 2074 6573 743c 2f74 heir own test

    these │ │ │ +00033370: 2073 6574 7469 6e67 735f 7061 636b 2074 settings_pack t │ │ │ +00033380: 6573 7473 2062 656c 6f6e 6720 696e 2074 ests belong in t │ │ │ +00033390: 6865 6972 206f 776e 2074 6573 743c 2f68 heir own test

    ../test/te │ │ │ +000333b0: 7374 5f74 7261 6e73 6665 722e 6370 703a st_transfer.cpp: │ │ │ +000333c0: 3136 333c 2f68 343e 3c70 7265 2073 7479 163

    .// to the tim
    │ │ │ +00033410: 6520 6974 2077 696c 6c20 7461 6b65 2074  e it will take t
    │ │ │ +00033420: 6f20 636f 6d70 6c65 7465 2074 6865 2074  o complete the t
    │ │ │ +00033430: 6573 740a 0970 6163 6b2e 7365 745f 696e  est..pack.set_in
    │ │ │ +00033440: 7428 7365 7474 696e 6773 5f70 6163 6b3a  t(settings_pack:
    │ │ │ +00033450: 3a6d 696e 5f72 6563 6f6e 6e65 6374 5f74  :min_reconnect_t
    │ │ │ +00033460: 696d 652c 2030 293b 0a09 7061 636b 2e73  ime, 0);..pack.s
    │ │ │ +00033470: 6574 5f69 6e74 2873 6574 7469 6e67 735f  et_int(settings_
    │ │ │ +00033480: 7061 636b 3a3a 7374 6f70 5f74 7261 636b  pack::stop_track
    │ │ │ +00033490: 6572 5f74 696d 656f 7574 2c20 3129 3b0a  er_timeout, 1);.
    │ │ │ +000334a0: 0970 6163 6b2e 7365 745f 626f 6f6c 2873  .pack.set_bool(s
    │ │ │ +000334b0: 6574 7469 6e67 735f 7061 636b 3a3a 616e  ettings_pack::an
    │ │ │ +000334c0: 6e6f 756e 6365 5f74 6f5f 616c 6c5f 7472  nounce_to_all_tr
    │ │ │ +000334d0: 6163 6b65 7273 2c20 7472 7565 293b 0a09  ackers, true);..
    │ │ │ +000334e0: 7061 636b 2e73 6574 5f62 6f6f 6c28 7365  pack.set_bool(se
    │ │ │ +000334f0: 7474 696e 6773 5f70 6163 6b3a 3a61 6e6e  ttings_pack::ann
    │ │ │ +00033500: 6f75 6e63 655f 746f 5f61 6c6c 5f74 6965  ounce_to_all_tie
    │ │ │ +00033510: 7273 2c20 7472 7565 293b 0a0a 092f 2f20  rs, true);...// 
    │ │ │ +00033520: 6d61 6b65 2073 7572 6520 7765 2061 6e6e  make sure we ann
    │ │ │ +00033530: 6f75 6e63 6520 746f 2062 6f74 6820 6874  ounce to both ht
    │ │ │ +00033540: 7470 2061 6e64 2075 6470 2074 7261 636b  tp and udp track
    │ │ │ +00033550: 6572 730a 0970 6163 6b2e 7365 745f 626f  ers..pack.set_bo
    │ │ │ +00033560: 6f6c 2873 6574 7469 6e67 735f 7061 636b  ol(settings_pack
    │ │ │ +00033570: 3a3a 7072 6566 6572 5f75 6470 5f74 7261  ::prefer_udp_tra
    │ │ │ +00033580: 636b 6572 732c 2066 616c 7365 293b 0a09  ckers, false);..
    │ │ │ +00033590: 7061 636b 2e73 6574 5f62 6f6f 6c28 7365  pack.set_bool(se
    │ │ │ +000335a0: 7474 696e 6773 5f70 6163 6b3a 3a65 6e61  ttings_pack::ena
    │ │ │ +000335b0: 626c 655f 6f75 7467 6f69 6e67 5f75 7470  ble_outgoing_utp
    │ │ │ +000335c0: 2c20 6661 6c73 6529 3b0a 0970 6163 6b2e  , false);..pack.
    │ │ │ +000335d0: 7365 745f 626f 6f6c 2873 6574 7469 6e67  set_bool(setting
    │ │ │ +000335e0: 735f 7061 636b 3a3a 656e 6162 6c65 5f69  s_pack::enable_i
    │ │ │ +000335f0: 6e63 6f6d 696e 675f 7574 702c 2066 616c  ncoming_utp, fal
    │ │ │ +00033600: 7365 293b 0a09 7061 636b 2e73 6574 5f62  se);..pack.set_b
    │ │ │ +00033610: 6f6f 6c28 7365 7474 696e 6773 5f70 6163  ool(settings_pac
    │ │ │ +00033620: 6b3a 3a65 6e61 626c 655f 6c73 642c 2066  k::enable_lsd, f
    │ │ │ +00033630: 616c 7365 293b 0a09 7061 636b 2e73 6574  alse);..pack.set
    │ │ │ +00033640: 5f62 6f6f 6c28 7365 7474 696e 6773 5f70  _bool(settings_p
    │ │ │ +00033650: 6163 6b3a 3a65 6e61 626c 655f 6e61 7470  ack::enable_natp
    │ │ │ +00033660: 6d70 2c20 6661 6c73 6529 3b0a 0970 6163  mp, false);..pac
    │ │ │ +00033670: 6b2e 7365 745f 626f 6f6c 2873 6574 7469  k.set_bool(setti
    │ │ │ +00033680: 6e67 735f 7061 636b 3a3a 656e 6162 6c65  ngs_pack::enable
    │ │ │ +00033690: 5f75 706e 702c 2066 616c 7365 293b 0a09  _upnp, false);..
    │ │ │ +000336a0: 7061 636b 2e73 6574 5f62 6f6f 6c28 7365  pack.set_bool(se
    │ │ │ +000336b0: 7474 696e 6773 5f70 6163 6b3a 3a65 6e61  ttings_pack::ena
    │ │ │ +000336c0: 626c 655f 6468 742c 2066 616c 7365 293b  ble_dht, false);
    │ │ │ +000336d0: 0a0a 0970 6163 6b2e 7365 745f 696e 7428  ...pack.set_int(
    │ │ │ +000336e0: 7365 7474 696e 6773 5f70 6163 6b3a 3a6f  settings_pack::o
    │ │ │ +000336f0: 7574 5f65 6e63 5f70 6f6c 6963 792c 2073  ut_enc_policy, s
    │ │ │ +00033700: 6574 7469 6e67 735f 7061 636b 3a3a 7065  ettings_pack::pe
    │ │ │ +00033710: 5f64 6973 6162 6c65 6429 3b0a 0970 6163  _disabled);..pac
    │ │ │ +00033720: 6b2e 7365 745f 696e 7428 7365 7474 696e  k.set_int(settin
    │ │ │ +00033730: 6773 5f70 6163 6b3a 3a69 6e5f 656e 635f  gs_pack::in_enc_
    │ │ │ +00033740: 706f 6c69 6379 2c20 7365 7474 696e 6773  policy, settings
    │ │ │ +00033750: 5f70 6163 6b3a 3a70 655f 6469 7361 626c  _pack::pe_disabl
    │ │ │ +00033760: 6564 293b 0a0a 0970 6163 6b2e 7365 745f  ed);...pack.set_
    │ │ │ +00033770: 626f 6f6c 2873 6574 7469 6e67 735f 7061  bool(settings_pa
    │ │ │ +00033780: 636b 3a3a 616c 6c6f 775f 6d75 6c74 6970  ck::allow_multip
    │ │ │ +00033790: 6c65 5f63 6f6e 6e65 6374 696f 6e73 5f70  le_connections_p
    │ │ │ +000337a0: 6572 5f69 702c 2066 616c 7365 293b 0a0a  er_ip, false);..
    │ │ │ +000337b0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .p │ │ │ +000337e0: 6163 6b2e 7365 745f 696e 7428 7365 7474 ack.set_int(sett │ │ │ +000337f0: 696e 6773 5f70 6163 6b3a 3a75 6e63 686f ings_pack::uncho │ │ │ +00033800: 6b65 5f73 6c6f 7473 5f6c 696d 6974 2c20 ke_slots_limit, │ │ │ +00033810: 3029 3b0a 3c2f 6469 763e 0973 6573 312e 0);.
    .ses1. │ │ │ +00033820: 6170 706c 795f 7365 7474 696e 6773 2870 apply_settings(p │ │ │ +00033830: 6163 6b29 3b0a 0954 4553 545f 4348 4543 ack);..TEST_CHEC │ │ │ +00033840: 4b28 7365 7331 2e67 6574 5f73 6574 7469 K(ses1.get_setti │ │ │ +00033850: 6e67 7328 292e 6765 745f 696e 7428 7365 ngs().get_int(se │ │ │ +00033860: 7474 696e 6773 5f70 6163 6b3a 3a75 6e63 ttings_pack::unc │ │ │ +00033870: 686f 6b65 5f73 6c6f 7473 5f6c 696d 6974 hoke_slots_limit │ │ │ +00033880: 2920 3d3d 2030 293b 0a0a 0970 6163 6b2e ) == 0);...pack. │ │ │ +00033890: 7365 745f 696e 7428 7365 7474 696e 6773 set_int(settings │ │ │ +000338a0: 5f70 6163 6b3a 3a75 6e63 686f 6b65 5f73 _pack::unchoke_s │ │ │ +000338b0: 6c6f 7473 5f6c 696d 6974 2c20 2d31 293b lots_limit, -1); │ │ │ +000338c0: 0a09 7365 7331 2e61 7070 6c79 5f73 6574 ..ses1.apply_set │ │ │ +000338d0: 7469 6e67 7328 7061 636b 293b 0a09 5445 tings(pack);..TE │ │ │ +000338e0: 5354 5f43 4845 434b 2873 6573 312e 6765 ST_CHECK(ses1.ge │ │ │ +000338f0: 745f 7365 7474 696e 6773 2829 2e67 6574 t_settings().get │ │ │ +00033900: 5f69 6e74 2873 6574 7469 6e67 735f 7061 _int(settings_pa │ │ │ +00033910: 636b 3a3a 756e 6368 6f6b 655f 736c 6f74 ck::unchoke_slot │ │ │ +00033920: 735f 6c69 6d69 7429 203d 3d20 2d31 293b s_limit) == -1); │ │ │ +00033930: 0a0a 0970 6163 6b2e 7365 745f 696e 7428 ...pack.set_int( │ │ │ +00033940: 7365 7474 696e 6773 5f70 6163 6b3a 3a75 settings_pack::u │ │ │ +00033950: 6e63 686f 6b65 5f73 6c6f 7473 5f6c 696d nchoke_slots_lim │ │ │ +00033960: 6974 2c20 3829 3b0a 0973 6573 312e 6170 it, 8);..ses1.ap │ │ │ +00033970: 706c 795f 7365 7474 696e 6773 2870 6163 ply_settings(pac │ │ │ +00033980: 6b29 3b0a 0954 4553 545f 4348 4543 4b28 k);..TEST_CHECK( │ │ │ +00033990: 7365 7331 2e67 6574 5f73 6574 7469 6e67 ses1.get_setting │ │ │ +000339a0: 7328 292e 6765 745f 696e 7428 7365 7474 s().get_int(sett │ │ │ +000339b0: 696e 6773 5f70 6163 6b3a 3a75 6e63 686f ings_pack::uncho │ │ │ +000339c0: 6b65 5f73 6c6f 7473 5f6c 696d 6974 2920 ke_slots_limit) │ │ │ +000339d0: 3d3d 2038 293b 0a0a 0973 6573 322e 6170 == 8);...ses2.ap │ │ │ +000339e0: 706c 795f 7365 7474 696e 6773 2870 6163 ply_settings(pac │ │ │ +000339f0: 6b29 3b0a 0a09 746f 7272 656e 745f 6861 k);...torrent_ha │ │ │ +00033a00: 6e64 6c65 2074 6f72 313b 0a09 746f 7272 ndle tor1;..torr │ │ │ +00033a10: 656e 745f 6861 6e64 6c65 2074 6f72 323b ent_handle tor2; │ │ │ +00033a20: 0a0a 0969 6e74 2070 6965 6365 5f73 697a ...int piece_siz │ │ │ +00033a30: 6520 3d20 3332 202a 2031 3032 343b 0a09 e = 32 * 1024;.. │ │ │ +00033a40: 696e 7420 7469 6d65 6f75 7420 3d20 3130 int timeout = 10 │ │ │ +00033a50: 3b0a 0969 6620 2866 6c61 6773 2026 616d ;..if (flags &am │ │ │ +00033a60: 703b 206c 6172 6765 5f70 6965 6365 5f73 p; large_piece_s │ │ │ +00033a70: 697a 6529 0a09 7b0a 0909 7069 6563 655f ize)..{...piece_ │ │ │ +00033a80: 7369 7a65 203d 2031 3032 3420 2a20 3130 size = 1024 * 10 │ │ │ +00033a90: 3234 3b0a 0909 7469 6d65 6f75 7420 3d20 24;...timeout = │ │ │ +00033aa0: 3930 3b0a 097d 0a0a 0963 7265 6174 655f 90;..}...create_ │ │ │ +00033ab0: 6469 7265 6374 6f72 7928 2274 6d70 315f directory("tmp1_ │ │ │ +00033ac0: 7472 616e 7366 6572 222c 2065 6329 3b0a transfer", ec);. │ │ │ +00033ad0: 0973 7464 3a3a 6f66 7374 7265 616d 2066 .std::ofstream f │ │ │ +00033ae0: 696c 6528 2274 6d70 315f 7472 616e 7366 ile("tmp1_transf │ │ │ +00033af0: 6572 2f74 656d 706f 7261 7279 2229 3b0a er/temporary");. │ │ │ +00033b00: 0961 6464 5f74 6f72 7265 6e74 5f70 6172 .add_torrent_par │ │ │ +00033b10: 616d 7320 6174 7020 3d20 3a3a 6372 6561 ams atp = ::crea │ │ │ +00033b20: 7465 5f74 6f72 7265 6e74 2826 616d 703b te_torrent(& │ │ │ +00033b30: 6669 6c65 2c20 2274 656d 706f 7261 7279 file, "temporary │ │ │ +00033b40: 222c 2070 6965 6365 5f73 697a 652c 2031 ", piece_size, 1 │ │ │ +00033b50: 332c 2066 616c 7365 0a09 092c 207b 7d2c 3, false..., {}, │ │ │ +00033b60: 2022 222c 2062 6f6f 6c28 666c 6167 7320 "", bool(flags │ │ │ +00033b70: 2661 6d70 3b20 6261 645f 7631 5f68 6173 & bad_v1_has │ │ │ +00033b80: 6865 7329 293b 0a09 6669 6c65 2e63 6c6f hes));..file.clo │ │ │ +00033b90: 7365 2829 3b0a 0a3c 2f70 7265 3e3c 2f74 se();..
    relevanc │ │ │ +00033bd0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0
    ../test/test_b │ │ │ +00033c10: 616e 6477 6964 7468 5f6c 696d 6974 6572 andwidth_limiter │ │ │ +00033c20: 2e63 7070 3a31 3430 3c2f 613e 3c2f 7464 .cpp:140fix these w │ │ │ +00033c40: 6172 6e69 6e67 733c 2f74 643e 3c2f 7472 arnings

    fix these w │ │ │ +00033ca0: 6172 6e69 6e67 733c 2f68 323e 3c68 343e arnings

    │ │ │ +00033cb0: 2e2e 2f74 6573 742f 7465 7374 5f62 616e ../test/test_ban │ │ │ +00033cc0: 6477 6964 7468 5f6c 696d 6974 6572 2e63 dwidth_limiter.c │ │ │ +00033cd0: 7070 3a31 3430 3c2f 6834 3e3c 7072 6520 pp:140

    }..void do_
    │ │ │ +00033d20: 6368 616e 6765 5f70 6565 725f 7261 7465  change_peer_rate
    │ │ │ +00033d30: 2863 6f6e 6e65 6374 696f 6e73 5f74 2661  (connections_t&a
    │ │ │ +00033d40: 6d70 3b20 762c 2069 6e74 206c 696d 6974  mp; v, int limit
    │ │ │ +00033d50: 290a 7b0a 0973 7461 7469 6320 696e 7420  ).{..static int 
    │ │ │ +00033d60: 636f 756e 7420 3d20 3130 3b0a 092d 2d63  count = 10;..--c
    │ │ │ +00033d70: 6f75 6e74 3b0a 0969 6620 2863 6f75 6e74  ount;..if (count
    │ │ │ +00033d80: 203d 3d20 3029 0a09 7b0a 0909 7374 643a   == 0)..{...std:
    │ │ │ +00033d90: 3a66 6f72 5f65 6163 6828 762e 6265 6769  :for_each(v.begi
    │ │ │ +00033da0: 6e28 292c 2076 2e65 6e64 2829 0a09 0909  n(), v.end()....
    │ │ │ +00033db0: 2c20 7374 643a 3a62 696e 6428 2661 6d70  , std::bind(&
    │ │ │ +00033dc0: 3b70 6565 725f 636f 6e6e 6563 7469 6f6e  ;peer_connection
    │ │ │ +00033dd0: 3a3a 7468 726f 7474 6c65 2c20 5f31 2c20  ::throttle, _1, 
    │ │ │ +00033de0: 6c69 6d69 7429 293b 0a09 0972 6574 7572  limit));...retur
    │ │ │ +00033df0: 6e3b 0a09 7d0a 0a09 696e 7420 6320 3d20  n;..}...int c = 
    │ │ │ +00033e00: 636f 756e 743b 0a09 666f 7220 2863 6f6e  count;..for (con
    │ │ │ +00033e10: 6e65 6374 696f 6e73 5f74 3a3a 6974 6572  nections_t::iter
    │ │ │ +00033e20: 6174 6f72 2069 203d 2076 2e62 6567 696e  ator i = v.begin
    │ │ │ +00033e30: 2829 3b20 6920 213d 2076 2e65 6e64 2829  (); i != v.end()
    │ │ │ +00033e40: 3b20 2b2b 692c 202b 2b63 290a 0909 692d  ; ++i, ++c)...i-
    │ │ │ +00033e50: 2667 743b 6765 7428 292d 2667 743b 7468  >get()->th
    │ │ │ +00033e60: 726f 7474 6c65 286c 696d 6974 202b 206c  rottle(limit + l
    │ │ │ +00033e70: 696d 6974 202f 2032 202a 2028 2863 2026  imit / 2 * ((c &
    │ │ │ +00033e80: 616d 703b 2031 293f 2d31 3a31 2929 3b0a  amp; 1)?-1:1));.
    │ │ │ +00033e90: 7d0a 0a73 7461 7469 6320 766f 6964 206e  }..static void n
    │ │ │ +00033ea0: 6f70 2829 207b 7d0a 0a3c 6469 7620 7374  op() {}..
    #if defin │ │ │ +00033ee0: 6564 205f 5f63 6c61 6e67 5f5f 2026 616d ed __clang__ &am │ │ │ +00033ef0: 703b 2661 6d70 3b20 5f5f 636c 616e 675f p;& __clang_ │ │ │ +00033f00: 6d61 6a6f 725f 5f20 2667 743b 3d20 3130 major__ >= 10 │ │ │ +00033f10: 0a3c 2f64 6976 3e23 7072 6167 6d61 2063 .
    #pragma c │ │ │ +00033f20: 6c61 6e67 2064 6961 676e 6f73 7469 6320 lang diagnostic │ │ │ +00033f30: 7075 7368 0a23 7072 6167 6d61 2063 6c61 push.#pragma cla │ │ │ +00033f40: 6e67 2064 6961 676e 6f73 7469 6320 6967 ng diagnostic ig │ │ │ +00033f50: 6e6f 7265 6420 222d 5769 6d70 6c69 6369 nored "-Wimplici │ │ │ +00033f60: 742d 696e 742d 666c 6f61 742d 636f 6e76 t-int-float-conv │ │ │ +00033f70: 6572 7369 6f6e 220a 2365 6e64 6966 0a0a ersion".#endif.. │ │ │ +00033f80: 766f 6964 2072 756e 5f74 6573 7428 636f void run_test(co │ │ │ +00033f90: 6e6e 6563 7469 6f6e 735f 7426 616d 703b nnections_t& │ │ │ +00033fa0: 2076 0a09 2c20 6175 783a 3a62 616e 6477 v.., aux::bandw │ │ │ +00033fb0: 6964 7468 5f6d 616e 6167 6572 2661 6d70 idth_manager& │ │ │ +00033fc0: 3b20 6d61 6e61 6765 720a 092c 2073 7464 ; manager.., std │ │ │ +00033fd0: 3a3a 6675 6e63 7469 6f6e 266c 743b 766f ::function<vo │ │ │ +00033fe0: 6964 2829 2667 743b 2066 203d 2026 616d id()> f = &am │ │ │ +00033ff0: 703b 6e6f 7029 0a7b 0a09 7374 643a 3a63 p;nop).{..std::c │ │ │ +00034000: 6f75 7420 266c 743b 266c 743b 2022 2d2d out << "-- │ │ │ +00034010: 2d2d 2d2d 2d2d 2d2d 2d2d 2d22 2026 6c74 -----------" < │ │ │ +00034020: 3b26 6c74 3b20 7374 643a 3a65 6e64 6c3b ;< std::endl; │ │ │ +00034030: 0a0a 0973 7464 3a3a 666f 725f 6561 6368 ...std::for_each │ │ │ +00034040: 2876 2e62 6567 696e 2829 2c20 762e 656e (v.begin(), v.en │ │ │ +00034050: 6428 290a 0909 2c20 7374 643a 3a62 696e d()..., std::bin │ │ │ +00034060: 6428 2661 6d70 3b70 6565 725f 636f 6e6e d(&peer_conn │ │ │ +00034070: 6563 7469 6f6e 3a3a 7374 6172 742c 205f ection::start, _ │ │ │ +00034080: 3129 293b 0a0a 096c 743a 3a61 7578 3a3a 1));...lt::aux:: │ │ │ +00034090: 7365 7373 696f 6e5f 7365 7474 696e 6773 session_settings │ │ │ +000340a0: 2073 3b0a 0969 6e74 2074 6963 6b5f 696e s;..int tick_in │ │ │ +000340b0: 7465 7276 616c 203d 2073 2e67 6574 5f69 terval = s.get_i │ │ │ +000340c0: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ +000340d0: 3a3a 7469 636b 5f69 6e74 6572 7661 6c29 ::tick_interval) │ │ │ +000340e0: 3b0a 0a09 666f 7220 2869 6e74 2069 203d ;...for (int i = │ │ │ +000340f0: 2030 3b20 6920 266c 743b 2069 6e74 2873 0; i < int(s │ │ │ +00034100: 616d 706c 655f 7469 6d65 202a 2031 3030 ample_time * 100 │ │ │ +00034110: 3020 2f20 7469 636b 5f69 6e74 6572 7661 0 / tick_interva │ │ │ +00034120: 6c29 3b20 2b2b 6929 0a09 7b0a 0909 6d61 l); ++i)..{...ma │ │ │ +00034130: 6e61 6765 722e 7570 6461 7465 5f71 756f nager.update_quo │ │ │ +00034140: 7461 7328 6d69 6c6c 6973 6563 6f6e 6473 tas(milliseconds │ │ │ +00034150: 2874 6963 6b5f 696e 7465 7276 616c 2929 (tick_interval)) │ │ │ +00034160: 3b0a 0909 6966 2028 2869 2025 2031 3529 ;...if ((i % 15) │ │ │ +00034170: 203d 3d20 3029 2066 2829 3b0a 097d 0a7d == 0) f();..}.} │ │ │ +00034180: 0a0a 626f 6f6c 2063 6c6f 7365 5f74 6f28 ..bool close_to( │ │ │ +00034190: 666c 6f61 7420 636f 6e73 7420 7661 6c2c float const val, │ │ │ +000341a0: 2066 6c6f 6174 2063 6f6e 7374 2063 6f6d float const com │ │ │ +000341b0: 702c 2066 6c6f 6174 2063 6f6e 7374 2065 p, float const e │ │ │ +000341c0: 7272 290a 7b0a 0972 6574 7572 6e20 7374 rr).{..return st │ │ │ +000341d0: 643a 3a61 6273 2876 616c 202d 2063 6f6d d::abs(val - com │ │ │ +000341e0: 7029 2026 6c74 3b3d 2065 7272 3b0a 7d0a p) <= err;.}. │ │ │ +000341f0: 0a76 6f69 6420 7370 6177 6e5f 636f 6e6e .void spawn_conn │ │ │ +00034200: 6563 7469 6f6e 7328 636f 6e6e 6563 7469 ections(connecti │ │ │ +00034210: 6f6e 735f 7426 616d 703b 2076 2c20 6175 ons_t& v, au │ │ │ +00034220: 783a 3a62 616e 6477 6964 7468 5f6d 616e x::bandwidth_man │ │ │ +00034230: 6167 6572 2661 6d70 3b20 6277 6d0a 092c ager& bwm.., │ │ │ +00034240: 2061 7578 3a3a 6261 6e64 7769 6474 685f aux::bandwidth_ │ │ │ +00034250: 6368 616e 6e65 6c26 616d 703b 2062 7763 channel& bwc │ │ │ +00034260: 2c20 696e 7420 6e75 6d2c 2063 6861 7220 , int num, char │ │ │ +00034270: 636f 6e73 742a 2070 7265 6669 7829 0a3c const* prefix).< │ │ │ +00034280: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00034290: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +000342a0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +000342b0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000342c0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../tes │ │ │ +000342f0: 742f 7465 7374 5f70 6565 725f 6c69 7374 t/test_peer_list │ │ │ +00034300: 2e63 7070 3a31 3236 393c 2f61 3e3c 2f74 .cpp:1269test erasi │ │ │ +00034320: 6e67 2070 6565 7273 3c2f 7464 3e3c 2f74 ng peers

    test erasi │ │ │ +00034380: 6e67 2070 6565 7273 3c2f 6832 3e3c 6834 ng peers

    ../test/test_pe │ │ │ +000343a0: 6572 5f6c 6973 742e 6370 703a 3132 3639 er_list.cpp:1269 │ │ │ +000343b0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +000343f0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +00034400: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +00034410: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +00034420: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +00034430: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ +00034460: 742f 7465 7374 5f70 6565 725f 6c69 7374  t/test_peer_list
    │ │ │ +00034470: 2e63 7070 3a31 3237 303c 2f61 3e3c 2f74  .cpp:1270test updat
    │ │ │ +00034490: 655f 7065 6572 5f70 6f72 7420 7769 7468  e_peer_port with
    │ │ │ +000344a0: 2061 6c6c 6f77 5f6d 756c 7469 706c 655f   allow_multiple_
    │ │ │ +000344b0: 636f 6e6e 6563 7469 6f6e 735f 7065 725f  connections_per_
    │ │ │ +000344c0: 6970 2061 6e64 2077 6974 686f 7574 3c2f  ip and without

    test │ │ │ +00034520: 2075 7064 6174 655f 7065 6572 5f70 6f72 update_peer_por │ │ │ +00034530: 7420 7769 7468 2061 6c6c 6f77 5f6d 756c t with allow_mul │ │ │ +00034540: 7469 706c 655f 636f 6e6e 6563 7469 6f6e tiple_connection │ │ │ +00034550: 735f 7065 725f 6970 2061 6e64 2077 6974 s_per_ip and wit │ │ │ +00034560: 686f 7574 3c2f 6832 3e3c 6834 3e2e 2e2f hout

    ../ │ │ │ +00034570: 7465 7374 2f74 6573 745f 7065 6572 5f6c test/test_peer_l │ │ │ +00034580: 6973 742e 6370 703a 3132 3730 3c2f 6834 ist.cpp:1270

    rele
    │ │ │ +00034600: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ +00034640: 7374 5f70 6565 725f 6c69 7374 2e63 7070  st_peer_list.cpp
    │ │ │ +00034650: 3a31 3237 313c 2f61 3e3c 2f74 643e 3c74  :1271test add i2p p
    │ │ │ +00034670: 6565 7273 3c2f 7464 3e3c 2f74 723e 3c74  eerstest add i2p p
    │ │ │ +000346d0: 6565 7273 3c2f 6832 3e3c 6834 3e2e 2e2f  eers

    ../ │ │ │ +000346e0: 7465 7374 2f74 6573 745f 7065 6572 5f6c test/test_peer_l │ │ │ +000346f0: 6973 742e 6370 703a 3132 3731 3c2f 6834 ist.cpp:1271

    rele
    │ │ │ +00034770: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ +000347b0: 7374 5f70 6565 725f 6c69 7374 2e63 7070  st_peer_list.cpp
    │ │ │ +000347c0: 3a31 3237 323c 2f61 3e3c 2f74 643e 3c74  :1272test allow_i2p
    │ │ │ +000347e0: 5f6d 6978 6564 3c2f 7464 3e3c 2f74 723e  _mixed
    │ │ │ +000347f0: 3c74 7220 6964 3d22 3131 3422 2073 7479  
    │ │ │ +00034820: 3c74 6420 636f 6c73 7061 6e3d 2233 223e  
    │ │ │ +00034830: 3c68 323e 7465 7374 2061 6c6c 6f77 5f69  

    test allow_i │ │ │ +00034840: 3270 5f6d 6978 6564 3c2f 6832 3e3c 6834 2p_mixed

    ../test/test_pe │ │ │ +00034860: 6572 5f6c 6973 742e 6370 703a 3132 3732 er_list.cpp:1272 │ │ │ +00034870: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +000348b0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +000348c0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +000348d0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +000348e0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +000348f0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ +00034920: 742f 7465 7374 5f70 6565 725f 6c69 7374  t/test_peer_list
    │ │ │ +00034930: 2e63 7070 3a31 3237 333c 2f61 3e3c 2f74  .cpp:1273test inser
    │ │ │ +00034950: 745f 7065 6572 2066 6169 6c69 6e67 2077  t_peer failing w
    │ │ │ +00034960: 6974 6820 616c 6c20 6572 726f 7220 636f  ith all error co
    │ │ │ +00034970: 6e64 6974 696f 6e73 3c2f 7464 3e3c 2f74  nditions

    test inser │ │ │ +000349d0: 745f 7065 6572 2066 6169 6c69 6e67 2077 t_peer failing w │ │ │ +000349e0: 6974 6820 616c 6c20 6572 726f 7220 636f ith all error co │ │ │ +000349f0: 6e64 6974 696f 6e73 3c2f 6832 3e3c 6834 nditions

    ../test/test_pe │ │ │ +00034a10: 6572 5f6c 6973 742e 6370 703a 3132 3733 er_list.cpp:1273 │ │ │ +00034a20: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +00034a60: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +00034a70: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +00034a80: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +00034a90: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +00034aa0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ +00034ad0: 742f 7465 7374 5f70 6565 725f 6c69 7374  t/test_peer_list
    │ │ │ +00034ae0: 2e63 7070 3a31 3237 343c 2f61 3e3c 2f74  .cpp:1274test IPv6<
    │ │ │ +00034b00: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d  /td>

    tes │ │ │ +00034b50: 7420 4950 7636 3c2f 6832 3e3c 6834 3e2e t IPv6

    . │ │ │ +00034b60: 2e2f 7465 7374 2f74 6573 745f 7065 6572 ./test/test_peer │ │ │ +00034b70: 5f6c 6973 742e 6370 703a 3132 3734 3c2f _list.cpp:1274

    re │ │ │ +00034bf0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ +00034c30: 7465 7374 5f70 6565 725f 6c69 7374 2e63 test_peer_list.c │ │ │ +00034c40: 7070 3a31 3237 353c 2f61 3e3c 2f74 643e pp:1275 │ │ │ +00034c50: 3c74 643e 7465 7374 2063 6f6e 6e65 6374 test connect │ │ │ +00034c60: 5f74 6f5f 7065 6572 2829 2066 6169 6c69 _to_peer() faili │ │ │ +00034c70: 6e67 3c2f 7464 3e3c 2f74 723e 3c74 7220 ng

    │ │ │ +00034cc0: 7465 7374 2063 6f6e 6e65 6374 5f74 6f5f test connect_to_ │ │ │ +00034cd0: 7065 6572 2829 2066 6169 6c69 6e67 3c2f peer() failing

    ../test/t │ │ │ +00034cf0: 6573 745f 7065 6572 5f6c 6973 742e 6370 est_peer_list.cp │ │ │ +00034d00: 703a 3132 3735 3c2f 6834 3e3c 7072 6520 p:1275

    
    │ │ │ +00034d50: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ +00034d80: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ +00034d90: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ +00034da0: 7074 3a65 7870 616e 6428 3131 3829 223e  pt:expand(118)">
    │ │ │ +00034db0: 2e2e 2f74 6573 742f 7465 7374 5f70 6565  ../test/test_pee
    │ │ │ +00034dc0: 725f 6c69 7374 2e63 7070 3a31 3237 363c  r_list.cpp:1276<
    │ │ │ +00034dd0: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374  /a>test
    │ │ │ +00034de0: 2063 6f6e 6e65 6374 696f 6e5f 636c 6f73   connection_clos
    │ │ │ +00034df0: 6564 3c2f 7464 3e3c 2f74 723e 3c74 7220  ed

    │ │ │ +00034e40: 7465 7374 2063 6f6e 6e65 6374 696f 6e5f test connection_ │ │ │ +00034e50: 636c 6f73 6564 3c2f 6832 3e3c 6834 3e2e closed

    . │ │ │ +00034e60: 2e2f 7465 7374 2f74 6573 745f 7065 6572 ./test/test_peer │ │ │ +00034e70: 5f6c 6973 742e 6370 703a 3132 3736 3c2f _list.cpp:1276

    re │ │ │ +00034ef0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ +00034f30: 7465 7374 5f70 6565 725f 6c69 7374 2e63 test_peer_list.c │ │ │ +00034f40: 7070 3a31 3237 373c 2f61 3e3c 2f74 643e pp:1277 │ │ │ +00034f50: 3c74 643e 636f 6e6e 6563 7420 6361 6e64 connect cand │ │ │ +00034f60: 6964 6174 6573 2072 6563 616c 6375 6c61 idates recalcula │ │ │ +00034f70: 7469 6f6e 2077 6865 6e20 696e 6372 656d tion when increm │ │ │ +00034f80: 656e 7469 6e67 2066 6169 6c63 6f75 6e74 enting failcount │ │ │ +00034f90: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    co │ │ │ +00034fe0: 6e6e 6563 7420 6361 6e64 6964 6174 6573 nnect candidates │ │ │ +00034ff0: 2072 6563 616c 6375 6c61 7469 6f6e 2077 recalculation w │ │ │ +00035000: 6865 6e20 696e 6372 656d 656e 7469 6e67 hen incrementing │ │ │ +00035010: 2066 6169 6c63 6f75 6e74 3c2f 6832 3e3c failcount

    < │ │ │ +00035020: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +00035030: 7065 6572 5f6c 6973 742e 6370 703a 3132 peer_list.cpp:12 │ │ │ +00035040: 3737 3c2f 6834 3e3c 7072 6520 7374 796c 77

    relevance 
    │ │ │ +000350c0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ +000350f0: 6573 742f 7465 7374 5f66 6c61 6773 2e63  est/test_flags.c
    │ │ │ +00035100: 7070 3a31 3332 3c2f 613e 3c2f 7464 3e3c  pp:132<
    │ │ │ +00035110: 7464 3e63 6861 6e67 6520 746f 2061 2064  td>change to a d
    │ │ │ +00035120: 6966 6665 7265 6e74 2074 6573 7420 7365  ifferent test se
    │ │ │ +00035130: 7475 702e 2063 7572 7265 6e74 6c79 2061  tup. currently a
    │ │ │ +00035140: 6c77 6179 7320 7061 7573 6564 2e20 7465  lways paused. te
    │ │ │ +00035150: 7374 5f73 6574 5f61 6674 6572 5f61 6464  st_set_after_add
    │ │ │ +00035160: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a  (torrent_flags::
    │ │ │ +00035170: 7061 7573 6564 293b 2074 6573 745f 756e  paused); test_un
    │ │ │ +00035180: 7365 745f 6166 7465 725f 6164 6428 746f  set_after_add(to
    │ │ │ +00035190: 7272 656e 745f 666c 6167 733a 3a70 6175  rrent_flags::pau
    │ │ │ +000351a0: 7365 6429 3b3c 2f74 643e 3c2f 7472 3e3c  sed);<
    │ │ │ +000351b0: 7472 2069 643d 2231 3230 2220 7374 796c  tr id="120" styl
    │ │ │ +000351c0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65  e="display: none
    │ │ │ +000351d0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c  ;" colspan="3"><
    │ │ │ +000351e0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c  td colspan="3"><
    │ │ │ +000351f0: 6832 3e63 6861 6e67 6520 746f 2061 2064  h2>change to a d
    │ │ │ +00035200: 6966 6665 7265 6e74 2074 6573 7420 7365  ifferent test se
    │ │ │ +00035210: 7475 702e 2063 7572 7265 6e74 6c79 2061  tup. currently a
    │ │ │ +00035220: 6c77 6179 7320 7061 7573 6564 2e0a 7465  lways paused..te
    │ │ │ +00035230: 7374 5f73 6574 5f61 6674 6572 5f61 6464  st_set_after_add
    │ │ │ +00035240: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a  (torrent_flags::
    │ │ │ +00035250: 7061 7573 6564 293b 0a74 6573 745f 756e  paused);.test_un
    │ │ │ +00035260: 7365 745f 6166 7465 725f 6164 6428 746f  set_after_add(to
    │ │ │ +00035270: 7272 656e 745f 666c 6167 733a 3a70 6175  rrent_flags::pau
    │ │ │ +00035280: 7365 6429 3b3c 2f68 323e 3c68 343e 2e2e  sed);

    .. │ │ │ +00035290: 2f74 6573 742f 7465 7374 5f66 6c61 6773 /test/test_flags │ │ │ +000352a0: 2e63 7070 3a31 3332 3c2f 6834 3e3c 7072 .cpp:132

    {..// sha │ │ │ +000352f0: 7265 2d6d 6f64 650a 0974 6573 745f 6164 re-mode..test_ad │ │ │ +00035300: 645f 616e 645f 6765 745f 666c 6167 7328 d_and_get_flags( │ │ │ +00035310: 746f 7272 656e 745f 666c 6167 733a 3a73 torrent_flags::s │ │ │ +00035320: 6861 7265 5f6d 6f64 6529 3b0a 0974 6573 hare_mode);..tes │ │ │ +00035330: 745f 7365 745f 6166 7465 725f 6164 6428 t_set_after_add( │ │ │ +00035340: 746f 7272 656e 745f 666c 6167 733a 3a73 torrent_flags::s │ │ │ +00035350: 6861 7265 5f6d 6f64 6529 3b0a 0974 6573 hare_mode);..tes │ │ │ +00035360: 745f 756e 7365 745f 6166 7465 725f 6164 t_unset_after_ad │ │ │ +00035370: 6428 746f 7272 656e 745f 666c 6167 733a d(torrent_flags: │ │ │ +00035380: 3a73 6861 7265 5f6d 6f64 6529 3b0a 7d0a :share_mode);.}. │ │ │ +00035390: 2365 6e64 6966 0a0a 544f 5252 454e 545f #endif..TORRENT_ │ │ │ +000353a0: 5445 5354 2866 6c61 675f 6170 706c 795f TEST(flag_apply_ │ │ │ +000353b0: 6970 5f66 696c 7465 7229 0a7b 0a09 2f2f ip_filter).{..// │ │ │ +000353c0: 2061 7070 6c79 2d69 702d 6669 6c74 6572 apply-ip-filter │ │ │ +000353d0: 0a09 7465 7374 5f61 6464 5f61 6e64 5f67 ..test_add_and_g │ │ │ +000353e0: 6574 5f66 6c61 6773 2874 6f72 7265 6e74 et_flags(torrent │ │ │ +000353f0: 5f66 6c61 6773 3a3a 6170 706c 795f 6970 _flags::apply_ip │ │ │ +00035400: 5f66 696c 7465 7229 3b0a 0974 6573 745f _filter);..test_ │ │ │ +00035410: 7365 745f 6166 7465 725f 6164 6428 746f set_after_add(to │ │ │ +00035420: 7272 656e 745f 666c 6167 733a 3a61 7070 rrent_flags::app │ │ │ +00035430: 6c79 5f69 705f 6669 6c74 6572 293b 0a09 ly_ip_filter);.. │ │ │ +00035440: 7465 7374 5f75 6e73 6574 5f61 6674 6572 test_unset_after │ │ │ +00035450: 5f61 6464 2874 6f72 7265 6e74 5f66 6c61 _add(torrent_fla │ │ │ +00035460: 6773 3a3a 6170 706c 795f 6970 5f66 696c gs::apply_ip_fil │ │ │ +00035470: 7465 7229 3b0a 7d0a 0a54 4f52 5245 4e54 ter);.}..TORRENT │ │ │ +00035480: 5f54 4553 5428 666c 6167 5f70 6175 7365 _TEST(flag_pause │ │ │ +00035490: 6429 0a7b 0a09 2f2f 2070 6175 7365 640a d).{..// paused. │ │ │ +000354a0: 0974 6573 745f 6164 645f 616e 645f 6765 .test_add_and_ge │ │ │ +000354b0: 745f 666c 6167 7328 746f 7272 656e 745f t_flags(torrent_ │ │ │ +000354c0: 666c 6167 733a 3a70 6175 7365 6429 3b0a flags::paused);. │ │ │ +000354d0: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    }. │ │ │ +00035500: 3c2f 6469 763e 0a54 4f52 5245 4e54 5f54
    .TORRENT_T │ │ │ +00035510: 4553 5428 666c 6167 5f61 7574 6f5f 6d61 EST(flag_auto_ma │ │ │ +00035520: 6e61 6765 6429 0a7b 0a09 2f2f 2061 7574 naged).{..// aut │ │ │ +00035530: 6f2d 6d61 6e61 6765 640a 0974 6573 745f o-managed..test_ │ │ │ +00035540: 6164 645f 616e 645f 6765 745f 666c 6167 add_and_get_flag │ │ │ +00035550: 7328 746f 7272 656e 745f 666c 6167 733a s(torrent_flags: │ │ │ +00035560: 3a61 7574 6f5f 6d61 6e61 6765 6429 3b0a :auto_managed);. │ │ │ +00035570: 0974 6573 745f 7365 745f 6166 7465 725f .test_set_after_ │ │ │ +00035580: 6164 6428 746f 7272 656e 745f 666c 6167 add(torrent_flag │ │ │ +00035590: 733a 3a61 7574 6f5f 6d61 6e61 6765 6429 s::auto_managed) │ │ │ +000355a0: 3b0a 0974 6573 745f 756e 7365 745f 6166 ;..test_unset_af │ │ │ +000355b0: 7465 725f 6164 6428 746f 7272 656e 745f ter_add(torrent_ │ │ │ +000355c0: 666c 6167 733a 3a61 7574 6f5f 6d61 6e61 flags::auto_mana │ │ │ +000355d0: 6765 6429 3b0a 7d0a 0a2f 2f20 7375 7065 ged);.}..// supe │ │ │ +000355e0: 7220 7365 6564 696e 6720 6d6f 6465 2069 r seeding mode i │ │ │ +000355f0: 7320 6175 746f 6d61 7469 6361 6c6c 7920 s automatically │ │ │ +00035600: 7475 726e 6564 206f 6666 2069 6620 7765 turned off if we │ │ │ +00035610: 2772 6520 6e6f 7420 6120 7365 6564 0a2f 're not a seed./ │ │ │ +00035620: 2f20 7369 6e63 6520 7468 6520 706f 7369 / since the posi │ │ │ +00035630: 785f 6469 736b 5f69 6f20 6973 206e 6f74 x_disk_io is not │ │ │ +00035640: 2074 6872 6561 6465 642c 2074 6869 7320 threaded, this │ │ │ +00035650: 7769 6c6c 2068 6170 7065 6e20 696d 6d65 will happen imme │ │ │ +00035660: 6469 6174 656c 790a 2369 6620 544f 5252 diately.#if TORR │ │ │ +00035670: 454e 545f 4841 5645 5f4d 4d41 500a 2369 ENT_HAVE_MMAP.#i │ │ │ +00035680: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +00035690: 5341 424c 455f 5355 5045 5253 4545 4449 SABLE_SUPERSEEDI │ │ │ +000356a0: 4e47 0a54 4f52 5245 4e54 5f54 4553 5428 NG.TORRENT_TEST( │ │ │ +000356b0: 666c 6167 5f73 7570 6572 5f73 6565 6469 flag_super_seedi │ │ │ +000356c0: 6e67 290a 7b0a 092f 2f20 7375 7065 722d ng).{..// super- │ │ │ +000356d0: 7365 6564 696e 670a 0974 6573 745f 6164 seeding..test_ad │ │ │ +000356e0: 645f 616e 645f 6765 745f 666c 6167 7328 d_and_get_flags( │ │ │ +000356f0: 746f 7272 656e 745f 666c 6167 733a 3a73 torrent_flags::s │ │ │ +00035700: 7570 6572 5f73 6565 6469 6e67 293b 0a09 uper_seeding);.. │ │ │ +00035710: 7465 7374 5f75 6e73 6574 5f61 6674 6572 test_unset_after │ │ │ +00035720: 5f61 6464 2874 6f72 7265 6e74 5f66 6c61 _add(torrent_fla │ │ │ +00035730: 6773 3a3a 7375 7065 725f 7365 6564 696e gs::super_seedin │ │ │ +00035740: 6729 3b0a 0974 6573 745f 7365 745f 6166 g);..test_set_af │ │ │ +00035750: 7465 725f 6164 6428 746f 7272 656e 745f ter_add(torrent_ │ │ │ +00035760: 666c 6167 733a 3a73 7570 6572 5f73 6565 flags::super_see │ │ │ +00035770: 6469 6e67 293b 0a7d 0a23 656e 6469 660a ding);.}.#endif. │ │ │ +00035780: 2365 6e64 6966 0a0a 544f 5252 454e 545f #endif..TORRENT_ │ │ │ +00035790: 5445 5354 2866 6c61 675f 7365 7175 656e TEST(flag_sequen │ │ │ +000357a0: 7469 616c 5f64 6f77 6e6c 6f61 6429 0a7b tial_download).{ │ │ │ +000357b0: 0a09 2f2f 2073 6571 7565 6e74 6961 6c2d ..// sequential- │ │ │ +000357c0: 646f 776e 6c6f 6164 0a09 7465 7374 5f61 download..test_a │ │ │ +000357d0: 6464 5f61 6e64 5f67 6574 5f66 6c61 6773 dd_and_get_flags │ │ │ +000357e0: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a (torrent_flags:: │ │ │ +000357f0: 7365 7175 656e 7469 616c 5f64 6f77 6e6c sequential_downl │ │ │ +00035800: 6f61 6429 3b0a 0974 6573 745f 7365 745f oad);..test_set_ │ │ │ +00035810: 6166 7465 725f 6164 6428 746f 7272 656e after_add(torren │ │ │ +00035820: 745f 666c 6167 733a 3a73 6571 7565 6e74 t_flags::sequent │ │ │ +00035830: 6961 6c5f 646f 776e 6c6f 6164 293b 0a09 ial_download);.. │ │ │ +00035840: 7465 7374 5f75 6e73 6574 5f61 6674 6572 test_unset_after │ │ │ +00035850: 5f61 6464 2874 6f72 7265 6e74 5f66 6c61 _add(torrent_fla │ │ │ +00035860: 6773 3a3a 7365 7175 656e 7469 616c 5f64 gs::sequential_d │ │ │ +00035870: 6f77 6e6c 6f61 6429 3b0a 7d0a 3c2f 7072 ownload);.}.
    rel │ │ │ +000358b0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../test/t │ │ │ +000358f0: 6573 745f 7265 7375 6d65 2e63 7070 3a35 est_resume.cpp:5 │ │ │ +00035900: 3931 3c2f 613e 3c2f 7464 3e3c 7464 3e74 91t │ │ │ +00035910: 6573 7420 7768 6174 2068 6170 7065 6e73 est what happens │ │ │ +00035920: 2077 6865 6e20 6c6f 6164 696e 6720 6120 when loading a │ │ │ +00035930: 7265 7375 6d65 2066 696c 6520 7769 7468 resume file with │ │ │ +00035940: 2062 6f74 6820 7069 6563 6520 7072 696f both piece prio │ │ │ +00035950: 7269 7469 6573 2061 6e64 2066 696c 6520 rities and file │ │ │ +00035960: 7072 696f 7269 7469 6573 2028 6669 6c65 priorities (file │ │ │ +00035970: 2070 7269 6f20 7368 6f75 6c64 2074 616b prio should tak │ │ │ +00035980: 6520 7072 6563 6564 656e 6365 293c 2f74 e precedence)

    test │ │ │ +000359e0: 7768 6174 2068 6170 7065 6e73 2077 6865 what happens whe │ │ │ +000359f0: 6e20 6c6f 6164 696e 6720 6120 7265 7375 n loading a resu │ │ │ +00035a00: 6d65 2066 696c 6520 7769 7468 2062 6f74 me file with bot │ │ │ +00035a10: 6820 7069 6563 6520 7072 696f 7269 7469 h piece prioriti │ │ │ +00035a20: 6573 0a61 6e64 2066 696c 6520 7072 696f es.and file prio │ │ │ +00035a30: 7269 7469 6573 2028 6669 6c65 2070 7269 rities (file pri │ │ │ +00035a40: 6f20 7368 6f75 6c64 2074 616b 6520 7072 o should take pr │ │ │ +00035a50: 6563 6564 656e 6365 293c 2f68 323e 3c68 ecedence)

    ../test/test_r │ │ │ +00035a70: 6573 756d 652e 6370 703a 3539 313c 2f68 esume.cpp:591
    ..{.
    │ │ │ +00035ac0: 0909 0954 4553 545f 4551 5541 4c28 7069  ...TEST_EQUAL(pi
    │ │ │ +00035ad0: 6563 6573 5b69 5d2c 2074 7275 6529 3b0a  eces[i], true);.
    │ │ │ +00035ae0: 0909 7d0a 097d 0a7d 0a0a 7d20 2f2f 2061  ..}..}.}..} // a
    │ │ │ +00035af0: 6e6f 6e79 6d6f 7573 206e 616d 6573 7061  nonymous namespa
    │ │ │ +00035b00: 6365 0a0a 544f 5252 454e 545f 5445 5354  ce..TORRENT_TEST
    │ │ │ +00035b10: 2870 6965 6365 5f73 6c6f 7473 5f73 6565  (piece_slots_see
    │ │ │ +00035b20: 6429 0a7b 0a09 7465 7374 5f70 6965 6365  d).{..test_piece
    │ │ │ +00035b30: 5f73 6c6f 7473 5f73 6565 6428 7365 7474  _slots_seed(sett
    │ │ │ +00035b40: 696e 6773 2829 293b 0a7d 0a0a 544f 5252  ings());.}..TORR
    │ │ │ +00035b50: 454e 545f 5445 5354 2870 6965 6365 5f73  ENT_TEST(piece_s
    │ │ │ +00035b60: 6c6f 7473 5f73 6565 645f 7375 6767 6573  lots_seed_sugges
    │ │ │ +00035b70: 745f 6361 6368 6529 0a7b 0a09 7365 7474  t_cache).{..sett
    │ │ │ +00035b80: 696e 6773 5f70 6163 6b20 7365 7474 203d  ings_pack sett =
    │ │ │ +00035b90: 2073 6574 7469 6e67 7328 293b 0a09 7365   settings();..se
    │ │ │ +00035ba0: 7474 2e73 6574 5f69 6e74 2873 6574 7469  tt.set_int(setti
    │ │ │ +00035bb0: 6e67 735f 7061 636b 3a3a 7375 6767 6573  ngs_pack::sugges
    │ │ │ +00035bc0: 745f 6d6f 6465 2c20 7365 7474 696e 6773  t_mode, settings
    │ │ │ +00035bd0: 5f70 6163 6b3a 3a73 7567 6765 7374 5f72  _pack::suggest_r
    │ │ │ +00035be0: 6561 645f 6361 6368 6529 3b0a 0974 6573  ead_cache);..tes
    │ │ │ +00035bf0: 745f 7069 6563 655f 736c 6f74 735f 7365  t_piece_slots_se
    │ │ │ +00035c00: 6564 2873 6574 7429 3b0a 7d0a 0a3c 6469  ed(sett);.}...
    < │ │ │ +00035c70: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00035c80: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00035cb0: 7465 7374 2f74 6573 745f 7265 7375 6d65 test/test_resume │ │ │ +00035cc0: 2e63 7070 3a35 3934 3c2f 613e 3c2f 7464 .cpp:594make sure a │ │ │ +00035ce0: 2072 6573 756d 6520 6669 6c65 206f 6e6c resume file onl │ │ │ +00035cf0: 7920 6576 6572 2063 6f6e 7461 696e 2066 y ever contain f │ │ │ +00035d00: 696c 6520 7072 696f 7269 7469 6573 204f ile priorities O │ │ │ +00035d10: 5220 7069 6563 6520 7072 696f 7269 7469 R piece prioriti │ │ │ +00035d20: 6573 2e20 4e65 7665 7220 626f 7468 2e3c es. Never both.< │ │ │ +00035d30: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    mak │ │ │ +00035d80: 6520 7375 7265 2061 2072 6573 756d 6520 e sure a resume │ │ │ +00035d90: 6669 6c65 206f 6e6c 7920 6576 6572 2063 file only ever c │ │ │ +00035da0: 6f6e 7461 696e 2066 696c 6520 7072 696f ontain file prio │ │ │ +00035db0: 7269 7469 6573 204f 5220 7069 6563 650a rities OR piece. │ │ │ +00035dc0: 7072 696f 7269 7469 6573 2e20 4e65 7665 priorities. Neve │ │ │ +00035dd0: 7220 626f 7468 2e3c 2f68 323e 3c68 343e r both.

    │ │ │ +00035de0: 2e2e 2f74 6573 742f 7465 7374 5f72 6573 ../test/test_res │ │ │ +00035df0: 756d 652e 6370 703a 3539 343c 2f68 343e ume.cpp:594

    │ │ │ +00035e00: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...TES
    │ │ │ +00035e40: 545f 4551 5541 4c28 7069 6563 6573 5b69  T_EQUAL(pieces[i
    │ │ │ +00035e50: 5d2c 2074 7275 6529 3b0a 0909 7d0a 097d  ], true);...}..}
    │ │ │ +00035e60: 0a7d 0a0a 7d20 2f2f 2061 6e6f 6e79 6d6f  .}..} // anonymo
    │ │ │ +00035e70: 7573 206e 616d 6573 7061 6365 0a0a 544f  us namespace..TO
    │ │ │ +00035e80: 5252 454e 545f 5445 5354 2870 6965 6365  RRENT_TEST(piece
    │ │ │ +00035e90: 5f73 6c6f 7473 5f73 6565 6429 0a7b 0a09  _slots_seed).{..
    │ │ │ +00035ea0: 7465 7374 5f70 6965 6365 5f73 6c6f 7473  test_piece_slots
    │ │ │ +00035eb0: 5f73 6565 6428 7365 7474 696e 6773 2829  _seed(settings()
    │ │ │ +00035ec0: 293b 0a7d 0a0a 544f 5252 454e 545f 5445  );.}..TORRENT_TE
    │ │ │ +00035ed0: 5354 2870 6965 6365 5f73 6c6f 7473 5f73  ST(piece_slots_s
    │ │ │ +00035ee0: 6565 645f 7375 6767 6573 745f 6361 6368  eed_suggest_cach
    │ │ │ +00035ef0: 6529 0a7b 0a09 7365 7474 696e 6773 5f70  e).{..settings_p
    │ │ │ +00035f00: 6163 6b20 7365 7474 203d 2073 6574 7469  ack sett = setti
    │ │ │ +00035f10: 6e67 7328 293b 0a09 7365 7474 2e73 6574  ngs();..sett.set
    │ │ │ +00035f20: 5f69 6e74 2873 6574 7469 6e67 735f 7061  _int(settings_pa
    │ │ │ +00035f30: 636b 3a3a 7375 6767 6573 745f 6d6f 6465  ck::suggest_mode
    │ │ │ +00035f40: 2c20 7365 7474 696e 6773 5f70 6163 6b3a  , settings_pack:
    │ │ │ +00035f50: 3a73 7567 6765 7374 5f72 6561 645f 6361  :suggest_read_ca
    │ │ │ +00035f60: 6368 6529 3b0a 0974 6573 745f 7069 6563  che);..test_piec
    │ │ │ +00035f70: 655f 736c 6f74 735f 7365 6564 2873 6574  e_slots_seed(set
    │ │ │ +00035f80: 7429 3b0a 7d0a 0a0a 3c64 6976 2073 7479  t);.}...
    .

    re │ │ │ +00035ff0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ +00036030: 7465 7374 5f72 6573 756d 652e 6370 703a test_resume.cpp: │ │ │ +00036040: 3539 373c 2f61 3e3c 2f74 643e 3c74 643e 597 │ │ │ +00036050: 6765 6e65 7261 6c6c 7920 7361 7665 3c2f generally save

    gene │ │ │ +000360b0: 7261 6c6c 7920 7361 7665 3c2f 6832 3e3c rally save

    < │ │ │ +000360c0: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +000360d0: 7265 7375 6d65 2e63 7070 3a35 3937 3c2f resume.cpp:597
    ..}
    │ │ │ +00036120: 0a09 7d0a 7d0a 0a7d 202f 2f20 616e 6f6e  ..}.}..} // anon
    │ │ │ +00036130: 796d 6f75 7320 6e61 6d65 7370 6163 650a  ymous namespace.
    │ │ │ +00036140: 0a54 4f52 5245 4e54 5f54 4553 5428 7069  .TORRENT_TEST(pi
    │ │ │ +00036150: 6563 655f 736c 6f74 735f 7365 6564 290a  ece_slots_seed).
    │ │ │ +00036160: 7b0a 0974 6573 745f 7069 6563 655f 736c  {..test_piece_sl
    │ │ │ +00036170: 6f74 735f 7365 6564 2873 6574 7469 6e67  ots_seed(setting
    │ │ │ +00036180: 7328 2929 3b0a 7d0a 0a54 4f52 5245 4e54  s());.}..TORRENT
    │ │ │ +00036190: 5f54 4553 5428 7069 6563 655f 736c 6f74  _TEST(piece_slot
    │ │ │ +000361a0: 735f 7365 6564 5f73 7567 6765 7374 5f63  s_seed_suggest_c
    │ │ │ +000361b0: 6163 6865 290a 7b0a 0973 6574 7469 6e67  ache).{..setting
    │ │ │ +000361c0: 735f 7061 636b 2073 6574 7420 3d20 7365  s_pack sett = se
    │ │ │ +000361d0: 7474 696e 6773 2829 3b0a 0973 6574 742e  ttings();..sett.
    │ │ │ +000361e0: 7365 745f 696e 7428 7365 7474 696e 6773  set_int(settings
    │ │ │ +000361f0: 5f70 6163 6b3a 3a73 7567 6765 7374 5f6d  _pack::suggest_m
    │ │ │ +00036200: 6f64 652c 2073 6574 7469 6e67 735f 7061  ode, settings_pa
    │ │ │ +00036210: 636b 3a3a 7375 6767 6573 745f 7265 6164  ck::suggest_read
    │ │ │ +00036220: 5f63 6163 6865 293b 0a09 7465 7374 5f70  _cache);..test_p
    │ │ │ +00036230: 6965 6365 5f73 6c6f 7473 5f73 6565 6428  iece_slots_seed(
    │ │ │ +00036240: 7365 7474 293b 0a7d 0a0a 0a0a 3c64 6976  sett);.}....
    .
    #if TORRENT_ABI │ │ │ +00036290: 5f56 4552 5349 4f4e 203d 3d20 310a 544f _VERSION == 1.TO │ │ │ +000362a0: 5252 454e 545f 5445 5354 2866 696c 655f RRENT_TEST(file_ │ │ │ +000362b0: 7072 696f 7269 7469 6573 5f64 6566 6175 priorities_defau │ │ │ +000362c0: 6c74 5f64 6570 7265 6361 7465 6429 0a7b lt_deprecated).{ │ │ │ +000362d0: 0a09 6c74 3a3a 7365 7373 696f 6e20 7365 ..lt::session se │ │ │ +000362e0: 7328 7365 7474 696e 6773 2829 293b 0a09 s(settings());.. │ │ │ +000362f0: 7374 643a 3a76 6563 746f 7226 6c74 3b64 std::vector<d │ │ │ +00036300: 6f77 6e6c 6f61 645f 7072 696f 7269 7479 ownload_priority │ │ │ +00036310: 5f74 2667 743b 2066 696c 655f 7072 696f _t> file_prio │ │ │ +00036320: 7269 7469 6573 203d 2074 6573 745f 7265 rities = test_re │ │ │ +00036330: 7375 6d65 5f66 6c61 6773 2873 6573 0a09 sume_flags(ses.. │ │ │ +00036340: 092c 207b 7d2c 2022 222c 2022 222c 2074 ., {}, "", "", t │ │ │ +00036350: 7275 6529 2e67 6574 5f66 696c 655f 7072 rue).get_file_pr │ │ │ +00036360: 696f 7269 7469 6573 2829 3b0a 0a09 5445 iorities();...TE │ │ │ +00036370: 5354 5f45 5155 414c 2866 696c 655f 7072 ST_EQUAL(file_pr │ │ │ +00036380: 696f 7269 7469 6573 2e73 697a 6528 292c iorities.size(), │ │ │ +00036390: 2033 293b 0a09 5445 5354 5f45 5155 414c 3);..TEST_EQUAL │ │ │ +000363a0: 2866 696c 655f 7072 696f 7269 7469 6573 (file_priorities │ │ │ +000363b0: 5b30 5d2c 2034 293b 0a09 5445 5354 5f45 [0], 4);..TEST_E │ │ │ +000363c0: 5155 414c 2866 696c 655f 7072 696f 7269 QUAL(file_priori │ │ │ +000363d0: 7469 6573 5b31 5d2c 2034 293b 0a09 5445 ties[1], 4);..TE │ │ │ +000363e0: 5354 5f45 5155 414c 2866 696c 655f 7072 ST_EQUAL(file_pr │ │ │ +000363f0: 696f 7269 7469 6573 5b32 5d2c 2034 293b iorities[2], 4); │ │ │ +00036400: 0a7d 0a0a 2f2f 2041 7320 6c6f 6e67 2061 .}..// As long a │ │ │ +00036410: 7320 7468 6520 6164 645f 746f 7272 656e s the add_torren │ │ │ +00036420: 745f 7061 7261 6d73 2070 7269 6f72 6974 t_params priorit │ │ │ +00036430: 6965 7320 6172 6520 656d 7074 792c 2074 ies are empty, t │ │ │ +00036440: 6865 2066 696c 655f 7072 696f 7269 7469 he file_prioriti │ │ │ +00036450: 6573 0a2f 2f20 6672 6f6d 2074 6865 2072 es.// from the r │ │ │ +00036460: 6573 756d 6520 6461 7461 2073 686f 756c esume data shoul │ │ │ +00036470: 6420 7461 6b65 2065 6666 6563 740a 544f d take effect.TO │ │ │ +00036480: 5252 454e 545f 5445 5354 2866 696c 655f RRENT_TEST(file_ │ │ │ +00036490: 7072 696f 7269 7469 6573 5f69 6e5f 7265 priorities_in_re │ │ │ +000364a0: 7375 6d65 5f64 6570 7265 6361 7465 6429 sume_deprecated) │ │ │ +000364b0: 0a7b 0a09 6c74 3a3a 7365 7373 696f 6e20 .{..lt::session │ │ │ +000364c0: 7365 7328 7365 7474 696e 6773 2829 293b ses(settings()); │ │ │ +000364d0: 0a09 7374 643a 3a76 6563 746f 7226 6c74 ..std::vector< │ │ │ +000364e0: 3b64 6f77 6e6c 6f61 645f 7072 696f 7269 ;download_priori │ │ │ +000364f0: 7479 5f74 2667 743b 2066 696c 655f 7072 ty_t> file_pr │ │ │ +00036500: 696f 7269 7469 6573 203d 2074 6573 745f iorities = test_ │ │ │ +00036510: 7265 7375 6d65 5f66 6c61 6773 2873 6573 resume_flags(ses │ │ │ +00036520: 2c20 7b7d 2c20 2222 2c20 2231 3233 2229 , {}, "", "123") │ │ │ +00036530: 2e67 6574 5f66 696c 655f 7072 696f 7269 .get_file_priori │ │ │ +00036540: 7469 6573 2829 3b0a 0a09 5445 5354 5f45 ties();...TEST_E │ │ │ +00036550: 5155 414c 2866 696c 655f 7072 696f 7269 QUAL(file_priori │ │ │ +00036560: 7469 6573 2e73 697a 6528 292c 2033 293b ties.size(), 3); │ │ │ +00036570: 0a09 5445 5354 5f45 5155 414c 2866 696c ..TEST_EQUAL(fil │ │ │ +00036580: 655f 7072 696f 7269 7469 6573 5b30 5d2c e_priorities[0], │ │ │ +00036590: 2031 293b 0a09 5445 5354 5f45 5155 414c 1);..TEST_EQUAL │ │ │ +000365a0: 2866 696c 655f 7072 696f 7269 7469 6573 (file_priorities │ │ │ +000365b0: 5b31 5d2c 2032 293b 0a09 5445 5354 5f45 [1], 2);..TEST_E │ │ │ +000365c0: 5155 414c 2866 696c 655f 7072 696f 7269 QUAL(file_priori │ │ │ +000365d0: 7469 6573 5b32 5d2c 2033 293b 0a7d 0a0a ties[2], 3);.}.. │ │ │ +000365e0: 2f2f 2069 6620 626f 7468 2072 6573 756d // if both resum │ │ │ +000365f0: 6520 6461 7461 2061 6e64 2061 6464 5f74 e data and add_t │ │ │ +00036600: 6f72 7265 6e74 5f70 6172 616d 7320 6861 orrent_params ha │ │ │ +00036610: 7320 6669 6c65 5f70 7269 6f72 6974 6965 s file_prioritie │ │ │ +00036620: 732c 2074 6865 0a2f 2f20 6164 645f 746f s, the.// add_to │ │ │ +00036630: 7272 656e 745f 7061 7261 6d73 206f 6e65 rrent_params one │ │ │ +00036640: 2074 616b 6520 7072 6563 6564 656e 6365 take precedence │ │ │ +00036650: 0a54 4f52 5245 4e54 5f54 4553 5428 6669 .TORRENT_TEST(fi │ │ │ +00036660: 6c65 5f70 7269 6f72 6974 6965 735f 696e le_priorities_in │ │ │ +00036670: 5f72 6573 756d 655f 616e 645f 7061 7261 _resume_and_para │ │ │ +00036680: 6d73 5f64 6570 7265 6361 7465 6429 0a7b ms_deprecated).{ │ │ │ +00036690: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +000366d0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../t │ │ │ +00036700: 6573 742f 7465 7374 5f72 6573 756d 652e est/test_resume. │ │ │ +00036710: 6370 703a 3932 303c 2f61 3e3c 2f74 643e cpp:920 │ │ │ +00036720: 3c74 643e 7465 7374 2061 6c6c 206f 7468 test all oth │ │ │ +00036730: 6572 2072 6573 756d 6520 666c 6167 7320 er resume flags │ │ │ +00036740: 6865 7265 2074 6f6f 2e20 5468 6973 2077 here too. This w │ │ │ +00036750: 6f75 6c64 2072 6571 7569 7265 2072 6574 ould require ret │ │ │ +00036760: 7572 6e69 6e67 206d 6f72 6520 7468 616e urning more than │ │ │ +00036770: 206a 7573 7420 7468 6520 746f 7272 656e just the torren │ │ │ +00036780: 745f 7374 6174 7573 2066 726f 6d20 7465 t_status from te │ │ │ +00036790: 7374 5f72 6573 756d 655f 666c 6167 732e st_resume_flags. │ │ │ +000367a0: 2041 6c73 6f20 6874 7470 2073 6565 6473 Also http seeds │ │ │ +000367b0: 2061 6e64 2074 7261 636b 6572 7320 666f and trackers fo │ │ │ +000367c0: 7220 696e 7374 616e 6365 3c2f 7464 3e3c r instance< │ │ │ +000367d0: 2f74 723e 3c74 7220 6964 3d22 3132 3422 /tr>

    test all │ │ │ +00036820: 206f 7468 6572 2072 6573 756d 6520 666c other resume fl │ │ │ +00036830: 6167 7320 6865 7265 2074 6f6f 2e20 5468 ags here too. Th │ │ │ +00036840: 6973 2077 6f75 6c64 2072 6571 7569 7265 is would require │ │ │ +00036850: 2072 6574 7572 6e69 6e67 0a6d 6f72 6520 returning.more │ │ │ +00036860: 7468 616e 206a 7573 7420 7468 6520 746f than just the to │ │ │ +00036870: 7272 656e 745f 7374 6174 7573 2066 726f rrent_status fro │ │ │ +00036880: 6d20 7465 7374 5f72 6573 756d 655f 666c m test_resume_fl │ │ │ +00036890: 6167 732e 2041 6c73 6f20 6874 7470 2073 ags. Also http s │ │ │ +000368a0: 6565 6473 0a61 6e64 2074 7261 636b 6572 eeds.and tracker │ │ │ +000368b0: 7320 666f 7220 696e 7374 616e 6365 3c2f s for instance

    ../test/t │ │ │ +000368d0: 6573 745f 7265 7375 6d65 2e63 7070 3a39 est_resume.cpp:9 │ │ │ +000368e0: 3230 3c2f 6834 3e3c 7072 6520 7374 796c 20

    .TEST_EQUAL(s.c
    │ │ │ +00036930: 6f6e 6e65 6374 696f 6e73 5f6c 696d 6974  onnections_limit
    │ │ │ +00036940: 2c20 3133 3435 293b 0a09 5445 5354 5f45  , 1345);..TEST_E
    │ │ │ +00036950: 5155 414c 2873 2e75 706c 6f61 6473 5f6c  QUAL(s.uploads_l
    │ │ │ +00036960: 696d 6974 2c20 3133 3436 293b 0a7d 0a0a  imit, 1346);.}..
    │ │ │ +00036970: 544f 5252 454e 545f 5445 5354 2870 6175  TORRENT_TEST(pau
    │ │ │ +00036980: 7365 645f 6465 7072 6563 6174 6564 290a  sed_deprecated).
    │ │ │ +00036990: 7b0a 096c 743a 3a73 6573 7369 6f6e 2073  {..lt::session s
    │ │ │ +000369a0: 6573 2873 6574 7469 6e67 7328 2929 3b0a  es(settings());.
    │ │ │ +000369b0: 092f 2f20 7265 7375 6d65 2064 6174 6120  .// resume data 
    │ │ │ +000369c0: 6f76 6572 7269 6465 7320 7468 6520 7061  overrides the pa
    │ │ │ +000369d0: 7573 6564 2066 6c61 670a 0961 7574 6f20  used flag..auto 
    │ │ │ +000369e0: 636f 6e73 7420 6e6f 7720 3d20 6c74 3a3a  const now = lt::
    │ │ │ +000369f0: 636c 6f63 6b5f 7479 7065 3a3a 6e6f 7728  clock_type::now(
    │ │ │ +00036a00: 293b 0a09 746f 7272 656e 745f 7374 6174  );..torrent_stat
    │ │ │ +00036a10: 7573 2073 203d 2074 6573 745f 7265 7375  us s = test_resu
    │ │ │ +00036a20: 6d65 5f66 6c61 6773 2873 6573 2c20 746f  me_flags(ses, to
    │ │ │ +00036a30: 7272 656e 745f 666c 6167 733a 3a70 6175  rrent_flags::pau
    │ │ │ +00036a40: 7365 642c 2022 222c 2022 222c 2074 7275  sed, "", "", tru
    │ │ │ +00036a50: 6529 2e73 7461 7475 7328 293b 0a09 6465  e).status();..de
    │ │ │ +00036a60: 6661 756c 745f 7465 7374 7328 732c 206e  fault_tests(s, n
    │ │ │ +00036a70: 6f77 293b 0a23 6966 6465 6620 544f 5252  ow);.#ifdef TORR
    │ │ │ +00036a80: 454e 545f 5749 4e44 4f57 530a 0954 4553  ENT_WINDOWS..TES
    │ │ │ +00036a90: 545f 4551 5541 4c28 732e 7361 7665 5f70  T_EQUAL(s.save_p
    │ │ │ +00036aa0: 6174 682c 2022 633a 5c5c 6164 645f 746f  ath, "c:\\add_to
    │ │ │ +00036ab0: 7272 656e 745f 7061 7261 6d73 2073 6176  rrent_params sav
    │ │ │ +00036ac0: 655f 7061 7468 2229 3b0a 2365 6c73 650a  e_path");.#else.
    │ │ │ +00036ad0: 0954 4553 545f 4551 5541 4c28 732e 7361  .TEST_EQUAL(s.sa
    │ │ │ +00036ae0: 7665 5f70 6174 682c 2022 2f61 6464 5f74  ve_path, "/add_t
    │ │ │ +00036af0: 6f72 7265 6e74 5f70 6172 616d 7320 7361  orrent_params sa
    │ │ │ +00036b00: 7665 5f70 6174 6822 293b 0a23 656e 6469  ve_path");.#endi
    │ │ │ +00036b10: 660a 0954 4553 545f 4551 5541 4c28 732e  f..TEST_EQUAL(s.
    │ │ │ +00036b20: 666c 6167 7320 2661 6d70 3b20 666c 6167  flags & flag
    │ │ │ +00036b30: 735f 6d61 736b 2c20 746f 7272 656e 745f  s_mask, torrent_
    │ │ │ +00036b40: 666c 6167 735f 747b 7d29 3b0a 0954 4553  flags_t{});..TES
    │ │ │ +00036b50: 545f 4551 5541 4c28 732e 636f 6e6e 6563  T_EQUAL(s.connec
    │ │ │ +00036b60: 7469 6f6e 735f 6c69 6d69 742c 2031 3334  tions_limit, 134
    │ │ │ +00036b70: 3529 3b0a 0954 4553 545f 4551 5541 4c28  5);..TEST_EQUAL(
    │ │ │ +00036b80: 732e 7570 6c6f 6164 735f 6c69 6d69 742c  s.uploads_limit,
    │ │ │ +00036b90: 2031 3334 3629 3b0a 0a3c 6469 7620 7374   1346);..
    }.
    . │ │ │ +00036bd0: 544f 5252 454e 545f 5445 5354 2875 726c TORRENT_TEST(url │ │ │ +00036be0: 5f73 6565 645f 7265 7375 6d65 5f64 6174 _seed_resume_dat │ │ │ +00036bf0: 615f 6465 7072 6563 6174 6564 290a 7b0a a_deprecated).{. │ │ │ +00036c00: 092f 2f20 6d65 7267 6520 7572 6c20 7365 .// merge url se │ │ │ +00036c10: 6564 7320 7769 7468 2072 6573 756d 6520 eds with resume │ │ │ +00036c20: 6461 7461 0a09 7374 643a 3a70 7269 6e74 data..std::print │ │ │ +00036c30: 6628 2266 6c61 6773 3a20 6d65 7267 655f f("flags: merge_ │ │ │ +00036c40: 7265 7375 6d65 5f68 7474 705f 7365 6564 resume_http_seed │ │ │ +00036c50: 735c 6e22 293b 0a09 6c74 3a3a 7365 7373 s\n");..lt::sess │ │ │ +00036c60: 696f 6e20 7365 7328 7365 7474 696e 6773 ion ses(settings │ │ │ +00036c70: 2829 293b 0a09 746f 7272 656e 745f 6861 ());..torrent_ha │ │ │ +00036c80: 6e64 6c65 2068 203d 2074 6573 745f 7265 ndle h = test_re │ │ │ +00036c90: 7375 6d65 5f66 6c61 6773 2873 6573 2c0a sume_flags(ses,. │ │ │ +00036ca0: 0909 746f 7272 656e 745f 666c 6167 733a ..torrent_flags: │ │ │ +00036cb0: 3a6d 6572 6765 5f72 6573 756d 655f 6874 :merge_resume_ht │ │ │ +00036cc0: 7470 5f73 6565 6473 2c20 2222 2c20 2222 tp_seeds, "", "" │ │ │ +00036cd0: 2c20 7472 7565 293b 0a09 7374 643a 3a73 , true);..std::s │ │ │ +00036ce0: 6574 266c 743b 7374 643a 3a73 7472 696e et<std::strin │ │ │ +00036cf0: 6726 6774 3b20 7573 203d 2068 2e75 726c g> us = h.url │ │ │ +00036d00: 5f73 6565 6473 2829 3b0a 0a09 5445 5354 _seeds();...TEST │ │ │ +00036d10: 5f45 5155 414c 2875 732e 7369 7a65 2829 _EQUAL(us.size() │ │ │ +00036d20: 2c20 3229 3b0a 0954 4553 545f 4551 5541 , 2);..TEST_EQUA │ │ │ +00036d30: 4c28 7374 643a 3a63 6f75 6e74 2875 732e L(std::count(us. │ │ │ +00036d40: 6265 6769 6e28 292c 2075 732e 656e 6428 begin(), us.end( │ │ │ +00036d50: 292c 2022 6874 7470 3a2f 2f61 6464 2d74 ), "http://add-t │ │ │ +00036d60: 6f72 7265 6e74 2d70 6172 616d 732d 7572 orrent-params-ur │ │ │ +00036d70: 6c2d 7365 6564 2e63 6f6d 2f22 292c 2031 l-seed.com/"), 1 │ │ │ +00036d80: 293b 0a09 5445 5354 5f45 5155 414c 2873 );..TEST_EQUAL(s │ │ │ +00036d90: 7464 3a3a 636f 756e 7428 7573 2e62 6567 td::count(us.beg │ │ │ +00036da0: 696e 2829 2c20 7573 2e65 6e64 2829 2c20 in(), us.end(), │ │ │ +00036db0: 2268 7474 703a 2f2f 7265 7375 6d65 2d64 "http://resume-d │ │ │ +00036dc0: 6174 612d 7572 6c2d 7365 6564 2e63 6f6d ata-url-seed.com │ │ │ +00036dd0: 2f22 292c 2031 293b 0a0a 092f 2f20 2268 /"), 1);...// "h │ │ │ +00036de0: 7474 703a 2f2f 746f 7272 656e 742d 6669 ttp://torrent-fi │ │ │ +00036df0: 6c65 2d75 726c 2d73 6565 642e 636f 6d2f le-url-seed.com/ │ │ │ +00036e00: 2220 6973 206e 6f20 6c6f 6e67 6572 2070 " is no longer p │ │ │ +00036e10: 6172 7420 6f66 2074 6f72 7265 6e74 5f69 art of torrent_i │ │ │ +00036e20: 6e66 6f2c 0a09 2f2f 2061 6e64 2073 6f20 nfo,..// and so │ │ │ +00036e30: 6973 206e 6f20 6c6f 6e67 6572 2069 6e63 is no longer inc │ │ │ +00036e40: 6c75 6465 6420 7768 656e 2074 6865 2074 luded when the t │ │ │ +00036e50: 6f72 7265 6e74 2069 7320 6164 6465 640a orrent is added. │ │ │ +00036e60: 7d0a 0a54 4f52 5245 4e54 5f54 4553 5428 }..TORRENT_TEST( │ │ │ +00036e70: 7265 7375 6d65 5f6f 7665 7272 6964 655f resume_override_ │ │ │ +00036e80: 746f 7272 656e 745f 6465 7072 6563 6174 torrent_deprecat │ │ │ +00036e90: 6564 290a 7b0a 092f 2f20 7265 7375 6d65 ed).{..// resume │ │ │ +00036ea0: 2064 6174 6120 6f76 6572 7269 6465 7320 data overrides │ │ │ +00036eb0: 7468 6520 2e74 6f72 7265 6e74 5f66 696c the .torrent_fil │ │ │ +00036ec0: 650a 0973 7464 3a3a 7072 696e 7466 2822 e..std::printf(" │ │ │ +00036ed0: 666c 6167 733a 206e 6f20 6d65 7267 655f flags: no merge_ │ │ │ +00036ee0: 7265 7375 6d65 5f68 7474 705f 7365 6564 resume_http_seed │ │ │ +00036ef0: 5c6e 2229 3b0a 096c 743a 3a73 6573 7369 \n");..lt::sessi │ │ │ +00036f00: 6f6e 2073 6573 2873 6574 7469 6e67 7328 on ses(settings( │ │ │ +00036f10: 2929 3b0a 0974 6f72 7265 6e74 5f68 616e ));..torrent_han │ │ │ +00036f20: 646c 6520 6820 3d20 7465 7374 5f72 6573 dle h = test_res │ │ │ +00036f30: 756d 655f 666c 6167 7328 7365 732c 0a09 ume_flags(ses,.. │ │ │ +00036f40: 0974 6f72 7265 6e74 5f66 6c61 6773 3a3a .torrent_flags:: │ │ │ +00036f50: 6d65 7267 655f 7265 7375 6d65 5f74 7261 merge_resume_tra │ │ │ +00036f60: 636b 6572 732c 2022 222c 2022 222c 2074 ckers, "", "", t │ │ │ +00036f70: 7275 6529 3b0a 0973 7464 3a3a 7365 7426 rue);..std::set& │ │ │ +00036f80: 6c74 3b73 7464 3a3a 7374 7269 6e67 2667 lt;std::string&g │ │ │ +00036f90: 743b 2075 7320 3d20 682e 7572 6c5f 7365 t; us = h.url_se │ │ │ +00036fa0: 6564 7328 293b 0a0a 0954 4553 545f 4551 eds();...TEST_EQ │ │ │ +00036fb0: 5541 4c28 7573 2e73 697a 6528 292c 2031 UAL(us.size(), 1 │ │ │ +00036fc0: 293b 0a09 5445 5354 5f45 5155 414c 2873 );..TEST_EQUAL(s │ │ │ +00036fd0: 7464 3a3a 636f 756e 7428 7573 2e62 6567 td::count(us.beg │ │ │ +00036fe0: 696e 2829 2c20 7573 2e65 6e64 2829 2c20 in(), us.end(), │ │ │ +00036ff0: 2268 7474 703a 2f2f 7265 7375 6d65 2d64 "http://resume-d │ │ │ +00037000: 6174 612d 7572 6c2d 7365 6564 2e63 6f6d ata-url-seed.com │ │ │ +00037010: 2f22 292c 2031 293b 0a7d 0a3c 2f70 7265 /"), 1);.}.
    rele │ │ │ +00037050: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../test/te │ │ │ +00037090: 7374 5f72 6573 756d 652e 6370 703a 3136 st_resume.cpp:16 │ │ │ +000370a0: 3734 3c2f 613e 3c2f 7464 3e3c 7464 3e74 74t │ │ │ +000370b0: 6573 7420 616c 6c20 6f74 6865 7220 7265 est all other re │ │ │ +000370c0: 7375 6d65 2066 6c61 6773 2068 6572 6520 sume flags here │ │ │ +000370d0: 746f 6f2e 2054 6869 7320 776f 756c 6420 too. This would │ │ │ +000370e0: 7265 7175 6972 6520 7265 7475 726e 696e require returnin │ │ │ +000370f0: 6720 6d6f 7265 2074 6861 6e20 6a75 7374 g more than just │ │ │ +00037100: 2074 6865 2074 6f72 7265 6e74 5f73 7461 the torrent_sta │ │ │ +00037110: 7475 7320 6672 6f6d 2074 6573 745f 7265 tus from test_re │ │ │ +00037120: 7375 6d65 5f66 6c61 6773 2e20 416c 736f sume_flags. Also │ │ │ +00037130: 2068 7474 7020 7365 6564 7320 616e 6420 http seeds and │ │ │ +00037140: 7472 6163 6b65 7273 2066 6f72 2069 6e73 trackers for ins │ │ │ +00037150: 7461 6e63 653c 2f74 643e 3c2f 7472 3e3c tance< │ │ │ +00037160: 7472 2069 643d 2231 3235 2220 7374 796c tr id="125" styl │ │ │ +00037170: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00037180: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00037190: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +000371a0: 6832 3e74 6573 7420 616c 6c20 6f74 6865 h2>test all othe │ │ │ +000371b0: 7220 7265 7375 6d65 2066 6c61 6773 2068 r resume flags h │ │ │ +000371c0: 6572 6520 746f 6f2e 2054 6869 7320 776f ere too. This wo │ │ │ +000371d0: 756c 6420 7265 7175 6972 6520 7265 7475 uld require retu │ │ │ +000371e0: 726e 696e 670a 6d6f 7265 2074 6861 6e20 rning.more than │ │ │ +000371f0: 6a75 7374 2074 6865 2074 6f72 7265 6e74 just the torrent │ │ │ +00037200: 5f73 7461 7475 7320 6672 6f6d 2074 6573 _status from tes │ │ │ +00037210: 745f 7265 7375 6d65 5f66 6c61 6773 2e20 t_resume_flags. │ │ │ +00037220: 416c 736f 2068 7474 7020 7365 6564 730a Also http seeds. │ │ │ +00037230: 616e 6420 7472 6163 6b65 7273 2066 6f72 and trackers for │ │ │ +00037240: 2069 6e73 7461 6e63 653c 2f68 323e 3c68 instance../test/test_r │ │ │ +00037260: 6573 756d 652e 6370 703a 3136 3734 3c2f esume.cpp:1674
    .TE
    │ │ │ +000372b0: 5354 5f45 5155 414c 2873 2e63 6f6e 6e65  ST_EQUAL(s.conne
    │ │ │ +000372c0: 6374 696f 6e73 5f6c 696d 6974 2c20 3133  ctions_limit, 13
    │ │ │ +000372d0: 3435 293b 0a09 5445 5354 5f45 5155 414c  45);..TEST_EQUAL
    │ │ │ +000372e0: 2873 2e75 706c 6f61 6473 5f6c 696d 6974  (s.uploads_limit
    │ │ │ +000372f0: 2c20 3133 3436 293b 0a7d 0a0a 544f 5252  , 1346);.}..TORR
    │ │ │ +00037300: 454e 545f 5445 5354 2870 6175 7365 6429  ENT_TEST(paused)
    │ │ │ +00037310: 0a7b 0a09 6c74 3a3a 7365 7373 696f 6e20  .{..lt::session 
    │ │ │ +00037320: 7365 7328 7365 7474 696e 6773 2829 293b  ses(settings());
    │ │ │ +00037330: 0a09 2f2f 2072 6573 756d 6520 6461 7461  ..// resume data
    │ │ │ +00037340: 206f 7665 7272 6964 6573 2074 6865 2070   overrides the p
    │ │ │ +00037350: 6175 7365 6420 666c 6167 0a09 6175 746f  aused flag..auto
    │ │ │ +00037360: 2063 6f6e 7374 206e 6f77 203d 206c 743a   const now = lt:
    │ │ │ +00037370: 3a63 6c6f 636b 5f74 7970 653a 3a6e 6f77  :clock_type::now
    │ │ │ +00037380: 2829 3b0a 0974 6f72 7265 6e74 5f73 7461  ();..torrent_sta
    │ │ │ +00037390: 7475 7320 7320 3d20 7465 7374 5f72 6573  tus s = test_res
    │ │ │ +000373a0: 756d 655f 666c 6167 7328 7365 732c 2074  ume_flags(ses, t
    │ │ │ +000373b0: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7061  orrent_flags::pa
    │ │ │ +000373c0: 7573 6564 292e 7374 6174 7573 2829 3b0a  used).status();.
    │ │ │ +000373d0: 0964 6566 6175 6c74 5f74 6573 7473 2873  .default_tests(s
    │ │ │ +000373e0: 2c20 6e6f 7729 3b0a 2369 6664 6566 2054  , now);.#ifdef T
    │ │ │ +000373f0: 4f52 5245 4e54 5f57 494e 444f 5753 0a09  ORRENT_WINDOWS..
    │ │ │ +00037400: 5445 5354 5f45 5155 414c 2873 2e73 6176  TEST_EQUAL(s.sav
    │ │ │ +00037410: 655f 7061 7468 2c20 2263 3a5c 5c61 6464  e_path, "c:\\add
    │ │ │ +00037420: 5f74 6f72 7265 6e74 5f70 6172 616d 7320  _torrent_params 
    │ │ │ +00037430: 7361 7665 5f70 6174 6822 293b 0a23 656c  save_path");.#el
    │ │ │ +00037440: 7365 0a09 5445 5354 5f45 5155 414c 2873  se..TEST_EQUAL(s
    │ │ │ +00037450: 2e73 6176 655f 7061 7468 2c20 222f 6164  .save_path, "/ad
    │ │ │ +00037460: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ +00037470: 2073 6176 655f 7061 7468 2229 3b0a 2365   save_path");.#e
    │ │ │ +00037480: 6e64 6966 0a09 5445 5354 5f45 5155 414c  ndif..TEST_EQUAL
    │ │ │ +00037490: 2873 2e66 6c61 6773 2026 616d 703b 2066  (s.flags & f
    │ │ │ +000374a0: 6c61 6773 5f6d 6173 6b2c 2074 6f72 7265  lags_mask, torre
    │ │ │ +000374b0: 6e74 5f66 6c61 6773 3a3a 7061 7573 6564  nt_flags::paused
    │ │ │ +000374c0: 293b 0a09 5445 5354 5f45 5155 414c 2873  );..TEST_EQUAL(s
    │ │ │ +000374d0: 2e63 6f6e 6e65 6374 696f 6e73 5f6c 696d  .connections_lim
    │ │ │ +000374e0: 6974 2c20 3133 3435 293b 0a09 5445 5354  it, 1345);..TEST
    │ │ │ +000374f0: 5f45 5155 414c 2873 2e75 706c 6f61 6473  _EQUAL(s.uploads
    │ │ │ +00037500: 5f6c 696d 6974 2c20 3133 3436 293b 0a0a  _limit, 1346);..
    │ │ │ +00037510: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    }. │ │ │ +00037540: 3c2f 6469 763e 0a54 4f52 5245 4e54 5f54
    .TORRENT_T │ │ │ +00037550: 4553 5428 6e6f 5f6d 6574 6164 6174 6129 EST(no_metadata) │ │ │ +00037560: 0a7b 0a09 6c74 3a3a 7365 7373 696f 6e20 .{..lt::session │ │ │ +00037570: 7365 7328 7365 7474 696e 6773 2829 293b ses(settings()); │ │ │ +00037580: 0a0a 0961 6464 5f74 6f72 7265 6e74 5f70 ...add_torrent_p │ │ │ +00037590: 6172 616d 7320 703b 0a09 702e 696e 666f arams p;..p.info │ │ │ +000375a0: 5f68 6173 6865 732e 7631 203d 2073 6861 _hashes.v1 = sha │ │ │ +000375b0: 315f 6861 7368 2822 6162 6162 6162 6162 1_hash("abababab │ │ │ +000375c0: 6162 6162 6162 6162 6162 6162 2229 3b0a abababababab");. │ │ │ +000375d0: 0970 2e73 6176 655f 7061 7468 203d 2022 .p.save_path = " │ │ │ +000375e0: 2e22 3b0a 0970 2e6e 616d 6520 3d20 2266 .";..p.name = "f │ │ │ +000375f0: 6f6f 6261 7222 3b0a 0974 6f72 7265 6e74 oobar";..torrent │ │ │ +00037600: 5f68 616e 646c 6520 6820 3d20 7365 732e _handle h = ses. │ │ │ +00037610: 6164 645f 746f 7272 656e 7428 7029 3b0a add_torrent(p);. │ │ │ +00037620: 0968 2e73 6176 655f 7265 7375 6d65 5f64 .h.save_resume_d │ │ │ +00037630: 6174 6128 746f 7272 656e 745f 6861 6e64 ata(torrent_hand │ │ │ +00037640: 6c65 3a3a 7361 7665 5f69 6e66 6f5f 6469 le::save_info_di │ │ │ +00037650: 6374 293b 0a09 616c 6572 7420 636f 6e73 ct);..alert cons │ │ │ +00037660: 742a 2061 203d 2077 6169 745f 666f 725f t* a = wait_for_ │ │ │ +00037670: 616c 6572 7428 7365 732c 2073 6176 655f alert(ses, save_ │ │ │ +00037680: 7265 7375 6d65 5f64 6174 615f 616c 6572 resume_data_aler │ │ │ +00037690: 743a 3a61 6c65 7274 5f74 7970 6529 3b0a t::alert_type);. │ │ │ +000376a0: 0954 4553 545f 4348 4543 4b28 6129 3b0a .TEST_CHECK(a);. │ │ │ +000376b0: 0973 6176 655f 7265 7375 6d65 5f64 6174 .save_resume_dat │ │ │ +000376c0: 615f 616c 6572 7420 636f 6e73 742a 2072 a_alert const* r │ │ │ +000376d0: 6120 3d20 616c 6572 745f 6361 7374 266c a = alert_cast&l │ │ │ +000376e0: 743b 7361 7665 5f72 6573 756d 655f 6461 t;save_resume_da │ │ │ +000376f0: 7461 5f61 6c65 7274 2667 743b 2861 293b ta_alert>(a); │ │ │ +00037700: 0a09 5445 5354 5f43 4845 434b 2872 6129 ..TEST_CHECK(ra) │ │ │ +00037710: 3b0a 0969 6620 2872 6129 0a09 7b0a 0909 ;..if (ra)..{... │ │ │ +00037720: 6175 746f 2063 6f6e 7374 2661 6d70 3b20 auto const& │ │ │ +00037730: 6174 7020 3d20 7261 2d26 6774 3b70 6172 atp = ra->par │ │ │ +00037740: 616d 733b 0a09 0954 4553 545f 4551 5541 ams;...TEST_EQUA │ │ │ +00037750: 4c28 6174 702e 696e 666f 5f68 6173 6865 L(atp.info_hashe │ │ │ +00037760: 732c 2070 2e69 6e66 6f5f 6861 7368 6573 s, p.info_hashes │ │ │ +00037770: 293b 0a09 0954 4553 545f 4551 5541 4c28 );...TEST_EQUAL( │ │ │ +00037780: 6174 702e 6e61 6d65 2c20 2266 6f6f 6261 atp.name, "fooba │ │ │ +00037790: 7222 293b 0a09 7d0a 7d0a 0a74 656d 706c r");..}.}..templ │ │ │ +000377a0: 6174 6520 266c 743b 7479 7065 6e61 6d65 ate <typename │ │ │ +000377b0: 2046 756e 2667 743b 0a76 6f69 6420 7465 Fun>.void te │ │ │ +000377c0: 7374 5f75 6e66 696e 6973 6865 645f 7069 st_unfinished_pi │ │ │ +000377d0: 6563 6573 2846 756e 2066 290a 7b0a 092f eces(Fun f).{../ │ │ │ +000377e0: 2f20 6372 6561 7465 2061 2074 6f72 7265 / create a torre │ │ │ +000377f0: 6e74 2061 6e64 2063 6f6d 706c 6574 6520 nt and complete │ │ │ +00037800: 6669 6c65 730a 0961 6464 5f74 6f72 7265 files..add_torre │ │ │ +00037810: 6e74 5f70 6172 616d 7320 7020 3d20 6765 nt_params p = ge │ │ │ +00037820: 6e65 7261 7465 5f74 6f72 7265 6e74 2874 nerate_torrent(t │ │ │ +00037830: 7275 652c 2074 7275 6529 3b0a 0961 7574 rue, true);..aut │ │ │ +00037840: 6f20 7469 203d 2070 2e74 693b 0a09 702e o ti = p.ti;..p. │ │ │ +00037850: 6861 7665 5f70 6965 6365 732e 7265 7369 have_pieces.resi │ │ │ +00037860: 7a65 2874 692d 2667 743b 6e75 6d5f 7069 ze(ti->num_pi │ │ │ +00037870: 6563 6573 2829 2c20 7472 7565 293b 0a3c eces(), true);.< │ │ │ +00037880: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00037890: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +000378a0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +000378b0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000378c0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../tes │ │ │ +000378f0: 742f 7465 7374 5f74 7261 636b 6572 5f6c t/test_tracker_l │ │ │ +00037900: 6973 742e 6370 703a 3436 373c 2f61 3e3c ist.cpp:467< │ │ │ +00037910: 2f74 643e 3c74 643e 7265 7365 743c 2f74 /td>reset

    reset │ │ │ +00037970: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ +00037980: 2f74 6573 745f 7472 6163 6b65 725f 6c69 /test_tracker_li │ │ │ +00037990: 7374 2e63 7070 3a34 3637 3c2f 6834 3e3c st.cpp:467

    < │ │ │ +000379a0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +000379b0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +000379c0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +000379d0: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ +000379e0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00037a10: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00037a20: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ +00037a50: 5f74 7261 636b 6572 5f6c 6973 742e 6370 _tracker_list.cp │ │ │ +00037a60: 703a 3436 383c 2f61 3e3c 2f74 643e 3c74 p:468completed │ │ │ +00037a80: 3c2f 7472 3e3c 7472 2069 643d 2231 3237

    complet │ │ │ +00037ad0: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ed

    ../te │ │ │ +00037ae0: 7374 2f74 6573 745f 7472 6163 6b65 725f st/test_tracker_ │ │ │ +00037af0: 6c69 7374 2e63 7070 3a34 3638 3c2f 6834 list.cpp:468

    rele
    │ │ │ +00037b70: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ +00037bb0: 7374 5f74 7261 636b 6572 5f6c 6973 742e  st_tracker_list.
    │ │ │ +00037bc0: 6370 703a 3436 393c 2f61 3e3c 2f74 643e  cpp:469
    │ │ │ +00037bd0: 3c74 643e 646f 6e74 5f74 7279 5f61 6761  dont_try_aga
    │ │ │ +00037be0: 696e 3c2f 7464 3e3c 2f74 723e 3c74 7220  in

    │ │ │ +00037c30: 646f 6e74 5f74 7279 5f61 6761 696e 3c2f dont_try_again

    ../test/t │ │ │ +00037c50: 6573 745f 7472 6163 6b65 725f 6c69 7374 est_tracker_list │ │ │ +00037c60: 2e63 7070 3a34 3639 3c2f 6834 3e3c 7072 .cpp:469

    relevanc │ │ │ +00037ce0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_m │ │ │ +00037d20: 6572 6b6c 655f 7472 6565 2e63 7070 3a39 erkle_tree.cpp:9 │ │ │ +00037d30: 3731 3c2f 613e 3c2f 7464 3e3c 7464 3e61 71a │ │ │ +00037d40: 6464 2074 6573 7420 666f 7220 6c6f 6164 dd test for load │ │ │ +00037d50: 5f70 6965 6365 5f6c 6179 6572 2829 3c2f _piece_layer()

    add │ │ │ +00037db0: 7465 7374 2066 6f72 206c 6f61 645f 7069 test for load_pi │ │ │ +00037dc0: 6563 655f 6c61 7965 7228 293c 2f68 323e ece_layer()

    │ │ │ +00037dd0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +00037de0: 5f6d 6572 6b6c 655f 7472 6565 2e63 7070 _merkle_tree.cpp │ │ │ +00037df0: 3a39 3731 3c2f 6834 3e3c 7072 6520 7374 :971

    
    │ │ │ +00037e60: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ +00037e70: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ +00037ea0: 2f74 6573 742f 7465 7374 5f6d 6572 6b6c  /test/test_merkl
    │ │ │ +00037eb0: 655f 7472 6565 2e63 7070 3a39 3732 3c2f  e_tree.cpp:972add t
    │ │ │ +00037ed0: 6573 7420 666f 7220 6164 645f 6861 7368  est for add_hash
    │ │ │ +00037ee0: 6573 2829 2077 6974 6820 616e 206f 6464  es() with an odd
    │ │ │ +00037ef0: 206e 756d 6265 7220 6f66 2062 6c6f 636b   number of block
    │ │ │ +00037f00: 733c 2f74 643e 3c2f 7472 3e3c 7472 2069  s

    a │ │ │ +00037f50: 6464 2074 6573 7420 666f 7220 6164 645f dd test for add_ │ │ │ +00037f60: 6861 7368 6573 2829 2077 6974 6820 616e hashes() with an │ │ │ +00037f70: 206f 6464 206e 756d 6265 7220 6f66 2062 odd number of b │ │ │ +00037f80: 6c6f 636b 733c 2f68 323e 3c68 343e 2e2e locks

    .. │ │ │ +00037f90: 2f74 6573 742f 7465 7374 5f6d 6572 6b6c /test/test_merkl │ │ │ +00037fa0: 655f 7472 6565 2e63 7070 3a39 3732 3c2f e_tree.cpp:972

    re │ │ │ +00038020: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../test/ │ │ │ +00038060: 7465 7374 5f6d 6572 6b6c 655f 7472 6565 test_merkle_tree │ │ │ +00038070: 2e63 7070 3a39 3733 3c2f 613e 3c2f 7464 .cpp:973add test fo │ │ │ +00038090: 7220 7365 745f 626c 6f63 6b28 2920 2873 r set_block() (s │ │ │ +000380a0: 6574 7469 6e67 2074 6865 206c 6173 7420 etting the last │ │ │ +000380b0: 626c 6f63 6b29 2077 6974 6820 616e 206f block) with an o │ │ │ +000380c0: 6464 206e 756d 6265 7220 6f66 2062 6c6f dd number of blo │ │ │ +000380d0: 636b 733c 2f74 643e 3c2f 7472 3e3c 7472 cks

    add test for se │ │ │ +00038130: 745f 626c 6f63 6b28 2920 2873 6574 7469 t_block() (setti │ │ │ +00038140: 6e67 2074 6865 206c 6173 7420 626c 6f63 ng the last bloc │ │ │ +00038150: 6b29 2077 6974 6820 616e 206f 6464 206e k) with an odd n │ │ │ +00038160: 756d 6265 7220 6f66 2062 6c6f 636b 733c umber of blocks< │ │ │ +00038170: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +00038180: 7465 7374 5f6d 6572 6b6c 655f 7472 6565 test_merkle_tree │ │ │ +00038190: 2e63 7070 3a39 3733 3c2f 6834 3e3c 7072 .cpp:973

    .TEST_CHE │ │ │ +000381e0: 434b 2874 2e6c 6f61 645f 7069 6563 655f CK(t.load_piece_ │ │ │ +000381f0: 6c61 7965 7228 7069 6563 655f 6c61 7965 layer(piece_laye │ │ │ +00038200: 725f 6279 7465 7329 293b 0a0a 092f 2f20 r_bytes));...// │ │ │ +00038210: 696e 2070 6965 6365 5f6c 6179 6572 206d in piece_layer m │ │ │ +00038220: 6f64 6520 7769 7468 2062 7070 2026 6774 ode with bpp > │ │ │ +00038230: 3b20 312c 206e 6f20 626c 6f63 6b73 2073 ; 1, no blocks s │ │ │ +00038240: 686f 756c 6420 7265 706f 7274 2061 7320 hould report as │ │ │ +00038250: 7665 7269 6669 6564 0a09 5445 5354 5f43 verified..TEST_C │ │ │ +00038260: 4845 434b 2874 2e76 6572 6966 6965 645f HECK(t.verified_ │ │ │ +00038270: 6c65 6166 7328 2920 3d3d 206e 6f6e 655f leafs() == none_ │ │ │ +00038280: 7365 7428 6e75 6d5f 626c 6f63 6b73 2929 set(num_blocks)) │ │ │ +00038290: 3b0a 0a09 2f2f 2061 6674 6572 206c 6f61 ;...// after loa │ │ │ +000382a0: 645f 7069 6563 655f 6c61 7965 7220 7468 d_piece_layer th │ │ │ +000382b0: 6520 7472 6565 2069 7320 6261 636b 2069 e tree is back i │ │ │ +000382c0: 6e20 7468 6520 7069 6563 655f 6c61 7965 n the piece_laye │ │ │ +000382d0: 722d 6f6e 6c79 0a09 2f2f 2073 7461 7465 r-only..// state │ │ │ +000382e0: 2c20 736f 2061 2073 696e 676c 6520 7365 , so a single se │ │ │ +000382f0: 745f 626c 6f63 6b20 6361 6e27 7420 7965 t_block can't ye │ │ │ +00038300: 7420 7665 7269 6679 2061 6761 696e 7374 t verify against │ │ │ +00038310: 2074 6865 2073 6962 6c69 6e67 2e0a 0961 the sibling...a │ │ │ +00038320: 7574 6f20 636f 6e73 7420 7265 7375 6c74 uto const result │ │ │ +00038330: 203d 2074 2e73 6574 5f62 6c6f 636b 2830 = t.set_block(0 │ │ │ +00038340: 2c20 665b 3531 315d 293b 0a09 5445 5354 , f[511]);..TEST │ │ │ +00038350: 5f43 4845 434b 2873 7464 3a3a 6765 7426 _CHECK(std::get& │ │ │ +00038360: 6c74 3b30 2667 743b 2872 6573 756c 7429 lt;0>(result) │ │ │ +00038370: 203d 3d20 6175 783a 3a6d 6572 6b6c 655f == aux::merkle_ │ │ │ +00038380: 7472 6565 3a3a 7365 745f 626c 6f63 6b5f tree::set_block_ │ │ │ +00038390: 7265 7375 6c74 3a3a 756e 6b6e 6f77 6e29 result::unknown) │ │ │ +000383a0: 3b0a 0a09 2f2f 2074 6865 2073 6574 5f62 ;...// the set_b │ │ │ +000383b0: 6c6f 636b 2061 626f 7665 2072 616e 2061 lock above ran a │ │ │ +000383c0: 6c6c 6f63 6174 655f 6675 6c6c 2829 2c20 llocate_full(), │ │ │ +000383d0: 6272 696e 6769 6e67 2075 7320 6261 636b bringing us back │ │ │ +000383e0: 2074 6f20 6675 6c6c 5f74 7265 650a 092f to full_tree../ │ │ │ +000383f0: 2f20 6d6f 6465 2077 6865 7265 2076 6572 / mode where ver │ │ │ +00038400: 6966 6965 645f 6c65 6166 7328 292f 626c ified_leafs()/bl │ │ │ +00038410: 6f63 6b73 5f76 6572 6966 6965 6428 2920 ocks_verified() │ │ │ +00038420: 636f 6e73 756c 7420 6d5f 626c 6f63 6b5f consult m_block_ │ │ │ +00038430: 7665 7269 6669 6564 0a09 2f2f 2064 6972 verified..// dir │ │ │ +00038440: 6563 746c 7920 2869 6e20 7069 6563 655f ectly (in piece_ │ │ │ +00038450: 6c61 7965 7220 6d6f 6465 2074 6865 7920 layer mode they │ │ │ +00038460: 6967 6e6f 7265 2069 7429 2e20 616c 6c6f ignore it). allo │ │ │ +00038470: 6361 7465 5f66 756c 6c27 7320 7265 7369 cate_full's resi │ │ │ +00038480: 7a65 0a09 2f2f 2070 7265 7365 7276 6573 ze..// preserves │ │ │ +00038490: 2061 6e79 2070 7265 2d65 7869 7374 696e any pre-existin │ │ │ +000384a0: 6720 6269 7473 2c20 736f 2068 6164 206c g bits, so had l │ │ │ +000384b0: 6f61 645f 7069 6563 655f 6c61 7965 7220 oad_piece_layer │ │ │ +000384c0: 6661 696c 6564 2074 6f0a 092f 2f20 636c failed to..// cl │ │ │ +000384d0: 6561 7220 7468 656d 2074 6865 2073 7461 ear them the sta │ │ │ +000384e0: 6c65 2070 6965 6365 2d30 2062 6974 7320 le piece-0 bits │ │ │ +000384f0: 776f 756c 6420 7265 7375 7266 6163 6520 would resurface │ │ │ +00038500: 6173 2022 7665 7269 6669 6564 2220 6865 as "verified" he │ │ │ +00038510: 7265 202d 2d0a 092f 2f20 6361 7463 6869 re --..// catchi │ │ │ +00038520: 6e67 2074 6865 2062 7567 2065 7665 6e20 ng the bug even │ │ │ +00038530: 696e 2062 7569 6c64 7320 636f 6d70 696c in builds compil │ │ │ +00038540: 6564 2077 6974 686f 7574 2069 6e76 6172 ed without invar │ │ │ +00038550: 6961 6e74 2063 6865 636b 732e 0a09 5445 iant checks...TE │ │ │ +00038560: 5354 5f43 4845 434b 2821 742e 626c 6f63 ST_CHECK(!t.bloc │ │ │ +00038570: 6b73 5f76 6572 6966 6965 6428 302c 2062 ks_verified(0, b │ │ │ +00038580: 6c6f 636b 735f 7065 725f 7069 6563 6529 locks_per_piece) │ │ │ +00038590: 293b 0a09 5445 5354 5f43 4845 434b 2874 );..TEST_CHECK(t │ │ │ +000385a0: 2e76 6572 6966 6965 645f 6c65 6166 7328 .verified_leafs( │ │ │ +000385b0: 2920 3d3d 206e 6f6e 655f 7365 7428 6e75 ) == none_set(nu │ │ │ +000385c0: 6d5f 626c 6f63 6b73 2929 3b0a 7d0a 0a3c m_blocks));.}..< │ │ │ +000385d0: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ +000385e0: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ +000385f0: 7769 6474 683d 2231 3030 2522 3e0a 3c2f width="100%">.
    < │ │ │ +00038610: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00038640: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00038670: 2e2f 7465 7374 2f74 6573 745f 746f 7272 ./test/test_torr │ │ │ +00038680: 656e 745f 696e 666f 2e63 7070 3a34 3737 ent_info.cpp:477 │ │ │ +00038690: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573 tes │ │ │ +000386a0: 7420 7265 6d61 705f 6669 6c65 733c 2f74 t remap_files

    test │ │ │ +00038700: 7265 6d61 705f 6669 6c65 733c 2f68 323e remap_files

    │ │ │ +00038710: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +00038720: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +00038730: 703a 3437 373c 2f68 343e 3c70 7265 2073 p:477

    <
    │ │ │ +00038780: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +000387b0: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +000387e0: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +000387f0: 656e 745f 696e 666f 2e63 7070 3a34 3738  ent_info.cpp:478
    │ │ │ +00038800: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +00038810: 7265 6e74 2077 6974 6820 2770 2720 2870  rent with 'p' (p
    │ │ │ +00038820: 6164 6669 6c65 2920 6174 7472 6962 7574  adfile) attribut
    │ │ │ +00038830: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069  e

    t │ │ │ +00038880: 6f72 7265 6e74 2077 6974 6820 2770 2720 orrent with 'p' │ │ │ +00038890: 2870 6164 6669 6c65 2920 6174 7472 6962 (padfile) attrib │ │ │ +000388a0: 7574 653c 2f68 323e 3c68 343e 2e2e 2f74 ute

    ../t │ │ │ +000388b0: 6573 742f 7465 7374 5f74 6f72 7265 6e74 est/test_torrent │ │ │ +000388c0: 5f69 6e66 6f2e 6370 703a 3437 383c 2f68 _info.cpp:478
    rel
    │ │ │ +00038940: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../test/t
    │ │ │ +00038980: 6573 745f 746f 7272 656e 745f 696e 666f  est_torrent_info
    │ │ │ +00038990: 2e63 7070 3a34 3739 3c2f 613e 3c2f 7464  .cpp:479torrent wit
    │ │ │ +000389b0: 6820 2768 2720 2868 6964 6465 6e29 2061  h 'h' (hidden) a
    │ │ │ +000389c0: 7474 7269 6275 7465 3c2f 7464 3e3c 2f74  ttribute

    torrent wi │ │ │ +00038a20: 7468 2027 6827 2028 6869 6464 656e 2920 th 'h' (hidden) │ │ │ +00038a30: 6174 7472 6962 7574 653c 2f68 323e 3c68 attribute

    ../test/test_t │ │ │ +00038a50: 6f72 7265 6e74 5f69 6e66 6f2e 6370 703a orrent_info.cpp: │ │ │ +00038a60: 3437 393c 2f68 343e 3c70 7265 2073 7479 479

    <
    │ │ │ +00038ad0: 7464 3e72 656c 6576 616e 6365 266e 6273  td>relevance&nbs
    │ │ │ +00038ae0: 703b 303c 2f74 643e 3c74 643e 3c61 2068  p;0../
    │ │ │ +00038b10: 7465 7374 2f74 6573 745f 746f 7272 656e  test/test_torren
    │ │ │ +00038b20: 745f 696e 666f 2e63 7070 3a34 3830 3c2f  t_info.cpp:480torre
    │ │ │ +00038b40: 6e74 2077 6974 6820 2778 2720 2865 7865  nt with 'x' (exe
    │ │ │ +00038b50: 6375 7461 626c 6529 2061 7474 7269 6275  cutable) attribu
    │ │ │ +00038b60: 7465 3c2f 7464 3e3c 2f74 723e 3c74 7220  te

    │ │ │ +00038bb0: 746f 7272 656e 7420 7769 7468 2027 7827 torrent with 'x' │ │ │ +00038bc0: 2028 6578 6563 7574 6162 6c65 2920 6174 (executable) at │ │ │ +00038bd0: 7472 6962 7574 653c 2f68 323e 3c68 343e tribute

    │ │ │ +00038be0: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72 ../test/test_tor │ │ │ +00038bf0: 7265 6e74 5f69 6e66 6f2e 6370 703a 3438 rent_info.cpp:48 │ │ │ +00038c00: 303c 2f68 343e 3c70 7265 2073 7479 6c65 0

    │ │ │ +00038c40: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ +00038c50: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00038c80: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../te │ │ │ +00038cb0: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ +00038cc0: 696e 666f 2e63 7070 3a34 3831 3c2f 613e info.cpp:481 │ │ │ +00038cd0: 3c2f 7464 3e3c 7464 3e74 6f72 7265 6e74 torrent │ │ │ +00038ce0: 2077 6974 6820 276c 2720 2873 796d 6c69 with 'l' (symli │ │ │ +00038cf0: 6e6b 2920 6174 7472 6962 7574 653c 2f74 nk) attribute

    torre │ │ │ +00038d50: 6e74 2077 6974 6820 276c 2720 2873 796d nt with 'l' (sym │ │ │ +00038d60: 6c69 6e6b 2920 6174 7472 6962 7574 653c link) attribute< │ │ │ +00038d70: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +00038d80: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ +00038d90: 6f2e 6370 703a 3438 313c 2f68 343e 3c70 o.cpp:481

    relevan │ │ │ +00038e10: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ +00038e50: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ +00038e60: 3a34 3832 3c2f 613e 3c2f 7464 3e3c 7464 :482torrent with mu │ │ │ +00038e80: 6c74 6970 6c65 2074 7261 636b 6572 7320 ltiple trackers │ │ │ +00038e90: 696e 206d 756c 7469 706c 6520 7469 6572 in multiple tier │ │ │ +00038ea0: 732c 206d 616b 696e 6720 7375 7265 2077 s, making sure w │ │ │ +00038eb0: 6520 7368 7566 666c 6520 7468 656d 2028 e shuffle them ( │ │ │ +00038ec0: 686f 7720 646f 2079 6f75 2074 6573 7420 how do you test │ │ │ +00038ed0: 7368 7566 666c 696e 673f 2c20 6c6f 6164 shuffling?, load │ │ │ +00038ee0: 2069 7420 6d75 6c74 6970 6c65 2074 696d it multiple tim │ │ │ +00038ef0: 6573 2061 6e64 206d 616b 6520 7375 7265 es and make sure │ │ │ +00038f00: 2069 7427 7320 696e 2064 6966 6665 7265 it's in differe │ │ │ +00038f10: 6e74 206f 7264 6572 2061 7420 6c65 6173 nt order at leas │ │ │ +00038f20: 7420 6f6e 6365 293c 2f74 643e 3c2f 7472 t once)

    torrent wit │ │ │ +00038f80: 6820 6d75 6c74 6970 6c65 2074 7261 636b h multiple track │ │ │ +00038f90: 6572 7320 696e 206d 756c 7469 706c 6520 ers in multiple │ │ │ +00038fa0: 7469 6572 732c 206d 616b 696e 6720 7375 tiers, making su │ │ │ +00038fb0: 7265 2077 650a 7368 7566 666c 6520 7468 re we.shuffle th │ │ │ +00038fc0: 656d 2028 686f 7720 646f 2079 6f75 2074 em (how do you t │ │ │ +00038fd0: 6573 7420 7368 7566 666c 696e 673f 2c20 est shuffling?, │ │ │ +00038fe0: 6c6f 6164 2069 7420 6d75 6c74 6970 6c65 load it multiple │ │ │ +00038ff0: 2074 696d 6573 2061 6e64 206d 616b 650a times and make. │ │ │ +00039000: 7375 7265 2069 7427 7320 696e 2064 6966 sure it's in dif │ │ │ +00039010: 6665 7265 6e74 206f 7264 6572 2061 7420 ferent order at │ │ │ +00039020: 6c65 6173 7420 6f6e 6365 293c 2f68 323e least once)

    │ │ │ +00039030: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +00039040: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +00039050: 703a 3438 323c 2f68 343e 3c70 7265 2073 p:482

    <
    │ │ │ +000390a0: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +000390d0: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +00039100: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +00039110: 656e 745f 696e 666f 2e63 7070 3a34 3835  ent_info.cpp:485
    │ │ │ +00039120: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +00039130: 7265 6e74 7320 7769 7468 2061 207a 6572  rents with a zer
    │ │ │ +00039140: 6f2d 6c65 6e67 7468 206e 616d 653c 2f74  o-length name

    torre │ │ │ +000391a0: 6e74 7320 7769 7468 2061 207a 6572 6f2d nts with a zero- │ │ │ +000391b0: 6c65 6e67 7468 206e 616d 653c 2f68 323e length name

    │ │ │ +000391c0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +000391d0: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +000391e0: 703a 3438 353c 2f68 343e 3c70 7265 2073 p:485

    <
    │ │ │ +00039230: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +00039260: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +00039290: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +000392a0: 656e 745f 696e 666f 2e63 7070 3a34 3836  ent_info.cpp:486
    │ │ │ +000392b0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +000392c0: 7265 6e74 2077 6974 6820 6120 6e6f 6e2d  rent with a non-
    │ │ │ +000392d0: 6469 6374 696f 6e61 7279 2069 6e66 6f2d  dictionary info-
    │ │ │ +000392e0: 7365 6374 696f 6e3c 2f74 643e 3c2f 7472  section

    torrent wit │ │ │ +00039340: 6820 6120 6e6f 6e2d 6469 6374 696f 6e61 h a non-dictiona │ │ │ +00039350: 7279 2069 6e66 6f2d 7365 6374 696f 6e3c ry info-section< │ │ │ +00039360: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +00039370: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ +00039380: 6f2e 6370 703a 3438 363c 2f68 343e 3c70 o.cpp:486

    relevan │ │ │ +00039400: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ +00039440: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ +00039450: 3a34 3837 3c2f 613e 3c2f 7464 3e3c 7464 :487torrents with D │ │ │ +00039470: 4854 206e 6f64 6573 3c2f 7464 3e3c 2f74 HT nodes

    torrents w │ │ │ +000394d0: 6974 6820 4448 5420 6e6f 6465 733c 2f68 ith DHT nodes

    ../test/te │ │ │ +000394f0: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e st_torrent_info. │ │ │ +00039500: 6370 703a 3438 373c 2f68 343e 3c70 7265 cpp:487

    relevance
    │ │ │ +00039580: 266e 6273 703b 303c 2f74 643e 3c74 643e   0
    │ │ │ +00039590: 3c61 2068 7265 663d 226a 6176 6173 6372  ../test/test_to
    │ │ │ +000395c0: 7272 656e 745f 696e 666f 2e63 7070 3a34  rrent_info.cpp:4
    │ │ │ +000395d0: 3838 3c2f 613e 3c2f 7464 3e3c 7464 3e74  88t
    │ │ │ +000395e0: 6f72 7265 6e74 2077 6974 6820 7572 6c2d  orrent with url-
    │ │ │ +000395f0: 6c69 7374 2061 7320 6120 7369 6e67 6c65  list as a single
    │ │ │ +00039600: 2073 7472 696e 673c 2f74 643e 3c2f 7472   string

    torrent wit │ │ │ +00039660: 6820 7572 6c2d 6c69 7374 2061 7320 6120 h url-list as a │ │ │ +00039670: 7369 6e67 6c65 2073 7472 696e 673c 2f68 single string

    ../test/te │ │ │ +00039690: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e st_torrent_info. │ │ │ +000396a0: 6370 703a 3438 383c 2f68 343e 3c70 7265 cpp:488

    relevance
    │ │ │ +00039720: 266e 6273 703b 303c 2f74 643e 3c74 643e   0
    │ │ │ +00039730: 3c61 2068 7265 663d 226a 6176 6173 6372  ../test/test_to
    │ │ │ +00039760: 7272 656e 745f 696e 666f 2e63 7070 3a34  rrent_info.cpp:4
    │ │ │ +00039770: 3839 3c2f 613e 3c2f 7464 3e3c 7464 3e74  89t
    │ │ │ +00039780: 6f72 7265 6e74 2077 6974 6820 6874 7470  orrent with http
    │ │ │ +00039790: 2073 6565 6420 6173 2061 2073 696e 676c   seed as a singl
    │ │ │ +000397a0: 6520 7374 7269 6e67 3c2f 7464 3e3c 2f74  e string

    torrent wi │ │ │ +00039800: 7468 2068 7474 7020 7365 6564 2061 7320 th http seed as │ │ │ +00039810: 6120 7369 6e67 6c65 2073 7472 696e 673c a single string< │ │ │ +00039820: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +00039830: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ +00039840: 6f2e 6370 703a 3438 393c 2f68 343e 3c70 o.cpp:489

    relevan │ │ │ +000398c0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ +00039900: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ +00039910: 3a34 3930 3c2f 613e 3c2f 7464 3e3c 7464 :490torrent with a │ │ │ +00039930: 636f 6d6d 656e 743c 2f74 643e 3c2f 7472 comment

    torrent wit │ │ │ +00039990: 6820 6120 636f 6d6d 656e 743c 2f68 323e h a comment

    │ │ │ +000399a0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +000399b0: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +000399c0: 703a 3439 303c 2f68 343e 3c70 7265 2073 p:490

    <
    │ │ │ +00039a10: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +00039a40: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +00039a70: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +00039a80: 656e 745f 696e 666f 2e63 7070 3a34 3931  ent_info.cpp:491
    │ │ │ +00039a90: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +00039aa0: 7265 6e74 2077 6974 6820 616e 2053 534c  rent with an SSL
    │ │ │ +00039ab0: 2063 6572 743c 2f74 643e 3c2f 7472 3e3c   cert<
    │ │ │ +00039ac0: 7472 2069 643d 2231 3434 2220 7374 796c  tr id="144" styl
    │ │ │ +00039ad0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65  e="display: none
    │ │ │ +00039ae0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c  ;" colspan="3"><
    │ │ │ +00039af0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c  td colspan="3"><
    │ │ │ +00039b00: 6832 3e74 6f72 7265 6e74 2077 6974 6820  h2>torrent with 
    │ │ │ +00039b10: 616e 2053 534c 2063 6572 743c 2f68 323e  an SSL cert
    │ │ │ +00039b20: 3c68 343e 2e2e 2f74 6573 742f 7465 7374  

    ../test/test │ │ │ +00039b30: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +00039b40: 703a 3439 313c 2f68 343e 3c70 7265 2073 p:491

    <
    │ │ │ +00039b90: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +00039bc0: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +00039bf0: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +00039c00: 656e 745f 696e 666f 2e63 7070 3a34 3932  ent_info.cpp:492
    │ │ │ +00039c10: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +00039c20: 7265 6e74 2077 6974 6820 6174 7472 6962  rent with attrib
    │ │ │ +00039c30: 7574 6573 2028 6578 6563 7574 6162 6c65  utes (executable
    │ │ │ +00039c40: 2061 6e64 2068 6964 6465 6e29 3c2f 7464   and hidden)

    torren │ │ │ +00039ca0: 7420 7769 7468 2061 7474 7269 6275 7465 t with attribute │ │ │ +00039cb0: 7320 2865 7865 6375 7461 626c 6520 616e s (executable an │ │ │ +00039cc0: 6420 6869 6464 656e 293c 2f68 323e 3c68 d hidden)

    ../test/test_t │ │ │ +00039ce0: 6f72 7265 6e74 5f69 6e66 6f2e 6370 703a orrent_info.cpp: │ │ │ +00039cf0: 3439 323c 2f68 343e 3c70 7265 2073 7479 492
    < │ │ │ +00039d60: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00039d70: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00039da0: 7465 7374 2f74 6573 745f 746f 7272 656e test/test_torren │ │ │ +00039db0: 745f 696e 666f 2e63 7070 3a34 3933 3c2f t_info.cpp:493torre │ │ │ +00039dd0: 6e74 5f69 6e66 6f20 636f 6e73 7472 7563 nt_info construc │ │ │ +00039de0: 746f 7220 7468 6174 2074 616b 6573 2061 tor that takes a │ │ │ +00039df0: 6e20 696e 7661 6c69 6420 6265 6e63 6f64 n invalid bencod │ │ │ +00039e00: 6564 2062 7566 6665 723c 2f74 643e 3c2f ed buffer

    torrent_i │ │ │ +00039e60: 6e66 6f20 636f 6e73 7472 7563 746f 7220 nfo constructor │ │ │ +00039e70: 7468 6174 2074 616b 6573 2061 6e20 696e that takes an in │ │ │ +00039e80: 7661 6c69 6420 6265 6e63 6f64 6564 2062 valid bencoded b │ │ │ +00039e90: 7566 6665 723c 2f68 323e 3c68 343e 2e2e uffer

    .. │ │ │ +00039ea0: 2f74 6573 742f 7465 7374 5f74 6f72 7265 /test/test_torre │ │ │ +00039eb0: 6e74 5f69 6e66 6f2e 6370 703a 3439 333c nt_info.cpp:493< │ │ │ +00039ec0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ +00039f30: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ +00039f40: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../test
    │ │ │ +00039f70: 2f74 6573 745f 746f 7272 656e 745f 696e  /test_torrent_in
    │ │ │ +00039f80: 666f 2e63 7070 3a34 3934 3c2f 613e 3c2f  fo.cpp:494verify_en
    │ │ │ +00039fa0: 636f 6469 6e67 2077 6974 6820 6120 7374  coding with a st
    │ │ │ +00039fb0: 7269 6e67 2074 6861 7420 7472 6967 6765  ring that trigge
    │ │ │ +00039fc0: 7273 2063 6861 7261 6374 6572 2072 6570  rs character rep
    │ │ │ +00039fd0: 6c61 6365 6d65 6e74 3c2f 7464 3e3c 2f74  lacement

    verify_enc │ │ │ +0003a030: 6f64 696e 6720 7769 7468 2061 2073 7472 oding with a str │ │ │ +0003a040: 696e 6720 7468 6174 2074 7269 6767 6572 ing that trigger │ │ │ +0003a050: 7320 6368 6172 6163 7465 7220 7265 706c s character repl │ │ │ +0003a060: 6163 656d 656e 743c 2f68 323e 3c68 343e acement

    │ │ │ +0003a070: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72 ../test/test_tor │ │ │ +0003a080: 7265 6e74 5f69 6e66 6f2e 6370 703a 3439 rent_info.cpp:49 │ │ │ +0003a090: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ +0003a0d0: 097b 2022 7632 5f69 6e76 616c 6964 5f70  .{ "v2_invalid_p
    │ │ │ +0003a0e0: 6965 6365 5f6c 6179 6572 2e74 6f72 7265  iece_layer.torre
    │ │ │ +0003a0f0: 6e74 222c 2065 7272 6f72 733a 3a74 6f72  nt", errors::tor
    │ │ │ +0003a100: 7265 6e74 5f69 6e76 616c 6964 5f70 6965  rent_invalid_pie
    │ │ │ +0003a110: 6365 5f6c 6179 6572 7d2c 0a09 7b20 2276  ce_layer},..{ "v
    │ │ │ +0003a120: 325f 696e 7661 6c69 645f 7069 6563 655f  2_invalid_piece_
    │ │ │ +0003a130: 6c61 7965 725f 726f 6f74 2e74 6f72 7265  layer_root.torre
    │ │ │ +0003a140: 6e74 222c 2065 7272 6f72 733a 3a74 6f72  nt", errors::tor
    │ │ │ +0003a150: 7265 6e74 5f69 6e76 616c 6964 5f70 6965  rent_invalid_pie
    │ │ │ +0003a160: 6365 5f6c 6179 6572 7d2c 0a09 7b20 2276  ce_layer},..{ "v
    │ │ │ +0003a170: 325f 756e 6b6e 6f77 6e5f 7069 6563 655f  2_unknown_piece_
    │ │ │ +0003a180: 6c61 7965 725f 656e 7472 792e 746f 7272  layer_entry.torr
    │ │ │ +0003a190: 656e 7422 2c20 6572 726f 7273 3a3a 746f  ent", errors::to
    │ │ │ +0003a1a0: 7272 656e 745f 696e 7661 6c69 645f 7069  rrent_invalid_pi
    │ │ │ +0003a1b0: 6563 655f 6c61 7965 727d 2c0a 097b 2022  ece_layer},..{ "
    │ │ │ +0003a1c0: 7632 5f69 6e76 616c 6964 5f70 6965 6365  v2_invalid_piece
    │ │ │ +0003a1d0: 5f6c 6179 6572 5f73 697a 652e 746f 7272  _layer_size.torr
    │ │ │ +0003a1e0: 656e 7422 2c20 6572 726f 7273 3a3a 746f  ent", errors::to
    │ │ │ +0003a1f0: 7272 656e 745f 696e 7661 6c69 645f 7069  rrent_invalid_pi
    │ │ │ +0003a200: 6563 655f 6c61 7965 727d 2c0a 097b 2022  ece_layer},..{ "
    │ │ │ +0003a210: 7632 5f62 6164 5f66 696c 655f 616c 6967  v2_bad_file_alig
    │ │ │ +0003a220: 6e6d 656e 742e 746f 7272 656e 7422 2c20  nment.torrent", 
    │ │ │ +0003a230: 6572 726f 7273 3a3a 746f 7272 656e 745f  errors::torrent_
    │ │ │ +0003a240: 696e 636f 6e73 6973 7465 6e74 5f66 696c  inconsistent_fil
    │ │ │ +0003a250: 6573 7d2c 0a09 7b20 2276 325f 756e 6f72  es},..{ "v2_unor
    │ │ │ +0003a260: 6465 7265 645f 6669 6c65 732e 746f 7272  dered_files.torr
    │ │ │ +0003a270: 656e 7422 2c20 6572 726f 7273 3a3a 696e  ent", errors::in
    │ │ │ +0003a280: 7661 6c69 645f 6265 6e63 6f64 696e 677d  valid_bencoding}
    │ │ │ +0003a290: 2c0a 097b 2022 7632 5f6f 7665 726c 6f6e  ,..{ "v2_overlon
    │ │ │ +0003a2a0: 675f 696e 7465 6765 722e 746f 7272 656e  g_integer.torren
    │ │ │ +0003a2b0: 7422 2c20 6572 726f 7273 3a3a 696e 7661  t", errors::inva
    │ │ │ +0003a2c0: 6c69 645f 6265 6e63 6f64 696e 677d 2c0a  lid_bencoding},.
    │ │ │ +0003a2d0: 097b 2022 7632 5f6d 6973 7369 6e67 5f66  .{ "v2_missing_f
    │ │ │ +0003a2e0: 696c 655f 726f 6f74 5f69 6e76 616c 6964  ile_root_invalid
    │ │ │ +0003a2f0: 5f73 796d 6c69 6e6b 2e74 6f72 7265 6e74  _symlink.torrent
    │ │ │ +0003a300: 222c 2065 7272 6f72 733a 3a74 6f72 7265  ", errors::torre
    │ │ │ +0003a310: 6e74 5f6d 6973 7369 6e67 5f70 6965 6365  nt_missing_piece
    │ │ │ +0003a320: 735f 726f 6f74 7d2c 0a09 7b20 2276 325f  s_root},..{ "v2_
    │ │ │ +0003a330: 6c61 7267 655f 6669 6c65 2e74 6f72 7265  large_file.torre
    │ │ │ +0003a340: 6e74 222c 2065 7272 6f72 733a 3a74 6f72  nt", errors::tor
    │ │ │ +0003a350: 7265 6e74 5f69 6e76 616c 6964 5f6c 656e  rent_invalid_len
    │ │ │ +0003a360: 6774 687d 2c0a 097b 2022 7632 5f6c 6172  gth},..{ "v2_lar
    │ │ │ +0003a370: 6765 5f6f 6666 7365 742e 746f 7272 656e  ge_offset.torren
    │ │ │ +0003a380: 7422 2c20 6572 726f 7273 3a3a 746f 6f5f  t", errors::too_
    │ │ │ +0003a390: 6d61 6e79 5f70 6965 6365 735f 696e 5f74  many_pieces_in_t
    │ │ │ +0003a3a0: 6f72 7265 6e74 7d2c 0a09 7b20 2276 325f  orrent},..{ "v2_
    │ │ │ +0003a3b0: 7069 6563 655f 7369 7a65 2e74 6f72 7265  piece_size.torre
    │ │ │ +0003a3c0: 6e74 222c 2065 7272 6f72 733a 3a74 6f72  nt", errors::tor
    │ │ │ +0003a3d0: 7265 6e74 5f6d 6973 7369 6e67 5f70 6965  rent_missing_pie
    │ │ │ +0003a3e0: 6365 5f6c 656e 6774 687d 2c0a 097b 2022  ce_length},..{ "
    │ │ │ +0003a3f0: 7632 5f69 6e76 616c 6964 5f70 6164 5f66  v2_invalid_pad_f
    │ │ │ +0003a400: 696c 652e 746f 7272 656e 7422 2c20 6572  ile.torrent", er
    │ │ │ +0003a410: 726f 7273 3a3a 746f 7272 656e 745f 696e  rors::torrent_in
    │ │ │ +0003a420: 7661 6c69 645f 7061 645f 6669 6c65 7d2c  valid_pad_file},
    │ │ │ +0003a430: 0a09 7b20 2276 325f 7a65 726f 5f72 6f6f  ..{ "v2_zero_roo
    │ │ │ +0003a440: 742e 746f 7272 656e 7422 2c20 6572 726f  t.torrent", erro
    │ │ │ +0003a450: 7273 3a3a 746f 7272 656e 745f 6d69 7373  rs::torrent_miss
    │ │ │ +0003a460: 696e 675f 7069 6563 6573 5f72 6f6f 747d  ing_pieces_root}
    │ │ │ +0003a470: 2c0a 097b 2022 7632 5f7a 6572 6f5f 726f  ,..{ "v2_zero_ro
    │ │ │ +0003a480: 6f74 5f73 6d61 6c6c 2e74 6f72 7265 6e74  ot_small.torrent
    │ │ │ +0003a490: 222c 2065 7272 6f72 733a 3a74 6f72 7265  ", errors::torre
    │ │ │ +0003a4a0: 6e74 5f6d 6973 7369 6e67 5f70 6965 6365  nt_missing_piece
    │ │ │ +0003a4b0: 735f 726f 6f74 7d2c 0a09 7b20 2276 325f  s_root},..{ "v2_
    │ │ │ +0003a4c0: 656d 7074 795f 6669 6c65 6e61 6d65 2e74  empty_filename.t
    │ │ │ +0003a4d0: 6f72 7265 6e74 222c 2065 7272 6f72 733a  orrent", errors:
    │ │ │ +0003a4e0: 3a74 6f72 7265 6e74 5f66 696c 655f 7061  :torrent_file_pa
    │ │ │ +0003a4f0: 7273 655f 6661 696c 6564 7d2c 0a09 7b20  rse_failed},..{ 
    │ │ │ +0003a500: 2264 7570 6c69 6361 7465 5f66 696c 6573  "duplicate_files
    │ │ │ +0003a510: 322e 746f 7272 656e 7422 2c20 6572 726f  2.torrent", erro
    │ │ │ +0003a520: 7273 3a3a 746f 6f5f 6d61 6e79 5f64 7570  rs::too_many_dup
    │ │ │ +0003a530: 6c69 6361 7465 5f66 696c 656e 616d 6573  licate_filenames
    │ │ │ +0003a540: 7d2c 0a7d 3b0a 0a7d 202f 2f20 616e 6f6e  },.};..} // anon
    │ │ │ +0003a550: 796d 6f75 7320 6e61 6d65 7370 6163 650a  ymous namespace.
    │ │ │ +0003a560: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0003a590: 3c2f 6469 763e 2369 6620 544f 5252 454e
    #if TORREN │ │ │ +0003a5a0: 545f 4142 495f 5645 5253 494f 4e20 266c T_ABI_VERSION &l │ │ │ +0003a5b0: 743b 2034 0a54 4f52 5245 4e54 5f54 4553 t; 4.TORRENT_TES │ │ │ +0003a5c0: 5428 6164 645f 7472 6163 6b65 7229 0a7b T(add_tracker).{ │ │ │ +0003a5d0: 0a09 746f 7272 656e 745f 696e 666f 2074 ..torrent_info t │ │ │ +0003a5e0: 6928 696e 666f 5f68 6173 685f 7428 7368 i(info_hash_t(sh │ │ │ +0003a5f0: 6131 5f68 6173 6828 2220 2020 2020 2020 a1_hash(" │ │ │ +0003a600: 2020 2020 2020 2020 2020 2020 2229 2929 "))) │ │ │ +0003a610: 3b0a 0954 4553 545f 4551 5541 4c28 7469 ;..TEST_EQUAL(ti │ │ │ +0003a620: 2e74 7261 636b 6572 7328 292e 7369 7a65 .trackers().size │ │ │ +0003a630: 2829 2c20 3029 3b0a 0a09 7469 2e61 6464 (), 0);...ti.add │ │ │ +0003a640: 5f74 7261 636b 6572 2822 6874 7470 3a2f _tracker("http:/ │ │ │ +0003a650: 2f74 6573 742e 636f 6d2f 616e 6e6f 756e /test.com/announ │ │ │ +0003a660: 6365 2229 3b0a 0954 4553 545f 4551 5541 ce");..TEST_EQUA │ │ │ +0003a670: 4c28 7469 2e74 7261 636b 6572 7328 292e L(ti.trackers(). │ │ │ +0003a680: 7369 7a65 2829 2c20 3129 3b0a 0a09 616e size(), 1);...an │ │ │ +0003a690: 6e6f 756e 6365 5f65 6e74 7279 2061 6520 nounce_entry ae │ │ │ +0003a6a0: 3d20 7469 2e74 7261 636b 6572 7328 295b = ti.trackers()[ │ │ │ +0003a6b0: 305d 3b0a 0954 4553 545f 4551 5541 4c28 0];..TEST_EQUAL( │ │ │ +0003a6c0: 6165 2e75 726c 2c20 2268 7474 703a 2f2f ae.url, "http:// │ │ │ +0003a6d0: 7465 7374 2e63 6f6d 2f61 6e6e 6f75 6e63 test.com/announc │ │ │ +0003a6e0: 6522 293b 0a0a 0974 692e 636c 6561 725f e");...ti.clear_ │ │ │ +0003a6f0: 7472 6163 6b65 7273 2829 3b0a 0954 4553 trackers();..TES │ │ │ +0003a700: 545f 4551 5541 4c28 7469 2e74 7261 636b T_EQUAL(ti.track │ │ │ +0003a710: 6572 7328 292e 7369 7a65 2829 2c20 3029 ers().size(), 0) │ │ │ +0003a720: 3b0a 7d0a 0a54 4f52 5245 4e54 5f54 4553 ;.}..TORRENT_TES │ │ │ +0003a730: 5428 7572 6c5f 6c69 7374 5f64 7570 6c69 T(url_list_dupli │ │ │ +0003a740: 6361 7465 290a 7b0a 0965 6e74 7279 2069 cate).{..entry i │ │ │ +0003a750: 6e66 6f3b 0a09 696e 666f 5b22 7069 6563 nfo;..info["piec │ │ │ +0003a760: 6573 225d 203d 2022 6161 6161 6161 6161 es"] = "aaaaaaaa │ │ │ +0003a770: 6161 6161 6161 6161 6161 6161 223b 0a09 aaaaaaaaaaaa";.. │ │ │ +0003a780: 696e 666f 5b22 6e61 6d65 2e75 7466 2d38 info["name.utf-8 │ │ │ +0003a790: 225d 203d 2022 7465 7374 3122 3b0a 0969 "] = "test1";..i │ │ │ +0003a7a0: 6e66 6f5b 226e 616d 6522 5d20 3d20 2274 nfo["name"] = "t │ │ │ +0003a7b0: 6573 745f 5f22 3b0a 0969 6e66 6f5b 2270 est__";..info["p │ │ │ +0003a7c0: 6965 6365 206c 656e 6774 6822 5d20 3d20 iece length"] = │ │ │ +0003a7d0: 3136 202a 2031 3032 343b 0a09 696e 666f 16 * 1024;..info │ │ │ +0003a7e0: 5b22 6c65 6e67 7468 225d 203d 2033 3234 ["length"] = 324 │ │ │ +0003a7f0: 353b 0a09 656e 7472 793a 3a6c 6973 745f 5;..entry::list_ │ │ │ +0003a800: 7479 7065 206c 3b0a 096c 2e70 7573 685f type l;..l.push_ │ │ │ +0003a810: 6261 636b 2865 6e74 7279 2822 6874 7470 back(entry("http │ │ │ +0003a820: 3a2f 2f66 6f6f 2e63 6f6d 2f62 6172 3122 ://foo.com/bar1" │ │ │ +0003a830: 2929 3b0a 096c 2e70 7573 685f 6261 636b ));..l.push_back │ │ │ +0003a840: 2865 6e74 7279 2822 6874 7470 3a2f 2f66 (entry("http://f │ │ │ +0003a850: 6f6f 2e63 6f6d 2f62 6172 3122 2929 3b20 oo.com/bar1")); │ │ │ +0003a860: 2f2f 2026 6c74 3b2d 2064 7570 6c69 6361 // <- duplica │ │ │ +0003a870: 7465 0a09 6c2e 7075 7368 5f62 6163 6b28 te..l.push_back( │ │ │ +0003a880: 656e 7472 7928 2268 7474 703a 2f2f 666f entry("http://fo │ │ │ +0003a890: 6f2e 636f 6d2f 6261 7232 2229 293b 0a09 o.com/bar2"));.. │ │ │ +0003a8a0: 656e 7472 7920 636f 6e73 7420 6528 6c29 entry const e(l) │ │ │ +0003a8b0: 3b0a 0965 6e74 7279 2074 6f72 7265 6e74 ;..entry torrent │ │ │ +0003a8c0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +0003a8f0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0003a900: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0003a930: 7465 7374 2f74 6573 745f 7570 6e70 2e63 test/test_upnp.c │ │ │ +0003a940: 7070 3a31 3333 3c2f 613e 3c2f 7464 3e3c pp:133< │ │ │ +0003a950: 7464 3e73 746f 7265 2074 6865 206c 6f67 td>store the log │ │ │ +0003a960: 2061 6e64 2076 6572 6966 7920 7468 6174 and verify that │ │ │ +0003a970: 2073 6f6d 6520 6b65 7920 6d65 7373 6167 some key messag │ │ │ +0003a980: 6573 2061 7265 2074 6865 7265 3c2f 7464 es are there

    store │ │ │ +0003a9e0: 7468 6520 6c6f 6720 616e 6420 7665 7269 the log and veri │ │ │ +0003a9f0: 6679 2074 6861 7420 736f 6d65 206b 6579 fy that some key │ │ │ +0003aa00: 206d 6573 7361 6765 7320 6172 6520 7468 messages are th │ │ │ +0003aa10: 6572 653c 2f68 323e 3c68 343e 2e2e 2f74 ere

    ../t │ │ │ +0003aa20: 6573 742f 7465 7374 5f75 706e 702e 6370 est/test_upnp.cp │ │ │ +0003aa30: 703a 3133 333c 2f68 343e 3c70 7265 2073 p:133

    ..., portmap
    │ │ │ +0003aa80: 5f70 726f 746f 636f 6c20 636f 6e73 7420  _protocol const 
    │ │ │ +0003aa90: 7072 6f74 6f63 6f6c 2c20 6572 726f 725f  protocol, error_
    │ │ │ +0003aaa0: 636f 6465 2063 6f6e 7374 2661 6d70 3b20  code const& 
    │ │ │ +0003aab0: 6572 720a 0909 092c 2070 6f72 746d 6170  err...., portmap
    │ │ │ +0003aac0: 5f74 7261 6e73 706f 7274 2c20 6175 783a  _transport, aux:
    │ │ │ +0003aad0: 3a6c 6973 7465 6e5f 736f 636b 6574 5f68  :listen_socket_h
    │ │ │ +0003aae0: 616e 646c 6520 636f 6e73 7426 616d 703b  andle const&
    │ │ │ +0003aaf0: 2920 6f76 6572 7269 6465 0a09 097b 0a09  ) override...{..
    │ │ │ +0003ab00: 0909 6361 6c6c 6261 636b 5f69 6e66 6f20  ..callback_info 
    │ │ │ +0003ab10: 696e 666f 203d 207b 6d61 7070 696e 672c  info = {mapping,
    │ │ │ +0003ab20: 2070 6f72 742c 2065 7272 7d3b 0a09 0909   port, err};....
    │ │ │ +0003ab30: 6361 6c6c 6261 636b 732e 7075 7368 5f62  callbacks.push_b
    │ │ │ +0003ab40: 6163 6b28 696e 666f 293b 0a09 0909 7374  ack(info);....st
    │ │ │ +0003ab50: 643a 3a63 6f75 7420 266c 743b 266c 743b  d::cout <<
    │ │ │ +0003ab60: 2022 6d61 7070 696e 673a 2022 2026 6c74   "mapping: " <
    │ │ │ +0003ab70: 3b26 6c74 3b20 7374 6174 6963 5f63 6173  ;< static_cas
    │ │ │ +0003ab80: 7426 6c74 3b69 6e74 2667 743b 286d 6170  t<int>(map
    │ │ │ +0003ab90: 7069 6e67 290a 0909 0909 266c 743b 266c  ping).....<&l
    │ │ │ +0003aba0: 743b 2022 2c20 706f 7274 3a20 2220 266c  t; ", port: " &l
    │ │ │ +0003abb0: 743b 266c 743b 2070 6f72 7420 266c 743b  t;< port <
    │ │ │ +0003abc0: 266c 743b 2022 2c20 4950 3a20 2220 266c  < ", IP: " &l
    │ │ │ +0003abd0: 743b 266c 743b 2069 700a 0909 0909 266c  t;< ip.....&l
    │ │ │ +0003abe0: 743b 266c 743b 2022 2c20 7072 6f74 6f3a  t;< ", proto:
    │ │ │ +0003abf0: 2022 2026 6c74 3b26 6c74 3b20 7374 6174   " << stat
    │ │ │ +0003ac00: 6963 5f63 6173 7426 6c74 3b69 6e74 2667  ic_cast<int&g
    │ │ │ +0003ac10: 743b 2870 726f 746f 636f 6c29 0a09 0909  t;(protocol)....
    │ │ │ +0003ac20: 0926 6c74 3b26 6c74 3b20 222c 2065 7272  .<< ", err
    │ │ │ +0003ac30: 6f72 3a20 5c22 2220 266c 743b 266c 743b  or: \"" <<
    │ │ │ +0003ac40: 2065 7272 2e6d 6573 7361 6765 2829 2026   err.message() &
    │ │ │ +0003ac50: 6c74 3b26 6c74 3b20 225c 225c 6e22 3b0a  lt;< "\"\n";.
    │ │ │ +0003ac60: 0909 7d0a 0923 6966 6e64 6566 2054 4f52  ..}..#ifndef TOR
    │ │ │ +0003ac70: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ +0003ac80: 4749 4e47 0a09 0962 6f6f 6c20 7368 6f75  GING...bool shou
    │ │ │ +0003ac90: 6c64 5f6c 6f67 5f70 6f72 746d 6170 2870  ld_log_portmap(p
    │ │ │ +0003aca0: 6f72 746d 6170 5f74 7261 6e73 706f 7274  ortmap_transport
    │ │ │ +0003acb0: 2920 636f 6e73 7420 6f76 6572 7269 6465  ) const override
    │ │ │ +0003acc0: 0a09 097b 0a09 0909 7265 7475 726e 2074  ...{....return t
    │ │ │ +0003acd0: 7275 653b 0a09 097d 0a0a 0909 766f 6964  rue;...}....void
    │ │ │ +0003ace0: 206c 6f67 5f70 6f72 746d 6170 2870 6f72   log_portmap(por
    │ │ │ +0003acf0: 746d 6170 5f74 7261 6e73 706f 7274 2c20  tmap_transport, 
    │ │ │ +0003ad00: 6368 6172 2063 6f6e 7374 2a20 6d73 670a  char const* msg.
    │ │ │ +0003ad10: 0909 092c 2061 7578 3a3a 6c69 7374 656e  ..., aux::listen
    │ │ │ +0003ad20: 5f73 6f63 6b65 745f 6861 6e64 6c65 2063  _socket_handle c
    │ │ │ +0003ad30: 6f6e 7374 2661 6d70 3b29 2063 6f6e 7374  onst&) const
    │ │ │ +0003ad40: 206f 7665 7272 6964 650a 0909 7b0a 0909   override...{...
    │ │ │ +0003ad50: 0973 7464 3a3a 636f 7574 2026 6c74 3b26  .std::cout <&
    │ │ │ +0003ad60: 6c74 3b20 2255 506e 503a 2022 2026 6c74  lt; "UPnP: " <
    │ │ │ +0003ad70: 3b26 6c74 3b20 6d73 6720 266c 743b 266c  ;< msg <&l
    │ │ │ +0003ad80: 743b 2073 7464 3a3a 656e 646c 3b0a 3c64  t; std::endl;...}.
    │ │ │ +0003adc0: 3c2f 6469 763e 0923 656e 6469 660a 097d  

    .#endif..} │ │ │ +0003add0: 3b0a 0a61 7578 3a3a 6970 5f69 6e74 6572 ;..aux::ip_inter │ │ │ +0003ade0: 6661 6365 2070 6963 6b5f 7570 6e70 5f69 face pick_upnp_i │ │ │ +0003adf0: 6e74 6572 6661 6365 2829 0a7b 0a09 6c74 nterface().{..lt │ │ │ +0003ae00: 3a3a 696f 5f63 6f6e 7465 7874 2069 6f73 ::io_context ios │ │ │ +0003ae10: 3b0a 0965 7272 6f72 5f63 6f64 6520 6563 ;..error_code ec │ │ │ +0003ae20: 3b0a 0961 7574 6f20 636f 6e73 7420 726f ;..auto const ro │ │ │ +0003ae30: 7574 6573 203d 2061 7578 3a3a 656e 756d utes = aux::enum │ │ │ +0003ae40: 5f72 6f75 7465 7328 696f 732c 2065 6329 _routes(ios, ec) │ │ │ +0003ae50: 3b0a 0969 6620 2865 6329 0a09 7b0a 0909 ;..if (ec)..{... │ │ │ +0003ae60: 7374 643a 3a63 6572 7220 266c 743b 266c std::cerr <&l │ │ │ +0003ae70: 743b 2022 6661 696c 6564 2074 6f20 656e t; "failed to en │ │ │ +0003ae80: 756d 6572 6174 6520 726f 7574 6573 3a20 umerate routes: │ │ │ +0003ae90: 2220 266c 743b 266c 743b 2065 632e 6d65 " << ec.me │ │ │ +0003aea0: 7373 6167 6528 2920 266c 743b 266c 743b ssage() << │ │ │ +0003aeb0: 2027 5c6e 273b 0a09 0954 4553 545f 4348 '\n';...TEST_CH │ │ │ +0003aec0: 4543 4b28 6661 6c73 6529 3b0a 0909 7265 ECK(false);...re │ │ │ +0003aed0: 7475 726e 207b 7d3b 0a09 7d0a 0961 7574 turn {};..}..aut │ │ │ +0003aee0: 6f20 636f 6e73 7420 6966 7320 3d20 6175 o const ifs = au │ │ │ +0003aef0: 783a 3a65 6e75 6d5f 6e65 745f 696e 7465 x::enum_net_inte │ │ │ +0003af00: 7266 6163 6573 2869 6f73 2c20 6563 293b rfaces(ios, ec); │ │ │ +0003af10: 0a09 6966 2028 6563 290a 097b 0a09 0973 ..if (ec)..{...s │ │ │ +0003af20: 7464 3a3a 6365 7272 2026 6c74 3b26 6c74 td::cerr << │ │ │ +0003af30: 3b20 2266 6169 6c65 6420 746f 2065 6e75 ; "failed to enu │ │ │ +0003af40: 6d65 7261 7465 206e 6574 776f 726b 2069 merate network i │ │ │ +0003af50: 6e74 6572 6661 6365 733a 2022 2026 6c74 nterfaces: " < │ │ │ +0003af60: 3b26 6c74 3b20 6563 2e6d 6573 7361 6765 ;< ec.message │ │ │ +0003af70: 2829 2026 6c74 3b26 6c74 3b20 275c 6e27 () << '\n' │ │ │ +0003af80: 3b0a 0909 5445 5354 5f43 4845 434b 2866 ;...TEST_CHECK(f │ │ │ +0003af90: 616c 7365 293b 0a09 0972 6574 7572 6e20 alse);...return │ │ │ +0003afa0: 7b7d 3b0a 097d 0a09 696e 7420 6964 7820 {};..}..int idx │ │ │ +0003afb0: 3d20 303b 0a09 666f 7220 2861 7574 6f20 = 0;..for (auto │ │ │ +0003afc0: 636f 6e73 7426 616d 703b 2066 6163 6520 const& face │ │ │ +0003afd0: 3a20 6966 7329 0a09 7b0a 0909 6966 2028 : ifs)..{...if ( │ │ │ +0003afe0: 2166 6163 652e 696e 7465 7266 6163 655f !face.interface_ │ │ │ +0003aff0: 6164 6472 6573 732e 6973 5f76 3428 2929 address.is_v4()) │ │ │ +0003b000: 2063 6f6e 7469 6e75 653b 0a09 0973 7464 continue;...std │ │ │ +0003b010: 3a3a 636f 7574 2026 6c74 3b26 6c74 3b20 ::cout << │ │ │ +0003b020: 2220 2d20 2220 266c 743b 266c 743b 2069 " - " << i │ │ │ +0003b030: 6478 0a09 0909 266c 743b 266c 743b 2027 dx....<< ' │ │ │ +0003b040: 2027 2026 6c74 3b26 6c74 3b20 6661 6365 ' << face │ │ │ +0003b050: 2e69 6e74 6572 6661 6365 5f61 6464 7265 .interface_addre │ │ │ +0003b060: 7373 2e74 6f5f 7374 7269 6e67 2829 0a09 ss.to_string().. │ │ │ +0003b070: 0909 266c 743b 266c 743b 2027 2027 2026 ..<< ' ' & │ │ │ +0003b080: 6c74 3b26 6c74 3b20 696e 7428 7374 6174 lt;< int(stat │ │ │ +0003b090: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a ic_cast<std:: │ │ │ +0003b0a0: 7569 6e74 385f 7426 6774 3b28 6661 6365 uint8_t>(face │ │ │ +0003b0b0: 2e73 7461 7465 2929 0a09 0909 266c 743b .state))....< │ │ │ +0003b0c0: 266c 743b 2027 2027 2026 6c74 3b26 6c74 < ' ' << │ │ │ +0003b0d0: 3b20 7374 6174 6963 5f63 6173 7426 6c74 ; static_cast< │ │ │ +0003b0e0: 3b73 7464 3a3a 7569 6e74 3332 5f74 2667 ;std::uint32_t&g │ │ │ +0003b0f0: 743b 2866 6163 652e 666c 6167 7329 0a09 t;(face.flags).. │ │ │ +0003b100: 0909 266c 743b 266c 743b 2027 2027 2026 ..<< ' ' & │ │ │ +0003b110: 6c74 3b26 6c74 3b20 6661 6365 2e6e 616d lt;< face.nam │ │ │ +0003b120: 6520 266c 743b 266c 743b 2027 5c6e 273b e << '\n'; │ │ │ +0003b130: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ +0003b170: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../t │ │ │ +0003b1a0: 6573 742f 7465 7374 5f74 696d 6573 7461 est/test_timesta │ │ │ +0003b1b0: 6d70 5f68 6973 746f 7279 2e63 7070 3a33 mp_history.cpp:3 │ │ │ +0003b1c0: 313c 2f61 3e3c 2f74 643e 3c74 643e 7465 1te │ │ │ +0003b1d0: 7374 2074 6865 2063 6173 6520 7768 6572 st the case wher │ │ │ +0003b1e0: 6520 7765 2068 6176 6520 3e20 3132 3020 e we have > 120 │ │ │ +0003b1f0: 7361 6d70 6c65 7320 2861 6e64 2068 6176 samples (and hav │ │ │ +0003b200: 6520 7468 6520 6261 7365 2064 656c 6179 e the base delay │ │ │ +0003b210: 2061 6374 7561 6c6c 7920 6265 2075 7064 actually be upd │ │ │ +0003b220: 6174 6564 293c 2f74 643e 3c2f 7472 3e3c ated)< │ │ │ +0003b230: 7472 2069 643d 2231 3439 2220 7374 796c tr id="149" styl │ │ │ +0003b240: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0003b250: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0003b260: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0003b270: 6832 3e74 6573 7420 7468 6520 6361 7365 h2>test the case │ │ │ +0003b280: 2077 6865 7265 2077 6520 6861 7665 203e where we have > │ │ │ +0003b290: 2031 3230 2073 616d 706c 6573 2028 616e 120 samples (an │ │ │ +0003b2a0: 6420 6861 7665 2074 6865 2062 6173 6520 d have the base │ │ │ +0003b2b0: 6465 6c61 7920 6163 7475 616c 6c79 2062 delay actually b │ │ │ +0003b2c0: 6520 7570 6461 7465 6429 3c2f 6832 3e3c e updated)< │ │ │ +0003b2d0: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +0003b2e0: 7469 6d65 7374 616d 705f 6869 7374 6f72 timestamp_histor │ │ │ +0003b2f0: 792e 6370 703a 3331 3c2f 6834 3e3c 7072 y.cpp:31relevanc │ │ │ +0003b370: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_t │ │ │ +0003b3b0: 696d 6573 7461 6d70 5f68 6973 746f 7279 imestamp_history │ │ │ +0003b3c0: 2e63 7070 3a33 323c 2f61 3e3c 2f74 643e .cpp:32 │ │ │ +0003b3d0: 3c74 643e 7465 7374 2074 6865 2063 6173 test the cas │ │ │ +0003b3e0: 6520 7768 6572 6520 6120 7361 6d70 6c65 e where a sample │ │ │ +0003b3f0: 2069 7320 6c6f 7765 7220 7468 616e 2074 is lower than t │ │ │ +0003b400: 6865 2068 6973 746f 7279 2065 6e74 7279 he history entry │ │ │ +0003b410: 2062 7574 206e 6f74 206c 6f77 6572 2074 but not lower t │ │ │ +0003b420: 6861 6e20 7468 6520 6261 7365 3c2f 7464 han the base

    test t │ │ │ +0003b480: 6865 2063 6173 6520 7768 6572 6520 6120 he case where a │ │ │ +0003b490: 7361 6d70 6c65 2069 7320 6c6f 7765 7220 sample is lower │ │ │ +0003b4a0: 7468 616e 2074 6865 2068 6973 746f 7279 than the history │ │ │ +0003b4b0: 2065 6e74 7279 2062 7574 206e 6f74 206c entry but not l │ │ │ +0003b4c0: 6f77 6572 2074 6861 6e20 7468 6520 6261 ower than the ba │ │ │ +0003b4d0: 7365 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 se

    ../te │ │ │ +0003b4e0: 7374 2f74 6573 745f 7469 6d65 7374 616d st/test_timestam │ │ │ +0003b4f0: 705f 6869 7374 6f72 792e 6370 703a 3332 p_history.cpp:32 │ │ │ +0003b500: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ +0003b540: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +0003b550: 656e 742f 6175 785f 2f74 696d 6573 7461  ent/aux_/timesta
    │ │ │ +0003b560: 6d70 5f68 6973 746f 7279 2e68 7070 220a  mp_history.hpp".
    │ │ │ +0003b570: 0a54 4f52 5245 4e54 5f54 4553 5428 7469  .TORRENT_TEST(ti
    │ │ │ +0003b580: 6d65 7374 616d 705f 6869 7374 6f72 7929  mestamp_history)
    │ │ │ +0003b590: 0a7b 0a09 7573 696e 6720 6e61 6d65 7370  .{..using namesp
    │ │ │ +0003b5a0: 6163 6520 6c74 3b0a 0a09 6175 783a 3a74  ace lt;...aux::t
    │ │ │ +0003b5b0: 696d 6573 7461 6d70 5f68 6973 746f 7279  imestamp_history
    │ │ │ +0003b5c0: 2068 3b0a 0954 4553 545f 4551 5541 4c28   h;..TEST_EQUAL(
    │ │ │ +0003b5d0: 682e 6164 645f 7361 6d70 6c65 2830 7833  h.add_sample(0x3
    │ │ │ +0003b5e0: 322c 2066 616c 7365 292c 2030 293b 0a09  2, false), 0);..
    │ │ │ +0003b5f0: 5445 5354 5f45 5155 414c 2868 2e62 6173  TEST_EQUAL(h.bas
    │ │ │ +0003b600: 6528 292c 2030 7833 3229 3b0a 0954 4553  e(), 0x32);..TES
    │ │ │ +0003b610: 545f 4551 5541 4c28 682e 6164 645f 7361  T_EQUAL(h.add_sa
    │ │ │ +0003b620: 6d70 6c65 2830 7833 332c 2066 616c 7365  mple(0x33, false
    │ │ │ +0003b630: 292c 2030 7831 293b 0a09 5445 5354 5f45  ), 0x1);..TEST_E
    │ │ │ +0003b640: 5155 414c 2868 2e62 6173 6528 292c 2030  QUAL(h.base(), 0
    │ │ │ +0003b650: 7833 3229 3b0a 0954 4553 545f 4551 5541  x32);..TEST_EQUA
    │ │ │ +0003b660: 4c28 682e 6164 645f 7361 6d70 6c65 2830  L(h.add_sample(0
    │ │ │ +0003b670: 7833 3433 332c 2066 616c 7365 292c 2030  x3433, false), 0
    │ │ │ +0003b680: 7833 3430 3129 3b0a 0954 4553 545f 4551  x3401);..TEST_EQ
    │ │ │ +0003b690: 5541 4c28 682e 6261 7365 2829 2c20 3078  UAL(h.base(), 0x
    │ │ │ +0003b6a0: 3332 293b 0a09 5445 5354 5f45 5155 414c  32);..TEST_EQUAL
    │ │ │ +0003b6b0: 2868 2e61 6464 5f73 616d 706c 6528 3078  (h.add_sample(0x
    │ │ │ +0003b6c0: 3330 2c20 6661 6c73 6529 2c20 3029 3b0a  30, false), 0);.
    │ │ │ +0003b6d0: 0954 4553 545f 4551 5541 4c28 682e 6261  .TEST_EQUAL(h.ba
    │ │ │ +0003b6e0: 7365 2829 2c20 3078 3330 293b 0a0a 092f  se(), 0x30);.../
    │ │ │ +0003b6f0: 2f20 7465 7374 2074 6861 7420 7772 6170  / test that wrap
    │ │ │ +0003b700: 7069 6e67 206f 6620 7468 6520 7469 6d65  ping of the time
    │ │ │ +0003b710: 7374 616d 7020 6973 2070 726f 7065 726c  stamp is properl
    │ │ │ +0003b720: 7920 6861 6e64 6c65 640a 0968 2e61 6464  y handled..h.add
    │ │ │ +0003b730: 5f73 616d 706c 6528 3078 6666 6666 6666  _sample(0xffffff
    │ │ │ +0003b740: 6633 2c20 6661 6c73 6529 3b0a 0954 4553  f3, false);..TES
    │ │ │ +0003b750: 545f 4551 5541 4c28 682e 6261 7365 2829  T_EQUAL(h.base()
    │ │ │ +0003b760: 2c20 3078 6666 6666 6666 6633 293b 0a0a  , 0xfffffff3);..
    │ │ │ +0003b770: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    }. │ │ │ +0003b7a0: 3c2f 6469 763e 0a3c 2f70 7265 3e3c 2f74
    .
    relevanc │ │ │ 0003b7e0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/tracker │ │ │ -0003b820: 5f6d 616e 6167 6572 2e63 7070 3a33 3136 _manager.cpp:316 │ │ │ -0003b830: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 6e74 int │ │ │ -0003b840: 726f 6475 6365 2061 2073 6574 7469 6e67 roduce a setting │ │ │ -0003b850: 2066 6f72 206d 6178 5f6f 6666 6572 733c for max_offers< │ │ │ -0003b860: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    int │ │ │ -0003b8b0: 726f 6475 6365 2061 2073 6574 7469 6e67 roduce a setting │ │ │ -0003b8c0: 2066 6f72 206d 6178 5f6f 6666 6572 733c for max_offers< │ │ │ -0003b8d0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ -0003b8e0: 7261 636b 6572 5f6d 616e 6167 6572 2e63 racker_manager.c │ │ │ -0003b8f0: 7070 3a33 3136 3c2f 6834 3e3c 7072 6520 pp:316

    ....{......
    │ │ │ -0003b940: 6d5f 7175 6575 6564 2e70 7573 685f 6261  m_queued.push_ba
    │ │ │ -0003b950: 636b 2873 7464 3a3a 6d6f 7665 2863 6f6e  ck(std::move(con
    │ │ │ -0003b960: 2929 3b0a 0909 0909 7d0a 0909 0909 6d5f  ));.....}.....m_
    │ │ │ -0003b970: 7374 6174 735f 636f 756e 7465 7273 2e73  stats_counters.s
    │ │ │ -0003b980: 6574 5f76 616c 7565 2863 6f75 6e74 6572  et_value(counter
    │ │ │ -0003b990: 733a 3a6e 756d 5f71 7565 7565 645f 7472  s::num_queued_tr
    │ │ │ -0003b9a0: 6163 6b65 725f 616e 6e6f 756e 6365 732c  acker_announces,
    │ │ │ -0003b9b0: 2073 7464 3a3a 696e 7436 345f 7428 6d5f   std::int64_t(m_
    │ │ │ -0003b9c0: 7175 6575 6564 2e73 697a 6528 2929 293b  queued.size()));
    │ │ │ -0003b9d0: 0a09 0909 7d0a 0909 0972 6574 7572 6e3b  ....}....return;
    │ │ │ -0003b9e0: 0a09 097d 0a09 0965 6c73 6520 6966 2028  ...}...else if (
    │ │ │ -0003b9f0: 7072 6f74 6f63 6f6c 203d 3d20 2275 6470  protocol == "udp
    │ │ │ -0003ba00: 2229 0a09 097b 0a09 0909 6175 746f 2063  ")...{....auto c
    │ │ │ -0003ba10: 6f6e 203d 2073 7464 3a3a 6d61 6b65 5f73  on = std::make_s
    │ │ │ -0003ba20: 6861 7265 6426 6c74 3b61 7578 3a3a 7564  hared<aux::ud
    │ │ │ -0003ba30: 705f 7472 6163 6b65 725f 636f 6e6e 6563  p_tracker_connec
    │ │ │ -0003ba40: 7469 6f6e 2667 743b 2869 6f73 2c20 2a74  tion>(ios, *t
    │ │ │ -0003ba50: 6869 732c 2073 7464 3a3a 6d6f 7665 2872  his, std::move(r
    │ │ │ -0003ba60: 6571 292c 2063 293b 0a09 0909 6d5f 7564  eq), c);....m_ud
    │ │ │ -0003ba70: 705f 636f 6e6e 735b 636f 6e2d 2667 743b  p_conns[con->
    │ │ │ -0003ba80: 7472 616e 7361 6374 696f 6e5f 6964 2829  transaction_id()
    │ │ │ -0003ba90: 5d20 3d20 636f 6e3b 0a09 0909 636f 6e2d  ] = con;....con-
    │ │ │ -0003baa0: 2667 743b 7374 6172 7428 293b 0a09 0909  >start();....
    │ │ │ -0003bab0: 7265 7475 726e 3b0a 2020 2020 2020 2020  return;.        
    │ │ │ -0003bac0: 7d0a 2369 6620 544f 5252 454e 545f 5553  }.#if TORRENT_US
    │ │ │ -0003bad0: 455f 5254 430a 2020 2020 2020 2020 656c  E_RTC.        el
    │ │ │ -0003bae0: 7365 2069 6620 2870 726f 746f 636f 6c20  se if (protocol 
    │ │ │ -0003baf0: 3d3d 2022 7773 2220 7c7c 2070 726f 746f  == "ws" || proto
    │ │ │ -0003bb00: 636f 6c20 3d3d 2022 7773 7322 290a 2020  col == "wss").  
    │ │ │ -0003bb10: 2020 2020 2020 7b0a 0909 0973 7464 3a3a        {....std::
    │ │ │ -0003bb20: 7368 6172 6564 5f70 7472 266c 743b 7265  shared_ptr<re
    │ │ │ -0003bb30: 7175 6573 745f 6361 6c6c 6261 636b 2667  quest_callback&g
    │ │ │ -0003bb40: 743b 2063 6220 3d20 632e 6c6f 636b 2829  t; cb = c.lock()
    │ │ │ -0003bb50: 3b0a 0909 0969 6620 2821 6362 2920 7265  ;....if (!cb) re
    │ │ │ -0003bb60: 7475 726e 3b0a 0a3c 6469 7620 7374 796c  turn;..
    ...const in │ │ │ -0003bba0: 7420 6d61 785f 6f66 6665 7273 203d 2031 t max_offers = 1 │ │ │ -0003bbb0: 303b 0a3c 2f64 6976 3e09 0909 7265 712e 0;.
    ...req. │ │ │ -0003bbc0: 6e75 6d5f 7761 6e74 203d 2073 7464 3a3a num_want = std:: │ │ │ -0003bbd0: 6d69 6e28 7265 712e 6e75 6d5f 7761 6e74 min(req.num_want │ │ │ -0003bbe0: 2c20 6d61 785f 6f66 6665 7273 293b 0a09 , max_offers);.. │ │ │ -0003bbf0: 0909 6966 2028 7265 712e 6e75 6d5f 7761 ..if (req.num_wa │ │ │ -0003bc00: 6e74 203d 3d20 3029 0a09 0909 7b0a 0909 nt == 0)....{... │ │ │ -0003bc10: 0909 2f2f 2077 6865 6e20 7765 2772 6520 ..// when we're │ │ │ -0003bc20: 7368 7574 7469 6e67 2064 6f77 6e2c 2077 shutting down, w │ │ │ -0003bc30: 6520 646f 6e27 7420 7265 616c 6c79 2077 e don't really w │ │ │ -0003bc40: 616e 7420 746f 0a09 0909 092f 2f20 7265 ant to.....// re │ │ │ -0003bc50: 2d65 7374 6162 6c69 7368 2074 6865 2070 -establish the p │ │ │ -0003bc60: 6572 7369 7374 656e 7420 7765 6273 6f63 ersistent websoc │ │ │ -0003bc70: 6b65 7420 636f 6e6e 6563 7469 6f6e 206a ket connection j │ │ │ -0003bc80: 7573 7420 746f 0a09 0909 092f 2f20 616e ust to.....// an │ │ │ -0003bc90: 6e6f 756e 6365 2022 7374 6f70 7065 6422 nounce "stopped" │ │ │ -0003bca0: 2c20 616e 6420 6164 7665 7274 6973 6520 , and advertise │ │ │ -0003bcb0: 3020 6f66 6665 7273 2e20 4974 206d 6179 0 offers. It may │ │ │ -0003bcc0: 2068 616e 670a 0909 0909 2f2f 2073 6875 hang.....// shu │ │ │ -0003bcd0: 7464 6f77 6e2e 0a09 0909 0970 6f73 7428 tdown......post( │ │ │ -0003bce0: 696f 732c 2073 7464 3a3a 6269 6e64 2826 ios, std::bind(& │ │ │ -0003bcf0: 616d 703b 7265 7175 6573 745f 6361 6c6c amp;request_call │ │ │ -0003bd00: 6261 636b 3a3a 7472 6163 6b65 725f 7265 back::tracker_re │ │ │ -0003bd10: 7175 6573 745f 6572 726f 722c 2063 622c quest_error, cb, │ │ │ -0003bd20: 2073 7464 3a3a 6d6f 7665 2872 6571 290a std::move(req). │ │ │ -0003bd30: 0909 0909 092c 2065 7272 6f72 733a 3a74 ....., errors::t │ │ │ -0003bd40: 6f72 7265 6e74 5f61 626f 7274 6564 2c20 orrent_aborted, │ │ │ -0003bd50: 6f70 6572 6174 696f 6e5f 743a 3a63 6f6e operation_t::con │ │ │ -0003bd60: 6e65 6374 0a09 0909 0909 2c20 2222 2c20 nect......, "", │ │ │ -0003bd70: 7365 636f 6e64 7333 3228 3029 2929 3b0a seconds32(0)));. │ │ │ -0003bd80: 0909 0909 7265 7475 726e 3b0a 0909 097d ....return;....} │ │ │ -0003bd90: 0a09 0909 6362 2d26 6774 3b67 656e 6572 ....cb->gener │ │ │ -0003bda0: 6174 655f 7274 635f 6f66 6665 7273 2872 ate_rtc_offers(r │ │ │ -0003bdb0: 6571 2e6e 756d 5f77 616e 740a 0909 0909 eq.num_want..... │ │ │ -0003bdc0: 2c20 5b74 6869 732c 2026 616d 703b 696f , [this, &io │ │ │ -0003bdd0: 732c 2072 6571 7565 7374 203d 2073 7464 s, request = std │ │ │ -0003bde0: 3a3a 6d6f 7665 2872 6571 292c 2063 5d28 ::move(req), c]( │ │ │ -0003bdf0: 6572 726f 725f 636f 6465 2063 6f6e 7374 error_code const │ │ │ -0003be00: 2661 6d70 3b20 6563 0a09 0909 0909 2c20 & ec......, │ │ │ -0003be10: 7374 643a 3a76 6563 746f 7226 6c74 3b61 std::vector<a │ │ │ -0003be20: 7578 3a3a 7274 635f 6f66 6665 7226 6774 ux::rtc_offer> │ │ │ -0003be30: 3b20 6f66 6665 7273 2920 6d75 7461 626c ; offers) mutabl │ │ │ -0003be40: 650a 0909 097b 0a09 0909 0969 6620 2821 e....{.....if (! │ │ │ -0003be50: 6563 2920 7265 7175 6573 742e 6f66 6665 ec) request.offe │ │ │ -0003be60: 7273 203d 2073 7464 3a3a 6d6f 7665 286f rs = std::move(o │ │ │ -0003be70: 6666 6572 7329 3b0a 0a09 0909 0961 7574 ffers);......aut │ │ │ -0003be80: 6f20 6974 203d 206d 5f77 6562 736f 636b o it = m_websock │ │ │ -0003be90: 6574 5f63 6f6e 6e73 2e66 696e 6428 7265 et_conns.find(re │ │ │ -0003bea0: 7175 6573 742e 7572 6c29 3b0a 0909 0909 quest.url);..... │ │ │ -0003beb0: 6966 2028 6974 2021 3d20 6d5f 7765 6273 if (it != m_webs │ │ │ -0003bec0: 6f63 6b65 745f 636f 6e6e 732e 656e 6428 ocket_conns.end( │ │ │ -0003bed0: 2920 2661 6d70 3b26 616d 703b 2069 742d ) && it- │ │ │ -0003bee0: 2667 743b 7365 636f 6e64 2d26 6774 3b69 >second->i │ │ │ -0003bef0: 735f 7374 6172 7465 6428 2929 207b 0a09 s_started()) {.. │ │ │ -0003bf00: 0909 0909 6974 2d26 6774 3b73 6563 6f6e ....it->secon │ │ │ -0003bf10: 642d 2667 743b 7175 6575 655f 7265 7175 d->queue_requ │ │ │ -0003bf20: 6573 7428 7374 643a 3a6d 6f76 6528 7265 est(std::move(re │ │ │ -0003bf30: 7175 6573 7429 2c20 6329 3b0a 0909 0909 quest), c);..... │ │ │ -0003bf40: 7d20 656c 7365 207b 0a09 0909 0909 6175 } else {......au │ │ │ -0003bf50: 746f 2063 6f6e 203d 2073 7464 3a3a 6d61 to con = std::ma │ │ │ -0003bf60: 6b65 5f73 6861 7265 6426 6c74 3b61 7578 ke_shared<aux │ │ │ -0003bf70: 3a3a 7765 6273 6f63 6b65 745f 7472 6163 ::websocket_trac │ │ │ -0003bf80: 6b65 725f 636f 6e6e 6563 7469 6f6e 2667 ker_connection&g │ │ │ -0003bf90: 743b 280a 0909 0909 0909 0969 6f73 2c20 t;(........ios, │ │ │ -0003bfa0: 2a74 6869 732c 2073 7464 3a3a 6d6f 7665 *this, std::move │ │ │ -0003bfb0: 2872 6571 7565 7374 292c 2063 293b 0a09 (request), c);.. │ │ │ -0003bfc0: 0909 0909 636f 6e2d 2667 743b 7374 6172 ....con->star │ │ │ -0003bfd0: 7428 293b 0a09 0909 0909 6d5f 7765 6273 t();......m_webs │ │ │ -0003bfe0: 6f63 6b65 745f 636f 6e6e 735b 7265 7175 ocket_conns[requ │ │ │ -0003bff0: 6573 742e 7572 6c5d 203d 2063 6f6e 3b0a est.url] = con;. │ │ │ -0003c000: 0909 0909 7d0a 0909 097d 293b 0a09 0909 ....}....});.... │ │ │ -0003c010: 7265 7475 726e 3b0a 2020 2020 2020 2020 return;. │ │ │ -0003c020: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -0003c050: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0003c060: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0003c090: 7372 632f 616c 6572 742e 6370 703a 3531 src/alert.cpp:51 │ │ │ -0003c0a0: 313c 2f61 3e3c 2f74 643e 3c74 643e 6973 1is │ │ │ -0003c0b0: 2069 7420 7265 6173 6f6e 6162 6c65 2074 it reasonable t │ │ │ -0003c0c0: 6f20 6a75 7374 2068 6172 642d 636f 6465 o just hard-code │ │ │ -0003c0d0: 2074 6869 7320 746f 2056 313f 3c2f 7464 this to V1?

    is it │ │ │ -0003c130: 7265 6173 6f6e 6162 6c65 2074 6f20 6a75 reasonable to ju │ │ │ -0003c140: 7374 2068 6172 642d 636f 6465 2074 6869 st hard-code thi │ │ │ -0003c150: 7320 746f 2056 313f 3c2f 6832 3e3c 6834 s to V1?

    ../src/alert.cp │ │ │ -0003c170: 703a 3531 313c 2f68 343e 3c70 7265 2073 p:511

    .{...TORRENT
    │ │ │ -0003c1c0: 5f41 5353 4552 5428 2175 2e65 6d70 7479  _ASSERT(!u.empty
    │ │ │ -0003c1d0: 2829 293b 0a09 7d0a 0a09 7374 643a 3a73  ());..}...std::s
    │ │ │ -0003c1e0: 7472 696e 6720 7472 6163 6b65 725f 7265  tring tracker_re
    │ │ │ -0003c1f0: 706c 795f 616c 6572 743a 3a6d 6573 7361  ply_alert::messa
    │ │ │ -0003c200: 6765 2829 2063 6f6e 7374 0a09 7b0a 2369  ge() const..{.#i
    │ │ │ -0003c210: 6664 6566 2054 4f52 5245 4e54 5f44 4953  fdef TORRENT_DIS
    │ │ │ -0003c220: 4142 4c45 5f41 4c45 5254 5f4d 5347 0a09  ABLE_ALERT_MSG..
    │ │ │ -0003c230: 0972 6574 7572 6e20 7b7d 3b0a 2365 6c73  .return {};.#els
    │ │ │ -0003c240: 650a 0909 6368 6172 2072 6574 5b34 3030  e...char ret[400
    │ │ │ -0003c250: 5d3b 0a09 0973 7464 3a3a 736e 7072 696e  ];...std::snprin
    │ │ │ -0003c260: 7466 2872 6574 2c20 7369 7a65 6f66 2872  tf(ret, sizeof(r
    │ │ │ -0003c270: 6574 292c 2022 2573 2072 6563 6569 7665  et), "%s receive
    │ │ │ -0003c280: 6420 7065 6572 733a 2025 6422 0a09 0909  d peers: %d"....
    │ │ │ -0003c290: 2c20 7472 6163 6b65 725f 616c 6572 743a  , tracker_alert:
    │ │ │ -0003c2a0: 3a6d 6573 7361 6765 2829 2e63 5f73 7472  :message().c_str
    │ │ │ -0003c2b0: 2829 0a09 0909 2c20 6e75 6d5f 7065 6572  ()...., num_peer
    │ │ │ -0003c2c0: 7329 3b0a 0909 7265 7475 726e 2072 6574  s);...return ret
    │ │ │ -0003c2d0: 3b0a 2365 6e64 6966 0a09 7d0a 0a09 6468  ;.#endif..}...dh
    │ │ │ -0003c2e0: 745f 7265 706c 795f 616c 6572 743a 3a64  t_reply_alert::d
    │ │ │ -0003c2f0: 6874 5f72 6570 6c79 5f61 6c65 7274 2861  ht_reply_alert(a
    │ │ │ -0003c300: 7578 3a3a 7374 6163 6b5f 616c 6c6f 6361  ux::stack_alloca
    │ │ │ -0003c310: 746f 7226 616d 703b 2061 6c6c 6f63 0a09  tor& alloc..
    │ │ │ -0003c320: 092c 2074 6f72 7265 6e74 5f68 616e 646c  ., torrent_handl
    │ │ │ -0003c330: 6520 636f 6e73 7426 616d 703b 2068 0a09  e const& h..
    │ │ │ -0003c340: 092c 2069 6e74 206e 7029 0a3c 6469 7620  ., int np).
    ..: tra │ │ │ -0003c380: 636b 6572 5f61 6c65 7274 2861 6c6c 6f63 cker_alert(alloc │ │ │ -0003c390: 2c20 682c 207b 7d2c 2070 726f 746f 636f , h, {}, protoco │ │ │ -0003c3a0: 6c5f 7665 7273 696f 6e3a 3a56 312c 2022 l_version::V1, " │ │ │ -0003c3b0: 2229 0a3c 2f64 6976 3e09 092c 206e 756d ").
    .., num │ │ │ -0003c3c0: 5f70 6565 7273 286e 7029 0a09 7b7d 0a0a _peers(np)..{}.. │ │ │ -0003c3d0: 0973 7464 3a3a 7374 7269 6e67 2064 6874 .std::string dht │ │ │ -0003c3e0: 5f72 6570 6c79 5f61 6c65 7274 3a3a 6d65 _reply_alert::me │ │ │ -0003c3f0: 7373 6167 6528 2920 636f 6e73 740a 097b ssage() const..{ │ │ │ -0003c400: 0a23 6966 6465 6620 544f 5252 454e 545f .#ifdef TORRENT_ │ │ │ -0003c410: 4449 5341 424c 455f 414c 4552 545f 4d53 DISABLE_ALERT_MS │ │ │ -0003c420: 470a 0909 7265 7475 726e 207b 7d3b 0a23 G...return {};.# │ │ │ -0003c430: 656c 7365 0a09 0963 6861 7220 7265 745b else...char ret[ │ │ │ -0003c440: 3430 305d 3b0a 0909 7374 643a 3a73 6e70 400];...std::snp │ │ │ -0003c450: 7269 6e74 6628 7265 742c 2073 697a 656f rintf(ret, sizeo │ │ │ -0003c460: 6628 7265 7429 2c20 2225 7320 7265 6365 f(ret), "%s rece │ │ │ -0003c470: 6976 6564 2044 4854 2070 6565 7273 3a20 ived DHT peers: │ │ │ -0003c480: 2564 220a 0909 092c 2074 7261 636b 6572 %d"...., tracker │ │ │ -0003c490: 5f61 6c65 7274 3a3a 6d65 7373 6167 6528 _alert::message( │ │ │ -0003c4a0: 292e 635f 7374 7228 292c 206e 756d 5f70 ).c_str(), num_p │ │ │ -0003c4b0: 6565 7273 293b 0a09 0972 6574 7572 6e20 eers);...return │ │ │ -0003c4c0: 7265 743b 0a23 656e 6469 660a 097d 0a0a ret;.#endif..}.. │ │ │ -0003c4d0: 0974 7261 636b 6572 5f61 6e6e 6f75 6e63 .tracker_announc │ │ │ -0003c4e0: 655f 616c 6572 743a 3a74 7261 636b 6572 e_alert::tracker │ │ │ -0003c4f0: 5f61 6e6e 6f75 6e63 655f 616c 6572 7428 _announce_alert( │ │ │ -0003c500: 6175 783a 3a73 7461 636b 5f61 6c6c 6f63 aux::stack_alloc │ │ │ -0003c510: 6174 6f72 2661 6d70 3b20 616c 6c6f 630a ator& alloc. │ │ │ -0003c520: 0909 2c20 746f 7272 656e 745f 6861 6e64 .., torrent_hand │ │ │ -0003c530: 6c65 2063 6f6e 7374 2661 6d70 3b20 682c le const& h, │ │ │ -0003c540: 2074 6370 3a3a 656e 6470 6f69 6e74 2063 tcp::endpoint c │ │ │ -0003c550: 6f6e 7374 2661 6d70 3b20 6570 2c20 7374 onst& ep, st │ │ │ -0003c560: 7269 6e67 5f76 6965 7720 750a 0909 2c20 ring_view u..., │ │ │ -0003c570: 7072 6f74 6f63 6f6c 5f76 6572 7369 6f6e protocol_version │ │ │ -0003c580: 2063 6f6e 7374 2076 2c20 6576 656e 745f const v, event_ │ │ │ -0003c590: 7420 636f 6e73 7420 6529 0a09 093a 2074 t const e)...: t │ │ │ -0003c5a0: 7261 636b 6572 5f61 6c65 7274 2861 6c6c racker_alert(all │ │ │ -0003c5b0: 6f63 2c20 682c 2065 702c 2076 2c20 7529 oc, h, ep, v, u) │ │ │ -0003c5c0: 0a09 092c 2065 7665 6e74 2865 290a 097b ..., event(e)..{ │ │ │ -0003c5d0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0003c5e0: 5428 2175 2e65 6d70 7479 2829 293b 0a09 T(!u.empty());.. │ │ │ -0003c5f0: 7d0a 0a09 7374 643a 3a73 7472 696e 6720 }...std::string │ │ │ -0003c600: 7472 6163 6b65 725f 616e 6e6f 756e 6365 tracker_announce │ │ │ -0003c610: 5f61 6c65 7274 3a3a 6d65 7373 6167 6528 _alert::message( │ │ │ -0003c620: 2920 636f 6e73 740a 097b 0a23 6966 6465 ) const..{.#ifde │ │ │ -0003c630: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ -0003c640: 455f 414c 4552 545f 4d53 470a 0909 7265 E_ALERT_MSG...re │ │ │ -0003c650: 7475 726e 207b 7d3b 0a23 656c 7365 0a09 turn {};.#else.. │ │ │ -0003c660: 0973 7461 7469 6320 636f 6e73 7420 6368 .static const ch │ │ │ -0003c670: 6172 2a20 636f 6e73 7420 6576 656e 745f ar* const event_ │ │ │ -0003c680: 7374 725b 5d20 3d20 7b22 6e6f 6e65 222c str[] = {"none", │ │ │ -0003c690: 2022 636f 6d70 6c65 7465 6422 2c20 2273 "completed", "s │ │ │ -0003c6a0: 7461 7274 6564 222c 2022 7374 6f70 7065 tarted", "stoppe │ │ │ -0003c6b0: 6422 2c20 2270 6175 7365 6422 7d3b 0a3c d", "paused"};.< │ │ │ -0003c6c0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0003c6d0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0003c6e0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0003c6f0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0003c700: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0003c730: 2f75 745f 6d65 7461 6461 7461 2e63 7070 /ut_metadata.cpp │ │ │ -0003c740: 3a32 3536 3c2f 613e 3c2f 7464 3e3c 7464 :256we really need │ │ │ -0003c760: 746f 2069 6e63 7265 6d65 6e74 2074 6865 to increment the │ │ │ -0003c770: 2072 6566 636f 756e 7465 7220 6f6e 2074 refcounter on t │ │ │ -0003c780: 6865 2074 6f72 7265 6e74 2077 6869 6c65 he torrent while │ │ │ -0003c790: 2074 6869 7320 6275 6666 6572 2069 7320 this buffer is │ │ │ -0003c7a0: 7374 696c 6c20 696e 2074 6865 2070 6565 still in the pee │ │ │ -0003c7b0: 7227 7320 7365 6e64 2062 7566 6665 723c r's send buffer< │ │ │ -0003c7c0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    we │ │ │ -0003c810: 7265 616c 6c79 206e 6565 6420 746f 2069 really need to i │ │ │ -0003c820: 6e63 7265 6d65 6e74 2074 6865 2072 6566 ncrement the ref │ │ │ -0003c830: 636f 756e 7465 7220 6f6e 2074 6865 2074 counter on the t │ │ │ -0003c840: 6f72 7265 6e74 0a77 6869 6c65 2074 6869 orrent.while thi │ │ │ -0003c850: 7320 6275 6666 6572 2069 7320 7374 696c s buffer is stil │ │ │ -0003c860: 6c20 696e 2074 6865 2070 6565 7227 7320 l in the peer's │ │ │ -0003c870: 7365 6e64 2062 7566 6665 723c 2f68 323e send buffer

    │ │ │ -0003c880: 3c68 343e 2e2e 2f73 7263 2f75 745f 6d65

    ../src/ut_me │ │ │ -0003c890: 7461 6461 7461 2e63 7070 3a32 3536 3c2f tadata.cpp:256
    ...
    │ │ │ -0003c8e0: 0969 6e74 2063 6f6e 7374 206f 6666 7365  .int const offse
    │ │ │ -0003c8f0: 7420 3d20 7069 6563 6520 2a20 3136 202a  t = piece * 16 *
    │ │ │ -0003c900: 2031 3032 343b 0a09 0909 096d 6574 6164   1024;.....metad
    │ │ │ -0003c910: 6174 6120 3d20 6d5f 7470 2e6d 6574 6164  ata = m_tp.metad
    │ │ │ -0003c920: 6174 6128 292e 6461 7461 2829 202b 206f  ata().data() + o
    │ │ │ -0003c930: 6666 7365 743b 0a09 0909 096d 6574 6164  ffset;.....metad
    │ │ │ -0003c940: 6174 615f 7069 6563 655f 7369 7a65 203d  ata_piece_size =
    │ │ │ -0003c950: 2073 7464 3a3a 6d69 6e28 0a09 0909 0909   std::min(......
    │ │ │ -0003c960: 696e 7428 6d5f 7470 2e6d 6574 6164 6174  int(m_tp.metadat
    │ │ │ -0003c970: 6128 292e 7369 7a65 2829 2920 2d20 6f66  a().size()) - of
    │ │ │ -0003c980: 6673 6574 2c20 3136 202a 2031 3032 3429  fset, 16 * 1024)
    │ │ │ -0003c990: 3b0a 0909 0909 544f 5252 454e 545f 4153  ;.....TORRENT_AS
    │ │ │ -0003c9a0: 5345 5254 286d 6574 6164 6174 615f 7069  SERT(metadata_pi
    │ │ │ -0003c9b0: 6563 655f 7369 7a65 2026 6774 3b20 3029  ece_size > 0)
    │ │ │ -0003c9c0: 3b0a 0909 0909 544f 5252 454e 545f 4153  ;.....TORRENT_AS
    │ │ │ -0003c9d0: 5345 5254 286f 6666 7365 7420 2667 743b  SERT(offset >
    │ │ │ -0003c9e0: 3d20 3029 3b0a 0909 0909 544f 5252 454e  = 0);.....TORREN
    │ │ │ -0003c9f0: 545f 4153 5345 5254 286f 6666 7365 7420  T_ASSERT(offset 
    │ │ │ -0003ca00: 2b20 6d65 7461 6461 7461 5f70 6965 6365  + metadata_piece
    │ │ │ -0003ca10: 5f73 697a 6520 266c 743b 3d20 6d5f 7470  _size <= m_tp
    │ │ │ -0003ca20: 2e6d 6574 6164 6174 6128 292e 7369 7a65  .metadata().size
    │ │ │ -0003ca30: 2829 293b 0a09 0909 7d0a 0a09 0909 6368  ());....}.....ch
    │ │ │ -0003ca40: 6172 206d 7367 5b32 3030 5d3b 0a09 0909  ar msg[200];....
    │ │ │ -0003ca50: 6368 6172 2a20 6865 6164 6572 203d 206d  char* header = m
    │ │ │ -0003ca60: 7367 3b0a 0909 0963 6861 722a 2070 203d  sg;....char* p =
    │ │ │ -0003ca70: 2026 616d 703b 6d73 675b 365d 3b0a 0909   &msg[6];...
    │ │ │ -0003ca80: 0969 6e74 2063 6f6e 7374 206c 656e 203d  .int const len =
    │ │ │ -0003ca90: 2062 656e 636f 6465 2870 2c20 6529 3b0a   bencode(p, e);.
    │ │ │ -0003caa0: 0909 0969 6e74 2063 6f6e 7374 2074 6f74  ...int const tot
    │ │ │ -0003cab0: 616c 5f73 697a 6520 3d20 3220 2b20 6c65  al_size = 2 + le
    │ │ │ -0003cac0: 6e20 2b20 6d65 7461 6461 7461 5f70 6965  n + metadata_pie
    │ │ │ -0003cad0: 6365 5f73 697a 653b 0a09 0909 6e61 6d65  ce_size;....name
    │ │ │ -0003cae0: 7370 6163 6520 696f 203d 2061 7578 3b0a  space io = aux;.
    │ │ │ -0003caf0: 0909 0969 6f3a 3a77 7269 7465 5f75 696e  ...io::write_uin
    │ │ │ -0003cb00: 7433 3228 746f 7461 6c5f 7369 7a65 2c20  t32(total_size, 
    │ │ │ -0003cb10: 6865 6164 6572 293b 0a09 0909 696f 3a3a  header);....io::
    │ │ │ -0003cb20: 7772 6974 655f 7569 6e74 3828 6175 783a  write_uint8(aux:
    │ │ │ -0003cb30: 3a62 745f 7065 6572 5f63 6f6e 6e65 6374  :bt_peer_connect
    │ │ │ -0003cb40: 696f 6e3a 3a6d 7367 5f65 7874 656e 6465  ion::msg_extende
    │ │ │ -0003cb50: 642c 2068 6561 6465 7229 3b0a 0909 0969  d, header);....i
    │ │ │ -0003cb60: 6f3a 3a77 7269 7465 5f75 696e 7438 286d  o::write_uint8(m
    │ │ │ -0003cb70: 5f6d 6573 7361 6765 5f69 6e64 6578 2c20  _message_index, 
    │ │ │ -0003cb80: 6865 6164 6572 293b 0a0a 0909 096d 5f70  header);.....m_p
    │ │ │ -0003cb90: 632e 7365 6e64 5f62 7566 6665 7228 7b6d  c.send_buffer({m
    │ │ │ -0003cba0: 7367 2c20 6c65 6e20 2b20 367d 293b 0a3c  sg, len + 6});.<
    │ │ │ -0003cbb0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0003cbc0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0003cbd0: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ -0003cbe0: 6966 2028 6d65 7461 6461 7461 5f70 6965  if (metadata_pie
    │ │ │ -0003cbf0: 6365 5f73 697a 6529 0a3c 2f64 6976 3e09  ce_size).

    . │ │ │ -0003cc00: 0909 7b0a 0909 0909 6d5f 7063 2e61 7070 ..{.....m_pc.app │ │ │ -0003cc10: 656e 645f 636f 6e73 745f 7365 6e64 5f62 end_const_send_b │ │ │ -0003cc20: 7566 6665 7228 0a09 0909 0909 7370 616e uffer(......span │ │ │ -0003cc30: 266c 743b 6368 6172 2667 743b 2863 6f6e <char>(con │ │ │ -0003cc40: 7374 5f63 6173 7426 6c74 3b63 6861 722a st_cast<char* │ │ │ -0003cc50: 2667 743b 286d 6574 6164 6174 6129 2c20 >(metadata), │ │ │ -0003cc60: 6d65 7461 6461 7461 5f70 6965 6365 5f73 metadata_piece_s │ │ │ -0003cc70: 697a 6529 2c20 6d65 7461 6461 7461 5f70 ize), metadata_p │ │ │ -0003cc80: 6965 6365 5f73 697a 6529 3b0a 0909 097d iece_size);....} │ │ │ -0003cc90: 0a0a 0909 096d 5f70 632e 7374 6174 735f .....m_pc.stats_ │ │ │ -0003cca0: 636f 756e 7465 7273 2829 2e69 6e63 5f73 counters().inc_s │ │ │ -0003ccb0: 7461 7473 5f63 6f75 6e74 6572 2863 6f75 tats_counter(cou │ │ │ -0003ccc0: 6e74 6572 733a 3a6e 756d 5f6f 7574 676f nters::num_outgo │ │ │ -0003ccd0: 696e 675f 6578 7465 6e64 6564 293b 0a09 ing_extended);.. │ │ │ -0003cce0: 0909 6d5f 7063 2e73 7461 7473 5f63 6f75 ..m_pc.stats_cou │ │ │ -0003ccf0: 6e74 6572 7328 292e 696e 635f 7374 6174 nters().inc_stat │ │ │ -0003cd00: 735f 636f 756e 7465 7228 636f 756e 7465 s_counter(counte │ │ │ -0003cd10: 7273 3a3a 6e75 6d5f 6f75 7467 6f69 6e67 rs::num_outgoing │ │ │ -0003cd20: 5f6d 6574 6164 6174 6129 3b0a 0909 7d0a _metadata);...}. │ │ │ -0003cd30: 0a09 0962 6f6f 6c20 6f6e 5f65 7874 656e ...bool on_exten │ │ │ -0003cd40: 6465 6428 696e 7420 636f 6e73 7420 6c65 ded(int const le │ │ │ -0003cd50: 6e67 7468 0a09 0909 2c20 696e 7420 636f ngth...., int co │ │ │ -0003cd60: 6e73 7420 6578 7465 6e64 6564 5f6d 7367 nst extended_msg │ │ │ -0003cd70: 2c20 7370 616e 266c 743b 6368 6172 2063 , span<char c │ │ │ -0003cd80: 6f6e 7374 2667 743b 2062 6f64 7929 206f onst> body) o │ │ │ -0003cd90: 7665 7272 6964 650a 0909 7b0a 0909 0969 verride...{....i │ │ │ -0003cda0: 6620 2865 7874 656e 6465 645f 6d73 6720 f (extended_msg │ │ │ -0003cdb0: 213d 2032 2920 7265 7475 726e 2066 616c != 2) return fal │ │ │ -0003cdc0: 7365 3b0a 0909 0969 6620 286d 5f6d 6573 se;....if (m_mes │ │ │ -0003cdd0: 7361 6765 5f69 6e64 6578 203d 3d20 3029 sage_index == 0) │ │ │ -0003cde0: 2072 6574 7572 6e20 6661 6c73 653b 0a0a return false;.. │ │ │ -0003cdf0: 0909 0969 6620 286c 656e 6774 6820 2667 ...if (length &g │ │ │ -0003ce00: 743b 2031 3720 2a20 3130 3234 290a 0909 t; 17 * 1024)... │ │ │ -0003ce10: 097b 0a23 6966 6e64 6566 2054 4f52 5245 .{.#ifndef TORRE │ │ │ -0003ce20: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ -0003ce30: 4e47 0a09 0909 096d 5f70 632e 7065 6572 NG.....m_pc.peer │ │ │ -0003ce40: 5f6c 6f67 2870 6565 725f 6c6f 675f 616c _log(peer_log_al │ │ │ -0003ce50: 6572 743a 3a69 6e63 6f6d 696e 675f 6d65 ert::incoming_me │ │ │ -0003ce60: 7373 6167 652c 2070 6565 725f 6c6f 675f ssage, peer_log_ │ │ │ -0003ce70: 616c 6572 743a 3a75 745f 6d65 7461 6461 alert::ut_metada │ │ │ -0003ce80: 7461 0a09 0909 0909 2c20 2270 6163 6b65 ta......, "packe │ │ │ -0003ce90: 7420 746f 6f20 6269 6720 2564 222c 206c t too big %d", l │ │ │ -0003cea0: 656e 6774 6829 3b0a 2365 6e64 6966 0a09 ength);.#endif.. │ │ │ -0003ceb0: 0909 096d 5f70 632e 6469 7363 6f6e 6e65 ...m_pc.disconne │ │ │ -0003cec0: 6374 2865 7272 6f72 733a 3a69 6e76 616c ct(errors::inval │ │ │ -0003ced0: 6964 5f6d 6574 6164 6174 615f 6d65 7373 id_metadata_mess │ │ │ -0003cee0: 6167 652c 206f 7065 7261 7469 6f6e 5f74 age, operation_t │ │ │ -0003cef0: 3a3a 6269 7474 6f72 7265 6e74 2c20 7065 ::bittorrent, pe │ │ │ -0003cf00: 6572 5f63 6f6e 6e65 6374 696f 6e5f 696e er_connection_in │ │ │ -0003cf10: 7465 7266 6163 653a 3a70 6565 725f 6572 terface::peer_er │ │ │ -0003cf20: 726f 7229 3b0a 0909 0909 7265 7475 726e ror);.....return │ │ │ -0003cf30: 2074 7275 653b 0a09 0909 7d0a 0a09 0909 true;....}..... │ │ │ -0003cf40: 6966 2028 216d 5f70 632e 7061 636b 6574 if (!m_pc.packet │ │ │ -0003cf50: 5f66 696e 6973 6865 6428 2929 2072 6574 _finished()) ret │ │ │ -0003cf60: 7572 6e20 7472 7565 3b0a 0a09 0909 6572 urn true;.....er │ │ │ -0003cf70: 726f 725f 636f 6465 2065 633b 0a09 0909 ror_code ec;.... │ │ │ -0003cf80: 6264 6563 6f64 655f 6e6f 6465 206d 7367 bdecode_node msg │ │ │ -0003cf90: 203d 2062 6465 636f 6465 2862 6f64 792c = bdecode(body, │ │ │ -0003cfa0: 2065 6329 3b0a 0909 0969 6620 286d 7367 ec);....if (msg │ │ │ -0003cfb0: 2e74 7970 6528 2920 213d 2062 6465 636f .type() != bdeco │ │ │ -0003cfc0: 6465 5f6e 6f64 653a 3a64 6963 745f 7429 de_node::dict_t) │ │ │ -0003cfd0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ -0003d010: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -0003d040: 7263 2f73 6d61 7274 5f62 616e 2e63 7070 rc/smart_ban.cpp │ │ │ -0003d050: 3a31 3538 3c2f 613e 3c2f 7464 3e3c 7464 :158replace with st │ │ │ -0003d070: 643a 3a65 7261 7365 5f69 6628 2920 6f6e d::erase_if() on │ │ │ -0003d080: 6365 2077 6520 7265 7175 6972 6520 432b ce we require C+ │ │ │ -0003d090: 2b32 303c 2f74 643e 3c2f 7472 3e3c 7472 +20

    replace with st │ │ │ -0003d0f0: 643a 3a65 7261 7365 5f69 6628 2920 6f6e d::erase_if() on │ │ │ -0003d100: 6365 2077 6520 7265 7175 6972 6520 432b ce we require C+ │ │ │ -0003d110: 2b32 303c 2f68 323e 3c68 343e 2e2e 2f73 +20

    ../s │ │ │ -0003d120: 7263 2f73 6d61 7274 5f62 616e 2e63 7070 rc/smart_ban.cpp │ │ │ -0003d130: 3a31 3538 3c2f 6834 3e3c 7072 6520 7374 :158

    ......, disk_
    │ │ │ -0003d180: 696e 7465 7266 6163 653a 3a66 6f72 6365  interface::force
    │ │ │ -0003d190: 5f63 6f70 7929 3b0a 0909 0909 7d0a 0a09  _copy);.....}...
    │ │ │ -0003d1a0: 0909 0972 2e73 7461 7274 202b 3d20 3136  ...r.start += 16
    │ │ │ -0003d1b0: 2a31 3032 343b 0a09 0909 0973 697a 6520  *1024;.....size 
    │ │ │ -0003d1c0: 2d3d 2031 362a 3130 3234 3b0a 0909 0909  -= 16*1024;.....
    │ │ │ -0003d1d0: 722e 6c65 6e67 7468 203d 2073 7464 3a3a  r.length = std::
    │ │ │ -0003d1e0: 6d69 6e28 3136 2a31 3032 342c 2073 697a  min(16*1024, siz
    │ │ │ -0003d1f0: 6529 3b0a 0909 0909 2b2b 7062 2e62 6c6f  e);.....++pb.blo
    │ │ │ -0003d200: 636b 5f69 6e64 6578 3b0a 0909 097d 0a09  ck_index;....}..
    │ │ │ -0003d210: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -0003d220: 2873 697a 6520 266c 743b 3d20 3029 3b0a  (size <= 0);.
    │ │ │ -0003d230: 0909 7d0a 0a09 092f 2f20 6e6f 7420 6465  ..}....// not de
    │ │ │ -0003d240: 636c 6172 6564 206f 6e20 746f 7272 656e  clared on torren
    │ │ │ -0003d250: 745f 706c 7567 696e 2028 776f 756c 6420  t_plugin (would 
    │ │ │ -0003d260: 7265 7175 6972 6520 616e 2041 4249 2d62  require an ABI-b
    │ │ │ -0003d270: 7265 616b 696e 6720 6e65 770a 0909 2f2f  reaking new...//
    │ │ │ -0003d280: 2076 6972 7475 616c 292e 2043 616c 6c65   virtual). Calle
    │ │ │ -0003d290: 6420 7669 6120 6120 646f 776e 6361 7374  d via a downcast
    │ │ │ -0003d2a0: 2069 6e20 746f 7272 656e 743a 3a70 6565   in torrent::pee
    │ │ │ -0003d2b0: 7273 5f65 7261 7365 6428 2920 e280 9420  rs_erased() ... 
    │ │ │ -0003d2c0: 7365 650a 0909 2f2f 2073 6d61 7274 5f62  see...// smart_b
    │ │ │ -0003d2d0: 616e 5f6e 6f74 6966 795f 6572 6173 655f  an_notify_erase_
    │ │ │ -0003d2e0: 7065 6572 7328 2920 6265 6c6f 770a 0909  peers() below...
    │ │ │ -0003d2f0: 766f 6964 206f 6e5f 6572 6173 655f 7065  void on_erase_pe
    │ │ │ -0003d300: 6572 7328 7370 616e 266c 743b 6175 783a  ers(span<aux:
    │ │ │ -0003d310: 3a74 6f72 7265 6e74 5f70 6565 722a 2063  :torrent_peer* c
    │ │ │ -0003d320: 6f6e 7374 2667 743b 2070 6565 7273 290a  onst> peers).
    │ │ │ -0003d330: 0909 7b0a 0909 0969 6620 286d 5f62 6c6f  ..{....if (m_blo
    │ │ │ -0003d340: 636b 5f68 6173 6865 732e 656d 7074 7928  ck_hashes.empty(
    │ │ │ -0003d350: 2920 7c7c 2070 6565 7273 2e65 6d70 7479  ) || peers.empty
    │ │ │ -0003d360: 2829 2920 7265 7475 726e 3b0a 0a09 0909  ()) return;.....
    │ │ │ -0003d370: 7374 643a 3a76 6563 746f 7226 6c74 3b61  std::vector<a
    │ │ │ -0003d380: 7578 3a3a 746f 7272 656e 745f 7065 6572  ux::torrent_peer
    │ │ │ -0003d390: 2a26 6774 3b20 6572 6173 6564 2870 6565  *> erased(pee
    │ │ │ -0003d3a0: 7273 2e62 6567 696e 2829 2c20 7065 6572  rs.begin(), peer
    │ │ │ -0003d3b0: 732e 656e 6428 2929 3b0a 0909 0973 7464  s.end());....std
    │ │ │ -0003d3c0: 3a3a 736f 7274 2865 7261 7365 642e 6265  ::sort(erased.be
    │ │ │ -0003d3d0: 6769 6e28 292c 2065 7261 7365 642e 656e  gin(), erased.en
    │ │ │ -0003d3e0: 6428 2929 3b0a 3c64 6976 2073 7479 6c65  d());.
    ...for (auto │ │ │ -0003d420: 2069 203d 206d 5f62 6c6f 636b 5f68 6173 i = m_block_has │ │ │ -0003d430: 6865 732e 6265 6769 6e28 293b 2069 2021 hes.begin(); i ! │ │ │ -0003d440: 3d20 6d5f 626c 6f63 6b5f 6861 7368 6573 = m_block_hashes │ │ │ -0003d450: 2e65 6e64 2829 3b29 0a3c 2f64 6976 3e09 .end();).
    . │ │ │ -0003d460: 0909 7b0a 0909 0909 6966 2028 7374 643a ..{.....if (std: │ │ │ -0003d470: 3a62 696e 6172 795f 7365 6172 6368 2865 :binary_search(e │ │ │ -0003d480: 7261 7365 642e 6265 6769 6e28 292c 2065 rased.begin(), e │ │ │ -0003d490: 7261 7365 642e 656e 6428 292c 2069 2d26 rased.end(), i-& │ │ │ -0003d4a0: 6774 3b73 6563 6f6e 642e 7065 6572 2929 gt;second.peer)) │ │ │ -0003d4b0: 0a09 0909 0909 6920 3d20 6d5f 626c 6f63 ......i = m_bloc │ │ │ -0003d4c0: 6b5f 6861 7368 6573 2e65 7261 7365 2869 k_hashes.erase(i │ │ │ -0003d4d0: 293b 0a09 0909 0965 6c73 650a 0909 0909 );.....else..... │ │ │ -0003d4e0: 092b 2b69 3b0a 0909 097d 0a09 097d 0a0a .++i;....}...}.. │ │ │ -0003d4f0: 0970 7269 7661 7465 3a0a 0a09 092f 2f20 .private:....// │ │ │ -0003d500: 7468 6973 2065 6e74 7279 2074 6965 7320 this entry ties │ │ │ -0003d510: 6120 7370 6563 6966 6963 2062 6c6f 636b a specific block │ │ │ -0003d520: 2043 5243 2074 6f0a 0909 2f2f 2061 2070 CRC to...// a p │ │ │ -0003d530: 6565 722e 0a09 0973 7472 7563 7420 626c eer....struct bl │ │ │ -0003d540: 6f63 6b5f 656e 7472 790a 0909 7b0a 0909 ock_entry...{... │ │ │ -0003d550: 0961 7578 3a3a 746f 7272 656e 745f 7065 .aux::torrent_pe │ │ │ -0003d560: 6572 2a20 7065 6572 3b0a 0909 0973 6861 er* peer;....sha │ │ │ -0003d570: 315f 6861 7368 2064 6967 6573 743b 0a09 1_hash digest;.. │ │ │ -0003d580: 097d 3b0a 0a09 0976 6f69 6420 6f6e 5f72 .};....void on_r │ │ │ -0003d590: 6561 645f 6661 696c 6564 5f62 6c6f 636b ead_failed_block │ │ │ -0003d5a0: 2870 6965 6365 5f62 6c6f 636b 2063 6f6e (piece_block con │ │ │ -0003d5b0: 7374 2062 2c20 6164 6472 6573 7320 636f st b, address co │ │ │ -0003d5c0: 6e73 7420 610a 0909 092c 2064 6973 6b5f nst a...., disk_ │ │ │ -0003d5d0: 6275 6666 6572 5f68 6f6c 6465 7220 6275 buffer_holder bu │ │ │ -0003d5e0: 6666 6572 2c20 696e 7420 636f 6e73 7420 ffer, int const │ │ │ -0003d5f0: 626c 6f63 6b5f 7369 7a65 0a09 0909 2c20 block_size...., │ │ │ -0003d600: 7374 6f72 6167 655f 6572 726f 7220 636f storage_error co │ │ │ -0003d610: 6e73 7426 616d 703b 2065 7272 6f72 290a nst& error). │ │ │ -0003d620: 0909 7b0a 0909 0954 4f52 5245 4e54 5f41 ..{....TORRENT_A │ │ │ -0003d630: 5353 4552 5428 6d5f 746f 7272 656e 742e SSERT(m_torrent. │ │ │ -0003d640: 7365 7373 696f 6e28 292e 6973 5f73 696e session().is_sin │ │ │ -0003d650: 676c 655f 7468 7265 6164 2829 293b 0a0a gle_thread());.. │ │ │ -0003d660: 0909 092f 2f20 6967 6e6f 7265 2072 6561 ...// ignore rea │ │ │ -0003d670: 6420 6572 726f 7273 0a09 0909 6966 2028 d errors....if ( │ │ │ -0003d680: 6572 726f 7229 2072 6574 7572 6e3b 0a0a error) return;.. │ │ │ -0003d690: 0909 0968 6173 6865 7220 683b 0a09 0909 ...hasher h;.... │ │ │ -0003d6a0: 682e 7570 6461 7465 287b 6275 6666 6572 h.update({buffer │ │ │ -0003d6b0: 2e64 6174 6128 292c 2062 6c6f 636b 5f73 .data(), block_s │ │ │ -0003d6c0: 697a 657d 293b 0a0a 3c2f 7072 653e 3c2f ize});..
    relevan │ │ │ -0003d700: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ -0003d740: 745f 7065 6572 2e63 7070 3a31 3637 3c2f t_peer.cpp:167how d │ │ │ -0003d760: 6f20 7765 2064 6561 6c20 7769 7468 206f o we deal with o │ │ │ -0003d770: 7572 2065 7874 6572 6e61 6c20 6164 6472 ur external addr │ │ │ -0003d780: 6573 7320 6368 616e 6769 6e67 3f3c 2f74 ess changing?

    how d │ │ │ -0003d7e0: 6f20 7765 2064 6561 6c20 7769 7468 206f o we deal with o │ │ │ -0003d7f0: 7572 2065 7874 6572 6e61 6c20 6164 6472 ur external addr │ │ │ -0003d800: 6573 7320 6368 616e 6769 6e67 3f3c 2f68 ess changing?

    ../src/tor │ │ │ -0003d820: 7265 6e74 5f70 6565 722e 6370 703a 3136 rent_peer.cpp:16 │ │ │ -0003d830: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ -0003d870: 2365 6e64 6966 0a09 092c 2069 735f 7636  #endif..., is_v6
    │ │ │ -0003d880: 5f61 6464 7228 6661 6c73 6529 0a23 6966  _addr(false).#if
    │ │ │ -0003d890: 2054 4f52 5245 4e54 5f55 5345 5f49 3250   TORRENT_USE_I2P
    │ │ │ -0003d8a0: 0a09 092c 2069 735f 6932 705f 6164 6472  ..., is_i2p_addr
    │ │ │ -0003d8b0: 2866 616c 7365 290a 2365 6e64 6966 0a23  (false).#endif.#
    │ │ │ -0003d8c0: 6966 2054 4f52 5245 4e54 5f55 5345 5f52  if TORRENT_USE_R
    │ │ │ -0003d8d0: 5443 0a09 092c 2069 735f 7274 635f 6164  TC..., is_rtc_ad
    │ │ │ -0003d8e0: 6472 2866 616c 7365 290a 2365 6e64 6966  dr(false).#endif
    │ │ │ -0003d8f0: 0a09 092c 206f 6e5f 7061 726f 6c65 2866  ..., on_parole(f
    │ │ │ -0003d900: 616c 7365 290a 0909 2c20 6261 6e6e 6564  alse)..., banned
    │ │ │ -0003d910: 2866 616c 7365 290a 0909 2c20 7375 7070  (false)..., supp
    │ │ │ -0003d920: 6f72 7473 5f75 7470 2874 7275 6529 202f  orts_utp(true) /
    │ │ │ -0003d930: 2f20 6173 7375 6d65 2070 6565 7273 2073  / assume peers s
    │ │ │ -0003d940: 7570 706f 7274 2075 7470 0a09 092c 2063  upport utp..., c
    │ │ │ -0003d950: 6f6e 6669 726d 6564 5f73 7570 706f 7274  onfirmed_support
    │ │ │ -0003d960: 735f 7574 7028 6661 6c73 6529 0a09 092c  s_utp(false)...,
    │ │ │ -0003d970: 2073 7570 706f 7274 735f 686f 6c65 7075   supports_holepu
    │ │ │ -0003d980: 6e63 6828 6661 6c73 6529 0a09 092c 2077  nch(false)..., w
    │ │ │ -0003d990: 6562 5f73 6565 6428 6661 6c73 6529 0a09  eb_seed(false)..
    │ │ │ -0003d9a0: 092c 2070 726f 746f 636f 6c5f 7632 2866  ., protocol_v2(f
    │ │ │ -0003d9b0: 616c 7365 290a 097b 7d0a 0a09 7374 643a  alse)..{}...std:
    │ │ │ -0003d9c0: 3a75 696e 7433 325f 7420 746f 7272 656e  :uint32_t torren
    │ │ │ -0003d9d0: 745f 7065 6572 3a3a 7261 6e6b 2861 7578  t_peer::rank(aux
    │ │ │ -0003d9e0: 3a3a 6578 7465 726e 616c 5f69 7020 636f  ::external_ip co
    │ │ │ -0003d9f0: 6e73 7426 616d 703b 2065 7874 6572 6e61  nst& externa
    │ │ │ -0003da00: 6c2c 2069 6e74 2065 7874 6572 6e61 6c5f  l, int external_
    │ │ │ -0003da10: 706f 7274 2920 636f 6e73 740a 097b 0a09  port) const..{..
    │ │ │ -0003da20: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -0003da30: 696e 5f75 7365 293b 0a3c 6469 7620 7374  in_use);.
    ..if (pee │ │ │ -0003da70: 725f 7261 6e6b 203d 3d20 3029 0a3c 2f64 r_rank == 0)....peer_rank │ │ │ -0003da90: 3d20 7065 6572 5f70 7269 6f72 6974 7928 = peer_priority( │ │ │ -0003daa0: 0a09 0909 0974 6370 3a3a 656e 6470 6f69 .....tcp::endpoi │ │ │ -0003dab0: 6e74 2865 7874 6572 6e61 6c2e 6578 7465 nt(external.exte │ │ │ -0003dac0: 726e 616c 5f61 6464 7265 7373 2874 6869 rnal_address(thi │ │ │ -0003dad0: 732d 2667 743b 6164 6472 6573 7328 2929 s->address()) │ │ │ -0003dae0: 2c20 7374 643a 3a75 696e 7431 365f 7428 , std::uint16_t( │ │ │ -0003daf0: 6578 7465 726e 616c 5f70 6f72 7429 290a external_port)). │ │ │ -0003db00: 0909 0909 2c20 7463 703a 3a65 6e64 706f ...., tcp::endpo │ │ │ -0003db10: 696e 7428 7468 6973 2d26 6774 3b61 6464 int(this->add │ │ │ -0003db20: 7265 7373 2829 2c20 7468 6973 2d26 6774 ress(), this-> │ │ │ -0003db30: 3b70 6f72 7429 293b 0a09 0972 6574 7572 ;port));...retur │ │ │ -0003db40: 6e20 7065 6572 5f72 616e 6b3b 0a09 7d0a n peer_rank;..}. │ │ │ -0003db50: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -0003db60: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ -0003db70: 0a09 7374 643a 3a73 7472 696e 6720 746f ..std::string to │ │ │ -0003db80: 7272 656e 745f 7065 6572 3a3a 746f 5f73 rrent_peer::to_s │ │ │ -0003db90: 7472 696e 6728 2920 636f 6e73 740a 097b tring() const..{ │ │ │ -0003dba0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0003dbb0: 5428 696e 5f75 7365 293b 0a23 6966 2054 T(in_use);.#if T │ │ │ -0003dbc0: 4f52 5245 4e54 5f55 5345 5f49 3250 0a09 ORRENT_USE_I2P.. │ │ │ -0003dbd0: 0969 6620 2869 735f 6932 705f 6164 6472 .if (is_i2p_addr │ │ │ -0003dbe0: 2920 7265 7475 726e 2073 7464 3a3a 7374 ) return std::st │ │ │ -0003dbf0: 7269 6e67 2864 6573 7428 2929 3b0a 2365 ring(dest());.#e │ │ │ -0003dc00: 6e64 6966 0a09 0972 6574 7572 6e20 6164 ndif...return ad │ │ │ -0003dc10: 6472 6573 7328 292e 746f 5f73 7472 696e dress().to_strin │ │ │ -0003dc20: 6728 293b 0a09 7d0a 2365 6e64 6966 0a0a g();..}.#endif.. │ │ │ -0003dc30: 0973 7464 3a3a 696e 7436 345f 7420 746f .std::int64_t to │ │ │ -0003dc40: 7272 656e 745f 7065 6572 3a3a 746f 7461 rrent_peer::tota │ │ │ -0003dc50: 6c5f 646f 776e 6c6f 6164 2829 2063 6f6e l_download() con │ │ │ -0003dc60: 7374 0a09 7b0a 0909 544f 5252 454e 545f st..{...TORRENT_ │ │ │ -0003dc70: 4153 5345 5254 2869 6e5f 7573 6529 3b0a ASSERT(in_use);. │ │ │ -0003dc80: 0909 6966 2028 636f 6e6e 6563 7469 6f6e ..if (connection │ │ │ -0003dc90: 2021 3d20 6e75 6c6c 7074 7229 0a09 097b != nullptr)...{ │ │ │ -0003dca0: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -0003dcb0: 5254 2870 7265 765f 616d 6f75 6e74 5f64 RT(prev_amount_d │ │ │ -0003dcc0: 6f77 6e6c 6f61 6420 3d3d 2030 293b 0a09 ownload == 0);.. │ │ │ -0003dcd0: 0909 7265 7475 726e 2063 6f6e 6e65 6374 ..return connect │ │ │ -0003dce0: 696f 6e2d 2667 743b 7374 6174 6973 7469 ion->statisti │ │ │ -0003dcf0: 6373 2829 2e74 6f74 616c 5f70 6179 6c6f cs().total_paylo │ │ │ -0003dd00: 6164 5f64 6f77 6e6c 6f61 6428 293b 0a09 ad_download();.. │ │ │ -0003dd10: 097d 0a09 0965 6c73 650a 0909 7b0a 0909 .}...else...{... │ │ │ -0003dd20: 0972 6574 7572 6e20 7374 643a 3a69 6e74 .return std::int │ │ │ -0003dd30: 3634 5f74 2870 7265 765f 616d 6f75 6e74 64_t(prev_amount │ │ │ -0003dd40: 5f64 6f77 6e6c 6f61 6429 202a 2031 3032 _download) * 102 │ │ │ -0003dd50: 343b 0a09 097d 0a09 7d0a 3c2f 7072 653e 4;...}..}.
    │ │ │ -0003dd60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0003dd90: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0003dda0: 3c74 643e 3c61 2068 7265 663d 226a 6176
    ../src/udp_ │ │ │ -0003ddd0: 7472 6163 6b65 725f 636f 6e6e 6563 7469 tracker_connecti │ │ │ -0003dde0: 6f6e 2e63 7070 3a36 3130 3c2f 613e 3c2f on.cpp:610why is th │ │ │ -0003de00: 6973 2061 206c 696e 6b65 6420 6c69 7374 is a linked list │ │ │ -0003de10: 3f3c 2f74 643e 3c2f 7472 3e3c 7472 2069 ?

    w │ │ │ -0003de60: 6879 2069 7320 7468 6973 2061 206c 696e hy is this a lin │ │ │ -0003de70: 6b65 6420 6c69 7374 3f3c 2f68 323e 3c68 ked list?

    ../src/udp_tra │ │ │ -0003de90: 636b 6572 5f63 6f6e 6e65 6374 696f 6e2e cker_connection. │ │ │ -0003dea0: 6370 703a 3631 303c 2f68 343e 3c70 7265 cpp:610
    ....ipv6_p
    │ │ │ -0003def0: 6565 725f 656e 7472 7920 657b 7d3b 0a09  eer_entry e{};..
    │ │ │ -0003df00: 0909 0973 7464 3a3a 6d65 6d63 7079 2865  ...std::memcpy(e
    │ │ │ -0003df10: 2e69 702e 6461 7461 2829 2c20 6275 662e  .ip.data(), buf.
    │ │ │ -0003df20: 6461 7461 2829 2c20 3136 293b 0a09 0909  data(), 16);....
    │ │ │ -0003df30: 0962 7566 203d 2062 7566 2e73 7562 7370  .buf = buf.subsp
    │ │ │ -0003df40: 616e 2831 3629 3b0a 0909 0909 652e 706f  an(16);.....e.po
    │ │ │ -0003df50: 7274 203d 2061 7578 3a3a 7265 6164 5f75  rt = aux::read_u
    │ │ │ -0003df60: 696e 7431 3628 6275 6629 3b0a 0909 0909  int16(buf);.....
    │ │ │ -0003df70: 7265 7370 2e70 6565 7273 362e 7075 7368  resp.peers6.push
    │ │ │ -0003df80: 5f62 6163 6b28 6529 3b0a 0909 097d 0a09  _back(e);....}..
    │ │ │ -0003df90: 097d 0a09 0965 6c73 650a 0909 7b0a 0909  .}...else...{...
    │ │ │ -0003dfa0: 0972 6573 702e 7065 6572 7334 2e72 6573  .resp.peers4.res
    │ │ │ -0003dfb0: 6572 7665 2873 7461 7469 635f 6361 7374  erve(static_cast
    │ │ │ -0003dfc0: 266c 743b 7374 643a 3a73 697a 655f 7426  <std::size_t&
    │ │ │ -0003dfd0: 6774 3b28 6e75 6d5f 7065 6572 7329 293b  gt;(num_peers));
    │ │ │ -0003dfe0: 0a09 0909 666f 7220 2869 6e74 2069 203d  ....for (int i =
    │ │ │ -0003dff0: 2030 3b20 6920 266c 743b 206e 756d 5f70   0; i < num_p
    │ │ │ -0003e000: 6565 7273 3b20 2b2b 6929 0a09 0909 7b0a  eers; ++i)....{.
    │ │ │ -0003e010: 0909 0909 6970 7634 5f70 6565 725f 656e  ....ipv4_peer_en
    │ │ │ -0003e020: 7472 7920 657b 7d3b 0a09 0909 0973 7464  try e{};.....std
    │ │ │ -0003e030: 3a3a 6d65 6d63 7079 2865 2e69 702e 6461  ::memcpy(e.ip.da
    │ │ │ -0003e040: 7461 2829 2c20 6275 662e 6461 7461 2829  ta(), buf.data()
    │ │ │ -0003e050: 2c20 3429 3b0a 0909 0909 6275 6620 3d20  , 4);.....buf = 
    │ │ │ -0003e060: 6275 662e 7375 6273 7061 6e28 3429 3b0a  buf.subspan(4);.
    │ │ │ -0003e070: 0909 0909 652e 706f 7274 203d 2061 7578  ....e.port = aux
    │ │ │ -0003e080: 3a3a 7265 6164 5f75 696e 7431 3628 6275  ::read_uint16(bu
    │ │ │ -0003e090: 6629 3b0a 0909 0909 7265 7370 2e70 6565  f);.....resp.pee
    │ │ │ -0003e0a0: 7273 342e 7075 7368 5f62 6163 6b28 6529  rs4.push_back(e)
    │ │ │ -0003e0b0: 3b0a 0909 097d 0a09 097d 0a0a 3c64 6976  ;....}...}..
    ..std: │ │ │ -0003e0f0: 3a6c 6973 7426 6c74 3b61 6464 7265 7373 :list<address │ │ │ -0003e100: 2667 743b 2069 705f 6c69 7374 3b0a 3c2f > ip_list;...std::trans │ │ │ -0003e120: 666f 726d 286d 5f65 6e64 706f 696e 7473 form(m_endpoints │ │ │ -0003e130: 2e62 6567 696e 2829 2c20 6d5f 656e 6470 .begin(), m_endp │ │ │ -0003e140: 6f69 6e74 732e 656e 6428 292c 2073 7464 oints.end(), std │ │ │ -0003e150: 3a3a 6261 636b 5f69 6e73 6572 7465 7228 ::back_inserter( │ │ │ -0003e160: 6970 5f6c 6973 7429 0a09 0909 2c20 5b5d ip_list)...., [] │ │ │ -0003e170: 2874 6370 3a3a 656e 6470 6f69 6e74 2063 (tcp::endpoint c │ │ │ -0003e180: 6f6e 7374 2661 6d70 3b20 6570 2920 7b20 onst& ep) { │ │ │ -0003e190: 7265 7475 726e 2065 702e 6164 6472 6573 return ep.addres │ │ │ -0003e1a0: 7328 293b 207d 2029 3b0a 0a09 0963 622d s(); } );....cb- │ │ │ -0003e1b0: 2667 743b 7472 6163 6b65 725f 7265 7370 >tracker_resp │ │ │ -0003e1c0: 6f6e 7365 2874 7261 636b 6572 5f72 6571 onse(tracker_req │ │ │ -0003e1d0: 2829 2c20 6d5f 7461 7267 6574 2e61 6464 (), m_target.add │ │ │ -0003e1e0: 7265 7373 2829 2c20 6970 5f6c 6973 742c ress(), ip_list, │ │ │ -0003e1f0: 2072 6573 7029 3b0a 0a09 0963 6c6f 7365 resp);....close │ │ │ -0003e200: 2829 3b0a 0909 7265 7475 726e 2074 7275 ();...return tru │ │ │ -0003e210: 653b 0a09 7d0a 0a09 626f 6f6c 2075 6470 e;..}...bool udp │ │ │ -0003e220: 5f74 7261 636b 6572 5f63 6f6e 6e65 6374 _tracker_connect │ │ │ -0003e230: 696f 6e3a 3a6f 6e5f 7363 7261 7065 5f72 ion::on_scrape_r │ │ │ -0003e240: 6573 706f 6e73 6528 7370 616e 266c 743b esponse(span< │ │ │ -0003e250: 6368 6172 2063 6f6e 7374 2667 743b 2062 char const> b │ │ │ -0003e260: 7566 290a 097b 0a09 0972 6573 7461 7274 uf)..{...restart │ │ │ -0003e270: 5f72 6561 645f 7469 6d65 6f75 7428 293b _read_timeout(); │ │ │ -0003e280: 0a09 0961 7574 6f20 636f 6e73 7420 6163 ...auto const ac │ │ │ -0003e290: 7469 6f6e 203d 2073 7461 7469 635f 6361 tion = static_ca │ │ │ -0003e2a0: 7374 266c 743b 6163 7469 6f6e 5f74 2667 st<action_t&g │ │ │ -0003e2b0: 743b 2861 7578 3a3a 7265 6164 5f69 6e74 t;(aux::read_int │ │ │ -0003e2c0: 3332 2862 7566 2929 3b0a 0909 7374 643a 32(buf));...std: │ │ │ -0003e2d0: 3a75 696e 7433 325f 7420 636f 6e73 7420 :uint32_t const │ │ │ -0003e2e0: 7472 616e 7361 6374 696f 6e20 3d20 6175 transaction = au │ │ │ -0003e2f0: 783a 3a72 6561 645f 7569 6e74 3332 2862 x::read_uint32(b │ │ │ -0003e300: 7566 293b 0a0a 0909 6966 2028 7472 616e uf);....if (tran │ │ │ -0003e310: 7361 6374 696f 6e20 213d 206d 5f74 7261 saction != m_tra │ │ │ -0003e320: 6e73 6163 7469 6f6e 5f69 6429 0a09 097b nsaction_id)...{ │ │ │ -0003e330: 0a09 0909 6661 696c 2865 7272 6f72 5f63 ....fail(error_c │ │ │ -0003e340: 6f64 6528 6572 726f 7273 3a3a 696e 7661 ode(errors::inva │ │ │ -0003e350: 6c69 645f 7472 6163 6b65 725f 7472 616e lid_tracker_tran │ │ │ -0003e360: 7361 6374 696f 6e5f 6964 292c 206f 7065 saction_id), ope │ │ │ -0003e370: 7261 7469 6f6e 5f74 3a3a 6269 7474 6f72 ration_t::bittor │ │ │ -0003e380: 7265 6e74 293b 0a09 0909 7265 7475 726e rent);....return │ │ │ -0003e390: 2066 616c 7365 3b0a 0909 7d0a 0a09 0969 false;...}....i │ │ │ -0003e3a0: 6620 2861 6374 696f 6e20 3d3d 2061 6374 f (action == act │ │ │ -0003e3b0: 696f 6e5f 743a 3a65 7272 6f72 290a 0909 ion_t::error)... │ │ │ -0003e3c0: 7b0a 0909 0966 6169 6c28 6572 726f 725f {....fail(error_ │ │ │ -0003e3d0: 636f 6465 2865 7272 6f72 733a 3a74 7261 code(errors::tra │ │ │ -0003e3e0: 636b 6572 5f66 6169 6c75 7265 292c 206f cker_failure), o │ │ │ -0003e3f0: 7065 7261 7469 6f6e 5f74 3a3a 6269 7474 peration_t::bitt │ │ │ -0003e400: 6f72 7265 6e74 0a09 0909 092c 2073 7464 orrent....., std │ │ │ -0003e410: 3a3a 7374 7269 6e67 2862 7566 2e64 6174 ::string(buf.dat │ │ │ -0003e420: 6128 292c 2073 7461 7469 635f 6361 7374 a(), static_cast │ │ │ -0003e430: 266c 743b 7374 643a 3a73 697a 655f 7426 <std::size_t& │ │ │ -0003e440: 6774 3b28 6275 662e 7369 7a65 2829 2929 gt;(buf.size())) │ │ │ -0003e450: 2e63 5f73 7472 2829 293b 0a09 0909 7265 .c_str());....re │ │ │ -0003e460: 7475 726e 2074 7275 653b 0a09 097d 0a0a turn true;...}.. │ │ │ -0003e470: 0909 6966 2028 6163 7469 6f6e 2021 3d20 ..if (action != │ │ │ -0003e480: 6163 7469 6f6e 5f74 3a3a 7363 7261 7065 action_t::scrape │ │ │ -0003e490: 290a 0909 7b0a 3c2f 7072 653e 3c2f 7464 )...{.
    relevance │ │ │ -0003e4d0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -0003e4e0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/disk_cac │ │ │ -0003e510: 6865 2e63 7070 3a37 3035 3c2f 613e 3c2f he.cpp:705pass the │ │ │ -0003e530: 626c 6f63 6b20 6f66 6673 6574 2061 7320 block offset as │ │ │ -0003e540: 6120 7061 7261 6d65 7465 7220 696e 7374 a parameter inst │ │ │ -0003e550: 6561 6420 6f66 2063 6f6d 7075 7469 6e67 ead of computing │ │ │ -0003e560: 2069 7420 6c69 6b65 2074 6869 733c 2f74 it like this

    pass │ │ │ -0003e5c0: 7468 6520 626c 6f63 6b20 6f66 6673 6574 the block offset │ │ │ -0003e5d0: 2061 7320 6120 7061 7261 6d65 7465 7220 as a parameter │ │ │ -0003e5e0: 696e 7374 6561 6420 6f66 2063 6f6d 7075 instead of compu │ │ │ -0003e5f0: 7469 6e67 2069 7420 6c69 6b65 2074 6869 ting it like thi │ │ │ -0003e600: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ -0003e610: 2f64 6973 6b5f 6361 6368 652e 6370 703a /disk_cache.cpp: │ │ │ -0003e620: 3730 353c 2f68 343e 3c70 7265 2073 7479 705

    template <t
    │ │ │ -0003e670: 7970 656e 616d 6520 4974 6572 2c20 7479  ypename Iter, ty
    │ │ │ -0003e680: 7065 6e61 6d65 2056 6965 7726 6774 3b0a  pename View>.
    │ │ │ -0003e690: 4974 6572 2064 6973 6b5f 6361 6368 653a  Iter disk_cache:
    │ │ │ -0003e6a0: 3a66 6c75 7368 5f70 6965 6365 5f69 6d70  :flush_piece_imp
    │ │ │ -0003e6b0: 6c28 5669 6577 2661 6d70 3b20 7669 6577  l(View& view
    │ │ │ -0003e6c0: 2c0a 0949 7465 7220 7069 6563 655f 6974  ,..Iter piece_it
    │ │ │ -0003e6d0: 6572 2c0a 0973 7464 3a3a 6675 6e63 7469  er,..std::functi
    │ │ │ -0003e6e0: 6f6e 266c 743b 696e 7428 6269 7466 6965  on<int(bitfie
    │ │ │ -0003e6f0: 6c64 2661 6d70 3b2c 2073 7061 6e26 6c74  ld&, span<
    │ │ │ -0003e700: 3b64 6973 6b5f 6a6f 622a 2063 6f6e 7374  ;disk_job* const
    │ │ │ -0003e710: 2667 743b 2926 6774 3b20 636f 6e73 7426  >)> const&
    │ │ │ -0003e720: 616d 703b 2066 2c0a 0973 7464 3a3a 756e  amp; f,..std::un
    │ │ │ -0003e730: 6971 7565 5f6c 6f63 6b26 6c74 3b73 7464  ique_lock<std
    │ │ │ -0003e740: 3a3a 6d75 7465 7826 6774 3b26 616d 703b  ::mutex>&
    │ │ │ -0003e750: 206c 2c0a 0973 7061 6e26 6c74 3b63 6163   l,..span<cac
    │ │ │ -0003e760: 6865 645f 626c 6f63 6b5f 656e 7472 7926  hed_block_entry&
    │ │ │ -0003e770: 6774 3b20 636f 6e73 7420 626c 6f63 6b73  gt; const blocks
    │ │ │ -0003e780: 2c0a 0973 7464 3a3a 6675 6e63 7469 6f6e  ,..std::function
    │ │ │ -0003e790: 266c 743b 766f 6964 286a 6f62 7175 6575  <void(jobqueu
    │ │ │ -0003e7a0: 655f 742c 2064 6973 6b5f 6a6f 622a 2926  e_t, disk_job*)&
    │ │ │ -0003e7b0: 6774 3b20 636c 6561 725f 7069 6563 655f  gt; clear_piece_
    │ │ │ -0003e7c0: 6675 6e29 0a7b 0a09 544f 5252 454e 545f  fun).{..TORRENT_
    │ │ │ -0003e7d0: 4153 5345 5254 286c 2e6f 776e 735f 6c6f  ASSERT(l.owns_lo
    │ │ │ -0003e7e0: 636b 2829 293b 0a09 2f2f 2077 6865 6e20  ck());..// when 
    │ │ │ -0003e7f0: 2262 6c6f 636b 7322 2063 6f76 6572 7320  "blocks" covers 
    │ │ │ -0003e800: 7468 6520 7768 6f6c 6520 7069 6563 6520  the whole piece 
    │ │ │ -0003e810: 7765 2063 616e 2075 7365 2074 6865 206d  we can use the m
    │ │ │ -0003e820: 6169 6e74 6169 6e65 6420 7065 722d 7069  aintained per-pi
    │ │ │ -0003e830: 6563 650a 092f 2f20 636f 756e 7465 7220  ece..// counter 
    │ │ │ -0003e840: 696e 7374 6561 6420 6f66 2073 6361 6e6e  instead of scann
    │ │ │ -0003e850: 696e 672e 2041 2073 7562 7370 616e 2028  ing. A subspan (
    │ │ │ -0003e860: 7468 6520 6368 6561 702d 666c 7573 6820  the cheap-flush 
    │ │ │ -0003e870: 7061 7373 2920 7374 696c 6c20 6e65 6564  pass) still need
    │ │ │ -0003e880: 730a 092f 2f20 746f 2063 6f75 6e74 2074  s..// to count t
    │ │ │ -0003e890: 6865 2077 7269 7465 206a 6f62 7320 7769  he write jobs wi
    │ │ │ -0003e8a0: 7468 696e 2074 6861 7420 7261 6e67 652e  thin that range.
    │ │ │ -0003e8b0: 0a09 696e 7420 636f 6e73 7420 6e75 6d5f  ..int const num_
    │ │ │ -0003e8c0: 626c 6f63 6b73 203d 2028 626c 6f63 6b73  blocks = (blocks
    │ │ │ -0003e8d0: 2e73 697a 6528 2920 3d3d 2070 6965 6365  .size() == piece
    │ │ │ -0003e8e0: 5f69 7465 722d 2667 743b 626c 6f63 6b73  _iter->blocks
    │ │ │ -0003e8f0: 5f69 6e5f 7069 6563 6528 2929 0a09 093f  _in_piece())...?
    │ │ │ -0003e900: 2069 6e74 2870 6965 6365 5f69 7465 722d   int(piece_iter-
    │ │ │ -0003e910: 2667 743b 6e75 6d5f 6a6f 6273 290a 0909  >num_jobs)...
    │ │ │ -0003e920: 3a20 636f 756e 745f 6a6f 6273 2862 6c6f  : count_jobs(blo
    │ │ │ -0003e930: 636b 7329 3b0a 0954 4f52 5245 4e54 5f41  cks);..TORRENT_A
    │ │ │ -0003e940: 5353 4552 5428 6e75 6d5f 626c 6f63 6b73  SSERT(num_blocks
    │ │ │ -0003e950: 203d 3d20 636f 756e 745f 6a6f 6273 2862   == count_jobs(b
    │ │ │ -0003e960: 6c6f 636b 7329 293b 0a09 6966 2028 6e75  locks));..if (nu
    │ │ │ -0003e970: 6d5f 626c 6f63 6b73 2026 6c74 3b3d 2030  m_blocks <= 0
    │ │ │ -0003e980: 290a 0909 7265 7475 726e 2073 7464 3a3a  )...return std::
    │ │ │ -0003e990: 6e65 7874 2870 6965 6365 5f69 7465 7229  next(piece_iter)
    │ │ │ -0003e9a0: 3b0a 0a09 2f2f 2062 6c6f 636b 7320 6d61  ;...// blocks ma
    │ │ │ -0003e9b0: 7920 6265 2061 2073 7562 7370 616e 206f  y be a subspan o
    │ │ │ -0003e9c0: 6620 616c 6c20 7468 6520 626c 6f63 6b73  f all the blocks
    │ │ │ -0003e9d0: 2069 6e20 7468 6520 7069 6563 652c 2073   in the piece, s
    │ │ │ -0003e9e0: 6f20 7768 656e 2063 6f6d 7061 7269 6e67  o when comparing
    │ │ │ -0003e9f0: 2066 6c75 7368 6564 5f63 7572 736f 7220   flushed_cursor 
    │ │ │ -0003ea00: 616e 6420 6861 7368 6572 5f63 7572 736f  and hasher_curso
    │ │ │ -0003ea10: 722c 2077 6520 6e65 6564 2074 6f20 6164  r, we need to ad
    │ │ │ -0003ea20: 6420 7468 6520 6f66 6673 6574 2e0a 3c64  d the offset...int
    │ │ │ -0003ea60: 2063 6f6e 7374 2062 6c6f 636b 5f6f 6666   const block_off
    │ │ │ -0003ea70: 7365 7420 3d20 7374 6174 6963 5f63 6173  set = static_cas
    │ │ │ -0003ea80: 7426 6c74 3b69 6e74 2667 743b 2862 6c6f  t<int>(blo
    │ │ │ -0003ea90: 636b 732e 6461 7461 2829 202d 2070 6965  cks.data() - pie
    │ │ │ -0003eaa0: 6365 5f69 7465 722d 2667 743b 6765 745f  ce_iter->get_
    │ │ │ -0003eab0: 626c 6f63 6b73 2829 2e64 6174 6128 2929  blocks().data())
    │ │ │ -0003eac0: 3b0a 3c2f 6469 763e 0a09 7669 6577 2e6d  ;.
    ..view.m │ │ │ -0003ead0: 6f64 6966 7928 7069 6563 655f 6974 6572 odify(piece_iter │ │ │ -0003eae0: 2c20 5b5d 2863 6163 6865 645f 7069 6563 , [](cached_piec │ │ │ -0003eaf0: 655f 656e 7472 7926 616d 703b 2065 2920 e_entry& e) │ │ │ -0003eb00: 7b0a 0909 544f 5252 454e 545f 4153 5345 {...TORRENT_ASSE │ │ │ -0003eb10: 5254 2821 2865 2e66 6c61 6773 2026 616d RT(!(e.flags &am │ │ │ -0003eb20: 703b 2063 6163 6865 645f 7069 6563 655f p; cached_piece_ │ │ │ -0003eb30: 656e 7472 793a 3a66 6c75 7368 696e 675f entry::flushing_ │ │ │ -0003eb40: 666c 6167 2929 3b0a 0909 652e 666c 6167 flag));...e.flag │ │ │ -0003eb50: 7320 7c3d 2063 6163 6865 645f 7069 6563 s |= cached_piec │ │ │ -0003eb60: 655f 656e 7472 793a 3a66 6c75 7368 696e e_entry::flushin │ │ │ -0003eb70: 675f 666c 6167 3b0a 097d 293b 0a0a 092f g_flag;..});.../ │ │ │ -0003eb80: 2f20 536e 6170 7368 6f74 2074 6865 2070 / Snapshot the p │ │ │ -0003eb90: 656e 6469 6e67 2077 7269 7465 5f6a 6f62 ending write_job │ │ │ -0003eba0: 2070 6f69 6e74 6572 2066 6f72 2065 6163 pointer for eac │ │ │ -0003ebb0: 6820 626c 6f63 6b20 7768 696c 6520 7765 h block while we │ │ │ -0003ebc0: 2073 7469 6c6c 0a09 2f2f 2068 6f6c 6420 still..// hold │ │ │ -0003ebd0: 7468 6520 6d75 7465 782e 2066 6c75 7368 the mutex. flush │ │ │ -0003ebe0: 696e 675f 666c 6167 2070 7265 7665 6e74 ing_flag prevent │ │ │ -0003ebf0: 7320 6f74 6865 7220 7468 7265 6164 7320 s other threads │ │ │ -0003ec00: 6672 6f6d 2066 6c75 7368 696e 670a 092f from flushing../ │ │ │ -0003ec10: 2f20 7468 6973 2070 6965 6365 2c20 6275 / this piece, bu │ │ │ -0003ec20: 7420 6469 736b 5f63 6163 6865 3a3a 696e t disk_cache::in │ │ │ -0003ec30: 7365 7274 2829 206d 6179 2073 7469 6c6c sert() may still │ │ │ -0003ec40: 2070 6f70 756c 6174 6520 7072 6576 696f populate previo │ │ │ -0003ec50: 7573 6c79 0a09 2f2f 2065 6d70 7479 2074 usly..// empty t │ │ │ -0003ec60: 7261 696c 696e 6720 736c 6f74 7320 2869 railing slots (i │ │ │ -0003ec70: 6e73 6572 7420 6f6e 6c79 2072 6571 7569 nsert only requi │ │ │ -0003ec80: 7265 7320 626c 6f63 6b5f 6964 7820 2667 res block_idx &g │ │ │ -0003ec90: 743b 3d20 6861 7368 6572 5f63 7572 736f t;= hasher_curso │ │ │ -0003eca0: 7229 2e0a 092f 2f20 5265 6164 696e 6720 r)...// Reading │ │ │ -0003ecb0: 6361 6368 6564 5f62 6c6f 636b 5f65 6e74 cached_block_ent │ │ │ -0003ecc0: 7279 3a3a 7772 6974 655f 7374 6174 6520 ry::write_state │ │ │ -0003ecd0: 6672 6f6d 206f 7574 7369 6465 2074 6865 from outside the │ │ │ -0003ece0: 206c 6f63 6b20 776f 756c 640a 092f 2f20 lock would..// │ │ │ -0003ecf0: 7261 6365 2077 6974 6820 7468 6174 2e20 race with that. │ │ │ -0003ed00: 4f6e 6365 2061 2073 6c6f 7420 686f 6c64 Once a slot hold │ │ │ -0003ed10: 7320 6120 6469 736b 5f6a 6f62 2074 6865 s a disk_job the │ │ │ -0003ed20: 206e 6574 776f 726b 2074 6872 6561 6420 network thread │ │ │ -0003ed30: 776f 6e27 740a 092f 2f20 746f 7563 6820 won't..// touch │ │ │ -0003ed40: 6974 2028 6e6f 7220 7468 6520 6a6f 6227 it (nor the job' │ │ │ -0003ed50: 7320 636f 6e74 656e 7473 2920 756e 7469 s contents) unti │ │ │ -0003ed60: 6c20 7468 6520 6469 736b 2074 6872 6561 l the disk threa │ │ │ -0003ed70: 6420 7461 6b65 7320 6974 0a09 2f2f 2062 d takes it..// b │ │ │ -0003ed80: 6163 6b2c 2073 6f20 7468 6520 736e 6170 ack, so the snap │ │ │ -0003ed90: 7368 6f74 7465 6420 706f 696e 7465 7273 shotted pointers │ │ │ -0003eda0: 2061 6e64 2074 6865 2062 7566 6665 7273 and the buffers │ │ │ -0003edb0: 2074 6865 7920 7265 6665 7265 6e63 6520 they reference │ │ │ -0003edc0: 7374 6179 0a09 2f2f 2076 616c 6964 2066 stay..// valid f │ │ │ -0003edd0: 6f72 2074 6865 2065 6e74 6972 6520 756e or the entire un │ │ │ -0003ede0: 6c6f 636b 6564 2072 6567 696f 6e20 6265 locked region be │ │ │ -0003edf0: 6c6f 772e 0a09 544f 5252 454e 545f 414c low...TORRENT_AL │ │ │ -0003ee00: 4c4f 4341 2873 6e61 7073 686f 742c 2064 LOCA(snapshot, d │ │ │ -0003ee10: 6973 6b5f 6a6f 622a 2c20 626c 6f63 6b73 isk_job*, blocks │ │ │ -0003ee20: 2e73 697a 6528 2929 3b0a 0966 6f72 2028 .size());..for ( │ │ │ -0003ee30: 696e 7420 6920 3d20 303b 2069 2026 6c74 int i = 0; i < │ │ │ -0003ee40: 3b20 626c 6f63 6b73 2e73 697a 6528 293b ; blocks.size(); │ │ │ -0003ee50: 202b 2b69 290a 0909 736e 6170 7368 6f74 ++i)...snapshot │ │ │ -0003ee60: 5b69 5d20 3d20 626c 6f63 6b73 5b69 5d2e [i] = blocks[i]. │ │ │ -0003ee70: 6765 745f 7772 6974 655f 6a6f 6228 293b get_write_job(); │ │ │ -0003ee80: 0a0a 092f 2f20 7765 2068 6176 6520 746f ...// we have to │ │ │ -0003ee90: 2072 656c 6561 7365 2074 6865 206c 6f63 release the loc │ │ │ -0003eea0: 6b20 7768 696c 6520 666c 7573 6869 6e67 k while flushing │ │ │ -0003eeb0: 2c20 6275 7420 7369 6e63 6520 7765 2073 , but since we s │ │ │ -0003eec0: 6574 2074 6865 0a09 2f2f 2022 666c 7573 et the..// "flus │ │ │ -0003eed0: 6869 6e67 2220 6d65 6d62 6572 2074 6f20 hing" member to │ │ │ -0003eee0: 7472 7565 2c20 7468 6973 2070 6965 6365 true, this piece │ │ │ -0003eef0: 2069 7320 7069 6e6e 6564 2074 6f20 7468 is pinned to th │ │ │ -0003ef00: 6520 6361 6368 650a 096c 2e75 6e6c 6f63 e cache..l.unloc │ │ │ -0003ef10: 6b28 293b 0a0a 0969 6e74 2063 6f75 6e74 k();...int count │ │ │ -0003ef20: 203d 2030 3b0a 0962 6974 6669 656c 6420 = 0;..bitfield │ │ │ -0003ef30: 666c 7573 6865 645f 626c 6f63 6b73 3b0a flushed_blocks;. │ │ │ -0003ef40: 097b 0a09 0961 7574 6f20 7365 203d 2073 .{...auto se = s │ │ │ -0003ef50: 636f 7065 5f65 6e64 285b 2661 6d70 3b5d cope_end([&] │ │ │ -0003ef60: 207b 0a09 0909 6c2e 6c6f 636b 2829 3b0a {....l.lock();. │ │ │ -0003ef70: 0909 0962 6f6f 6c20 6e6f 7469 6679 203d ...bool notify = │ │ │ -0003ef80: 2066 616c 7365 3b0a 0909 0976 6965 772e false;....view. │ │ │ -0003ef90: 6d6f 6469 6679 2870 6965 6365 5f69 7465 modify(piece_ite │ │ │ -0003efa0: 722c 205b 2661 6d70 3b6e 6f74 6966 795d r, [&notify] │ │ │ -0003efb0: 2863 6163 6865 645f 7069 6563 655f 656e (cached_piece_en │ │ │ -0003efc0: 7472 7926 616d 703b 2065 2920 7b0a 3c2f try& e) {.r │ │ │ -0003f000: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0003f010: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0003f040: 6370 7569 642e 6370 703a 3131 343c 2f61 cpuid.cpp:114enable │ │ │ -0003f060: 2077 6865 6e20 6161 7263 6836 3420 6973 when aarch64 is │ │ │ -0003f070: 2072 6561 6c6c 7920 7465 7374 6564 3c2f really tested

    enab │ │ │ -0003f0d0: 6c65 2077 6865 6e20 6161 7263 6836 3420 le when aarch64 │ │ │ -0003f0e0: 6973 2072 6561 6c6c 7920 7465 7374 6564 is really tested │ │ │ -0003f0f0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0003f100: 6370 7569 642e 6370 703a 3131 343c 2f68 cpuid.cpp:114
    .boo
    │ │ │ -0003f150: 6c20 7375 7070 6f72 7473 5f6d 6d78 2829  l supports_mmx()
    │ │ │ -0003f160: 206e 6f65 7863 6570 740a 097b 0a23 6966   noexcept..{.#if
    │ │ │ -0003f170: 2054 4f52 5245 4e54 5f48 4153 5f53 5345   TORRENT_HAS_SSE
    │ │ │ -0003f180: 0a09 0973 7464 3a3a 7569 6e74 3332 5f74  ...std::uint32_t
    │ │ │ -0003f190: 2063 7075 695b 345d 203d 207b 307d 3b0a   cpui[4] = {0};.
    │ │ │ -0003f1a0: 0909 6370 7569 6428 6370 7569 2c20 3129  ..cpuid(cpui, 1)
    │ │ │ -0003f1b0: 3b0a 0909 7265 7475 726e 2028 6370 7569  ;...return (cpui
    │ │ │ -0003f1c0: 5b32 5d20 2661 6d70 3b20 2831 2026 6c74  [2] & (1 <
    │ │ │ -0003f1d0: 3b26 6c74 3b20 3233 2929 2021 3d20 303b  ;< 23)) != 0;
    │ │ │ -0003f1e0: 0a23 656c 7365 0a09 0972 6574 7572 6e20  .#else...return 
    │ │ │ -0003f1f0: 6661 6c73 653b 0a23 656e 6469 660a 097d  false;.#endif..}
    │ │ │ -0003f200: 0a0a 0962 6f6f 6c20 7375 7070 6f72 7473  ...bool supports
    │ │ │ -0003f210: 5f61 726d 5f6e 656f 6e28 2920 6e6f 6578  _arm_neon() noex
    │ │ │ -0003f220: 6365 7074 0a09 7b0a 2369 6620 544f 5252  cept..{.#if TORR
    │ │ │ -0003f230: 454e 545f 4841 535f 4152 4d5f 4e45 4f4e  ENT_HAS_ARM_NEON
    │ │ │ -0003f240: 2026 616d 703b 2661 6d70 3b20 544f 5252   && TORR
    │ │ │ -0003f250: 454e 545f 4841 535f 4155 5856 0a23 6966  ENT_HAS_AUXV.#if
    │ │ │ -0003f260: 2064 6566 696e 6564 205f 5f61 726d 5f5f   defined __arm__
    │ │ │ -0003f270: 0a09 092f 2f72 6574 7572 6e20 2867 6574  ...//return (get
    │ │ │ -0003f280: 6175 7876 616c 2841 545f 4857 4341 5029  auxval(AT_HWCAP)
    │ │ │ -0003f290: 2026 616d 703b 2048 5743 4150 5f4e 454f   & HWCAP_NEO
    │ │ │ -0003f2a0: 4e29 3b0a 0909 7265 7475 726e 2028 6865  N);...return (he
    │ │ │ -0003f2b0: 6c70 6572 5f67 6574 6175 7876 616c 2831  lper_getauxval(1
    │ │ │ -0003f2c0: 3629 2026 616d 703b 2028 3120 266c 743b  6) & (1 <
    │ │ │ -0003f2d0: 266c 743b 2031 3229 293b 0a23 656c 6966  < 12));.#elif
    │ │ │ -0003f2e0: 2064 6566 696e 6564 205f 5f61 6172 6368   defined __aarch
    │ │ │ -0003f2f0: 3634 5f5f 0a09 092f 2f72 6574 7572 6e20  64__...//return 
    │ │ │ -0003f300: 2867 6574 6175 7876 616c 2841 545f 4857  (getauxval(AT_HW
    │ │ │ -0003f310: 4341 5029 2026 616d 703b 2048 5743 4150  CAP) & HWCAP
    │ │ │ -0003f320: 5f41 5349 4d44 293b 0a09 092f 2f72 6574  _ASIMD);...//ret
    │ │ │ -0003f330: 7572 6e20 2867 6574 6175 7876 616c 2831  urn (getauxval(1
    │ │ │ -0003f340: 3629 2026 616d 703b 2028 3120 266c 743b  6) & (1 <
    │ │ │ -0003f350: 266c 743b 2031 2929 3b0a 3c64 6976 2073  < 1));.
    ..return │ │ │ -0003f390: 2066 616c 7365 3b0a 3c2f 6469 763e 2365 false;.
    #e │ │ │ -0003f3a0: 6e64 6966 0a23 656c 7365 0a09 0972 6574 ndif.#else...ret │ │ │ -0003f3b0: 7572 6e20 6661 6c73 653b 0a23 656e 6469 urn false;.#endi │ │ │ -0003f3c0: 660a 097d 0a0a 0962 6f6f 6c20 7375 7070 f..}...bool supp │ │ │ -0003f3d0: 6f72 7473 5f61 726d 5f63 7263 3332 6328 orts_arm_crc32c( │ │ │ -0003f3e0: 2920 6e6f 6578 6365 7074 0a09 7b0a 2369 ) noexcept..{.#i │ │ │ -0003f3f0: 6620 544f 5252 454e 545f 4841 535f 4152 f TORRENT_HAS_AR │ │ │ -0003f400: 4d5f 4352 4333 3220 2661 6d70 3b26 616d M_CRC32 &&am │ │ │ -0003f410: 703b 2054 4f52 5245 4e54 5f48 4153 5f41 p; TORRENT_HAS_A │ │ │ -0003f420: 5558 560a 2369 6620 6465 6669 6e65 6420 UXV.#if defined │ │ │ -0003f430: 544f 5252 454e 545f 464f 5243 455f 4152 TORRENT_FORCE_AR │ │ │ -0003f440: 4d5f 4352 4333 320a 0909 7265 7475 726e M_CRC32...return │ │ │ -0003f450: 2074 7275 653b 0a23 656c 6966 2064 6566 true;.#elif def │ │ │ -0003f460: 696e 6564 205f 5f61 726d 5f5f 0a09 092f ined __arm__.../ │ │ │ -0003f470: 2f72 6574 7572 6e20 2867 6574 6175 7876 /return (getauxv │ │ │ -0003f480: 616c 2841 545f 4857 4341 5032 2920 2661 al(AT_HWCAP2) &a │ │ │ -0003f490: 6d70 3b20 4857 4341 5032 5f43 5243 3332 mp; HWCAP2_CRC32 │ │ │ -0003f4a0: 293b 0a09 0972 6574 7572 6e20 2868 656c );...return (hel │ │ │ -0003f4b0: 7065 725f 6765 7461 7578 7661 6c28 3236 per_getauxval(26 │ │ │ -0003f4c0: 2920 2661 6d70 3b20 2831 2026 6c74 3b26 ) & (1 <& │ │ │ -0003f4d0: 6c74 3b20 3429 293b 0a23 656c 6966 2064 lt; 4));.#elif d │ │ │ -0003f4e0: 6566 696e 6564 205f 5f61 6172 6368 3634 efined __aarch64 │ │ │ -0003f4f0: 5f5f 0a09 092f 2f72 6574 7572 6e20 2867 __...//return (g │ │ │ -0003f500: 6574 6175 7876 616c 2841 545f 4857 4341 etauxval(AT_HWCA │ │ │ -0003f510: 5029 2026 616d 703b 2048 5743 4150 5f43 P) & HWCAP_C │ │ │ -0003f520: 5243 3332 293b 0a09 0972 6574 7572 6e20 RC32);...return │ │ │ -0003f530: 2868 656c 7065 725f 6765 7461 7578 7661 (helper_getauxva │ │ │ -0003f540: 6c28 3136 2920 2661 6d70 3b20 2831 2026 l(16) & (1 & │ │ │ -0003f550: 6c74 3b26 6c74 3b20 3729 293b 0a23 656e lt;< 7));.#en │ │ │ -0003f560: 6469 660a 2365 6c73 650a 0909 7265 7475 dif.#else...retu │ │ │ -0003f570: 726e 2066 616c 7365 3b0a 2365 6e64 6966 rn false;.#endif │ │ │ -0003f580: 0a09 7d0a 0a23 6966 6465 6620 5f5f 636c ..}..#ifdef __cl │ │ │ -0003f590: 616e 675f 5f0a 2370 7261 676d 6120 636c ang__.#pragma cl │ │ │ -0003f5a0: 616e 6720 6469 6167 6e6f 7374 6963 2070 ang diagnostic p │ │ │ -0003f5b0: 6f70 0a23 656e 6469 660a 0a7d 202f 2f20 op.#endif..} // │ │ │ -0003f5c0: 616e 6f6e 796d 6f75 7320 6e61 6d65 7370 anonymous namesp │ │ │ -0003f5d0: 6163 650a 0a09 626f 6f6c 2063 6f6e 7374 ace...bool const │ │ │ -0003f5e0: 2073 7365 3432 5f73 7570 706f 7274 203d sse42_support = │ │ │ -0003f5f0: 2073 7570 706f 7274 735f 7373 6534 3228 supports_sse42( │ │ │ -0003f600: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ -0003f630: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0003f640: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -0003f670: 2f73 7263 2f73 6574 7469 6e67 735f 7061 /src/settings_pa │ │ │ -0003f680: 636b 2e63 7070 3a32 3835 3c2f 613e 3c2f ck.cpp:285deprecate │ │ │ -0003f6a0: 2074 6869 733c 2f74 643e 3c2f 7472 3e3c this< │ │ │ -0003f6b0: 7472 2069 643d 2231 3539 2220 7374 796c tr id="159" styl │ │ │ -0003f6c0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0003f6d0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0003f6e0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0003f6f0: 6832 3e64 6570 7265 6361 7465 2074 6869 h2>deprecate thi │ │ │ -0003f700: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ -0003f710: 2f73 6574 7469 6e67 735f 7061 636b 2e63 /settings_pack.c │ │ │ -0003f720: 7070 3a32 3835 3c2f 6834 3e3c 7072 6520 pp:285

    ..SET(outgo
    │ │ │ -0003f770: 696e 675f 706f 7274 2c20 302c 206e 756c  ing_port, 0, nul
    │ │ │ -0003f780: 6c70 7472 292c 0a09 0953 4554 286e 756d  lptr),...SET(num
    │ │ │ -0003f790: 5f6f 7574 676f 696e 675f 706f 7274 732c  _outgoing_ports,
    │ │ │ -0003f7a0: 2030 2c20 6e75 6c6c 7074 7229 2c0a 0909   0, nullptr),...
    │ │ │ -0003f7b0: 5345 5428 7065 6572 5f64 7363 702c 2030  SET(peer_dscp, 0
    │ │ │ -0003f7c0: 7830 312c 2026 616d 703b 7365 7373 696f  x01, &sessio
    │ │ │ -0003f7d0: 6e5f 696d 706c 3a3a 7570 6461 7465 5f70  n_impl::update_p
    │ │ │ -0003f7e0: 6565 725f 6473 6370 292c 0a09 0953 4554  eer_dscp),...SET
    │ │ │ -0003f7f0: 2861 6374 6976 655f 646f 776e 6c6f 6164  (active_download
    │ │ │ -0003f800: 732c 2033 2c20 2661 6d70 3b73 6573 7369  s, 3, &sessi
    │ │ │ -0003f810: 6f6e 5f69 6d70 6c3a 3a74 7269 6767 6572  on_impl::trigger
    │ │ │ -0003f820: 5f61 7574 6f5f 6d61 6e61 6765 292c 0a09  _auto_manage),..
    │ │ │ -0003f830: 0953 4554 2861 6374 6976 655f 7365 6564  .SET(active_seed
    │ │ │ -0003f840: 732c 2035 2c20 2661 6d70 3b73 6573 7369  s, 5, &sessi
    │ │ │ -0003f850: 6f6e 5f69 6d70 6c3a 3a74 7269 6767 6572  on_impl::trigger
    │ │ │ -0003f860: 5f61 7574 6f5f 6d61 6e61 6765 292c 0a09  _auto_manage),..
    │ │ │ -0003f870: 0953 4554 2861 6374 6976 655f 6368 6563  .SET(active_chec
    │ │ │ -0003f880: 6b69 6e67 2c20 312c 2026 616d 703b 7365  king, 1, &se
    │ │ │ -0003f890: 7373 696f 6e5f 696d 706c 3a3a 7472 6967  ssion_impl::trig
    │ │ │ -0003f8a0: 6765 725f 6175 746f 5f6d 616e 6167 6529  ger_auto_manage)
    │ │ │ -0003f8b0: 2c0a 0909 5345 5428 6163 7469 7665 5f64  ,...SET(active_d
    │ │ │ -0003f8c0: 6874 5f6c 696d 6974 2c20 3838 2c20 6e75  ht_limit, 88, nu
    │ │ │ -0003f8d0: 6c6c 7074 7229 2c0a 0909 5345 5428 6163  llptr),...SET(ac
    │ │ │ -0003f8e0: 7469 7665 5f74 7261 636b 6572 5f6c 696d  tive_tracker_lim
    │ │ │ -0003f8f0: 6974 2c20 3136 3030 2c20 6e75 6c6c 7074  it, 1600, nullpt
    │ │ │ -0003f900: 7229 2c0a 0909 5345 5428 6163 7469 7665  r),...SET(active
    │ │ │ -0003f910: 5f6c 7364 5f6c 696d 6974 2c20 3630 2c20  _lsd_limit, 60, 
    │ │ │ -0003f920: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428  nullptr),...SET(
    │ │ │ -0003f930: 6163 7469 7665 5f6c 696d 6974 2c20 3530  active_limit, 50
    │ │ │ -0003f940: 302c 2026 616d 703b 7365 7373 696f 6e5f  0, &session_
    │ │ │ -0003f950: 696d 706c 3a3a 7472 6967 6765 725f 6175  impl::trigger_au
    │ │ │ -0003f960: 746f 5f6d 616e 6167 6529 2c0a 0909 4445  to_manage),...DE
    │ │ │ -0003f970: 5052 4543 4154 4544 5f53 4554 2861 6374  PRECATED_SET(act
    │ │ │ -0003f980: 6976 655f 6c6f 6164 6564 5f6c 696d 6974  ive_loaded_limit
    │ │ │ -0003f990: 2c20 302c 2026 616d 703b 7365 7373 696f  , 0, &sessio
    │ │ │ -0003f9a0: 6e5f 696d 706c 3a3a 7472 6967 6765 725f  n_impl::trigger_
    │ │ │ -0003f9b0: 6175 746f 5f6d 616e 6167 6529 2c0a 0909  auto_manage),...
    │ │ │ -0003f9c0: 5345 5428 6175 746f 5f6d 616e 6167 655f  SET(auto_manage_
    │ │ │ -0003f9d0: 696e 7465 7276 616c 2c20 3330 2c20 6e75  interval, 30, nu
    │ │ │ -0003f9e0: 6c6c 7074 7229 2c0a 0909 5345 5428 7365  llptr),...SET(se
    │ │ │ -0003f9f0: 6564 5f74 696d 655f 6c69 6d69 742c 2032  ed_time_limit, 2
    │ │ │ -0003fa00: 3420 2a20 3630 202a 2036 302c 206e 756c  4 * 60 * 60, nul
    │ │ │ -0003fa10: 6c70 7472 292c 0a09 0953 4554 2861 7574  lptr),...SET(aut
    │ │ │ -0003fa20: 6f5f 7363 7261 7065 5f69 6e74 6572 7661  o_scrape_interva
    │ │ │ -0003fa30: 6c2c 2031 3830 302c 206e 756c 6c70 7472  l, 1800, nullptr
    │ │ │ -0003fa40: 292c 0a09 0953 4554 2861 7574 6f5f 7363  ),...SET(auto_sc
    │ │ │ -0003fa50: 7261 7065 5f6d 696e 5f69 6e74 6572 7661  rape_min_interva
    │ │ │ -0003fa60: 6c2c 2033 3030 2c20 6e75 6c6c 7074 7229  l, 300, nullptr)
    │ │ │ -0003fa70: 2c0a 0909 5345 5428 6d61 785f 7065 6572  ,...SET(max_peer
    │ │ │ -0003fa80: 6c69 7374 5f73 697a 652c 2033 3030 302c  list_size, 3000,
    │ │ │ -0003fa90: 206e 756c 6c70 7472 292c 0a09 0953 4554   nullptr),...SET
    │ │ │ -0003faa0: 286d 6178 5f70 6175 7365 645f 7065 6572  (max_paused_peer
    │ │ │ -0003fab0: 6c69 7374 5f73 697a 652c 2031 3030 302c  list_size, 1000,
    │ │ │ -0003fac0: 206e 756c 6c70 7472 292c 0a09 0953 4554   nullptr),...SET
    │ │ │ -0003fad0: 286d 696e 5f61 6e6e 6f75 6e63 655f 696e  (min_announce_in
    │ │ │ -0003fae0: 7465 7276 616c 2c20 3520 2a20 3630 2c20  terval, 5 * 60, 
    │ │ │ -0003faf0: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428  nullptr),...SET(
    │ │ │ -0003fb00: 6175 746f 5f6d 616e 6167 655f 7374 6172  auto_manage_star
    │ │ │ -0003fb10: 7475 702c 2036 302c 206e 756c 6c70 7472  tup, 60, nullptr
    │ │ │ -0003fb20: 292c 0a09 0953 4554 2873 6565 6469 6e67  ),...SET(seeding
    │ │ │ -0003fb30: 5f70 6965 6365 5f71 756f 7461 2c20 3230  _piece_quota, 20
    │ │ │ -0003fb40: 2c20 6e75 6c6c 7074 7229 2c0a 3c64 6976  , nullptr),.
    ..SET( │ │ │ -0003fb80: 6d61 785f 7265 6a65 6374 732c 2035 302c max_rejects, 50, │ │ │ -0003fb90: 206e 756c 6c70 7472 292c 0a3c 2f64 6976 nullptr),.
    ..SET(recv_sock │ │ │ -0003fbb0: 6574 5f62 7566 6665 725f 7369 7a65 2c20 et_buffer_size, │ │ │ -0003fbc0: 302c 2026 616d 703b 7365 7373 696f 6e5f 0, &session_ │ │ │ -0003fbd0: 696d 706c 3a3a 7570 6461 7465 5f73 6f63 impl::update_soc │ │ │ -0003fbe0: 6b65 745f 6275 6666 6572 5f73 697a 6529 ket_buffer_size) │ │ │ -0003fbf0: 2c0a 0909 5345 5428 7365 6e64 5f73 6f63 ,...SET(send_soc │ │ │ -0003fc00: 6b65 745f 6275 6666 6572 5f73 697a 652c ket_buffer_size, │ │ │ -0003fc10: 2030 2c20 2661 6d70 3b73 6573 7369 6f6e 0, &session │ │ │ -0003fc20: 5f69 6d70 6c3a 3a75 7064 6174 655f 736f _impl::update_so │ │ │ -0003fc30: 636b 6574 5f62 7566 6665 725f 7369 7a65 cket_buffer_size │ │ │ -0003fc40: 292c 0a09 0953 4554 286d 6178 5f70 6565 ),...SET(max_pee │ │ │ -0003fc50: 725f 7265 6376 5f62 7566 6665 725f 7369 r_recv_buffer_si │ │ │ -0003fc60: 7a65 2c20 3220 2a20 3130 3234 202a 2031 ze, 2 * 1024 * 1 │ │ │ -0003fc70: 3032 342c 206e 756c 6c70 7472 292c 0a09 024, nullptr),.. │ │ │ -0003fc80: 0944 4550 5245 4341 5445 445f 5345 5428 .DEPRECATED_SET( │ │ │ -0003fc90: 6669 6c65 5f63 6865 636b 735f 6465 6c61 file_checks_dela │ │ │ -0003fca0: 795f 7065 725f 626c 6f63 6b2c 2030 2c20 y_per_block, 0, │ │ │ -0003fcb0: 6e75 6c6c 7074 7229 2c0a 0909 4445 5052 nullptr),...DEPR │ │ │ -0003fcc0: 4543 4154 4544 325f 5345 5428 7265 6164 ECATED2_SET(read │ │ │ -0003fcd0: 5f63 6163 6865 5f6c 696e 655f 7369 7a65 _cache_line_size │ │ │ -0003fce0: 2c20 3332 2c20 6e75 6c6c 7074 7229 2c0a , 32, nullptr),. │ │ │ -0003fcf0: 0909 4445 5052 4543 4154 4544 325f 5345 ..DEPRECATED2_SE │ │ │ -0003fd00: 5428 7772 6974 655f 6361 6368 655f 6c69 T(write_cache_li │ │ │ -0003fd10: 6e65 5f73 697a 652c 2031 362c 206e 756c ne_size, 16, nul │ │ │ -0003fd20: 6c70 7472 292c 0a09 0953 4554 286f 7074 lptr),...SET(opt │ │ │ -0003fd30: 696d 6973 7469 635f 6469 736b 5f72 6574 imistic_disk_ret │ │ │ -0003fd40: 7279 2c20 3130 202a 2036 302c 206e 756c ry, 10 * 60, nul │ │ │ -0003fd50: 6c70 7472 292c 0a09 0953 4554 286d 6178 lptr),...SET(max │ │ │ -0003fd60: 5f73 7567 6765 7374 5f70 6965 6365 732c _suggest_pieces, │ │ │ -0003fd70: 2031 362c 206e 756c 6c70 7472 292c 0a09 16, nullptr),.. │ │ │ -0003fd80: 0953 4554 286c 6f63 616c 5f73 6572 7669 .SET(local_servi │ │ │ -0003fd90: 6365 5f61 6e6e 6f75 6e63 655f 696e 7465 ce_announce_inte │ │ │ -0003fda0: 7276 616c 2c20 3520 2a20 3630 2c20 6e75 rval, 5 * 60, nu │ │ │ -0003fdb0: 6c6c 7074 7229 2c0a 0909 5345 5428 6468 llptr),...SET(dh │ │ │ -0003fdc0: 745f 616e 6e6f 756e 6365 5f69 6e74 6572 t_announce_inter │ │ │ -0003fdd0: 7661 6c2c 2031 3520 2a20 3630 2c20 2661 val, 15 * 60, &a │ │ │ -0003fde0: 6d70 3b73 6573 7369 6f6e 5f69 6d70 6c3a mp;session_impl: │ │ │ -0003fdf0: 3a75 7064 6174 655f 6468 745f 616e 6e6f :update_dht_anno │ │ │ -0003fe00: 756e 6365 5f69 6e74 6572 7661 6c29 2c0a unce_interval),. │ │ │ -0003fe10: 0909 5345 5428 7564 705f 7472 6163 6b65 ..SET(udp_tracke │ │ │ -0003fe20: 725f 746f 6b65 6e5f 6578 7069 7279 2c20 r_token_expiry, │ │ │ -0003fe30: 3630 2c20 6e75 6c6c 7074 7229 2c0a 0909 60, nullptr),... │ │ │ -0003fe40: 4445 5052 4543 4154 4544 5f53 4554 2864 DEPRECATED_SET(d │ │ │ -0003fe50: 6566 6175 6c74 5f63 6163 6865 5f6d 696e efault_cache_min │ │ │ -0003fe60: 5f61 6765 2c20 312c 206e 756c 6c70 7472 _age, 1, nullptr │ │ │ -0003fe70: 292c 0a09 0953 4554 286e 756d 5f6f 7074 ),...SET(num_opt │ │ │ -0003fe80: 696d 6973 7469 635f 756e 6368 6f6b 655f imistic_unchoke_ │ │ │ -0003fe90: 736c 6f74 732c 2030 2c20 6e75 6c6c 7074 slots, 0, nullpt │ │ │ -0003fea0: 7229 2c0a 0909 4445 5052 4543 4154 4544 r),...DEPRECATED │ │ │ -0003feb0: 5f53 4554 2864 6566 6175 6c74 5f65 7374 _SET(default_est │ │ │ -0003fec0: 5f72 6563 6970 726f 6361 7469 6f6e 5f72 _reciprocation_r │ │ │ -0003fed0: 6174 652c 2031 3630 3030 2c20 6e75 6c6c ate, 16000, null │ │ │ -0003fee0: 7074 7229 2c0a 0909 4445 5052 4543 4154 ptr),...DEPRECAT │ │ │ -0003fef0: 4544 5f53 4554 2869 6e63 7265 6173 655f ED_SET(increase_ │ │ │ -0003ff00: 6573 745f 7265 6369 7072 6f63 6174 696f est_reciprocatio │ │ │ -0003ff10: 6e5f 7261 7465 2c20 3230 2c20 6e75 6c6c n_rate, 20, null │ │ │ -0003ff20: 7074 7229 2c0a 0909 4445 5052 4543 4154 ptr),...DEPRECAT │ │ │ -0003ff30: 4544 5f53 4554 2864 6563 7265 6173 655f ED_SET(decrease_ │ │ │ -0003ff40: 6573 745f 7265 6369 7072 6f63 6174 696f est_reciprocatio │ │ │ -0003ff50: 6e5f 7261 7465 2c20 332c 206e 756c 6c70 n_rate, 3, nullp │ │ │ -0003ff60: 7472 292c 0a09 0953 4554 286d 6178 5f70 tr),...SET(max_p │ │ │ -0003ff70: 6578 5f70 6565 7273 2c20 3530 2c20 6e75 ex_peers, 50, nu │ │ │ -0003ff80: 6c6c 7074 7229 2c0a 0909 5345 5428 7469 llptr),...SET(ti │ │ │ -0003ff90: 636b 5f69 6e74 6572 7661 6c2c 2035 3030 ck_interval, 500 │ │ │ -0003ffa0: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345 , nullptr),...SE │ │ │ -0003ffb0: 5428 7368 6172 655f 6d6f 6465 5f74 6172 T(share_mode_tar │ │ │ -0003ffc0: 6765 742c 2033 2c20 6e75 6c6c 7074 7229 get, 3, nullptr) │ │ │ -0003ffd0: 2c0a 0909 5345 5428 7570 6c6f 6164 5f72 ,...SET(upload_r │ │ │ -0003ffe0: 6174 655f 6c69 6d69 742c 2030 2c20 2661 ate_limit, 0, &a │ │ │ -0003fff0: 6d70 3b73 6573 7369 6f6e 5f69 6d70 6c3a mp;session_impl: │ │ │ -00040000: 3a75 7064 6174 655f 7570 6c6f 6164 5f72 :update_upload_r │ │ │ -00040010: 6174 6529 2c0a 0909 5345 5428 646f 776e ate),...SET(down │ │ │ -00040020: 6c6f 6164 5f72 6174 655f 6c69 6d69 742c load_rate_limit, │ │ │ -00040030: 2030 2c20 2661 6d70 3b73 6573 7369 6f6e 0, &session │ │ │ -00040040: 5f69 6d70 6c3a 3a75 7064 6174 655f 646f _impl::update_do │ │ │ -00040050: 776e 6c6f 6164 5f72 6174 6529 2c0a 0909 wnload_rate),... │ │ │ -00040060: 4445 5052 4543 4154 4544 5f53 4554 286c DEPRECATED_SET(l │ │ │ -00040070: 6f63 616c 5f75 706c 6f61 645f 7261 7465 ocal_upload_rate │ │ │ -00040080: 5f6c 696d 6974 2c20 302c 2026 616d 703b _limit, 0, & │ │ │ -00040090: 7365 7373 696f 6e5f 696d 706c 3a3a 7570 session_impl::up │ │ │ -000400a0: 6461 7465 5f6c 6f63 616c 5f75 706c 6f61 date_local_uploa │ │ │ -000400b0: 645f 7261 7465 292c 0a09 0944 4550 5245 d_rate),...DEPRE │ │ │ -000400c0: 4341 5445 445f 5345 5428 6c6f 6361 6c5f CATED_SET(local_ │ │ │ -000400d0: 646f 776e 6c6f 6164 5f72 6174 655f 6c69 download_rate_li │ │ │ -000400e0: 6d69 742c 2030 2c20 2661 6d70 3b73 6573 mit, 0, &ses │ │ │ -000400f0: 7369 6f6e 5f69 6d70 6c3a 3a75 7064 6174 sion_impl::updat │ │ │ -00040100: 655f 6c6f 6361 6c5f 646f 776e 6c6f 6164 e_local_download │ │ │ -00040110: 5f72 6174 6529 2c0a 0909 5345 5428 6468 _rate),...SET(dh │ │ │ -00040120: 745f 7570 6c6f 6164 5f72 6174 655f 6c69 t_upload_rate_li │ │ │ -00040130: 6d69 742c 2038 3030 302c 2026 616d 703b mit, 8000, & │ │ │ -00040140: 7365 7373 696f 6e5f 696d 706c 3a3a 7570 session_impl::up │ │ │ -00040150: 6461 7465 5f64 6874 5f75 706c 6f61 645f date_dht_upload_ │ │ │ -00040160: 7261 7465 5f6c 696d 6974 292c 0a09 0953 rate_limit),...S │ │ │ -00040170: 4554 2875 6e63 686f 6b65 5f73 6c6f 7473 ET(unchoke_slots │ │ │ -00040180: 5f6c 696d 6974 2c20 382c 2026 616d 703b _limit, 8, & │ │ │ -00040190: 7365 7373 696f 6e5f 696d 706c 3a3a 7570 session_impl::up │ │ │ -000401a0: 6461 7465 5f75 6e63 686f 6b65 5f6c 696d date_unchoke_lim │ │ │ -000401b0: 6974 292c 0a09 0944 4550 5245 4341 5445 it),...DEPRECATE │ │ │ -000401c0: 445f 5345 5428 6861 6c66 5f6f 7065 6e5f D_SET(half_open_ │ │ │ -000401d0: 6c69 6d69 742c 2030 2c20 6e75 6c6c 7074 limit, 0, nullpt │ │ │ -000401e0: 7229 2c0a 0909 5345 5428 636f 6e6e 6563 r),...SET(connec │ │ │ -000401f0: 7469 6f6e 735f 6c69 6d69 742c 2032 3030 tions_limit, 200 │ │ │ -00040200: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69 , &session_i │ │ │ -00040210: 6d70 6c3a 3a75 7064 6174 655f 636f 6e6e mpl::update_conn │ │ │ -00040220: 6563 7469 6f6e 735f 6c69 6d69 7429 2c0a ections_limit),. │ │ │ -00040230: 0909 5345 5428 636f 6e6e 6563 7469 6f6e ..SET(connection │ │ │ -00040240: 735f 736c 6163 6b2c 2031 302c 206e 756c s_slack, 10, nul │ │ │ -00040250: 6c70 7472 292c 0a09 0953 4554 2875 7470 lptr),...SET(utp │ │ │ -00040260: 5f74 6172 6765 745f 6465 6c61 792c 2031 _target_delay, 1 │ │ │ -00040270: 3030 2c20 6e75 6c6c 7074 7229 2c0a 0909 00, nullptr),... │ │ │ -00040280: 5345 5428 7574 705f 6761 696e 5f66 6163 SET(utp_gain_fac │ │ │ -00040290: 746f 722c 2033 3030 302c 206e 756c 6c70 tor, 3000, nullp │ │ │ -000402a0: 7472 292c 0a3c 2f70 7265 3e3c 2f74 643e tr),.
    │ │ │ -000402b0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -000402e0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -000402f0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00040300: 7074 3a65 7870 616e 6428 3136 3029 223e pt:expand(160)"> │ │ │ -00040310: 2e2e 2f73 7263 2f73 6574 7469 6e67 735f ../src/settings_ │ │ │ -00040320: 7061 636b 2e63 7070 3a35 3734 3c2f 613e pack.cpp:574 │ │ │ -00040330: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ -00040340: 6420 6265 206e 6963 6520 746f 2072 6573 d be nice to res │ │ │ -00040350: 6572 7665 2829 2074 6865 7365 2076 6563 erve() these vec │ │ │ -00040360: 746f 7273 2075 7020 6672 6f6e 743c 2f74 tors up front

    it wo │ │ │ -000403c0: 756c 6420 6265 206e 6963 6520 746f 2072 uld be nice to r │ │ │ -000403d0: 6573 6572 7665 2829 2074 6865 7365 2076 eserve() these v │ │ │ -000403e0: 6563 746f 7273 2075 7020 6672 6f6e 743c ectors up front< │ │ │ -000403f0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ -00040400: 6574 7469 6e67 735f 7061 636b 2e63 7070 ettings_pack.cpp │ │ │ -00040410: 3a35 3734 3c2f 6834 3e3c 7072 6520 7374 :574

    ...s.set_str(
    │ │ │ -00040460: 7365 7474 696e 6773 5f70 6163 6b3a 3a73  settings_pack::s
    │ │ │ -00040470: 7472 696e 675f 7479 7065 5f62 6173 6520  tring_type_base 
    │ │ │ -00040480: 7c20 692c 2073 7472 5f73 6574 7469 6e67  | i, str_setting
    │ │ │ -00040490: 735b 695d 2e64 6566 6175 6c74 5f76 616c  s[i].default_val
    │ │ │ -000404a0: 7565 293b 0a09 0909 544f 5252 454e 545f  ue);....TORRENT_
    │ │ │ -000404b0: 4153 5345 5254 2873 2e67 6574 5f73 7472  ASSERT(s.get_str
    │ │ │ -000404c0: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ -000404d0: 7374 7269 6e67 5f74 7970 655f 6261 7365  string_type_base
    │ │ │ -000404e0: 202b 2069 2920 3d3d 2073 7472 5f73 6574   + i) == str_set
    │ │ │ -000404f0: 7469 6e67 735b 695d 2e64 6566 6175 6c74  tings[i].default
    │ │ │ -00040500: 5f76 616c 7565 293b 0a09 097d 0a0a 0909  _value);...}....
    │ │ │ -00040510: 666f 7220 2869 6e74 2069 203d 2030 3b20  for (int i = 0; 
    │ │ │ -00040520: 6920 266c 743b 2073 6574 7469 6e67 735f  i < settings_
    │ │ │ -00040530: 7061 636b 3a3a 6e75 6d5f 696e 745f 7365  pack::num_int_se
    │ │ │ -00040540: 7474 696e 6773 3b20 2b2b 6929 0a09 097b  ttings; ++i)...{
    │ │ │ -00040550: 0a09 0909 732e 7365 745f 696e 7428 7365  ....s.set_int(se
    │ │ │ -00040560: 7474 696e 6773 5f70 6163 6b3a 3a69 6e74  ttings_pack::int
    │ │ │ -00040570: 5f74 7970 655f 6261 7365 207c 2069 2c20  _type_base | i, 
    │ │ │ -00040580: 696e 745f 7365 7474 696e 6773 5b69 5d2e  int_settings[i].
    │ │ │ -00040590: 6465 6661 756c 745f 7661 6c75 6529 3b0a  default_value);.
    │ │ │ -000405a0: 0909 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -000405b0: 5428 732e 6765 745f 696e 7428 7365 7474  T(s.get_int(sett
    │ │ │ -000405c0: 696e 6773 5f70 6163 6b3a 3a69 6e74 5f74  ings_pack::int_t
    │ │ │ -000405d0: 7970 655f 6261 7365 202b 2069 2920 3d3d  ype_base + i) ==
    │ │ │ -000405e0: 2069 6e74 5f73 6574 7469 6e67 735b 695d   int_settings[i]
    │ │ │ -000405f0: 2e64 6566 6175 6c74 5f76 616c 7565 293b  .default_value);
    │ │ │ -00040600: 0a09 097d 0a0a 0909 666f 7220 2869 6e74  ...}....for (int
    │ │ │ -00040610: 2069 203d 2030 3b20 6920 266c 743b 2073   i = 0; i < s
    │ │ │ -00040620: 6574 7469 6e67 735f 7061 636b 3a3a 6e75  ettings_pack::nu
    │ │ │ -00040630: 6d5f 626f 6f6c 5f73 6574 7469 6e67 733b  m_bool_settings;
    │ │ │ -00040640: 202b 2b69 290a 0909 7b0a 0909 0973 2e73   ++i)...{....s.s
    │ │ │ -00040650: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ -00040660: 5f70 6163 6b3a 3a62 6f6f 6c5f 7479 7065  _pack::bool_type
    │ │ │ -00040670: 5f62 6173 6520 7c20 692c 2062 6f6f 6c5f  _base | i, bool_
    │ │ │ -00040680: 7365 7474 696e 6773 5b69 5d2e 6465 6661  settings[i].defa
    │ │ │ -00040690: 756c 745f 7661 6c75 6529 3b0a 0909 0954  ult_value);....T
    │ │ │ -000406a0: 4f52 5245 4e54 5f41 5353 4552 5428 732e  ORRENT_ASSERT(s.
    │ │ │ -000406b0: 6765 745f 626f 6f6c 2873 6574 7469 6e67  get_bool(setting
    │ │ │ -000406c0: 735f 7061 636b 3a3a 626f 6f6c 5f74 7970  s_pack::bool_typ
    │ │ │ -000406d0: 655f 6261 7365 202b 2069 2920 3d3d 2062  e_base + i) == b
    │ │ │ -000406e0: 6f6f 6c5f 7365 7474 696e 6773 5b69 5d2e  ool_settings[i].
    │ │ │ -000406f0: 6465 6661 756c 745f 7661 6c75 6529 3b0a  default_value);.
    │ │ │ -00040700: 0909 7d0a 097d 0a0a 0973 6574 7469 6e67  ..}..}...setting
    │ │ │ -00040710: 735f 7061 636b 2064 6566 6175 6c74 5f73  s_pack default_s
    │ │ │ -00040720: 6574 7469 6e67 7328 290a 097b 0a09 0973  ettings()..{...s
    │ │ │ -00040730: 6574 7469 6e67 735f 7061 636b 2072 6574  ettings_pack ret
    │ │ │ -00040740: 3b0a 3c64 6976 2073 7479 6c65 3d22 6261  ;.
    │ │ │ -00040770: 0909 666f 7220 2869 6e74 2069 203d 2030 ..for (int i = 0 │ │ │ -00040780: 3b20 6920 266c 743b 2073 6574 7469 6e67 ; i < setting │ │ │ -00040790: 735f 7061 636b 3a3a 6e75 6d5f 7374 7269 s_pack::num_stri │ │ │ -000407a0: 6e67 5f73 6574 7469 6e67 733b 202b 2b69 ng_settings; ++i │ │ │ -000407b0: 290a 3c2f 6469 763e 0909 7b0a 0909 0969 ).
    ..{....i │ │ │ -000407c0: 6620 2873 7472 5f73 6574 7469 6e67 735b f (str_settings[ │ │ │ -000407d0: 695d 2e64 6566 6175 6c74 5f76 616c 7565 i].default_value │ │ │ -000407e0: 2e65 6d70 7479 2829 2920 636f 6e74 696e .empty()) contin │ │ │ -000407f0: 7565 3b0a 0909 0972 6574 2e73 6574 5f73 ue;....ret.set_s │ │ │ -00040800: 7472 2873 6574 7469 6e67 735f 7061 636b tr(settings_pack │ │ │ -00040810: 3a3a 7374 7269 6e67 5f74 7970 655f 6261 ::string_type_ba │ │ │ -00040820: 7365 202b 2069 2c20 7374 725f 7365 7474 se + i, str_sett │ │ │ -00040830: 696e 6773 5b69 5d2e 6465 6661 756c 745f ings[i].default_ │ │ │ -00040840: 7661 6c75 6529 3b0a 0909 7d0a 0a09 0966 value);...}....f │ │ │ -00040850: 6f72 2028 696e 7420 6920 3d20 303b 2069 or (int i = 0; i │ │ │ -00040860: 2026 6c74 3b20 7365 7474 696e 6773 5f70 < settings_p │ │ │ -00040870: 6163 6b3a 3a6e 756d 5f69 6e74 5f73 6574 ack::num_int_set │ │ │ -00040880: 7469 6e67 733b 202b 2b69 290a 0909 7b0a tings; ++i)...{. │ │ │ -00040890: 0909 0972 6574 2e73 6574 5f69 6e74 2873 ...ret.set_int(s │ │ │ -000408a0: 6574 7469 6e67 735f 7061 636b 3a3a 696e ettings_pack::in │ │ │ -000408b0: 745f 7479 7065 5f62 6173 6520 2b20 692c t_type_base + i, │ │ │ -000408c0: 2069 6e74 5f73 6574 7469 6e67 735b 695d int_settings[i] │ │ │ -000408d0: 2e64 6566 6175 6c74 5f76 616c 7565 293b .default_value); │ │ │ -000408e0: 0a09 097d 0a0a 0909 666f 7220 2869 6e74 ...}....for (int │ │ │ -000408f0: 2069 203d 2030 3b20 6920 266c 743b 2073 i = 0; i < s │ │ │ -00040900: 6574 7469 6e67 735f 7061 636b 3a3a 6e75 ettings_pack::nu │ │ │ -00040910: 6d5f 626f 6f6c 5f73 6574 7469 6e67 733b m_bool_settings; │ │ │ -00040920: 202b 2b69 290a 0909 7b0a 0909 0972 6574 ++i)...{....ret │ │ │ -00040930: 2e73 6574 5f62 6f6f 6c28 7365 7474 696e .set_bool(settin │ │ │ -00040940: 6773 5f70 6163 6b3a 3a62 6f6f 6c5f 7479 gs_pack::bool_ty │ │ │ -00040950: 7065 5f62 6173 6520 2b20 692c 2062 6f6f pe_base + i, boo │ │ │ -00040960: 6c5f 7365 7474 696e 6773 5b69 5d2e 6465 l_settings[i].de │ │ │ -00040970: 6661 756c 745f 7661 6c75 6529 3b0a 0909 fault_value);... │ │ │ -00040980: 7d0a 0909 7265 7475 726e 2072 6574 3b0a }...return ret;. │ │ │ -00040990: 097d 0a0a 0976 6f69 6420 6170 706c 795f .}...void apply_ │ │ │ -000409a0: 7061 636b 2873 6574 7469 6e67 735f 7061 pack(settings_pa │ │ │ -000409b0: 636b 2063 6f6e 7374 2a20 7061 636b 2c20 ck const* pack, │ │ │ -000409c0: 6175 783a 3a73 6573 7369 6f6e 5f73 6574 aux::session_set │ │ │ -000409d0: 7469 6e67 7326 616d 703b 2073 6574 740a tings& sett. │ │ │ -000409e0: 0909 2c20 6175 783a 3a73 6573 7369 6f6e .., aux::session │ │ │ -000409f0: 5f69 6d70 6c2a 2073 6573 290a 097b 0a09 _impl* ses)..{.. │ │ │ -00040a00: 0975 7369 6e67 2066 756e 5f74 203d 2076 .using fun_t = v │ │ │ -00040a10: 6f69 6420 2861 7578 3a3a 7365 7373 696f oid (aux::sessio │ │ │ -00040a20: 6e5f 696d 706c 3a3a 2a29 2829 3b0a 0909 n_impl::*)();... │ │ │ -00040a30: 7374 643a 3a76 6563 746f 7226 6c74 3b66 std::vector<f │ │ │ -00040a40: 756e 5f74 2667 743b 2063 616c 6c62 6163 un_t> callbac │ │ │ -00040a50: 6b73 3b0a 0a09 0973 6574 742e 6275 6c6b ks;....sett.bulk │ │ │ -00040a60: 5f73 6574 285b 2661 6d70 3b5d 2861 7578 _set([&](aux │ │ │ -00040a70: 3a3a 7365 7373 696f 6e5f 7365 7474 696e ::session_settin │ │ │ -00040a80: 6773 5f73 696e 676c 655f 7468 7265 6164 gs_single_thread │ │ │ -00040a90: 2661 6d70 3b20 7329 0a09 097b 0a09 0909 & s)...{.... │ │ │ -00040aa0: 6170 706c 795f 7061 636b 5f69 6d70 6c28 apply_pack_impl( │ │ │ -00040ab0: 7061 636b 2c20 732c 2073 6573 203f 2026 pack, s, ses ? & │ │ │ -00040ac0: 616d 703b 6361 6c6c 6261 636b 7320 3a20 amp;callbacks : │ │ │ -00040ad0: 6e75 6c6c 7074 7229 3b0a 0909 7d29 3b0a nullptr);...});. │ │ │ -00040ae0: 0a09 092f 2f20 6361 6c6c 2074 6865 2063 ...// call the c │ │ │ -00040af0: 616c 6c62 6163 6b73 206f 6e63 6520 616c allbacks once al │ │ │ -00040b00: 6c20 7468 6520 7365 7474 696e 6773 2068 l the settings h │ │ │ -00040b10: 6176 6520 6265 656e 2061 7070 6c69 6564 ave been applied │ │ │ -00040b20: 2c20 616e 640a 0909 2f2f 206f 6e6c 7920 , and...// only │ │ │ -00040b30: 6f6e 6365 2070 6572 2063 616c 6c62 6163 once per callbac │ │ │ -00040b40: 6b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 k.
    < │ │ │ -00040b70: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00040b80: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00040bb0: 7372 632f 7765 625f 636f 6e6e 6563 7469 src/web_connecti │ │ │ -00040bc0: 6f6e 5f62 6173 652e 6370 703a 3530 3c2f on_base.cpp:50intro │ │ │ -00040be0: 6475 6365 2061 2077 6562 2d73 6565 6420 duce a web-seed │ │ │ -00040bf0: 6465 6661 756c 7420 636c 6173 7320 7768 default class wh │ │ │ -00040c00: 6963 6820 6861 7320 6120 6c6f 7720 646f ich has a low do │ │ │ -00040c10: 776e 6c6f 6164 2070 7269 6f72 6974 793c wnload priority< │ │ │ -00040c20: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    int │ │ │ -00040c70: 726f 6475 6365 2061 2077 6562 2d73 6565 roduce a web-see │ │ │ -00040c80: 6420 6465 6661 756c 7420 636c 6173 7320 d default class │ │ │ -00040c90: 7768 6963 6820 6861 7320 6120 6c6f 7720 which has a low │ │ │ -00040ca0: 646f 776e 6c6f 6164 2070 7269 6f72 6974 download priorit │ │ │ -00040cb0: 793c 2f68 323e 3c68 343e 2e2e 2f73 7263 y

    ../src │ │ │ -00040cc0: 2f77 6562 5f63 6f6e 6e65 6374 696f 6e5f /web_connection_ │ │ │ -00040cd0: 6261 7365 2e63 7070 3a35 303c 2f68 343e base.cpp:50

    │ │ │ -00040ce0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..: pe
    │ │ │ -00040d20: 6572 5f63 6f6e 6e65 6374 696f 6e28 7061  er_connection(pa
    │ │ │ -00040d30: 636b 290a 0909 2c20 6d5f 6669 7273 745f  ck)..., m_first_
    │ │ │ -00040d40: 7265 7175 6573 7428 7472 7565 290a 0909  request(true)...
    │ │ │ -00040d50: 2c20 6d5f 7373 6c28 6661 6c73 6529 0a09  , m_ssl(false)..
    │ │ │ -00040d60: 092c 206d 5f65 7874 6572 6e61 6c5f 6175  ., m_external_au
    │ │ │ -00040d70: 7468 2877 6562 2e61 7574 6829 0a09 092c  th(web.auth)...,
    │ │ │ -00040d80: 206d 5f65 7874 7261 5f68 6561 6465 7273   m_extra_headers
    │ │ │ -00040d90: 2877 6562 2e65 7874 7261 5f68 6561 6465  (web.extra_heade
    │ │ │ -00040da0: 7273 290a 0909 2c20 6d5f 7061 7273 6572  rs)..., m_parser
    │ │ │ -00040db0: 2861 7578 3a3a 6874 7470 5f70 6172 7365  (aux::http_parse
    │ │ │ -00040dc0: 723a 3a64 6f6e 745f 7061 7273 655f 6368  r::dont_parse_ch
    │ │ │ -00040dd0: 756e 6b73 290a 0909 2c20 6d5f 626f 6479  unks)..., m_body
    │ │ │ -00040de0: 5f73 7461 7274 2830 290a 097b 0a09 0954  _start(0)..{...T
    │ │ │ -00040df0: 4f52 5245 4e54 5f41 5353 4552 5428 2661  ORRENT_ASSERT(&a
    │ │ │ -00040e00: 6d70 3b77 6562 2e70 6565 725f 696e 666f  mp;web.peer_info
    │ │ │ -00040e10: 203d 3d20 7061 636b 2e70 6565 7269 6e66   == pack.peerinf
    │ │ │ -00040e20: 6f29 3b0a 0909 2f2f 2077 6865 6e20 676f  o);...// when go
    │ │ │ -00040e30: 696e 6720 7468 726f 7567 6820 6120 7072  ing through a pr
    │ │ │ -00040e40: 6f78 792c 2077 6520 646f 6e27 7420 6e65  oxy, we don't ne
    │ │ │ -00040e50: 6365 7373 6172 696c 7920 6861 7665 2061  cessarily have a
    │ │ │ -00040e60: 6e20 656e 6470 6f69 6e74 2068 6572 652c  n endpoint here,
    │ │ │ -00040e70: 0a09 092f 2f20 7369 6e63 6520 7468 6520  ...// since the 
    │ │ │ -00040e80: 7072 6f78 7920 6d69 6768 7420 6265 2072  proxy might be r
    │ │ │ -00040e90: 6573 6f6c 7669 6e67 2074 6865 2068 6f73  esolving the hos
    │ │ │ -00040ea0: 746e 616d 652c 206e 6f74 2075 730a 0909  tname, not us...
    │ │ │ -00040eb0: 544f 5252 454e 545f 4153 5345 5254 2877  TORRENT_ASSERT(w
    │ │ │ -00040ec0: 6562 2e65 6e64 706f 696e 7473 2e65 6d70  eb.endpoints.emp
    │ │ │ -00040ed0: 7479 2829 207c 7c20 7765 622e 656e 6470  ty() || web.endp
    │ │ │ -00040ee0: 6f69 6e74 732e 6672 6f6e 7428 2920 3d3d  oints.front() ==
    │ │ │ -00040ef0: 2070 6163 6b2e 656e 6470 293b 0a0a 0909   pack.endp);....
    │ │ │ -00040f00: 494e 5641 5249 414e 545f 4348 4543 4b3b  INVARIANT_CHECK;
    │ │ │ -00040f10: 0a0a 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -00040f20: 5254 2869 735f 6f75 7467 6f69 6e67 2829  RT(is_outgoing()
    │ │ │ -00040f30: 293b 0a0a 0909 544f 5252 454e 545f 4153  );....TORRENT_AS
    │ │ │ -00040f40: 5345 5254 2821 6d5f 746f 7272 656e 742e  SERT(!m_torrent.
    │ │ │ -00040f50: 6c6f 636b 2829 2d26 6774 3b69 735f 7570  lock()->is_up
    │ │ │ -00040f60: 6c6f 6164 5f6f 6e6c 7928 2929 3b0a 0a09  load_only());...
    │ │ │ -00040f70: 092f 2f20 7765 206f 6e6c 7920 7761 6e74  .// we only want
    │ │ │ -00040f80: 206c 6566 742d 6f76 6572 2062 616e 6477   left-over bandw
    │ │ │ -00040f90: 6964 7468 0a3c 6469 7620 7374 796c 653d  idth.
    .
    ..std: │ │ │ -00040fd0: 3a73 7472 696e 6720 7072 6f74 6f63 6f6c :string protocol │ │ │ -00040fe0: 3b0a 0909 6572 726f 725f 636f 6465 2065 ;...error_code e │ │ │ -00040ff0: 633b 0a09 0973 7464 3a3a 7469 6528 7072 c;...std::tie(pr │ │ │ -00041000: 6f74 6f63 6f6c 2c20 6d5f 6261 7369 635f otocol, m_basic_ │ │ │ -00041010: 6175 7468 2c20 6d5f 686f 7374 2c20 6d5f auth, m_host, m_ │ │ │ -00041020: 706f 7274 2c20 6d5f 7061 7468 290a 0909 port, m_path)... │ │ │ -00041030: 093d 2070 6172 7365 5f75 726c 5f63 6f6d .= parse_url_com │ │ │ -00041040: 706f 6e65 6e74 7328 7765 622e 7572 6c2c ponents(web.url, │ │ │ -00041050: 2065 6329 3b0a 0909 544f 5252 454e 545f ec);...TORRENT_ │ │ │ -00041060: 4153 5345 5254 2821 6563 293b 0a0a 0909 ASSERT(!ec);.... │ │ │ -00041070: 6966 2028 6d5f 706f 7274 203d 3d20 2d31 if (m_port == -1 │ │ │ -00041080: 2026 616d 703b 2661 6d70 3b20 7072 6f74 && prot │ │ │ -00041090: 6f63 6f6c 203d 3d20 2268 7474 7022 290a ocol == "http"). │ │ │ -000410a0: 0909 096d 5f70 6f72 7420 3d20 3830 3b0a ...m_port = 80;. │ │ │ -000410b0: 0a23 6966 2054 4f52 5245 4e54 5f55 5345 .#if TORRENT_USE │ │ │ -000410c0: 5f53 534c 0a09 0969 6620 2870 726f 746f _SSL...if (proto │ │ │ -000410d0: 636f 6c20 3d3d 2022 6874 7470 7322 290a col == "https"). │ │ │ -000410e0: 0909 7b0a 0909 096d 5f73 736c 203d 2074 ..{....m_ssl = t │ │ │ -000410f0: 7275 653b 0a09 0909 6966 2028 6d5f 706f rue;....if (m_po │ │ │ -00041100: 7274 203d 3d20 2d31 2920 6d5f 706f 7274 rt == -1) m_port │ │ │ -00041110: 203d 2034 3433 3b0a 0909 7d0a 2365 6e64 = 443;...}.#end │ │ │ -00041120: 6966 0a0a 0909 6966 2028 216d 5f62 6173 if....if (!m_bas │ │ │ -00041130: 6963 5f61 7574 682e 656d 7074 7928 2929 ic_auth.empty()) │ │ │ -00041140: 0a09 0909 6d5f 6261 7369 635f 6175 7468 ....m_basic_auth │ │ │ -00041150: 203d 2062 6173 6536 3465 6e63 6f64 6528 = base64encode( │ │ │ -00041160: 6d5f 6261 7369 635f 6175 7468 293b 0a0a m_basic_auth);.. │ │ │ -00041170: 0909 6d5f 7365 7276 6572 5f73 7472 696e ..m_server_strin │ │ │ -00041180: 6720 3d20 6d5f 686f 7374 3b0a 0909 6175 g = m_host;...au │ │ │ -00041190: 783a 3a76 6572 6966 795f 656e 636f 6469 x::verify_encodi │ │ │ -000411a0: 6e67 286d 5f73 6572 7665 725f 7374 7269 ng(m_server_stri │ │ │ -000411b0: 6e67 293b 0a09 7d0a 0a09 696e 7420 7765 ng);..}...int we │ │ │ -000411c0: 625f 636f 6e6e 6563 7469 6f6e 5f62 6173 b_connection_bas │ │ │ -000411d0: 653a 3a74 696d 656f 7574 2829 2063 6f6e e::timeout() con │ │ │ -000411e0: 7374 0a09 7b0a 0909 2f2f 2073 696e 6365 st..{...// since │ │ │ -000411f0: 2074 6869 7320 6973 2061 2077 6562 2073 this is a web s │ │ │ -00041200: 6565 642c 2063 6861 6e67 6520 7468 6520 eed, change the │ │ │ -00041210: 7469 6d65 6f75 740a 0909 2f2f 2061 6363 timeout...// acc │ │ │ -00041220: 6f72 6469 6e67 2074 6f20 7468 6520 7365 ording to the se │ │ │ -00041230: 7474 696e 6773 2e0a 0909 7265 7475 726e ttings....return │ │ │ -00041240: 206d 5f73 6574 7469 6e67 732e 6765 745f m_settings.get_ │ │ │ -00041250: 696e 7428 7365 7474 696e 6773 5f70 6163 int(settings_pac │ │ │ -00041260: 6b3a 3a75 726c 7365 6564 5f74 696d 656f k::urlseed_timeo │ │ │ -00041270: 7574 293b 0a09 7d0a 3c2f 7072 653e 3c2f ut);..}.
    relevan │ │ │ -000412b0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0
    ../src/part_f │ │ │ -000412f0: 696c 652e 6370 703a 3239 343c 2f61 3e3c ile.cpp:294< │ │ │ -00041300: 2f74 643e 3c74 643e 7768 6174 2064 6f20 /td>what do │ │ │ -00041310: 7765 2064 6f20 6966 2073 6f6d 656f 6e65 we do if someone │ │ │ -00041320: 2069 7320 6375 7272 656e 746c 7920 7265 is currently re │ │ │ -00041330: 6164 696e 6720 6672 6f6d 2074 6865 2064 ading from the d │ │ │ -00041340: 6973 6b20 6672 6f6d 2074 6869 7320 7069 isk from this pi │ │ │ -00041350: 6563 653f 2064 6f65 7320 6974 206d 6174 ece? does it mat │ │ │ -00041360: 7465 723f 2053 696e 6365 2077 6520 776f ter? Since we wo │ │ │ -00041370: 6e27 7420 6163 7469 7665 6c79 2065 7261 n't actively era │ │ │ -00041380: 7365 2074 6865 2064 6174 6120 6672 6f6d se the data from │ │ │ -00041390: 2064 6973 6b2c 2062 7574 2069 7420 6d61 disk, but it ma │ │ │ -000413a0: 7920 6265 206f 7665 7277 7269 7474 656e y be overwritten │ │ │ -000413b0: 2073 6f6f 6e2c 2069 7427 7320 7072 6f62 soon, it's prob │ │ │ -000413c0: 6162 6c79 206e 6f74 2074 6861 7420 6269 ably not that bi │ │ │ -000413d0: 6720 6f66 2061 2064 6561 6c3c 2f74 643e g of a deal │ │ │ -000413e0: 3c2f 7472 3e3c 7472 2069 643d 2231 3632

    what do │ │ │ -00041430: 2077 6520 646f 2069 6620 736f 6d65 6f6e we do if someon │ │ │ -00041440: 6520 6973 2063 7572 7265 6e74 6c79 2072 e is currently r │ │ │ -00041450: 6561 6469 6e67 2066 726f 6d20 7468 6520 eading from the │ │ │ -00041460: 6469 736b 0a66 726f 6d20 7468 6973 2070 disk.from this p │ │ │ -00041470: 6965 6365 3f20 646f 6573 2069 7420 6d61 iece? does it ma │ │ │ -00041480: 7474 6572 3f20 5369 6e63 6520 7765 2077 tter? Since we w │ │ │ -00041490: 6f6e 2774 2061 6374 6976 656c 7920 6572 on't actively er │ │ │ -000414a0: 6173 6520 7468 650a 6461 7461 2066 726f ase the.data fro │ │ │ -000414b0: 6d20 6469 736b 2c20 6275 7420 6974 206d m disk, but it m │ │ │ -000414c0: 6179 2062 6520 6f76 6572 7772 6974 7465 ay be overwritte │ │ │ -000414d0: 6e20 736f 6f6e 2c20 6974 2773 2070 726f n soon, it's pro │ │ │ -000414e0: 6261 626c 7920 6e6f 7420 7468 6174 0a62 bably not that.b │ │ │ -000414f0: 6967 206f 6620 6120 6465 616c 3c2f 6832 ig of a deal

    ../src/part │ │ │ -00041510: 5f66 696c 652e 6370 703a 3239 343c 2f68 _file.cpp:294
    ....
    │ │ │ -00041560: 6372 6561 7465 5f64 6972 6563 746f 7269  create_directori
    │ │ │ -00041570: 6573 286d 5f70 6174 682c 2065 6329 3b0a  es(m_path, ec);.
    │ │ │ -00041580: 0909 0909 6966 2028 6563 2920 7265 7475  ....if (ec) retu
    │ │ │ -00041590: 726e 207b 7d3b 0a09 0909 0972 6574 7572  rn {};.....retur
    │ │ │ -000415a0: 6e20 7b66 6e2c 2030 2c20 6d6f 6465 7d3b  n {fn, 0, mode};
    │ │ │ -000415b0: 0a09 0909 7d0a 0909 0972 6574 7572 6e20  ....}....return 
    │ │ │ -000415c0: 7b7d 3b0a 0909 7d0a 097d 0a09 6361 7463  {};...}..}..catc
    │ │ │ -000415d0: 6820 2873 746f 7261 6765 5f65 7272 6f72  h (storage_error
    │ │ │ -000415e0: 2063 6f6e 7374 2661 6d70 3b20 6529 0a09   const& e)..
    │ │ │ -000415f0: 7b0a 0909 6563 203d 2065 2e65 633b 0a09  {...ec = e.ec;..
    │ │ │ -00041600: 0972 6574 7572 6e20 7b7d 3b0a 097d 0a0a  .return {};..}..
    │ │ │ -00041610: 0976 6f69 6420 7061 7274 5f66 696c 653a  .void part_file:
    │ │ │ -00041620: 3a66 7265 655f 7069 6563 6528 7069 6563  :free_piece(piec
    │ │ │ -00041630: 655f 696e 6465 785f 7420 636f 6e73 7420  e_index_t const 
    │ │ │ -00041640: 7069 6563 6529 0a09 7b0a 0909 7374 643a  piece)..{...std:
    │ │ │ -00041650: 3a6c 6f63 6b5f 6775 6172 6426 6c74 3b73  :lock_guard<s
    │ │ │ -00041660: 7464 3a3a 6d75 7465 7826 6774 3b20 6c28  td::mutex> l(
    │ │ │ -00041670: 6d5f 6d75 7465 7829 3b0a 0a09 0961 7574  m_mutex);....aut
    │ │ │ -00041680: 6f20 636f 6e73 7420 6920 3d20 6d5f 7069  o const i = m_pi
    │ │ │ -00041690: 6563 655f 6d61 702e 6669 6e64 2870 6965  ece_map.find(pie
    │ │ │ -000416a0: 6365 293b 0a09 0969 6620 2869 203d 3d20  ce);...if (i == 
    │ │ │ -000416b0: 6d5f 7069 6563 655f 6d61 702e 656e 6428  m_piece_map.end(
    │ │ │ -000416c0: 2929 2072 6574 7572 6e3b 0a0a 3c64 6976  )) return;..
    .
    ..m_free_slots. │ │ │ -00041710: 7075 7368 5f62 6163 6b28 692d 2667 743b push_back(i-> │ │ │ -00041720: 7365 636f 6e64 293b 0a09 096d 5f70 6965 second);...m_pie │ │ │ -00041730: 6365 5f6d 6170 2e65 7261 7365 2869 293b ce_map.erase(i); │ │ │ -00041740: 0a09 096d 5f64 6972 7479 5f6d 6574 6164 ...m_dirty_metad │ │ │ -00041750: 6174 6120 3d20 7472 7565 3b0a 097d 0a0a ata = true;..}.. │ │ │ -00041760: 0976 6f69 6420 7061 7274 5f66 696c 653a .void part_file: │ │ │ -00041770: 3a6d 6f76 655f 7061 7274 6669 6c65 2873 :move_partfile(s │ │ │ -00041780: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374 td::string const │ │ │ -00041790: 2661 6d70 3b20 7061 7468 2c20 6572 726f & path, erro │ │ │ -000417a0: 725f 636f 6465 2661 6d70 3b20 6563 290a r_code& ec). │ │ │ -000417b0: 097b 0a09 0973 7464 3a3a 6c6f 636b 5f67 .{...std::lock_g │ │ │ -000417c0: 7561 7264 266c 743b 7374 643a 3a6d 7574 uard<std::mut │ │ │ -000417d0: 6578 2667 743b 206c 286d 5f6d 7574 6578 ex> l(m_mutex │ │ │ -000417e0: 293b 0a0a 0909 666c 7573 685f 6d65 7461 );....flush_meta │ │ │ -000417f0: 6461 7461 5f69 6d70 6c28 6563 293b 0a09 data_impl(ec);.. │ │ │ -00041800: 0969 6620 2865 6329 2072 6574 7572 6e3b .if (ec) return; │ │ │ -00041810: 0a0a 0909 6966 2028 216d 5f70 6965 6365 ....if (!m_piece │ │ │ -00041820: 5f6d 6170 2e65 6d70 7479 2829 290a 0909 _map.empty())... │ │ │ -00041830: 7b0a 0909 0973 7464 3a3a 7374 7269 6e67 {....std::string │ │ │ -00041840: 206f 6c64 5f70 6174 6820 3d20 636f 6d62 old_path = comb │ │ │ -00041850: 696e 655f 7061 7468 286d 5f70 6174 682c ine_path(m_path, │ │ │ -00041860: 206d 5f6e 616d 6529 3b0a 0909 0973 7464 m_name);....std │ │ │ -00041870: 3a3a 7374 7269 6e67 206e 6577 5f70 6174 ::string new_pat │ │ │ -00041880: 6820 3d20 636f 6d62 696e 655f 7061 7468 h = combine_path │ │ │ -00041890: 2870 6174 682c 206d 5f6e 616d 6529 3b0a (path, m_name);. │ │ │ -000418a0: 0a09 0909 7265 6e61 6d65 286f 6c64 5f70 ....rename(old_p │ │ │ -000418b0: 6174 682c 206e 6577 5f70 6174 682c 2065 ath, new_path, e │ │ │ -000418c0: 6329 3b0a 0909 0969 6620 2865 6320 3d3d c);....if (ec == │ │ │ -000418d0: 2062 6f6f 7374 3a3a 7379 7374 656d 3a3a boost::system:: │ │ │ -000418e0: 6572 7263 3a3a 6e6f 5f73 7563 685f 6669 errc::no_such_fi │ │ │ -000418f0: 6c65 5f6f 725f 6469 7265 6374 6f72 7929 le_or_directory) │ │ │ -00041900: 0a09 0909 0965 632e 636c 6561 7228 293b .....ec.clear(); │ │ │ -00041910: 0a0a 0909 0969 6620 2865 6329 0a09 0909 .....if (ec).... │ │ │ -00041920: 7b0a 0909 0909 7374 6f72 6167 655f 6572 {.....storage_er │ │ │ -00041930: 726f 7220 7365 3b0a 0909 0909 6175 783a ror se;.....aux: │ │ │ -00041940: 3a63 6f70 795f 6669 6c65 286f 6c64 5f70 :copy_file(old_p │ │ │ -00041950: 6174 682c 206e 6577 5f70 6174 682c 2073 ath, new_path, s │ │ │ -00041960: 6529 3b0a 0909 0909 6563 203d 2073 652e e);.....ec = se. │ │ │ -00041970: 6563 3b0a 0909 0909 6966 2028 6563 2920 ec;.....if (ec) │ │ │ -00041980: 7265 7475 726e 3b0a 0909 0909 7265 6d6f return;.....remo │ │ │ -00041990: 7665 286f 6c64 5f70 6174 682c 2065 6329 ve(old_path, ec) │ │ │ -000419a0: 3b0a 0909 097d 0a09 097d 0a3c 2f70 7265 ;....}...}.
    rele │ │ │ -000419e0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/par │ │ │ -00041a20: 745f 6669 6c65 2e63 7070 3a34 3035 3c2f t_file.cpp:405inste │ │ │ -00041a40: 6164 206f 6620 7265 6275 696c 6469 6e67 ad of rebuilding │ │ │ -00041a50: 2074 6865 2077 686f 6c65 2066 696c 6520 the whole file │ │ │ -00041a60: 6865 6164 6572 2061 6e64 2066 6c75 7368 header and flush │ │ │ -00041a70: 696e 6720 6974 2c20 7570 6461 7465 2074 ing it, update t │ │ │ -00041a80: 6865 2073 6c6f 7420 656e 7472 6965 7320 he slot entries │ │ │ -00041a90: 6173 2077 6520 676f 3c2f 7464 3e3c 2f74 as we go

    instead of │ │ │ -00041af0: 2072 6562 7569 6c64 696e 6720 7468 6520 rebuilding the │ │ │ -00041b00: 7768 6f6c 6520 6669 6c65 2068 6561 6465 whole file heade │ │ │ -00041b10: 720a 616e 6420 666c 7573 6869 6e67 2069 r.and flushing i │ │ │ -00041b20: 742c 2075 7064 6174 6520 7468 6520 736c t, update the sl │ │ │ -00041b30: 6f74 2065 6e74 7269 6573 2061 7320 7765 ot entries as we │ │ │ -00041b40: 2067 6f3c 2f68 323e 3c68 343e 2e2e 2f73 go

    ../s │ │ │ -00041b50: 7263 2f70 6172 745f 6669 6c65 2e63 7070 rc/part_file.cpp │ │ │ -00041b60: 3a34 3035 3c2f 6834 3e3c 7072 6520 7374 :405

    ......TORRENT
    │ │ │ -00041bb0: 5f41 5353 4552 5428 6a2d 2667 743b 7365  _ASSERT(j->se
    │ │ │ -00041bc0: 636f 6e64 203d 3d20 736c 6f74 293b 0a09  cond == slot);..
    │ │ │ -00041bd0: 0909 0909 096d 5f66 7265 655f 736c 6f74  .....m_free_slot
    │ │ │ -00041be0: 732e 7075 7368 5f62 6163 6b28 6a2d 2667  s.push_back(j-&g
    │ │ │ -00041bf0: 743b 7365 636f 6e64 293b 0a09 0909 0909  t;second);......
    │ │ │ -00041c00: 096d 5f70 6965 6365 5f6d 6170 2e65 7261  .m_piece_map.era
    │ │ │ -00041c10: 7365 286a 293b 0a09 0909 0909 096d 5f64  se(j);.......m_d
    │ │ │ -00041c20: 6972 7479 5f6d 6574 6164 6174 6120 3d20  irty_metadata = 
    │ │ │ -00041c30: 7472 7565 3b0a 0909 0909 097d 0a09 0909  true;......}....
    │ │ │ -00041c40: 097d 0a09 0909 7d0a 0909 0966 696c 655f  .}....}....file_
    │ │ │ -00041c50: 6f66 6673 6574 202b 3d20 626c 6f63 6b5f  offset += block_
    │ │ │ -00041c60: 746f 5f63 6f70 793b 0a09 0909 7069 6563  to_copy;....piec
    │ │ │ -00041c70: 655f 6f66 6673 6574 203d 2030 3b0a 0909  e_offset = 0;...
    │ │ │ -00041c80: 0973 697a 6520 2d3d 2062 6c6f 636b 5f74  .size -= block_t
    │ │ │ -00041c90: 6f5f 636f 7079 3b0a 0909 7d0a 097d 0a0a  o_copy;...}..}..
    │ │ │ -00041ca0: 0976 6f69 6420 7061 7274 5f66 696c 653a  .void part_file:
    │ │ │ -00041cb0: 3a66 6c75 7368 5f6d 6574 6164 6174 6128  :flush_metadata(
    │ │ │ -00041cc0: 6572 726f 725f 636f 6465 2661 6d70 3b20  error_code& 
    │ │ │ -00041cd0: 6563 290a 097b 0a09 0973 7464 3a3a 6c6f  ec)..{...std::lo
    │ │ │ -00041ce0: 636b 5f67 7561 7264 266c 743b 7374 643a  ck_guard<std:
    │ │ │ -00041cf0: 3a6d 7574 6578 2667 743b 206c 286d 5f6d  :mutex> l(m_m
    │ │ │ -00041d00: 7574 6578 293b 0a0a 0909 666c 7573 685f  utex);....flush_
    │ │ │ -00041d10: 6d65 7461 6461 7461 5f69 6d70 6c28 6563  metadata_impl(ec
    │ │ │ -00041d20: 293b 0a09 7d0a 0a3c 6469 7620 7374 796c  );..}..
    .void part_ │ │ │ -00041d60: 6669 6c65 3a3a 666c 7573 685f 6d65 7461 file::flush_meta │ │ │ -00041d70: 6461 7461 5f69 6d70 6c28 6572 726f 725f data_impl(error_ │ │ │ -00041d80: 636f 6465 2661 6d70 3b20 6563 290a 3c2f code& ec)..{...// do w │ │ │ -00041da0: 6520 6e65 6564 2074 6f20 666c 7573 6820 e need to flush │ │ │ -00041db0: 7468 6520 6d65 7461 6461 7461 3f0a 0909 the metadata?... │ │ │ -00041dc0: 6966 2028 6d5f 6469 7274 795f 6d65 7461 if (m_dirty_meta │ │ │ -00041dd0: 6461 7461 203d 3d20 6661 6c73 6529 2072 data == false) r │ │ │ -00041de0: 6574 7572 6e3b 0a0a 0909 6966 2028 6d5f eturn;....if (m_ │ │ │ -00041df0: 7069 6563 655f 6d61 702e 656d 7074 7928 piece_map.empty( │ │ │ -00041e00: 2929 0a09 097b 0a09 0909 2f2f 2069 6620 ))...{....// if │ │ │ -00041e10: 7765 2064 6f6e 2774 2068 6176 6520 616e we don't have an │ │ │ -00041e20: 7920 7069 6563 6573 206c 6566 7420 696e y pieces left in │ │ │ -00041e30: 2074 6865 0a09 0909 2f2f 2070 6172 7420 the....// part │ │ │ -00041e40: 6669 6c65 2c20 7265 6d6f 7665 2069 740a file, remove it. │ │ │ -00041e50: 0909 0973 7464 3a3a 7374 7269 6e67 2063 ...std::string c │ │ │ -00041e60: 6f6e 7374 2070 203d 2063 6f6d 6269 6e65 onst p = combine │ │ │ -00041e70: 5f70 6174 6828 6d5f 7061 7468 2c20 6d5f _path(m_path, m_ │ │ │ -00041e80: 6e61 6d65 293b 0a09 0909 7265 6d6f 7665 name);....remove │ │ │ -00041e90: 2870 2c20 6563 293b 0a0a 0909 0969 6620 (p, ec);.....if │ │ │ -00041ea0: 2865 6320 3d3d 2062 6f6f 7374 3a3a 7379 (ec == boost::sy │ │ │ -00041eb0: 7374 656d 3a3a 6572 7263 3a3a 6e6f 5f73 stem::errc::no_s │ │ │ -00041ec0: 7563 685f 6669 6c65 5f6f 725f 6469 7265 uch_file_or_dire │ │ │ -00041ed0: 6374 6f72 7929 0a09 0909 0965 632e 636c ctory).....ec.cl │ │ │ -00041ee0: 6561 7228 293b 0a09 0909 7265 7475 726e ear();....return │ │ │ -00041ef0: 3b0a 0909 7d0a 0a09 0961 7574 6f20 6620 ;...}....auto f │ │ │ -00041f00: 3d20 6f70 656e 5f66 696c 6528 6175 783a = open_file(aux: │ │ │ -00041f10: 3a6f 7065 6e5f 6d6f 6465 3a3a 7772 6974 :open_mode::writ │ │ │ -00041f20: 6520 7c20 6175 783a 3a6f 7065 6e5f 6d6f e | aux::open_mo │ │ │ -00041f30: 6465 3a3a 6869 6464 656e 2c20 6563 293b de::hidden, ec); │ │ │ -00041f40: 0a09 0969 6620 2865 6329 2072 6574 7572 ...if (ec) retur │ │ │ -00041f50: 6e3b 0a0a 0909 7374 643a 3a76 6563 746f n;....std::vecto │ │ │ -00041f60: 7226 6c74 3b63 6861 7226 6774 3b20 6865 r<char> he │ │ │ -00041f70: 6164 6572 2873 7461 7469 635f 6361 7374 ader(static_cast │ │ │ -00041f80: 266c 743b 7374 643a 3a73 697a 655f 7426 <std::size_t& │ │ │ -00041f90: 6774 3b28 6d5f 6865 6164 6572 5f73 697a gt;(m_header_siz │ │ │ -00041fa0: 6529 293b 0a0a 0909 7573 696e 6720 6e61 e));....using na │ │ │ -00041fb0: 6d65 7370 6163 6520 6c69 6274 6f72 7265 mespace libtorre │ │ │ -00041fc0: 6e74 3a3a 6175 783b 0a0a 0909 6368 6172 nt::aux;....char │ │ │ -00041fd0: 2a20 7074 7220 3d20 6865 6164 6572 2e64 * ptr = header.d │ │ │ -00041fe0: 6174 6128 293b 0a09 0977 7269 7465 5f75 ata();...write_u │ │ │ -00041ff0: 696e 7433 3228 6d5f 6d61 785f 7069 6563 int32(m_max_piec │ │ │ -00042000: 6573 2c20 7074 7229 3b0a 0909 7772 6974 es, ptr);...writ │ │ │ -00042010: 655f 7569 6e74 3332 286d 5f70 6965 6365 e_uint32(m_piece │ │ │ -00042020: 5f73 697a 652c 2070 7472 293b 0a0a 0909 _size, ptr);.... │ │ │ -00042030: 666f 7220 2870 6965 6365 5f69 6e64 6578 for (piece_index │ │ │ -00042040: 5f74 2070 6965 6365 2830 293b 2070 6965 _t piece(0); pie │ │ │ -00042050: 6365 2026 6c74 3b20 7069 6563 655f 696e ce < piece_in │ │ │ -00042060: 6465 785f 7428 6d5f 6d61 785f 7069 6563 dex_t(m_max_piec │ │ │ -00042070: 6573 293b 202b 2b70 6965 6365 290a 0909 es); ++piece)... │ │ │ -00042080: 7b0a 0909 0961 7574 6f20 636f 6e73 7420 {....auto const │ │ │ -00042090: 6920 3d20 6d5f 7069 6563 655f 6d61 702e i = m_piece_map. │ │ │ -000420a0: 6669 6e64 2870 6965 6365 293b 0a3c 2f70 find(piece);.

    re │ │ │ -000420e0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../src/t │ │ │ -00042120: 6f72 7265 6e74 5f68 616e 646c 652e 6370 orrent_handle.cp │ │ │ -00042130: 703a 3535 343c 2f61 3e3c 2f74 643e 3c74 p:554support moving │ │ │ -00042150: 2066 696c 6573 2069 6e74 6f20 7468 6973 files into this │ │ │ -00042160: 2063 616c 6c3c 2f74 643e 3c2f 7472 3e3c call< │ │ │ -00042170: 7472 2069 643d 2231 3634 2220 7374 796c tr id="164" styl │ │ │ -00042180: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00042190: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000421a0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000421b0: 6832 3e73 7570 706f 7274 206d 6f76 696e h2>support movin │ │ │ -000421c0: 6720 6669 6c65 7320 696e 746f 2074 6869 g files into thi │ │ │ -000421d0: 7320 6361 6c6c 3c2f 6832 3e3c 6834 3e2e s call

    . │ │ │ -000421e0: 2e2f 7372 632f 746f 7272 656e 745f 6861 ./src/torrent_ha │ │ │ -000421f0: 6e64 6c65 2e63 7070 3a35 3534 3c2f 6834 ndle.cpp:554

    ..aut
    │ │ │ -00042240: 6f2a 2063 6f6e 7374 2072 6574 7020 3d20  o* const retp = 
    │ │ │ -00042250: 2661 6d70 3b70 7269 6f3b 0a09 0973 796e  &prio;...syn
    │ │ │ -00042260: 635f 6361 6c6c 2826 616d 703b 6175 783a  c_call(&aux:
    │ │ │ -00042270: 3a74 6f72 7265 6e74 3a3a 7069 6563 655f  :torrent::piece_
    │ │ │ -00042280: 7072 696f 7269 7469 6573 2c20 7265 7470  priorities, retp
    │ │ │ -00042290: 293b 0a09 0973 7464 3a3a 7665 6374 6f72  );...std::vector
    │ │ │ -000422a0: 266c 743b 696e 7426 6774 3b20 7265 743b  <int> ret;
    │ │ │ -000422b0: 0a09 0972 6574 2e72 6573 6572 7665 2870  ...ret.reserve(p
    │ │ │ -000422c0: 7269 6f2e 7369 7a65 2829 293b 0a09 0966  rio.size());...f
    │ │ │ -000422d0: 6f72 2028 6175 746f 2070 203a 2070 7269  or (auto p : pri
    │ │ │ -000422e0: 6f29 0a09 0909 7265 742e 7075 7368 5f62  o)....ret.push_b
    │ │ │ -000422f0: 6163 6b28 696e 7428 7374 6174 6963 5f63  ack(int(static_c
    │ │ │ -00042300: 6173 7426 6c74 3b73 7464 3a3a 7569 6e74  ast<std::uint
    │ │ │ -00042310: 385f 7426 6774 3b28 7029 2929 3b0a 0909  8_t>(p)));...
    │ │ │ -00042320: 7265 7475 726e 2072 6574 3b0a 097d 0a23  return ret;..}.#
    │ │ │ -00042330: 656e 6469 660a 0a09 766f 6964 2074 6f72  endif...void tor
    │ │ │ -00042340: 7265 6e74 5f68 616e 646c 653a 3a66 696c  rent_handle::fil
    │ │ │ -00042350: 655f 7072 696f 7269 7479 2866 696c 655f  e_priority(file_
    │ │ │ -00042360: 696e 6465 785f 7420 696e 6465 782c 2064  index_t index, d
    │ │ │ -00042370: 6f77 6e6c 6f61 645f 7072 696f 7269 7479  ownload_priority
    │ │ │ -00042380: 5f74 2070 7269 6f72 6974 7929 2063 6f6e  _t priority) con
    │ │ │ -00042390: 7374 0a09 7b0a 0909 6173 796e 635f 6361  st..{...async_ca
    │ │ │ -000423a0: 6c6c 2826 616d 703b 6175 783a 3a74 6f72  ll(&aux::tor
    │ │ │ -000423b0: 7265 6e74 3a3a 7365 745f 6669 6c65 5f70  rent::set_file_p
    │ │ │ -000423c0: 7269 6f72 6974 792c 2069 6e64 6578 2c20  riority, index, 
    │ │ │ -000423d0: 7072 696f 7269 7479 293b 0a09 7d0a 0a09  priority);..}...
    │ │ │ -000423e0: 646f 776e 6c6f 6164 5f70 7269 6f72 6974  download_priorit
    │ │ │ -000423f0: 795f 7420 746f 7272 656e 745f 6861 6e64  y_t torrent_hand
    │ │ │ -00042400: 6c65 3a3a 6669 6c65 5f70 7269 6f72 6974  le::file_priorit
    │ │ │ -00042410: 7928 6669 6c65 5f69 6e64 6578 5f74 2069  y(file_index_t i
    │ │ │ -00042420: 6e64 6578 2920 636f 6e73 740a 097b 0a09  ndex) const..{..
    │ │ │ -00042430: 0972 6574 7572 6e20 7379 6e63 5f63 616c  .return sync_cal
    │ │ │ -00042440: 6c5f 7265 7426 6c74 3b64 6f77 6e6c 6f61  l_ret<downloa
    │ │ │ -00042450: 645f 7072 696f 7269 7479 5f74 2667 743b  d_priority_t>
    │ │ │ -00042460: 2864 6f6e 745f 646f 776e 6c6f 6164 2c20  (dont_download, 
    │ │ │ -00042470: 2661 6d70 3b61 7578 3a3a 746f 7272 656e  &aux::torren
    │ │ │ -00042480: 743a 3a66 696c 655f 7072 696f 7269 7479  t::file_priority
    │ │ │ -00042490: 2c20 696e 6465 7829 3b0a 097d 0a0a 3c64  , index);..}...voi
    │ │ │ -000424d0: 6420 746f 7272 656e 745f 6861 6e64 6c65  d torrent_handle
    │ │ │ -000424e0: 3a3a 7072 696f 7269 7469 7a65 5f66 696c  ::prioritize_fil
    │ │ │ -000424f0: 6573 2873 7464 3a3a 7665 6374 6f72 266c  es(std::vector&l
    │ │ │ -00042500: 743b 646f 776e 6c6f 6164 5f70 7269 6f72  t;download_prior
    │ │ │ -00042510: 6974 795f 7426 6774 3b20 636f 6e73 7426  ity_t> const&
    │ │ │ -00042520: 616d 703b 2066 696c 6573 2920 636f 6e73  amp; files) cons
    │ │ │ -00042530: 740a 3c2f 6469 763e 097b 0a09 0961 7379  t.
    .{...asy │ │ │ -00042540: 6e63 5f63 616c 6c28 2661 6d70 3b61 7578 nc_call(&aux │ │ │ -00042550: 3a3a 746f 7272 656e 743a 3a70 7269 6f72 ::torrent::prior │ │ │ -00042560: 6974 697a 655f 6669 6c65 730a 0909 092c itize_files...., │ │ │ -00042570: 2073 7461 7469 635f 6361 7374 266c 743b static_cast< │ │ │ -00042580: 6175 783a 3a76 6563 746f 7226 6c74 3b64 aux::vector<d │ │ │ -00042590: 6f77 6e6c 6f61 645f 7072 696f 7269 7479 ownload_priority │ │ │ -000425a0: 5f74 2c20 6669 6c65 5f69 6e64 6578 5f74 _t, file_index_t │ │ │ -000425b0: 2667 743b 2063 6f6e 7374 2661 6d70 3b26 > const&& │ │ │ -000425c0: 6774 3b28 6669 6c65 7329 293b 0a09 7d0a gt;(files));..}. │ │ │ -000425d0: 0a09 766f 6964 2074 6f72 7265 6e74 5f68 ..void torrent_h │ │ │ -000425e0: 616e 646c 653a 3a70 6f73 745f 6669 6c65 andle::post_file │ │ │ -000425f0: 5f70 7269 6f72 6974 6965 7328 2920 636f _priorities() co │ │ │ -00042600: 6e73 740a 097b 0a09 0961 7379 6e63 5f63 nst..{...async_c │ │ │ -00042610: 616c 6c28 2661 6d70 3b61 7578 3a3a 746f all(&aux::to │ │ │ -00042620: 7272 656e 743a 3a70 6f73 745f 6669 6c65 rrent::post_file │ │ │ -00042630: 5f70 7269 6f72 6974 6965 7329 3b0a 097d _priorities);..} │ │ │ -00042640: 0a0a 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ -00042650: 743b 646f 776e 6c6f 6164 5f70 7269 6f72 t;download_prior │ │ │ -00042660: 6974 795f 7426 6774 3b20 746f 7272 656e ity_t> torren │ │ │ -00042670: 745f 6861 6e64 6c65 3a3a 6765 745f 6669 t_handle::get_fi │ │ │ -00042680: 6c65 5f70 7269 6f72 6974 6965 7328 2920 le_priorities() │ │ │ -00042690: 636f 6e73 740a 097b 0a09 0961 7578 3a3a const..{...aux:: │ │ │ -000426a0: 7665 6374 6f72 266c 743b 646f 776e 6c6f vector<downlo │ │ │ -000426b0: 6164 5f70 7269 6f72 6974 795f 742c 2066 ad_priority_t, f │ │ │ -000426c0: 696c 655f 696e 6465 785f 7426 6774 3b20 ile_index_t> │ │ │ -000426d0: 7265 743b 0a09 0961 7574 6f2a 2063 6f6e ret;...auto* con │ │ │ -000426e0: 7374 2072 6574 7020 3d20 2661 6d70 3b72 st retp = &r │ │ │ -000426f0: 6574 3b0a 0909 7379 6e63 5f63 616c 6c28 et;...sync_call( │ │ │ -00042700: 2661 6d70 3b61 7578 3a3a 746f 7272 656e &aux::torren │ │ │ -00042710: 743a 3a66 696c 655f 7072 696f 7269 7469 t::file_prioriti │ │ │ -00042720: 6573 2c20 7265 7470 293b 0a09 0972 6574 es, retp);...ret │ │ │ -00042730: 7572 6e20 544f 5252 454e 545f 5256 4f28 urn TORRENT_RVO( │ │ │ -00042740: 7265 7429 3b0a 097d 0a0a 2369 6620 544f ret);..}..#if TO │ │ │ -00042750: 5252 454e 545f 4142 495f 5645 5253 494f RRENT_ABI_VERSIO │ │ │ -00042760: 4e20 3d3d 2031 0a0a 2f2f 203d 3d3d 3d3d N == 1..// ===== │ │ │ -00042770: 3d3d 3d3d 3d3d 3d20 7374 6172 7420 6465 ======= start de │ │ │ -00042780: 7072 6563 6174 696f 6e20 3d3d 3d3d 3d3d precation ====== │ │ │ -00042790: 3d3d 3d3d 3d3d 3d3d 3d0a 0a09 766f 6964 =========...void │ │ │ -000427a0: 2074 6f72 7265 6e74 5f68 616e 646c 653a torrent_handle: │ │ │ -000427b0: 3a70 7269 6f72 6974 697a 655f 6669 6c65 :prioritize_file │ │ │ -000427c0: 7328 7374 643a 3a76 6563 746f 7226 6c74 s(std::vector< │ │ │ -000427d0: 3b69 6e74 2667 743b 2063 6f6e 7374 2661 ;int> const&a │ │ │ -000427e0: 6d70 3b20 6669 6c65 7329 2063 6f6e 7374 mp; files) const │ │ │ -000427f0: 0a09 7b0a 0909 6175 783a 3a76 6563 746f ..{...aux::vecto │ │ │ -00042800: 7226 6c74 3b64 6f77 6e6c 6f61 645f 7072 r<download_pr │ │ │ -00042810: 696f 7269 7479 5f74 2c20 6669 6c65 5f69 iority_t, file_i │ │ │ -00042820: 6e64 6578 5f74 2667 743b 2066 696c 655f ndex_t> file_ │ │ │ -00042830: 7072 696f 3b0a 0909 6669 6c65 5f70 7269 prio;...file_pri │ │ │ -00042840: 6f2e 7265 7365 7276 6528 6669 6c65 732e o.reserve(files. │ │ │ -00042850: 7369 7a65 2829 293b 0a09 0966 6f72 2028 size());...for ( │ │ │ -00042860: 6175 746f 2063 6f6e 7374 2070 203a 2066 auto const p : f │ │ │ -00042870: 696c 6573 2920 7b0a 0909 0966 696c 655f iles) {....file_ │ │ │ -00042880: 7072 696f 2e70 7573 685f 6261 636b 2864 prio.push_back(d │ │ │ -00042890: 6f77 6e6c 6f61 645f 7072 696f 7269 7479 ownload_priority │ │ │ -000428a0: 5f74 2873 7461 7469 635f 6361 7374 266c _t(static_cast&l │ │ │ -000428b0: 743b 7374 643a 3a75 696e 7438 5f74 2667 t;std::uint8_t&g │ │ │ -000428c0: 743b 2870 2929 293b 0a09 097d 0a09 0961 t;(p)));...}...a │ │ │ -000428d0: 7379 6e63 5f63 616c 6c28 2661 6d70 3b61 sync_call(&a │ │ │ -000428e0: 7578 3a3a 746f 7272 656e 743a 3a70 7269 ux::torrent::pri │ │ │ -000428f0: 6f72 6974 697a 655f 6669 6c65 732c 2066 oritize_files, f │ │ │ -00042900: 696c 655f 7072 696f 293b 0a3c 2f70 7265 ile_prio);.rele │ │ │ -00042940: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ -00042980: 7265 6e74 5f68 616e 646c 652e 6370 703a rent_handle.cpp: │ │ │ -00042990: 3833 393c 2f61 3e3c 2f74 643e 3c74 643e 839 │ │ │ -000429a0: 6465 7072 6563 6174 6520 7468 6520 6f76 deprecate the ov │ │ │ -000429b0: 6572 6c6f 6164 2074 6861 7420 7461 6b65 erload that take │ │ │ -000429c0: 7320 616e 2069 6e64 6578 3c2f 7464 3e3c s an index< │ │ │ -000429d0: 2f74 723e 3c74 7220 6964 3d22 3136 3522 /tr>

    deprecat │ │ │ -00042a20: 6520 7468 6520 6f76 6572 6c6f 6164 2074 e the overload t │ │ │ -00042a30: 6861 7420 7461 6b65 7320 616e 2069 6e64 hat takes an ind │ │ │ -00042a40: 6578 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ex

    ../sr │ │ │ -00042a50: 632f 746f 7272 656e 745f 6861 6e64 6c65 c/torrent_handle │ │ │ -00042a60: 2e63 7070 3a38 3339 3c2f 6834 3e3c 7072 .cpp:839

    ...auto t │ │ │ -00042ab0: 203d 206d 5f74 6f72 7265 6e74 2e6c 6f63 = m_torrent.loc │ │ │ -00042ac0: 6b28 293b 0a09 0969 6620 2821 7420 7c7c k();...if (!t || │ │ │ -00042ad0: 2021 742d 2667 743b 6861 735f 7374 6f72 !t->has_stor │ │ │ -00042ae0: 6167 6528 2929 2072 6574 7572 6e3b 0a09 age()) return;.. │ │ │ -00042af0: 0961 7574 6f26 616d 703b 2073 6573 203d .auto& ses = │ │ │ -00042b00: 2073 7461 7469 635f 6361 7374 266c 743b static_cast< │ │ │ -00042b10: 7365 7373 696f 6e5f 696d 706c 2661 6d70 session_impl& │ │ │ -00042b20: 3b26 6774 3b28 742d 2667 743b 7365 7373 ;>(t->sess │ │ │ -00042b30: 696f 6e28 2929 3b0a 0909 7374 6174 7573 ion());...status │ │ │ -00042b40: 203d 2073 6573 2e64 6973 6b5f 7468 7265 = ses.disk_thre │ │ │ -00042b50: 6164 2829 2e67 6574 5f73 7461 7475 7328 ad().get_status( │ │ │ -00042b60: 742d 2667 743b 7374 6f72 6167 6528 2929 t->storage()) │ │ │ -00042b70: 3b0a 097d 0a23 656e 6469 660a 0a09 766f ;..}.#endif...vo │ │ │ -00042b80: 6964 2074 6f72 7265 6e74 5f68 616e 646c id torrent_handl │ │ │ -00042b90: 653a 3a66 6f72 6365 5f64 6874 5f61 6e6e e::force_dht_ann │ │ │ -00042ba0: 6f75 6e63 6528 2920 636f 6e73 740a 097b ounce() const..{ │ │ │ -00042bb0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -00042bc0: 5f44 4953 4142 4c45 5f44 4854 0a09 0961 _DISABLE_DHT...a │ │ │ -00042bd0: 7379 6e63 5f63 616c 6c28 2661 6d70 3b61 sync_call(&a │ │ │ -00042be0: 7578 3a3a 746f 7272 656e 743a 3a64 6874 ux::torrent::dht │ │ │ -00042bf0: 5f61 6e6e 6f75 6e63 6529 3b0a 2365 6e64 _announce);.#end │ │ │ -00042c00: 6966 0a09 7d0a 0a09 766f 6964 2074 6f72 if..}...void tor │ │ │ -00042c10: 7265 6e74 5f68 616e 646c 653a 3a66 6f72 rent_handle::for │ │ │ -00042c20: 6365 5f6c 7364 5f61 6e6e 6f75 6e63 6528 ce_lsd_announce( │ │ │ -00042c30: 2920 636f 6e73 740a 097b 0a09 0961 7379 ) const..{...asy │ │ │ -00042c40: 6e63 5f63 616c 6c28 2661 6d70 3b61 7578 nc_call(&aux │ │ │ -00042c50: 3a3a 746f 7272 656e 743a 3a6c 7364 5f61 ::torrent::lsd_a │ │ │ -00042c60: 6e6e 6f75 6e63 6529 3b0a 097d 0a0a 3c64 nnounce);..}...voi │ │ │ -00042ca0: 6420 746f 7272 656e 745f 6861 6e64 6c65 d torrent_handle │ │ │ -00042cb0: 3a3a 666f 7263 655f 7265 616e 6e6f 756e ::force_reannoun │ │ │ -00042cc0: 6365 2869 6e74 2063 6f6e 7374 2073 2c20 ce(int const s, │ │ │ -00042cd0: 696e 7420 636f 6e73 7420 6964 782c 2072 int const idx, r │ │ │ -00042ce0: 6561 6e6e 6f75 6e63 655f 666c 6167 735f eannounce_flags_ │ │ │ -00042cf0: 7420 636f 6e73 7420 666c 6167 7329 2063 t const flags) c │ │ │ -00042d00: 6f6e 7374 0a3c 2f64 6976 3e09 7b0a 0909 onst.
    .{... │ │ │ -00042d10: 6173 796e 635f 6361 6c6c 2826 616d 703b async_call(& │ │ │ -00042d20: 6175 783a 3a74 6f72 7265 6e74 3a3a 666f aux::torrent::fo │ │ │ -00042d30: 7263 655f 7472 6163 6b65 725f 7265 7175 rce_tracker_requ │ │ │ -00042d40: 6573 742c 2061 7578 3a3a 7469 6d65 5f6e est, aux::time_n │ │ │ -00042d50: 6f77 2829 202b 2073 6563 6f6e 6473 2873 ow() + seconds(s │ │ │ -00042d60: 292c 2069 6478 2c20 666c 6167 7329 3b0a ), idx, flags);. │ │ │ -00042d70: 097d 0a0a 0976 6f69 6420 746f 7272 656e .}...void torren │ │ │ -00042d80: 745f 6861 6e64 6c65 3a3a 666f 7263 655f t_handle::force_ │ │ │ -00042d90: 7265 616e 6e6f 756e 6365 2869 6e74 2063 reannounce(int c │ │ │ -00042da0: 6f6e 7374 2073 2c20 7374 643a 3a73 7472 onst s, std::str │ │ │ -00042db0: 696e 6720 636f 6e73 7426 616d 703b 2075 ing const& u │ │ │ -00042dc0: 726c 2c20 7265 616e 6e6f 756e 6365 5f66 rl, reannounce_f │ │ │ -00042dd0: 6c61 6773 5f74 2063 6f6e 7374 2066 6c61 lags_t const fla │ │ │ -00042de0: 6773 2920 636f 6e73 740a 097b 0a09 0961 gs) const..{...a │ │ │ -00042df0: 7379 6e63 5f63 616c 6c28 2661 6d70 3b61 sync_call(&a │ │ │ -00042e00: 7578 3a3a 746f 7272 656e 743a 3a66 6f72 ux::torrent::for │ │ │ -00042e10: 6365 5f74 7261 636b 6572 5f72 6571 7565 ce_tracker_reque │ │ │ -00042e20: 7374 5f75 726c 2c20 6175 783a 3a74 696d st_url, aux::tim │ │ │ -00042e30: 655f 6e6f 7728 2920 2b20 7365 636f 6e64 e_now() + second │ │ │ -00042e40: 7328 7329 2c20 7572 6c2c 2066 6c61 6773 s(s), url, flags │ │ │ -00042e50: 293b 0a09 7d0a 0a09 766f 6964 2074 6f72 );..}...void tor │ │ │ -00042e60: 7265 6e74 5f68 616e 646c 653a 3a66 6f72 rent_handle::for │ │ │ -00042e70: 6365 5f72 6561 6e6e 6f75 6e63 6528 696e ce_reannounce(in │ │ │ -00042e80: 7420 636f 6e73 7420 732c 2072 6561 6e6e t const s, reann │ │ │ -00042e90: 6f75 6e63 655f 666c 6167 735f 7420 636f ounce_flags_t co │ │ │ -00042ea0: 6e73 7420 666c 6167 7329 2063 6f6e 7374 nst flags) const │ │ │ -00042eb0: 0a09 7b0a 0909 6173 796e 635f 6361 6c6c ..{...async_call │ │ │ -00042ec0: 2826 616d 703b 6175 783a 3a74 6f72 7265 (&aux::torre │ │ │ -00042ed0: 6e74 3a3a 666f 7263 655f 7472 6163 6b65 nt::force_tracke │ │ │ -00042ee0: 725f 7265 7175 6573 742c 2061 7578 3a3a r_request, aux:: │ │ │ -00042ef0: 7469 6d65 5f6e 6f77 2829 202b 2073 6563 time_now() + sec │ │ │ -00042f00: 6f6e 6473 2873 292c 202d 312c 2066 6c61 onds(s), -1, fla │ │ │ -00042f10: 6773 293b 0a09 7d0a 0a09 7374 643a 3a76 gs);..}...std::v │ │ │ -00042f20: 6563 746f 7226 6c74 3b6f 7065 6e5f 6669 ector<open_fi │ │ │ -00042f30: 6c65 5f73 7461 7465 2667 743b 2074 6f72 le_state> tor │ │ │ -00042f40: 7265 6e74 5f68 616e 646c 653a 3a66 696c rent_handle::fil │ │ │ -00042f50: 655f 7374 6174 7573 2829 2063 6f6e 7374 e_status() const │ │ │ -00042f60: 0a09 7b0a 0909 6175 746f 2074 203d 206d ..{...auto t = m │ │ │ -00042f70: 5f74 6f72 7265 6e74 2e6c 6f63 6b28 293b _torrent.lock(); │ │ │ -00042f80: 0a09 0969 6620 2821 7420 7c7c 2021 742d ...if (!t || !t- │ │ │ -00042f90: 2667 743b 6861 735f 7374 6f72 6167 6528 >has_storage( │ │ │ -00042fa0: 2929 2072 6574 7572 6e20 7b7d 3b0a 0909 )) return {};... │ │ │ -00042fb0: 6175 746f 2661 6d70 3b20 7365 7320 3d20 auto& ses = │ │ │ -00042fc0: 7374 6174 6963 5f63 6173 7426 6c74 3b73 static_cast<s │ │ │ -00042fd0: 6573 7369 6f6e 5f69 6d70 6c26 616d 703b ession_impl& │ │ │ -00042fe0: 2667 743b 2874 2d26 6774 3b73 6573 7369 >(t->sessi │ │ │ -00042ff0: 6f6e 2829 293b 0a09 0972 6574 7572 6e20 on());...return │ │ │ -00043000: 7365 732e 6469 736b 5f74 6872 6561 6428 ses.disk_thread( │ │ │ -00043010: 292e 6765 745f 7374 6174 7573 2874 2d26 ).get_status(t-& │ │ │ -00043020: 6774 3b73 746f 7261 6765 2829 293b 0a09 gt;storage());.. │ │ │ -00043030: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74 }...void torrent │ │ │ -00043040: 5f68 616e 646c 653a 3a70 6f73 745f 6669 _handle::post_fi │ │ │ -00043050: 6c65 5f73 7461 7475 7328 2920 636f 6e73 le_status() cons │ │ │ -00043060: 740a 097b 0a09 0961 7379 6e63 5f63 616c t..{...async_cal │ │ │ -00043070: 6c28 2661 6d70 3b61 7578 3a3a 746f 7272 l(&aux::torr │ │ │ -00043080: 656e 743a 3a70 6f73 745f 6669 6c65 5f73 ent::post_file_s │ │ │ -00043090: 7461 7475 7329 3b0a 097d 0a0a 0976 6f69 tatus);..}...voi │ │ │ -000430a0: 6420 746f 7272 656e 745f 6861 6e64 6c65 d torrent_handle │ │ │ -000430b0: 3a3a 7363 7261 7065 5f74 7261 636b 6572 ::scrape_tracker │ │ │ -000430c0: 2869 6e74 2069 6478 2920 636f 6e73 740a (int idx) const. │ │ │ -000430d0: 097b 0a09 0961 7379 6e63 5f63 616c 6c28 .{...async_call( │ │ │ -000430e0: 2661 6d70 3b61 7578 3a3a 746f 7272 656e &aux::torren │ │ │ -000430f0: 743a 3a73 6372 6170 655f 7472 6163 6b65 t::scrape_tracke │ │ │ -00043100: 722c 2069 6478 2c20 7472 7565 293b 0a3c r, idx, true);.< │ │ │ -00043110: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00043120: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00043130: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00043140: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00043150: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -00043180: 2f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 /torrent_info.cp │ │ │ -00043190: 703a 3136 3335 3c2f 613e 3c2f 7464 3e3c p:1635< │ │ │ -000431a0: 7464 3e63 6f6c 6c65 6374 696f 6e73 3c2f td>collections

    coll │ │ │ -00043200: 6563 7469 6f6e 733c 2f68 323e 3c68 343e ections

    │ │ │ -00043210: 2e2e 2f73 7263 2f74 6f72 7265 6e74 5f69 ../src/torrent_i │ │ │ -00043220: 6e66 6f2e 6370 703a 3136 3335 3c2f 6834 nfo.cpp:1635

    rele
    │ │ │ -000432a0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../src/tor
    │ │ │ -000432e0: 7265 6e74 5f69 6e66 6f2e 6370 703a 3136  rent_info.cpp:16
    │ │ │ -000432f0: 3336 3c2f 613e 3c2f 7464 3e3c 7464 3e73  36s
    │ │ │ -00043300: 696d 696c 6172 3c2f 7464 3e3c 2f74 723e  imilar
    │ │ │ -00043310: 3c74 7220 6964 3d22 3136 3722 2073 7479  
    │ │ │ -00043340: 3c74 6420 636f 6c73 7061 6e3d 2233 223e  
    │ │ │ -00043350: 3c68 323e 7369 6d69 6c61 723c 2f68 323e  

    similar

    │ │ │ -00043360: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ -00043370: 6e74 5f69 6e66 6f2e 6370 703a 3136 3336 nt_info.cpp:1636 │ │ │ -00043380: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -000433c0: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ -000433d0: 7426 616d 703b 2075 726c 203a 2061 7470  t& url : atp
    │ │ │ -000433e0: 2e75 726c 5f73 6565 6473 290a 0909 7b0a  .url_seeds)...{.
    │ │ │ -000433f0: 0909 0977 6562 5f73 6565 645f 656e 7472  ...web_seed_entr
    │ │ │ -00043400: 7920 656e 7428 7572 6c29 3b0a 0909 0965  y ent(url);....e
    │ │ │ -00043410: 6e74 2e74 7970 6520 3d20 7765 625f 7365  nt.type = web_se
    │ │ │ -00043420: 6564 5f65 6e74 7279 3a3a 7572 6c5f 7365  ed_entry::url_se
    │ │ │ -00043430: 6564 3b0a 0909 096d 5f77 6562 5f73 6565  ed;....m_web_see
    │ │ │ -00043440: 6473 2e70 7573 685f 6261 636b 2873 7464  ds.push_back(std
    │ │ │ -00043450: 3a3a 6d6f 7665 2865 6e74 2929 3b0a 0909  ::move(ent));...
    │ │ │ -00043460: 7d0a 0a09 0966 6f72 2028 6175 746f 2063  }....for (auto c
    │ │ │ -00043470: 6f6e 7374 2661 6d70 3b20 7572 6c20 3a20  onst& url : 
    │ │ │ -00043480: 6174 702e 6874 7470 5f73 6565 6473 290a  atp.http_seeds).
    │ │ │ -00043490: 0909 7b0a 0909 0977 6562 5f73 6565 645f  ..{....web_seed_
    │ │ │ -000434a0: 656e 7472 7920 656e 7428 7572 6c29 3b0a  entry ent(url);.
    │ │ │ -000434b0: 0909 0965 6e74 2e74 7970 6520 3d20 7765  ...ent.type = we
    │ │ │ -000434c0: 625f 7365 6564 5f65 6e74 7279 3a3a 6874  b_seed_entry::ht
    │ │ │ -000434d0: 7470 5f73 6565 643b 0a09 0909 6d5f 7765  tp_seed;....m_we
    │ │ │ -000434e0: 625f 7365 6564 732e 7075 7368 5f62 6163  b_seeds.push_bac
    │ │ │ -000434f0: 6b28 7374 643a 3a6d 6f76 6528 656e 7429  k(std::move(ent)
    │ │ │ -00043500: 293b 0a09 097d 0a0a 0909 666f 7220 2861  );...}....for (a
    │ │ │ -00043510: 7574 6f20 636f 6e73 7426 616d 703b 206e  uto const& n
    │ │ │ -00043520: 203a 2061 7470 2e64 6874 5f6e 6f64 6573   : atp.dht_nodes
    │ │ │ -00043530: 290a 0909 7b0a 0909 096d 5f6e 6f64 6573  )...{....m_nodes
    │ │ │ -00043540: 2e65 6d70 6c61 6365 5f62 6163 6b28 6e29  .emplace_back(n)
    │ │ │ -00043550: 3b0a 0909 7d0a 0a3c 6469 7620 7374 796c  ;...}..
    ..return tr │ │ │ -00043590: 7565 3b0a 3c2f 6469 763e 097d 0a0a 0976 ue;.
    .}...v │ │ │ -000435a0: 6f69 6420 746f 7272 656e 745f 696e 666f oid torrent_info │ │ │ -000435b0: 3a3a 6164 645f 7472 6163 6b65 7228 7374 ::add_tracker(st │ │ │ -000435c0: 643a 3a73 7472 696e 6720 636f 6e73 7426 d::string const& │ │ │ -000435d0: 616d 703b 2075 726c 2c20 696e 7420 636f amp; url, int co │ │ │ -000435e0: 6e73 7420 7469 6572 290a 097b 0a09 0961 nst tier)..{...a │ │ │ -000435f0: 6464 5f74 7261 636b 6572 2875 726c 2c20 dd_tracker(url, │ │ │ -00043600: 7469 6572 2c20 616e 6e6f 756e 6365 5f65 tier, announce_e │ │ │ -00043610: 6e74 7279 3a3a 736f 7572 6365 5f63 6c69 ntry::source_cli │ │ │ -00043620: 656e 7429 3b0a 097d 0a0a 0976 6f69 6420 ent);..}...void │ │ │ -00043630: 746f 7272 656e 745f 696e 666f 3a3a 6164 torrent_info::ad │ │ │ -00043640: 645f 7472 6163 6b65 7228 7374 643a 3a73 d_tracker(std::s │ │ │ -00043650: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ -00043660: 2075 726c 2c20 696e 7420 636f 6e73 7420 url, int const │ │ │ -00043670: 7469 6572 0a09 092c 2061 6e6e 6f75 6e63 tier..., announc │ │ │ -00043680: 655f 656e 7472 793a 3a74 7261 636b 6572 e_entry::tracker │ │ │ -00043690: 5f73 6f75 7263 6520 636f 6e73 7420 736f _source const so │ │ │ -000436a0: 7572 6365 290a 097b 0a09 0954 4f52 5245 urce)..{...TORRE │ │ │ -000436b0: 4e54 5f41 5353 4552 545f 5052 4543 4f4e NT_ASSERT_PRECON │ │ │ -000436c0: 4428 2175 726c 2e65 6d70 7479 2829 293b D(!url.empty()); │ │ │ -000436d0: 0a09 0961 7574 6f20 636f 6e73 7420 6920 ...auto const i │ │ │ -000436e0: 3d20 7374 643a 3a66 696e 645f 6966 286d = std::find_if(m │ │ │ -000436f0: 5f75 726c 732e 6265 6769 6e28 292c 206d _urls.begin(), m │ │ │ -00043700: 5f75 726c 732e 656e 6428 290a 0909 092c _urls.end()...., │ │ │ -00043710: 205b 2661 6d70 3b75 726c 5d28 616e 6e6f [&url](anno │ │ │ -00043720: 756e 6365 5f65 6e74 7279 2063 6f6e 7374 unce_entry const │ │ │ -00043730: 2661 6d70 3b20 6165 2920 7b20 7265 7475 & ae) { retu │ │ │ -00043740: 726e 2061 652e 7572 6c20 3d3d 2075 726c rn ae.url == url │ │ │ -00043750: 3b20 7d29 3b0a 0909 6966 2028 6920 213d ; });...if (i != │ │ │ -00043760: 206d 5f75 726c 732e 656e 6428 2929 2072 m_urls.end()) r │ │ │ -00043770: 6574 7572 6e3b 0a09 0969 6620 2821 6c74 eturn;...if (!lt │ │ │ -00043780: 3a3a 6175 783a 3a69 735f 7661 6c69 645f ::aux::is_valid_ │ │ │ -00043790: 7472 6163 6b65 725f 7572 6c28 7572 6c29 tracker_url(url) │ │ │ -000437a0: 2920 7265 7475 726e 3b0a 0a09 0961 6e6e ) return;....ann │ │ │ -000437b0: 6f75 6e63 655f 656e 7472 7920 6528 7572 ounce_entry e(ur │ │ │ -000437c0: 6c29 3b0a 0909 652e 7469 6572 203d 2073 l);...e.tier = s │ │ │ -000437d0: 7464 3a3a 7569 6e74 385f 7428 7469 6572 td::uint8_t(tier │ │ │ -000437e0: 293b 0a09 0965 2e73 6f75 7263 6520 3d20 );...e.source = │ │ │ -000437f0: 736f 7572 6365 3b0a 0909 6d5f 7572 6c73 source;...m_urls │ │ │ -00043800: 2e70 7573 685f 6261 636b 2865 293b 0a0a .push_back(e);.. │ │ │ -00043810: 0909 7374 643a 3a73 6f72 7428 6d5f 7572 ..std::sort(m_ur │ │ │ -00043820: 6c73 2e62 6567 696e 2829 2c20 6d5f 7572 ls.begin(), m_ur │ │ │ -00043830: 6c73 2e65 6e64 2829 0a09 0909 2c20 5b5d ls.end()...., [] │ │ │ -00043840: 2028 616e 6e6f 756e 6365 5f65 6e74 7279 (announce_entry │ │ │ -00043850: 2063 6f6e 7374 2661 6d70 3b20 6c68 732c const& lhs, │ │ │ -00043860: 2061 6e6e 6f75 6e63 655f 656e 7472 7920 announce_entry │ │ │ -00043870: 636f 6e73 7426 616d 703b 2072 6873 290a const& rhs). │ │ │ -00043880: 0909 097b 2072 6574 7572 6e20 6c68 732e ...{ return lhs. │ │ │ -00043890: 7469 6572 2026 6c74 3b20 7268 732e 7469 tier < rhs.ti │ │ │ -000438a0: 6572 3b20 7d29 3b0a 097d 0a0a 0976 6f69 er; });..}...voi │ │ │ -000438b0: 6420 746f 7272 656e 745f 696e 666f 3a3a d torrent_info:: │ │ │ -000438c0: 636c 6561 725f 7472 6163 6b65 7273 2829 clear_trackers() │ │ │ -000438d0: 0a09 7b0a 0909 6d5f 7572 6c73 2e63 6c65 ..{...m_urls.cle │ │ │ -000438e0: 6172 2829 3b0a 097d 0a3c 2f70 7265 3e3c ar();..}.
    < │ │ │ -000438f0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00043920: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00043930: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/posix │ │ │ -00043960: 5f70 6172 745f 6669 6c65 2e63 7070 3a33 _part_file.cpp:3 │ │ │ -00043970: 3136 3c2f 613e 3c2f 7464 3e3c 7464 3e77 16w │ │ │ -00043980: 6861 7420 646f 2077 6520 646f 2069 6620 hat do we do if │ │ │ -00043990: 736f 6d65 6f6e 6520 6973 2063 7572 7265 someone is curre │ │ │ -000439a0: 6e74 6c79 2072 6561 6469 6e67 2066 726f ntly reading fro │ │ │ -000439b0: 6d20 7468 6520 6469 736b 2066 726f 6d20 m the disk from │ │ │ -000439c0: 7468 6973 2070 6965 6365 3f20 646f 6573 this piece? does │ │ │ -000439d0: 2069 7420 6d61 7474 6572 3f20 5369 6e63 it matter? Sinc │ │ │ -000439e0: 6520 7765 2077 6f6e 2774 2061 6374 6976 e we won't activ │ │ │ -000439f0: 656c 7920 6572 6173 6520 7468 6520 6461 ely erase the da │ │ │ -00043a00: 7461 2066 726f 6d20 6469 736b 2c20 6275 ta from disk, bu │ │ │ -00043a10: 7420 6974 206d 6179 2062 6520 6f76 6572 t it may be over │ │ │ -00043a20: 7772 6974 7465 6e20 736f 6f6e 2c20 6974 written soon, it │ │ │ -00043a30: 2773 2070 726f 6261 626c 7920 6e6f 7420 's probably not │ │ │ -00043a40: 7468 6174 2062 6967 206f 6620 6120 6465 that big of a de │ │ │ -00043a50: 616c 3c2f 7464 3e3c 2f74 723e 3c74 7220 al

    │ │ │ -00043aa0: 7768 6174 2064 6f20 7765 2064 6f20 6966 what do we do if │ │ │ -00043ab0: 2073 6f6d 656f 6e65 2069 7320 6375 7272 someone is curr │ │ │ -00043ac0: 656e 746c 7920 7265 6164 696e 6720 6672 ently reading fr │ │ │ -00043ad0: 6f6d 2074 6865 2064 6973 6b0a 6672 6f6d om the disk.from │ │ │ -00043ae0: 2074 6869 7320 7069 6563 653f 2064 6f65 this piece? doe │ │ │ -00043af0: 7320 6974 206d 6174 7465 723f 2053 696e s it matter? Sin │ │ │ -00043b00: 6365 2077 6520 776f 6e27 7420 6163 7469 ce we won't acti │ │ │ -00043b10: 7665 6c79 2065 7261 7365 2074 6865 0a64 vely erase the.d │ │ │ -00043b20: 6174 6120 6672 6f6d 2064 6973 6b2c 2062 ata from disk, b │ │ │ -00043b30: 7574 2069 7420 6d61 7920 6265 206f 7665 ut it may be ove │ │ │ -00043b40: 7277 7269 7474 656e 2073 6f6f 6e2c 2069 rwritten soon, i │ │ │ -00043b50: 7427 7320 7072 6f62 6162 6c79 206e 6f74 t's probably not │ │ │ -00043b60: 2074 6861 740a 6269 6720 6f66 2061 2064 that.big of a d │ │ │ -00043b70: 6561 6c3c 2f68 323e 3c68 343e 2e2e 2f73 eal

    ../s │ │ │ -00043b80: 7263 2f70 6f73 6978 5f70 6172 745f 6669 rc/posix_part_fi │ │ │ -00043b90: 6c65 2e63 7070 3a33 3136 3c2f 6834 3e3c le.cpp:316

    < │ │ │ -00043ba0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00043bb0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00043bc0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00043bd0: 7820 2364 6464 3b22 3e0a 0909 0969 6620 x #ddd;">....if │ │ │ -00043be0: 2865 6329 2072 6574 7572 6e20 7b7d 3b0a (ec) return {};. │ │ │ -00043bf0: 0a23 6966 6465 6620 544f 5252 454e 545f .#ifdef TORRENT_ │ │ │ -00043c00: 5749 4e44 4f57 530a 0909 0972 6574 203d WINDOWS....ret = │ │ │ -00043c10: 2066 696c 655f 706f 696e 7465 7228 3a3a file_pointer(:: │ │ │ -00043c20: 5f77 666f 7065 6e28 636f 6e76 6572 745f _wfopen(convert_ │ │ │ -00043c30: 746f 5f6e 6174 6976 655f 7061 7468 5f73 to_native_path_s │ │ │ -00043c40: 7472 696e 6728 666e 292e 635f 7374 7228 tring(fn).c_str( │ │ │ -00043c50: 292c 204c 2277 622b 2229 293b 0a23 656c ), L"wb+"));.#el │ │ │ -00043c60: 7365 0a09 0909 7265 7420 3d20 6669 6c65 se....ret = file │ │ │ -00043c70: 5f70 6f69 6e74 6572 283a 3a66 6f70 656e _pointer(::fopen │ │ │ -00043c80: 2866 6e2e 635f 7374 7228 292c 2022 7762 (fn.c_str(), "wb │ │ │ -00043c90: 2b22 2929 3b0a 2365 6e64 6966 0a09 0909 +"));.#endif.... │ │ │ -00043ca0: 6966 2028 7265 742e 6669 6c65 2829 203d if (ret.file() = │ │ │ -00043cb0: 3d20 6e75 6c6c 7074 7229 0a09 0909 0965 = nullptr).....e │ │ │ -00043cc0: 632e 6173 7369 676e 2865 7272 6e6f 2c20 c.assign(errno, │ │ │ -00043cd0: 6765 6e65 7269 635f 6361 7465 676f 7279 generic_category │ │ │ -00043ce0: 2829 293b 0a09 097d 0a09 0969 6620 2865 ());...}...if (e │ │ │ -00043cf0: 6329 2072 6574 7572 6e20 7b7d 3b0a 0909 c) return {};... │ │ │ -00043d00: 7265 7475 726e 2072 6574 3b0a 097d 0a0a return ret;..}.. │ │ │ -00043d10: 0976 6f69 6420 706f 7369 785f 7061 7274 .void posix_part │ │ │ -00043d20: 5f66 696c 653a 3a66 7265 655f 7069 6563 _file::free_piec │ │ │ -00043d30: 6528 7069 6563 655f 696e 6465 785f 7420 e(piece_index_t │ │ │ -00043d40: 636f 6e73 7420 7069 6563 6529 0a09 7b0a const piece)..{. │ │ │ -00043d50: 0909 6175 746f 2063 6f6e 7374 2069 203d ..auto const i = │ │ │ -00043d60: 206d 5f70 6965 6365 5f6d 6170 2e66 696e m_piece_map.fin │ │ │ -00043d70: 6428 7069 6563 6529 3b0a 0909 6966 2028 d(piece);...if ( │ │ │ -00043d80: 6920 3d3d 206d 5f70 6965 6365 5f6d 6170 i == m_piece_map │ │ │ -00043d90: 2e65 6e64 2829 2920 7265 7475 726e 3b0a .end()) return;. │ │ │ -00043da0: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ -00043dd0: 3c2f 6469 763e 0909 6d5f 6672 6565 5f73
    ..m_free_s │ │ │ -00043de0: 6c6f 7473 2e70 7573 685f 6261 636b 2869 lots.push_back(i │ │ │ -00043df0: 2d26 6774 3b73 6563 6f6e 6429 3b0a 0909 ->second);... │ │ │ -00043e00: 6d5f 7069 6563 655f 6d61 702e 6572 6173 m_piece_map.eras │ │ │ -00043e10: 6528 6929 3b0a 0909 6d5f 6469 7274 795f e(i);...m_dirty_ │ │ │ -00043e20: 6d65 7461 6461 7461 203d 2074 7275 653b metadata = true; │ │ │ -00043e30: 0a09 7d0a 0a09 766f 6964 2070 6f73 6978 ..}...void posix │ │ │ -00043e40: 5f70 6172 745f 6669 6c65 3a3a 6d6f 7665 _part_file::move │ │ │ -00043e50: 5f70 6172 7466 696c 6528 7374 643a 3a73 _partfile(std::s │ │ │ -00043e60: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ -00043e70: 2070 6174 682c 2065 7272 6f72 5f63 6f64 path, error_cod │ │ │ -00043e80: 6526 616d 703b 2065 6329 0a09 7b0a 0909 e& ec)..{... │ │ │ -00043e90: 666c 7573 685f 6d65 7461 6461 7461 5f69 flush_metadata_i │ │ │ -00043ea0: 6d70 6c28 6563 293b 0a09 0969 6620 2865 mpl(ec);...if (e │ │ │ -00043eb0: 6329 2072 6574 7572 6e3b 0a0a 0909 6966 c) return;....if │ │ │ -00043ec0: 2028 216d 5f70 6965 6365 5f6d 6170 2e65 (!m_piece_map.e │ │ │ -00043ed0: 6d70 7479 2829 290a 0909 7b0a 0909 0973 mpty())...{....s │ │ │ -00043ee0: 7464 3a3a 7374 7269 6e67 206f 6c64 5f70 td::string old_p │ │ │ -00043ef0: 6174 6820 3d20 636f 6d62 696e 655f 7061 ath = combine_pa │ │ │ -00043f00: 7468 286d 5f70 6174 682c 206d 5f6e 616d th(m_path, m_nam │ │ │ -00043f10: 6529 3b0a 0909 0973 7464 3a3a 7374 7269 e);....std::stri │ │ │ -00043f20: 6e67 206e 6577 5f70 6174 6820 3d20 636f ng new_path = co │ │ │ -00043f30: 6d62 696e 655f 7061 7468 2870 6174 682c mbine_path(path, │ │ │ -00043f40: 206d 5f6e 616d 6529 3b0a 0a09 0909 7265 m_name);.....re │ │ │ -00043f50: 6e61 6d65 286f 6c64 5f70 6174 682c 206e name(old_path, n │ │ │ -00043f60: 6577 5f70 6174 682c 2065 6329 3b0a 0909 ew_path, ec);... │ │ │ -00043f70: 0969 6620 2865 6320 3d3d 2062 6f6f 7374 .if (ec == boost │ │ │ -00043f80: 3a3a 7379 7374 656d 3a3a 6572 7263 3a3a ::system::errc:: │ │ │ -00043f90: 6e6f 5f73 7563 685f 6669 6c65 5f6f 725f no_such_file_or_ │ │ │ -00043fa0: 6469 7265 6374 6f72 7929 0a09 0909 0965 directory).....e │ │ │ -00043fb0: 632e 636c 6561 7228 293b 0a0a 0909 0969 c.clear();.....i │ │ │ -00043fc0: 6620 2865 6329 0a09 0909 7b0a 0909 0909 f (ec)....{..... │ │ │ -00043fd0: 7374 6f72 6167 655f 6572 726f 7220 7365 storage_error se │ │ │ -00043fe0: 3b0a 0909 0909 6175 783a 3a63 6f70 795f ;.....aux::copy_ │ │ │ -00043ff0: 6669 6c65 286f 6c64 5f70 6174 682c 206e file(old_path, n │ │ │ -00044000: 6577 5f70 6174 682c 2073 6529 3b0a 0909 ew_path, se);... │ │ │ -00044010: 0909 6563 203d 2073 652e 6563 3b0a 0909 ..ec = se.ec;... │ │ │ -00044020: 0909 6966 2028 6563 2920 7265 7475 726e ..if (ec) return │ │ │ -00044030: 3b0a 0909 0909 7265 6d6f 7665 286f 6c64 ;.....remove(old │ │ │ -00044040: 5f70 6174 682c 2065 6329 3b0a 0909 097d _path, ec);....} │ │ │ -00044050: 0a09 097d 0a09 096d 5f70 6174 6820 3d20 ...}...m_path = │ │ │ -00044060: 7061 7468 3b0a 097d 0a3c 2f70 7265 3e3c path;..}.< │ │ │ -00044070: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000440a0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000440b0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/posix │ │ │ -000440e0: 5f70 6172 745f 6669 6c65 2e63 7070 3a34 _part_file.cpp:4 │ │ │ -000440f0: 3038 3c2f 613e 3c2f 7464 3e3c 7464 3e69 08i │ │ │ -00044100: 6e73 7465 6164 206f 6620 7265 6275 696c nstead of rebuil │ │ │ -00044110: 6469 6e67 2074 6865 2077 686f 6c65 2066 ding the whole f │ │ │ -00044120: 696c 6520 6865 6164 6572 2061 6e64 2066 ile header and f │ │ │ -00044130: 6c75 7368 696e 6720 6974 2c20 7570 6461 lushing it, upda │ │ │ -00044140: 7465 2074 6865 2073 6c6f 7420 656e 7472 te the slot entr │ │ │ -00044150: 6965 7320 6173 2077 6520 676f 3c2f 7464 ies as we go

    instea │ │ │ -000441b0: 6420 6f66 2072 6562 7569 6c64 696e 6720 d of rebuilding │ │ │ -000441c0: 7468 6520 7768 6f6c 6520 6669 6c65 2068 the whole file h │ │ │ -000441d0: 6561 6465 720a 616e 6420 666c 7573 6869 eader.and flushi │ │ │ -000441e0: 6e67 2069 742c 2075 7064 6174 6520 7468 ng it, update th │ │ │ -000441f0: 6520 736c 6f74 2065 6e74 7269 6573 2061 e slot entries a │ │ │ -00044200: 7320 7765 2067 6f3c 2f68 323e 3c68 343e s we go

    │ │ │ -00044210: 2e2e 2f73 7263 2f70 6f73 6978 5f70 6172 ../src/posix_par │ │ │ -00044220: 745f 6669 6c65 2e63 7070 3a34 3038 3c2f t_file.cpp:408
    ...
    │ │ │ -00044270: 0909 0965 632e 6173 7369 676e 2865 7272  ...ec.assign(err
    │ │ │ -00044280: 6e6f 2c20 6765 6e65 7269 635f 6361 7465  no, generic_cate
    │ │ │ -00044290: 676f 7279 2829 293b 0a09 0909 0909 656c  gory());......el
    │ │ │ -000442a0: 7365 0a09 0909 0909 0965 632e 6173 7369  se.......ec.assi
    │ │ │ -000442b0: 676e 2865 7272 6f72 733a 3a66 696c 655f  gn(errors::file_
    │ │ │ -000442c0: 746f 6f5f 7368 6f72 742c 206c 6962 746f  too_short, libto
    │ │ │ -000442d0: 7272 656e 745f 6361 7465 676f 7279 2829  rrent_category()
    │ │ │ -000442e0: 293b 0a09 0909 097d 0a0a 0909 0909 6966  );.....}......if
    │ │ │ -000442f0: 2028 6563 2920 7265 7475 726e 3b0a 0a09   (ec) return;...
    │ │ │ -00044300: 0909 0966 2866 696c 655f 6f66 6673 6574  ...f(file_offset
    │ │ │ -00044310: 2c20 7b62 7566 2e67 6574 2829 2c20 626c  , {buf.get(), bl
    │ │ │ -00044320: 6f63 6b5f 746f 5f63 6f70 797d 293b 0a09  ock_to_copy});..
    │ │ │ -00044330: 0909 7d0a 0909 0966 696c 655f 6f66 6673  ..}....file_offs
    │ │ │ -00044340: 6574 202b 3d20 626c 6f63 6b5f 746f 5f63  et += block_to_c
    │ │ │ -00044350: 6f70 793b 0a09 0909 7069 6563 655f 6f66  opy;....piece_of
    │ │ │ -00044360: 6673 6574 203d 2030 3b0a 0909 0973 697a  fset = 0;....siz
    │ │ │ -00044370: 6520 2d3d 2062 6c6f 636b 5f74 6f5f 636f  e -= block_to_co
    │ │ │ -00044380: 7079 3b0a 0909 7d0a 097d 0a0a 0976 6f69  py;...}..}...voi
    │ │ │ -00044390: 6420 706f 7369 785f 7061 7274 5f66 696c  d posix_part_fil
    │ │ │ -000443a0: 653a 3a66 6c75 7368 5f6d 6574 6164 6174  e::flush_metadat
    │ │ │ -000443b0: 6128 6572 726f 725f 636f 6465 2661 6d70  a(error_code&
    │ │ │ -000443c0: 3b20 6563 290a 097b 0a09 0966 6c75 7368  ; ec)..{...flush
    │ │ │ -000443d0: 5f6d 6574 6164 6174 615f 696d 706c 2865  _metadata_impl(e
    │ │ │ -000443e0: 6329 3b0a 097d 0a0a 3c64 6976 2073 7479  c);..}..
    .void posi │ │ │ -00044420: 785f 7061 7274 5f66 696c 653a 3a66 6c75 x_part_file::flu │ │ │ -00044430: 7368 5f6d 6574 6164 6174 615f 696d 706c sh_metadata_impl │ │ │ -00044440: 2865 7272 6f72 5f63 6f64 6526 616d 703b (error_code& │ │ │ -00044450: 2065 6329 0a3c 2f64 6976 3e09 7b0a 0909 ec).
    .{... │ │ │ -00044460: 2f2f 2064 6f20 7765 206e 6565 6420 746f // do we need to │ │ │ -00044470: 2066 6c75 7368 2074 6865 206d 6574 6164 flush the metad │ │ │ -00044480: 6174 613f 0a09 0969 6620 286d 5f64 6972 ata?...if (m_dir │ │ │ -00044490: 7479 5f6d 6574 6164 6174 6120 3d3d 2066 ty_metadata == f │ │ │ -000444a0: 616c 7365 2920 7265 7475 726e 3b0a 0a09 alse) return;... │ │ │ -000444b0: 0969 6620 286d 5f70 6965 6365 5f6d 6170 .if (m_piece_map │ │ │ -000444c0: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ -000444d0: 092f 2f20 6966 2077 6520 646f 6e27 7420 .// if we don't │ │ │ -000444e0: 6861 7665 2061 6e79 2070 6965 6365 7320 have any pieces │ │ │ -000444f0: 6c65 6674 2069 6e20 7468 650a 0909 092f left in the..../ │ │ │ -00044500: 2f20 7061 7274 2066 696c 652c 2072 656d / part file, rem │ │ │ -00044510: 6f76 6520 6974 0a09 0909 7374 643a 3a73 ove it....std::s │ │ │ -00044520: 7472 696e 6720 636f 6e73 7420 7020 3d20 tring const p = │ │ │ -00044530: 636f 6d62 696e 655f 7061 7468 286d 5f70 combine_path(m_p │ │ │ -00044540: 6174 682c 206d 5f6e 616d 6529 3b0a 0909 ath, m_name);... │ │ │ -00044550: 0972 656d 6f76 6528 702c 2065 6329 3b0a .remove(p, ec);. │ │ │ -00044560: 0a09 0909 6966 2028 6563 203d 3d20 626f ....if (ec == bo │ │ │ -00044570: 6f73 743a 3a73 7973 7465 6d3a 3a65 7272 ost::system::err │ │ │ -00044580: 633a 3a6e 6f5f 7375 6368 5f66 696c 655f c::no_such_file_ │ │ │ -00044590: 6f72 5f64 6972 6563 746f 7279 290a 0909 or_directory)... │ │ │ -000445a0: 0909 6563 2e63 6c65 6172 2829 3b0a 0909 ..ec.clear();... │ │ │ -000445b0: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909 .return;...}.... │ │ │ -000445c0: 6175 746f 2066 203d 206f 7065 6e5f 6669 auto f = open_fi │ │ │ -000445d0: 6c65 286f 7065 6e5f 6d6f 6465 3a3a 7265 le(open_mode::re │ │ │ -000445e0: 6164 5f77 7269 7465 2c20 6563 293b 0a09 ad_write, ec);.. │ │ │ -000445f0: 0969 6620 2865 6329 2072 6574 7572 6e3b .if (ec) return; │ │ │ -00044600: 0a0a 0909 7374 643a 3a76 6563 746f 7226 ....std::vector& │ │ │ -00044610: 6c74 3b63 6861 7226 6774 3b20 6865 6164 lt;char> head │ │ │ -00044620: 6572 2873 7461 7469 635f 6361 7374 266c er(static_cast&l │ │ │ -00044630: 743b 7374 643a 3a73 697a 655f 7426 6774 t;std::size_t> │ │ │ -00044640: 3b28 6d5f 6865 6164 6572 5f73 697a 6529 ;(m_header_size) │ │ │ -00044650: 293b 0a0a 0909 7573 696e 6720 6e61 6d65 );....using name │ │ │ -00044660: 7370 6163 6520 6c69 6274 6f72 7265 6e74 space libtorrent │ │ │ -00044670: 3a3a 6175 783b 0a0a 0909 6368 6172 2a20 ::aux;....char* │ │ │ -00044680: 7074 7220 3d20 6865 6164 6572 2e64 6174 ptr = header.dat │ │ │ -00044690: 6128 293b 0a09 0977 7269 7465 5f75 696e a();...write_uin │ │ │ -000446a0: 7433 3228 6d5f 6d61 785f 7069 6563 6573 t32(m_max_pieces │ │ │ -000446b0: 2c20 7074 7229 3b0a 0909 7772 6974 655f , ptr);...write_ │ │ │ -000446c0: 7569 6e74 3332 286d 5f70 6965 6365 5f73 uint32(m_piece_s │ │ │ -000446d0: 697a 652c 2070 7472 293b 0a0a 0909 666f ize, ptr);....fo │ │ │ -000446e0: 7220 2870 6965 6365 5f69 6e64 6578 5f74 r (piece_index_t │ │ │ -000446f0: 2070 6965 6365 2830 293b 2070 6965 6365 piece(0); piece │ │ │ -00044700: 2026 6c74 3b20 7069 6563 655f 696e 6465 < piece_inde │ │ │ -00044710: 785f 7428 6d5f 6d61 785f 7069 6563 6573 x_t(m_max_pieces │ │ │ -00044720: 293b 202b 2b70 6965 6365 290a 0909 7b0a ); ++piece)...{. │ │ │ -00044730: 0909 0961 7574 6f20 636f 6e73 7420 6920 ...auto const i │ │ │ -00044740: 3d20 6d5f 7069 6563 655f 6d61 702e 6669 = m_piece_map.fi │ │ │ -00044750: 6e64 2870 6965 6365 293b 0a3c 2f70 7265 nd(piece);.
    rele │ │ │ -00044790: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/fil │ │ │ -000447d0: 655f 7374 6f72 6167 652e 6370 703a 3132 e_storage.cpp:12 │ │ │ -000447e0: 393c 2f61 3e3c 2f74 643e 3c74 643e 6174 9at │ │ │ -000447f0: 2061 7070 6561 7273 2073 6574 5f6e 616d appears set_nam │ │ │ -00044800: 6520 6973 2061 6c77 6179 7320 7472 7565 e is always true │ │ │ -00044810: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    at │ │ │ -00044860: 2061 7070 6561 7273 2073 6574 5f6e 616d appears set_nam │ │ │ -00044870: 6520 6973 2061 6c77 6179 7320 7472 7565 e is always true │ │ │ -00044880: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00044890: 6669 6c65 5f73 746f 7261 6765 2e63 7070 file_storage.cpp │ │ │ -000448a0: 3a31 3239 3c2f 6834 3e3c 7072 6520 7374 :129

    ..return stat
    │ │ │ -000448f0: 6963 5f63 6173 7426 6c74 3b69 6e74 2667  ic_cast<int&g
    │ │ │ -00044900: 743b 280a 0909 0973 7464 3a3a 6d69 6e28  t;(....std::min(
    │ │ │ -00044910: 7374 6174 6963 5f63 6173 7426 6c74 3b73  static_cast<s
    │ │ │ -00044920: 7464 3a3a 7569 6e74 3634 5f74 2667 743b  td::uint64_t>
    │ │ │ -00044930: 2870 6965 6365 5f6c 656e 6774 6828 2929  (piece_length())
    │ │ │ -00044940: 2c20 6669 6c65 5f69 7465 722d 2667 743b  , file_iter->
    │ │ │ -00044950: 6f66 6673 6574 202d 2074 6172 6765 742e  offset - target.
    │ │ │ -00044960: 6f66 6673 6574 2929 3b0a 097d 0a0a 0969  offset));..}...i
    │ │ │ -00044970: 6e74 2066 696c 655f 7374 6f72 6167 653a  nt file_storage:
    │ │ │ -00044980: 3a62 6c6f 636b 735f 696e 5f70 6965 6365  :blocks_in_piece
    │ │ │ -00044990: 3228 7069 6563 655f 696e 6465 785f 7420  2(piece_index_t 
    │ │ │ -000449a0: 636f 6e73 7420 696e 6465 7829 2063 6f6e  const index) con
    │ │ │ -000449b0: 7374 0a09 7b0a 0909 2f2f 2074 6865 206e  st..{...// the n
    │ │ │ -000449c0: 756d 6265 7220 6f66 2064 6566 6175 6c74  umber of default
    │ │ │ -000449d0: 5f62 6c6f 636b 5f73 697a 6520 696e 2061  _block_size in a
    │ │ │ -000449e0: 2070 6965 6365 2073 697a 652c 2072 6f75   piece size, rou
    │ │ │ -000449f0: 6e64 696e 6720 7570 0a09 0972 6574 7572  nding up...retur
    │ │ │ -00044a00: 6e20 2870 6965 6365 5f73 697a 6532 2869  n (piece_size2(i
    │ │ │ -00044a10: 6e64 6578 2920 2b20 6465 6661 756c 745f  ndex) + default_
    │ │ │ -00044a20: 626c 6f63 6b5f 7369 7a65 202d 2031 2920  block_size - 1) 
    │ │ │ -00044a30: 2f20 6465 6661 756c 745f 626c 6f63 6b5f  / default_block_
    │ │ │ -00044a40: 7369 7a65 3b0a 097d 0a0a 0969 6e74 2066  size;..}...int f
    │ │ │ -00044a50: 696c 655f 7374 6f72 6167 653a 3a62 6c6f  ile_storage::blo
    │ │ │ -00044a60: 636b 735f 7065 725f 7069 6563 6528 2920  cks_per_piece() 
    │ │ │ -00044a70: 636f 6e73 740a 097b 0a09 0972 6574 7572  const..{...retur
    │ │ │ -00044a80: 6e20 286d 5f70 6965 6365 5f6c 656e 6774  n (m_piece_lengt
    │ │ │ -00044a90: 6820 2b20 6465 6661 756c 745f 626c 6f63  h + default_bloc
    │ │ │ -00044aa0: 6b5f 7369 7a65 202d 2031 2920 2f20 6465  k_size - 1) / de
    │ │ │ -00044ab0: 6661 756c 745f 626c 6f63 6b5f 7369 7a65  fault_block_size
    │ │ │ -00044ac0: 3b0a 097d 0a0a 092f 2f20 7061 7468 2069  ;..}...// path i
    │ │ │ -00044ad0: 7320 7375 7070 6f73 6564 2074 6f20 696e  s supposed to in
    │ │ │ -00044ae0: 636c 7564 6520 7468 6520 6e61 6d65 206f  clude the name o
    │ │ │ -00044af0: 6620 7468 6520 746f 7272 656e 7420 6974  f the torrent it
    │ │ │ -00044b00: 7365 6c66 2e0a 092f 2f20 6f72 2061 6e20  self...// or an 
    │ │ │ -00044b10: 6162 736f 6c75 7465 2070 6174 682c 2074  absolute path, t
    │ │ │ -00044b20: 6f20 6d6f 7665 2061 2066 696c 6520 6f75  o move a file ou
    │ │ │ -00044b30: 7473 6964 6520 6f66 2074 6865 2064 6f77  tside of the dow
    │ │ │ -00044b40: 6e6c 6f61 6420 6469 7265 6374 6f72 790a  nload directory.
    │ │ │ -00044b50: 0976 6f69 6420 6669 6c65 5f73 746f 7261  .void file_stora
    │ │ │ -00044b60: 6765 3a3a 7570 6461 7465 5f70 6174 685f  ge::update_path_
    │ │ │ -00044b70: 696e 6465 7828 6175 783a 3a66 696c 655f  index(aux::file_
    │ │ │ -00044b80: 656e 7472 7926 616d 703b 2065 0a09 092c  entry& e...,
    │ │ │ -00044b90: 2073 7464 3a3a 7374 7269 6e67 2063 6f6e   std::string con
    │ │ │ -00044ba0: 7374 2661 6d70 3b20 7061 7468 2c20 626f  st& path, bo
    │ │ │ -00044bb0: 6f6c 2063 6f6e 7374 2073 6574 5f6e 616d  ol const set_nam
    │ │ │ -00044bc0: 6529 0a09 7b0a 3c64 6976 2073 7479 6c65  e)..{.
    ..if (is_com │ │ │ -00044c00: 706c 6574 6528 7061 7468 2929 0a3c 2f64 plete(path))...{....TORREN │ │ │ -00044c20: 545f 4153 5345 5254 2873 6574 5f6e 616d T_ASSERT(set_nam │ │ │ -00044c30: 6529 3b0a 0909 0965 2e73 6574 5f6e 616d e);....e.set_nam │ │ │ -00044c40: 6528 7061 7468 293b 0a09 0909 652e 7061 e(path);....e.pa │ │ │ -00044c50: 7468 5f69 6e64 6578 203d 2061 7578 3a3a th_index = aux:: │ │ │ -00044c60: 6669 6c65 5f65 6e74 7279 3a3a 7061 7468 file_entry::path │ │ │ -00044c70: 5f69 735f 6162 736f 6c75 7465 3b0a 0909 _is_absolute;... │ │ │ -00044c80: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909 .return;...}.... │ │ │ -00044c90: 544f 5252 454e 545f 4153 5345 5254 2870 TORRENT_ASSERT(p │ │ │ -00044ca0: 6174 685b 305d 2021 3d20 272f 2729 3b0a ath[0] != '/');. │ │ │ -00044cb0: 0a09 092f 2f20 7370 6c69 7420 7468 6520 ...// split the │ │ │ -00044cc0: 7374 7269 6e67 2069 6e74 6f20 7468 6520 string into the │ │ │ -00044cd0: 6c65 6166 2066 696c 656e 616d 650a 0909 leaf filename... │ │ │ -00044ce0: 2f2f 2061 6e64 2074 6865 2062 7261 6e63 // and the branc │ │ │ -00044cf0: 6820 7061 7468 0a09 0961 7574 6f20 5b62 h path...auto [b │ │ │ -00044d00: 7261 6e63 685f 7061 7468 2c20 6c65 6166 ranch_path, leaf │ │ │ -00044d10: 5d20 3d20 7273 706c 6974 5f70 6174 6828 ] = rsplit_path( │ │ │ -00044d20: 7061 7468 293b 0a0a 0909 6966 2028 6272 path);....if (br │ │ │ -00044d30: 616e 6368 5f70 6174 682e 656d 7074 7928 anch_path.empty( │ │ │ -00044d40: 2929 0a09 097b 0a09 0909 6966 2028 7365 ))...{....if (se │ │ │ -00044d50: 745f 6e61 6d65 2920 652e 7365 745f 6e61 t_name) e.set_na │ │ │ -00044d60: 6d65 286c 6561 6629 3b0a 0909 0965 2e70 me(leaf);....e.p │ │ │ -00044d70: 6174 685f 696e 6465 7820 3d20 6175 783a ath_index = aux: │ │ │ -00044d80: 3a66 696c 655f 656e 7472 793a 3a6e 6f5f :file_entry::no_ │ │ │ -00044d90: 7061 7468 3b0a 0909 0972 6574 7572 6e3b path;....return; │ │ │ -00044da0: 0a09 097d 0a0a 0909 2f2f 2069 6620 7468 ...}....// if th │ │ │ -00044db0: 6520 7061 7468 202a 646f 6573 2a20 636f e path *does* co │ │ │ -00044dc0: 6e74 6169 6e20 7468 6520 6e61 6d65 206f ntain the name o │ │ │ -00044dd0: 6620 7468 6520 746f 7272 656e 7420 2861 f the torrent (a │ │ │ -00044de0: 7320 7765 2065 7870 6563 7429 0a09 092f s we expect).../ │ │ │ -00044df0: 2f20 7374 7269 7020 6974 2062 6566 6f72 / strip it befor │ │ │ -00044e00: 6520 6164 6469 6e67 2069 7420 746f 206d e adding it to m │ │ │ -00044e10: 5f70 6174 6873 0a09 0969 6620 286c 7370 _paths...if (lsp │ │ │ -00044e20: 6c69 745f 7061 7468 2862 7261 6e63 685f lit_path(branch_ │ │ │ -00044e30: 7061 7468 292e 6669 7273 7420 3d3d 206d path).first == m │ │ │ -00044e40: 5f6e 616d 6529 0a09 097b 0a09 0909 6272 _name)...{....br │ │ │ -00044e50: 616e 6368 5f70 6174 6820 3d20 6c73 706c anch_path = lspl │ │ │ -00044e60: 6974 5f70 6174 6828 6272 616e 6368 5f70 it_path(branch_p │ │ │ -00044e70: 6174 6829 2e73 6563 6f6e 643b 0a09 0909 ath).second;.... │ │ │ -00044e80: 2f2f 2073 7472 6970 2064 7570 6c69 6361 // strip duplica │ │ │ -00044e90: 7465 2073 6570 6172 6174 6f72 730a 0909 te separators... │ │ │ -00044ea0: 0977 6869 6c65 2028 2162 7261 6e63 685f .while (!branch_ │ │ │ -00044eb0: 7061 7468 2e65 6d70 7479 2829 2026 616d path.empty() &am │ │ │ -00044ec0: 703b 2661 6d70 3b20 2862 7261 6e63 685f p;& (branch_ │ │ │ -00044ed0: 7061 7468 2e66 726f 6e74 2829 203d 3d20 path.front() == │ │ │ -00044ee0: 544f 5252 454e 545f 5345 5041 5241 544f TORRENT_SEPARATO │ │ │ -00044ef0: 520a 2369 6620 6465 6669 6e65 6428 544f R.#if defined(TO │ │ │ -00044f00: 5252 454e 545f 5749 4e44 4f57 5329 207c RRENT_WINDOWS) | │ │ │ -00044f10: 7c20 6465 6669 6e65 6428 544f 5252 454e | defined(TORREN │ │ │ -00044f20: 545f 4f53 3229 0a09 0909 097c 7c20 6272 T_OS2).....|| br │ │ │ -00044f30: 616e 6368 5f70 6174 682e 6672 6f6e 7428 anch_path.front( │ │ │ -00044f40: 2920 3d3d 2027 2f27 0a23 656e 6469 660a ) == '/'.#endif. │ │ │ -00044f50: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00044f60: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00044f90: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00044fc0: 632f 6669 6c65 5f73 746f 7261 6765 2e63 c/file_storage.c │ │ │ -00044fd0: 7070 3a35 3632 3c2f 613e 3c2f 7464 3e3c pp:562< │ │ │ -00044fe0: 7464 3e6d 6179 6265 2069 7420 776f 756c td>maybe it woul │ │ │ -00044ff0: 6420 6265 206e 6963 6520 746f 2068 6176 d be nice to hav │ │ │ -00045000: 6520 6120 6265 7474 6572 2069 6e64 6578 e a better index │ │ │ -00045010: 2068 6572 653c 2f74 643e 3c2f 7472 3e3c here< │ │ │ -00045020: 7472 2069 643d 2231 3731 2220 7374 796c tr id="171" styl │ │ │ -00045030: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00045040: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00045050: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00045060: 6832 3e6d 6179 6265 2069 7420 776f 756c h2>maybe it woul │ │ │ -00045070: 6420 6265 206e 6963 6520 746f 2068 6176 d be nice to hav │ │ │ -00045080: 6520 6120 6265 7474 6572 2069 6e64 6578 e a better index │ │ │ -00045090: 2068 6572 653c 2f68 323e 3c68 343e 2e2e here

    .. │ │ │ -000450a0: 2f73 7263 2f66 696c 655f 7374 6f72 6167 /src/file_storag │ │ │ -000450b0: 652e 6370 703a 3536 323c 2f68 343e 3c70 e.cpp:562

    ..auto f │ │ │ -00045100: 696c 655f 6974 6572 203d 2073 7464 3a3a ile_iter = std:: │ │ │ -00045110: 7570 7065 725f 626f 756e 6428 0a09 0909 upper_bound(.... │ │ │ -00045120: 6d5f 6669 6c65 732e 6265 6769 6e28 292c m_files.begin(), │ │ │ -00045130: 206d 5f66 696c 6573 2e65 6e64 2829 2c20 m_files.end(), │ │ │ -00045140: 7461 7267 6574 2c20 636f 6d70 6172 655f target, compare_ │ │ │ -00045150: 6669 6c65 5f6f 6666 7365 7429 3b0a 0a09 file_offset);... │ │ │ -00045160: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -00045170: 6669 6c65 5f69 7465 7220 213d 206d 5f66 file_iter != m_f │ │ │ -00045180: 696c 6573 2e62 6567 696e 2829 293b 0a09 iles.begin());.. │ │ │ -00045190: 092d 2d66 696c 655f 6974 6572 3b0a 0909 .--file_iter;... │ │ │ -000451a0: 7265 7475 726e 2066 696c 655f 696e 6465 return file_inde │ │ │ -000451b0: 785f 747b 696e 7428 6669 6c65 5f69 7465 x_t{int(file_ite │ │ │ -000451c0: 7220 2d20 6d5f 6669 6c65 732e 6265 6769 r - m_files.begi │ │ │ -000451d0: 6e28 2929 7d3b 0a09 7d0a 0a09 6669 6c65 n())};..}...file │ │ │ -000451e0: 5f69 6e64 6578 5f74 2066 696c 655f 7374 _index_t file_st │ │ │ -000451f0: 6f72 6167 653a 3a66 696c 655f 696e 6465 orage::file_inde │ │ │ -00045200: 785f 6174 5f70 6965 6365 2870 6965 6365 x_at_piece(piece │ │ │ -00045210: 5f69 6e64 6578 5f74 2063 6f6e 7374 2070 _index_t const p │ │ │ -00045220: 6965 6365 2920 636f 6e73 740a 097b 0a09 iece) const..{.. │ │ │ -00045230: 0972 6574 7572 6e20 6669 6c65 5f69 6e64 .return file_ind │ │ │ -00045240: 6578 5f61 745f 6f66 6673 6574 2873 7461 ex_at_offset(sta │ │ │ -00045250: 7469 635f 6361 7374 266c 743b 696e 7426 tic_cast<int& │ │ │ -00045260: 6774 3b28 7069 6563 6529 202a 2073 7464 gt;(piece) * std │ │ │ -00045270: 3a3a 696e 7436 345f 7428 7069 6563 655f ::int64_t(piece_ │ │ │ -00045280: 6c65 6e67 7468 2829 2929 3b0a 097d 0a0a length()));..}.. │ │ │ -00045290: 0966 696c 655f 696e 6465 785f 7420 6669 .file_index_t fi │ │ │ -000452a0: 6c65 5f73 746f 7261 6765 3a3a 6c61 7374 le_storage::last │ │ │ -000452b0: 5f66 696c 655f 696e 6465 785f 6174 5f70 _file_index_at_p │ │ │ -000452c0: 6965 6365 2870 6965 6365 5f69 6e64 6578 iece(piece_index │ │ │ -000452d0: 5f74 2063 6f6e 7374 2070 6965 6365 2920 _t const piece) │ │ │ -000452e0: 636f 6e73 740a 097b 0a09 0972 6574 7572 const..{...retur │ │ │ -000452f0: 6e20 6669 6c65 5f69 6e64 6578 5f61 745f n file_index_at_ │ │ │ -00045300: 6f66 6673 6574 2873 7461 7469 635f 6361 offset(static_ca │ │ │ -00045310: 7374 266c 743b 696e 7426 6774 3b28 7069 st<int>(pi │ │ │ -00045320: 6563 6529 202a 2073 7464 3a3a 696e 7436 ece) * std::int6 │ │ │ -00045330: 345f 7428 7069 6563 655f 6c65 6e67 7468 4_t(piece_length │ │ │ -00045340: 2829 2920 2b20 7069 6563 655f 7369 7a65 ()) + piece_size │ │ │ -00045350: 2870 6965 6365 2920 2d20 3129 3b0a 097d (piece) - 1);..} │ │ │ -00045360: 0a0a 0966 696c 655f 696e 6465 785f 7420 ...file_index_t │ │ │ -00045370: 6669 6c65 5f73 746f 7261 6765 3a3a 6669 file_storage::fi │ │ │ -00045380: 6c65 5f69 6e64 6578 5f66 6f72 5f72 6f6f le_index_for_roo │ │ │ -00045390: 7428 7368 6132 3536 5f68 6173 6820 636f t(sha256_hash co │ │ │ -000453a0: 6e73 7426 616d 703b 2072 6f6f 745f 6861 nst& root_ha │ │ │ -000453b0: 7368 2920 636f 6e73 740a 097b 0a3c 6469 sh) const..{...for │ │ │ -000453f0: 2028 6669 6c65 5f69 6e64 6578 5f74 2063 (file_index_t c │ │ │ -00045400: 6f6e 7374 2069 203a 2066 696c 655f 7261 onst i : file_ra │ │ │ -00045410: 6e67 6528 2929 0a3c 2f64 6976 3e09 097b nge()).

    ..{ │ │ │ -00045420: 0a09 0909 6966 2028 726f 6f74 2869 2920 ....if (root(i) │ │ │ -00045430: 3d3d 2072 6f6f 745f 6861 7368 2920 7265 == root_hash) re │ │ │ -00045440: 7475 726e 2069 3b0a 0909 7d0a 0909 7265 turn i;...}...re │ │ │ -00045450: 7475 726e 2066 696c 655f 696e 6465 785f turn file_index_ │ │ │ -00045460: 747b 2d31 7d3b 0a09 7d0a 0a09 7069 6563 t{-1};..}...piec │ │ │ -00045470: 655f 696e 6465 785f 7420 6669 6c65 5f73 e_index_t file_s │ │ │ -00045480: 746f 7261 6765 3a3a 7069 6563 655f 696e torage::piece_in │ │ │ -00045490: 6465 785f 6174 5f66 696c 6528 6669 6c65 dex_at_file(file │ │ │ -000454a0: 5f69 6e64 6578 5f74 2066 2920 636f 6e73 _index_t f) cons │ │ │ -000454b0: 740a 097b 0a09 0972 6574 7572 6e20 7069 t..{...return pi │ │ │ -000454c0: 6563 655f 696e 6465 785f 747b 6175 783a ece_index_t{aux: │ │ │ -000454d0: 3a6e 756d 6572 6963 5f63 6173 7426 6c74 :numeric_cast< │ │ │ -000454e0: 3b69 6e74 2667 743b 2866 696c 655f 6f66 ;int>(file_of │ │ │ -000454f0: 6673 6574 2866 2920 2f20 7069 6563 655f fset(f) / piece_ │ │ │ -00045500: 6c65 6e67 7468 2829 297d 3b0a 097d 0a0a length())};..}.. │ │ │ -00045510: 0970 6965 6365 5f69 6e64 6578 5f74 2066 .piece_index_t f │ │ │ -00045520: 696c 655f 7374 6f72 6167 653a 3a6c 6173 ile_storage::las │ │ │ -00045530: 745f 7069 6563 655f 696e 6465 785f 6174 t_piece_index_at │ │ │ -00045540: 5f66 696c 6528 6669 6c65 5f69 6e64 6578 _file(file_index │ │ │ -00045550: 5f74 2066 2920 636f 6e73 740a 097b 0a09 _t f) const..{.. │ │ │ -00045560: 0972 6574 7572 6e20 7069 6563 655f 696e .return piece_in │ │ │ -00045570: 6465 785f 747b 6175 783a 3a6e 756d 6572 dex_t{aux::numer │ │ │ -00045580: 6963 5f63 6173 7426 6c74 3b69 6e74 2667 ic_cast<int&g │ │ │ -00045590: 743b 2828 6669 6c65 5f6f 6666 7365 7428 t;((file_offset( │ │ │ -000455a0: 6629 202b 2066 696c 655f 7369 7a65 2866 f) + file_size(f │ │ │ -000455b0: 2920 2d20 3129 202f 2070 6965 6365 5f6c ) - 1) / piece_l │ │ │ -000455c0: 656e 6774 6828 2929 7d3b 0a09 7d0a 0a23 ength())};..}..# │ │ │ -000455d0: 6966 2054 4f52 5245 4e54 5f41 4249 5f56 if TORRENT_ABI_V │ │ │ -000455e0: 4552 5349 4f4e 2026 6c74 3b3d 2032 0a09 ERSION <= 2.. │ │ │ -000455f0: 6368 6172 2063 6f6e 7374 2a20 6669 6c65 char const* file │ │ │ -00045600: 5f73 746f 7261 6765 3a3a 6669 6c65 5f6e _storage::file_n │ │ │ -00045610: 616d 655f 7074 7228 6669 6c65 5f69 6e64 ame_ptr(file_ind │ │ │ -00045620: 6578 5f74 2063 6f6e 7374 2069 6e64 6578 ex_t const index │ │ │ -00045630: 2920 636f 6e73 740a 097b 0a09 0972 6574 ) const..{...ret │ │ │ -00045640: 7572 6e20 6d5f 6669 6c65 735b 696e 6465 urn m_files[inde │ │ │ -00045650: 785d 2e6e 616d 653b 0a09 7d0a 0a09 696e x].name;..}...in │ │ │ -00045660: 7420 6669 6c65 5f73 746f 7261 6765 3a3a t file_storage:: │ │ │ -00045670: 6669 6c65 5f6e 616d 655f 6c65 6e28 6669 file_name_len(fi │ │ │ -00045680: 6c65 5f69 6e64 6578 5f74 2063 6f6e 7374 le_index_t const │ │ │ -00045690: 2069 6e64 6578 2920 636f 6e73 740a 097b index) const..{ │ │ │ -000456a0: 0a09 0969 6620 286d 5f66 696c 6573 5b69 ...if (m_files[i │ │ │ -000456b0: 6e64 6578 5d2e 6e61 6d65 5f6c 656e 203d ndex].name_len = │ │ │ -000456c0: 3d20 6175 783a 3a66 696c 655f 656e 7472 = aux::file_entr │ │ │ -000456d0: 793a 3a6e 616d 655f 6973 5f6f 776e 6564 y::name_is_owned │ │ │ -000456e0: 290a 0909 0972 6574 7572 6e20 2d31 3b0a )....return -1;. │ │ │ -000456f0: 0909 7265 7475 726e 206d 5f66 696c 6573 ..return m_files │ │ │ -00045700: 5b69 6e64 6578 5d2e 6e61 6d65 5f6c 656e [index].name_len │ │ │ -00045710: 3b0a 097d 0a23 656e 6469 660a 0a3c 2f70 ;..}.#endif..

    re │ │ │ -00045750: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/f │ │ │ -00045790: 696c 655f 7374 6f72 6167 652e 6370 703a ile_storage.cpp: │ │ │ -000457a0: 3131 3636 3c2f 613e 3c2f 7464 3e3c 7464 1166do we still nee │ │ │ -000457c0: 6420 7468 6973 2063 6173 653f 3c2f 7464 d this case?

    do we │ │ │ -00045820: 7374 696c 6c20 6e65 6564 2074 6869 7320 still need this │ │ │ -00045830: 6361 7365 3f3c 2f68 323e 3c68 343e 2e2e case?

    .. │ │ │ -00045840: 2f73 7263 2f66 696c 655f 7374 6f72 6167 /src/file_storag │ │ │ -00045850: 652e 6370 703a 3131 3636 3c2f 6834 3e3c e.cpp:1166

    < │ │ │ -00045860: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00045870: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00045880: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00045890: 7820 2364 6464 3b22 3e09 0909 0970 726f x #ddd;">....pro │ │ │ -000458a0: 6365 7373 5f73 7472 696e 675f 6c6f 7765 cess_string_lowe │ │ │ -000458b0: 7263 6173 6528 6372 632c 2070 293b 0a09 rcase(crc, p);.. │ │ │ -000458c0: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -000458d0: 5428 702e 7369 7a65 2829 2026 6774 3b20 T(p.size() > │ │ │ -000458e0: 3029 3b0a 0909 0909 544f 5252 454e 545f 0);.....TORRENT_ │ │ │ -000458f0: 4153 5345 5254 2870 5b70 2e73 697a 6528 ASSERT(p[p.size( │ │ │ -00045900: 2920 2d20 315d 2021 3d20 544f 5252 454e ) - 1] != TORREN │ │ │ -00045910: 545f 5345 5041 5241 544f 5229 3b0a 0909 T_SEPARATOR);... │ │ │ -00045920: 0909 6372 632e 7072 6f63 6573 735f 6279 ..crc.process_by │ │ │ -00045930: 7465 2854 4f52 5245 4e54 5f53 4550 4152 te(TORRENT_SEPAR │ │ │ -00045940: 4154 4f52 293b 0a09 0909 7d0a 0909 0970 ATOR);....}....p │ │ │ -00045950: 726f 6365 7373 5f73 7472 696e 675f 6c6f rocess_string_lo │ │ │ -00045960: 7765 7263 6173 6528 6372 632c 2066 652e wercase(crc, fe. │ │ │ -00045970: 6669 6c65 6e61 6d65 2829 293b 0a09 097d filename());...} │ │ │ -00045980: 0a0a 0909 7265 7475 726e 2063 7263 2e63 ....return crc.c │ │ │ -00045990: 6865 636b 7375 6d28 293b 0a09 7d0a 0a09 hecksum();..}... │ │ │ -000459a0: 7374 643a 3a73 7472 696e 6720 6669 6c65 std::string file │ │ │ -000459b0: 5f73 746f 7261 6765 3a3a 6669 6c65 5f70 _storage::file_p │ │ │ -000459c0: 6174 6828 6669 6c65 5f69 6e64 6578 5f74 ath(file_index_t │ │ │ -000459d0: 2063 6f6e 7374 2069 6e64 6578 2c20 7374 const index, st │ │ │ -000459e0: 643a 3a73 7472 696e 6720 636f 6e73 7426 d::string const& │ │ │ -000459f0: 616d 703b 2073 6176 655f 7061 7468 2920 amp; save_path) │ │ │ -00045a00: 636f 6e73 740a 097b 0a09 0954 4f52 5245 const..{...TORRE │ │ │ -00045a10: 4e54 5f41 5353 4552 545f 5052 4543 4f4e NT_ASSERT_PRECON │ │ │ -00045a20: 4428 696e 6465 7820 2667 743b 3d20 6669 D(index >= fi │ │ │ -00045a30: 6c65 5f69 6e64 6578 5f74 2830 2920 2661 le_index_t(0) &a │ │ │ -00045a40: 6d70 3b26 616d 703b 2069 6e64 6578 2026 mp;& index & │ │ │ -00045a50: 6c74 3b20 656e 645f 6669 6c65 2829 293b lt; end_file()); │ │ │ -00045a60: 0a09 0961 7578 3a3a 6669 6c65 5f65 6e74 ...aux::file_ent │ │ │ -00045a70: 7279 2063 6f6e 7374 2661 6d70 3b20 6665 ry const& fe │ │ │ -00045a80: 203d 206d 5f66 696c 6573 5b69 6e64 6578 = m_files[index │ │ │ -00045a90: 5d3b 0a0a 0909 7374 643a 3a73 7472 696e ];....std::strin │ │ │ -00045aa0: 6720 7265 743b 0a0a 0909 6966 2028 6665 g ret;....if (fe │ │ │ -00045ab0: 2e70 6174 685f 696e 6465 7820 3d3d 2061 .path_index == a │ │ │ -00045ac0: 7578 3a3a 6669 6c65 5f65 6e74 7279 3a3a ux::file_entry:: │ │ │ -00045ad0: 7061 7468 5f69 735f 6162 736f 6c75 7465 path_is_absolute │ │ │ -00045ae0: 290a 0909 7b0a 3c64 6976 2073 7479 6c65 )...{.
    ...ret = fe. │ │ │ -00045b20: 6669 6c65 6e61 6d65 2829 3b0a 3c2f 6469 filename();...}...else if │ │ │ -00045b40: 2866 652e 7061 7468 5f69 6e64 6578 203d (fe.path_index = │ │ │ -00045b50: 3d20 6175 783a 3a66 696c 655f 656e 7472 = aux::file_entr │ │ │ -00045b60: 793a 3a6e 6f5f 7061 7468 290a 0909 7b0a y::no_path)...{. │ │ │ -00045b70: 0909 0972 6574 2e72 6573 6572 7665 2873 ...ret.reserve(s │ │ │ -00045b80: 6176 655f 7061 7468 2e73 697a 6528 2920 ave_path.size() │ │ │ -00045b90: 2b20 6665 2e66 696c 656e 616d 6528 292e + fe.filename(). │ │ │ -00045ba0: 7369 7a65 2829 202b 2031 293b 0a09 0909 size() + 1);.... │ │ │ -00045bb0: 7265 742e 6173 7369 676e 2873 6176 655f ret.assign(save_ │ │ │ -00045bc0: 7061 7468 293b 0a09 0909 6170 7065 6e64 path);....append │ │ │ -00045bd0: 5f70 6174 6828 7265 742c 2066 652e 6669 _path(ret, fe.fi │ │ │ -00045be0: 6c65 6e61 6d65 2829 293b 0a09 097d 0a09 lename());...}.. │ │ │ -00045bf0: 0965 6c73 6520 6966 2028 6665 2e6e 6f5f .else if (fe.no_ │ │ │ -00045c00: 726f 6f74 5f64 6972 290a 0909 7b0a 0909 root_dir)...{... │ │ │ -00045c10: 0973 7464 3a3a 7374 7269 6e67 2063 6f6e .std::string con │ │ │ -00045c20: 7374 2661 6d70 3b20 7020 3d20 6d5f 7061 st& p = m_pa │ │ │ -00045c30: 7468 735b 6665 2e70 6174 685f 696e 6465 ths[fe.path_inde │ │ │ -00045c40: 785d 3b0a 0a09 0909 7265 742e 7265 7365 x];.....ret.rese │ │ │ -00045c50: 7276 6528 7361 7665 5f70 6174 682e 7369 rve(save_path.si │ │ │ -00045c60: 7a65 2829 202b 2070 2e73 697a 6528 2920 ze() + p.size() │ │ │ -00045c70: 2b20 6665 2e66 696c 656e 616d 6528 292e + fe.filename(). │ │ │ -00045c80: 7369 7a65 2829 202b 2032 293b 0a09 0909 size() + 2);.... │ │ │ -00045c90: 7265 742e 6173 7369 676e 2873 6176 655f ret.assign(save_ │ │ │ -00045ca0: 7061 7468 293b 0a09 0909 6170 7065 6e64 path);....append │ │ │ -00045cb0: 5f70 6174 6828 7265 742c 2070 293b 0a09 _path(ret, p);.. │ │ │ -00045cc0: 0909 6170 7065 6e64 5f70 6174 6828 7265 ..append_path(re │ │ │ -00045cd0: 742c 2066 652e 6669 6c65 6e61 6d65 2829 t, fe.filename() │ │ │ -00045ce0: 293b 0a09 097d 0a09 0965 6c73 650a 0909 );...}...else... │ │ │ -00045cf0: 7b0a 0909 0973 7464 3a3a 7374 7269 6e67 {....std::string │ │ │ -00045d00: 2063 6f6e 7374 2661 6d70 3b20 7020 3d20 const& p = │ │ │ -00045d10: 6d5f 7061 7468 735b 6665 2e70 6174 685f m_paths[fe.path_ │ │ │ -00045d20: 696e 6465 785d 3b0a 0a09 0909 7265 742e index];.....ret. │ │ │ -00045d30: 7265 7365 7276 6528 7361 7665 5f70 6174 reserve(save_pat │ │ │ -00045d40: 682e 7369 7a65 2829 202b 206d 5f6e 616d h.size() + m_nam │ │ │ -00045d50: 652e 7369 7a65 2829 202b 2070 2e73 697a e.size() + p.siz │ │ │ -00045d60: 6528 2920 2b20 6665 2e66 696c 656e 616d e() + fe.filenam │ │ │ -00045d70: 6528 292e 7369 7a65 2829 202b 2033 293b e().size() + 3); │ │ │ -00045d80: 0a09 0909 7265 742e 6173 7369 676e 2873 ....ret.assign(s │ │ │ -00045d90: 6176 655f 7061 7468 293b 0a09 0909 6170 ave_path);....ap │ │ │ -00045da0: 7065 6e64 5f70 6174 6828 7265 742c 206d pend_path(ret, m │ │ │ -00045db0: 5f6e 616d 6529 3b0a 0909 0961 7070 656e _name);....appen │ │ │ -00045dc0: 645f 7061 7468 2872 6574 2c20 7029 3b0a d_path(ret, p);. │ │ │ -00045dd0: 0909 0961 7070 656e 645f 7061 7468 2872 ...append_path(r │ │ │ -00045de0: 6574 2c20 6665 2e66 696c 656e 616d 6528 et, fe.filename( │ │ │ -00045df0: 2929 3b0a 0909 7d0a 0a09 092f 2f20 6120 ));...}....// a │ │ │ -00045e00: 7369 6e67 6c65 2072 6574 7572 6e20 7374 single return st │ │ │ -00045e10: 6174 656d 656e 742c 206a 7573 7420 746f atement, just to │ │ │ -00045e20: 206d 616b 6520 4e52 564f 206d 6f72 6520 make NRVO more │ │ │ -00045e30: 6c69 6b65 6c79 2074 6f20 6b69 636b 2069 likely to kick i │ │ │ -00045e40: 6e0a 0909 7265 7475 726e 2072 6574 3b0a n...return ret;. │ │ │ -00045e50: 097d 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .}. │ │ │ -00045e80: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00045e90: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00045ec0: 2f73 7263 2f66 696c 655f 7374 6f72 6167 /src/file_storag │ │ │ -00045ed0: 652e 6370 703a 3133 3037 3c2f 613e 3c2f e.cpp:1307deprecate │ │ │ -00045ef0: 6420 7468 6973 2e20 446f 2077 6520 6e65 d this. Do we ne │ │ │ -00045f00: 6564 2066 696c 655f 7374 6f72 6167 6520 ed file_storage │ │ │ -00045f10: 746f 2073 7570 706f 7274 2061 6273 6f6c to support absol │ │ │ -00045f20: 7574 6520 7061 7468 733f 3c2f 7464 3e3c ute paths?< │ │ │ -00045f30: 2f74 723e 3c74 7220 6964 3d22 3137 3322 /tr>

    deprecat │ │ │ -00045f80: 6564 2074 6869 732e 2044 6f20 7765 206e ed this. Do we n │ │ │ -00045f90: 6565 6420 6669 6c65 5f73 746f 7261 6765 eed file_storage │ │ │ -00045fa0: 2074 6f20 7375 7070 6f72 7420 6162 736f to support abso │ │ │ -00045fb0: 6c75 7465 2070 6174 6873 3f3c 2f68 323e lute paths?

    │ │ │ -00045fc0: 3c68 343e 2e2e 2f73 7263 2f66 696c 655f

    ../src/file_ │ │ │ -00045fd0: 7374 6f72 6167 652e 6370 703a 3133 3037 storage.cpp:1307 │ │ │ -00045fe0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00046020: 7d0a 0a09 696e 7420 6669 6c65 5f73 746f  }...int file_sto
    │ │ │ -00046030: 7261 6765 3a3a 6669 6c65 5f66 6972 7374  rage::file_first
    │ │ │ -00046040: 5f62 6c6f 636b 5f6e 6f64 6528 6669 6c65  _block_node(file
    │ │ │ -00046050: 5f69 6e64 6578 5f74 2069 6e64 6578 2920  _index_t index) 
    │ │ │ -00046060: 636f 6e73 740a 097b 0a09 0954 4f52 5245  const..{...TORRE
    │ │ │ -00046070: 4e54 5f41 5353 4552 545f 5052 4543 4f4e  NT_ASSERT_PRECON
    │ │ │ -00046080: 4428 696e 6465 7820 2667 743b 3d20 6669  D(index >= fi
    │ │ │ -00046090: 6c65 5f69 6e64 6578 5f74 2830 2920 2661  le_index_t(0) &a
    │ │ │ -000460a0: 6d70 3b26 616d 703b 2069 6e64 6578 2026  mp;& index &
    │ │ │ -000460b0: 6c74 3b20 656e 645f 6669 6c65 2829 293b  lt; end_file());
    │ │ │ -000460c0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -000460d0: 545f 5052 4543 4f4e 4428 6d5f 7069 6563  T_PRECOND(m_piec
    │ │ │ -000460e0: 655f 6c65 6e67 7468 2026 6774 3b20 3029  e_length > 0)
    │ │ │ -000460f0: 3b0a 0909 696e 7420 636f 6e73 7420 6c65  ;...int const le
    │ │ │ -00046100: 6166 5f6c 6179 6572 5f73 697a 6520 3d20  af_layer_size = 
    │ │ │ -00046110: 6d65 726b 6c65 5f6e 756d 5f6c 6561 6673  merkle_num_leafs
    │ │ │ -00046120: 2866 696c 655f 6e75 6d5f 626c 6f63 6b73  (file_num_blocks
    │ │ │ -00046130: 2869 6e64 6578 2929 3b0a 0909 7265 7475  (index));...retu
    │ │ │ -00046140: 726e 206d 6572 6b6c 655f 6e75 6d5f 6e6f  rn merkle_num_no
    │ │ │ -00046150: 6465 7328 6c65 6166 5f6c 6179 6572 5f73  des(leaf_layer_s
    │ │ │ -00046160: 697a 6529 202d 206c 6561 665f 6c61 7965  ize) - leaf_laye
    │ │ │ -00046170: 725f 7369 7a65 3b0a 097d 0a0a 0966 696c  r_size;..}...fil
    │ │ │ -00046180: 655f 666c 6167 735f 7420 6669 6c65 5f73  e_flags_t file_s
    │ │ │ -00046190: 746f 7261 6765 3a3a 6669 6c65 5f66 6c61  torage::file_fla
    │ │ │ -000461a0: 6773 2866 696c 655f 696e 6465 785f 7420  gs(file_index_t 
    │ │ │ -000461b0: 636f 6e73 7420 696e 6465 7829 2063 6f6e  const index) con
    │ │ │ -000461c0: 7374 0a09 7b0a 0909 544f 5252 454e 545f  st..{...TORRENT_
    │ │ │ -000461d0: 4153 5345 5254 5f50 5245 434f 4e44 2869  ASSERT_PRECOND(i
    │ │ │ -000461e0: 6e64 6578 2026 6774 3b3d 2066 696c 655f  ndex >= file_
    │ │ │ -000461f0: 696e 6465 785f 7428 3029 2026 616d 703b  index_t(0) &
    │ │ │ -00046200: 2661 6d70 3b20 696e 6465 7820 266c 743b  & index <
    │ │ │ -00046210: 2065 6e64 5f66 696c 6528 2929 3b0a 0909   end_file());...
    │ │ │ -00046220: 6175 783a 3a66 696c 655f 656e 7472 7920  aux::file_entry 
    │ │ │ -00046230: 636f 6e73 7426 616d 703b 2066 6520 3d20  const& fe = 
    │ │ │ -00046240: 6d5f 6669 6c65 735b 696e 6465 785d 3b0a  m_files[index];.
    │ │ │ -00046250: 0909 7265 7475 726e 2028 6665 2e70 6164  ..return (fe.pad
    │ │ │ -00046260: 5f66 696c 6520 3f20 6669 6c65 5f73 746f  _file ? file_sto
    │ │ │ -00046270: 7261 6765 3a3a 666c 6167 5f70 6164 5f66  rage::flag_pad_f
    │ │ │ -00046280: 696c 6520 3a20 6669 6c65 5f66 6c61 6773  ile : file_flags
    │ │ │ -00046290: 5f74 7b7d 290a 0909 097c 2028 6665 2e68  _t{})....| (fe.h
    │ │ │ -000462a0: 6964 6465 6e5f 6174 7472 6962 7574 6520  idden_attribute 
    │ │ │ -000462b0: 3f20 6669 6c65 5f73 746f 7261 6765 3a3a  ? file_storage::
    │ │ │ -000462c0: 666c 6167 5f68 6964 6465 6e20 3a20 6669  flag_hidden : fi
    │ │ │ -000462d0: 6c65 5f66 6c61 6773 5f74 7b7d 290a 0909  le_flags_t{})...
    │ │ │ -000462e0: 097c 2028 6665 2e65 7865 6375 7461 626c  .| (fe.executabl
    │ │ │ -000462f0: 655f 6174 7472 6962 7574 6520 3f20 6669  e_attribute ? fi
    │ │ │ -00046300: 6c65 5f73 746f 7261 6765 3a3a 666c 6167  le_storage::flag
    │ │ │ -00046310: 5f65 7865 6375 7461 626c 6520 3a20 6669  _executable : fi
    │ │ │ -00046320: 6c65 5f66 6c61 6773 5f74 7b7d 290a 0909  le_flags_t{})...
    │ │ │ -00046330: 097c 2028 6665 2e73 796d 6c69 6e6b 5f61  .| (fe.symlink_a
    │ │ │ -00046340: 7474 7269 6275 7465 203f 2066 696c 655f  ttribute ? file_
    │ │ │ -00046350: 7374 6f72 6167 653a 3a66 6c61 675f 7379  storage::flag_sy
    │ │ │ -00046360: 6d6c 696e 6b20 3a20 6669 6c65 5f66 6c61  mlink : file_fla
    │ │ │ -00046370: 6773 5f74 7b7d 293b 0a09 7d0a 0a3c 6469  gs_t{});..}...bool
    │ │ │ -000463b0: 2066 696c 655f 7374 6f72 6167 653a 3a66   file_storage::f
    │ │ │ -000463c0: 696c 655f 6162 736f 6c75 7465 5f70 6174  ile_absolute_pat
    │ │ │ -000463d0: 6828 6669 6c65 5f69 6e64 6578 5f74 2063  h(file_index_t c
    │ │ │ -000463e0: 6f6e 7374 2069 6e64 6578 2920 636f 6e73  onst index) cons
    │ │ │ -000463f0: 740a 3c2f 6469 763e 097b 0a09 0954 4f52  t.
    .{...TOR │ │ │ -00046400: 5245 4e54 5f41 5353 4552 545f 5052 4543 RENT_ASSERT_PREC │ │ │ -00046410: 4f4e 4428 696e 6465 7820 2667 743b 3d20 OND(index >= │ │ │ -00046420: 6669 6c65 5f69 6e64 6578 5f74 2830 2920 file_index_t(0) │ │ │ -00046430: 2661 6d70 3b26 616d 703b 2069 6e64 6578 && index │ │ │ -00046440: 2026 6c74 3b20 656e 645f 6669 6c65 2829 < end_file() │ │ │ -00046450: 293b 0a09 0961 7578 3a3a 6669 6c65 5f65 );...aux::file_e │ │ │ -00046460: 6e74 7279 2063 6f6e 7374 2661 6d70 3b20 ntry const& │ │ │ -00046470: 6665 203d 206d 5f66 696c 6573 5b69 6e64 fe = m_files[ind │ │ │ -00046480: 6578 5d3b 0a09 0972 6574 7572 6e20 6665 ex];...return fe │ │ │ -00046490: 2e70 6174 685f 696e 6465 7820 3d3d 2061 .path_index == a │ │ │ -000464a0: 7578 3a3a 6669 6c65 5f65 6e74 7279 3a3a ux::file_entry:: │ │ │ -000464b0: 7061 7468 5f69 735f 6162 736f 6c75 7465 path_is_absolute │ │ │ -000464c0: 3b0a 097d 0a0a 2369 6620 544f 5252 454e ;..}..#if TORREN │ │ │ -000464d0: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ -000464e0: 2031 0a09 7368 6131 5f68 6173 6820 6669 1..sha1_hash fi │ │ │ -000464f0: 6c65 5f73 746f 7261 6765 3a3a 6861 7368 le_storage::hash │ │ │ -00046500: 2861 7578 3a3a 6669 6c65 5f65 6e74 7279 (aux::file_entry │ │ │ -00046510: 2063 6f6e 7374 2661 6d70 3b20 6665 2920 const& fe) │ │ │ -00046520: 636f 6e73 740a 097b 0a09 0969 6e74 2063 const..{...int c │ │ │ -00046530: 6f6e 7374 2069 6e64 6578 203d 2069 6e74 onst index = int │ │ │ -00046540: 2826 616d 703b 6665 202d 2026 616d 703b (&fe - & │ │ │ -00046550: 6d5f 6669 6c65 732e 6672 6f6e 7428 2929 m_files.front()) │ │ │ -00046560: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ -00046570: 5254 5f50 5245 434f 4e44 2869 6e64 6578 RT_PRECOND(index │ │ │ -00046580: 2026 6774 3b3d 2066 696c 655f 696e 6465 >= file_inde │ │ │ -00046590: 785f 747b 7d20 2661 6d70 3b26 616d 703b x_t{} && │ │ │ -000465a0: 2069 6e64 6578 2026 6c74 3b20 656e 645f index < end_ │ │ │ -000465b0: 6669 6c65 2829 293b 0a09 0969 6620 2869 file());...if (i │ │ │ -000465c0: 6e64 6578 2026 6774 3b3d 2069 6e74 286d ndex >= int(m │ │ │ -000465d0: 5f66 696c 655f 6861 7368 6573 2e73 697a _file_hashes.siz │ │ │ -000465e0: 6528 2929 2920 7265 7475 726e 2073 6861 e())) return sha │ │ │ -000465f0: 315f 6861 7368 286e 756c 6c70 7472 293b 1_hash(nullptr); │ │ │ -00046600: 0a09 0972 6574 7572 6e20 7368 6131 5f68 ...return sha1_h │ │ │ -00046610: 6173 6828 6d5f 6669 6c65 5f68 6173 6865 ash(m_file_hashe │ │ │ -00046620: 735b 696e 6465 785d 293b 0a09 7d0a 0a09 s[index]);..}... │ │ │ -00046630: 7374 643a 3a73 7472 696e 6720 6669 6c65 std::string file │ │ │ -00046640: 5f73 746f 7261 6765 3a3a 7379 6d6c 696e _storage::symlin │ │ │ -00046650: 6b28 6175 783a 3a66 696c 655f 656e 7472 k(aux::file_entr │ │ │ -00046660: 7920 636f 6e73 7426 616d 703b 2066 6529 y const& fe) │ │ │ -00046670: 2063 6f6e 7374 0a09 7b0a 0909 544f 5252 const..{...TORR │ │ │ -00046680: 454e 545f 4153 5345 5254 5f50 5245 434f ENT_ASSERT_PRECO │ │ │ -00046690: 4e44 2866 652e 7379 6d6c 696e 6b5f 696e ND(fe.symlink_in │ │ │ -000466a0: 6465 7820 266c 743b 2069 6e74 286d 5f73 dex < int(m_s │ │ │ -000466b0: 796d 6c69 6e6b 732e 7369 7a65 2829 2929 ymlinks.size())) │ │ │ -000466c0: 3b0a 0909 7265 7475 726e 206d 5f73 796d ;...return m_sym │ │ │ -000466d0: 6c69 6e6b 735b 6665 2e73 796d 6c69 6e6b links[fe.symlink │ │ │ -000466e0: 5f69 6e64 6578 5d3b 0a09 7d0a 0a09 7374 _index];..}...st │ │ │ -000466f0: 643a 3a74 696d 655f 7420 6669 6c65 5f73 d::time_t file_s │ │ │ -00046700: 746f 7261 6765 3a3a 6d74 696d 6528 6175 torage::mtime(au │ │ │ -00046710: 783a 3a66 696c 655f 656e 7472 7920 636f x::file_entry co │ │ │ -00046720: 6e73 7426 616d 703b 2066 6529 2063 6f6e nst& fe) con │ │ │ -00046730: 7374 0a09 7b0a 0909 696e 7420 636f 6e73 st..{...int cons │ │ │ -00046740: 7420 696e 6465 7820 3d20 696e 7428 2661 t index = int(&a │ │ │ -00046750: 6d70 3b66 6520 2d20 2661 6d70 3b6d 5f66 mp;fe - &m_f │ │ │ -00046760: 696c 6573 2e66 726f 6e74 2829 293b 0a09 iles.front());.. │ │ │ -00046770: 0954 4f52 5245 4e54 5f41 5353 4552 545f .TORRENT_ASSERT_ │ │ │ -00046780: 5052 4543 4f4e 4428 696e 6465 7820 2667 PRECOND(index &g │ │ │ -00046790: 743b 3d20 6669 6c65 5f69 6e64 6578 5f74 t;= file_index_t │ │ │ -000467a0: 7b7d 2026 616d 703b 2661 6d70 3b20 696e {} && in │ │ │ -000467b0: 6465 7820 266c 743b 2065 6e64 5f66 696c dex < end_fil │ │ │ -000467c0: 6528 2929 3b0a 0909 6966 2028 696e 6465 e());...if (inde │ │ │ -000467d0: 7820 2667 743b 3d20 696e 7428 6d5f 6d74 x >= int(m_mt │ │ │ -000467e0: 696d 652e 7369 7a65 2829 2929 2072 6574 ime.size())) ret │ │ │ -000467f0: 7572 6e20 303b 0a09 0972 6574 7572 6e20 urn 0;...return │ │ │ -00046800: 6d5f 6d74 696d 655b 696e 6465 785d 3b0a m_mtime[index];. │ │ │ -00046810: 097d 0a0a 0969 6e74 2066 696c 655f 7374 .}...int file_st │ │ │ -00046820: 6f72 6167 653a 3a66 696c 655f 696e 6465 orage::file_inde │ │ │ -00046830: 7828 6175 783a 3a66 696c 655f 656e 7472 x(aux::file_entr │ │ │ -00046840: 7920 636f 6e73 7426 616d 703b 2066 6529 y const& fe) │ │ │ -00046850: 2063 6f6e 7374 0a3c 2f70 7265 3e3c 2f74 const.relevanc │ │ │ -00046890: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/file_st │ │ │ -000468d0: 6f72 6167 652e 6370 703a 3134 3231 3c2f orage.cpp:1421this │ │ │ -000468f0: 776f 756c 6420 6265 206d 6f72 6520 6566 would be more ef │ │ │ -00046900: 6669 6369 656e 7420 6966 206d 5f70 6174 ficient if m_pat │ │ │ -00046910: 6873 2077 6173 2073 6f72 7465 6420 6669 hs was sorted fi │ │ │ -00046920: 7273 742c 2073 7563 6820 7468 6174 2061 rst, such that a │ │ │ -00046930: 206c 6f77 6572 2070 6174 6820 696e 6465 lower path inde │ │ │ -00046940: 7820 616c 7761 7973 206d 6561 6e74 2073 x always meant s │ │ │ -00046950: 6f72 7465 642d 6265 666f 7265 3c2f 7464 orted-before

    this w │ │ │ -000469b0: 6f75 6c64 2062 6520 6d6f 7265 2065 6666 ould be more eff │ │ │ -000469c0: 6963 6965 6e74 2069 6620 6d5f 7061 7468 icient if m_path │ │ │ -000469d0: 7320 7761 7320 736f 7274 6564 2066 6972 s was sorted fir │ │ │ -000469e0: 7374 2c20 7375 6368 0a74 6861 7420 6120 st, such.that a │ │ │ -000469f0: 6c6f 7765 7220 7061 7468 2069 6e64 6578 lower path index │ │ │ -00046a00: 2061 6c77 6179 7320 6d65 616e 7420 736f always meant so │ │ │ -00046a10: 7274 6564 2d62 6566 6f72 653c 2f68 323e rted-before

    │ │ │ -00046a20: 3c68 343e 2e2e 2f73 7263 2f66 696c 655f

    ../src/file_ │ │ │ -00046a30: 7374 6f72 6167 652e 6370 703a 3134 3231 storage.cpp:1421 │ │ │ -00046a40: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00046a80: 7d0a 0a09 766f 6964 2066 696c 655f 7374  }...void file_st
    │ │ │ -00046a90: 6f72 6167 653a 3a63 616e 6f6e 6963 616c  orage::canonical
    │ │ │ -00046aa0: 697a 655f 696d 706c 2862 6f6f 6c20 636f  ize_impl(bool co
    │ │ │ -00046ab0: 6e73 7420 6261 636b 7761 7264 735f 636f  nst backwards_co
    │ │ │ -00046ac0: 6d70 6174 6962 6c65 290a 097b 0a09 0954  mpatible)..{...T
    │ │ │ -00046ad0: 4f52 5245 4e54 5f41 5353 4552 5428 7069  ORRENT_ASSERT(pi
    │ │ │ -00046ae0: 6563 655f 6c65 6e67 7468 2829 2026 6774  ece_length() >
    │ │ │ -00046af0: 3b3d 2031 3620 2a20 3130 3234 293b 0a0a  ;= 16 * 1024);..
    │ │ │ -00046b00: 0909 2f2f 2075 7365 2074 6869 7320 7665  ..// use this ve
    │ │ │ -00046b10: 6374 6f72 2074 6f20 7472 6163 6b20 7468  ctor to track th
    │ │ │ -00046b20: 6520 6e65 7720 6f72 6465 7269 6e67 206f  e new ordering o
    │ │ │ -00046b30: 6620 6669 6c65 730a 0909 2f2f 2074 6869  f files...// thi
    │ │ │ -00046b40: 7320 616c 6c6f 7773 2074 6865 2075 7365  s allows the use
    │ │ │ -00046b50: 206f 6620 5354 4c20 616c 676f 7269 7468   of STL algorith
    │ │ │ -00046b60: 6d73 2064 6573 7069 7465 2074 6865 6d0a  ms despite them.
    │ │ │ -00046b70: 0909 2f2f 206e 6f74 2073 7570 706f 7274  ..// not support
    │ │ │ -00046b80: 696e 6720 6120 6375 7374 6f6d 2073 7761  ing a custom swa
    │ │ │ -00046b90: 7020 6675 6e63 746f 720a 0909 6175 783a  p functor...aux:
    │ │ │ -00046ba0: 3a76 6563 746f 7226 6c74 3b66 696c 655f  :vector<file_
    │ │ │ -00046bb0: 696e 6465 785f 742c 2066 696c 655f 696e  index_t, file_in
    │ │ │ -00046bc0: 6465 785f 7426 6774 3b20 6e65 775f 6f72  dex_t> new_or
    │ │ │ -00046bd0: 6465 7228 656e 645f 6669 6c65 2829 293b  der(end_file());
    │ │ │ -00046be0: 0a09 0966 6f72 2028 6175 746f 2069 203a  ...for (auto i :
    │ │ │ -00046bf0: 2066 696c 655f 7261 6e67 6528 2929 0a09   file_range())..
    │ │ │ -00046c00: 0909 6e65 775f 6f72 6465 725b 695d 203d  ..new_order[i] =
    │ │ │ -00046c10: 2069 3b0a 0a09 092f 2f20 7265 6d6f 7665   i;....// remove
    │ │ │ -00046c20: 2061 6e79 2065 7869 7374 696e 6720 7061   any existing pa
    │ │ │ -00046c30: 6420 6669 6c65 730a 0909 7b0a 0909 0961  d files...{....a
    │ │ │ -00046c40: 7574 6f20 7061 645f 6265 6769 6e20 3d20  uto pad_begin = 
    │ │ │ -00046c50: 7374 643a 3a70 6172 7469 7469 6f6e 286e  std::partition(n
    │ │ │ -00046c60: 6577 5f6f 7264 6572 2e62 6567 696e 2829  ew_order.begin()
    │ │ │ -00046c70: 2c20 6e65 775f 6f72 6465 722e 656e 6428  , new_order.end(
    │ │ │ -00046c80: 290a 0909 0909 2c20 5b74 6869 735d 2866  )....., [this](f
    │ │ │ -00046c90: 696c 655f 696e 6465 785f 7420 6929 207b  ile_index_t i) {
    │ │ │ -00046ca0: 2072 6574 7572 6e20 216d 5f66 696c 6573   return !m_files
    │ │ │ -00046cb0: 5b69 5d2e 7061 645f 6669 6c65 3b20 7d29  [i].pad_file; })
    │ │ │ -00046cc0: 3b0a 0909 096e 6577 5f6f 7264 6572 2e65  ;....new_order.e
    │ │ │ -00046cd0: 7261 7365 2870 6164 5f62 6567 696e 2c20  rase(pad_begin, 
    │ │ │ -00046ce0: 6e65 775f 6f72 6465 722e 656e 6428 2929  new_order.end())
    │ │ │ -00046cf0: 3b0a 0909 7d0a 0a3c 6469 7620 7374 796c  ;...}..
    .
    ..// │ │ │ -00046d30: 2073 6f72 7420 6669 6c65 7320 6279 2070 sort files by p │ │ │ -00046d40: 6174 682f 6e61 6d65 0a09 0973 7464 3a3a ath/name...std:: │ │ │ -00046d50: 736f 7274 286e 6577 5f6f 7264 6572 2e62 sort(new_order.b │ │ │ -00046d60: 6567 696e 2829 2c20 6e65 775f 6f72 6465 egin(), new_orde │ │ │ -00046d70: 722e 656e 6428 290a 0909 092c 205b 7468 r.end()...., [th │ │ │ -00046d80: 6973 5d28 6669 6c65 5f69 6e64 6578 5f74 is](file_index_t │ │ │ -00046d90: 206c 2c20 6669 6c65 5f69 6e64 6578 5f74 l, file_index_t │ │ │ -00046da0: 2072 290a 0909 7b0a 0909 092f 2f20 6173 r)...{....// as │ │ │ -00046db0: 7375 6d69 6e67 206d 5f70 6174 6873 2061 suming m_paths a │ │ │ -00046dc0: 7265 2075 6e69 7175 6521 0a09 0909 6175 re unique!....au │ │ │ -00046dd0: 746f 2063 6f6e 7374 2661 6d70 3b20 6c66 to const& lf │ │ │ -00046de0: 203d 206d 5f66 696c 6573 5b6c 5d3b 0a09 = m_files[l];.. │ │ │ -00046df0: 0909 6175 746f 2063 6f6e 7374 2661 6d70 ..auto const& │ │ │ -00046e00: 3b20 7266 203d 206d 5f66 696c 6573 5b72 ; rf = m_files[r │ │ │ -00046e10: 5d3b 0a09 0909 6966 2028 6c66 2e70 6174 ];....if (lf.pat │ │ │ -00046e20: 685f 696e 6465 7820 213d 2072 662e 7061 h_index != rf.pa │ │ │ -00046e30: 7468 5f69 6e64 6578 290a 0909 097b 0a09 th_index)....{.. │ │ │ -00046e40: 0909 0969 6e74 2063 6f6e 7374 2072 6574 ...int const ret │ │ │ -00046e50: 203d 2070 6174 685f 636f 6d70 6172 6528 = path_compare( │ │ │ -00046e60: 6d5f 7061 7468 735b 6c66 2e70 6174 685f m_paths[lf.path_ │ │ │ -00046e70: 696e 6465 785d 2c20 6c66 2e66 696c 656e index], lf.filen │ │ │ -00046e80: 616d 6528 290a 0909 0909 092c 206d 5f70 ame()......, m_p │ │ │ -00046e90: 6174 6873 5b72 662e 7061 7468 5f69 6e64 aths[rf.path_ind │ │ │ -00046ea0: 6578 5d2c 2072 662e 6669 6c65 6e61 6d65 ex], rf.filename │ │ │ -00046eb0: 2829 293b 0a09 0909 0969 6620 2872 6574 ());.....if (ret │ │ │ -00046ec0: 2021 3d20 3029 2072 6574 7572 6e20 7265 != 0) return re │ │ │ -00046ed0: 7420 266c 743b 2030 3b0a 0909 097d 0a09 t < 0;....}.. │ │ │ -00046ee0: 0909 7265 7475 726e 206c 662e 6669 6c65 ..return lf.file │ │ │ -00046ef0: 6e61 6d65 2829 2026 6c74 3b20 7266 2e66 name() < rf.f │ │ │ -00046f00: 696c 656e 616d 6528 293b 0a09 097d 293b ilename();...}); │ │ │ -00046f10: 0a0a 0909 6175 783a 3a76 6563 746f 7226 ....aux::vector& │ │ │ -00046f20: 6c74 3b61 7578 3a3a 6669 6c65 5f65 6e74 lt;aux::file_ent │ │ │ -00046f30: 7279 2c20 6669 6c65 5f69 6e64 6578 5f74 ry, file_index_t │ │ │ -00046f40: 2667 743b 206e 6577 5f66 696c 6573 3b0a > new_files;. │ │ │ -00046f50: 0909 6175 783a 3a76 6563 746f 7226 6c74 ..aux::vector< │ │ │ -00046f60: 3b63 6861 7220 636f 6e73 742a 2c20 6669 ;char const*, fi │ │ │ -00046f70: 6c65 5f69 6e64 6578 5f74 2667 743b 206e le_index_t> n │ │ │ -00046f80: 6577 5f66 696c 655f 6861 7368 6573 3b0a ew_file_hashes;. │ │ │ -00046f90: 0909 6175 783a 3a76 6563 746f 7226 6c74 ..aux::vector< │ │ │ -00046fa0: 3b73 7464 3a3a 7469 6d65 5f74 2c20 6669 ;std::time_t, fi │ │ │ -00046fb0: 6c65 5f69 6e64 6578 5f74 2667 743b 206e le_index_t> n │ │ │ -00046fc0: 6577 5f6d 7469 6d65 3b0a 0a09 092f 2f20 ew_mtime;....// │ │ │ -00046fd0: 7265 7365 7276 6520 656e 6f75 6768 2073 reserve enough s │ │ │ -00046fe0: 7061 6365 2066 6f72 2074 6865 2077 6f72 pace for the wor │ │ │ -00046ff0: 7374 2063 6173 6520 6166 7465 7220 7061 st case after pa │ │ │ -00047000: 6464 696e 670a 0909 6e65 775f 6669 6c65 dding...new_file │ │ │ -00047010: 732e 7265 7365 7276 6528 6e65 775f 6f72 s.reserve(new_or │ │ │ -00047020: 6465 722e 7369 7a65 2829 202a 2032 202d der.size() * 2 - │ │ │ -00047030: 2031 293b 0a09 0969 6620 2821 6d5f 6669 1);...if (!m_fi │ │ │ -00047040: 6c65 5f68 6173 6865 732e 656d 7074 7928 le_hashes.empty( │ │ │ -00047050: 2929 0a09 0909 6e65 775f 6669 6c65 5f68 ))....new_file_h │ │ │ -00047060: 6173 6865 732e 7265 7365 7276 6528 6e65 ashes.reserve(ne │ │ │ -00047070: 775f 6f72 6465 722e 7369 7a65 2829 202a w_order.size() * │ │ │ -00047080: 2032 202d 2031 293b 0a09 0969 6620 2821 2 - 1);...if (! │ │ │ -00047090: 6d5f 6d74 696d 652e 656d 7074 7928 2929 m_mtime.empty()) │ │ │ -000470a0: 0a09 0909 6e65 775f 6d74 696d 652e 7265 ....new_mtime.re │ │ │ -000470b0: 7365 7276 6528 6e65 775f 6f72 6465 722e serve(new_order. │ │ │ -000470c0: 7369 7a65 2829 202a 2032 202d 2031 293b size() * 2 - 1); │ │ │ -000470d0: 0a0a 0909 2f2f 2072 652d 636f 6d70 7574 ....// re-comput │ │ │ -000470e0: 6520 6f66 6673 6574 7320 616e 6420 696e e offsets and in │ │ │ -000470f0: 7365 7274 2070 6164 2066 696c 6573 2061 sert pad files a │ │ │ -00047100: 7320 6e65 6365 7373 6172 790a 0909 7374 s necessary...st │ │ │ -00047110: 643a 3a69 6e74 3634 5f74 206f 6666 203d d::int64_t off = │ │ │ -00047120: 2030 3b0a 0909 7374 643a 3a69 6e74 3634 0;...std::int64 │ │ │ -00047130: 5f74 206f 6e5f 6469 736b 203d 2030 3b0a _t on_disk = 0;. │ │ │ -00047140: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00047150: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00047180: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../sr │ │ │ -000471b0: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ -000471c0: 703a 3838 3c2f 613e 3c2f 7464 3e3c 7464 p:88in C++20, use s │ │ │ -000471e0: 7464 3a3a 6964 656e 7469 7479 3c2f 7464 td::identity

    in C++ │ │ │ -00047240: 3230 2c20 7573 6520 7374 643a 3a69 6465 20, use std::ide │ │ │ -00047250: 6e74 6974 793c 2f68 323e 3c68 343e 2e2e ntity

    .. │ │ │ -00047260: 2f73 7263 2f6d 6572 6b6c 655f 7472 6565 /src/merkle_tree │ │ │ -00047270: 2e63 7070 3a38 383c 2f68 343e 3c70 7265 .cpp:88

    ..allocate
    │ │ │ -000472c0: 5f66 756c 6c28 293b 0a0a 0909 6d65 726b  _full();....merk
    │ │ │ -000472d0: 6c65 5f76 616c 6964 6174 655f 636f 7079  le_validate_copy
    │ │ │ -000472e0: 2874 2c20 6d5f 7472 6565 2c20 726f 6f74  (t, m_tree, root
    │ │ │ -000472f0: 2829 2c20 6d5f 626c 6f63 6b5f 7665 7269  (), m_block_veri
    │ │ │ -00047300: 6669 6564 293b 0a0a 0909 6c6f 6164 5f76  fied);....load_v
    │ │ │ -00047310: 6572 6966 6965 645f 6269 7473 2876 6572  erified_bits(ver
    │ │ │ -00047320: 6966 6965 6429 3b0a 0a09 096f 7074 696d  ified);....optim
    │ │ │ -00047330: 697a 655f 7374 6f72 6167 6528 293b 0a09  ize_storage();..
    │ │ │ -00047340: 096f 7074 696d 697a 655f 7374 6f72 6167  .optimize_storag
    │ │ │ -00047350: 655f 7069 6563 655f 6c61 7965 7228 293b  e_piece_layer();
    │ │ │ -00047360: 0a09 7d0a 0a09 766f 6964 206d 6572 6b6c  ..}...void merkl
    │ │ │ -00047370: 655f 7472 6565 3a3a 636c 6561 7228 290a  e_tree::clear().
    │ │ │ -00047380: 097b 0a09 096d 5f74 7265 652e 636c 6561  .{...m_tree.clea
    │ │ │ -00047390: 7228 293b 0a09 096d 5f74 7265 652e 7368  r();...m_tree.sh
    │ │ │ -000473a0: 7269 6e6b 5f74 6f5f 6669 7428 293b 0a09  rink_to_fit();..
    │ │ │ -000473b0: 096d 5f62 6c6f 636b 5f76 6572 6966 6965  .m_block_verifie
    │ │ │ -000473c0: 642e 636c 6561 7228 293b 0a09 096d 5f6d  d.clear();...m_m
    │ │ │ -000473d0: 6f64 6520 3d20 6d6f 6465 5f74 3a3a 656d  ode = mode_t::em
    │ │ │ -000473e0: 7074 795f 7472 6565 3b0a 097d 0a0a 6e61  pty_tree;..}..na
    │ │ │ -000473f0: 6d65 7370 6163 6520 7b0a 0a3c 6469 7620  mespace {..
    .struct │ │ │ -00047430: 2069 6465 6e74 6974 790a 3c2f 6469 763e identity.
    │ │ │ -00047440: 097b 0a09 0962 6f6f 6c20 6f70 6572 6174 .{...bool operat │ │ │ -00047450: 6f72 2829 2862 6f6f 6c20 6229 2063 6f6e or()(bool b) con │ │ │ -00047460: 7374 207b 2072 6574 7572 6e20 623b 207d st { return b; } │ │ │ -00047470: 0a09 7d3b 0a7d 0a0a 0976 6f69 6420 6d65 ..};.}...void me │ │ │ -00047480: 726b 6c65 5f74 7265 653a 3a6c 6f61 645f rkle_tree::load_ │ │ │ -00047490: 7370 6172 7365 5f74 7265 6528 7370 616e sparse_tree(span │ │ │ -000474a0: 266c 743b 7368 6132 3536 5f68 6173 6820 <sha256_hash │ │ │ -000474b0: 636f 6e73 7426 6774 3b20 740a 0909 2c20 const> t..., │ │ │ -000474c0: 6269 7466 6965 6c64 2063 6f6e 7374 2661 bitfield const&a │ │ │ -000474d0: 6d70 3b20 6d61 736b 0a09 092c 2062 6974 mp; mask..., bit │ │ │ -000474e0: 6669 656c 6420 636f 6e73 7426 616d 703b field const& │ │ │ -000474f0: 2076 6572 6966 6965 6429 0a09 7b0a 0909 verified)..{... │ │ │ -00047500: 494e 5641 5249 414e 545f 4348 4543 4b3b INVARIANT_CHECK; │ │ │ -00047510: 0a0a 0909 2f2f 2054 6865 2073 697a 6520 ....// The size │ │ │ -00047520: 6f66 2074 6865 206d 6173 6b20 7368 6f75 of the mask shou │ │ │ -00047530: 6c64 206e 6f74 2065 7863 6565 6420 7468 ld not exceed th │ │ │ -00047540: 6520 7369 7a65 206f 6620 7468 6520 7472 e size of the tr │ │ │ -00047550: 6565 2c20 6275 7420 6120 6d61 736b 206c ee, but a mask l │ │ │ -00047560: 6172 6765 7220 7468 616e 0a09 092f 2f20 arger than...// │ │ │ -00047570: 7468 6520 7472 6565 2063 616e 2062 6520 the tree can be │ │ │ -00047580: 656e 636f 756e 7465 7265 6420 696e 2074 encountered in t │ │ │ -00047590: 6865 2022 7265 7375 6d65 2064 6174 6122 he "resume data" │ │ │ -000475a0: 2066 6f72 2073 6f6d 6520 7265 6173 6f6e for some reason │ │ │ -000475b0: 2c20 7065 7268 6170 7320 7468 6572 6520 , perhaps there │ │ │ -000475c0: 6973 0a09 092f 2f20 6120 6275 6720 696e is...// a bug in │ │ │ -000475d0: 2074 6865 2022 7265 7375 6d65 2064 6174 the "resume dat │ │ │ -000475e0: 6122 2067 656e 6572 6174 696f 6e20 616c a" generation al │ │ │ -000475f0: 676f 7269 7468 6d2e 0a09 092f 2f20 536f gorithm....// So │ │ │ -00047600: 2077 6520 6a75 7374 2070 726f 6365 7373 we just process │ │ │ -00047610: 206d 6173 6b20 6974 656d 7320 636f 756e mask items coun │ │ │ -00047620: 7420 7570 2074 6f20 7472 6565 2073 697a t up to tree siz │ │ │ -00047630: 652e 0a09 0969 6e74 2063 6f6e 7374 206d e....int const m │ │ │ -00047640: 6173 6b5f 7369 7a65 203d 2073 7464 3a3a ask_size = std:: │ │ │ -00047650: 6d69 6e28 6d61 736b 2e73 697a 6528 292c min(mask.size(), │ │ │ -00047660: 2069 6e74 2873 697a 6528 2929 293b 0a0a int(size()));.. │ │ │ -00047670: 0909 696e 7420 636f 6e73 7420 6669 7273 ..int const firs │ │ │ -00047680: 745f 626c 6f63 6b20 3d20 626c 6f63 6b5f t_block = block_ │ │ │ -00047690: 6c61 7965 725f 7374 6172 7428 293b 0a09 layer_start();.. │ │ │ -000476a0: 0969 6e74 2063 6f6e 7374 2065 6e64 5f62 .int const end_b │ │ │ -000476b0: 6c6f 636b 203d 2066 6972 7374 5f62 6c6f lock = first_blo │ │ │ -000476c0: 636b 202b 206d 5f6e 756d 5f62 6c6f 636b ck + m_num_block │ │ │ -000476d0: 733b 0a0a 0909 544f 5252 454e 545f 4153 s;....TORRENT_AS │ │ │ -000476e0: 5345 5254 2866 6972 7374 5f62 6c6f 636b SERT(first_block │ │ │ -000476f0: 2026 6c74 3b20 696e 7428 7369 7a65 2829 < int(size() │ │ │ -00047700: 2929 3b0a 0909 544f 5252 454e 545f 4153 ));...TORRENT_AS │ │ │ -00047710: 5345 5254 2865 6e64 5f62 6c6f 636b 2026 SERT(end_block & │ │ │ -00047720: 6c74 3b3d 2069 6e74 2873 697a 6528 2929 lt;= int(size()) │ │ │ -00047730: 293b 0a0a 0909 2f2f 2069 6620 7468 6520 );....// if the │ │ │ -00047740: 6d61 736b 2063 6f76 6572 7320 616c 6c20 mask covers all │ │ │ -00047750: 626c 6f63 6b73 2c20 676f 2073 7472 6169 blocks, go strai │ │ │ -00047760: 6768 7420 746f 2062 6c6f 636b 5f6c 6179 ght to block_lay │ │ │ -00047770: 6572 0a09 092f 2f20 6d6f 6465 2c20 616e er...// mode, an │ │ │ -00047780: 6420 7661 6c69 6461 7465 0a09 0969 6620 d validate...if │ │ │ -00047790: 2828 6669 7273 745f 626c 6f63 6b20 266c ((first_block &l │ │ │ -000477a0: 743b 206d 6173 6b5f 7369 7a65 2920 2661 t; mask_size) &a │ │ │ -000477b0: 6d70 3b26 616d 703b 2028 656e 645f 626c mp;& (end_bl │ │ │ -000477c0: 6f63 6b20 266c 743b 3d20 6d61 736b 5f73 ock <= mask_s │ │ │ -000477d0: 697a 6529 0a09 0909 2661 6d70 3b26 616d ize)....&&am │ │ │ -000477e0: 703b 2073 7464 3a3a 616c 6c5f 6f66 286d p; std::all_of(m │ │ │ -000477f0: 6173 6b2e 6265 6769 6e28 2920 2b20 6669 ask.begin() + fi │ │ │ -00047800: 7273 745f 626c 6f63 6b2c 206d 6173 6b2e rst_block, mask. │ │ │ -00047810: 6265 6769 6e28 2920 2b20 656e 645f 626c begin() + end_bl │ │ │ -00047820: 6f63 6b2c 2069 6465 6e74 6974 7928 2929 ock, identity()) │ │ │ -00047830: 290a 0909 7b0a 0909 092f 2f20 7468 6520 )...{....// the │ │ │ -00047840: 696e 6465 7820 696e 2074 2074 6861 7420 index in t that │ │ │ -00047850: 706f 696e 7473 2074 6f20 6669 7273 745f points to first_ │ │ │ -00047860: 626c 6f63 6b0a 0909 0961 7574 6f20 636f block....auto co │ │ │ -00047870: 6e73 7420 626c 6f63 6b5f 696e 6465 7820 nst block_index │ │ │ -00047880: 3d20 7374 643a 3a63 6f75 6e74 5f69 6628 = std::count_if( │ │ │ -00047890: 6d61 736b 2e62 6567 696e 2829 2c20 6d61 mask.begin(), ma │ │ │ -000478a0: 736b 2e62 6567 696e 2829 202b 2066 6972 sk.begin() + fir │ │ │ -000478b0: 7374 5f62 6c6f 636b 2c20 6964 656e 7469 st_block, identi │ │ │ -000478c0: 7479 2829 293b 0a3c 2f70 7265 3e3c 2f74 ty());.
    relevanc │ │ │ -00047900: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/merkle_ │ │ │ -00047940: 7472 6565 2e63 7070 3a33 3037 3c2f 613e tree.cpp:307 │ │ │ -00047950: 3c2f 7464 3e3c 7464 3e74 6869 7320 6361 this ca │ │ │ -00047960: 6e20 6265 206f 7074 696d 697a 6564 2062 n be optimized b │ │ │ -00047970: 7920 7573 696e 6720 6d5f 7472 6565 2061 y using m_tree a │ │ │ -00047980: 7320 7374 6f72 6167 6520 746f 2066 696c s storage to fil │ │ │ -00047990: 6c20 7468 6973 2074 7265 6520 696e 746f l this tree into │ │ │ -000479a0: 2c20 616e 6420 7468 656e 2063 6c65 6172 , and then clear │ │ │ -000479b0: 2069 7420 6966 2074 6865 2068 6173 6865 it if the hashe │ │ │ -000479c0: 7320 6661 696c 3c2f 7464 3e3c 2f74 723e s fail │ │ │ -000479d0: 3c74 7220 6964 3d22 3137 3622 2073 7479 │ │ │ -00047a00: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00047a10: 3c68 323e 7468 6973 2063 616e 2062 6520

    this can be │ │ │ -00047a20: 6f70 7469 6d69 7a65 6420 6279 2075 7369 optimized by usi │ │ │ -00047a30: 6e67 206d 5f74 7265 6520 6173 2073 746f ng m_tree as sto │ │ │ -00047a40: 7261 6765 2074 6f20 6669 6c6c 2074 6869 rage to fill thi │ │ │ -00047a50: 730a 7472 6565 2069 6e74 6f2c 2061 6e64 s.tree into, and │ │ │ -00047a60: 2074 6865 6e20 636c 6561 7220 6974 2069 then clear it i │ │ │ -00047a70: 6620 7468 6520 6861 7368 6573 2066 6169 f the hashes fai │ │ │ -00047a80: 6c3c 2f68 323e 3c68 343e 2e2e 2f73 7263 l

    ../src │ │ │ -00047a90: 2f6d 6572 6b6c 655f 7472 6565 2e63 7070 /merkle_tree.cpp │ │ │ -00047aa0: 3a33 3037 3c2f 6834 3e3c 7072 6520 7374 :307

    .{...INVARIAN
    │ │ │ -00047af0: 545f 4348 4543 4b3b 0a0a 0909 2f2f 2061  T_CHECK;....// a
    │ │ │ -00047b00: 7320 7765 2073 6574 2074 6865 2068 6173  s we set the has
    │ │ │ -00047b10: 6865 7320 6f66 2069 6e74 6572 696f 7220  hes of interior 
    │ │ │ -00047b20: 6e6f 6465 732c 2077 6520 6d61 7920 6265  nodes, we may be
    │ │ │ -00047b30: 2061 626c 6520 746f 2076 616c 6964 6174   able to validat
    │ │ │ -00047b40: 650a 0909 2f2f 2062 6c6f 636b 2068 6173  e...// block has
    │ │ │ -00047b50: 6865 7320 7468 6174 2077 6520 6861 6420  hes that we had 
    │ │ │ -00047b60: 7369 6e63 6520 6561 726c 6965 722e 2041  since earlier. A
    │ │ │ -00047b70: 6e79 2062 6c6f 636b 7320 7468 6174 2063  ny blocks that c
    │ │ │ -00047b80: 616e 2062 650a 0909 2f2f 2076 616c 6964  an be...// valid
    │ │ │ -00047b90: 6174 6564 2c20 616e 6420 6661 696c 6564  ated, and failed
    │ │ │ -00047ba0: 2c20 6172 6520 6164 6465 6420 746f 2074  , are added to t
    │ │ │ -00047bb0: 6869 7320 6c69 7374 0a09 0961 6464 5f68  his list...add_h
    │ │ │ -00047bc0: 6173 6865 735f 7265 7375 6c74 5f74 2072  ashes_result_t r
    │ │ │ -00047bd0: 6574 3b0a 0a09 092f 2f20 7765 2061 6c72  et;....// we alr
    │ │ │ -00047be0: 6561 6479 2068 6176 6520 616c 6c20 6861  eady have all ha
    │ │ │ -00047bf0: 7368 6573 0a09 0969 6620 286d 5f6d 6f64  shes...if (m_mod
    │ │ │ -00047c00: 6520 3d3d 206d 6f64 655f 743a 3a62 6c6f  e == mode_t::blo
    │ │ │ -00047c10: 636b 5f6c 6179 6572 290a 0909 7b0a 0909  ck_layer)...{...
    │ │ │ -00047c20: 092f 2f20 7369 6e63 6520 7765 2772 6520  .// since we're 
    │ │ │ -00047c30: 616c 7265 6164 7920 6f6e 2074 6865 2062  already on the b
    │ │ │ -00047c40: 6c6f 636b 206c 6179 6572 206d 6f64 652c  lock layer mode,
    │ │ │ -00047c50: 2077 6520 6861 7665 2074 6865 2077 686f   we have the who
    │ │ │ -00047c60: 6c65 0a09 0909 2f2f 2074 7265 652c 2061  le....// tree, a
    │ │ │ -00047c70: 6e64 2077 6527 7665 2061 6c72 6561 6479  nd we've already
    │ │ │ -00047c80: 2072 6570 6f72 7465 6420 616e 7920 7069   reported any pi
    │ │ │ -00047c90: 6563 6573 2061 7320 7061 7373 696e 6720  eces as passing 
    │ │ │ -00047ca0: 7468 6174 206d 6179 0a09 0909 2f2f 2068  that may....// h
    │ │ │ -00047cb0: 6176 6520 6578 6973 7465 6420 696e 2074  ave existed in t
    │ │ │ -00047cc0: 6865 2074 7265 6520 7768 656e 2077 6520  he tree when we 
    │ │ │ -00047cd0: 636f 6d70 6c65 7465 6420 6974 2e20 4174  completed it. At
    │ │ │ -00047ce0: 2074 6869 7320 706f 696e 7420 6e6f 0a09   this point no..
    │ │ │ -00047cf0: 0909 2f2f 206d 6f72 6520 7069 6563 6573  ..// more pieces
    │ │ │ -00047d00: 2073 686f 756c 6420 6265 2072 6570 6f72   should be repor
    │ │ │ -00047d10: 7465 6420 6173 2070 6173 7365 640a 0909  ted as passed...
    │ │ │ -00047d20: 0972 6574 7572 6e20 7265 743b 0a09 097d  .return ret;...}
    │ │ │ -00047d30: 0a0a 0909 616c 6c6f 6361 7465 5f66 756c  ....allocate_ful
    │ │ │ -00047d40: 6c28 293b 0a0a 3c64 6976 2073 7479 6c65  l();..
    ..int const │ │ │ -00047d80: 6c65 6166 5f63 6f75 6e74 203d 206d 6572 leaf_count = mer │ │ │ -00047d90: 6b6c 655f 6e75 6d5f 6c65 6166 7328 696e kle_num_leafs(in │ │ │ -00047da0: 7428 6861 7368 6573 2e73 697a 6528 2929 t(hashes.size()) │ │ │ -00047db0: 293b 0a3c 2f64 6976 3e09 0961 7578 3a3a );.
    ..aux:: │ │ │ -00047dc0: 7665 6374 6f72 266c 743b 7368 6132 3536 vector<sha256 │ │ │ -00047dd0: 5f68 6173 6826 6774 3b20 7472 6565 286d _hash> tree(m │ │ │ -00047de0: 6572 6b6c 655f 6e75 6d5f 6e6f 6465 7328 erkle_num_nodes( │ │ │ -00047df0: 6c65 6166 5f63 6f75 6e74 2929 3b0a 0909 leaf_count));... │ │ │ -00047e00: 7374 643a 3a63 6f70 7928 6861 7368 6573 std::copy(hashes │ │ │ -00047e10: 2e62 6567 696e 2829 2c20 6861 7368 6573 .begin(), hashes │ │ │ -00047e20: 2e65 6e64 2829 2c20 7472 6565 2e65 6e64 .end(), tree.end │ │ │ -00047e30: 2829 202d 206c 6561 665f 636f 756e 7429 () - leaf_count) │ │ │ -00047e40: 3b0a 0a09 092f 2f20 7468 6520 656e 6420 ;....// the end │ │ │ -00047e50: 6f66 2061 2066 696c 6520 6973 2061 2073 of a file is a s │ │ │ -00047e60: 7065 6369 616c 2063 6173 652c 2077 6520 pecial case, we │ │ │ -00047e70: 6d61 7920 6e65 6564 2074 6f20 7061 6420 may need to pad │ │ │ -00047e80: 7468 6520 6c65 6166 206c 6179 6572 0a09 the leaf layer.. │ │ │ -00047e90: 0969 6620 286c 6561 665f 636f 756e 7420 .if (leaf_count │ │ │ -00047ea0: 2667 743b 2068 6173 6865 732e 7369 7a65 > hashes.size │ │ │ -00047eb0: 2829 290a 0909 7b0a 0909 0969 6e74 2063 ())...{....int c │ │ │ -00047ec0: 6f6e 7374 206c 6561 665f 6c61 7965 725f onst leaf_layer_ │ │ │ -00047ed0: 7369 7a65 203d 206e 756d 5f6c 6561 6673 size = num_leafs │ │ │ -00047ee0: 2829 3b0a 0909 092f 2f20 6173 7375 6d69 ();....// assumi │ │ │ -00047ef0: 6e67 2075 6e63 6c65 5f68 6173 6865 7320 ng uncle_hashes │ │ │ -00047f00: 6c65 6164 2061 6c6c 2074 6865 2077 6179 lead all the way │ │ │ -00047f10: 2074 6f20 7468 6520 726f 6f74 2c20 7468 to the root, th │ │ │ -00047f20: 6579 2074 656c 6c20 7573 0a09 0909 2f2f ey tell us....// │ │ │ -00047f30: 2068 6f77 206d 616e 7920 6c61 7965 7273 how many layers │ │ │ -00047f40: 2064 6f77 6e20 7765 2061 7265 0a09 0909 down we are.... │ │ │ -00047f50: 696e 7420 636f 6e73 7420 696e 7365 7274 int const insert │ │ │ -00047f60: 5f6c 6179 6572 5f73 697a 6520 3d20 6c65 _layer_size = le │ │ │ -00047f70: 6166 5f63 6f75 6e74 2026 6c74 3b26 6c74 af_count << │ │ │ -00047f80: 3b20 756e 636c 655f 6861 7368 6573 2e73 ; uncle_hashes.s │ │ │ -00047f90: 697a 6528 293b 0a09 0909 6966 2028 6c65 ize();....if (le │ │ │ -00047fa0: 6166 5f6c 6179 6572 5f73 697a 6520 213d af_layer_size != │ │ │ -00047fb0: 2069 6e73 6572 745f 6c61 7965 725f 7369 insert_layer_si │ │ │ -00047fc0: 7a65 290a 0909 097b 0a09 0909 0973 6861 ze)....{.....sha │ │ │ -00047fd0: 3235 365f 6861 7368 2063 6f6e 7374 2070 256_hash const p │ │ │ -00047fe0: 6164 5f68 6173 6820 3d20 6d65 726b 6c65 ad_hash = merkle │ │ │ -00047ff0: 5f70 6164 286c 6561 665f 6c61 7965 725f _pad(leaf_layer_ │ │ │ -00048000: 7369 7a65 2c20 696e 7365 7274 5f6c 6179 size, insert_lay │ │ │ -00048010: 6572 5f73 697a 6529 3b0a 0909 0909 666f er_size);.....fo │ │ │ -00048020: 7220 2869 6e74 2069 203d 2069 6e74 2868 r (int i = int(h │ │ │ -00048030: 6173 6865 732e 7369 7a65 2829 293b 2069 ashes.size()); i │ │ │ -00048040: 2026 6c74 3b20 6c65 6166 5f63 6f75 6e74 < leaf_count │ │ │ -00048050: 3b20 2b2b 6929 0a09 0909 0909 7472 6565 ; ++i)......tree │ │ │ -00048060: 5b74 7265 652e 656e 645f 696e 6465 7828 [tree.end_index( │ │ │ -00048070: 2920 2d20 6c65 6166 5f63 6f75 6e74 202b ) - leaf_count + │ │ │ -00048080: 2069 5d20 3d20 7061 645f 6861 7368 3b0a i] = pad_hash;. │ │ │ -00048090: 0909 097d 0a09 097d 0a0a 0909 6d65 726b ...}...}....merk │ │ │ -000480a0: 6c65 5f66 696c 6c5f 7472 6565 2874 7265 le_fill_tree(tre │ │ │ -000480b0: 652c 206c 6561 665f 636f 756e 7429 3b0a e, leaf_count);. │ │ │ -000480c0: 0a09 0969 6e74 2063 6f6e 7374 2062 6173 ...int const bas │ │ │ -000480d0: 655f 6e75 6d5f 6c61 7965 7273 203d 206d e_num_layers = m │ │ │ -000480e0: 6572 6b6c 655f 6e75 6d5f 6c61 7965 7273 erkle_num_layers │ │ │ -000480f0: 286c 6561 665f 636f 756e 7429 3b0a 0a09 (leaf_count);... │ │ │ -00048100: 092f 2f20 7468 6973 2069 7320 7468 6520 .// this is the │ │ │ -00048110: 696e 6465 7820 6f66 2074 6865 206e 6f64 index of the nod │ │ │ -00048120: 6520 7768 6572 6520 7765 276c 6c20 696e e where we'll in │ │ │ -00048130: 7365 7274 2074 6865 2072 6f6f 7420 6f66 sert the root of │ │ │ -00048140: 2074 6865 0a09 092f 2f20 7375 6274 7265 the...// subtre │ │ │ -00048150: 6520 2874 7265 6529 2e20 4974 2773 2061 e (tree). It's a │ │ │ -00048160: 6c73 6f20 7468 6520 6861 7368 2074 6865 lso the hash the │ │ │ -00048170: 2075 6e63 6c65 5f68 6173 6865 7320 6172 uncle_hashes ar │ │ │ -00048180: 6520 6865 7265 2074 6f20 7072 6f76 650a e here to prove. │ │ │ -00048190: 0909 2f2f 2069 7320 7661 6c69 642e 0a09 ..// is valid... │ │ │ -000481a0: 0969 6e74 2063 6f6e 7374 2069 6e73 6572 .int const inser │ │ │ -000481b0: 745f 726f 6f74 5f69 6478 203d 2064 6573 t_root_idx = des │ │ │ -000481c0: 745f 7374 6172 745f 6964 7820 2667 743b t_start_idx > │ │ │ -000481d0: 2667 743b 2062 6173 655f 6e75 6d5f 6c61 > base_num_la │ │ │ -000481e0: 7965 7273 3b0a 0a09 092f 2f20 7374 6172 yers;....// star │ │ │ -000481f0: 7420 7769 7468 2076 616c 6964 6174 696e t with validatin │ │ │ -00048200: 6720 7468 6520 7072 6f6f 6673 2c20 616e g the proofs, an │ │ │ -00048210: 6420 696e 7365 7274 696e 6720 7468 656d d inserting them │ │ │ -00048220: 2061 7320 7765 2067 6f2e 0a09 0969 6620 as we go....if │ │ │ -00048230: 2821 6d65 726b 6c65 5f76 616c 6964 6174 (!merkle_validat │ │ │ -00048240: 655f 616e 645f 696e 7365 7274 5f70 726f e_and_insert_pro │ │ │ -00048250: 6f66 7328 6d5f 7472 6565 2c20 696e 7365 ofs(m_tree, inse │ │ │ -00048260: 7274 5f72 6f6f 745f 6964 782c 2074 7265 rt_root_idx, tre │ │ │ -00048270: 655b 305d 2c20 756e 636c 655f 6861 7368 e[0], uncle_hash │ │ │ -00048280: 6573 2929 0a09 0909 7265 7475 726e 207b es))....return { │ │ │ -00048290: 7d3b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f };.
    │ │ │ -000482c0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -000482d0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00048300: 2f73 7263 2f6d 6572 6b6c 655f 7472 6565 /src/merkle_tree │ │ │ -00048310: 2e63 7070 3a33 3535 3c2f 613e 3c2f 7464 .cpp:355a piece out │ │ │ -00048330: 7369 6465 206f 6620 7468 6973 2072 616e side of this ran │ │ │ -00048340: 6765 206d 6179 2061 6c73 6f20 6661 696c ge may also fail │ │ │ -00048350: 2c20 6966 206f 6e65 206f 6620 7468 6520 , if one of the │ │ │ -00048360: 756e 636c 6520 6861 7368 6573 2069 7320 uncle hashes is │ │ │ -00048370: 6174 2074 6865 206c 6179 6572 2072 6967 at the layer rig │ │ │ -00048380: 6874 2061 626f 7665 2074 6865 2062 6c6f ht above the blo │ │ │ -00048390: 636b 2068 6173 6865 733c 2f74 643e 3c2f ck hashes

    a piece o │ │ │ -000483f0: 7574 7369 6465 206f 6620 7468 6973 2072 utside of this r │ │ │ -00048400: 616e 6765 206d 6179 2061 6c73 6f20 6661 ange may also fa │ │ │ -00048410: 696c 2c20 6966 206f 6e65 206f 6620 7468 il, if one of th │ │ │ -00048420: 6520 756e 636c 650a 6861 7368 6573 2069 e uncle.hashes i │ │ │ -00048430: 7320 6174 2074 6865 206c 6179 6572 2072 s at the layer r │ │ │ -00048440: 6967 6874 2061 626f 7665 2074 6865 2062 ight above the b │ │ │ -00048450: 6c6f 636b 2068 6173 6865 733c 2f68 323e lock hashes

    │ │ │ -00048460: 3c68 343e 2e2e 2f73 7263 2f6d 6572 6b6c

    ../src/merkl │ │ │ -00048470: 655f 7472 6565 2e63 7070 3a33 3535 3c2f e_tree.cpp:355
    ..i
    │ │ │ -000484c0: 6e74 2063 6f6e 7374 2069 6e73 6572 745f  nt const insert_
    │ │ │ -000484d0: 726f 6f74 5f69 6478 203d 2064 6573 745f  root_idx = dest_
    │ │ │ -000484e0: 7374 6172 745f 6964 7820 2667 743b 2667  start_idx >&g
    │ │ │ -000484f0: 743b 2062 6173 655f 6e75 6d5f 6c61 7965  t; base_num_laye
    │ │ │ -00048500: 7273 3b0a 0a09 092f 2f20 7374 6172 7420  rs;....// start 
    │ │ │ -00048510: 7769 7468 2076 616c 6964 6174 696e 6720  with validating 
    │ │ │ -00048520: 7468 6520 7072 6f6f 6673 2c20 616e 6420  the proofs, and 
    │ │ │ -00048530: 696e 7365 7274 696e 6720 7468 656d 2061  inserting them a
    │ │ │ -00048540: 7320 7765 2067 6f2e 0a09 0969 6620 2821  s we go....if (!
    │ │ │ -00048550: 6d65 726b 6c65 5f76 616c 6964 6174 655f  merkle_validate_
    │ │ │ -00048560: 616e 645f 696e 7365 7274 5f70 726f 6f66  and_insert_proof
    │ │ │ -00048570: 7328 6d5f 7472 6565 2c20 696e 7365 7274  s(m_tree, insert
    │ │ │ -00048580: 5f72 6f6f 745f 6964 782c 2074 7265 655b  _root_idx, tree[
    │ │ │ -00048590: 305d 2c20 756e 636c 655f 6861 7368 6573  0], uncle_hashes
    │ │ │ -000485a0: 2929 0a09 0909 7265 7475 726e 207b 7d3b  ))....return {};
    │ │ │ -000485b0: 0a0a 0909 2f2f 2066 6972 7374 2066 696c  ....// first fil
    │ │ │ -000485c0: 6c20 696e 2074 6865 2073 7562 7472 6565  l in the subtree
    │ │ │ -000485d0: 206f 6620 6b6e 6f77 6e20 6861 7368 6573   of known hashes
    │ │ │ -000485e0: 2066 726f 6d20 7468 6520 6261 7365 206c   from the base l
    │ │ │ -000485f0: 6179 6572 0a09 0961 7574 6f20 636f 6e73  ayer...auto cons
    │ │ │ -00048600: 7420 6e75 6d5f 6c65 6166 7320 3d20 6d65  t num_leafs = me
    │ │ │ -00048610: 726b 6c65 5f6e 756d 5f6c 6561 6673 286d  rkle_num_leafs(m
    │ │ │ -00048620: 5f6e 756d 5f62 6c6f 636b 7329 3b0a 0909  _num_blocks);...
    │ │ │ -00048630: 6175 746f 2063 6f6e 7374 2066 6972 7374  auto const first
    │ │ │ -00048640: 5f6c 6561 6620 3d20 6d65 726b 6c65 5f66  _leaf = merkle_f
    │ │ │ -00048650: 6972 7374 5f6c 6561 6628 6e75 6d5f 6c65  irst_leaf(num_le
    │ │ │ -00048660: 6166 7329 3b0a 0a09 092f 2f20 7468 6973  afs);....// this
    │ │ │ -00048670: 2069 7320 7468 6520 7374 6172 7420 6f66   is the start of
    │ │ │ -00048680: 2074 6865 206c 6561 6620 6c61 7965 7220   the leaf layer 
    │ │ │ -00048690: 6f66 2022 7472 6565 222e 2057 6527 6c6c  of "tree". We'll
    │ │ │ -000486a0: 2075 7365 2074 6869 730a 0909 2f2f 2076   use this...// v
    │ │ │ -000486b0: 6172 6961 626c 6520 746f 2073 7465 7020  ariable to step 
    │ │ │ -000486c0: 7570 7761 7264 7320 746f 7761 7264 7320  upwards towards 
    │ │ │ -000486d0: 7468 6520 726f 6f74 0a09 0969 6e74 2073  the root...int s
    │ │ │ -000486e0: 6f75 7263 655f 6375 7273 6f72 203d 2069  ource_cursor = i
    │ │ │ -000486f0: 6e74 2874 7265 652e 7369 7a65 2829 2920  nt(tree.size()) 
    │ │ │ -00048700: 2d20 6c65 6166 5f63 6f75 6e74 3b0a 0909  - leaf_count;...
    │ │ │ -00048710: 2f2f 2074 6865 2072 756e 6e69 6e67 2069  // the running i
    │ │ │ -00048720: 6e64 6578 2069 6e20 7468 6520 6c6f 6f70  ndex in the loop
    │ │ │ -00048730: 0a09 0969 6e74 2064 6573 745f 6375 7273  ...int dest_curs
    │ │ │ -00048740: 6f72 203d 2064 6573 745f 7374 6172 745f  or = dest_start_
    │ │ │ -00048750: 6964 783b 0a0a 0909 2f2f 2074 6865 206e  idx;....// the n
    │ │ │ -00048760: 756d 6265 7220 6f66 2074 7265 6520 6c65  umber of tree le
    │ │ │ -00048770: 7665 6c73 2069 6e20 6120 7069 6563 6520  vels in a piece 
    │ │ │ -00048780: 6861 7368 2e20 3020 6d65 616e 7320 7468  hash. 0 means th
    │ │ │ -00048790: 6520 626c 6f63 6b20 6c61 7965 7220 6973  e block layer is
    │ │ │ -000487a0: 0a09 092f 2f20 7468 6520 7361 6d65 2061  ...// the same a
    │ │ │ -000487b0: 7320 7468 6520 7069 6563 6520 6c61 7965  s the piece laye
    │ │ │ -000487c0: 720a 0909 696e 7420 636f 6e73 7420 6261  r...int const ba
    │ │ │ -000487d0: 7365 203d 2070 6965 6365 5f6c 6576 656c  se = piece_level
    │ │ │ -000487e0: 7328 293b 0a0a 3c64 6976 2073 7479 6c65  s();..
    ..for (int l │ │ │ -00048820: 6179 6572 5f73 697a 6520 3d20 6c65 6166 ayer_size = leaf │ │ │ -00048830: 5f63 6f75 6e74 3b20 6c61 7965 725f 7369 _count; layer_si │ │ │ -00048840: 7a65 2021 3d20 303b 206c 6179 6572 5f73 ze != 0; layer_s │ │ │ -00048850: 697a 6520 2f3d 2032 290a 3c2f 6469 763e ize /= 2).
    │ │ │ -00048860: 0909 7b0a 0909 0966 6f72 2028 696e 7420 ..{....for (int │ │ │ -00048870: 6920 3d20 303b 2069 2026 6c74 3b20 6c61 i = 0; i < la │ │ │ -00048880: 7965 725f 7369 7a65 3b20 2b2b 6929 0a09 yer_size; ++i).. │ │ │ -00048890: 0909 7b0a 0909 0909 696e 7420 636f 6e73 ..{.....int cons │ │ │ -000488a0: 7420 6473 745f 6964 7820 3d20 6465 7374 t dst_idx = dest │ │ │ -000488b0: 5f63 7572 736f 7220 2b20 693b 0a09 0909 _cursor + i;.... │ │ │ -000488c0: 0969 6e74 2063 6f6e 7374 2073 7263 5f69 .int const src_i │ │ │ -000488d0: 6478 203d 2073 6f75 7263 655f 6375 7273 dx = source_curs │ │ │ -000488e0: 6f72 202b 2069 3b0a 0909 0909 6966 2028 or + i;.....if ( │ │ │ -000488f0: 6861 735f 6e6f 6465 2864 7374 5f69 6478 has_node(dst_idx │ │ │ -00048900: 2929 0a09 0909 097b 0a09 0909 0909 6966 )).....{......if │ │ │ -00048910: 2028 6d5f 7472 6565 5b64 7374 5f69 6478 (m_tree[dst_idx │ │ │ -00048920: 5d20 213d 2074 7265 655b 7372 635f 6964 ] != tree[src_id │ │ │ -00048930: 785d 290a 0909 0909 097b 0a09 0909 0909 x])......{...... │ │ │ -00048940: 092f 2f20 7468 6973 206d 7573 7420 6265 .// this must be │ │ │ -00048950: 2061 2062 6c6f 636b 2068 6173 6820 6265 a block hash be │ │ │ -00048960: 6361 7573 6520 696e 6e65 7220 6e6f 6465 cause inner node │ │ │ -00048970: 7320 6172 6520 6e6f 7420 6669 6c6c 6564 s are not filled │ │ │ -00048980: 2069 6e20 756e 7469 6c0a 0909 0909 0909 in until....... │ │ │ -00048990: 2f2f 2074 6865 7920 6361 6e20 6265 2076 // they can be v │ │ │ -000489a0: 6572 6966 6965 642e 2054 6869 7320 6173 erified. This as │ │ │ -000489b0: 7365 7274 2065 6e73 7572 6573 2077 6527 sert ensures we' │ │ │ -000489c0: 7265 2061 7420 7468 650a 0909 0909 0909 re at the....... │ │ │ -000489d0: 2f2f 206c 6561 6620 6c61 7965 7220 6f66 // leaf layer of │ │ │ -000489e0: 2074 6865 2066 696c 6520 7472 6565 0a09 the file tree.. │ │ │ -000489f0: 0909 0909 0954 4f52 5245 4e54 5f41 5353 .....TORRENT_ASS │ │ │ -00048a00: 4552 5428 6473 745f 6964 7820 2667 743b ERT(dst_idx > │ │ │ -00048a10: 3d20 6669 7273 745f 6c65 6166 293b 0a0a = first_leaf);.. │ │ │ -00048a20: 0909 0909 0909 696e 7420 636f 6e73 7420 ......int const │ │ │ -00048a30: 706f 7320 3d20 6473 745f 6964 7820 2d20 pos = dst_idx - │ │ │ -00048a40: 6669 7273 745f 6c65 6166 3b0a 0909 0909 first_leaf;..... │ │ │ -00048a50: 0909 6175 746f 2063 6f6e 7374 2070 6965 ..auto const pie │ │ │ -00048a60: 6365 203d 2070 6965 6365 5f69 6e64 6578 ce = piece_index │ │ │ -00048a70: 5f74 7b70 6f73 2026 6774 3b26 6774 3b20 _t{pos >> │ │ │ -00048a80: 6d5f 626c 6f63 6b73 5f70 6572 5f70 6965 m_blocks_per_pie │ │ │ -00048a90: 6365 5f6c 6f67 7d20 2b20 6669 6c65 5f70 ce_log} + file_p │ │ │ -00048aa0: 6965 6365 5f6f 6666 7365 743b 0a09 0909 iece_offset;.... │ │ │ -00048ab0: 0909 0969 6e74 2063 6f6e 7374 2062 6c6f ...int const blo │ │ │ -00048ac0: 636b 203d 2070 6f73 2026 616d 703b 2028 ck = pos & ( │ │ │ -00048ad0: 2831 2026 6c74 3b26 6c74 3b20 6d5f 626c (1 << m_bl │ │ │ -00048ae0: 6f63 6b73 5f70 6572 5f70 6965 6365 5f6c ocks_per_piece_l │ │ │ -00048af0: 6f67 2920 2d20 3129 3b0a 0a09 0909 0909 og) - 1);....... │ │ │ -00048b00: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -00048b10: 706f 7320 266c 743b 206d 5f6e 756d 5f62 pos < m_num_b │ │ │ -00048b20: 6c6f 636b 7329 3b0a 0909 0909 0909 6966 locks);.......if │ │ │ -00048b30: 2028 2172 6574 2e66 6169 6c65 642e 656d (!ret.failed.em │ │ │ -00048b40: 7074 7928 2920 2661 6d70 3b26 616d 703b pty() && │ │ │ -00048b50: 2072 6574 2e66 6169 6c65 642e 6261 636b ret.failed.back │ │ │ -00048b60: 2829 2e66 6972 7374 203d 3d20 7069 6563 ().first == piec │ │ │ -00048b70: 6529 0a09 0909 0909 0909 7265 742e 6661 e)........ret.fa │ │ │ -00048b80: 696c 6564 2e62 6163 6b28 292e 7365 636f iled.back().seco │ │ │ -00048b90: 6e64 2e70 7573 685f 6261 636b 2862 6c6f nd.push_back(blo │ │ │ -00048ba0: 636b 293b 0a09 0909 0909 0965 6c73 650a ck);.......else. │ │ │ -00048bb0: 0909 0909 0909 0972 6574 2e66 6169 6c65 .......ret.faile │ │ │ -00048bc0: 642e 656d 706c 6163 655f 6261 636b 2870 d.emplace_back(p │ │ │ -00048bd0: 6965 6365 2c20 7374 643a 3a76 6563 746f iece, std::vecto │ │ │ -00048be0: 7226 6c74 3b69 6e74 2667 743b 7b62 6c6f r<int>{blo │ │ │ -00048bf0: 636b 7d29 3b0a 0a09 0909 0909 092f 2f20 ck});........// │ │ │ -00048c00: 6e6f 7720 7468 6174 2074 6869 7320 6861 now that this ha │ │ │ -00048c10: 7368 2068 6173 2062 6565 6e20 7265 706f sh has been repo │ │ │ -00048c20: 7274 6564 2061 7320 6661 696c 696e 672c rted as failing, │ │ │ -00048c30: 2077 650a 0909 0909 0909 2f2f 2063 616e we.......// can │ │ │ -00048c40: 2063 6c65 6172 2069 742e 2054 6869 7320 clear it. This │ │ │ -00048c50: 7769 6c6c 2070 7265 7665 6e74 2069 7420 will prevent it │ │ │ -00048c60: 6672 6f6d 2062 6569 6e67 0a09 0909 0909 from being...... │ │ │ -00048c70: 092f 2f20 7265 706f 7274 6564 2061 7320 .// reported as │ │ │ -00048c80: 6661 696c 696e 6720 6167 6169 6e2e 0a09 failing again... │ │ │ -00048c90: 0909 0909 096d 5f74 7265 655b 6473 745f .....m_tree[dst_ │ │ │ -00048ca0: 6964 785d 2e63 6c65 6172 2829 3b0a 0909 idx].clear();... │ │ │ -00048cb0: 0909 097d 0a09 0909 0909 656c 7365 2069 ...}......else i │ │ │ -00048cc0: 6620 2864 7374 5f69 6478 2026 6774 3b3d f (dst_idx >= │ │ │ -00048cd0: 2066 6972 7374 5f6c 6561 6629 0a3c 2f70 first_leaf).

    re │ │ │ -00048d10: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ -00048d50: 6572 6b6c 655f 7472 6565 2e63 7070 3a34 erkle_tree.cpp:4 │ │ │ -00048d60: 3335 3c2f 613e 3c2f 7464 3e3c 7464 3e69 35i │ │ │ -00048d70: 6e73 7465 6164 206f 6620 6f76 6572 7772 nstead of overwr │ │ │ -00048d80: 6974 696e 6720 7468 6520 726f 6f74 2061 iting the root a │ │ │ -00048d90: 6e64 2063 6f6d 7061 7269 6e67 2069 7420 nd comparing it │ │ │ -00048da0: 6167 6169 6e73 7420 6861 7368 6573 5b5d against hashes[] │ │ │ -00048db0: 2c20 7772 6974 6520 6120 6675 6e63 7469 , write a functi │ │ │ -00048dc0: 6f6e 7320 7468 6174 202a 7661 6c69 6461 ons that *valida │ │ │ -00048dd0: 7465 732a 2061 2074 7265 6520 6279 206a tes* a tree by j │ │ │ -00048de0: 7573 7420 6669 6c6c 696e 6720 6974 2075 ust filling it u │ │ │ -00048df0: 7020 746f 2074 6865 206c 6576 656c 2062 p to the level b │ │ │ -00048e00: 656c 6f77 2074 6865 2072 6f6f 7420 616e elow the root an │ │ │ -00048e10: 6420 7468 656e 2076 616c 6964 6174 6573 d then validates │ │ │ -00048e20: 2069 742e 3c2f 7464 3e3c 2f74 723e 3c74 it.instead of ove │ │ │ -00048e80: 7277 7269 7469 6e67 2074 6865 2072 6f6f rwriting the roo │ │ │ -00048e90: 7420 616e 6420 636f 6d70 6172 696e 6720 t and comparing │ │ │ -00048ea0: 6974 0a61 6761 696e 7374 2068 6173 6865 it.against hashe │ │ │ -00048eb0: 735b 5d2c 2077 7269 7465 2061 2066 756e s[], write a fun │ │ │ -00048ec0: 6374 696f 6e73 2074 6861 7420 2a76 616c ctions that *val │ │ │ -00048ed0: 6964 6174 6573 2a20 6120 7472 6565 0a62 idates* a tree.b │ │ │ -00048ee0: 7920 6a75 7374 2066 696c 6c69 6e67 2069 y just filling i │ │ │ -00048ef0: 7420 7570 2074 6f20 7468 6520 6c65 7665 t up to the leve │ │ │ -00048f00: 6c20 6265 6c6f 7720 7468 6520 726f 6f74 l below the root │ │ │ -00048f10: 2061 6e64 2074 6865 6e0a 7661 6c69 6461 and then.valida │ │ │ -00048f20: 7465 7320 6974 2e3c 2f68 323e 3c68 343e tes it.

    │ │ │ -00048f30: 2e2e 2f73 7263 2f6d 6572 6b6c 655f 7472 ../src/merkle_tr │ │ │ -00048f40: 6565 2e63 7070 3a34 3335 3c2f 6834 3e3c ee.cpp:435

    < │ │ │ -00048f50: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00048f60: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00048f70: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00048f80: 7820 2364 6464 3b22 3e09 0909 2661 6d70 x #ddd;">...& │ │ │ -00048f90: 3b26 616d 703b 2064 6573 745f 7374 6172 ;& dest_star │ │ │ -00048fa0: 745f 6964 7820 266c 743b 2066 6972 7374 t_idx < first │ │ │ -00048fb0: 5f70 6965 6365 5f69 6478 202b 206e 756d _piece_idx + num │ │ │ -00048fc0: 5f70 6965 6365 7328 2929 0a09 097b 0a09 _pieces())...{.. │ │ │ -00048fd0: 0909 696e 7420 636f 6e73 7420 626c 6f63 ..int const bloc │ │ │ -00048fe0: 6b73 5f69 6e5f 7069 6563 6520 3d20 3120 ks_in_piece = 1 │ │ │ -00048ff0: 266c 743b 266c 743b 2062 6173 653b 0a0a << base;.. │ │ │ -00049000: 0909 092f 2f20 6974 206d 6179 206e 6f77 ...// it may now │ │ │ -00049010: 2062 6520 706f 7373 6962 6c65 2074 6f20 be possible to │ │ │ -00049020: 7665 7269 6679 2074 6865 2068 6173 6865 verify the hashe │ │ │ -00049030: 7320 6f66 2070 7265 7669 6f75 736c 7920 s of previously │ │ │ -00049040: 7265 6365 6976 6564 2062 6c6f 636b 730a received blocks. │ │ │ -00049050: 0909 092f 2f20 7472 7920 746f 2076 6572 ...// try to ver │ │ │ -00049060: 6966 7920 6173 206d 616e 7920 6368 696c ify as many chil │ │ │ -00049070: 6420 6e6f 6465 7320 6f66 2074 6865 2072 d nodes of the r │ │ │ -00049080: 6563 6569 7665 6420 6861 7368 6573 2061 eceived hashes a │ │ │ -00049090: 7320 706f 7373 6962 6c65 0a09 0909 666f s possible....fo │ │ │ -000490a0: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ -000490b0: 266c 743b 2069 6e74 2868 6173 6865 732e < int(hashes. │ │ │ -000490c0: 7369 7a65 2829 293b 202b 2b69 290a 0909 size()); ++i)... │ │ │ -000490d0: 097b 0a09 0909 0969 6e74 2063 6f6e 7374 .{.....int const │ │ │ -000490e0: 2070 6965 6365 203d 2064 6573 745f 7374 piece = dest_st │ │ │ -000490f0: 6172 745f 6964 7820 2b20 693b 0a09 0909 art_idx + i;.... │ │ │ -00049100: 0969 6620 2870 6965 6365 202d 2066 6972 .if (piece - fir │ │ │ -00049110: 7374 5f70 6965 6365 5f69 6478 2026 6774 st_piece_idx > │ │ │ -00049120: 3b3d 206e 756d 5f70 6965 6365 7328 2929 ;= num_pieces()) │ │ │ -00049130: 0a09 0909 0909 6272 6561 6b3b 0a09 0909 ......break;.... │ │ │ -00049140: 092f 2f20 7468 6520 6669 7273 7420 626c .// the first bl │ │ │ -00049150: 6f63 6b20 696e 2074 6869 7320 7069 6563 ock in this piec │ │ │ -00049160: 650a 0909 0909 696e 7420 636f 6e73 7420 e.....int const │ │ │ -00049170: 626c 6f63 6b5f 6964 7820 3d20 6d65 726b block_idx = merk │ │ │ -00049180: 6c65 5f67 6574 5f66 6972 7374 5f63 6869 le_get_first_chi │ │ │ -00049190: 6c64 2870 6965 6365 2c20 6261 7365 293b ld(piece, base); │ │ │ -000491a0: 0a0a 0909 0909 696e 7420 636f 6e73 7420 ......int const │ │ │ -000491b0: 626c 6f63 6b5f 656e 645f 6964 7820 3d20 block_end_idx = │ │ │ -000491c0: 7374 643a 3a6d 696e 2862 6c6f 636b 5f69 std::min(block_i │ │ │ -000491d0: 6478 202b 2062 6c6f 636b 735f 696e 5f70 dx + blocks_in_p │ │ │ -000491e0: 6965 6365 2c20 6669 7273 745f 6c65 6166 iece, first_leaf │ │ │ -000491f0: 202b 206d 5f6e 756d 5f62 6c6f 636b 7329 + m_num_blocks) │ │ │ -00049200: 3b0a 0909 0909 6966 2028 7374 643a 3a61 ;.....if (std::a │ │ │ -00049210: 6e79 5f6f 6628 6d5f 7472 6565 2e62 6567 ny_of(m_tree.beg │ │ │ -00049220: 696e 2829 202b 2062 6c6f 636b 5f69 6478 in() + block_idx │ │ │ -00049230: 0a09 0909 0909 2c20 6d5f 7472 6565 2e62 ......, m_tree.b │ │ │ -00049240: 6567 696e 2829 202b 2062 6c6f 636b 5f65 egin() + block_e │ │ │ -00049250: 6e64 5f69 6478 0a09 0909 0909 2c20 5b5d nd_idx......, [] │ │ │ -00049260: 2873 6861 3235 365f 6861 7368 2063 6f6e (sha256_hash con │ │ │ -00049270: 7374 2661 6d70 3b20 6829 207b 2072 6574 st& h) { ret │ │ │ -00049280: 7572 6e20 682e 6973 5f61 6c6c 5f7a 6572 urn h.is_all_zer │ │ │ -00049290: 6f73 2829 3b20 7d29 290a 0909 0909 0963 os(); }))......c │ │ │ -000492a0: 6f6e 7469 6e75 653b 0a0a 3c64 6976 2073 ontinue;..
    ....merk │ │ │ -000492e0: 6c65 5f66 696c 6c5f 7472 6565 286d 5f74 le_fill_tree(m_t │ │ │ -000492f0: 7265 652c 2062 6c6f 636b 735f 696e 5f70 ree, blocks_in_p │ │ │ -00049300: 6965 6365 2c20 626c 6f63 6b5f 6964 7829 iece, block_idx) │ │ │ -00049310: 3b0a 3c2f 6469 763e 0909 0909 6966 2028 ;.
    ....if ( │ │ │ -00049320: 6d5f 7472 6565 5b70 6965 6365 5d20 213d m_tree[piece] != │ │ │ -00049330: 2068 6173 6865 735b 695d 290a 0909 0909 hashes[i])..... │ │ │ -00049340: 7b0a 0909 0909 096d 6572 6b6c 655f 636c {......merkle_cl │ │ │ -00049350: 6561 725f 7472 6565 286d 5f74 7265 652c ear_tree(m_tree, │ │ │ -00049360: 2062 6c6f 636b 735f 696e 5f70 6965 6365 blocks_in_piece │ │ │ -00049370: 2c20 626c 6f63 6b5f 6964 7829 3b0a 0909 , block_idx);... │ │ │ -00049380: 0909 092f 2f20 7772 6974 6520 6261 636b ...// write back │ │ │ -00049390: 2074 6865 2063 6f72 7265 6374 2068 6173 the correct has │ │ │ -000493a0: 680a 0909 0909 096d 5f74 7265 655b 7069 h......m_tree[pi │ │ │ -000493b0: 6563 655d 203d 2068 6173 6865 735b 695d ece] = hashes[i] │ │ │ -000493c0: 3b0a 0909 0909 0954 4f52 5245 4e54 5f41 ;......TORRENT_A │ │ │ -000493d0: 5353 4552 5428 626c 6f63 6b73 5f69 6e5f SSERT(blocks_in_ │ │ │ -000493e0: 7069 6563 6520 3d3d 2062 6c6f 636b 735f piece == blocks_ │ │ │ -000493f0: 7065 725f 7069 6563 6528 2929 3b0a 0a09 per_piece());... │ │ │ -00049400: 0909 0909 2f2f 2061 6e20 656d 7074 7920 ....// an empty │ │ │ -00049410: 626c 6f63 6b73 2076 6563 746f 7220 696e blocks vector in │ │ │ -00049420: 6469 6361 7465 7320 7468 6174 2077 6520 dicates that we │ │ │ -00049430: 646f 6e27 7420 6861 7665 2074 6865 0a09 don't have the.. │ │ │ -00049440: 0909 0909 2f2f 2062 6c6f 636b 2068 6173 ....// block has │ │ │ -00049450: 6865 732c 2061 6e64 2077 6520 6361 6e27 hes, and we can' │ │ │ -00049460: 7420 6b6e 6f77 2077 6869 6368 2062 6c6f t know which blo │ │ │ -00049470: 636b 2066 6169 6c65 640a 0909 0909 092f ck failed....../ │ │ │ -00049480: 2f20 7468 6973 2077 696c 6c20 6361 7573 / this will caus │ │ │ -00049490: 6520 7468 6520 626c 6f63 6b20 6861 7368 e the block hash │ │ │ -000494a0: 6573 2074 6f20 6265 2072 6571 7565 7374 es to be request │ │ │ -000494b0: 6564 0a09 0909 0909 7265 742e 6661 696c ed......ret.fail │ │ │ -000494c0: 6564 2e65 6d70 6c61 6365 5f62 6163 6b28 ed.emplace_back( │ │ │ -000494d0: 7069 6563 655f 696e 6465 785f 747b 7069 piece_index_t{pi │ │ │ -000494e0: 6563 6520 2d20 6669 7273 745f 7069 6563 ece - first_piec │ │ │ -000494f0: 655f 6964 787d 202b 2066 696c 655f 7069 e_idx} + file_pi │ │ │ -00049500: 6563 655f 6f66 6673 6574 0a09 0909 0909 ece_offset...... │ │ │ -00049510: 092c 2073 7464 3a3a 7665 6374 6f72 266c ., std::vector&l │ │ │ -00049520: 743b 696e 7426 6774 3b28 2929 3b0a 0909 t;int>());... │ │ │ -00049530: 0909 7d0a 0909 0909 656c 7365 0a09 0909 ..}.....else.... │ │ │ -00049540: 097b 0a09 0909 0909 7265 742e 7061 7373 .{......ret.pass │ │ │ -00049550: 6564 2e70 7573 685f 6261 636b 2870 6965 ed.push_back(pie │ │ │ -00049560: 6365 5f69 6e64 6578 5f74 7b70 6965 6365 ce_index_t{piece │ │ │ -00049570: 202d 2066 6972 7374 5f70 6965 6365 5f69 - first_piece_i │ │ │ -00049580: 6478 7d20 2b20 6669 6c65 5f70 6965 6365 dx} + file_piece │ │ │ -00049590: 5f6f 6666 7365 7429 3b0a 0909 0909 092f _offset);....../ │ │ │ -000495a0: 2f20 7265 636f 7264 2074 6861 7420 7468 / record that th │ │ │ -000495b0: 6573 6520 626c 6f63 6b20 6861 7368 6573 ese block hashes │ │ │ -000495c0: 2061 7265 2063 6f72 7265 6374 210a 0909 are correct!... │ │ │ -000495d0: 0909 0969 6e74 2063 6f6e 7374 206c 6561 ...int const lea │ │ │ -000495e0: 6673 5f73 7461 7274 203d 2062 6c6f 636b fs_start = block │ │ │ -000495f0: 5f69 6478 202d 2062 6c6f 636b 5f6c 6179 _idx - block_lay │ │ │ -00049600: 6572 5f73 7461 7274 2829 3b0a 0909 0909 er_start();..... │ │ │ -00049610: 0969 6e74 2063 6f6e 7374 206c 6561 6673 .int const leafs │ │ │ -00049620: 5f65 6e64 203d 2073 7464 3a3a 6d69 6e28 _end = std::min( │ │ │ -00049630: 6d5f 6e75 6d5f 626c 6f63 6b73 2c20 6c65 m_num_blocks, le │ │ │ -00049640: 6166 735f 7374 6172 7420 2b20 626c 6f63 afs_start + bloc │ │ │ -00049650: 6b73 5f69 6e5f 7069 6563 6529 3b0a 3c2f ks_in_piece);.r │ │ │ -00049690: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -000496a0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -000496d0: 6d65 726b 6c65 5f74 7265 652e 6370 703a merkle_tree.cpp: │ │ │ -000496e0: 3435 393c 2f61 3e3c 2f74 643e 3c74 643e 459 │ │ │ -000496f0: 7468 6973 2063 6f75 6c64 2062 6520 646f this could be do │ │ │ -00049700: 6e65 206d 6f72 6520 6566 6669 6369 656e ne more efficien │ │ │ -00049710: 746c 7920 6966 2062 6974 6669 656c 6420 tly if bitfield │ │ │ -00049720: 6861 6420 6120 6675 6e63 7469 6f6e 2074 had a function t │ │ │ -00049730: 6f20 7365 7420 6120 7261 6e67 6520 6f66 o set a range of │ │ │ -00049740: 2062 6974 733c 2f74 643e 3c2f 7472 3e3c bits< │ │ │ -00049750: 7472 2069 643d 2231 3739 2220 7374 796c tr id="179" styl │ │ │ -00049760: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00049770: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00049780: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00049790: 6832 3e74 6869 7320 636f 756c 6420 6265 h2>this could be │ │ │ -000497a0: 2064 6f6e 6520 6d6f 7265 2065 6666 6963 done more effic │ │ │ -000497b0: 6965 6e74 6c79 2069 6620 6269 7466 6965 iently if bitfie │ │ │ -000497c0: 6c64 2068 6164 2061 2066 756e 6374 696f ld had a functio │ │ │ -000497d0: 6e0a 746f 2073 6574 2061 2072 616e 6765 n.to set a range │ │ │ -000497e0: 206f 6620 6269 7473 3c2f 6832 3e3c 6834 of bits

    ../src/merkle_t │ │ │ -00049800: 7265 652e 6370 703a 3435 393c 2f68 343e ree.cpp:459

    │ │ │ -00049810: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ....me
    │ │ │ -00049850: 726b 6c65 5f66 696c 6c5f 7472 6565 286d  rkle_fill_tree(m
    │ │ │ -00049860: 5f74 7265 652c 2062 6c6f 636b 735f 696e  _tree, blocks_in
    │ │ │ -00049870: 5f70 6965 6365 2c20 626c 6f63 6b5f 6964  _piece, block_id
    │ │ │ -00049880: 7829 3b0a 0909 0909 6966 2028 6d5f 7472  x);.....if (m_tr
    │ │ │ -00049890: 6565 5b70 6965 6365 5d20 213d 2068 6173  ee[piece] != has
    │ │ │ -000498a0: 6865 735b 695d 290a 0909 0909 7b0a 0909  hes[i]).....{...
    │ │ │ -000498b0: 0909 096d 6572 6b6c 655f 636c 6561 725f  ...merkle_clear_
    │ │ │ -000498c0: 7472 6565 286d 5f74 7265 652c 2062 6c6f  tree(m_tree, blo
    │ │ │ -000498d0: 636b 735f 696e 5f70 6965 6365 2c20 626c  cks_in_piece, bl
    │ │ │ -000498e0: 6f63 6b5f 6964 7829 3b0a 0909 0909 092f  ock_idx);....../
    │ │ │ -000498f0: 2f20 7772 6974 6520 6261 636b 2074 6865  / write back the
    │ │ │ -00049900: 2063 6f72 7265 6374 2068 6173 680a 0909   correct hash...
    │ │ │ -00049910: 0909 096d 5f74 7265 655b 7069 6563 655d  ...m_tree[piece]
    │ │ │ -00049920: 203d 2068 6173 6865 735b 695d 3b0a 0909   = hashes[i];...
    │ │ │ -00049930: 0909 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -00049940: 5428 626c 6f63 6b73 5f69 6e5f 7069 6563  T(blocks_in_piec
    │ │ │ -00049950: 6520 3d3d 2062 6c6f 636b 735f 7065 725f  e == blocks_per_
    │ │ │ -00049960: 7069 6563 6528 2929 3b0a 0a09 0909 0909  piece());.......
    │ │ │ -00049970: 2f2f 2061 6e20 656d 7074 7920 626c 6f63  // an empty bloc
    │ │ │ -00049980: 6b73 2076 6563 746f 7220 696e 6469 6361  ks vector indica
    │ │ │ -00049990: 7465 7320 7468 6174 2077 6520 646f 6e27  tes that we don'
    │ │ │ -000499a0: 7420 6861 7665 2074 6865 0a09 0909 0909  t have the......
    │ │ │ -000499b0: 2f2f 2062 6c6f 636b 2068 6173 6865 732c  // block hashes,
    │ │ │ -000499c0: 2061 6e64 2077 6520 6361 6e27 7420 6b6e   and we can't kn
    │ │ │ -000499d0: 6f77 2077 6869 6368 2062 6c6f 636b 2066  ow which block f
    │ │ │ -000499e0: 6169 6c65 640a 0909 0909 092f 2f20 7468  ailed......// th
    │ │ │ -000499f0: 6973 2077 696c 6c20 6361 7573 6520 7468  is will cause th
    │ │ │ -00049a00: 6520 626c 6f63 6b20 6861 7368 6573 2074  e block hashes t
    │ │ │ -00049a10: 6f20 6265 2072 6571 7565 7374 6564 0a09  o be requested..
    │ │ │ -00049a20: 0909 0909 7265 742e 6661 696c 6564 2e65  ....ret.failed.e
    │ │ │ -00049a30: 6d70 6c61 6365 5f62 6163 6b28 7069 6563  mplace_back(piec
    │ │ │ -00049a40: 655f 696e 6465 785f 747b 7069 6563 6520  e_index_t{piece 
    │ │ │ -00049a50: 2d20 6669 7273 745f 7069 6563 655f 6964  - first_piece_id
    │ │ │ -00049a60: 787d 202b 2066 696c 655f 7069 6563 655f  x} + file_piece_
    │ │ │ -00049a70: 6f66 6673 6574 0a09 0909 0909 092c 2073  offset......., s
    │ │ │ -00049a80: 7464 3a3a 7665 6374 6f72 266c 743b 696e  td::vector<in
    │ │ │ -00049a90: 7426 6774 3b28 2929 3b0a 0909 0909 7d0a  t>());.....}.
    │ │ │ -00049aa0: 0909 0909 656c 7365 0a09 0909 097b 0a09  ....else.....{..
    │ │ │ -00049ab0: 0909 0909 7265 742e 7061 7373 6564 2e70  ....ret.passed.p
    │ │ │ -00049ac0: 7573 685f 6261 636b 2870 6965 6365 5f69  ush_back(piece_i
    │ │ │ -00049ad0: 6e64 6578 5f74 7b70 6965 6365 202d 2066  ndex_t{piece - f
    │ │ │ -00049ae0: 6972 7374 5f70 6965 6365 5f69 6478 7d20  irst_piece_idx} 
    │ │ │ -00049af0: 2b20 6669 6c65 5f70 6965 6365 5f6f 6666  + file_piece_off
    │ │ │ -00049b00: 7365 7429 3b0a 0909 0909 092f 2f20 7265  set);......// re
    │ │ │ -00049b10: 636f 7264 2074 6861 7420 7468 6573 6520  cord that these 
    │ │ │ -00049b20: 626c 6f63 6b20 6861 7368 6573 2061 7265  block hashes are
    │ │ │ -00049b30: 2063 6f72 7265 6374 210a 0909 0909 0969   correct!......i
    │ │ │ -00049b40: 6e74 2063 6f6e 7374 206c 6561 6673 5f73  nt const leafs_s
    │ │ │ -00049b50: 7461 7274 203d 2062 6c6f 636b 5f69 6478  tart = block_idx
    │ │ │ -00049b60: 202d 2062 6c6f 636b 5f6c 6179 6572 5f73   - block_layer_s
    │ │ │ -00049b70: 7461 7274 2829 3b0a 0909 0909 0969 6e74  tart();......int
    │ │ │ -00049b80: 2063 6f6e 7374 206c 6561 6673 5f65 6e64   const leafs_end
    │ │ │ -00049b90: 203d 2073 7464 3a3a 6d69 6e28 6d5f 6e75   = std::min(m_nu
    │ │ │ -00049ba0: 6d5f 626c 6f63 6b73 2c20 6c65 6166 735f  m_blocks, leafs_
    │ │ │ -00049bb0: 7374 6172 7420 2b20 626c 6f63 6b73 5f69  start + blocks_i
    │ │ │ -00049bc0: 6e5f 7069 6563 6529 3b0a 3c64 6976 2073  n_piece);.
    .....for │ │ │ -00049c00: 2028 696e 7420 6b20 3d20 6c65 6166 735f (int k = leafs_ │ │ │ -00049c10: 7374 6172 743b 206b 2026 6c74 3b20 6c65 start; k < le │ │ │ -00049c20: 6166 735f 656e 643b 202b 2b6b 290a 3c2f afs_end; ++k).......m_bloc │ │ │ -00049c40: 6b5f 7665 7269 6669 6564 2e73 6574 5f62 k_verified.set_b │ │ │ -00049c50: 6974 286b 293b 0a09 0909 097d 0a09 0909 it(k);.....}.... │ │ │ -00049c60: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -00049c70: 2870 6965 6365 202d 2066 6972 7374 5f70 (piece - first_p │ │ │ -00049c80: 6965 6365 5f69 6478 2920 2667 743b 3d20 iece_idx) >= │ │ │ -00049c90: 3029 3b0a 0909 097d 0a09 097d 0a0a 0909 0);....}...}.... │ │ │ -00049ca0: 6f70 7469 6d69 7a65 5f73 746f 7261 6765 optimize_storage │ │ │ -00049cb0: 2829 3b0a 0a09 0972 6574 7572 6e20 7265 ();....return re │ │ │ -00049cc0: 743b 0a09 7d0a 0a09 7374 643a 3a74 7570 t;..}...std::tup │ │ │ -00049cd0: 6c65 266c 743b 6d65 726b 6c65 5f74 7265 le<merkle_tre │ │ │ -00049ce0: 653a 3a73 6574 5f62 6c6f 636b 5f72 6573 e::set_block_res │ │ │ -00049cf0: 756c 742c 2069 6e74 2c20 696e 7426 6774 ult, int, int> │ │ │ -00049d00: 3b20 6d65 726b 6c65 5f74 7265 653a 3a73 ; merkle_tree::s │ │ │ -00049d10: 6574 5f62 6c6f 636b 2869 6e74 2063 6f6e et_block(int con │ │ │ -00049d20: 7374 2062 6c6f 636b 5f69 6e64 6578 0a09 st block_index.. │ │ │ -00049d30: 092c 2073 6861 3235 365f 6861 7368 2063 ., sha256_hash c │ │ │ -00049d40: 6f6e 7374 2661 6d70 3b20 6829 0a09 7b0a onst& h)..{. │ │ │ -00049d50: 2369 6664 6566 2054 4f52 5245 4e54 5f45 #ifdef TORRENT_E │ │ │ -00049d60: 5850 454e 5349 5645 5f49 4e56 4152 4941 XPENSIVE_INVARIA │ │ │ -00049d70: 4e54 5f43 4845 434b 530a 0909 494e 5641 NT_CHECKS...INVA │ │ │ -00049d80: 5249 414e 545f 4348 4543 4b3b 0a23 656e RIANT_CHECK;.#en │ │ │ -00049d90: 6469 660a 0909 544f 5252 454e 545f 4153 dif...TORRENT_AS │ │ │ -00049da0: 5345 5254 2862 6c6f 636b 5f69 6e64 6578 SERT(block_index │ │ │ -00049db0: 2026 6c74 3b20 6d5f 6e75 6d5f 626c 6f63 < m_num_bloc │ │ │ -00049dc0: 6b73 293b 0a0a 0909 6175 746f 2063 6f6e ks);....auto con │ │ │ -00049dd0: 7374 206e 756d 5f6c 6561 6673 203d 206d st num_leafs = m │ │ │ -00049de0: 6572 6b6c 655f 6e75 6d5f 6c65 6166 7328 erkle_num_leafs( │ │ │ -00049df0: 6d5f 6e75 6d5f 626c 6f63 6b73 293b 0a09 m_num_blocks);.. │ │ │ -00049e00: 0961 7574 6f20 636f 6e73 7420 6669 7273 .auto const firs │ │ │ -00049e10: 745f 6c65 6166 203d 206d 6572 6b6c 655f t_leaf = merkle_ │ │ │ -00049e20: 6669 7273 745f 6c65 6166 286e 756d 5f6c first_leaf(num_l │ │ │ -00049e30: 6561 6673 293b 0a09 0961 7574 6f20 636f eafs);...auto co │ │ │ -00049e40: 6e73 7420 626c 6f63 6b5f 7472 6565 5f69 nst block_tree_i │ │ │ -00049e50: 6e64 6578 203d 2066 6972 7374 5f6c 6561 ndex = first_lea │ │ │ -00049e60: 6620 2b20 626c 6f63 6b5f 696e 6465 783b f + block_index; │ │ │ -00049e70: 0a0a 0909 6966 2028 626c 6f63 6b73 5f76 ....if (blocks_v │ │ │ -00049e80: 6572 6966 6965 6428 626c 6f63 6b5f 696e erified(block_in │ │ │ -00049e90: 6465 782c 2031 2929 0a09 097b 0a09 0909 dex, 1))...{.... │ │ │ -00049ea0: 2f2f 2069 6620 7468 6973 2062 6c6f 636b // if this block │ │ │ -00049eb0: 7327 7320 6861 7368 2069 7320 616c 7265 s's hash is alre │ │ │ -00049ec0: 6164 7920 6b6e 6f77 6e2c 2063 6865 636b ady known, check │ │ │ -00049ed0: 2074 6865 2070 6173 7365 642d 696e 2068 the passed-in h │ │ │ -00049ee0: 6173 6820 6167 6169 6e73 7420 6974 0a09 ash against it.. │ │ │ -00049ef0: 0909 6966 2028 636f 6d70 6172 655f 6e6f ..if (compare_no │ │ │ -00049f00: 6465 2862 6c6f 636b 5f74 7265 655f 696e de(block_tree_in │ │ │ -00049f10: 6465 782c 2068 2929 0a09 0909 0972 6574 dex, h)).....ret │ │ │ -00049f20: 7572 6e20 7374 643a 3a6d 616b 655f 7475 urn std::make_tu │ │ │ -00049f30: 706c 6528 7365 745f 626c 6f63 6b5f 7265 ple(set_block_re │ │ │ -00049f40: 7375 6c74 3a3a 6f6b 2c20 626c 6f63 6b5f sult::ok, block_ │ │ │ -00049f50: 696e 6465 782c 2031 293b 0a09 0909 656c index, 1);....el │ │ │ -00049f60: 7365 0a09 0909 0972 6574 7572 6e20 7374 se.....return st │ │ │ -00049f70: 643a 3a6d 616b 655f 7475 706c 6528 7365 d::make_tuple(se │ │ │ -00049f80: 745f 626c 6f63 6b5f 7265 7375 6c74 3a3a t_block_result:: │ │ │ -00049f90: 626c 6f63 6b5f 6861 7368 5f66 6169 6c65 block_hash_faile │ │ │ -00049fa0: 642c 2062 6c6f 636b 5f69 6e64 6578 2c20 d, block_index, │ │ │ -00049fb0: 3129 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 1);.
    < │ │ │ -00049fc0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00049ff0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0004a020: 2e2f 7372 632f 6d65 726b 6c65 5f74 7265 ./src/merkle_tre │ │ │ -0004a030: 652e 6370 703a 3532 333c 2f61 3e3c 2f74 e.cpp:523
    this could │ │ │ -0004a050: 2062 6520 646f 6e65 206d 6f72 6520 6566 be done more ef │ │ │ -0004a060: 6669 6369 656e 746c 7920 6966 2062 6974 ficiently if bit │ │ │ -0004a070: 6669 656c 6420 6861 6420 6120 6675 6e63 field had a func │ │ │ -0004a080: 7469 6f6e 2074 6f20 7365 7420 6120 7261 tion to set a ra │ │ │ -0004a090: 6e67 6520 6f66 2062 6974 733c 2f74 643e nge of bits │ │ │ -0004a0a0: 3c2f 7472 3e3c 7472 2069 643d 2231 3830

    this co │ │ │ -0004a0f0: 756c 6420 6265 2064 6f6e 6520 6d6f 7265 uld be done more │ │ │ -0004a100: 2065 6666 6963 6965 6e74 6c79 2069 6620 efficiently if │ │ │ -0004a110: 6269 7466 6965 6c64 2068 6164 2061 2066 bitfield had a f │ │ │ -0004a120: 756e 6374 696f 6e0a 746f 2073 6574 2061 unction.to set a │ │ │ -0004a130: 2072 616e 6765 206f 6620 6269 7473 3c2f range of bits

    ../src/me │ │ │ -0004a150: 726b 6c65 5f74 7265 652e 6370 703a 3532 rkle_tree.cpp:52 │ │ │ -0004a160: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -0004a1a0: 0909 096d 6572 6b6c 655f 6669 6e64 5f6b  ...merkle_find_k
    │ │ │ -0004a1b0: 6e6f 776e 5f73 7562 7472 6565 286d 5f74  nown_subtree(m_t
    │ │ │ -0004a1c0: 7265 652c 2062 6c6f 636b 5f69 6e64 6578  ree, block_index
    │ │ │ -0004a1d0: 2c20 6d5f 6e75 6d5f 626c 6f63 6b73 293b  , m_num_blocks);
    │ │ │ -0004a1e0: 0a0a 0909 2f2f 2069 6620 7468 6520 726f  ....// if the ro
    │ │ │ -0004a1f0: 6f74 206e 6f64 6520 6973 2075 6e6b 6e6f  ot node is unkno
    │ │ │ -0004a200: 776e 2074 6865 2068 6173 6865 7320 6361  wn the hashes ca
    │ │ │ -0004a210: 6e6e 6f74 2062 6520 7665 7269 6669 6564  nnot be verified
    │ │ │ -0004a220: 2079 6574 0a09 0969 6620 286d 5f74 7265   yet...if (m_tre
    │ │ │ -0004a230: 655b 726f 6f74 5f69 6e64 6578 5d2e 6973  e[root_index].is
    │ │ │ -0004a240: 5f61 6c6c 5f7a 6572 6f73 2829 290a 0909  _all_zeros())...
    │ │ │ -0004a250: 0972 6574 7572 6e20 7374 643a 3a6d 616b  .return std::mak
    │ │ │ -0004a260: 655f 7475 706c 6528 7365 745f 626c 6f63  e_tuple(set_bloc
    │ │ │ -0004a270: 6b5f 7265 7375 6c74 3a3a 756e 6b6e 6f77  k_result::unknow
    │ │ │ -0004a280: 6e2c 206c 6561 6673 5f73 7461 7274 2c20  n, leafs_start, 
    │ │ │ -0004a290: 6c65 6166 735f 7369 7a65 293b 0a0a 0909  leafs_size);....
    │ │ │ -0004a2a0: 2f2f 2073 6176 6520 7468 6520 726f 6f74  // save the root
    │ │ │ -0004a2b0: 2068 6173 6820 6265 6361 7573 6520 6d65   hash because me
    │ │ │ -0004a2c0: 726b 6c65 5f66 696c 6c5f 7472 6565 2077  rkle_fill_tree w
    │ │ │ -0004a2d0: 696c 6c20 6f76 6572 7772 6974 6520 6974  ill overwrite it
    │ │ │ -0004a2e0: 0a09 0973 6861 3235 365f 6861 7368 2063  ...sha256_hash c
    │ │ │ -0004a2f0: 6f6e 7374 2072 6f6f 7420 3d20 6d5f 7472  onst root = m_tr
    │ │ │ -0004a300: 6565 5b72 6f6f 745f 696e 6465 785d 3b0a  ee[root_index];.
    │ │ │ -0004a310: 0909 6d65 726b 6c65 5f66 696c 6c5f 7472  ..merkle_fill_tr
    │ │ │ -0004a320: 6565 286d 5f74 7265 652c 206c 6561 6673  ee(m_tree, leafs
    │ │ │ -0004a330: 5f73 697a 652c 2066 6972 7374 5f6c 6561  _size, first_lea
    │ │ │ -0004a340: 6620 2b20 6c65 6166 735f 7374 6172 7429  f + leafs_start)
    │ │ │ -0004a350: 3b0a 0a09 0969 6620 2872 6f6f 7420 213d  ;....if (root !=
    │ │ │ -0004a360: 206d 5f74 7265 655b 726f 6f74 5f69 6e64   m_tree[root_ind
    │ │ │ -0004a370: 6578 5d29 0a09 097b 0a09 0909 2f2f 2068  ex])...{....// h
    │ │ │ -0004a380: 6173 6820 6661 696c 7572 652c 2063 6c65  ash failure, cle
    │ │ │ -0004a390: 6172 2061 6c6c 2074 6865 2069 6e74 6572  ar all the inter
    │ │ │ -0004a3a0: 6e61 6c20 6e6f 6465 730a 0909 092f 2f20  nal nodes....// 
    │ │ │ -0004a3b0: 7468 6520 7768 6f6c 6520 7069 6563 6520  the whole piece 
    │ │ │ -0004a3c0: 6661 696c 6564 2074 6865 2068 6173 6820  failed the hash 
    │ │ │ -0004a3d0: 6368 6563 6b2e 2043 6c65 6172 2061 6c6c  check. Clear all
    │ │ │ -0004a3e0: 2062 6c6f 636b 2068 6173 6865 730a 0909   block hashes...
    │ │ │ -0004a3f0: 092f 2f20 696e 2074 6869 7320 7069 6563  .// in this piec
    │ │ │ -0004a400: 6520 616e 6420 7265 706f 7274 2061 2068  e and report a h
    │ │ │ -0004a410: 6173 6820 6661 696c 7572 650a 0909 096d  ash failure....m
    │ │ │ -0004a420: 6572 6b6c 655f 636c 6561 725f 7472 6565  erkle_clear_tree
    │ │ │ -0004a430: 286d 5f74 7265 652c 206c 6561 6673 5f73  (m_tree, leafs_s
    │ │ │ -0004a440: 697a 652c 2066 6972 7374 5f6c 6561 6620  ize, first_leaf 
    │ │ │ -0004a450: 2b20 6c65 6166 735f 7374 6172 7429 3b0a  + leafs_start);.
    │ │ │ -0004a460: 0909 096d 5f74 7265 655b 726f 6f74 5f69  ...m_tree[root_i
    │ │ │ -0004a470: 6e64 6578 5d20 3d20 726f 6f74 3b0a 0909  ndex] = root;...
    │ │ │ -0004a480: 0972 6574 7572 6e20 7374 643a 3a6d 616b  .return std::mak
    │ │ │ -0004a490: 655f 7475 706c 6528 7365 745f 626c 6f63  e_tuple(set_bloc
    │ │ │ -0004a4a0: 6b5f 7265 7375 6c74 3a3a 6861 7368 5f66  k_result::hash_f
    │ │ │ -0004a4b0: 6169 6c65 642c 206c 6561 6673 5f73 7461  ailed, leafs_sta
    │ │ │ -0004a4c0: 7274 2c20 6c65 6166 735f 7369 7a65 293b  rt, leafs_size);
    │ │ │ -0004a4d0: 0a09 097d 0a0a 3c64 6976 2073 7479 6c65  ...}..
    ..int const │ │ │ -0004a510: 6c65 6166 735f 656e 6420 3d20 7374 643a leafs_end = std: │ │ │ -0004a520: 3a6d 696e 286d 5f6e 756d 5f62 6c6f 636b :min(m_num_block │ │ │ -0004a530: 732c 206c 6561 6673 5f73 7461 7274 202b s, leafs_start + │ │ │ -0004a540: 206c 6561 6673 5f73 697a 6529 3b0a 3c2f leafs_size);...for (int i │ │ │ -0004a560: 203d 206c 6561 6673 5f73 7461 7274 3b20 = leafs_start; │ │ │ -0004a570: 6920 266c 743b 206c 6561 6673 5f65 6e64 i < leafs_end │ │ │ -0004a580: 3b20 2b2b 6929 0a09 0909 6d5f 626c 6f63 ; ++i)....m_bloc │ │ │ -0004a590: 6b5f 7665 7269 6669 6564 2e73 6574 5f62 k_verified.set_b │ │ │ -0004a5a0: 6974 2869 293b 0a0a 0909 2f2f 2061 7474 it(i);....// att │ │ │ -0004a5b0: 656d 7074 696e 6720 746f 206f 7074 696d empting to optim │ │ │ -0004a5c0: 697a 6520 7374 6f72 6167 6520 6973 2071 ize storage is q │ │ │ -0004a5d0: 7569 7465 2063 6f73 746c 792c 206f 6e6c uite costly, onl │ │ │ -0004a5e0: 7920 646f 2069 7420 6966 2077 6520 6861 y do it if we ha │ │ │ -0004a5f0: 7665 0a09 092f 2f20 6120 7265 6173 6f6e ve...// a reason │ │ │ -0004a600: 2074 6f20 6265 6c69 6576 6520 6974 206d to believe it m │ │ │ -0004a610: 6967 6874 2068 6176 6520 616e 2065 6666 ight have an eff │ │ │ -0004a620: 6563 740a 0909 6966 2028 626c 6f63 6b5f ect...if (block_ │ │ │ -0004a630: 696e 6465 7820 3d3d 206d 5f6e 756d 5f62 index == m_num_b │ │ │ -0004a640: 6c6f 636b 7320 2d20 3120 7c7c 2021 6d5f locks - 1 || !m_ │ │ │ -0004a650: 7472 6565 5b62 6c6f 636b 5f74 7265 655f tree[block_tree_ │ │ │ -0004a660: 696e 6465 7820 2b20 315d 2e69 735f 616c index + 1].is_al │ │ │ -0004a670: 6c5f 7a65 726f 7328 2929 0a09 0909 6f70 l_zeros())....op │ │ │ -0004a680: 7469 6d69 7a65 5f73 746f 7261 6765 2829 timize_storage() │ │ │ -0004a690: 3b0a 0a09 0972 6574 7572 6e20 7374 643a ;....return std: │ │ │ -0004a6a0: 3a6d 616b 655f 7475 706c 6528 7365 745f :make_tuple(set_ │ │ │ -0004a6b0: 626c 6f63 6b5f 7265 7375 6c74 3a3a 6f6b block_result::ok │ │ │ -0004a6c0: 2c20 6c65 6166 735f 7374 6172 742c 206c , leafs_start, l │ │ │ -0004a6d0: 6561 6673 5f73 697a 6529 3b0a 097d 0a0a eafs_size);..}.. │ │ │ -0004a6e0: 0973 7464 3a3a 7369 7a65 5f74 206d 6572 .std::size_t mer │ │ │ -0004a6f0: 6b6c 655f 7472 6565 3a3a 7369 7a65 2829 kle_tree::size() │ │ │ -0004a700: 2063 6f6e 7374 0a09 7b0a 0909 7265 7475 const..{...retu │ │ │ -0004a710: 726e 2073 7461 7469 635f 6361 7374 266c rn static_cast&l │ │ │ -0004a720: 743b 7374 643a 3a73 697a 655f 7426 6774 t;std::size_t> │ │ │ -0004a730: 3b28 6d65 726b 6c65 5f6e 756d 5f6e 6f64 ;(merkle_num_nod │ │ │ -0004a740: 6573 286d 6572 6b6c 655f 6e75 6d5f 6c65 es(merkle_num_le │ │ │ -0004a750: 6166 7328 6d5f 6e75 6d5f 626c 6f63 6b73 afs(m_num_blocks │ │ │ -0004a760: 2929 293b 0a09 7d0a 0a09 696e 7420 6d65 )));..}...int me │ │ │ -0004a770: 726b 6c65 5f74 7265 653a 3a6e 756d 5f70 rkle_tree::num_p │ │ │ -0004a780: 6965 6365 7328 2920 636f 6e73 740a 097b ieces() const..{ │ │ │ -0004a790: 0a09 0969 6e74 2063 6f6e 7374 2070 7320 ...int const ps │ │ │ -0004a7a0: 3d20 626c 6f63 6b73 5f70 6572 5f70 6965 = blocks_per_pie │ │ │ -0004a7b0: 6365 2829 3b0a 0909 544f 5252 454e 545f ce();...TORRENT_ │ │ │ -0004a7c0: 4153 5345 5254 2870 7320 2667 743b 2030 ASSERT(ps > 0 │ │ │ -0004a7d0: 293b 0a09 0972 6574 7572 6e20 286d 5f6e );...return (m_n │ │ │ -0004a7e0: 756d 5f62 6c6f 636b 7320 2b20 7073 202d um_blocks + ps - │ │ │ -0004a7f0: 2031 2920 2667 743b 2667 743b 206d 5f62 1) >> m_b │ │ │ -0004a800: 6c6f 636b 735f 7065 725f 7069 6563 655f locks_per_piece_ │ │ │ -0004a810: 6c6f 673b 0a09 7d0a 0a09 696e 7420 6d65 log;..}...int me │ │ │ -0004a820: 726b 6c65 5f74 7265 653a 3a62 6c6f 636b rkle_tree::block │ │ │ -0004a830: 5f6c 6179 6572 5f73 7461 7274 2829 2063 _layer_start() c │ │ │ -0004a840: 6f6e 7374 0a09 7b0a 0909 696e 7420 636f onst..{...int co │ │ │ -0004a850: 6e73 7420 6e75 6d5f 6c65 6166 7320 3d20 nst num_leafs = │ │ │ -0004a860: 6d65 726b 6c65 5f6e 756d 5f6c 6561 6673 merkle_num_leafs │ │ │ -0004a870: 286d 5f6e 756d 5f62 6c6f 636b 7329 3b0a (m_num_blocks);. │ │ │ -0004a880: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0004a890: 286e 756d 5f6c 6561 6673 2026 6774 3b20 (num_leafs > │ │ │ -0004a8a0: 3029 3b0a 0909 7265 7475 726e 206d 6572 0);...return mer │ │ │ -0004a8b0: 6b6c 655f 6669 7273 745f 6c65 6166 286e kle_first_leaf(n │ │ │ -0004a8c0: 756d 5f6c 6561 6673 293b 0a09 7d0a 0a3c um_leafs);..}..< │ │ │ -0004a8d0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0004a8e0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0004a8f0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0004a900: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0004a910: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0004a940: 2f63 686f 6b65 722e 6370 703a 3233 353c /choker.cpp:235< │ │ │ -0004a950: 2f61 3e3c 2f74 643e 3c74 643e 6d61 6b65 /a>make │ │ │ -0004a960: 2063 6f6e 6669 6775 7261 626c 653c 2f74 configurable

    make │ │ │ -0004a9c0: 636f 6e66 6967 7572 6162 6c65 3c2f 6832 configurable

    ../src/chok │ │ │ -0004a9e0: 6572 2e63 7070 3a32 3335 3c2f 6834 3e3c er.cpp:235

    < │ │ │ -0004a9f0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0004aa00: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0004aa10: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0004aa20: 7820 2364 6464 3b22 3e09 0909 2f2f 2066 x #ddd;">...// f │ │ │ -0004aa30: 6972 7374 2072 6573 6574 2074 6865 206e irst reset the n │ │ │ -0004aa40: 756d 6265 7220 6f66 2075 6e63 686f 6b65 umber of unchoke │ │ │ -0004aa50: 2073 6c6f 7473 2c20 6265 6361 7573 6520 slots, because │ │ │ -0004aa60: 7765 276c 6c20 6361 6c63 756c 6174 650a we'll calculate. │ │ │ -0004aa70: 0909 092f 2f20 6974 2070 7572 656c 7920 ...// it purely │ │ │ -0004aa80: 6261 7365 6420 6f6e 2074 6865 2063 7572 based on the cur │ │ │ -0004aa90: 7265 6e74 2073 7461 7465 206f 6620 6f75 rent state of ou │ │ │ -0004aaa0: 7220 7065 6572 732e 0a09 0909 7570 6c6f r peers.....uplo │ │ │ -0004aab0: 6164 5f73 6c6f 7473 203d 2030 3b0a 0a09 ad_slots = 0;... │ │ │ -0004aac0: 0909 696e 7420 7261 7465 5f74 6872 6573 ..int rate_thres │ │ │ -0004aad0: 686f 6c64 203d 2073 6574 742e 6765 745f hold = sett.get_ │ │ │ -0004aae0: 696e 7428 7365 7474 696e 6773 5f70 6163 int(settings_pac │ │ │ -0004aaf0: 6b3a 3a72 6174 655f 6368 6f6b 6572 5f69 k::rate_choker_i │ │ │ -0004ab00: 6e69 7469 616c 5f74 6872 6573 686f 6c64 nitial_threshold │ │ │ -0004ab10: 293b 0a0a 0909 0973 7464 3a3a 736f 7274 );.....std::sort │ │ │ -0004ab20: 2870 6565 7273 2e62 6567 696e 2829 2c20 (peers.begin(), │ │ │ -0004ab30: 7065 6572 732e 656e 6428 290a 0909 0909 peers.end()..... │ │ │ -0004ab40: 2c20 5b5d 2870 6565 725f 636f 6e6e 6563 , [](peer_connec │ │ │ -0004ab50: 7469 6f6e 2063 6f6e 7374 2a20 6c68 732c tion const* lhs, │ │ │ -0004ab60: 2070 6565 725f 636f 6e6e 6563 7469 6f6e peer_connection │ │ │ -0004ab70: 2063 6f6e 7374 2a20 7268 7329 0a09 0909 const* rhs).... │ │ │ -0004ab80: 097b 2072 6574 7572 6e20 7570 6c6f 6164 .{ return upload │ │ │ -0004ab90: 5f72 6174 655f 636f 6d70 6172 6528 6c68 _rate_compare(lh │ │ │ -0004aba0: 732c 2072 6873 293b 207d 293b 0a0a 0909 s, rhs); });.... │ │ │ -0004abb0: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ -0004abc0: 2a20 7020 3a20 7065 6572 7329 0a09 0909 * p : peers).... │ │ │ -0004abd0: 7b0a 0909 0909 696e 7420 636f 6e73 7420 {.....int const │ │ │ -0004abe0: 7261 7465 203d 2069 6e74 2870 2d26 6774 rate = int(p-> │ │ │ -0004abf0: 3b75 706c 6f61 6465 645f 696e 5f6c 6173 ;uploaded_in_las │ │ │ -0004ac00: 745f 726f 756e 6428 290a 0909 0909 092a t_round()......* │ │ │ -0004ac10: 2031 3030 3020 2f20 746f 7461 6c5f 6d69 1000 / total_mi │ │ │ -0004ac20: 6c6c 6973 6563 6f6e 6473 2875 6e63 686f lliseconds(uncho │ │ │ -0004ac30: 6b65 5f69 6e74 6572 7661 6c29 293b 0a0a ke_interval));.. │ │ │ -0004ac40: 0909 0909 2f2f 2061 6c77 6179 7320 6861 ....// always ha │ │ │ -0004ac50: 7665 2061 7420 6c65 6173 7420 3120 756e ve at least 1 un │ │ │ -0004ac60: 6368 6f6b 6520 736c 6f74 0a09 0909 0969 choke slot.....i │ │ │ -0004ac70: 6620 2872 6174 6520 266c 743b 2072 6174 f (rate < rat │ │ │ -0004ac80: 655f 7468 7265 7368 6f6c 6429 2062 7265 e_threshold) bre │ │ │ -0004ac90: 616b 3b0a 0a09 0909 092b 2b75 706c 6f61 ak;......++uploa │ │ │ -0004aca0: 645f 736c 6f74 733b 0a0a 3c64 6976 2073 d_slots;..
    ....rate │ │ │ -0004ace0: 5f74 6872 6573 686f 6c64 202b 3d20 3230 _threshold += 20 │ │ │ -0004acf0: 3438 3b0a 3c2f 6469 763e 0909 097d 0a09 48;.
    ...}.. │ │ │ -0004ad00: 0909 2b2b 7570 6c6f 6164 5f73 6c6f 7473 ..++upload_slots │ │ │ -0004ad10: 3b0a 0909 7d0a 0a09 092f 2f20 736f 7274 ;...}....// sort │ │ │ -0004ad20: 7320 7468 6520 7065 6572 7320 7468 6174 s the peers that │ │ │ -0004ad30: 2061 7265 2065 6c69 6769 626c 6520 666f are eligible fo │ │ │ -0004ad40: 7220 756e 6368 6f6b 6520 6279 2064 6f77 r unchoke by dow │ │ │ -0004ad50: 6e6c 6f61 6420 7261 7465 2061 6e64 0a09 nload rate and.. │ │ │ -0004ad60: 092f 2f20 7365 636f 6e64 6172 7920 6279 .// secondary by │ │ │ -0004ad70: 2074 6f74 616c 2075 706c 6f61 642e 2054 total upload. T │ │ │ -0004ad80: 6865 2072 6561 736f 6e20 666f 7220 7468 he reason for th │ │ │ -0004ad90: 6973 2069 732c 2069 6620 616c 6c20 746f is is, if all to │ │ │ -0004ada0: 7272 656e 7473 2061 7265 0a09 092f 2f20 rrents are...// │ │ │ -0004adb0: 6265 696e 6720 7365 6564 6564 2c20 7468 being seeded, th │ │ │ -0004adc0: 6520 646f 776e 6c6f 6164 2072 6174 6520 e download rate │ │ │ -0004add0: 7769 6c6c 2062 6520 302c 2061 6e64 2074 will be 0, and t │ │ │ -0004ade0: 6865 2070 6565 7273 2077 6520 6861 7665 he peers we have │ │ │ -0004adf0: 2073 656e 740a 0909 2f2f 2074 6865 206c sent...// the l │ │ │ -0004ae00: 6561 7374 2074 6f20 7368 6f75 6c64 2062 east to should b │ │ │ -0004ae10: 6520 756e 6368 6f6b 6564 0a0a 0909 2f2f e unchoked....// │ │ │ -0004ae20: 2077 6520 7573 6520 7061 7274 6961 6c20 we use partial │ │ │ -0004ae30: 736f 7274 2068 6572 652c 2062 6563 6175 sort here, becau │ │ │ -0004ae40: 7365 2077 6520 6f6e 6c79 2063 6172 6520 se we only care │ │ │ -0004ae50: 6162 6f75 7420 7468 6520 746f 700a 0909 about the top... │ │ │ -0004ae60: 2f2f 2075 706c 6f61 645f 736c 6f74 7320 // upload_slots │ │ │ -0004ae70: 7065 6572 732e 0a0a 0909 696e 7420 636f peers.....int co │ │ │ -0004ae80: 6e73 7420 736c 6f74 7320 3d20 7374 643a nst slots = std: │ │ │ -0004ae90: 3a6d 696e 2875 706c 6f61 645f 736c 6f74 :min(upload_slot │ │ │ -0004aea0: 732c 2069 6e74 2870 6565 7273 2e73 697a s, int(peers.siz │ │ │ -0004aeb0: 6528 2929 293b 0a0a 0909 6966 2028 7365 e()));....if (se │ │ │ -0004aec0: 7474 2e67 6574 5f69 6e74 2873 6574 7469 tt.get_int(setti │ │ │ -0004aed0: 6e67 735f 7061 636b 3a3a 7365 6564 5f63 ngs_pack::seed_c │ │ │ -0004aee0: 686f 6b69 6e67 5f61 6c67 6f72 6974 686d hoking_algorithm │ │ │ -0004aef0: 290a 0909 093d 3d20 7365 7474 696e 6773 )....== settings │ │ │ -0004af00: 5f70 6163 6b3a 3a72 6f75 6e64 5f72 6f62 _pack::round_rob │ │ │ -0004af10: 696e 290a 0909 7b0a 0909 0969 6e74 2063 in)...{....int c │ │ │ -0004af20: 6f6e 7374 2070 6965 6365 7320 3d20 7365 onst pieces = se │ │ │ -0004af30: 7474 2e67 6574 5f69 6e74 2873 6574 7469 tt.get_int(setti │ │ │ -0004af40: 6e67 735f 7061 636b 3a3a 7365 6564 696e ngs_pack::seedin │ │ │ -0004af50: 675f 7069 6563 655f 7175 6f74 6129 3b0a g_piece_quota);. │ │ │ -0004af60: 0a09 0909 7374 643a 3a6e 7468 5f65 6c65 ....std::nth_ele │ │ │ -0004af70: 6d65 6e74 2870 6565 7273 2e62 6567 696e ment(peers.begin │ │ │ -0004af80: 2829 2c20 7065 6572 732e 6265 6769 6e28 (), peers.begin( │ │ │ -0004af90: 290a 0909 0909 2b20 736c 6f74 732c 2070 ).....+ slots, p │ │ │ -0004afa0: 6565 7273 2e65 6e64 2829 0a09 0909 092c eers.end()....., │ │ │ -0004afb0: 205b 7069 6563 6573 5d28 7065 6572 5f63 [pieces](peer_c │ │ │ -0004afc0: 6f6e 6e65 6374 696f 6e20 636f 6e73 742a onnection const* │ │ │ -0004afd0: 206c 6873 2c20 7065 6572 5f63 6f6e 6e65 lhs, peer_conne │ │ │ -0004afe0: 6374 696f 6e20 636f 6e73 742a 2072 6873 ction const* rhs │ │ │ -0004aff0: 290a 0909 0909 7b20 7265 7475 726e 2075 ).....{ return u │ │ │ -0004b000: 6e63 686f 6b65 5f63 6f6d 7061 7265 5f72 nchoke_compare_r │ │ │ -0004b010: 7228 6c68 732c 2072 6873 2c20 7069 6563 r(lhs, rhs, piec │ │ │ -0004b020: 6573 293b 207d 293b 0a09 097d 0a09 0965 es); });...}...e │ │ │ -0004b030: 6c73 6520 6966 2028 7365 7474 2e67 6574 lse if (sett.get │ │ │ -0004b040: 5f69 6e74 2873 6574 7469 6e67 735f 7061 _int(settings_pa │ │ │ -0004b050: 636b 3a3a 7365 6564 5f63 686f 6b69 6e67 ck::seed_choking │ │ │ -0004b060: 5f61 6c67 6f72 6974 686d 290a 0909 093d _algorithm)....= │ │ │ -0004b070: 3d20 7365 7474 696e 6773 5f70 6163 6b3a = settings_pack: │ │ │ -0004b080: 3a66 6173 7465 7374 5f75 706c 6f61 6429 :fastest_upload) │ │ │ -0004b090: 0a09 097b 0a09 0909 7374 643a 3a6e 7468 ...{....std::nth │ │ │ -0004b0a0: 5f65 6c65 6d65 6e74 2870 6565 7273 2e62 _element(peers.b │ │ │ -0004b0b0: 6567 696e 2829 2c20 7065 6572 732e 6265 egin(), peers.be │ │ │ -0004b0c0: 6769 6e28 290a 0909 0909 2b20 736c 6f74 gin().....+ slot │ │ │ -0004b0d0: 732c 2070 6565 7273 2e65 6e64 2829 0a09 s, peers.end().. │ │ │ -0004b0e0: 0909 092c 205b 5d28 7065 6572 5f63 6f6e ..., [](peer_con │ │ │ -0004b0f0: 6e65 6374 696f 6e20 636f 6e73 742a 206c nection const* l │ │ │ -0004b100: 6873 2c20 7065 6572 5f63 6f6e 6e65 6374 hs, peer_connect │ │ │ -0004b110: 696f 6e20 636f 6e73 742a 2072 6873 290a ion const* rhs). │ │ │ -0004b120: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0004b130: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0004b160: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0004b190: 632f 6164 645f 746f 7272 656e 745f 7061 c/add_torrent_pa │ │ │ -0004b1a0: 7261 6d73 2e63 7070 3a33 313c 2f61 3e3c rams.cpp:31< │ │ │ -0004b1b0: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ -0004b1c0: 2062 6520 6e69 6365 2069 6620 7468 6973 be nice if this │ │ │ -0004b1d0: 2077 6173 206e 6f74 6872 6f77 2064 6566 was nothrow def │ │ │ -0004b1e0: 6175 6c74 2063 6f6e 7374 7275 6374 6962 ault constructib │ │ │ -0004b1f0: 6c65 2073 7461 7469 635f 6173 7365 7274 le static_assert │ │ │ -0004b200: 2873 7464 3a3a 6973 5f6e 6f74 6872 6f77 (std::is_nothrow │ │ │ -0004b210: 5f64 6566 6175 6c74 5f63 6f6e 7374 7275 _default_constru │ │ │ -0004b220: 6374 6962 6c65 3c61 6464 5f74 6f72 7265 ctible::valu │ │ │ -0004b240: 6520 2c20 2273 686f 756c 6420 6265 206e e , "should be n │ │ │ -0004b250: 6f74 6872 6f77 2064 6566 6175 6c74 2063 othrow default c │ │ │ -0004b260: 6f6e 7374 7275 6374 6962 6c65 2229 3b3c onstructible");< │ │ │ -0004b270: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ -0004b2c0: 776f 756c 6420 6265 206e 6963 6520 6966 would be nice if │ │ │ -0004b2d0: 2074 6869 7320 7761 7320 6e6f 7468 726f this was nothro │ │ │ -0004b2e0: 7720 6465 6661 756c 7420 636f 6e73 7472 w default constr │ │ │ -0004b2f0: 7563 7469 626c 650a 7374 6174 6963 5f61 uctible.static_a │ │ │ -0004b300: 7373 6572 7428 7374 643a 3a69 735f 6e6f ssert(std::is_no │ │ │ -0004b310: 7468 726f 775f 6465 6661 756c 745f 636f throw_default_co │ │ │ -0004b320: 6e73 7472 7563 7469 626c 653c 6164 645f nstructible: │ │ │ -0004b340: 3a76 616c 7565 0a2c 2022 7368 6f75 6c64 :value., "should │ │ │ -0004b350: 2062 6520 6e6f 7468 726f 7720 6465 6661 be nothrow defa │ │ │ -0004b360: 756c 7420 636f 6e73 7472 7563 7469 626c ult constructibl │ │ │ -0004b370: 6522 293b 3c2f 6832 3e3c 6834 3e2e 2e2f e");

    ../ │ │ │ -0004b380: 7372 632f 6164 645f 746f 7272 656e 745f src/add_torrent_ │ │ │ -0004b390: 7061 7261 6d73 2e63 7070 3a33 313c 2f68 params.cpp:31
    #inc
    │ │ │ -0004b3e0: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ -0004b3f0: 2f61 6464 5f74 6f72 7265 6e74 5f70 6172  /add_torrent_par
    │ │ │ -0004b400: 616d 732e 6870 7022 0a0a 6e61 6d65 7370  ams.hpp"..namesp
    │ │ │ -0004b410: 6163 6520 6c69 6274 6f72 7265 6e74 207b  ace libtorrent {
    │ │ │ -0004b420: 0a0a 0961 6464 5f74 6f72 7265 6e74 5f70  ...add_torrent_p
    │ │ │ -0004b430: 6172 616d 733a 3a61 6464 5f74 6f72 7265  arams::add_torre
    │ │ │ -0004b440: 6e74 5f70 6172 616d 7328 2920 3d20 6465  nt_params() = de
    │ │ │ -0004b450: 6661 756c 743b 0a09 6164 645f 746f 7272  fault;..add_torr
    │ │ │ -0004b460: 656e 745f 7061 7261 6d73 3a3a 7e61 6464  ent_params::~add
    │ │ │ -0004b470: 5f74 6f72 7265 6e74 5f70 6172 616d 7328  _torrent_params(
    │ │ │ -0004b480: 2920 3d20 6465 6661 756c 743b 0a09 6164  ) = default;..ad
    │ │ │ -0004b490: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ -0004b4a0: 3a3a 6164 645f 746f 7272 656e 745f 7061  ::add_torrent_pa
    │ │ │ -0004b4b0: 7261 6d73 2861 6464 5f74 6f72 7265 6e74  rams(add_torrent
    │ │ │ -0004b4c0: 5f70 6172 616d 7326 616d 703b 2661 6d70  _params&&
    │ │ │ -0004b4d0: 3b29 206e 6f65 7863 6570 7420 3d20 6465  ;) noexcept = de
    │ │ │ -0004b4e0: 6661 756c 743b 0a09 6164 645f 746f 7272  fault;..add_torr
    │ │ │ -0004b4f0: 656e 745f 7061 7261 6d73 2661 6d70 3b20  ent_params& 
    │ │ │ -0004b500: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ -0004b510: 6d73 3a3a 6f70 6572 6174 6f72 3d28 6164  ms::operator=(ad
    │ │ │ -0004b520: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ -0004b530: 2661 6d70 3b26 616d 703b 2920 2661 6d70  &&) &
    │ │ │ -0004b540: 3b20 6e6f 6578 6365 7074 203d 2064 6566  ; noexcept = def
    │ │ │ -0004b550: 6175 6c74 3b0a 0961 6464 5f74 6f72 7265  ault;..add_torre
    │ │ │ -0004b560: 6e74 5f70 6172 616d 733a 3a61 6464 5f74  nt_params::add_t
    │ │ │ -0004b570: 6f72 7265 6e74 5f70 6172 616d 7328 6164  orrent_params(ad
    │ │ │ -0004b580: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ -0004b590: 2063 6f6e 7374 2661 6d70 3b29 203d 2064   const&) = d
    │ │ │ -0004b5a0: 6566 6175 6c74 3b0a 0961 6464 5f74 6f72  efault;..add_tor
    │ │ │ -0004b5b0: 7265 6e74 5f70 6172 616d 7326 616d 703b  rent_params&
    │ │ │ -0004b5c0: 2061 6464 5f74 6f72 7265 6e74 5f70 6172   add_torrent_par
    │ │ │ -0004b5d0: 616d 733a 3a6f 7065 7261 746f 723d 2861  ams::operator=(a
    │ │ │ -0004b5e0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d  dd_torrent_param
    │ │ │ -0004b5f0: 7320 636f 6e73 7426 616d 703b 2920 2661  s const&) &a
    │ │ │ -0004b600: 6d70 3b20 3d20 6465 6661 756c 743b 0a0a  mp; = default;..
    │ │ │ -0004b610: 0973 7461 7469 635f 6173 7365 7274 2873  .static_assert(s
    │ │ │ -0004b620: 7464 3a3a 6973 5f6e 6f74 6872 6f77 5f6d  td::is_nothrow_m
    │ │ │ -0004b630: 6f76 655f 636f 6e73 7472 7563 7469 626c  ove_constructibl
    │ │ │ -0004b640: 6526 6c74 3b61 6464 5f74 6f72 7265 6e74  e<add_torrent
    │ │ │ -0004b650: 5f70 6172 616d 7326 6774 3b3a 3a76 616c  _params>::val
    │ │ │ -0004b660: 7565 0a09 092c 2022 7368 6f75 6c64 2062  ue..., "should b
    │ │ │ -0004b670: 6520 6e6f 7468 726f 7720 6d6f 7665 2063  e nothrow move c
    │ │ │ -0004b680: 6f6e 7374 7275 6374 6962 6c65 2229 3b0a  onstructible");.
    │ │ │ -0004b690: 0a09 7374 6174 6963 5f61 7373 6572 7428  ..static_assert(
    │ │ │ -0004b6a0: 7374 643a 3a69 735f 6e6f 7468 726f 775f  std::is_nothrow_
    │ │ │ -0004b6b0: 6d6f 7665 5f63 6f6e 7374 7275 6374 6962  move_constructib
    │ │ │ -0004b6c0: 6c65 266c 743b 7374 643a 3a73 7472 696e  le<std::strin
    │ │ │ -0004b6d0: 6726 6774 3b3a 3a76 616c 7565 0a09 092c  g>::value...,
    │ │ │ -0004b6e0: 2022 7368 6f75 6c64 2062 6520 6e6f 7468   "should be noth
    │ │ │ -0004b6f0: 726f 7720 6d6f 7665 2063 6f6e 7374 7275  row move constru
    │ │ │ -0004b700: 6374 6962 6c65 2229 3b0a 0a09 7374 6174  ctible");...stat
    │ │ │ -0004b710: 6963 5f61 7373 6572 7428 7374 643a 3a69  ic_assert(std::i
    │ │ │ -0004b720: 735f 6e6f 7468 726f 775f 6d6f 7665 5f61  s_nothrow_move_a
    │ │ │ -0004b730: 7373 6967 6e61 626c 6526 6c74 3b61 6464  ssignable<add
    │ │ │ -0004b740: 5f74 6f72 7265 6e74 5f70 6172 616d 7326  _torrent_params&
    │ │ │ -0004b750: 6774 3b3a 3a76 616c 7565 0a09 092c 2022  gt;::value..., "
    │ │ │ -0004b760: 7368 6f75 6c64 2062 6520 6e6f 7468 726f  should be nothro
    │ │ │ -0004b770: 7720 6d6f 7665 2061 7373 6967 6e61 626c  w move assignabl
    │ │ │ -0004b780: 6522 293b 0a0a 3c64 6976 2073 7479 6c65  e");..
    .
    names │ │ │ -0004b7c0: 7061 6365 2061 7578 207b 0a0a 092f 2f20 pace aux {...// │ │ │ -0004b7d0: 7265 7475 726e 7320 7768 6574 6865 7220 returns whether │ │ │ -0004b7e0: 7468 6973 2061 6464 5f74 6f72 7265 6e74 this add_torrent │ │ │ -0004b7f0: 5f70 6172 616d 7320 6f62 6a65 6374 2068 _params object h │ │ │ -0004b800: 6173 2022 7265 7375 6d65 2d64 6174 6122 as "resume-data" │ │ │ -0004b810: 2c20 692e 652e 0a09 2f2f 2069 6e66 6f72 , i.e...// infor │ │ │ -0004b820: 6d61 7469 6f6e 2061 626f 7574 2077 6869 mation about whi │ │ │ -0004b830: 6368 2070 6965 6365 7320 7765 2068 6176 ch pieces we hav │ │ │ -0004b840: 652e 0a09 626f 6f6c 2063 6f6e 7461 696e e...bool contain │ │ │ -0004b850: 735f 7265 7375 6d65 5f64 6174 6128 6164 s_resume_data(ad │ │ │ -0004b860: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ -0004b870: 2063 6f6e 7374 2661 6d70 3b20 6174 7029 const& atp) │ │ │ -0004b880: 0a09 7b0a 0909 7265 7475 726e 2021 6174 ..{...return !at │ │ │ -0004b890: 702e 6861 7665 5f70 6965 6365 732e 656d p.have_pieces.em │ │ │ -0004b8a0: 7074 7928 290a 0909 097c 7c20 2861 7470 pty()....|| (atp │ │ │ -0004b8b0: 2e66 6c61 6773 2026 616d 703b 2074 6f72 .flags & tor │ │ │ -0004b8c0: 7265 6e74 5f66 6c61 6773 3a3a 7365 6564 rent_flags::seed │ │ │ -0004b8d0: 5f6d 6f64 6529 3b0a 097d 0a7d 0a0a 7d0a _mode);..}.}..}. │ │ │ -0004b8e0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0004b8f0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0004b920: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0004b950: 632f 6932 705f 7065 782e 6370 703a 3430 c/i2p_pex.cpp:40 │ │ │ -0004b960: 303c 2f61 3e3c 2f74 643e 3c74 643e 6661 0fa │ │ │ -0004b970: 6374 6f72 2074 6869 7320 6f75 7420 696e ctor this out in │ │ │ -0004b980: 746f 2022 736c 6964 696e 6720 7769 6e64 to "sliding wind │ │ │ -0004b990: 6f77 223f 2049 7427 7320 7368 6172 6564 ow"? It's shared │ │ │ -0004b9a0: 2077 6974 6820 7574 5f70 6578 3c2f 7464 with ut_pex

    factor │ │ │ -0004ba00: 2074 6869 7320 6f75 7420 696e 746f 2022 this out into " │ │ │ -0004ba10: 736c 6964 696e 6720 7769 6e64 6f77 223f sliding window"? │ │ │ -0004ba20: 2049 7427 7320 7368 6172 6564 2077 6974 It's shared wit │ │ │ -0004ba30: 6820 7574 5f70 6578 3c2f 6832 3e3c 6834 h ut_pex

    ../src/i2p_pex. │ │ │ -0004ba50: 6370 703a 3430 303c 2f68 343e 3c70 7265 cpp:400

    ...m_pc.st
    │ │ │ -0004baa0: 6174 735f 636f 756e 7465 7273 2829 2e69  ats_counters().i
    │ │ │ -0004bab0: 6e63 5f73 7461 7473 5f63 6f75 6e74 6572  nc_stats_counter
    │ │ │ -0004bac0: 2863 6f75 6e74 6572 733a 3a6e 756d 5f6f  (counters::num_o
    │ │ │ -0004bad0: 7574 676f 696e 675f 6578 7465 6e64 6564  utgoing_extended
    │ │ │ -0004bae0: 293b 0a09 0909 6d5f 7063 2e73 7461 7473  );....m_pc.stats
    │ │ │ -0004baf0: 5f63 6f75 6e74 6572 7328 292e 696e 635f  _counters().inc_
    │ │ │ -0004bb00: 7374 6174 735f 636f 756e 7465 7228 636f  stats_counter(co
    │ │ │ -0004bb10: 756e 7465 7273 3a3a 6e75 6d5f 6f75 7467  unters::num_outg
    │ │ │ -0004bb20: 6f69 6e67 5f70 6578 293b 0a0a 2369 666e  oing_pex);..#ifn
    │ │ │ -0004bb30: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ -0004bb40: 424c 455f 4c4f 4747 494e 470a 0909 096d  BLE_LOGGING....m
    │ │ │ -0004bb50: 5f70 632e 7065 6572 5f6c 6f67 2870 6565  _pc.peer_log(pee
    │ │ │ -0004bb60: 725f 6c6f 675f 616c 6572 743a 3a6f 7574  r_log_alert::out
    │ │ │ -0004bb70: 676f 696e 675f 6d65 7373 6167 652c 2070  going_message, p
    │ │ │ -0004bb80: 6565 725f 6c6f 675f 616c 6572 743a 3a69  eer_log_alert::i
    │ │ │ -0004bb90: 3270 5f70 6578 5f66 756c 6c0a 0909 0909  2p_pex_full.....
    │ │ │ -0004bba0: 2c20 2261 6464 6564 3a20 2564 206d 7367  , "added: %d msg
    │ │ │ -0004bbb0: 5f73 697a 653a 2025 6422 2c20 6e75 6d5f  _size: %d", num_
    │ │ │ -0004bbc0: 6164 6465 642c 2069 6e74 2870 6578 5f6d  added, int(pex_m
    │ │ │ -0004bbd0: 7367 2e73 697a 6528 2929 293b 0a23 656e  sg.size()));.#en
    │ │ │ -0004bbe0: 6469 660a 0909 7d0a 0a09 0961 7578 3a3a  dif...}....aux::
    │ │ │ -0004bbf0: 746f 7272 656e 7426 616d 703b 206d 5f74  torrent& m_t
    │ │ │ -0004bc00: 6f72 7265 6e74 3b0a 0909 6175 783a 3a70  orrent;...aux::p
    │ │ │ -0004bc10: 6565 725f 636f 6e6e 6563 7469 6f6e 2661  eer_connection&a
    │ │ │ -0004bc20: 6d70 3b20 6d5f 7063 3b0a 0909 6932 705f  mp; m_pc;...i2p_
    │ │ │ -0004bc30: 7065 785f 706c 7567 696e 2661 6d70 3b20  pex_plugin& 
    │ │ │ -0004bc40: 6d5f 7470 3b0a 0a09 092f 2f20 7468 6520  m_tp;....// the 
    │ │ │ -0004bc50: 6c61 7374 2070 6578 206d 6573 7361 6765  last pex message
    │ │ │ -0004bc60: 7320 7765 2072 6563 6569 7665 640a 0909  s we received...
    │ │ │ -0004bc70: 2f2f 205b 305d 2069 7320 7468 6520 6f6c  // [0] is the ol
    │ │ │ -0004bc80: 6465 7374 206f 6e65 2e20 5468 6572 6520  dest one. There 
    │ │ │ -0004bc90: 6973 2061 2070 726f 626c 656d 2077 6974  is a problem wit
    │ │ │ -0004bca0: 680a 0909 2f2f 2072 6174 6520 6c69 6d69  h...// rate limi
    │ │ │ -0004bcb0: 7465 6420 636f 6e6e 6563 7469 6f6e 732c  ted connections,
    │ │ │ -0004bcc0: 2062 6563 6175 7365 2077 6520 6d61 7920   because we may 
    │ │ │ -0004bcd0: 7369 740a 0909 2f2f 2066 6f72 2061 206c  sit...// for a l
    │ │ │ -0004bce0: 6f6e 6720 7469 6d65 2c20 6163 6375 6d75  ong time, accumu
    │ │ │ -0004bcf0: 6c61 7469 6e67 2070 6578 206d 6573 7361  lating pex messa
    │ │ │ -0004bd00: 6765 732c 2061 6e64 0a09 092f 2f20 7468  ges, and...// th
    │ │ │ -0004bd10: 656e 206f 6e63 6520 7765 2072 6561 6420  en once we read 
    │ │ │ -0004bd20: 6672 6f6d 2074 6865 2073 6f63 6b65 7420  from the socket 
    │ │ │ -0004bd30: 6974 2077 696c 6c20 6c6f 6f6b 206c 696b  it will look lik
    │ │ │ -0004bd40: 650a 0909 2f2f 2077 6520 7265 6365 6976  e...// we receiv
    │ │ │ -0004bd50: 6564 2074 6865 6d20 616c 6c20 6261 636b  ed them all back
    │ │ │ -0004bd60: 2074 6f20 6261 636b 2e20 5468 6174 2773   to back. That's
    │ │ │ -0004bd70: 2077 6879 0a09 092f 2f20 7765 206c 6f6f   why...// we loo
    │ │ │ -0004bd80: 6b20 6174 2036 2070 6578 206d 6573 7361  k at 6 pex messa
    │ │ │ -0004bd90: 6765 7320 6261 636b 2e0a 3c64 6976 2073  ges back..
    ..aux::a │ │ │ -0004bdd0: 7272 6179 266c 743b 7469 6d65 5f70 6f69 rray<time_poi │ │ │ -0004bde0: 6e74 2c20 3626 6774 3b20 6d5f 6c61 7374 nt, 6> m_last │ │ │ -0004bdf0: 5f70 6578 3b0a 3c2f 6469 763e 0a09 0974 _pex;.
    ...t │ │ │ -0004be00: 696d 655f 706f 696e 7420 6d5f 6c61 7374 ime_point m_last │ │ │ -0004be10: 5f6d 7367 3b0a 0909 696e 7420 6d5f 6d65 _msg;...int m_me │ │ │ -0004be20: 7373 6167 655f 696e 6465 7820 3d20 303b ssage_index = 0; │ │ │ -0004be30: 0a0a 0909 2f2f 2074 6869 7320 6973 2069 ....// this is i │ │ │ -0004be40: 6e69 7469 616c 697a 6564 2074 6f20 7472 nitialized to tr │ │ │ -0004be50: 7565 2c20 616e 6420 7365 7420 746f 0a09 ue, and set to.. │ │ │ -0004be60: 092f 2f20 6661 6c73 6520 6166 7465 7220 .// false after │ │ │ -0004be70: 7468 6520 6669 7273 7420 7065 7820 6d65 the first pex me │ │ │ -0004be80: 7373 6167 6520 6861 7320 6265 656e 2073 ssage has been s │ │ │ -0004be90: 656e 742e 0a09 092f 2f20 6974 2069 7320 ent....// it is │ │ │ -0004bea0: 7573 6564 2074 6f20 6b6e 6f77 2069 6620 used to know if │ │ │ -0004beb0: 6120 6469 6666 206d 6573 7361 6765 206f a diff message o │ │ │ -0004bec0: 7220 6120 6675 6c6c 0a09 092f 2f20 6d65 r a full...// me │ │ │ -0004bed0: 7373 6167 6520 7368 6f75 6c64 2062 6520 ssage should be │ │ │ -0004bee0: 7365 6e74 2e0a 0909 626f 6f6c 206d 5f66 sent....bool m_f │ │ │ -0004bef0: 6972 7374 5f74 696d 6520 3d20 7472 7565 irst_time = true │ │ │ -0004bf00: 3b0a 097d 3b0a 0a09 7374 643a 3a73 6861 ;..};...std::sha │ │ │ -0004bf10: 7265 645f 7074 7226 6c74 3b70 6565 725f red_ptr<peer_ │ │ │ -0004bf20: 706c 7567 696e 2667 743b 2069 3270 5f70 plugin> i2p_p │ │ │ -0004bf30: 6578 5f70 6c75 6769 6e3a 3a6e 6577 5f63 ex_plugin::new_c │ │ │ -0004bf40: 6f6e 6e65 6374 696f 6e28 7065 6572 5f63 onnection(peer_c │ │ │ -0004bf50: 6f6e 6e65 6374 696f 6e5f 6861 6e64 6c65 onnection_handle │ │ │ -0004bf60: 2063 6f6e 7374 2661 6d70 3b20 7063 290a const& pc). │ │ │ -0004bf70: 097b 0a09 0969 6620 2870 632e 7479 7065 .{...if (pc.type │ │ │ -0004bf80: 2829 2021 3d20 636f 6e6e 6563 7469 6f6e () != connection │ │ │ -0004bf90: 5f74 7970 653a 3a62 6974 746f 7272 656e _type::bittorren │ │ │ -0004bfa0: 7429 2072 6574 7572 6e20 7b7d 3b0a 0909 t) return {};... │ │ │ -0004bfb0: 6175 783a 3a62 745f 7065 6572 5f63 6f6e aux::bt_peer_con │ │ │ -0004bfc0: 6e65 6374 696f 6e2a 2063 203d 2073 7461 nection* c = sta │ │ │ -0004bfd0: 7469 635f 6361 7374 266c 743b 6175 783a tic_cast<aux: │ │ │ -0004bfe0: 3a62 745f 7065 6572 5f63 6f6e 6e65 6374 :bt_peer_connect │ │ │ -0004bff0: 696f 6e2a 2667 743b 2870 632e 6e61 7469 ion*>(pc.nati │ │ │ -0004c000: 7665 5f68 616e 646c 6528 292e 6765 7428 ve_handle().get( │ │ │ -0004c010: 2929 3b0a 0a09 092f 2f20 7468 6973 2065 ));....// this e │ │ │ -0004c020: 7874 656e 7369 6f6e 2069 7320 6f6e 6c79 xtension is only │ │ │ -0004c030: 2066 6f72 2069 3270 2070 6565 7220 636f for i2p peer co │ │ │ -0004c040: 6e6e 6563 7469 6f6e 730a 0909 6966 2028 nnections...if ( │ │ │ -0004c050: 2169 735f 6932 7028 632d 2667 743b 6765 !is_i2p(c->ge │ │ │ -0004c060: 745f 736f 636b 6574 2829 2929 2072 6574 t_socket())) ret │ │ │ -0004c070: 7572 6e20 7b7d 3b0a 0a09 0972 6574 7572 urn {};....retur │ │ │ -0004c080: 6e20 7374 643a 3a6d 616b 655f 7368 6172 n std::make_shar │ │ │ -0004c090: 6564 266c 743b 6932 705f 7065 785f 7065 ed<i2p_pex_pe │ │ │ -0004c0a0: 6572 5f70 6c75 6769 6e26 6774 3b28 6d5f er_plugin>(m_ │ │ │ -0004c0b0: 746f 7272 656e 742c 202a 632c 202a 7468 torrent, *c, *th │ │ │ -0004c0c0: 6973 293b 0a09 7d0a 7d20 7d0a 0a6e 616d is);..}.} }..nam │ │ │ -0004c0d0: 6573 7061 6365 206c 6962 746f 7272 656e espace libtorren │ │ │ -0004c0e0: 7420 7b0a 0a09 7374 643a 3a73 6861 7265 t {...std::share │ │ │ -0004c0f0: 645f 7074 7226 6c74 3b74 6f72 7265 6e74 d_ptr<torrent │ │ │ -0004c100: 5f70 6c75 6769 6e26 6774 3b20 6372 6561 _plugin> crea │ │ │ -0004c110: 7465 5f69 3270 5f70 6578 5f70 6c75 6769 te_i2p_pex_plugi │ │ │ -0004c120: 6e28 746f 7272 656e 745f 6861 6e64 6c65 n(torrent_handle │ │ │ -0004c130: 2063 6f6e 7374 2661 6d70 3b20 7468 2c20 const& th, │ │ │ -0004c140: 636c 6965 6e74 5f64 6174 615f 7429 0a09 client_data_t).. │ │ │ -0004c150: 7b0a 0909 6175 783a 3a74 6f72 7265 6e74 {...aux::torrent │ │ │ -0004c160: 2a20 7420 3d20 7468 2e6e 6174 6976 655f * t = th.native_ │ │ │ -0004c170: 6861 6e64 6c65 2829 2e67 6574 2829 3b0a handle().get();. │ │ │ -0004c180: 0909 2f2f 206f 6e6c 7920 6164 6420 6578 ..// only add ex │ │ │ -0004c190: 7465 6e73 696f 6e20 746f 2069 3270 2074 tension to i2p t │ │ │ -0004c1a0: 6f72 7265 6e74 730a 0909 6966 2028 742d orrents...if (t- │ │ │ -0004c1b0: 2667 743b 746f 7272 656e 745f 6669 6c65 >torrent_file │ │ │ -0004c1c0: 2829 2e70 7269 7628 2920 7c7c 2021 742d ().priv() || !t- │ │ │ -0004c1d0: 2667 743b 6973 5f69 3270 2829 290a 3c2f >is_i2p()).r │ │ │ -0004c210: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0004c220: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0004c250: 6970 5f6e 6f74 6966 6965 722e 6370 703a ip_notifier.cpp: │ │ │ -0004c260: 3138 3c2f 613e 3c2f 7464 3e3c 7464 3e73 18s │ │ │ -0004c270: 696d 756c 6174 6f72 2073 7570 706f 7274 imulator support │ │ │ -0004c280: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    si │ │ │ -0004c2d0: 6d75 6c61 746f 7220 7375 7070 6f72 743c mulator support< │ │ │ -0004c2e0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f69 /h2>

    ../src/i │ │ │ -0004c2f0: 705f 6e6f 7469 6669 6572 2e63 7070 3a31 p_notifier.cpp:1 │ │ │ -0004c300: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ -0004c340: 0a23 656e 6469 660a 2365 6e64 6966 0a2f  .#endif.#endif./
    │ │ │ -0004c350: 2a0a 0a43 6f70 7972 6967 6874 2028 6329  *..Copyright (c)
    │ │ │ -0004c360: 2032 3031 362d 3230 3137 2c20 3230 3231   2016-2017, 2021
    │ │ │ -0004c370: 2c20 416c 6465 6e20 546f 7272 6573 0a43  , Alden Torres.C
    │ │ │ -0004c380: 6f70 7972 6967 6874 2028 6329 2032 3031  opyright (c) 201
    │ │ │ -0004c390: 362c 2032 3032 302c 2053 7465 7665 6e20  6, 2020, Steven 
    │ │ │ -0004c3a0: 5369 6c6f 7469 0a43 6f70 7972 6967 6874  Siloti.Copyright
    │ │ │ -0004c3b0: 2028 6329 2032 3031 372d 3230 3232 2c20   (c) 2017-2022, 
    │ │ │ -0004c3c0: 4172 7669 6420 4e6f 7262 6572 670a 436f  Arvid Norberg.Co
    │ │ │ -0004c3d0: 7079 7269 6768 7420 2863 2920 3230 3137  pyright (c) 2017
    │ │ │ -0004c3e0: 2c20 5469 6d20 4e69 6564 6572 6861 7573  , Tim Niederhaus
    │ │ │ -0004c3f0: 656e 0a43 6f70 7972 6967 6874 2028 6329  en.Copyright (c)
    │ │ │ -0004c400: 2032 3032 302c 2054 6967 6572 2057 616e   2020, Tiger Wan
    │ │ │ -0004c410: 670a 416c 6c20 7269 6768 7473 2072 6573  g.All rights res
    │ │ │ -0004c420: 6572 7665 642e 0a0a 596f 7520 6d61 7920  erved...You may 
    │ │ │ -0004c430: 7573 652c 2064 6973 7472 6962 7574 6520  use, distribute 
    │ │ │ -0004c440: 616e 6420 6d6f 6469 6679 2074 6869 7320  and modify this 
    │ │ │ -0004c450: 636f 6465 2075 6e64 6572 2074 6865 2074  code under the t
    │ │ │ -0004c460: 6572 6d73 206f 6620 7468 6520 4253 4420  erms of the BSD 
    │ │ │ -0004c470: 6c69 6365 6e73 652c 0a73 6565 204c 4943  license,.see LIC
    │ │ │ -0004c480: 454e 5345 2066 696c 652e 0a2a 2f0a 0a23  ENSE file..*/..#
    │ │ │ -0004c490: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -0004c4a0: 656e 742f 6175 785f 2f69 705f 6e6f 7469  ent/aux_/ip_noti
    │ │ │ -0004c4b0: 6669 6572 2e68 7070 220a 2369 6e63 6c75  fier.hpp".#inclu
    │ │ │ -0004c4c0: 6465 2022 6c69 6274 6f72 7265 6e74 2f61  de "libtorrent/a
    │ │ │ -0004c4d0: 7373 6572 742e 6870 7022 0a0a 2369 6620  ssert.hpp"..#if 
    │ │ │ -0004c4e0: 6465 6669 6e65 6420 544f 5252 454e 545f  defined TORRENT_
    │ │ │ -0004c4f0: 4255 494c 445f 5349 4d55 4c41 544f 520a  BUILD_SIMULATOR.
    │ │ │ -0004c500: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    #e │ │ │ -0004c530: 6c69 6620 544f 5252 454e 545f 5553 455f lif TORRENT_USE_ │ │ │ -0004c540: 4e45 544c 494e 4b0a 3c2f 6469 763e 2369 NETLINK.
    #i │ │ │ -0004c550: 6e63 6c75 6465 2022 6c69 6274 6f72 7265 nclude "libtorre │ │ │ -0004c560: 6e74 2f61 7578 5f2f 6e65 746c 696e 6b2e nt/aux_/netlink. │ │ │ -0004c570: 6870 7022 0a23 696e 636c 7564 6520 226c hpp".#include "l │ │ │ -0004c580: 6962 746f 7272 656e 742f 736f 636b 6574 ibtorrent/socket │ │ │ -0004c590: 2e68 7070 220a 2369 6e63 6c75 6465 2026 .hpp".#include & │ │ │ -0004c5a0: 6c74 3b61 7272 6179 2667 743b 0a23 696e lt;array>.#in │ │ │ -0004c5b0: 636c 7564 6520 266c 743b 756e 6f72 6465 clude <unorde │ │ │ -0004c5c0: 7265 645f 6d61 7026 6774 3b0a 2365 6c69 red_map>.#eli │ │ │ -0004c5d0: 6620 544f 5252 454e 545f 5553 455f 5359 f TORRENT_USE_SY │ │ │ -0004c5e0: 5354 454d 434f 4e46 4947 5552 4154 494f STEMCONFIGURATIO │ │ │ -0004c5f0: 4e20 7c7c 2054 4f52 5245 4e54 5f55 5345 N || TORRENT_USE │ │ │ -0004c600: 5f53 435f 4e45 5457 4f52 4b5f 5245 4143 _SC_NETWORK_REAC │ │ │ -0004c610: 4841 4249 4c49 5459 0a23 696e 636c 7564 HABILITY.#includ │ │ │ -0004c620: 6520 266c 743b 5379 7374 656d 436f 6e66 e <SystemConf │ │ │ -0004c630: 6967 7572 6174 696f 6e2f 5379 7374 656d iguration/System │ │ │ -0004c640: 436f 6e66 6967 7572 6174 696f 6e2e 6826 Configuration.h& │ │ │ -0004c650: 6774 3b0a 2365 6c69 6620 6465 6669 6e65 gt;.#elif define │ │ │ -0004c660: 6420 544f 5252 454e 545f 5749 4e44 4f57 d TORRENT_WINDOW │ │ │ -0004c670: 530a 2369 6e63 6c75 6465 2022 6c69 6274 S.#include "libt │ │ │ -0004c680: 6f72 7265 6e74 2f61 7578 5f2f 7468 726f orrent/aux_/thro │ │ │ -0004c690: 772e 6870 7022 0a23 696e 636c 7564 6520 w.hpp".#include │ │ │ -0004c6a0: 226c 6962 746f 7272 656e 742f 6175 785f "libtorrent/aux_ │ │ │ -0004c6b0: 2f64 6973 6162 6c65 5f77 6172 6e69 6e67 /disable_warning │ │ │ -0004c6c0: 735f 7075 7368 2e68 7070 220a 2369 6e63 s_push.hpp".#inc │ │ │ -0004c6d0: 6c75 6465 2026 6c74 3b69 7068 6c70 6170 lude <iphlpap │ │ │ -0004c6e0: 692e 6826 6774 3b0a 2369 6664 6566 2054 i.h>.#ifdef T │ │ │ -0004c6f0: 4f52 5245 4e54 5f57 494e 5254 0a23 696e ORRENT_WINRT.#in │ │ │ -0004c700: 636c 7564 6520 266c 743b 6e65 7469 6f61 clude <netioa │ │ │ -0004c710: 7069 2e68 2667 743b 0a23 656e 6469 660a pi.h>.#endif. │ │ │ -0004c720: 2369 6e63 6c75 6465 2026 6c74 3b6d 7574 #include <mut │ │ │ -0004c730: 6578 2667 743b 0a23 696e 636c 7564 6520 ex>.#include │ │ │ -0004c740: 226c 6962 746f 7272 656e 742f 6175 785f "libtorrent/aux_ │ │ │ -0004c750: 2f64 6973 6162 6c65 5f77 6172 6e69 6e67 /disable_warning │ │ │ -0004c760: 735f 706f 702e 6870 7022 0a23 656e 6469 s_pop.hpp".#endi │ │ │ -0004c770: 660a 0a23 696e 636c 7564 6520 226c 6962 f..#include "lib │ │ │ -0004c780: 746f 7272 656e 742f 6175 785f 2f6e 6574 torrent/aux_/net │ │ │ -0004c790: 6c69 6e6b 5f75 7469 6c73 2e68 7070 220a link_utils.hpp". │ │ │ -0004c7a0: 0a6e 616d 6573 7061 6365 206c 6962 746f .namespace libto │ │ │ -0004c7b0: 7272 656e 743a 3a61 7578 207b 0a0a 6e61 rrent::aux {..na │ │ │ -0004c7c0: 6d65 7370 6163 6520 7b0a 0a23 6966 2028 mespace {..#if ( │ │ │ -0004c7d0: 544f 5252 454e 545f 5553 455f 5359 5354 TORRENT_USE_SYST │ │ │ -0004c7e0: 454d 434f 4e46 4947 5552 4154 494f 4e20 EMCONFIGURATION │ │ │ -0004c7f0: 7c7c 2054 4f52 5245 4e54 5f55 5345 5f53 || TORRENT_USE_S │ │ │ -0004c800: 435f 4e45 5457 4f52 4b5f 5245 4143 4841 C_NETWORK_REACHA │ │ │ -0004c810: 4249 4c49 5459 2920 2661 6d70 3b26 616d BILITY) &&am │ │ │ -0004c820: 703b 205c 0a09 2164 6566 696e 6564 2054 p; \..!defined T │ │ │ -0004c830: 4f52 5245 4e54 5f42 5549 4c44 5f53 494d ORRENT_BUILD_SIM │ │ │ -0004c840: 554c 4154 4f52 0a0a 2f2f 2063 6f6d 6d6f ULATOR..// commo │ │ │ -0004c850: 6e20 7574 696c 6974 6965 7320 666f 7220 n utilities for │ │ │ -0004c860: 4d61 6320 616e 6420 694f 530a 7465 6d70 Mac and iOS.temp │ │ │ -0004c870: 6c61 7465 2026 6c74 3b74 7970 656e 616d late <typenam │ │ │ -0004c880: 6520 5426 6774 3b20 766f 6964 2043 4652 e T> void CFR │ │ │ -0004c890: 6566 5265 7461 696e 2854 2068 2920 7b20 efRetain(T h) { │ │ │ -0004c8a0: 4346 5265 7461 696e 2868 293b 207d 0a74 CFRetain(h); }.t │ │ │ -0004c8b0: 656d 706c 6174 6520 266c 743b 7479 7065 emplate <type │ │ │ -0004c8c0: 6e61 6d65 2054 2667 743b 2076 6f69 6420 name T> void │ │ │ -0004c8d0: 4346 5265 6652 656c 6561 7365 2854 2068 CFRefRelease(T h │ │ │ -0004c8e0: 2920 7b20 4346 5265 6c65 6173 6528 6829 ) { CFRelease(h) │ │ │ -0004c8f0: 3b20 7d0a 0a3c 2f70 7265 3e3c 2f74 643e ; }..
    │ │ │ -0004c900: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0004c930: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0004c940: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0004c950: 7074 3a65 7870 616e 6428 3138 3529 223e pt:expand(185)"> │ │ │ -0004c960: 2e2e 2f73 7263 2f74 7261 636b 6572 5f6c ../src/tracker_l │ │ │ -0004c970: 6973 742e 6370 703a 3833 3c2f 613e 3c2f ist.cpp:83if this t │ │ │ -0004c990: 6872 6f77 732c 206e 6577 5f61 6520 6e65 hrows, new_ae ne │ │ │ -0004c9a0: 6564 7320 746f 2062 6520 6672 6565 643c eds to be freed< │ │ │ -0004c9b0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    if │ │ │ -0004ca00: 7468 6973 2074 6872 6f77 732c 206e 6577 this throws, new │ │ │ -0004ca10: 5f61 6520 6e65 6564 7320 746f 2062 6520 _ae needs to be │ │ │ -0004ca20: 6672 6565 643c 2f68 323e 3c68 343e 2e2e freed

    .. │ │ │ -0004ca30: 2f73 7263 2f74 7261 636b 6572 5f6c 6973 /src/tracker_lis │ │ │ -0004ca40: 742e 6370 703a 3833 3c2f 6834 3e3c 7072 t.cpp:83

    {..ae-> │ │ │ -0004ca90: 3b66 6169 6c5f 6c69 6d69 7420 3d20 313b ;fail_limit = 1; │ │ │ -0004caa0: 0a7d 0a0a 626f 6f6c 2074 7261 636b 6572 .}..bool tracker │ │ │ -0004cab0: 5f6c 6973 743a 3a61 6464 5f74 7261 636b _list::add_track │ │ │ -0004cac0: 6572 2861 6e6e 6f75 6e63 655f 656e 7472 er(announce_entr │ │ │ -0004cad0: 7920 636f 6e73 7426 616d 703b 2061 6529 y const& ae) │ │ │ -0004cae0: 0a7b 0a09 494e 5641 5249 414e 545f 4348 .{..INVARIANT_CH │ │ │ -0004caf0: 4543 4b3b 0a0a 0969 6620 2861 652e 7572 ECK;...if (ae.ur │ │ │ -0004cb00: 6c2e 656d 7074 7928 2929 2072 6574 7572 l.empty()) retur │ │ │ -0004cb10: 6e20 6661 6c73 653b 0a09 6175 746f 2a20 n false;..auto* │ │ │ -0004cb20: 6b20 3d20 6669 6e64 5f74 7261 636b 6572 k = find_tracker │ │ │ -0004cb30: 2861 652e 7572 6c29 3b0a 0969 6620 286b (ae.url);..if (k │ │ │ -0004cb40: 290a 097b 0a09 096b 2d26 6774 3b73 6f75 )..{...k->sou │ │ │ -0004cb50: 7263 6520 7c3d 2061 652e 736f 7572 6365 rce |= ae.source │ │ │ -0004cb60: 3b0a 0909 7265 7475 726e 2066 616c 7365 ;...return false │ │ │ -0004cb70: 3b0a 097d 0a0a 0961 7574 6f2a 206e 6577 ;..}...auto* new │ │ │ -0004cb80: 5f61 6520 3d20 6d5f 7374 6f72 6167 652e _ae = m_storage. │ │ │ -0004cb90: 636f 6e73 7472 7563 7428 6165 293b 0a09 construct(ae);.. │ │ │ -0004cba0: 6966 2028 6d5f 7472 6163 6b65 7273 2e65 if (m_trackers.e │ │ │ -0004cbb0: 6d70 7479 2829 290a 097b 0a09 096d 5f74 mpty())..{...m_t │ │ │ -0004cbc0: 7261 636b 6572 732e 7075 7368 5f62 6163 rackers.push_bac │ │ │ -0004cbd0: 6b28 2a6e 6577 5f61 6529 3b0a 3c64 6976 k(*new_ae);.
    ..m_ur │ │ │ -0004cc10: 6c5f 696e 6465 782e 696e 7365 7274 2873 l_index.insert(s │ │ │ -0004cc20: 7464 3a3a 6d61 6b65 5f70 6169 7228 7374 td::make_pair(st │ │ │ -0004cc30: 7269 6e67 5f76 6965 7728 6e65 775f 6165 ring_view(new_ae │ │ │ -0004cc40: 2d26 6774 3b75 726c 292c 206e 6577 5f61 ->url), new_a │ │ │ -0004cc50: 6529 293b 0a3c 2f64 6976 3e09 0972 6574 e));.
    ..ret │ │ │ -0004cc60: 7572 6e20 7472 7565 3b0a 097d 0a0a 0961 urn true;..}...a │ │ │ -0004cc70: 7574 6f20 6974 6572 203d 206d 5f74 7261 uto iter = m_tra │ │ │ -0004cc80: 636b 6572 732e 656e 6428 293b 0a09 7768 ckers.end();..wh │ │ │ -0004cc90: 696c 6520 2869 7465 7220 213d 206d 5f74 ile (iter != m_t │ │ │ -0004cca0: 7261 636b 6572 732e 6265 6769 6e28 2920 rackers.begin() │ │ │ -0004ccb0: 2661 6d70 3b26 616d 703b 2073 7464 3a3a && std:: │ │ │ -0004ccc0: 7072 6576 2869 7465 7229 2d26 6774 3b74 prev(iter)->t │ │ │ -0004ccd0: 6965 7220 2667 743b 206e 6577 5f61 652d ier > new_ae- │ │ │ -0004cce0: 2667 743b 7469 6572 290a 0909 2d2d 6974 >tier)...--it │ │ │ -0004ccf0: 6572 3b0a 0a09 6d5f 7472 6163 6b65 7273 er;...m_trackers │ │ │ -0004cd00: 2e69 6e73 6572 7428 6974 6572 2c20 2a6e .insert(iter, *n │ │ │ -0004cd10: 6577 5f61 6529 3b0a 3c2f 7072 653e 3c2f ew_ae);.
    relevan │ │ │ -0004cd50: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/tracke │ │ │ -0004cd90: 725f 6c69 7374 2e63 7070 3a39 333c 2f61 r_list.cpp:93if thi │ │ │ -0004cdb0: 7320 7468 726f 7773 2c20 6e65 775f 6165 s throws, new_ae │ │ │ -0004cdc0: 206e 6565 6473 2074 6f20 6265 2066 7265 needs to be fre │ │ │ -0004cdd0: 6564 3c2f 7464 3e3c 2f74 723e 3c74 7220 ed

    │ │ │ -0004ce20: 6966 2074 6869 7320 7468 726f 7773 2c20 if this throws, │ │ │ -0004ce30: 6e65 775f 6165 206e 6565 6473 2074 6f20 new_ae needs to │ │ │ -0004ce40: 6265 2066 7265 6564 3c2f 6832 3e3c 6834 be freed

    ../src/tracker_ │ │ │ -0004ce60: 6c69 7374 2e63 7070 3a39 333c 2f68 343e list.cpp:93

    │ │ │ -0004ce70: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .auto*
    │ │ │ -0004ceb0: 206b 203d 2066 696e 645f 7472 6163 6b65   k = find_tracke
    │ │ │ -0004cec0: 7228 6165 2e75 726c 293b 0a09 6966 2028  r(ae.url);..if (
    │ │ │ -0004ced0: 6b29 0a09 7b0a 0909 6b2d 2667 743b 736f  k)..{...k->so
    │ │ │ -0004cee0: 7572 6365 207c 3d20 6165 2e73 6f75 7263  urce |= ae.sourc
    │ │ │ -0004cef0: 653b 0a09 0972 6574 7572 6e20 6661 6c73  e;...return fals
    │ │ │ -0004cf00: 653b 0a09 7d0a 0a09 6175 746f 2a20 6e65  e;..}...auto* ne
    │ │ │ -0004cf10: 775f 6165 203d 206d 5f73 746f 7261 6765  w_ae = m_storage
    │ │ │ -0004cf20: 2e63 6f6e 7374 7275 6374 2861 6529 3b0a  .construct(ae);.
    │ │ │ -0004cf30: 0969 6620 286d 5f74 7261 636b 6572 732e  .if (m_trackers.
    │ │ │ -0004cf40: 656d 7074 7928 2929 0a09 7b0a 0909 6d5f  empty())..{...m_
    │ │ │ -0004cf50: 7472 6163 6b65 7273 2e70 7573 685f 6261  trackers.push_ba
    │ │ │ -0004cf60: 636b 282a 6e65 775f 6165 293b 0a09 096d  ck(*new_ae);...m
    │ │ │ -0004cf70: 5f75 726c 5f69 6e64 6578 2e69 6e73 6572  _url_index.inser
    │ │ │ -0004cf80: 7428 7374 643a 3a6d 616b 655f 7061 6972  t(std::make_pair
    │ │ │ -0004cf90: 2873 7472 696e 675f 7669 6577 286e 6577  (string_view(new
    │ │ │ -0004cfa0: 5f61 652d 2667 743b 7572 6c29 2c20 6e65  _ae->url), ne
    │ │ │ -0004cfb0: 775f 6165 2929 3b0a 0909 7265 7475 726e  w_ae));...return
    │ │ │ -0004cfc0: 2074 7275 653b 0a09 7d0a 0a09 6175 746f   true;..}...auto
    │ │ │ -0004cfd0: 2069 7465 7220 3d20 6d5f 7472 6163 6b65   iter = m_tracke
    │ │ │ -0004cfe0: 7273 2e65 6e64 2829 3b0a 0977 6869 6c65  rs.end();..while
    │ │ │ -0004cff0: 2028 6974 6572 2021 3d20 6d5f 7472 6163   (iter != m_trac
    │ │ │ -0004d000: 6b65 7273 2e62 6567 696e 2829 2026 616d  kers.begin() &am
    │ │ │ -0004d010: 703b 2661 6d70 3b20 7374 643a 3a70 7265  p;& std::pre
    │ │ │ -0004d020: 7628 6974 6572 292d 2667 743b 7469 6572  v(iter)->tier
    │ │ │ -0004d030: 2026 6774 3b20 6e65 775f 6165 2d26 6774   > new_ae->
    │ │ │ -0004d040: 3b74 6965 7229 0a09 092d 2d69 7465 723b  ;tier)...--iter;
    │ │ │ -0004d050: 0a0a 096d 5f74 7261 636b 6572 732e 696e  ...m_trackers.in
    │ │ │ -0004d060: 7365 7274 2869 7465 722c 202a 6e65 775f  sert(iter, *new_
    │ │ │ -0004d070: 6165 293b 0a3c 6469 7620 7374 796c 653d  ae);.
    .m_url_index. │ │ │ -0004d0b0: 696e 7365 7274 2873 7464 3a3a 6d61 6b65 insert(std::make │ │ │ -0004d0c0: 5f70 6169 7228 7374 7269 6e67 5f76 6965 _pair(string_vie │ │ │ -0004d0d0: 7728 6e65 775f 6165 2d26 6774 3b75 726c w(new_ae->url │ │ │ -0004d0e0: 292c 206e 6577 5f61 6529 293b 0a3c 2f64 ), new_ae));...if (new_ae- │ │ │ -0004d100: 2667 743b 736f 7572 6365 203d 3d20 3029 >source == 0) │ │ │ -0004d110: 206e 6577 5f61 652d 2667 743b 736f 7572 new_ae->sour │ │ │ -0004d120: 6365 203d 206c 743a 3a61 6e6e 6f75 6e63 ce = lt::announc │ │ │ -0004d130: 655f 656e 7472 793a 3a73 6f75 7263 655f e_entry::source_ │ │ │ -0004d140: 636c 6965 6e74 3b0a 0972 6574 7572 6e20 client;..return │ │ │ -0004d150: 7472 7565 3b0a 7d0a 0a76 6f69 6420 7472 true;.}..void tr │ │ │ -0004d160: 6163 6b65 725f 6c69 7374 3a3a 7072 696f acker_list::prio │ │ │ -0004d170: 7269 7469 7a65 5f75 6470 5f74 7261 636b ritize_udp_track │ │ │ -0004d180: 6572 7328 290a 7b0a 0949 4e56 4152 4941 ers().{..INVARIA │ │ │ -0004d190: 4e54 5f43 4845 434b 3b0a 0a09 2f2f 206c NT_CHECK;...// l │ │ │ -0004d1a0: 6f6f 6b20 666f 7220 7564 702d 7472 6163 ook for udp-trac │ │ │ -0004d1b0: 6b65 7273 0a09 666f 7220 2861 7574 6f20 kers..for (auto │ │ │ -0004d1c0: 6920 3d20 6d5f 7472 6163 6b65 7273 2e62 i = m_trackers.b │ │ │ -0004d1d0: 6567 696e 2829 2c20 656e 6428 6d5f 7472 egin(), end(m_tr │ │ │ -0004d1e0: 6163 6b65 7273 2e65 6e64 2829 293b 2069 ackers.end()); i │ │ │ -0004d1f0: 2021 3d20 656e 643b 202b 2b69 290a 097b != end; ++i)..{ │ │ │ -0004d200: 0a09 0969 6620 2869 2d26 6774 3b75 726c ...if (i->url │ │ │ -0004d210: 2e73 7562 7374 7228 302c 2036 2920 213d .substr(0, 6) != │ │ │ -0004d220: 2022 7564 703a 2f2f 2229 2063 6f6e 7469 "udp://") conti │ │ │ -0004d230: 6e75 653b 0a09 092f 2f20 6e6f 772c 206c nue;...// now, l │ │ │ -0004d240: 6f6f 6b20 666f 7220 7472 6163 6b65 7273 ook for trackers │ │ │ -0004d250: 2077 6974 6820 7468 6520 7361 6d65 2068 with the same h │ │ │ -0004d260: 6f73 746e 616d 650a 0909 2f2f 2074 6861 ostname...// tha │ │ │ -0004d270: 7420 6973 2068 6173 2068 6967 6865 7220 t is has higher │ │ │ -0004d280: 7072 696f 7269 7479 2074 6861 6e20 7468 priority than th │ │ │ -0004d290: 6973 206f 6e65 0a09 092f 2f20 6966 2077 is one...// if w │ │ │ -0004d2a0: 6520 6669 6e64 206f 6e65 2c20 7377 6170 e find one, swap │ │ │ -0004d2b0: 2077 6974 6820 7468 6520 7564 702d 7472 with the udp-tr │ │ │ -0004d2c0: 6163 6b65 720a 0909 6572 726f 725f 636f acker...error_co │ │ │ -0004d2d0: 6465 2065 633b 0a09 0973 7464 3a3a 7374 de ec;...std::st │ │ │ -0004d2e0: 7269 6e67 2075 6470 5f68 6f73 746e 616d ring udp_hostnam │ │ │ -0004d2f0: 653b 0a09 0975 7369 6e67 2073 7464 3a3a e;...using std:: │ │ │ -0004d300: 6967 6e6f 7265 3b0a 0909 7374 643a 3a74 ignore;...std::t │ │ │ -0004d310: 6965 2869 676e 6f72 652c 2069 676e 6f72 ie(ignore, ignor │ │ │ -0004d320: 652c 2075 6470 5f68 6f73 746e 616d 652c e, udp_hostname, │ │ │ -0004d330: 2069 676e 6f72 652c 2069 676e 6f72 6529 ignore, ignore) │ │ │ -0004d340: 0a09 0909 3d20 7061 7273 655f 7572 6c5f ....= parse_url_ │ │ │ -0004d350: 636f 6d70 6f6e 656e 7473 2869 2d26 6774 components(i-> │ │ │ -0004d360: 3b75 726c 2c20 6563 293b 0a09 0966 6f72 ;url, ec);...for │ │ │ -0004d370: 2028 6175 746f 206a 203d 206d 5f74 7261 (auto j = m_tra │ │ │ -0004d380: 636b 6572 732e 6265 6769 6e28 293b 206a ckers.begin(); j │ │ │ -0004d390: 2021 3d20 693b 202b 2b6a 290a 0909 7b0a != i; ++j)...{. │ │ │ -0004d3a0: 0909 0969 6620 286a 2d26 6774 3b75 726c ...if (j->url │ │ │ -0004d3b0: 2e73 7562 7374 7228 302c 2036 2920 3d3d .substr(0, 6) == │ │ │ -0004d3c0: 2022 7564 703a 2f2f 2229 2063 6f6e 7469 "udp://") conti │ │ │ -0004d3d0: 6e75 653b 0a09 0909 7374 643a 3a73 7472 nue;....std::str │ │ │ -0004d3e0: 696e 6720 686f 7374 6e61 6d65 3b0a 0909 ing hostname;... │ │ │ -0004d3f0: 0973 7464 3a3a 7469 6528 6967 6e6f 7265 .std::tie(ignore │ │ │ -0004d400: 2c20 6967 6e6f 7265 2c20 686f 7374 6e61 , ignore, hostna │ │ │ -0004d410: 6d65 2c20 6967 6e6f 7265 2c20 6967 6e6f me, ignore, igno │ │ │ -0004d420: 7265 290a 0909 0909 3d20 7061 7273 655f re).....= parse_ │ │ │ -0004d430: 7572 6c5f 636f 6d70 6f6e 656e 7473 286a url_components(j │ │ │ -0004d440: 2d26 6774 3b75 726c 2c20 6563 293b 0a09 ->url, ec);.. │ │ │ -0004d450: 0909 6966 2028 686f 7374 6e61 6d65 2021 ..if (hostname ! │ │ │ -0004d460: 3d20 7564 705f 686f 7374 6e61 6d65 2920 = udp_hostname) │ │ │ -0004d470: 636f 6e74 696e 7565 3b0a 0909 0961 7574 continue;....aut │ │ │ -0004d480: 6f2a 2061 6531 203d 2026 616d 703b 2a69 o* ae1 = &*i │ │ │ -0004d490: 3b0a 0909 0961 7574 6f2a 2061 6532 203d ;....auto* ae2 = │ │ │ -0004d4a0: 2026 616d 703b 2a6a 3b0a 3c2f 7072 653e &*j;.
    │ │ │ -0004d4b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0004d4e0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0004d4f0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/file │ │ │ -0004d520: 2e63 7070 3a31 3833 3c2f 613e 3c2f 7464 .cpp:183if we have │ │ │ -0004d540: 6d6f 7265 2074 6861 6e20 3120 6275 6666 more than 1 buff │ │ │ -0004d550: 6572 2c20 636f 616c 6573 6365 2069 6e74 er, coalesce int │ │ │ -0004d560: 6f20 6120 7369 6e67 6c65 2062 7566 6665 o a single buffe │ │ │ -0004d570: 7220 616e 6420 6120 7369 6e67 6c65 2063 r and a single c │ │ │ -0004d580: 616c 6c3c 2f74 643e 3c2f 7472 3e3c 7472 all

    if we have more │ │ │ -0004d5e0: 2074 6861 6e20 3120 6275 6666 6572 2c20 than 1 buffer, │ │ │ -0004d5f0: 636f 616c 6573 6365 2069 6e74 6f20 6120 coalesce into a │ │ │ -0004d600: 7369 6e67 6c65 2062 7566 6665 720a 616e single buffer.an │ │ │ -0004d610: 6420 6120 7369 6e67 6c65 2063 616c 6c3c d a single call< │ │ │ -0004d620: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f66 /h2>

    ../src/f │ │ │ -0004d630: 696c 652e 6370 703a 3138 333c 2f68 343e ile.cpp:183

    │ │ │ -0004d640: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ....ec
    │ │ │ -0004d680: 203d 2065 7272 6f72 5f63 6f64 6528 6572   = error_code(er
    │ │ │ -0004d690: 726e 6f2c 2073 7973 7465 6d5f 6361 7465  rno, system_cate
    │ │ │ -0004d6a0: 676f 7279 2829 293b 0a09 0909 0972 6574  gory());.....ret
    │ │ │ -0004d6b0: 7572 6e20 2d31 3b0a 0909 097d 0a09 0909  urn -1;....}....
    │ │ │ -0004d6c0: 7265 7420 2b3d 2072 3b0a 0909 0966 696c  ret += r;....fil
    │ │ │ -0004d6d0: 655f 6f66 6673 6574 202b 3d20 723b 0a09  e_offset += r;..
    │ │ │ -0004d6e0: 0909 7665 6320 3d20 6164 7661 6e63 655f  ..vec = advance_
    │ │ │ -0004d6f0: 696f 7665 6328 7665 632c 2072 293b 0a09  iovec(vec, r);..
    │ │ │ -0004d700: 097d 2077 6869 6c65 2028 7665 632e 7369  .} while (vec.si
    │ │ │ -0004d710: 7a65 2829 2026 6774 3b20 3029 3b0a 0909  ze() > 0);...
    │ │ │ -0004d720: 7265 7475 726e 2072 6574 3b0a 097d 0a23  return ret;..}.#
    │ │ │ -0004d730: 656c 7365 0a09 696e 7420 7077 7269 7465  else..int pwrite
    │ │ │ -0004d740: 765f 616c 6c28 6861 6e64 6c65 5f74 7970  v_all(handle_typ
    │ │ │ -0004d750: 6520 636f 6e73 7420 6861 6e64 6c65 0a09  e const handle..
    │ │ │ -0004d760: 092c 2073 7061 6e26 6c74 3b73 7061 6e26  ., span<span&
    │ │ │ -0004d770: 6c74 3b63 6861 7220 636f 6e73 7426 6774  lt;char const>
    │ │ │ -0004d780: 3b20 636f 6e73 7426 6774 3b20 6275 6673  ; const> bufs
    │ │ │ -0004d790: 0a09 092c 2073 7464 3a3a 696e 7436 345f  ..., std::int64_
    │ │ │ -0004d7a0: 7420 6669 6c65 5f6f 6666 7365 740a 0909  t file_offset...
    │ │ │ -0004d7b0: 2c20 6572 726f 725f 636f 6465 2661 6d70  , error_code&
    │ │ │ -0004d7c0: 3b20 6563 290a 097b 0a09 0954 4f52 5245  ; ec)..{...TORRE
    │ │ │ -0004d7d0: 4e54 5f41 5353 4552 5428 6275 6673 2e73  NT_ASSERT(bufs.s
    │ │ │ -0004d7e0: 697a 6528 2920 2667 743b 2030 293b 0a09  ize() > 0);..
    │ │ │ -0004d7f0: 0969 6620 2862 7566 732e 7369 7a65 2829  .if (bufs.size()
    │ │ │ -0004d800: 203d 3d20 3129 0a09 0909 7265 7475 726e   == 1)....return
    │ │ │ -0004d810: 2070 7772 6974 655f 616c 6c28 6861 6e64   pwrite_all(hand
    │ │ │ -0004d820: 6c65 2c20 6275 6673 5b30 5d2c 2066 696c  le, bufs[0], fil
    │ │ │ -0004d830: 655f 6f66 6673 6574 2c20 6563 293b 0a0a  e_offset, ec);..
    │ │ │ -0004d840: 0909 696e 7420 7265 7420 3d20 303b 0a3c  ..int ret = 0;.<
    │ │ │ -0004d850: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0004d860: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0004d870: 7769 6474 683d 2231 3030 2522 3e09 0966  width="100%">..f
    │ │ │ -0004d880: 6f72 2028 6175 746f 2063 6f6e 7374 2661  or (auto const&a
    │ │ │ -0004d890: 6d70 3b20 6220 3a20 6275 6673 290a 3c2f  mp; b : bufs)...{....int r
    │ │ │ -0004d8b0: 203d 2070 7772 6974 655f 616c 6c28 6861   = pwrite_all(ha
    │ │ │ -0004d8c0: 6e64 6c65 2c20 622c 2066 696c 655f 6f66  ndle, b, file_of
    │ │ │ -0004d8d0: 6673 6574 2c20 6563 293b 0a09 0909 6966  fset, ec);....if
    │ │ │ -0004d8e0: 2028 6563 2920 7265 7475 726e 202d 313b   (ec) return -1;
    │ │ │ -0004d8f0: 0a09 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -0004d900: 5254 2872 2026 6774 3b20 3029 3b0a 0909  RT(r > 0);...
    │ │ │ -0004d910: 0966 696c 655f 6f66 6673 6574 202b 3d20  .file_offset += 
    │ │ │ -0004d920: 723b 0a09 0909 7265 7420 2b3d 2072 3b0a  r;....ret += r;.
    │ │ │ -0004d930: 0909 7d0a 0909 7265 7475 726e 2072 6574  ..}...return ret
    │ │ │ -0004d940: 3b0a 097d 0a23 656e 6469 660a 0a23 6966  ;..}.#endif..#if
    │ │ │ -0004d950: 6465 6620 544f 5252 454e 545f 5749 4e44  def TORRENT_WIND
    │ │ │ -0004d960: 4f57 530a 0969 6e74 2070 7265 6164 5f61  OWS..int pread_a
    │ │ │ -0004d970: 6c6c 2868 616e 646c 655f 7479 7065 2063  ll(handle_type c
    │ │ │ -0004d980: 6f6e 7374 2066 640a 0909 2c20 7370 616e  onst fd..., span
    │ │ │ -0004d990: 266c 743b 6368 6172 2667 743b 2063 6f6e  <char> con
    │ │ │ -0004d9a0: 7374 2062 7566 0a09 092c 2073 7464 3a3a  st buf..., std::
    │ │ │ -0004d9b0: 696e 7436 345f 7420 636f 6e73 7420 6f66  int64_t const of
    │ │ │ -0004d9c0: 6673 6574 0a09 092c 2065 7272 6f72 5f63  fset..., error_c
    │ │ │ -0004d9d0: 6f64 6526 616d 703b 2065 6329 0a09 7b0a  ode& ec)..{.
    │ │ │ -0004d9e0: 0909 4f56 4552 4c41 5050 4544 206f 6c7b  ..OVERLAPPED ol{
    │ │ │ -0004d9f0: 7d3b 0a09 096f 6c2e 4f66 6673 6574 203d  };...ol.Offset =
    │ │ │ -0004da00: 206f 6666 7365 7420 2661 6d70 3b20 3078   offset & 0x
    │ │ │ -0004da10: 6666 6666 6666 6666 3b0a 0909 6f6c 2e4f  ffffffff;...ol.O
    │ │ │ -0004da20: 6666 7365 7448 6967 6820 3d20 6f66 6673  ffsetHigh = offs
    │ │ │ -0004da30: 6574 2026 6774 3b26 6774 3b20 3332 3b0a  et >> 32;.
    │ │ │ -0004da40: 0909 4457 4f52 4420 636f 6e73 7420 6279  ..DWORD const by
    │ │ │ -0004da50: 7465 735f 746f 5f72 6561 6420 3d20 4457  tes_to_read = DW
    │ │ │ -0004da60: 4f52 4428 6275 662e 7369 7a65 2829 293b  ORD(buf.size());
    │ │ │ -0004da70: 0a09 0944 574f 5244 2062 7974 6573 5f72  ...DWORD bytes_r
    │ │ │ -0004da80: 6561 6420 3d20 303b 0a09 0969 6620 2852  ead = 0;...if (R
    │ │ │ -0004da90: 6561 6446 696c 6528 6664 2c20 6275 662e  eadFile(fd, buf.
    │ │ │ -0004daa0: 6461 7461 2829 2c20 6279 7465 735f 746f  data(), bytes_to
    │ │ │ -0004dab0: 5f72 6561 642c 2026 616d 703b 6279 7465  _read, &byte
    │ │ │ -0004dac0: 735f 7265 6164 2c20 2661 6d70 3b6f 6c29  s_read, &ol)
    │ │ │ -0004dad0: 203d 3d20 4641 4c53 4529 0a09 097b 0a09   == FALSE)...{..
    │ │ │ -0004dae0: 0909 6563 203d 2065 7272 6f72 5f63 6f64  ..ec = error_cod
    │ │ │ -0004daf0: 6528 3a3a 4765 744c 6173 7445 7272 6f72  e(::GetLastError
    │ │ │ -0004db00: 2829 2c20 7379 7374 656d 5f63 6174 6567  (), system_categ
    │ │ │ -0004db10: 6f72 7928 2929 3b0a 0909 0972 6574 7572  ory());....retur
    │ │ │ -0004db20: 6e20 2d31 3b0a 0909 7d0a 0a09 0969 6620  n -1;...}....if 
    │ │ │ -0004db30: 2862 7974 6573 5f72 6561 6420 213d 2062  (bytes_read != b
    │ │ │ -0004db40: 7974 6573 5f74 6f5f 7265 6164 290a 0909  ytes_to_read)...
    │ │ │ -0004db50: 7b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  {.
    < │ │ │ -0004db80: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0004db90: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0004dbc0: 7372 632f 7265 736f 6c76 655f 6475 706c src/resolve_dupl │ │ │ -0004dbd0: 6963 6174 655f 6669 6c65 6e61 6d65 732e icate_filenames. │ │ │ -0004dbe0: 6370 703a 3135 383c 2f61 3e3c 2f74 643e cpp:158 │ │ │ -0004dbf0: 3c74 643e 7468 6973 2063 616e 2062 6520 this can be │ │ │ -0004dc00: 6d6f 7265 2065 6666 6963 6965 6e74 2066 more efficient f │ │ │ -0004dc10: 6f72 2076 3220 746f 7272 656e 7473 3c2f or v2 torrents

    this │ │ │ -0004dc70: 2063 616e 2062 6520 6d6f 7265 2065 6666 can be more eff │ │ │ -0004dc80: 6963 6965 6e74 2066 6f72 2076 3220 746f icient for v2 to │ │ │ -0004dc90: 7272 656e 7473 3c2f 6832 3e3c 6834 3e2e rrents

    . │ │ │ -0004dca0: 2e2f 7372 632f 7265 736f 6c76 655f 6475 ./src/resolve_du │ │ │ -0004dcb0: 706c 6963 6174 655f 6669 6c65 6e61 6d65 plicate_filename │ │ │ -0004dcc0: 732e 6370 703a 3135 383c 2f68 343e 3c70 s.cpp:158

    ....}... │ │ │ -0004dd10: 0909 2b2b 6e75 6d5f 636f 6c6c 6973 696f ..++num_collisio │ │ │ -0004dd20: 6e73 3b0a 0909 0909 6966 2028 6e75 6d5f ns;.....if (num_ │ │ │ -0004dd30: 636f 6c6c 6973 696f 6e73 2026 6774 3b20 collisions > │ │ │ -0004dd40: 6d61 785f 6475 706c 6963 6174 655f 6669 max_duplicate_fi │ │ │ -0004dd50: 6c65 6e61 6d65 7329 0a09 0909 097b 0a09 lenames).....{.. │ │ │ -0004dd60: 0909 0909 6563 203d 2065 7272 6f72 733a ....ec = errors: │ │ │ -0004dd70: 3a74 6f6f 5f6d 616e 795f 6475 706c 6963 :too_many_duplic │ │ │ -0004dd80: 6174 655f 6669 6c65 6e61 6d65 733b 0a09 ate_filenames;.. │ │ │ -0004dd90: 0909 0909 7265 7475 726e 207b 7d3b 0a09 ....return {};.. │ │ │ -0004dda0: 0909 097d 0a09 0909 7d0a 0909 0972 6574 ...}....}....ret │ │ │ -0004ddb0: 2e69 6e73 6572 7428 7b69 2c20 6669 6c65 .insert({i, file │ │ │ -0004ddc0: 6e61 6d65 7d29 3b0a 0909 7d0a 0909 7265 name});...}...re │ │ │ -0004ddd0: 7475 726e 2072 6574 3b0a 097d 0a0a 7d0a turn ret;..}..}. │ │ │ -0004dde0: 0a09 7374 643a 3a6d 6170 266c 743b 6669 ..std::map<fi │ │ │ -0004ddf0: 6c65 5f69 6e64 6578 5f74 2c20 7374 643a le_index_t, std: │ │ │ -0004de00: 3a73 7472 696e 6726 6774 3b20 7265 736f :string> reso │ │ │ -0004de10: 6c76 655f 6475 706c 6963 6174 655f 6669 lve_duplicate_fi │ │ │ -0004de20: 6c65 6e61 6d65 7328 0a09 0966 696c 655f lenames(...file_ │ │ │ -0004de30: 7374 6f72 6167 6520 636f 6e73 7426 616d storage const&am │ │ │ -0004de40: 703b 2066 730a 0909 2c20 696e 7420 636f p; fs..., int co │ │ │ -0004de50: 6e73 7420 6d61 785f 6475 706c 6963 6174 nst max_duplicat │ │ │ -0004de60: 655f 6669 6c65 6e61 6d65 730a 0909 2c20 e_filenames..., │ │ │ -0004de70: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ -0004de80: 6563 290a 097b 0a3c 6469 7620 7374 796c ec)..{.

    ..std::unor │ │ │ -0004dec0: 6465 7265 645f 7365 7426 6c74 3b73 7464 dered_set<std │ │ │ -0004ded0: 3a3a 7569 6e74 3332 5f74 2667 743b 2066 ::uint32_t> f │ │ │ -0004dee0: 696c 6573 3b0a 3c2f 6469 763e 0a09 0973 iles;.
    ...s │ │ │ -0004def0: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374 td::string const │ │ │ -0004df00: 2065 6d70 7479 5f73 7472 3b0a 0a09 092f empty_str;..../ │ │ │ -0004df10: 2f20 696e 7365 7274 2061 6c6c 2064 6972 / insert all dir │ │ │ -0004df20: 6563 746f 7269 6573 2066 6972 7374 2c20 ectories first, │ │ │ -0004df30: 746f 206d 616b 6520 7375 7265 206e 6f20 to make sure no │ │ │ -0004df40: 6669 6c65 730a 0909 2f2f 2061 7265 2061 files...// are a │ │ │ -0004df50: 6c6c 6f77 6564 2074 6f20 636f 6c6c 6965 llowed to collie │ │ │ -0004df60: 6420 7769 7468 2074 6865 6d0a 0909 6673 d with them...fs │ │ │ -0004df70: 2e61 6c6c 5f70 6174 685f 6861 7368 6573 .all_path_hashes │ │ │ -0004df80: 2866 696c 6573 293b 0a09 0966 6f72 2028 (files);...for ( │ │ │ -0004df90: 6175 746f 2063 6f6e 7374 2069 203a 2066 auto const i : f │ │ │ -0004dfa0: 732e 6669 6c65 5f72 616e 6765 2829 290a s.file_range()). │ │ │ -0004dfb0: 0909 7b0a 0909 092f 2f20 6173 206c 6f6e ..{....// as lon │ │ │ -0004dfc0: 6720 6173 2074 6869 7320 6669 6c65 2061 g as this file a │ │ │ -0004dfd0: 6c72 6561 6479 2065 7869 7374 730a 0909 lready exists... │ │ │ -0004dfe0: 092f 2f20 696e 6372 6561 7365 2074 6865 .// increase the │ │ │ -0004dff0: 2063 6f75 6e74 6572 0a09 0909 7374 643a counter....std: │ │ │ -0004e000: 3a75 696e 7433 325f 7420 636f 6e73 7420 :uint32_t const │ │ │ -0004e010: 6820 3d20 6673 2e66 696c 655f 7061 7468 h = fs.file_path │ │ │ -0004e020: 5f68 6173 6828 692c 2065 6d70 7479 5f73 _hash(i, empty_s │ │ │ -0004e030: 7472 293b 0a09 0909 6966 2028 2166 696c tr);....if (!fil │ │ │ -0004e040: 6573 2e69 6e73 6572 7428 6829 2e73 6563 es.insert(h).sec │ │ │ -0004e050: 6f6e 6429 0a09 0909 7b0a 0909 0909 2f2f ond)....{.....// │ │ │ -0004e060: 2054 6869 7320 6669 6c65 6e61 6d65 2061 This filename a │ │ │ -0004e070: 7070 6561 7273 2074 6f20 616c 7265 6164 ppears to alread │ │ │ -0004e080: 7920 6578 6973 7421 0a09 0909 092f 2f20 y exist!.....// │ │ │ -0004e090: 4966 2074 6869 7320 6861 7070 656e 732c If this happens, │ │ │ -0004e0a0: 206a 7573 7420 7374 6172 7420 6f76 6572 just start over │ │ │ -0004e0b0: 2061 6e64 2064 6f20 6974 2074 6865 2073 and do it the s │ │ │ -0004e0c0: 6c6f 7720 7761 792c 0a09 0909 092f 2f20 low way,.....// │ │ │ -0004e0d0: 636f 6d70 6172 696e 6720 6675 6c6c 2066 comparing full f │ │ │ -0004e0e0: 696c 6520 6e61 6d65 7320 616e 6420 636f ile names and co │ │ │ -0004e0f0: 6d65 2075 7020 7769 7468 206e 6577 206e me up with new n │ │ │ -0004e100: 616d 6573 0a09 0909 0972 6574 7572 6e20 ames.....return │ │ │ -0004e110: 7265 736f 6c76 655f 6475 706c 6963 6174 resolve_duplicat │ │ │ -0004e120: 655f 6669 6c65 6e61 6d65 735f 736c 6f77 e_filenames_slow │ │ │ -0004e130: 2866 732c 206d 6178 5f64 7570 6c69 6361 (fs, max_duplica │ │ │ -0004e140: 7465 5f66 696c 656e 616d 6573 2c20 6563 te_filenames, ec │ │ │ -0004e150: 293b 0a09 0909 7d0a 0909 7d0a 0909 7265 );....}...}...re │ │ │ -0004e160: 7475 726e 207b 7d3b 0a09 7d0a 0a7d 0a3c turn {};..}..}.< │ │ │ -0004e170: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0004e180: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0004e190: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0004e1a0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0004e1b0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0004e1e0: 2f70 6965 6365 5f70 6963 6b65 722e 6370 /piece_picker.cp │ │ │ -0004e1f0: 703a 3130 303c 2f61 3e3c 2f74 643e 3c74 p:100find a better │ │ │ -0004e210: 706c 6163 6520 666f 7220 7468 6973 3c2f place for this

    find │ │ │ -0004e270: 2061 2062 6574 7465 7220 706c 6163 6520 a better place │ │ │ -0004e280: 666f 7220 7468 6973 3c2f 6832 3e3c 6834 for this

    ../src/piece_pi │ │ │ -0004e2a0: 636b 6572 2e63 7070 3a31 3030 3c2f 6834 cker.cpp:100

    ...{.
    │ │ │ -0004e2f0: 0909 0909 7374 643a 3a63 6572 7220 266c  ....std::cerr &l
    │ │ │ -0004e300: 743b 266c 743b 2022 202e 2e2e 223b 0a09  t;< " ...";..
    │ │ │ -0004e310: 0909 0962 7265 616b 3b0a 0909 097d 0a09  ...break;....}..
    │ │ │ -0004e320: 0909 6966 2028 2a69 203d 3d20 2d31 2920  ..if (*i == -1) 
    │ │ │ -0004e330: 6272 6561 6b3b 0a09 0909 7768 696c 6520  break;....while 
    │ │ │ -0004e340: 286a 2021 3d20 702e 6d5f 7072 696f 7269  (j != p.m_priori
    │ │ │ -0004e350: 7479 5f62 6f75 6e64 6172 6965 732e 656e  ty_boundaries.en
    │ │ │ -0004e360: 6428 2920 2661 6d70 3b26 616d 703b 202a  d() && *
    │ │ │ -0004e370: 6a20 266c 743b 3d20 696e 6465 7829 0a09  j <= index)..
    │ │ │ -0004e380: 0909 7b0a 0909 0909 7374 643a 3a63 6572  ..{.....std::cer
    │ │ │ -0004e390: 7220 266c 743b 266c 743b 2022 7c20 223b  r << "| ";
    │ │ │ -0004e3a0: 0a09 0909 092b 2b6a 3b0a 0909 097d 0a09  .....++j;....}..
    │ │ │ -0004e3b0: 0909 7374 643a 3a63 6572 7220 266c 743b  ..std::cerr <
    │ │ │ -0004e3c0: 266c 743b 202a 6920 266c 743b 266c 743b  < *i <<
    │ │ │ -0004e3d0: 2022 2822 2026 6c74 3b26 6c74 3b20 702e   "(" << p.
    │ │ │ -0004e3e0: 6d5f 7069 6563 655f 6d61 705b 2a69 5d2e  m_piece_map[*i].
    │ │ │ -0004e3f0: 696e 6465 7820 266c 743b 266c 743b 2022  index << "
    │ │ │ -0004e400: 2920 223b 0a09 0909 2d2d 6c69 6d69 743b  ) ";....--limit;
    │ │ │ -0004e410: 0a09 097d 0a09 0973 7464 3a3a 6365 7272  ...}...std::cerr
    │ │ │ -0004e420: 2026 6c74 3b26 6c74 3b20 7374 643a 3a65   << std::e
    │ │ │ -0004e430: 6e64 6c3b 0a09 7d0a 7d0a 2365 6e64 6966  ndl;..}.}.#endif
    │ │ │ -0004e440: 202f 2f20 544f 5252 454e 545f 5049 434b   // TORRENT_PICK
    │ │ │ -0004e450: 4552 5f4c 4f47 0a0a 6e61 6d65 7370 6163  ER_LOG..namespac
    │ │ │ -0004e460: 6520 6c69 6274 6f72 7265 6e74 207b 0a0a  e libtorrent {..
    │ │ │ -0004e470: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .c │ │ │ -0004e4a0: 6f6e 7374 2070 6965 6365 5f62 6c6f 636b onst piece_block │ │ │ -0004e4b0: 2070 6965 6365 5f62 6c6f 636b 3a3a 696e piece_block::in │ │ │ -0004e4c0: 7661 6c69 6428 0a3c 2f64 6976 3e09 0973 valid(.
    ..s │ │ │ -0004e4d0: 7464 3a3a 6e75 6d65 7269 635f 6c69 6d69 td::numeric_limi │ │ │ -0004e4e0: 7473 266c 743b 7069 6563 655f 696e 6465 ts<piece_inde │ │ │ -0004e4f0: 785f 7426 6774 3b3a 3a6d 6178 2829 0a09 x_t>::max().. │ │ │ -0004e500: 092c 2073 7464 3a3a 6e75 6d65 7269 635f ., std::numeric_ │ │ │ -0004e510: 6c69 6d69 7473 266c 743b 696e 7426 6774 limits<int> │ │ │ -0004e520: 3b3a 3a6d 6178 2829 293b 0a7d 0a0a 6e61 ;::max());.}..na │ │ │ -0004e530: 6d65 7370 6163 6520 6c69 6274 6f72 7265 mespace libtorre │ │ │ -0004e540: 6e74 3a3a 6175 7820 7b0a 0a09 2f2f 2074 nt::aux {...// t │ │ │ -0004e550: 6865 206d 6178 206e 756d 6265 7220 6f66 he max number of │ │ │ -0004e560: 2062 6c6f 636b 7320 746f 2063 7265 6174 blocks to creat │ │ │ -0004e570: 6520 616e 2061 6666 696e 6974 7920 666f e an affinity fo │ │ │ -0004e580: 720a 0963 6f6e 7374 6578 7072 2069 6e74 r..constexpr int │ │ │ -0004e590: 206d 6178 5f70 6965 6365 5f61 6666 696e max_piece_affin │ │ │ -0004e5a0: 6974 795f 6578 7465 6e74 203d 2034 202a ity_extent = 4 * │ │ │ -0004e5b0: 2031 3032 3420 2a20 3130 3234 202f 2064 1024 * 1024 / d │ │ │ -0004e5c0: 6566 6175 6c74 5f62 6c6f 636b 5f73 697a efault_block_siz │ │ │ -0004e5d0: 653b 0a0a 0970 6965 6365 5f70 6963 6b65 e;...piece_picke │ │ │ -0004e5e0: 723a 3a70 6965 6365 5f70 6963 6b65 7228 r::piece_picker( │ │ │ -0004e5f0: 7374 643a 3a69 6e74 3634 5f74 2063 6f6e std::int64_t con │ │ │ -0004e600: 7374 2074 6f74 616c 5f73 697a 652c 2069 st total_size, i │ │ │ -0004e610: 6e74 2063 6f6e 7374 2070 6965 6365 5f73 nt const piece_s │ │ │ -0004e620: 697a 6529 0a09 093a 206d 5f70 7269 6f72 ize)...: m_prior │ │ │ -0004e630: 6974 795f 626f 756e 6461 7269 6573 2831 ity_boundaries(1 │ │ │ -0004e640: 2c20 6d5f 7069 6563 6573 2e65 6e64 5f69 , m_pieces.end_i │ │ │ -0004e650: 6e64 6578 2829 290a 097b 0a09 0954 4f52 ndex())..{...TOR │ │ │ -0004e660: 5245 4e54 5f41 5353 4552 5428 746f 7461 RENT_ASSERT(tota │ │ │ -0004e670: 6c5f 7369 7a65 2026 6774 3b20 3029 3b0a l_size > 0);. │ │ │ -0004e680: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0004e690: 2870 6965 6365 5f73 697a 6520 2667 743b (piece_size > │ │ │ -0004e6a0: 2030 293b 0a23 6966 6465 6620 544f 5252 0);.#ifdef TORR │ │ │ -0004e6b0: 454e 545f 5049 434b 4552 5f4c 4f47 0a09 ENT_PICKER_LOG.. │ │ │ -0004e6c0: 0973 7464 3a3a 6365 7272 2026 6c74 3b26 .std::cerr <& │ │ │ -0004e6d0: 6c74 3b20 225b 2220 266c 743b 266c 743b lt; "[" << │ │ │ -0004e6e0: 2074 6869 7320 266c 743b 266c 743b 2022 this << " │ │ │ -0004e6f0: 5d20 2220 266c 743b 266c 743b 2022 6e65 ] " << "ne │ │ │ -0004e700: 7720 7069 6563 655f 7069 636b 6572 2220 w piece_picker" │ │ │ -0004e710: 266c 743b 266c 743b 2073 7464 3a3a 656e << std::en │ │ │ -0004e720: 646c 3b0a 2365 6e64 6966 0a23 6966 2054 dl;.#endif.#if T │ │ │ -0004e730: 4f52 5245 4e54 5f55 5345 5f49 4e56 4152 ORRENT_USE_INVAR │ │ │ -0004e740: 4941 4e54 5f43 4845 434b 530a 0909 6368 IANT_CHECKS...ch │ │ │ -0004e750: 6563 6b5f 696e 7661 7269 616e 7428 293b eck_invariant(); │ │ │ -0004e760: 0a23 656e 6469 660a 0a09 0972 6573 697a .#endif....resiz │ │ │ -0004e770: 6528 746f 7461 6c5f 7369 7a65 2c20 7069 e(total_size, pi │ │ │ -0004e780: 6563 655f 7369 7a65 293b 0a09 7d0a 0a09 ece_size);..}... │ │ │ -0004e790: 766f 6964 2070 6965 6365 5f70 6963 6b65 void piece_picke │ │ │ -0004e7a0: 723a 3a72 6573 697a 6528 7374 643a 3a69 r::resize(std::i │ │ │ -0004e7b0: 6e74 3634 5f74 2063 6f6e 7374 2074 6f74 nt64_t const tot │ │ │ -0004e7c0: 616c 5f73 697a 652c 2069 6e74 2063 6f6e al_size, int con │ │ │ -0004e7d0: 7374 2070 6965 6365 5f73 697a 6529 0a09 st piece_size).. │ │ │ -0004e7e0: 7b0a 0909 544f 5252 454e 545f 4153 5345 {...TORRENT_ASSE │ │ │ -0004e7f0: 5254 2874 6f74 616c 5f73 697a 6520 2667 RT(total_size &g │ │ │ -0004e800: 743b 2030 293b 0a09 0954 4f52 5245 4e54 t; 0);...TORRENT │ │ │ -0004e810: 5f41 5353 4552 5428 7069 6563 655f 7369 _ASSERT(piece_si │ │ │ -0004e820: 7a65 2026 6774 3b20 3029 3b0a 0a09 096d ze > 0);....m │ │ │ -0004e830: 5f74 6f74 616c 5f73 697a 6520 3d20 746f _total_size = to │ │ │ -0004e840: 7461 6c5f 7369 7a65 3b0a 3c2f 7072 653e tal_size;.
    │ │ │ -0004e850: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0004e880: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0004e890: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/piec │ │ │ -0004e8c0: 655f 7069 636b 6572 2e63 7070 3a32 3035 e_picker.cpp:205 │ │ │ -0004e8d0: 333c 2f61 3e3c 2f74 643e 3c74 643e 7468 3th │ │ │ -0004e8e0: 6973 2063 6f75 6c64 2070 726f 6261 626c is could probabl │ │ │ -0004e8f0: 7920 6265 206f 7074 696d 697a 6564 2062 y be optimized b │ │ │ -0004e900: 7920 696e 6372 656d 656e 7461 6c6c 7920 y incrementally │ │ │ -0004e910: 6361 6c6c 696e 6720 7061 7274 6961 6c5f calling partial_ │ │ │ -0004e920: 736f 7274 2074 6f20 736f 7274 206f 6e65 sort to sort one │ │ │ -0004e930: 206d 6f72 6520 656c 656d 656e 7420 696e more element in │ │ │ -0004e940: 2074 6865 206c 6973 742e 2042 6563 6175 the list. Becau │ │ │ -0004e950: 7365 2063 6861 6e63 6573 2061 7265 2074 se chances are t │ │ │ -0004e960: 6861 7420 7765 276c 6c20 6a75 7374 206e hat we'll just n │ │ │ -0004e970: 6565 6420 6120 7369 6e67 6c65 2070 6965 eed a single pie │ │ │ -0004e980: 6365 2c20 616e 6420 6f6e 6365 2077 6527 ce, and once we' │ │ │ -0004e990: 7665 2070 6963 6b65 6420 6672 6f6d 2069 ve picked from i │ │ │ -0004e9a0: 7420 7765 2772 6520 646f 6e65 2e20 536f t we're done. So │ │ │ -0004e9b0: 7274 696e 6720 7468 6520 7265 7374 206f rting the rest o │ │ │ -0004e9c0: 6620 7468 6520 6c69 7374 2069 6e20 7468 f the list in th │ │ │ -0004e9d0: 6174 2063 6173 6520 6973 2061 2077 6173 at case is a was │ │ │ -0004e9e0: 7465 206f 6620 7469 6d65 2e3c 2f74 643e te of time. │ │ │ -0004e9f0: 3c2f 7472 3e3c 7472 2069 643d 2231 3930

    this co │ │ │ -0004ea40: 756c 6420 7072 6f62 6162 6c79 2062 6520 uld probably be │ │ │ -0004ea50: 6f70 7469 6d69 7a65 6420 6279 2069 6e63 optimized by inc │ │ │ -0004ea60: 7265 6d65 6e74 616c 6c79 0a63 616c 6c69 rementally.calli │ │ │ -0004ea70: 6e67 2070 6172 7469 616c 5f73 6f72 7420 ng partial_sort │ │ │ -0004ea80: 746f 2073 6f72 7420 6f6e 6520 6d6f 7265 to sort one more │ │ │ -0004ea90: 2065 6c65 6d65 6e74 2069 6e20 7468 6520 element in the │ │ │ -0004eaa0: 6c69 7374 2e20 4265 6361 7573 650a 6368 list. Because.ch │ │ │ -0004eab0: 616e 6365 7320 6172 6520 7468 6174 2077 ances are that w │ │ │ -0004eac0: 6527 6c6c 206a 7573 7420 6e65 6564 2061 e'll just need a │ │ │ -0004ead0: 2073 696e 676c 6520 7069 6563 652c 2061 single piece, a │ │ │ -0004eae0: 6e64 206f 6e63 6520 7765 2776 650a 7069 nd once we've.pi │ │ │ -0004eaf0: 636b 6564 2066 726f 6d20 6974 2077 6527 cked from it we' │ │ │ -0004eb00: 7265 2064 6f6e 652e 2053 6f72 7469 6e67 re done. Sorting │ │ │ -0004eb10: 2074 6865 2072 6573 7420 6f66 2074 6865 the rest of the │ │ │ -0004eb20: 206c 6973 7420 696e 2074 6861 740a 6361 list in that.ca │ │ │ -0004eb30: 7365 2069 7320 6120 7761 7374 6520 6f66 se is a waste of │ │ │ -0004eb40: 2074 696d 652e 3c2f 6832 3e3c 6834 3e2e time.

    . │ │ │ -0004eb50: 2e2f 7372 632f 7069 6563 655f 7069 636b ./src/piece_pick │ │ │ -0004eb60: 6572 2e63 7070 3a32 3035 333c 2f68 343e er.cpp:2053

    │ │ │ -0004eb70: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...// 
    │ │ │ -0004ebb0: 6e6f 772c 2063 6f70 7920 6f76 6572 2074  now, copy over t
    │ │ │ -0004ebc0: 6865 2070 6f69 6e74 6572 732e 2057 6520  he pointers. We 
    │ │ │ -0004ebd0: 616c 736f 2061 7070 6c79 2061 2066 696c  also apply a fil
    │ │ │ -0004ebe0: 7465 7220 6865 7265 2074 6f20 6e6f 740a  ter here to not.
    │ │ │ -0004ebf0: 0909 092f 2f20 696e 636c 7564 6520 696e  ...// include in
    │ │ │ -0004ec00: 656c 6967 6962 6c65 2070 6965 6365 7320  eligible pieces 
    │ │ │ -0004ec10: 696e 2063 6572 7461 696e 206d 6f64 6573  in certain modes
    │ │ │ -0004ec20: 2e20 466f 7220 696e 7374 616e 6365 2c20  . For instance, 
    │ │ │ -0004ec30: 6120 7069 6563 650a 0909 092f 2f20 7468  a piece....// th
    │ │ │ -0004ec40: 6174 2074 6865 2063 7572 7265 6e74 2070  at the current p
    │ │ │ -0004ec50: 6565 7220 646f 6573 6e27 7420 6861 7665  eer doesn't have
    │ │ │ -0004ec60: 2069 7320 6e6f 7420 696e 636c 7564 6564   is not included
    │ │ │ -0004ec70: 2e0a 0909 0966 6f72 2028 6175 746f 2063  .....for (auto c
    │ │ │ -0004ec80: 6f6e 7374 2661 6d70 3b20 6470 203a 206d  onst& dp : m
    │ │ │ -0004ec90: 5f64 6f77 6e6c 6f61 6473 5b70 6965 6365  _downloads[piece
    │ │ │ -0004eca0: 5f70 6f73 3a3a 7069 6563 655f 646f 776e  _pos::piece_down
    │ │ │ -0004ecb0: 6c6f 6164 696e 675d 290a 0909 097b 0a09  loading])....{..
    │ │ │ -0004ecc0: 0909 0970 632e 696e 635f 7374 6174 735f  ...pc.inc_stats_
    │ │ │ -0004ecd0: 636f 756e 7465 7228 636f 756e 7465 7273  counter(counters
    │ │ │ -0004ece0: 3a3a 7069 6563 655f 7069 636b 6572 5f70  ::piece_picker_p
    │ │ │ -0004ecf0: 6172 7469 616c 5f6c 6f6f 7073 293b 0a0a  artial_loops);..
    │ │ │ -0004ed00: 0909 0909 6966 2028 2169 735f 7069 6563  ....if (!is_piec
    │ │ │ -0004ed10: 655f 6672 6565 2864 702e 696e 6465 782c  e_free(dp.index,
    │ │ │ -0004ed20: 2070 6965 6365 7329 2920 636f 6e74 696e   pieces)) contin
    │ │ │ -0004ed30: 7565 3b0a 0a09 0909 0954 4f52 5245 4e54  ue;......TORRENT
    │ │ │ -0004ed40: 5f41 5353 4552 5428 6d5f 7069 6563 655f  _ASSERT(m_piece_
    │ │ │ -0004ed50: 6d61 705b 6470 2e69 6e64 6578 5d2e 646f  map[dp.index].do
    │ │ │ -0004ed60: 776e 6c6f 6164 5f71 7565 7565 2829 0a09  wnload_queue()..
    │ │ │ -0004ed70: 0909 0909 3d3d 2070 6965 6365 5f70 6f73  ....== piece_pos
    │ │ │ -0004ed80: 3a3a 7069 6563 655f 646f 776e 6c6f 6164  ::piece_download
    │ │ │ -0004ed90: 696e 6729 3b0a 0a09 0909 096f 7264 6572  ing);......order
    │ │ │ -0004eda0: 6564 5f70 6172 7469 616c 735b 6e75 6d5f  ed_partials[num_
    │ │ │ -0004edb0: 6f72 6465 7265 645f 7061 7274 6961 6c73  ordered_partials
    │ │ │ -0004edc0: 2b2b 5d20 3d20 2661 6d70 3b64 703b 0a09  ++] = &dp;..
    │ │ │ -0004edd0: 0909 7d0a 0a09 0909 2f2f 206e 6f77 2c20  ..}.....// now, 
    │ │ │ -0004ede0: 736f 7274 2074 6865 206c 6973 742e 0a09  sort the list...
    │ │ │ -0004edf0: 0909 6966 2028 6f70 7469 6f6e 7320 2661  ..if (options &a
    │ │ │ -0004ee00: 6d70 3b20 7261 7265 7374 5f66 6972 7374  mp; rarest_first
    │ │ │ -0004ee10: 290a 0909 097b 0a09 0909 0972 6574 207c  )....{.....ret |
    │ │ │ -0004ee20: 3d20 7069 636b 6572 5f6c 6f67 5f61 6c65  = picker_log_ale
    │ │ │ -0004ee30: 7274 3a3a 7261 7265 7374 5f66 6972 7374  rt::rarest_first
    │ │ │ -0004ee40: 5f70 6172 7469 616c 733b 0a0a 3c64 6976  _partials;..
    ....st │ │ │ -0004ee80: 643a 3a73 6f72 7428 6f72 6465 7265 645f d::sort(ordered_ │ │ │ -0004ee90: 7061 7274 6961 6c73 2e62 6567 696e 2829 partials.begin() │ │ │ -0004eea0: 2c20 6f72 6465 7265 645f 7061 7274 6961 , ordered_partia │ │ │ -0004eeb0: 6c73 2e62 6567 696e 2829 202b 206e 756d ls.begin() + num │ │ │ -0004eec0: 5f6f 7264 6572 6564 5f70 6172 7469 616c _ordered_partial │ │ │ -0004eed0: 730a 3c2f 6469 763e 0909 0909 092c 2073 s.
    ....., s │ │ │ -0004eee0: 7464 3a3a 6269 6e64 2826 616d 703b 7069 td::bind(&pi │ │ │ -0004eef0: 6563 655f 7069 636b 6572 3a3a 7061 7274 ece_picker::part │ │ │ -0004ef00: 6961 6c5f 636f 6d70 6172 655f 7261 7265 ial_compare_rare │ │ │ -0004ef10: 7374 5f66 6972 7374 2c20 7468 6973 0a09 st_first, this.. │ │ │ -0004ef20: 0909 0909 092c 205f 312c 205f 3229 293b ....., _1, _2)); │ │ │ -0004ef30: 0a09 0909 7d0a 0a09 0909 666f 7220 2869 ....}.....for (i │ │ │ -0004ef40: 6e74 2069 203d 2030 3b20 6920 266c 743b nt i = 0; i < │ │ │ -0004ef50: 206e 756d 5f6f 7264 6572 6564 5f70 6172 num_ordered_par │ │ │ -0004ef60: 7469 616c 733b 202b 2b69 290a 0909 097b tials; ++i)....{ │ │ │ -0004ef70: 0a09 0909 0972 6574 207c 3d20 7069 636b .....ret |= pick │ │ │ -0004ef80: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 7072 er_log_alert::pr │ │ │ -0004ef90: 696f 7269 7469 7a65 5f70 6172 7469 616c ioritize_partial │ │ │ -0004efa0: 733b 0a0a 0909 0909 6e75 6d5f 626c 6f63 s;......num_bloc │ │ │ -0004efb0: 6b73 203d 2061 6464 5f62 6c6f 636b 735f ks = add_blocks_ │ │ │ -0004efc0: 646f 776e 6c6f 6164 696e 6728 2a6f 7264 downloading(*ord │ │ │ -0004efd0: 6572 6564 5f70 6172 7469 616c 735b 695d ered_partials[i] │ │ │ -0004efe0: 2c20 7069 6563 6573 0a09 0909 0909 2c20 , pieces......, │ │ │ -0004eff0: 696e 7465 7265 7374 696e 675f 626c 6f63 interesting_bloc │ │ │ -0004f000: 6b73 2c20 6261 636b 7570 5f62 6c6f 636b ks, backup_block │ │ │ -0004f010: 730a 0909 0909 092c 206e 756d 5f62 6c6f s......, num_blo │ │ │ -0004f020: 636b 732c 2070 7265 6665 725f 636f 6e74 cks, prefer_cont │ │ │ -0004f030: 6967 756f 7573 5f62 6c6f 636b 732c 2070 iguous_blocks, p │ │ │ -0004f040: 6565 722c 206f 7074 696f 6e73 293b 0a09 eer, options);.. │ │ │ -0004f050: 0909 0969 6620 286e 756d 5f62 6c6f 636b ...if (num_block │ │ │ -0004f060: 7320 266c 743b 3d20 3029 2072 6574 7572 s <= 0) retur │ │ │ -0004f070: 6e20 7265 743b 0a09 0909 0969 6620 2869 n ret;.....if (i │ │ │ -0004f080: 6e74 2862 6163 6b75 705f 626c 6f63 6b73 nt(backup_blocks │ │ │ -0004f090: 2e73 697a 6528 2929 2026 6774 3b3d 206e .size()) >= n │ │ │ -0004f0a0: 756d 5f62 6c6f 636b 7329 0a09 0909 0909 um_blocks)...... │ │ │ -0004f0b0: 6272 6561 6b3b 0a09 0909 7d0a 0a09 0909 break;....}..... │ │ │ -0004f0c0: 6e75 6d5f 626c 6f63 6b73 203d 2061 7070 num_blocks = app │ │ │ -0004f0d0: 656e 645f 626c 6f63 6b73 2869 6e74 6572 end_blocks(inter │ │ │ -0004f0e0: 6573 7469 6e67 5f62 6c6f 636b 732c 2062 esting_blocks, b │ │ │ -0004f0f0: 6163 6b75 705f 626c 6f63 6b73 0a09 0909 ackup_blocks.... │ │ │ -0004f100: 092c 206e 756d 5f62 6c6f 636b 7329 3b0a ., num_blocks);. │ │ │ -0004f110: 0909 0969 6620 286e 756d 5f62 6c6f 636b ...if (num_block │ │ │ -0004f120: 7320 266c 743b 3d20 3029 2072 6574 7572 s <= 0) retur │ │ │ -0004f130: 6e20 7265 743b 0a09 097d 0a0a 0909 6966 n ret;...}....if │ │ │ -0004f140: 2028 2173 7567 6765 7374 6564 5f70 6965 (!suggested_pie │ │ │ -0004f150: 6365 732e 656d 7074 7928 2929 0a09 097b ces.empty())...{ │ │ │ -0004f160: 0a09 0909 666f 7220 2870 6965 6365 5f69 ....for (piece_i │ │ │ -0004f170: 6e64 6578 5f74 2069 203a 2073 7567 6765 ndex_t i : sugge │ │ │ -0004f180: 7374 6564 5f70 6965 6365 7329 0a09 0909 sted_pieces).... │ │ │ -0004f190: 7b0a 0909 0909 7063 2e69 6e63 5f73 7461 {.....pc.inc_sta │ │ │ -0004f1a0: 7473 5f63 6f75 6e74 6572 2863 6f75 6e74 ts_counter(count │ │ │ -0004f1b0: 6572 733a 3a70 6965 6365 5f70 6963 6b65 ers::piece_picke │ │ │ -0004f1c0: 725f 7375 6767 6573 745f 6c6f 6f70 7329 r_suggest_loops) │ │ │ -0004f1d0: 3b0a 0909 0909 6966 2028 2169 735f 7069 ;.....if (!is_pi │ │ │ -0004f1e0: 6563 655f 6672 6565 2869 2c20 7069 6563 ece_free(i, piec │ │ │ -0004f1f0: 6573 2929 2063 6f6e 7469 6e75 653b 0a0a es)) continue;.. │ │ │ -0004f200: 0909 0909 7265 7420 7c3d 2070 6963 6b65 ....ret |= picke │ │ │ -0004f210: 725f 6c6f 675f 616c 6572 743a 3a73 7567 r_log_alert::sug │ │ │ -0004f220: 6765 7374 6564 5f70 6965 6365 733b 0a0a gested_pieces;.. │ │ │ -0004f230: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0004f240: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0004f270: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0004f2a0: 632f 7069 6563 655f 7069 636b 6572 2e63 c/piece_picker.c │ │ │ -0004f2b0: 7070 3a32 3139 353c 2f61 3e3c 2f74 643e pp:2195 │ │ │ -0004f2c0: 3c74 643e 4973 2069 7420 6120 676f 6f64 Is it a good │ │ │ -0004f2d0: 2069 6465 6120 7468 6174 2074 6869 7320 idea that this │ │ │ -0004f2e0: 6166 6669 6e69 7479 2074 616b 6573 2070 affinity takes p │ │ │ -0004f2f0: 7265 6365 6465 6e63 6520 6f76 6572 2070 recedence over p │ │ │ -0004f300: 6965 6365 2070 7269 6f72 6974 793f 3c2f iece priority?

    Is i │ │ │ -0004f360: 7420 6120 676f 6f64 2069 6465 6120 7468 t a good idea th │ │ │ -0004f370: 6174 2074 6869 7320 6166 6669 6e69 7479 at this affinity │ │ │ -0004f380: 2074 616b 6573 2070 7265 6365 6465 6e63 takes precedenc │ │ │ -0004f390: 6520 6f76 6572 0a70 6965 6365 2070 7269 e over.piece pri │ │ │ -0004f3a0: 6f72 6974 793f 3c2f 6832 3e3c 6834 3e2e ority?

    . │ │ │ -0004f3b0: 2e2f 7372 632f 7069 6563 655f 7069 636b ./src/piece_pick │ │ │ -0004f3c0: 6572 2e63 7070 3a32 3139 353c 2f68 343e er.cpp:2195

    │ │ │ -0004f3d0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ......
    │ │ │ -0004f410: 7063 2e69 6e63 5f73 7461 7473 5f63 6f75  pc.inc_stats_cou
    │ │ │ -0004f420: 6e74 6572 2863 6f75 6e74 6572 733a 3a70  nter(counters::p
    │ │ │ -0004f430: 6965 6365 5f70 6963 6b65 725f 7265 7665  iece_picker_reve
    │ │ │ -0004f440: 7273 655f 7261 7265 5f6c 6f6f 7073 293b  rse_rare_loops);
    │ │ │ -0004f450: 0a0a 0909 0909 0909 6966 2028 2169 735f  ........if (!is_
    │ │ │ -0004f460: 7069 6563 655f 6672 6565 286d 5f70 6965  piece_free(m_pie
    │ │ │ -0004f470: 6365 735b 705d 2c20 7069 6563 6573 2929  ces[p], pieces))
    │ │ │ -0004f480: 2063 6f6e 7469 6e75 653b 0a09 0909 0909   continue;......
    │ │ │ -0004f490: 092f 2f20 6375 7273 6f72 7320 6172 6520  .// cursors are 
    │ │ │ -0004f4a0: 6e6f 7420 6d75 7461 7465 6420 6475 7269  not mutated duri
    │ │ │ -0004f4b0: 6e67 2070 6963 6b69 6e67 3b20 6d61 6b65  ng picking; make
    │ │ │ -0004f4c0: 2073 7572 6520 7765 2064 6f6e 2774 2070   sure we don't p
    │ │ │ -0004f4d0: 6963 6b20 7069 6563 6573 2077 6974 6869  ick pieces withi
    │ │ │ -0004f4e0: 6e20 7468 650a 0909 0909 0909 2f2f 2073  n the.......// s
    │ │ │ -0004f4f0: 6571 7565 6e74 6961 6c20 7261 6e67 6520  equential range 
    │ │ │ -0004f500: 6966 2069 6e20 7365 7175 656e 7469 616c  if in sequential
    │ │ │ -0004f510: 2064 6f77 6e6c 6f61 6420 6d6f 6465 2073   download mode s
    │ │ │ -0004f520: 6f20 7468 6174 2077 6520 646f 6e27 7420  o that we don't 
    │ │ │ -0004f530: 7069 636b 2064 7570 6c69 6361 7465 2070  pick duplicate p
    │ │ │ -0004f540: 6965 6365 730a 0909 0909 0909 6966 2028  ieces.......if (
    │ │ │ -0004f550: 286f 7074 696f 6e73 2026 616d 703b 2073  (options & s
    │ │ │ -0004f560: 6571 7565 6e74 6961 6c29 2026 616d 703b  equential) &
    │ │ │ -0004f570: 2661 6d70 3b20 6d5f 7069 6563 6573 5b70  & m_pieces[p
    │ │ │ -0004f580: 5d20 2667 743b 3d20 6d5f 6375 7273 6f72  ] >= m_cursor
    │ │ │ -0004f590: 2026 616d 703b 2661 6d70 3b20 6d5f 7069   && m_pi
    │ │ │ -0004f5a0: 6563 6573 5b70 5d20 266c 743b 206d 5f72  eces[p] < m_r
    │ │ │ -0004f5b0: 6576 6572 7365 5f63 7572 736f 7229 2063  everse_cursor) c
    │ │ │ -0004f5c0: 6f6e 7469 6e75 653b 0a0a 0909 0909 0909  ontinue;........
    │ │ │ -0004f5d0: 7265 7420 7c3d 2070 6963 6b65 725f 6c6f  ret |= picker_lo
    │ │ │ -0004f5e0: 675f 616c 6572 743a 3a72 6576 6572 7365  g_alert::reverse
    │ │ │ -0004f5f0: 5f72 6172 6573 745f 6669 7273 743b 0a0a  _rarest_first;..
    │ │ │ -0004f600: 0909 0909 0909 6e75 6d5f 626c 6f63 6b73  ......num_blocks
    │ │ │ -0004f610: 203d 2061 6464 5f62 6c6f 636b 7328 6d5f   = add_blocks(m_
    │ │ │ -0004f620: 7069 6563 6573 5b70 5d2c 2070 6965 6365  pieces[p], piece
    │ │ │ -0004f630: 730a 0909 0909 0909 092c 2069 6e74 6572  s........, inter
    │ │ │ -0004f640: 6573 7469 6e67 5f62 6c6f 636b 730a 0909  esting_blocks...
    │ │ │ -0004f650: 0909 0909 092c 2062 6163 6b75 705f 626c  ....., backup_bl
    │ │ │ -0004f660: 6f63 6b73 2c20 6e75 6d5f 626c 6f63 6b73  ocks, num_blocks
    │ │ │ -0004f670: 0a09 0909 0909 0909 2c20 7072 6566 6572  ........, prefer
    │ │ │ -0004f680: 5f63 6f6e 7469 6775 6f75 735f 626c 6f63  _contiguous_bloc
    │ │ │ -0004f690: 6b73 2c20 7065 6572 2c20 6967 6e6f 7265  ks, peer, ignore
    │ │ │ -0004f6a0: 645f 7069 6563 6573 0a09 0909 0909 0909  d_pieces........
    │ │ │ -0004f6b0: 2c20 6f70 7469 6f6e 7329 3b0a 0909 0909  , options);.....
    │ │ │ -0004f6c0: 0909 6966 2028 6e75 6d5f 626c 6f63 6b73  ..if (num_blocks
    │ │ │ -0004f6d0: 2026 6c74 3b3d 2030 2920 7265 7475 726e   <= 0) return
    │ │ │ -0004f6e0: 2072 6574 3b0a 0909 0909 097d 0a09 0909   ret;......}....
    │ │ │ -0004f6f0: 097d 0a09 0909 7d0a 0909 0965 6c73 650a  .}....}....else.
    │ │ │ -0004f700: 0909 097b 0a3c 6469 7620 7374 796c 653d  ...{.
    ....if (optio │ │ │ -0004f740: 6e73 2026 616d 703b 2070 6965 6365 5f65 ns & piece_e │ │ │ -0004f750: 7874 656e 745f 6166 6669 6e69 7479 290a xtent_affinity). │ │ │ -0004f760: 3c2f 6469 763e 0909 0909 7b0a 0909 0909
    ....{..... │ │ │ -0004f770: 0969 6e74 2074 6f5f 6572 6173 6520 3d20 .int to_erase = │ │ │ -0004f780: 2d31 3b0a 0909 0909 0969 6e74 2069 6478 -1;......int idx │ │ │ -0004f790: 203d 202d 313b 0a09 0909 0909 666f 7220 = -1;......for │ │ │ -0004f7a0: 2870 6965 6365 5f65 7874 656e 745f 7420 (piece_extent_t │ │ │ -0004f7b0: 636f 6e73 7420 6520 3a20 6d5f 7265 6365 const e : m_rece │ │ │ -0004f7c0: 6e74 5f65 7874 656e 7473 290a 0909 0909 nt_extents)..... │ │ │ -0004f7d0: 097b 0a09 0909 0909 092b 2b69 6478 3b0a .{.......++idx;. │ │ │ -0004f7e0: 0909 0909 0909 626f 6f6c 2068 6176 655f ......bool have_ │ │ │ -0004f7f0: 616c 6c20 3d20 7472 7565 3b0a 0909 0909 all = true;..... │ │ │ -0004f800: 0909 666f 7220 2870 6965 6365 5f69 6e64 ..for (piece_ind │ │ │ -0004f810: 6578 5f74 2063 6f6e 7374 2070 203a 2065 ex_t const p : e │ │ │ -0004f820: 7874 656e 745f 666f 7228 6529 290a 0909 xtent_for(e))... │ │ │ -0004f830: 0909 0909 7b0a 0909 0909 0909 0969 6620 ....{........if │ │ │ -0004f840: 2821 6d5f 7069 6563 655f 6d61 705b 705d (!m_piece_map[p] │ │ │ -0004f850: 2e66 6c75 7368 6564 2829 2920 6861 7665 .flushed()) have │ │ │ -0004f860: 5f61 6c6c 203d 2066 616c 7365 3b0a 0909 _all = false;... │ │ │ -0004f870: 0909 0909 0969 6620 2821 6973 5f70 6965 .....if (!is_pie │ │ │ -0004f880: 6365 5f66 7265 6528 702c 2070 6965 6365 ce_free(p, piece │ │ │ -0004f890: 7329 2920 636f 6e74 696e 7565 3b0a 0909 s)) continue;... │ │ │ -0004f8a0: 0909 0909 0969 6620 2828 6f70 7469 6f6e .....if ((option │ │ │ -0004f8b0: 7320 2661 6d70 3b20 7365 7175 656e 7469 s & sequenti │ │ │ -0004f8c0: 616c 2920 2661 6d70 3b26 616d 703b 2070 al) && p │ │ │ -0004f8d0: 2026 6774 3b3d 206d 5f63 7572 736f 7220 >= m_cursor │ │ │ -0004f8e0: 2661 6d70 3b26 616d 703b 2070 2026 6c74 && p < │ │ │ -0004f8f0: 3b20 6d5f 7265 7665 7273 655f 6375 7273 ; m_reverse_curs │ │ │ -0004f900: 6f72 2920 636f 6e74 696e 7565 3b0a 0a09 or) continue;... │ │ │ -0004f910: 0909 0909 0909 7265 7420 7c3d 2070 6963 ......ret |= pic │ │ │ -0004f920: 6b65 725f 6c6f 675f 616c 6572 743a 3a65 ker_log_alert::e │ │ │ -0004f930: 7874 656e 745f 6166 6669 6e69 7479 3b0a xtent_affinity;. │ │ │ -0004f940: 0a09 0909 0909 0909 6e75 6d5f 626c 6f63 ........num_bloc │ │ │ -0004f950: 6b73 203d 2061 6464 5f62 6c6f 636b 7328 ks = add_blocks( │ │ │ -0004f960: 702c 2070 6965 6365 730a 0909 0909 0909 p, pieces....... │ │ │ -0004f970: 0909 2c20 696e 7465 7265 7374 696e 675f .., interesting_ │ │ │ -0004f980: 626c 6f63 6b73 0a09 0909 0909 0909 092c blocks........., │ │ │ -0004f990: 2062 6163 6b75 705f 626c 6f63 6b73 2c20 backup_blocks, │ │ │ -0004f9a0: 6e75 6d5f 626c 6f63 6b73 0a09 0909 0909 num_blocks...... │ │ │ -0004f9b0: 0909 092c 2070 7265 6665 725f 636f 6e74 ..., prefer_cont │ │ │ -0004f9c0: 6967 756f 7573 5f62 6c6f 636b 732c 2070 iguous_blocks, p │ │ │ -0004f9d0: 6565 722c 2069 676e 6f72 6564 5f70 6965 eer, ignored_pie │ │ │ -0004f9e0: 6365 730a 0909 0909 0909 0909 2c20 6f70 ces........., op │ │ │ -0004f9f0: 7469 6f6e 7329 3b0a 0909 0909 0909 0969 tions);........i │ │ │ -0004fa00: 6620 286e 756d 5f62 6c6f 636b 7320 266c f (num_blocks &l │ │ │ -0004fa10: 743b 3d20 3029 0a09 0909 0909 0909 7b0a t;= 0)........{. │ │ │ -0004fa20: 0909 0909 0909 0909 2f2f 2069 6620 7765 ........// if we │ │ │ -0004fa30: 2068 6176 6520 616c 6c20 7069 6563 6573 have all pieces │ │ │ -0004fa40: 2062 656c 6f6e 6769 6e67 2074 6f20 7468 belonging to th │ │ │ -0004fa50: 6973 2065 7874 656e 742c 2072 656d 6f76 is extent, remov │ │ │ -0004fa60: 6520 6974 0a09 0909 0909 0909 0969 6620 e it.........if │ │ │ -0004fa70: 2874 6f5f 6572 6173 6520 213d 202d 3129 (to_erase != -1) │ │ │ -0004fa80: 206d 5f72 6563 656e 745f 6578 7465 6e74 m_recent_extent │ │ │ -0004fa90: 732e 6572 6173 6528 6d5f 7265 6365 6e74 s.erase(m_recent │ │ │ -0004faa0: 5f65 7874 656e 7473 2e62 6567 696e 2829 _extents.begin() │ │ │ -0004fab0: 202b 2074 6f5f 6572 6173 6529 3b0a 0909 + to_erase);... │ │ │ -0004fac0: 0909 0909 0909 7265 7475 726e 2072 6574 ......return ret │ │ │ -0004fad0: 3b0a 0909 0909 0909 097d 0a09 0909 0909 ;........}...... │ │ │ -0004fae0: 097d 0a09 0909 0909 092f 2f20 6966 2077 .}.......// if w │ │ │ -0004faf0: 6520 6861 7665 2061 6c6c 2070 6965 6365 e have all piece │ │ │ -0004fb00: 7320 6265 6c6f 6e67 696e 6720 746f 2074 s belonging to t │ │ │ -0004fb10: 6869 7320 6578 7465 6e74 2c20 7265 6d6f his extent, remo │ │ │ -0004fb20: 7665 2069 740a 0909 0909 0909 6966 2028 ve it.......if ( │ │ │ -0004fb30: 6861 7665 5f61 6c6c 2920 746f 5f65 7261 have_all) to_era │ │ │ -0004fb40: 7365 203d 2069 6478 3b0a 0909 0909 097d se = idx;......} │ │ │ -0004fb50: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0004fb90: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -0004fbc0: 7263 2f70 6965 6365 5f70 6963 6b65 722e rc/piece_picker. │ │ │ -0004fbd0: 6370 703a 3235 3437 3c2f 613e 3c2f 7464 cpp:2547when expand │ │ │ -0004fbf0: 696e 6720 7069 6563 6573 2066 6f72 2063 ing pieces for c │ │ │ -0004fc00: 6163 6865 2073 7472 6970 6520 7265 6173 ache stripe reas │ │ │ -0004fc10: 6f6e 732c 2074 6865 2021 646f 776e 6c6f ons, the !downlo │ │ │ -0004fc20: 6164 696e 6720 636f 6e64 6974 696f 6e20 ading condition │ │ │ -0004fc30: 646f 6573 6e27 7420 6d61 6b65 206d 7563 doesn't make muc │ │ │ -0004fc40: 6820 7365 6e73 653c 2f74 643e 3c2f 7472 h sense

    when expand │ │ │ -0004fca0: 696e 6720 7069 6563 6573 2066 6f72 2063 ing pieces for c │ │ │ -0004fcb0: 6163 6865 2073 7472 6970 6520 7265 6173 ache stripe reas │ │ │ -0004fcc0: 6f6e 732c 0a74 6865 2021 646f 776e 6c6f ons,.the !downlo │ │ │ -0004fcd0: 6164 696e 6720 636f 6e64 6974 696f 6e20 ading condition │ │ │ -0004fce0: 646f 6573 6e27 7420 6d61 6b65 206d 7563 doesn't make muc │ │ │ -0004fcf0: 6820 7365 6e73 653c 2f68 323e 3c68 343e h sense

    │ │ │ -0004fd00: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ -0004fd10: 6b65 722e 6370 703a 3235 3437 3c2f 6834 ker.cpp:2547

    ..TOR
    │ │ │ -0004fd60: 5245 4e54 5f41 5353 4552 5428 696e 6465  RENT_ASSERT(inde
    │ │ │ -0004fd70: 7820 266c 743b 206d 5f70 6965 6365 5f6d  x < m_piece_m
    │ │ │ -0004fd80: 6170 2e65 6e64 5f69 6e64 6578 2829 293b  ap.end_index());
    │ │ │ -0004fd90: 0a09 0969 6620 286e 6578 7428 696e 6465  ...if (next(inde
    │ │ │ -0004fda0: 7829 203d 3d20 6d5f 7069 6563 655f 6d61  x) == m_piece_ma
    │ │ │ -0004fdb0: 702e 656e 645f 696e 6465 7828 2929 0a09  p.end_index())..
    │ │ │ -0004fdc0: 0909 7265 7475 726e 206d 5f62 6c6f 636b  ..return m_block
    │ │ │ -0004fdd0: 735f 696e 5f6c 6173 745f 7069 6563 653b  s_in_last_piece;
    │ │ │ -0004fde0: 0a09 0965 6c73 650a 0909 0972 6574 7572  ...else....retur
    │ │ │ -0004fdf0: 6e20 626c 6f63 6b73 5f70 6572 5f70 6965  n blocks_per_pie
    │ │ │ -0004fe00: 6365 2829 3b0a 097d 0a0a 0962 6f6f 6c20  ce();..}...bool 
    │ │ │ -0004fe10: 7069 6563 655f 7069 636b 6572 3a3a 6973  piece_picker::is
    │ │ │ -0004fe20: 5f70 6965 6365 5f66 7265 6528 7069 6563  _piece_free(piec
    │ │ │ -0004fe30: 655f 696e 6465 785f 7420 636f 6e73 7420  e_index_t const 
    │ │ │ -0004fe40: 7069 6563 650a 0909 2c20 7479 7065 645f  piece..., typed_
    │ │ │ -0004fe50: 6269 7466 6965 6c64 266c 743b 7069 6563  bitfield<piec
    │ │ │ -0004fe60: 655f 696e 6465 785f 7426 6774 3b20 636f  e_index_t> co
    │ │ │ -0004fe70: 6e73 7426 616d 703b 2062 6974 6d61 736b  nst& bitmask
    │ │ │ -0004fe80: 2920 636f 6e73 740a 097b 0a09 0972 6574  ) const..{...ret
    │ │ │ -0004fe90: 7572 6e20 6269 746d 6173 6b5b 7069 6563  urn bitmask[piec
    │ │ │ -0004fea0: 655d 0a09 0909 2661 6d70 3b26 616d 703b  e]....&&
    │ │ │ -0004feb0: 2021 6d5f 7069 6563 655f 6d61 705b 7069   !m_piece_map[pi
    │ │ │ -0004fec0: 6563 655d 2e66 6c75 7368 6564 2829 0a09  ece].flushed()..
    │ │ │ -0004fed0: 0909 2661 6d70 3b26 616d 703b 2021 6d5f  ..&& !m_
    │ │ │ -0004fee0: 7069 6563 655f 6d61 705b 7069 6563 655d  piece_map[piece]
    │ │ │ -0004fef0: 2e66 696c 7465 7265 6428 293b 0a09 7d0a  .filtered();..}.
    │ │ │ -0004ff00: 0a09 626f 6f6c 2070 6965 6365 5f70 6963  ..bool piece_pic
    │ │ │ -0004ff10: 6b65 723a 3a63 616e 5f70 6963 6b28 7069  ker::can_pick(pi
    │ │ │ -0004ff20: 6563 655f 696e 6465 785f 7420 636f 6e73  ece_index_t cons
    │ │ │ -0004ff30: 7420 7069 6563 650a 0909 2c20 7479 7065  t piece..., type
    │ │ │ -0004ff40: 645f 6269 7466 6965 6c64 266c 743b 7069  d_bitfield<pi
    │ │ │ -0004ff50: 6563 655f 696e 6465 785f 7426 6774 3b20  ece_index_t> 
    │ │ │ -0004ff60: 636f 6e73 7426 616d 703b 2062 6974 6d61  const& bitma
    │ │ │ -0004ff70: 736b 2920 636f 6e73 740a 097b 0a09 0972  sk) const..{...r
    │ │ │ -0004ff80: 6574 7572 6e20 6269 746d 6173 6b5b 7069  eturn bitmask[pi
    │ │ │ -0004ff90: 6563 655d 0a09 0909 2661 6d70 3b26 616d  ece]....&&am
    │ │ │ -0004ffa0: 703b 2021 6d5f 7069 6563 655f 6d61 705b  p; !m_piece_map[
    │ │ │ -0004ffb0: 7069 6563 655d 2e66 6c75 7368 6564 2829  piece].flushed()
    │ │ │ -0004ffc0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0004fff0: 0909 2661 6d70 3b26 616d 703b 2021 6d5f ..&& !m_ │ │ │ -00050000: 7069 6563 655f 6d61 705b 7069 6563 655d piece_map[piece] │ │ │ -00050010: 2e64 6f77 6e6c 6f61 6469 6e67 2829 0a3c .downloading().< │ │ │ -00050020: 2f64 6976 3e09 0909 2661 6d70 3b26 616d /div>...&&am │ │ │ -00050030: 703b 2021 6d5f 7069 6563 655f 6d61 705b p; !m_piece_map[ │ │ │ -00050040: 7069 6563 655d 2e66 696c 7465 7265 6428 piece].filtered( │ │ │ -00050050: 293b 0a09 7d0a 0a23 6966 2054 4f52 5245 );..}..#if TORRE │ │ │ -00050060: 4e54 5f55 5345 5f49 4e56 4152 4941 4e54 NT_USE_INVARIANT │ │ │ -00050070: 5f43 4845 434b 530a 0976 6f69 6420 7069 _CHECKS..void pi │ │ │ -00050080: 6563 655f 7069 636b 6572 3a3a 6368 6563 ece_picker::chec │ │ │ -00050090: 6b5f 7065 6572 7328 290a 097b 0a09 0966 k_peers()..{...f │ │ │ -000500a0: 6f72 2028 6175 746f 2063 6f6e 7374 2661 or (auto const&a │ │ │ -000500b0: 6d70 3b20 6220 3a20 6d5f 626c 6f63 6b5f mp; b : m_block_ │ │ │ -000500c0: 696e 666f 290a 0909 7b0a 0909 0954 4f52 info)...{....TOR │ │ │ -000500d0: 5245 4e54 5f41 5353 4552 5428 622e 7065 RENT_ASSERT(b.pe │ │ │ -000500e0: 6572 203d 3d20 6e75 6c6c 7074 7220 7c7c er == nullptr || │ │ │ -000500f0: 2073 7461 7469 635f 6361 7374 266c 743b static_cast< │ │ │ -00050100: 6175 783a 3a74 6f72 7265 6e74 5f70 6565 aux::torrent_pee │ │ │ -00050110: 722a 2667 743b 2862 2e70 6565 7229 2d26 r*>(b.peer)-& │ │ │ -00050120: 6774 3b69 6e5f 7573 6529 3b0a 0909 7d0a gt;in_use);...}. │ │ │ -00050130: 097d 0a23 656e 6469 660a 0a09 766f 6964 .}.#endif...void │ │ │ -00050140: 2070 6965 6365 5f70 6963 6b65 723a 3a63 piece_picker::c │ │ │ -00050150: 6c65 6172 5f70 6565 7228 6175 783a 3a74 lear_peer(aux::t │ │ │ -00050160: 6f72 7265 6e74 5f70 6565 722a 2070 6565 orrent_peer* pee │ │ │ -00050170: 7229 0a09 7b0a 0909 666f 7220 2861 7574 r)..{...for (aut │ │ │ -00050180: 6f26 616d 703b 2062 203a 206d 5f62 6c6f o& b : m_blo │ │ │ -00050190: 636b 5f69 6e66 6f29 0a09 097b 0a09 0909 ck_info)...{.... │ │ │ -000501a0: 6966 2028 622e 7065 6572 203d 3d20 7065 if (b.peer == pe │ │ │ -000501b0: 6572 2920 622e 7065 6572 203d 206e 756c er) b.peer = nul │ │ │ -000501c0: 6c70 7472 3b0a 0909 7d0a 097d 0a0a 092f lptr;...}..}.../ │ │ │ -000501d0: 2f20 7468 6520 6669 7273 7420 626f 6f6c / the first bool │ │ │ -000501e0: 2069 7320 7472 7565 2069 6620 7468 6973 is true if this │ │ │ -000501f0: 2069 7320 7468 6520 6f6e 6c79 2070 6565 is the only pee │ │ │ -00050200: 7220 7468 6174 2068 6173 2072 6571 7565 r that has reque │ │ │ -00050210: 7374 6564 2061 6e64 2064 6f77 6e6c 6f61 sted and downloa │ │ │ -00050220: 6465 640a 092f 2f20 626c 6f63 6b73 2066 ded..// blocks f │ │ │ -00050230: 726f 6d20 7468 6973 2070 6965 6365 2e0a rom this piece.. │ │ │ -00050240: 092f 2f20 7468 6520 7365 636f 6e64 2062 .// the second b │ │ │ -00050250: 6f6f 6c20 6973 2074 7275 6520 6966 2074 ool is true if t │ │ │ -00050260: 6869 7320 6973 2074 6865 206f 6e6c 7920 his is the only │ │ │ -00050270: 6163 7469 7665 2070 6565 7220 7468 6174 active peer that │ │ │ -00050280: 2069 7320 7265 7175 6573 7469 6e67 0a09 is requesting.. │ │ │ -00050290: 2f2f 2061 6e64 2064 6f77 6e6c 6f61 6469 // and downloadi │ │ │ -000502a0: 6e67 2062 6c6f 636b 7320 6672 6f6d 2074 ng blocks from t │ │ │ -000502b0: 6869 7320 7069 6563 652e 2041 6374 6976 his piece. Activ │ │ │ -000502c0: 6520 6d65 616e 7320 6861 7669 6e67 2061 e means having a │ │ │ -000502d0: 2063 6f6e 6e65 6374 696f 6e2e 0a3c 2f70 connection..

    re │ │ │ -00050310: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/p │ │ │ -00050350: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ -00050360: 3331 3139 3c2f 613e 3c2f 7464 3e3c 7464 3119should 5 be con │ │ │ -00050380: 6669 6775 7261 626c 653f 3c2f 7464 3e3c figurable?< │ │ │ -00050390: 2f74 723e 3c74 7220 6964 3d22 3139 3322 /tr>

    should 5 │ │ │ -000503e0: 2062 6520 636f 6e66 6967 7572 6162 6c65 be configurable │ │ │ -000503f0: 3f3c 2f68 323e 3c68 343e 2e2e 2f73 7263 ?

    ../src │ │ │ -00050400: 2f70 6965 6365 5f70 6963 6b65 722e 6370 /piece_picker.cp │ │ │ -00050410: 703a 3331 3139 3c2f 6834 3e3c 7072 6520 p:3119

    ..bool have
    │ │ │ -00050460: 5f61 6c6c 203d 2074 7275 653b 0a0a 0909  _all = true;....
    │ │ │ -00050470: 666f 7220 2861 7574 6f20 636f 6e73 7420  for (auto const 
    │ │ │ -00050480: 7069 6563 6520 3a20 6578 7465 6e74 5f66  piece : extent_f
    │ │ │ -00050490: 6f72 2874 6869 735f 6578 7465 6e74 2929  or(this_extent))
    │ │ │ -000504a0: 0a09 097b 0a09 0909 6966 2028 7069 6563  ...{....if (piec
    │ │ │ -000504b0: 6520 3d3d 2070 2920 636f 6e74 696e 7565  e == p) continue
    │ │ │ -000504c0: 3b0a 0a09 0909 6966 2028 216d 5f70 6965  ;.....if (!m_pie
    │ │ │ -000504d0: 6365 5f6d 6170 5b70 6965 6365 5d2e 666c  ce_map[piece].fl
    │ │ │ -000504e0: 7573 6865 6428 2929 2068 6176 655f 616c  ushed()) have_al
    │ │ │ -000504f0: 6c20 3d20 6661 6c73 653b 0a0a 0909 092f  l = false;...../
    │ │ │ -00050500: 2f20 6966 2061 7420 6c65 6173 7420 6f6e  / if at least on
    │ │ │ -00050510: 6520 7069 6563 6520 696e 2074 6869 7320  e piece in this 
    │ │ │ -00050520: 6578 7465 6e74 2068 6173 2061 2064 6966  extent has a dif
    │ │ │ -00050530: 6665 7265 6e74 2070 7269 6f72 6974 7920  ferent priority 
    │ │ │ -00050540: 7468 616e 0a09 0909 2f2f 2074 6865 206f  than....// the o
    │ │ │ -00050550: 6e65 2077 6520 6a75 7374 2073 7461 7274  ne we just start
    │ │ │ -00050560: 6564 2064 6f77 6e6c 6f61 6469 6e67 2c20  ed downloading, 
    │ │ │ -00050570: 646f 6e27 7420 6372 6561 7465 2061 6e20  don't create an 
    │ │ │ -00050580: 6166 6669 6e69 7479 2066 6f72 0a09 0909  affinity for....
    │ │ │ -00050590: 2f2f 2061 646a 6163 656e 7420 7069 6563  // adjacent piec
    │ │ │ -000505a0: 6573 2e20 5468 6973 2070 726f 6261 626c  es. This probabl
    │ │ │ -000505b0: 7920 6d65 616e 7320 7468 6520 7069 6563  y means the piec
    │ │ │ -000505c0: 6573 2062 656c 6f6e 6720 746f 2064 6966  es belong to dif
    │ │ │ -000505d0: 6665 7265 6e74 0a09 0909 2f2f 2066 696c  ferent....// fil
    │ │ │ -000505e0: 6573 2c20 6f72 2074 6861 7420 736f 6d65  es, or that some
    │ │ │ -000505f0: 206f 7468 6572 206d 6563 6861 6e69 736d   other mechanism
    │ │ │ -00050600: 2064 6574 6572 6d69 6e69 6e67 2074 6865   determining the
    │ │ │ -00050610: 2070 7269 6f72 6974 7920 7368 6f75 6c64   priority should
    │ │ │ -00050620: 0a09 0909 2f2f 2074 616b 6520 7072 6563  ....// take prec
    │ │ │ -00050630: 6564 656e 6365 2e0a 0909 0969 6620 2870  edence.....if (p
    │ │ │ -00050640: 6965 6365 5f70 7269 6f72 6974 7928 7069  iece_priority(pi
    │ │ │ -00050650: 6563 6529 2021 3d20 7468 6973 5f70 7269  ece) != this_pri
    │ │ │ -00050660: 6f29 2072 6574 7572 6e3b 0a09 097d 0a0a  o) return;...}..
    │ │ │ -00050670: 0909 2f2f 2069 6620 7765 2061 6c72 6561  ..// if we alrea
    │ │ │ -00050680: 6479 2068 6176 6520 616c 6c20 7468 6520  dy have all the 
    │ │ │ -00050690: 2a6f 7468 6572 2a20 7069 6563 6573 2069  *other* pieces i
    │ │ │ -000506a0: 6e20 7468 6973 2065 7874 656e 742c 2074  n this extent, t
    │ │ │ -000506b0: 6865 7265 2773 206e 6f0a 0909 2f2f 206e  here's no...// n
    │ │ │ -000506c0: 6565 6420 746f 2069 6e66 6c61 7465 2074  eed to inflate t
    │ │ │ -000506d0: 6865 6972 2070 7269 6f72 6974 6965 730a  heir priorities.
    │ │ │ -000506e0: 0909 6966 2028 6861 7665 5f61 6c6c 2920  ..if (have_all) 
    │ │ │ -000506f0: 7265 7475 726e 3b0a 0a3c 6469 7620 7374  return;..
    ..if (m_r │ │ │ -00050730: 6563 656e 745f 6578 7465 6e74 732e 7369 ecent_extents.si │ │ │ -00050740: 7a65 2829 2026 6c74 3b20 3529 0a3c 2f64 ze() < 5)....m_recent_e │ │ │ -00050760: 7874 656e 7473 2e70 7573 685f 6261 636b xtents.push_back │ │ │ -00050770: 2874 6869 735f 6578 7465 6e74 293b 0a0a (this_extent);.. │ │ │ -00050780: 0909 2f2f 206c 696d 6974 2074 6865 206e ..// limit the n │ │ │ -00050790: 756d 6265 7220 6f66 2065 7874 656e 7420 umber of extent │ │ │ -000507a0: 6166 6669 6e69 7469 6573 2061 6374 6976 affinities activ │ │ │ -000507b0: 6520 6174 2061 6e79 2067 6976 656e 2074 e at any given t │ │ │ -000507c0: 696d 6520 746f 206c 696d 6974 0a09 092f ime to limit.../ │ │ │ -000507d0: 2f20 7468 6520 636f 7374 206f 6620 6368 / the cost of ch │ │ │ -000507e0: 6563 6b69 6e67 2074 6865 6d2e 2041 6c73 ecking them. Als │ │ │ -000507f0: 6f2c 2064 6f6e 2774 2072 6570 6c61 6365 o, don't replace │ │ │ -00050800: 2074 6865 6d2c 2063 6f6d 6d69 7420 746f them, commit to │ │ │ -00050810: 0a09 092f 2f20 6669 6e69 7368 696e 6720 ...// finishing │ │ │ -00050820: 7468 656d 2062 6566 6f72 6520 7374 6172 them before star │ │ │ -00050830: 7469 6e67 2061 6e6f 7468 6572 2065 7874 ting another ext │ │ │ -00050840: 656e 742e 2054 6869 7320 6973 2061 6e61 ent. This is ana │ │ │ -00050850: 6c6f 676f 7573 2074 6f0a 0909 2f2f 206c logous to...// l │ │ │ -00050860: 696d 6974 696e 6720 7468 6520 6e75 6d62 imiting the numb │ │ │ -00050870: 6572 206f 6620 7061 7274 6961 6c20 7069 er of partial pi │ │ │ -00050880: 6563 6573 2e0a 097d 0a0a 092f 2f20 6f70 eces...}...// op │ │ │ -00050890: 7469 6f6e 7320 6d61 7920 6265 2030 206f tions may be 0 o │ │ │ -000508a0: 7220 7069 6563 655f 7069 636b 6572 3a3a r piece_picker:: │ │ │ -000508b0: 7265 7665 7273 650a 092f 2f20 7265 7475 reverse..// retu │ │ │ -000508c0: 726e 7320 6661 6c73 6520 6966 2074 6865 rns false if the │ │ │ -000508d0: 2062 6c6f 636b 2063 6f75 6c64 206e 6f74 block could not │ │ │ -000508e0: 2062 6520 6d61 726b 6564 2061 7320 646f be marked as do │ │ │ -000508f0: 776e 6c6f 6164 696e 670a 0962 6f6f 6c20 wnloading..bool │ │ │ -00050900: 7069 6563 655f 7069 636b 6572 3a3a 6d61 piece_picker::ma │ │ │ -00050910: 726b 5f61 735f 646f 776e 6c6f 6164 696e rk_as_downloadin │ │ │ -00050920: 6728 7069 6563 655f 626c 6f63 6b20 636f g(piece_block co │ │ │ -00050930: 6e73 7420 626c 6f63 6b0a 0909 2c20 6175 nst block..., au │ │ │ -00050940: 783a 3a74 6f72 7265 6e74 5f70 6565 722a x::torrent_peer* │ │ │ -00050950: 2070 6565 722c 2070 6963 6b65 725f 6f70 peer, picker_op │ │ │ -00050960: 7469 6f6e 735f 7420 636f 6e73 7420 6f70 tions_t const op │ │ │ -00050970: 7469 6f6e 7329 0a09 7b0a 2369 6664 6566 tions)..{.#ifdef │ │ │ -00050980: 2054 4f52 5245 4e54 5f50 4943 4b45 525f TORRENT_PICKER_ │ │ │ -00050990: 4c4f 470a 0909 7374 643a 3a63 6572 7220 LOG...std::cerr │ │ │ -000509a0: 266c 743b 266c 743b 2022 5b22 2026 6c74 << "[" < │ │ │ -000509b0: 3b26 6c74 3b20 7468 6973 2026 6c74 3b26 ;< this <& │ │ │ -000509c0: 6c74 3b20 225d 2022 2026 6c74 3b26 6c74 lt; "] " << │ │ │ -000509d0: 3b20 226d 6172 6b5f 6173 5f64 6f77 6e6c ; "mark_as_downl │ │ │ -000509e0: 6f61 6469 6e67 2820 7b22 0a09 0909 266c oading( {"....&l │ │ │ -000509f0: 743b 266c 743b 2062 6c6f 636b 2e70 6965 t;< block.pie │ │ │ -00050a00: 6365 5f69 6e64 6578 2026 6c74 3b26 6c74 ce_index << │ │ │ -00050a10: 3b20 222c 2022 2026 6c74 3b26 6c74 3b20 ; ", " << │ │ │ -00050a20: 626c 6f63 6b2e 626c 6f63 6b5f 696e 6465 block.block_inde │ │ │ -00050a30: 7820 266c 743b 266c 743b 2022 7d20 2922 x << "} )" │ │ │ -00050a40: 2026 6c74 3b26 6c74 3b20 7374 643a 3a65 << std::e │ │ │ -00050a50: 6e64 6c3b 0a23 656e 6469 660a 0a09 0954 ndl;.#endif....T │ │ │ -00050a60: 4f52 5245 4e54 5f41 5353 4552 5428 7065 ORRENT_ASSERT(pe │ │ │ -00050a70: 6572 203d 3d20 6e75 6c6c 7074 7220 7c7c er == nullptr || │ │ │ -00050a80: 2070 6565 722d 2667 743b 696e 5f75 7365 peer->in_use │ │ │ -00050a90: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ -00050aa0: 4552 5428 626c 6f63 6b2e 626c 6f63 6b5f ERT(block.block_ │ │ │ -00050ab0: 696e 6465 7820 213d 2070 6965 6365 5f62 index != piece_b │ │ │ -00050ac0: 6c6f 636b 3a3a 696e 7661 6c69 642e 626c lock::invalid.bl │ │ │ -00050ad0: 6f63 6b5f 696e 6465 7829 3b0a 0909 544f ock_index);...TO │ │ │ -00050ae0: 5252 454e 545f 4153 5345 5254 2862 6c6f RRENT_ASSERT(blo │ │ │ -00050af0: 636b 2e70 6965 6365 5f69 6e64 6578 2021 ck.piece_index ! │ │ │ -00050b00: 3d20 7069 6563 655f 626c 6f63 6b3a 3a69 = piece_block::i │ │ │ -00050b10: 6e76 616c 6964 2e70 6965 6365 5f69 6e64 nvalid.piece_ind │ │ │ -00050b20: 6578 293b 0a09 0954 4f52 5245 4e54 5f41 ex);...TORRENT_A │ │ │ -00050b30: 5353 4552 5428 626c 6f63 6b2e 7069 6563 SSERT(block.piec │ │ │ -00050b40: 655f 696e 6465 7820 266c 743b 206d 5f70 e_index < m_p │ │ │ -00050b50: 6965 6365 5f6d 6170 2e65 6e64 5f69 6e64 iece_map.end_ind │ │ │ -00050b60: 6578 2829 293b 0a09 0954 4f52 5245 4e54 ex());...TORRENT │ │ │ -00050b70: 5f41 5353 4552 5428 626c 6f63 6b2e 626c _ASSERT(block.bl │ │ │ -00050b80: 6f63 6b5f 696e 6465 7820 266c 743b 2062 ock_index < b │ │ │ -00050b90: 6c6f 636b 735f 696e 5f70 6965 6365 2862 locks_in_piece(b │ │ │ -00050ba0: 6c6f 636b 2e70 6965 6365 5f69 6e64 6578 lock.piece_index │ │ │ -00050bb0: 2929 3b0a 0909 544f 5252 454e 545f 4153 ));...TORRENT_AS │ │ │ -00050bc0: 5345 5254 2821 6d5f 7069 6563 655f 6d61 SERT(!m_piece_ma │ │ │ -00050bd0: 705b 626c 6f63 6b2e 7069 6563 655f 696e p[block.piece_in │ │ │ -00050be0: 6465 785d 2e66 6c75 7368 6564 2829 293b dex].flushed()); │ │ │ -00050bf0: 0a0a 0909 7069 6563 655f 706f 7326 616d ....piece_pos&am │ │ │ -00050c00: 703b 2070 203d 206d 5f70 6965 6365 5f6d p; p = m_piece_m │ │ │ -00050c10: 6170 5b62 6c6f 636b 2e70 6965 6365 5f69 ap[block.piece_i │ │ │ -00050c20: 6e64 6578 5d3b 0a09 0969 6620 2870 2e64 ndex];...if (p.d │ │ │ -00050c30: 6f77 6e6c 6f61 645f 7175 6575 6528 2920 ownload_queue() │ │ │ -00050c40: 3d3d 2070 6965 6365 5f70 6f73 3a3a 7069 == piece_pos::pi │ │ │ -00050c50: 6563 655f 6f70 656e 290a 0909 7b0a 2369 ece_open)...{.#i │ │ │ -00050c60: 6664 6566 2054 4f52 5245 4e54 5f45 5850 fdef TORRENT_EXP │ │ │ -00050c70: 454e 5349 5645 5f49 4e56 4152 4941 4e54 ENSIVE_INVARIANT │ │ │ -00050c80: 5f43 4845 434b 530a 0909 0949 4e56 4152 _CHECKS....INVAR │ │ │ -00050c90: 4941 4e54 5f43 4845 434b 3b0a 3c2f 7072 IANT_CHECK;.rel │ │ │ -00050cd0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/st │ │ │ -00050d10: 6f72 6167 655f 7574 696c 732e 6370 703a orage_utils.cpp: │ │ │ -00050d20: 3132 333c 2f61 3e3c 2f74 643e 3c74 643e 123 │ │ │ -00050d30: 6964 6561 6c6c 792c 2069 6620 7765 2065 ideally, if we e │ │ │ -00050d40: 6e64 2075 7020 636f 7079 696e 6720 6669 nd up copying fi │ │ │ -00050d50: 6c65 7320 6265 6361 7573 6520 6f66 2061 les because of a │ │ │ -00050d60: 206d 6f76 6520 6163 726f 7373 2076 6f6c move across vol │ │ │ -00050d70: 756d 6573 2c20 7468 6520 736f 7572 6365 umes, the source │ │ │ -00050d80: 2073 686f 756c 6420 6e6f 7420 6265 2064 should not be d │ │ │ -00050d90: 656c 6574 6564 2075 6e74 696c 2074 6865 eleted until the │ │ │ -00050da0: 7927 7665 2061 6c6c 2062 6565 6e20 636f y've all been co │ │ │ -00050db0: 7069 6564 2e20 5468 6174 2077 6f75 6c64 pied. That would │ │ │ -00050dc0: 206c 6574 2075 7320 726f 6c6c 6261 636b let us rollback │ │ │ -00050dd0: 2077 6974 6820 6869 6768 6572 2063 6f6e with higher con │ │ │ -00050de0: 6669 6465 6e63 652e 3c2f 7464 3e3c 2f74 fidence.

    ideally, i │ │ │ -00050e40: 6620 7765 2065 6e64 2075 7020 636f 7079 f we end up copy │ │ │ -00050e50: 696e 6720 6669 6c65 7320 6265 6361 7573 ing files becaus │ │ │ -00050e60: 6520 6f66 2061 206d 6f76 6520 6163 726f e of a move acro │ │ │ -00050e70: 7373 0a76 6f6c 756d 6573 2c20 7468 6520 ss.volumes, the │ │ │ -00050e80: 736f 7572 6365 2073 686f 756c 6420 6e6f source should no │ │ │ -00050e90: 7420 6265 2064 656c 6574 6564 2075 6e74 t be deleted unt │ │ │ -00050ea0: 696c 2074 6865 7927 7665 2061 6c6c 2062 il they've all b │ │ │ -00050eb0: 6565 6e0a 636f 7069 6564 2e20 5468 6174 een.copied. That │ │ │ -00050ec0: 2077 6f75 6c64 206c 6574 2075 7320 726f would let us ro │ │ │ -00050ed0: 6c6c 6261 636b 2077 6974 6820 6869 6768 llback with high │ │ │ -00050ee0: 6572 2063 6f6e 6669 6465 6e63 652e 3c2f er confidence.

    ../src/st │ │ │ -00050f00: 6f72 6167 655f 7574 696c 732e 6370 703a orage_utils.cpp: │ │ │ -00050f10: 3132 333c 2f68 343e 3c70 7265 2073 7479 123

    ..// later...a
    │ │ │ -00050f60: 7578 3a3a 7665 6374 6f72 266c 743b 626f  ux::vector<bo
    │ │ │ -00050f70: 6f6c 2c20 6669 6c65 5f69 6e64 6578 5f74  ol, file_index_t
    │ │ │ -00050f80: 2667 743b 2063 6f70 6965 645f 6669 6c65  > copied_file
    │ │ │ -00050f90: 7328 7374 643a 3a73 697a 655f 7428 662e  s(std::size_t(f.
    │ │ │ -00050fa0: 6e75 6d5f 6669 6c65 7328 2929 2c20 6661  num_files()), fa
    │ │ │ -00050fb0: 6c73 6529 3b0a 0a09 092f 2f20 7472 6163  lse);....// trac
    │ │ │ -00050fc0: 6b20 686f 7720 6661 7220 7765 2067 6f74  k how far we got
    │ │ │ -00050fd0: 2069 6e20 6361 7365 206f 6620 616e 2065   in case of an e
    │ │ │ -00050fe0: 7272 6f72 0a09 0966 696c 655f 696e 6465  rror...file_inde
    │ │ │ -00050ff0: 785f 7420 6669 6c65 5f69 6e64 6578 7b7d  x_t file_index{}
    │ │ │ -00051000: 3b0a 0909 666f 7220 2861 7574 6f20 636f  ;...for (auto co
    │ │ │ -00051010: 6e73 7420 6920 3a20 662e 6669 6c65 5f72  nst i : f.file_r
    │ │ │ -00051020: 616e 6765 2829 290a 0909 7b0a 0909 092f  ange())...{..../
    │ │ │ -00051030: 2f20 6669 6c65 7320 6d6f 7665 6420 6f75  / files moved ou
    │ │ │ -00051040: 7420 746f 2061 6273 6f6c 7574 6520 7061  t to absolute pa
    │ │ │ -00051050: 7468 7320 6172 6520 6e6f 7420 6d6f 7665  ths are not move
    │ │ │ -00051060: 640a 0909 0969 6620 2866 2e66 696c 655f  d....if (f.file_
    │ │ │ -00051070: 6162 736f 6c75 7465 5f70 6174 6828 6929  absolute_path(i)
    │ │ │ -00051080: 2920 636f 6e74 696e 7565 3b0a 0a09 0909  ) continue;.....
    │ │ │ -00051090: 7374 643a 3a73 7472 696e 6720 636f 6e73  std::string cons
    │ │ │ -000510a0: 7420 6f6c 645f 7061 7468 203d 2063 6f6d  t old_path = com
    │ │ │ -000510b0: 6269 6e65 5f70 6174 6828 7361 7665 5f70  bine_path(save_p
    │ │ │ -000510c0: 6174 682c 2066 2e66 696c 655f 7061 7468  ath, f.file_path
    │ │ │ -000510d0: 2869 2929 3b0a 0909 0973 7464 3a3a 7374  (i));....std::st
    │ │ │ -000510e0: 7269 6e67 2063 6f6e 7374 206e 6577 5f70  ring const new_p
    │ │ │ -000510f0: 6174 6820 3d20 636f 6d62 696e 655f 7061  ath = combine_pa
    │ │ │ -00051100: 7468 286e 6577 5f73 6176 655f 7061 7468  th(new_save_path
    │ │ │ -00051110: 2c20 662e 6669 6c65 5f70 6174 6828 6929  , f.file_path(i)
    │ │ │ -00051120: 293b 0a0a 0909 0965 7272 6f72 5f63 6f64  );.....error_cod
    │ │ │ -00051130: 6520 6967 6e6f 7265 3b0a 0909 0969 6620  e ignore;....if 
    │ │ │ -00051140: 2866 6c61 6773 203d 3d20 6d6f 7665 5f66  (flags == move_f
    │ │ │ -00051150: 6c61 6773 5f74 3a3a 646f 6e74 5f72 6570  lags_t::dont_rep
    │ │ │ -00051160: 6c61 6365 2026 616d 703b 2661 6d70 3b20  lace && 
    │ │ │ -00051170: 6578 6973 7473 286e 6577 5f70 6174 682c  exists(new_path,
    │ │ │ -00051180: 2069 676e 6f72 6529 290a 0909 097b 0a09   ignore))....{..
    │ │ │ -00051190: 0909 0972 6574 207c 3d20 6469 736b 5f73  ...ret |= disk_s
    │ │ │ -000511a0: 7461 7475 733a 3a6e 6565 645f 6675 6c6c  tatus::need_full
    │ │ │ -000511b0: 5f63 6865 636b 3b0a 0909 0909 636f 6e74  _check;.....cont
    │ │ │ -000511c0: 696e 7565 3b0a 0909 097d 0a0a 3c64 6976  inue;....}..
    ...mov │ │ │ -00051200: 655f 6669 6c65 286f 6c64 5f70 6174 682c e_file(old_path, │ │ │ -00051210: 206e 6577 5f70 6174 682c 2065 6329 3b0a new_path, ec);. │ │ │ -00051220: 3c2f 6469 763e 0a09 0909 2f2f 2069 6620
    ....// if │ │ │ -00051230: 7468 6520 736f 7572 6365 2066 696c 6520 the source file │ │ │ -00051240: 646f 6573 6e27 7420 6578 6973 742e 2054 doesn't exist. T │ │ │ -00051250: 6861 7427 7320 6e6f 7420 6120 7072 6f62 hat's not a prob │ │ │ -00051260: 6c65 6d0a 0909 092f 2f20 7765 206a 7573 lem....// we jus │ │ │ -00051270: 7420 6967 6e6f 7265 2074 6861 7420 6669 t ignore that fi │ │ │ -00051280: 6c65 0a09 0909 6966 2028 6563 2e65 6320 le....if (ec.ec │ │ │ -00051290: 3d3d 2062 6f6f 7374 3a3a 7379 7374 656d == boost::system │ │ │ -000512a0: 3a3a 6572 7263 3a3a 6e6f 5f73 7563 685f ::errc::no_such_ │ │ │ -000512b0: 6669 6c65 5f6f 725f 6469 7265 6374 6f72 file_or_director │ │ │ -000512c0: 7929 0a09 0909 0965 632e 6563 2e63 6c65 y).....ec.ec.cle │ │ │ -000512d0: 6172 2829 3b0a 0909 0965 6c73 6520 6966 ar();....else if │ │ │ -000512e0: 2028 6563 0a09 0909 0926 616d 703b 2661 (ec.....&&a │ │ │ -000512f0: 6d70 3b20 6563 2e65 6320 213d 2062 6f6f mp; ec.ec != boo │ │ │ -00051300: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ -00051310: 3a3a 696e 7661 6c69 645f 6172 6775 6d65 ::invalid_argume │ │ │ -00051320: 6e74 0a09 0909 0926 616d 703b 2661 6d70 nt.....&& │ │ │ -00051330: 3b20 6563 2e65 6320 213d 2062 6f6f 7374 ; ec.ec != boost │ │ │ -00051340: 3a3a 7379 7374 656d 3a3a 6572 7263 3a3a ::system::errc:: │ │ │ -00051350: 7065 726d 6973 7369 6f6e 5f64 656e 6965 permission_denie │ │ │ -00051360: 6429 0a09 0909 7b0a 0909 0909 2f2f 206d d)....{.....// m │ │ │ -00051370: 6f76 696e 6720 7468 6520 6669 6c65 2066 oving the file f │ │ │ -00051380: 6169 6c65 640a 0909 0909 2f2f 206f 6e20 ailed.....// on │ │ │ -00051390: 4f53 582c 2074 6865 2065 7272 6f72 2077 OSX, the error w │ │ │ -000513a0: 6865 6e20 7472 7969 6e67 2074 6f20 7265 hen trying to re │ │ │ -000513b0: 6e61 6d65 2061 2066 696c 6520 6163 726f name a file acro │ │ │ -000513c0: 7373 2064 6966 6665 7265 6e74 0a09 0909 ss different.... │ │ │ -000513d0: 092f 2f20 766f 6c75 6d65 7320 6973 2045 .// volumes is E │ │ │ -000513e0: 5844 4556 2c20 7768 6963 6820 7769 6c6c XDEV, which will │ │ │ -000513f0: 206d 616b 6520 6974 2066 616c 6c20 6261 make it fall ba │ │ │ -00051400: 636b 2074 6f20 636f 7079 696e 672e 0a09 ck to copying... │ │ │ -00051410: 0909 0965 632e 6563 2e63 6c65 6172 2829 ...ec.ec.clear() │ │ │ -00051420: 3b0a 0909 0909 636f 7079 5f66 696c 6528 ;.....copy_file( │ │ │ -00051430: 6f6c 645f 7061 7468 2c20 6e65 775f 7061 old_path, new_pa │ │ │ -00051440: 7468 2c20 6563 293b 0a09 0909 0969 6620 th, ec);.....if │ │ │ -00051450: 2821 6563 2920 636f 7069 6564 5f66 696c (!ec) copied_fil │ │ │ -00051460: 6573 5b69 5d20 3d20 7472 7565 3b0a 0909 es[i] = true;... │ │ │ -00051470: 097d 0a0a 0909 0969 6620 2865 6329 0a09 .}.....if (ec).. │ │ │ -00051480: 0909 7b0a 0909 0909 6563 2e66 696c 6528 ..{.....ec.file( │ │ │ -00051490: 6929 3b0a 0909 0909 6669 6c65 5f69 6e64 i);.....file_ind │ │ │ -000514a0: 6578 203d 2069 3b0a 0909 0909 6272 6561 ex = i;.....brea │ │ │ -000514b0: 6b3b 0a09 0909 7d0a 0909 7d0a 0a09 0969 k;....}...}....i │ │ │ -000514c0: 6620 2821 6563 2026 616d 703b 2661 6d70 f (!ec && │ │ │ -000514d0: 3b20 6d6f 7665 5f70 6172 7466 696c 6529 ; move_partfile) │ │ │ -000514e0: 0a09 097b 0a09 0909 6572 726f 725f 636f ...{....error_co │ │ │ -000514f0: 6465 2065 3b0a 0909 096d 6f76 655f 7061 de e;....move_pa │ │ │ -00051500: 7274 6669 6c65 286e 6577 5f73 6176 655f rtfile(new_save_ │ │ │ -00051510: 7061 7468 2c20 6529 3b0a 0909 0969 6620 path, e);....if │ │ │ -00051520: 2865 290a 3c2f 7072 653e 3c2f 7464 3e3c (e).
    < │ │ │ -00051530: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00051560: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00051590: 2e2f 7372 632f 7374 6f72 6167 655f 7574 ./src/storage_ut │ │ │ -000515a0: 696c 732e 6370 703a 3433 313c 2f61 3e3c ils.cpp:431< │ │ │ -000515b0: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ -000515c0: 2073 6565 6d20 7265 6173 6f6e 6162 6c65 seem reasonable │ │ │ -000515d0: 2074 6f2c 2069 6e73 7465 6164 2c20 7365 to, instead, se │ │ │ -000515e0: 7420 7468 6520 6861 7665 5f70 6965 6365 t the have_piece │ │ │ -000515f0: 7320 6269 7473 2066 6f72 2074 6865 2070 s bits for the p │ │ │ -00051600: 6965 6365 7320 7265 7072 6573 656e 7469 ieces representi │ │ │ -00051610: 6e67 2074 6865 7365 2066 696c 6573 2c20 ng these files, │ │ │ -00051620: 616e 6420 7265 7375 6d65 2077 6974 6820 and resume with │ │ │ -00051630: 7468 6520 6e6f 726d 616c 206c 6f67 6963 the normal logic │ │ │ -00051640: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ -00051690: 2077 6f75 6c64 2073 6565 6d20 7265 6173 would seem reas │ │ │ -000516a0: 6f6e 6162 6c65 2074 6f2c 2069 6e73 7465 onable to, inste │ │ │ -000516b0: 6164 2c20 7365 7420 7468 6520 6861 7665 ad, set the have │ │ │ -000516c0: 5f70 6965 6365 7320 6269 7473 0a66 6f72 _pieces bits.for │ │ │ -000516d0: 2074 6865 2070 6965 6365 7320 7265 7072 the pieces repr │ │ │ -000516e0: 6573 656e 7469 6e67 2074 6865 7365 2066 esenting these f │ │ │ -000516f0: 696c 6573 2c20 616e 6420 7265 7375 6d65 iles, and resume │ │ │ -00051700: 2077 6974 6820 7468 6520 6e6f 726d 616c with the normal │ │ │ -00051710: 0a6c 6f67 6963 3c2f 6832 3e3c 6834 3e2e .logic

    . │ │ │ -00051720: 2e2f 7372 632f 7374 6f72 6167 655f 7574 ./src/storage_ut │ │ │ -00051730: 696c 732e 6370 703a 3433 313c 2f68 343e ils.cpp:431

    │ │ │ -00051740: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .....c
    │ │ │ -00051780: 6f6e 7469 6e75 653b 0a0a 0909 0909 7374  ontinue;......st
    │ │ │ -00051790: 643a 3a69 6e74 3634 5f74 2063 6f6e 7374  d::int64_t const
    │ │ │ -000517a0: 2073 697a 6520 3d20 6765 745f 6669 6c65   size = get_file
    │ │ │ -000517b0: 7369 7a65 2873 7461 742c 2066 696c 655f  size(stat, file_
    │ │ │ -000517c0: 696e 6465 782c 2066 730a 0909 0909 092c  index, fs......,
    │ │ │ -000517d0: 2073 6176 655f 7061 7468 2c20 6563 293b   save_path, ec);
    │ │ │ -000517e0: 0a09 0909 0969 6620 2873 697a 6520 266c  .....if (size &l
    │ │ │ -000517f0: 743b 2030 2920 7265 7475 726e 2066 616c  t; 0) return fal
    │ │ │ -00051800: 7365 3b0a 0a09 0909 0969 6620 2873 697a  se;......if (siz
    │ │ │ -00051810: 6520 266c 743b 2066 732e 6669 6c65 5f73  e < fs.file_s
    │ │ │ -00051820: 697a 6528 6669 6c65 5f69 6e64 6578 2929  ize(file_index))
    │ │ │ -00051830: 0a09 0909 097b 0a09 0909 0909 6563 2e65  .....{......ec.e
    │ │ │ -00051840: 6320 3d20 6572 726f 7273 3a3a 6d69 736d  c = errors::mism
    │ │ │ -00051850: 6174 6368 696e 675f 6669 6c65 5f73 697a  atching_file_siz
    │ │ │ -00051860: 653b 0a09 0909 0909 6563 2e66 696c 6528  e;......ec.file(
    │ │ │ -00051870: 6669 6c65 5f69 6e64 6578 293b 0a09 0909  file_index);....
    │ │ │ -00051880: 0909 6563 2e6f 7065 7261 7469 6f6e 203d  ..ec.operation =
    │ │ │ -00051890: 206f 7065 7261 7469 6f6e 5f74 3a3a 6368   operation_t::ch
    │ │ │ -000518a0: 6563 6b5f 7265 7375 6d65 3b0a 0909 0909  eck_resume;.....
    │ │ │ -000518b0: 0972 6574 7572 6e20 6661 6c73 653b 0a09  .return false;..
    │ │ │ -000518c0: 0909 097d 0a09 0909 7d0a 0909 0972 6574  ...}....}....ret
    │ │ │ -000518d0: 7572 6e20 7472 7565 3b0a 0909 7d0a 0a23  urn true;...}..#
    │ │ │ -000518e0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -000518f0: 4953 4142 4c45 5f4d 5554 4142 4c45 5f54  ISABLE_MUTABLE_T
    │ │ │ -00051900: 4f52 5245 4e54 530a 0909 2f2f 2061 6c77  ORRENTS...// alw
    │ │ │ -00051910: 6179 7320 7472 6967 6765 7220 6120 6675  ays trigger a fu
    │ │ │ -00051920: 6c6c 2072 6563 6865 636b 2077 6865 6e20  ll recheck when 
    │ │ │ -00051930: 7765 2070 756c 6c20 696e 2066 696c 6573  we pull in files
    │ │ │ -00051940: 2066 726f 6d20 6f74 6865 720a 0909 2f2f   from other...//
    │ │ │ -00051950: 2074 6f72 7265 6e74 732c 2076 6961 2068   torrents, via h
    │ │ │ -00051960: 6172 6420 6c69 6e6b 730a 3c64 6976 2073  ard links.
    ..if (ad │ │ │ -000519a0: 6465 645f 6669 6c65 7329 2072 6574 7572 ded_files) retur │ │ │ -000519b0: 6e20 6661 6c73 653b 0a3c 2f64 6976 3e23 n false;.
    # │ │ │ -000519c0: 656e 6469 660a 0a09 092f 2f20 7061 7273 endif....// pars │ │ │ -000519d0: 6520 6861 7665 2062 6974 6d61 736b 2e20 e have bitmask. │ │ │ -000519e0: 5665 7269 6679 2074 6861 7420 6669 6c65 Verify that file │ │ │ -000519f0: 7320 746f 7563 6865 6420 6279 2063 6f6d s touched by com │ │ │ -00051a00: 706c 6574 6564 2070 6965 6365 730a 0909 pleted pieces... │ │ │ -00051a10: 2f2f 2061 6374 7561 6c6c 7920 6578 6973 // actually exis │ │ │ -00051a20: 742e 2041 2063 6f6d 706c 6574 6564 2070 t. A completed p │ │ │ -00051a30: 6965 6365 206d 6179 2073 7061 6e20 6d75 iece may span mu │ │ │ -00051a40: 6c74 6970 6c65 2066 696c 6573 2e0a 0909 ltiple files.... │ │ │ -00051a50: 666f 7220 2866 696c 655f 696e 6465 785f for (file_index_ │ │ │ -00051a60: 7420 636f 6e73 7420 6669 6c65 5f69 6e64 t const file_ind │ │ │ -00051a70: 6578 203a 2066 732e 6669 6c65 5f72 616e ex : fs.file_ran │ │ │ -00051a80: 6765 2829 290a 0909 7b0a 0909 092f 2f20 ge())...{....// │ │ │ -00051a90: 6669 6c65 7320 7769 7468 2070 7269 6f72 files with prior │ │ │ -00051aa0: 6974 7920 7a65 726f 206d 6179 206e 6f74 ity zero may not │ │ │ -00051ab0: 2068 6176 6520 6265 656e 2073 6176 6564 have been saved │ │ │ -00051ac0: 2074 6f20 6469 736b 2061 7420 7468 6569 to disk at thei │ │ │ -00051ad0: 720a 0909 092f 2f20 6578 7065 6374 6564 r....// expected │ │ │ -00051ae0: 206c 6f63 6174 696f 6e2c 2062 7574 2069 location, but i │ │ │ -00051af0: 7320 6c69 6b65 6c79 2074 6f20 6265 2069 s likely to be i │ │ │ -00051b00: 6e20 6120 7061 7274 6669 6c65 2e20 4a75 n a partfile. Ju │ │ │ -00051b10: 7374 2065 7865 6d70 7420 6974 0a09 0909 st exempt it.... │ │ │ -00051b20: 2f2f 2066 726f 6d20 6368 6563 6b69 6e67 // from checking │ │ │ -00051b30: 0a09 0909 6966 2028 6669 6c65 5f69 6e64 ....if (file_ind │ │ │ -00051b40: 6578 2026 6c74 3b20 6669 6c65 5f70 7269 ex < file_pri │ │ │ -00051b50: 6f72 6974 792e 656e 645f 696e 6465 7828 ority.end_index( │ │ │ -00051b60: 290a 0909 0909 2661 6d70 3b26 616d 703b ).....&& │ │ │ -00051b70: 2066 696c 655f 7072 696f 7269 7479 5b66 file_priority[f │ │ │ -00051b80: 696c 655f 696e 6465 785d 203d 3d20 646f ile_index] == do │ │ │ -00051b90: 6e74 5f64 6f77 6e6c 6f61 6429 0a09 0909 nt_download).... │ │ │ -00051ba0: 0963 6f6e 7469 6e75 653b 0a0a 0909 0969 .continue;.....i │ │ │ -00051bb0: 6620 2866 732e 7061 645f 6669 6c65 5f61 f (fs.pad_file_a │ │ │ -00051bc0: 7428 6669 6c65 5f69 6e64 6578 2929 2063 t(file_index)) c │ │ │ -00051bd0: 6f6e 7469 6e75 653b 0a09 0909 6966 2028 ontinue;....if ( │ │ │ -00051be0: 6673 2e66 696c 655f 7369 7a65 2866 696c fs.file_size(fil │ │ │ -00051bf0: 655f 696e 6465 7829 203d 3d20 3029 2063 e_index) == 0) c │ │ │ -00051c00: 6f6e 7469 6e75 653b 0a0a 0909 0961 7574 ontinue;.....aut │ │ │ -00051c10: 6f20 636f 6e73 7420 7069 6563 655f 7261 o const piece_ra │ │ │ -00051c20: 6e67 6520 3d20 6175 783a 3a66 696c 655f nge = aux::file_ │ │ │ -00051c30: 7069 6563 655f 7261 6e67 655f 696e 636c piece_range_incl │ │ │ -00051c40: 7573 6976 6528 6673 2c20 6669 6c65 5f69 usive(fs, file_i │ │ │ -00051c50: 6e64 6578 293b 0a09 0909 7069 6563 655f ndex);....piece_ │ │ │ -00051c60: 696e 6465 785f 7420 636f 6e73 7420 7374 index_t const st │ │ │ -00051c70: 6172 745f 7069 6563 6520 3d20 7069 6563 art_piece = piec │ │ │ -00051c80: 655f 7261 6e67 652e 5f62 6567 696e 3b0a e_range._begin;. │ │ │ -00051c90: 0a09 0909 7069 6563 655f 696e 6465 785f ....piece_index_ │ │ │ -00051ca0: 7420 636f 6e73 7420 656e 645f 7069 6563 t const end_piec │ │ │ -00051cb0: 6520 3d20 7374 643a 3a6d 696e 2870 6965 e = std::min(pie │ │ │ -00051cc0: 6365 5f72 616e 6765 2e5f 656e 642c 2072 ce_range._end, r │ │ │ -00051cd0: 642e 6861 7665 5f70 6965 6365 732e 656e d.have_pieces.en │ │ │ -00051ce0: 645f 696e 6465 7828 2929 3b0a 0a09 0909 d_index());..... │ │ │ -00051cf0: 626f 6f6c 2068 6173 5f63 6f6d 706c 6574 bool has_complet │ │ │ -00051d00: 6564 5f72 6573 756d 655f 7069 6563 6520 ed_resume_piece │ │ │ -00051d10: 3d20 6661 6c73 653b 0a09 0909 666f 7220 = false;....for │ │ │ -00051d20: 2870 6965 6365 5f69 6e64 6578 5f74 2070 (piece_index_t p │ │ │ -00051d30: 6965 6365 203d 2073 7461 7274 5f70 6965 iece = start_pie │ │ │ -00051d40: 6365 3b20 7069 6563 6520 266c 743b 2065 ce; piece < e │ │ │ -00051d50: 6e64 5f70 6965 6365 3b20 2b2b 7069 6563 nd_piece; ++piec │ │ │ -00051d60: 6529 0a09 0909 7b0a 0909 0909 6966 2028 e)....{.....if ( │ │ │ -00051d70: 2172 642e 6861 7665 5f70 6965 6365 732e !rd.have_pieces. │ │ │ -00051d80: 6765 745f 6269 7428 7069 6563 6529 2920 get_bit(piece)) │ │ │ -00051d90: 636f 6e74 696e 7565 3b0a 0909 0909 6861 continue;.....ha │ │ │ -00051da0: 735f 636f 6d70 6c65 7465 645f 7265 7375 s_completed_resu │ │ │ -00051db0: 6d65 5f70 6965 6365 203d 2074 7275 653b me_piece = true; │ │ │ -00051dc0: 0a09 0909 0962 7265 616b 3b0a 0909 097d .....break;....} │ │ │ -00051dd0: 0a0a 0909 0969 6620 2821 6861 735f 636f .....if (!has_co │ │ │ -00051de0: 6d70 6c65 7465 645f 7265 7375 6d65 5f70 mpleted_resume_p │ │ │ -00051df0: 6965 6365 2920 636f 6e74 696e 7565 3b0a iece) continue;. │ │ │ -00051e00: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00051e10: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00051e40: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00051e70: 632f 6469 7361 626c 6564 5f64 6973 6b5f c/disabled_disk_ │ │ │ -00051e80: 696f 2e63 7070 3a38 333c 2f61 3e3c 2f74 io.cpp:83it would b │ │ │ -00051ea0: 6520 6e69 6365 2074 6f20 7265 7475 726e e nice to return │ │ │ -00051eb0: 2061 2076 616c 6964 2068 6173 6820 6f66 a valid hash of │ │ │ -00051ec0: 207a 6572 6f65 7320 6865 7265 3c2f 7464 zeroes here

    it wou │ │ │ -00051f20: 6c64 2062 6520 6e69 6365 2074 6f20 7265 ld be nice to re │ │ │ -00051f30: 7475 726e 2061 2076 616c 6964 2068 6173 turn a valid has │ │ │ -00051f40: 6820 6f66 207a 6572 6f65 7320 6865 7265 h of zeroes here │ │ │ -00051f50: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00051f60: 6469 7361 626c 6564 5f64 6973 6b5f 696f disabled_disk_io │ │ │ -00051f70: 2e63 7070 3a38 333c 2f68 343e 3c70 7265 .cpp:83

    ..});..}..
    │ │ │ -00051fc0: 0962 6f6f 6c20 6173 796e 635f 7772 6974  .bool async_writ
    │ │ │ -00051fd0: 6528 7374 6f72 6167 655f 696e 6465 785f  e(storage_index_
    │ │ │ -00051fe0: 740a 0909 2c20 7065 6572 5f72 6571 7565  t..., peer_reque
    │ │ │ -00051ff0: 7374 2063 6f6e 7374 2661 6d70 3b20 720a  st const& r.
    │ │ │ -00052000: 0909 2c20 6368 6172 2063 6f6e 7374 2a2c  .., char const*,
    │ │ │ -00052010: 2073 7464 3a3a 7368 6172 6564 5f70 7472   std::shared_ptr
    │ │ │ -00052020: 266c 743b 6469 736b 5f6f 6273 6572 7665  <disk_observe
    │ │ │ -00052030: 7226 6774 3b0a 0909 2c20 7374 643a 3a66  r>..., std::f
    │ │ │ -00052040: 756e 6374 696f 6e26 6c74 3b76 6f69 6428  unction<void(
    │ │ │ -00052050: 7374 6f72 6167 655f 6572 726f 7220 636f  storage_error co
    │ │ │ -00052060: 6e73 7426 616d 703b 2926 6774 3b20 6861  nst&)> ha
    │ │ │ -00052070: 6e64 6c65 720a 0909 2c20 6469 736b 5f6a  ndler..., disk_j
    │ │ │ -00052080: 6f62 5f66 6c61 6773 5f74 2920 6f76 6572  ob_flags_t) over
    │ │ │ -00052090: 7269 6465 0a09 7b0a 0909 544f 5252 454e  ride..{...TORREN
    │ │ │ -000520a0: 545f 4153 5345 5254 2872 2e6c 656e 6774  T_ASSERT(r.lengt
    │ │ │ -000520b0: 6820 266c 743b 3d20 6465 6661 756c 745f  h <= default_
    │ │ │ -000520c0: 626c 6f63 6b5f 7369 7a65 293b 0a09 0954  block_size);...T
    │ │ │ -000520d0: 4f52 5245 4e54 5f55 4e55 5345 4428 7229  ORRENT_UNUSED(r)
    │ │ │ -000520e0: 3b0a 0a09 0970 6f73 7428 6d5f 696f 732c  ;....post(m_ios,
    │ │ │ -000520f0: 205b 6820 3d20 7374 643a 3a6d 6f76 6528   [h = std::move(
    │ │ │ -00052100: 6861 6e64 6c65 7229 5d20 7b20 6828 7374  handler)] { h(st
    │ │ │ -00052110: 6f72 6167 655f 6572 726f 727b 7d29 3b20  orage_error{}); 
    │ │ │ -00052120: 7d29 3b0a 0909 7265 7475 726e 2066 616c  });...return fal
    │ │ │ -00052130: 7365 3b0a 097d 0a0a 0976 6f69 6420 6173  se;..}...void as
    │ │ │ -00052140: 796e 635f 6861 7368 2873 746f 7261 6765  ync_hash(storage
    │ │ │ -00052150: 5f69 6e64 6578 5f74 0a09 092c 2070 6965  _index_t..., pie
    │ │ │ -00052160: 6365 5f69 6e64 6578 5f74 2070 6965 6365  ce_index_t piece
    │ │ │ -00052170: 2c20 7370 616e 266c 743b 7368 6132 3536  , span<sha256
    │ │ │ -00052180: 5f68 6173 6826 6774 3b2c 2064 6973 6b5f  _hash>, disk_
    │ │ │ -00052190: 6a6f 625f 666c 6167 735f 740a 0909 2c20  job_flags_t..., 
    │ │ │ -000521a0: 7374 643a 3a66 756e 6374 696f 6e26 6c74  std::function<
    │ │ │ -000521b0: 3b76 6f69 6428 7069 6563 655f 696e 6465  ;void(piece_inde
    │ │ │ -000521c0: 785f 742c 2073 6861 315f 6861 7368 2063  x_t, sha1_hash c
    │ │ │ -000521d0: 6f6e 7374 2661 6d70 3b2c 2073 746f 7261  onst&, stora
    │ │ │ -000521e0: 6765 5f65 7272 6f72 2063 6f6e 7374 2661  ge_error const&a
    │ │ │ -000521f0: 6d70 3b29 2667 743b 2068 616e 646c 6572  mp;)> handler
    │ │ │ -00052200: 2920 6f76 6572 7269 6465 0a09 7b0a 3c64  ) override..{...po
    │ │ │ -00052240: 7374 286d 5f69 6f73 2c20 5b68 203d 2073  st(m_ios, [h = s
    │ │ │ -00052250: 7464 3a3a 6d6f 7665 2868 616e 646c 6572  td::move(handler
    │ │ │ -00052260: 292c 2070 6965 6365 5d20 7b20 6828 7069  ), piece] { h(pi
    │ │ │ -00052270: 6563 652c 2073 6861 315f 6861 7368 7b7d  ece, sha1_hash{}
    │ │ │ -00052280: 2c20 7374 6f72 6167 655f 6572 726f 727b  , storage_error{
    │ │ │ -00052290: 7d29 3b20 7d29 3b0a 3c2f 6469 763e 097d  }); });.
    .} │ │ │ -000522a0: 0a0a 0976 6f69 6420 6173 796e 635f 6861 ...void async_ha │ │ │ -000522b0: 7368 3228 7374 6f72 6167 655f 696e 6465 sh2(storage_inde │ │ │ -000522c0: 785f 742c 2070 6965 6365 5f69 6e64 6578 x_t, piece_index │ │ │ -000522d0: 5f74 2070 6965 6365 2c20 696e 740a 0909 _t piece, int... │ │ │ -000522e0: 2c20 6469 736b 5f6a 6f62 5f66 6c61 6773 , disk_job_flags │ │ │ -000522f0: 5f74 0a09 092c 2073 7464 3a3a 6675 6e63 _t..., std::func │ │ │ -00052300: 7469 6f6e 266c 743b 766f 6964 2870 6965 tion<void(pie │ │ │ -00052310: 6365 5f69 6e64 6578 5f74 2c20 7368 6132 ce_index_t, sha2 │ │ │ -00052320: 3536 5f68 6173 6820 636f 6e73 7426 616d 56_hash const&am │ │ │ -00052330: 703b 2c20 7374 6f72 6167 655f 6572 726f p;, storage_erro │ │ │ -00052340: 7220 636f 6e73 7426 616d 703b 2926 6774 r const&)> │ │ │ -00052350: 3b20 6861 6e64 6c65 7229 206f 7665 7272 ; handler) overr │ │ │ -00052360: 6964 650a 097b 0a09 0970 6f73 7428 6d5f ide..{...post(m_ │ │ │ -00052370: 696f 732c 205b 6820 3d20 7374 643a 3a6d ios, [h = std::m │ │ │ -00052380: 6f76 6528 6861 6e64 6c65 7229 2c20 7069 ove(handler), pi │ │ │ -00052390: 6563 655d 2829 207b 2068 2870 6965 6365 ece]() { h(piece │ │ │ -000523a0: 2c20 7368 6132 3536 5f68 6173 687b 7d2c , sha256_hash{}, │ │ │ -000523b0: 2073 746f 7261 6765 5f65 7272 6f72 7b7d storage_error{} │ │ │ -000523c0: 293b 207d 293b 0a09 7d0a 0a09 766f 6964 ); });..}...void │ │ │ -000523d0: 2061 7379 6e63 5f6d 6f76 655f 7374 6f72 async_move_stor │ │ │ -000523e0: 6167 6528 7374 6f72 6167 655f 696e 6465 age(storage_inde │ │ │ -000523f0: 785f 740a 0909 2c20 7374 643a 3a73 7472 x_t..., std::str │ │ │ -00052400: 696e 6720 702c 206d 6f76 655f 666c 6167 ing p, move_flag │ │ │ -00052410: 735f 740a 0909 2c20 7374 643a 3a66 756e s_t..., std::fun │ │ │ -00052420: 6374 696f 6e26 6c74 3b76 6f69 6428 7374 ction<void(st │ │ │ -00052430: 6174 7573 5f74 2c20 7374 643a 3a73 7472 atus_t, std::str │ │ │ -00052440: 696e 6720 636f 6e73 7426 616d 703b 2c20 ing const&, │ │ │ -00052450: 7374 6f72 6167 655f 6572 726f 7220 636f storage_error co │ │ │ -00052460: 6e73 7426 616d 703b 2926 6774 3b20 6861 nst&)> ha │ │ │ -00052470: 6e64 6c65 7229 206f 7665 7272 6964 650a ndler) override. │ │ │ -00052480: 097b 0a09 0970 6f73 7428 6d5f 696f 732c .{...post(m_ios, │ │ │ -00052490: 205b 6820 3d20 7374 643a 3a6d 6f76 6528 [h = std::move( │ │ │ -000524a0: 6861 6e64 6c65 7229 2c20 7061 7468 203d handler), path = │ │ │ -000524b0: 2073 7464 3a3a 6d6f 7665 2870 295d 2028 std::move(p)] ( │ │ │ -000524c0: 2920 6d75 7461 626c 650a 0909 097b 2068 ) mutable....{ h │ │ │ -000524d0: 2873 7461 7475 735f 747b 7d2c 2073 7464 (status_t{}, std │ │ │ -000524e0: 3a3a 6d6f 7665 2870 6174 6829 2c20 7374 ::move(path), st │ │ │ -000524f0: 6f72 6167 655f 6572 726f 727b 7d29 3b20 orage_error{}); │ │ │ -00052500: 7d29 3b0a 097d 0a0a 0976 6f69 6420 6173 });..}...void as │ │ │ -00052510: 796e 635f 7265 6c65 6173 655f 6669 6c65 ync_release_file │ │ │ -00052520: 7328 7374 6f72 6167 655f 696e 6465 785f s(storage_index_ │ │ │ -00052530: 742c 2073 7464 3a3a 6675 6e63 7469 6f6e t, std::function │ │ │ -00052540: 266c 743b 766f 6964 2829 2667 743b 2068 <void()> h │ │ │ -00052550: 616e 646c 6572 2920 6f76 6572 7269 6465 andler) override │ │ │ -00052560: 0a09 7b0a 0909 706f 7374 286d 5f69 6f73 ..{...post(m_ios │ │ │ -00052570: 2c20 5b68 203d 2073 7464 3a3a 6d6f 7665 , [h = std::move │ │ │ -00052580: 2868 616e 646c 6572 295d 207b 2068 2829 (handler)] { h() │ │ │ -00052590: 3b20 7d29 3b0a 097d 0a0a 0976 6f69 6420 ; });..}...void │ │ │ -000525a0: 6173 796e 635f 6465 6c65 7465 5f66 696c async_delete_fil │ │ │ -000525b0: 6573 2873 746f 7261 6765 5f69 6e64 6578 es(storage_index │ │ │ -000525c0: 5f74 0a09 092c 2072 656d 6f76 655f 666c _t..., remove_fl │ │ │ -000525d0: 6167 735f 742c 2073 7464 3a3a 6675 6e63 ags_t, std::func │ │ │ -000525e0: 7469 6f6e 266c 743b 766f 6964 2873 746f tion<void(sto │ │ │ -000525f0: 7261 6765 5f65 7272 6f72 2063 6f6e 7374 rage_error const │ │ │ -00052600: 2661 6d70 3b29 2667 743b 2068 616e 646c &)> handl │ │ │ -00052610: 6572 2920 6f76 6572 7269 6465 0a09 7b0a er) override..{. │ │ │ -00052620: 0909 706f 7374 286d 5f69 6f73 2c20 5b68 ..post(m_ios, [h │ │ │ -00052630: 203d 2073 7464 3a3a 6d6f 7665 2868 616e = std::move(han │ │ │ -00052640: 646c 6572 295d 207b 2068 2873 746f 7261 dler)] { h(stora │ │ │ -00052650: 6765 5f65 7272 6f72 7b7d 293b 207d 293b ge_error{}); }); │ │ │ -00052660: 0a09 7d0a 0a09 766f 6964 2061 7379 6e63 ..}...void async │ │ │ -00052670: 5f63 6865 636b 5f66 696c 6573 2873 746f _check_files(sto │ │ │ -00052680: 7261 6765 5f69 6e64 6578 5f74 0a09 092c rage_index_t..., │ │ │ -00052690: 2061 6464 5f74 6f72 7265 6e74 5f70 6172 add_torrent_par │ │ │ -000526a0: 616d 7320 636f 6e73 742a 0a3c 2f70 7265 ams const*.
    rele │ │ │ -000526e0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/utp │ │ │ -00052720: 5f73 6f63 6b65 745f 6d61 6e61 6765 722e _socket_manager. │ │ │ -00052730: 6370 703a 3138 303c 2f61 3e3c 2f74 643e cpp:180 │ │ │ -00052740: 3c74 643e 7468 6973 2073 686f 756c 6420 this should │ │ │ -00052750: 6e6f 7420 6265 2068 6561 7020 616c 6c6f not be heap allo │ │ │ -00052760: 6361 7465 642c 2073 6f63 6b65 7473 2073 cated, sockets s │ │ │ -00052770: 686f 756c 6420 6265 206d 6f76 6162 6c65 hould be movable │ │ │ -00052780: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    th │ │ │ -000527d0: 6973 2073 686f 756c 6420 6e6f 7420 6265 is should not be │ │ │ -000527e0: 2068 6561 7020 616c 6c6f 6361 7465 642c heap allocated, │ │ │ -000527f0: 2073 6f63 6b65 7473 2073 686f 756c 6420 sockets should │ │ │ -00052800: 6265 206d 6f76 6162 6c65 3c2f 6832 3e3c be movable

    < │ │ │ -00052810: 6834 3e2e 2e2f 7372 632f 7574 705f 736f h4>../src/utp_so │ │ │ -00052820: 636b 6574 5f6d 616e 6167 6572 2e63 7070 cket_manager.cpp │ │ │ -00052830: 3a31 3830 3c2f 6834 3e3c 7072 6520 7374 :180
    .//..UTP_LOGV
    │ │ │ -00052880: 2822 696e 636f 6d69 6e67 2070 6163 6b65  ("incoming packe
    │ │ │ -00052890: 7420 6964 3a25 6420 736f 7572 6365 3a25  t id:%d source:%
    │ │ │ -000528a0: 735c 6e22 2c20 6964 2c20 7072 696e 745f  s\n", id, print_
    │ │ │ -000528b0: 656e 6470 6f69 6e74 2865 7029 2e63 5f73  endpoint(ep).c_s
    │ │ │ -000528c0: 7472 2829 293b 0a0a 0909 6966 2028 216d  tr());....if (!m
    │ │ │ -000528d0: 5f73 6574 742e 6765 745f 626f 6f6c 2873  _sett.get_bool(s
    │ │ │ -000528e0: 6574 7469 6e67 735f 7061 636b 3a3a 656e  ettings_pack::en
    │ │ │ -000528f0: 6162 6c65 5f69 6e63 6f6d 696e 675f 7574  able_incoming_ut
    │ │ │ -00052900: 7029 290a 0909 0972 6574 7572 6e20 6661  p))....return fa
    │ │ │ -00052910: 6c73 653b 0a0a 0909 2f2f 2069 6620 6e6f  lse;....// if no
    │ │ │ -00052920: 7420 666f 756e 642c 2073 6565 2069 6620  t found, see if 
    │ │ │ -00052930: 6974 2773 2061 2053 594e 2070 6163 6b65  it's a SYN packe
    │ │ │ -00052940: 742c 2069 6620 6974 2069 732c 0a09 092f  t, if it is,.../
    │ │ │ -00052950: 2f20 6372 6561 7465 2061 206e 6577 2075  / create a new u
    │ │ │ -00052960: 7470 5f73 7472 6561 6d0a 0909 6966 2028  tp_stream...if (
    │ │ │ -00052970: 7068 2d26 6774 3b67 6574 5f74 7970 6528  ph->get_type(
    │ │ │ -00052980: 2920 3d3d 2053 545f 5359 4e29 0a09 097b  ) == ST_SYN)...{
    │ │ │ -00052990: 0a09 0909 2f2f 2070 6f73 7369 626c 6520  ....// possible 
    │ │ │ -000529a0: 5359 4e20 666c 6f6f 642e 204a 7573 7420  SYN flood. Just 
    │ │ │ -000529b0: 6967 6e6f 7265 0a09 0909 6966 2028 696e  ignore....if (in
    │ │ │ -000529c0: 7428 6d5f 7574 705f 736f 636b 6574 732e  t(m_utp_sockets.
    │ │ │ -000529d0: 7369 7a65 2829 2920 2667 743b 206d 5f73  size()) > m_s
    │ │ │ -000529e0: 6574 742e 6765 745f 696e 7428 7365 7474  ett.get_int(sett
    │ │ │ -000529f0: 696e 6773 5f70 6163 6b3a 3a63 6f6e 6e65  ings_pack::conne
    │ │ │ -00052a00: 6374 696f 6e73 5f6c 696d 6974 2920 2a20  ctions_limit) * 
    │ │ │ -00052a10: 3229 0a09 0909 0972 6574 7572 6e20 6661  2).....return fa
    │ │ │ -00052a20: 6c73 653b 0a0a 0909 0954 4f52 5245 4e54  lse;.....TORRENT
    │ │ │ -00052a30: 5f41 5353 4552 5428 6d5f 6e65 775f 636f  _ASSERT(m_new_co
    │ │ │ -00052a40: 6e6e 6563 7469 6f6e 203d 3d20 2d31 293b  nnection == -1);
    │ │ │ -00052a50: 0a09 0909 2f2f 2063 7265 6174 6520 7468  ....// create th
    │ │ │ -00052a60: 6520 6e65 7720 736f 636b 6574 2077 6974  e new socket wit
    │ │ │ -00052a70: 6820 7468 6973 2049 440a 0909 096d 5f6e  h this ID....m_n
    │ │ │ -00052a80: 6577 5f63 6f6e 6e65 6374 696f 6e20 3d20  ew_connection = 
    │ │ │ -00052a90: 6964 3b0a 0a2f 2f09 0909 5554 505f 4c4f  id;..//...UTP_LO
    │ │ │ -00052aa0: 4756 2822 6e6f 7420 666f 756e 642c 206e  GV("not found, n
    │ │ │ -00052ab0: 6577 2063 6f6e 6e65 6374 696f 6e20 6964  ew connection id
    │ │ │ -00052ac0: 3a25 645c 6e22 2c20 6d5f 6e65 775f 636f  :%d\n", m_new_co
    │ │ │ -00052ad0: 6e6e 6563 7469 6f6e 293b 0a0a 3c64 6976  nnection);..
    ...aux │ │ │ -00052b10: 3a3a 736f 636b 6574 5f74 7970 6520 6328 ::socket_type c( │ │ │ -00052b20: 6175 783a 3a69 6e73 7461 6e74 6961 7465 aux::instantiate │ │ │ -00052b30: 5f63 6f6e 6e65 6374 696f 6e28 6d5f 696f _connection(m_io │ │ │ -00052b40: 732c 2061 7578 3a3a 7072 6f78 795f 7365 s, aux::proxy_se │ │ │ -00052b50: 7474 696e 6773 2829 2c20 6d5f 7373 6c5f ttings(), m_ssl_ │ │ │ -00052b60: 636f 6e74 6578 742c 2074 6869 732c 2074 context, this, t │ │ │ -00052b70: 7275 652c 2066 616c 7365 2929 3b0a 3c2f rue, false));.....utp_stre │ │ │ -00052b90: 616d 2a20 7374 7220 3d20 6e75 6c6c 7074 am* str = nullpt │ │ │ -00052ba0: 723b 0a23 6966 6465 6620 544f 5252 454e r;.#ifdef TORREN │ │ │ -00052bb0: 545f 5353 4c5f 5045 4552 530a 0909 0969 T_SSL_PEERS....i │ │ │ -00052bc0: 6620 2869 735f 7373 6c28 6329 290a 0909 f (is_ssl(c))... │ │ │ -00052bd0: 0909 7374 7220 3d20 2661 6d70 3b73 7464 ..str = &std │ │ │ -00052be0: 3a3a 6765 7426 6c74 3b73 736c 5f73 7472 ::get<ssl_str │ │ │ -00052bf0: 6561 6d26 6c74 3b75 7470 5f73 7472 6561 eam<utp_strea │ │ │ -00052c00: 6d26 6774 3b26 6774 3b28 6329 2e6e 6578 m>>(c).nex │ │ │ -00052c10: 745f 6c61 7965 7228 293b 0a09 0909 656c t_layer();....el │ │ │ -00052c20: 7365 0a23 656e 6469 660a 0909 0909 7374 se.#endif.....st │ │ │ -00052c30: 7220 3d20 7374 643a 3a67 6574 5f69 6626 r = std::get_if& │ │ │ -00052c40: 6c74 3b75 7470 5f73 7472 6561 6d26 6774 lt;utp_stream> │ │ │ -00052c50: 3b28 2661 6d70 3b63 293b 0a0a 0909 0954 ;(&c);.....T │ │ │ -00052c60: 4f52 5245 4e54 5f41 5353 4552 5428 7374 ORRENT_ASSERT(st │ │ │ -00052c70: 7229 3b0a 0909 0969 6e74 2063 6f6e 7374 r);....int const │ │ │ -00052c80: 206d 7475 203d 206d 7475 5f66 6f72 5f64 mtu = mtu_for_d │ │ │ -00052c90: 6573 7428 6570 2e61 6464 7265 7373 2829 est(ep.address() │ │ │ -00052ca0: 293b 0a09 0909 7374 722d 2667 743b 6765 );....str->ge │ │ │ -00052cb0: 745f 696d 706c 2829 2d26 6774 3b69 6e69 t_impl()->ini │ │ │ -00052cc0: 745f 6d74 7528 6d74 7529 3b0a 0909 0973 t_mtu(mtu);....s │ │ │ -00052cd0: 7472 2d26 6774 3b67 6574 5f69 6d70 6c28 tr->get_impl( │ │ │ -00052ce0: 292d 2667 743b 6d5f 736f 636b 203d 2073 )->m_sock = s │ │ │ -00052cf0: 7464 3a3a 6d6f 7665 2873 6f63 6b65 7429 td::move(socket) │ │ │ -00052d00: 3b0a 0909 0962 6f6f 6c20 636f 6e73 7420 ;....bool const │ │ │ -00052d10: 7265 7420 3d20 7374 722d 2667 743b 6765 ret = str->ge │ │ │ -00052d20: 745f 696d 706c 2829 2d26 6774 3b69 6e63 t_impl()->inc │ │ │ -00052d30: 6f6d 696e 675f 7061 636b 6574 2870 2c20 oming_packet(p, │ │ │ -00052d40: 6570 2c20 7265 6365 6976 655f 7469 6d65 ep, receive_time │ │ │ -00052d50: 293b 0a09 0909 6966 2028 2172 6574 2920 );....if (!ret) │ │ │ -00052d60: 7265 7475 726e 2066 616c 7365 3b0a 0909 return false;... │ │ │ -00052d70: 096d 5f6c 6173 745f 736f 636b 6574 203d .m_last_socket = │ │ │ -00052d80: 2073 7472 2d26 6774 3b67 6574 5f69 6d70 str->get_imp │ │ │ -00052d90: 6c28 293b 0a09 0909 6d5f 6362 2873 7464 l();....m_cb(std │ │ │ -00052da0: 3a3a 6d6f 7665 2863 2929 3b0a 0909 092f ::move(c));..../ │ │ │ -00052db0: 2f20 7468 6520 636f 6e6e 6563 7469 6f6e / the connection │ │ │ -00052dc0: 206d 6f73 7420 6c69 6b65 6c79 2063 6861 most likely cha │ │ │ -00052dd0: 6e67 6564 2069 7473 2063 6f6e 6e65 6374 nged its connect │ │ │ -00052de0: 696f 6e20 4944 2068 6572 650a 0909 092f ion ID here..../ │ │ │ -00052df0: 2f20 7765 206e 6565 6420 746f 206d 6f76 / we need to mov │ │ │ -00052e00: 6520 6974 2074 6f20 7468 6520 636f 7272 e it to the corr │ │ │ -00052e10: 6563 7420 4944 0a09 0909 7265 7475 726e ect ID....return │ │ │ -00052e20: 2074 7275 653b 0a09 097d 0a0a 0909 6966 true;...}....if │ │ │ -00052e30: 2028 7068 2d26 6774 3b67 6574 5f74 7970 (ph->get_typ │ │ │ -00052e40: 6528 2920 3d3d 2053 545f 5245 5345 5429 e() == ST_RESET) │ │ │ -00052e50: 2072 6574 7572 6e20 6661 6c73 653b 0a0a return false;.. │ │ │ -00052e60: 0909 2f2f 2023 6572 726f 7220 7365 6e64 ..// #error send │ │ │ -00052e70: 2072 6573 6574 0a0a 0909 7265 7475 726e reset....return │ │ │ -00052e80: 2066 616c 7365 3b0a 097d 0a0a 0976 6f69 false;..}...voi │ │ │ -00052e90: 6420 7574 705f 736f 636b 6574 5f6d 616e d utp_socket_man │ │ │ -00052ea0: 6167 6572 3a3a 7375 6273 6372 6962 655f ager::subscribe_ │ │ │ -00052eb0: 7772 6974 6162 6c65 2875 7470 5f73 6f63 writable(utp_soc │ │ │ -00052ec0: 6b65 745f 696d 706c 2a20 7329 0a3c 2f70 ket_impl* s).

    re │ │ │ -00052f00: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/r │ │ │ -00052f40: 616e 646f 6d2e 6370 703a 3131 373c 2f61 andom.cpp:117improv │ │ │ -00052f60: 6520 6361 6c6c 696e 6720 5241 4e44 5f62 e calling RAND_b │ │ │ -00052f70: 7974 6573 206d 756c 7469 706c 6520 7469 ytes multiple ti │ │ │ -00052f80: 6d65 732c 2075 7369 6e67 2066 616c 6c62 mes, using fallb │ │ │ -00052f90: 6163 6b20 666f 7220 6e6f 773c 2f74 643e ack for now │ │ │ -00052fa0: 3c2f 7472 3e3c 7472 2069 643d 2231 3938

    improve │ │ │ -00052ff0: 2063 616c 6c69 6e67 2052 414e 445f 6279 calling RAND_by │ │ │ -00053000: 7465 7320 6d75 6c74 6970 6c65 2074 696d tes multiple tim │ │ │ -00053010: 6573 2c20 7573 696e 6720 6661 6c6c 6261 es, using fallba │ │ │ -00053020: 636b 2066 6f72 206e 6f77 3c2f 6832 3e3c ck for now

    < │ │ │ -00053030: 6834 3e2e 2e2f 7372 632f 7261 6e64 6f6d h4>../src/random │ │ │ -00053040: 2e63 7070 3a31 3137 3c2f 6834 3e3c 7072 .cpp:117#else.... │ │ │ -00053090: 7374 643a 3a67 656e 6572 6174 6528 6275 std::generate(bu │ │ │ -000530a0: 6666 6572 2e62 6567 696e 2829 2c20 6275 ffer.begin(), bu │ │ │ -000530b0: 6666 6572 2e65 6e64 2829 2c20 5b5d 207b ffer.end(), [] { │ │ │ -000530c0: 2072 6574 7572 6e20 6368 6172 2872 616e return char(ran │ │ │ -000530d0: 646f 6d28 3078 6666 2929 3b20 7d29 3b0a dom(0xff)); });. │ │ │ -000530e0: 2365 6e64 6966 0a09 097d 0a0a 0909 766f #endif...}....vo │ │ │ -000530f0: 6964 2063 7279 7074 6f5f 7261 6e64 6f6d id crypto_random │ │ │ -00053100: 5f62 7974 6573 2873 7061 6e26 6c74 3b63 _bytes(span<c │ │ │ -00053110: 6861 7226 6774 3b20 6275 6666 6572 290a har> buffer). │ │ │ -00053120: 0909 7b0a 2369 6664 6566 2054 4f52 5245 ..{.#ifdef TORRE │ │ │ -00053130: 4e54 5f42 5549 4c44 5f53 494d 554c 4154 NT_BUILD_SIMULAT │ │ │ -00053140: 4f52 0a09 0909 2f2f 2049 6e20 7468 6520 OR....// In the │ │ │ -00053150: 7369 6d75 6c61 746f 7220 7765 2077 616e simulator we wan │ │ │ -00053160: 7420 6465 7465 726d 696e 6973 7469 6320 t deterministic │ │ │ -00053170: 7261 6e64 6f6d 206e 756d 6265 7273 0a09 random numbers.. │ │ │ -00053180: 0909 7374 643a 3a67 656e 6572 6174 6528 ..std::generate( │ │ │ -00053190: 6275 6666 6572 2e62 6567 696e 2829 2c20 buffer.begin(), │ │ │ -000531a0: 6275 6666 6572 2e65 6e64 2829 2c20 5b5d buffer.end(), [] │ │ │ -000531b0: 207b 2072 6574 7572 6e20 6368 6172 2872 { return char(r │ │ │ -000531c0: 616e 646f 6d28 3078 6666 2929 3b20 7d29 andom(0xff)); }) │ │ │ -000531d0: 3b0a 2365 6c69 6620 544f 5252 454e 545f ;.#elif TORRENT_ │ │ │ -000531e0: 5553 455f 434e 470a 0909 0961 7578 3a3a USE_CNG....aux:: │ │ │ -000531f0: 636e 675f 6765 6e5f 7261 6e64 6f6d 2862 cng_gen_random(b │ │ │ -00053200: 7566 6665 7229 3b0a 2365 6c69 6620 544f uffer);.#elif TO │ │ │ -00053210: 5252 454e 545f 5553 455f 4352 5950 544f RRENT_USE_CRYPTO │ │ │ -00053220: 4150 490a 0909 092f 2f20 7769 6e64 6f77 API....// window │ │ │ -00053230: 730a 0909 0961 7578 3a3a 6372 7970 745f s....aux::crypt_ │ │ │ -00053240: 6765 6e5f 7261 6e64 6f6d 2862 7566 6665 gen_random(buffe │ │ │ -00053250: 7229 3b0a 2365 6c69 6620 6465 6669 6e65 r);.#elif define │ │ │ -00053260: 6420 544f 5252 454e 545f 5553 455f 4c49 d TORRENT_USE_LI │ │ │ -00053270: 4243 5259 5054 4f20 2661 6d70 3b26 616d BCRYPTO &&am │ │ │ -00053280: 703b 2021 6465 6669 6e65 6420 544f 5252 p; !defined TORR │ │ │ -00053290: 454e 545f 5553 455f 574f 4c46 5353 4c0a ENT_USE_WOLFSSL. │ │ │ -000532a0: 2f2f 2077 6f6c 6653 534c 2075 7365 7320 // wolfSSL uses │ │ │ -000532b0: 7763 5f52 4e47 5f47 656e 6572 6174 6542 wc_RNG_GenerateB │ │ │ -000532c0: 6c6f 636b 2061 7320 7468 6520 696e 7465 lock as the inte │ │ │ -000532d0: 726e 616c 2066 756e 6374 696f 6e20 666f rnal function fo │ │ │ -000532e0: 7220 7468 650a 2f2f 206f 7065 6e73 736c r the.// openssl │ │ │ -000532f0: 2063 6f6d 7061 7469 6269 6c69 7479 206c compatibility l │ │ │ -00053300: 6179 6572 2e20 5468 6973 2066 756e 6374 ayer. This funct │ │ │ -00053310: 696f 6e20 4150 4920 646f 6573 206e 6f74 ion API does not │ │ │ -00053320: 2073 7570 706f 7274 0a2f 2f20 616e 2061 support.// an a │ │ │ -00053330: 7262 6974 7261 7279 2062 7566 6665 7220 rbitrary buffer │ │ │ -00053340: 7369 7a65 2028 6f70 656e 7373 6c20 646f size (openssl do │ │ │ -00053350: 6573 292c 2069 7420 6973 206c 696d 6974 es), it is limit │ │ │ -00053360: 6564 2062 7920 7468 650a 2f2f 2063 6f6e ed by the.// con │ │ │ -00053370: 7374 616e 7420 524e 475f 4d41 585f 424c stant RNG_MAX_BL │ │ │ -00053380: 4f43 4b5f 4c45 4e2e 0a3c 6469 7620 7374 OCK_LEN..
    .
    .. │ │ │ -000533c0: 092f 2f20 6f70 656e 7373 6c0a 0909 0969 .// openssl....i │ │ │ -000533d0: 6e74 2072 203d 2052 414e 445f 6279 7465 nt r = RAND_byte │ │ │ -000533e0: 7328 7265 696e 7465 7270 7265 745f 6361 s(reinterpret_ca │ │ │ -000533f0: 7374 266c 743b 756e 7369 676e 6564 2063 st<unsigned c │ │ │ -00053400: 6861 722a 2667 743b 2862 7566 6665 722e har*>(buffer. │ │ │ -00053410: 6461 7461 2829 290a 0909 0909 2c20 696e data())....., in │ │ │ -00053420: 7428 6275 6666 6572 2e73 697a 6528 2929 t(buffer.size()) │ │ │ -00053430: 293b 0a09 0909 6966 2028 7220 213d 2031 );....if (r != 1 │ │ │ -00053440: 2920 6175 783a 3a74 6872 6f77 5f65 7826 ) aux::throw_ex& │ │ │ -00053450: 6c74 3b73 7973 7465 6d5f 6572 726f 7226 lt;system_error& │ │ │ -00053460: 6774 3b28 6572 726f 7273 3a3a 6e6f 5f65 gt;(errors::no_e │ │ │ -00053470: 6e74 726f 7079 293b 0a23 656c 6966 2054 ntropy);.#elif T │ │ │ -00053480: 4f52 5245 4e54 5f55 5345 5f47 4554 5241 ORRENT_USE_GETRA │ │ │ -00053490: 4e44 4f4d 0a09 0909 7373 697a 655f 7420 NDOM....ssize_t │ │ │ -000534a0: 636f 6e73 7420 7220 3d20 3a3a 6765 7472 const r = ::getr │ │ │ -000534b0: 616e 646f 6d28 6275 6666 6572 2e64 6174 andom(buffer.dat │ │ │ -000534c0: 6128 292c 2073 7461 7469 635f 6361 7374 a(), static_cast │ │ │ -000534d0: 266c 743b 7374 643a 3a73 697a 655f 7426 <std::size_t& │ │ │ -000534e0: 6774 3b28 6275 6666 6572 2e73 697a 6528 gt;(buffer.size( │ │ │ -000534f0: 2929 2c20 3029 3b0a 0909 0969 6620 2872 )), 0);....if (r │ │ │ -00053500: 203d 3d20 7373 697a 655f 7428 6275 6666 == ssize_t(buff │ │ │ -00053510: 6572 2e73 697a 6528 2929 2920 7265 7475 er.size())) retu │ │ │ -00053520: 726e 3b0a 0909 0969 6620 2872 203d 3d20 rn;....if (r == │ │ │ -00053530: 2d31 2026 616d 703b 2661 6d70 3b20 6572 -1 && er │ │ │ -00053540: 726e 6f20 213d 2045 4e4f 5359 5329 2061 rno != ENOSYS) a │ │ │ -00053550: 7578 3a3a 7468 726f 775f 6578 266c 743b ux::throw_ex< │ │ │ -00053560: 7379 7374 656d 5f65 7272 6f72 2667 743b system_error> │ │ │ -00053570: 2865 7272 6f72 5f63 6f64 6528 6572 726e (error_code(errn │ │ │ -00053580: 6f2c 2067 656e 6572 6963 5f63 6174 6567 o, generic_categ │ │ │ -00053590: 6f72 7928 2929 293b 0a09 0909 7374 6174 ory()));....stat │ │ │ -000535a0: 6963 2064 6576 5f72 616e 646f 6d20 6465 ic dev_random de │ │ │ -000535b0: 763b 0a09 0909 6465 762e 7265 6164 2862 v;....dev.read(b │ │ │ -000535c0: 7566 6665 7229 3b0a 2365 6c69 6620 544f uffer);.#elif TO │ │ │ -000535d0: 5252 454e 545f 5553 455f 4445 565f 5241 RRENT_USE_DEV_RA │ │ │ -000535e0: 4e44 4f4d 0a09 0909 7374 6174 6963 2064 NDOM....static d │ │ │ -000535f0: 6576 5f72 616e 646f 6d20 6465 763b 0a09 ev_random dev;.. │ │ │ -00053600: 0909 6465 762e 7265 6164 2862 7566 6665 ..dev.read(buffe │ │ │ -00053610: 7229 3b0a 2365 6c73 650a 0a23 6966 2054 r);.#else..#if T │ │ │ -00053620: 4f52 5245 4e54 5f42 524f 4b45 4e5f 5241 ORRENT_BROKEN_RA │ │ │ -00053630: 4e44 4f4d 5f44 4556 4943 450a 0909 092f NDOM_DEVICE..../ │ │ │ -00053640: 2f20 6576 656e 2070 7365 7564 6f20 7261 / even pseudo ra │ │ │ -00053650: 6e64 6f6d 206e 756d 6265 7273 2072 656c ndom numbers rel │ │ │ -00053660: 7920 6f6e 2062 6569 6e67 2061 626c 6520 y on being able │ │ │ -00053670: 746f 2073 6565 6420 7468 6520 7261 6e64 to seed the rand │ │ │ -00053680: 6f6d 0a09 0909 2f2f 2067 656e 6572 6174 om....// generat │ │ │ -00053690: 6f72 0a23 6572 726f 7220 226e 6f20 656e or.#error "no en │ │ │ -000536a0: 7472 6f70 7920 736f 7572 6365 2061 7661 tropy source ava │ │ │ -000536b0: 696c 6162 6c65 220a 2365 6c73 650a 2369 ilable".#else.#i │ │ │ -000536c0: 6664 6566 2054 4f52 5245 4e54 5f49 5f57 fdef TORRENT_I_W │ │ │ -000536d0: 414e 545f 494e 5345 4355 5245 5f52 414e ANT_INSECURE_RAN │ │ │ -000536e0: 444f 4d5f 4e55 4d42 4552 530a 0909 0973 DOM_NUMBERS....s │ │ │ -000536f0: 7464 3a3a 6765 6e65 7261 7465 2862 7566 td::generate(buf │ │ │ -00053700: 6665 722e 6265 6769 6e28 292c 2062 7566 fer.begin(), buf │ │ │ -00053710: 6665 722e 656e 6428 292c 205b 5d20 7b20 fer.end(), [] { │ │ │ -00053720: 7265 7475 726e 2063 6861 7228 7261 6e64 return char(rand │ │ │ -00053730: 6f6d 2830 7866 6629 293b 207d 293b 0a23 om(0xff)); });.# │ │ │ -00053740: 656c 7365 0a23 6572 726f 7220 226e 6f20 else.#error "no │ │ │ -00053750: 7365 6375 7265 2065 6e74 726f 7079 2073 secure entropy s │ │ │ -00053760: 6f75 7263 6520 6176 6169 6c61 626c 652e ource available. │ │ │ -00053770: 2049 6620 796f 7520 7265 616c 6c79 2077 If you really w │ │ │ -00053780: 616e 7420 696e 7365 6375 7265 2072 616e ant insecure ran │ │ │ -00053790: 646f 6d20 6e75 6d62 6572 732c 2064 6566 dom numbers, def │ │ │ -000537a0: 696e 6520 544f 5252 454e 545f 495f 5741 ine TORRENT_I_WA │ │ │ -000537b0: 4e54 5f49 4e53 4543 5552 455f 5241 4e44 NT_INSECURE_RAND │ │ │ -000537c0: 4f4d 5f4e 554d 4245 5253 220a 2365 6e64 OM_NUMBERS".#end │ │ │ -000537d0: 6966 0a23 656e 6469 660a 0a23 656e 6469 if.#endif..#endi │ │ │ -000537e0: 660a 0909 7d0a 0a3c 2f70 7265 3e3c 2f74 f...}..
    relevanc │ │ │ -00053820: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/pe_cryp │ │ │ -00053860: 746f 2e63 7070 3a33 323c 2f61 3e3c 2f74 to.cpp:32it would b │ │ │ -00053880: 6520 6e69 6365 2074 6f20 6765 7420 7468 e nice to get th │ │ │ -00053890: 6520 6c69 7465 7261 6c20 776f 726b 696e e literal workin │ │ │ -000538a0: 673c 2f74 643e 3c2f 7472 3e3c 7472 2069 g

    i │ │ │ -000538f0: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ -00053900: 746f 2067 6574 2074 6865 206c 6974 6572 to get the liter │ │ │ -00053910: 616c 2077 6f72 6b69 6e67 3c2f 6832 3e3c al working

    < │ │ │ -00053920: 6834 3e2e 2e2f 7372 632f 7065 5f63 7279 h4>../src/pe_cry │ │ │ -00053930: 7074 6f2e 6370 703a 3332 3c2f 6834 3e3c pto.cpp:32< │ │ │ -00053940: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00053950: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00053960: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00053970: 7820 2364 6464 3b22 3e2a 2f0a 0a23 6966 x #ddd;">*/..#if │ │ │ -00053980: 2021 6465 6669 6e65 6420 544f 5252 454e !defined TORREN │ │ │ -00053990: 545f 4449 5341 424c 455f 454e 4352 5950 T_DISABLE_ENCRYP │ │ │ -000539a0: 5449 4f4e 0a0a 2369 6e63 6c75 6465 2026 TION..#include & │ │ │ -000539b0: 6c74 3b63 7374 6469 6e74 2667 743b 0a23 lt;cstdint>.# │ │ │ -000539c0: 696e 636c 7564 6520 266c 743b 616c 676f include <algo │ │ │ -000539d0: 7269 7468 6d26 6774 3b0a 2369 6e63 6c75 rithm>.#inclu │ │ │ -000539e0: 6465 2026 6c74 3b72 616e 646f 6d26 6774 de <random> │ │ │ -000539f0: 3b0a 0a23 696e 636c 7564 6520 226c 6962 ;..#include "lib │ │ │ -00053a00: 746f 7272 656e 742f 6175 785f 2f64 6973 torrent/aux_/dis │ │ │ -00053a10: 6162 6c65 5f77 6172 6e69 6e67 735f 7075 able_warnings_pu │ │ │ -00053a20: 7368 2e68 7070 220a 2369 6e63 6c75 6465 sh.hpp".#include │ │ │ -00053a30: 2026 6c74 3b62 6f6f 7374 2f6d 756c 7469 <boost/multi │ │ │ -00053a40: 7072 6563 6973 696f 6e2f 696e 7465 6765 precision/intege │ │ │ -00053a50: 722e 6870 7026 6774 3b0a 2369 6e63 6c75 r.hpp>.#inclu │ │ │ -00053a60: 6465 2022 6c69 6274 6f72 7265 6e74 2f61 de "libtorrent/a │ │ │ -00053a70: 7578 5f2f 6469 7361 626c 655f 7761 726e ux_/disable_warn │ │ │ -00053a80: 696e 6773 5f70 6f70 2e68 7070 220a 0a23 ings_pop.hpp"..# │ │ │ -00053a90: 696e 636c 7564 6520 226c 6962 746f 7272 include "libtorr │ │ │ -00053aa0: 656e 742f 6175 785f 2f72 616e 646f 6d2e ent/aux_/random. │ │ │ -00053ab0: 6870 7022 0a23 696e 636c 7564 6520 226c hpp".#include "l │ │ │ -00053ac0: 6962 746f 7272 656e 742f 6175 785f 2f61 ibtorrent/aux_/a │ │ │ -00053ad0: 6c6c 6f63 612e 6870 7022 0a23 696e 636c lloca.hpp".#incl │ │ │ -00053ae0: 7564 6520 226c 6962 746f 7272 656e 742f ude "libtorrent/ │ │ │ -00053af0: 6175 785f 2f70 655f 6372 7970 746f 2e68 aux_/pe_crypto.h │ │ │ -00053b00: 7070 220a 2369 6e63 6c75 6465 2022 6c69 pp".#include "li │ │ │ -00053b10: 6274 6f72 7265 6e74 2f68 6173 6865 722e btorrent/hasher. │ │ │ -00053b20: 6870 7022 0a0a 6e61 6d65 7370 6163 6520 hpp"..namespace │ │ │ -00053b30: 6c69 6274 6f72 7265 6e74 3a3a 6175 7820 libtorrent::aux │ │ │ -00053b40: 7b0a 0a09 6e61 6d65 7370 6163 6520 7b0a {...namespace {. │ │ │ -00053b50: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .. │ │ │ -00053b80: 6b65 795f 7420 636f 6e73 7420 6468 5f70 key_t const dh_p │ │ │ -00053b90: 7269 6d65 0a3c 2f64 6976 3e09 0909 2822 rime.
    ...(" │ │ │ -00053ba0: 3078 4646 4646 4646 4646 4646 4646 4646 0xFFFFFFFFFFFFFF │ │ │ -00053bb0: 4646 4339 3046 4441 4132 3231 3638 4332 FFC90FDAA22168C2 │ │ │ -00053bc0: 3334 4334 4336 3632 3842 3830 4443 3143 34C4C6628B80DC1C │ │ │ -00053bd0: 4431 3239 3032 3445 3038 3841 3637 4343 D129024E088A67CC │ │ │ -00053be0: 3734 3032 3042 4245 4136 3342 3133 3942 74020BBEA63B139B │ │ │ -00053bf0: 3232 3531 3441 3038 3739 3845 3334 3034 22514A08798E3404 │ │ │ -00053c00: 4444 4546 3935 3139 4233 4344 3341 3433 DDEF9519B3CD3A43 │ │ │ -00053c10: 3142 3330 3242 3041 3644 4632 3546 3134 1B302B0A6DF25F14 │ │ │ -00053c20: 3337 3446 4531 3335 3644 3644 3531 4332 374FE1356D6D51C2 │ │ │ -00053c30: 3435 4534 3835 4235 3736 3632 3545 3745 45E485B576625E7E │ │ │ -00053c40: 4336 4634 3443 3432 4539 4136 3341 3336 C6F44C42E9A63A36 │ │ │ -00053c50: 3231 3030 3030 3030 3030 3030 3039 3035 2100000000000905 │ │ │ -00053c60: 3633 2229 3b0a 097d 0a0a 0973 7464 3a3a 63");..}...std:: │ │ │ -00053c70: 6172 7261 7926 6c74 3b63 6861 722c 2039 array<char, 9 │ │ │ -00053c80: 3626 6774 3b20 6578 706f 7274 5f6b 6579 6> export_key │ │ │ -00053c90: 286b 6579 5f74 2063 6f6e 7374 2661 6d70 (key_t const& │ │ │ -00053ca0: 3b20 6b29 0a09 7b0a 0909 7374 643a 3a61 ; k)..{...std::a │ │ │ -00053cb0: 7272 6179 266c 743b 6368 6172 2c20 3936 rray<char, 96 │ │ │ -00053cc0: 2667 743b 2072 6574 3b0a 0909 6175 746f > ret;...auto │ │ │ -00053cd0: 2a20 6265 6769 6e20 3d20 7265 696e 7465 * begin = reinte │ │ │ -00053ce0: 7270 7265 745f 6361 7374 266c 743b 7374 rpret_cast<st │ │ │ -00053cf0: 643a 3a75 696e 7438 5f74 2a26 6774 3b28 d::uint8_t*>( │ │ │ -00053d00: 7265 742e 6461 7461 2829 293b 0a09 0973 ret.data());...s │ │ │ -00053d10: 7464 3a3a 7569 6e74 385f 742a 2065 6e64 td::uint8_t* end │ │ │ -00053d20: 203d 206d 703a 3a65 7870 6f72 745f 6269 = mp::export_bi │ │ │ -00053d30: 7473 286b 2c20 6265 6769 6e2c 2038 293b ts(k, begin, 8); │ │ │ -00053d40: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..
    < │ │ │ -00053d70: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00053d80: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00053db0: 7372 632f 7065 5f63 7279 7074 6f2e 6370 src/pe_crypto.cp │ │ │ -00053dc0: 703a 3433 3c2f 613e 3c2f 7464 3e3c 7464 p:43it would be nic │ │ │ -00053de0: 6520 746f 2062 6520 6162 6c65 2074 6f20 e to be able to │ │ │ -00053df0: 6578 706f 7274 2074 6f20 6120 6669 7865 export to a fixe │ │ │ -00053e00: 6420 7769 6474 6820 6669 656c 642c 2073 d width field, s │ │ │ -00053e10: 6f20 7765 2077 6f75 6c64 6e27 7420 6861 o we wouldn't ha │ │ │ -00053e20: 7665 2074 6f20 7368 6966 7420 6974 206c ve to shift it l │ │ │ -00053e30: 6174 6572 3c2f 7464 3e3c 2f74 723e 3c74 aterit would be ni │ │ │ -00053e90: 6365 2074 6f20 6265 2061 626c 6520 746f ce to be able to │ │ │ -00053ea0: 2065 7870 6f72 7420 746f 2061 2066 6978 export to a fix │ │ │ -00053eb0: 6564 2077 6964 7468 2066 6965 6c64 2c20 ed width field, │ │ │ -00053ec0: 736f 0a77 6520 776f 756c 646e 2774 2068 so.we wouldn't h │ │ │ -00053ed0: 6176 6520 746f 2073 6869 6674 2069 7420 ave to shift it │ │ │ -00053ee0: 6c61 7465 723c 2f68 323e 3c68 343e 2e2e later

    .. │ │ │ -00053ef0: 2f73 7263 2f70 655f 6372 7970 746f 2e63 /src/pe_crypto.c │ │ │ -00053f00: 7070 3a34 333c 2f68 343e 3c70 7265 2073 pp:43

    #include "li
    │ │ │ -00053f50: 6274 6f72 7265 6e74 2f61 7578 5f2f 6469  btorrent/aux_/di
    │ │ │ -00053f60: 7361 626c 655f 7761 726e 696e 6773 5f70  sable_warnings_p
    │ │ │ -00053f70: 6f70 2e68 7070 220a 0a23 696e 636c 7564  op.hpp"..#includ
    │ │ │ -00053f80: 6520 226c 6962 746f 7272 656e 742f 6175  e "libtorrent/au
    │ │ │ -00053f90: 785f 2f72 616e 646f 6d2e 6870 7022 0a23  x_/random.hpp".#
    │ │ │ -00053fa0: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00053fb0: 656e 742f 6175 785f 2f61 6c6c 6f63 612e  ent/aux_/alloca.
    │ │ │ -00053fc0: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ -00053fd0: 6962 746f 7272 656e 742f 6175 785f 2f70  ibtorrent/aux_/p
    │ │ │ -00053fe0: 655f 6372 7970 746f 2e68 7070 220a 2369  e_crypto.hpp".#i
    │ │ │ -00053ff0: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ -00054000: 6e74 2f68 6173 6865 722e 6870 7022 0a0a  nt/hasher.hpp"..
    │ │ │ -00054010: 6e61 6d65 7370 6163 6520 6c69 6274 6f72  namespace libtor
    │ │ │ -00054020: 7265 6e74 3a3a 6175 7820 7b0a 0a09 6e61  rent::aux {...na
    │ │ │ -00054030: 6d65 7370 6163 6520 7b0a 0909 6b65 795f  mespace {...key_
    │ │ │ -00054040: 7420 636f 6e73 7420 6468 5f70 7269 6d65  t const dh_prime
    │ │ │ -00054050: 0a09 0909 2822 3078 4646 4646 4646 4646  ....("0xFFFFFFFF
    │ │ │ -00054060: 4646 4646 4646 4646 4339 3046 4441 4132  FFFFFFFFC90FDAA2
    │ │ │ -00054070: 3231 3638 4332 3334 4334 4336 3632 3842  2168C234C4C6628B
    │ │ │ -00054080: 3830 4443 3143 4431 3239 3032 3445 3038  80DC1CD129024E08
    │ │ │ -00054090: 3841 3637 4343 3734 3032 3042 4245 4136  8A67CC74020BBEA6
    │ │ │ -000540a0: 3342 3133 3942 3232 3531 3441 3038 3739  3B139B22514A0879
    │ │ │ -000540b0: 3845 3334 3034 4444 4546 3935 3139 4233  8E3404DDEF9519B3
    │ │ │ -000540c0: 4344 3341 3433 3142 3330 3242 3041 3644  CD3A431B302B0A6D
    │ │ │ -000540d0: 4632 3546 3134 3337 3446 4531 3335 3644  F25F14374FE1356D
    │ │ │ -000540e0: 3644 3531 4332 3435 4534 3835 4235 3736  6D51C245E485B576
    │ │ │ -000540f0: 3632 3545 3745 4336 4634 3443 3432 4539  625E7EC6F44C42E9
    │ │ │ -00054100: 4136 3341 3336 3231 3030 3030 3030 3030  A63A362100000000
    │ │ │ -00054110: 3030 3039 3035 3633 2229 3b0a 097d 0a0a  00090563");..}..
    │ │ │ -00054120: 0973 7464 3a3a 6172 7261 7926 6c74 3b63  .std::array<c
    │ │ │ -00054130: 6861 722c 2039 3626 6774 3b20 6578 706f  har, 96> expo
    │ │ │ -00054140: 7274 5f6b 6579 286b 6579 5f74 2063 6f6e  rt_key(key_t con
    │ │ │ -00054150: 7374 2661 6d70 3b20 6b29 0a09 7b0a 0909  st& k)..{...
    │ │ │ -00054160: 7374 643a 3a61 7272 6179 266c 743b 6368  std::array<ch
    │ │ │ -00054170: 6172 2c20 3936 2667 743b 2072 6574 3b0a  ar, 96> ret;.
    │ │ │ -00054180: 0909 6175 746f 2a20 6265 6769 6e20 3d20  ..auto* begin = 
    │ │ │ -00054190: 7265 696e 7465 7270 7265 745f 6361 7374  reinterpret_cast
    │ │ │ -000541a0: 266c 743b 7374 643a 3a75 696e 7438 5f74  <std::uint8_t
    │ │ │ -000541b0: 2a26 6774 3b28 7265 742e 6461 7461 2829  *>(ret.data()
    │ │ │ -000541c0: 293b 0a09 0973 7464 3a3a 7569 6e74 385f  );...std::uint8_
    │ │ │ -000541d0: 742a 2065 6e64 203d 206d 703a 3a65 7870  t* end = mp::exp
    │ │ │ -000541e0: 6f72 745f 6269 7473 286b 2c20 6265 6769  ort_bits(k, begi
    │ │ │ -000541f0: 6e2c 2038 293b 0a0a 3c64 6976 2073 7479  n, 8);..
    ..if (end │ │ │ -00054230: 266c 743b 2062 6567 696e 202b 2039 3629 < begin + 96) │ │ │ -00054240: 0a3c 2f64 6976 3e09 097b 0a09 0909 696e .
    ..{....in │ │ │ -00054250: 7420 636f 6e73 7420 6c65 6e20 3d20 696e t const len = in │ │ │ -00054260: 7428 656e 6420 2d20 6265 6769 6e29 3b0a t(end - begin);. │ │ │ -00054270: 2369 6620 6465 6669 6e65 6420 5f5f 474e #if defined __GN │ │ │ -00054280: 5543 5f5f 2026 616d 703b 2661 6d70 3b20 UC__ && │ │ │ -00054290: 5f5f 474e 5543 5f5f 203d 3d20 3132 0a23 __GNUC__ == 12.# │ │ │ -000542a0: 7072 6167 6d61 2047 4343 2064 6961 676e pragma GCC diagn │ │ │ -000542b0: 6f73 7469 6320 7075 7368 0a23 7072 6167 ostic push.#prag │ │ │ -000542c0: 6d61 2047 4343 2064 6961 676e 6f73 7469 ma GCC diagnosti │ │ │ -000542d0: 6320 6967 6e6f 7265 6420 222d 5773 7472 c ignored "-Wstr │ │ │ -000542e0: 696e 676f 702d 6f76 6572 666c 6f77 220a ingop-overflow". │ │ │ -000542f0: 2365 6e64 6966 0a09 0909 7374 643a 3a6d #endif....std::m │ │ │ -00054300: 656d 6d6f 7665 2862 6567 696e 202b 2039 emmove(begin + 9 │ │ │ -00054310: 3620 2d20 6c65 6e2c 2062 6567 696e 2c20 6 - len, begin, │ │ │ -00054320: 6175 783a 3a6e 756d 6572 6963 5f63 6173 aux::numeric_cas │ │ │ -00054330: 7426 6c74 3b73 7464 3a3a 7369 7a65 5f74 t<std::size_t │ │ │ -00054340: 2667 743b 286c 656e 2929 3b0a 2369 6620 >(len));.#if │ │ │ -00054350: 6465 6669 6e65 6420 5f5f 474e 5543 5f5f defined __GNUC__ │ │ │ -00054360: 2026 616d 703b 2661 6d70 3b20 5f5f 474e && __GN │ │ │ -00054370: 5543 5f5f 203d 3d20 3132 0a23 7072 6167 UC__ == 12.#prag │ │ │ -00054380: 6d61 2047 4343 2064 6961 676e 6f73 7469 ma GCC diagnosti │ │ │ -00054390: 6320 706f 700a 2365 6e64 6966 0a09 0909 c pop.#endif.... │ │ │ -000543a0: 7374 643a 3a6d 656d 7365 7428 6265 6769 std::memset(begi │ │ │ -000543b0: 6e2c 2030 2c20 6175 783a 3a6e 756d 6572 n, 0, aux::numer │ │ │ -000543c0: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a ic_cast<std:: │ │ │ -000543d0: 7369 7a65 5f74 2667 743b 2839 3620 2d20 size_t>(96 - │ │ │ -000543e0: 6c65 6e29 293b 0a09 097d 0a09 0972 6574 len));...}...ret │ │ │ -000543f0: 7572 6e20 7265 743b 0a09 7d0a 0a09 766f urn ret;..}...vo │ │ │ -00054400: 6964 2072 6334 5f69 6e69 7428 636f 6e73 id rc4_init(cons │ │ │ -00054410: 7420 756e 7369 676e 6564 2063 6861 722a t unsigned char* │ │ │ -00054420: 2069 6e2c 2073 7464 3a3a 7369 7a65 5f74 in, std::size_t │ │ │ -00054430: 206c 656e 2c20 7263 3420 2a73 7461 7465 len, rc4 *state │ │ │ -00054440: 293b 0a09 7374 643a 3a73 697a 655f 7420 );..std::size_t │ │ │ -00054450: 7263 345f 656e 6372 7970 7428 756e 7369 rc4_encrypt(unsi │ │ │ -00054460: 676e 6564 2063 6861 7220 2a6f 7574 2c20 gned char *out, │ │ │ -00054470: 7374 643a 3a73 697a 655f 7420 6f75 746c std::size_t outl │ │ │ -00054480: 656e 2c20 7263 3420 2a73 7461 7465 293b en, rc4 *state); │ │ │ -00054490: 0a0a 092f 2f20 5365 7420 7468 6520 7072 ...// Set the pr │ │ │ -000544a0: 696d 6520 5020 616e 6420 7468 6520 6765 ime P and the ge │ │ │ -000544b0: 6e65 7261 746f 722c 2067 656e 6572 6174 nerator, generat │ │ │ -000544c0: 6520 6c6f 6361 6c20 7075 626c 6963 206b e local public k │ │ │ -000544d0: 6579 0a09 6468 5f6b 6579 5f65 7863 6861 ey..dh_key_excha │ │ │ -000544e0: 6e67 653a 3a64 685f 6b65 795f 6578 6368 nge::dh_key_exch │ │ │ -000544f0: 616e 6765 2829 0a09 7b0a 0909 6175 783a ange()..{...aux: │ │ │ -00054500: 3a61 7272 6179 266c 743b 7374 643a 3a75 :array<std::u │ │ │ -00054510: 696e 7438 5f74 2c20 3936 2667 743b 2072 int8_t, 96> r │ │ │ -00054520: 616e 646f 6d5f 6b65 793b 0a09 0961 7578 andom_key;...aux │ │ │ -00054530: 3a3a 7261 6e64 6f6d 5f62 7974 6573 287b ::random_bytes({ │ │ │ -00054540: 7265 696e 7465 7270 7265 745f 6361 7374 reinterpret_cast │ │ │ -00054550: 266c 743b 6368 6172 2a26 6774 3b28 7261 <char*>(ra │ │ │ -00054560: 6e64 6f6d 5f6b 6579 2e64 6174 6128 2929 ndom_key.data()) │ │ │ -00054570: 0a09 0909 2c20 7374 6174 6963 5f63 6173 ...., static_cas │ │ │ -00054580: 7426 6c74 3b73 7464 3a3a 7074 7264 6966 t<std::ptrdif │ │ │ -00054590: 665f 7426 6774 3b28 7261 6e64 6f6d 5f6b f_t>(random_k │ │ │ -000545a0: 6579 2e73 697a 6528 2929 7d29 3b0a 0a09 ey.size())});... │ │ │ -000545b0: 092f 2f20 6372 6561 7465 206c 6f63 616c .// create local │ │ │ -000545c0: 206b 6579 2028 7261 6e64 6f6d 290a 0909 key (random)... │ │ │ -000545d0: 6d70 3a3a 696d 706f 7274 5f62 6974 7328 mp::import_bits( │ │ │ -000545e0: 6d5f 6468 5f6c 6f63 616c 5f73 6563 7265 m_dh_local_secre │ │ │ -000545f0: 742c 2072 616e 646f 6d5f 6b65 792e 6265 t, random_key.be │ │ │ -00054600: 6769 6e28 292c 2072 616e 646f 6d5f 6b65 gin(), random_ke │ │ │ -00054610: 792e 656e 6428 2929 3b0a 0a09 092f 2f20 y.end());....// │ │ │ -00054620: 6b65 7920 3d20 2832 205e 2073 6563 7265 key = (2 ^ secre │ │ │ -00054630: 7429 2025 2070 7269 6d65 0a09 096d 5f64 t) % prime...m_d │ │ │ -00054640: 685f 6c6f 6361 6c5f 6b65 7920 3d20 6d70 h_local_key = mp │ │ │ -00054650: 3a3a 706f 776d 286b 6579 5f74 2832 292c ::powm(key_t(2), │ │ │ -00054660: 206d 5f64 685f 6c6f 6361 6c5f 7365 6372 m_dh_local_secr │ │ │ -00054670: 6574 2c20 6468 5f70 7269 6d65 293b 0a3c et, dh_prime);.< │ │ │ -00054680: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00054690: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -000546a0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -000546b0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -000546c0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -000546f0: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e /peer_connection │ │ │ -00054700: 2e63 7070 3a31 3037 313c 2f61 3e3c 2f74 .cpp:1071this shoul │ │ │ -00054720: 6420 6265 2074 6865 2067 6c6f 6261 6c20 d be the global │ │ │ -00054730: 646f 776e 6c6f 6164 2072 6174 653c 2f74 download rate

    this │ │ │ -00054790: 7368 6f75 6c64 2062 6520 7468 6520 676c should be the gl │ │ │ -000547a0: 6f62 616c 2064 6f77 6e6c 6f61 6420 7261 obal download ra │ │ │ -000547b0: 7465 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 te

    ../sr │ │ │ -000547c0: 632f 7065 6572 5f63 6f6e 6e65 6374 696f c/peer_connectio │ │ │ -000547d0: 6e2e 6370 703a 3130 3731 3c2f 6834 3e3c n.cpp:1071

    < │ │ │ -000547e0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000547f0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00054800: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00054810: 7820 2364 6464 3b22 3e0a 0909 696e 7420 x #ddd;">...int │ │ │ -00054820: 7261 7465 203d 2030 3b0a 0a09 092f 2f20 rate = 0;....// │ │ │ -00054830: 6966 2077 6520 6861 7665 6e27 7420 7265 if we haven't re │ │ │ -00054840: 6365 6976 6564 2061 6e79 2064 6174 6120 ceived any data │ │ │ -00054850: 7265 6365 6e74 6c79 2c20 7468 6520 6375 recently, the cu │ │ │ -00054860: 7272 656e 7420 646f 776e 6c6f 6164 2072 rrent download r │ │ │ -00054870: 6174 650a 0909 2f2f 2069 7320 6e6f 7420 ate...// is not │ │ │ -00054880: 7265 7072 6573 656e 7461 7469 7665 0a09 representative.. │ │ │ -00054890: 0969 6620 2861 7578 3a3a 7469 6d65 5f6e .if (aux::time_n │ │ │ -000548a0: 6f77 2829 202d 206d 5f6c 6173 745f 7069 ow() - m_last_pi │ │ │ -000548b0: 6563 652e 6765 7428 6d5f 636f 6e6e 6563 ece.get(m_connec │ │ │ -000548c0: 7429 2026 6774 3b20 7365 636f 6e64 7328 t) > seconds( │ │ │ -000548d0: 3330 2920 2661 6d70 3b26 616d 703b 206d 30) && m │ │ │ -000548e0: 5f64 6f77 6e6c 6f61 645f 7261 7465 5f70 _download_rate_p │ │ │ -000548f0: 6561 6b20 2667 743b 2030 290a 0909 7b0a eak > 0)...{. │ │ │ -00054900: 0909 0972 6174 6520 3d20 6d5f 646f 776e ...rate = m_down │ │ │ -00054910: 6c6f 6164 5f72 6174 655f 7065 616b 3b0a load_rate_peak;. │ │ │ -00054920: 0909 7d0a 0909 656c 7365 2069 6620 2861 ..}...else if (a │ │ │ -00054930: 7578 3a3a 7469 6d65 5f6e 6f77 2829 202d ux::time_now() - │ │ │ -00054940: 206d 5f6c 6173 745f 756e 6368 6f6b 6564 m_last_unchoked │ │ │ -00054950: 2e67 6574 286d 5f63 6f6e 6e65 6374 2920 .get(m_connect) │ │ │ -00054960: 266c 743b 2073 6563 6f6e 6473 2835 290a < seconds(5). │ │ │ -00054970: 0909 0926 616d 703b 2661 6d70 3b20 6d5f ...&& m_ │ │ │ -00054980: 7374 6174 6973 7469 6373 2e74 6f74 616c statistics.total │ │ │ -00054990: 5f70 6179 6c6f 6164 5f75 706c 6f61 6428 _payload_upload( │ │ │ -000549a0: 2920 266c 743b 2032 202a 2030 7834 3030 ) < 2 * 0x400 │ │ │ -000549b0: 3029 0a09 097b 0a09 0909 2f2f 2069 6620 0)...{....// if │ │ │ -000549c0: 7765 2772 6520 6861 7665 206f 6e6c 7920 we're have only │ │ │ -000549d0: 6265 656e 2075 6e63 686f 6b65 6420 666f been unchoked fo │ │ │ -000549e0: 7220 6120 7368 6f72 7420 7065 7269 6f64 r a short period │ │ │ -000549f0: 206f 6620 7469 6d65 2c0a 0909 092f 2f20 of time,....// │ │ │ -00054a00: 7765 2064 6f6e 2774 206b 6e6f 7720 7768 we don't know wh │ │ │ -00054a10: 6174 2072 6174 6520 7765 2063 616e 2067 at rate we can g │ │ │ -00054a20: 6574 2066 726f 6d20 7468 6973 2070 6565 et from this pee │ │ │ -00054a30: 722e 2049 6e73 7465 6164 206f 6620 6173 r. Instead of as │ │ │ -00054a40: 7375 6d69 6e67 0a09 0909 2f2f 2074 6865 suming....// the │ │ │ -00054a50: 206c 6f77 6573 7420 706f 7373 6962 6c65 lowest possible │ │ │ -00054a60: 2072 6174 652c 2061 7373 756d 6520 7468 rate, assume th │ │ │ -00054a70: 6520 6176 6572 6167 652e 0a0a 0909 0969 e average......i │ │ │ -00054a80: 6e74 2070 6565 7273 5f77 6974 685f 7265 nt peers_with_re │ │ │ -00054a90: 7175 6573 7473 203d 2069 6e74 2873 7461 quests = int(sta │ │ │ -00054aa0: 7473 5f63 6f75 6e74 6572 7328 295b 636f ts_counters()[co │ │ │ -00054ab0: 756e 7465 7273 3a3a 6e75 6d5f 7065 6572 unters::num_peer │ │ │ -00054ac0: 735f 646f 776e 5f72 6571 7565 7374 735d s_down_requests] │ │ │ -00054ad0: 293b 0a09 0909 2f2f 2061 766f 6964 2064 );....// avoid d │ │ │ -00054ae0: 6976 6973 696f 6e20 6279 2030 0a09 0909 ivision by 0.... │ │ │ -00054af0: 6966 2028 7065 6572 735f 7769 7468 5f72 if (peers_with_r │ │ │ -00054b00: 6571 7565 7374 7320 3d3d 2030 2920 7065 equests == 0) pe │ │ │ -00054b10: 6572 735f 7769 7468 5f72 6571 7565 7374 ers_with_request │ │ │ -00054b20: 7320 3d20 313b 0a0a 3c64 6976 2073 7479 s = 1;..
    ...rate = │ │ │ -00054b60: 742d 2667 743b 7374 6174 6973 7469 6373 t->statistics │ │ │ -00054b70: 2829 2e74 7261 6e73 6665 725f 7261 7465 ().transfer_rate │ │ │ -00054b80: 2861 7578 3a3a 7374 6174 3a3a 646f 776e (aux::stat::down │ │ │ -00054b90: 6c6f 6164 5f70 6179 6c6f 6164 2920 2f20 load_payload) / │ │ │ -00054ba0: 7065 6572 735f 7769 7468 5f72 6571 7565 peers_with_reque │ │ │ -00054bb0: 7374 733b 0a3c 2f64 6976 3e09 097d 0a09 sts;.
    ..}.. │ │ │ -00054bc0: 0965 6c73 650a 0909 7b0a 0909 092f 2f20 .else...{....// │ │ │ -00054bd0: 6375 7272 656e 7420 646f 776e 6c6f 6164 current download │ │ │ -00054be0: 2072 6174 6520 696e 2062 7974 6573 2070 rate in bytes p │ │ │ -00054bf0: 6572 2073 6563 6f6e 6473 0a09 0909 7261 er seconds....ra │ │ │ -00054c00: 7465 203d 206d 5f73 7461 7469 7374 6963 te = m_statistic │ │ │ -00054c10: 732e 7472 616e 7366 6572 5f72 6174 6528 s.transfer_rate( │ │ │ -00054c20: 6175 783a 3a73 7461 743a 3a64 6f77 6e6c aux::stat::downl │ │ │ -00054c30: 6f61 645f 7061 796c 6f61 6429 3b0a 0909 oad_payload);... │ │ │ -00054c40: 7d0a 0a09 092f 2f20 6176 6f69 6420 6469 }....// avoid di │ │ │ -00054c50: 7669 7369 6f6e 2062 7920 7a65 726f 0a09 vision by zero.. │ │ │ -00054c60: 0969 6620 2872 6174 6520 266c 743b 2035 .if (rate < 5 │ │ │ -00054c70: 3029 2072 6174 6520 3d20 3530 3b0a 0a09 0) rate = 50;... │ │ │ -00054c80: 092f 2f20 6176 6572 6167 6520 6f66 2063 .// average of c │ │ │ -00054c90: 7572 7265 6e74 2072 6174 6520 616e 6420 urrent rate and │ │ │ -00054ca0: 7065 616b 0a2f 2f09 0972 6174 6520 3d20 peak.//..rate = │ │ │ -00054cb0: 2872 6174 6520 2b20 6d5f 646f 776e 6c6f (rate + m_downlo │ │ │ -00054cc0: 6164 5f72 6174 655f 7065 616b 2920 2f20 ad_rate_peak) / │ │ │ -00054cd0: 323b 0a0a 0909 7265 7475 726e 206d 696c 2;....return mil │ │ │ -00054ce0: 6c69 7365 636f 6e64 7328 2873 7464 3a3a liseconds((std:: │ │ │ -00054cf0: 696e 7436 345f 7428 6d5f 6f75 7473 7461 int64_t(m_outsta │ │ │ -00054d00: 6e64 696e 675f 6279 7465 7329 202b 2065 nding_bytes) + e │ │ │ -00054d10: 7874 7261 5f62 7974 6573 0a09 0909 0909 xtra_bytes...... │ │ │ -00054d20: 0909 092b 206d 5f71 7565 7565 645f 7469 ...+ m_queued_ti │ │ │ -00054d30: 6d65 5f63 7269 7469 6361 6c20 2a20 742d me_critical * t- │ │ │ -00054d40: 2667 743b 626c 6f63 6b5f 7369 7a65 2829 >block_size() │ │ │ -00054d50: 202a 2031 3030 3029 0a09 0909 2f20 7261 * 1000)..../ ra │ │ │ -00054d60: 7465 293b 0a09 7d0a 0a09 766f 6964 2070 te);..}...void p │ │ │ -00054d70: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a eer_connection:: │ │ │ -00054d80: 6164 645f 7374 6174 2873 7464 3a3a 696e add_stat(std::in │ │ │ -00054d90: 7436 345f 7420 636f 6e73 7420 646f 776e t64_t const down │ │ │ -00054da0: 6c6f 6164 6564 2c20 7374 643a 3a69 6e74 loaded, std::int │ │ │ -00054db0: 3634 5f74 2063 6f6e 7374 2075 706c 6f61 64_t const uploa │ │ │ -00054dc0: 6465 6429 0a09 7b0a 0909 544f 5252 454e ded)..{...TORREN │ │ │ -00054dd0: 545f 4153 5345 5254 2869 735f 7369 6e67 T_ASSERT(is_sing │ │ │ -00054de0: 6c65 5f74 6872 6561 6428 2929 3b0a 0909 le_thread());... │ │ │ -00054df0: 6d5f 7374 6174 6973 7469 6373 2e61 6464 m_statistics.add │ │ │ -00054e00: 5f73 7461 7428 646f 776e 6c6f 6164 6564 _stat(downloaded │ │ │ -00054e10: 2c20 7570 6c6f 6164 6564 293b 0a09 7d0a , uploaded);..}. │ │ │ -00054e20: 0a09 7368 6131 5f68 6173 6820 7065 6572 ..sha1_hash peer │ │ │ -00054e30: 5f63 6f6e 6e65 6374 696f 6e3a 3a61 7373 _connection::ass │ │ │ -00054e40: 6f63 6961 7465 645f 696e 666f 5f68 6173 ociated_info_has │ │ │ -00054e50: 6828 2920 636f 6e73 740a 097b 0a09 0961 h() const..{...a │ │ │ -00054e60: 7574 6f20 7420 3d20 6173 736f 6369 6174 uto t = associat │ │ │ -00054e70: 6564 5f74 6f72 7265 6e74 2829 2e6c 6f63 ed_torrent().loc │ │ │ -00054e80: 6b28 293b 0a09 0954 4f52 5245 4e54 5f41 k();...TORRENT_A │ │ │ -00054e90: 5353 4552 5428 7429 3b0a 0909 6175 746f SSERT(t);...auto │ │ │ -00054ea0: 2063 6f6e 7374 2661 6d70 3b20 6968 203d const& ih = │ │ │ -00054eb0: 2074 2d26 6774 3b69 6e66 6f5f 6861 7368 t->info_hash │ │ │ -00054ec0: 2829 3b0a 0909 2f2f 2069 6620 7072 6f74 ();...// if prot │ │ │ -00054ed0: 6f63 6f6c 5f76 3220 6973 2073 6574 206f ocol_v2 is set o │ │ │ -00054ee0: 6e20 7468 6520 7065 6572 2c20 7468 6973 n the peer, this │ │ │ -00054ef0: 2062 6574 7465 7220 6265 2061 2076 3220 better be a v2 │ │ │ -00054f00: 746f 7272 656e 742c 0a3c 2f70 7265 3e3c torrent,.
    < │ │ │ -00054f10: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00054f40: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00054f50: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/peer_ │ │ │ -00054f80: 636f 6e6e 6563 7469 6f6e 2e63 7070 3a31 connection.cpp:1 │ │ │ -00054f90: 3137 343c 2f61 3e3c 2f74 643e 3c74 643e 174 │ │ │ -00054fa0: 7374 6f72 6520 7468 6520 7361 6832 3536 store the sah256 │ │ │ -00054fb0: 2068 6173 6820 6f66 2074 6865 2064 6573 hash of the des │ │ │ -00054fc0: 7469 6e61 7469 6f6e 2069 6e20 7468 6520 tination in the │ │ │ -00054fd0: 6932 705f 7065 6572 2073 7472 7563 742c i2p_peer struct, │ │ │ -00054fe0: 2073 6f20 7765 2064 6f6e 2774 2068 6176 so we don't hav │ │ │ -00054ff0: 6520 746f 2072 6563 6f6d 7075 7465 2069 e to recompute i │ │ │ -00055000: 7420 6576 6572 7920 7469 6d65 3c2f 7464 t every time

    store │ │ │ -00055060: 7468 6520 7361 6832 3536 2068 6173 6820 the sah256 hash │ │ │ -00055070: 6f66 2074 6865 2064 6573 7469 6e61 7469 of the destinati │ │ │ -00055080: 6f6e 2069 6e20 7468 650a 6932 705f 7065 on in the.i2p_pe │ │ │ -00055090: 6572 2073 7472 7563 742c 2073 6f20 7765 er struct, so we │ │ │ -000550a0: 2064 6f6e 2774 2068 6176 6520 746f 2072 don't have to r │ │ │ -000550b0: 6563 6f6d 7075 7465 2069 7420 6576 6572 ecompute it ever │ │ │ -000550c0: 7920 7469 6d65 3c2f 6832 3e3c 6834 3e2e y time

    . │ │ │ -000550d0: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ -000550e0: 6374 696f 6e2e 6370 703a 3131 3734 3c2f ction.cpp:1174
    ..a
    │ │ │ -00055130: 7574 6f20 7420 3d20 6d5f 746f 7272 656e  uto t = m_torren
    │ │ │ -00055140: 742e 6c6f 636b 2829 3b0a 0909 6966 2028  t.lock();...if (
    │ │ │ -00055150: 2174 2920 7265 7475 726e 3b0a 0909 742d  !t) return;...t-
    │ │ │ -00055160: 2667 743b 7365 6e74 5f73 796e 2869 7076  >sent_syn(ipv
    │ │ │ -00055170: 3629 3b0a 097d 0a0a 0976 6f69 6420 7065  6);..}...void pe
    │ │ │ -00055180: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a72  er_connection::r
    │ │ │ -00055190: 6563 6569 7665 645f 7379 6e61 636b 2862  eceived_synack(b
    │ │ │ -000551a0: 6f6f 6c20 636f 6e73 7420 6970 7636 290a  ool const ipv6).
    │ │ │ -000551b0: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ -000551c0: 4552 5428 6973 5f73 696e 676c 655f 7468  ERT(is_single_th
    │ │ │ -000551d0: 7265 6164 2829 293b 0a09 096d 5f73 7461  read());...m_sta
    │ │ │ -000551e0: 7469 7374 6963 732e 7265 6365 6976 6564  tistics.received
    │ │ │ -000551f0: 5f73 796e 6163 6b28 6970 7636 293b 0a09  _synack(ipv6);..
    │ │ │ -00055200: 0969 6620 286d 5f69 676e 6f72 655f 7374  .if (m_ignore_st
    │ │ │ -00055210: 6174 7329 2072 6574 7572 6e3b 0a09 0961  ats) return;...a
    │ │ │ -00055220: 7574 6f20 7420 3d20 6d5f 746f 7272 656e  uto t = m_torren
    │ │ │ -00055230: 742e 6c6f 636b 2829 3b0a 0909 6966 2028  t.lock();...if (
    │ │ │ -00055240: 2174 2920 7265 7475 726e 3b0a 0909 742d  !t) return;...t-
    │ │ │ -00055250: 2667 743b 7265 6365 6976 6564 5f73 796e  >received_syn
    │ │ │ -00055260: 6163 6b28 6970 7636 293b 0a09 7d0a 0a09  ack(ipv6);..}...
    │ │ │ -00055270: 7065 6572 5f65 6e64 706f 696e 745f 7420  peer_endpoint_t 
    │ │ │ -00055280: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ -00055290: 3a72 656d 6f74 655f 656e 6470 6f69 6e74  :remote_endpoint
    │ │ │ -000552a0: 2829 2063 6f6e 7374 0a09 7b0a 2369 6620  () const..{.#if 
    │ │ │ -000552b0: 544f 5252 454e 545f 5553 455f 4932 500a  TORRENT_USE_I2P.
    │ │ │ -000552c0: 0909 6966 2028 6175 746f 2073 203d 2073  ..if (auto s = s
    │ │ │ -000552d0: 7464 3a3a 6765 745f 6966 266c 743b 6932  td::get_if<i2
    │ │ │ -000552e0: 705f 7374 7265 616d 2667 743b 2826 616d  p_stream>(&am
    │ │ │ -000552f0: 703b 6d5f 736f 636b 6574 2929 0a09 097b  p;m_socket))...{
    │ │ │ -00055300: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00055330: 0909 7265 7475 726e 2068 6173 6865 7232 ..return hasher2 │ │ │ -00055340: 3536 2862 6173 6536 3464 6563 6f64 655f 56(base64decode_ │ │ │ -00055350: 6932 7028 732d 2667 743b 6465 7374 696e i2p(s->destin │ │ │ -00055360: 6174 696f 6e28 2929 292e 6669 6e61 6c28 ation())).final( │ │ │ -00055370: 293b 0a3c 2f64 6976 3e09 097d 0a23 656e );.
    ..}.#en │ │ │ -00055380: 6469 660a 0909 7265 7475 726e 206d 5f72 dif...return m_r │ │ │ -00055390: 656d 6f74 653b 0a09 7d0a 0a23 6966 2054 emote;..}..#if T │ │ │ -000553a0: 4f52 5245 4e54 5f55 5345 5f49 3250 0a09 ORRENT_USE_I2P.. │ │ │ -000553b0: 7374 643a 3a73 7472 696e 6720 636f 6e73 std::string cons │ │ │ -000553c0: 7426 616d 703b 2070 6565 725f 636f 6e6e t& peer_conn │ │ │ -000553d0: 6563 7469 6f6e 3a3a 6465 7374 696e 6174 ection::destinat │ │ │ -000553e0: 696f 6e28 2920 636f 6e73 740a 097b 0a09 ion() const..{.. │ │ │ -000553f0: 0973 7461 7469 6320 7374 643a 3a73 7472 .static std::str │ │ │ -00055400: 696e 6720 636f 6e73 7420 656d 7074 793b ing const empty; │ │ │ -00055410: 0a09 0961 7574 6f20 7320 3d20 7374 643a ...auto s = std: │ │ │ -00055420: 3a67 6574 5f69 6626 6c74 3b69 3270 5f73 :get_if<i2p_s │ │ │ -00055430: 7472 6561 6d26 6774 3b28 2661 6d70 3b6d tream>(&m │ │ │ -00055440: 5f73 6f63 6b65 7429 3b0a 0909 7265 7475 _socket);...retu │ │ │ -00055450: 726e 2073 203f 2073 2d26 6774 3b64 6573 rn s ? s->des │ │ │ -00055460: 7469 6e61 7469 6f6e 2829 203a 2065 6d70 tination() : emp │ │ │ -00055470: 7479 3b0a 097d 0a0a 0973 7464 3a3a 7374 ty;..}...std::st │ │ │ -00055480: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ -00055490: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a peer_connection: │ │ │ -000554a0: 3a6c 6f63 616c 5f69 3270 5f65 6e64 706f :local_i2p_endpo │ │ │ -000554b0: 696e 7428 2920 636f 6e73 740a 097b 0a09 int() const..{.. │ │ │ -000554c0: 0973 7461 7469 6320 7374 643a 3a73 7472 .static std::str │ │ │ -000554d0: 696e 6720 636f 6e73 7420 656d 7074 793b ing const empty; │ │ │ -000554e0: 0a09 0961 7574 6f20 7320 3d20 7374 643a ...auto s = std: │ │ │ -000554f0: 3a67 6574 5f69 6626 6c74 3b69 3270 5f73 :get_if<i2p_s │ │ │ -00055500: 7472 6561 6d26 6774 3b28 2661 6d70 3b6d tream>(&m │ │ │ -00055510: 5f73 6f63 6b65 7429 3b0a 0909 7265 7475 _socket);...retu │ │ │ -00055520: 726e 2073 203f 2073 2d26 6774 3b6c 6f63 rn s ? s->loc │ │ │ -00055530: 616c 5f69 3270 5f65 6e64 706f 696e 7428 al_i2p_endpoint( │ │ │ -00055540: 2920 3a20 656d 7074 793b 0a09 7d0a 2365 ) : empty;..}.#e │ │ │ -00055550: 6e64 6966 0a0a 0974 7970 6564 5f62 6974 ndif...typed_bit │ │ │ -00055560: 6669 656c 6426 6c74 3b70 6965 6365 5f69 field<piece_i │ │ │ -00055570: 6e64 6578 5f74 2667 743b 2063 6f6e 7374 ndex_t> const │ │ │ -00055580: 2661 6d70 3b20 7065 6572 5f63 6f6e 6e65 & peer_conne │ │ │ -00055590: 6374 696f 6e3a 3a67 6574 5f62 6974 6669 ction::get_bitfi │ │ │ -000555a0: 656c 6428 2920 636f 6e73 740a 097b 0a09 eld() const..{.. │ │ │ -000555b0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -000555c0: 6973 5f73 696e 676c 655f 7468 7265 6164 is_single_thread │ │ │ -000555d0: 2829 293b 0a09 0972 6574 7572 6e20 6d5f ());...return m_ │ │ │ -000555e0: 6861 7665 5f70 6965 6365 3b0a 097d 0a0a have_piece;..}.. │ │ │ -000555f0: 0976 6f69 6420 7065 6572 5f63 6f6e 6e65 .void peer_conne │ │ │ -00055600: 6374 696f 6e3a 3a72 6563 6569 7665 645f ction::received_ │ │ │ -00055610: 7661 6c69 645f 6461 7461 2870 6965 6365 valid_data(piece │ │ │ -00055620: 5f69 6e64 6578 5f74 2063 6f6e 7374 2069 _index_t const i │ │ │ -00055630: 6e64 6578 290a 097b 0a09 0954 4f52 5245 ndex)..{...TORRE │ │ │ -00055640: 4e54 5f41 5353 4552 5428 6973 5f73 696e NT_ASSERT(is_sin │ │ │ -00055650: 676c 655f 7468 7265 6164 2829 293b 0a3c gle_thread());.< │ │ │ -00055660: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00055670: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00055680: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00055690: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -000556a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -000556d0: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e /peer_connection │ │ │ -000556e0: 2e63 7070 3a33 3533 343c 2f61 3e3c 2f74 .cpp:3534sort the a │ │ │ -00055700: 6c6c 6f77 6564 2066 6173 7420 7365 7420 llowed fast set │ │ │ -00055710: 696e 2070 7269 6f72 6974 7920 6f72 6465 in priority orde │ │ │ -00055720: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    s │ │ │ -00055770: 6f72 7420 7468 6520 616c 6c6f 7765 6420 ort the allowed │ │ │ -00055780: 6661 7374 2073 6574 2069 6e20 7072 696f fast set in prio │ │ │ -00055790: 7269 7479 206f 7264 6572 3c2f 6832 3e3c rity order

    < │ │ │ -000557a0: 6834 3e2e 2e2f 7372 632f 7065 6572 5f63 h4>../src/peer_c │ │ │ -000557b0: 6f6e 6e65 6374 696f 6e2e 6370 703a 3335 onnection.cpp:35 │ │ │ -000557c0: 3334 3c2f 6834 3e3c 7072 6520 7374 796c 34

    ...// if the pe
    │ │ │ -00055810: 6572 2068 6173 2074 6865 2070 6965 6365  er has the piece
    │ │ │ -00055820: 2061 6e64 2077 6520 7761 6e74 0a09 092f   and we want.../
    │ │ │ -00055830: 2f20 746f 2064 6f77 6e6c 6f61 6420 6974  / to download it
    │ │ │ -00055840: 2c20 7265 7175 6573 7420 6974 0a09 0969  , request it...i
    │ │ │ -00055850: 6620 2869 6e64 6578 2026 6c74 3b20 6d5f  f (index < m_
    │ │ │ -00055860: 6861 7665 5f70 6965 6365 2e65 6e64 5f69  have_piece.end_i
    │ │ │ -00055870: 6e64 6578 2829 0a09 0909 2661 6d70 3b26  ndex()....&&
    │ │ │ -00055880: 616d 703b 206d 5f68 6176 655f 7069 6563  amp; m_have_piec
    │ │ │ -00055890: 655b 696e 6465 785d 0a09 0909 2661 6d70  e[index]....&
    │ │ │ -000558a0: 3b26 616d 703b 2021 742d 2667 743b 6861  ;& !t->ha
    │ │ │ -000558b0: 7665 5f70 6965 6365 2869 6e64 6578 290a  ve_piece(index).
    │ │ │ -000558c0: 0909 0926 616d 703b 2661 6d70 3b20 742d  ...&& t-
    │ │ │ -000558d0: 2667 743b 7661 6c69 645f 6d65 7461 6461  >valid_metada
    │ │ │ -000558e0: 7461 2829 0a09 0909 2661 6d70 3b26 616d  ta()....&&am
    │ │ │ -000558f0: 703b 2074 2d26 6774 3b68 6173 5f70 6963  p; t->has_pic
    │ │ │ -00055900: 6b65 7228 290a 0909 0926 616d 703b 2661  ker()....&&a
    │ │ │ -00055910: 6d70 3b20 742d 2667 743b 7069 636b 6572  mp; t->picker
    │ │ │ -00055920: 2829 2e70 6965 6365 5f70 7269 6f72 6974  ().piece_priorit
    │ │ │ -00055930: 7928 696e 6465 7829 2026 6774 3b20 646f  y(index) > do
    │ │ │ -00055940: 6e74 5f64 6f77 6e6c 6f61 6429 0a09 097b  nt_download)...{
    │ │ │ -00055950: 0a09 0909 742d 2667 743b 7065 6572 5f69  ....t->peer_i
    │ │ │ -00055960: 735f 696e 7465 7265 7374 696e 6728 2a74  s_interesting(*t
    │ │ │ -00055970: 6869 7329 3b0a 0909 7d0a 097d 0a0a 0973  his);...}..}...s
    │ │ │ -00055980: 7464 3a3a 7665 6374 6f72 266c 743b 7069  td::vector<pi
    │ │ │ -00055990: 6563 655f 696e 6465 785f 7426 6774 3b20  ece_index_t> 
    │ │ │ -000559a0: 636f 6e73 7426 616d 703b 2070 6565 725f  const& peer_
    │ │ │ -000559b0: 636f 6e6e 6563 7469 6f6e 3a3a 616c 6c6f  connection::allo
    │ │ │ -000559c0: 7765 645f 6661 7374 2829 0a09 7b0a 0909  wed_fast()..{...
    │ │ │ -000559d0: 544f 5252 454e 545f 4153 5345 5254 2869  TORRENT_ASSERT(i
    │ │ │ -000559e0: 735f 7369 6e67 6c65 5f74 6872 6561 6428  s_single_thread(
    │ │ │ -000559f0: 2929 3b0a 0909 6175 746f 2074 203d 206d  ));...auto t = m
    │ │ │ -00055a00: 5f74 6f72 7265 6e74 2e6c 6f63 6b28 293b  _torrent.lock();
    │ │ │ -00055a10: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -00055a20: 5428 7429 3b0a 0a3c 6469 7620 7374 796c  T(t);..
    ..return m_ │ │ │ -00055a60: 616c 6c6f 7765 645f 6661 7374 3b0a 3c2f allowed_fast;..}...bool pe │ │ │ -00055a80: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a63 er_connection::c │ │ │ -00055a90: 616e 5f72 6571 7565 7374 5f74 696d 655f an_request_time_ │ │ │ -00055aa0: 6372 6974 6963 616c 2829 2063 6f6e 7374 critical() const │ │ │ -00055ab0: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ -00055ac0: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ -00055ad0: 6872 6561 6428 2929 3b0a 0909 6966 2028 hread());...if ( │ │ │ -00055ae0: 6861 735f 7065 6572 5f63 686f 6b65 6428 has_peer_choked( │ │ │ -00055af0: 2920 7c7c 2021 6973 5f69 6e74 6572 6573 ) || !is_interes │ │ │ -00055b00: 7469 6e67 2829 2920 7265 7475 726e 2066 ting()) return f │ │ │ -00055b10: 616c 7365 3b0a 0909 6966 2028 696e 7428 alse;...if (int( │ │ │ -00055b20: 6d5f 646f 776e 6c6f 6164 5f71 7565 7565 m_download_queue │ │ │ -00055b30: 2e73 697a 6528 2929 202b 2069 6e74 286d .size()) + int(m │ │ │ -00055b40: 5f72 6571 7565 7374 5f71 7565 7565 2e73 _request_queue.s │ │ │ -00055b50: 697a 6528 2929 0a09 0909 2667 743b 206d ize())....> m │ │ │ -00055b60: 5f64 6573 6972 6564 5f71 7565 7565 5f73 _desired_queue_s │ │ │ -00055b70: 697a 6520 2a20 3229 2072 6574 7572 6e20 ize * 2) return │ │ │ -00055b80: 6661 6c73 653b 0a09 0969 6620 286f 6e5f false;...if (on_ │ │ │ -00055b90: 7061 726f 6c65 2829 2920 7265 7475 726e parole()) return │ │ │ -00055ba0: 2066 616c 7365 3b0a 0909 6966 2028 6d5f false;...if (m_ │ │ │ -00055bb0: 6469 7363 6f6e 6e65 6374 696e 6729 2072 disconnecting) r │ │ │ -00055bc0: 6574 7572 6e20 6661 6c73 653b 0a09 0961 eturn false;...a │ │ │ -00055bd0: 7574 6f20 7420 3d20 6d5f 746f 7272 656e uto t = m_torren │ │ │ -00055be0: 742e 6c6f 636b 2829 3b0a 0909 544f 5252 t.lock();...TORR │ │ │ -00055bf0: 454e 545f 4153 5345 5254 2874 293b 0a09 ENT_ASSERT(t);.. │ │ │ -00055c00: 0969 6620 2874 2d26 6774 3b75 706c 6f61 .if (t->uploa │ │ │ -00055c10: 645f 6d6f 6465 2829 2920 7265 7475 726e d_mode()) return │ │ │ -00055c20: 2066 616c 7365 3b0a 0a09 092f 2f20 6967 false;....// ig │ │ │ -00055c30: 6e6f 7265 2073 6e75 6262 6564 2070 6565 nore snubbed pee │ │ │ -00055c40: 7273 2c20 7369 6e63 6520 7468 6579 2772 rs, since they'r │ │ │ -00055c50: 6520 6e6f 7420 6c69 6b65 6c79 2074 6f20 e not likely to │ │ │ -00055c60: 7265 7475 726e 2070 6965 6365 7320 696e return pieces in │ │ │ -00055c70: 2061 0a09 092f 2f20 7469 6d65 6c79 206d a...// timely m │ │ │ -00055c80: 616e 6e65 7220 616e 7977 6179 0a09 0969 anner anyway...i │ │ │ -00055c90: 6620 286d 5f73 6e75 6262 6564 2920 7265 f (m_snubbed) re │ │ │ -00055ca0: 7475 726e 2066 616c 7365 3b0a 0909 7265 turn false;...re │ │ │ -00055cb0: 7475 726e 2074 7275 653b 0a09 7d0a 0a09 turn true;..}... │ │ │ -00055cc0: 626f 6f6c 2070 6565 725f 636f 6e6e 6563 bool peer_connec │ │ │ -00055cd0: 7469 6f6e 3a3a 6d61 6b65 5f74 696d 655f tion::make_time_ │ │ │ -00055ce0: 6372 6974 6963 616c 2870 6965 6365 5f62 critical(piece_b │ │ │ -00055cf0: 6c6f 636b 2063 6f6e 7374 2661 6d70 3b20 lock const& │ │ │ -00055d00: 626c 6f63 6b29 0a09 7b0a 0909 544f 5252 block)..{...TORR │ │ │ -00055d10: 454e 545f 4153 5345 5254 2869 735f 7369 ENT_ASSERT(is_si │ │ │ -00055d20: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a ngle_thread());. │ │ │ -00055d30: 0909 6175 746f 2063 6f6e 7374 2072 6974 ..auto const rit │ │ │ -00055d40: 203d 2073 7464 3a3a 6669 6e64 5f69 6628 = std::find_if( │ │ │ -00055d50: 6d5f 7265 7175 6573 745f 7175 6575 652e m_request_queue. │ │ │ -00055d60: 6265 6769 6e28 290a 0909 092c 206d 5f72 begin()...., m_r │ │ │ -00055d70: 6571 7565 7374 5f71 7565 7565 2e65 6e64 equest_queue.end │ │ │ -00055d80: 2829 2c20 6175 783a 3a68 6173 5f62 6c6f (), aux::has_blo │ │ │ -00055d90: 636b 2862 6c6f 636b 2929 3b0a 0909 6966 ck(block));...if │ │ │ -00055da0: 2028 7269 7420 3d3d 206d 5f72 6571 7565 (rit == m_reque │ │ │ -00055db0: 7374 5f71 7565 7565 2e65 6e64 2829 2920 st_queue.end()) │ │ │ -00055dc0: 7265 7475 726e 2066 616c 7365 3b0a 2369 return false;.#i │ │ │ -00055dd0: 6620 544f 5252 454e 545f 5553 455f 4153 f TORRENT_USE_AS │ │ │ -00055de0: 5345 5254 530a 0909 6175 746f 2074 203d SERTS...auto t = │ │ │ -00055df0: 206d 5f74 6f72 7265 6e74 2e6c 6f63 6b28 m_torrent.lock( │ │ │ -00055e00: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ -00055e10: 4552 5428 7429 3b0a 0909 544f 5252 454e ERT(t);...TORREN │ │ │ -00055e20: 545f 4153 5345 5254 2874 2d26 6774 3b68 T_ASSERT(t->h │ │ │ -00055e30: 6173 5f70 6963 6b65 7228 2929 3b0a 3c2f as_picker());.r │ │ │ -00055e70: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00055e80: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00055eb0: 7061 636b 6574 5f62 7566 6665 722e 6370 packet_buffer.cp │ │ │ -00055ec0: 703a 3133 343c 2f61 3e3c 2f74 643e 3c74 p:134use compare_le │ │ │ -00055ee0: 7373 5f77 7261 7020 666f 7220 7468 6973 ss_wrap for this │ │ │ -00055ef0: 2063 6f6d 7061 7269 736f 6e20 6173 2077 comparison as w │ │ │ -00055f00: 656c 6c3c 2f74 643e 3c2f 7472 3e3c 7472 ell

    use compare_les │ │ │ -00055f60: 735f 7772 6170 2066 6f72 2074 6869 7320 s_wrap for this │ │ │ -00055f70: 636f 6d70 6172 6973 6f6e 2061 7320 7765 comparison as we │ │ │ -00055f80: 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ll

    ../sr │ │ │ -00055f90: 632f 7061 636b 6574 5f62 7566 6665 722e c/packet_buffer. │ │ │ -00055fa0: 6370 703a 3133 343c 2f68 343e 3c70 7265 cpp:134

    .{...INVAR
    │ │ │ -00055ff0: 4941 4e54 5f43 4845 434b 3b0a 0909 544f  IANT_CHECK;...TO
    │ │ │ -00056000: 5252 454e 545f 4153 5345 5254 5f56 414c  RRENT_ASSERT_VAL
    │ │ │ -00056010: 2873 697a 6520 266c 743b 3d20 3078 6666  (size <= 0xff
    │ │ │ -00056020: 6666 2c20 7369 7a65 293b 0a09 0973 7464  ff, size);...std
    │ │ │ -00056030: 3a3a 7569 6e74 3332 5f74 206e 6577 5f73  ::uint32_t new_s
    │ │ │ -00056040: 697a 6520 3d20 6d5f 6361 7061 6369 7479  ize = m_capacity
    │ │ │ -00056050: 203d 3d20 3020 3f20 3136 203a 206d 5f63   == 0 ? 16 : m_c
    │ │ │ -00056060: 6170 6163 6974 793b 0a0a 0909 7768 696c  apacity;....whil
    │ │ │ -00056070: 6520 286e 6577 5f73 697a 6520 266c 743b  e (new_size <
    │ │ │ -00056080: 2073 697a 6529 0a09 0909 6e65 775f 7369   size)....new_si
    │ │ │ -00056090: 7a65 2026 6c74 3b26 6c74 3b3d 2031 3b0a  ze <<= 1;.
    │ │ │ -000560a0: 0a09 0961 7574 6f20 6e65 775f 7374 6f72  ...auto new_stor
    │ │ │ -000560b0: 6167 6520 3d20 6175 783a 3a6d 616b 655f  age = aux::make_
    │ │ │ -000560c0: 756e 6971 7565 266c 743b 7061 636b 6574  unique<packet
    │ │ │ -000560d0: 5f70 7472 5b5d 2c20 696e 6465 785f 7479  _ptr[], index_ty
    │ │ │ -000560e0: 7065 2667 743b 286e 6577 5f73 697a 6529  pe>(new_size)
    │ │ │ -000560f0: 3b0a 0a09 0966 6f72 2028 696e 6465 785f  ;....for (index_
    │ │ │ -00056100: 7479 7065 2069 203d 206d 5f66 6972 7374  type i = m_first
    │ │ │ -00056110: 3b20 6920 266c 743b 2028 6d5f 6669 7273  ; i < (m_firs
    │ │ │ -00056120: 7420 2b20 6d5f 6361 7061 6369 7479 293b  t + m_capacity);
    │ │ │ -00056130: 202b 2b69 290a 0909 096e 6577 5f73 746f   ++i)....new_sto
    │ │ │ -00056140: 7261 6765 5b69 2026 616d 703b 2028 6e65  rage[i & (ne
    │ │ │ -00056150: 775f 7369 7a65 202d 2031 295d 203d 2073  w_size - 1)] = s
    │ │ │ -00056160: 7464 3a3a 6d6f 7665 286d 5f73 746f 7261  td::move(m_stora
    │ │ │ -00056170: 6765 5b69 2026 616d 703b 2028 6d5f 6361  ge[i & (m_ca
    │ │ │ -00056180: 7061 6369 7479 202d 2031 295d 293b 0a0a  pacity - 1)]);..
    │ │ │ -00056190: 0909 6d5f 7374 6f72 6167 6520 3d20 7374  ..m_storage = st
    │ │ │ -000561a0: 643a 3a6d 6f76 6528 6e65 775f 7374 6f72  d::move(new_stor
    │ │ │ -000561b0: 6167 6529 3b0a 0909 6d5f 6361 7061 6369  age);...m_capaci
    │ │ │ -000561c0: 7479 203d 206e 6577 5f73 697a 653b 0a09  ty = new_size;..
    │ │ │ -000561d0: 7d0a 0a09 7061 636b 6574 5f70 7472 2070  }...packet_ptr p
    │ │ │ -000561e0: 6163 6b65 745f 6275 6666 6572 3a3a 7265  acket_buffer::re
    │ │ │ -000561f0: 6d6f 7665 2869 6e64 6578 5f74 7970 6520  move(index_type 
    │ │ │ -00056200: 6964 7829 0a09 7b0a 0909 494e 5641 5249  idx)..{...INVARI
    │ │ │ -00056210: 414e 545f 4348 4543 4b3b 0a3c 6469 7620  ANT_CHECK;.
    ..if (i │ │ │ -00056250: 6478 2026 6774 3b3d 206d 5f66 6972 7374 dx >= m_first │ │ │ -00056260: 202b 206d 5f63 6170 6163 6974 7929 0a3c + m_capacity).< │ │ │ -00056270: 2f64 6976 3e09 0909 7265 7475 726e 207b /div>...return { │ │ │ -00056280: 7d3b 0a0a 0909 6966 2028 636f 6d70 6172 };....if (compar │ │ │ -00056290: 655f 6c65 7373 5f77 7261 7028 6964 782c e_less_wrap(idx, │ │ │ -000562a0: 206d 5f66 6972 7374 2c20 3078 6666 6666 m_first, 0xffff │ │ │ -000562b0: 2929 0a09 0909 7265 7475 726e 207b 7d3b ))....return {}; │ │ │ -000562c0: 0a0a 0909 7374 643a 3a73 697a 655f 7420 ....std::size_t │ │ │ -000562d0: 636f 6e73 7420 6d61 736b 203d 206d 5f63 const mask = m_c │ │ │ -000562e0: 6170 6163 6974 7920 2d20 313b 0a09 0970 apacity - 1;...p │ │ │ -000562f0: 6163 6b65 745f 7074 7220 6f6c 645f 7661 acket_ptr old_va │ │ │ -00056300: 6c75 6520 3d20 7374 643a 3a6d 6f76 6528 lue = std::move( │ │ │ -00056310: 6d5f 7374 6f72 6167 655b 6964 7820 2661 m_storage[idx &a │ │ │ -00056320: 6d70 3b20 6d61 736b 5d29 3b0a 0909 6d5f mp; mask]);...m_ │ │ │ -00056330: 7374 6f72 6167 655b 6964 7820 2661 6d70 storage[idx & │ │ │ -00056340: 3b20 6d61 736b 5d2e 7265 7365 7428 293b ; mask].reset(); │ │ │ -00056350: 0a0a 0909 6966 2028 6f6c 645f 7661 6c75 ....if (old_valu │ │ │ -00056360: 6529 0a09 097b 0a09 0909 2d2d 6d5f 7369 e)...{....--m_si │ │ │ -00056370: 7a65 3b0a 0909 0969 6620 286d 5f73 697a ze;....if (m_siz │ │ │ -00056380: 6520 3d3d 2030 2920 6d5f 6c61 7374 203d e == 0) m_last = │ │ │ -00056390: 206d 5f66 6972 7374 3b0a 0909 7d0a 0a09 m_first;...}... │ │ │ -000563a0: 0969 6620 2869 6478 203d 3d20 6d5f 6669 .if (idx == m_fi │ │ │ -000563b0: 7273 7420 2661 6d70 3b26 616d 703b 206d rst && m │ │ │ -000563c0: 5f73 697a 6520 213d 2030 290a 0909 7b0a _size != 0)...{. │ │ │ -000563d0: 0909 092b 2b6d 5f66 6972 7374 3b0a 0909 ...++m_first;... │ │ │ -000563e0: 0966 6f72 2028 696e 6465 785f 7479 7065 .for (index_type │ │ │ -000563f0: 2069 203d 2030 3b20 6920 266c 743b 206d i = 0; i < m │ │ │ -00056400: 5f63 6170 6163 6974 793b 202b 2b69 2c20 _capacity; ++i, │ │ │ -00056410: 2b2b 6d5f 6669 7273 7429 0a09 0909 0969 ++m_first).....i │ │ │ -00056420: 6620 286d 5f73 746f 7261 6765 5b6d 5f66 f (m_storage[m_f │ │ │ -00056430: 6972 7374 2026 616d 703b 206d 6173 6b5d irst & mask] │ │ │ -00056440: 2920 6272 6561 6b3b 0a09 0909 6d5f 6669 ) break;....m_fi │ │ │ -00056450: 7273 7420 2661 6d70 3b3d 2030 7866 6666 rst &= 0xfff │ │ │ -00056460: 663b 0a09 097d 0a0a 0909 6966 2028 2828 f;...}....if ((( │ │ │ -00056470: 6964 7820 2b20 3129 2026 616d 703b 2030 idx + 1) & 0 │ │ │ -00056480: 7866 6666 6629 203d 3d20 6d5f 6c61 7374 xffff) == m_last │ │ │ -00056490: 2026 616d 703b 2661 6d70 3b20 6d5f 7369 && m_si │ │ │ -000564a0: 7a65 2021 3d20 3029 0a09 097b 0a09 0909 ze != 0)...{.... │ │ │ -000564b0: 2d2d 6d5f 6c61 7374 3b0a 0909 0966 6f72 --m_last;....for │ │ │ -000564c0: 2028 696e 6465 785f 7479 7065 2069 203d (index_type i = │ │ │ -000564d0: 2030 3b20 6920 266c 743b 206d 5f63 6170 0; i < m_cap │ │ │ -000564e0: 6163 6974 793b 202b 2b69 2c20 2d2d 6d5f acity; ++i, --m_ │ │ │ -000564f0: 6c61 7374 290a 0909 0909 6966 2028 6d5f last).....if (m_ │ │ │ -00056500: 7374 6f72 6167 655b 6d5f 6c61 7374 2026 storage[m_last & │ │ │ -00056510: 616d 703b 206d 6173 6b5d 2920 6272 6561 amp; mask]) brea │ │ │ -00056520: 6b3b 0a09 0909 2b2b 6d5f 6c61 7374 3b0a k;....++m_last;. │ │ │ -00056530: 0909 096d 5f6c 6173 7420 2661 6d70 3b3d ...m_last &= │ │ │ -00056540: 2030 7866 6666 663b 0a3c 2f70 7265 3e3c 0xffff;.
    < │ │ │ -00056550: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00056580: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00056590: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/sessi │ │ │ -000565c0: 6f6e 5f69 6d70 6c2e 6370 703a 3538 323c on_impl.cpp:582< │ │ │ -000565d0: 2f61 3e3c 2f74 643e 3c74 643e 636f 6d65 /a>come │ │ │ -000565e0: 2075 7020 7769 7468 2073 6f6d 6520 6162 up with some ab │ │ │ -000565f0: 7374 7261 6374 696f 6e20 746f 2064 6f20 straction to do │ │ │ -00056600: 7468 6973 2066 6f72 2067 6e75 746c 7320 this for gnutls │ │ │ -00056610: 6173 2077 656c 6c20 6c6f 6164 2063 6572 as well load cer │ │ │ -00056620: 7469 6669 6361 7465 7320 6672 6f6d 2074 tificates from t │ │ │ -00056630: 6865 2077 696e 646f 7773 2073 7973 7465 he windows syste │ │ │ -00056640: 6d20 6365 7274 6966 6963 6174 6520 7374 m certificate st │ │ │ -00056650: 6f72 653c 2f74 643e 3c2f 7472 3e3c 7472 ore

    come up with so │ │ │ -000566b0: 6d65 2061 6273 7472 6163 7469 6f6e 2074 me abstraction t │ │ │ -000566c0: 6f20 646f 2074 6869 7320 666f 7220 676e o do this for gn │ │ │ -000566d0: 7574 6c73 2061 7320 7765 6c6c 0a6c 6f61 utls as well.loa │ │ │ -000566e0: 6420 6365 7274 6966 6963 6174 6573 2066 d certificates f │ │ │ -000566f0: 726f 6d20 7468 6520 7769 6e64 6f77 7320 rom the windows │ │ │ -00056700: 7379 7374 656d 2063 6572 7469 6669 6361 system certifica │ │ │ -00056710: 7465 2073 746f 7265 3c2f 6832 3e3c 6834 te store

    ../src/session_ │ │ │ -00056730: 696d 706c 2e63 7070 3a35 3832 3c2f 6834 impl.cpp:582

    ..pau
    │ │ │ -00056780: 7365 2829 3b0a 097d 0a23 656e 6469 660a  se();..}.#endif.
    │ │ │ -00056790: 0a09 2f2f 2054 6869 7320 6675 6e63 7469  ..// This functi
    │ │ │ -000567a0: 6f6e 2069 7320 6361 6c6c 6564 2062 7920  on is called by 
    │ │ │ -000567b0: 7468 6520 6372 6561 7469 6e67 2074 6872  the creating thr
    │ │ │ -000567c0: 6561 642c 206e 6f74 2069 6e20 7468 6520  ead, not in the 
    │ │ │ -000567d0: 6d65 7373 6167 6520 6c6f 6f70 2773 0a09  message loop's..
    │ │ │ -000567e0: 2f2f 2069 6f5f 636f 6e74 6578 7420 7468  // io_context th
    │ │ │ -000567f0: 7265 6164 2e0a 0976 6f69 6420 7365 7373  read...void sess
    │ │ │ -00056800: 696f 6e5f 696d 706c 3a3a 7374 6172 745f  ion_impl::start_
    │ │ │ -00056810: 7365 7373 696f 6e28 290a 097b 0a23 6966  session()..{.#if
    │ │ │ -00056820: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ -00056830: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0973  ABLE_LOGGING...s
    │ │ │ -00056840: 6573 7369 6f6e 5f6c 6f67 2822 7374 6172  ession_log("star
    │ │ │ -00056850: 7420 7365 7373 696f 6e22 293b 0a23 656e  t session");.#en
    │ │ │ -00056860: 6469 660a 0a23 6966 2054 4f52 5245 4e54  dif..#if TORRENT
    │ │ │ -00056870: 5f55 5345 5f53 534c 0a09 0965 7272 6f72  _USE_SSL...error
    │ │ │ -00056880: 5f63 6f64 6520 6563 3b0a 0909 6d5f 7373  _code ec;...m_ss
    │ │ │ -00056890: 6c5f 6374 782e 7365 745f 6465 6661 756c  l_ctx.set_defaul
    │ │ │ -000568a0: 745f 7665 7269 6679 5f70 6174 6873 2865  t_verify_paths(e
    │ │ │ -000568b0: 6329 3b0a 2369 666e 6465 6620 544f 5252  c);.#ifndef TORR
    │ │ │ -000568c0: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ -000568d0: 494e 470a 0909 6966 2028 6563 2920 7365  ING...if (ec) se
    │ │ │ -000568e0: 7373 696f 6e5f 6c6f 6728 2253 534c 2073  ssion_log("SSL s
    │ │ │ -000568f0: 6574 5f64 6566 6175 6c74 2076 6572 6966  et_default verif
    │ │ │ -00056900: 795f 7061 7468 7320 6661 696c 6564 3a20  y_paths failed: 
    │ │ │ -00056910: 2573 222c 2065 632e 6d65 7373 6167 6528  %s", ec.message(
    │ │ │ -00056920: 292e 635f 7374 7228 2929 3b0a 0909 6563  ).c_str());...ec
    │ │ │ -00056930: 2e63 6c65 6172 2829 3b0a 2365 6e64 6966  .clear();.#endif
    │ │ │ -00056940: 0a23 6966 2064 6566 696e 6564 2054 4f52  .#if defined TOR
    │ │ │ -00056950: 5245 4e54 5f57 494e 444f 5753 2026 616d  RENT_WINDOWS &am
    │ │ │ -00056960: 703b 2661 6d70 3b20 6465 6669 6e65 6420  p;& defined 
    │ │ │ -00056970: 544f 5252 454e 545f 5553 455f 4f50 454e  TORRENT_USE_OPEN
    │ │ │ -00056980: 5353 4c20 2661 6d70 3b26 616d 703b 2021  SSL && !
    │ │ │ -00056990: 6465 6669 6e65 6420 544f 5252 454e 545f  defined TORRENT_
    │ │ │ -000569a0: 5749 4e52 540a 3c64 6976 2073 7479 6c65  WINRT.
    ..X509_STORE │ │ │ -000569e0: 2a20 7374 6f72 6520 3d20 5835 3039 5f53 * store = X509_S │ │ │ -000569f0: 544f 5245 5f6e 6577 2829 3b0a 3c2f 6469 TORE_new();...if (store).. │ │ │ -00056a10: 097b 0a09 0909 4843 4552 5453 544f 5245 .{....HCERTSTORE │ │ │ -00056a20: 2073 7973 7465 6d5f 7374 6f72 6520 3d20 system_store = │ │ │ -00056a30: 4365 7274 4f70 656e 5379 7374 656d 5374 CertOpenSystemSt │ │ │ -00056a40: 6f72 6541 2830 2c20 2252 4f4f 5422 293b oreA(0, "ROOT"); │ │ │ -00056a50: 0a09 0909 2f2f 2074 6869 7320 6973 2062 ....// this is b │ │ │ -00056a60: 6573 7420 6566 666f 7274 0a09 0909 6966 est effort....if │ │ │ -00056a70: 2028 7379 7374 656d 5f73 746f 7265 290a (system_store). │ │ │ -00056a80: 0909 097b 0a09 0909 0943 4552 545f 434f ...{.....CERT_CO │ │ │ -00056a90: 4e54 4558 5420 636f 6e73 742a 2063 7478 NTEXT const* ctx │ │ │ -00056aa0: 203d 206e 756c 6c70 7472 3b0a 0909 0909 = nullptr;..... │ │ │ -00056ab0: 7768 696c 6520 2828 6374 7820 3d20 4365 while ((ctx = Ce │ │ │ -00056ac0: 7274 456e 756d 4365 7274 6966 6963 6174 rtEnumCertificat │ │ │ -00056ad0: 6573 496e 5374 6f72 6528 7379 7374 656d esInStore(system │ │ │ -00056ae0: 5f73 746f 7265 2c20 6374 7829 2920 213d _store, ctx)) != │ │ │ -00056af0: 206e 756c 6c70 7472 290a 0909 0909 7b0a nullptr).....{. │ │ │ -00056b00: 0909 0909 0975 6e73 6967 6e65 6420 6368 .....unsigned ch │ │ │ -00056b10: 6172 2063 6f6e 7374 2a20 6365 7274 5f70 ar const* cert_p │ │ │ -00056b20: 7472 203d 2072 6569 6e74 6572 7072 6574 tr = reinterpret │ │ │ -00056b30: 5f63 6173 7426 6c74 3b75 6e73 6967 6e65 _cast<unsigne │ │ │ -00056b40: 6420 6368 6172 2063 6f6e 7374 2a26 6774 d char const*> │ │ │ -00056b50: 3b28 6374 782d 2667 743b 7062 4365 7274 ;(ctx->pbCert │ │ │ -00056b60: 456e 636f 6465 6429 3b0a 0909 0909 0958 Encoded);......X │ │ │ -00056b70: 3530 392a 2078 3530 3920 3d20 6432 695f 509* x509 = d2i_ │ │ │ -00056b80: 5835 3039 286e 756c 6c70 7472 2c20 2661 X509(nullptr, &a │ │ │ -00056b90: 6d70 3b63 6572 745f 7074 722c 2063 7478 mp;cert_ptr, ctx │ │ │ -00056ba0: 2d26 6774 3b63 6243 6572 7445 6e63 6f64 ->cbCertEncod │ │ │ -00056bb0: 6564 293b 0a09 0909 0909 2f2f 2074 6869 ed);......// thi │ │ │ -00056bc0: 7320 6973 2062 6573 7420 6566 666f 7274 s is best effort │ │ │ -00056bd0: 0a09 0909 0909 6966 2028 2178 3530 3929 ......if (!x509) │ │ │ -00056be0: 2063 6f6e 7469 6e75 653b 0a09 0909 0909 continue;...... │ │ │ -00056bf0: 5835 3039 5f53 544f 5245 5f61 6464 5f63 X509_STORE_add_c │ │ │ -00056c00: 6572 7428 7374 6f72 652c 2078 3530 3929 ert(store, x509) │ │ │ -00056c10: 3b0a 0909 0909 0958 3530 395f 6672 6565 ;......X509_free │ │ │ -00056c20: 2878 3530 3929 3b0a 0909 0909 7d0a 0909 (x509);.....}... │ │ │ -00056c30: 0909 4365 7274 4672 6565 4365 7274 6966 ..CertFreeCertif │ │ │ -00056c40: 6963 6174 6543 6f6e 7465 7874 2863 7478 icateContext(ctx │ │ │ -00056c50: 293b 0a09 0909 0943 6572 7443 6c6f 7365 );.....CertClose │ │ │ -00056c60: 5374 6f72 6528 7379 7374 656d 5f73 746f Store(system_sto │ │ │ -00056c70: 7265 2c20 3029 3b0a 0909 097d 0a09 097d re, 0);....}...} │ │ │ -00056c80: 0a0a 0909 5353 4c5f 4354 582a 2073 736c ....SSL_CTX* ssl │ │ │ -00056c90: 5f63 7478 203d 206d 5f73 736c 5f63 7478 _ctx = m_ssl_ctx │ │ │ -00056ca0: 2e6e 6174 6976 655f 6861 6e64 6c65 2829 .native_handle() │ │ │ -00056cb0: 3b0a 0909 5353 4c5f 4354 585f 7365 745f ;...SSL_CTX_set_ │ │ │ -00056cc0: 6365 7274 5f73 746f 7265 2873 736c 5f63 cert_store(ssl_c │ │ │ -00056cd0: 7478 2c20 7374 6f72 6529 3b0a 2365 6e64 tx, store);.#end │ │ │ -00056ce0: 6966 0a23 6966 6465 6620 5f5f 4150 504c if.#ifdef __APPL │ │ │ -00056cf0: 455f 5f0a 0909 6d5f 7373 6c5f 6374 782e E__...m_ssl_ctx. │ │ │ -00056d00: 6c6f 6164 5f76 6572 6966 795f 6669 6c65 load_verify_file │ │ │ -00056d10: 2822 2f65 7463 2f73 736c 2f63 6572 742e ("/etc/ssl/cert. │ │ │ -00056d20: 7065 6d22 2c20 6563 293b 0a23 6966 6e64 pem", ec);.#ifnd │ │ │ -00056d30: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ -00056d40: 4c45 5f4c 4f47 4749 4e47 0a09 0969 6620 LE_LOGGING...if │ │ │ -00056d50: 2865 6329 2073 6573 7369 6f6e 5f6c 6f67 (ec) session_log │ │ │ -00056d60: 2822 5353 4c20 6c6f 6164 5f76 6572 6966 ("SSL load_verif │ │ │ -00056d70: 795f 6669 6c65 2066 6169 6c65 643a 2025 y_file failed: % │ │ │ -00056d80: 7322 2c20 6563 2e6d 6573 7361 6765 2829 s", ec.message() │ │ │ -00056d90: 2e63 5f73 7472 2829 293b 0a23 656e 6469 .c_str());.#endi │ │ │ -00056da0: 660a 0909 6563 2e63 6c65 6172 2829 3b0a f...ec.clear();. │ │ │ -00056db0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00056dc0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00056df0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../sr │ │ │ -00056e20: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -00056e30: 7070 3a31 3435 343c 2f61 3e3c 2f74 643e pp:1454 │ │ │ -00056e40: 3c74 643e 6974 2077 6f75 6c64 2062 6520 it would be │ │ │ -00056e50: 6e69 6365 2074 6f20 7265 7365 7276 6528 nice to reserve( │ │ │ -00056e60: 2920 7468 6573 6520 7665 6374 6f72 7320 ) these vectors │ │ │ -00056e70: 7570 2066 726f 6e74 3c2f 7464 3e3c 2f74 up front

    it would b │ │ │ -00056ed0: 6520 6e69 6365 2074 6f20 7265 7365 7276 e nice to reserv │ │ │ -00056ee0: 6528 2920 7468 6573 6520 7665 6374 6f72 e() these vector │ │ │ -00056ef0: 7320 7570 2066 726f 6e74 3c2f 6832 3e3c s up front

    < │ │ │ -00056f00: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ -00056f10: 6e5f 696d 706c 2e63 7070 3a31 3435 343c n_impl.cpp:1454< │ │ │ -00056f20: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -00056f60: 0962 616e 6477 6964 7468 5f63 6861 6e6e  .bandwidth_chann
    │ │ │ -00056f70: 656c 2a20 6368 203d 2026 616d 703b 702d  el* ch = &p-
    │ │ │ -00056f80: 2667 743b 6368 616e 6e65 6c5b 7065 6572  >channel[peer
    │ │ │ -00056f90: 5f63 6f6e 6e65 6374 696f 6e3a 3a64 6f77  _connection::dow
    │ │ │ -00056fa0: 6e6c 6f61 645f 6368 616e 6e65 6c5d 3b0a  nload_channel];.
    │ │ │ -00056fb0: 0909 0969 6620 2875 7365 5f71 756f 7461  ...if (use_quota
    │ │ │ -00056fc0: 5f6f 7665 7268 6561 6428 6368 2c20 616d  _overhead(ch, am
    │ │ │ -00056fd0: 6f75 6e74 5f64 6f77 6e29 290a 0909 0909  ount_down)).....
    │ │ │ -00056fe0: 7265 7420 7c3d 2031 7520 266c 743b 266c  ret |= 1u <&l
    │ │ │ -00056ff0: 743b 2070 6565 725f 636f 6e6e 6563 7469  t; peer_connecti
    │ │ │ -00057000: 6f6e 3a3a 646f 776e 6c6f 6164 5f63 6861  on::download_cha
    │ │ │ -00057010: 6e6e 656c 3b0a 0909 0963 6820 3d20 2661  nnel;....ch = &a
    │ │ │ -00057020: 6d70 3b70 2d26 6774 3b63 6861 6e6e 656c  mp;p->channel
    │ │ │ -00057030: 5b70 6565 725f 636f 6e6e 6563 7469 6f6e  [peer_connection
    │ │ │ -00057040: 3a3a 7570 6c6f 6164 5f63 6861 6e6e 656c  ::upload_channel
    │ │ │ -00057050: 5d3b 0a09 0909 6966 2028 7573 655f 7175  ];....if (use_qu
    │ │ │ -00057060: 6f74 615f 6f76 6572 6865 6164 2863 682c  ota_overhead(ch,
    │ │ │ -00057070: 2061 6d6f 756e 745f 7570 2929 0a09 0909   amount_up))....
    │ │ │ -00057080: 0972 6574 207c 3d20 3175 2026 6c74 3b26  .ret |= 1u <&
    │ │ │ -00057090: 6c74 3b20 7065 6572 5f63 6f6e 6e65 6374  lt; peer_connect
    │ │ │ -000570a0: 696f 6e3a 3a75 706c 6f61 645f 6368 616e  ion::upload_chan
    │ │ │ -000570b0: 6e65 6c3b 0a09 097d 0a09 0972 6574 7572  nel;...}...retur
    │ │ │ -000570c0: 6e20 7265 743b 0a09 7d0a 0a09 2f2f 2073  n ret;..}...// s
    │ │ │ -000570d0: 6573 7369 6f6e 5f69 6d70 6c20 6973 2072  ession_impl is r
    │ │ │ -000570e0: 6573 706f 6e73 6962 6c65 2066 6f72 2064  esponsible for d
    │ │ │ -000570f0: 656c 6574 696e 6720 2770 6163 6b27 0a09  eleting 'pack'..
    │ │ │ -00057100: 766f 6964 2073 6573 7369 6f6e 5f69 6d70  void session_imp
    │ │ │ -00057110: 6c3a 3a61 7070 6c79 5f73 6574 7469 6e67  l::apply_setting
    │ │ │ -00057120: 735f 7061 636b 2873 7464 3a3a 7368 6172  s_pack(std::shar
    │ │ │ -00057130: 6564 5f70 7472 266c 743b 7365 7474 696e  ed_ptr<settin
    │ │ │ -00057140: 6773 5f70 6163 6b26 6774 3b20 7061 636b  gs_pack> pack
    │ │ │ -00057150: 290a 097b 0a09 0949 4e56 4152 4941 4e54  )..{...INVARIANT
    │ │ │ -00057160: 5f43 4845 434b 3b0a 0909 6170 706c 795f  _CHECK;...apply_
    │ │ │ -00057170: 7365 7474 696e 6773 5f70 6163 6b5f 696d  settings_pack_im
    │ │ │ -00057180: 706c 282a 7061 636b 293b 0a09 7d0a 0a09  pl(*pack);..}...
    │ │ │ -00057190: 7365 7474 696e 6773 5f70 6163 6b20 7365  settings_pack se
    │ │ │ -000571a0: 7373 696f 6e5f 696d 706c 3a3a 6765 745f  ssion_impl::get_
    │ │ │ -000571b0: 7365 7474 696e 6773 2829 2063 6f6e 7374  settings() const
    │ │ │ -000571c0: 0a09 7b0a 0909 7365 7474 696e 6773 5f70  ..{...settings_p
    │ │ │ -000571d0: 6163 6b20 7265 743b 0a3c 6469 7620 7374  ack ret;.
    ..for (in │ │ │ -00057210: 7420 6920 3d20 7365 7474 696e 6773 5f70 t i = settings_p │ │ │ -00057220: 6163 6b3a 3a73 7472 696e 675f 7479 7065 ack::string_type │ │ │ -00057230: 5f62 6173 653b 0a3c 2f64 6976 3e09 0909 _base;.
    ... │ │ │ -00057240: 6920 266c 743b 2073 6574 7469 6e67 735f i < settings_ │ │ │ -00057250: 7061 636b 3a3a 6d61 785f 7374 7269 6e67 pack::max_string │ │ │ -00057260: 5f73 6574 7469 6e67 5f69 6e74 6572 6e61 _setting_interna │ │ │ -00057270: 6c3b 202b 2b69 290a 0909 7b0a 0909 0972 l; ++i)...{....r │ │ │ -00057280: 6574 2e73 6574 5f73 7472 2869 2c20 6d5f et.set_str(i, m_ │ │ │ -00057290: 7365 7474 696e 6773 2e67 6574 5f73 7472 settings.get_str │ │ │ -000572a0: 2869 2929 3b0a 0909 7d0a 0909 666f 7220 (i));...}...for │ │ │ -000572b0: 2869 6e74 2069 203d 2073 6574 7469 6e67 (int i = setting │ │ │ -000572c0: 735f 7061 636b 3a3a 696e 745f 7479 7065 s_pack::int_type │ │ │ -000572d0: 5f62 6173 653b 0a09 0909 6920 266c 743b _base;....i < │ │ │ -000572e0: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ -000572f0: 6d61 785f 696e 745f 7365 7474 696e 675f max_int_setting_ │ │ │ -00057300: 696e 7465 726e 616c 3b20 2b2b 6929 0a09 internal; ++i).. │ │ │ -00057310: 097b 0a09 0909 7265 742e 7365 745f 696e .{....ret.set_in │ │ │ -00057320: 7428 692c 206d 5f73 6574 7469 6e67 732e t(i, m_settings. │ │ │ -00057330: 6765 745f 696e 7428 6929 293b 0a09 097d get_int(i));...} │ │ │ -00057340: 0a09 0966 6f72 2028 696e 7420 6920 3d20 ...for (int i = │ │ │ -00057350: 7365 7474 696e 6773 5f70 6163 6b3a 3a62 settings_pack::b │ │ │ -00057360: 6f6f 6c5f 7479 7065 5f62 6173 653b 0a09 ool_type_base;.. │ │ │ -00057370: 0909 6920 266c 743b 2073 6574 7469 6e67 ..i < setting │ │ │ -00057380: 735f 7061 636b 3a3a 6d61 785f 626f 6f6c s_pack::max_bool │ │ │ -00057390: 5f73 6574 7469 6e67 5f69 6e74 6572 6e61 _setting_interna │ │ │ -000573a0: 6c3b 202b 2b69 290a 0909 7b0a 0909 0972 l; ++i)...{....r │ │ │ -000573b0: 6574 2e73 6574 5f62 6f6f 6c28 692c 206d et.set_bool(i, m │ │ │ -000573c0: 5f73 6574 7469 6e67 732e 6765 745f 626f _settings.get_bo │ │ │ -000573d0: 6f6c 2869 2929 3b0a 0909 7d0a 0909 7265 ol(i));...}...re │ │ │ -000573e0: 7475 726e 2072 6574 3b0a 097d 0a0a 6e61 turn ret;..}..na │ │ │ -000573f0: 6d65 7370 6163 6520 7b0a 0974 656d 706c mespace {..templ │ │ │ -00057400: 6174 6520 266c 743b 7479 7065 6e61 6d65 ate <typename │ │ │ -00057410: 2050 6163 6b26 6774 3b0a 0969 6e74 2067 Pack>..int g │ │ │ -00057420: 6574 5f73 6574 7469 6e67 5f69 6d70 6c28 et_setting_impl( │ │ │ -00057430: 5061 636b 2063 6f6e 7374 2661 6d70 3b20 Pack const& │ │ │ -00057440: 702c 2069 6e74 206e 616d 652c 2069 6e74 p, int name, int │ │ │ -00057450: 2a29 0a09 7b20 7265 7475 726e 2070 2e67 *)..{ return p.g │ │ │ -00057460: 6574 5f69 6e74 286e 616d 6529 3b20 7d0a et_int(name); }. │ │ │ -00057470: 0a09 7465 6d70 6c61 7465 2026 6c74 3b74 ..template <t │ │ │ -00057480: 7970 656e 616d 6520 5061 636b 2667 743b ypename Pack> │ │ │ -00057490: 0a09 626f 6f6c 2067 6574 5f73 6574 7469 ..bool get_setti │ │ │ -000574a0: 6e67 5f69 6d70 6c28 5061 636b 2063 6f6e ng_impl(Pack con │ │ │ -000574b0: 7374 2661 6d70 3b20 702c 2069 6e74 206e st& p, int n │ │ │ -000574c0: 616d 652c 2062 6f6f 6c2a 290a 097b 2072 ame, bool*)..{ r │ │ │ -000574d0: 6574 7572 6e20 702e 6765 745f 626f 6f6c eturn p.get_bool │ │ │ -000574e0: 286e 616d 6529 3b20 7d0a 0a09 7465 6d70 (name); }...temp │ │ │ -000574f0: 6c61 7465 2026 6c74 3b74 7970 656e 616d late <typenam │ │ │ -00057500: 6520 5061 636b 2667 743b 0a09 7374 643a e Pack>..std: │ │ │ -00057510: 3a73 7472 696e 6720 6765 745f 7365 7474 :string get_sett │ │ │ -00057520: 696e 675f 696d 706c 2850 6163 6b20 636f ing_impl(Pack co │ │ │ -00057530: 6e73 7426 616d 703b 2070 2c20 696e 7420 nst& p, int │ │ │ -00057540: 6e61 6d65 2c20 7374 643a 3a73 7472 696e name, std::strin │ │ │ -00057550: 672a 290a 097b 2072 6574 7572 6e20 702e g*)..{ return p. │ │ │ -00057560: 6765 745f 7374 7228 6e61 6d65 293b 207d get_str(name); } │ │ │ -00057570: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..
    < │ │ │ -000575a0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000575b0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -000575e0: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -000575f0: 2e63 7070 3a31 3938 393c 2f61 3e3c 2f74 .cpp:1989could this │ │ │ -00057610: 2066 756e 6374 696f 6e20 6265 206d 6572 function be mer │ │ │ -00057620: 6765 6420 7769 7468 2065 7870 616e 645f ged with expand_ │ │ │ -00057630: 756e 7370 6563 6966 6965 645f 6164 6472 unspecified_addr │ │ │ -00057640: 6573 7365 733f 2072 6967 6874 206e 6f77 esses? right now │ │ │ -00057650: 2062 6f74 6820 6c69 7374 656e 5f65 6e64 both listen_end │ │ │ -00057660: 706f 696e 745f 7420 616e 6420 6c69 7374 point_t and list │ │ │ -00057670: 656e 5f69 6e74 6572 6661 6365 5f74 2061 en_interface_t a │ │ │ -00057680: 7265 2061 6c6d 6f73 7420 6964 656e 7469 re almost identi │ │ │ -00057690: 6361 6c2c 206d 6179 6265 2074 6865 206c cal, maybe the l │ │ │ -000576a0: 6174 7465 7220 636f 756c 6420 6265 2072 atter could be r │ │ │ -000576b0: 656d 6f76 6564 2074 6f6f 3c2f 7464 3e3c emoved too< │ │ │ -000576c0: 2f74 723e 3c74 7220 6964 3d22 3230 3722 /tr>

    could th │ │ │ -00057710: 6973 2066 756e 6374 696f 6e20 6265 206d is function be m │ │ │ -00057720: 6572 6765 6420 7769 7468 2065 7870 616e erged with expan │ │ │ -00057730: 645f 756e 7370 6563 6966 6965 645f 6164 d_unspecified_ad │ │ │ -00057740: 6472 6573 7365 733f 0a72 6967 6874 206e dresses?.right n │ │ │ -00057750: 6f77 2062 6f74 6820 6c69 7374 656e 5f65 ow both listen_e │ │ │ -00057760: 6e64 706f 696e 745f 7420 616e 6420 6c69 ndpoint_t and li │ │ │ -00057770: 7374 656e 5f69 6e74 6572 6661 6365 5f74 sten_interface_t │ │ │ -00057780: 2061 7265 2061 6c6d 6f73 740a 6964 656e are almost.iden │ │ │ -00057790: 7469 6361 6c2c 206d 6179 6265 2074 6865 tical, maybe the │ │ │ -000577a0: 206c 6174 7465 7220 636f 756c 6420 6265 latter could be │ │ │ -000577b0: 2072 656d 6f76 6564 2074 6f6f 3c2f 6832 removed too

    ../src/sess │ │ │ -000577d0: 696f 6e5f 696d 706c 2e63 7070 3a31 3938 ion_impl.cpp:198 │ │ │ -000577e0: 393c 2f68 343e 3c70 7265 2073 7479 6c65 9

    │ │ │ -00057820: 0909 7365 7373 696f 6e5f 6c6f 6728 2246  ..session_log("F
    │ │ │ -00057830: 4154 414c 2053 4553 5349 4f4e 2045 5252  ATAL SESSION ERR
    │ │ │ -00057840: 4f52 2028 2573 203a 2025 6429 205b 2573  OR (%s : %d) [%s
    │ │ │ -00057850: 5d22 0a09 0909 2c20 6563 2e63 6174 6567  ]"...., ec.categ
    │ │ │ -00057860: 6f72 7928 292e 6e61 6d65 2829 2c20 6563  ory().name(), ec
    │ │ │ -00057870: 2e76 616c 7565 2829 2c20 6563 2e6d 6573  .value(), ec.mes
    │ │ │ -00057880: 7361 6765 2829 2e63 5f73 7472 2829 293b  sage().c_str());
    │ │ │ -00057890: 0a23 656e 6469 660a 0909 7468 6973 2d26  .#endif...this-&
    │ │ │ -000578a0: 6774 3b61 626f 7274 2829 3b0a 097d 0a0a  gt;abort();..}..
    │ │ │ -000578b0: 0976 6f69 6420 7365 7373 696f 6e5f 696d  .void session_im
    │ │ │ -000578c0: 706c 3a3a 6f6e 5f69 705f 6368 616e 6765  pl::on_ip_change
    │ │ │ -000578d0: 2865 7272 6f72 5f63 6f64 6520 636f 6e73  (error_code cons
    │ │ │ -000578e0: 7426 616d 703b 2065 6329 0a09 7b0a 2369  t& ec)..{.#i
    │ │ │ -000578f0: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ -00057900: 5341 424c 455f 4c4f 4747 494e 470a 0909  SABLE_LOGGING...
    │ │ │ -00057910: 6966 2028 2165 6329 0a09 0909 7365 7373  if (!ec)....sess
    │ │ │ -00057920: 696f 6e5f 6c6f 6728 2272 6563 6569 7665  ion_log("receive
    │ │ │ -00057930: 6420 6970 2063 6861 6e67 6520 6672 6f6d  d ip change from
    │ │ │ -00057940: 2069 6e74 6572 6e61 6c20 6970 5f6e 6f74   internal ip_not
    │ │ │ -00057950: 6966 6965 7222 293b 0a09 0965 6c73 650a  ifier");...else.
    │ │ │ -00057960: 0909 0973 6573 7369 6f6e 5f6c 6f67 2822  ...session_log("
    │ │ │ -00057970: 7265 6365 6976 6564 2065 7272 6f72 206f  received error o
    │ │ │ -00057980: 6e5f 6970 5f63 6861 6e67 653a 2025 642c  n_ip_change: %d,
    │ │ │ -00057990: 2025 7322 2c20 6563 2e76 616c 7565 2829   %s", ec.value()
    │ │ │ -000579a0: 2c20 6563 2e6d 6573 7361 6765 2829 2e63  , ec.message().c
    │ │ │ -000579b0: 5f73 7472 2829 293b 0a23 656e 6469 660a  _str());.#endif.
    │ │ │ -000579c0: 0909 6966 2028 6563 207c 7c20 6d5f 6162  ..if (ec || m_ab
    │ │ │ -000579d0: 6f72 7420 7c7c 2021 6d5f 6970 5f6e 6f74  ort || !m_ip_not
    │ │ │ -000579e0: 6966 6965 7229 2072 6574 7572 6e3b 0a09  ifier) return;..
    │ │ │ -000579f0: 096d 5f69 705f 6e6f 7469 6669 6572 2d26  .m_ip_notifier-&
    │ │ │ -00057a00: 6774 3b61 7379 6e63 5f77 6169 7428 5b74  gt;async_wait([t
    │ │ │ -00057a10: 6869 735d 2028 6572 726f 725f 636f 6465  his] (error_code
    │ │ │ -00057a20: 2063 6f6e 7374 2661 6d70 3b20 6529 0a09   const& e)..
    │ │ │ -00057a30: 0909 7b20 7772 6170 2826 616d 703b 7365  ..{ wrap(&se
    │ │ │ -00057a40: 7373 696f 6e5f 696d 706c 3a3a 6f6e 5f69  ssion_impl::on_i
    │ │ │ -00057a50: 705f 6368 616e 6765 2c20 6529 3b20 7d29  p_change, e); })
    │ │ │ -00057a60: 3b0a 0909 7265 6f70 656e 5f6e 6574 776f  ;...reopen_netwo
    │ │ │ -00057a70: 726b 5f73 6f63 6b65 7473 287b 7d29 3b0a  rk_sockets({});.
    │ │ │ -00057a80: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    .void interfac │ │ │ -00057ac0: 655f 746f 5f65 6e64 706f 696e 7473 286c e_to_endpoints(l │ │ │ -00057ad0: 6973 7465 6e5f 696e 7465 7266 6163 655f isten_interface_ │ │ │ -00057ae0: 7420 636f 6e73 7426 616d 703b 2069 6661 t const& ifa │ │ │ -00057af0: 6365 0a3c 2f64 6976 3e09 092c 206c 6973 ce.
    .., lis │ │ │ -00057b00: 7465 6e5f 736f 636b 6574 5f66 6c61 6773 ten_socket_flags │ │ │ -00057b10: 5f74 2066 6c61 6773 0a09 092c 2073 7061 _t flags..., spa │ │ │ -00057b20: 6e26 6c74 3b69 705f 696e 7465 7266 6163 n<ip_interfac │ │ │ -00057b30: 6520 636f 6e73 7426 6774 3b20 636f 6e73 e const> cons │ │ │ -00057b40: 7420 6966 730a 0909 2c20 7374 643a 3a76 t ifs..., std::v │ │ │ -00057b50: 6563 746f 7226 6c74 3b6c 6973 7465 6e5f ector<listen_ │ │ │ -00057b60: 656e 6470 6f69 6e74 5f74 2667 743b 2661 endpoint_t>&a │ │ │ -00057b70: 6d70 3b20 6570 7329 0a09 7b0a 0909 666c mp; eps)..{...fl │ │ │ -00057b80: 6167 7320 7c3d 2069 6661 6365 2e6c 6f63 ags |= iface.loc │ │ │ -00057b90: 616c 203f 206c 6973 7465 6e5f 736f 636b al ? listen_sock │ │ │ -00057ba0: 6574 5f74 3a3a 6c6f 6361 6c5f 6e65 7477 et_t::local_netw │ │ │ -00057bb0: 6f72 6b20 3a20 6c69 7374 656e 5f73 6f63 ork : listen_soc │ │ │ -00057bc0: 6b65 745f 666c 6167 735f 747b 7d3b 0a09 ket_flags_t{};.. │ │ │ -00057bd0: 0974 7261 6e73 706f 7274 2063 6f6e 7374 .transport const │ │ │ -00057be0: 2073 736c 203d 2069 6661 6365 2e73 736c ssl = iface.ssl │ │ │ -00057bf0: 203f 2074 7261 6e73 706f 7274 3a3a 7373 ? transport::ss │ │ │ -00057c00: 6c20 3a20 7472 616e 7370 6f72 743a 3a70 l : transport::p │ │ │ -00057c10: 6c61 696e 7465 7874 3b0a 0a09 092f 2f20 laintext;....// │ │ │ -00057c20: 4669 7273 742c 2063 6865 636b 2074 6f20 First, check to │ │ │ -00057c30: 7365 6520 6966 2069 7427 7320 616e 2049 see if it's an I │ │ │ -00057c40: 5020 6164 6472 6573 730a 0909 6572 726f P address...erro │ │ │ -00057c50: 725f 636f 6465 2065 7272 3b0a 0909 6164 r_code err;...ad │ │ │ -00057c60: 6472 6573 7320 636f 6e73 7420 6164 7220 dress const adr │ │ │ -00057c70: 3d20 6d61 6b65 5f61 6464 7265 7373 2869 = make_address(i │ │ │ -00057c80: 6661 6365 2e64 6576 6963 652e 635f 7374 face.device.c_st │ │ │ -00057c90: 7228 292c 2065 7272 293b 0a09 0969 6620 r(), err);...if │ │ │ -00057ca0: 2821 6572 7229 0a09 097b 0a09 0909 6570 (!err)...{....ep │ │ │ -00057cb0: 732e 656d 706c 6163 655f 6261 636b 2861 s.emplace_back(a │ │ │ -00057cc0: 6472 2c20 6966 6163 652e 706f 7274 2c20 dr, iface.port, │ │ │ -00057cd0: 7374 643a 3a73 7472 696e 677b 7d2c 2073 std::string{}, s │ │ │ -00057ce0: 736c 2c20 666c 6167 7329 3b0a 0909 7d0a sl, flags);...}. │ │ │ -00057cf0: 0909 656c 7365 0a09 097b 0a09 0909 666c ..else...{....fl │ │ │ -00057d00: 6167 7320 7c3d 206c 6973 7465 6e5f 736f ags |= listen_so │ │ │ -00057d10: 636b 6574 5f74 3a3a 7761 735f 6578 7061 cket_t::was_expa │ │ │ -00057d20: 6e64 6564 3b0a 0a09 0909 2f2f 2074 6869 nded;.....// thi │ │ │ -00057d30: 7320 6973 2074 6865 2063 6173 6520 7768 s is the case wh │ │ │ -00057d40: 6572 6520 6465 7669 6365 206e 616d 6573 ere device names │ │ │ -00057d50: 2061 206e 6574 776f 726b 2064 6576 6963 a network devic │ │ │ -00057d60: 652e 2057 6520 6e65 6564 2074 6f0a 0909 e. We need to... │ │ │ -00057d70: 092f 2f20 656e 756d 6572 6174 6520 616c .// enumerate al │ │ │ -00057d80: 6c20 4950 7320 6173 736f 6369 6174 6564 l IPs associated │ │ │ -00057d90: 2077 6974 6820 7468 6973 2064 6576 6963 with this devic │ │ │ -00057da0: 650a 0909 0966 6f72 2028 6175 746f 2063 e....for (auto c │ │ │ -00057db0: 6f6e 7374 2661 6d70 3b20 6970 6661 6365 onst& ipface │ │ │ -00057dc0: 203a 2069 6673 290a 0909 097b 0a09 0909 : ifs)....{.... │ │ │ -00057dd0: 092f 2f20 7765 2772 6520 6c6f 6f6b 696e .// we're lookin │ │ │ -00057de0: 6720 666f 7220 6120 7370 6563 6966 6963 g for a specific │ │ │ -00057df0: 2069 6e74 6572 6661 6365 2c20 616e 6420 interface, and │ │ │ -00057e00: 6974 7320 6164 6472 6573 730a 0909 0909 its address..... │ │ │ -00057e10: 2f2f 2028 7768 6963 6820 6d75 7374 2062 // (which must b │ │ │ -00057e20: 6520 6f66 2074 6865 2073 616d 6520 6661 e of the same fa │ │ │ -00057e30: 6d69 6c79 2061 7320 7468 6520 6164 6472 mily as the addr │ │ │ -00057e40: 6573 7320 7765 2772 650a 0909 0909 2f2f ess we're.....// │ │ │ -00057e50: 2063 6f6e 6e65 6374 696e 6720 746f 290a connecting to). │ │ │ -00057e60: 0909 0909 6966 2028 6966 6163 652e 6465 ....if (iface.de │ │ │ -00057e70: 7669 6365 2021 3d20 6970 6661 6365 2e6e vice != ipface.n │ │ │ -00057e80: 616d 6529 2063 6f6e 7469 6e75 653b 0a0a ame) continue;.. │ │ │ -00057e90: 0909 0909 626f 6f6c 2063 6f6e 7374 206c ....bool const l │ │ │ -00057ea0: 6f63 616c 203d 2069 6661 6365 2e6c 6f63 ocal = iface.loc │ │ │ -00057eb0: 616c 0a09 0909 0909 7c7c 2069 7066 6163 al......|| ipfac │ │ │ -00057ec0: 652e 696e 7465 7266 6163 655f 6164 6472 e.interface_addr │ │ │ -00057ed0: 6573 732e 6973 5f6c 6f6f 7062 6163 6b28 ess.is_loopback( │ │ │ -00057ee0: 290a 0909 0909 097c 7c20 6973 5f6c 696e )......|| is_lin │ │ │ -00057ef0: 6b5f 6c6f 6361 6c28 6970 6661 6365 2e69 k_local(ipface.i │ │ │ -00057f00: 6e74 6572 6661 6365 5f61 6464 7265 7373 nterface_address │ │ │ -00057f10: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ -00057f40: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00057f50: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00057f80: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ -00057f90: 6c2e 6370 703a 3233 3031 3c2f 613e 3c2f l.cpp:2301it would │ │ │ -00057fb0: 7072 6f62 6162 6c79 2062 6520 6265 7474 probably be bett │ │ │ -00057fc0: 6572 2074 6f20 646f 2074 6869 7320 6279 er to do this by │ │ │ -00057fd0: 2068 6176 696e 6720 6120 6c69 7374 656e having a listen │ │ │ -00057fe0: 2d73 6f63 6b65 7420 2276 6572 7369 6f6e -socket "version │ │ │ -00057ff0: 2220 6e75 6d62 6572 2074 6861 7420 6765 " number that ge │ │ │ -00058000: 7473 2062 756d 7065 642e 2041 6e64 2069 ts bumped. And i │ │ │ -00058010: 6e73 7465 6164 206f 6620 7365 7474 696e nstead of settin │ │ │ -00058020: 6720 6120 626f 6f6c 2074 6f20 6469 7361 g a bool to disa │ │ │ -00058030: 626c 6520 6120 7472 6163 6b65 722c 2077 ble a tracker, w │ │ │ -00058040: 6520 7365 7420 7468 6520 7665 7273 696f e set the versio │ │ │ -00058050: 6e20 6e75 6d62 6572 2074 6861 7420 6974 n number that it │ │ │ -00058060: 2077 6173 2064 6973 6162 6c65 6420 6174 was disabled at │ │ │ -00058070: 2e20 5468 6973 2063 6861 6e67 6520 776f . This change wo │ │ │ -00058080: 756c 6420 6166 6665 6374 2074 6865 2041 uld affect the A │ │ │ -00058090: 4249 2069 6e20 312e 322c 2073 6f20 7368 BI in 1.2, so sh │ │ │ -000580a0: 6f75 6c64 2062 6520 646f 6e65 2069 6e20 ould be done in │ │ │ -000580b0: 322e 3020 6f72 206c 6174 6572 3c2f 7464 2.0 or later

    it wou │ │ │ -00058110: 6c64 2070 726f 6261 626c 7920 6265 2062 ld probably be b │ │ │ -00058120: 6574 7465 7220 746f 2064 6f20 7468 6973 etter to do this │ │ │ -00058130: 2062 7920 6861 7669 6e67 2061 0a6c 6973 by having a.lis │ │ │ -00058140: 7465 6e2d 736f 636b 6574 2022 7665 7273 ten-socket "vers │ │ │ -00058150: 696f 6e22 206e 756d 6265 7220 7468 6174 ion" number that │ │ │ -00058160: 2067 6574 7320 6275 6d70 6564 2e20 416e gets bumped. An │ │ │ -00058170: 6420 696e 7374 6561 6420 6f66 0a73 6574 d instead of.set │ │ │ -00058180: 7469 6e67 2061 2062 6f6f 6c20 746f 2064 ting a bool to d │ │ │ -00058190: 6973 6162 6c65 2061 2074 7261 636b 6572 isable a tracker │ │ │ -000581a0: 2c20 7765 2073 6574 2074 6865 2076 6572 , we set the ver │ │ │ -000581b0: 7369 6f6e 206e 756d 6265 7220 7468 6174 sion number that │ │ │ -000581c0: 0a69 7420 7761 7320 6469 7361 626c 6564 .it was disabled │ │ │ -000581d0: 2061 742e 2054 6869 7320 6368 616e 6765 at. This change │ │ │ -000581e0: 2077 6f75 6c64 2061 6666 6563 7420 7468 would affect th │ │ │ -000581f0: 6520 4142 4920 696e 2031 2e32 2c20 736f e ABI in 1.2, so │ │ │ -00058200: 0a73 686f 756c 6420 6265 2064 6f6e 6520 .should be done │ │ │ -00058210: 696e 2032 2e30 206f 7220 6c61 7465 723c in 2.0 or later< │ │ │ -00058220: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ -00058230: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ -00058240: 3233 3031 3c2f 6834 3e3c 7072 6520 7374 2301

    ..{....for (a
    │ │ │ -00058290: 7574 6f20 636f 6e73 7426 616d 703b 2073  uto const& s
    │ │ │ -000582a0: 203a 206d 5f6c 6973 7465 6e5f 736f 636b   : m_listen_sock
    │ │ │ -000582b0: 6574 7329 0a09 0909 0972 656d 6170 5f70  ets).....remap_p
    │ │ │ -000582c0: 6f72 7473 2872 656d 6170 5f6e 6174 706d  orts(remap_natpm
    │ │ │ -000582d0: 705f 616e 645f 7570 6e70 2c20 2a73 293b  p_and_upnp, *s);
    │ │ │ -000582e0: 0a09 097d 0a09 0965 6c73 650a 0909 7b0a  ...}...else...{.
    │ │ │ -000582f0: 0909 092f 2f20 6e65 7720 736f 636b 6574  ...// new socket
    │ │ │ -00058300: 7320 6e65 6564 2074 6f20 6d61 7020 706f  s need to map po
    │ │ │ -00058310: 7274 7320 6576 656e 2069 6620 7468 6520  rts even if the 
    │ │ │ -00058320: 6361 6c6c 6572 2064 6964 206e 6f74 2072  caller did not r
    │ │ │ -00058330: 6571 7565 7374 0a09 0909 2f2f 2072 652d  equest....// re-
    │ │ │ -00058340: 6d61 7070 696e 670a 0909 0966 6f72 2028  mapping....for (
    │ │ │ -00058350: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ -00058360: 7320 3a20 6e65 775f 736f 636b 6574 7329  s : new_sockets)
    │ │ │ -00058370: 0a09 0909 0972 656d 6170 5f70 6f72 7473  .....remap_ports
    │ │ │ -00058380: 2872 656d 6170 5f6e 6174 706d 705f 616e  (remap_natpmp_an
    │ │ │ -00058390: 645f 7570 6e70 2c20 2a73 293b 0a09 097d  d_upnp, *s);...}
    │ │ │ -000583a0: 0a0a 0909 7570 6461 7465 5f6c 7364 2829  ....update_lsd()
    │ │ │ -000583b0: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f55  ;..#if TORRENT_U
    │ │ │ -000583c0: 5345 5f49 3250 0a09 096f 7065 6e5f 6e65  SE_I2P...open_ne
    │ │ │ -000583d0: 775f 696e 636f 6d69 6e67 5f69 3270 5f63  w_incoming_i2p_c
    │ │ │ -000583e0: 6f6e 6e65 6374 696f 6e28 293b 0a23 656e  onnection();.#en
    │ │ │ -000583f0: 6469 660a 0a09 092f 2f20 7472 6163 6b65  dif....// tracke
    │ │ │ -00058400: 7273 2074 6861 7420 7765 7265 206e 6f74  rs that were not
    │ │ │ -00058410: 2072 6561 6368 6162 6c65 2c20 6d61 7920   reachable, may 
    │ │ │ -00058420: 6861 7665 2062 6563 6f6d 6520 7265 6163  have become reac
    │ │ │ -00058430: 6861 626c 6520 6e6f 772e 0a09 092f 2f20  hable now....// 
    │ │ │ -00058440: 736f 2063 6c65 6172 2074 6865 2022 6469  so clear the "di
    │ │ │ -00058450: 7361 626c 6564 2220 666c 6167 7320 746f  sabled" flags to
    │ │ │ -00058460: 206c 6574 2074 6865 6d20 6265 2074 7269   let them be tri
    │ │ │ -00058470: 6564 206f 6e65 206d 6f72 6520 7469 6d65  ed one more time
    │ │ │ -00058480: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -000584b0: 0966 6f72 2028 6175 746f 2661 6d70 3b20 .for (auto& │ │ │ -000584c0: 7420 3a20 6d5f 746f 7272 656e 7473 290a t : m_torrents). │ │ │ -000584d0: 3c2f 6469 763e 0909 0974 2d26 6774 3b65
    ...t->e │ │ │ -000584e0: 6e61 626c 655f 616c 6c5f 7472 6163 6b65 nable_all_tracke │ │ │ -000584f0: 7273 2829 3b0a 097d 0a0a 0976 6f69 6420 rs();..}...void │ │ │ -00058500: 7365 7373 696f 6e5f 696d 706c 3a3a 7265 session_impl::re │ │ │ -00058510: 6f70 656e 5f6e 6574 776f 726b 5f73 6f63 open_network_soc │ │ │ -00058520: 6b65 7473 2872 656f 7065 6e5f 6e65 7477 kets(reopen_netw │ │ │ -00058530: 6f72 6b5f 666c 6167 735f 7420 636f 6e73 ork_flags_t cons │ │ │ -00058540: 7420 6f70 7469 6f6e 7329 0a09 7b0a 0909 t options)..{... │ │ │ -00058550: 7265 6f70 656e 5f6c 6973 7465 6e5f 736f reopen_listen_so │ │ │ -00058560: 636b 6574 7328 626f 6f6c 286f 7074 696f ckets(bool(optio │ │ │ -00058570: 6e73 2026 616d 703b 2073 6573 7369 6f6e ns & session │ │ │ -00058580: 5f68 616e 646c 653a 3a72 656f 7065 6e5f _handle::reopen_ │ │ │ -00058590: 6d61 705f 706f 7274 7329 293b 0a09 7d0a map_ports));..}. │ │ │ -000585a0: 0a09 6e61 6d65 7370 6163 6520 7b0a 0909 ..namespace {... │ │ │ -000585b0: 7465 6d70 6c61 7465 2026 6c74 3b74 7970 template <typ │ │ │ -000585c0: 656e 616d 6520 4d61 7050 726f 746f 636f ename MapProtoco │ │ │ -000585d0: 6c2c 2074 7970 656e 616d 6520 5072 6f74 l, typename Prot │ │ │ -000585e0: 6f54 7970 652c 2074 7970 656e 616d 6520 oType, typename │ │ │ -000585f0: 456e 6470 6f69 6e74 5479 7065 2667 743b EndpointType> │ │ │ -00058600: 0a09 0976 6f69 6420 6d61 705f 706f 7274 ...void map_port │ │ │ -00058610: 284d 6170 5072 6f74 6f63 6f6c 2661 6d70 (MapProtocol& │ │ │ -00058620: 3b20 6d2c 2050 726f 746f 5479 7065 2070 ; m, ProtoType p │ │ │ -00058630: 726f 746f 636f 6c2c 2045 6e64 706f 696e rotocol, Endpoin │ │ │ -00058640: 7454 7970 6520 636f 6e73 7426 616d 703b tType const& │ │ │ -00058650: 2065 700a 0909 092c 2070 6f72 745f 6d61 ep...., port_ma │ │ │ -00058660: 7070 696e 675f 7426 616d 703b 206d 6170 pping_t& map │ │ │ -00058670: 5f68 616e 646c 652c 2073 7464 3a3a 7374 _handle, std::st │ │ │ -00058680: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ -00058690: 6465 7669 6365 290a 0909 7b0a 0909 0969 device)...{....i │ │ │ -000586a0: 6620 286d 6170 5f68 616e 646c 6520 213d f (map_handle != │ │ │ -000586b0: 2070 6f72 745f 6d61 7070 696e 675f 747b port_mapping_t{ │ │ │ -000586c0: 2d31 7d29 206d 2e64 656c 6574 655f 6d61 -1}) m.delete_ma │ │ │ -000586d0: 7070 696e 6728 6d61 705f 6861 6e64 6c65 pping(map_handle │ │ │ -000586e0: 293b 0a09 0909 6d61 705f 6861 6e64 6c65 );....map_handle │ │ │ -000586f0: 203d 2070 6f72 745f 6d61 7070 696e 675f = port_mapping_ │ │ │ -00058700: 747b 2d31 7d3b 0a0a 0909 0961 6464 7265 t{-1};.....addre │ │ │ -00058710: 7373 2063 6f6e 7374 2061 6464 7220 3d20 ss const addr = │ │ │ -00058720: 6570 2e61 6464 7265 7373 2829 3b0a 0909 ep.address();... │ │ │ -00058730: 092f 2f20 7769 7468 2049 5076 3420 7468 .// with IPv4 th │ │ │ -00058740: 6520 696e 7465 7266 6163 6520 6d69 6768 e interface migh │ │ │ -00058750: 7420 6265 2062 6568 696e 6420 4e41 5420 t be behind NAT │ │ │ -00058760: 736f 2077 6520 6361 6e27 7420 736b 6970 so we can't skip │ │ │ -00058770: 2074 6865 6d0a 0909 092f 2f20 6261 7365 them....// base │ │ │ -00058780: 6420 6f6e 2074 6865 2073 636f 7065 206f d on the scope o │ │ │ -00058790: 6620 7468 6520 6c6f 6361 6c20 6164 6472 f the local addr │ │ │ -000587a0: 6573 730a 0909 0969 6620 2861 6464 722e ess....if (addr. │ │ │ -000587b0: 6973 5f76 3628 2920 2661 6d70 3b26 616d is_v6() &&am │ │ │ -000587c0: 703b 2069 735f 6c6f 6361 6c28 6164 6472 p; is_local(addr │ │ │ -000587d0: 2929 0a09 0909 0972 6574 7572 6e3b 0a0a )).....return;.. │ │ │ -000587e0: 0909 092f 2f20 6f6e 6c79 2075 7064 6174 ...// only updat │ │ │ -000587f0: 6520 7468 6973 206d 6170 7069 6e67 2069 e this mapping i │ │ │ -00058800: 6620 7765 2061 6374 7561 6c6c 7920 6861 f we actually ha │ │ │ -00058810: 7665 2061 2073 6f63 6b65 7420 6c69 7374 ve a socket list │ │ │ -00058820: 656e 696e 670a 0909 0969 6620 2865 7020 ening....if (ep │ │ │ -00058830: 213d 2045 6e64 706f 696e 7454 7970 6528 != EndpointType( │ │ │ -00058840: 2929 0a09 0909 096d 6170 5f68 616e 646c )).....map_handl │ │ │ -00058850: 6520 3d20 6d2e 6164 645f 6d61 7070 696e e = m.add_mappin │ │ │ -00058860: 6728 7072 6f74 6f63 6f6c 2c20 6570 2e70 g(protocol, ep.p │ │ │ -00058870: 6f72 7428 292c 2065 702c 2064 6576 6963 ort(), ep, devic │ │ │ -00058880: 6529 3b0a 0909 7d0a 097d 0a0a 0976 6f69 e);...}..}...voi │ │ │ -00058890: 6420 7365 7373 696f 6e5f 696d 706c 3a3a d session_impl:: │ │ │ -000588a0: 7265 6d61 705f 706f 7274 7328 7265 6d61 remap_ports(rema │ │ │ -000588b0: 705f 706f 7274 5f6d 6173 6b5f 7420 636f p_port_mask_t co │ │ │ -000588c0: 6e73 7420 6d61 736b 0a09 092c 206c 6973 nst mask..., lis │ │ │ -000588d0: 7465 6e5f 736f 636b 6574 5f74 2661 6d70 ten_socket_t& │ │ │ -000588e0: 3b20 7329 0a3c 2f70 7265 3e3c 2f74 643e ; s).
    │ │ │ -000588f0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00058920: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00058930: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00058940: 7074 3a65 7870 616e 6428 3230 3929 223e pt:expand(209)"> │ │ │ -00058950: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -00058960: 6d70 6c2e 6370 703a 3239 3430 3c2f 613e mpl.cpp:2940 │ │ │ -00058970: 3c2f 7464 3e3c 7464 3e74 6869 7320 7369 this si │ │ │ -00058980: 7a65 206e 6565 6420 746f 2062 6520 6361 ze need to be ca │ │ │ -00058990: 7070 6564 3c2f 7464 3e3c 2f74 723e 3c74 ppedthis size need │ │ │ -000589f0: 2074 6f20 6265 2063 6170 7065 643c 2f68 to be capped

    ../src/ses │ │ │ -00058a10: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3239 sion_impl.cpp:29 │ │ │ -00058a20: 3430 3c2f 6834 3e3c 7072 6520 7374 796c 40

    ....// handshak
    │ │ │ -00058a70: 696e 670a 0909 0909 7265 7475 726e 2073  ing.....return s
    │ │ │ -00058a80: 6f63 6b65 745f 7479 7065 2873 736c 5f73  ocket_type(ssl_s
    │ │ │ -00058a90: 7472 6561 6d26 6c74 3b74 6370 3a3a 736f  tream<tcp::so
    │ │ │ -00058aa0: 636b 6574 2667 743b 2874 6370 3a3a 736f  cket>(tcp::so
    │ │ │ -00058ab0: 636b 6574 2873 7464 3a3a 6d6f 7665 2873  cket(std::move(s
    │ │ │ -00058ac0: 2929 2c20 6d5f 7065 6572 5f73 736c 5f63  )), m_peer_ssl_c
    │ │ │ -00058ad0: 7478 2929 3b0a 0909 097d 0a09 0909 656c  tx));....}....el
    │ │ │ -00058ae0: 7365 0a23 656e 6469 660a 0909 097b 0a09  se.#endif....{..
    │ │ │ -00058af0: 0909 0972 6574 7572 6e20 736f 636b 6574  ...return socket
    │ │ │ -00058b00: 5f74 7970 6528 7463 703a 3a73 6f63 6b65  _type(tcp::socke
    │ │ │ -00058b10: 7428 7374 643a 3a6d 6f76 6528 7329 2929  t(std::move(s)))
    │ │ │ -00058b20: 3b0a 0909 097d 0a09 097d 2829 3b0a 0a23  ;....}...}();..#
    │ │ │ -00058b30: 6966 6465 6620 544f 5252 454e 545f 5353  ifdef TORRENT_SS
    │ │ │ -00058b40: 4c5f 5045 4552 530a 0909 544f 5252 454e  L_PEERS...TORREN
    │ │ │ -00058b50: 545f 4153 5345 5254 2828 7373 6c20 3d3d  T_ASSERT((ssl ==
    │ │ │ -00058b60: 2074 7261 6e73 706f 7274 3a3a 7373 6c29   transport::ssl)
    │ │ │ -00058b70: 203d 3d20 6973 5f73 736c 2863 2929 3b0a   == is_ssl(c));.
    │ │ │ -00058b80: 2365 6e64 6966 0a0a 2369 6664 6566 2054  #endif..#ifdef T
    │ │ │ -00058b90: 4f52 5245 4e54 5f53 534c 5f50 4545 5253  ORRENT_SSL_PEERS
    │ │ │ -00058ba0: 0a09 0969 6620 2873 736c 203d 3d20 7472  ...if (ssl == tr
    │ │ │ -00058bb0: 616e 7370 6f72 743a 3a73 736c 290a 0909  ansport::ssl)...
    │ │ │ -00058bc0: 7b0a 0909 0954 4f52 5245 4e54 5f41 5353  {....TORRENT_ASS
    │ │ │ -00058bd0: 4552 5428 6973 5f73 736c 2863 2929 3b0a  ERT(is_ssl(c));.
    │ │ │ -00058be0: 0a09 0909 2f2f 2073 6176 6520 7468 6520  ....// save the 
    │ │ │ -00058bf0: 736f 636b 6574 2073 6f20 7765 2063 616e  socket so we can
    │ │ │ -00058c00: 2063 616e 6365 6c20 7468 6520 6861 6e64   cancel the hand
    │ │ │ -00058c10: 7368 616b 650a 3c64 6976 2073 7479 6c65  shake.
    ...auto iter │ │ │ -00058c50: 203d 206d 5f69 6e63 6f6d 696e 675f 736f = m_incoming_so │ │ │ -00058c60: 636b 6574 732e 656d 706c 6163 6528 7374 ckets.emplace(st │ │ │ -00058c70: 643a 3a6d 616b 655f 756e 6971 7565 266c d::make_unique&l │ │ │ -00058c80: 743b 736f 636b 6574 5f74 7970 6526 6774 t;socket_type> │ │ │ -00058c90: 3b28 7374 643a 3a6d 6f76 6528 6329 2929 ;(std::move(c))) │ │ │ -00058ca0: 2e66 6972 7374 3b0a 3c2f 6469 763e 0a09 .first;.
    .. │ │ │ -00058cb0: 0909 6175 746f 2073 6f63 6b20 3d20 6974 ..auto sock = it │ │ │ -00058cc0: 6572 2d26 6774 3b67 6574 2829 3b0a 0909 er->get();... │ │ │ -00058cd0: 092f 2f20 666f 7220 5353 4c20 636f 6e6e .// for SSL conn │ │ │ -00058ce0: 6563 7469 6f6e 732c 2069 6e63 6f6d 696e ections, incomin │ │ │ -00058cf0: 675f 636f 6e6e 6563 7469 6f6e 2829 2069 g_connection() i │ │ │ -00058d00: 7320 6361 6c6c 6564 0a09 0909 2f2f 2061 s called....// a │ │ │ -00058d10: 6674 6572 2074 6865 2068 616e 6473 6861 fter the handsha │ │ │ -00058d20: 6b65 2069 7320 646f 6e65 0a09 0909 4144 ke is done....AD │ │ │ -00058d30: 445f 4f55 5453 5441 4e44 494e 475f 4153 D_OUTSTANDING_AS │ │ │ -00058d40: 594e 4328 2273 6573 7369 6f6e 5f69 6d70 YNC("session_imp │ │ │ -00058d50: 6c3a 3a73 736c 5f68 616e 6473 6861 6b65 l::ssl_handshake │ │ │ -00058d60: 2229 3b0a 0909 0973 7464 3a3a 6765 7426 ");....std::get& │ │ │ -00058d70: 6c74 3b73 736c 5f73 7472 6561 6d26 6c74 lt;ssl_stream< │ │ │ -00058d80: 3b74 6370 3a3a 736f 636b 6574 2667 743b ;tcp::socket> │ │ │ -00058d90: 2667 743b 282a 2a69 7465 7229 2e61 7379 >(**iter).asy │ │ │ -00058da0: 6e63 5f61 6363 6570 745f 6861 6e64 7368 nc_accept_handsh │ │ │ -00058db0: 616b 6528 0a09 0909 095b 7468 6973 2c20 ake(.....[this, │ │ │ -00058dc0: 736f 636b 5d20 2865 7272 6f72 5f63 6f64 sock] (error_cod │ │ │ -00058dd0: 6520 636f 6e73 7426 616d 703b 2065 7272 e const& err │ │ │ -00058de0: 2920 7b20 7373 6c5f 6861 6e64 7368 616b ) { ssl_handshak │ │ │ -00058df0: 6528 6572 722c 2073 6f63 6b29 3b20 7d29 e(err, sock); }) │ │ │ -00058e00: 3b0a 0909 7d0a 0909 656c 7365 0a23 656e ;...}...else.#en │ │ │ -00058e10: 6469 660a 0909 7b0a 0909 0969 6e63 6f6d dif...{....incom │ │ │ -00058e20: 696e 675f 636f 6e6e 6563 7469 6f6e 2873 ing_connection(s │ │ │ -00058e30: 7464 3a3a 6d6f 7665 2863 2929 3b0a 0909 td::move(c));... │ │ │ -00058e40: 7d0a 097d 0a0a 2369 6664 6566 2054 4f52 }..}..#ifdef TOR │ │ │ -00058e50: 5245 4e54 5f53 534c 5f50 4545 5253 0a0a RENT_SSL_PEERS.. │ │ │ -00058e60: 0976 6f69 6420 7365 7373 696f 6e5f 696d .void session_im │ │ │ -00058e70: 706c 3a3a 6f6e 5f69 6e63 6f6d 696e 675f pl::on_incoming_ │ │ │ -00058e80: 7574 705f 7373 6c28 736f 636b 6574 5f74 utp_ssl(socket_t │ │ │ -00058e90: 7970 6520 7329 0a09 7b0a 0909 544f 5252 ype s)..{...TORR │ │ │ -00058ea0: 454e 545f 4153 5345 5254 2869 735f 7373 ENT_ASSERT(is_ss │ │ │ -00058eb0: 6c28 7329 293b 0a0a 0909 2f2f 2073 6176 l(s));....// sav │ │ │ -00058ec0: 6520 7468 6520 736f 636b 6574 2073 6f20 e the socket so │ │ │ -00058ed0: 7765 2063 616e 2063 616e 6365 6c20 7468 we can cancel th │ │ │ -00058ee0: 6520 6861 6e64 7368 616b 650a 0a3c 2f70 e handshake..

    re │ │ │ -00058f20: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/s │ │ │ -00058f60: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ -00058f70: 3239 3635 3c2f 613e 3c2f 7464 3e3c 7464 2965this size need │ │ │ -00058f90: 746f 2062 6520 6361 7070 6564 3c2f 7464 to be capped

    this s │ │ │ -00058ff0: 697a 6520 6e65 6564 2074 6f20 6265 2063 ize need to be c │ │ │ -00059000: 6170 7065 643c 2f68 323e 3c68 343e 2e2e apped

    .. │ │ │ -00059010: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ -00059020: 6c2e 6370 703a 3239 3635 3c2f 6834 3e3c l.cpp:2965

    < │ │ │ -00059030: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00059040: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00059050: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00059060: 7820 2364 6464 3b22 3e09 0909 2f2f 2061 x #ddd;">...// a │ │ │ -00059070: 6674 6572 2074 6865 2068 616e 6473 6861 fter the handsha │ │ │ -00059080: 6b65 2069 7320 646f 6e65 0a09 0909 4144 ke is done....AD │ │ │ -00059090: 445f 4f55 5453 5441 4e44 494e 475f 4153 D_OUTSTANDING_AS │ │ │ -000590a0: 594e 4328 2273 6573 7369 6f6e 5f69 6d70 YNC("session_imp │ │ │ -000590b0: 6c3a 3a73 736c 5f68 616e 6473 6861 6b65 l::ssl_handshake │ │ │ -000590c0: 2229 3b0a 0909 0973 7464 3a3a 6765 7426 ");....std::get& │ │ │ -000590d0: 6c74 3b73 736c 5f73 7472 6561 6d26 6c74 lt;ssl_stream< │ │ │ -000590e0: 3b74 6370 3a3a 736f 636b 6574 2667 743b ;tcp::socket> │ │ │ -000590f0: 2667 743b 282a 2a69 7465 7229 2e61 7379 >(**iter).asy │ │ │ -00059100: 6e63 5f61 6363 6570 745f 6861 6e64 7368 nc_accept_handsh │ │ │ -00059110: 616b 6528 0a09 0909 095b 7468 6973 2c20 ake(.....[this, │ │ │ -00059120: 736f 636b 5d20 2865 7272 6f72 5f63 6f64 sock] (error_cod │ │ │ -00059130: 6520 636f 6e73 7426 616d 703b 2065 7272 e const& err │ │ │ -00059140: 2920 7b20 7373 6c5f 6861 6e64 7368 616b ) { ssl_handshak │ │ │ -00059150: 6528 6572 722c 2073 6f63 6b29 3b20 7d29 e(err, sock); }) │ │ │ -00059160: 3b0a 0909 7d0a 0909 656c 7365 0a23 656e ;...}...else.#en │ │ │ -00059170: 6469 660a 0909 7b0a 0909 0969 6e63 6f6d dif...{....incom │ │ │ -00059180: 696e 675f 636f 6e6e 6563 7469 6f6e 2873 ing_connection(s │ │ │ -00059190: 7464 3a3a 6d6f 7665 2863 2929 3b0a 0909 td::move(c));... │ │ │ -000591a0: 7d0a 097d 0a0a 2369 6664 6566 2054 4f52 }..}..#ifdef TOR │ │ │ -000591b0: 5245 4e54 5f53 534c 5f50 4545 5253 0a0a RENT_SSL_PEERS.. │ │ │ -000591c0: 0976 6f69 6420 7365 7373 696f 6e5f 696d .void session_im │ │ │ -000591d0: 706c 3a3a 6f6e 5f69 6e63 6f6d 696e 675f pl::on_incoming_ │ │ │ -000591e0: 7574 705f 7373 6c28 736f 636b 6574 5f74 utp_ssl(socket_t │ │ │ -000591f0: 7970 6520 7329 0a09 7b0a 0909 544f 5252 ype s)..{...TORR │ │ │ -00059200: 454e 545f 4153 5345 5254 2869 735f 7373 ENT_ASSERT(is_ss │ │ │ -00059210: 6c28 7329 293b 0a0a 0909 2f2f 2073 6176 l(s));....// sav │ │ │ -00059220: 6520 7468 6520 736f 636b 6574 2073 6f20 e the socket so │ │ │ -00059230: 7765 2063 616e 2063 616e 6365 6c20 7468 we can cancel th │ │ │ -00059240: 6520 6861 6e64 7368 616b 650a 0a3c 6469 e handshake....aut │ │ │ -00059280: 6f20 6974 6572 203d 206d 5f69 6e63 6f6d o iter = m_incom │ │ │ -00059290: 696e 675f 736f 636b 6574 732e 656d 706c ing_sockets.empl │ │ │ -000592a0: 6163 6528 7374 643a 3a6d 616b 655f 756e ace(std::make_un │ │ │ -000592b0: 6971 7565 266c 743b 736f 636b 6574 5f74 ique<socket_t │ │ │ -000592c0: 7970 6526 6774 3b28 7374 643a 3a6d 6f76 ype>(std::mov │ │ │ -000592d0: 6528 7329 2929 2e66 6972 7374 3b0a 3c2f e(s))).first;...auto sock │ │ │ -000592f0: 3d20 6974 6572 2d26 6774 3b67 6574 2829 = iter->get() │ │ │ -00059300: 3b0a 0a09 092f 2f20 666f 7220 5353 4c20 ;....// for SSL │ │ │ -00059310: 636f 6e6e 6563 7469 6f6e 732c 2069 6e63 connections, inc │ │ │ -00059320: 6f6d 696e 675f 636f 6e6e 6563 7469 6f6e oming_connection │ │ │ -00059330: 2829 2069 7320 6361 6c6c 6564 0a09 092f () is called.../ │ │ │ -00059340: 2f20 6166 7465 7220 7468 6520 6861 6e64 / after the hand │ │ │ -00059350: 7368 616b 6520 6973 2064 6f6e 650a 0909 shake is done... │ │ │ -00059360: 4144 445f 4f55 5453 5441 4e44 494e 475f ADD_OUTSTANDING_ │ │ │ -00059370: 4153 594e 4328 2273 6573 7369 6f6e 5f69 ASYNC("session_i │ │ │ -00059380: 6d70 6c3a 3a73 736c 5f68 616e 6473 6861 mpl::ssl_handsha │ │ │ -00059390: 6b65 2229 3b0a 0909 7374 643a 3a67 6574 ke");...std::get │ │ │ -000593a0: 266c 743b 7373 6c5f 7374 7265 616d 266c <ssl_stream&l │ │ │ -000593b0: 743b 7574 705f 7374 7265 616d 2667 743b t;utp_stream> │ │ │ -000593c0: 2667 743b 282a 2a69 7465 7229 2e61 7379 >(**iter).asy │ │ │ -000593d0: 6e63 5f61 6363 6570 745f 6861 6e64 7368 nc_accept_handsh │ │ │ -000593e0: 616b 6528 0a09 0909 5b74 6869 732c 2073 ake(....[this, s │ │ │ -000593f0: 6f63 6b5d 2028 6572 726f 725f 636f 6465 ock] (error_code │ │ │ -00059400: 2063 6f6e 7374 2661 6d70 3b20 6572 7229 const& err) │ │ │ -00059410: 207b 2073 736c 5f68 616e 6473 6861 6b65 { ssl_handshake │ │ │ -00059420: 2865 7272 2c20 736f 636b 293b 207d 293b (err, sock); }); │ │ │ -00059430: 0a09 7d0a 0a09 2f2f 2074 6f20 7465 7374 ..}...// to test │ │ │ -00059440: 2053 534c 2063 6f6e 6e65 6374 696f 6e73 SSL connections │ │ │ -00059450: 2c20 6f6e 6520 6361 6e20 7573 6520 7468 , one can use th │ │ │ -00059460: 6973 206f 7065 6e73 736c 2063 6f6d 6d61 is openssl comma │ │ │ -00059470: 6e64 2074 656d 706c 6174 653a 0a09 2f2f nd template:..// │ │ │ -00059480: 0a09 2f2f 206f 7065 6e73 736c 2073 5f63 ..// openssl s_c │ │ │ -00059490: 6c69 656e 7420 2d63 6572 7420 266c 743b lient -cert < │ │ │ -000594a0: 636c 6965 6e74 2d63 6572 7426 6774 3b2e client-cert>. │ │ │ -000594b0: 7065 6d20 2d6b 6579 2026 6c74 3b63 6c69 pem -key <cli │ │ │ -000594c0: 656e 742d 7072 6976 6174 652d 6b65 7926 ent-private-key& │ │ │ -000594d0: 6774 3b2e 7065 6d0a 092f 2f20 2020 2d43 gt;.pem..// -C │ │ │ -000594e0: 4166 696c 6520 266c 743b 746f 7272 656e Afile <torren │ │ │ -000594f0: 742d 6365 7274 2667 743b 2e70 656d 2020 t-cert>.pem │ │ │ -00059500: 2d64 6562 7567 202d 636f 6e6e 6563 7420 -debug -connect │ │ │ -00059510: 3132 372e 302e 302e 313a 3434 3333 202d 127.0.0.1:4433 - │ │ │ -00059520: 746c 7331 0a09 2f2f 2020 202d 7365 7276 tls1..// -serv │ │ │ -00059530: 6572 6e61 6d65 2026 6c74 3b68 6578 2d65 ername <hex-e │ │ │ -00059540: 6e63 6f64 6564 2d69 6e66 6f2d 6861 7368 ncoded-info-hash │ │ │ -00059550: 2667 743b 0a0a 0976 6f69 6420 7365 7373 >...void sess │ │ │ -00059560: 696f 6e5f 696d 706c 3a3a 7373 6c5f 6861 ion_impl::ssl_ha │ │ │ -00059570: 6e64 7368 616b 6528 6572 726f 725f 636f ndshake(error_co │ │ │ -00059580: 6465 2063 6f6e 7374 2661 6d70 3b20 6563 de const& ec │ │ │ -00059590: 2c20 736f 636b 6574 5f74 7970 652a 2073 , socket_type* s │ │ │ -000595a0: 6f63 6b29 0a09 7b0a 0909 434f 4d50 4c45 ock)..{...COMPLE │ │ │ -000595b0: 5445 5f41 5359 4e43 2822 7365 7373 696f TE_ASYNC("sessio │ │ │ -000595c0: 6e5f 696d 706c 3a3a 7373 6c5f 6861 6e64 n_impl::ssl_hand │ │ │ -000595d0: 7368 616b 6522 293b 0a0a 0909 6175 746f shake");....auto │ │ │ -000595e0: 2069 7465 7220 3d20 6d5f 696e 636f 6d69 iter = m_incomi │ │ │ -000595f0: 6e67 5f73 6f63 6b65 7473 2e66 696e 6428 ng_sockets.find( │ │ │ -00059600: 736f 636b 293b 0a0a 0909 2f2f 2074 6869 sock);....// thi │ │ │ -00059610: 7320 6861 7070 656e 7320 6966 2074 6865 s happens if the │ │ │ -00059620: 2053 534c 2063 6f6e 6e65 6374 696f 6e20 SSL connection │ │ │ -00059630: 6973 2061 626f 7274 6564 2062 6563 6175 is aborted becau │ │ │ -00059640: 7365 2077 6527 7265 2073 6875 7474 696e se we're shuttin │ │ │ -00059650: 670a 0909 2f2f 2064 6f77 6e0a 0909 6966 g...// down...if │ │ │ -00059660: 2028 6974 6572 203d 3d20 6d5f 696e 636f (iter == m_inco │ │ │ -00059670: 6d69 6e67 5f73 6f63 6b65 7473 2e65 6e64 ming_sockets.end │ │ │ -00059680: 2829 2920 7265 7475 726e 3b0a 0a09 0973 ()) return;....s │ │ │ -00059690: 6f63 6b65 745f 7479 7065 2073 2873 7464 ocket_type s(std │ │ │ -000596a0: 3a3a 6d6f 7665 282a 2a69 7465 7229 293b ::move(**iter)); │ │ │ -000596b0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -000596c0: 5428 6973 5f73 736c 2873 2929 3b0a 0909 T(is_ssl(s));... │ │ │ -000596d0: 6d5f 696e 636f 6d69 6e67 5f73 6f63 6b65 m_incoming_socke │ │ │ -000596e0: 7473 2e65 7261 7365 2869 7465 7229 3b0a ts.erase(iter);. │ │ │ -000596f0: 0a09 0965 7272 6f72 5f63 6f64 6520 653b ...error_code e; │ │ │ -00059700: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00059740: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -00059770: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -00059780: 6370 703a 3336 3838 3c2f 613e 3c2f 7464 cpp:3688have a sepa │ │ │ -000597a0: 7261 7465 206c 6973 7420 666f 7220 7468 rate list for th │ │ │ -000597b0: 6573 6520 636f 6e6e 6563 7469 6f6e 732c ese connections, │ │ │ -000597c0: 2069 6e73 7465 6164 206f 6620 6861 7669 instead of havi │ │ │ -000597d0: 6e67 2074 6f20 6c6f 6f70 2074 6872 6f75 ng to loop throu │ │ │ -000597e0: 6768 2061 6c6c 206f 6620 7468 656d 3c2f gh all of them

    have │ │ │ -00059840: 2061 2073 6570 6172 6174 6520 6c69 7374 a separate list │ │ │ -00059850: 2066 6f72 2074 6865 7365 2063 6f6e 6e65 for these conne │ │ │ -00059860: 6374 696f 6e73 2c20 696e 7374 6561 6420 ctions, instead │ │ │ -00059870: 6f66 2068 6176 696e 6720 746f 206c 6f6f of having to loo │ │ │ -00059880: 7020 7468 726f 7567 6820 616c 6c20 6f66 p through all of │ │ │ -00059890: 2074 6865 6d3c 2f68 323e 3c68 343e 2e2e them

    .. │ │ │ -000598a0: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ -000598b0: 6c2e 6370 703a 3336 3838 3c2f 6834 3e3c l.cpp:3688

    < │ │ │ -000598c0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000598d0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000598e0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -000598f0: 7820 2364 6464 3b22 3e09 092f 2f20 2d2d x #ddd;">..// -- │ │ │ -00059900: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059910: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059920: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059930: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a09 0969 ------------...i │ │ │ -00059940: 6620 2821 6d5f 7061 7573 6564 2920 6d5f f (!m_paused) m_ │ │ │ -00059950: 6175 746f 5f6d 616e 6167 655f 7469 6d65 auto_manage_time │ │ │ -00059960: 5f73 6361 6c65 722d 2d3b 0a09 0969 6620 _scaler--;...if │ │ │ -00059970: 286d 5f61 7574 6f5f 6d61 6e61 6765 5f74 (m_auto_manage_t │ │ │ -00059980: 696d 655f 7363 616c 6572 2026 6c74 3b20 ime_scaler < │ │ │ -00059990: 3029 0a09 097b 0a09 0909 6d5f 6175 746f 0)...{....m_auto │ │ │ -000599a0: 5f6d 616e 6167 655f 7469 6d65 5f73 6361 _manage_time_sca │ │ │ -000599b0: 6c65 7220 3d20 7365 7474 696e 6773 2829 ler = settings() │ │ │ -000599c0: 2e67 6574 5f69 6e74 2873 6574 7469 6e67 .get_int(setting │ │ │ -000599d0: 735f 7061 636b 3a3a 6175 746f 5f6d 616e s_pack::auto_man │ │ │ -000599e0: 6167 655f 696e 7465 7276 616c 293b 0a09 age_interval);.. │ │ │ -000599f0: 0909 7265 6361 6c63 756c 6174 655f 6175 ..recalculate_au │ │ │ -00059a00: 746f 5f6d 616e 6167 6564 5f74 6f72 7265 to_managed_torre │ │ │ -00059a10: 6e74 7328 293b 0a09 097d 0a0a 0909 2f2f nts();...}....// │ │ │ -00059a20: 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d --------------- │ │ │ -00059a30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059a40: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059a50: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a ---------------. │ │ │ -00059a60: 0909 2f2f 2063 6865 636b 2066 6f72 2069 ..// check for i │ │ │ -00059a70: 6e63 6f6d 696e 6720 636f 6e6e 6563 7469 ncoming connecti │ │ │ -00059a80: 6f6e 7320 7468 6174 206d 6967 6874 2068 ons that might h │ │ │ -00059a90: 6176 6520 7469 6d65 6420 6f75 740a 0909 ave timed out... │ │ │ -00059aa0: 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d // ------------- │ │ │ -00059ab0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059ac0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059ad0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059ae0: 2d0a 0a09 0966 6f72 2028 6175 746f 2069 -....for (auto i │ │ │ -00059af0: 203d 206d 5f63 6f6e 6e65 6374 696f 6e73 = m_connections │ │ │ -00059b00: 2e62 6567 696e 2829 3b20 6920 213d 206d .begin(); i != m │ │ │ -00059b10: 5f63 6f6e 6e65 6374 696f 6e73 2e65 6e64 _connections.end │ │ │ -00059b20: 2829 3b29 0a09 097b 0a09 0909 7065 6572 ();)...{....peer │ │ │ -00059b30: 5f63 6f6e 6e65 6374 696f 6e2a 2070 203d _connection* p = │ │ │ -00059b40: 2028 2a69 292e 6765 7428 293b 0a09 0909 (*i).get();.... │ │ │ -00059b50: 2b2b 693b 0a09 0909 2f2f 2069 676e 6f72 ++i;....// ignor │ │ │ -00059b60: 6520 636f 6e6e 6563 7469 6f6e 7320 7468 e connections th │ │ │ -00059b70: 6174 2061 6c72 6561 6479 2068 6176 6520 at already have │ │ │ -00059b80: 6120 746f 7272 656e 742c 2073 696e 6365 a torrent, since │ │ │ -00059b90: 2074 6865 790a 0909 092f 2f20 6172 6520 they....// are │ │ │ -00059ba0: 7469 636b 6564 2074 6872 6f75 6768 2074 ticked through t │ │ │ -00059bb0: 6865 2074 6f72 7265 6e74 7327 2073 6563 he torrents' sec │ │ │ -00059bc0: 6f6e 645f 7469 636b 0a09 0909 6966 2028 ond_tick....if ( │ │ │ -00059bd0: 2170 2d26 6774 3b61 7373 6f63 6961 7465 !p->associate │ │ │ -00059be0: 645f 746f 7272 656e 7428 292e 6578 7069 d_torrent().expi │ │ │ -00059bf0: 7265 6428 2929 2063 6f6e 7469 6e75 653b red()) continue; │ │ │ -00059c00: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261 ..
    │ │ │ -00059c30: 0909 0969 6e74 2074 696d 656f 7574 203d ...int timeout = │ │ │ -00059c40: 206d 5f73 6574 7469 6e67 732e 6765 745f m_settings.get_ │ │ │ -00059c50: 696e 7428 7365 7474 696e 6773 5f70 6163 int(settings_pac │ │ │ -00059c60: 6b3a 3a68 616e 6473 6861 6b65 5f74 696d k::handshake_tim │ │ │ -00059c70: 656f 7574 293b 0a3c 2f64 6976 3e23 6966 eout);.
    #if │ │ │ -00059c80: 2054 4f52 5245 4e54 5f55 5345 5f49 3250 TORRENT_USE_I2P │ │ │ -00059c90: 0a09 0909 7469 6d65 6f75 7420 2a3d 2069 ....timeout *= i │ │ │ -00059ca0: 735f 6932 7028 702d 2667 743b 6765 745f s_i2p(p->get_ │ │ │ -00059cb0: 736f 636b 6574 2829 2920 3f20 3420 3a20 socket()) ? 4 : │ │ │ -00059cc0: 313b 0a23 656e 6469 660a 0909 0969 6620 1;.#endif....if │ │ │ -00059cd0: 286d 5f6c 6173 745f 7469 636b 202d 2070 (m_last_tick - p │ │ │ -00059ce0: 2d26 6774 3b63 6f6e 6e65 6374 6564 5f74 ->connected_t │ │ │ -00059cf0: 696d 6520 2829 2026 6774 3b20 7365 636f ime () > seco │ │ │ -00059d00: 6e64 7328 7469 6d65 6f75 7429 290a 0909 nds(timeout))... │ │ │ -00059d10: 0909 702d 2667 743b 6469 7363 6f6e 6e65 ..p->disconne │ │ │ -00059d20: 6374 2865 7272 6f72 733a 3a74 696d 6564 ct(errors::timed │ │ │ -00059d30: 5f6f 7574 2c20 6f70 6572 6174 696f 6e5f _out, operation_ │ │ │ -00059d40: 743a 3a62 6974 746f 7272 656e 7429 3b0a t::bittorrent);. │ │ │ -00059d50: 0909 7d0a 0a09 092f 2f20 2d2d 2d2d 2d2d ..}....// ------ │ │ │ -00059d60: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059d70: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059d80: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059d90: 2d2d 2d2d 2d2d 2d2d 0a09 092f 2f20 7365 --------...// se │ │ │ -00059da0: 636f 6e64 5f74 6963 6b20 6576 6572 7920 cond_tick every │ │ │ -00059db0: 746f 7272 656e 7420 2874 6861 7420 7761 torrent (that wa │ │ │ -00059dc0: 6e74 7320 6974 290a 0909 2f2f 202d 2d2d nts it)...// --- │ │ │ -00059dd0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059de0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059df0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059e00: 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0a23 6966 -----------..#if │ │ │ -00059e10: 2054 4f52 5245 4e54 5f44 4542 5547 5f53 TORRENT_DEBUG_S │ │ │ -00059e20: 5452 4541 4d49 4e47 2026 6774 3b20 300a TREAMING > 0. │ │ │ -00059e30: 0909 7374 643a 3a70 7269 6e74 6628 225c ..std::printf("\ │ │ │ -00059e40: 3033 335b 324a 5c30 3333 5b30 3b30 4822 033[2J\033[0;0H" │ │ │ -00059e50: 293b 0a23 656e 6469 660a 0a09 0961 7578 );.#endif....aux │ │ │ -00059e60: 3a3a 7665 6374 6f72 266c 743b 746f 7272 ::vector<torr │ │ │ -00059e70: 656e 742a 2667 743b 2661 6d70 3b20 7761 ent*>& wa │ │ │ -00059e80: 6e74 5f74 6963 6b20 3d20 6d5f 746f 7272 nt_tick = m_torr │ │ │ -00059e90: 656e 745f 6c69 7374 735b 746f 7272 656e ent_lists[torren │ │ │ -00059ea0: 745f 7761 6e74 5f74 6963 6b5d 3b0a 0909 t_want_tick];... │ │ │ -00059eb0: 666f 7220 2869 6e74 2069 203d 2030 3b20 for (int i = 0; │ │ │ -00059ec0: 6920 266c 743b 2069 6e74 2877 616e 745f i < int(want_ │ │ │ -00059ed0: 7469 636b 2e73 697a 6528 2929 3b20 2b2b tick.size()); ++ │ │ │ -00059ee0: 6929 0a09 097b 0a09 0909 746f 7272 656e i)...{....torren │ │ │ -00059ef0: 7426 616d 703b 2074 203d 202a 7761 6e74 t& t = *want │ │ │ -00059f00: 5f74 6963 6b5b 695d 3b0a 0909 0954 4f52 _tick[i];....TOR │ │ │ -00059f10: 5245 4e54 5f41 5353 4552 5428 742e 7761 RENT_ASSERT(t.wa │ │ │ -00059f20: 6e74 5f74 6963 6b28 2929 3b0a 0909 0954 nt_tick());....T │ │ │ -00059f30: 4f52 5245 4e54 5f41 5353 4552 5428 2174 ORRENT_ASSERT(!t │ │ │ -00059f40: 2e69 735f 6162 6f72 7465 6428 2929 3b0a .is_aborted());. │ │ │ -00059f50: 0a09 0909 742e 7365 636f 6e64 5f74 6963 ....t.second_tic │ │ │ -00059f60: 6b28 7469 636b 5f69 6e74 6572 7661 6c5f k(tick_interval_ │ │ │ -00059f70: 6d73 293b 0a0a 0909 092f 2f20 6966 2074 ms);.....// if t │ │ │ -00059f80: 6865 2063 616c 6c20 746f 2073 6563 6f6e he call to secon │ │ │ -00059f90: 645f 7469 636b 2063 6175 7365 6420 7468 d_tick caused th │ │ │ -00059fa0: 6520 746f 7272 656e 740a 0909 092f 2f20 e torrent....// │ │ │ -00059fb0: 746f 206e 6f20 6c6f 6e67 6572 2077 616e to no longer wan │ │ │ -00059fc0: 7420 746f 2062 6520 7469 636b 6564 2028 t to be ticked ( │ │ │ -00059fd0: 692e 652e 2069 7420 7761 730a 0909 092f i.e. it was..../ │ │ │ -00059fe0: 2f20 7265 6d6f 7665 6420 6672 6f6d 2074 / removed from t │ │ │ -00059ff0: 6865 206c 6973 7429 2077 6520 6e65 6564 he list) we need │ │ │ -0005a000: 2074 6f20 6261 636b 2075 7020 7468 6520 to back up the │ │ │ -0005a010: 636f 756e 7465 720a 0909 092f 2f20 746f counter....// to │ │ │ -0005a020: 206e 6f74 206d 6973 7320 7468 6520 746f not miss the to │ │ │ -0005a030: 7272 656e 7420 6166 7465 7220 6974 0a09 rrent after it.. │ │ │ -0005a040: 0909 6966 2028 2174 2e77 616e 745f 7469 ..if (!t.want_ti │ │ │ -0005a050: 636b 2829 2920 2d2d 693b 0a09 097d 0a3c ck()) --i;...}.< │ │ │ -0005a060: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0005a070: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0005a080: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0005a090: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0005a0a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0005a0d0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0005a0e0: 703a 3337 3231 3c2f 613e 3c2f 7464 3e3c p:3721< │ │ │ -0005a0f0: 7464 3e74 6869 7320 7368 6f75 6c64 2061 td>this should a │ │ │ -0005a100: 7070 6c79 2074 6f20 616c 6c20 6261 6e64 pply to all band │ │ │ -0005a110: 7769 6474 6820 6368 616e 6e65 6c73 3c2f width channels

    this │ │ │ -0005a170: 2073 686f 756c 6420 6170 706c 7920 746f should apply to │ │ │ -0005a180: 2061 6c6c 2062 616e 6477 6964 7468 2063 all bandwidth c │ │ │ -0005a190: 6861 6e6e 656c 733c 2f68 323e 3c68 343e hannels

    │ │ │ -0005a1a0: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0005a1b0: 6d70 6c2e 6370 703a 3337 3231 3c2f 6834 mpl.cpp:3721

    #if T
    │ │ │ -0005a200: 4f52 5245 4e54 5f44 4542 5547 5f53 5452  ORRENT_DEBUG_STR
    │ │ │ -0005a210: 4541 4d49 4e47 2026 6774 3b20 300a 0909  EAMING > 0...
    │ │ │ -0005a220: 7374 643a 3a70 7269 6e74 6628 225c 3033  std::printf("\03
    │ │ │ -0005a230: 335b 324a 5c30 3333 5b30 3b30 4822 293b  3[2J\033[0;0H");
    │ │ │ -0005a240: 0a23 656e 6469 660a 0a09 0961 7578 3a3a  .#endif....aux::
    │ │ │ -0005a250: 7665 6374 6f72 266c 743b 746f 7272 656e  vector<torren
    │ │ │ -0005a260: 742a 2667 743b 2661 6d70 3b20 7761 6e74  t*>& want
    │ │ │ -0005a270: 5f74 6963 6b20 3d20 6d5f 746f 7272 656e  _tick = m_torren
    │ │ │ -0005a280: 745f 6c69 7374 735b 746f 7272 656e 745f  t_lists[torrent_
    │ │ │ -0005a290: 7761 6e74 5f74 6963 6b5d 3b0a 0909 666f  want_tick];...fo
    │ │ │ -0005a2a0: 7220 2869 6e74 2069 203d 2030 3b20 6920  r (int i = 0; i 
    │ │ │ -0005a2b0: 266c 743b 2069 6e74 2877 616e 745f 7469  < int(want_ti
    │ │ │ -0005a2c0: 636b 2e73 697a 6528 2929 3b20 2b2b 6929  ck.size()); ++i)
    │ │ │ -0005a2d0: 0a09 097b 0a09 0909 746f 7272 656e 7426  ...{....torrent&
    │ │ │ -0005a2e0: 616d 703b 2074 203d 202a 7761 6e74 5f74  amp; t = *want_t
    │ │ │ -0005a2f0: 6963 6b5b 695d 3b0a 0909 0954 4f52 5245  ick[i];....TORRE
    │ │ │ -0005a300: 4e54 5f41 5353 4552 5428 742e 7761 6e74  NT_ASSERT(t.want
    │ │ │ -0005a310: 5f74 6963 6b28 2929 3b0a 0909 0954 4f52  _tick());....TOR
    │ │ │ -0005a320: 5245 4e54 5f41 5353 4552 5428 2174 2e69  RENT_ASSERT(!t.i
    │ │ │ -0005a330: 735f 6162 6f72 7465 6428 2929 3b0a 0a09  s_aborted());...
    │ │ │ -0005a340: 0909 742e 7365 636f 6e64 5f74 6963 6b28  ..t.second_tick(
    │ │ │ -0005a350: 7469 636b 5f69 6e74 6572 7661 6c5f 6d73  tick_interval_ms
    │ │ │ -0005a360: 293b 0a0a 0909 092f 2f20 6966 2074 6865  );.....// if the
    │ │ │ -0005a370: 2063 616c 6c20 746f 2073 6563 6f6e 645f   call to second_
    │ │ │ -0005a380: 7469 636b 2063 6175 7365 6420 7468 6520  tick caused the 
    │ │ │ -0005a390: 746f 7272 656e 740a 0909 092f 2f20 746f  torrent....// to
    │ │ │ -0005a3a0: 206e 6f20 6c6f 6e67 6572 2077 616e 7420   no longer want 
    │ │ │ -0005a3b0: 746f 2062 6520 7469 636b 6564 2028 692e  to be ticked (i.
    │ │ │ -0005a3c0: 652e 2069 7420 7761 730a 0909 092f 2f20  e. it was....// 
    │ │ │ -0005a3d0: 7265 6d6f 7665 6420 6672 6f6d 2074 6865  removed from the
    │ │ │ -0005a3e0: 206c 6973 7429 2077 6520 6e65 6564 2074   list) we need t
    │ │ │ -0005a3f0: 6f20 6261 636b 2075 7020 7468 6520 636f  o back up the co
    │ │ │ -0005a400: 756e 7465 720a 0909 092f 2f20 746f 206e  unter....// to n
    │ │ │ -0005a410: 6f74 206d 6973 7320 7468 6520 746f 7272  ot miss the torr
    │ │ │ -0005a420: 656e 7420 6166 7465 7220 6974 0a09 0909  ent after it....
    │ │ │ -0005a430: 6966 2028 2174 2e77 616e 745f 7469 636b  if (!t.want_tick
    │ │ │ -0005a440: 2829 2920 2d2d 693b 0a09 097d 0a0a 3c64  ()) --i;...}....if
    │ │ │ -0005a480: 2028 6d5f 7365 7474 696e 6773 2e67 6574   (m_settings.get
    │ │ │ -0005a490: 5f62 6f6f 6c28 7365 7474 696e 6773 5f70  _bool(settings_p
    │ │ │ -0005a4a0: 6163 6b3a 3a72 6174 655f 6c69 6d69 745f  ack::rate_limit_
    │ │ │ -0005a4b0: 6970 5f6f 7665 7268 6561 6429 290a 3c2f  ip_overhead))...{....int c
    │ │ │ -0005a4d0: 6f6e 7374 2075 705f 6c69 6d69 7420 3d20  onst up_limit = 
    │ │ │ -0005a4e0: 7570 6c6f 6164 5f72 6174 655f 6c69 6d69  upload_rate_limi
    │ │ │ -0005a4f0: 7428 6d5f 676c 6f62 616c 5f63 6c61 7373  t(m_global_class
    │ │ │ -0005a500: 293b 0a09 0909 696e 7420 636f 6e73 7420  );....int const 
    │ │ │ -0005a510: 646f 776e 5f6c 696d 6974 203d 2064 6f77  down_limit = dow
    │ │ │ -0005a520: 6e6c 6f61 645f 7261 7465 5f6c 696d 6974  nload_rate_limit
    │ │ │ -0005a530: 286d 5f67 6c6f 6261 6c5f 636c 6173 7329  (m_global_class)
    │ │ │ -0005a540: 3b0a 0a09 0909 6966 2028 646f 776e 5f6c  ;.....if (down_l
    │ │ │ -0005a550: 696d 6974 2026 6774 3b20 300a 0909 0909  imit > 0.....
    │ │ │ -0005a560: 2661 6d70 3b26 616d 703b 206d 5f73 7461  && m_sta
    │ │ │ -0005a570: 742e 646f 776e 6c6f 6164 5f69 705f 6f76  t.download_ip_ov
    │ │ │ -0005a580: 6572 6865 6164 2829 2026 6774 3b3d 2064  erhead() >= d
    │ │ │ -0005a590: 6f77 6e5f 6c69 6d69 740a 0909 0909 2661  own_limit.....&a
    │ │ │ -0005a5a0: 6d70 3b26 616d 703b 206d 5f61 6c65 7274  mp;& m_alert
    │ │ │ -0005a5b0: 732e 7368 6f75 6c64 5f70 6f73 7426 6c74  s.should_post<
    │ │ │ -0005a5c0: 3b70 6572 666f 726d 616e 6365 5f61 6c65  ;performance_ale
    │ │ │ -0005a5d0: 7274 2667 743b 2829 290a 0909 097b 0a09  rt>())....{..
    │ │ │ -0005a5e0: 0909 096d 5f61 6c65 7274 732e 656d 706c  ...m_alerts.empl
    │ │ │ -0005a5f0: 6163 655f 616c 6572 7426 6c74 3b70 6572  ace_alert<per
    │ │ │ -0005a600: 666f 726d 616e 6365 5f61 6c65 7274 2667  formance_alert&g
    │ │ │ -0005a610: 743b 2874 6f72 7265 6e74 5f68 616e 646c  t;(torrent_handl
    │ │ │ -0005a620: 6528 290a 0909 0909 092c 2070 6572 666f  e()......, perfo
    │ │ │ -0005a630: 726d 616e 6365 5f61 6c65 7274 3a3a 646f  rmance_alert::do
    │ │ │ -0005a640: 776e 6c6f 6164 5f6c 696d 6974 5f74 6f6f  wnload_limit_too
    │ │ │ -0005a650: 5f6c 6f77 293b 0a09 0909 7d0a 0a09 0909  _low);....}.....
    │ │ │ -0005a660: 6966 2028 7570 5f6c 696d 6974 2026 6774  if (up_limit >
    │ │ │ -0005a670: 3b20 300a 0909 0909 2661 6d70 3b26 616d  ; 0.....&&am
    │ │ │ -0005a680: 703b 206d 5f73 7461 742e 7570 6c6f 6164  p; m_stat.upload
    │ │ │ -0005a690: 5f69 705f 6f76 6572 6865 6164 2829 2026  _ip_overhead() &
    │ │ │ -0005a6a0: 6774 3b3d 2075 705f 6c69 6d69 740a 0909  gt;= up_limit...
    │ │ │ -0005a6b0: 0909 2661 6d70 3b26 616d 703b 206d 5f61  ..&& m_a
    │ │ │ -0005a6c0: 6c65 7274 732e 7368 6f75 6c64 5f70 6f73  lerts.should_pos
    │ │ │ -0005a6d0: 7426 6c74 3b70 6572 666f 726d 616e 6365  t<performance
    │ │ │ -0005a6e0: 5f61 6c65 7274 2667 743b 2829 290a 0909  _alert>())...
    │ │ │ -0005a6f0: 097b 0a09 0909 096d 5f61 6c65 7274 732e  .{.....m_alerts.
    │ │ │ -0005a700: 656d 706c 6163 655f 616c 6572 7426 6c74  emplace_alert<
    │ │ │ -0005a710: 3b70 6572 666f 726d 616e 6365 5f61 6c65  ;performance_ale
    │ │ │ -0005a720: 7274 2667 743b 2874 6f72 7265 6e74 5f68  rt>(torrent_h
    │ │ │ -0005a730: 616e 646c 6528 290a 0909 0909 092c 2070  andle()......, p
    │ │ │ -0005a740: 6572 666f 726d 616e 6365 5f61 6c65 7274  erformance_alert
    │ │ │ -0005a750: 3a3a 7570 6c6f 6164 5f6c 696d 6974 5f74  ::upload_limit_t
    │ │ │ -0005a760: 6f6f 5f6c 6f77 293b 0a09 0909 7d0a 0909  oo_low);....}...
    │ │ │ -0005a770: 7d0a 0a23 6966 2054 4f52 5245 4e54 5f41  }..#if TORRENT_A
    │ │ │ -0005a780: 4249 5f56 4552 5349 4f4e 203d 3d20 310a  BI_VERSION == 1.
    │ │ │ -0005a790: 0909 6d5f 7065 616b 5f75 705f 7261 7465  ..m_peak_up_rate
    │ │ │ -0005a7a0: 203d 2073 7464 3a3a 6d61 7828 6d5f 7374   = std::max(m_st
    │ │ │ -0005a7b0: 6174 2e75 706c 6f61 645f 7261 7465 2829  at.upload_rate()
    │ │ │ -0005a7c0: 2c20 6d5f 7065 616b 5f75 705f 7261 7465  , m_peak_up_rate
    │ │ │ -0005a7d0: 293b 0a23 656e 6469 660a 0a09 096d 5f73  );.#endif....m_s
    │ │ │ -0005a7e0: 7461 742e 7365 636f 6e64 5f74 6963 6b28  tat.second_tick(
    │ │ │ -0005a7f0: 7469 636b 5f69 6e74 6572 7661 6c5f 6d73  tick_interval_ms
    │ │ │ -0005a800: 293b 0a0a 0909 2f2f 202d 2d2d 2d2d 2d2d  );....// -------
    │ │ │ -0005a810: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005a820: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005a830: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005a840: 2d2d 2d2d 2d2d 2d0a 0909 2f2f 2073 6372  -------...// scr
    │ │ │ -0005a850: 6170 6520 7061 7573 6564 2074 6f72 7265  ape paused torre
    │ │ │ -0005a860: 6e74 7320 7468 6174 2061 7265 2061 7574  nts that are aut
    │ │ │ -0005a870: 6f20 6d61 6e61 6765 640a 0909 2f2f 2028  o managed...// (
    │ │ │ -0005a880: 756e 6c65 7373 2074 6865 2073 6573 7369  unless the sessi
    │ │ │ -0005a890: 6f6e 2069 7320 7061 7573 6564 290a 3c2f  on is paused).r
    │ │ │ -0005a8d0: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -0005a8e0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/
    │ │ │ -0005a910: 7365 7373 696f 6e5f 696d 706c 2e63 7070  session_impl.cpp
    │ │ │ -0005a920: 3a34 3437 363c 2f61 3e3c 2f74 643e 3c74  :4476use a lower li
    │ │ │ -0005a940: 6d69 7420 7468 616e 206d 5f73 6574 7469  mit than m_setti
    │ │ │ -0005a950: 6e67 732e 636f 6e6e 6563 7469 6f6e 735f  ngs.connections_
    │ │ │ -0005a960: 6c69 6d69 7420 746f 2061 6c6c 6f63 6174  limit to allocat
    │ │ │ -0005a970: 6520 7468 6520 746f 2031 3025 206f 7220  e the to 10% or 
    │ │ │ -0005a980: 736f 206f 6620 636f 6e6e 6563 7469 6f6e  so of connection
    │ │ │ -0005a990: 2073 6c6f 7473 2066 6f72 2069 6e63 6f6d   slots for incom
    │ │ │ -0005a9a0: 696e 6720 636f 6e6e 6563 7469 6f6e 7320  ing connections 
    │ │ │ -0005a9b0: 6361 7020 7468 6973 2061 7420 6d61 7820  cap this at max 
    │ │ │ -0005a9c0: 2d20 312c 2073 696e 6365 2077 6520 6d61  - 1, since we ma
    │ │ │ -0005a9d0: 7920 6164 6420 6f6e 6520 6265 6c6f 773c  y add one below<
    │ │ │ -0005a9e0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d  /td>

    use │ │ │ -0005aa30: 2061 206c 6f77 6572 206c 696d 6974 2074 a lower limit t │ │ │ -0005aa40: 6861 6e20 6d5f 7365 7474 696e 6773 2e63 han m_settings.c │ │ │ -0005aa50: 6f6e 6e65 6374 696f 6e73 5f6c 696d 6974 onnections_limit │ │ │ -0005aa60: 0a74 6f20 616c 6c6f 6361 7465 2074 6865 .to allocate the │ │ │ -0005aa70: 2074 6f20 3130 2520 6f72 2073 6f20 6f66 to 10% or so of │ │ │ -0005aa80: 2063 6f6e 6e65 6374 696f 6e20 736c 6f74 connection slot │ │ │ -0005aa90: 7320 666f 7220 696e 636f 6d69 6e67 0a63 s for incoming.c │ │ │ -0005aaa0: 6f6e 6e65 6374 696f 6e73 0a63 6170 2074 onnections.cap t │ │ │ -0005aab0: 6869 7320 6174 206d 6178 202d 2031 2c20 his at max - 1, │ │ │ -0005aac0: 7369 6e63 6520 7765 206d 6179 2061 6464 since we may add │ │ │ -0005aad0: 206f 6e65 2062 656c 6f77 3c2f 6832 3e3c one below

    < │ │ │ -0005aae0: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ -0005aaf0: 6e5f 696d 706c 2e63 7070 3a34 3437 363c n_impl.cpp:4476< │ │ │ -0005ab00: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0005ab40: 2f2f 2062 6f6f 7374 2c20 7768 6963 6820  // boost, which 
    │ │ │ -0005ab50: 6172 6520 646f 6e65 2069 6d6d 6564 6961  are done immedia
    │ │ │ -0005ab60: 7465 6c79 206f 6e20 6120 7472 6163 6b65  tely on a tracke
    │ │ │ -0005ab70: 7220 7265 7370 6f6e 7365 2e20 5468 6573  r response. Thes
    │ │ │ -0005ab80: 650a 0909 2f2f 2063 6f6e 6e65 6374 696f  e...// connectio
    │ │ │ -0005ab90: 6e73 206e 6565 6473 2074 6f20 6265 2064  ns needs to be d
    │ │ │ -0005aba0: 6564 7563 7465 6420 6672 6f6d 2074 6865  educted from the
    │ │ │ -0005abb0: 2072 6567 756c 6172 2063 6f6e 6e65 6374   regular connect
    │ │ │ -0005abc0: 696f 6e20 6174 7465 6d70 740a 0909 2f2f  ion attempt...//
    │ │ │ -0005abd0: 2071 756f 7461 2066 6f72 2074 6869 7320   quota for this 
    │ │ │ -0005abe0: 7469 636b 0a09 0969 6620 286d 5f62 6f6f  tick...if (m_boo
    │ │ │ -0005abf0: 7374 5f63 6f6e 6e65 6374 696f 6e73 2026  st_connections &
    │ │ │ -0005ac00: 6774 3b20 3029 0a09 097b 0a09 0909 6966  gt; 0)...{....if
    │ │ │ -0005ac10: 2028 6d5f 626f 6f73 745f 636f 6e6e 6563   (m_boost_connec
    │ │ │ -0005ac20: 7469 6f6e 7320 2667 743b 206d 6178 5f63  tions > max_c
    │ │ │ -0005ac30: 6f6e 6e65 6374 696f 6e73 290a 0909 097b  onnections)....{
    │ │ │ -0005ac40: 0a09 0909 096d 5f62 6f6f 7374 5f63 6f6e  .....m_boost_con
    │ │ │ -0005ac50: 6e65 6374 696f 6e73 202d 3d20 6d61 785f  nections -= max_
    │ │ │ -0005ac60: 636f 6e6e 6563 7469 6f6e 733b 0a09 0909  connections;....
    │ │ │ -0005ac70: 096d 6178 5f63 6f6e 6e65 6374 696f 6e73  .max_connections
    │ │ │ -0005ac80: 203d 2030 3b0a 0909 097d 0a09 0909 656c   = 0;....}....el
    │ │ │ -0005ac90: 7365 0a09 0909 7b0a 0909 0909 6d61 785f  se....{.....max_
    │ │ │ -0005aca0: 636f 6e6e 6563 7469 6f6e 7320 2d3d 206d  connections -= m
    │ │ │ -0005acb0: 5f62 6f6f 7374 5f63 6f6e 6e65 6374 696f  _boost_connectio
    │ │ │ -0005acc0: 6e73 3b0a 0909 0909 6d5f 626f 6f73 745f  ns;.....m_boost_
    │ │ │ -0005acd0: 636f 6e6e 6563 7469 6f6e 7320 3d20 303b  connections = 0;
    │ │ │ -0005ace0: 0a09 0909 7d0a 0909 7d0a 0a09 092f 2f20  ....}...}....// 
    │ │ │ -0005acf0: 7a65 726f 2063 6f6e 6e65 6374 696f 6e73  zero connections
    │ │ │ -0005ad00: 2073 7065 6564 7320 6172 6520 616c 6c6f   speeds are allo
    │ │ │ -0005ad10: 7765 642c 2077 6520 6a75 7374 2077 6f6e  wed, we just won
    │ │ │ -0005ad20: 2774 206d 616b 6520 616e 7920 636f 6e6e  't make any conn
    │ │ │ -0005ad30: 6563 7469 6f6e 730a 0909 6966 2028 6d61  ections...if (ma
    │ │ │ -0005ad40: 785f 636f 6e6e 6563 7469 6f6e 7320 266c  x_connections &l
    │ │ │ -0005ad50: 743b 3d20 3029 2072 6574 7572 6e3b 0a0a  t;= 0) return;..
    │ │ │ -0005ad60: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -0005ad90: 696e 7420 636f 6e73 7420 6c69 6d69 7420 int const limit │ │ │ -0005ada0: 3d20 7374 643a 3a6d 696e 286d 5f73 6574 = std::min(m_set │ │ │ -0005adb0: 7469 6e67 732e 6765 745f 696e 7428 7365 tings.get_int(se │ │ │ -0005adc0: 7474 696e 6773 5f70 6163 6b3a 3a63 6f6e ttings_pack::con │ │ │ -0005add0: 6e65 6374 696f 6e73 5f6c 696d 6974 290a nections_limit). │ │ │ -0005ade0: 3c2f 6469 763e 0909 092d 206e 756d 5f63
    ...- num_c │ │ │ -0005adf0: 6f6e 6e65 6374 696f 6e73 2829 2c20 7374 onnections(), st │ │ │ -0005ae00: 643a 3a6e 756d 6572 6963 5f6c 696d 6974 d::numeric_limit │ │ │ -0005ae10: 7326 6c74 3b69 6e74 2667 743b 3a3a 6d61 s<int>::ma │ │ │ -0005ae20: 7828 2920 2d20 3129 3b0a 0a09 092f 2f20 x() - 1);....// │ │ │ -0005ae30: 7468 6973 206c 6f67 6963 2069 7320 6865 this logic is he │ │ │ -0005ae40: 7265 2074 6f20 736d 6f6f 7468 206f 7574 re to smooth out │ │ │ -0005ae50: 2074 6865 206e 756d 6265 7220 6f66 206e the number of n │ │ │ -0005ae60: 6577 2063 6f6e 6e65 6374 696f 6e0a 0909 ew connection... │ │ │ -0005ae70: 2f2f 2061 7474 656d 7074 7320 6f76 6572 // attempts over │ │ │ -0005ae80: 2074 696d 652c 2074 6f20 7072 6576 656e time, to preven │ │ │ -0005ae90: 7420 636f 6e6e 6563 7469 6e67 2061 206c t connecting a l │ │ │ -0005aea0: 6172 6765 206e 756d 6265 7220 6f66 0a09 arge number of.. │ │ │ -0005aeb0: 092f 2f20 736f 636b 6574 732c 2077 6169 .// sockets, wai │ │ │ -0005aec0: 7420 3130 2073 6563 6f6e 6473 2c20 616e t 10 seconds, an │ │ │ -0005aed0: 6420 7468 656e 2074 7279 2061 6761 696e d then try again │ │ │ -0005aee0: 0a09 0969 6620 286d 5f73 6574 7469 6e67 ...if (m_setting │ │ │ -0005aef0: 732e 6765 745f 626f 6f6c 2873 6574 7469 s.get_bool(setti │ │ │ -0005af00: 6e67 735f 7061 636b 3a3a 736d 6f6f 7468 ngs_pack::smooth │ │ │ -0005af10: 5f63 6f6e 6e65 6374 7329 2026 616d 703b _connects) & │ │ │ -0005af20: 2661 6d70 3b20 6d61 785f 636f 6e6e 6563 & max_connec │ │ │ -0005af30: 7469 6f6e 7320 2667 743b 2028 6c69 6d69 tions > (limi │ │ │ -0005af40: 742b 3129 202f 2032 290a 0909 096d 6178 t+1) / 2)....max │ │ │ -0005af50: 5f63 6f6e 6e65 6374 696f 6e73 203d 2028 _connections = ( │ │ │ -0005af60: 6c69 6d69 7420 2b20 3129 202f 2032 3b0a limit + 1) / 2;. │ │ │ -0005af70: 0a09 0961 7578 3a3a 7665 6374 6f72 266c ...aux::vector&l │ │ │ -0005af80: 743b 746f 7272 656e 742a 2667 743b 2661 t;torrent*>&a │ │ │ -0005af90: 6d70 3b20 7761 6e74 5f70 6565 7273 5f64 mp; want_peers_d │ │ │ -0005afa0: 6f77 6e6c 6f61 6420 3d20 6d5f 746f 7272 ownload = m_torr │ │ │ -0005afb0: 656e 745f 6c69 7374 735b 746f 7272 656e ent_lists[torren │ │ │ -0005afc0: 745f 7761 6e74 5f70 6565 7273 5f64 6f77 t_want_peers_dow │ │ │ -0005afd0: 6e6c 6f61 645d 3b0a 0909 6175 783a 3a76 nload];...aux::v │ │ │ -0005afe0: 6563 746f 7226 6c74 3b74 6f72 7265 6e74 ector<torrent │ │ │ -0005aff0: 2a26 6774 3b26 616d 703b 2077 616e 745f *>& want_ │ │ │ -0005b000: 7065 6572 735f 6669 6e69 7368 6564 203d peers_finished = │ │ │ -0005b010: 206d 5f74 6f72 7265 6e74 5f6c 6973 7473 m_torrent_lists │ │ │ -0005b020: 5b74 6f72 7265 6e74 5f77 616e 745f 7065 [torrent_want_pe │ │ │ -0005b030: 6572 735f 6669 6e69 7368 6564 5d3b 0a0a ers_finished];.. │ │ │ -0005b040: 0909 2f2f 2069 6620 6e6f 2074 6f72 7265 ..// if no torre │ │ │ -0005b050: 6e74 2077 616e 7420 616e 7920 7065 6572 nt want any peer │ │ │ -0005b060: 732c 206a 7573 7420 7265 7475 726e 0a09 s, just return.. │ │ │ -0005b070: 0969 6620 2877 616e 745f 7065 6572 735f .if (want_peers_ │ │ │ -0005b080: 646f 776e 6c6f 6164 2e65 6d70 7479 2829 download.empty() │ │ │ -0005b090: 2026 616d 703b 2661 6d70 3b20 7761 6e74 && want │ │ │ -0005b0a0: 5f70 6565 7273 5f66 696e 6973 6865 642e _peers_finished. │ │ │ -0005b0b0: 656d 7074 7928 2929 2072 6574 7572 6e3b empty()) return; │ │ │ -0005b0c0: 0a0a 0909 2f2f 2069 6620 7765 2064 6f6e ....// if we don │ │ │ -0005b0d0: 2774 2068 6176 6520 616e 7920 636f 6e6e 't have any conn │ │ │ -0005b0e0: 6563 7469 6f6e 2061 7474 656d 7074 2071 ection attempt q │ │ │ -0005b0f0: 756f 7461 2c20 7265 7475 726e 0a09 0969 uota, return...i │ │ │ -0005b100: 6620 286d 6178 5f63 6f6e 6e65 6374 696f f (max_connectio │ │ │ -0005b110: 6e73 2026 6c74 3b3d 2030 2920 7265 7475 ns <= 0) retu │ │ │ -0005b120: 726e 3b0a 0a09 0969 6e74 2073 7465 7073 rn;....int steps │ │ │ -0005b130: 5f73 696e 6365 5f6c 6173 745f 636f 6e6e _since_last_conn │ │ │ -0005b140: 6563 7420 3d20 303b 0a09 0969 6e74 2063 ect = 0;...int c │ │ │ -0005b150: 6f6e 7374 206e 756d 5f74 6f72 7265 6e74 onst num_torrent │ │ │ -0005b160: 7320 3d20 696e 7428 7761 6e74 5f70 6565 s = int(want_pee │ │ │ -0005b170: 7273 5f66 696e 6973 6865 642e 7369 7a65 rs_finished.size │ │ │ -0005b180: 2829 202b 2077 616e 745f 7065 6572 735f () + want_peers_ │ │ │ -0005b190: 646f 776e 6c6f 6164 2e73 697a 6528 2929 download.size()) │ │ │ -0005b1a0: 3b0a 0909 666f 7220 283b 3b29 0a09 097b ;...for (;;)...{ │ │ │ -0005b1b0: 0a09 0909 6966 2028 6d5f 6e65 7874 5f64 ....if (m_next_d │ │ │ -0005b1c0: 6f77 6e6c 6f61 6469 6e67 5f63 6f6e 6e65 ownloading_conne │ │ │ -0005b1d0: 6374 5f74 6f72 7265 6e74 2026 6774 3b3d ct_torrent >= │ │ │ -0005b1e0: 2069 6e74 2877 616e 745f 7065 6572 735f int(want_peers_ │ │ │ -0005b1f0: 646f 776e 6c6f 6164 2e73 697a 6528 2929 download.size()) │ │ │ -0005b200: 290a 0909 0909 6d5f 6e65 7874 5f64 6f77 ).....m_next_dow │ │ │ -0005b210: 6e6c 6f61 6469 6e67 5f63 6f6e 6e65 6374 nloading_connect │ │ │ -0005b220: 5f74 6f72 7265 6e74 203d 2030 3b0a 0a09 _torrent = 0;... │ │ │ -0005b230: 0909 6966 2028 6d5f 6e65 7874 5f66 696e ..if (m_next_fin │ │ │ -0005b240: 6973 6865 645f 636f 6e6e 6563 745f 746f ished_connect_to │ │ │ -0005b250: 7272 656e 7420 2667 743b 3d20 696e 7428 rrent >= int( │ │ │ -0005b260: 7761 6e74 5f70 6565 7273 5f66 696e 6973 want_peers_finis │ │ │ -0005b270: 6865 642e 7369 7a65 2829 2929 0a09 0909 hed.size())).... │ │ │ -0005b280: 096d 5f6e 6578 745f 6669 6e69 7368 6564 .m_next_finished │ │ │ -0005b290: 5f63 6f6e 6e65 6374 5f74 6f72 7265 6e74 _connect_torrent │ │ │ -0005b2a0: 203d 2030 3b0a 0a09 0909 746f 7272 656e = 0;.....torren │ │ │ -0005b2b0: 742a 2074 203d 206e 756c 6c70 7472 3b0a t* t = nullptr;. │ │ │ -0005b2c0: 0909 092f 2f20 7468 6572 6520 6172 6520 ...// there are │ │ │ -0005b2d0: 7072 696f 7269 7469 7a65 6420 746f 7272 prioritized torr │ │ │ -0005b2e0: 656e 7473 2e20 5069 636b 206f 6e65 206f ents. Pick one o │ │ │ -0005b2f0: 6620 7468 6f73 650a 0909 0977 6869 6c65 f those....while │ │ │ -0005b300: 2028 216d 5f70 7269 6f5f 746f 7272 656e (!m_prio_torren │ │ │ -0005b310: 7473 2e65 6d70 7479 2829 290a 3c2f 7072 ts.empty()).rel │ │ │ -0005b350: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/se │ │ │ -0005b390: 7373 696f 6e5f 696d 706c 2e63 7070 3a34 ssion_impl.cpp:4 │ │ │ -0005b3a0: 3632 313c 2f61 3e3c 2f74 643e 3c74 643e 621 │ │ │ -0005b3b0: 706f 7374 2061 206d 6573 7361 6765 2074 post a message t │ │ │ -0005b3c0: 6f20 6861 7665 2074 6869 7320 6861 7070 o have this happ │ │ │ -0005b3d0: 656e 2069 6d6d 6564 6961 7465 6c79 2069 en immediately i │ │ │ -0005b3e0: 6e73 7465 6164 206f 6620 7761 6974 696e nstead of waitin │ │ │ -0005b3f0: 6720 666f 7220 7468 6520 6e65 7874 2074 g for the next t │ │ │ -0005b400: 6963 6b3c 2f74 643e 3c2f 7472 3e3c 7472 ick

    post a message │ │ │ -0005b460: 746f 2068 6176 6520 7468 6973 2068 6170 to have this hap │ │ │ -0005b470: 7065 6e0a 696d 6d65 6469 6174 656c 7920 pen.immediately │ │ │ -0005b480: 696e 7374 6561 6420 6f66 2077 6169 7469 instead of waiti │ │ │ -0005b490: 6e67 2066 6f72 2074 6865 206e 6578 7420 ng for the next │ │ │ -0005b4a0: 7469 636b 3c2f 6832 3e3c 6834 3e2e 2e2f tick

    ../ │ │ │ -0005b4b0: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0005b4c0: 2e63 7070 3a34 3632 313c 2f68 343e 3c70 .cpp:4621

    ....cont │ │ │ -0005b510: 696e 7565 3b0a 0909 097d 0a0a 0909 0969 inue;....}.....i │ │ │ -0005b520: 6620 2821 702d 2667 743b 6973 5f70 6565 f (!p->is_pee │ │ │ -0005b530: 725f 696e 7465 7265 7374 6564 2829 0a09 r_interested().. │ │ │ -0005b540: 0909 097c 7c20 702d 2667 743b 6973 5f64 ...|| p->is_d │ │ │ -0005b550: 6973 636f 6e6e 6563 7469 6e67 2829 0a09 isconnecting().. │ │ │ -0005b560: 0909 097c 7c20 702d 2667 743b 6973 5f63 ...|| p->is_c │ │ │ -0005b570: 6f6e 6e65 6374 696e 6728 2929 0a09 0909 onnecting()).... │ │ │ -0005b580: 7b0a 0909 0909 2f2f 2074 6869 7320 7065 {.....// this pe │ │ │ -0005b590: 6572 2069 7320 6e6f 7420 756e 6368 6f6b er is not unchok │ │ │ -0005b5a0: 6162 6c65 2e20 536f 2c20 6966 2069 7427 able. So, if it' │ │ │ -0005b5b0: 7320 756e 6368 6f6b 6564 0a09 0909 092f s unchoked...../ │ │ │ -0005b5c0: 2f20 616c 7265 6164 792c 206d 616b 6520 / already, make │ │ │ -0005b5d0: 7375 7265 2074 6f20 6368 6f6b 6520 6974 sure to choke it │ │ │ -0005b5e0: 2e0a 0909 0909 6966 2028 702d 2667 743b ......if (p-> │ │ │ -0005b5f0: 6973 5f63 686f 6b65 6428 2929 0a09 0909 is_choked()).... │ │ │ -0005b600: 097b 0a09 0909 0909 702d 2667 743b 7265 .{......p->re │ │ │ -0005b610: 7365 745f 6368 6f6b 655f 636f 756e 7465 set_choke_counte │ │ │ -0005b620: 7273 2829 3b0a 0909 0909 0963 6f6e 7469 rs();......conti │ │ │ -0005b630: 6e75 653b 0a09 0909 097d 0a09 0909 0969 nue;.....}.....i │ │ │ -0005b640: 6620 2870 6920 2661 6d70 3b26 616d 703b f (pi && │ │ │ -0005b650: 2070 692d 2667 743b 6f70 7469 6d69 7374 pi->optimist │ │ │ -0005b660: 6963 616c 6c79 5f75 6e63 686f 6b65 6429 ically_unchoked) │ │ │ -0005b670: 0a09 0909 097b 0a09 0909 0909 6d5f 7374 .....{......m_st │ │ │ -0005b680: 6174 735f 636f 756e 7465 7273 2e69 6e63 ats_counters.inc │ │ │ -0005b690: 5f73 7461 7473 5f63 6f75 6e74 6572 2863 _stats_counter(c │ │ │ -0005b6a0: 6f75 6e74 6572 733a 3a6e 756d 5f70 6565 ounters::num_pee │ │ │ -0005b6b0: 7273 5f75 705f 756e 6368 6f6b 6564 5f6f rs_up_unchoked_o │ │ │ -0005b6c0: 7074 696d 6973 7469 632c 202d 3129 3b0a ptimistic, -1);. │ │ │ -0005b6d0: 0909 0909 0970 692d 2667 743b 6f70 7469 .....pi->opti │ │ │ -0005b6e0: 6d69 7374 6963 616c 6c79 5f75 6e63 686f mistically_uncho │ │ │ -0005b6f0: 6b65 6420 3d20 6661 6c73 653b 0a09 0909 ked = false;.... │ │ │ -0005b700: 0909 2f2f 2066 6f72 6365 2061 206e 6577 ..// force a new │ │ │ -0005b710: 206f 7074 696d 6973 7469 6320 756e 6368 optimistic unch │ │ │ -0005b720: 6f6b 650a 0909 0909 096d 5f6f 7074 696d oke......m_optim │ │ │ -0005b730: 6973 7469 635f 756e 6368 6f6b 655f 7469 istic_unchoke_ti │ │ │ -0005b740: 6d65 5f73 6361 6c65 7220 3d20 303b 0a3c me_scaler = 0;.< │ │ │ -0005b750: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -0005b760: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -0005b770: 7769 6474 683d 2231 3030 2522 3e09 0909 width="100%">... │ │ │ -0005b780: 097d 0a3c 2f64 6976 3e09 0909 0974 2d26 .}.

    ....t-& │ │ │ -0005b790: 6774 3b63 686f 6b65 5f70 6565 7228 2a70 gt;choke_peer(*p │ │ │ -0005b7a0: 293b 0a09 0909 0970 2d26 6774 3b72 6573 );.....p->res │ │ │ -0005b7b0: 6574 5f63 686f 6b65 5f63 6f75 6e74 6572 et_choke_counter │ │ │ -0005b7c0: 7328 293b 0a09 0909 0963 6f6e 7469 6e75 s();.....continu │ │ │ -0005b7d0: 653b 0a09 0909 7d0a 0a09 0909 7065 6572 e;....}.....peer │ │ │ -0005b7e0: 732e 7075 7368 5f62 6163 6b28 702e 6765 s.push_back(p.ge │ │ │ -0005b7f0: 7428 2929 3b0a 0909 7d0a 0a09 0969 6e74 t());...}....int │ │ │ -0005b800: 2063 6f6e 7374 2061 6c6c 6f77 6564 5f75 const allowed_u │ │ │ -0005b810: 706c 6f61 645f 736c 6f74 7320 3d20 756e pload_slots = un │ │ │ -0005b820: 6368 6f6b 655f 736f 7274 2870 6565 7273 choke_sort(peers │ │ │ -0005b830: 0a09 0909 2c20 756e 6368 6f6b 655f 696e ...., unchoke_in │ │ │ -0005b840: 7465 7276 616c 2c20 6d5f 7365 7474 696e terval, m_settin │ │ │ -0005b850: 6773 293b 0a0a 0909 6966 2028 6d5f 7365 gs);....if (m_se │ │ │ -0005b860: 7474 696e 6773 2e67 6574 5f69 6e74 2873 ttings.get_int(s │ │ │ -0005b870: 6574 7469 6e67 735f 7061 636b 3a3a 6368 ettings_pack::ch │ │ │ -0005b880: 6f6b 696e 675f 616c 676f 7269 7468 6d29 oking_algorithm) │ │ │ -0005b890: 203d 3d20 7365 7474 696e 6773 5f70 6163 == settings_pac │ │ │ -0005b8a0: 6b3a 3a66 6978 6564 5f73 6c6f 7473 5f63 k::fixed_slots_c │ │ │ -0005b8b0: 686f 6b65 7229 0a09 097b 0a09 0909 696e hoker)...{....in │ │ │ -0005b8c0: 7420 636f 6e73 7420 7570 6c6f 6164 5f73 t const upload_s │ │ │ -0005b8d0: 6c6f 7473 203d 2067 6574 5f69 6e74 5f73 lots = get_int_s │ │ │ -0005b8e0: 6574 7469 6e67 2873 6574 7469 6e67 735f etting(settings_ │ │ │ -0005b8f0: 7061 636b 3a3a 756e 6368 6f6b 655f 736c pack::unchoke_sl │ │ │ -0005b900: 6f74 735f 6c69 6d69 7429 3b0a 0909 096d ots_limit);....m │ │ │ -0005b910: 5f73 7461 7473 5f63 6f75 6e74 6572 732e _stats_counters. │ │ │ -0005b920: 7365 745f 7661 6c75 6528 636f 756e 7465 set_value(counte │ │ │ -0005b930: 7273 3a3a 6e75 6d5f 756e 6368 6f6b 655f rs::num_unchoke_ │ │ │ -0005b940: 736c 6f74 732c 2075 706c 6f61 645f 736c slots, upload_sl │ │ │ -0005b950: 6f74 7329 3b0a 0909 7d0a 0909 656c 7365 ots);...}...else │ │ │ -0005b960: 0a09 097b 0a09 0909 6d5f 7374 6174 735f ...{....m_stats_ │ │ │ -0005b970: 636f 756e 7465 7273 2e73 6574 5f76 616c counters.set_val │ │ │ -0005b980: 7565 2863 6f75 6e74 6572 733a 3a6e 756d ue(counters::num │ │ │ -0005b990: 5f75 6e63 686f 6b65 5f73 6c6f 7473 0a09 _unchoke_slots.. │ │ │ -0005b9a0: 0909 092c 2061 6c6c 6f77 6564 5f75 706c ..., allowed_upl │ │ │ -0005b9b0: 6f61 645f 736c 6f74 7329 3b0a 0909 7d0a oad_slots);...}. │ │ │ -0005b9c0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -0005b9d0: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ -0005b9e0: 0a09 0969 6620 2873 686f 756c 645f 6c6f ...if (should_lo │ │ │ -0005b9f0: 6728 2929 0a09 097b 0a09 0909 7365 7373 g())...{....sess │ │ │ -0005ba00: 696f 6e5f 6c6f 6728 2252 4543 414c 4355 ion_log("RECALCU │ │ │ -0005ba10: 4c41 5445 2055 4e43 484f 4b45 2053 4c4f LATE UNCHOKE SLO │ │ │ -0005ba20: 5453 3a20 5b20 7065 6572 733a 2025 6420 TS: [ peers: %d │ │ │ -0005ba30: 220a 0909 0909 2265 6c69 6769 626c 652d "....."eligible- │ │ │ -0005ba40: 7065 6572 733a 2025 6422 0a09 0909 0922 peers: %d"....." │ │ │ -0005ba50: 2061 6c6c 6f77 6564 2d73 6c6f 7473 3a20 allowed-slots: │ │ │ -0005ba60: 2564 205d 220a 0909 0909 2c20 696e 7428 %d ]"....., int( │ │ │ -0005ba70: 6d5f 636f 6e6e 6563 7469 6f6e 732e 7369 m_connections.si │ │ │ -0005ba80: 7a65 2829 290a 0909 0909 2c20 696e 7428 ze())....., int( │ │ │ -0005ba90: 7065 6572 732e 7369 7a65 2829 290a 3c2f peers.size()).r │ │ │ -0005bad0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0005bae0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0005bb10: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -0005bb20: 3a34 3934 383c 2f61 3e3c 2f74 643e 3c74 :4948it might be a │ │ │ -0005bb40: 6e69 6365 2066 6561 7475 7265 2068 6572 nice feature her │ │ │ -0005bb50: 6520 746f 206c 696d 6974 2074 6865 206e e to limit the n │ │ │ -0005bb60: 756d 6265 7220 6f66 2074 6f72 7265 6e74 umber of torrent │ │ │ -0005bb70: 7320 746f 2073 656e 6420 696e 2061 2073 s to send in a s │ │ │ -0005bb80: 696e 676c 6520 7570 6461 7465 2e20 4279 ingle update. By │ │ │ -0005bb90: 206a 7573 7420 706f 7374 696e 6720 7468 just posting th │ │ │ -0005bba0: 6520 6669 7273 7420 6e20 746f 7272 656e e first n torren │ │ │ -0005bbb0: 7473 2c20 7468 6579 2077 6f75 6c64 206e ts, they would n │ │ │ -0005bbc0: 6963 656c 7920 6265 2072 6f75 6e64 2d72 icely be round-r │ │ │ -0005bbd0: 6f62 696e 6564 2062 6563 6175 7365 2074 obined because t │ │ │ -0005bbe0: 6865 2074 6f72 7265 6e74 206c 6973 7473 he torrent lists │ │ │ -0005bbf0: 2061 7265 2061 6c77 6179 7320 7075 7368 are always push │ │ │ -0005bc00: 6564 2062 6163 6b2e 2050 6572 6861 7073 ed back. Perhaps │ │ │ -0005bc10: 2074 6865 2073 7461 7475 735f 7570 6461 the status_upda │ │ │ -0005bc20: 7465 5f61 6c65 7274 2063 6f75 6c64 2065 te_alert could e │ │ │ -0005bc30: 7665 6e20 6861 7665 2061 2066 6978 6564 ven have a fixed │ │ │ -0005bc40: 2061 7272 6179 206f 6620 6e20 656e 7472 array of n entr │ │ │ -0005bc50: 6965 7320 7261 7468 6572 2074 6861 6e20 ies rather than │ │ │ -0005bc60: 6120 7665 6374 6f72 2c20 746f 2066 7572 a vector, to fur │ │ │ -0005bc70: 7468 6572 2069 6d70 726f 7665 206d 656d ther improve mem │ │ │ -0005bc80: 6f72 7920 6c6f 6361 6c69 7479 2e3c 2f74 ory locality.

    it mi │ │ │ -0005bce0: 6768 7420 6265 2061 206e 6963 6520 6665 ght be a nice fe │ │ │ -0005bcf0: 6174 7572 6520 6865 7265 2074 6f20 6c69 ature here to li │ │ │ -0005bd00: 6d69 7420 7468 6520 6e75 6d62 6572 206f mit the number o │ │ │ -0005bd10: 6620 746f 7272 656e 7473 0a74 6f20 7365 f torrents.to se │ │ │ -0005bd20: 6e64 2069 6e20 6120 7369 6e67 6c65 2075 nd in a single u │ │ │ -0005bd30: 7064 6174 652e 2042 7920 6a75 7374 2070 pdate. By just p │ │ │ -0005bd40: 6f73 7469 6e67 2074 6865 2066 6972 7374 osting the first │ │ │ -0005bd50: 206e 2074 6f72 7265 6e74 732c 2074 6865 n torrents, the │ │ │ -0005bd60: 790a 776f 756c 6420 6e69 6365 6c79 2062 y.would nicely b │ │ │ -0005bd70: 6520 726f 756e 642d 726f 6269 6e65 6420 e round-robined │ │ │ -0005bd80: 6265 6361 7573 6520 7468 6520 746f 7272 because the torr │ │ │ -0005bd90: 656e 7420 6c69 7374 7320 6172 6520 616c ent lists are al │ │ │ -0005bda0: 7761 7973 0a70 7573 6865 6420 6261 636b ways.pushed back │ │ │ -0005bdb0: 2e20 5065 7268 6170 7320 7468 6520 7374 . Perhaps the st │ │ │ -0005bdc0: 6174 7573 5f75 7064 6174 655f 616c 6572 atus_update_aler │ │ │ -0005bdd0: 7420 636f 756c 6420 6576 656e 2068 6176 t could even hav │ │ │ -0005bde0: 6520 6120 6669 7865 640a 6172 7261 7920 e a fixed.array │ │ │ -0005bdf0: 6f66 206e 2065 6e74 7269 6573 2072 6174 of n entries rat │ │ │ -0005be00: 6865 7220 7468 616e 2061 2076 6563 746f her than a vecto │ │ │ -0005be10: 722c 2074 6f20 6675 7274 6865 7220 696d r, to further im │ │ │ -0005be20: 7072 6f76 6520 6d65 6d6f 7279 0a6c 6f63 prove memory.loc │ │ │ -0005be30: 616c 6974 792e 3c2f 6832 3e3c 6834 3e2e ality.

    . │ │ │ -0005be40: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -0005be50: 706c 2e63 7070 3a34 3934 383c 2f68 343e pl.cpp:4948

    │ │ │ -0005be60: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...t-&
    │ │ │ -0005bea0: 6774 3b73 7461 7475 7328 2661 6d70 3b73  gt;status(&s
    │ │ │ -0005beb0: 742c 2066 6c61 6773 293b 0a09 097d 0a09  t, flags);...}..
    │ │ │ -0005bec0: 7d0a 0a09 766f 6964 2073 6573 7369 6f6e  }...void session
    │ │ │ -0005bed0: 5f69 6d70 6c3a 3a70 6f73 745f 746f 7272  _impl::post_torr
    │ │ │ -0005bee0: 656e 745f 7570 6461 7465 7328 7374 6174  ent_updates(stat
    │ │ │ -0005bef0: 7573 5f66 6c61 6773 5f74 2063 6f6e 7374  us_flags_t const
    │ │ │ -0005bf00: 2066 6c61 6773 290a 097b 0a09 0949 4e56   flags)..{...INV
    │ │ │ -0005bf10: 4152 4941 4e54 5f43 4845 434b 3b0a 0a09  ARIANT_CHECK;...
    │ │ │ -0005bf20: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -0005bf30: 6973 5f73 696e 676c 655f 7468 7265 6164  is_single_thread
    │ │ │ -0005bf40: 2829 293b 0a0a 0909 7374 643a 3a76 6563  ());....std::vec
    │ │ │ -0005bf50: 746f 7226 6c74 3b74 6f72 7265 6e74 2a26  tor<torrent*&
    │ │ │ -0005bf60: 6774 3b26 616d 703b 2073 7461 7465 5f75  gt;& state_u
    │ │ │ -0005bf70: 7064 6174 6573 0a09 0909 3d20 6d5f 746f  pdates....= m_to
    │ │ │ -0005bf80: 7272 656e 745f 6c69 7374 735b 6175 783a  rrent_lists[aux:
    │ │ │ -0005bf90: 3a73 6573 7369 6f6e 5f69 6d70 6c3a 3a74  :session_impl::t
    │ │ │ -0005bfa0: 6f72 7265 6e74 5f73 7461 7465 5f75 7064  orrent_state_upd
    │ │ │ -0005bfb0: 6174 6573 5d3b 0a0a 2369 6620 544f 5252  ates];..#if TORR
    │ │ │ -0005bfc0: 454e 545f 5553 455f 4153 5345 5254 530a  ENT_USE_ASSERTS.
    │ │ │ -0005bfd0: 0909 6d5f 706f 7374 696e 675f 746f 7272  ..m_posting_torr
    │ │ │ -0005bfe0: 656e 745f 7570 6461 7465 7320 3d20 7472  ent_updates = tr
    │ │ │ -0005bff0: 7565 3b0a 2365 6e64 6966 0a0a 0909 7374  ue;.#endif....st
    │ │ │ -0005c000: 643a 3a76 6563 746f 7226 6c74 3b74 6f72  d::vector<tor
    │ │ │ -0005c010: 7265 6e74 5f73 7461 7475 7326 6774 3b20  rent_status> 
    │ │ │ -0005c020: 7374 6174 7573 3b0a 0909 7374 6174 7573  status;...status
    │ │ │ -0005c030: 2e72 6573 6572 7665 2873 7461 7465 5f75  .reserve(state_u
    │ │ │ -0005c040: 7064 6174 6573 2e73 697a 6528 2929 3b0a  pdates.size());.
    │ │ │ -0005c050: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0005c080: 0966 6f72 2028 6175 746f 2661 6d70 3b20 .for (auto& │ │ │ -0005c090: 7420 3a20 7374 6174 655f 7570 6461 7465 t : state_update │ │ │ -0005c0a0: 7329 0a3c 2f64 6976 3e09 097b 0a09 0909 s).
    ..{.... │ │ │ -0005c0b0: 544f 5252 454e 545f 4153 5345 5254 2874 TORRENT_ASSERT(t │ │ │ -0005c0c0: 2d26 6774 3b6d 5f6c 696e 6b73 5b61 7578 ->m_links[aux │ │ │ -0005c0d0: 3a3a 7365 7373 696f 6e5f 696d 706c 3a3a ::session_impl:: │ │ │ -0005c0e0: 746f 7272 656e 745f 7374 6174 655f 7570 torrent_state_up │ │ │ -0005c0f0: 6461 7465 735d 2e69 6e5f 6c69 7374 2829 dates].in_list() │ │ │ -0005c100: 293b 0a09 0909 7374 6174 7573 2e65 6d70 );....status.emp │ │ │ -0005c110: 6c61 6365 5f62 6163 6b28 293b 0a09 0909 lace_back();.... │ │ │ -0005c120: 2f2f 2071 7565 7279 696e 6720 6163 6375 // querying accu │ │ │ -0005c130: 7261 7465 2064 6f77 6e6c 6f61 6420 636f rate download co │ │ │ -0005c140: 756e 7465 7273 206d 6179 2072 6571 7569 unters may requi │ │ │ -0005c150: 7265 0a09 0909 2f2f 2074 6865 2074 6f72 re....// the tor │ │ │ -0005c160: 7265 6e74 2074 6f20 6265 206c 6f61 6465 rent to be loade │ │ │ -0005c170: 642e 204c 6f61 6469 6e67 2061 2074 6f72 d. Loading a tor │ │ │ -0005c180: 7265 6e74 2c20 616e 6420 6576 6963 7469 rent, and evicti │ │ │ -0005c190: 6e67 2061 6e6f 7468 6572 0a09 0909 2f2f ng another....// │ │ │ -0005c1a0: 206f 6e65 2077 696c 6c20 6c65 6164 2074 one will lead t │ │ │ -0005c1b0: 6f20 6361 6c6c 696e 6720 7374 6174 655f o calling state_ │ │ │ -0005c1c0: 7570 6461 7465 6428 292c 2077 6869 6368 updated(), which │ │ │ -0005c1d0: 2073 6372 6577 7320 7769 7468 0a09 0909 screws with.... │ │ │ -0005c1e0: 2f2f 2074 6869 7320 6c69 7374 2077 6869 // this list whi │ │ │ -0005c1f0: 6c65 2077 6527 7265 2077 6f72 6b69 6e67 le we're working │ │ │ -0005c200: 206f 6e20 6974 2c20 616e 6420 6272 6561 on it, and brea │ │ │ -0005c210: 6b20 7468 696e 6773 0a09 0909 742d 2667 k things....t-&g │ │ │ -0005c220: 743b 7374 6174 7573 2826 616d 703b 7374 t;status(&st │ │ │ -0005c230: 6174 7573 2e62 6163 6b28 292c 2066 6c61 atus.back(), fla │ │ │ -0005c240: 6773 293b 0a09 0909 742d 2667 743b 636c gs);....t->cl │ │ │ -0005c250: 6561 725f 696e 5f73 7461 7465 5f75 7064 ear_in_state_upd │ │ │ -0005c260: 6174 6528 293b 0a09 097d 0a09 0973 7461 ate();...}...sta │ │ │ -0005c270: 7465 5f75 7064 6174 6573 2e63 6c65 6172 te_updates.clear │ │ │ -0005c280: 2829 3b0a 0a23 6966 2054 4f52 5245 4e54 ();..#if TORRENT │ │ │ -0005c290: 5f55 5345 5f41 5353 4552 5453 0a09 096d _USE_ASSERTS...m │ │ │ -0005c2a0: 5f70 6f73 7469 6e67 5f74 6f72 7265 6e74 _posting_torrent │ │ │ -0005c2b0: 5f75 7064 6174 6573 203d 2066 616c 7365 _updates = false │ │ │ -0005c2c0: 3b0a 2365 6e64 6966 0a0a 0909 6d5f 616c ;.#endif....m_al │ │ │ -0005c2d0: 6572 7473 2e65 6d70 6c61 6365 5f61 6c65 erts.emplace_ale │ │ │ -0005c2e0: 7274 266c 743b 7374 6174 655f 7570 6461 rt<state_upda │ │ │ -0005c2f0: 7465 5f61 6c65 7274 2667 743b 2873 7464 te_alert>(std │ │ │ -0005c300: 3a3a 6d6f 7665 2873 7461 7475 7329 293b ::move(status)); │ │ │ -0005c310: 0a09 7d0a 0a09 766f 6964 2073 6573 7369 ..}...void sessi │ │ │ -0005c320: 6f6e 5f69 6d70 6c3a 3a70 6f73 745f 7365 on_impl::post_se │ │ │ -0005c330: 7373 696f 6e5f 7374 6174 7328 290a 097b ssion_stats()..{ │ │ │ -0005c340: 0a09 0969 6620 2821 6d5f 706f 7374 6564 ...if (!m_posted │ │ │ -0005c350: 5f73 7461 7473 5f68 6561 6465 7229 0a09 _stats_header).. │ │ │ -0005c360: 097b 0a09 0909 6d5f 706f 7374 6564 5f73 .{....m_posted_s │ │ │ -0005c370: 7461 7473 5f68 6561 6465 7220 3d20 7472 tats_header = tr │ │ │ -0005c380: 7565 3b0a 0909 096d 5f61 6c65 7274 732e ue;....m_alerts. │ │ │ -0005c390: 656d 706c 6163 655f 616c 6572 7426 6c74 emplace_alert< │ │ │ -0005c3a0: 3b73 6573 7369 6f6e 5f73 7461 7473 5f68 ;session_stats_h │ │ │ -0005c3b0: 6561 6465 725f 616c 6572 7426 6774 3b28 eader_alert>( │ │ │ -0005c3c0: 293b 0a09 097d 0a09 096d 5f64 6973 6b5f );...}...m_disk_ │ │ │ -0005c3d0: 7468 7265 6164 2d26 6774 3b75 7064 6174 thread->updat │ │ │ -0005c3e0: 655f 7374 6174 735f 636f 756e 7465 7273 e_stats_counters │ │ │ -0005c3f0: 286d 5f73 7461 7473 5f63 6f75 6e74 6572 (m_stats_counter │ │ │ -0005c400: 7329 3b0a 0a23 6966 6e64 6566 2054 4f52 s);..#ifndef TOR │ │ │ -0005c410: 5245 4e54 5f44 4953 4142 4c45 5f44 4854 RENT_DISABLE_DHT │ │ │ -0005c420: 0a09 0969 6620 286d 5f64 6874 290a 3c2f ...if (m_dht).r │ │ │ -0005c460: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0005c470: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0005c4a0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -0005c4b0: 3a35 3334 323c 2f61 3e3c 2f74 643e 3c74 :5342factor out thi │ │ │ -0005c4d0: 7320 6c6f 6769 6320 696e 746f 2061 2073 s logic into a s │ │ │ -0005c4e0: 6570 6172 6174 6520 6675 6e63 7469 6f6e eparate function │ │ │ -0005c4f0: 2066 6f72 2075 6e69 7420 7465 7374 696e for unit testin │ │ │ -0005c500: 673c 2f74 643e 3c2f 7472 3e3c 7472 2069 g

    f │ │ │ -0005c550: 6163 746f 7220 6f75 7420 7468 6973 206c actor out this l │ │ │ -0005c560: 6f67 6963 2069 6e74 6f20 6120 7365 7061 ogic into a sepa │ │ │ -0005c570: 7261 7465 2066 756e 6374 696f 6e20 666f rate function fo │ │ │ -0005c580: 7220 756e 6974 0a74 6573 7469 6e67 3c2f r unit.testing

    ../src/se │ │ │ -0005c5a0: 7373 696f 6e5f 696d 706c 2e63 7070 3a35 ssion_impl.cpp:5 │ │ │ -0005c5b0: 3334 323c 2f68 343e 3c70 7265 2073 7479 342

    ..if (m_settin
    │ │ │ -0005c600: 6773 2e67 6574 5f69 6e74 2873 6574 7469  gs.get_int(setti
    │ │ │ -0005c610: 6e67 735f 7061 636b 3a3a 6f75 7467 6f69  ngs_pack::outgoi
    │ │ │ -0005c620: 6e67 5f70 6f72 7429 2026 6774 3b20 3029  ng_port) > 0)
    │ │ │ -0005c630: 0a09 097b 0a23 6966 6465 6620 544f 5252  ...{.#ifdef TORR
    │ │ │ -0005c640: 454e 545f 5749 4e44 4f57 530a 0909 0973  ENT_WINDOWS....s
    │ │ │ -0005c650: 2e73 6574 5f6f 7074 696f 6e28 6578 636c  .set_option(excl
    │ │ │ -0005c660: 7573 6976 655f 6164 6472 6573 735f 7573  usive_address_us
    │ │ │ -0005c670: 6528 7472 7565 292c 2065 6329 3b0a 2365  e(true), ec);.#e
    │ │ │ -0005c680: 6c73 650a 0909 0973 2e73 6574 5f6f 7074  lse....s.set_opt
    │ │ │ -0005c690: 696f 6e28 7463 703a 3a61 6363 6570 746f  ion(tcp::accepto
    │ │ │ -0005c6a0: 723a 3a72 6575 7365 5f61 6464 7265 7373  r::reuse_address
    │ │ │ -0005c6b0: 2874 7275 6529 2c20 6563 293b 0a23 656e  (true), ec);.#en
    │ │ │ -0005c6c0: 6469 660a 0909 092f 2f20 6967 6e6f 7265  dif....// ignore
    │ │ │ -0005c6d0: 2065 7272 6f72 7320 6265 6361 7573 6520   errors because 
    │ │ │ -0005c6e0: 7468 6520 756e 6465 726c 7969 6e67 2073  the underlying s
    │ │ │ -0005c6f0: 6f63 6b65 7420 6d61 7920 6e6f 740a 0909  ocket may not...
    │ │ │ -0005c700: 092f 2f20 6265 206f 7065 6e65 6420 7965  .// be opened ye
    │ │ │ -0005c710: 742e 2054 6869 7320 6861 7070 656e 7320  t. This happens 
    │ │ │ -0005c720: 7768 656e 2077 6527 7265 2072 6f75 7469  when we're routi
    │ │ │ -0005c730: 6e67 2074 6872 6f75 6768 0a09 0909 2f2f  ng through....//
    │ │ │ -0005c740: 2061 2070 726f 7879 2e20 496e 2074 6861   a proxy. In tha
    │ │ │ -0005c750: 7420 6361 7365 2c20 7765 2064 6f6e 2774  t case, we don't
    │ │ │ -0005c760: 2079 6574 206b 6e6f 7720 7468 6520 6164   yet know the ad
    │ │ │ -0005c770: 6472 6573 7320 6f66 0a09 0909 2f2f 2074  dress of....// t
    │ │ │ -0005c780: 6865 2070 726f 7879 2073 6572 7665 722c  he proxy server,
    │ │ │ -0005c790: 2061 6e64 206d 6f72 6520 696d 706f 7274   and more import
    │ │ │ -0005c7a0: 616e 746c 792c 2077 6520 646f 6e27 7420  antly, we don't 
    │ │ │ -0005c7b0: 6b6e 6f77 0a09 0909 2f2f 2074 6865 2061  know....// the a
    │ │ │ -0005c7c0: 6464 7265 7373 2066 616d 696c 7920 6f66  ddress family of
    │ │ │ -0005c7d0: 2069 7473 2061 6464 7265 7373 2e20 5468   its address. Th
    │ │ │ -0005c7e0: 6973 206d 6561 6e73 2077 6520 6361 6e27  is means we can'
    │ │ │ -0005c7f0: 740a 0909 092f 2f20 6f70 656e 2074 6865  t....// open the
    │ │ │ -0005c800: 2073 6f63 6b65 7420 7965 742e 2054 6865   socket yet. The
    │ │ │ -0005c810: 2073 6f63 6b73 2061 6273 7472 6163 7469   socks abstracti
    │ │ │ -0005c820: 6f6e 206c 6179 6572 2064 6566 6572 730a  on layer defers.
    │ │ │ -0005c830: 0909 092f 2f20 6f70 656e 696e 6720 6974  ...// opening it
    │ │ │ -0005c840: 2e0a 0909 0965 632e 636c 6561 7228 293b  .....ec.clear();
    │ │ │ -0005c850: 0a09 0909 6269 6e64 5f65 702e 706f 7274  ....bind_ep.port
    │ │ │ -0005c860: 2873 7464 3a3a 7569 6e74 3136 5f74 286e  (std::uint16_t(n
    │ │ │ -0005c870: 6578 745f 706f 7274 2829 2929 3b0a 0909  ext_port()));...
    │ │ │ -0005c880: 7d0a 0a09 0969 6620 2869 735f 7574 7028  }....if (is_utp(
    │ │ │ -0005c890: 7329 290a 0909 7b0a 3c64 6976 2073 7479  s))...{.
    .
    ... │ │ │ -0005c8d0: 7574 705f 736f 636b 6574 5f69 6d70 6c2a utp_socket_impl* │ │ │ -0005c8e0: 2069 6d70 6c20 3d20 6e75 6c6c 7074 723b impl = nullptr; │ │ │ -0005c8f0: 0a09 0909 7472 616e 7370 6f72 7420 7373 ....transport ss │ │ │ -0005c900: 6c20 3d20 7472 616e 7370 6f72 743a 3a70 l = transport::p │ │ │ -0005c910: 6c61 696e 7465 7874 3b0a 2369 6620 544f laintext;.#if TO │ │ │ -0005c920: 5252 454e 545f 5553 455f 5353 4c0a 0909 RRENT_USE_SSL... │ │ │ -0005c930: 0969 6620 2873 7464 3a3a 6765 745f 6966 .if (std::get_if │ │ │ -0005c940: 266c 743b 7373 6c5f 7374 7265 616d 266c <ssl_stream&l │ │ │ -0005c950: 743b 7574 705f 7374 7265 616d 2667 743b t;utp_stream> │ │ │ -0005c960: 2667 743b 2826 616d 703b 732e 7661 7228 >(&s.var( │ │ │ -0005c970: 2929 2021 3d20 6e75 6c6c 7074 7229 0a09 )) != nullptr).. │ │ │ -0005c980: 0909 7b0a 0909 0909 696d 706c 203d 2073 ..{.....impl = s │ │ │ -0005c990: 7464 3a3a 6765 7426 6c74 3b73 736c 5f73 td::get<ssl_s │ │ │ -0005c9a0: 7472 6561 6d26 6c74 3b75 7470 5f73 7472 tream<utp_str │ │ │ -0005c9b0: 6561 6d26 6774 3b26 6774 3b28 7329 2e6e eam>>(s).n │ │ │ -0005c9c0: 6578 745f 6c61 7965 7228 292e 6765 745f ext_layer().get_ │ │ │ -0005c9d0: 696d 706c 2829 3b0a 0909 0909 7373 6c20 impl();.....ssl │ │ │ -0005c9e0: 3d20 7472 616e 7370 6f72 743a 3a73 736c = transport::ssl │ │ │ -0005c9f0: 3b0a 0909 097d 0a09 0909 656c 7365 0a23 ;....}....else.# │ │ │ -0005ca00: 656e 6469 660a 0909 0909 696d 706c 203d endif.....impl = │ │ │ -0005ca10: 2073 7464 3a3a 6765 7426 6c74 3b75 7470 std::get<utp │ │ │ -0005ca20: 5f73 7472 6561 6d26 6774 3b28 7329 2e67 _stream>(s).g │ │ │ -0005ca30: 6574 5f69 6d70 6c28 293b 0a0a 0909 0973 et_impl();.....s │ │ │ -0005ca40: 7464 3a3a 7665 6374 6f72 266c 743b 7374 td::vector<st │ │ │ -0005ca50: 643a 3a73 6861 7265 645f 7074 7226 6c74 d::shared_ptr< │ │ │ -0005ca60: 3b6c 6973 7465 6e5f 736f 636b 6574 5f74 ;listen_socket_t │ │ │ -0005ca70: 2667 743b 2667 743b 2077 6974 685f 6761 >> with_ga │ │ │ -0005ca80: 7465 7761 7973 3b0a 0909 0973 7464 3a3a teways;....std:: │ │ │ -0005ca90: 7368 6172 6564 5f70 7472 266c 743b 6c69 shared_ptr<li │ │ │ -0005caa0: 7374 656e 5f73 6f63 6b65 745f 7426 6774 sten_socket_t> │ │ │ -0005cab0: 3b20 6d61 7463 683b 0a09 0909 666f 7220 ; match;....for │ │ │ -0005cac0: 2861 7574 6f20 636f 6e73 7426 616d 703b (auto const& │ │ │ -0005cad0: 206c 7320 3a20 6d5f 6c69 7374 656e 5f73 ls : m_listen_s │ │ │ -0005cae0: 6f63 6b65 7473 290a 0909 097b 0a09 0909 ockets)....{.... │ │ │ -0005caf0: 092f 2f20 7468 6973 2069 7320 616c 6d6f .// this is almo │ │ │ -0005cb00: 7374 2c20 6275 7420 6e6f 7420 7175 6974 st, but not quit │ │ │ -0005cb10: 652c 206c 696b 6520 6361 6e5f 726f 7574 e, like can_rout │ │ │ -0005cb20: 6528 290a 0909 0909 6966 2028 2128 6c73 e().....if (!(ls │ │ │ -0005cb30: 2d26 6774 3b66 6c61 6773 2026 616d 703b ->flags & │ │ │ -0005cb40: 206c 6973 7465 6e5f 736f 636b 6574 5f74 listen_socket_t │ │ │ -0005cb50: 3a3a 7072 6f78 7929 0a09 0909 0909 2661 ::proxy)......&a │ │ │ -0005cb60: 6d70 3b26 616d 703b 2069 735f 7634 286c mp;& is_v4(l │ │ │ -0005cb70: 732d 2667 743b 6c6f 6361 6c5f 656e 6470 s->local_endp │ │ │ -0005cb80: 6f69 6e74 2920 213d 2072 656d 6f74 655f oint) != remote_ │ │ │ -0005cb90: 6164 6472 6573 732e 6973 5f76 3428 2929 address.is_v4()) │ │ │ -0005cba0: 0a09 0909 0909 636f 6e74 696e 7565 3b0a ......continue;. │ │ │ -0005cbb0: 0909 0909 6966 2028 6c73 2d26 6774 3b73 ....if (ls->s │ │ │ -0005cbc0: 736c 2021 3d20 7373 6c29 2063 6f6e 7469 sl != ssl) conti │ │ │ -0005cbd0: 6e75 653b 0a09 0909 0969 6620 2821 286c nue;.....if (!(l │ │ │ -0005cbe0: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ -0005cbf0: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f ; listen_socket_ │ │ │ -0005cc00: 743a 3a6c 6f63 616c 5f6e 6574 776f 726b t::local_network │ │ │ -0005cc10: 2929 0a09 0909 0909 7769 7468 5f67 6174 ))......with_gat │ │ │ -0005cc20: 6577 6179 732e 7075 7368 5f62 6163 6b28 eways.push_back( │ │ │ -0005cc30: 6c73 293b 0a0a 0909 0909 6966 2028 6c73 ls);......if (ls │ │ │ -0005cc40: 2d26 6774 3b66 6c61 6773 2026 616d 703b ->flags & │ │ │ -0005cc50: 206c 6973 7465 6e5f 736f 636b 6574 5f74 listen_socket_t │ │ │ -0005cc60: 3a3a 7072 6f78 790a 0909 0909 097c 7c20 ::proxy......|| │ │ │ -0005cc70: 6d61 7463 685f 6164 6472 5f6d 6173 6b28 match_addr_mask( │ │ │ -0005cc80: 6c73 2d26 6774 3b6c 6f63 616c 5f65 6e64 ls->local_end │ │ │ -0005cc90: 706f 696e 742e 6164 6472 6573 7328 292c point.address(), │ │ │ -0005cca0: 2072 656d 6f74 655f 6164 6472 6573 732c remote_address, │ │ │ -0005ccb0: 206c 732d 2667 743b 6e65 746d 6173 6b29 ls->netmask) │ │ │ -0005ccc0: 290a 0909 0909 7b0a 0909 0909 092f 2f20 ).....{......// │ │ │ -0005ccd0: 6973 2074 6869 7320 6265 7474 6572 2074 is this better t │ │ │ -0005cce0: 6861 6e20 7468 6520 7072 6576 696f 7573 han the previous │ │ │ -0005ccf0: 206d 6174 6368 3f0a 0909 0909 096d 6174 match?......mat │ │ │ -0005cd00: 6368 203d 206c 733b 0a09 0909 097d 0a3c ch = ls;.....}.< │ │ │ -0005cd10: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0005cd20: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0005cd30: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0005cd40: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0005cd50: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0005cd80: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0005cd90: 703a 3630 3730 3c2f 613e 3c2f 7464 3e3c p:6070< │ │ │ -0005cda0: 7464 3e72 6566 6163 746f 722c 206d 6f76 td>refactor, mov │ │ │ -0005cdb0: 6520 7468 6520 7374 6f72 6167 6520 746f e the storage to │ │ │ -0005cdc0: 2064 6874 5f74 7261 636b 6572 3c2f 7464 dht_tracker

    refact │ │ │ -0005ce20: 6f72 2c20 6d6f 7665 2074 6865 2073 746f or, move the sto │ │ │ -0005ce30: 7261 6765 2074 6f20 6468 745f 7472 6163 rage to dht_trac │ │ │ -0005ce40: 6b65 723c 2f68 323e 3c68 343e 2e2e 2f73 ker

    ../s │ │ │ -0005ce50: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -0005ce60: 6370 703a 3630 3730 3c2f 6834 3e3c 7072 cpp:6070

    #ifndef T │ │ │ -0005ceb0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ -0005cec0: 4f47 4749 4e47 0a09 0909 7365 7373 696f OGGING....sessio │ │ │ -0005ced0: 6e5f 6c6f 6728 226e 6f74 2073 7461 7274 n_log("not start │ │ │ -0005cee0: 696e 6720 4448 542c 206f 7574 7374 616e ing DHT, outstan │ │ │ -0005cef0: 6469 6e67 2072 6f75 7465 7220 6c6f 6f6b ding router look │ │ │ -0005cf00: 7570 733a 2025 6422 0a09 0909 092c 206d ups: %d"....., m │ │ │ -0005cf10: 5f6f 7574 7374 616e 6469 6e67 5f72 6f75 _outstanding_rou │ │ │ -0005cf20: 7465 725f 6c6f 6f6b 7570 7329 3b0a 2365 ter_lookups);.#e │ │ │ -0005cf30: 6e64 6966 0a09 0909 7265 7475 726e 3b0a ndif....return;. │ │ │ -0005cf40: 0909 7d0a 0a09 0969 6620 286d 5f61 626f ..}....if (m_abo │ │ │ -0005cf50: 7274 290a 0909 7b0a 2369 666e 6465 6620 rt)...{.#ifndef │ │ │ -0005cf60: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -0005cf70: 4c4f 4747 494e 470a 0909 0973 6573 7369 LOGGING....sessi │ │ │ -0005cf80: 6f6e 5f6c 6f67 2822 6e6f 7420 7374 6172 on_log("not star │ │ │ -0005cf90: 7469 6e67 2044 4854 2c20 6162 6f72 7469 ting DHT, aborti │ │ │ -0005cfa0: 6e67 2229 3b0a 2365 6e64 6966 0a09 0909 ng");.#endif.... │ │ │ -0005cfb0: 7265 7475 726e 3b0a 0909 7d0a 0a23 6966 return;...}..#if │ │ │ -0005cfc0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -0005cfd0: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0973 ABLE_LOGGING...s │ │ │ -0005cfe0: 6573 7369 6f6e 5f6c 6f67 2822 7374 6172 ession_log("star │ │ │ -0005cff0: 7469 6e67 2044 4854 2c20 7275 6e6e 696e ting DHT, runnin │ │ │ -0005d000: 673a 2025 732c 2072 6f75 7465 7220 6c6f g: %s, router lo │ │ │ -0005d010: 6f6b 7570 733a 2025 6422 0a09 0909 2c20 okups: %d"...., │ │ │ -0005d020: 6d5f 6468 7420 3f20 2274 7275 6522 203a m_dht ? "true" : │ │ │ -0005d030: 2022 6661 6c73 6522 2c20 6d5f 6f75 7473 "false", m_outs │ │ │ -0005d040: 7461 6e64 696e 675f 726f 7574 6572 5f6c tanding_router_l │ │ │ -0005d050: 6f6f 6b75 7073 293b 0a23 656e 6469 660a ookups);.#endif. │ │ │ -0005d060: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ -0005d090: 096d 5f64 6874 5f73 746f 7261 6765 203d .m_dht_storage = │ │ │ -0005d0a0: 206d 5f64 6874 5f73 746f 7261 6765 5f63 m_dht_storage_c │ │ │ -0005d0b0: 6f6e 7374 7275 6374 6f72 286d 5f73 6574 onstructor(m_set │ │ │ -0005d0c0: 7469 6e67 7329 3b0a 3c2f 6469 763e 0909 tings);.
    .. │ │ │ -0005d0d0: 6d5f 6468 7420 3d20 7374 643a 3a6d 616b m_dht = std::mak │ │ │ -0005d0e0: 655f 7368 6172 6564 266c 743b 6468 743a e_shared<dht: │ │ │ -0005d0f0: 3a64 6874 5f74 7261 636b 6572 2667 743b :dht_tracker> │ │ │ -0005d100: 280a 0909 0973 7461 7469 635f 6361 7374 (....static_cast │ │ │ -0005d110: 266c 743b 6468 743a 3a64 6874 5f6f 6273 <dht::dht_obs │ │ │ -0005d120: 6572 7665 722a 2667 743b 2874 6869 7329 erver*>(this) │ │ │ -0005d130: 0a09 0909 2c20 6d5f 696f 5f63 6f6e 7465 ...., m_io_conte │ │ │ -0005d140: 7874 0a09 0909 2c20 5b74 6869 735d 2861 xt...., [this](a │ │ │ -0005d150: 7578 3a3a 6c69 7374 656e 5f73 6f63 6b65 ux::listen_socke │ │ │ -0005d160: 745f 6861 6e64 6c65 2063 6f6e 7374 2661 t_handle const&a │ │ │ -0005d170: 6d70 3b20 736f 636b 0a09 0909 092c 2075 mp; sock....., u │ │ │ -0005d180: 6470 3a3a 656e 6470 6f69 6e74 2063 6f6e dp::endpoint con │ │ │ -0005d190: 7374 2661 6d70 3b20 6570 0a09 0909 092c st& ep....., │ │ │ -0005d1a0: 2073 7061 6e26 6c74 3b63 6861 7220 636f span<char co │ │ │ -0005d1b0: 6e73 7426 6774 3b20 700a 0909 0909 2c20 nst> p....., │ │ │ -0005d1c0: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ -0005d1d0: 6563 0a09 0909 092c 2075 6470 5f73 656e ec....., udp_sen │ │ │ -0005d1e0: 645f 666c 6167 735f 7420 636f 6e73 7420 d_flags_t const │ │ │ -0005d1f0: 666c 6167 7329 0a09 0909 097b 2073 656e flags).....{ sen │ │ │ -0005d200: 645f 7564 705f 7061 636b 6574 5f6c 6973 d_udp_packet_lis │ │ │ -0005d210: 7465 6e28 736f 636b 2c20 6570 2c20 702c ten(sock, ep, p, │ │ │ -0005d220: 2065 632c 2066 6c61 6773 293b 207d 0a09 ec, flags); }.. │ │ │ -0005d230: 0909 2c20 6d5f 7365 7474 696e 6773 0a09 .., m_settings.. │ │ │ -0005d240: 0909 2c20 6d5f 7374 6174 735f 636f 756e .., m_stats_coun │ │ │ -0005d250: 7465 7273 0a09 0909 2c20 2a6d 5f64 6874 ters...., *m_dht │ │ │ -0005d260: 5f73 746f 7261 6765 0a09 0909 2c20 7374 _storage...., st │ │ │ -0005d270: 643a 3a6d 6f76 6528 6d5f 6468 745f 7374 d::move(m_dht_st │ │ │ -0005d280: 6174 6529 293b 0a0a 0909 666f 7220 2861 ate));....for (a │ │ │ -0005d290: 7574 6f26 616d 703b 2073 203a 206d 5f6c uto& s : m_l │ │ │ -0005d2a0: 6973 7465 6e5f 736f 636b 6574 7329 0a09 isten_sockets).. │ │ │ -0005d2b0: 097b 0a09 0909 6966 2028 732d 2667 743b .{....if (s-> │ │ │ -0005d2c0: 7373 6c20 213d 2074 7261 6e73 706f 7274 ssl != transport │ │ │ -0005d2d0: 3a3a 7373 6c0a 0909 0909 2661 6d70 3b26 ::ssl.....&& │ │ │ -0005d2e0: 616d 703b 2021 2873 2d26 6774 3b66 6c61 amp; !(s->fla │ │ │ -0005d2f0: 6773 2026 616d 703b 206c 6973 7465 6e5f gs & listen_ │ │ │ -0005d300: 736f 636b 6574 5f74 3a3a 6c6f 6361 6c5f socket_t::local_ │ │ │ -0005d310: 6e65 7477 6f72 6b29 290a 0909 097b 0a09 network))....{.. │ │ │ -0005d320: 0909 096d 5f64 6874 2d26 6774 3b6e 6577 ...m_dht->new │ │ │ -0005d330: 5f73 6f63 6b65 7428 7329 3b0a 0909 097d _socket(s);....} │ │ │ -0005d340: 0a09 097d 0a0a 0909 666f 7220 2861 7574 ...}....for (aut │ │ │ -0005d350: 6f20 636f 6e73 7426 616d 703b 206e 203a o const& n : │ │ │ -0005d360: 206d 5f64 6874 5f72 6f75 7465 725f 6e6f m_dht_router_no │ │ │ -0005d370: 6465 7329 0a09 097b 0a09 0909 6d5f 6468 des)...{....m_dh │ │ │ -0005d380: 742d 2667 743b 6164 645f 726f 7574 6572 t->add_router │ │ │ -0005d390: 5f6e 6f64 6528 6e29 3b0a 0909 7d0a 0a09 _node(n);...}... │ │ │ -0005d3a0: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ -0005d3b0: 2661 6d70 3b20 6e20 3a20 6d5f 6468 745f & n : m_dht_ │ │ │ -0005d3c0: 6e6f 6465 7329 0a09 097b 0a3c 2f70 7265 nodes)...{.
    rele │ │ │ -0005d400: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ -0005d440: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3634 sion_impl.cpp:64 │ │ │ -0005d450: 3533 3c2f 613e 3c2f 7464 3e3c 7464 3e61 53a │ │ │ -0005d460: 7373 6572 7473 2074 6861 7420 6e6f 206f sserts that no o │ │ │ -0005d470: 7574 7374 616e 6469 6e67 2061 7379 6e63 utstanding async │ │ │ -0005d480: 206f 7065 7261 7469 6f6e 7320 6172 6520 operations are │ │ │ -0005d490: 7374 696c 6c20 696e 2066 6c69 6768 743c still in flight< │ │ │ -0005d4a0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    ass │ │ │ -0005d4f0: 6572 7473 2074 6861 7420 6e6f 206f 7574 erts that no out │ │ │ -0005d500: 7374 616e 6469 6e67 2061 7379 6e63 206f standing async o │ │ │ -0005d510: 7065 7261 7469 6f6e 7320 6172 6520 7374 perations are st │ │ │ -0005d520: 696c 6c20 696e 2066 6c69 6768 743c 2f68 ill in flight

    ../src/ses │ │ │ -0005d540: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3634 sion_impl.cpp:64 │ │ │ -0005d550: 3533 3c2f 6834 3e3c 7072 6520 7374 796c 53

    ..if (!m_dht) r
    │ │ │ -0005d5a0: 6574 7572 6e3b 0a09 096d 5f64 6874 2d26  eturn;...m_dht-&
    │ │ │ -0005d5b0: 6774 3b64 6972 6563 745f 7265 7175 6573  gt;direct_reques
    │ │ │ -0005d5c0: 7428 6570 2c20 652c 2073 7464 3a3a 6269  t(ep, e, std::bi
    │ │ │ -0005d5d0: 6e64 2826 616d 703b 6f6e 5f64 6972 6563  nd(&on_direc
    │ │ │ -0005d5e0: 745f 7265 7370 6f6e 7365 2c20 7374 643a  t_response, std:
    │ │ │ -0005d5f0: 3a72 6566 286d 5f61 6c65 7274 7329 2c20  :ref(m_alerts), 
    │ │ │ -0005d600: 7573 6572 6461 7461 2c20 5f31 2929 3b0a  userdata, _1));.
    │ │ │ -0005d610: 097d 0a0a 2365 6e64 6966 0a0a 0962 6f6f  .}..#endif...boo
    │ │ │ -0005d620: 6c20 7365 7373 696f 6e5f 696d 706c 3a3a  l session_impl::
    │ │ │ -0005d630: 6973 5f6c 6973 7465 6e69 6e67 2829 2063  is_listening() c
    │ │ │ -0005d640: 6f6e 7374 0a09 7b0a 0909 7265 7475 726e  onst..{...return
    │ │ │ -0005d650: 2021 6d5f 6c69 7374 656e 5f73 6f63 6b65   !m_listen_socke
    │ │ │ -0005d660: 7473 2e65 6d70 7479 2829 3b0a 097d 0a0a  ts.empty();..}..
    │ │ │ -0005d670: 0973 6573 7369 6f6e 5f69 6d70 6c3a 3a7e  .session_impl::~
    │ │ │ -0005d680: 7365 7373 696f 6e5f 696d 706c 2829 0a09  session_impl()..
    │ │ │ -0005d690: 7b0a 0909 2f2f 2073 696e 6365 2077 6527  {...// since we'
    │ │ │ -0005d6a0: 7265 2064 6573 7472 7563 7469 6e67 2074  re destructing t
    │ │ │ -0005d6b0: 6865 2073 6573 7369 6f6e 2c20 6e6f 206d  he session, no m
    │ │ │ -0005d6c0: 6f72 6520 616c 6572 7473 2077 696c 6c20  ore alerts will 
    │ │ │ -0005d6d0: 6d61 6b65 2069 7420 6f75 7420 746f 0a09  make it out to..
    │ │ │ -0005d6e0: 092f 2f20 7468 6520 7573 6572 2e20 536f  .// the user. So
    │ │ │ -0005d6f0: 2073 746f 7020 706f 7374 696e 6720 7468   stop posting th
    │ │ │ -0005d700: 656d 206e 6f77 0a09 096d 5f61 6c65 7274  em now...m_alert
    │ │ │ -0005d710: 732e 7365 745f 616c 6572 745f 6d61 736b  s.set_alert_mask
    │ │ │ -0005d720: 287b 7d29 3b0a 0909 6d5f 616c 6572 7473  ({});...m_alerts
    │ │ │ -0005d730: 2e73 6574 5f6e 6f74 6966 795f 6675 6e63  .set_notify_func
    │ │ │ -0005d740: 7469 6f6e 287b 7d29 3b0a 0a09 092f 2f20  tion({});....// 
    │ │ │ -0005d750: 7468 6973 2069 7320 6e6f 7420 616c 6c6f  this is not allo
    │ │ │ -0005d760: 7765 6420 746f 2062 6520 7468 6520 6e65  wed to be the ne
    │ │ │ -0005d770: 7477 6f72 6b20 7468 7265 6164 210a 2f2f  twork thread!.//
    │ │ │ -0005d780: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -0005d790: 2869 735f 6e6f 745f 7468 7265 6164 2829  (is_not_thread()
    │ │ │ -0005d7a0: 293b 0a3c 6469 7620 7374 796c 653d 2262  );.
    .
    ..// thi │ │ │ -0005d7e0: 7320 6361 6e20 6861 7070 656e 2069 6620 s can happen if │ │ │ -0005d7f0: 7765 2065 6e64 2074 6865 2069 6f5f 636f we end the io_co │ │ │ -0005d800: 6e74 6578 7420 7275 6e20 6c6f 6f70 2077 ntext run loop w │ │ │ -0005d810: 6974 6820 616e 2065 7863 6570 7469 6f6e ith an exception │ │ │ -0005d820: 0a09 096d 5f63 6f6e 6e65 6374 696f 6e73 ...m_connections │ │ │ -0005d830: 2e63 6c65 6172 2829 3b0a 0909 666f 7220 .clear();...for │ │ │ -0005d840: 2861 7574 6f26 616d 703b 2074 203a 206d (auto& t : m │ │ │ -0005d850: 5f74 6f72 7265 6e74 7329 0a09 097b 0a09 _torrents)...{.. │ │ │ -0005d860: 0909 742d 2667 743b 7061 6e69 6328 293b ..t->panic(); │ │ │ -0005d870: 0a09 0909 742d 2667 743b 6162 6f72 7428 ....t->abort( │ │ │ -0005d880: 293b 0a09 097d 0a09 096d 5f74 6f72 7265 );...}...m_torre │ │ │ -0005d890: 6e74 732e 636c 6561 7228 293b 0a0a 0909 nts.clear();.... │ │ │ -0005d8a0: 2f2f 2074 6869 7320 6861 7320 7072 6f62 // this has prob │ │ │ -0005d8b0: 6162 6c79 2062 6565 6e20 6361 6c6c 6564 ably been called │ │ │ -0005d8c0: 2061 6c72 6561 6479 2c20 6275 7420 696e already, but in │ │ │ -0005d8d0: 2063 6173 6520 6f66 2073 7564 6465 6e0a case of sudden. │ │ │ -0005d8e0: 0909 2f2f 2074 6572 6d69 6e61 7469 6f6e ..// termination │ │ │ -0005d8f0: 2074 6872 6f75 6768 2061 6e20 6578 6365 through an exce │ │ │ -0005d900: 7074 696f 6e2c 2069 7420 6d61 7920 6e6f ption, it may no │ │ │ -0005d910: 7420 6861 7665 2062 6565 6e20 646f 6e65 t have been done │ │ │ -0005d920: 0a09 0961 626f 7274 5f73 7461 6765 3228 ...abort_stage2( │ │ │ -0005d930: 293b 0a0a 2369 6620 6465 6669 6e65 6420 );..#if defined │ │ │ -0005d940: 544f 5252 454e 545f 4153 494f 5f44 4542 TORRENT_ASIO_DEB │ │ │ -0005d950: 5547 4749 4e47 0a09 0946 494c 452a 2066 UGGING...FILE* f │ │ │ -0005d960: 203d 2066 6f70 656e 2822 7761 6b65 7570 = fopen("wakeup │ │ │ -0005d970: 732e 6c6f 6722 2c20 2277 2b22 293b 0a09 s.log", "w+");.. │ │ │ -0005d980: 0969 6620 2866 2021 3d20 6e75 6c6c 7074 .if (f != nullpt │ │ │ -0005d990: 7229 0a09 097b 0a09 0909 7469 6d65 5f70 r)...{....time_p │ │ │ -0005d9a0: 6f69 6e74 206d 203d 206d 696e 5f74 696d oint m = min_tim │ │ │ -0005d9b0: 6528 293b 0a09 0909 6966 2028 215f 7761 e();....if (!_wa │ │ │ -0005d9c0: 6b65 7570 732e 656d 7074 7928 2929 206d keups.empty()) m │ │ │ -0005d9d0: 203d 205f 7761 6b65 7570 735b 305d 2e74 = _wakeups[0].t │ │ │ -0005d9e0: 696d 6573 7461 6d70 3b0a 0909 0974 696d imestamp;....tim │ │ │ -0005d9f0: 655f 706f 696e 7420 7072 6576 203d 206d e_point prev = m │ │ │ -0005da00: 3b0a 0909 0973 7464 3a3a 7569 6e74 3634 ;....std::uint64 │ │ │ -0005da10: 5f74 2070 7265 765f 6373 7720 3d20 303b _t prev_csw = 0; │ │ │ -0005da20: 0a09 0909 6966 2028 215f 7761 6b65 7570 ....if (!_wakeup │ │ │ -0005da30: 732e 656d 7074 7928 2929 2070 7265 765f s.empty()) prev_ │ │ │ -0005da40: 6373 7720 3d20 5f77 616b 6575 7073 5b30 csw = _wakeups[0 │ │ │ -0005da50: 5d2e 636f 6e74 6578 745f 7377 6974 6368 ].context_switch │ │ │ -0005da60: 6573 3b0a 0909 0973 7464 3a3a 6670 7269 es;....std::fpri │ │ │ -0005da70: 6e74 6628 662c 2022 6162 732e 2074 696d ntf(f, "abs. tim │ │ │ -0005da80: 655c 7472 656c 2e20 7469 6d65 5c74 6374 e\trel. time\tct │ │ │ -0005da90: 7820 7377 6974 6368 5c74 6964 6c65 2d77 x switch\tidle-w │ │ │ -0005daa0: 616b 6575 705c 746f 7065 7261 7469 6f6e akeup\toperation │ │ │ -0005dab0: 5c6e 2229 3b0a 0909 0966 6f72 2028 7761 \n");....for (wa │ │ │ -0005dac0: 6b65 7570 5f74 2063 6f6e 7374 2661 6d70 keup_t const& │ │ │ -0005dad0: 3b20 7720 3a20 5f77 616b 6575 7073 290a ; w : _wakeups). │ │ │ -0005dae0: 0909 097b 0a09 0909 0962 6f6f 6c20 636f ...{.....bool co │ │ │ -0005daf0: 6e73 7420 6964 6c65 5f77 616b 6575 7020 nst idle_wakeup │ │ │ -0005db00: 3d20 772e 636f 6e74 6578 745f 7377 6974 = w.context_swit │ │ │ -0005db10: 6368 6573 2026 6774 3b20 7072 6576 5f63 ches > prev_c │ │ │ -0005db20: 7377 3b0a 0909 0909 7374 643a 3a66 7072 sw;.....std::fpr │ │ │ -0005db30: 696e 7466 2866 2c20 2225 2220 5052 4964 intf(f, "%" PRId │ │ │ -0005db40: 3634 2022 5c74 2522 2050 5249 6436 3420 64 "\t%" PRId64 │ │ │ -0005db50: 225c 7425 2220 5052 4964 3634 2022 5c74 "\t%" PRId64 "\t │ │ │ -0005db60: 2563 5c74 2573 5c6e 220a 0909 0909 092c %c\t%s\n"......, │ │ │ -0005db70: 2074 6f74 616c 5f6d 6963 726f 7365 636f total_microseco │ │ │ -0005db80: 6e64 7328 772e 7469 6d65 7374 616d 7020 nds(w.timestamp │ │ │ -0005db90: 2d20 6d29 0a09 0909 0909 2c20 746f 7461 - m)......, tota │ │ │ -0005dba0: 6c5f 6d69 6372 6f73 6563 6f6e 6473 2877 l_microseconds(w │ │ │ -0005dbb0: 2e74 696d 6573 7461 6d70 202d 2070 7265 .timestamp - pre │ │ │ -0005dbc0: 7629 0a09 0909 0909 2c20 772e 636f 6e74 v)......, w.cont │ │ │ -0005dbd0: 6578 745f 7377 6974 6368 6573 0a3c 2f70 ext_switches.

    re │ │ │ -0005dc10: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ -0005dc50: 6d61 705f 6469 736b 5f69 6f2e 6370 703a map_disk_io.cpp: │ │ │ -0005dc60: 3337 373c 2f61 3e3c 2f74 643e 3c74 643e 377 │ │ │ -0005dc70: 696e 2074 6865 2066 7574 7572 652c 2070 in the future, p │ │ │ -0005dc80: 726f 7061 6761 7465 2065 7863 6570 7469 ropagate excepti │ │ │ -0005dc90: 6f6e 7320 6261 636b 2074 6f20 7468 6520 ons back to the │ │ │ -0005dca0: 6861 6e64 6c65 7273 3c2f 7464 3e3c 2f74 handlers

    in the fut │ │ │ -0005dd00: 7572 652c 2070 726f 7061 6761 7465 2065 ure, propagate e │ │ │ -0005dd10: 7863 6570 7469 6f6e 7320 6261 636b 2074 xceptions back t │ │ │ -0005dd20: 6f20 7468 6520 6861 6e64 6c65 7273 3c2f o the handlers

    ../src/mm │ │ │ -0005dd40: 6170 5f64 6973 6b5f 696f 2e63 7070 3a33 ap_disk_io.cpp:3 │ │ │ -0005dd50: 3737 3c2f 6834 3e3c 7072 6520 7374 796c 77

    .void mmap_disk
    │ │ │ -0005dda0: 5f69 6f3a 3a70 6572 666f 726d 5f6a 6f62  _io::perform_job
    │ │ │ -0005ddb0: 2861 7578 3a3a 6d6d 6170 5f64 6973 6b5f  (aux::mmap_disk_
    │ │ │ -0005ddc0: 6a6f 622a 206a 2c20 6a6f 6271 7565 7565  job* j, jobqueue
    │ │ │ -0005ddd0: 5f74 2661 6d70 3b20 636f 6d70 6c65 7465  _t& complete
    │ │ │ -0005dde0: 645f 6a6f 6273 290a 097b 0a09 0954 4f52  d_jobs)..{...TOR
    │ │ │ -0005ddf0: 5245 4e54 5f41 5353 4552 5428 6a2d 2667  RENT_ASSERT(j-&g
    │ │ │ -0005de00: 743b 6e65 7874 203d 3d20 6e75 6c6c 7074  t;next == nullpt
    │ │ │ -0005de10: 7229 3b0a 0909 544f 5252 454e 545f 4153  r);...TORRENT_AS
    │ │ │ -0005de20: 5345 5254 2828 6a2d 2667 743b 666c 6167  SERT((j->flag
    │ │ │ -0005de30: 7320 2661 6d70 3b20 6175 783a 3a64 6973  s & aux::dis
    │ │ │ -0005de40: 6b5f 6a6f 623a 3a69 6e5f 7072 6f67 7265  k_job::in_progre
    │ │ │ -0005de50: 7373 2920 7c7c 2021 6a2d 2667 743b 7374  ss) || !j->st
    │ │ │ -0005de60: 6f72 6167 6529 3b0a 0a23 6966 2044 4542  orage);..#if DEB
    │ │ │ -0005de70: 5547 5f44 4953 4b5f 5448 5245 4144 0a09  UG_DISK_THREAD..
    │ │ │ -0005de80: 097b 0a09 0909 7374 643a 3a75 6e69 7175  .{....std::uniqu
    │ │ │ -0005de90: 655f 6c6f 636b 266c 743b 7374 643a 3a6d  e_lock<std::m
    │ │ │ -0005dea0: 7574 6578 2667 743b 206c 286d 5f6a 6f62  utex> l(m_job
    │ │ │ -0005deb0: 5f6d 7574 6578 293b 0a0a 0909 0944 4c4f  _mutex);.....DLO
    │ │ │ -0005dec0: 4728 2270 6572 666f 726d 5f6a 6f62 206a  G("perform_job j
    │ │ │ -0005ded0: 6f62 3a20 2573 206f 7574 7374 616e 6469  ob: %s outstandi
    │ │ │ -0005dee0: 6e67 3a20 2564 5c6e 220a 0909 0909 2c20  ng: %d\n"....., 
    │ │ │ -0005def0: 7072 696e 745f 6a6f 6228 2a6a 292e 635f  print_job(*j).c_
    │ │ │ -0005df00: 7374 7228 290a 0909 0909 2c20 6a2d 2667  str()....., j-&g
    │ │ │ -0005df10: 743b 7374 6f72 6167 6520 3f20 6a2d 2667  t;storage ? j-&g
    │ │ │ -0005df20: 743b 7374 6f72 6167 652d 2667 743b 6e75  t;storage->nu
    │ │ │ -0005df30: 6d5f 6f75 7473 7461 6e64 696e 675f 6a6f  m_outstanding_jo
    │ │ │ -0005df40: 6273 2829 203a 202d 3129 3b0a 0909 7d0a  bs() : -1);...}.
    │ │ │ -0005df50: 2365 6e64 6966 0a0a 0909 7374 643a 3a73  #endif....std::s
    │ │ │ -0005df60: 6861 7265 645f 7074 7226 6c74 3b61 7578  hared_ptr<aux
    │ │ │ -0005df70: 3a3a 6d6d 6170 5f73 746f 7261 6765 2667  ::mmap_storage&g
    │ │ │ -0005df80: 743b 2073 746f 7261 6765 203d 206a 2d26  t; storage = j-&
    │ │ │ -0005df90: 6774 3b73 746f 7261 6765 3b0a 0a09 096d  gt;storage;....m
    │ │ │ -0005dfa0: 5f73 7461 7473 5f63 6f75 6e74 6572 732e  _stats_counters.
    │ │ │ -0005dfb0: 696e 635f 7374 6174 735f 636f 756e 7465  inc_stats_counte
    │ │ │ -0005dfc0: 7228 636f 756e 7465 7273 3a3a 6e75 6d5f  r(counters::num_
    │ │ │ -0005dfd0: 7275 6e6e 696e 675f 6469 736b 5f6a 6f62  running_disk_job
    │ │ │ -0005dfe0: 732c 2031 293b 0a0a 0909 2f2f 2063 616c  s, 1);....// cal
    │ │ │ -0005dff0: 6c20 6469 736b 2066 756e 6374 696f 6e0a  l disk function.
    │ │ │ -0005e000: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -0005e030: 7374 6174 7573 5f74 2072 6574 7b7d 3b0a status_t ret{};. │ │ │ -0005e040: 3c2f 6469 763e 0909 7472 790a 0909 7b0a
    ..try...{. │ │ │ -0005e050: 0909 0972 6574 203d 2073 7464 3a3a 7669 ...ret = std::vi │ │ │ -0005e060: 7369 7428 5b74 6869 732c 206a 5d28 6175 sit([this, j](au │ │ │ -0005e070: 746f 2661 6d70 3b20 6129 207b 2072 6574 to& a) { ret │ │ │ -0005e080: 7572 6e20 7468 6973 2d26 6774 3b64 6f5f urn this->do_ │ │ │ -0005e090: 6a6f 6228 612c 206a 293b 207d 2c20 6a2d job(a, j); }, j- │ │ │ -0005e0a0: 2667 743b 6163 7469 6f6e 293b 0a09 097d >action);...} │ │ │ -0005e0b0: 0a09 0963 6174 6368 2028 626f 6f73 743a ...catch (boost: │ │ │ -0005e0c0: 3a73 7973 7465 6d3a 3a73 7973 7465 6d5f :system::system_ │ │ │ -0005e0d0: 6572 726f 7220 636f 6e73 7426 616d 703b error const& │ │ │ -0005e0e0: 2065 7272 290a 0909 7b0a 0909 0972 6574 err)...{....ret │ │ │ -0005e0f0: 203d 2064 6973 6b5f 7374 6174 7573 3a3a = disk_status:: │ │ │ -0005e100: 6661 7461 6c5f 6469 736b 5f65 7272 6f72 fatal_disk_error │ │ │ -0005e110: 3b0a 0909 096a 2d26 6774 3b65 7272 6f72 ;....j->error │ │ │ -0005e120: 2e65 6320 3d20 6572 722e 636f 6465 2829 .ec = err.code() │ │ │ -0005e130: 3b0a 0909 096a 2d26 6774 3b65 7272 6f72 ;....j->error │ │ │ -0005e140: 2e6f 7065 7261 7469 6f6e 203d 206f 7065 .operation = ope │ │ │ -0005e150: 7261 7469 6f6e 5f74 3a3a 6578 6365 7074 ration_t::except │ │ │ -0005e160: 696f 6e3b 0a09 097d 0a09 0963 6174 6368 ion;...}...catch │ │ │ -0005e170: 2028 7374 643a 3a62 6164 5f61 6c6c 6f63 (std::bad_alloc │ │ │ -0005e180: 2063 6f6e 7374 2661 6d70 3b29 0a09 097b const&)...{ │ │ │ -0005e190: 0a09 0909 7265 7420 3d20 6469 736b 5f73 ....ret = disk_s │ │ │ -0005e1a0: 7461 7475 733a 3a66 6174 616c 5f64 6973 tatus::fatal_dis │ │ │ -0005e1b0: 6b5f 6572 726f 723b 0a09 0909 6a2d 2667 k_error;....j-&g │ │ │ -0005e1c0: 743b 6572 726f 722e 6563 203d 2065 7272 t;error.ec = err │ │ │ -0005e1d0: 6f72 733a 3a6e 6f5f 6d65 6d6f 7279 3b0a ors::no_memory;. │ │ │ -0005e1e0: 0909 096a 2d26 6774 3b65 7272 6f72 2e6f ...j->error.o │ │ │ -0005e1f0: 7065 7261 7469 6f6e 203d 206f 7065 7261 peration = opera │ │ │ -0005e200: 7469 6f6e 5f74 3a3a 6578 6365 7074 696f tion_t::exceptio │ │ │ -0005e210: 6e3b 0a09 097d 0a09 0963 6174 6368 2028 n;...}...catch ( │ │ │ -0005e220: 7374 643a 3a65 7863 6570 7469 6f6e 2063 std::exception c │ │ │ -0005e230: 6f6e 7374 2661 6d70 3b29 0a09 097b 0a09 onst&)...{.. │ │ │ -0005e240: 0909 7265 7420 3d20 6469 736b 5f73 7461 ..ret = disk_sta │ │ │ -0005e250: 7475 733a 3a66 6174 616c 5f64 6973 6b5f tus::fatal_disk_ │ │ │ -0005e260: 6572 726f 723b 0a09 0909 6a2d 2667 743b error;....j-> │ │ │ -0005e270: 6572 726f 722e 6563 203d 2062 6f6f 7374 error.ec = boost │ │ │ -0005e280: 3a3a 6173 696f 3a3a 6572 726f 723a 3a66 ::asio::error::f │ │ │ -0005e290: 6175 6c74 3b0a 0909 096a 2d26 6774 3b65 ault;....j->e │ │ │ -0005e2a0: 7272 6f72 2e6f 7065 7261 7469 6f6e 203d rror.operation = │ │ │ -0005e2b0: 206f 7065 7261 7469 6f6e 5f74 3a3a 6578 operation_t::ex │ │ │ -0005e2c0: 6365 7074 696f 6e3b 0a09 097d 0a0a 0909 ception;...}.... │ │ │ -0005e2d0: 2f2f 206e 6f74 6520 7468 6174 202d 3220 // note that -2 │ │ │ -0005e2e0: 6572 726f 7273 2061 7265 204f 4b0a 0909 errors are OK... │ │ │ -0005e2f0: 544f 5252 454e 545f 4153 5345 5254 2821 TORRENT_ASSERT(! │ │ │ -0005e300: 2872 6574 2026 616d 703b 2064 6973 6b5f (ret & disk_ │ │ │ -0005e310: 7374 6174 7573 3a3a 6661 7461 6c5f 6469 status::fatal_di │ │ │ -0005e320: 736b 5f65 7272 6f72 290a 0909 097c 7c20 sk_error)....|| │ │ │ -0005e330: 286a 2d26 6774 3b65 7272 6f72 2e65 6320 (j->error.ec │ │ │ -0005e340: 2661 6d70 3b26 616d 703b 206a 2d26 6774 && j-> │ │ │ -0005e350: 3b65 7272 6f72 2e6f 7065 7261 7469 6f6e ;error.operation │ │ │ -0005e360: 2021 3d20 6f70 6572 6174 696f 6e5f 743a != operation_t: │ │ │ -0005e370: 3a75 6e6b 6e6f 776e 2929 3b0a 0a09 096d :unknown));....m │ │ │ -0005e380: 5f73 7461 7473 5f63 6f75 6e74 6572 732e _stats_counters. │ │ │ -0005e390: 696e 635f 7374 6174 735f 636f 756e 7465 inc_stats_counte │ │ │ -0005e3a0: 7228 636f 756e 7465 7273 3a3a 6e75 6d5f r(counters::num_ │ │ │ -0005e3b0: 7275 6e6e 696e 675f 6469 736b 5f6a 6f62 running_disk_job │ │ │ -0005e3c0: 732c 202d 3129 3b0a 0a09 096a 2d26 6774 s, -1);....j-> │ │ │ -0005e3d0: 3b72 6574 203d 2072 6574 3b0a 3c2f 7072 ;ret = ret;.rel │ │ │ -0005e410: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/mm │ │ │ -0005e450: 6170 5f64 6973 6b5f 696f 2e63 7070 3a38 ap_disk_io.cpp:8 │ │ │ -0005e460: 3536 3c2f 613e 3c2f 7464 3e3c 7464 3e74 56t │ │ │ -0005e470: 6869 7320 6973 2070 6f74 656e 7469 616c his is potential │ │ │ -0005e480: 6c79 2076 6572 7920 6578 7065 6e73 6976 ly very expensiv │ │ │ -0005e490: 652e 204f 6e65 2077 6179 2074 6f20 736f e. One way to so │ │ │ -0005e4a0: 6c76 6520 6974 2077 6f75 6c64 2062 6520 lve it would be │ │ │ -0005e4b0: 746f 2068 6176 6520 6120 6665 6e63 6520 to have a fence │ │ │ -0005e4c0: 666f 7220 6a75 7374 2074 6869 7320 6f6e for just this on │ │ │ -0005e4d0: 6520 7069 6563 652e 2062 7574 2069 7420 e piece. but it │ │ │ -0005e4e0: 6861 7264 6c79 2073 6565 6d73 2077 6f72 hardly seems wor │ │ │ -0005e4f0: 7468 2074 6865 2063 6f6d 706c 6578 6974 th the complexit │ │ │ -0005e500: 7920 616e 6420 636f 7374 206a 7573 7420 y and cost just │ │ │ -0005e510: 666f 7220 7468 6520 6564 6765 2063 6173 for the edge cas │ │ │ -0005e520: 6520 6f66 2072 6563 6569 7669 6e67 2061 e of receiving a │ │ │ -0005e530: 2063 6f72 7275 7074 2070 6965 6365 3c2f corrupt piece

    this │ │ │ -0005e590: 2069 7320 706f 7465 6e74 6961 6c6c 7920 is potentially │ │ │ -0005e5a0: 7665 7279 2065 7870 656e 7369 7665 2e20 very expensive. │ │ │ -0005e5b0: 4f6e 6520 7761 7920 746f 2073 6f6c 7665 One way to solve │ │ │ -0005e5c0: 0a69 7420 776f 756c 6420 6265 2074 6f20 .it would be to │ │ │ -0005e5d0: 6861 7665 2061 2066 656e 6365 2066 6f72 have a fence for │ │ │ -0005e5e0: 206a 7573 7420 7468 6973 206f 6e65 2070 just this one p │ │ │ -0005e5f0: 6965 6365 2e0a 6275 7420 6974 2068 6172 iece..but it har │ │ │ -0005e600: 646c 7920 7365 656d 7320 776f 7274 6820 dly seems worth │ │ │ -0005e610: 7468 6520 636f 6d70 6c65 7869 7479 2061 the complexity a │ │ │ -0005e620: 6e64 2063 6f73 7420 6a75 7374 2066 6f72 nd cost just for │ │ │ -0005e630: 2074 6865 2065 6467 650a 6361 7365 206f the edge.case o │ │ │ -0005e640: 6620 7265 6365 6976 696e 6720 6120 636f f receiving a co │ │ │ -0005e650: 7272 7570 7420 7069 6563 653c 2f68 323e rrupt piece

    │ │ │ -0005e660: 3c68 343e 2e2e 2f73 7263 2f6d 6d61 705f

    ../src/mmap_ │ │ │ -0005e670: 6469 736b 5f69 6f2e 6370 703a 3835 363c disk_io.cpp:856< │ │ │ -0005e680: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0005e6c0: 0973 7464 3a3a 6d6f 7665 2870 7269 6f73  .std::move(prios
    │ │ │ -0005e6d0: 290a 0909 293b 0a0a 0909 6164 645f 6665  )...);....add_fe
    │ │ │ -0005e6e0: 6e63 655f 6a6f 6228 6a29 3b0a 097d 0a0a  nce_job(j);..}..
    │ │ │ -0005e6f0: 0976 6f69 6420 6d6d 6170 5f64 6973 6b5f  .void mmap_disk_
    │ │ │ -0005e700: 696f 3a3a 6173 796e 635f 636c 6561 725f  io::async_clear_
    │ │ │ -0005e710: 7069 6563 6528 7374 6f72 6167 655f 696e  piece(storage_in
    │ │ │ -0005e720: 6465 785f 7420 636f 6e73 7420 7374 6f72  dex_t const stor
    │ │ │ -0005e730: 6167 650a 0909 2c20 7069 6563 655f 696e  age..., piece_in
    │ │ │ -0005e740: 6465 785f 7420 636f 6e73 7420 696e 6465  dex_t const inde
    │ │ │ -0005e750: 782c 2073 7464 3a3a 6675 6e63 7469 6f6e  x, std::function
    │ │ │ -0005e760: 266c 743b 766f 6964 2870 6965 6365 5f69  <void(piece_i
    │ │ │ -0005e770: 6e64 6578 5f74 2926 6774 3b20 6861 6e64  ndex_t)> hand
    │ │ │ -0005e780: 6c65 7229 0a09 7b0a 0909 6175 783a 3a6d  ler)..{...aux::m
    │ │ │ -0005e790: 6d61 705f 6469 736b 5f6a 6f62 2a20 6a20  map_disk_job* j 
    │ │ │ -0005e7a0: 3d20 6d5f 6a6f 625f 706f 6f6c 2e61 6c6c  = m_job_pool.all
    │ │ │ -0005e7b0: 6f63 6174 655f 6a6f 6226 6c74 3b61 7578  ocate_job<aux
    │ │ │ -0005e7c0: 3a3a 6a6f 623a 3a63 6c65 6172 5f70 6965  ::job::clear_pie
    │ │ │ -0005e7d0: 6365 2667 743b 280a 0909 097b 7d2c 0a09  ce>(....{},..
    │ │ │ -0005e7e0: 0909 6d5f 746f 7272 656e 7473 5b73 746f  ..m_torrents[sto
    │ │ │ -0005e7f0: 7261 6765 5d2d 2667 743b 7368 6172 6564  rage]->shared
    │ │ │ -0005e800: 5f66 726f 6d5f 7468 6973 2829 2c0a 0909  _from_this(),...
    │ │ │ -0005e810: 0973 7464 3a3a 6d6f 7665 2868 616e 646c  .std::move(handl
    │ │ │ -0005e820: 6572 292c 0a09 0909 696e 6465 780a 0909  er),....index...
    │ │ │ -0005e830: 293b 0a0a 0909 2f2f 2072 6567 756c 6172  );....// regular
    │ │ │ -0005e840: 206a 6f62 7320 6172 6520 6e6f 7420 6775   jobs are not gu
    │ │ │ -0005e850: 6172 616e 7465 6564 2074 6f20 6265 2065  aranteed to be e
    │ │ │ -0005e860: 7865 6375 7465 6420 696e 2d6f 7264 6572  xecuted in-order
    │ │ │ -0005e870: 0a09 092f 2f20 7369 6e63 6520 636c 6561  ...// since clea
    │ │ │ -0005e880: 7220 7069 6563 6520 6d75 7374 2067 7561  r piece must gua
    │ │ │ -0005e890: 7261 6e74 6565 2074 6861 7420 616c 6c20  rantee that all 
    │ │ │ -0005e8a0: 7772 6974 6520 6a6f 6273 2074 6861 740a  write jobs that.
    │ │ │ -0005e8b0: 0909 2f2f 2068 6176 6520 6265 656e 2069  ..// have been i
    │ │ │ -0005e8c0: 7373 7565 6420 6669 6e69 7368 2062 6566  ssued finish bef
    │ │ │ -0005e8d0: 6f72 6520 7468 6520 636c 6561 7220 7069  ore the clear pi
    │ │ │ -0005e8e0: 6563 6520 6a6f 6220 636f 6d70 6c65 7465  ece job complete
    │ │ │ -0005e8f0: 730a 0a3c 6469 7620 7374 796c 653d 2262  s..
    .
    relevan │ │ │ -0005e960: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/mmap_d │ │ │ -0005e9a0: 6973 6b5f 696f 2e63 7070 3a38 3631 3c2f isk_io.cpp:861Perha │ │ │ -0005e9c0: 7073 2074 6865 206a 6f62 2071 7565 7565 ps the job queue │ │ │ -0005e9d0: 2063 6f75 6c64 2062 6520 7472 6176 6572 could be traver │ │ │ -0005e9e0: 7365 6420 616e 6420 616c 6c20 6a6f 6273 sed and all jobs │ │ │ -0005e9f0: 2066 6f72 2074 6869 7320 7069 6563 6520 for this piece │ │ │ -0005ea00: 636f 756c 6420 6265 2063 616e 6365 6c6c could be cancell │ │ │ -0005ea10: 6564 2e20 4966 2074 6865 7265 2061 7265 ed. If there are │ │ │ -0005ea20: 206e 6f20 7468 7265 6164 7320 6375 7272 no threads curr │ │ │ -0005ea30: 656e 746c 7920 7772 6974 696e 6720 746f ently writing to │ │ │ -0005ea40: 2074 6869 7320 7069 6563 652c 2077 6520 this piece, we │ │ │ -0005ea50: 636f 756c 6420 736b 6970 2074 6865 2066 could skip the f │ │ │ -0005ea60: 656e 6365 2061 6c74 6f67 6574 6865 723c ence altogether< │ │ │ -0005ea70: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    Per │ │ │ -0005eac0: 6861 7073 2074 6865 206a 6f62 2071 7565 haps the job que │ │ │ -0005ead0: 7565 2063 6f75 6c64 2062 6520 7472 6176 ue could be trav │ │ │ -0005eae0: 6572 7365 6420 616e 6420 616c 6c20 6a6f ersed and all jo │ │ │ -0005eaf0: 6273 2066 6f72 2074 6869 730a 7069 6563 bs for this.piec │ │ │ -0005eb00: 6520 636f 756c 6420 6265 2063 616e 6365 e could be cance │ │ │ -0005eb10: 6c6c 6564 2e20 4966 2074 6865 7265 2061 lled. If there a │ │ │ -0005eb20: 7265 206e 6f20 7468 7265 6164 7320 6375 re no threads cu │ │ │ -0005eb30: 7272 656e 746c 7920 7772 6974 696e 670a rrently writing. │ │ │ -0005eb40: 746f 2074 6869 7320 7069 6563 652c 2077 to this piece, w │ │ │ -0005eb50: 6520 636f 756c 6420 736b 6970 2074 6865 e could skip the │ │ │ -0005eb60: 2066 656e 6365 2061 6c74 6f67 6574 6865 fence altogethe │ │ │ -0005eb70: 723c 2f68 323e 3c68 343e 2e2e 2f73 7263 r

    ../src │ │ │ -0005eb80: 2f6d 6d61 705f 6469 736b 5f69 6f2e 6370 /mmap_disk_io.cp │ │ │ -0005eb90: 703a 3836 313c 2f68 343e 3c70 7265 2073 p:861

    ..);....add_
    │ │ │ -0005ebe0: 6665 6e63 655f 6a6f 6228 6a29 3b0a 097d  fence_job(j);..}
    │ │ │ -0005ebf0: 0a0a 0976 6f69 6420 6d6d 6170 5f64 6973  ...void mmap_dis
    │ │ │ -0005ec00: 6b5f 696f 3a3a 6173 796e 635f 636c 6561  k_io::async_clea
    │ │ │ -0005ec10: 725f 7069 6563 6528 7374 6f72 6167 655f  r_piece(storage_
    │ │ │ -0005ec20: 696e 6465 785f 7420 636f 6e73 7420 7374  index_t const st
    │ │ │ -0005ec30: 6f72 6167 650a 0909 2c20 7069 6563 655f  orage..., piece_
    │ │ │ -0005ec40: 696e 6465 785f 7420 636f 6e73 7420 696e  index_t const in
    │ │ │ -0005ec50: 6465 782c 2073 7464 3a3a 6675 6e63 7469  dex, std::functi
    │ │ │ -0005ec60: 6f6e 266c 743b 766f 6964 2870 6965 6365  on<void(piece
    │ │ │ -0005ec70: 5f69 6e64 6578 5f74 2926 6774 3b20 6861  _index_t)> ha
    │ │ │ -0005ec80: 6e64 6c65 7229 0a09 7b0a 0909 6175 783a  ndler)..{...aux:
    │ │ │ -0005ec90: 3a6d 6d61 705f 6469 736b 5f6a 6f62 2a20  :mmap_disk_job* 
    │ │ │ -0005eca0: 6a20 3d20 6d5f 6a6f 625f 706f 6f6c 2e61  j = m_job_pool.a
    │ │ │ -0005ecb0: 6c6c 6f63 6174 655f 6a6f 6226 6c74 3b61  llocate_job<a
    │ │ │ -0005ecc0: 7578 3a3a 6a6f 623a 3a63 6c65 6172 5f70  ux::job::clear_p
    │ │ │ -0005ecd0: 6965 6365 2667 743b 280a 0909 097b 7d2c  iece>(....{},
    │ │ │ -0005ece0: 0a09 0909 6d5f 746f 7272 656e 7473 5b73  ....m_torrents[s
    │ │ │ -0005ecf0: 746f 7261 6765 5d2d 2667 743b 7368 6172  torage]->shar
    │ │ │ -0005ed00: 6564 5f66 726f 6d5f 7468 6973 2829 2c0a  ed_from_this(),.
    │ │ │ -0005ed10: 0909 0973 7464 3a3a 6d6f 7665 2868 616e  ...std::move(han
    │ │ │ -0005ed20: 646c 6572 292c 0a09 0909 696e 6465 780a  dler),....index.
    │ │ │ -0005ed30: 0909 293b 0a0a 0909 2f2f 2072 6567 756c  ..);....// regul
    │ │ │ -0005ed40: 6172 206a 6f62 7320 6172 6520 6e6f 7420  ar jobs are not 
    │ │ │ -0005ed50: 6775 6172 616e 7465 6564 2074 6f20 6265  guaranteed to be
    │ │ │ -0005ed60: 2065 7865 6375 7465 6420 696e 2d6f 7264   executed in-ord
    │ │ │ -0005ed70: 6572 0a09 092f 2f20 7369 6e63 6520 636c  er...// since cl
    │ │ │ -0005ed80: 6561 7220 7069 6563 6520 6d75 7374 2067  ear piece must g
    │ │ │ -0005ed90: 7561 7261 6e74 6565 2074 6861 7420 616c  uarantee that al
    │ │ │ -0005eda0: 6c20 7772 6974 6520 6a6f 6273 2074 6861  l write jobs tha
    │ │ │ -0005edb0: 740a 0909 2f2f 2068 6176 6520 6265 656e  t...// have been
    │ │ │ -0005edc0: 2069 7373 7565 6420 6669 6e69 7368 2062   issued finish b
    │ │ │ -0005edd0: 6566 6f72 6520 7468 6520 636c 6561 7220  efore the clear 
    │ │ │ -0005ede0: 7069 6563 6520 6a6f 6220 636f 6d70 6c65  piece job comple
    │ │ │ -0005edf0: 7465 730a 0a0a 3c64 6976 2073 7479 6c65  tes...
    ..add_fence_ │ │ │ -0005ee30: 6a6f 6228 6a29 3b0a 3c2f 6469 763e 097d job(j);.
    .} │ │ │ -0005ee40: 0a0a 0973 7461 7475 735f 7420 6d6d 6170 ...status_t mmap │ │ │ -0005ee50: 5f64 6973 6b5f 696f 3a3a 646f 5f6a 6f62 _disk_io::do_job │ │ │ -0005ee60: 2861 7578 3a3a 6a6f 623a 3a68 6173 6826 (aux::job::hash& │ │ │ -0005ee70: 616d 703b 2061 2c20 6175 783a 3a6d 6d61 amp; a, aux::mma │ │ │ -0005ee80: 705f 6469 736b 5f6a 6f62 2a20 6a29 0a09 p_disk_job* j).. │ │ │ -0005ee90: 7b0a 0909 2f2f 2077 6527 7265 206e 6f74 {...// we're not │ │ │ -0005eea0: 2075 7369 6e67 2061 2063 6163 6865 2e20 using a cache. │ │ │ -0005eeb0: 5468 6973 2069 7320 7468 6520 7369 6d70 This is the simp │ │ │ -0005eec0: 6c65 2070 6174 680a 0909 2f2f 206a 7573 le path...// jus │ │ │ -0005eed0: 7420 7265 6164 2073 7472 6169 6768 7420 t read straight │ │ │ -0005eee0: 6672 6f6d 2074 6865 2066 696c 650a 0909 from the file... │ │ │ -0005eef0: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ -0005ef00: 5f6d 6167 6963 203d 3d20 3078 3133 3337 _magic == 0x1337 │ │ │ -0005ef10: 293b 0a0a 0909 626f 6f6c 2063 6f6e 7374 );....bool const │ │ │ -0005ef20: 2076 3120 3d20 626f 6f6c 286a 2d26 6774 v1 = bool(j-> │ │ │ -0005ef30: 3b66 6c61 6773 2026 616d 703b 2064 6973 ;flags & dis │ │ │ -0005ef40: 6b5f 696e 7465 7266 6163 653a 3a76 315f k_interface::v1_ │ │ │ -0005ef50: 6861 7368 293b 0a09 0962 6f6f 6c20 636f hash);...bool co │ │ │ -0005ef60: 6e73 7420 7632 203d 2021 612e 626c 6f63 nst v2 = !a.bloc │ │ │ -0005ef70: 6b5f 6861 7368 6573 2e65 6d70 7479 2829 k_hashes.empty() │ │ │ -0005ef80: 3b0a 0a09 0969 6e74 2063 6f6e 7374 2070 ;....int const p │ │ │ -0005ef90: 6965 6365 5f73 697a 6520 3d20 7631 203f iece_size = v1 ? │ │ │ -0005efa0: 206a 2d26 6774 3b73 746f 7261 6765 2d26 j->storage-& │ │ │ -0005efb0: 6774 3b66 696c 6573 2829 2e70 6965 6365 gt;files().piece │ │ │ -0005efc0: 5f73 697a 6528 612e 7069 6563 6529 203a _size(a.piece) : │ │ │ -0005efd0: 2030 3b0a 0909 696e 7420 636f 6e73 7420 0;...int const │ │ │ -0005efe0: 7069 6563 655f 7369 7a65 3220 3d20 7632 piece_size2 = v2 │ │ │ -0005eff0: 203f 206a 2d26 6774 3b73 746f 7261 6765 ? j->storage │ │ │ -0005f000: 2d26 6774 3b66 696c 6573 2829 2e70 6965 ->files().pie │ │ │ -0005f010: 6365 5f73 697a 6532 2861 2e70 6965 6365 ce_size2(a.piece │ │ │ -0005f020: 2920 3a20 303b 0a09 0969 6e74 2063 6f6e ) : 0;...int con │ │ │ -0005f030: 7374 2062 6c6f 636b 735f 696e 5f70 6965 st blocks_in_pie │ │ │ -0005f040: 6365 203d 2076 3120 3f20 2870 6965 6365 ce = v1 ? (piece │ │ │ -0005f050: 5f73 697a 6520 2b20 6465 6661 756c 745f _size + default_ │ │ │ -0005f060: 626c 6f63 6b5f 7369 7a65 202d 2031 2920 block_size - 1) │ │ │ -0005f070: 2f20 6465 6661 756c 745f 626c 6f63 6b5f / default_block_ │ │ │ -0005f080: 7369 7a65 203a 2030 3b0a 0909 696e 7420 size : 0;...int │ │ │ -0005f090: 636f 6e73 7420 626c 6f63 6b73 5f69 6e5f const blocks_in_ │ │ │ -0005f0a0: 7069 6563 6532 203d 2076 3220 3f20 6a2d piece2 = v2 ? j- │ │ │ -0005f0b0: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ -0005f0c0: 6669 6c65 7328 292e 626c 6f63 6b73 5f69 files().blocks_i │ │ │ -0005f0d0: 6e5f 7069 6563 6532 2861 2e70 6965 6365 n_piece2(a.piece │ │ │ -0005f0e0: 2920 3a20 303b 0a09 0961 7578 3a3a 6f70 ) : 0;...aux::op │ │ │ -0005f0f0: 656e 5f6d 6f64 655f 7420 636f 6e73 7420 en_mode_t const │ │ │ -0005f100: 6669 6c65 5f6d 6f64 6520 3d20 6669 6c65 file_mode = file │ │ │ -0005f110: 5f6d 6f64 655f 666f 725f 6a6f 6228 6a29 _mode_for_job(j) │ │ │ -0005f120: 3b0a 0a09 0954 4f52 5245 4e54 5f41 5353 ;....TORRENT_ASS │ │ │ -0005f130: 4552 5428 2176 3220 7c7c 2069 6e74 2861 ERT(!v2 || int(a │ │ │ -0005f140: 2e62 6c6f 636b 5f68 6173 6865 732e 7369 .block_hashes.si │ │ │ -0005f150: 7a65 2829 2920 2667 743b 3d20 626c 6f63 ze()) >= bloc │ │ │ -0005f160: 6b73 5f69 6e5f 7069 6563 6532 293b 0a09 ks_in_piece2);.. │ │ │ -0005f170: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0005f180: 7631 207c 7c20 7632 293b 0a0a 0909 2f2f v1 || v2);....// │ │ │ -0005f190: 2063 6f6e 7375 6d65 2053 4841 2d32 3536 consume SHA-256 │ │ │ -0005f1a0: 2068 6173 6865 7320 636f 6d70 7574 6564 hashes computed │ │ │ -0005f1b0: 2069 6e6c 696e 6520 6475 7269 6e67 2064 inline during d │ │ │ -0005f1c0: 6f5f 6a6f 6228 7772 6974 6529 3b20 666f o_job(write); fo │ │ │ -0005f1d0: 7220 616e 790a 0909 2f2f 2062 6c6f 636b r any...// block │ │ │ -0005f1e0: 2077 6865 7265 2077 6520 646f 6e27 7420 where we don't │ │ │ -0005f1f0: 6861 7665 206f 6e65 2028 616e 2061 6c6c have one (an all │ │ │ -0005f200: 2d7a 6572 6f20 656e 7472 7929 2c20 6661 -zero entry), fa │ │ │ -0005f210: 6c6c 2074 6872 6f75 6768 2074 6f20 7468 ll through to th │ │ │ -0005f220: 650a 0909 2f2f 2065 7869 7374 696e 6720 e...// existing │ │ │ -0005f230: 7061 7468 0a09 0961 7578 3a3a 7665 6374 path...aux::vect │ │ │ -0005f240: 6f72 266c 743b 7368 6132 3536 5f68 6173 or<sha256_has │ │ │ -0005f250: 6826 6774 3b20 636f 6e73 7420 7063 203d h> const pc = │ │ │ -0005f260: 0a09 0909 7632 203f 206a 2d26 6774 3b73 ....v2 ? j->s │ │ │ -0005f270: 746f 7261 6765 2d26 6774 3b74 616b 655f torage->take_ │ │ │ -0005f280: 7072 6563 6f6d 7075 7465 645f 7632 2861 precomputed_v2(a │ │ │ -0005f290: 2e70 6965 6365 2920 3a20 6175 783a 3a76 .piece) : aux::v │ │ │ -0005f2a0: 6563 746f 7226 6c74 3b73 6861 3235 365f ector<sha256_ │ │ │ -0005f2b0: 6861 7368 2667 743b 7b7d 3b0a 0a09 0968 hash>{};....h │ │ │ -0005f2c0: 6173 6865 7220 683b 0a09 0969 6e74 2072 asher h;...int r │ │ │ -0005f2d0: 6574 203d 2030 3b0a 0909 696e 7420 6f66 et = 0;...int of │ │ │ -0005f2e0: 6673 6574 203d 2030 3b0a 0909 696e 7420 fset = 0;...int │ │ │ -0005f2f0: 636f 6e73 7420 626c 6f63 6b73 5f74 6f5f const blocks_to_ │ │ │ -0005f300: 7265 6164 203d 2073 7464 3a3a 6d61 7828 read = std::max( │ │ │ -0005f310: 626c 6f63 6b73 5f69 6e5f 7069 6563 652c blocks_in_piece, │ │ │ -0005f320: 2062 6c6f 636b 735f 696e 5f70 6965 6365 blocks_in_piece │ │ │ -0005f330: 3229 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2);.
    < │ │ │ -0005f340: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0005f370: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0
    . │ │ │ -0005f3a0: 2e2f 7372 632f 7365 7373 696f 6e2e 6370 ./src/session.cp │ │ │ -0005f3b0: 703a 3236 313c 2f61 3e3c 2f74 643e 3c74 p:261start() should │ │ │ -0005f3d0: 206a 7573 7420 7573 6520 666c 6167 7320 just use flags │ │ │ -0005f3e0: 6f75 7420 6f66 2074 6865 2073 6573 7369 out of the sessi │ │ │ -0005f3f0: 6f6e 5f70 6172 616d 7320 6f62 6a65 6374 on_params object │ │ │ -0005f400: 2c3c 2f74 643e 3c2f 7472 3e3c 7472 2069 ,

    s │ │ │ -0005f450: 7461 7274 2829 2073 686f 756c 6420 6a75 tart() should ju │ │ │ -0005f460: 7374 2075 7365 2066 6c61 6773 206f 7574 st use flags out │ │ │ -0005f470: 206f 6620 7468 6520 7365 7373 696f 6e5f of the session_ │ │ │ -0005f480: 7061 7261 6d73 206f 626a 6563 742c 3c2f params object,

    ../src/se │ │ │ -0005f4a0: 7373 696f 6e2e 6370 703a 3236 313c 2f68 ssion.cpp:261
    ..SE
    │ │ │ -0005f4f0: 545f 424f 4f4c 2872 6573 7472 6963 745f  T_BOOL(restrict_
    │ │ │ -0005f500: 726f 7574 696e 675f 6970 7329 3b0a 0909  routing_ips);...
    │ │ │ -0005f510: 5345 545f 424f 4f4c 2872 6573 7472 6963  SET_BOOL(restric
    │ │ │ -0005f520: 745f 7365 6172 6368 5f69 7073 293b 0a09  t_search_ips);..
    │ │ │ -0005f530: 0953 4554 5f42 4f4f 4c28 6578 7465 6e64  .SET_BOOL(extend
    │ │ │ -0005f540: 6564 5f72 6f75 7469 6e67 5f74 6162 6c65  ed_routing_table
    │ │ │ -0005f550: 293b 0a09 0953 4554 5f42 4f4f 4c28 6167  );...SET_BOOL(ag
    │ │ │ -0005f560: 6772 6573 7369 7665 5f6c 6f6f 6b75 7073  gressive_lookups
    │ │ │ -0005f570: 293b 0a09 0953 4554 5f42 4f4f 4c28 7072  );...SET_BOOL(pr
    │ │ │ -0005f580: 6976 6163 795f 6c6f 6f6b 7570 7329 3b0a  ivacy_lookups);.
    │ │ │ -0005f590: 0909 5345 545f 424f 4f4c 2865 6e66 6f72  ..SET_BOOL(enfor
    │ │ │ -0005f5a0: 6365 5f6e 6f64 655f 6964 293b 0a09 0953  ce_node_id);...S
    │ │ │ -0005f5b0: 4554 5f42 4f4f 4c28 6967 6e6f 7265 5f64  ET_BOOL(ignore_d
    │ │ │ -0005f5c0: 6172 6b5f 696e 7465 726e 6574 293b 0a09  ark_internet);..
    │ │ │ -0005f5d0: 0953 4554 5f49 4e54 2862 6c6f 636b 5f74  .SET_INT(block_t
    │ │ │ -0005f5e0: 696d 656f 7574 293b 0a09 0953 4554 5f49  imeout);...SET_I
    │ │ │ -0005f5f0: 4e54 2862 6c6f 636b 5f72 6174 656c 696d  NT(block_ratelim
    │ │ │ -0005f600: 6974 293b 0a09 0953 4554 5f42 4f4f 4c28  it);...SET_BOOL(
    │ │ │ -0005f610: 7265 6164 5f6f 6e6c 7929 3b0a 0909 5345  read_only);...SE
    │ │ │ -0005f620: 545f 494e 5428 6974 656d 5f6c 6966 6574  T_INT(item_lifet
    │ │ │ -0005f630: 696d 6529 3b0a 0909 5345 545f 494e 5428  ime);...SET_INT(
    │ │ │ -0005f640: 7570 6c6f 6164 5f72 6174 655f 6c69 6d69  upload_rate_limi
    │ │ │ -0005f650: 7429 3b0a 0909 5345 545f 494e 5428 7361  t);...SET_INT(sa
    │ │ │ -0005f660: 6d70 6c65 5f69 6e66 6f68 6173 6865 735f  mple_infohashes_
    │ │ │ -0005f670: 696e 7465 7276 616c 293b 0a09 0953 4554  interval);...SET
    │ │ │ -0005f680: 5f49 4e54 286d 6178 5f69 6e66 6f68 6173  _INT(max_infohas
    │ │ │ -0005f690: 6865 735f 7361 6d70 6c65 5f63 6f75 6e74  hes_sample_count
    │ │ │ -0005f6a0: 293b 0a23 756e 6465 6620 5345 545f 424f  );.#undef SET_BO
    │ │ │ -0005f6b0: 4f4c 0a23 756e 6465 6620 5345 545f 494e  OL.#undef SET_IN
    │ │ │ -0005f6c0: 540a 0909 7d0a 2365 6e64 6966 0a23 656e  T...}.#endif.#en
    │ │ │ -0005f6d0: 6469 660a 0a3c 6469 7620 7374 796c 653d  dif..
    ..m_impl = st │ │ │ -0005f710: 643a 3a6d 616b 655f 7368 6172 6564 266c d::make_shared&l │ │ │ -0005f720: 743b 6175 783a 3a73 6573 7369 6f6e 5f69 t;aux::session_i │ │ │ -0005f730: 6d70 6c26 6774 3b28 7374 643a 3a72 6566 mpl>(std::ref │ │ │ -0005f740: 282a 696f 7329 0a3c 2f64 6976 3e09 0909 (*ios).
    ... │ │ │ -0005f750: 2c20 7374 643a 3a6d 6f76 6528 7061 7261 , std::move(para │ │ │ -0005f760: 6d73 2e73 6574 7469 6e67 7329 0a09 0909 ms.settings).... │ │ │ -0005f770: 2c20 7374 643a 3a6d 6f76 6528 7061 7261 , std::move(para │ │ │ -0005f780: 6d73 2e64 6973 6b5f 696f 5f63 6f6e 7374 ms.disk_io_const │ │ │ -0005f790: 7275 6374 6f72 290a 0909 092c 2066 6c61 ructor)...., fla │ │ │ -0005f7a0: 6773 293b 0a09 092a 7374 6174 6963 5f63 gs);...*static_c │ │ │ -0005f7b0: 6173 7426 6c74 3b73 6573 7369 6f6e 5f68 ast<session_h │ │ │ -0005f7c0: 616e 646c 652a 2667 743b 2874 6869 7329 andle*>(this) │ │ │ -0005f7d0: 203d 2073 6573 7369 6f6e 5f68 616e 646c = session_handl │ │ │ -0005f7e0: 6528 6d5f 696d 706c 293b 0a0a 2369 666e e(m_impl);..#ifn │ │ │ -0005f7f0: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -0005f800: 424c 455f 4558 5445 4e53 494f 4e53 0a09 BLE_EXTENSIONS.. │ │ │ -0005f810: 0966 6f72 2028 6175 746f 2661 6d70 3b20 .for (auto& │ │ │ -0005f820: 6578 7420 3a20 7061 7261 6d73 2e65 7874 ext : params.ext │ │ │ -0005f830: 656e 7369 6f6e 7329 0a09 097b 0a09 0909 ensions)...{.... │ │ │ -0005f840: 6578 742d 2667 743b 6c6f 6164 5f73 7461 ext->load_sta │ │ │ -0005f850: 7465 2870 6172 616d 732e 6578 745f 7374 te(params.ext_st │ │ │ -0005f860: 6174 6529 3b0a 0909 096d 5f69 6d70 6c2d ate);....m_impl- │ │ │ -0005f870: 2667 743b 6164 645f 7365 735f 6578 7465 >add_ses_exte │ │ │ -0005f880: 6e73 696f 6e28 7374 643a 3a6d 6f76 6528 nsion(std::move( │ │ │ -0005f890: 6578 7429 293b 0a09 097d 0a23 656e 6469 ext));...}.#endi │ │ │ -0005f8a0: 660a 0a23 6966 6e64 6566 2054 4f52 5245 f..#ifndef TORRE │ │ │ -0005f8b0: 4e54 5f44 4953 4142 4c45 5f44 4854 0a09 NT_DISABLE_DHT.. │ │ │ -0005f8c0: 096d 5f69 6d70 6c2d 2667 743b 7365 745f .m_impl->set_ │ │ │ -0005f8d0: 6468 745f 7374 6174 6528 7374 643a 3a6d dht_state(std::m │ │ │ -0005f8e0: 6f76 6528 7061 7261 6d73 2e64 6874 5f73 ove(params.dht_s │ │ │ -0005f8f0: 7461 7465 2929 3b0a 0a09 0954 4f52 5245 tate));....TORRE │ │ │ -0005f900: 4e54 5f41 5353 4552 5428 7061 7261 6d73 NT_ASSERT(params │ │ │ -0005f910: 2e64 6874 5f73 746f 7261 6765 5f63 6f6e .dht_storage_con │ │ │ -0005f920: 7374 7275 6374 6f72 293b 0a09 096d 5f69 structor);...m_i │ │ │ -0005f930: 6d70 6c2d 2667 743b 7365 745f 6468 745f mpl->set_dht_ │ │ │ -0005f940: 7374 6f72 6167 6528 7374 643a 3a6d 6f76 storage(std::mov │ │ │ -0005f950: 6528 7061 7261 6d73 2e64 6874 5f73 746f e(params.dht_sto │ │ │ -0005f960: 7261 6765 5f63 6f6e 7374 7275 6374 6f72 rage_constructor │ │ │ -0005f970: 2929 3b0a 2365 6e64 6966 0a0a 0909 6966 ));.#endif....if │ │ │ -0005f980: 2028 2170 6172 616d 732e 6970 5f66 696c (!params.ip_fil │ │ │ -0005f990: 7465 722e 656d 7074 7928 2929 0a09 097b ter.empty())...{ │ │ │ -0005f9a0: 0a09 0909 7374 643a 3a73 6861 7265 645f ....std::shared_ │ │ │ -0005f9b0: 7074 7226 6c74 3b69 705f 6669 6c74 6572 ptr<ip_filter │ │ │ -0005f9c0: 2667 743b 2063 6f70 7920 3d20 7374 643a > copy = std: │ │ │ -0005f9d0: 3a6d 616b 655f 7368 6172 6564 266c 743b :make_shared< │ │ │ -0005f9e0: 6970 5f66 696c 7465 7226 6774 3b28 7374 ip_filter>(st │ │ │ -0005f9f0: 643a 3a6d 6f76 6528 7061 7261 6d73 2e69 d::move(params.i │ │ │ -0005fa00: 705f 6669 6c74 6572 2929 3b0a 0909 096d p_filter));....m │ │ │ -0005fa10: 5f69 6d70 6c2d 2667 743b 7365 745f 6970 _impl->set_ip │ │ │ -0005fa20: 5f66 696c 7465 7228 7374 643a 3a6d 6f76 _filter(std::mov │ │ │ -0005fa30: 6528 636f 7079 2929 3b0a 0909 7d0a 0a09 e(copy));...}... │ │ │ -0005fa40: 096d 5f69 6d70 6c2d 2667 743b 7374 6172 .m_impl->star │ │ │ -0005fa50: 745f 7365 7373 696f 6e28 293b 0a0a 0909 t_session();.... │ │ │ -0005fa60: 6966 2028 696e 7465 726e 616c 5f65 7865 if (internal_exe │ │ │ -0005fa70: 6375 746f 7229 0a09 097b 0a3c 2f70 7265 cutor)...{.
    rele │ │ │ -0005fab0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/mag │ │ │ -0005faf0: 6e65 745f 7572 692e 6370 703a 3432 353c net_uri.cpp:425< │ │ │ -0005fb00: 2f61 3e3c 2f74 643e 3c74 643e 7768 6174 /a>what │ │ │ -0005fb10: 2773 2074 6865 2072 6967 6874 206e 756d 's the right num │ │ │ -0005fb20: 6265 7220 6865 7265 3f3c 2f74 643e 3c2f ber here?

    what's th │ │ │ -0005fb80: 6520 7269 6768 7420 6e75 6d62 6572 2068 e right number h │ │ │ -0005fb90: 6572 653f 3c2f 6832 3e3c 6834 3e2e 2e2f ere?

    ../ │ │ │ -0005fba0: 7372 632f 6d61 676e 6574 5f75 7269 2e63 src/magnet_uri.c │ │ │ -0005fbb0: 7070 3a34 3235 3c2f 6834 3e3c 7072 6520 pp:425

    ...}....els
    │ │ │ -0005fc00: 6520 6966 2028 6175 783a 3a73 7472 696e  e if (aux::strin
    │ │ │ -0005fc10: 675f 6571 7561 6c5f 6e6f 5f63 6173 6528  g_equal_no_case(
    │ │ │ -0005fc20: 6e61 6d65 2c20 2273 6f22 5f73 7629 2920  name, "so"_sv)) 
    │ │ │ -0005fc30: 2f2f 2073 656c 6563 742d 6f6e 6c79 2028  // select-only (
    │ │ │ -0005fc40: 6669 6c65 7329 0a09 0909 7b0a 0909 0909  files)....{.....
    │ │ │ -0005fc50: 2f2f 2061 6363 6570 7420 6f6e 6c79 2064  // accept only d
    │ │ │ -0005fc60: 6967 6974 732c 2027 2d27 2061 6e64 2027  igits, '-' and '
    │ │ │ -0005fc70: 2c27 0a09 0909 0969 6620 2873 7464 3a3a  ,'.....if (std::
    │ │ │ -0005fc80: 616e 795f 6f66 2876 616c 7565 2e62 6567  any_of(value.beg
    │ │ │ -0005fc90: 696e 2829 2c20 7661 6c75 652e 656e 6428  in(), value.end(
    │ │ │ -0005fca0: 292c 205b 5d28 6368 6172 2063 290a 0909  ), [](char c)...
    │ │ │ -0005fcb0: 0909 097b 2072 6574 7572 6e20 2161 7578  ...{ return !aux
    │ │ │ -0005fcc0: 3a3a 6973 5f64 6967 6974 2863 2920 2661  ::is_digit(c) &a
    │ │ │ -0005fcd0: 6d70 3b26 616d 703b 2063 2021 3d20 272d  mp;& c != '-
    │ │ │ -0005fce0: 2720 2661 6d70 3b26 616d 703b 2063 2021  ' && c !
    │ │ │ -0005fcf0: 3d20 272c 273b 207d 2929 0a09 0909 0909  = ','; }))......
    │ │ │ -0005fd00: 636f 6e74 696e 7565 3b0a 0a09 0909 092f  continue;....../
    │ │ │ -0005fd10: 2f20 6d61 6b65 2073 7572 6520 616c 6c20  / make sure all 
    │ │ │ -0005fd20: 6669 6c65 2070 7269 6f72 6974 6965 7320  file priorities 
    │ │ │ -0005fd30: 6172 6520 7365 7420 746f 2030 2c20 6578  are set to 0, ex
    │ │ │ -0005fd40: 6365 7074 2074 6865 206f 6e65 730a 0909  cept the ones...
    │ │ │ -0005fd50: 0909 2f2f 2077 6520 7370 6563 6966 7920  ..// we specify 
    │ │ │ -0005fd60: 696e 2074 6865 2066 696c 655f 7072 696f  in the file_prio
    │ │ │ -0005fd70: 7269 7469 6573 0a09 0909 0970 2e66 6c61  rities.....p.fla
    │ │ │ -0005fd80: 6773 207c 3d20 746f 7272 656e 745f 666c  gs |= torrent_fl
    │ │ │ -0005fd90: 6167 733a 3a64 6566 6175 6c74 5f64 6f6e  ags::default_don
    │ │ │ -0005fda0: 745f 646f 776e 6c6f 6164 3b0a 0a09 0909  t_download;.....
    │ │ │ -0005fdb0: 0964 6f0a 0909 0909 7b0a 0909 0909 0973  .do.....{......s
    │ │ │ -0005fdc0: 7472 696e 675f 7669 6577 2074 6f6b 656e  tring_view token
    │ │ │ -0005fdd0: 3b0a 0909 0909 0973 7464 3a3a 7469 6528  ;......std::tie(
    │ │ │ -0005fde0: 746f 6b65 6e2c 2076 616c 7565 2920 3d20  token, value) = 
    │ │ │ -0005fdf0: 6175 783a 3a73 706c 6974 5f73 7472 696e  aux::split_strin
    │ │ │ -0005fe00: 6728 7661 6c75 652c 2027 2c27 293b 0a0a  g(value, ',');..
    │ │ │ -0005fe10: 0909 0909 0969 6620 2874 6f6b 656e 2e65  .....if (token.e
    │ │ │ -0005fe20: 6d70 7479 2829 2920 636f 6e74 696e 7565  mpty()) continue
    │ │ │ -0005fe30: 3b0a 0a09 0909 0909 696e 7420 6964 7831  ;.......int idx1
    │ │ │ -0005fe40: 2c20 6964 7832 3b0a 3c64 6976 2073 7479  , idx2;.
    .....const │ │ │ -0005fe80: 6578 7072 2069 6e74 206d 6178 5f69 6e64 expr int max_ind │ │ │ -0005fe90: 6578 203d 2031 3030 3030 3b20 2f2f 2063 ex = 10000; // c │ │ │ -0005fea0: 616e 2774 2072 6973 6b20 6f75 7420 6f66 an't risk out of │ │ │ -0005feb0: 206d 656d 6f72 790a 3c2f 6469 763e 0a09 memory.
    .. │ │ │ -0005fec0: 0909 0909 6175 746f 2063 6f6e 7374 2064 ....auto const d │ │ │ -0005fed0: 6976 6964 6572 203d 2074 6f6b 656e 2e66 ivider = token.f │ │ │ -0005fee0: 696e 645f 6669 7273 745f 6f66 2827 2d27 ind_first_of('-' │ │ │ -0005fef0: 293b 0a09 0909 0909 6966 2028 6469 7669 );......if (divi │ │ │ -0005ff00: 6465 7220 213d 2073 7464 3a3a 7374 7269 der != std::stri │ │ │ -0005ff10: 6e67 3a3a 6e70 6f73 2920 2f2f 2069 7427 ng::npos) // it' │ │ │ -0005ff20: 7320 6120 7261 6e67 650a 0909 0909 097b s a range......{ │ │ │ -0005ff30: 0a09 0909 0909 0969 6620 2864 6976 6964 .......if (divid │ │ │ -0005ff40: 6572 203d 3d20 3029 202f 2f20 6e6f 2073 er == 0) // no s │ │ │ -0005ff50: 7461 7274 2069 6e64 6578 0a09 0909 0909 tart index...... │ │ │ -0005ff60: 0909 636f 6e74 696e 7565 3b0a 0909 0909 ..continue;..... │ │ │ -0005ff70: 0909 6966 2028 6469 7669 6465 7220 3d3d ..if (divider == │ │ │ -0005ff80: 2074 6f6b 656e 2e73 697a 6528 2920 2d20 token.size() - │ │ │ -0005ff90: 3129 202f 2f20 6e6f 2065 6e64 2069 6e64 1) // no end ind │ │ │ -0005ffa0: 6578 0a09 0909 0909 0909 636f 6e74 696e ex........contin │ │ │ -0005ffb0: 7565 3b0a 0a09 0909 0909 0969 6478 3120 ue;........idx1 │ │ │ -0005ffc0: 3d20 7374 643a 3a61 746f 6928 7374 643a = std::atoi(std: │ │ │ -0005ffd0: 3a73 7472 696e 6728 746f 6b65 6e2e 7375 :string(token.su │ │ │ -0005ffe0: 6273 7472 2830 2c20 6469 7669 6465 7229 bstr(0, divider) │ │ │ -0005fff0: 292e 635f 7374 7228 2929 3b0a 0909 0909 ).c_str());..... │ │ │ -00060000: 0909 6966 2028 6964 7831 2026 6c74 3b20 ..if (idx1 < │ │ │ -00060010: 3020 7c7c 2069 6478 3120 2667 743b 206d 0 || idx1 > m │ │ │ -00060020: 6178 5f69 6e64 6578 2920 2f2f 2069 6e76 ax_index) // inv │ │ │ -00060030: 616c 6964 2069 6e64 6578 0a09 0909 0909 alid index...... │ │ │ -00060040: 0909 636f 6e74 696e 7565 3b0a 0909 0909 ..continue;..... │ │ │ -00060050: 0909 6964 7832 203d 2073 7464 3a3a 6174 ..idx2 = std::at │ │ │ -00060060: 6f69 2873 7464 3a3a 7374 7269 6e67 2874 oi(std::string(t │ │ │ -00060070: 6f6b 656e 2e73 7562 7374 7228 6469 7669 oken.substr(divi │ │ │ -00060080: 6465 7220 2b20 3129 292e 635f 7374 7228 der + 1)).c_str( │ │ │ -00060090: 2929 3b0a 0909 0909 0909 6966 2028 6964 ));.......if (id │ │ │ -000600a0: 7832 2026 6c74 3b20 3020 7c7c 2069 6478 x2 < 0 || idx │ │ │ -000600b0: 3220 2667 743b 206d 6178 5f69 6e64 6578 2 > max_index │ │ │ -000600c0: 2920 2f2f 2069 6e76 616c 6964 2069 6e64 ) // invalid ind │ │ │ -000600d0: 6578 0a09 0909 0909 0909 636f 6e74 696e ex........contin │ │ │ -000600e0: 7565 3b0a 0a09 0909 0909 0969 6620 2869 ue;........if (i │ │ │ -000600f0: 6478 3120 2667 743b 2069 6478 3229 202f dx1 > idx2) / │ │ │ -00060100: 2f20 7772 6f6e 6720 7261 6e67 6520 6c69 / wrong range li │ │ │ -00060110: 6d69 7473 0a09 0909 0909 0909 636f 6e74 mits........cont │ │ │ -00060120: 696e 7565 3b0a 0909 0909 097d 0a09 0909 inue;......}.... │ │ │ -00060130: 0909 656c 7365 202f 2f20 6974 2773 2061 ..else // it's a │ │ │ -00060140: 6e20 696e 6465 780a 0909 0909 097b 0a09 n index......{.. │ │ │ -00060150: 0909 0909 0969 6478 3120 3d20 7374 643a .....idx1 = std: │ │ │ -00060160: 3a61 746f 6928 7374 643a 3a73 7472 696e :atoi(std::strin │ │ │ -00060170: 6728 746f 6b65 6e29 2e63 5f73 7472 2829 g(token).c_str() │ │ │ -00060180: 293b 0a09 0909 0909 0969 6620 2869 6478 );.......if (idx │ │ │ -00060190: 3120 266c 743b 2030 207c 7c20 6964 7831 1 < 0 || idx1 │ │ │ -000601a0: 2026 6774 3b20 6d61 785f 696e 6465 7829 > max_index) │ │ │ -000601b0: 202f 2f20 696e 7661 6c69 6420 696e 6465 // invalid inde │ │ │ -000601c0: 780a 0909 0909 0909 0963 6f6e 7469 6e75 x........continu │ │ │ -000601d0: 653b 0a09 0909 0909 0969 6478 3220 3d20 e;.......idx2 = │ │ │ -000601e0: 6964 7831 3b0a 0909 0909 097d 0a0a 0909 idx1;......}.... │ │ │ -000601f0: 0909 0969 6620 2869 6e74 2870 2e66 696c ...if (int(p.fil │ │ │ -00060200: 655f 7072 696f 7269 7469 6573 2e73 697a e_priorities.siz │ │ │ -00060210: 6528 2929 2026 6c74 3b3d 2069 6478 3229 e()) <= idx2) │ │ │ -00060220: 0a09 0909 0909 0970 2e66 696c 655f 7072 .......p.file_pr │ │ │ -00060230: 696f 7269 7469 6573 2e72 6573 697a 6528 iorities.resize( │ │ │ -00060240: 7374 6174 6963 5f63 6173 7426 6c74 3b73 static_cast<s │ │ │ -00060250: 7464 3a3a 7369 7a65 5f74 2667 743b 2869 td::size_t>(i │ │ │ -00060260: 6478 3229 202b 2031 2c20 646f 6e74 5f64 dx2) + 1, dont_d │ │ │ -00060270: 6f77 6e6c 6f61 6429 3b0a 0a3c 2f70 7265 ownload);..
    rele │ │ │ -000602b0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0
    ../src/udp │ │ │ -000602f0: 5f73 6f63 6b65 742e 6370 703a 3634 333c _socket.cpp:643< │ │ │ -00060300: 2f61 3e3c 2f74 643e 3c74 643e 7065 7268 /a>perh │ │ │ -00060310: 6170 7320 616e 2061 7474 656d 7074 2073 aps an attempt s │ │ │ -00060320: 686f 756c 6420 6265 206d 6164 6520 746f hould be made to │ │ │ -00060330: 2062 696e 6420 6d5f 736f 636b 7335 5f73 bind m_socks5_s │ │ │ -00060340: 6f63 6b20 746f 2074 6865 2064 6576 6963 ock to the devic │ │ │ -00060350: 6520 6f66 206d 5f6c 6973 7465 6e5f 736f e of m_listen_so │ │ │ -00060360: 636b 6574 3c2f 7464 3e3c 2f74 723e 3c74 cketperhaps an att │ │ │ -000603c0: 656d 7074 2073 686f 756c 6420 6265 206d empt should be m │ │ │ -000603d0: 6164 6520 746f 2062 696e 6420 6d5f 736f ade to bind m_so │ │ │ -000603e0: 636b 7335 5f73 6f63 6b20 746f 2074 6865 cks5_sock to the │ │ │ -000603f0: 0a64 6576 6963 6520 6f66 206d 5f6c 6973 .device of m_lis │ │ │ -00060400: 7465 6e5f 736f 636b 6574 3c2f 6832 3e3c ten_socket

    < │ │ │ -00060410: 6834 3e2e 2e2f 7372 632f 7564 705f 736f h4>../src/udp_so │ │ │ -00060420: 636b 6574 2e63 7070 3a36 3433 3c2f 6834 cket.cpp:643

    .if (
    │ │ │ -00060470: 6563 290a 097b 0a09 0969 6620 286d 5f61  ec)..{...if (m_a
    │ │ │ -00060480: 6c65 7274 732e 7368 6f75 6c64 5f70 6f73  lerts.should_pos
    │ │ │ -00060490: 7426 6c74 3b73 6f63 6b73 355f 616c 6572  t<socks5_aler
    │ │ │ -000604a0: 7426 6774 3b28 2929 0a09 0909 6d5f 616c  t>())....m_al
    │ │ │ -000604b0: 6572 7473 2e65 6d70 6c61 6365 5f61 6c65  erts.emplace_ale
    │ │ │ -000604c0: 7274 266c 743b 736f 636b 7335 5f61 6c65  rt<socks5_ale
    │ │ │ -000604d0: 7274 2667 743b 286d 5f70 726f 7879 5f61  rt>(m_proxy_a
    │ │ │ -000604e0: 6464 722c 206f 7065 7261 7469 6f6e 5f74  ddr, operation_t
    │ │ │ -000604f0: 3a3a 736f 636b 5f6f 7074 696f 6e2c 2065  ::sock_option, e
    │ │ │ -00060500: 6329 3b0a 0909 6563 2e63 6c65 6172 2829  c);...ec.clear()
    │ │ │ -00060510: 3b0a 097d 0a23 656e 6469 660a 2365 6e64  ;..}.#endif.#end
    │ │ │ -00060520: 6966 0a0a 0974 6370 3a3a 656e 6470 6f69  if...tcp::endpoi
    │ │ │ -00060530: 6e74 2063 6f6e 7374 2062 696e 645f 6570  nt const bind_ep
    │ │ │ -00060540: 286d 5f6c 6973 7465 6e5f 736f 636b 6574  (m_listen_socket
    │ │ │ -00060550: 2e67 6574 5f6c 6f63 616c 5f65 6e64 706f  .get_local_endpo
    │ │ │ -00060560: 696e 7428 292e 6164 6472 6573 7328 292c  int().address(),
    │ │ │ -00060570: 2030 293b 0a09 6d5f 736f 636b 7335 5f73   0);..m_socks5_s
    │ │ │ -00060580: 6f63 6b2e 6269 6e64 2862 696e 645f 6570  ock.bind(bind_ep
    │ │ │ -00060590: 2c20 6563 293b 0a09 6966 2028 6563 290a  , ec);..if (ec).
    │ │ │ -000605a0: 097b 0a09 0969 6620 286d 5f61 6c65 7274  .{...if (m_alert
    │ │ │ -000605b0: 732e 7368 6f75 6c64 5f70 6f73 7426 6c74  s.should_post<
    │ │ │ -000605c0: 3b73 6f63 6b73 355f 616c 6572 7426 6774  ;socks5_alert>
    │ │ │ -000605d0: 3b28 2929 0a09 0909 6d5f 616c 6572 7473  ;())....m_alerts
    │ │ │ -000605e0: 2e65 6d70 6c61 6365 5f61 6c65 7274 266c  .emplace_alert&l
    │ │ │ -000605f0: 743b 736f 636b 7335 5f61 6c65 7274 2667  t;socks5_alert&g
    │ │ │ -00060600: 743b 286d 5f70 726f 7879 5f61 6464 722c  t;(m_proxy_addr,
    │ │ │ -00060610: 206f 7065 7261 7469 6f6e 5f74 3a3a 736f   operation_t::so
    │ │ │ -00060620: 636b 5f62 696e 642c 2065 6329 3b0a 0909  ck_bind, ec);...
    │ │ │ -00060630: 2b2b 6d5f 6661 696c 7572 6573 3b0a 0909  ++m_failures;...
    │ │ │ -00060640: 7265 7472 795f 636f 6e6e 6563 7469 6f6e  retry_connection
    │ │ │ -00060650: 2829 3b0a 0909 7265 7475 726e 3b0a 097d  ();...return;..}
    │ │ │ -00060660: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00060690: 0a3c 2f64 6976 3e09 4144 445f 4f55 5453 .
    .ADD_OUTS │ │ │ -000606a0: 5441 4e44 494e 475f 4153 594e 4328 2273 TANDING_ASYNC("s │ │ │ -000606b0: 6f63 6b73 353a 3a6f 6e5f 636f 6e6e 6563 ocks5::on_connec │ │ │ -000606c0: 7465 6422 293b 0a09 6d5f 736f 636b 7335 ted");..m_socks5 │ │ │ -000606d0: 5f73 6f63 6b2e 6173 796e 635f 636f 6e6e _sock.async_conn │ │ │ -000606e0: 6563 7428 6d5f 7072 6f78 795f 6164 6472 ect(m_proxy_addr │ │ │ -000606f0: 0a09 092c 2073 7464 3a3a 6269 6e64 2826 ..., std::bind(& │ │ │ -00060700: 616d 703b 736f 636b 7335 3a3a 6f6e 5f63 amp;socks5::on_c │ │ │ -00060710: 6f6e 6e65 6374 6564 2c20 7365 6c66 2829 onnected, self() │ │ │ -00060720: 2c20 5f31 2929 3b0a 0a09 4144 445f 4f55 , _1));...ADD_OU │ │ │ -00060730: 5453 5441 4e44 494e 475f 4153 594e 4328 TSTANDING_ASYNC( │ │ │ -00060740: 2273 6f63 6b73 353a 3a6f 6e5f 636f 6e6e "socks5::on_conn │ │ │ -00060750: 6563 745f 7469 6d65 6f75 7422 293b 0a09 ect_timeout");.. │ │ │ -00060760: 6d5f 7469 6d65 722e 6578 7069 7265 735f m_timer.expires_ │ │ │ -00060770: 6166 7465 7228 7365 636f 6e64 7328 3130 after(seconds(10 │ │ │ -00060780: 2929 3b0a 096d 5f74 696d 6572 2e61 7379 ));..m_timer.asy │ │ │ -00060790: 6e63 5f77 6169 7428 7374 643a 3a62 696e nc_wait(std::bin │ │ │ -000607a0: 6428 2661 6d70 3b73 6f63 6b73 353a 3a6f d(&socks5::o │ │ │ -000607b0: 6e5f 636f 6e6e 6563 745f 7469 6d65 6f75 n_connect_timeou │ │ │ -000607c0: 740a 0909 2c20 7365 6c66 2829 2c20 5f31 t..., self(), _1 │ │ │ -000607d0: 2929 3b0a 7d0a 0a76 6f69 6420 736f 636b ));.}..void sock │ │ │ -000607e0: 7335 3a3a 6f6e 5f63 6f6e 6e65 6374 5f74 s5::on_connect_t │ │ │ -000607f0: 696d 656f 7574 2865 7272 6f72 5f63 6f64 imeout(error_cod │ │ │ -00060800: 6520 636f 6e73 7426 616d 703b 2065 290a e const& e). │ │ │ -00060810: 7b0a 0943 4f4d 504c 4554 455f 4153 594e {..COMPLETE_ASYN │ │ │ -00060820: 4328 2273 6f63 6b73 353a 3a6f 6e5f 636f C("socks5::on_co │ │ │ -00060830: 6e6e 6563 745f 7469 6d65 6f75 7422 293b nnect_timeout"); │ │ │ -00060840: 0a0a 0969 6620 2865 203d 3d20 626f 6f73 ...if (e == boos │ │ │ -00060850: 743a 3a61 7369 6f3a 3a65 7272 6f72 3a3a t::asio::error:: │ │ │ -00060860: 6f70 6572 6174 696f 6e5f 6162 6f72 7465 operation_aborte │ │ │ -00060870: 6429 2072 6574 7572 6e3b 0a0a 0969 6620 d) return;...if │ │ │ -00060880: 286d 5f61 626f 7274 2920 7265 7475 726e (m_abort) return │ │ │ -00060890: 3b0a 0a09 6966 2028 6d5f 616c 6572 7473 ;...if (m_alerts │ │ │ -000608a0: 2e73 686f 756c 645f 706f 7374 266c 743b .should_post< │ │ │ -000608b0: 736f 636b 7335 5f61 6c65 7274 2667 743b socks5_alert> │ │ │ -000608c0: 2829 290a 0909 6d5f 616c 6572 7473 2e65 ())...m_alerts.e │ │ │ -000608d0: 6d70 6c61 6365 5f61 6c65 7274 266c 743b mplace_alert< │ │ │ -000608e0: 736f 636b 7335 5f61 6c65 7274 2667 743b socks5_alert> │ │ │ -000608f0: 286d 5f70 726f 7879 5f61 6464 722c 206f (m_proxy_addr, o │ │ │ -00060900: 7065 7261 7469 6f6e 5f74 3a3a 636f 6e6e peration_t::conn │ │ │ -00060910: 6563 742c 2065 7272 6f72 733a 3a74 696d ect, errors::tim │ │ │ -00060920: 6564 5f6f 7574 293b 0a0a 0965 7272 6f72 ed_out);...error │ │ │ -00060930: 5f63 6f64 6520 6967 6e6f 7265 3b0a 096d _code ignore;..m │ │ │ -00060940: 5f73 6f63 6b73 355f 736f 636b 2e63 6c6f _socks5_sock.clo │ │ │ -00060950: 7365 2869 676e 6f72 6529 3b0a 0a09 2b2b se(ignore);...++ │ │ │ -00060960: 6d5f 6661 696c 7572 6573 3b0a 0972 6574 m_failures;..ret │ │ │ -00060970: 7279 5f63 6f6e 6e65 6374 696f 6e28 293b ry_connection(); │ │ │ -00060980: 0a7d 0a0a 766f 6964 2073 6f63 6b73 353a .}..void socks5: │ │ │ -00060990: 3a6f 6e5f 636f 6e6e 6563 7465 6428 6572 :on_connected(er │ │ │ -000609a0: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ -000609b0: 6d70 3b20 6529 0a7b 0a3c 2f70 7265 3e3c mp; e).{.
    < │ │ │ -000609c0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000609f0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00060a00: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/pread │ │ │ -00060a30: 5f64 6973 6b5f 696f 2e63 7070 3a37 3431 _disk_io.cpp:741 │ │ │ -00060a40: 3c2f 613e 3c2f 7464 3e3c 7464 3e62 6163 bac │ │ │ -00060a50: 6b2d 7072 6573 7375 7265 2028 7468 6520 k-pressure (the │ │ │ -00060a60: 6469 736b 5f6f 6273 6572 7665 7220 6f29 disk_observer o) │ │ │ -00060a70: 2069 7320 6472 6f70 7065 6420 6f6e 2074 is dropped on t │ │ │ -00060a80: 6865 2062 6c6f 636b 6564 2070 6174 682e he blocked path. │ │ │ -00060a90: 2061 7379 6e63 5f77 7269 7465 2072 6574 async_write ret │ │ │ -00060aa0: 7572 6e73 2066 616c 7365 2028 6b65 6570 urns false (keep │ │ │ -00060ab0: 2077 7269 7469 6e67 2920 6275 7420 7468 writing) but th │ │ │ -00060ac0: 6520 6361 6368 6527 7320 6261 636b 2d70 e cache's back-p │ │ │ -00060ad0: 7265 7373 7572 6520 2864 7269 7665 6e20 ressure (driven │ │ │ -00060ae0: 6f66 6620 6d5f 626c 6f63 6b73 2920 6361 off m_blocks) ca │ │ │ -00060af0: 6e27 7420 7365 6520 7468 6520 7061 726b n't see the park │ │ │ -00060b00: 6564 2077 7269 7465 732c 2073 6f20 6120 ed writes, so a │ │ │ -00060b10: 6c6f 6e67 2d6c 6976 6564 2066 656e 6365 long-lived fence │ │ │ -00060b20: 2028 652e 672e 206d 6f76 655f 7374 6f72 (e.g. move_stor │ │ │ -00060b30: 6167 6529 206f 6e20 6120 6275 7379 2074 age) on a busy t │ │ │ -00060b40: 6f72 7265 6e74 2063 616e 2067 726f 7720 orrent can grow │ │ │ -00060b50: 6d5f 626c 6f63 6b65 645f 6a6f 6273 2075 m_blocked_jobs u │ │ │ -00060b60: 6e62 6f75 6e64 6564 2e20 4361 7272 7920 nbounded. Carry │ │ │ -00060b70: 7468 6520 6f62 7365 7276 6572 2074 6872 the observer thr │ │ │ -00060b80: 6f75 6768 2074 6f20 7468 726f 7474 6c65 ough to throttle │ │ │ -00060b90: 2074 6865 2070 6565 7220 7768 696c 6520 the peer while │ │ │ -00060ba0: 6974 7320 7772 6974 6573 2061 7265 2070 its writes are p │ │ │ -00060bb0: 6172 6b65 642e 3c2f 7464 3e3c 2f74 723e arked. │ │ │ -00060bc0: 3c74 7220 6964 3d22 3232 3522 2073 7479 │ │ │ -00060bf0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00060c00: 3c68 323e 6261 636b 2d70 7265 7373 7572

    back-pressur │ │ │ -00060c10: 6520 2874 6865 2064 6973 6b5f 6f62 7365 e (the disk_obse │ │ │ -00060c20: 7276 6572 206f 2920 6973 2064 726f 7070 rver o) is dropp │ │ │ -00060c30: 6564 206f 6e20 7468 6520 626c 6f63 6b65 ed on the blocke │ │ │ -00060c40: 6420 7061 7468 2e0a 6173 796e 635f 7772 d path..async_wr │ │ │ -00060c50: 6974 6520 7265 7475 726e 7320 6661 6c73 ite returns fals │ │ │ -00060c60: 6520 286b 6565 7020 7772 6974 696e 6729 e (keep writing) │ │ │ -00060c70: 2062 7574 2074 6865 2063 6163 6865 2773 but the cache's │ │ │ -00060c80: 2062 6163 6b2d 7072 6573 7375 7265 0a28 back-pressure.( │ │ │ -00060c90: 6472 6976 656e 206f 6666 206d 5f62 6c6f driven off m_blo │ │ │ -00060ca0: 636b 7329 2063 616e 2774 2073 6565 2074 cks) can't see t │ │ │ -00060cb0: 6865 2070 6172 6b65 6420 7772 6974 6573 he parked writes │ │ │ -00060cc0: 2c20 736f 2061 206c 6f6e 672d 6c69 7665 , so a long-live │ │ │ -00060cd0: 6420 6665 6e63 650a 2865 2e67 2e20 6d6f d fence.(e.g. mo │ │ │ -00060ce0: 7665 5f73 746f 7261 6765 2920 6f6e 2061 ve_storage) on a │ │ │ -00060cf0: 2062 7573 7920 746f 7272 656e 7420 6361 busy torrent ca │ │ │ -00060d00: 6e20 6772 6f77 206d 5f62 6c6f 636b 6564 n grow m_blocked │ │ │ -00060d10: 5f6a 6f62 7320 756e 626f 756e 6465 642e _jobs unbounded. │ │ │ -00060d20: 0a43 6172 7279 2074 6865 206f 6273 6572 .Carry the obser │ │ │ -00060d30: 7665 7220 7468 726f 7567 6820 746f 2074 ver through to t │ │ │ -00060d40: 6872 6f74 746c 6520 7468 6520 7065 6572 hrottle the peer │ │ │ -00060d50: 2077 6869 6c65 2069 7473 2077 7269 7465 while its write │ │ │ -00060d60: 7320 6172 6520 7061 726b 6564 2e3c 2f68 s are parked.

    ../src/pre │ │ │ -00060d80: 6164 5f64 6973 6b5f 696f 2e63 7070 3a37 ad_disk_io.cpp:7 │ │ │ -00060d90: 3431 3c2f 6834 3e3c 7072 6520 7374 796c 41

    .// storage's o
    │ │ │ -00060de0: 7574 7374 616e 6469 6e67 2d6a 6f62 2063  utstanding-job c
    │ │ │ -00060df0: 6f75 6e74 2e20 6973 5f62 6c6f 636b 6564  ount. is_blocked
    │ │ │ -00060e00: 2829 2068 6173 206e 6f74 2072 756e 2c20  () has not run, 
    │ │ │ -00060e10: 736f 206a 2069 7320 6e6f 740a 092f 2f20  so j is not..// 
    │ │ │ -00060e20: 696e 5f70 726f 6772 6573 7320 616e 6420  in_progress and 
    │ │ │ -00060e30: 6d75 7374 206e 6f74 2062 6520 6a6f 625f  must not be job_
    │ │ │ -00060e40: 636f 6d70 6c65 7465 2829 6420 2d2d 2061  complete()d -- a
    │ │ │ -00060e50: 626f 7274 2069 7420 6469 7265 6374 6c79  bort it directly
    │ │ │ -00060e60: 2e0a 0969 6620 286d 5f61 626f 7274 290a  ...if (m_abort).
    │ │ │ -00060e70: 097b 0a09 096d 5f63 6f6d 706c 6574 6564  .{...m_completed
    │ │ │ -00060e80: 5f6a 6f62 732e 6162 6f72 745f 6a6f 6228  _jobs.abort_job(
    │ │ │ -00060e90: 6d5f 696f 732c 206a 293b 0a09 0972 6574  m_ios, j);...ret
    │ │ │ -00060ea0: 7572 6e20 6661 6c73 653b 0a09 7d0a 0a09  urn false;..}...
    │ │ │ -00060eb0: 2f2f 2061 2077 7269 7465 2063 6f75 6e74  // a write count
    │ │ │ -00060ec0: 7320 6173 2061 6e20 6f75 7473 7461 6e64  s as an outstand
    │ │ │ -00060ed0: 696e 6720 6a6f 6220 6f6e 2074 6865 2073  ing job on the s
    │ │ │ -00060ee0: 746f 7261 6765 2028 6c69 6b65 2061 2072  torage (like a r
    │ │ │ -00060ef0: 6561 6420 6f72 2068 6173 6829 2c0a 092f  ead or hash),../
    │ │ │ -00060f00: 2f20 736f 2061 2066 656e 6365 2077 6169  / so a fence wai
    │ │ │ -00060f10: 7473 2066 6f72 2062 7566 6665 7265 6420  ts for buffered 
    │ │ │ -00060f20: 7772 6974 6573 2061 6e64 2074 6865 6972  writes and their
    │ │ │ -00060f30: 2069 6e2d 666c 6967 6874 2066 6c75 7368   in-flight flush
    │ │ │ -00060f40: 2062 6566 6f72 6520 6974 0a09 2f2f 2072   before it..// r
    │ │ │ -00060f50: 756e 732c 2072 6174 6865 7220 7468 616e  uns, rather than
    │ │ │ -00060f60: 2074 6561 7269 6e67 2074 6865 2073 746f   tearing the sto
    │ │ │ -00060f70: 7261 6765 2064 6f77 6e20 756e 6465 7220  rage down under 
    │ │ │ -00060f80: 6120 666c 7573 682e 2054 6869 7320 646f  a flush. This do
    │ │ │ -00060f90: 6573 206e 6f74 0a09 2f2f 2064 6561 646c  es not..// deadl
    │ │ │ -00060fa0: 6f63 6b20 7468 6520 6665 6e63 653a 2061  ock the fence: a
    │ │ │ -00060fb0: 6464 5f66 656e 6365 5f6a 6f62 2829 2068  dd_fence_job() h
    │ │ │ -00060fc0: 616e 6473 2061 2073 746f 7261 6765 2077  ands a storage w
    │ │ │ -00060fd0: 6974 6820 6f75 7473 7461 6e64 696e 6720  ith outstanding 
    │ │ │ -00060fe0: 7772 6974 6573 0a09 2f2f 2074 6f20 6120  writes..// to a 
    │ │ │ -00060ff0: 6765 6e65 7269 6320 7468 7265 6164 2074  generic thread t
    │ │ │ -00061000: 6f20 666c 7573 682c 2064 7261 696e 696e  o flush, drainin
    │ │ │ -00061010: 6720 7468 6520 7772 6974 6573 2074 6865  g the writes the
    │ │ │ -00061020: 2066 656e 6365 2077 6169 7473 206f 6e2e   fence waits on.
    │ │ │ -00061030: 0a09 2f2f 0a09 2f2f 2077 6865 6e20 6120  ..//..// when a 
    │ │ │ -00061040: 6665 6e63 6520 6973 2075 702c 2069 735f  fence is up, is_
    │ │ │ -00061050: 626c 6f63 6b65 6428 2920 7061 726b 7320  blocked() parks 
    │ │ │ -00061060: 7468 6520 6a6f 6220 696e 2074 6865 2066  the job in the f
    │ │ │ -00061070: 656e 6365 2773 2062 6c6f 636b 6564 2071  ence's blocked q
    │ │ │ -00061080: 7565 7565 0a09 2f2f 2074 6f20 6265 2072  ueue..// to be r
    │ │ │ -00061090: 6570 6f73 7465 6420 696e 746f 2074 6865  eposted into the
    │ │ │ -000610a0: 2063 6163 6865 206f 6e63 6520 7468 6520   cache once the 
    │ │ │ -000610b0: 6665 6e63 6520 6c6f 7765 7273 2028 6164  fence lowers (ad
    │ │ │ -000610c0: 645f 636f 6d70 6c65 7465 645f 6a6f 6273  d_completed_jobs
    │ │ │ -000610d0: 5f69 6d70 6c29 2e0a 092f 2f20 496e 7365  _impl)...// Inse
    │ │ │ -000610e0: 7274 696e 6720 6e6f 7720 776f 756c 6420  rting now would 
    │ │ │ -000610f0: 7261 6365 2074 6561 7264 6f77 6e3a 2066  race teardown: f
    │ │ │ -00061100: 6f72 2063 6c65 6172 5f70 6965 6365 2074  or clear_piece t
    │ │ │ -00061110: 6865 2063 7065 2069 7320 6162 6f75 7420  he cpe is about 
    │ │ │ -00061120: 746f 2062 650a 092f 2f20 7265 7365 742c  to be..// reset,
    │ │ │ -00061130: 2066 6f72 2073 746f 7261 6765 2d77 6964   for storage-wid
    │ │ │ -00061140: 6520 6665 6e63 6573 2074 6865 2073 746f  e fences the sto
    │ │ │ -00061150: 7261 6765 2069 7320 6162 6f75 7420 746f  rage is about to
    │ │ │ -00061160: 2067 6f20 6177 6179 2e20 5061 726b 696e   go away. Parkin
    │ │ │ -00061170: 670a 092f 2f20 6b65 6570 7320 7468 6520  g..// keeps the 
    │ │ │ -00061180: 626c 6f63 6b20 2277 7269 7469 6e67 2220  block "writing" 
    │ │ │ -00061190: 696e 2074 6865 2070 6963 6b65 7227 7320  in the picker's 
    │ │ │ -000611a0: 7669 6577 2c20 736f 2074 6865 2070 6965  view, so the pie
    │ │ │ -000611b0: 6365 2069 736e 2774 2072 6570 6f72 7465  ce isn't reporte
    │ │ │ -000611c0: 640a 092f 2f20 6669 6e69 7368 6564 2061  d..// finished a
    │ │ │ -000611d0: 6e64 2069 7473 2068 6173 6820 6973 6e27  nd its hash isn'
    │ │ │ -000611e0: 7420 7265 7175 6573 7465 6420 6265 666f  t requested befo
    │ │ │ -000611f0: 7265 2074 6865 2062 6c6f 636b 2068 6173  re the block has
    │ │ │ -00061200: 2062 6565 6e20 696e 7365 7274 6564 2e0a   been inserted..
    │ │ │ -00061210: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .i │ │ │ -00061240: 6620 286a 2d26 6774 3b73 746f 7261 6765 f (j->storage │ │ │ -00061250: 2d26 6774 3b69 735f 626c 6f63 6b65 6428 ->is_blocked( │ │ │ -00061260: 6a2c 206d 5f73 7461 7473 5f63 6f75 6e74 j, m_stats_count │ │ │ -00061270: 6572 7329 290a 3c2f 6469 763e 097b 0a09 ers)).
    .{.. │ │ │ -00061280: 0972 6574 7572 6e20 6661 6c73 653b 0a09 .return false;.. │ │ │ -00061290: 7d0a 0a09 2f2f 2069 735f 626c 6f63 6b65 }...// is_blocke │ │ │ -000612a0: 6428 2920 6d61 726b 6564 206a 2069 6e5f d() marked j in_ │ │ │ -000612b0: 7072 6f67 7265 7373 2061 6e64 2063 6f75 progress and cou │ │ │ -000612c0: 6e74 6564 2069 7420 6173 206f 7574 7374 nted it as outst │ │ │ -000612d0: 616e 6469 6e67 2e0a 0962 6f6f 6c20 636f anding...bool co │ │ │ -000612e0: 6e73 7420 6578 6365 6564 6564 203d 2061 nst exceeded = a │ │ │ -000612f0: 6464 5f77 7269 7465 5f74 6f5f 6361 6368 dd_write_to_cach │ │ │ -00061300: 6528 6a2c 2073 7464 3a3a 6d6f 7665 286f e(j, std::move(o │ │ │ -00061310: 2929 3b0a 0973 6368 6564 756c 655f 666c ));..schedule_fl │ │ │ -00061320: 7573 6828 293b 0a09 7265 7475 726e 2065 ush();..return e │ │ │ -00061330: 7863 6565 6465 643b 0a7d 0a0a 6175 783a xceeded;.}..aux: │ │ │ -00061340: 3a69 6e73 6572 745f 7265 7375 6c74 5f66 :insert_result_f │ │ │ -00061350: 6c61 6773 2070 7265 6164 5f64 6973 6b5f lags pread_disk_ │ │ │ -00061360: 696f 3a3a 696e 7365 7274 5f77 7269 7465 io::insert_write │ │ │ -00061370: 280a 0961 7578 3a3a 7072 6561 645f 6469 (..aux::pread_di │ │ │ -00061380: 736b 5f6a 6f62 2a20 6a2c 2073 7464 3a3a sk_job* j, std:: │ │ │ -00061390: 7368 6172 6564 5f70 7472 266c 743b 6469 shared_ptr<di │ │ │ -000613a0: 736b 5f6f 6273 6572 7665 7226 6774 3b20 sk_observer> │ │ │ -000613b0: 6f29 0a7b 0a09 6175 746f 2063 6f6e 7374 o).{..auto const │ │ │ -000613c0: 2661 6d70 3b20 6120 3d20 7374 643a 3a67 & a = std::g │ │ │ -000613d0: 6574 266c 743b 6175 783a 3a6a 6f62 3a3a et<aux::job:: │ │ │ -000613e0: 7772 6974 6526 6774 3b28 6a2d 2667 743b write>(j-> │ │ │ -000613f0: 6163 7469 6f6e 293b 0a09 7069 6563 655f action);..piece_ │ │ │ -00061400: 696e 6465 785f 7420 636f 6e73 7420 7069 index_t const pi │ │ │ -00061410: 6563 6520 3d20 612e 7069 6563 653b 0a09 ece = a.piece;.. │ │ │ -00061420: 696e 7420 636f 6e73 7420 6f66 6673 6574 int const offset │ │ │ -00061430: 203d 2061 2e6f 6666 7365 743b 0a0a 0944 = a.offset;...D │ │ │ -00061440: 4c4f 4728 2261 7379 6e63 5f77 7269 7465 LOG("async_write │ │ │ -00061450: 3a20 7069 6563 653a 2025 6420 6f66 6673 : piece: %d offs │ │ │ -00061460: 6574 3a20 2564 2066 6c61 6773 3a20 2578 et: %d flags: %x │ │ │ -00061470: 5c6e 222c 0a09 0969 6e74 2870 6965 6365 \n",...int(piece │ │ │ -00061480: 292c 0a09 0969 6e74 286f 6666 7365 7429 ),...int(offset) │ │ │ -00061490: 2c0a 0909 7374 6174 6963 5f63 6173 7426 ,...static_cast& │ │ │ -000614a0: 6c74 3b73 7464 3a3a 7569 6e74 385f 7426 lt;std::uint8_t& │ │ │ -000614b0: 6774 3b28 6a2d 2667 743b 666c 6167 7329 gt;(j->flags) │ │ │ -000614c0: 293b 0a09 626f 6f6c 2063 6f6e 7374 2066 );..bool const f │ │ │ -000614d0: 6f72 6365 5f66 6c75 7368 203d 2062 6f6f orce_flush = boo │ │ │ -000614e0: 6c28 6a2d 2667 743b 666c 6167 7320 2661 l(j->flags &a │ │ │ -000614f0: 6d70 3b20 666c 7573 685f 7069 6563 6529 mp; flush_piece) │ │ │ -00061500: 3b0a 0966 696c 655f 7374 6f72 6167 6520 ;..file_storage │ │ │ -00061510: 636f 6e73 7426 616d 703b 2066 7320 3d20 const& fs = │ │ │ -00061520: 6a2d 2667 743b 7374 6f72 6167 652d 2667 j->storage-&g │ │ │ -00061530: 743b 6669 6c65 7328 293b 0a09 2f2f 2069 t;files();..// i │ │ │ -00061540: 6e20 6f72 6465 7220 746f 2063 6f6d 7075 n order to compu │ │ │ -00061550: 7465 2076 3120 6861 7368 6573 2c20 7765 te v1 hashes, we │ │ │ -00061560: 206e 6565 6420 7468 6520 6675 6c6c 2070 need the full p │ │ │ -00061570: 6965 6365 2c20 696e 636c 7564 696e 6720 iece, including │ │ │ -00061580: 7061 640a 092f 2f20 6669 6c65 732e 2045 pad..// files. E │ │ │ -00061590: 7665 6e20 7468 6f75 6768 2076 3220 746f ven though v2 to │ │ │ -000615a0: 7272 656e 7473 2067 7561 7261 6e74 6565 rrents guarantee │ │ │ -000615b0: 2074 6861 7420 7468 6579 2061 7265 207a that they are z │ │ │ -000615c0: 6572 6f2e 0a09 696e 7420 636f 6e73 7420 ero...int const │ │ │ -000615d0: 7069 6563 655f 7369 7a65 203d 206a 2d26 piece_size = j-& │ │ │ -000615e0: 6774 3b73 746f 7261 6765 2d26 6774 3b76 gt;storage->v │ │ │ -000615f0: 3128 2920 3f20 6673 2e70 6965 6365 5f73 1() ? fs.piece_s │ │ │ -00061600: 697a 6528 7069 6563 6529 203a 2066 732e ize(piece) : fs. │ │ │ -00061610: 7069 6563 655f 7369 7a65 3228 7069 6563 piece_size2(piec │ │ │ -00061620: 6529 3b0a 0954 4f52 5245 4e54 5f41 5353 e);..TORRENT_ASS │ │ │ -00061630: 4552 5428 612e 6275 6666 6572 5f73 697a ERT(a.buffer_siz │ │ │ -00061640: 6520 3d3d 2073 7464 3a3a 6d69 6e28 7069 e == std::min(pi │ │ │ -00061650: 6563 655f 7369 7a65 202d 206f 6666 7365 ece_size - offse │ │ │ -00061660: 742c 2064 6566 6175 6c74 5f62 6c6f 636b t, default_block │ │ │ -00061670: 5f73 697a 6529 293b 0a09 6175 783a 3a64 _size));..aux::d │ │ │ -00061680: 6973 6b5f 6361 6368 653a 3a70 6965 6365 isk_cache::piece │ │ │ -00061690: 5f65 6e74 7279 5f70 6172 616d 7320 636f _entry_params co │ │ │ -000616a0: 6e73 7420 7069 6563 655f 7061 7261 6d73 nst piece_params │ │ │ -000616b0: 7b0a 0909 6673 2e70 6965 6365 5f73 697a {...fs.piece_siz │ │ │ -000616c0: 6532 2870 6965 6365 292c 2070 6965 6365 e2(piece), piece │ │ │ -000616d0: 5f73 697a 652c 206a 2d26 6774 3b73 746f _size, j->sto │ │ │ -000616e0: 7261 6765 2d26 6774 3b76 3128 292c 206a rage->v1(), j │ │ │ -000616f0: 2d26 6774 3b73 746f 7261 6765 2d26 6774 ->storage-> │ │ │ -00061700: 3b76 3228 292c 206a 2d26 6774 3b73 746f ;v2(), j->sto │ │ │ -00061710: 7261 6765 7d3b 0a09 7265 7475 726e 206d rage};..return m │ │ │ -00061720: 5f63 6163 6865 2e69 6e73 6572 7428 7b6a _cache.insert({j │ │ │ -00061730: 2d26 6774 3b73 746f 7261 6765 2d26 6774 ->storage-> │ │ │ -00061740: 3b73 746f 7261 6765 5f69 6e64 6578 2829 ;storage_index() │ │ │ -00061750: 2c20 7069 6563 657d 2c0a 3c2f 7072 653e , piece},.
    │ │ │ -00061760: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00061790: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -000617a0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/prea │ │ │ -000617d0: 645f 6469 736b 5f69 6f2e 6370 703a 3932 d_disk_io.cpp:92 │ │ │ -000617e0: 353c 2f61 3e3c 2f74 643e 3c74 643e 7765 5we │ │ │ -000617f0: 206d 6179 206e 6f74 206e 6565 6420 746f may not need to │ │ │ -00061800: 2064 6f20 7468 6973 2c20 7468 6520 6361 do this, the ca │ │ │ -00061810: 6368 6520 636f 756c 6420 7465 6c6c 2075 che could tell u │ │ │ -00061820: 7320 7468 6973 2070 6965 6365 2073 686f s this piece sho │ │ │ -00061830: 756c 6420 6265 2066 6c75 7368 6564 2074 uld be flushed t │ │ │ -00061840: 6f20 6469 736b 206e 6f77 2e3c 2f74 643e o disk now. │ │ │ -00061850: 3c2f 7472 3e3c 7472 2069 643d 2232 3236

    we may │ │ │ -000618a0: 6e6f 7420 6e65 6564 2074 6f20 646f 2074 not need to do t │ │ │ -000618b0: 6869 732c 2074 6865 2063 6163 6865 2063 his, the cache c │ │ │ -000618c0: 6f75 6c64 2074 656c 6c20 7573 0a74 6869 ould tell us.thi │ │ │ -000618d0: 7320 7069 6563 6520 7368 6f75 6c64 2062 s piece should b │ │ │ -000618e0: 6520 666c 7573 6865 6420 746f 2064 6973 e flushed to dis │ │ │ -000618f0: 6b20 6e6f 772e 3c2f 6832 3e3c 6834 3e2e k now.

    . │ │ │ -00061900: 2e2f 7372 632f 7072 6561 645f 6469 736b ./src/pread_disk │ │ │ -00061910: 5f69 6f2e 6370 703a 3932 353c 2f68 343e _io.cpp:925

    │ │ │ -00061920: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...fil
    │ │ │ -00061960: 6c5f 7072 6563 6f6d 7075 7465 645f 7632  l_precomputed_v2
    │ │ │ -00061970: 280a 0909 0909 612e 626c 6f63 6b5f 6861  (.....a.block_ha
    │ │ │ -00061980: 7368 6573 2c20 6a2d 2667 743b 7374 6f72  shes, j->stor
    │ │ │ -00061990: 6167 652d 2667 743b 7461 6b65 5f70 7265  age->take_pre
    │ │ │ -000619a0: 636f 6d70 7574 6564 5f76 3228 7069 6563  computed_v2(piec
    │ │ │ -000619b0: 6529 2c20 626c 6f63 6b73 5f69 6e5f 7069  e), blocks_in_pi
    │ │ │ -000619c0: 6563 6532 293b 0a0a 0909 0966 6f72 2028  ece2);.....for (
    │ │ │ -000619d0: 696e 7420 6920 3d20 303b 2069 2026 6c74  int i = 0; i <
    │ │ │ -000619e0: 3b20 626c 6f63 6b73 5f69 6e5f 7069 6563  ; blocks_in_piec
    │ │ │ -000619f0: 6532 3b20 2b2b 6929 0a09 0909 7b0a 0909  e2; ++i)....{...
    │ │ │ -00061a00: 0909 6966 2028 6920 2667 743b 3d20 696e  ..if (i >= in
    │ │ │ -00061a10: 7428 612e 626c 6f63 6b5f 6861 7368 6573  t(a.block_hashes
    │ │ │ -00061a20: 2e73 697a 6528 2929 207c 7c20 612e 626c  .size()) || a.bl
    │ │ │ -00061a30: 6f63 6b5f 6861 7368 6573 5b69 5d2e 6973  ock_hashes[i].is
    │ │ │ -00061a40: 5f61 6c6c 5f7a 6572 6f73 2829 290a 0909  _all_zeros())...
    │ │ │ -00061a50: 0909 7b0a 0909 0909 096e 6565 645f 6469  ..{......need_di
    │ │ │ -00061a60: 736b 5f66 616c 6c62 6163 6b20 3d20 7472  sk_fallback = tr
    │ │ │ -00061a70: 7565 3b0a 0909 0909 0962 7265 616b 3b0a  ue;......break;.
    │ │ │ -00061a80: 0909 0909 7d0a 0909 097d 0a09 097d 0a0a  ....}....}...}..
    │ │ │ -00061a90: 0909 6966 2028 6e65 6564 5f64 6973 6b5f  ..if (need_disk_
    │ │ │ -00061aa0: 6661 6c6c 6261 636b 290a 0909 7b0a 0909  fallback)...{...
    │ │ │ -00061ab0: 0944 4c4f 4728 2261 7379 6e63 5f68 6173  .DLOG("async_has
    │ │ │ -00061ac0: 683a 2076 3220 6861 7368 6573 2069 6e63  h: v2 hashes inc
    │ │ │ -00061ad0: 6f6d 706c 6574 652c 2066 616c 6c69 6e67  omplete, falling
    │ │ │ -00061ae0: 2062 6163 6b20 746f 2064 6f5f 6a6f 6228   back to do_job(
    │ │ │ -00061af0: 6861 7368 295c 6e22 293b 0a09 0909 6164  hash)\n");....ad
    │ │ │ -00061b00: 645f 6a6f 6228 6a29 3b0a 0909 0972 6574  d_job(j);....ret
    │ │ │ -00061b10: 7572 6e3b 0a09 097d 0a0a 3c64 6976 2073  urn;...}..
    ..m_gene │ │ │ -00061b50: 7269 635f 7468 7265 6164 732e 696e 7465 ric_threads.inte │ │ │ -00061b60: 7272 7570 7428 293b 0a3c 2f64 6976 3e0a rrupt();.
    . │ │ │ -00061b70: 0909 6a6f 6271 7565 7565 5f74 206a 6f62 ..jobqueue_t job │ │ │ -00061b80: 733b 0a09 096a 6f62 732e 7075 7368 5f62 s;...jobs.push_b │ │ │ -00061b90: 6163 6b28 6a29 3b0a 0909 6164 645f 636f ack(j);...add_co │ │ │ -00061ba0: 6d70 6c65 7465 645f 6a6f 6273 2873 7464 mpleted_jobs(std │ │ │ -00061bb0: 3a3a 6d6f 7665 286a 6f62 7329 293b 0a09 ::move(jobs));.. │ │ │ -00061bc0: 0972 6574 7572 6e3b 0a09 7d0a 0a09 2f2f .return;..}...// │ │ │ -00061bd0: 2049 6e20 7468 6973 2063 6173 6520 7468 In this case th │ │ │ -00061be0: 6520 6a6f 6220 6861 7320 6265 656e 2071 e job has been q │ │ │ -00061bf0: 7565 7565 6420 6f6e 2074 6865 2070 6965 ueued on the pie │ │ │ -00061c00: 6365 2c20 616e 6420 7769 6c6c 2062 6520 ce, and will be │ │ │ -00061c10: 706f 7374 6564 0a09 2f2f 206f 6e63 6520 posted..// once │ │ │ -00061c20: 7468 6520 6861 7368 696e 6720 636f 6d70 the hashing comp │ │ │ -00061c30: 6c65 7465 730a 0969 6620 2872 6574 203d letes..if (ret = │ │ │ -00061c40: 3d20 6175 783a 3a64 6973 6b5f 6361 6368 = aux::disk_cach │ │ │ -00061c50: 653a 3a6a 6f62 5f71 7565 7565 6429 0a09 e::job_queued).. │ │ │ -00061c60: 0972 6574 7572 6e3b 0a0a 0961 6464 5f6a .return;...add_j │ │ │ -00061c70: 6f62 286a 293b 0a7d 0a0a 766f 6964 2070 ob(j);.}..void p │ │ │ -00061c80: 7265 6164 5f64 6973 6b5f 696f 3a3a 6173 read_disk_io::as │ │ │ -00061c90: 796e 635f 6861 7368 3228 7374 6f72 6167 ync_hash2(storag │ │ │ -00061ca0: 655f 696e 6465 785f 7420 636f 6e73 7420 e_index_t const │ │ │ -00061cb0: 7374 6f72 6167 650a 092c 2070 6965 6365 storage.., piece │ │ │ -00061cc0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2070 _index_t const p │ │ │ -00061cd0: 6965 6365 2c20 696e 7420 636f 6e73 7420 iece, int const │ │ │ -00061ce0: 6f66 6673 6574 2c20 6469 736b 5f6a 6f62 offset, disk_job │ │ │ -00061cf0: 5f66 6c61 6773 5f74 2063 6f6e 7374 2066 _flags_t const f │ │ │ -00061d00: 6c61 6773 0a09 2c20 7374 643a 3a66 756e lags.., std::fun │ │ │ -00061d10: 6374 696f 6e26 6c74 3b76 6f69 6428 7069 ction<void(pi │ │ │ -00061d20: 6563 655f 696e 6465 785f 742c 2073 6861 ece_index_t, sha │ │ │ -00061d30: 3235 365f 6861 7368 2063 6f6e 7374 2661 256_hash const&a │ │ │ -00061d40: 6d70 3b2c 2073 746f 7261 6765 5f65 7272 mp;, storage_err │ │ │ -00061d50: 6f72 2063 6f6e 7374 2661 6d70 3b29 2667 or const&)&g │ │ │ -00061d60: 743b 2068 616e 646c 6572 290a 7b0a 0954 t; handler).{..T │ │ │ -00061d70: 4f52 5245 4e54 5f41 5353 4552 5428 7661 ORRENT_ASSERT(va │ │ │ -00061d80: 6c69 645f 666c 6167 7328 666c 6167 7329 lid_flags(flags) │ │ │ -00061d90: 293b 0a09 6175 783a 3a70 7265 6164 5f64 );..aux::pread_d │ │ │ -00061da0: 6973 6b5f 6a6f 622a 206a 203d 206d 5f6a isk_job* j = m_j │ │ │ -00061db0: 6f62 5f70 6f6f 6c2e 616c 6c6f 6361 7465 ob_pool.allocate │ │ │ -00061dc0: 5f6a 6f62 266c 743b 6175 783a 3a6a 6f62 _job<aux::job │ │ │ -00061dd0: 3a3a 6861 7368 3226 6774 3b28 0a09 0966 ::hash2>(...f │ │ │ -00061de0: 6c61 6773 2c0a 0909 6d5f 746f 7272 656e lags,...m_torren │ │ │ -00061df0: 7473 5b73 746f 7261 6765 5d2d 2667 743b ts[storage]-> │ │ │ -00061e00: 7368 6172 6564 5f66 726f 6d5f 7468 6973 shared_from_this │ │ │ -00061e10: 2829 2c0a 0909 7374 643a 3a6d 6f76 6528 (),...std::move( │ │ │ -00061e20: 6861 6e64 6c65 7229 2c0a 0909 7069 6563 handler),...piec │ │ │ -00061e30: 652c 0a09 096f 6666 7365 742c 0a09 0973 e,...offset,...s │ │ │ -00061e40: 6861 3235 365f 6861 7368 7b7d 0a09 293b ha256_hash{}..); │ │ │ -00061e50: 0a0a 092f 2f20 496e 2074 6865 6f72 792c ...// In theory, │ │ │ -00061e60: 2077 6520 636f 756c 6420 6368 6563 6b20 we could check │ │ │ -00061e70: 7468 6520 6361 6368 6520 666f 7220 7468 the cache for th │ │ │ -00061e80: 6973 2062 6c6f 636b 2068 6173 682c 2062 is block hash, b │ │ │ -00061e90: 7574 2077 650a 3c2f 7072 653e 3c2f 7464 ut we.
    relevance │ │ │ -00061ed0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00061ee0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/pread_di │ │ │ -00061f10: 736b 5f69 6f2e 6370 703a 3133 3631 3c2f sk_io.cpp:1361maybe │ │ │ -00061f30: 2077 6520 646f 6e27 7420 6e65 6564 2074 we don't need t │ │ │ -00061f40: 6f20 7772 6974 6520 746f 2066 696c 6573 o write to files │ │ │ -00061f50: 2077 6527 7265 2061 626f 7574 2074 6f20 we're about to │ │ │ -00061f60: 6465 6c65 7465 3c2f 7464 3e3c 2f74 723e delete │ │ │ -00061f70: 3c74 7220 6964 3d22 3232 3722 2073 7479 │ │ │ -00061fa0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00061fb0: 3c68 323e 6d61 7962 6520 7765 2064 6f6e

    maybe we don │ │ │ -00061fc0: 2774 206e 6565 6420 746f 2077 7269 7465 't need to write │ │ │ -00061fd0: 2074 6f20 6669 6c65 7320 7765 2772 6520 to files we're │ │ │ -00061fe0: 6162 6f75 7420 746f 2064 656c 6574 653c about to delete< │ │ │ -00061ff0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ -00062000: 7265 6164 5f64 6973 6b5f 696f 2e63 7070 read_disk_io.cpp │ │ │ -00062010: 3a31 3336 313c 2f68 343e 3c70 7265 2073 :1361

    .a.path = st
    │ │ │ -00062060: 643a 3a6d 6f76 6528 7029 3b0a 0972 6574  d::move(p);..ret
    │ │ │ -00062070: 7572 6e20 7265 743b 0a7d 0a0a 7374 6174  urn ret;.}..stat
    │ │ │ -00062080: 7573 5f74 2070 7265 6164 5f64 6973 6b5f  us_t pread_disk_
    │ │ │ -00062090: 696f 3a3a 646f 5f6a 6f62 2861 7578 3a3a  io::do_job(aux::
    │ │ │ -000620a0: 6a6f 623a 3a72 656c 6561 7365 5f66 696c  job::release_fil
    │ │ │ -000620b0: 6573 2661 6d70 3b2c 2061 7578 3a3a 7072  es&, aux::pr
    │ │ │ -000620c0: 6561 645f 6469 736b 5f6a 6f62 2a20 6a29  ead_disk_job* j)
    │ │ │ -000620d0: 0a7b 0a09 2f2f 2069 6620 7468 6973 2061  .{..// if this a
    │ │ │ -000620e0: 7373 6572 7420 6661 696c 732c 2073 6f6d  ssert fails, som
    │ │ │ -000620f0: 6574 6869 6e67 2773 2077 726f 6e67 2077  ething's wrong w
    │ │ │ -00062100: 6974 6820 7468 6520 6665 6e63 6520 6c6f  ith the fence lo
    │ │ │ -00062110: 6769 630a 0954 4f52 5245 4e54 5f41 5353  gic..TORRENT_ASS
    │ │ │ -00062120: 4552 5428 6a2d 2667 743b 7374 6f72 6167  ERT(j->storag
    │ │ │ -00062130: 652d 2667 743b 6e75 6d5f 6f75 7473 7461  e->num_outsta
    │ │ │ -00062140: 6e64 696e 675f 6a6f 6273 2829 203d 3d20  nding_jobs() == 
    │ │ │ -00062150: 3129 3b0a 0966 6c75 7368 5f73 746f 7261  1);..flush_stora
    │ │ │ -00062160: 6765 286a 2d26 6774 3b73 746f 7261 6765  ge(j->storage
    │ │ │ -00062170: 293b 0a09 6a2d 2667 743b 7374 6f72 6167  );..j->storag
    │ │ │ -00062180: 652d 2667 743b 7265 6c65 6173 655f 6669  e->release_fi
    │ │ │ -00062190: 6c65 7328 6a2d 2667 743b 6572 726f 7229  les(j->error)
    │ │ │ -000621a0: 3b0a 0972 6574 7572 6e20 6a2d 2667 743b  ;..return j->
    │ │ │ -000621b0: 6572 726f 7220 3f20 6469 736b 5f73 7461  error ? disk_sta
    │ │ │ -000621c0: 7475 733a 3a66 6174 616c 5f64 6973 6b5f  tus::fatal_disk_
    │ │ │ -000621d0: 6572 726f 7220 3a20 7374 6174 7573 5f74  error : status_t
    │ │ │ -000621e0: 7b7d 3b0a 7d0a 0a73 7461 7475 735f 7420  {};.}..status_t 
    │ │ │ -000621f0: 7072 6561 645f 6469 736b 5f69 6f3a 3a64  pread_disk_io::d
    │ │ │ -00062200: 6f5f 6a6f 6228 6175 783a 3a6a 6f62 3a3a  o_job(aux::job::
    │ │ │ -00062210: 6465 6c65 7465 5f66 696c 6573 2661 6d70  delete_files&
    │ │ │ -00062220: 3b20 612c 2061 7578 3a3a 7072 6561 645f  ; a, aux::pread_
    │ │ │ -00062230: 6469 736b 5f6a 6f62 2a20 6a29 0a7b 0a09  disk_job* j).{..
    │ │ │ -00062240: 544f 5252 454e 545f 4153 5345 5254 2861  TORRENT_ASSERT(a
    │ │ │ -00062250: 2e66 6c61 6773 293b 0a0a 092f 2f20 6966  .flags);...// if
    │ │ │ -00062260: 2074 6869 7320 6173 7365 7274 2066 6169   this assert fai
    │ │ │ -00062270: 6c73 2c20 736f 6d65 7468 696e 6727 7320  ls, something's 
    │ │ │ -00062280: 7772 6f6e 6720 7769 7468 2074 6865 2066  wrong with the f
    │ │ │ -00062290: 656e 6365 206c 6f67 6963 0a09 544f 5252  ence logic..TORR
    │ │ │ -000622a0: 454e 545f 4153 5345 5254 286a 2d26 6774  ENT_ASSERT(j->
    │ │ │ -000622b0: 3b73 746f 7261 6765 2d26 6774 3b6e 756d  ;storage->num
    │ │ │ -000622c0: 5f6f 7574 7374 616e 6469 6e67 5f6a 6f62  _outstanding_job
    │ │ │ -000622d0: 7328 2920 3d3d 2031 293b 0a0a 3c64 6976  s() == 1);..
    .flush │ │ │ -00062310: 5f73 746f 7261 6765 286a 2d26 6774 3b73 _storage(j->s │ │ │ -00062320: 746f 7261 6765 293b 0a3c 2f64 6976 3e0a torage);.
    . │ │ │ -00062330: 096a 2d26 6774 3b73 746f 7261 6765 2d26 .j->storage-& │ │ │ -00062340: 6774 3b64 656c 6574 655f 6669 6c65 7328 gt;delete_files( │ │ │ -00062350: 612e 666c 6167 732c 206a 2d26 6774 3b65 a.flags, j->e │ │ │ -00062360: 7272 6f72 293b 0a09 7265 7475 726e 206a rror);..return j │ │ │ -00062370: 2d26 6774 3b65 7272 6f72 203f 2064 6973 ->error ? dis │ │ │ -00062380: 6b5f 7374 6174 7573 3a3a 6661 7461 6c5f k_status::fatal_ │ │ │ -00062390: 6469 736b 5f65 7272 6f72 203a 2073 7461 disk_error : sta │ │ │ -000623a0: 7475 735f 747b 7d3b 0a7d 0a0a 7374 6174 tus_t{};.}..stat │ │ │ -000623b0: 7573 5f74 2070 7265 6164 5f64 6973 6b5f us_t pread_disk_ │ │ │ -000623c0: 696f 3a3a 646f 5f6a 6f62 2861 7578 3a3a io::do_job(aux:: │ │ │ -000623d0: 6a6f 623a 3a63 6865 636b 5f66 6173 7472 job::check_fastr │ │ │ -000623e0: 6573 756d 6526 616d 703b 2061 2c20 6175 esume& a, au │ │ │ -000623f0: 783a 3a70 7265 6164 5f64 6973 6b5f 6a6f x::pread_disk_jo │ │ │ -00062400: 622a 206a 290a 7b0a 092f 2f20 6966 2074 b* j).{..// if t │ │ │ -00062410: 6869 7320 6173 7365 7274 2066 6169 6c73 his assert fails │ │ │ -00062420: 2c20 736f 6d65 7468 696e 6727 7320 7772 , something's wr │ │ │ -00062430: 6f6e 6720 7769 7468 2074 6865 2066 656e ong with the fen │ │ │ -00062440: 6365 206c 6f67 6963 0a09 544f 5252 454e ce logic..TORREN │ │ │ -00062450: 545f 4153 5345 5254 286a 2d26 6774 3b73 T_ASSERT(j->s │ │ │ -00062460: 746f 7261 6765 2d26 6774 3b6e 756d 5f6f torage->num_o │ │ │ -00062470: 7574 7374 616e 6469 6e67 5f6a 6f62 7328 utstanding_jobs( │ │ │ -00062480: 2920 3d3d 2031 293b 0a09 666c 7573 685f ) == 1);..flush_ │ │ │ -00062490: 7374 6f72 6167 6528 6a2d 2667 743b 7374 storage(j->st │ │ │ -000624a0: 6f72 6167 6529 3b0a 0961 6464 5f74 6f72 orage);..add_tor │ │ │ -000624b0: 7265 6e74 5f70 6172 616d 7320 636f 6e73 rent_params cons │ │ │ -000624c0: 742a 2072 6420 3d20 612e 7265 7375 6d65 t* rd = a.resume │ │ │ -000624d0: 5f64 6174 613b 0a09 6164 645f 746f 7272 _data;..add_torr │ │ │ -000624e0: 656e 745f 7061 7261 6d73 2074 6d70 3b0a ent_params tmp;. │ │ │ -000624f0: 0969 6620 2872 6420 3d3d 206e 756c 6c70 .if (rd == nullp │ │ │ -00062500: 7472 2920 7264 203d 2026 616d 703b 746d tr) rd = &tm │ │ │ -00062510: 703b 0a0a 0973 7464 3a3a 756e 6971 7565 p;...std::unique │ │ │ -00062520: 5f70 7472 266c 743b 6175 783a 3a76 6563 _ptr<aux::vec │ │ │ -00062530: 746f 7226 6c74 3b73 7464 3a3a 7374 7269 tor<std::stri │ │ │ -00062540: 6e67 2c20 6669 6c65 5f69 6e64 6578 5f74 ng, file_index_t │ │ │ -00062550: 2667 743b 2667 743b 206c 696e 6b73 2861 >> links(a │ │ │ -00062560: 2e6c 696e 6b73 293b 0a09 2f2f 2063 6865 .links);..// che │ │ │ -00062570: 636b 2069 6620 7468 6520 6661 7374 7265 ck if the fastre │ │ │ -00062580: 7375 6d65 2064 6174 6120 6973 2075 7020 sume data is up │ │ │ -00062590: 746f 2064 6174 650a 092f 2f20 6966 2069 to date..// if i │ │ │ -000625a0: 7420 6973 2c20 7573 6520 6974 2061 6e64 t is, use it and │ │ │ -000625b0: 2072 6574 7572 6e20 7472 7565 2e20 4966 return true. If │ │ │ -000625c0: 2069 740a 092f 2f20 6973 6e27 7420 7265 it..// isn't re │ │ │ -000625d0: 7475 726e 2066 616c 7365 2061 6e64 2074 turn false and t │ │ │ -000625e0: 6865 2066 756c 6c20 6368 6563 6b0a 092f he full check../ │ │ │ -000625f0: 2f20 7769 6c6c 2062 6520 7275 6e2e 2049 / will be run. I │ │ │ -00062600: 6620 7468 6520 6c69 6e6b 7320 706f 696e f the links poin │ │ │ -00062610: 7465 7220 6973 206e 6f6e 2d65 6d70 7479 ter is non-empty │ │ │ -00062620: 2c20 6974 2068 6173 2074 6865 2073 616d , it has the sam │ │ │ -00062630: 6520 6e75 6d62 6572 0a09 2f2f 206f 6620 e number..// of │ │ │ -00062640: 656c 656d 656e 7473 2061 7320 7468 6572 elements as ther │ │ │ -00062650: 6520 6172 6520 6669 6c65 732e 2045 6163 e are files. Eac │ │ │ -00062660: 6820 656c 656d 656e 7420 6973 2065 6974 h element is eit │ │ │ -00062670: 6865 7220 656d 7074 7920 6f72 2063 6f6e her empty or con │ │ │ -00062680: 7461 696e 730a 092f 2f20 7468 6520 6162 tains..// the ab │ │ │ -00062690: 736f 6c75 7465 2070 6174 6820 746f 2061 solute path to a │ │ │ -000626a0: 2066 696c 6520 6964 656e 7469 6361 6c20 file identical │ │ │ -000626b0: 746f 2074 6865 2063 6f72 7265 7370 6f6e to the correspon │ │ │ -000626c0: 6469 6e67 2066 696c 6520 696e 2074 6869 ding file in thi │ │ │ -000626d0: 730a 092f 2f20 746f 7272 656e 742e 2054 s..// torrent. T │ │ │ -000626e0: 6865 2073 746f 7261 6765 206d 7573 7420 he storage must │ │ │ -000626f0: 6372 6561 7465 2068 6172 6420 6c69 6e6b create hard link │ │ │ -00062700: 7320 286f 7220 636f 7079 2920 7468 6f73 s (or copy) thos │ │ │ -00062710: 6520 6669 6c65 732e 2049 660a 092f 2f20 e files. If..// │ │ │ -00062720: 616e 7920 6669 6c65 2064 6f65 7320 6e6f any file does no │ │ │ -00062730: 7420 6578 6973 7420 6f72 2069 7320 696e t exist or is in │ │ │ -00062740: 6163 6365 7373 6962 6c65 2c20 7468 6520 accessible, the │ │ │ -00062750: 6469 736b 206a 6f62 206d 7573 7420 6661 disk job must fa │ │ │ -00062760: 696c 2e0a 0a09 544f 5252 454e 545f 4153 il....TORRENT_AS │ │ │ -00062770: 5345 5254 286a 2d26 6774 3b73 746f 7261 SERT(j->stora │ │ │ -00062780: 6765 2d26 6774 3b66 696c 6573 2829 2e70 ge->files().p │ │ │ -00062790: 6965 6365 5f6c 656e 6774 6828 2920 2667 iece_length() &g │ │ │ -000627a0: 743b 2030 293b 0a0a 092f 2f20 616c 7761 t; 0);...// alwa │ │ │ -000627b0: 7973 2069 6e69 7469 616c 697a 6520 7468 ys initialize th │ │ │ -000627c0: 6520 7374 6f72 6167 650a 0961 7574 6f20 e storage..auto │ │ │ -000627d0: 636f 6e73 7420 7265 745f 666c 6167 203d const ret_flag = │ │ │ -000627e0: 206a 2d26 6774 3b73 746f 7261 6765 2d26 j->storage-& │ │ │ -000627f0: 6774 3b69 6e69 7469 616c 697a 6528 6d5f gt;initialize(m_ │ │ │ -00062800: 7365 7474 696e 6773 2c20 6a2d 2667 743b settings, j-> │ │ │ -00062810: 6572 726f 7229 3b0a 0969 6620 286a 2d26 error);..if (j-& │ │ │ -00062820: 6774 3b65 7272 6f72 2920 7265 7475 726e gt;error) return │ │ │ -00062830: 2064 6973 6b5f 7374 6174 7573 3a3a 6661 disk_status::fa │ │ │ -00062840: 7461 6c5f 6469 736b 5f65 7272 6f72 207c tal_disk_error | │ │ │ -00062850: 2072 6574 5f66 6c61 673b 0a0a 3c2f 7072 ret_flag;..rel │ │ │ -00062890: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0
    ../src/to │ │ │ -000628d0: 7272 656e 742e 6370 703a 3230 3934 3c2f rrent.cpp:2094this │ │ │ -000628f0: 636f 756c 6420 6265 206f 7074 696d 697a could be optimiz │ │ │ -00062900: 6564 2062 7920 6c6f 6f6b 696e 6720 7570 ed by looking up │ │ │ -00062910: 2077 6869 6368 2066 696c 6573 2061 7265 which files are │ │ │ -00062920: 2063 6f6d 706c 6574 6520 616e 6420 6a75 complete and ju │ │ │ -00062930: 7374 206c 6f6f 6b20 6174 2074 686f 7365 st look at those │ │ │ -00062940: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    th │ │ │ -00062990: 6973 2063 6f75 6c64 2062 6520 6f70 7469 is could be opti │ │ │ -000629a0: 6d69 7a65 6420 6279 206c 6f6f 6b69 6e67 mized by looking │ │ │ -000629b0: 2075 7020 7768 6963 6820 6669 6c65 7320 up which files │ │ │ -000629c0: 6172 650a 636f 6d70 6c65 7465 2061 6e64 are.complete and │ │ │ -000629d0: 206a 7573 7420 6c6f 6f6b 2061 7420 7468 just look at th │ │ │ -000629e0: 6f73 653c 2f68 323e 3c68 343e 2e2e 2f73 ose

    ../s │ │ │ -000629f0: 7263 2f74 6f72 7265 6e74 2e63 7070 3a32 rc/torrent.cpp:2 │ │ │ -00062a00: 3039 343c 2f68 343e 3c70 7265 2073 7479 094

    //....TORRENT_
    │ │ │ -00062a50: 4153 5345 5254 2870 6963 6b65 7228 292e  ASSERT(picker().
    │ │ │ -00062a60: 6861 7665 5f70 6965 6365 2869 2929 3b0a  have_piece(i));.
    │ │ │ -00062a70: 0909 0909 7765 5f68 6176 6528 6929 3b0a  ....we_have(i);.
    │ │ │ -00062a80: 0909 097d 0a09 097d 0a0a 0909 7365 745f  ...}...}....set_
    │ │ │ -00062a90: 7374 6174 6528 746f 7272 656e 745f 7374  state(torrent_st
    │ │ │ -00062aa0: 6174 7573 3a3a 6368 6563 6b69 6e67 5f72  atus::checking_r
    │ │ │ -00062ab0: 6573 756d 655f 6461 7461 293b 0a0a 0909  esume_data);....
    │ │ │ -00062ac0: 6175 783a 3a76 6563 746f 7226 6c74 3b73  aux::vector<s
    │ │ │ -00062ad0: 7464 3a3a 7374 7269 6e67 2c20 6669 6c65  td::string, file
    │ │ │ -00062ae0: 5f69 6e64 6578 5f74 2667 743b 206c 696e  _index_t> lin
    │ │ │ -00062af0: 6b73 3b0a 2369 666e 6465 6620 544f 5252  ks;.#ifndef TORR
    │ │ │ -00062b00: 454e 545f 4449 5341 424c 455f 4d55 5441  ENT_DISABLE_MUTA
    │ │ │ -00062b10: 424c 455f 544f 5252 454e 5453 0a09 0969  BLE_TORRENTS...i
    │ │ │ -00062b20: 6620 2821 6d5f 746f 7272 656e 745f 6669  f (!m_torrent_fi
    │ │ │ -00062b30: 6c65 2d26 6774 3b73 696d 696c 6172 5f74  le->similar_t
    │ │ │ -00062b40: 6f72 7265 6e74 7328 292e 656d 7074 7928  orrents().empty(
    │ │ │ -00062b50: 290a 0909 097c 7c20 216d 5f74 6f72 7265  )....|| !m_torre
    │ │ │ -00062b60: 6e74 5f66 696c 652d 2667 743b 636f 6c6c  nt_file->coll
    │ │ │ -00062b70: 6563 7469 6f6e 7328 292e 656d 7074 7928  ections().empty(
    │ │ │ -00062b80: 2929 0a09 097b 0a09 0909 7265 736f 6c76  ))...{....resolv
    │ │ │ -00062b90: 655f 6c69 6e6b 7320 7265 7328 6d5f 746f  e_links res(m_to
    │ │ │ -00062ba0: 7272 656e 745f 6669 6c65 293b 0a0a 0909  rrent_file);....
    │ │ │ -00062bb0: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ -00062bc0: 2661 6d70 3b20 6968 203a 206d 5f74 6f72  & ih : m_tor
    │ │ │ -00062bd0: 7265 6e74 5f66 696c 652d 2667 743b 7369  rent_file->si
    │ │ │ -00062be0: 6d69 6c61 725f 746f 7272 656e 7473 2829  milar_torrents()
    │ │ │ -00062bf0: 290a 0909 097b 0a09 0909 0973 7464 3a3a  )....{.....std::
    │ │ │ -00062c00: 7368 6172 6564 5f70 7472 266c 743b 746f  shared_ptr<to
    │ │ │ -00062c10: 7272 656e 7426 6774 3b20 7420 3d20 6d5f  rrent> t = m_
    │ │ │ -00062c20: 7365 732e 6669 6e64 5f74 6f72 7265 6e74  ses.find_torrent
    │ │ │ -00062c30: 2869 6e66 6f5f 6861 7368 5f74 2869 6829  (info_hash_t(ih)
    │ │ │ -00062c40: 292e 6c6f 636b 2829 3b0a 0909 0909 6966  ).lock();.....if
    │ │ │ -00062c50: 2028 2174 2920 636f 6e74 696e 7565 3b0a   (!t) continue;.
    │ │ │ -00062c60: 0a09 0909 092f 2f20 4f6e 6c79 2061 7474  .....// Only att
    │ │ │ -00062c70: 656d 7074 2074 6f20 7265 7573 6520 6669  empt to reuse fi
    │ │ │ -00062c80: 6c65 7320 6672 6f6d 2074 6f72 7265 6e74  les from torrent
    │ │ │ -00062c90: 7320 7468 6174 2061 7265 2073 6565 6469  s that are seedi
    │ │ │ -00062ca0: 6e67 2e0a 3c64 6976 2073 7479 6c65 3d22  ng..
    ....if (!t-> │ │ │ -00062ce0: 3b69 735f 7365 6564 2829 2920 636f 6e74 ;is_seed()) cont │ │ │ -00062cf0: 696e 7565 3b0a 3c2f 6469 763e 0a09 0909 inue;.
    .... │ │ │ -00062d00: 0961 7574 6f20 7469 203d 2074 2d26 6774 .auto ti = t-> │ │ │ -00062d10: 3b67 6574 5f74 6f72 7265 6e74 5f66 696c ;get_torrent_fil │ │ │ -00062d20: 6528 293b 0a09 0909 0972 6573 2e6d 6174 e();.....res.mat │ │ │ -00062d30: 6368 282a 7469 2c20 6669 6c65 6e61 6d65 ch(*ti, filename │ │ │ -00062d40: 7328 7469 2d26 6774 3b6c 6179 6f75 7428 s(ti->layout( │ │ │ -00062d50: 292c 2074 2d26 6774 3b6d 5f72 656e 616d ), t->m_renam │ │ │ -00062d60: 6564 5f66 696c 6573 292c 2074 2d26 6774 ed_files), t-> │ │ │ -00062d70: 3b73 6176 655f 7061 7468 2829 293b 0a09 ;save_path());.. │ │ │ -00062d80: 0909 7d0a 0909 0966 6f72 2028 6175 746f ..}....for (auto │ │ │ -00062d90: 2063 6f6e 7374 2661 6d70 3b20 6320 3a20 const& c : │ │ │ -00062da0: 6d5f 746f 7272 656e 745f 6669 6c65 2d26 m_torrent_file-& │ │ │ -00062db0: 6774 3b63 6f6c 6c65 6374 696f 6e73 2829 gt;collections() │ │ │ -00062dc0: 290a 0909 097b 0a09 0909 0973 7464 3a3a )....{.....std:: │ │ │ -00062dd0: 7665 6374 6f72 266c 743b 7374 643a 3a73 vector<std::s │ │ │ -00062de0: 6861 7265 645f 7074 7226 6c74 3b74 6f72 hared_ptr<tor │ │ │ -00062df0: 7265 6e74 2667 743b 2667 743b 2074 7320 rent>> ts │ │ │ -00062e00: 3d20 6d5f 7365 732e 6669 6e64 5f63 6f6c = m_ses.find_col │ │ │ -00062e10: 6c65 6374 696f 6e28 6329 3b0a 0a09 0909 lection(c);..... │ │ │ -00062e20: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ -00062e30: 2661 6d70 3b20 7420 3a20 7473 290a 0909 & t : ts)... │ │ │ -00062e40: 0909 7b0a 0909 0909 092f 2f20 4f6e 6c79 ..{......// Only │ │ │ -00062e50: 2061 7474 656d 7074 2074 6f20 7265 7573 attempt to reus │ │ │ -00062e60: 6520 6669 6c65 7320 6672 6f6d 2074 6f72 e files from tor │ │ │ -00062e70: 7265 6e74 7320 7468 6174 2061 7265 2073 rents that are s │ │ │ -00062e80: 6565 6469 6e67 2e0a 3c2f 7072 653e 3c2f eeding..
    relevan │ │ │ -00062ec0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0
    ../src/torren │ │ │ -00062f00: 742e 6370 703a 3231 3038 3c2f 613e 3c2f t.cpp:2108this coul │ │ │ -00062f20: 6420 6265 206f 7074 696d 697a 6564 2062 d be optimized b │ │ │ -00062f30: 7920 6c6f 6f6b 696e 6720 7570 2077 6869 y looking up whi │ │ │ -00062f40: 6368 2066 696c 6573 2061 7265 2063 6f6d ch files are com │ │ │ -00062f50: 706c 6574 6520 616e 6420 6a75 7374 206c plete and just l │ │ │ -00062f60: 6f6f 6b20 6174 2074 686f 7365 3c2f 7464 ook at those

    this c │ │ │ -00062fc0: 6f75 6c64 2062 6520 6f70 7469 6d69 7a65 ould be optimize │ │ │ -00062fd0: 6420 6279 206c 6f6f 6b69 6e67 2075 7020 d by looking up │ │ │ -00062fe0: 7768 6963 6820 6669 6c65 7320 6172 650a which files are. │ │ │ -00062ff0: 636f 6d70 6c65 7465 2061 6e64 206a 7573 complete and jus │ │ │ -00063000: 7420 6c6f 6f6b 2061 7420 7468 6f73 653c t look at those< │ │ │ -00063010: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ -00063020: 6f72 7265 6e74 2e63 7070 3a32 3130 383c orrent.cpp:2108< │ │ │ -00063030: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -00063070: 0972 6573 6f6c 7665 5f6c 696e 6b73 2072  .resolve_links r
    │ │ │ -00063080: 6573 286d 5f74 6f72 7265 6e74 5f66 696c  es(m_torrent_fil
    │ │ │ -00063090: 6529 3b0a 0a09 0909 666f 7220 2861 7574  e);.....for (aut
    │ │ │ -000630a0: 6f20 636f 6e73 7426 616d 703b 2069 6820  o const& ih 
    │ │ │ -000630b0: 3a20 6d5f 746f 7272 656e 745f 6669 6c65  : m_torrent_file
    │ │ │ -000630c0: 2d26 6774 3b73 696d 696c 6172 5f74 6f72  ->similar_tor
    │ │ │ -000630d0: 7265 6e74 7328 2929 0a09 0909 7b0a 0909  rents())....{...
    │ │ │ -000630e0: 0909 7374 643a 3a73 6861 7265 645f 7074  ..std::shared_pt
    │ │ │ -000630f0: 7226 6c74 3b74 6f72 7265 6e74 2667 743b  r<torrent>
    │ │ │ -00063100: 2074 203d 206d 5f73 6573 2e66 696e 645f   t = m_ses.find_
    │ │ │ -00063110: 746f 7272 656e 7428 696e 666f 5f68 6173  torrent(info_has
    │ │ │ -00063120: 685f 7428 6968 2929 2e6c 6f63 6b28 293b  h_t(ih)).lock();
    │ │ │ -00063130: 0a09 0909 0969 6620 2821 7429 2063 6f6e  .....if (!t) con
    │ │ │ -00063140: 7469 6e75 653b 0a0a 0909 0909 2f2f 204f  tinue;......// O
    │ │ │ -00063150: 6e6c 7920 6174 7465 6d70 7420 746f 2072  nly attempt to r
    │ │ │ -00063160: 6575 7365 2066 696c 6573 2066 726f 6d20  euse files from 
    │ │ │ -00063170: 746f 7272 656e 7473 2074 6861 7420 6172  torrents that ar
    │ │ │ -00063180: 6520 7365 6564 696e 672e 0a09 0909 0969  e seeding......i
    │ │ │ -00063190: 6620 2821 742d 2667 743b 6973 5f73 6565  f (!t->is_see
    │ │ │ -000631a0: 6428 2929 2063 6f6e 7469 6e75 653b 0a0a  d()) continue;..
    │ │ │ -000631b0: 0909 0909 6175 746f 2074 6920 3d20 742d  ....auto ti = t-
    │ │ │ -000631c0: 2667 743b 6765 745f 746f 7272 656e 745f  >get_torrent_
    │ │ │ -000631d0: 6669 6c65 2829 3b0a 0909 0909 7265 732e  file();.....res.
    │ │ │ -000631e0: 6d61 7463 6828 2a74 692c 2066 696c 656e  match(*ti, filen
    │ │ │ -000631f0: 616d 6573 2874 692d 2667 743b 6c61 796f  ames(ti->layo
    │ │ │ -00063200: 7574 2829 2c20 742d 2667 743b 6d5f 7265  ut(), t->m_re
    │ │ │ -00063210: 6e61 6d65 645f 6669 6c65 7329 2c20 742d  named_files), t-
    │ │ │ -00063220: 2667 743b 7361 7665 5f70 6174 6828 2929  >save_path())
    │ │ │ -00063230: 3b0a 0909 097d 0a09 0909 666f 7220 2861  ;....}....for (a
    │ │ │ -00063240: 7574 6f20 636f 6e73 7426 616d 703b 2063  uto const& c
    │ │ │ -00063250: 203a 206d 5f74 6f72 7265 6e74 5f66 696c   : m_torrent_fil
    │ │ │ -00063260: 652d 2667 743b 636f 6c6c 6563 7469 6f6e  e->collection
    │ │ │ -00063270: 7328 2929 0a09 0909 7b0a 0909 0909 7374  s())....{.....st
    │ │ │ -00063280: 643a 3a76 6563 746f 7226 6c74 3b73 7464  d::vector<std
    │ │ │ -00063290: 3a3a 7368 6172 6564 5f70 7472 266c 743b  ::shared_ptr<
    │ │ │ -000632a0: 746f 7272 656e 7426 6774 3b26 6774 3b20  torrent>> 
    │ │ │ -000632b0: 7473 203d 206d 5f73 6573 2e66 696e 645f  ts = m_ses.find_
    │ │ │ -000632c0: 636f 6c6c 6563 7469 6f6e 2863 293b 0a0a  collection(c);..
    │ │ │ -000632d0: 0909 0909 666f 7220 2861 7574 6f20 636f  ....for (auto co
    │ │ │ -000632e0: 6e73 7426 616d 703b 2074 203a 2074 7329  nst& t : ts)
    │ │ │ -000632f0: 0a09 0909 097b 0a09 0909 0909 2f2f 204f  .....{......// O
    │ │ │ -00063300: 6e6c 7920 6174 7465 6d70 7420 746f 2072  nly attempt to r
    │ │ │ -00063310: 6575 7365 2066 696c 6573 2066 726f 6d20  euse files from 
    │ │ │ -00063320: 746f 7272 656e 7473 2074 6861 7420 6172  torrents that ar
    │ │ │ -00063330: 6520 7365 6564 696e 672e 0a3c 6469 7620  e seeding..
    .....if │ │ │ -00063370: 2028 2174 2d26 6774 3b69 735f 7365 6564 (!t->is_seed │ │ │ -00063380: 2829 2920 636f 6e74 696e 7565 3b0a 3c2f ()) continue;.......auto t │ │ │ -000633a0: 6920 3d20 742d 2667 743b 6765 745f 746f i = t->get_to │ │ │ -000633b0: 7272 656e 745f 6669 6c65 2829 3b0a 0909 rrent_file();... │ │ │ -000633c0: 0909 0972 6573 2e6d 6174 6368 282a 7469 ...res.match(*ti │ │ │ -000633d0: 2c20 6669 6c65 6e61 6d65 7328 7469 2d26 , filenames(ti-& │ │ │ -000633e0: 6774 3b6c 6179 6f75 7428 292c 2074 2d26 gt;layout(), t-& │ │ │ -000633f0: 6774 3b6d 5f72 656e 616d 6564 5f66 696c gt;m_renamed_fil │ │ │ -00063400: 6573 292c 2074 2d26 6774 3b73 6176 655f es), t->save_ │ │ │ -00063410: 7061 7468 2829 293b 0a09 0909 097d 0a09 path());.....}.. │ │ │ -00063420: 0909 7d0a 0a09 0909 6c69 6e6b 7320 3d20 ..}.....links = │ │ │ -00063430: 7374 643a 3a6d 6f76 6528 7265 7329 2e67 std::move(res).g │ │ │ -00063440: 6574 5f6c 696e 6b73 2829 3b0a 0909 7d0a et_links();...}. │ │ │ -00063450: 2365 6e64 6966 202f 2f20 544f 5252 454e #endif // TORREN │ │ │ -00063460: 545f 4449 5341 424c 455f 4d55 5441 424c T_DISABLE_MUTABL │ │ │ -00063470: 455f 544f 5252 454e 5453 0a0a 2369 6620 E_TORRENTS..#if │ │ │ -00063480: 544f 5252 454e 545f 5553 455f 4153 5345 TORRENT_USE_ASSE │ │ │ -00063490: 5254 530a 0909 544f 5252 454e 545f 4153 RTS...TORRENT_AS │ │ │ -000634a0: 5345 5254 286d 5f6f 7574 7374 616e 6469 SERT(m_outstandi │ │ │ -000634b0: 6e67 5f63 6865 636b 5f66 696c 6573 203d ng_check_files = │ │ │ -000634c0: 3d20 6661 6c73 6529 3b0a 0909 6d5f 6f75 = false);...m_ou │ │ │ -000634d0: 7473 7461 6e64 696e 675f 6368 6563 6b5f tstanding_check_ │ │ │ -000634e0: 6669 6c65 7320 3d20 7472 7565 3b0a 2365 files = true;.#e │ │ │ -000634f0: 6e64 6966 0a0a 0909 6966 2028 216d 5f61 ndif....if (!m_a │ │ │ -00063500: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -00063510: 7320 7c7c 2021 286d 5f61 6464 5f74 6f72 s || !(m_add_tor │ │ │ -00063520: 7265 6e74 5f70 6172 616d 732d 2667 743b rent_params-> │ │ │ -00063530: 666c 6167 7320 2661 6d70 3b20 746f 7272 flags & torr │ │ │ -00063540: 656e 745f 666c 6167 733a 3a6e 6f5f 7665 ent_flags::no_ve │ │ │ -00063550: 7269 6679 5f66 696c 6573 2929 0a09 097b rify_files))...{ │ │ │ -00063560: 0a09 0909 6d5f 7365 732e 6469 736b 5f74 ....m_ses.disk_t │ │ │ -00063570: 6872 6561 6428 292e 6173 796e 635f 6368 hread().async_ch │ │ │ -00063580: 6563 6b5f 6669 6c65 7328 0a09 0909 096d eck_files(.....m │ │ │ -00063590: 5f73 746f 7261 6765 2c20 6d5f 6164 645f _storage, m_add_ │ │ │ -000635a0: 746f 7272 656e 745f 7061 7261 6d73 203f torrent_params ? │ │ │ -000635b0: 206d 5f61 6464 5f74 6f72 7265 6e74 5f70 m_add_torrent_p │ │ │ -000635c0: 6172 616d 732e 6765 7428 2920 3a20 6e75 arams.get() : nu │ │ │ -000635d0: 6c6c 7074 720a 0909 0909 2c20 7374 643a llptr....., std: │ │ │ -000635e0: 3a6d 6f76 6528 6c69 6e6b 7329 2c20 5b73 :move(links), [s │ │ │ -000635f0: 656c 6620 3d20 7368 6172 6564 5f66 726f elf = shared_fro │ │ │ -00063600: 6d5f 7468 6973 2829 5d28 7374 6174 7573 m_this()](status │ │ │ -00063610: 5f74 2073 742c 2073 746f 7261 6765 5f65 _t st, storage_e │ │ │ -00063620: 7272 6f72 2063 6f6e 7374 2661 6d70 3b20 rror const& │ │ │ -00063630: 6572 726f 7229 0a09 0909 097b 2073 656c error).....{ sel │ │ │ -00063640: 662d 2667 743b 6f6e 5f72 6573 756d 655f f->on_resume_ │ │ │ -00063650: 6461 7461 5f63 6865 636b 6564 2873 742c data_checked(st, │ │ │ -00063660: 2065 7272 6f72 293b 207d 293b 0a23 6966 error); });.#if │ │ │ -00063670: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -00063680: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0909 ABLE_LOGGING.... │ │ │ -00063690: 6465 6275 675f 6c6f 6728 2269 6e69 742c debug_log("init, │ │ │ -000636a0: 2061 7379 6e63 5f63 6865 636b 5f66 696c async_check_fil │ │ │ -000636b0: 6573 2229 3b0a 2365 6e64 6966 0a09 0909 es");.#endif.... │ │ │ -000636c0: 6d5f 7365 732e 6465 6665 7272 6564 5f73 m_ses.deferred_s │ │ │ -000636d0: 7562 6d69 745f 6a6f 6273 2829 3b0a 0909 ubmit_jobs();... │ │ │ -000636e0: 7d0a 0909 656c 7365 0a09 097b 0a09 0909 }...else...{.... │ │ │ -000636f0: 6f6e 5f72 6573 756d 655f 6461 7461 5f63 on_resume_data_c │ │ │ -00063700: 6865 636b 6564 287b 7d2c 2073 746f 7261 hecked({}, stora │ │ │ -00063710: 6765 5f65 7272 6f72 7b7d 293b 0a09 097d ge_error{});...} │ │ │ -00063720: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00063760: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -00063790: 7263 2f74 6f72 7265 6e74 2e63 7070 3a32 rc/torrent.cpp:2 │ │ │ -000637a0: 3837 393c 2f61 3e3c 2f74 643e 3c74 643e 879 │ │ │ -000637b0: 7468 6973 2070 6174 7465 726e 2069 7320 this pattern is │ │ │ -000637c0: 7265 7065 6174 6564 2069 6e20 6120 6665 repeated in a fe │ │ │ -000637d0: 7720 706c 6163 6573 2e20 4661 6374 6f72 w places. Factor │ │ │ -000637e0: 2074 6869 7320 696e 746f 2061 2066 756e this into a fun │ │ │ -000637f0: 6374 696f 6e20 616e 6420 6765 6e65 7261 ction and genera │ │ │ -00063800: 6c69 7a65 2074 6865 2063 6f6e 6365 7074 lize the concept │ │ │ -00063810: 206f 6620 6120 746f 7272 656e 7420 6861 of a torrent ha │ │ │ -00063820: 7669 6e67 2061 2064 6564 6963 6174 6564 ving a dedicated │ │ │ -00063830: 206c 6973 7465 6e20 706f 7274 3c2f 7464 listen port

    this p │ │ │ -00063890: 6174 7465 726e 2069 7320 7265 7065 6174 attern is repeat │ │ │ -000638a0: 6564 2069 6e20 6120 6665 7720 706c 6163 ed in a few plac │ │ │ -000638b0: 6573 2e20 4661 6374 6f72 2074 6869 7320 es. Factor this │ │ │ -000638c0: 696e 746f 0a61 2066 756e 6374 696f 6e20 into.a function │ │ │ -000638d0: 616e 6420 6765 6e65 7261 6c69 7a65 2074 and generalize t │ │ │ -000638e0: 6865 2063 6f6e 6365 7074 206f 6620 6120 he concept of a │ │ │ -000638f0: 746f 7272 656e 7420 6861 7669 6e67 2061 torrent having a │ │ │ -00063900: 0a64 6564 6963 6174 6564 206c 6973 7465 .dedicated liste │ │ │ -00063910: 6e20 706f 7274 3c2f 6832 3e3c 6834 3e2e n port

    . │ │ │ -00063920: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -00063930: 703a 3238 3739 3c2f 6834 3e3c 7072 6520 p:2879

    ..// not re
    │ │ │ -00063980: 6164 7920 666f 7220 7065 6572 732e 2045  ady for peers. E
    │ │ │ -00063990: 7863 6570 742c 2069 6620 7765 2064 6f6e  xcept, if we don
    │ │ │ -000639a0: 2774 2068 6176 6520 6d65 7461 6461 7461  't have metadata
    │ │ │ -000639b0: 2c0a 0909 2f2f 2077 6520 6e65 6564 2070  ,...// we need p
    │ │ │ -000639c0: 6565 7273 2074 6f20 646f 776e 6c6f 6164  eers to download
    │ │ │ -000639d0: 2066 726f 6d0a 0909 6966 2028 216d 5f66   from...if (!m_f
    │ │ │ -000639e0: 696c 6573 5f63 6865 636b 6564 2026 616d  iles_checked &am
    │ │ │ -000639f0: 703b 2661 6d70 3b20 7661 6c69 645f 6d65  p;& valid_me
    │ │ │ -00063a00: 7461 6461 7461 2829 2920 7265 7475 726e  tadata()) return
    │ │ │ -00063a10: 3b0a 0a09 0969 6620 2821 6d5f 616e 6e6f  ;....if (!m_anno
    │ │ │ -00063a20: 756e 6365 5f74 6f5f 6c73 6429 2072 6574  unce_to_lsd) ret
    │ │ │ -00063a30: 7572 6e3b 0a0a 0909 2f2f 2070 7269 7661  urn;....// priva
    │ │ │ -00063a40: 7465 2074 6f72 7265 6e74 7320 6172 6520  te torrents are 
    │ │ │ -00063a50: 6e65 7665 7220 616e 6e6f 756e 6365 6420  never announced 
    │ │ │ -00063a60: 6f6e 204c 5344 0a09 0969 6620 286d 5f74  on LSD...if (m_t
    │ │ │ -00063a70: 6f72 7265 6e74 5f66 696c 652d 2667 743b  orrent_file->
    │ │ │ -00063a80: 6973 5f76 616c 6964 2829 2026 616d 703b  is_valid() &
    │ │ │ -00063a90: 2661 6d70 3b20 6d5f 746f 7272 656e 745f  & m_torrent_
    │ │ │ -00063aa0: 6669 6c65 2d26 6774 3b70 7269 7628 2929  file->priv())
    │ │ │ -00063ab0: 2072 6574 7572 6e3b 0a0a 2369 6620 544f   return;..#if TO
    │ │ │ -00063ac0: 5252 454e 545f 5553 455f 4932 500a 0909  RRENT_USE_I2P...
    │ │ │ -00063ad0: 2f2f 2069 3270 2074 6f72 7265 6e74 7320  // i2p torrents 
    │ │ │ -00063ae0: 6172 6520 616c 736f 206e 6576 6572 2061  are also never a
    │ │ │ -00063af0: 6e6e 6f75 6e63 6564 206f 6e20 4c53 440a  nnounced on LSD.
    │ │ │ -00063b00: 0909 2f2f 2075 6e6c 6573 7320 7765 2061  ..// unless we a
    │ │ │ -00063b10: 6c6c 6f77 206d 6978 6564 2073 7761 726d  llow mixed swarm
    │ │ │ -00063b20: 730a 0909 6966 2028 6973 5f69 3270 2829  s...if (is_i2p()
    │ │ │ -00063b30: 2026 616d 703b 2661 6d70 3b20 2173 6574   && !set
    │ │ │ -00063b40: 7469 6e67 7328 292e 6765 745f 626f 6f6c  tings().get_bool
    │ │ │ -00063b50: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ -00063b60: 616c 6c6f 775f 6932 705f 6d69 7865 6429  allow_i2p_mixed)
    │ │ │ -00063b70: 290a 0909 0972 6574 7572 6e3b 0a23 656e  )....return;.#en
    │ │ │ -00063b80: 6469 660a 0a09 0969 6620 2869 735f 7061  dif....if (is_pa
    │ │ │ -00063b90: 7573 6564 2829 2920 7265 7475 726e 3b0a  used()) return;.
    │ │ │ -00063ba0: 0a09 0969 6620 2821 6d5f 7365 732e 6861  ...if (!m_ses.ha
    │ │ │ -00063bb0: 735f 6c73 6428 2929 2072 6574 7572 6e3b  s_lsd()) return;
    │ │ │ -00063bc0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00063bf0: 2369 6664 6566 2054 4f52 5245 4e54 5f53 #ifdef TORRENT_S │ │ │ -00063c00: 534c 5f50 4545 5253 0a3c 2f64 6976 3e09 SL_PEERS.
    . │ │ │ -00063c10: 0969 6e74 2070 6f72 7420 3d20 6973 5f73 .int port = is_s │ │ │ -00063c20: 736c 5f74 6f72 7265 6e74 2829 203f 206d sl_torrent() ? m │ │ │ -00063c30: 5f73 6573 2e73 736c 5f6c 6973 7465 6e5f _ses.ssl_listen_ │ │ │ -00063c40: 706f 7274 2829 203a 206d 5f73 6573 2e6c port() : m_ses.l │ │ │ -00063c50: 6973 7465 6e5f 706f 7274 2829 3b0a 2365 isten_port();.#e │ │ │ -00063c60: 6c73 650a 0909 696e 7420 706f 7274 203d lse...int port = │ │ │ -00063c70: 206d 5f73 6573 2e6c 6973 7465 6e5f 706f m_ses.listen_po │ │ │ -00063c80: 7274 2829 3b0a 2365 6e64 6966 0a0a 0909 rt();.#endif.... │ │ │ -00063c90: 2f2f 2061 6e6e 6f75 6e63 6520 7769 7468 // announce with │ │ │ -00063ca0: 2074 6865 206c 6f63 616c 2064 6973 636f the local disco │ │ │ -00063cb0: 7665 7279 2073 6572 7669 6365 0a09 096d very service...m │ │ │ -00063cc0: 5f74 6f72 7265 6e74 5f66 696c 652d 2667 _torrent_file-&g │ │ │ -00063cd0: 743b 696e 666f 5f68 6173 6865 7328 292e t;info_hashes(). │ │ │ -00063ce0: 666f 725f 6561 6368 285b 2661 6d70 3b5d for_each([&] │ │ │ -00063cf0: 2873 6861 315f 6861 7368 2063 6f6e 7374 (sha1_hash const │ │ │ -00063d00: 2661 6d70 3b20 6968 2c20 7072 6f74 6f63 & ih, protoc │ │ │ -00063d10: 6f6c 5f76 6572 7369 6f6e 290a 0909 7b0a ol_version)...{. │ │ │ -00063d20: 0909 096d 5f73 6573 2e61 6e6e 6f75 6e63 ...m_ses.announc │ │ │ -00063d30: 655f 6c73 6428 6968 2c20 706f 7274 293b e_lsd(ih, port); │ │ │ -00063d40: 0a09 097d 293b 0a09 7d0a 0a23 6966 6e64 ...});..}..#ifnd │ │ │ -00063d50: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ -00063d60: 4c45 5f44 4854 0a0a 0976 6f69 6420 746f LE_DHT...void to │ │ │ -00063d70: 7272 656e 743a 3a64 6874 5f61 6e6e 6f75 rrent::dht_annou │ │ │ -00063d80: 6e63 6528 290a 097b 0a09 0954 4f52 5245 nce()..{...TORRE │ │ │ -00063d90: 4e54 5f41 5353 4552 5428 6973 5f73 696e NT_ASSERT(is_sin │ │ │ -00063da0: 676c 655f 7468 7265 6164 2829 293b 0a09 gle_thread());.. │ │ │ -00063db0: 0969 6620 2821 6d5f 7365 732e 6468 7428 .if (!m_ses.dht( │ │ │ -00063dc0: 2929 0a09 097b 0a23 6966 6e64 6566 2054 ))...{.#ifndef T │ │ │ -00063dd0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ -00063de0: 4f47 4749 4e47 0a09 0909 6465 6275 675f OGGING....debug_ │ │ │ -00063df0: 6c6f 6728 2244 4854 3a20 6e6f 2064 6874 log("DHT: no dht │ │ │ -00063e00: 2069 6e69 7469 616c 697a 6564 2229 3b0a initialized");. │ │ │ -00063e10: 2365 6e64 6966 0a09 0909 7265 7475 726e #endif....return │ │ │ -00063e20: 3b0a 0909 7d0a 0909 6966 2028 2173 686f ;...}...if (!sho │ │ │ -00063e30: 756c 645f 616e 6e6f 756e 6365 5f64 6874 uld_announce_dht │ │ │ -00063e40: 2829 290a 0909 7b0a 2369 666e 6465 6620 ())...{.#ifndef │ │ │ -00063e50: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00063e60: 4c4f 4747 494e 470a 0909 0969 6620 2873 LOGGING....if (s │ │ │ -00063e70: 686f 756c 645f 6c6f 6728 2929 0a09 0909 hould_log()).... │ │ │ -00063e80: 7b0a 2369 6620 544f 5252 454e 545f 5553 {.#if TORRENT_US │ │ │ -00063e90: 455f 4932 500a 3c2f 7072 653e 3c2f 7464 E_I2P.
    relevance │ │ │ -00063ed0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00063ee0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent. │ │ │ -00063f10: 6370 703a 3332 3234 3c2f 613e 3c2f 7464 cpp:3224it would be │ │ │ -00063f30: 206e 6963 6520 746f 2072 6169 7365 2074 nice to raise t │ │ │ -00063f40: 6865 2061 6273 7472 6163 7469 6f6e 206c he abstraction l │ │ │ -00063f50: 6576 656c 206f 6620 7468 6520 7472 6163 evel of the trac │ │ │ -00063f60: 6b65 725f 6c69 7374 206f 7220 7472 6163 ker_list or trac │ │ │ -00063f70: 6b65 7273 2061 2062 6974 2068 6572 653c kers a bit here< │ │ │ -00063f80: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ -00063fd0: 776f 756c 6420 6265 206e 6963 6520 746f would be nice to │ │ │ -00063fe0: 2072 6169 7365 2074 6865 2061 6273 7472 raise the abstr │ │ │ -00063ff0: 6163 7469 6f6e 206c 6576 656c 206f 6620 action level of │ │ │ -00064000: 7468 650a 7472 6163 6b65 725f 6c69 7374 the.tracker_list │ │ │ -00064010: 206f 7220 7472 6163 6b65 7273 2061 2062 or trackers a b │ │ │ -00064020: 6974 2068 6572 653c 2f68 323e 3c68 343e it here

    │ │ │ -00064030: 2e2e 2f73 7263 2f74 6f72 7265 6e74 2e63 ../src/torrent.c │ │ │ -00064040: 7070 3a33 3232 343c 2f68 343e 3c70 7265 pp:3224

    ..time_poi
    │ │ │ -00064090: 6e74 3332 2063 6f6e 7374 206e 6f77 203d  nt32 const now =
    │ │ │ -000640a0: 2061 7578 3a3a 7469 6d65 5f6e 6f77 3332   aux::time_now32
    │ │ │ -000640b0: 2829 3b0a 0a09 092f 2f20 6561 6368 206c  ();....// each l
    │ │ │ -000640c0: 6973 7465 6e20 736f 636b 6574 2067 6574  isten socket get
    │ │ │ -000640d0: 7320 6974 7320 6f77 6e20 616e 6e6f 756e  s its own announ
    │ │ │ -000640e0: 6365 2073 7461 7465 0a09 092f 2f20 736f  ce state...// so
    │ │ │ -000640f0: 2074 6861 7420 6561 6368 206f 6e65 2073   that each one s
    │ │ │ -00064100: 686f 756c 6420 6765 7420 6174 206c 6561  hould get at lea
    │ │ │ -00064110: 7374 206f 6e65 2061 6e6e 6f75 6e63 650a  st one announce.
    │ │ │ -00064120: 0909 7374 643a 3a76 6563 746f 7226 6c74  ..std::vector<
    │ │ │ -00064130: 3b61 6e6e 6f75 6e63 655f 7374 6174 6526  ;announce_state&
    │ │ │ -00064140: 6774 3b20 6c69 7374 656e 5f73 6f63 6b65  gt; listen_socke
    │ │ │ -00064150: 745f 7374 6174 6573 3b0a 0a09 0962 6f6f  t_states;....boo
    │ │ │ -00064160: 6c20 636f 6e73 7420 616e 6e6f 756e 6365  l const announce
    │ │ │ -00064170: 5f74 6f5f 616c 6c5f 7469 6572 7320 3d20  _to_all_tiers = 
    │ │ │ -00064180: 7365 7474 696e 6773 2829 2e67 6574 5f62  settings().get_b
    │ │ │ -00064190: 6f6f 6c28 7365 7474 696e 6773 5f70 6163  ool(settings_pac
    │ │ │ -000641a0: 6b3a 3a61 6e6e 6f75 6e63 655f 746f 5f61  k::announce_to_a
    │ │ │ -000641b0: 6c6c 5f74 6965 7273 293b 0a09 0962 6f6f  ll_tiers);...boo
    │ │ │ -000641c0: 6c20 636f 6e73 7420 616e 6e6f 756e 6365  l const announce
    │ │ │ -000641d0: 5f74 6f5f 616c 6c5f 7472 6163 6b65 7273  _to_all_trackers
    │ │ │ -000641e0: 203d 2073 6574 7469 6e67 7328 292e 6765   = settings().ge
    │ │ │ -000641f0: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ -00064200: 7061 636b 3a3a 616e 6e6f 756e 6365 5f74  pack::announce_t
    │ │ │ -00064210: 6f5f 616c 6c5f 7472 6163 6b65 7273 293b  o_all_trackers);
    │ │ │ -00064220: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -00064230: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ -00064240: 0a09 0969 6e74 2069 6478 203d 202d 313b  ...int idx = -1;
    │ │ │ -00064250: 0a09 0969 6620 2873 686f 756c 645f 6c6f  ...if (should_lo
    │ │ │ -00064260: 6728 2929 0a09 097b 0a09 0909 6465 6275  g())...{....debu
    │ │ │ -00064270: 675f 6c6f 6728 222a 2a2a 2061 6e6e 6f75  g_log("*** annou
    │ │ │ -00064280: 6e63 653a 2022 0a09 0909 0922 5b20 616e  nce: "....."[ an
    │ │ │ -00064290: 6e6f 756e 6365 5f74 6f5f 616c 6c5f 7469  nounce_to_all_ti
    │ │ │ -000642a0: 6572 733a 2025 6420 616e 6e6f 756e 6365  ers: %d announce
    │ │ │ -000642b0: 5f74 6f5f 616c 6c5f 7472 6163 6b65 7273  _to_all_trackers
    │ │ │ -000642c0: 3a20 2564 206e 756d 5f74 7261 636b 6572  : %d num_tracker
    │ │ │ -000642d0: 733a 2025 6420 5d22 0a09 0909 092c 2061  s: %d ]"....., a
    │ │ │ -000642e0: 6e6e 6f75 6e63 655f 746f 5f61 6c6c 5f74  nnounce_to_all_t
    │ │ │ -000642f0: 6965 7273 0a09 0909 092c 2061 6e6e 6f75  iers....., annou
    │ │ │ -00064300: 6e63 655f 746f 5f61 6c6c 5f74 7261 636b  nce_to_all_track
    │ │ │ -00064310: 6572 730a 0909 0909 2c20 696e 7428 6d5f  ers....., int(m_
    │ │ │ -00064320: 7472 6163 6b65 7273 2e73 697a 6528 2929  trackers.size())
    │ │ │ -00064330: 293b 0a09 097d 0a23 656e 6469 660a 0a3c  );...}.#endif..<
    │ │ │ -00064340: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -00064350: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -00064360: 7769 6474 683d 2231 3030 2522 3e09 0966  width="100%">..f
    │ │ │ -00064370: 6f72 2028 6175 746f 2661 6d70 3b20 6165  or (auto& ae
    │ │ │ -00064380: 203a 206d 5f74 7261 636b 6572 7329 0a3c   : m_trackers).<
    │ │ │ -00064390: 2f64 6976 3e09 097b 0a23 6966 6e64 6566  /div>..{.#ifndef
    │ │ │ -000643a0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ -000643b0: 5f4c 4f47 4749 4e47 0a09 0909 2b2b 6964  _LOGGING....++id
    │ │ │ -000643c0: 783b 0a23 656e 6469 660a 0909 0972 6566  x;.#endif....ref
    │ │ │ -000643d0: 7265 7368 5f65 6e64 706f 696e 745f 6c69  resh_endpoint_li
    │ │ │ -000643e0: 7374 286d 5f73 6573 2c20 6973 5f73 736c  st(m_ses, is_ssl
    │ │ │ -000643f0: 5f74 6f72 7265 6e74 2829 2c20 626f 6f6c  _torrent(), bool
    │ │ │ -00064400: 286d 5f63 6f6d 706c 6574 655f 7365 6e74  (m_complete_sent
    │ │ │ -00064410: 292c 2061 6529 3b0a 0a09 0909 2f2f 2069  ), ae);.....// i
    │ │ │ -00064420: 6620 7472 6163 6b65 7269 6420 6973 206e  f trackerid is n
    │ │ │ -00064430: 6f74 2073 7065 6369 6669 6564 2066 6f72  ot specified for
    │ │ │ -00064440: 2074 7261 636b 6572 2075 7365 2064 6566   tracker use def
    │ │ │ -00064450: 6175 6c74 206f 6e65 2c20 7072 6f62 6162  ault one, probab
    │ │ │ -00064460: 6c79 2073 6574 2065 7870 6c69 6369 746c  ly set explicitl
    │ │ │ -00064470: 790a 0909 0972 6571 2e74 7261 636b 6572  y....req.tracker
    │ │ │ -00064480: 6964 203d 2061 652e 7472 6163 6b65 7269  id = ae.trackeri
    │ │ │ -00064490: 642e 656d 7074 7928 2920 3f20 6d5f 7472  d.empty() ? m_tr
    │ │ │ -000644a0: 6163 6b65 7269 6420 3a20 6165 2e74 7261  ackerid : ae.tra
    │ │ │ -000644b0: 636b 6572 6964 3b0a 0909 0972 6571 2e75  ckerid;....req.u
    │ │ │ -000644c0: 726c 203d 2061 652e 7572 6c3b 0a0a 2369  rl = ae.url;..#i
    │ │ │ -000644d0: 6620 544f 5252 454e 545f 5553 455f 4932  f TORRENT_USE_I2
    │ │ │ -000644e0: 500a 0909 092f 2f20 6966 2077 6520 646f  P....// if we do
    │ │ │ -000644f0: 6e27 7420 616c 6c6f 7720 6d69 7869 6e67  n't allow mixing
    │ │ │ -00064500: 206e 6f72 6d61 6c20 7065 6572 7320 696e   normal peers in
    │ │ │ -00064510: 746f 2074 6869 7320 6932 7020 746f 7272  to this i2p torr
    │ │ │ -00064520: 656e 742c 0a09 0909 2f2f 2073 6b69 7020  ent,....// skip 
    │ │ │ -00064530: 6e6f 6e2d 6932 7020 7472 6163 6b65 7273  non-i2p trackers
    │ │ │ -00064540: 2e20 7570 6461 7465 5f74 7261 636b 6572  . update_tracker
    │ │ │ -00064550: 5f74 696d 6572 2829 2061 7070 6c69 6573  _timer() applies
    │ │ │ -00064560: 2074 6865 0a09 0909 2f2f 2073 616d 6520   the....// same 
    │ │ │ -00064570: 736b 6970 2073 6f20 7468 6520 7469 6d65  skip so the time
    │ │ │ -00064580: 7220 646f 6573 6e27 7420 6b65 6570 2066  r doesn't keep f
    │ │ │ -00064590: 6972 696e 6720 666f 7220 7472 6163 6b65  iring for tracke
    │ │ │ -000645a0: 7273 2077 6527 6c6c 0a09 0909 2f2f 206e  rs we'll....// n
    │ │ │ -000645b0: 6576 6572 2063 6f6e 7461 6374 2e0a 0909  ever contact....
    │ │ │ -000645c0: 0969 6620 2821 6932 705f 636f 6d70 6174  .if (!i2p_compat
    │ │ │ -000645d0: 6962 6c65 5f74 7261 636b 6572 2861 6529  ible_tracker(ae)
    │ │ │ -000645e0: 2920 636f 6e74 696e 7565 3b0a 0909 092f  ) continue;..../
    │ │ │ -000645f0: 2f20 7265 7120 6973 2072 6575 7365 6420  / req is reused 
    │ │ │ -00064600: 6163 726f 7373 2069 7465 7261 7469 6f6e  across iteration
    │ │ │ -00064610: 732c 2073 6f20 7365 7420 7468 6520 6932  s, so set the i2
    │ │ │ -00064620: 7020 6269 7420 746f 206d 6174 6368 0a09  p bit to match..
    │ │ │ -00064630: 0909 2f2f 2074 6869 7320 7472 6163 6b65  ..// this tracke
    │ │ │ -00064640: 7220 7261 7468 6572 2074 6861 6e20 6f6e  r rather than on
    │ │ │ -00064650: 6c79 2065 7665 7220 4f52 2d69 6e67 2069  ly ever OR-ing i
    │ │ │ -00064660: 7420 696e 2e0a 0909 0969 6620 2861 652e  t in.....if (ae.
    │ │ │ -00064670: 6932 7029 0a09 0909 0972 6571 2e6b 696e  i2p).....req.kin
    │ │ │ -00064680: 6420 7c3d 2074 7261 636b 6572 5f72 6571  d |= tracker_req
    │ │ │ -00064690: 7565 7374 3a3a 6932 703b 0a09 0909 656c  uest::i2p;....el
    │ │ │ -000646a0: 7365 0a09 0909 0972 6571 2e6b 696e 6420  se.....req.kind 
    │ │ │ -000646b0: 2661 6d70 3b3d 207e 7472 6163 6b65 725f  &= ~tracker_
    │ │ │ -000646c0: 7265 7175 6573 743a 3a69 3270 3b0a 2365  request::i2p;.#e
    │ │ │ -000646d0: 6e64 6966 0a0a 0909 0966 6f72 2028 6175  ndif.....for (au
    │ │ │ -000646e0: 746f 2661 6d70 3b20 6165 7020 3a20 6165  to& aep : ae
    │ │ │ -000646f0: 2e65 6e64 706f 696e 7473 290a 0909 097b  .endpoints)....{
    │ │ │ -00064700: 0a09 0909 092f 2f20 646f 206e 6f74 2061  .....// do not a
    │ │ │ -00064710: 6464 2063 6f64 6520 7768 6963 6820 636f  dd code which co
    │ │ │ -00064720: 6e74 696e 7565 7320 746f 2074 6865 206e  ntinues to the n
    │ │ │ -00064730: 6578 7420 656e 6470 6f69 6e74 2068 6572  ext endpoint her
    │ │ │ -00064740: 6521 0a09 0909 092f 2f20 6c69 7374 656e  e!.....// listen
    │ │ │ -00064750: 5f73 6f63 6b65 745f 7374 6174 6573 206e  _socket_states n
    │ │ │ -00064760: 6565 6473 2074 6f20 6265 2070 6f70 756c  eeds to be popul
    │ │ │ -00064770: 6174 6564 2065 7665 6e20 6966 206e 6f6e  ated even if non
    │ │ │ -00064780: 6520 6f66 2074 6865 2065 6e64 706f 696e  e of the endpoin
    │ │ │ -00064790: 7473 0a09 0909 092f 2f20 7769 6c6c 2062  ts.....// will b
    │ │ │ -000647a0: 6520 616e 6e6f 756e 6369 6e67 2066 6f72  e announcing for
    │ │ │ -000647b0: 2074 6869 7320 7472 6163 6b65 720a 0909   this tracker...
    │ │ │ -000647c0: 0909 2f2f 206f 7468 6572 7769 7365 2074  ..// otherwise t
    │ │ │ -000647d0: 6865 2065 6172 6c79 2062 6169 6c20 6f75  he early bail ou
    │ │ │ -000647e0: 7420 7768 656e 206e 6569 7468 6572 2061  t when neither a
    │ │ │ -000647f0: 6e6e 6f75 6e63 655f 746f 5f61 6c6c 5f74  nnounce_to_all_t
    │ │ │ -00064800: 7261 636b 6572 730a 3c2f 7072 653e 3c2f  rackers.
    relevan │ │ │ -00064840: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ -00064880: 742e 6370 703a 3337 3538 3c2f 613e 3c2f t.cpp:3758move this │ │ │ -000648a0: 2069 6e74 6f20 6120 6675 6e63 7469 6f6e into a function │ │ │ -000648b0: 206f 6e20 7472 6163 6b65 725f 6c69 7374 on tracker_list │ │ │ -000648c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    mo │ │ │ -00064910: 7665 2074 6869 7320 696e 746f 2061 2066 ve this into a f │ │ │ -00064920: 756e 6374 696f 6e20 6f6e 2074 7261 636b unction on track │ │ │ -00064930: 6572 5f6c 6973 743c 2f68 323e 3c68 343e er_list

    │ │ │ -00064940: 2e2e 2f73 7263 2f74 6f72 7265 6e74 2e63 ../src/torrent.c │ │ │ -00064950: 7070 3a33 3735 383c 2f68 343e 3c70 7265 pp:3758

    .., struct
    │ │ │ -000649a0: 2074 7261 636b 6572 5f72 6573 706f 6e73   tracker_respons
    │ │ │ -000649b0: 6520 636f 6e73 7426 616d 703b 2072 6573  e const& res
    │ │ │ -000649c0: 7029 0a09 7b0a 0909 544f 5252 454e 545f  p)..{...TORRENT_
    │ │ │ -000649d0: 4153 5345 5254 2869 735f 7369 6e67 6c65  ASSERT(is_single
    │ │ │ -000649e0: 5f74 6872 6561 6428 2929 3b0a 0a09 0949  _thread());....I
    │ │ │ -000649f0: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a  NVARIANT_CHECK;.
    │ │ │ -00064a00: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -00064a10: 2821 2872 2e6b 696e 6420 2661 6d70 3b20  (!(r.kind & 
    │ │ │ -00064a20: 7472 6163 6b65 725f 7265 7175 6573 743a  tracker_request:
    │ │ │ -00064a30: 3a73 6372 6170 655f 7265 7175 6573 7429  :scrape_request)
    │ │ │ -00064a40: 293b 0a0a 0909 2f2f 2069 6620 7468 6520  );....// if the 
    │ │ │ -00064a50: 7472 6163 6b65 7220 746f 6c64 2075 7320  tracker told us 
    │ │ │ -00064a60: 7768 6174 206f 7572 2065 7874 6572 6e61  what our externa
    │ │ │ -00064a70: 6c20 4950 2061 6464 7265 7373 2069 732c  l IP address is,
    │ │ │ -00064a80: 2072 6563 6f72 6420 6974 2077 6974 680a   record it with.
    │ │ │ -00064a90: 0909 2f2f 206f 7574 2065 7874 6572 6e61  ..// out externa
    │ │ │ -00064aa0: 6c20 4950 2063 6f75 6e74 6572 2028 616e  l IP counter (an
    │ │ │ -00064ab0: 6420 7061 7373 2061 6c6f 6e67 2074 6865  d pass along the
    │ │ │ -00064ac0: 2049 5020 6f66 2074 6865 2074 7261 636b   IP of the track
    │ │ │ -00064ad0: 6572 2074 6f20 6b6e 6f77 0a09 092f 2f20  er to know...// 
    │ │ │ -00064ae0: 7768 6f20 746f 2061 7474 7269 6275 7465  who to attribute
    │ │ │ -00064af0: 2074 6869 7320 766f 7465 2074 6f29 0a09   this vote to)..
    │ │ │ -00064b00: 0969 6620 2872 6573 702e 6578 7465 726e  .if (resp.extern
    │ │ │ -00064b10: 616c 5f69 7020 213d 2061 6464 7265 7373  al_ip != address
    │ │ │ -00064b20: 2829 2026 616d 703b 2661 6d70 3b20 2174  () && !t
    │ │ │ -00064b30: 7261 636b 6572 5f69 702e 6973 5f75 6e73  racker_ip.is_uns
    │ │ │ -00064b40: 7065 6369 6669 6564 2829 2026 616d 703b  pecified() &
    │ │ │ -00064b50: 2661 6d70 3b20 722e 6f75 7467 6f69 6e67  & r.outgoing
    │ │ │ -00064b60: 5f73 6f63 6b65 7429 0a09 0909 6d5f 7365  _socket)....m_se
    │ │ │ -00064b70: 732e 7365 745f 6578 7465 726e 616c 5f61  s.set_external_a
    │ │ │ -00064b80: 6464 7265 7373 2872 2e6f 7574 676f 696e  ddress(r.outgoin
    │ │ │ -00064b90: 675f 736f 636b 6574 2e67 6574 5f6c 6f63  g_socket.get_loc
    │ │ │ -00064ba0: 616c 5f65 6e64 706f 696e 7428 290a 0909  al_endpoint()...
    │ │ │ -00064bb0: 0909 2c20 7265 7370 2e65 7874 6572 6e61  .., resp.externa
    │ │ │ -00064bc0: 6c5f 6970 0a09 0909 092c 2061 7578 3a3a  l_ip....., aux::
    │ │ │ -00064bd0: 7365 7373 696f 6e5f 696e 7465 7266 6163  session_interfac
    │ │ │ -00064be0: 653a 3a73 6f75 7263 655f 7472 6163 6b65  e::source_tracke
    │ │ │ -00064bf0: 722c 2074 7261 636b 6572 5f69 7029 3b0a  r, tracker_ip);.
    │ │ │ -00064c00: 0a09 0974 696d 655f 706f 696e 7433 3220  ...time_point32 
    │ │ │ -00064c10: 636f 6e73 7420 6e6f 7720 3d20 6175 783a  const now = aux:
    │ │ │ -00064c20: 3a74 696d 655f 6e6f 7733 3228 293b 0a0a  :time_now32();..
    │ │ │ -00064c30: 0909 7072 6f74 6f63 6f6c 5f76 6572 7369  ..protocol_versi
    │ │ │ -00064c40: 6f6e 2063 6f6e 7374 2076 203d 2072 2e69  on const v = r.i
    │ │ │ -00064c50: 6e66 6f5f 6861 7368 203d 3d20 746f 7272  nfo_hash == torr
    │ │ │ -00064c60: 656e 745f 6669 6c65 2829 2e69 6e66 6f5f  ent_file().info_
    │ │ │ -00064c70: 6861 7368 6573 2829 2e76 310a 0909 093f  hashes().v1....?
    │ │ │ -00064c80: 2070 726f 746f 636f 6c5f 7665 7273 696f   protocol_versio
    │ │ │ -00064c90: 6e3a 3a56 3120 3a20 7072 6f74 6f63 6f6c  n::V1 : protocol
    │ │ │ -00064ca0: 5f76 6572 7369 6f6e 3a3a 5632 3b0a 0a3c  _version::V2;..<
    │ │ │ -00064cb0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -00064cc0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -00064cd0: 7769 6474 683d 2231 3030 2522 3e09 0961  width="100%">..a
    │ │ │ -00064ce0: 7578 3a3a 616e 6e6f 756e 6365 5f65 6e74  ux::announce_ent
    │ │ │ -00064cf0: 7279 2a20 6165 203d 206d 5f74 7261 636b  ry* ae = m_track
    │ │ │ -00064d00: 6572 732e 6669 6e64 5f74 7261 636b 6572  ers.find_tracker
    │ │ │ -00064d10: 2872 2e75 726c 293b 0a3c 2f64 6976 3e0a  (r.url);.

    . │ │ │ -00064d20: 0909 7463 703a 3a65 6e64 706f 696e 7420 ..tcp::endpoint │ │ │ -00064d30: 6c6f 6361 6c5f 656e 6470 6f69 6e74 3b0a local_endpoint;. │ │ │ -00064d40: 0909 6966 2028 6165 290a 0909 7b0a 0909 ..if (ae)...{... │ │ │ -00064d50: 0961 7574 6f2a 2061 6570 203d 2061 652d .auto* aep = ae- │ │ │ -00064d60: 2667 743b 6669 6e64 5f65 6e64 706f 696e >find_endpoin │ │ │ -00064d70: 7428 722e 6f75 7467 6f69 6e67 5f73 6f63 t(r.outgoing_soc │ │ │ -00064d80: 6b65 7429 3b0a 0909 0969 6620 2861 6570 ket);....if (aep │ │ │ -00064d90: 290a 0909 097b 0a09 0909 0961 7574 6f26 )....{.....auto& │ │ │ -00064da0: 616d 703b 2061 203d 2061 6570 2d26 6774 amp; a = aep-> │ │ │ -00064db0: 3b69 6e66 6f5f 6861 7368 6573 5b76 5d3b ;info_hashes[v]; │ │ │ -00064dc0: 0a0a 0909 0909 6c6f 6361 6c5f 656e 6470 ......local_endp │ │ │ -00064dd0: 6f69 6e74 203d 2061 6570 2d26 6774 3b6c oint = aep->l │ │ │ -00064de0: 6f63 616c 5f65 6e64 706f 696e 743b 0a09 ocal_endpoint;.. │ │ │ -00064df0: 0909 0969 6620 2872 6573 702e 696e 636f ...if (resp.inco │ │ │ -00064e00: 6d70 6c65 7465 2026 6774 3b3d 2030 2920 mplete >= 0) │ │ │ -00064e10: 612e 7363 7261 7065 5f69 6e63 6f6d 706c a.scrape_incompl │ │ │ -00064e20: 6574 6520 3d20 7265 7370 2e69 6e63 6f6d ete = resp.incom │ │ │ -00064e30: 706c 6574 653b 0a09 0909 0969 6620 2872 plete;.....if (r │ │ │ -00064e40: 6573 702e 636f 6d70 6c65 7465 2026 6774 esp.complete > │ │ │ -00064e50: 3b3d 2030 2920 612e 7363 7261 7065 5f63 ;= 0) a.scrape_c │ │ │ -00064e60: 6f6d 706c 6574 6520 3d20 7265 7370 2e63 omplete = resp.c │ │ │ -00064e70: 6f6d 706c 6574 653b 0a09 0909 0969 6620 omplete;.....if │ │ │ -00064e80: 2872 6573 702e 646f 776e 6c6f 6164 6564 (resp.downloaded │ │ │ -00064e90: 2026 6774 3b3d 2030 2920 612e 7363 7261 >= 0) a.scra │ │ │ -00064ea0: 7065 5f64 6f77 6e6c 6f61 6465 6420 3d20 pe_downloaded = │ │ │ -00064eb0: 7265 7370 2e64 6f77 6e6c 6f61 6465 643b resp.downloaded; │ │ │ -00064ec0: 0a09 0909 0969 6620 2821 612e 7374 6172 .....if (!a.star │ │ │ -00064ed0: 745f 7365 6e74 2026 616d 703b 2661 6d70 t_sent && │ │ │ -00064ee0: 3b20 722e 6576 656e 7420 3d3d 2065 7665 ; r.event == eve │ │ │ -00064ef0: 6e74 5f74 3a3a 7374 6172 7465 6429 0a09 nt_t::started).. │ │ │ -00064f00: 0909 0909 612e 7374 6172 745f 7365 6e74 ....a.start_sent │ │ │ -00064f10: 203d 2074 7275 653b 0a09 0909 0969 6620 = true;.....if │ │ │ -00064f20: 2821 612e 636f 6d70 6c65 7465 5f73 656e (!a.complete_sen │ │ │ -00064f30: 7420 2661 6d70 3b26 616d 703b 2072 2e65 t && r.e │ │ │ -00064f40: 7665 6e74 203d 3d20 6576 656e 745f 743a vent == event_t: │ │ │ -00064f50: 3a63 6f6d 706c 6574 6564 290a 0909 0909 :completed)..... │ │ │ -00064f60: 7b0a 0909 0909 0961 2e63 6f6d 706c 6574 {......a.complet │ │ │ -00064f70: 655f 7365 6e74 203d 2074 7275 653b 0a09 e_sent = true;.. │ │ │ -00064f80: 0909 0909 2f2f 2077 6520 7375 6363 6573 ....// we succes │ │ │ -00064f90: 7366 756c 6c79 2072 6570 6f72 7465 6420 sfully reported │ │ │ -00064fa0: 6576 656e 743d 636f 6d70 6c65 7465 6420 event=completed │ │ │ -00064fb0: 746f 206f 6e65 2074 7261 636b 6572 2e20 to one tracker. │ │ │ -00064fc0: 446f 6e27 740a 0909 0909 092f 2f20 7365 Don't......// se │ │ │ -00064fd0: 6e64 2069 7420 746f 2061 6e79 206f 7468 nd it to any oth │ │ │ -00064fe0: 6572 206f 6e65 7320 6672 6f6d 206e 6f77 er ones from now │ │ │ -00064ff0: 206f 6e20 2874 6865 7265 206d 6179 2062 on (there may b │ │ │ -00065000: 6520 6f74 6865 720a 0909 0909 092f 2f20 e other......// │ │ │ -00065010: 616e 6e6f 756e 6365 7320 6f75 7473 7461 announces outsta │ │ │ -00065020: 6e64 696e 6720 7269 6768 7420 6e6f 7720 nding right now │ │ │ -00065030: 7468 6f75 6768 290a 0909 0909 096d 5f63 though)......m_c │ │ │ -00065040: 6f6d 706c 6574 655f 7365 6e74 203d 2074 omplete_sent = t │ │ │ -00065050: 7275 653b 0a09 0909 097d 0a09 0909 0961 rue;.....}.....a │ │ │ -00065060: 652d 2667 743b 7665 7269 6669 6564 203d e->verified = │ │ │ -00065070: 2074 7275 653b 0a09 0909 0961 2e6e 6578 true;.....a.nex │ │ │ -00065080: 745f 616e 6e6f 756e 6365 203d 206e 6f77 t_announce = now │ │ │ -00065090: 202b 2072 6573 702e 696e 7465 7276 616c + resp.interval │ │ │ -000650a0: 3b0a 0909 0909 612e 6d69 6e5f 616e 6e6f ;.....a.min_anno │ │ │ -000650b0: 756e 6365 203d 206e 6f77 202b 2072 6573 unce = now + res │ │ │ -000650c0: 702e 6d69 6e5f 696e 7465 7276 616c 3b0a p.min_interval;. │ │ │ -000650d0: 0909 0909 612e 7570 6461 7469 6e67 203d ....a.updating = │ │ │ -000650e0: 2066 616c 7365 3b0a 0909 0909 612e 6661 false;.....a.fa │ │ │ -000650f0: 696c 7320 3d20 303b 0a09 0909 0961 2e6c ils = 0;.....a.l │ │ │ -00065100: 6173 745f 6572 726f 722e 636c 6561 7228 ast_error.clear( │ │ │ -00065110: 293b 0a09 0909 0961 2e6d 6573 7361 6765 );.....a.message │ │ │ -00065120: 203d 2021 7265 7370 2e77 6172 6e69 6e67 = !resp.warning │ │ │ -00065130: 5f6d 6573 7361 6765 2e65 6d70 7479 2829 _message.empty() │ │ │ -00065140: 203f 2072 6573 702e 7761 726e 696e 675f ? resp.warning_ │ │ │ -00065150: 6d65 7373 6167 6520 3a20 7374 643a 3a73 message : std::s │ │ │ -00065160: 7472 696e 6728 293b 0a3c 2f70 7265 3e3c tring();.< │ │ │ -00065170: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000651a0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000651b0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ -000651e0: 6e74 2e63 7070 3a33 3835 323c 2f61 3e3c nt.cpp:3852< │ │ │ -000651f0: 2f74 643e 3c74 643e 7468 6520 6465 7374 /td>the dest │ │ │ -00065200: 696e 6174 696f 6e20 7374 7269 6e67 2073 ination string s │ │ │ -00065210: 686f 756c 6420 6265 2062 6173 6536 3420 hould be base64 │ │ │ -00065220: 6465 636f 6465 6420 616e 6420 7368 6132 decoded and sha2 │ │ │ -00065230: 3536 2068 6173 6865 6420 746f 2066 6f72 56 hashed to for │ │ │ -00065240: 6d20 7468 6520 6465 7374 696e 6174 696f m the destinatio │ │ │ -00065250: 6e20 6164 6472 6573 7320 616e 6420 7374 n address and st │ │ │ -00065260: 6f72 6520 7468 6174 2069 6e20 7468 6520 ore that in the │ │ │ -00065270: 6932 705f 7065 6572 206f 626a 6563 7420 i2p_peer object │ │ │ -00065280: 6469 7265 6374 6c79 3c2f 7464 3e3c 2f74 directly

    the destin │ │ │ -000652e0: 6174 696f 6e20 7374 7269 6e67 2073 686f ation string sho │ │ │ -000652f0: 756c 6420 6265 2062 6173 6536 3420 6465 uld be base64 de │ │ │ -00065300: 636f 6465 6420 616e 640a 7368 6132 3536 coded and.sha256 │ │ │ -00065310: 2068 6173 6865 6420 746f 2066 6f72 6d20 hashed to form │ │ │ -00065320: 7468 6520 6465 7374 696e 6174 696f 6e20 the destination │ │ │ -00065330: 6164 6472 6573 7320 616e 6420 7374 6f72 address and stor │ │ │ -00065340: 650a 7468 6174 2069 6e20 7468 6520 6932 e.that in the i2 │ │ │ -00065350: 705f 7065 6572 206f 626a 6563 7420 6469 p_peer object di │ │ │ -00065360: 7265 6374 6c79 3c2f 6832 3e3c 6834 3e2e rectly

    . │ │ │ -00065370: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -00065380: 703a 3338 3532 3c2f 6834 3e3c 7072 6520 p:3852

    ..for (auto
    │ │ │ -000653d0: 2063 6f6e 7374 2661 6d70 3b20 6920 3a20   const& i : 
    │ │ │ -000653e0: 7265 7370 2e70 6565 7273 290a 0909 7b0a  resp.peers)...{.
    │ │ │ -000653f0: 0909 092f 2f20 646f 6e27 7420 6d61 6b65  ...// don't make
    │ │ │ -00065400: 2063 6f6e 6e65 6374 696f 6e73 2074 6f20   connections to 
    │ │ │ -00065410: 6f75 7273 656c 660a 0909 0969 6620 2869  ourself....if (i
    │ │ │ -00065420: 2e70 6964 203d 3d20 6d5f 7065 6572 5f69  .pid == m_peer_i
    │ │ │ -00065430: 6429 0a09 0909 0963 6f6e 7469 6e75 653b  d).....continue;
    │ │ │ -00065440: 0a0a 2369 6620 544f 5252 454e 545f 5553  ..#if TORRENT_US
    │ │ │ -00065450: 455f 4932 500a 0909 0969 6620 2872 2e69  E_I2P....if (r.i
    │ │ │ -00065460: 3270 636f 6e6e 290a 0909 097b 0a09 0909  2pconn)....{....
    │ │ │ -00065470: 092f 2f20 7468 6973 2069 7320 616e 2069  .// this is an i
    │ │ │ -00065480: 3270 206e 616d 652c 2077 6520 6e65 6564  2p name, we need
    │ │ │ -00065490: 2074 6f20 7573 6520 7468 6520 5341 4d20   to use the SAM 
    │ │ │ -000654a0: 636f 6e6e 6563 7469 6f6e 0a09 0909 092f  connection...../
    │ │ │ -000654b0: 2f20 746f 2064 6f20 7468 6520 6e61 6d65  / to do the name
    │ │ │ -000654c0: 206c 6f6f 6b75 700a 0909 0909 6966 2028   lookup.....if (
    │ │ │ -000654d0: 7374 7269 6e67 5f65 6e64 735f 7769 7468  string_ends_with
    │ │ │ -000654e0: 2869 2e68 6f73 746e 616d 652c 2022 2e69  (i.hostname, ".i
    │ │ │ -000654f0: 3270 2229 290a 0909 0909 7b0a 0909 0909  2p")).....{.....
    │ │ │ -00065500: 0941 4444 5f4f 5554 5354 414e 4449 4e47  .ADD_OUTSTANDING
    │ │ │ -00065510: 5f41 5359 4e43 2822 746f 7272 656e 743a  _ASYNC("torrent:
    │ │ │ -00065520: 3a6f 6e5f 6932 705f 7265 736f 6c76 6522  :on_i2p_resolve"
    │ │ │ -00065530: 293b 0a09 0909 0909 722e 6932 7063 6f6e  );......r.i2pcon
    │ │ │ -00065540: 6e2d 2667 743b 6173 796e 635f 6e61 6d65  n->async_name
    │ │ │ -00065550: 5f6c 6f6f 6b75 7028 692e 686f 7374 6e61  _lookup(i.hostna
    │ │ │ -00065560: 6d65 2e63 5f73 7472 2829 0a09 0909 0909  me.c_str()......
    │ │ │ -00065570: 092c 205b 7365 6c66 203d 2073 6861 7265  ., [self = share
    │ │ │ -00065580: 645f 6672 6f6d 5f74 6869 7328 295d 2028  d_from_this()] (
    │ │ │ -00065590: 6572 726f 725f 636f 6465 2063 6f6e 7374  error_code const
    │ │ │ -000655a0: 2661 6d70 3b20 6563 2c20 6368 6172 2063  & ec, char c
    │ │ │ -000655b0: 6f6e 7374 2a20 6465 7374 290a 0909 0909  onst* dest).....
    │ │ │ -000655c0: 0909 7b20 7365 6c66 2d26 6774 3b74 6f72  ..{ self->tor
    │ │ │ -000655d0: 7265 6e74 3a3a 6f6e 5f69 3270 5f72 6573  rent::on_i2p_res
    │ │ │ -000655e0: 6f6c 7665 2865 632c 2064 6573 742c 2070  olve(ec, dest, p
    │ │ │ -000655f0: 6565 725f 696e 666f 3a3a 7472 6163 6b65  eer_info::tracke
    │ │ │ -00065600: 7229 3b20 7d29 3b0a 0909 0909 7d0a 0909  r); });.....}...
    │ │ │ -00065610: 0909 656c 7365 0a09 0909 097b 0a3c 6469  ..else.....{......
    │ │ │ -00065650: 746f 7272 656e 745f 7374 6174 6520 7374  torrent_state st
    │ │ │ -00065660: 203d 2067 6574 5f70 6565 725f 6c69 7374   = get_peer_list
    │ │ │ -00065670: 5f73 7461 7465 2829 3b0a 3c2f 6469 763e  _state();.
    │ │ │ -00065680: 0909 0909 096e 6565 645f 7065 6572 5f6c  .....need_peer_l
    │ │ │ -00065690: 6973 7428 293b 0a09 0909 0909 6966 2028  ist();......if (
    │ │ │ -000656a0: 6d5f 7065 6572 5f6c 6973 742d 2667 743b  m_peer_list->
    │ │ │ -000656b0: 6164 645f 6932 705f 7065 6572 2869 2e68  add_i2p_peer(i.h
    │ │ │ -000656c0: 6f73 746e 616d 652c 2070 6565 725f 696e  ostname, peer_in
    │ │ │ -000656d0: 666f 3a3a 7472 6163 6b65 722c 207b 7d2c  fo::tracker, {},
    │ │ │ -000656e0: 2026 616d 703b 7374 2929 0a09 0909 0909   &st))......
    │ │ │ -000656f0: 0973 7461 7465 5f75 7064 6174 6564 2829  .state_updated()
    │ │ │ -00065700: 3b0a 0909 0909 0970 6565 7273 5f65 7261  ;......peers_era
    │ │ │ -00065710: 7365 6428 7374 2e65 7261 7365 6429 3b0a  sed(st.erased);.
    │ │ │ -00065720: 0909 0909 7d0a 0909 097d 0a09 0909 656c  ....}....}....el
    │ │ │ -00065730: 7365 0a23 656e 6469 660a 0909 097b 0a09  se.#endif....{..
    │ │ │ -00065740: 0909 0941 4444 5f4f 5554 5354 414e 4449  ...ADD_OUTSTANDI
    │ │ │ -00065750: 4e47 5f41 5359 4e43 2822 746f 7272 656e  NG_ASYNC("torren
    │ │ │ -00065760: 743a 3a6f 6e5f 7065 6572 5f6e 616d 655f  t::on_peer_name_
    │ │ │ -00065770: 6c6f 6f6b 7570 2229 3b0a 0909 0909 6d5f  lookup");.....m_
    │ │ │ -00065780: 7365 732e 6765 745f 7265 736f 6c76 6572  ses.get_resolver
    │ │ │ -00065790: 2829 2e61 7379 6e63 5f72 6573 6f6c 7665  ().async_resolve
    │ │ │ -000657a0: 2869 2e68 6f73 746e 616d 652c 2061 7578  (i.hostname, aux
    │ │ │ -000657b0: 3a3a 7265 736f 6c76 6572 5f69 6e74 6572  ::resolver_inter
    │ │ │ -000657c0: 6661 6365 3a3a 6162 6f72 745f 6f6e 5f73  face::abort_on_s
    │ │ │ -000657d0: 6875 7464 6f77 6e0a 0909 0909 092c 2073  hutdown......, s
    │ │ │ -000657e0: 7464 3a3a 6269 6e64 2826 616d 703b 746f  td::bind(&to
    │ │ │ -000657f0: 7272 656e 743a 3a6f 6e5f 7065 6572 5f6e  rrent::on_peer_n
    │ │ │ -00065800: 616d 655f 6c6f 6f6b 7570 2c20 7368 6172  ame_lookup, shar
    │ │ │ -00065810: 6564 5f66 726f 6d5f 7468 6973 2829 2c20  ed_from_this(), 
    │ │ │ -00065820: 5f31 2c20 5f32 2c20 692e 706f 7274 2c20  _1, _2, i.port, 
    │ │ │ -00065830: 7629 293b 0a09 0909 7d0a 0909 7d0a 0a23  v));....}...}..#
    │ │ │ -00065840: 6966 2054 4f52 5245 4e54 5f55 5345 5f49  if TORRENT_USE_I
    │ │ │ -00065850: 3250 0a09 0969 6620 2872 2e69 3270 636f  2P...if (r.i2pco
    │ │ │ -00065860: 6e6e 290a 0909 7b0a 0909 0966 6f72 2028  nn)...{....for (
    │ │ │ -00065870: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ -00065880: 6920 3a20 7265 7370 2e69 3270 5f70 6565  i : resp.i2p_pee
    │ │ │ -00065890: 7273 290a 0909 097b 0a09 0909 0961 6464  rs)....{.....add
    │ │ │ -000658a0: 5f69 3270 5f70 6565 7228 692e 6465 7374  _i2p_peer(i.dest
    │ │ │ -000658b0: 696e 6174 696f 6e2c 2070 6565 725f 696e  ination, peer_in
    │ │ │ -000658c0: 666f 3a3a 7472 6163 6b65 7229 3b0a 0909  fo::tracker);...
    │ │ │ -000658d0: 097d 0a09 097d 0a23 656e 6469 660a 0a09  .}...}.#endif...
    │ │ │ -000658e0: 092f 2f20 7468 6572 6520 6172 6520 3220  .// there are 2 
    │ │ │ -000658f0: 7265 6173 6f6e 7320 746f 2061 6c6c 6f77  reasons to allow
    │ │ │ -00065900: 206c 6f63 616c 2049 5073 2074 6f20 6265   local IPs to be
    │ │ │ -00065910: 2072 6574 7572 6e65 6420 6672 6f6d 2061   returned from a
    │ │ │ -00065920: 0a09 092f 2f20 6e6f 6e2d 6c6f 6361 6c20  ...// non-local 
    │ │ │ -00065930: 7472 6163 6b65 720a 0909 2f2f 2031 2e20  tracker...// 1. 
    │ │ │ -00065940: 7265 7472 6163 6b65 7273 2061 7265 2070  retrackers are p
    │ │ │ -00065950: 6f70 756c 6172 2069 6e20 7275 7373 6961  opular in russia
    │ │ │ -00065960: 2c20 7768 6572 6520 616e 2049 5350 2072  , where an ISP r
    │ │ │ -00065970: 756e 7320 6120 7472 6163 6b65 7220 7769  uns a tracker wi
    │ │ │ -00065980: 7468 696e 0a09 092f 2f20 2020 2074 6865  thin...//    the
    │ │ │ -00065990: 2041 5320 2862 7574 206e 6f74 206f 6e20   AS (but not on 
    │ │ │ -000659a0: 7468 6520 6c6f 6361 6c20 6e65 7477 6f72  the local networ
    │ │ │ -000659b0: 6b29 2067 6976 696e 6720 6f75 7420 7065  k) giving out pe
    │ │ │ -000659c0: 6572 7320 6f6e 6c79 2066 726f 6d20 7468  ers only from th
    │ │ │ -000659d0: 650a 0909 2f2f 2020 2020 6c6f 6361 6c20  e...//    local 
    │ │ │ -000659e0: 6e65 7477 6f72 6b0a 3c2f 7072 653e 3c2f  network.
    relevan │ │ │ -00065a20: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ -00065a60: 742e 6370 703a 3431 3736 3c2f 613e 3c2f t.cpp:4176store i2p │ │ │ -00065a80: 2061 6464 7265 7373 6573 2061 7320 6120 addresses as a │ │ │ -00065a90: 3332 2062 7974 6520 7368 6132 3536 2068 32 byte sha256 h │ │ │ -00065aa0: 6173 6820 696e 2074 6865 2069 3270 5f70 ash in the i2p_p │ │ │ -00065ab0: 6565 7220 6f62 6a65 6374 2c20 7261 7468 eer object, rath │ │ │ -00065ac0: 6572 2074 6861 6e20 7265 736f 6c76 696e er than resolvin │ │ │ -00065ad0: 6720 6974 2069 6e74 6f20 7468 6520 6675 g it into the fu │ │ │ -00065ae0: 6c6c 2076 6173 6536 3420 6465 7374 696e ll vase64 destin │ │ │ -00065af0: 6174 696f 6e2e 2057 6520 7368 6f75 6c64 ation. We should │ │ │ -00065b00: 206b 6565 7020 7468 6520 6675 6c6c 2064 keep the full d │ │ │ -00065b10: 6573 7469 6e61 7469 6f6e 2061 7320 6120 estination as a │ │ │ -00065b20: 6361 6368 6520 696e 2074 6865 2069 3270 cache in the i2p │ │ │ -00065b30: 5f70 6565 7220 6f62 6a65 6374 2073 7469 _peer object sti │ │ │ -00065b40: 6c6c 2e3c 2f74 643e 3c2f 7472 3e3c 7472 ll.

    store i2p addre │ │ │ -00065ba0: 7373 6573 2061 7320 6120 3332 2062 7974 sses as a 32 byt │ │ │ -00065bb0: 6520 7368 6132 3536 2068 6173 6820 696e e sha256 hash in │ │ │ -00065bc0: 2074 6865 0a69 3270 5f70 6565 7220 6f62 the.i2p_peer ob │ │ │ -00065bd0: 6a65 6374 2c20 7261 7468 6572 2074 6861 ject, rather tha │ │ │ -00065be0: 6e20 7265 736f 6c76 696e 6720 6974 2069 n resolving it i │ │ │ -00065bf0: 6e74 6f20 7468 6520 6675 6c6c 2076 6173 nto the full vas │ │ │ -00065c00: 6536 340a 6465 7374 696e 6174 696f 6e2e e64.destination. │ │ │ -00065c10: 2057 6520 7368 6f75 6c64 206b 6565 7020 We should keep │ │ │ -00065c20: 7468 6520 6675 6c6c 2064 6573 7469 6e61 the full destina │ │ │ -00065c30: 7469 6f6e 2061 7320 6120 6361 6368 6520 tion as a cache │ │ │ -00065c40: 696e 2074 6865 0a69 3270 5f70 6565 7220 in the.i2p_peer │ │ │ -00065c50: 6f62 6a65 6374 2073 7469 6c6c 2e3c 2f68 object still.

    ../src/tor │ │ │ -00065c70: 7265 6e74 2e63 7070 3a34 3137 363c 2f68 rent.cpp:4176
    #ifn
    │ │ │ -00065cc0: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ -00065cd0: 424c 455f 4c4f 4747 494e 470a 0909 656c  BLE_LOGGING...el
    │ │ │ -00065ce0: 7365 0a09 097b 0a09 0909 6465 6275 675f  se...{....debug_
    │ │ │ -00065cf0: 6c6f 6728 222a 2a2a 2066 6f75 6e64 206e  log("*** found n
    │ │ │ -00065d00: 6f20 7472 6163 6b65 7220 656e 6470 6f69  o tracker endpoi
    │ │ │ -00065d10: 6e74 7320 746f 2061 6e6e 6f75 6e63 6522  nts to announce"
    │ │ │ -00065d20: 293b 0a09 097d 0a23 656e 6469 660a 097d  );...}.#endif..}
    │ │ │ -00065d30: 0a0a 2369 6620 544f 5252 454e 545f 4142  ..#if TORRENT_AB
    │ │ │ -00065d40: 495f 5645 5253 494f 4e20 3d3d 2031 0a09  I_VERSION == 1..
    │ │ │ -00065d50: 766f 6964 2074 6f72 7265 6e74 3a3a 7365  void torrent::se
    │ │ │ -00065d60: 745f 7472 6163 6b65 725f 6c6f 6769 6e28  t_tracker_login(
    │ │ │ -00065d70: 7374 643a 3a73 7472 696e 6720 636f 6e73  std::string cons
    │ │ │ -00065d80: 7426 616d 703b 206e 616d 650a 0909 2c20  t& name..., 
    │ │ │ -00065d90: 7374 643a 3a73 7472 696e 6720 636f 6e73  std::string cons
    │ │ │ -00065da0: 7426 616d 703b 2070 7729 0a09 7b0a 0909  t& pw)..{...
    │ │ │ -00065db0: 6d5f 7573 6572 6e61 6d65 203d 206e 616d  m_username = nam
    │ │ │ -00065dc0: 653b 0a09 096d 5f70 6173 7377 6f72 6420  e;...m_password 
    │ │ │ -00065dd0: 3d20 7077 3b0a 097d 0a23 656e 6469 660a  = pw;..}.#endif.
    │ │ │ -00065de0: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ -00065df0: 5f49 3250 0a09 766f 6964 2074 6f72 7265  _I2P..void torre
    │ │ │ -00065e00: 6e74 3a3a 6164 645f 6932 705f 7065 6572  nt::add_i2p_peer
    │ │ │ -00065e10: 2873 6861 3235 365f 6861 7368 2063 6f6e  (sha256_hash con
    │ │ │ -00065e20: 7374 2661 6d70 3b20 6465 7374 2c20 7065  st& dest, pe
    │ │ │ -00065e30: 6572 5f73 6f75 7263 655f 666c 6167 735f  er_source_flags_
    │ │ │ -00065e40: 7420 636f 6e73 7420 736f 7572 6365 290a  t const source).
    │ │ │ -00065e50: 097b 0a3c 6469 7620 7374 796c 653d 2262  .{.
    ..i2p_connectio │ │ │ -00065e90: 6e26 616d 703b 2069 3270 636f 6e6e 203d n& i2pconn = │ │ │ -00065ea0: 2073 6573 7369 6f6e 2829 2e69 3270 5f63 session().i2p_c │ │ │ -00065eb0: 6f6e 6e28 293b 0a3c 2f64 6976 3e09 0969 onn();.
    ..i │ │ │ -00065ec0: 6620 2821 6932 7063 6f6e 6e2e 6973 5f6f f (!i2pconn.is_o │ │ │ -00065ed0: 7065 6e28 2929 2072 6574 7572 6e3b 0a0a pen()) return;.. │ │ │ -00065ee0: 0909 7374 643a 3a73 7472 696e 6720 6465 ..std::string de │ │ │ -00065ef0: 7374 696e 6174 696f 6e20 3d20 6261 7365 stination = base │ │ │ -00065f00: 3332 656e 636f 6465 5f69 3270 2864 6573 32encode_i2p(des │ │ │ -00065f10: 7429 3b0a 0909 6465 7374 696e 6174 696f t);...destinatio │ │ │ -00065f20: 6e20 2b3d 2022 2e62 3332 2e69 3270 223b n += ".b32.i2p"; │ │ │ -00065f30: 0a0a 0909 4144 445f 4f55 5453 5441 4e44 ....ADD_OUTSTAND │ │ │ -00065f40: 494e 475f 4153 594e 4328 2274 6f72 7265 ING_ASYNC("torre │ │ │ -00065f50: 6e74 3a3a 6f6e 5f69 3270 5f72 6573 6f6c nt::on_i2p_resol │ │ │ -00065f60: 7665 2229 3b0a 0909 6932 7063 6f6e 6e2e ve");...i2pconn. │ │ │ -00065f70: 6173 796e 635f 6e61 6d65 5f6c 6f6f 6b75 async_name_looku │ │ │ -00065f80: 7028 6465 7374 696e 6174 696f 6e2e 635f p(destination.c_ │ │ │ -00065f90: 7374 7228 290a 0909 092c 205b 7365 6c66 str()...., [self │ │ │ -00065fa0: 203d 2073 6861 7265 645f 6672 6f6d 5f74 = shared_from_t │ │ │ -00065fb0: 6869 7328 292c 2073 6f75 7263 655d 2028 his(), source] ( │ │ │ -00065fc0: 6572 726f 725f 636f 6465 2063 6f6e 7374 error_code const │ │ │ -00065fd0: 2661 6d70 3b20 6563 2c20 6368 6172 2063 & ec, char c │ │ │ -00065fe0: 6f6e 7374 2a20 6429 0a09 0909 7b20 7365 onst* d)....{ se │ │ │ -00065ff0: 6c66 2d26 6774 3b74 6f72 7265 6e74 3a3a lf->torrent:: │ │ │ -00066000: 6f6e 5f69 3270 5f72 6573 6f6c 7665 2865 on_i2p_resolve(e │ │ │ -00066010: 632c 2064 2c20 736f 7572 6365 293b 207d c, d, source); } │ │ │ -00066020: 293b 0a09 7d0a 0a09 766f 6964 2074 6f72 );..}...void tor │ │ │ -00066030: 7265 6e74 3a3a 6f6e 5f69 3270 5f72 6573 rent::on_i2p_res │ │ │ -00066040: 6f6c 7665 2865 7272 6f72 5f63 6f64 6520 olve(error_code │ │ │ -00066050: 636f 6e73 7426 616d 703b 2065 632c 2063 const& ec, c │ │ │ -00066060: 6861 7220 636f 6e73 742a 2064 6573 742c har const* dest, │ │ │ -00066070: 2070 6565 725f 736f 7572 6365 5f66 6c61 peer_source_fla │ │ │ -00066080: 6773 5f74 2063 6f6e 7374 2073 6f75 7263 gs_t const sourc │ │ │ -00066090: 6529 2074 7279 0a09 7b0a 0909 544f 5252 e) try..{...TORR │ │ │ -000660a0: 454e 545f 4153 5345 5254 2869 735f 7369 ENT_ASSERT(is_si │ │ │ -000660b0: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a ngle_thread());. │ │ │ -000660c0: 0a09 0949 4e56 4152 4941 4e54 5f43 4845 ...INVARIANT_CHE │ │ │ -000660d0: 434b 3b0a 0a09 0943 4f4d 504c 4554 455f CK;....COMPLETE_ │ │ │ -000660e0: 4153 594e 4328 2274 6f72 7265 6e74 3a3a ASYNC("torrent:: │ │ │ -000660f0: 6f6e 5f69 3270 5f72 6573 6f6c 7665 2229 on_i2p_resolve") │ │ │ -00066100: 3b0a 2369 666e 6465 6620 544f 5252 454e ;.#ifndef TORREN │ │ │ -00066110: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ -00066120: 470a 0909 6966 2028 6563 2026 616d 703b G...if (ec & │ │ │ -00066130: 2661 6d70 3b20 7368 6f75 6c64 5f6c 6f67 & should_log │ │ │ -00066140: 2829 290a 0909 0964 6562 7567 5f6c 6f67 ())....debug_log │ │ │ -00066150: 2822 6932 705f 7265 736f 6c76 6520 6572 ("i2p_resolve er │ │ │ -00066160: 726f 723a 2025 7322 2c20 6563 2e6d 6573 ror: %s", ec.mes │ │ │ -00066170: 7361 6765 2829 2e63 5f73 7472 2829 293b sage().c_str()); │ │ │ -00066180: 0a23 656e 6469 660a 0909 6966 2028 6563 .#endif...if (ec │ │ │ -00066190: 207c 7c20 6d5f 6162 6f72 7420 7c7c 206d || m_abort || m │ │ │ -000661a0: 5f73 6573 2e69 735f 6162 6f72 7465 6428 _ses.is_aborted( │ │ │ -000661b0: 2929 2072 6574 7572 6e3b 0a0a 0909 6e65 )) return;....ne │ │ │ -000661c0: 6564 5f70 6565 725f 6c69 7374 2829 3b0a ed_peer_list();. │ │ │ -000661d0: 0909 746f 7272 656e 745f 7374 6174 6520 ..torrent_state │ │ │ -000661e0: 7374 203d 2067 6574 5f70 6565 725f 6c69 st = get_peer_li │ │ │ -000661f0: 7374 5f73 7461 7465 2829 3b0a 0909 6966 st_state();...if │ │ │ -00066200: 2028 6d5f 7065 6572 5f6c 6973 742d 2667 (m_peer_list-&g │ │ │ -00066210: 743b 6164 645f 6932 705f 7065 6572 2864 t;add_i2p_peer(d │ │ │ -00066220: 6573 742c 2073 6f75 7263 652c 207b 7d2c est, source, {}, │ │ │ -00066230: 2026 616d 703b 7374 2929 0a09 0909 7374 &st))....st │ │ │ -00066240: 6174 655f 7570 6461 7465 6428 293b 0a09 ate_updated();.. │ │ │ -00066250: 0970 6565 7273 5f65 7261 7365 6428 7374 .peers_erased(st │ │ │ -00066260: 2e65 7261 7365 6429 3b0a 0a3c 2f70 7265 .erased);..
    rele │ │ │ -000662a0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ -000662e0: 7265 6e74 2e63 7070 3a34 3233 333c 2f61 rent.cpp:4233add on │ │ │ -00066300: 6520 7065 6572 2070 6572 2049 5020 7468 e peer per IP th │ │ │ -00066310: 6520 686f 7374 6e61 6d65 2072 6573 6f6c e hostname resol │ │ │ -00066320: 7665 7320 746f 3c2f 7464 3e3c 2f74 723e ves to │ │ │ -00066330: 3c74 7220 6964 3d22 3233 3522 2073 7479 │ │ │ -00066360: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00066370: 3c68 323e 6164 6420 6f6e 6520 7065 6572

    add one peer │ │ │ -00066380: 2070 6572 2049 5020 7468 6520 686f 7374 per IP the host │ │ │ -00066390: 6e61 6d65 2072 6573 6f6c 7665 7320 746f name resolves to │ │ │ -000663a0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -000663b0: 746f 7272 656e 742e 6370 703a 3432 3333 torrent.cpp:4233 │ │ │ -000663c0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00066400: 6361 7463 6820 282e 2e2e 2920 7b20 6861  catch (...) { ha
    │ │ │ -00066410: 6e64 6c65 5f65 7863 6570 7469 6f6e 2829  ndle_exception()
    │ │ │ -00066420: 3b20 7d0a 2365 6e64 6966 0a0a 0976 6f69  ; }.#endif...voi
    │ │ │ -00066430: 6420 746f 7272 656e 743a 3a6f 6e5f 7065  d torrent::on_pe
    │ │ │ -00066440: 6572 5f6e 616d 655f 6c6f 6f6b 7570 2865  er_name_lookup(e
    │ │ │ -00066450: 7272 6f72 5f63 6f64 6520 636f 6e73 7426  rror_code const&
    │ │ │ -00066460: 616d 703b 2065 0a09 092c 2073 7464 3a3a  amp; e..., std::
    │ │ │ -00066470: 7665 6374 6f72 266c 743b 6164 6472 6573  vector<addres
    │ │ │ -00066480: 7326 6774 3b20 636f 6e73 7426 616d 703b  s> const&
    │ │ │ -00066490: 2068 6f73 745f 6c69 7374 2c20 696e 7420   host_list, int 
    │ │ │ -000664a0: 636f 6e73 7420 706f 7274 0a09 092c 2070  const port..., p
    │ │ │ -000664b0: 726f 746f 636f 6c5f 7665 7273 696f 6e20  rotocol_version 
    │ │ │ -000664c0: 636f 6e73 7420 7629 2074 7279 0a09 7b0a  const v) try..{.
    │ │ │ -000664d0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -000664e0: 2869 735f 7369 6e67 6c65 5f74 6872 6561  (is_single_threa
    │ │ │ -000664f0: 6428 2929 3b0a 0a09 0949 4e56 4152 4941  d());....INVARIA
    │ │ │ -00066500: 4e54 5f43 4845 434b 3b0a 0a09 0943 4f4d  NT_CHECK;....COM
    │ │ │ -00066510: 504c 4554 455f 4153 594e 4328 2274 6f72  PLETE_ASYNC("tor
    │ │ │ -00066520: 7265 6e74 3a3a 6f6e 5f70 6565 725f 6e61  rent::on_peer_na
    │ │ │ -00066530: 6d65 5f6c 6f6f 6b75 7022 293b 0a0a 2369  me_lookup");..#i
    │ │ │ -00066540: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ -00066550: 5341 424c 455f 4c4f 4747 494e 470a 0909  SABLE_LOGGING...
    │ │ │ -00066560: 6966 2028 6520 2661 6d70 3b26 616d 703b  if (e &&
    │ │ │ -00066570: 2073 686f 756c 645f 6c6f 6728 2929 0a09   should_log())..
    │ │ │ -00066580: 0909 6465 6275 675f 6c6f 6728 2270 6565  ..debug_log("pee
    │ │ │ -00066590: 7220 6e61 6d65 206c 6f6f 6b75 7020 6572  r name lookup er
    │ │ │ -000665a0: 726f 723a 2025 7322 2c20 652e 6d65 7373  ror: %s", e.mess
    │ │ │ -000665b0: 6167 6528 292e 635f 7374 7228 2929 3b0a  age().c_str());.
    │ │ │ -000665c0: 2365 6e64 6966 0a0a 0909 6966 2028 6520  #endif....if (e 
    │ │ │ -000665d0: 7c7c 206d 5f61 626f 7274 207c 7c20 686f  || m_abort || ho
    │ │ │ -000665e0: 7374 5f6c 6973 742e 656d 7074 7928 2920  st_list.empty() 
    │ │ │ -000665f0: 7c7c 206d 5f73 6573 2e69 735f 6162 6f72  || m_ses.is_abor
    │ │ │ -00066600: 7465 6428 2929 2072 6574 7572 6e3b 0a0a  ted()) return;..
    │ │ │ -00066610: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -00066640: 7463 703a 3a65 6e64 706f 696e 7420 686f tcp::endpoint ho │ │ │ -00066650: 7374 2868 6f73 745f 6c69 7374 2e66 726f st(host_list.fro │ │ │ -00066660: 6e74 2829 2c20 7374 643a 3a75 696e 7431 nt(), std::uint1 │ │ │ -00066670: 365f 7428 706f 7274 2929 3b0a 3c2f 6469 6_t(port));....if (m_ip_fi │ │ │ -00066690: 6c74 6572 2026 616d 703b 2661 6d70 3b20 lter && │ │ │ -000666a0: 6d5f 6970 5f66 696c 7465 722d 2667 743b m_ip_filter-> │ │ │ -000666b0: 6163 6365 7373 2868 6f73 742e 6164 6472 access(host.addr │ │ │ -000666c0: 6573 7328 2929 2026 616d 703b 2069 705f ess()) & ip_ │ │ │ -000666d0: 6669 6c74 6572 3a3a 626c 6f63 6b65 6429 filter::blocked) │ │ │ -000666e0: 0a09 097b 0a23 6966 6e64 6566 2054 4f52 ...{.#ifndef TOR │ │ │ -000666f0: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ -00066700: 4749 4e47 0a09 0909 6966 2028 7368 6f75 GING....if (shou │ │ │ -00066710: 6c64 5f6c 6f67 2829 290a 0909 097b 0a09 ld_log())....{.. │ │ │ -00066720: 0909 0964 6562 7567 5f6c 6f67 2822 626c ...debug_log("bl │ │ │ -00066730: 6f63 6b65 6420 6970 2066 726f 6d20 7472 ocked ip from tr │ │ │ -00066740: 6163 6b65 723a 2025 7322 2c20 686f 7374 acker: %s", host │ │ │ -00066750: 2e61 6464 7265 7373 2829 2e74 6f5f 7374 .address().to_st │ │ │ -00066760: 7269 6e67 2829 2e63 5f73 7472 2829 293b ring().c_str()); │ │ │ -00066770: 0a09 0909 7d0a 2365 6e64 6966 0a09 0909 ....}.#endif.... │ │ │ -00066780: 6966 2028 6d5f 7365 732e 616c 6572 7473 if (m_ses.alerts │ │ │ -00066790: 2829 2e73 686f 756c 645f 706f 7374 266c ().should_post&l │ │ │ -000667a0: 743b 7065 6572 5f62 6c6f 636b 6564 5f61 t;peer_blocked_a │ │ │ -000667b0: 6c65 7274 2667 743b 2829 290a 0909 0909 lert>())..... │ │ │ -000667c0: 6d5f 7365 732e 616c 6572 7473 2829 2e65 m_ses.alerts().e │ │ │ -000667d0: 6d70 6c61 6365 5f61 6c65 7274 266c 743b mplace_alert< │ │ │ -000667e0: 7065 6572 5f62 6c6f 636b 6564 5f61 6c65 peer_blocked_ale │ │ │ -000667f0: 7274 2667 743b 2867 6574 5f68 616e 646c rt>(get_handl │ │ │ -00066800: 6528 290a 0909 0909 092c 2068 6f73 742c e()......, host, │ │ │ -00066810: 2070 6565 725f 626c 6f63 6b65 645f 616c peer_blocked_al │ │ │ -00066820: 6572 743a 3a69 705f 6669 6c74 6572 293b ert::ip_filter); │ │ │ -00066830: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a ....return;...}. │ │ │ -00066840: 0a09 0969 6620 2861 6464 5f70 6565 7228 ...if (add_peer( │ │ │ -00066850: 686f 7374 2c20 7065 6572 5f69 6e66 6f3a host, peer_info: │ │ │ -00066860: 3a74 7261 636b 6572 2c20 7620 3d3d 2070 :tracker, v == p │ │ │ -00066870: 726f 746f 636f 6c5f 7665 7273 696f 6e3a rotocol_version: │ │ │ -00066880: 3a56 3220 3f20 7065 785f 6c74 5f76 3220 :V2 ? pex_lt_v2 │ │ │ -00066890: 3a20 7065 785f 666c 6167 735f 7428 3029 : pex_flags_t(0) │ │ │ -000668a0: 2929 0a09 097b 0a09 0909 7374 6174 655f ))...{....state_ │ │ │ -000668b0: 7570 6461 7465 6428 293b 0a0a 2369 666e updated();..#ifn │ │ │ -000668c0: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -000668d0: 424c 455f 4c4f 4747 494e 470a 0909 0969 BLE_LOGGING....i │ │ │ -000668e0: 6620 2873 686f 756c 645f 6c6f 6728 2929 f (should_log()) │ │ │ -000668f0: 0a09 0909 7b0a 0909 0909 6465 6275 675f ....{.....debug_ │ │ │ -00066900: 6c6f 6728 226e 616d 652d 6c6f 6f6b 7570 log("name-lookup │ │ │ -00066910: 2061 6464 5f70 6565 7228 2920 5b20 2573 add_peer() [ %s │ │ │ -00066920: 205d 2063 6f6e 6e65 6374 2d63 616e 6469 ] connect-candi │ │ │ -00066930: 6461 7465 733a 2025 6422 0a09 0909 0909 dates: %d"...... │ │ │ -00066940: 2c20 686f 7374 2e61 6464 7265 7373 2829 , host.address() │ │ │ -00066950: 2e74 6f5f 7374 7269 6e67 2829 2e63 5f73 .to_string().c_s │ │ │ -00066960: 7472 2829 0a09 0909 0909 2c20 6d5f 7065 tr()......, m_pe │ │ │ -00066970: 6572 5f6c 6973 7420 3f20 6d5f 7065 6572 er_list ? m_peer │ │ │ -00066980: 5f6c 6973 742d 2667 743b 6e75 6d5f 636f _list->num_co │ │ │ -00066990: 6e6e 6563 745f 6361 6e64 6964 6174 6573 nnect_candidates │ │ │ -000669a0: 2829 203a 202d 3129 3b0a 0909 097d 0a23 () : -1);....}.# │ │ │ -000669b0: 656e 6469 660a 0909 7d0a 0909 7570 6461 endif...}...upda │ │ │ -000669c0: 7465 5f77 616e 745f 7065 6572 7328 293b te_want_peers(); │ │ │ -000669d0: 0a09 7d0a 3c2f 7072 653e 3c2f 7464 3e3c ..}.
    < │ │ │ -000669e0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00066a10: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00066a40: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -00066a50: 703a 3439 3531 3c2f 613e 3c2f 7464 3e3c p:4951< │ │ │ -00066a60: 7464 3e6f 6e6c 7920 646f 2074 6869 7320 td>only do this │ │ │ -00066a70: 6966 2074 6865 2070 6965 6365 2073 697a if the piece siz │ │ │ -00066a80: 6520 3e20 3120 626c 6f63 6b73 2054 6869 e > 1 blocks Thi │ │ │ -00066a90: 7320 6973 2061 2076 3220 746f 7272 656e s is a v2 torren │ │ │ -00066aa0: 7420 736f 2077 6520 6361 6e20 7265 7175 t so we can requ │ │ │ -00066ab0: 6573 7420 6765 7420 626c 6f63 6b20 6c65 est get block le │ │ │ -00066ac0: 7665 6c20 6861 7368 6573 2e3c 2f74 643e vel hashes. │ │ │ -00066ad0: 3c2f 7472 3e3c 7472 2069 643d 2232 3336

    only do │ │ │ -00066b20: 2074 6869 7320 6966 2074 6865 2070 6965 this if the pie │ │ │ -00066b30: 6365 2073 697a 6520 3e20 3120 626c 6f63 ce size > 1 bloc │ │ │ -00066b40: 6b73 0a54 6869 7320 6973 2061 2076 3220 ks.This is a v2 │ │ │ -00066b50: 746f 7272 656e 7420 736f 2077 6520 6361 torrent so we ca │ │ │ -00066b60: 6e20 7265 7175 6573 7420 6765 7420 626c n request get bl │ │ │ -00066b70: 6f63 6b0a 6c65 7665 6c20 6861 7368 6573 ock.level hashes │ │ │ -00066b80: 2e3c 2f68 323e 3c68 343e 2e2e 2f73 7263 .

    ../src │ │ │ -00066b90: 2f74 6f72 7265 6e74 2e63 7070 3a34 3935 /torrent.cpp:495 │ │ │ -00066ba0: 313c 2f68 343e 3c70 7265 2073 7479 6c65 1

    │ │ │ -00066be0: 0909 7b0a 0909 0973 7464 3a3a 7365 7426  ..{....std::set&
    │ │ │ -00066bf0: 6c74 3b74 6f72 7265 6e74 5f70 6565 722a  lt;torrent_peer*
    │ │ │ -00066c00: 2667 743b 2072 6574 3b0a 0909 0969 6620  > ret;....if 
    │ │ │ -00066c10: 2821 626c 6f63 6b73 2e65 6d70 7479 2829  (!blocks.empty()
    │ │ │ -00066c20: 2026 616d 703b 2661 6d70 3b20 2164 6f77   && !dow
    │ │ │ -00066c30: 6e6c 6f61 6465 7273 2e65 6d70 7479 2829  nloaders.empty()
    │ │ │ -00066c40: 290a 0909 097b 0a09 0909 0966 6f72 2028  )....{.....for (
    │ │ │ -00066c50: 6175 746f 2063 6f6e 7374 2062 203a 2062  auto const b : b
    │ │ │ -00066c60: 6c6f 636b 7329 2072 6574 2e69 6e73 6572  locks) ret.inser
    │ │ │ -00066c70: 7428 646f 776e 6c6f 6164 6572 735b 7374  t(downloaders[st
    │ │ │ -00066c80: 643a 3a73 697a 655f 7428 6229 5d29 3b0a  d::size_t(b)]);.
    │ │ │ -00066c90: 0909 097d 0a09 0909 656c 7365 0a09 0909  ...}....else....
    │ │ │ -00066ca0: 7b0a 0909 0909 7374 643a 3a63 6f70 7928  {.....std::copy(
    │ │ │ -00066cb0: 646f 776e 6c6f 6164 6572 732e 6265 6769  downloaders.begi
    │ │ │ -00066cc0: 6e28 292c 2064 6f77 6e6c 6f61 6465 7273  n(), downloaders
    │ │ │ -00066cd0: 2e65 6e64 2829 2c20 7374 643a 3a69 6e73  .end(), std::ins
    │ │ │ -00066ce0: 6572 7465 7228 7265 742c 2072 6574 2e62  erter(ret, ret.b
    │ │ │ -00066cf0: 6567 696e 2829 2929 3b0a 0909 097d 0a09  egin()));....}..
    │ │ │ -00066d00: 0909 7265 7475 726e 2072 6574 3b0a 0909  ..return ret;...
    │ │ │ -00066d10: 7d28 293b 0a0a 0909 2f2f 2069 6620 7468  }();....// if th
    │ │ │ -00066d20: 6973 2070 6965 6365 2077 6173 6e27 7420  is piece wasn't 
    │ │ │ -00066d30: 646f 776e 6c6f 6164 6564 2066 726f 6d20  downloaded from 
    │ │ │ -00066d40: 7065 6572 732c 2077 6520 6a75 7374 2066  peers, we just f
    │ │ │ -00066d50: 6f75 6e64 2069 7420 6f6e 2064 6973 6b2e  ound it on disk.
    │ │ │ -00066d60: 0a09 092f 2f20 496e 2074 6861 7420 6361  ...// In that ca
    │ │ │ -00066d70: 7365 2c20 7765 2073 686f 756c 6420 6a75  se, we should ju
    │ │ │ -00066d80: 7374 2063 6f6e 7369 6465 7220 6974 2061  st consider it a
    │ │ │ -00066d90: 7320 226e 6f74 2d68 6176 6522 2061 6e64  s "not-have" and
    │ │ │ -00066da0: 2074 6865 7265 2773 206e 6f0a 0909 2f2f   there's no...//
    │ │ │ -00066db0: 206e 6565 6420 746f 2074 7279 2074 6f20   need to try to 
    │ │ │ -00066dc0: 6765 7420 6869 6768 6572 2066 6964 656c  get higher fidel
    │ │ │ -00066dd0: 6974 7920 6861 7368 6573 2028 7965 7429  ity hashes (yet)
    │ │ │ -00066de0: 0a09 0962 6f6f 6c20 636f 6e73 7420 666f  ...bool const fo
    │ │ │ -00066df0: 756e 645f 6f6e 5f64 6973 6b20 3d20 7065  und_on_disk = pe
    │ │ │ -00066e00: 6572 732e 7369 7a65 2829 203d 3d20 3120  ers.size() == 1 
    │ │ │ -00066e10: 2661 6d70 3b26 616d 703b 2070 6565 7273  && peers
    │ │ │ -00066e20: 2e63 6f75 6e74 286e 756c 6c70 7472 293b  .count(nullptr);
    │ │ │ -00066e30: 0a0a 0909 6966 2028 746f 7272 656e 745f  ....if (torrent_
    │ │ │ -00066e40: 6669 6c65 2829 2e69 6e66 6f5f 6861 7368  file().info_hash
    │ │ │ -00066e50: 6573 2829 2e68 6173 5f76 3228 2920 2661  es().has_v2() &a
    │ │ │ -00066e60: 6d70 3b26 616d 703b 2062 6c6f 636b 732e  mp;& blocks.
    │ │ │ -00066e70: 656d 7074 7928 2920 2661 6d70 3b26 616d  empty() &&am
    │ │ │ -00066e80: 703b 2021 666f 756e 645f 6f6e 5f64 6973  p; !found_on_dis
    │ │ │ -00066e90: 6b29 0a09 097b 0a3c 6469 7620 7374 796c  k)...{.
    ...verify_b │ │ │ -00066ed0: 6c6f 636b 5f68 6173 6865 7328 696e 6465 lock_hashes(inde │ │ │ -00066ee0: 7829 3b0a 3c2f 6469 763e 0909 7d0a 0a09 x);.
    ..}... │ │ │ -00066ef0: 092f 2f20 7468 6520 6265 6c6f 7720 636f .// the below co │ │ │ -00066f00: 6465 2069 7320 7065 6e61 6c69 7a69 6e67 de is penalizing │ │ │ -00066f10: 2070 6565 7273 2074 6861 7420 7365 6e74 peers that sent │ │ │ -00066f20: 2075 7365 2062 6164 2064 6174 612e 0a09 use bad data... │ │ │ -00066f30: 092f 2f20 696e 6372 6561 7365 2074 6865 .// increase the │ │ │ -00066f40: 2074 6f74 616c 2061 6d6f 756e 7420 6f66 total amount of │ │ │ -00066f50: 2066 6169 6c65 6420 6279 7465 730a 0909 failed bytes... │ │ │ -00066f60: 6966 2028 2166 6f75 6e64 5f6f 6e5f 6469 if (!found_on_di │ │ │ -00066f70: 736b 290a 0909 7b0a 0909 0969 6620 2862 sk)...{....if (b │ │ │ -00066f80: 6c6f 636b 732e 656d 7074 7928 2929 0a09 locks.empty()).. │ │ │ -00066f90: 0909 0961 6464 5f66 6169 6c65 645f 6279 ...add_failed_by │ │ │ -00066fa0: 7465 7328 6d5f 746f 7272 656e 745f 6669 tes(m_torrent_fi │ │ │ -00066fb0: 6c65 2d26 6774 3b70 6965 6365 5f73 697a le->piece_siz │ │ │ -00066fc0: 6528 696e 6465 7829 293b 0a09 0909 656c e(index));....el │ │ │ -00066fd0: 7365 0a09 0909 0961 6464 5f66 6169 6c65 se.....add_faile │ │ │ -00066fe0: 645f 6279 7465 7328 7374 6174 6963 5f63 d_bytes(static_c │ │ │ -00066ff0: 6173 7426 6c74 3b69 6e74 2667 743b 2862 ast<int>(b │ │ │ -00067000: 6c6f 636b 732e 7369 7a65 2829 2920 2a20 locks.size()) * │ │ │ -00067010: 6465 6661 756c 745f 626c 6f63 6b5f 7369 default_block_si │ │ │ -00067020: 7a65 293b 0a0a 2369 666e 6465 6620 544f ze);..#ifndef TO │ │ │ -00067030: 5252 454e 545f 4449 5341 424c 455f 4558 RRENT_DISABLE_EX │ │ │ -00067040: 5445 4e53 494f 4e53 0a09 0909 666f 7220 TENSIONS....for │ │ │ -00067050: 2861 7574 6f26 616d 703b 2065 7874 203a (auto& ext : │ │ │ -00067060: 206d 5f65 7874 656e 7369 6f6e 7329 0a09 m_extensions).. │ │ │ -00067070: 0909 7b0a 0909 0909 6578 742d 2667 743b ..{.....ext-> │ │ │ -00067080: 6f6e 5f70 6965 6365 5f66 6169 6c65 6428 on_piece_failed( │ │ │ -00067090: 696e 6465 7829 3b0a 0909 097d 0a23 656e index);....}.#en │ │ │ -000670a0: 6469 660a 0a09 0909 2f2f 2064 6964 2077 dif.....// did w │ │ │ -000670b0: 6520 7265 6365 6976 6520 7468 6973 2070 e receive this p │ │ │ -000670c0: 6965 6365 2066 726f 6d20 6120 7369 6e67 iece from a sing │ │ │ -000670d0: 6c65 2070 6565 723f 0a09 0909 2f2f 2069 le peer?....// i │ │ │ -000670e0: 6620 7765 206b 6e6f 7720 6578 6163 746c f we know exactl │ │ │ -000670f0: 7920 7768 6963 6820 626c 6f63 6b73 2066 y which blocks f │ │ │ -00067100: 6169 6c65 6420 7468 6520 6861 7368 2c20 ailed the hash, │ │ │ -00067110: 7765 2063 616e 2061 6c73 6f20 6265 2063 we can also be c │ │ │ -00067120: 6572 7461 696e 0a09 0909 2f2f 2074 6861 ertain....// tha │ │ │ -00067130: 7420 616c 6c20 7065 6572 7320 696e 2074 t all peers in t │ │ │ -00067140: 6865 206c 6973 7420 7365 6e74 2075 7320 he list sent us │ │ │ -00067150: 6261 6420 6461 7461 0a09 0909 626f 6f6c bad data....bool │ │ │ -00067160: 2063 6f6e 7374 206b 6e6f 776e 5f62 6164 const known_bad │ │ │ -00067170: 5f70 6565 7220 3d20 7065 6572 732e 7369 _peer = peers.si │ │ │ -00067180: 7a65 2829 203d 3d20 3120 7c7c 2021 626c ze() == 1 || !bl │ │ │ -00067190: 6f63 6b73 2e65 6d70 7479 2829 3b0a 0a09 ocks.empty();... │ │ │ -000671a0: 0909 7065 6e61 6c69 7a65 5f70 6565 7273 ..penalize_peers │ │ │ -000671b0: 2870 6565 7273 2c20 696e 6465 782c 206b (peers, index, k │ │ │ -000671c0: 6e6f 776e 5f62 6164 5f70 6565 7229 3b0a nown_bad_peer);. │ │ │ -000671d0: 0909 7d0a 0a09 092f 2f20 4966 206d 5f73 ..}....// If m_s │ │ │ -000671e0: 746f 7261 6765 2069 736e 2774 2073 6574 torage isn't set │ │ │ -000671f0: 2068 6572 652c 2069 7420 6d65 616e 7320 here, it means │ │ │ -00067200: 7765 2772 6520 7368 7574 7469 6e67 2064 we're shutting d │ │ │ -00067210: 6f77 6e0a 0909 6966 2028 6d5f 7374 6f72 own...if (m_stor │ │ │ -00067220: 6167 6529 0a09 097b 0a09 0909 2f2f 2069 age)...{....// i │ │ │ -00067230: 7420 646f 6573 6e27 7420 6d61 6b65 206d t doesn't make m │ │ │ -00067240: 7563 6820 7365 6e73 6520 746f 2066 6169 uch sense to fai │ │ │ -00067250: 6c20 746f 2068 6173 6820 6120 7069 6563 l to hash a piec │ │ │ -00067260: 650a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 e.
    < │ │ │ -00067290: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000672a0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -000672d0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -000672e0: 3739 3037 3c2f 613e 3c2f 7464 3e3c 7464 7907come up with a │ │ │ -00067300: 6265 7474 6572 2077 6179 206f 6620 646f better way of do │ │ │ -00067310: 696e 6720 7468 6973 2c20 696e 7374 6561 ing this, instea │ │ │ -00067320: 6420 6f66 2061 6e20 696d 6d65 6469 6174 d of an immediat │ │ │ -00067330: 656c 7920 696e 766f 6b65 6420 6c61 6d62 ely invoked lamb │ │ │ -00067340: 6461 2065 7870 7265 7373 696f 6e2e 3c2f da expression.

    come │ │ │ -000673a0: 2075 7020 7769 7468 2061 2062 6574 7465 up with a bette │ │ │ -000673b0: 7220 7761 7920 6f66 2064 6f69 6e67 2074 r way of doing t │ │ │ -000673c0: 6869 732c 2069 6e73 7465 6164 206f 6620 his, instead of │ │ │ -000673d0: 616e 0a69 6d6d 6564 6961 7465 6c79 2069 an.immediately i │ │ │ -000673e0: 6e76 6f6b 6564 206c 616d 6264 6120 6578 nvoked lambda ex │ │ │ -000673f0: 7072 6573 7369 6f6e 2e3c 2f68 323e 3c68 pression.

    ../src/torrent │ │ │ -00067410: 2e63 7070 3a37 3930 373c 2f68 343e 3c70 .cpp:7907

    .....|| │ │ │ -00067460: 7065 6572 696e 666f 2d26 6774 3b63 6f6e peerinfo->con │ │ │ -00067470: 6669 726d 6564 5f73 7570 706f 7274 735f firmed_supports_ │ │ │ -00067480: 7574 7029 290a 0909 097b 0a09 0909 0973 utp))....{.....s │ │ │ -00067490: 6d20 3d20 6d5f 7365 732e 7574 705f 736f m = m_ses.utp_so │ │ │ -000674a0: 636b 6574 5f6d 616e 6167 6572 2829 3b0a cket_manager();. │ │ │ -000674b0: 0909 097d 0a0a 0909 092f 2f20 646f 6e27 ...}.....// don' │ │ │ -000674c0: 7420 6d61 6b65 2061 2054 4350 2063 6f6e t make a TCP con │ │ │ -000674d0: 6e65 6374 696f 6e20 6966 2069 7427 7320 nection if it's │ │ │ -000674e0: 6469 7361 626c 6564 0a09 0909 6966 2028 disabled....if ( │ │ │ -000674f0: 736d 203d 3d20 6e75 6c6c 7074 7220 2661 sm == nullptr &a │ │ │ -00067500: 6d70 3b26 616d 703b 2021 7365 7474 696e mp;& !settin │ │ │ -00067510: 6773 2829 2e67 6574 5f62 6f6f 6c28 7365 gs().get_bool(se │ │ │ -00067520: 7474 696e 6773 5f70 6163 6b3a 3a65 6e61 ttings_pack::ena │ │ │ -00067530: 626c 655f 6f75 7467 6f69 6e67 5f74 6370 ble_outgoing_tcp │ │ │ -00067540: 2929 0a09 0909 7b0a 2369 666e 6465 6620 ))....{.#ifndef │ │ │ -00067550: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00067560: 4c4f 4747 494e 470a 0909 0909 6966 2028 LOGGING.....if ( │ │ │ -00067570: 7368 6f75 6c64 5f6c 6f67 2829 290a 0909 should_log())... │ │ │ -00067580: 0909 7b0a 0909 0909 0964 6562 7567 5f6c ..{......debug_l │ │ │ -00067590: 6f67 2822 6469 7363 6172 6469 6e67 2070 og("discarding p │ │ │ -000675a0: 6565 7220 5c22 2573 5c22 3a20 5443 5020 eer \"%s\": TCP │ │ │ -000675b0: 636f 6e6e 6563 7469 6f6e 7320 6469 7361 connections disa │ │ │ -000675c0: 626c 6564 2022 0a09 0909 0909 0922 5b20 bled "......."[ │ │ │ -000675d0: 7375 7070 6f72 7473 2d75 7470 3a20 2564 supports-utp: %d │ │ │ -000675e0: 205d 222c 2070 6565 7269 6e66 6f2d 2667 ]", peerinfo-&g │ │ │ -000675f0: 743b 746f 5f73 7472 696e 6728 292e 635f t;to_string().c_ │ │ │ -00067600: 7374 7228 290a 0909 0909 0909 2c20 7065 str()......., pe │ │ │ -00067610: 6572 696e 666f 2d26 6774 3b73 7570 706f erinfo->suppo │ │ │ -00067620: 7274 735f 7574 7029 3b0a 0909 0909 7d0a rts_utp);.....}. │ │ │ -00067630: 2365 6e64 6966 0a09 0909 0972 6574 7572 #endif.....retur │ │ │ -00067640: 6e20 6661 6c73 653b 0a09 0909 7d0a 0909 n false;....}... │ │ │ -00067650: 7d0a 0a3c 6469 7620 7374 796c 653d 2262 }..

    ..aux::socket_t │ │ │ -00067690: 7970 6520 7320 3d20 5b26 616d 703b 5d20 ype s = [&] │ │ │ -000676a0: 7b0a 3c2f 6469 763e 0a23 6966 2054 4f52 {.
    .#if TOR │ │ │ -000676b0: 5245 4e54 5f55 5345 5f49 3250 0a09 0969 RENT_USE_I2P...i │ │ │ -000676c0: 6620 2870 6565 7269 6e66 6f2d 2667 743b f (peerinfo-> │ │ │ -000676d0: 6973 5f69 3270 5f61 6464 7229 0a09 097b is_i2p_addr)...{ │ │ │ -000676e0: 0a09 0909 2f2f 2049 7427 7320 6e6f 7420 ....// It's not │ │ │ -000676f0: 656e 7469 7265 6c79 206f 6276 696f 7573 entirely obvious │ │ │ -00067700: 2077 6879 2074 6869 7320 7065 6572 2063 why this peer c │ │ │ -00067710: 6f6e 6e65 6374 696f 6e20 6973 206e 6f74 onnection is not │ │ │ -00067720: 206d 6172 6b65 6420 6173 0a09 0909 2f2f marked as....// │ │ │ -00067730: 206f 6e65 2e20 5468 6520 6d61 696e 2066 one. The main f │ │ │ -00067740: 6561 7475 7265 206f 6620 6120 7065 6572 eature of a peer │ │ │ -00067750: 2063 6f6e 6e65 6374 696f 6e20 6973 2074 connection is t │ │ │ -00067760: 6861 7420 7768 6574 6865 7220 6f72 206e hat whether or n │ │ │ -00067770: 6f74 2077 650a 0909 092f 2f20 7072 6f78 ot we....// prox │ │ │ -00067780: 7920 6974 2069 7320 636f 6e66 6967 7572 y it is configur │ │ │ -00067790: 6162 6c65 2e20 5768 656e 2077 6520 7573 able. When we us │ │ │ -000677a0: 6520 6932 702c 2077 6520 7761 6e74 2074 e i2p, we want t │ │ │ -000677b0: 6f20 616c 7761 7973 2070 726f 780a 0909 o always prox... │ │ │ -000677c0: 092f 2f20 6576 6572 7974 6869 6e67 2076 .// everything v │ │ │ -000677d0: 6961 2069 3270 2e0a 0a09 0909 6175 783a ia i2p......aux: │ │ │ -000677e0: 3a70 726f 7879 5f73 6574 7469 6e67 7320 :proxy_settings │ │ │ -000677f0: 7072 6f78 793b 0a09 0909 7072 6f78 792e proxy;....proxy. │ │ │ -00067800: 686f 7374 6e61 6d65 203d 2073 6574 7469 hostname = setti │ │ │ -00067810: 6e67 7328 292e 6765 745f 7374 7228 7365 ngs().get_str(se │ │ │ -00067820: 7474 696e 6773 5f70 6163 6b3a 3a69 3270 ttings_pack::i2p │ │ │ -00067830: 5f68 6f73 746e 616d 6529 3b0a 0909 0970 _hostname);....p │ │ │ -00067840: 726f 7879 2e70 6f72 7420 3d20 7374 643a roxy.port = std: │ │ │ -00067850: 3a75 696e 7431 365f 7428 7365 7474 696e :uint16_t(settin │ │ │ -00067860: 6773 2829 2e67 6574 5f69 6e74 2873 6574 gs().get_int(set │ │ │ -00067870: 7469 6e67 735f 7061 636b 3a3a 6932 705f tings_pack::i2p_ │ │ │ -00067880: 706f 7274 2929 3b0a 0909 0970 726f 7879 port));....proxy │ │ │ -00067890: 2e74 7970 6520 3d20 7365 7474 696e 6773 .type = settings │ │ │ -000678a0: 5f70 6163 6b3a 3a69 3270 5f70 726f 7879 _pack::i2p_proxy │ │ │ -000678b0: 3b0a 0a09 0909 6175 783a 3a73 6f63 6b65 ;.....aux::socke │ │ │ -000678c0: 745f 7479 7065 2072 6574 203d 2069 6e73 t_type ret = ins │ │ │ -000678d0: 7461 6e74 6961 7465 5f63 6f6e 6e65 6374 tantiate_connect │ │ │ -000678e0: 696f 6e28 6d5f 7365 732e 6765 745f 636f ion(m_ses.get_co │ │ │ -000678f0: 6e74 6578 7428 290a 0909 0909 2c20 7072 ntext()....., pr │ │ │ -00067900: 6f78 792c 206e 756c 6c70 7472 2c20 6e75 oxy, nullptr, nu │ │ │ -00067910: 6c6c 7074 722c 2066 616c 7365 2c20 6661 llptr, false, fa │ │ │ -00067920: 6c73 6529 3b0a 0909 0961 7574 6f26 616d lse);....auto&am │ │ │ -00067930: 703b 2073 7472 203d 2073 7464 3a3a 6765 p; str = std::ge │ │ │ -00067940: 7426 6c74 3b69 3270 5f73 7472 6561 6d26 t<i2p_stream& │ │ │ -00067950: 6774 3b28 7265 7429 3b0a 0909 0973 7472 gt;(ret);....str │ │ │ -00067960: 2e73 6574 5f6c 6f63 616c 5f69 3270 5f65 .set_local_i2p_e │ │ │ -00067970: 6e64 706f 696e 7428 6d5f 7365 732e 6c6f ndpoint(m_ses.lo │ │ │ -00067980: 6361 6c5f 6932 705f 656e 6470 6f69 6e74 cal_i2p_endpoint │ │ │ -00067990: 2829 293b 0a09 0909 7374 722e 7365 745f ());....str.set_ │ │ │ -000679a0: 6465 7374 696e 6174 696f 6e28 7374 6174 destination(stat │ │ │ -000679b0: 6963 5f63 6173 7426 6c74 3b69 3270 5f70 ic_cast<i2p_p │ │ │ -000679c0: 6565 722a 2667 743b 2870 6565 7269 6e66 eer*>(peerinf │ │ │ -000679d0: 6f29 2d26 6774 3b64 6573 7428 2929 3b0a o)->dest());. │ │ │ -000679e0: 0909 0973 7472 2e73 6574 5f63 6f6d 6d61 ...str.set_comma │ │ │ -000679f0: 6e64 2869 3270 5f73 7472 6561 6d3a 3a63 nd(i2p_stream::c │ │ │ -00067a00: 6d64 5f63 6f6e 6e65 6374 293b 0a09 0909 md_connect);.... │ │ │ -00067a10: 7374 722e 7365 745f 7365 7373 696f 6e5f str.set_session_ │ │ │ -00067a20: 6964 286d 5f73 6573 2e69 3270 5f73 6573 id(m_ses.i2p_ses │ │ │ -00067a30: 7369 6f6e 2829 293b 0a09 0909 7265 7475 sion());....retu │ │ │ -00067a40: 726e 2072 6574 3b0a 0909 7d0a 0909 656c rn ret;...}...el │ │ │ -00067a50: 7365 0a23 656e 6469 660a 0909 7b0a 0909 se.#endif...{... │ │ │ -00067a60: 0976 6f69 642a 2075 7365 7264 6174 6120 .void* userdata │ │ │ -00067a70: 3d20 6e75 6c6c 7074 723b 0a23 6966 6465 = nullptr;.#ifde │ │ │ -00067a80: 6620 544f 5252 454e 545f 5353 4c5f 5045 f TORRENT_SSL_PE │ │ │ -00067a90: 4552 530a 0909 0969 6620 2869 735f 7373 ERS....if (is_ss │ │ │ -00067aa0: 6c5f 746f 7272 656e 7428 2929 0a09 0909 l_torrent()).... │ │ │ -00067ab0: 7b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 {.< │ │ │ -00067ae0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00067af0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00067b20: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00067b30: 3935 3636 3c2f 613e 3c2f 7464 3e3c 7464 9566perhaps 0 shoul │ │ │ -00067b50: 6420 6163 7475 616c 6c79 206d 6561 6e20 d actually mean │ │ │ -00067b60: 303c 2f74 643e 3c2f 7472 3e3c 7472 2069 0

    p │ │ │ -00067bb0: 6572 6861 7073 2030 2073 686f 756c 6420 erhaps 0 should │ │ │ -00067bc0: 6163 7475 616c 6c79 206d 6561 6e20 303c actually mean 0< │ │ │ -00067bd0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ -00067be0: 6f72 7265 6e74 2e63 7070 3a39 3536 363c orrent.cpp:9566< │ │ │ -00067bf0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -00067c30: 2f2f 2066 696e 6973 6865 6420 746f 7272  // finished torr
    │ │ │ -00067c40: 656e 7473 206d 6179 206e 6f74 2063 6861  ents may not cha
    │ │ │ -00067c50: 6e67 6520 7468 6569 7220 7175 6575 6520  nge their queue 
    │ │ │ -00067c60: 706f 7369 7469 6f6e 732c 2061 7320 6974  positions, as it
    │ │ │ -00067c70: 2773 2073 6574 2074 6f0a 0909 2f2f 202d  's set to...// -
    │ │ │ -00067c80: 310a 0909 6966 2028 286d 5f61 626f 7274  1...if ((m_abort
    │ │ │ -00067c90: 207c 7c20 6973 5f66 696e 6973 6865 6428   || is_finished(
    │ │ │ -00067ca0: 2929 2026 616d 703b 2661 6d70 3b20 7020  )) && p 
    │ │ │ -00067cb0: 213d 206e 6f5f 706f 7329 2072 6574 7572  != no_pos) retur
    │ │ │ -00067cc0: 6e3b 0a0a 0909 544f 5252 454e 545f 4153  n;....TORRENT_AS
    │ │ │ -00067cd0: 5345 5254 2828 7020 3d3d 206e 6f5f 706f  SERT((p == no_po
    │ │ │ -00067ce0: 7329 203d 3d20 6973 5f66 696e 6973 6865  s) == is_finishe
    │ │ │ -00067cf0: 6428 290a 0909 097c 7c20 2821 6d5f 6175  d()....|| (!m_au
    │ │ │ -00067d00: 746f 5f6d 616e 6167 6564 2026 616d 703b  to_managed &
    │ │ │ -00067d10: 2661 6d70 3b20 7020 3d3d 206e 6f5f 706f  & p == no_po
    │ │ │ -00067d20: 7329 0a09 0909 7c7c 2028 6d5f 6162 6f72  s)....|| (m_abor
    │ │ │ -00067d30: 7420 2661 6d70 3b26 616d 703b 2070 203d  t && p =
    │ │ │ -00067d40: 3d20 6e6f 5f70 6f73 290a 0909 097c 7c20  = no_pos)....|| 
    │ │ │ -00067d50: 2821 6d5f 6164 6465 6420 2661 6d70 3b26  (!m_added &&
    │ │ │ -00067d60: 616d 703b 2070 203d 3d20 6e6f 5f70 6f73  amp; p == no_pos
    │ │ │ -00067d70: 2929 3b0a 0909 6966 2028 7020 3d3d 206d  ));...if (p == m
    │ │ │ -00067d80: 5f73 6571 7565 6e63 655f 6e75 6d62 6572  _sequence_number
    │ │ │ -00067d90: 2920 7265 7475 726e 3b0a 0a09 0954 4f52  ) return;....TOR
    │ │ │ -00067da0: 5245 4e54 5f41 5353 4552 5428 7020 2667  RENT_ASSERT(p &g
    │ │ │ -00067db0: 743b 3d20 6e6f 5f70 6f73 293b 0a0a 0909  t;= no_pos);....
    │ │ │ -00067dc0: 7374 6174 655f 7570 6461 7465 6428 293b  state_updated();
    │ │ │ -00067dd0: 0a0a 0909 6d5f 7365 732e 7365 745f 7175  ....m_ses.set_qu
    │ │ │ -00067de0: 6575 655f 706f 7369 7469 6f6e 2874 6869  eue_position(thi
    │ │ │ -00067df0: 732c 2070 293b 0a09 7d0a 0a09 766f 6964  s, p);..}...void
    │ │ │ -00067e00: 2074 6f72 7265 6e74 3a3a 7365 745f 6d61   torrent::set_ma
    │ │ │ -00067e10: 785f 7570 6c6f 6164 7328 696e 7420 6c69  x_uploads(int li
    │ │ │ -00067e20: 6d69 742c 2062 6f6f 6c20 636f 6e73 7420  mit, bool const 
    │ │ │ -00067e30: 7374 6174 655f 7570 6461 7465 290a 097b  state_update)..{
    │ │ │ -00067e40: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -00067e50: 5428 6973 5f73 696e 676c 655f 7468 7265  T(is_single_thre
    │ │ │ -00067e60: 6164 2829 293b 0a3c 6469 7620 7374 796c  ad());.
    ..if (limit │ │ │ -00067ea0: 2026 6c74 3b3d 2030 2920 6c69 6d69 7420 <= 0) limit │ │ │ -00067eb0: 3d20 2831 2026 6c74 3b26 6c74 3b20 3234 = (1 << 24 │ │ │ -00067ec0: 2920 2d20 313b 0a3c 2f64 6976 3e09 0969 ) - 1;.
    ..i │ │ │ -00067ed0: 6620 2869 6e74 286d 5f6d 6178 5f75 706c f (int(m_max_upl │ │ │ -00067ee0: 6f61 6473 2920 3d3d 206c 696d 6974 2920 oads) == limit) │ │ │ -00067ef0: 7265 7475 726e 3b0a 0909 6966 2028 7374 return;...if (st │ │ │ -00067f00: 6174 655f 7570 6461 7465 2920 7374 6174 ate_update) stat │ │ │ -00067f10: 655f 7570 6461 7465 6428 293b 0a09 096d e_updated();...m │ │ │ -00067f20: 5f6d 6178 5f75 706c 6f61 6473 203d 2061 _max_uploads = a │ │ │ -00067f30: 7578 3a3a 6e75 6d65 7269 635f 6361 7374 ux::numeric_cast │ │ │ -00067f40: 266c 743b 7374 643a 3a75 696e 7433 325f <std::uint32_ │ │ │ -00067f50: 7426 6774 3b28 6c69 6d69 7429 3b0a 2369 t>(limit);.#i │ │ │ -00067f60: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ -00067f70: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ -00067f80: 6966 2028 7368 6f75 6c64 5f6c 6f67 2829 if (should_log() │ │ │ -00067f90: 2026 616d 703b 2661 6d70 3b20 7374 6174 && stat │ │ │ -00067fa0: 655f 7570 6461 7465 290a 0909 0964 6562 e_update)....deb │ │ │ -00067fb0: 7567 5f6c 6f67 2822 2a2a 2a20 7365 742d ug_log("*** set- │ │ │ -00067fc0: 6d61 782d 7570 6c6f 6164 733a 2025 6422 max-uploads: %d" │ │ │ -00067fd0: 2c20 6d5f 6d61 785f 7570 6c6f 6164 7329 , m_max_uploads) │ │ │ -00067fe0: 3b0a 2365 6e64 6966 0a0a 0909 6966 2028 ;.#endif....if ( │ │ │ -00067ff0: 7374 6174 655f 7570 6461 7465 290a 0909 state_update)... │ │ │ -00068000: 0973 6574 5f6e 6565 645f 7361 7665 5f72 .set_need_save_r │ │ │ -00068010: 6573 756d 6528 746f 7272 656e 745f 6861 esume(torrent_ha │ │ │ -00068020: 6e64 6c65 3a3a 6966 5f63 6f6e 6669 675f ndle::if_config_ │ │ │ -00068030: 6368 616e 6765 6429 3b0a 097d 0a0a 0976 changed);..}...v │ │ │ -00068040: 6f69 6420 746f 7272 656e 743a 3a73 6574 oid torrent::set │ │ │ -00068050: 5f6d 6178 5f63 6f6e 6e65 6374 696f 6e73 _max_connections │ │ │ -00068060: 2869 6e74 206c 696d 6974 2c20 626f 6f6c (int limit, bool │ │ │ -00068070: 2063 6f6e 7374 2073 7461 7465 5f75 7064 const state_upd │ │ │ -00068080: 6174 6529 0a09 7b0a 0909 544f 5252 454e ate)..{...TORREN │ │ │ -00068090: 545f 4153 5345 5254 2869 735f 7369 6e67 T_ASSERT(is_sing │ │ │ -000680a0: 6c65 5f74 6872 6561 6428 2929 3b0a 3c2f le_thread());.r │ │ │ -000680e0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -000680f0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00068120: 746f 7272 656e 742e 6370 703a 3935 3833 torrent.cpp:9583 │ │ │ -00068130: 3c2f 613e 3c2f 7464 3e3c 7464 3e70 6572 per │ │ │ -00068140: 6861 7073 2030 2073 686f 756c 6420 6163 haps 0 should ac │ │ │ -00068150: 7475 616c 6c79 206d 6561 6e20 303c 2f74 tually mean 0

    perha │ │ │ -000681b0: 7073 2030 2073 686f 756c 6420 6163 7475 ps 0 should actu │ │ │ -000681c0: 616c 6c79 206d 6561 6e20 303c 2f68 323e ally mean 0

    │ │ │ -000681d0: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ -000681e0: 6e74 2e63 7070 3a39 3538 333c 2f68 343e nt.cpp:9583

    │ │ │ -000681f0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..void
    │ │ │ -00068230: 2074 6f72 7265 6e74 3a3a 7365 745f 6d61   torrent::set_ma
    │ │ │ -00068240: 785f 7570 6c6f 6164 7328 696e 7420 6c69  x_uploads(int li
    │ │ │ -00068250: 6d69 742c 2062 6f6f 6c20 636f 6e73 7420  mit, bool const 
    │ │ │ -00068260: 7374 6174 655f 7570 6461 7465 290a 097b  state_update)..{
    │ │ │ -00068270: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -00068280: 5428 6973 5f73 696e 676c 655f 7468 7265  T(is_single_thre
    │ │ │ -00068290: 6164 2829 293b 0a09 0969 6620 286c 696d  ad());...if (lim
    │ │ │ -000682a0: 6974 2026 6c74 3b3d 2030 2920 6c69 6d69  it <= 0) limi
    │ │ │ -000682b0: 7420 3d20 2831 2026 6c74 3b26 6c74 3b20  t = (1 << 
    │ │ │ -000682c0: 3234 2920 2d20 313b 0a09 0969 6620 2869  24) - 1;...if (i
    │ │ │ -000682d0: 6e74 286d 5f6d 6178 5f75 706c 6f61 6473  nt(m_max_uploads
    │ │ │ -000682e0: 2920 3d3d 206c 696d 6974 2920 7265 7475  ) == limit) retu
    │ │ │ -000682f0: 726e 3b0a 0909 6966 2028 7374 6174 655f  rn;...if (state_
    │ │ │ -00068300: 7570 6461 7465 2920 7374 6174 655f 7570  update) state_up
    │ │ │ -00068310: 6461 7465 6428 293b 0a09 096d 5f6d 6178  dated();...m_max
    │ │ │ -00068320: 5f75 706c 6f61 6473 203d 2061 7578 3a3a  _uploads = aux::
    │ │ │ -00068330: 6e75 6d65 7269 635f 6361 7374 266c 743b  numeric_cast<
    │ │ │ -00068340: 7374 643a 3a75 696e 7433 325f 7426 6774  std::uint32_t>
    │ │ │ -00068350: 3b28 6c69 6d69 7429 3b0a 2369 666e 6465  ;(limit);.#ifnde
    │ │ │ -00068360: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ -00068370: 455f 4c4f 4747 494e 470a 0909 6966 2028  E_LOGGING...if (
    │ │ │ -00068380: 7368 6f75 6c64 5f6c 6f67 2829 2026 616d  should_log() &am
    │ │ │ -00068390: 703b 2661 6d70 3b20 7374 6174 655f 7570  p;& state_up
    │ │ │ -000683a0: 6461 7465 290a 0909 0964 6562 7567 5f6c  date)....debug_l
    │ │ │ -000683b0: 6f67 2822 2a2a 2a20 7365 742d 6d61 782d  og("*** set-max-
    │ │ │ -000683c0: 7570 6c6f 6164 733a 2025 6422 2c20 6d5f  uploads: %d", m_
    │ │ │ -000683d0: 6d61 785f 7570 6c6f 6164 7329 3b0a 2365  max_uploads);.#e
    │ │ │ -000683e0: 6e64 6966 0a0a 0909 6966 2028 7374 6174  ndif....if (stat
    │ │ │ -000683f0: 655f 7570 6461 7465 290a 0909 0973 6574  e_update)....set
    │ │ │ -00068400: 5f6e 6565 645f 7361 7665 5f72 6573 756d  _need_save_resum
    │ │ │ -00068410: 6528 746f 7272 656e 745f 6861 6e64 6c65  e(torrent_handle
    │ │ │ -00068420: 3a3a 6966 5f63 6f6e 6669 675f 6368 616e  ::if_config_chan
    │ │ │ -00068430: 6765 6429 3b0a 097d 0a0a 0976 6f69 6420  ged);..}...void 
    │ │ │ -00068440: 746f 7272 656e 743a 3a73 6574 5f6d 6178  torrent::set_max
    │ │ │ -00068450: 5f63 6f6e 6e65 6374 696f 6e73 2869 6e74  _connections(int
    │ │ │ -00068460: 206c 696d 6974 2c20 626f 6f6c 2063 6f6e   limit, bool con
    │ │ │ -00068470: 7374 2073 7461 7465 5f75 7064 6174 6529  st state_update)
    │ │ │ -00068480: 0a09 7b0a 0909 544f 5252 454e 545f 4153  ..{...TORRENT_AS
    │ │ │ -00068490: 5345 5254 2869 735f 7369 6e67 6c65 5f74  SERT(is_single_t
    │ │ │ -000684a0: 6872 6561 6428 2929 3b0a 3c64 6976 2073  hread());.
    ..if (li │ │ │ -000684e0: 6d69 7420 266c 743b 3d20 3029 206c 696d mit <= 0) lim │ │ │ -000684f0: 6974 203d 2028 3120 266c 743b 266c 743b it = (1 << │ │ │ -00068500: 2032 3429 202d 2031 3b0a 3c2f 6469 763e 24) - 1;.
    │ │ │ -00068510: 0909 6966 2028 696e 7428 6d5f 6d61 785f ..if (int(m_max_ │ │ │ -00068520: 636f 6e6e 6563 7469 6f6e 7329 203d 3d20 connections) == │ │ │ -00068530: 6c69 6d69 7429 2072 6574 7572 6e3b 0a09 limit) return;.. │ │ │ -00068540: 0969 6620 2873 7461 7465 5f75 7064 6174 .if (state_updat │ │ │ -00068550: 6529 2073 7461 7465 5f75 7064 6174 6564 e) state_updated │ │ │ -00068560: 2829 3b0a 0909 6d5f 6d61 785f 636f 6e6e ();...m_max_conn │ │ │ -00068570: 6563 7469 6f6e 7320 3d20 6175 783a 3a6e ections = aux::n │ │ │ -00068580: 756d 6572 6963 5f63 6173 7426 6c74 3b73 umeric_cast<s │ │ │ -00068590: 7464 3a3a 7569 6e74 3332 5f74 2667 743b td::uint32_t> │ │ │ -000685a0: 286c 696d 6974 293b 0a09 0975 7064 6174 (limit);...updat │ │ │ -000685b0: 655f 7761 6e74 5f70 6565 7273 2829 3b0a e_want_peers();. │ │ │ -000685c0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -000685d0: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ -000685e0: 0a09 0969 6620 2873 686f 756c 645f 6c6f ...if (should_lo │ │ │ -000685f0: 6728 2920 2661 6d70 3b26 616d 703b 2073 g() && s │ │ │ -00068600: 7461 7465 5f75 7064 6174 6529 0a09 0909 tate_update).... │ │ │ -00068610: 6465 6275 675f 6c6f 6728 222a 2a2a 2073 debug_log("*** s │ │ │ -00068620: 6574 2d6d 6178 2d63 6f6e 6e65 6374 696f et-max-connectio │ │ │ -00068630: 6e73 3a20 2564 222c 206d 5f6d 6178 5f63 ns: %d", m_max_c │ │ │ -00068640: 6f6e 6e65 6374 696f 6e73 293b 0a23 656e onnections);.#en │ │ │ -00068650: 6469 660a 0a09 0969 6620 286e 756d 5f70 dif....if (num_p │ │ │ -00068660: 6565 7273 2829 2026 6774 3b20 696e 7428 eers() > int( │ │ │ -00068670: 6d5f 6d61 785f 636f 6e6e 6563 7469 6f6e m_max_connection │ │ │ -00068680: 7329 290a 0909 7b0a 0909 0964 6973 636f s))...{....disco │ │ │ -00068690: 6e6e 6563 745f 7065 6572 7328 6e75 6d5f nnect_peers(num_ │ │ │ -000686a0: 7065 6572 7328 2920 2d20 6d5f 6d61 785f peers() - m_max_ │ │ │ -000686b0: 636f 6e6e 6563 7469 6f6e 730a 0909 0909 connections..... │ │ │ -000686c0: 2c20 6572 726f 7273 3a3a 746f 6f5f 6d61 , errors::too_ma │ │ │ -000686d0: 6e79 5f63 6f6e 6e65 6374 696f 6e73 293b ny_connections); │ │ │ -000686e0: 0a09 097d 0a0a 0909 6966 2028 7374 6174 ...}....if (stat │ │ │ -000686f0: 655f 7570 6461 7465 290a 0909 0973 6574 e_update)....set │ │ │ -00068700: 5f6e 6565 645f 7361 7665 5f72 6573 756d _need_save_resum │ │ │ -00068710: 6528 746f 7272 656e 745f 6861 6e64 6c65 e(torrent_handle │ │ │ -00068720: 3a3a 6966 5f63 6f6e 6669 675f 6368 616e ::if_config_chan │ │ │ -00068730: 6765 6429 3b0a 097d 0a0a 0976 6f69 6420 ged);..}...void │ │ │ -00068740: 746f 7272 656e 743a 3a73 6574 5f75 706c torrent::set_upl │ │ │ -00068750: 6f61 645f 6c69 6d69 7428 696e 7420 636f oad_limit(int co │ │ │ -00068760: 6e73 7420 6c69 6d69 7429 0a09 7b0a 0909 nst limit)..{... │ │ │ -00068770: 7365 745f 6c69 6d69 745f 696d 706c 286c set_limit_impl(l │ │ │ -00068780: 696d 6974 2c20 7065 6572 5f63 6f6e 6e65 imit, peer_conne │ │ │ -00068790: 6374 696f 6e3a 3a75 706c 6f61 645f 6368 ction::upload_ch │ │ │ -000687a0: 616e 6e65 6c29 3b0a 2369 666e 6465 6620 annel);.#ifndef │ │ │ -000687b0: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -000687c0: 4c4f 4747 494e 470a 0909 6465 6275 675f LOGGING...debug_ │ │ │ -000687d0: 6c6f 6728 222a 2a2a 2073 6574 2d75 706c log("*** set-upl │ │ │ -000687e0: 6f61 642d 6c69 6d69 743a 2025 6422 2c20 oad-limit: %d", │ │ │ -000687f0: 6c69 6d69 7429 3b0a 2365 6e64 6966 0a09 limit);.#endif.. │ │ │ -00068800: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74 }...void torrent │ │ │ -00068810: 3a3a 7365 745f 646f 776e 6c6f 6164 5f6c ::set_download_l │ │ │ -00068820: 696d 6974 2869 6e74 2063 6f6e 7374 206c imit(int const l │ │ │ -00068830: 696d 6974 290a 097b 0a3c 2f70 7265 3e3c imit)..{.
    < │ │ │ -00068840: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00068870: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00068880: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ -000688b0: 6e74 2e63 7070 3a31 3135 3233 3c2f 613e nt.cpp:11523 │ │ │ -000688c0: 3c2f 7464 3e3c 7464 3e69 6e73 7465 6164 instead │ │ │ -000688d0: 206f 6620 7265 736f 7274 696e 6720 7468 of resorting th │ │ │ -000688e0: 6520 7768 6f6c 6520 6c69 7374 2c20 696e e whole list, in │ │ │ -000688f0: 7365 7274 2074 6865 2070 6565 7273 2064 sert the peers d │ │ │ -00068900: 6972 6563 746c 7920 696e 746f 2074 6865 irectly into the │ │ │ -00068910: 2072 6967 6874 2070 6c61 6365 3c2f 7464 right place

    instea │ │ │ -00068970: 6420 6f66 2072 6573 6f72 7469 6e67 2074 d of resorting t │ │ │ -00068980: 6865 2077 686f 6c65 206c 6973 742c 2069 he whole list, i │ │ │ -00068990: 6e73 6572 7420 7468 6520 7065 6572 730a nsert the peers. │ │ │ -000689a0: 6469 7265 6374 6c79 2069 6e74 6f20 7468 directly into th │ │ │ -000689b0: 6520 7269 6768 7420 706c 6163 653c 2f68 e right place

    ../src/tor │ │ │ -000689d0: 7265 6e74 2e63 7070 3a31 3135 3233 3c2f rent.cpp:11523
    ...
    │ │ │ -00068a20: 0973 7464 3a3a 7072 696e 7466 2822 7469  .std::printf("ti
    │ │ │ -00068a30: 6d65 6420 6f75 7420 5b61 7665 7261 6765  med out [average
    │ │ │ -00068a40: 2d70 6965 6365 2d74 696d 653a 2025 6420  -piece-time: %d 
    │ │ │ -00068a50: 6d73 205d 5c6e 220a 0909 0909 092c 206d  ms ]\n"......, m
    │ │ │ -00068a60: 5f61 7665 7261 6765 5f70 6965 6365 5f74  _average_piece_t
    │ │ │ -00068a70: 696d 6529 3b0a 2365 6e64 6966 0a09 0909  ime);.#endif....
    │ │ │ -00068a80: 7d0a 0a09 0909 2f2f 2070 6963 6b20 616c  }.....// pick al
    │ │ │ -00068a90: 6c20 626c 6f63 6b73 2066 6f72 2074 6869  l blocks for thi
    │ │ │ -00068aa0: 7320 7069 6563 652e 2074 6865 2070 6565  s piece. the pee
    │ │ │ -00068ab0: 7273 206c 6973 7420 6973 206b 6570 7420  rs list is kept 
    │ │ │ -00068ac0: 7570 2074 6f20 6461 7465 0a09 0909 2f2f  up to date....//
    │ │ │ -00068ad0: 2061 6e64 2073 6f72 7465 642e 2077 6865   and sorted. whe
    │ │ │ -00068ae0: 6e20 7765 2069 7373 7565 2061 2072 6571  n we issue a req
    │ │ │ -00068af0: 7565 7374 2074 6f20 6120 7065 6572 2c20  uest to a peer, 
    │ │ │ -00068b00: 6974 7320 646f 776e 6c6f 6164 2071 7565  its download que
    │ │ │ -00068b10: 7565 0a09 0909 2f2f 2074 696d 6520 7769  ue....// time wi
    │ │ │ -00068b20: 6c6c 2069 6e63 7265 6173 6520 616e 6420  ll increase and 
    │ │ │ -00068b30: 6974 206d 6179 206e 6565 6420 746f 2062  it may need to b
    │ │ │ -00068b40: 6520 6275 6d70 6564 2069 6e20 7468 6520  e bumped in the 
    │ │ │ -00068b50: 7065 6572 7320 6c69 7374 2c0a 0909 092f  peers list,..../
    │ │ │ -00068b60: 2f20 7369 6e63 6520 6974 2773 206f 7264  / since it's ord
    │ │ │ -00068b70: 6572 6564 2062 7920 646f 776e 6c6f 6164  ered by download
    │ │ │ -00068b80: 2071 7565 7565 2074 696d 650a 0909 0970   queue time....p
    │ │ │ -00068b90: 6963 6b5f 7469 6d65 5f63 7269 7469 6361  ick_time_critica
    │ │ │ -00068ba0: 6c5f 626c 6f63 6b28 7065 6572 732c 2069  l_block(peers, i
    │ │ │ -00068bb0: 676e 6f72 655f 7065 6572 730a 0909 0909  gnore_peers.....
    │ │ │ -00068bc0: 2c20 7065 6572 735f 7769 7468 5f72 6571  , peers_with_req
    │ │ │ -00068bd0: 7565 7374 730a 0909 0909 2c20 7069 2c20  uests....., pi, 
    │ │ │ -00068be0: 2661 6d70 3b69 2c20 6d5f 7069 636b 6572  &i, m_picker
    │ │ │ -00068bf0: 2e67 6574 2829 0a09 0909 092c 2062 6c6f  .get()....., blo
    │ │ │ -00068c00: 636b 735f 696e 5f70 6965 6365 2c20 7469  cks_in_piece, ti
    │ │ │ -00068c10: 6d65 645f 6f75 7429 3b0a 0a09 0909 2f2f  med_out);.....//
    │ │ │ -00068c20: 2070 7574 2062 6163 6b20 7468 6520 7065   put back the pe
    │ │ │ -00068c30: 6572 7320 7765 2069 676e 6f72 6564 2069  ers we ignored i
    │ │ │ -00068c40: 6e74 6f20 7468 6520 7065 6572 206c 6973  nto the peer lis
    │ │ │ -00068c50: 7420 666f 7220 7468 6520 6e65 7874 2070  t for the next p
    │ │ │ -00068c60: 6965 6365 0a09 0909 6966 2028 2169 676e  iece....if (!ign
    │ │ │ -00068c70: 6f72 655f 7065 6572 732e 656d 7074 7928  ore_peers.empty(
    │ │ │ -00068c80: 2929 0a09 0909 7b0a 0909 0909 7065 6572  ))....{.....peer
    │ │ │ -00068c90: 732e 696e 7365 7274 2870 6565 7273 2e62  s.insert(peers.b
    │ │ │ -00068ca0: 6567 696e 2829 2c20 6967 6e6f 7265 5f70  egin(), ignore_p
    │ │ │ -00068cb0: 6565 7273 2e62 6567 696e 2829 2c20 6967  eers.begin(), ig
    │ │ │ -00068cc0: 6e6f 7265 5f70 6565 7273 2e65 6e64 2829  nore_peers.end()
    │ │ │ -00068cd0: 293b 0a09 0909 0969 676e 6f72 655f 7065  );.....ignore_pe
    │ │ │ -00068ce0: 6572 732e 636c 6561 7228 293b 0a0a 3c64  ers.clear();......
    │ │ │ -00068d20: 7374 643a 3a73 6f72 7428 7065 6572 732e  std::sort(peers.
    │ │ │ -00068d30: 6265 6769 6e28 292c 2070 6565 7273 2e65  begin(), peers.e
    │ │ │ -00068d40: 6e64 2829 0a3c 2f64 6976 3e09 0909 0909  nd()......
    │ │ │ -00068d50: 2c20 5b5d 2028 7065 6572 5f63 6f6e 6e65  , [] (peer_conne
    │ │ │ -00068d60: 6374 696f 6e20 636f 6e73 742a 206c 6873  ction const* lhs
    │ │ │ -00068d70: 2c20 7065 6572 5f63 6f6e 6e65 6374 696f  , peer_connectio
    │ │ │ -00068d80: 6e20 636f 6e73 742a 2072 6873 290a 0909  n const* rhs)...
    │ │ │ -00068d90: 0909 097b 2072 6574 7572 6e20 6c68 732d  ...{ return lhs-
    │ │ │ -00068da0: 2667 743b 646f 776e 6c6f 6164 5f71 7565  >download_que
    │ │ │ -00068db0: 7565 5f74 696d 6528 3136 2a31 3032 3429  ue_time(16*1024)
    │ │ │ -00068dc0: 2026 6c74 3b20 7268 732d 2667 743b 646f   < rhs->do
    │ │ │ -00068dd0: 776e 6c6f 6164 5f71 7565 7565 5f74 696d  wnload_queue_tim
    │ │ │ -00068de0: 6528 3136 2a31 3032 3429 3b20 7d29 3b0a  e(16*1024); });.
    │ │ │ -00068df0: 0909 097d 0a0a 0909 092f 2f20 6966 2074  ...}.....// if t
    │ │ │ -00068e00: 6869 7320 7065 6572 2773 2064 6f77 6e6c  his peer's downl
    │ │ │ -00068e10: 6f61 6420 7469 6d65 2065 7863 6565 6473  oad time exceeds
    │ │ │ -00068e20: 2032 2073 6563 6f6e 6473 2c20 7765 2772   2 seconds, we'r
    │ │ │ -00068e30: 6520 646f 6e65 2e0a 0909 092f 2f20 5765  e done.....// We
    │ │ │ -00068e40: 2064 6f6e 2774 2077 616e 7420 746f 2062   don't want to b
    │ │ │ -00068e50: 7569 6c64 2075 6e72 6561 736f 6e61 626c  uild unreasonabl
    │ │ │ -00068e60: 7920 6c6f 6e67 2072 6571 7565 7374 2071  y long request q
    │ │ │ -00068e70: 7565 7565 730a 0909 0969 6620 2821 7065  ueues....if (!pe
    │ │ │ -00068e80: 6572 732e 656d 7074 7928 2920 2661 6d70  ers.empty() &
    │ │ │ -00068e90: 3b26 616d 703b 2070 6565 7273 5b30 5d2d  ;& peers[0]-
    │ │ │ -00068ea0: 2667 743b 646f 776e 6c6f 6164 5f71 7565  >download_que
    │ │ │ -00068eb0: 7565 5f74 696d 6528 2920 2667 743b 206d  ue_time() > m
    │ │ │ -00068ec0: 696c 6c69 7365 636f 6e64 7328 3230 3030  illiseconds(2000
    │ │ │ -00068ed0: 2929 0a09 0909 0962 7265 616b 3b0a 0909  )).....break;...
    │ │ │ -00068ee0: 7d0a 0a09 092f 2f20 636f 6d6d 6974 2061  }....// commit a
    │ │ │ -00068ef0: 6c6c 2074 6865 2074 696d 6520 6372 6974  ll the time crit
    │ │ │ -00068f00: 6963 616c 2072 6571 7565 7374 730a 0909  ical requests...
    │ │ │ -00068f10: 666f 7220 2861 7574 6f2a 2070 203a 2070  for (auto* p : p
    │ │ │ -00068f20: 6565 7273 5f77 6974 685f 7265 7175 6573  eers_with_reques
    │ │ │ -00068f30: 7473 290a 0909 7b0a 0909 0970 2d26 6774  ts)...{....p->
    │ │ │ -00068f40: 3b73 656e 645f 626c 6f63 6b5f 7265 7175  ;send_block_requ
    │ │ │ -00068f50: 6573 7473 2829 3b0a 0909 7d0a 097d 0a23  ests();...}..}.#
    │ │ │ -00068f60: 656e 6469 6620 2f2f 2054 4f52 5245 4e54  endif // TORRENT
    │ │ │ -00068f70: 5f44 4953 4142 4c45 5f53 5452 4541 4d49  _DISABLE_STREAMI
    │ │ │ -00068f80: 4e47 0a0a 0973 7464 3a3a 7365 7426 6c74  NG...std::set<
    │ │ │ -00068f90: 3b73 7464 3a3a 7374 7269 6e67 2667 743b  ;std::string>
    │ │ │ -00068fa0: 2074 6f72 7265 6e74 3a3a 7765 625f 7365   torrent::web_se
    │ │ │ -00068fb0: 6564 7328 2920 636f 6e73 740a 097b 0a09  eds() const..{..
    │ │ │ -00068fc0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -00068fd0: 6973 5f73 696e 676c 655f 7468 7265 6164  is_single_thread
    │ │ │ -00068fe0: 2829 293b 0a09 0973 7464 3a3a 7365 7426  ());...std::set&
    │ │ │ -00068ff0: 6c74 3b73 7464 3a3a 7374 7269 6e67 2667  lt;std::string&g
    │ │ │ -00069000: 743b 2072 6574 3b0a 0909 666f 7220 2861  t; ret;...for (a
    │ │ │ -00069010: 7574 6f20 636f 6e73 7426 616d 703b 2073  uto const& s
    │ │ │ -00069020: 203a 206d 5f77 6562 5f73 6565 6473 290a   : m_web_seeds).
    │ │ │ -00069030: 0909 7b0a 0909 0969 6620 2873 2e70 6565  ..{....if (s.pee
    │ │ │ -00069040: 725f 696e 666f 2e62 616e 6e65 6429 2063  r_info.banned) c
    │ │ │ -00069050: 6f6e 7469 6e75 653b 0a09 0909 6966 2028  ontinue;....if (
    │ │ │ -00069060: 732e 7265 6d6f 7665 6429 2063 6f6e 7469  s.removed) conti
    │ │ │ -00069070: 6e75 653b 0a09 0909 7265 742e 696e 7365  nue;....ret.inse
    │ │ │ -00069080: 7274 2873 2e75 726c 293b 0a09 097d 0a09  rt(s.url);...}..
    │ │ │ -00069090: 0972 6574 7572 6e20 7265 743b 0a09 7d0a  .return ret;..}.
    │ │ │ -000690a0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -000690b0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -000690e0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00069110: 632f 656e 756d 5f6e 6574 2e63 7070 3a32 c/enum_net.cpp:2 │ │ │ -00069120: 3436 3c2f 613e 3c2f 7464 3e3c 7464 3e69 46i │ │ │ -00069130: 6620 7765 2067 6574 2068 6572 652c 2074 f we get here, t │ │ │ -00069140: 6865 2063 616c 6c65 7220 7374 696c 6c20 he caller still │ │ │ -00069150: 6173 7375 6d65 7320 7468 6520 6572 726f assumes the erro │ │ │ -00069160: 7220 636f 6465 2069 7320 7265 706f 7274 r code is report │ │ │ -00069170: 6564 2076 6961 2065 7272 6e6f 3c2f 7464 ed via errno

    if we │ │ │ -000691d0: 6765 7420 6865 7265 2c20 7468 6520 6361 get here, the ca │ │ │ -000691e0: 6c6c 6572 2073 7469 6c6c 2061 7373 756d ller still assum │ │ │ -000691f0: 6573 2074 6865 2065 7272 6f72 2063 6f64 es the error cod │ │ │ -00069200: 650a 6973 2072 6570 6f72 7465 6420 7669 e.is reported vi │ │ │ -00069210: 6120 6572 726e 6f3c 2f68 323e 3c68 343e a errno

    │ │ │ -00069220: 2e2e 2f73 7263 2f65 6e75 6d5f 6e65 742e ../src/enum_net. │ │ │ -00069230: 6370 703a 3234 363c 2f68 343e 3c70 7265 cpp:246

    ..;..}.#en
    │ │ │ -00069280: 6469 660a 0a23 6966 2054 4f52 5245 4e54  dif..#if TORRENT
    │ │ │ -00069290: 5f55 5345 5f4e 4554 4c49 4e4b 0a0a 0969  _USE_NETLINK...i
    │ │ │ -000692a0: 6e74 2072 6561 645f 6e6c 5f73 6f63 6b28  nt read_nl_sock(
    │ │ │ -000692b0: 696e 7420 736f 636b 2c20 7374 643a 3a75  int sock, std::u
    │ │ │ -000692c0: 696e 7433 325f 7420 636f 6e73 7420 7365  int32_t const se
    │ │ │ -000692d0: 712c 2073 7464 3a3a 7569 6e74 3332 5f74  q, std::uint32_t
    │ │ │ -000692e0: 2063 6f6e 7374 2070 6964 0a09 092c 2073   const pid..., s
    │ │ │ -000692f0: 7464 3a3a 6675 6e63 7469 6f6e 266c 743b  td::function<
    │ │ │ -00069300: 766f 6964 286e 6c6d 7367 6864 7220 636f  void(nlmsghdr co
    │ │ │ -00069310: 6e73 742a 2926 6774 3b20 6f6e 5f6d 7367  nst*)> on_msg
    │ │ │ -00069320: 290a 097b 0a09 0973 7464 3a3a 6172 7261  )..{...std::arra
    │ │ │ -00069330: 7926 6c74 3b63 6861 722c 2034 3039 3626  y<char, 4096&
    │ │ │ -00069340: 6774 3b20 6275 663b 0a09 0966 6f72 2028  gt; buf;...for (
    │ │ │ -00069350: 3b3b 290a 0909 7b0a 0909 0969 6e74 2063  ;;)...{....int c
    │ │ │ -00069360: 6f6e 7374 2072 6561 645f 6c65 6e20 3d20  onst read_len = 
    │ │ │ -00069370: 696e 7428 7265 6376 2873 6f63 6b2c 2062  int(recv(sock, b
    │ │ │ -00069380: 7566 2e64 6174 6128 292c 2062 7566 2e73  uf.data(), buf.s
    │ │ │ -00069390: 697a 6528 292c 2030 2929 3b0a 0909 0969  ize(), 0));....i
    │ │ │ -000693a0: 6620 2872 6561 645f 6c65 6e20 266c 743b  f (read_len <
    │ │ │ -000693b0: 2030 2920 7265 7475 726e 202d 313b 0a0a   0) return -1;..
    │ │ │ -000693c0: 0909 0961 7574 6f20 636f 6e73 742a 206e  ...auto const* n
    │ │ │ -000693d0: 6c5f 6864 7220 3d20 7265 696e 7465 7270  l_hdr = reinterp
    │ │ │ -000693e0: 7265 745f 6361 7374 266c 743b 6e6c 6d73  ret_cast<nlms
    │ │ │ -000693f0: 6768 6472 2063 6f6e 7374 2a26 6774 3b28  ghdr const*>(
    │ │ │ -00069400: 6275 662e 6461 7461 2829 293b 0a09 0909  buf.data());....
    │ │ │ -00069410: 696e 7420 6c65 6e20 3d20 7265 6164 5f6c  int len = read_l
    │ │ │ -00069420: 656e 3b0a 0a09 0909 666f 7220 283b 206c  en;.....for (; l
    │ │ │ -00069430: 656e 2026 6774 3b20 3020 2661 6d70 3b26  en > 0 &&
    │ │ │ -00069440: 616d 703b 2061 7578 3a3a 6e6c 6d73 675f  amp; aux::nlmsg_
    │ │ │ -00069450: 6f6b 286e 6c5f 6864 722c 206c 656e 293b  ok(nl_hdr, len);
    │ │ │ -00069460: 206e 6c5f 6864 7220 3d20 6175 783a 3a6e   nl_hdr = aux::n
    │ │ │ -00069470: 6c6d 7367 5f6e 6578 7428 6e6c 5f68 6472  lmsg_next(nl_hdr
    │ │ │ -00069480: 2c20 6c65 6e29 290a 0909 097b 0a3c 6469  , len))....{.....i
    │ │ │ -000694c0: 6620 2828 6175 783a 3a6e 6c6d 7367 5f6f  f ((aux::nlmsg_o
    │ │ │ -000694d0: 6b28 6e6c 5f68 6472 2c20 7265 6164 5f6c  k(nl_hdr, read_l
    │ │ │ -000694e0: 656e 2920 3d3d 2030 2920 7c7c 2028 6e6c  en) == 0) || (nl
    │ │ │ -000694f0: 5f68 6472 2d26 6774 3b6e 6c6d 7367 5f74  _hdr->nlmsg_t
    │ │ │ -00069500: 7970 6520 3d3d 204e 4c4d 5347 5f45 5252  ype == NLMSG_ERR
    │ │ │ -00069510: 4f52 2929 0a3c 2f64 6976 3e09 0909 0909  OR))......
    │ │ │ -00069520: 7265 7475 726e 202d 313b 0a09 0909 092f  return -1;...../
    │ │ │ -00069530: 2f20 7468 6973 2066 756e 6374 696f 6e20  / this function 
    │ │ │ -00069540: 646f 6573 6e27 7420 6861 6e64 6c65 206d  doesn't handle m
    │ │ │ -00069550: 756c 7469 706c 6520 7265 7175 6573 7473  ultiple requests
    │ │ │ -00069560: 2061 7420 7468 6520 7361 6d65 2074 696d   at the same tim
    │ │ │ -00069570: 650a 0909 0909 2f2f 2073 6f20 7265 706f  e.....// so repo
    │ │ │ -00069580: 7274 2061 6e20 6572 726f 7220 6966 2074  rt an error if t
    │ │ │ -00069590: 6865 206d 6573 7361 6765 2064 6f65 7320  he message does 
    │ │ │ -000695a0: 6e6f 7420 6861 7665 2074 6865 2065 7870  not have the exp
    │ │ │ -000695b0: 6563 7465 6420 7365 7120 616e 6420 7069  ected seq and pi
    │ │ │ -000695c0: 640a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  d.
    < │ │ │ -000695f0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00069600: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00069630: 7372 632f 656e 756d 5f6e 6574 2e63 7070 src/enum_net.cpp │ │ │ -00069640: 3a32 3532 3c2f 613e 3c2f 7464 3e3c 7464 :252if we get here, │ │ │ -00069660: 2074 6865 2063 616c 6c65 7220 7374 696c the caller stil │ │ │ -00069670: 6c20 6173 7375 6d65 7320 7468 6520 6572 l assumes the er │ │ │ -00069680: 726f 7220 636f 6465 2069 7320 7265 706f ror code is repo │ │ │ -00069690: 7274 6564 2076 6961 2065 7272 6e6f 3c2f rted via errno

    if w │ │ │ -000696f0: 6520 6765 7420 6865 7265 2c20 7468 6520 e get here, the │ │ │ -00069700: 6361 6c6c 6572 2073 7469 6c6c 2061 7373 caller still ass │ │ │ -00069710: 756d 6573 2074 6865 2065 7272 6f72 2063 umes the error c │ │ │ -00069720: 6f64 650a 6973 2072 6570 6f72 7465 6420 ode.is reported │ │ │ -00069730: 7669 6120 6572 726e 6f3c 2f68 323e 3c68 via errno

    ../src/enum_ne │ │ │ -00069750: 742e 6370 703a 3235 323c 2f68 343e 3c70 t.cpp:252

    #if TORR │ │ │ -000697a0: 454e 545f 5553 455f 4e45 544c 494e 4b0a ENT_USE_NETLINK. │ │ │ -000697b0: 0a09 696e 7420 7265 6164 5f6e 6c5f 736f ..int read_nl_so │ │ │ -000697c0: 636b 2869 6e74 2073 6f63 6b2c 2073 7464 ck(int sock, std │ │ │ -000697d0: 3a3a 7569 6e74 3332 5f74 2063 6f6e 7374 ::uint32_t const │ │ │ -000697e0: 2073 6571 2c20 7374 643a 3a75 696e 7433 seq, std::uint3 │ │ │ -000697f0: 325f 7420 636f 6e73 7420 7069 640a 0909 2_t const pid... │ │ │ -00069800: 2c20 7374 643a 3a66 756e 6374 696f 6e26 , std::function& │ │ │ -00069810: 6c74 3b76 6f69 6428 6e6c 6d73 6768 6472 lt;void(nlmsghdr │ │ │ -00069820: 2063 6f6e 7374 2a29 2667 743b 206f 6e5f const*)> on_ │ │ │ -00069830: 6d73 6729 0a09 7b0a 0909 7374 643a 3a61 msg)..{...std::a │ │ │ -00069840: 7272 6179 266c 743b 6368 6172 2c20 3430 rray<char, 40 │ │ │ -00069850: 3936 2667 743b 2062 7566 3b0a 0909 666f 96> buf;...fo │ │ │ -00069860: 7220 283b 3b29 0a09 097b 0a09 0909 696e r (;;)...{....in │ │ │ -00069870: 7420 636f 6e73 7420 7265 6164 5f6c 656e t const read_len │ │ │ -00069880: 203d 2069 6e74 2872 6563 7628 736f 636b = int(recv(sock │ │ │ -00069890: 2c20 6275 662e 6461 7461 2829 2c20 6275 , buf.data(), bu │ │ │ -000698a0: 662e 7369 7a65 2829 2c20 3029 293b 0a09 f.size(), 0));.. │ │ │ -000698b0: 0909 6966 2028 7265 6164 5f6c 656e 2026 ..if (read_len & │ │ │ -000698c0: 6c74 3b20 3029 2072 6574 7572 6e20 2d31 lt; 0) return -1 │ │ │ -000698d0: 3b0a 0a09 0909 6175 746f 2063 6f6e 7374 ;.....auto const │ │ │ -000698e0: 2a20 6e6c 5f68 6472 203d 2072 6569 6e74 * nl_hdr = reint │ │ │ -000698f0: 6572 7072 6574 5f63 6173 7426 6c74 3b6e erpret_cast<n │ │ │ -00069900: 6c6d 7367 6864 7220 636f 6e73 742a 2667 lmsghdr const*&g │ │ │ -00069910: 743b 2862 7566 2e64 6174 6128 2929 3b0a t;(buf.data());. │ │ │ -00069920: 0909 0969 6e74 206c 656e 203d 2072 6561 ...int len = rea │ │ │ -00069930: 645f 6c65 6e3b 0a0a 0909 0966 6f72 2028 d_len;.....for ( │ │ │ -00069940: 3b20 6c65 6e20 2667 743b 2030 2026 616d ; len > 0 &am │ │ │ -00069950: 703b 2661 6d70 3b20 6175 783a 3a6e 6c6d p;& aux::nlm │ │ │ -00069960: 7367 5f6f 6b28 6e6c 5f68 6472 2c20 6c65 sg_ok(nl_hdr, le │ │ │ -00069970: 6e29 3b20 6e6c 5f68 6472 203d 2061 7578 n); nl_hdr = aux │ │ │ -00069980: 3a3a 6e6c 6d73 675f 6e65 7874 286e 6c5f ::nlmsg_next(nl_ │ │ │ -00069990: 6864 722c 206c 656e 2929 0a09 0909 7b0a hdr, len))....{. │ │ │ -000699a0: 0909 0909 6966 2028 2861 7578 3a3a 6e6c ....if ((aux::nl │ │ │ -000699b0: 6d73 675f 6f6b 286e 6c5f 6864 722c 2072 msg_ok(nl_hdr, r │ │ │ -000699c0: 6561 645f 6c65 6e29 203d 3d20 3029 207c ead_len) == 0) | │ │ │ -000699d0: 7c20 286e 6c5f 6864 722d 2667 743b 6e6c | (nl_hdr->nl │ │ │ -000699e0: 6d73 675f 7479 7065 203d 3d20 4e4c 4d53 msg_type == NLMS │ │ │ -000699f0: 475f 4552 524f 5229 290a 0909 0909 0972 G_ERROR))......r │ │ │ -00069a00: 6574 7572 6e20 2d31 3b0a 0909 0909 2f2f eturn -1;.....// │ │ │ -00069a10: 2074 6869 7320 6675 6e63 7469 6f6e 2064 this function d │ │ │ -00069a20: 6f65 736e 2774 2068 616e 646c 6520 6d75 oesn't handle mu │ │ │ -00069a30: 6c74 6970 6c65 2072 6571 7565 7374 7320 ltiple requests │ │ │ -00069a40: 6174 2074 6865 2073 616d 6520 7469 6d65 at the same time │ │ │ -00069a50: 0a09 0909 092f 2f20 736f 2072 6570 6f72 .....// so repor │ │ │ -00069a60: 7420 616e 2065 7272 6f72 2069 6620 7468 t an error if th │ │ │ -00069a70: 6520 6d65 7373 6167 6520 646f 6573 206e e message does n │ │ │ -00069a80: 6f74 2068 6176 6520 7468 6520 6578 7065 ot have the expe │ │ │ -00069a90: 6374 6564 2073 6571 2061 6e64 2070 6964 cted seq and pid │ │ │ -00069aa0: 0a3c 6469 7620 7374 796c 653d 2262 6163 .

    . │ │ │ -00069ad0: 0909 0969 6620 286e 6c5f 6864 722d 2667 ...if (nl_hdr-&g │ │ │ -00069ae0: 743b 6e6c 6d73 675f 7365 7120 213d 2073 t;nlmsg_seq != s │ │ │ -00069af0: 6571 207c 7c20 6e6c 5f68 6472 2d26 6774 eq || nl_hdr-> │ │ │ -00069b00: 3b6e 6c6d 7367 5f70 6964 2021 3d20 7069 ;nlmsg_pid != pi │ │ │ -00069b10: 6429 0a3c 2f64 6976 3e09 0909 0909 7265 d).
    .....re │ │ │ -00069b20: 7475 726e 202d 313b 0a0a 0909 0909 6966 turn -1;......if │ │ │ -00069b30: 2028 6e6c 5f68 6472 2d26 6774 3b6e 6c6d (nl_hdr->nlm │ │ │ -00069b40: 7367 5f74 7970 6520 3d3d 204e 4c4d 5347 sg_type == NLMSG │ │ │ -00069b50: 5f44 4f4e 4529 2072 6574 7572 6e20 303b _DONE) return 0; │ │ │ -00069b60: 0a0a 0909 0909 6f6e 5f6d 7367 286e 6c5f ......on_msg(nl_ │ │ │ -00069b70: 6864 7229 3b0a 0a09 0909 0969 6620 2828 hdr);......if (( │ │ │ -00069b80: 6e6c 5f68 6472 2d26 6774 3b6e 6c6d 7367 nl_hdr->nlmsg │ │ │ -00069b90: 5f66 6c61 6773 2026 616d 703b 204e 4c4d _flags & NLM │ │ │ -00069ba0: 5f46 5f4d 554c 5449 2920 3d3d 2030 2920 _F_MULTI) == 0) │ │ │ -00069bb0: 7265 7475 726e 2030 3b0a 0909 097d 0a09 return 0;....}.. │ │ │ -00069bc0: 097d 0a2f 2f09 0972 6574 7572 6e20 303b .}.//..return 0; │ │ │ -00069bd0: 0a09 7d0a 0a09 696e 7420 6e6c 5f64 756d ..}...int nl_dum │ │ │ -00069be0: 705f 7265 7175 6573 7428 696e 7420 636f p_request(int co │ │ │ -00069bf0: 6e73 7420 736f 636b 2c20 7374 643a 3a75 nst sock, std::u │ │ │ -00069c00: 696e 7433 325f 7420 636f 6e73 7420 7365 int32_t const se │ │ │ -00069c10: 710a 0909 2c20 6e6c 6d73 6768 6472 2a20 q..., nlmsghdr* │ │ │ -00069c20: 636f 6e73 7420 7265 7175 6573 745f 6d73 const request_ms │ │ │ -00069c30: 672c 2073 7464 3a3a 6675 6e63 7469 6f6e g, std::function │ │ │ -00069c40: 266c 743b 766f 6964 286e 6c6d 7367 6864 <void(nlmsghd │ │ │ -00069c50: 7220 636f 6e73 742a 2926 6774 3b20 6f6e r const*)> on │ │ │ -00069c60: 5f6d 7367 290a 097b 0a09 0972 6571 7565 _msg)..{...reque │ │ │ -00069c70: 7374 5f6d 7367 2d26 6774 3b6e 6c6d 7367 st_msg->nlmsg │ │ │ -00069c80: 5f66 6c61 6773 203d 204e 4c4d 5f46 5f44 _flags = NLM_F_D │ │ │ -00069c90: 554d 5020 7c20 4e4c 4d5f 465f 5245 5155 UMP | NLM_F_REQU │ │ │ -00069ca0: 4553 543b 0a09 0972 6571 7565 7374 5f6d EST;...request_m │ │ │ -00069cb0: 7367 2d26 6774 3b6e 6c6d 7367 5f73 6571 sg->nlmsg_seq │ │ │ -00069cc0: 203d 2073 6571 3b0a 0909 2f2f 2069 6e20 = seq;...// in │ │ │ -00069cd0: 7468 656f 7279 206e 6c6d 7367 5f70 6964 theory nlmsg_pid │ │ │ -00069ce0: 2073 686f 756c 6420 6265 2073 6574 2074 should be set t │ │ │ -00069cf0: 6f20 7468 6520 6e65 746c 696e 6b20 706f o the netlink po │ │ │ -00069d00: 7274 2049 4420 284e 4f54 2074 6865 2070 rt ID (NOT the p │ │ │ -00069d10: 726f 6365 7373 2049 4429 0a09 092f 2f20 rocess ID)...// │ │ │ -00069d20: 6f66 2074 6865 2073 656e 6465 722c 2062 of the sender, b │ │ │ -00069d30: 7574 2074 6865 206b 6572 6e65 6c20 6967 ut the kernel ig │ │ │ -00069d40: 6e6f 7265 7320 7468 6973 2066 6965 6c64 nores this field │ │ │ -00069d50: 2073 6f20 6974 2069 7320 7479 7069 6361 so it is typica │ │ │ -00069d60: 6c6c 7920 7365 7420 746f 0a09 092f 2f20 lly set to...// │ │ │ -00069d70: 7a65 726f 0a09 0972 6571 7565 7374 5f6d zero...request_m │ │ │ -00069d80: 7367 2d26 6774 3b6e 6c6d 7367 5f70 6964 sg->nlmsg_pid │ │ │ -00069d90: 203d 2030 3b0a 0a09 0969 6620 283a 3a73 = 0;....if (::s │ │ │ -00069da0: 656e 6428 736f 636b 2c20 7265 7175 6573 end(sock, reques │ │ │ -00069db0: 745f 6d73 672c 2072 6571 7565 7374 5f6d t_msg, request_m │ │ │ -00069dc0: 7367 2d26 6774 3b6e 6c6d 7367 5f6c 656e sg->nlmsg_len │ │ │ -00069dd0: 2c20 3029 2026 6c74 3b20 3029 0a09 0909 , 0) < 0).... │ │ │ -00069de0: 7265 7475 726e 202d 313b 0a0a 0909 2f2f return -1;....// │ │ │ -00069df0: 2067 6574 2074 6865 2073 6f63 6b65 7427 get the socket' │ │ │ -00069e00: 7320 706f 7274 2049 4420 736f 2074 6861 s port ID so tha │ │ │ -00069e10: 7420 7765 2063 616e 2076 6572 6966 7920 t we can verify │ │ │ -00069e20: 6974 2069 6e20 7468 6520 7265 7370 6f6e it in the respon │ │ │ -00069e30: 7365 0a09 0973 6f63 6b61 6464 725f 6e6c se...sockaddr_nl │ │ │ -00069e40: 2073 6f63 6b5f 6164 6472 3b0a 0909 736f sock_addr;...so │ │ │ -00069e50: 636b 6c65 6e5f 7420 736f 636b 5f61 6464 cklen_t sock_add │ │ │ -00069e60: 725f 6c65 6e20 3d20 7369 7a65 6f66 2873 r_len = sizeof(s │ │ │ -00069e70: 6f63 6b5f 6164 6472 293b 0a09 0969 6620 ock_addr);...if │ │ │ -00069e80: 283a 3a67 6574 736f 636b 6e61 6d65 2873 (::getsockname(s │ │ │ -00069e90: 6f63 6b2c 2072 6569 6e74 6572 7072 6574 ock, reinterpret │ │ │ -00069ea0: 5f63 6173 7426 6c74 3b73 6f63 6b61 6464 _cast<sockadd │ │ │ -00069eb0: 722a 2667 743b 2826 616d 703b 736f 636b r*>(&sock │ │ │ -00069ec0: 5f61 6464 7229 2c20 2661 6d70 3b73 6f63 _addr), &soc │ │ │ -00069ed0: 6b5f 6164 6472 5f6c 656e 2920 266c 743b k_addr_len) < │ │ │ -00069ee0: 2030 290a 0909 0972 6574 7572 6e20 2d31 0)....return -1 │ │ │ -00069ef0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.< │ │ │ -00069f20: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00069f30: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00069f60: 7372 632f 6669 6e67 6572 7072 696e 742e src/fingerprint. │ │ │ -00069f70: 6370 703a 3535 3c2f 613e 3c2f 7464 3e3c cpp:55< │ │ │ -00069f80: 7464 3e74 6865 2066 696e 6765 7270 7269 td>the fingerpri │ │ │ -00069f90: 6e74 2063 6f6e 7374 7275 6374 6f72 2073 nt constructor s │ │ │ -00069fa0: 686f 756c 6420 7461 6b65 2061 2073 7472 hould take a str │ │ │ -00069fb0: 696e 675f 7669 6577 3c2f 7464 3e3c 2f74 ing_view

    the finger │ │ │ -0006a010: 7072 696e 7420 636f 6e73 7472 7563 746f print constructo │ │ │ -0006a020: 7220 7368 6f75 6c64 2074 616b 6520 6120 r should take a │ │ │ -0006a030: 7374 7269 6e67 5f76 6965 773c 2f68 323e string_view

    │ │ │ -0006a040: 3c68 343e 2e2e 2f73 7263 2f66 696e 6765

    ../src/finge │ │ │ -0006a050: 7270 7269 6e74 2e63 7070 3a35 353c 2f68 rprint.cpp:55
    ..TO
    │ │ │ -0006a0a0: 5252 454e 545f 4153 5345 5254 5f50 5245  RRENT_ASSERT_PRE
    │ │ │ -0006a0b0: 434f 4e44 286d 696e 6f72 2026 6774 3b3d  COND(minor >=
    │ │ │ -0006a0c0: 2030 293b 0a09 0954 4f52 5245 4e54 5f41   0);...TORRENT_A
    │ │ │ -0006a0d0: 5353 4552 545f 5052 4543 4f4e 4428 7265  SSERT_PRECOND(re
    │ │ │ -0006a0e0: 7669 7369 6f6e 2026 6774 3b3d 2030 293b  vision >= 0);
    │ │ │ -0006a0f0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -0006a100: 545f 5052 4543 4f4e 4428 7461 6720 2667  T_PRECOND(tag &g
    │ │ │ -0006a110: 743b 3d20 3029 3b0a 0909 544f 5252 454e  t;= 0);...TORREN
    │ │ │ -0006a120: 545f 4153 5345 5254 5f50 5245 434f 4e44  T_ASSERT_PRECOND
    │ │ │ -0006a130: 286e 616d 652e 7369 7a65 2829 203d 3d20  (name.size() == 
    │ │ │ -0006a140: 3229 3b0a 0909 6966 2028 6e61 6d65 2e73  2);...if (name.s
    │ │ │ -0006a150: 697a 6528 2920 266c 743b 2032 2920 6e61  ize() < 2) na
    │ │ │ -0006a160: 6d65 203d 2022 2d2d 223b 0a0a 0909 7374  me = "--";....st
    │ │ │ -0006a170: 643a 3a73 7472 696e 6720 7265 743b 0a09  d::string ret;..
    │ │ │ -0006a180: 0972 6574 2e72 6573 697a 6528 3829 3b0a  .ret.resize(8);.
    │ │ │ -0006a190: 0909 7265 745b 305d 203d 2027 2d27 3b0a  ..ret[0] = '-';.
    │ │ │ -0006a1a0: 0909 7265 745b 315d 203d 206e 616d 655b  ..ret[1] = name[
    │ │ │ -0006a1b0: 305d 3b0a 0909 7265 745b 325d 203d 206e  0];...ret[2] = n
    │ │ │ -0006a1c0: 616d 655b 315d 3b0a 0909 7265 745b 335d  ame[1];...ret[3]
    │ │ │ -0006a1d0: 203d 2076 6572 7369 6f6e 5f74 6f5f 6368   = version_to_ch
    │ │ │ -0006a1e0: 6172 286d 616a 6f72 293b 0a09 0972 6574  ar(major);...ret
    │ │ │ -0006a1f0: 5b34 5d20 3d20 7665 7273 696f 6e5f 746f  [4] = version_to
    │ │ │ -0006a200: 5f63 6861 7228 6d69 6e6f 7229 3b0a 0909  _char(minor);...
    │ │ │ -0006a210: 7265 745b 355d 203d 2076 6572 7369 6f6e  ret[5] = version
    │ │ │ -0006a220: 5f74 6f5f 6368 6172 2872 6576 6973 696f  _to_char(revisio
    │ │ │ -0006a230: 6e29 3b0a 0909 7265 745b 365d 203d 2076  n);...ret[6] = v
    │ │ │ -0006a240: 6572 7369 6f6e 5f74 6f5f 6368 6172 2874  ersion_to_char(t
    │ │ │ -0006a250: 6167 293b 0a09 0972 6574 5b37 5d20 3d20  ag);...ret[7] = 
    │ │ │ -0006a260: 272d 273b 0a09 0972 6574 7572 6e20 7265  '-';...return re
    │ │ │ -0006a270: 743b 0a09 7d0a 0a23 6966 6465 6620 5f5f  t;..}..#ifdef __
    │ │ │ -0006a280: 636c 616e 675f 5f0a 3c64 6976 2073 7479  clang__.
    #pragma cl │ │ │ -0006a2c0: 616e 6720 6469 6167 6e6f 7374 6963 2070 ang diagnostic p │ │ │ -0006a2d0: 7573 680a 3c2f 6469 763e 2370 7261 676d ush.
    #pragm │ │ │ -0006a2e0: 6120 636c 616e 6720 6469 6167 6e6f 7374 a clang diagnost │ │ │ -0006a2f0: 6963 2069 676e 6f72 6564 2022 2d57 756e ic ignored "-Wun │ │ │ -0006a300: 6b6e 6f77 6e2d 7761 726e 696e 672d 6f70 known-warning-op │ │ │ -0006a310: 7469 6f6e 220a 2370 7261 676d 6120 636c tion".#pragma cl │ │ │ -0006a320: 616e 6720 6469 6167 6e6f 7374 6963 2069 ang diagnostic i │ │ │ -0006a330: 676e 6f72 6564 2022 2d57 756e 7361 6665 gnored "-Wunsafe │ │ │ -0006a340: 2d62 7566 6665 722d 7573 6167 6522 0a23 -buffer-usage".# │ │ │ -0006a350: 656e 6469 660a 0a09 6669 6e67 6572 7072 endif...fingerpr │ │ │ -0006a360: 696e 743a 3a66 696e 6765 7270 7269 6e74 int::fingerprint │ │ │ -0006a370: 2863 6f6e 7374 2063 6861 722a 2069 645f (const char* id_ │ │ │ -0006a380: 7374 7269 6e67 2c20 696e 7420 6d61 6a6f string, int majo │ │ │ -0006a390: 722c 2069 6e74 206d 696e 6f72 0a09 092c r, int minor..., │ │ │ -0006a3a0: 2069 6e74 2072 6576 6973 696f 6e2c 2069 int revision, i │ │ │ -0006a3b0: 6e74 2074 6167 290a 0909 3a20 6d61 6a6f nt tag)...: majo │ │ │ -0006a3c0: 725f 7665 7273 696f 6e28 6d61 6a6f 7229 r_version(major) │ │ │ -0006a3d0: 0a09 092c 206d 696e 6f72 5f76 6572 7369 ..., minor_versi │ │ │ -0006a3e0: 6f6e 286d 696e 6f72 290a 0909 2c20 7265 on(minor)..., re │ │ │ -0006a3f0: 7669 7369 6f6e 5f76 6572 7369 6f6e 2872 vision_version(r │ │ │ -0006a400: 6576 6973 696f 6e29 0a09 092c 2074 6167 evision)..., tag │ │ │ -0006a410: 5f76 6572 7369 6f6e 2874 6167 290a 097b _version(tag)..{ │ │ │ -0006a420: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0006a430: 5428 6964 5f73 7472 696e 6729 3b0a 0909 T(id_string);... │ │ │ -0006a440: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ -0006a450: 616a 6f72 2026 6774 3b3d 2030 293b 0a09 ajor >= 0);.. │ │ │ -0006a460: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0006a470: 6d69 6e6f 7220 2667 743b 3d20 3029 3b0a minor >= 0);. │ │ │ -0006a480: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0006a490: 2872 6576 6973 696f 6e20 2667 743b 3d20 (revision >= │ │ │ -0006a4a0: 3029 3b0a 0909 544f 5252 454e 545f 4153 0);...TORRENT_AS │ │ │ -0006a4b0: 5345 5254 2874 6167 2026 6774 3b3d 2030 SERT(tag >= 0 │ │ │ -0006a4c0: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ -0006a4d0: 4552 5428 7374 643a 3a73 7472 6c65 6e28 ERT(std::strlen( │ │ │ -0006a4e0: 6964 5f73 7472 696e 6729 203d 3d20 3229 id_string) == 2) │ │ │ -0006a4f0: 3b0a 0909 6e61 6d65 5b30 5d20 3d20 6964 ;...name[0] = id │ │ │ -0006a500: 5f73 7472 696e 675b 305d 3b0a 0909 6e61 _string[0];...na │ │ │ -0006a510: 6d65 5b31 5d20 3d20 6964 5f73 7472 696e me[1] = id_strin │ │ │ -0006a520: 675b 315d 3b0a 097d 0a0a 2369 6664 6566 g[1];..}..#ifdef │ │ │ -0006a530: 205f 5f63 6c61 6e67 5f5f 0a23 7072 6167 __clang__.#prag │ │ │ -0006a540: 6d61 2063 6c61 6e67 2064 6961 676e 6f73 ma clang diagnos │ │ │ -0006a550: 7469 6320 706f 700a 2365 6e64 6966 0a0a tic pop.#endif.. │ │ │ -0006a560: 2369 6620 544f 5252 454e 545f 4142 495f #if TORRENT_ABI_ │ │ │ -0006a570: 5645 5253 494f 4e20 3d3d 2031 0a09 7374 VERSION == 1..st │ │ │ -0006a580: 643a 3a73 7472 696e 6720 6669 6e67 6572 d::string finger │ │ │ -0006a590: 7072 696e 743a 3a74 6f5f 7374 7269 6e67 print::to_string │ │ │ -0006a5a0: 2829 2063 6f6e 7374 0a09 7b0a 0909 7265 () const..{...re │ │ │ -0006a5b0: 7475 726e 2067 656e 6572 6174 655f 6669 turn generate_fi │ │ │ -0006a5c0: 6e67 6572 7072 696e 7428 7374 643a 3a73 ngerprint(std::s │ │ │ -0006a5d0: 7472 696e 6728 6e61 6d65 2c20 3229 2c20 tring(name, 2), │ │ │ -0006a5e0: 6d61 6a6f 725f 7665 7273 696f 6e2c 206d major_version, m │ │ │ -0006a5f0: 696e 6f72 5f76 6572 7369 6f6e 0a09 0909 inor_version.... │ │ │ -0006a600: 2c20 7265 7669 7369 6f6e 5f76 6572 7369 , revision_versi │ │ │ -0006a610: 6f6e 2c20 7461 675f 7665 7273 696f 6e29 on, tag_version) │ │ │ -0006a620: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ -0006a650: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0006a660: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0006a690: 7372 632f 7065 7266 6f72 6d61 6e63 655f src/performance_ │ │ │ -0006a6a0: 636f 756e 7465 7273 2e63 7070 3a31 373c counters.cpp:17< │ │ │ -0006a6b0: 2f61 3e3c 2f74 643e 3c74 643e 6d6f 7665 /a>move │ │ │ -0006a6c0: 2073 7461 7473 5f63 6f75 6e74 6572 5f74 stats_counter_t │ │ │ -0006a6d0: 206f 7574 206f 6620 636f 756e 7465 7273 out of counters │ │ │ -0006a6e0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    mo │ │ │ -0006a730: 7665 2073 7461 7473 5f63 6f75 6e74 6572 ve stats_counter │ │ │ -0006a740: 5f74 206f 7574 206f 6620 636f 756e 7465 _t out of counte │ │ │ -0006a750: 7273 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 rs

    ../sr │ │ │ -0006a760: 632f 7065 7266 6f72 6d61 6e63 655f 636f c/performance_co │ │ │ -0006a770: 756e 7465 7273 2e63 7070 3a31 373c 2f68 unters.cpp:17
    rel
    │ │ │ -0006a7f0: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../src/pe
    │ │ │ -0006a830: 7266 6f72 6d61 6e63 655f 636f 756e 7465  rformance_counte
    │ │ │ -0006a840: 7273 2e63 7070 3a31 383c 2f61 3e3c 2f74  rs.cpp:18should bit
    │ │ │ -0006a860: 746f 7272 656e 7420 6b65 6570 2d61 6c69  torrent keep-ali
    │ │ │ -0006a870: 7665 206d 6573 7361 6765 7320 6861 7665  ve messages have
    │ │ │ -0006a880: 2061 2063 6f75 6e74 6572 2074 6f6f 3f3c   a counter too?<
    │ │ │ -0006a890: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d  /td>

    sho │ │ │ -0006a8e0: 756c 6420 6269 7474 6f72 7265 6e74 206b uld bittorrent k │ │ │ -0006a8f0: 6565 702d 616c 6976 6520 6d65 7373 6167 eep-alive messag │ │ │ -0006a900: 6573 2068 6176 6520 6120 636f 756e 7465 es have a counte │ │ │ -0006a910: 7220 746f 6f3f 3c2f 6832 3e3c 6834 3e2e r too?

    . │ │ │ -0006a920: 2e2f 7372 632f 7065 7266 6f72 6d61 6e63 ./src/performanc │ │ │ -0006a930: 655f 636f 756e 7465 7273 2e63 7070 3a31 e_counters.cpp:1 │ │ │ -0006a940: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ -0006a980: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -0006a990: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0006a9c0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0006a9f0: 632f 7065 7266 6f72 6d61 6e63 655f 636f c/performance_co │ │ │ -0006aa00: 756e 7465 7273 2e63 7070 3a31 393c 2f61 unters.cpp:19It wou │ │ │ -0006aa20: 6c64 2062 6520 6e69 6365 2069 6620 7468 ld be nice if th │ │ │ -0006aa30: 6973 2063 6f75 6c64 2062 6520 616e 2069 is could be an i │ │ │ -0006aa40: 6e74 6572 6e61 6c20 7479 7065 2e20 6465 nternal type. de │ │ │ -0006aa50: 6661 756c 745f 6469 736b 5f63 6f6e 7374 fault_disk_const │ │ │ -0006aa60: 7275 6374 6f72 2064 6570 656e 6473 206f ructor depends o │ │ │ -0006aa70: 6e20 6974 206e 6f77 3c2f 7464 3e3c 2f74 n it now

    It would b │ │ │ -0006aad0: 6520 6e69 6365 2069 6620 7468 6973 2063 e nice if this c │ │ │ -0006aae0: 6f75 6c64 2062 6520 616e 2069 6e74 6572 ould be an inter │ │ │ -0006aaf0: 6e61 6c20 7479 7065 2e20 6465 6661 756c nal type. defaul │ │ │ -0006ab00: 745f 6469 736b 5f63 6f6e 7374 7275 6374 t_disk_construct │ │ │ -0006ab10: 6f72 2064 6570 656e 6473 206f 6e20 6974 or depends on it │ │ │ -0006ab20: 206e 6f77 3c2f 6832 3e3c 6834 3e2e 2e2f now

    ../ │ │ │ -0006ab30: 7372 632f 7065 7266 6f72 6d61 6e63 655f src/performance_ │ │ │ -0006ab40: 636f 756e 7465 7273 2e63 7070 3a31 393c counters.cpp:19< │ │ │ -0006ab50: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    #e
    │ │ │ -0006ab90: 6e64 6966 202f 2f20 544f 5252 454e 545f  ndif // TORRENT_
    │ │ │ -0006aba0: 4142 495f 5645 5253 494f 4e0a 0a7d 0a0a  ABI_VERSION..}..
    │ │ │ -0006abb0: 2f2a 0a0a 436f 7079 7269 6768 7420 2863  /*..Copyright (c
    │ │ │ -0006abc0: 2920 3230 3130 2c20 3230 3133 2d32 3032  ) 2010, 2013-202
    │ │ │ -0006abd0: 302c 2041 7276 6964 204e 6f72 6265 7267  0, Arvid Norberg
    │ │ │ -0006abe0: 0a43 6f70 7972 6967 6874 2028 6329 2032  .Copyright (c) 2
    │ │ │ -0006abf0: 3031 362d 3230 3137 2c20 416c 6465 6e20  016-2017, Alden 
    │ │ │ -0006ac00: 546f 7272 6573 0a41 6c6c 2072 6967 6874  Torres.All right
    │ │ │ -0006ac10: 7320 7265 7365 7276 6564 2e0a 0a59 6f75  s reserved...You
    │ │ │ -0006ac20: 206d 6179 2075 7365 2c20 6469 7374 7269   may use, distri
    │ │ │ -0006ac30: 6275 7465 2061 6e64 206d 6f64 6966 7920  bute and modify 
    │ │ │ -0006ac40: 7468 6973 2063 6f64 6520 756e 6465 7220  this code under 
    │ │ │ -0006ac50: 7468 6520 7465 726d 7320 6f66 2074 6865  the terms of the
    │ │ │ -0006ac60: 2042 5344 206c 6963 656e 7365 2c0a 7365   BSD license,.se
    │ │ │ -0006ac70: 6520 4c49 4345 4e53 4520 6669 6c65 2e0a  e LICENSE file..
    │ │ │ -0006ac80: 2a2f 0a0a 2369 6e63 6c75 6465 2022 6c69  */..#include "li
    │ │ │ -0006ac90: 6274 6f72 7265 6e74 2f70 6572 666f 726d  btorrent/perform
    │ │ │ -0006aca0: 616e 6365 5f63 6f75 6e74 6572 732e 6870  ance_counters.hp
    │ │ │ -0006acb0: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ -0006acc0: 746f 7272 656e 742f 6173 7365 7274 2e68  torrent/assert.h
    │ │ │ -0006acd0: 7070 220a 2369 6e63 6c75 6465 2026 6c74  pp".#include <
    │ │ │ -0006ace0: 3b63 7374 7269 6e67 2667 743b 202f 2f20  ;cstring> // 
    │ │ │ -0006acf0: 666f 7220 6d65 6d73 6574 0a0a 6e61 6d65  for memset..name
    │ │ │ -0006ad00: 7370 6163 6520 6c69 6274 6f72 7265 6e74  space libtorrent
    │ │ │ -0006ad10: 207b 0a0a 3c64 6976 2073 7479 6c65 3d22   {..
    .counters::cou │ │ │ -0006ad50: 6e74 6572 7328 2920 544f 5252 454e 545f nters() TORRENT_ │ │ │ -0006ad60: 434f 554e 5445 525f 4e4f 4558 4345 5054 COUNTER_NOEXCEPT │ │ │ -0006ad70: 0a3c 2f64 6976 3e09 7b0a 2369 6664 6566 .
    .{.#ifdef │ │ │ -0006ad80: 2041 544f 4d49 435f 4c4c 4f4e 475f 4c4f ATOMIC_LLONG_LO │ │ │ -0006ad90: 434b 5f46 5245 450a 0909 666f 7220 2861 CK_FREE...for (a │ │ │ -0006ada0: 7574 6f26 616d 703b 2063 6f75 6e74 6572 uto& counter │ │ │ -0006adb0: 203a 206d 5f73 7461 7473 5f63 6f75 6e74 : m_stats_count │ │ │ -0006adc0: 6572 290a 0909 0963 6f75 6e74 6572 2e73 er)....counter.s │ │ │ -0006add0: 746f 7265 2830 2c20 7374 643a 3a6d 656d tore(0, std::mem │ │ │ -0006ade0: 6f72 795f 6f72 6465 725f 7265 6c61 7865 ory_order_relaxe │ │ │ -0006adf0: 6429 3b0a 2365 6c73 650a 0909 6d5f 7374 d);.#else...m_st │ │ │ -0006ae00: 6174 735f 636f 756e 7465 722e 6669 6c6c ats_counter.fill │ │ │ -0006ae10: 2830 293b 0a23 656e 6469 660a 097d 0a0a (0);.#endif..}.. │ │ │ -0006ae20: 0963 6f75 6e74 6572 733a 3a63 6f75 6e74 .counters::count │ │ │ -0006ae30: 6572 7328 636f 756e 7465 7273 2063 6f6e ers(counters con │ │ │ -0006ae40: 7374 2661 6d70 3b20 6329 2054 4f52 5245 st& c) TORRE │ │ │ -0006ae50: 4e54 5f43 4f55 4e54 4552 5f4e 4f45 5843 NT_COUNTER_NOEXC │ │ │ -0006ae60: 4550 540a 097b 0a23 6966 6465 6620 4154 EPT..{.#ifdef AT │ │ │ -0006ae70: 4f4d 4943 5f4c 4c4f 4e47 5f4c 4f43 4b5f OMIC_LLONG_LOCK_ │ │ │ -0006ae80: 4652 4545 0a09 0966 6f72 2028 696e 7420 FREE...for (int │ │ │ -0006ae90: 6920 3d20 303b 2069 2026 6c74 3b20 6d5f i = 0; i < m_ │ │ │ -0006aea0: 7374 6174 735f 636f 756e 7465 722e 656e stats_counter.en │ │ │ -0006aeb0: 645f 696e 6465 7828 293b 202b 2b69 290a d_index(); ++i). │ │ │ -0006aec0: 0909 096d 5f73 7461 7473 5f63 6f75 6e74 ...m_stats_count │ │ │ -0006aed0: 6572 5b69 5d2e 7374 6f72 6528 0a09 0909 er[i].store(.... │ │ │ -0006aee0: 0963 2e6d 5f73 7461 7473 5f63 6f75 6e74 .c.m_stats_count │ │ │ -0006aef0: 6572 5b69 5d2e 6c6f 6164 2873 7464 3a3a er[i].load(std:: │ │ │ -0006af00: 6d65 6d6f 7279 5f6f 7264 6572 5f72 656c memory_order_rel │ │ │ -0006af10: 6178 6564 290a 0909 0909 092c 2073 7464 axed)......, std │ │ │ -0006af20: 3a3a 6d65 6d6f 7279 5f6f 7264 6572 5f72 ::memory_order_r │ │ │ -0006af30: 656c 6178 6564 293b 0a23 656c 7365 0a09 elaxed);.#else.. │ │ │ -0006af40: 0973 7464 3a3a 6c6f 636b 5f67 7561 7264 .std::lock_guard │ │ │ -0006af50: 266c 743b 7374 643a 3a6d 7574 6578 2667 <std::mutex&g │ │ │ -0006af60: 743b 206c 2863 2e6d 5f6d 7574 6578 293b t; l(c.m_mutex); │ │ │ -0006af70: 0a09 096d 5f73 7461 7473 5f63 6f75 6e74 ...m_stats_count │ │ │ -0006af80: 6572 203d 2063 2e6d 5f73 7461 7473 5f63 er = c.m_stats_c │ │ │ -0006af90: 6f75 6e74 6572 3b0a 2365 6e64 6966 0a09 ounter;.#endif.. │ │ │ -0006afa0: 7d0a 0a09 636f 756e 7465 7273 2661 6d70 }...counters& │ │ │ -0006afb0: 3b20 636f 756e 7465 7273 3a3a 6f70 6572 ; counters::oper │ │ │ -0006afc0: 6174 6f72 3d28 636f 756e 7465 7273 2063 ator=(counters c │ │ │ -0006afd0: 6f6e 7374 2661 6d70 3b20 6329 2026 616d onst& c) &am │ │ │ -0006afe0: 703b 2054 4f52 5245 4e54 5f43 4f55 4e54 p; TORRENT_COUNT │ │ │ -0006aff0: 4552 5f4e 4f45 5843 4550 540a 097b 0a09 ER_NOEXCEPT..{.. │ │ │ -0006b000: 0969 6620 2826 616d 703b 6320 3d3d 2074 .if (&c == t │ │ │ -0006b010: 6869 7329 2072 6574 7572 6e20 2a74 6869 his) return *thi │ │ │ -0006b020: 733b 0a23 6966 6465 6620 4154 4f4d 4943 s;.#ifdef ATOMIC │ │ │ -0006b030: 5f4c 4c4f 4e47 5f4c 4f43 4b5f 4652 4545 _LLONG_LOCK_FREE │ │ │ -0006b040: 0a09 0966 6f72 2028 696e 7420 6920 3d20 ...for (int i = │ │ │ -0006b050: 303b 2069 2026 6c74 3b20 6d5f 7374 6174 0; i < m_stat │ │ │ -0006b060: 735f 636f 756e 7465 722e 656e 645f 696e s_counter.end_in │ │ │ -0006b070: 6465 7828 293b 202b 2b69 290a 0909 096d dex(); ++i)....m │ │ │ -0006b080: 5f73 7461 7473 5f63 6f75 6e74 6572 5b69 _stats_counter[i │ │ │ -0006b090: 5d2e 7374 6f72 6528 0a09 0909 0963 2e6d ].store(.....c.m │ │ │ -0006b0a0: 5f73 7461 7473 5f63 6f75 6e74 6572 5b69 _stats_counter[i │ │ │ -0006b0b0: 5d2e 6c6f 6164 2873 7464 3a3a 6d65 6d6f ].load(std::memo │ │ │ -0006b0c0: 7279 5f6f 7264 6572 5f72 656c 6178 6564 ry_order_relaxed │ │ │ -0006b0d0: 290a 0909 0909 092c 2073 7464 3a3a 6d65 )......, std::me │ │ │ -0006b0e0: 6d6f 7279 5f6f 7264 6572 5f72 656c 6178 mory_order_relax │ │ │ -0006b0f0: 6564 293b 0a3c 2f70 7265 3e3c 2f74 643e ed);.
    │ │ │ -0006b100: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0006b130: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0006b140: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0006b150: 7074 3a65 7870 616e 6428 3234 3729 223e pt:expand(247)"> │ │ │ -0006b160: 2e2e 2f73 7263 2f6b 6164 656d 6c69 612f ../src/kademlia/ │ │ │ -0006b170: 6974 656d 2e63 7070 3a31 3230 3c2f 613e item.cpp:120 │ │ │ -0006b180: 3c2f 7464 3e3c 7464 3e69 6d70 6c65 6d65 impleme │ │ │ -0006b190: 6e74 2063 746f 7220 666f 7220 656e 7472 nt ctor for entr │ │ │ -0006b1a0: 7920 6672 6f6d 2062 6465 636f 6465 5f6e y from bdecode_n │ │ │ -0006b1b0: 6f64 653f 3c2f 7464 3e3c 2f74 723e 3c74 ode?implement ctor │ │ │ -0006b210: 2066 6f72 2065 6e74 7279 2066 726f 6d20 for entry from │ │ │ -0006b220: 6264 6563 6f64 655f 6e6f 6465 3f3c 2f68 bdecode_node?

    ../src/kad │ │ │ -0006b240: 656d 6c69 612f 6974 656d 2e63 7070 3a31 emlia/item.cpp:1 │ │ │ -0006b250: 3230 3c2f 6834 3e3c 7072 6520 7374 796c 20

    ., secret_key c
    │ │ │ -0006b2a0: 6f6e 7374 2661 6d70 3b20 736b 290a 7b0a  onst& sk).{.
    │ │ │ -0006b2b0: 0963 6861 7220 7374 725b 3132 3030 5d3b  .char str[1200];
    │ │ │ -0006b2c0: 0a09 696e 7420 636f 6e73 7420 6c65 6e20  ..int const len 
    │ │ │ -0006b2d0: 3d20 6361 6e6f 6e69 6361 6c5f 7374 7269  = canonical_stri
    │ │ │ -0006b2e0: 6e67 2876 2c20 7365 712c 2073 616c 742c  ng(v, seq, salt,
    │ │ │ -0006b2f0: 2073 7472 293b 0a0a 0972 6574 7572 6e20   str);...return 
    │ │ │ -0006b300: 6564 3235 3531 395f 7369 676e 287b 7374  ed25519_sign({st
    │ │ │ -0006b310: 722c 206c 656e 7d2c 2070 6b2c 2073 6b29  r, len}, pk, sk)
    │ │ │ -0006b320: 3b0a 7d0a 0a69 7465 6d3a 3a69 7465 6d28  ;.}..item::item(
    │ │ │ -0006b330: 7075 626c 6963 5f6b 6579 2063 6f6e 7374  public_key const
    │ │ │ -0006b340: 2661 6d70 3b20 706b 2c20 7370 616e 266c  & pk, span&l
    │ │ │ -0006b350: 743b 6368 6172 2063 6f6e 7374 2667 743b  t;char const>
    │ │ │ -0006b360: 2073 616c 7429 0a09 3a20 6d5f 7361 6c74   salt)..: m_salt
    │ │ │ -0006b370: 2873 616c 742e 6461 7461 2829 2c20 7374  (salt.data(), st
    │ │ │ -0006b380: 6174 6963 5f63 6173 7426 6c74 3b73 7464  atic_cast<std
    │ │ │ -0006b390: 3a3a 7369 7a65 5f74 2667 743b 2873 616c  ::size_t>(sal
    │ │ │ -0006b3a0: 742e 7369 7a65 2829 2929 0a09 2c20 6d5f  t.size())).., m_
    │ │ │ -0006b3b0: 706b 2870 6b29 0a09 2c20 6d5f 6d75 7461  pk(pk).., m_muta
    │ │ │ -0006b3c0: 626c 6528 7472 7565 290a 7b7d 0a0a 6974  ble(true).{}..it
    │ │ │ -0006b3d0: 656d 3a3a 6974 656d 2865 6e74 7279 2076  em::item(entry v
    │ │ │ -0006b3e0: 290a 093a 206d 5f76 616c 7565 2873 7464  )..: m_value(std
    │ │ │ -0006b3f0: 3a3a 6d6f 7665 2876 2929 0a7b 7d0a 0a69  ::move(v)).{}..i
    │ │ │ -0006b400: 7465 6d3a 3a69 7465 6d28 6264 6563 6f64  tem::item(bdecod
    │ │ │ -0006b410: 655f 6e6f 6465 2063 6f6e 7374 2661 6d70  e_node const&
    │ │ │ -0006b420: 3b20 7629 0a7b 0a3c 6469 7620 7374 796c  ; v).{.
    .m_value = │ │ │ -0006b460: 763b 0a3c 2f64 6976 3e7d 0a0a 6974 656d v;.
    }..item │ │ │ -0006b470: 3a3a 6974 656d 2865 6e74 7279 2076 2c20 ::item(entry v, │ │ │ -0006b480: 7370 616e 266c 743b 6368 6172 2063 6f6e span<char con │ │ │ -0006b490: 7374 2667 743b 2073 616c 740a 092c 2073 st> salt.., s │ │ │ -0006b4a0: 6571 7565 6e63 655f 6e75 6d62 6572 2063 equence_number c │ │ │ -0006b4b0: 6f6e 7374 2073 6571 2c20 7075 626c 6963 onst seq, public │ │ │ -0006b4c0: 5f6b 6579 2063 6f6e 7374 2661 6d70 3b20 _key const& │ │ │ -0006b4d0: 706b 2c20 7365 6372 6574 5f6b 6579 2063 pk, secret_key c │ │ │ -0006b4e0: 6f6e 7374 2661 6d70 3b20 736b 290a 7b0a onst& sk).{. │ │ │ -0006b4f0: 0961 7373 6967 6e28 7374 643a 3a6d 6f76 .assign(std::mov │ │ │ -0006b500: 6528 7629 2c20 7361 6c74 2c20 7365 712c e(v), salt, seq, │ │ │ -0006b510: 2070 6b2c 2073 6b29 3b0a 7d0a 0a76 6f69 pk, sk);.}..voi │ │ │ -0006b520: 6420 6974 656d 3a3a 6173 7369 676e 2865 d item::assign(e │ │ │ -0006b530: 6e74 7279 2076 290a 7b0a 096d 5f6d 7574 ntry v).{..m_mut │ │ │ -0006b540: 6162 6c65 203d 2066 616c 7365 3b0a 096d able = false;..m │ │ │ -0006b550: 5f76 616c 7565 203d 2073 7464 3a3a 6d6f _value = std::mo │ │ │ -0006b560: 7665 2876 293b 0a7d 0a0a 766f 6964 2069 ve(v);.}..void i │ │ │ -0006b570: 7465 6d3a 3a61 7373 6967 6e28 656e 7472 tem::assign(entr │ │ │ -0006b580: 7920 762c 2073 7061 6e26 6c74 3b63 6861 y v, span<cha │ │ │ -0006b590: 7220 636f 6e73 7426 6774 3b20 7361 6c74 r const> salt │ │ │ -0006b5a0: 0a09 2c20 7365 7175 656e 6365 5f6e 756d .., sequence_num │ │ │ -0006b5b0: 6265 7220 636f 6e73 7420 7365 712c 2070 ber const seq, p │ │ │ -0006b5c0: 7562 6c69 635f 6b65 7920 636f 6e73 7426 ublic_key const& │ │ │ -0006b5d0: 616d 703b 2070 6b2c 2073 6563 7265 745f amp; pk, secret_ │ │ │ -0006b5e0: 6b65 7920 636f 6e73 7426 616d 703b 2073 key const& s │ │ │ -0006b5f0: 6b29 0a7b 0a09 7374 643a 3a61 7272 6179 k).{..std::array │ │ │ -0006b600: 266c 743b 6368 6172 2c20 3130 3030 2667 <char, 1000&g │ │ │ -0006b610: 743b 2062 7566 6665 723b 0a09 696e 7420 t; buffer;..int │ │ │ -0006b620: 636f 6e73 7420 6273 697a 6520 3d20 6265 const bsize = be │ │ │ -0006b630: 6e63 6f64 6528 6275 6666 6572 2e62 6567 ncode(buffer.beg │ │ │ -0006b640: 696e 2829 2c20 7629 3b0a 0954 4f52 5245 in(), v);..TORRE │ │ │ -0006b650: 4e54 5f41 5353 4552 5428 6273 697a 6520 NT_ASSERT(bsize │ │ │ -0006b660: 266c 743b 3d20 3130 3030 293b 0a09 6d5f <= 1000);..m_ │ │ │ -0006b670: 7369 6720 3d20 7369 676e 5f6d 7574 6162 sig = sign_mutab │ │ │ -0006b680: 6c65 5f69 7465 6d28 7370 616e 266c 743b le_item(span< │ │ │ -0006b690: 6368 6172 2063 6f6e 7374 2667 743b 2862 char const>(b │ │ │ -0006b6a0: 7566 6665 7229 2e66 6972 7374 2862 7369 uffer).first(bsi │ │ │ -0006b6b0: 7a65 290a 0909 2c20 7361 6c74 2c20 7365 ze)..., salt, se │ │ │ -0006b6c0: 712c 2070 6b2c 2073 6b29 3b0a 096d 5f73 q, pk, sk);..m_s │ │ │ -0006b6d0: 616c 742e 6173 7369 676e 2873 616c 742e alt.assign(salt. │ │ │ -0006b6e0: 6461 7461 2829 2c20 7374 6174 6963 5f63 data(), static_c │ │ │ -0006b6f0: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ -0006b700: 5f74 2667 743b 2873 616c 742e 7369 7a65 _t>(salt.size │ │ │ -0006b710: 2829 2929 3b0a 096d 5f70 6b20 3d20 706b ()));..m_pk = pk │ │ │ -0006b720: 3b0a 096d 5f73 6571 203d 2073 6571 3b0a ;..m_seq = seq;. │ │ │ -0006b730: 096d 5f6d 7574 6162 6c65 203d 2074 7275 .m_mutable = tru │ │ │ -0006b740: 653b 0a09 6d5f 7661 6c75 6520 3d20 7374 e;..m_value = st │ │ │ -0006b750: 643a 3a6d 6f76 6528 7629 3b0a 7d0a 0a76 d::move(v);.}..v │ │ │ -0006b760: 6f69 6420 6974 656d 3a3a 6173 7369 676e oid item::assign │ │ │ -0006b770: 2862 6465 636f 6465 5f6e 6f64 6520 636f (bdecode_node co │ │ │ -0006b780: 6e73 7426 616d 703b 2076 290a 3c2f 7072 nst& v).rel │ │ │ -0006b7c0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/ka │ │ │ -0006b800: 6465 6d6c 6961 2f6e 6f64 655f 6964 2e63 demlia/node_id.c │ │ │ -0006b810: 7070 3a34 333c 2f61 3e3c 2f74 643e 3c74 pp:43it's a little │ │ │ -0006b830: 6269 7420 7765 6972 6420 746f 2072 6574 bit weird to ret │ │ │ -0006b840: 7572 6e20 3135 3920 2d20 6c65 6164 696e urn 159 - leadin │ │ │ -0006b850: 6720 7a65 726f 6573 2e20 4974 2073 686f g zeroes. It sho │ │ │ -0006b860: 756c 6420 7072 6f62 6162 6c79 2062 6520 uld probably be │ │ │ -0006b870: 3136 3020 2d20 6c65 6164 696e 6720 7a65 160 - leading ze │ │ │ -0006b880: 726f 6573 2c20 6275 7420 616c 6c20 6f74 roes, but all ot │ │ │ -0006b890: 6865 7220 636f 6465 2069 6e20 6865 7265 her code in here │ │ │ -0006b8a0: 2069 7320 7475 6e65 6420 746f 2074 6869 is tuned to thi │ │ │ -0006b8b0: 7320 6578 7065 6374 6174 696f 6e20 6e6f s expectation no │ │ │ -0006b8c0: 772c 2061 6e64 2069 7420 646f 6573 6e27 w, and it doesn' │ │ │ -0006b8d0: 7420 7265 616c 6c79 206d 6174 7465 7220 t really matter │ │ │ -0006b8e0: 286f 7468 6572 2074 6861 6e20 636f 6d70 (other than comp │ │ │ -0006b8f0: 6c65 7869 7479 293c 2f74 643e 3c2f 7472 lexity)

    it's a litt │ │ │ -0006b950: 6c65 2062 6974 2077 6569 7264 2074 6f20 le bit weird to │ │ │ -0006b960: 7265 7475 726e 2031 3539 202d 206c 6561 return 159 - lea │ │ │ -0006b970: 6469 6e67 207a 6572 6f65 732e 2049 7420 ding zeroes. It │ │ │ -0006b980: 7368 6f75 6c64 0a70 726f 6261 626c 7920 should.probably │ │ │ -0006b990: 6265 2031 3630 202d 206c 6561 6469 6e67 be 160 - leading │ │ │ -0006b9a0: 207a 6572 6f65 732c 2062 7574 2061 6c6c zeroes, but all │ │ │ -0006b9b0: 206f 7468 6572 2063 6f64 6520 696e 2068 other code in h │ │ │ -0006b9c0: 6572 6520 6973 2074 756e 6564 2074 6f0a ere is tuned to. │ │ │ -0006b9d0: 7468 6973 2065 7870 6563 7461 7469 6f6e this expectation │ │ │ -0006b9e0: 206e 6f77 2c20 616e 6420 6974 2064 6f65 now, and it doe │ │ │ -0006b9f0: 736e 2774 2072 6561 6c6c 7920 6d61 7474 sn't really matt │ │ │ -0006ba00: 6572 2028 6f74 6865 7220 7468 616e 2063 er (other than c │ │ │ -0006ba10: 6f6d 706c 6578 6974 7929 3c2f 6832 3e3c omplexity)

    < │ │ │ -0006ba20: 6834 3e2e 2e2f 7372 632f 6b61 6465 6d6c h4>../src/kademl │ │ │ -0006ba30: 6961 2f6e 6f64 655f 6964 2e63 7070 3a34 ia/node_id.cpp:4 │ │ │ -0006ba40: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -0006ba80: 0a2f 2f20 7265 7475 726e 7320 7468 6520  .// returns the 
    │ │ │ -0006ba90: 6469 7374 616e 6365 2062 6574 7765 656e  distance between
    │ │ │ -0006baa0: 2074 6865 2074 776f 206e 6f64 6573 0a2f   the two nodes./
    │ │ │ -0006bab0: 2f20 7573 696e 6720 7468 6520 6b61 6465  / using the kade
    │ │ │ -0006bac0: 6d6c 6961 2058 4f52 2d6d 6574 7269 630a  mlia XOR-metric.
    │ │ │ -0006bad0: 6e6f 6465 5f69 6420 6469 7374 616e 6365  node_id distance
    │ │ │ -0006bae0: 286e 6f64 655f 6964 2063 6f6e 7374 2661  (node_id const&a
    │ │ │ -0006baf0: 6d70 3b20 6e31 2c20 6e6f 6465 5f69 6420  mp; n1, node_id 
    │ │ │ -0006bb00: 636f 6e73 7426 616d 703b 206e 3229 0a7b  const& n2).{
    │ │ │ -0006bb10: 0a09 7265 7475 726e 206e 3120 5e20 6e32  ..return n1 ^ n2
    │ │ │ -0006bb20: 3b0a 7d0a 0a2f 2f20 7265 7475 726e 7320  ;.}..// returns 
    │ │ │ -0006bb30: 7472 7565 2069 663a 2064 6973 7461 6e63  true if: distanc
    │ │ │ -0006bb40: 6528 6e31 2c20 7265 6629 2026 6c74 3b20  e(n1, ref) < 
    │ │ │ -0006bb50: 6469 7374 616e 6365 286e 322c 2072 6566  distance(n2, ref
    │ │ │ -0006bb60: 290a 626f 6f6c 2063 6f6d 7061 7265 5f72  ).bool compare_r
    │ │ │ -0006bb70: 6566 286e 6f64 655f 6964 2063 6f6e 7374  ef(node_id const
    │ │ │ -0006bb80: 2661 6d70 3b20 6e31 2c20 6e6f 6465 5f69  & n1, node_i
    │ │ │ -0006bb90: 6420 636f 6e73 7426 616d 703b 206e 322c  d const& n2,
    │ │ │ -0006bba0: 206e 6f64 655f 6964 2063 6f6e 7374 2661   node_id const&a
    │ │ │ -0006bbb0: 6d70 3b20 7265 6629 0a7b 0a09 6e6f 6465  mp; ref).{..node
    │ │ │ -0006bbc0: 5f69 6420 636f 6e73 7420 6c68 7320 3d20  _id const lhs = 
    │ │ │ -0006bbd0: 6e31 205e 2072 6566 3b0a 096e 6f64 655f  n1 ^ ref;..node_
    │ │ │ -0006bbe0: 6964 2063 6f6e 7374 2072 6873 203d 206e  id const rhs = n
    │ │ │ -0006bbf0: 3220 5e20 7265 663b 0a09 7265 7475 726e  2 ^ ref;..return
    │ │ │ -0006bc00: 206c 6873 2026 6c74 3b20 7268 733b 0a7d   lhs < rhs;.}
    │ │ │ -0006bc10: 0a0a 2f2f 2072 6574 7572 6e73 206e 2069  ..// returns n i
    │ │ │ -0006bc20: 6e3a 2032 5e6e 2026 6c74 3b3d 2064 6973  n: 2^n <= dis
    │ │ │ -0006bc30: 7461 6e63 6528 6e31 2c20 6e32 2920 266c  tance(n1, n2) &l
    │ │ │ -0006bc40: 743b 2032 5e28 6e2b 3129 0a2f 2f20 7573  t; 2^(n+1).// us
    │ │ │ -0006bc50: 6566 756c 2066 6f72 2066 696e 6469 6e67  eful for finding
    │ │ │ -0006bc60: 206f 7574 2077 6869 6368 2062 7563 6b65   out which bucke
    │ │ │ -0006bc70: 7420 6120 6e6f 6465 2062 656c 6f6e 6773  t a node belongs
    │ │ │ -0006bc80: 2074 6f0a 696e 7420 6469 7374 616e 6365   to.int distance
    │ │ │ -0006bc90: 5f65 7870 286e 6f64 655f 6964 2063 6f6e  _exp(node_id con
    │ │ │ -0006bca0: 7374 2661 6d70 3b20 6e31 2c20 6e6f 6465  st& n1, node
    │ │ │ -0006bcb0: 5f69 6420 636f 6e73 7426 616d 703b 206e  _id const& n
    │ │ │ -0006bcc0: 3229 0a7b 0a3c 6469 7620 7374 796c 653d  2).{.
    .return std:: │ │ │ -0006bd00: 6d61 7828 3135 3920 2d20 6469 7374 616e max(159 - distan │ │ │ -0006bd10: 6365 286e 312c 206e 3229 2e63 6f75 6e74 ce(n1, n2).count │ │ │ -0006bd20: 5f6c 6561 6469 6e67 5f7a 6572 6f65 7328 _leading_zeroes( │ │ │ -0006bd30: 292c 2030 293b 0a3c 2f64 6976 3e7d 0a0a ), 0);.
    }.. │ │ │ -0006bd40: 696e 7420 6d69 6e5f 6469 7374 616e 6365 int min_distance │ │ │ -0006bd50: 5f65 7870 286e 6f64 655f 6964 2063 6f6e _exp(node_id con │ │ │ -0006bd60: 7374 2661 6d70 3b20 6e31 2c20 7374 643a st& n1, std: │ │ │ -0006bd70: 3a76 6563 746f 7226 6c74 3b6e 6f64 655f :vector<node_ │ │ │ -0006bd80: 6964 2667 743b 2063 6f6e 7374 2661 6d70 id> const& │ │ │ -0006bd90: 3b20 6964 7329 0a7b 0a09 544f 5252 454e ; ids).{..TORREN │ │ │ -0006bda0: 545f 4153 5345 5254 2869 6473 2e73 697a T_ASSERT(ids.siz │ │ │ -0006bdb0: 6528 2920 2667 743b 2030 293b 0a0a 0969 e() > 0);...i │ │ │ -0006bdc0: 6e74 206d 696e 203d 2031 3630 3b20 2f2f nt min = 160; // │ │ │ -0006bdd0: 2073 6565 2064 6973 7461 6e63 655f 6578 see distance_ex │ │ │ -0006bde0: 7020 666f 7220 7468 6520 7768 7920 6f66 p for the why of │ │ │ -0006bdf0: 2074 6869 7320 636f 6e73 7461 6e74 0a09 this constant.. │ │ │ -0006be00: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ -0006be10: 616d 703b 206e 6f64 655f 6964 203a 2069 amp; node_id : i │ │ │ -0006be20: 6473 290a 097b 0a09 096d 696e 203d 2073 ds)..{...min = s │ │ │ -0006be30: 7464 3a3a 6d69 6e28 6d69 6e2c 2064 6973 td::min(min, dis │ │ │ -0006be40: 7461 6e63 655f 6578 7028 6e31 2c20 6e6f tance_exp(n1, no │ │ │ -0006be50: 6465 5f69 6429 293b 0a09 7d0a 0a09 7265 de_id));..}...re │ │ │ -0006be60: 7475 726e 206d 696e 3b0a 7d0a 0a6e 6f64 turn min;.}..nod │ │ │ -0006be70: 655f 6964 2067 656e 6572 6174 655f 6964 e_id generate_id │ │ │ -0006be80: 5f69 6d70 6c28 6164 6472 6573 7320 636f _impl(address co │ │ │ -0006be90: 6e73 7426 616d 703b 2069 705f 2c20 7374 nst& ip_, st │ │ │ -0006bea0: 643a 3a75 696e 7433 325f 7420 7229 0a7b d::uint32_t r).{ │ │ │ -0006beb0: 0a09 7374 643a 3a75 696e 7438 5f74 2a20 ..std::uint8_t* │ │ │ -0006bec0: 6970 203d 206e 756c 6c70 7472 3b0a 0a09 ip = nullptr;... │ │ │ -0006bed0: 7374 6174 6963 2073 7464 3a3a 7569 6e74 static std::uint │ │ │ -0006bee0: 385f 7420 636f 6e73 7420 7634 6d61 736b 8_t const v4mask │ │ │ -0006bef0: 5b5d 203d 207b 2030 7830 332c 2030 7830 [] = { 0x03, 0x0 │ │ │ -0006bf00: 662c 2030 7833 662c 2030 7866 6620 7d3b f, 0x3f, 0xff }; │ │ │ -0006bf10: 0a09 7374 6174 6963 2073 7464 3a3a 7569 ..static std::ui │ │ │ -0006bf20: 6e74 385f 7420 636f 6e73 7420 7636 6d61 nt8_t const v6ma │ │ │ -0006bf30: 736b 5b5d 203d 207b 2030 7830 312c 2030 sk[] = { 0x01, 0 │ │ │ -0006bf40: 7830 332c 2030 7830 372c 2030 7830 662c x03, 0x07, 0x0f, │ │ │ -0006bf50: 2030 7831 662c 2030 7833 662c 2030 7837 0x1f, 0x3f, 0x7 │ │ │ -0006bf60: 662c 2030 7866 6620 7d3b 0a09 7374 643a f, 0xff };..std: │ │ │ -0006bf70: 3a75 696e 7438 5f74 2063 6f6e 7374 2a20 :uint8_t const* │ │ │ -0006bf80: 6d61 736b 203d 206e 756c 6c70 7472 3b0a mask = nullptr;. │ │ │ -0006bf90: 0969 6e74 206e 756d 5f6f 6374 6574 7320 .int num_octets │ │ │ -0006bfa0: 3d20 303b 0a0a 0961 6464 7265 7373 5f76 = 0;...address_v │ │ │ -0006bfb0: 343a 3a62 7974 6573 5f74 7970 6520 6234 4::bytes_type b4 │ │ │ -0006bfc0: 7b7d 3b0a 0961 6464 7265 7373 5f76 363a {};..address_v6: │ │ │ -0006bfd0: 3a62 7974 6573 5f74 7970 6520 6236 7b7d :bytes_type b6{} │ │ │ -0006bfe0: 3b0a 0969 6620 2869 705f 2e69 735f 7636 ;..if (ip_.is_v6 │ │ │ -0006bff0: 2829 290a 097b 0a09 0962 3620 3d20 6970 ())..{...b6 = ip │ │ │ -0006c000: 5f2e 746f 5f76 3628 292e 746f 5f62 7974 _.to_v6().to_byt │ │ │ -0006c010: 6573 2829 3b0a 0909 6970 203d 2062 362e es();...ip = b6. │ │ │ -0006c020: 6461 7461 2829 3b0a 3c2f 7072 653e 3c2f data();.
    relevan │ │ │ -0006c060: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/kademl │ │ │ -0006c0a0: 6961 2f70 7574 5f64 6174 612e 6370 703a ia/put_data.cpp: │ │ │ -0006c0b0: 3639 3c2f 613e 3c2f 7464 3e3c 7464 3e77 69w │ │ │ -0006c0c0: 6861 7420 6966 206f 2069 7320 6e6f 7420 hat if o is not │ │ │ -0006c0d0: 616e 2069 6e73 7461 6e63 6520 6f66 2070 an instance of p │ │ │ -0006c0e0: 7574 5f64 6174 615f 6f62 7365 7276 6572 ut_data_observer │ │ │ -0006c0f0: 3f20 5468 6973 206e 6565 6420 746f 2062 ? This need to b │ │ │ -0006c100: 6520 7265 6465 7369 676e 6564 2066 6f72 e redesigned for │ │ │ -0006c110: 2062 6574 7465 7220 7479 7065 2073 6166 better type saf │ │ │ -0006c120: 6574 792e 3c2f 7464 3e3c 2f74 723e 3c74 ety.what if o is n │ │ │ -0006c180: 6f74 2061 6e20 696e 7374 616e 6365 206f ot an instance o │ │ │ -0006c190: 6620 7075 745f 6461 7461 5f6f 6273 6572 f put_data_obser │ │ │ -0006c1a0: 7665 723f 2054 6869 7320 6e65 6564 2074 ver? This need t │ │ │ -0006c1b0: 6f20 6265 0a72 6564 6573 6967 6e65 6420 o be.redesigned │ │ │ -0006c1c0: 666f 7220 6265 7474 6572 2074 7970 6520 for better type │ │ │ -0006c1d0: 7361 6665 7479 2e3c 2f68 323e 3c68 343e safety.

    │ │ │ -0006c1e0: 2e2e 2f73 7263 2f6b 6164 656d 6c69 612f ../src/kademlia/ │ │ │ -0006c1f0: 7075 745f 6461 7461 2e63 7070 3a36 393c put_data.cpp:69< │ │ │ -0006c200: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .}
    │ │ │ -0006c240: 0a7d 0a0a 766f 6964 2070 7574 5f64 6174  .}..void put_dat
    │ │ │ -0006c250: 613a 3a64 6f6e 6528 290a 7b0a 096d 5f64  a::done().{..m_d
    │ │ │ -0006c260: 6f6e 6520 3d20 7472 7565 3b0a 0a23 6966  one = true;..#if
    │ │ │ -0006c270: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ -0006c280: 4142 4c45 5f4c 4f47 4749 4e47 0a09 6765  ABLE_LOGGING..ge
    │ │ │ -0006c290: 745f 6e6f 6465 2829 2e6f 6273 6572 7665  t_node().observe
    │ │ │ -0006c2a0: 7228 292d 2667 743b 6c6f 6728 6468 745f  r()->log(dht_
    │ │ │ -0006c2b0: 6c6f 6767 6572 3a3a 7472 6176 6572 7361  logger::traversa
    │ │ │ -0006c2c0: 6c2c 2022 5b25 755d 2025 7320 444f 4e45  l, "[%u] %s DONE
    │ │ │ -0006c2d0: 2c20 7265 7370 6f6e 7365 2025 642c 2074  , response %d, t
    │ │ │ -0006c2e0: 696d 656f 7574 2025 6422 0a09 092c 2069  imeout %d"..., i
    │ │ │ -0006c2f0: 6428 292c 206e 616d 6528 292c 206e 756d  d(), name(), num
    │ │ │ -0006c300: 5f72 6573 706f 6e73 6573 2829 2c20 6e75  _responses(), nu
    │ │ │ -0006c310: 6d5f 7469 6d65 6f75 7473 2829 293b 0a23  m_timeouts());.#
    │ │ │ -0006c320: 656e 6469 660a 0a09 6d5f 7075 745f 6361  endif...m_put_ca
    │ │ │ -0006c330: 6c6c 6261 636b 286d 5f64 6174 612c 206e  llback(m_data, n
    │ │ │ -0006c340: 756d 5f72 6573 706f 6e73 6573 2829 293b  um_responses());
    │ │ │ -0006c350: 0a09 7472 6176 6572 7361 6c5f 616c 676f  ..traversal_algo
    │ │ │ -0006c360: 7269 7468 6d3a 3a64 6f6e 6528 293b 0a7d  rithm::done();.}
    │ │ │ -0006c370: 0a0a 626f 6f6c 2070 7574 5f64 6174 613a  ..bool put_data:
    │ │ │ -0006c380: 3a69 6e76 6f6b 6528 6f62 7365 7276 6572  :invoke(observer
    │ │ │ -0006c390: 5f70 7472 206f 290a 7b0a 0969 6620 286d  _ptr o).{..if (m
    │ │ │ -0006c3a0: 5f64 6f6e 6529 2072 6574 7572 6e20 6661  _done) return fa
    │ │ │ -0006c3b0: 6c73 653b 0a0a 3c64 6976 2073 7479 6c65  lse;..
    .auto* po = │ │ │ -0006c3f0: 7374 6174 6963 5f63 6173 7426 6c74 3b70 static_cast<p │ │ │ -0006c400: 7574 5f64 6174 615f 6f62 7365 7276 6572 ut_data_observer │ │ │ -0006c410: 2a26 6774 3b28 6f2e 6765 7428 2929 3b0a *>(o.get());. │ │ │ -0006c420: 3c2f 6469 763e 0a09 656e 7472 7920 653b
    ..entry e; │ │ │ -0006c430: 0a09 655b 2279 225d 203d 2022 7122 3b0a ..e["y"] = "q";. │ │ │ -0006c440: 0965 5b22 7122 5d20 3d20 2270 7574 223b .e["q"] = "put"; │ │ │ -0006c450: 0a09 656e 7472 7926 616d 703b 2061 203d ..entry& a = │ │ │ -0006c460: 2065 5b22 6122 5d3b 0a09 615b 2276 225d e["a"];..a["v"] │ │ │ -0006c470: 203d 206d 5f64 6174 612e 7661 6c75 6528 = m_data.value( │ │ │ -0006c480: 293b 0a09 615b 2274 6f6b 656e 225d 203d );..a["token"] = │ │ │ -0006c490: 2070 6f2d 2667 743b 6d5f 746f 6b65 6e3b po->m_token; │ │ │ -0006c4a0: 0a09 6966 2028 6d5f 6461 7461 2e69 735f ..if (m_data.is_ │ │ │ -0006c4b0: 6d75 7461 626c 6528 2929 0a09 7b0a 0909 mutable())..{... │ │ │ -0006c4c0: 615b 226b 225d 203d 206d 5f64 6174 612e a["k"] = m_data. │ │ │ -0006c4d0: 706b 2829 2e62 7974 6573 3b0a 0909 615b pk().bytes;...a[ │ │ │ -0006c4e0: 2273 6571 225d 203d 206d 5f64 6174 612e "seq"] = m_data. │ │ │ -0006c4f0: 7365 7128 292e 7661 6c75 653b 0a09 0961 seq().value;...a │ │ │ -0006c500: 5b22 7369 6722 5d20 3d20 6d5f 6461 7461 ["sig"] = m_data │ │ │ -0006c510: 2e73 6967 2829 2e62 7974 6573 3b0a 0909 .sig().bytes;... │ │ │ -0006c520: 6966 2028 216d 5f64 6174 612e 7361 6c74 if (!m_data.salt │ │ │ -0006c530: 2829 2e65 6d70 7479 2829 290a 0909 7b0a ().empty())...{. │ │ │ -0006c540: 0909 0961 5b22 7361 6c74 225d 203d 206d ...a["salt"] = m │ │ │ -0006c550: 5f64 6174 612e 7361 6c74 2829 3b0a 0909 _data.salt();... │ │ │ -0006c560: 7d0a 097d 0a0a 096d 5f6e 6f64 652e 7374 }..}...m_node.st │ │ │ -0006c570: 6174 735f 636f 756e 7465 7273 2829 2e69 ats_counters().i │ │ │ -0006c580: 6e63 5f73 7461 7473 5f63 6f75 6e74 6572 nc_stats_counter │ │ │ -0006c590: 2863 6f75 6e74 6572 733a 3a64 6874 5f70 (counters::dht_p │ │ │ -0006c5a0: 7574 5f6f 7574 293b 0a0a 0972 6574 7572 ut_out);...retur │ │ │ -0006c5b0: 6e20 6d5f 6e6f 6465 2e6d 5f72 7063 2e69 n m_node.m_rpc.i │ │ │ -0006c5c0: 6e76 6f6b 6528 652c 206f 2d26 6774 3b74 nvoke(e, o->t │ │ │ -0006c5d0: 6172 6765 745f 6570 2829 2c20 6f29 3b0a arget_ep(), o);. │ │ │ -0006c5e0: 7d0a 0a7d 207d 202f 2f20 6e61 6d65 7370 }..} } // namesp │ │ │ -0006c5f0: 6163 6520 6c69 6274 6f72 7265 6e74 3a3a ace libtorrent:: │ │ │ -0006c600: 6468 740a 3c2f 7072 653e 3c2f 7464 3e3c dht.
    < │ │ │ -0006c610: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0006c640: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0006c670: 2e2f 7372 632f 6b61 6465 6d6c 6961 2f72 ./src/kademlia/r │ │ │ -0006c680: 6f75 7469 6e67 5f74 6162 6c65 2e63 7070 outing_table.cpp │ │ │ -0006c690: 3a32 3634 3c2f 613e 3c2f 7464 3e3c 7464 :264This is tempora │ │ │ -0006c6b0: 7279 2e20 466f 7220 6e6f 772c 206f 6e6c ry. For now, onl │ │ │ -0006c6c0: 7920 7265 706f 7274 2074 6865 206c 6172 y report the lar │ │ │ -0006c6d0: 6765 7374 2072 6f75 7469 6e67 2074 6162 gest routing tab │ │ │ -0006c6e0: 6c65 2028 6f66 2070 6f74 656e 7469 616c le (of potential │ │ │ -0006c6f0: 6c79 206d 756c 7469 706c 6520 6f6e 6573 ly multiple ones │ │ │ -0006c700: 2c20 666f 7220 6d75 6c74 692d 686f 6d65 , for multi-home │ │ │ -0006c710: 6420 7379 7374 656d 7329 2069 6e20 6e65 d systems) in ne │ │ │ -0006c720: 7874 206d 616a 6f72 2076 6572 7369 6f6e xt major version │ │ │ -0006c730: 2c20 6272 6561 6b20 7468 6520 4142 4920 , break the ABI │ │ │ -0006c740: 616e 6420 7375 7070 6f72 7420 7265 706f and support repo │ │ │ -0006c750: 7274 696e 6720 616c 6c20 6f66 2074 6865 rting all of the │ │ │ -0006c760: 6d20 696e 2074 6865 2064 6874 5f73 7461 m in the dht_sta │ │ │ -0006c770: 7473 5f61 6c65 7274 3c2f 7464 3e3c 2f74 ts_alert

    This is te │ │ │ -0006c7d0: 6d70 6f72 6172 792e 2046 6f72 206e 6f77 mporary. For now │ │ │ -0006c7e0: 2c20 6f6e 6c79 2072 6570 6f72 7420 7468 , only report th │ │ │ -0006c7f0: 6520 6c61 7267 6573 7420 726f 7574 696e e largest routin │ │ │ -0006c800: 6720 7461 626c 650a 286f 6620 706f 7465 g table.(of pote │ │ │ -0006c810: 6e74 6961 6c6c 7920 6d75 6c74 6970 6c65 ntially multiple │ │ │ -0006c820: 206f 6e65 732c 2066 6f72 206d 756c 7469 ones, for multi │ │ │ -0006c830: 2d68 6f6d 6564 2073 7973 7465 6d73 290a -homed systems). │ │ │ -0006c840: 696e 206e 6578 7420 6d61 6a6f 7220 7665 in next major ve │ │ │ -0006c850: 7273 696f 6e2c 2062 7265 616b 2074 6865 rsion, break the │ │ │ -0006c860: 2041 4249 2061 6e64 2073 7570 706f 7274 ABI and support │ │ │ -0006c870: 2072 6570 6f72 7469 6e67 2061 6c6c 206f reporting all o │ │ │ -0006c880: 6620 7468 656d 2069 6e0a 7468 6520 6468 f them in.the dh │ │ │ -0006c890: 745f 7374 6174 735f 616c 6572 743c 2f68 t_stats_alert

    ../src/kad │ │ │ -0006c8b0: 656d 6c69 612f 726f 7574 696e 675f 7461 emlia/routing_ta │ │ │ -0006c8c0: 626c 652e 6370 703a 3236 343c 2f68 343e ble.cpp:264

    │ │ │ -0006c8d0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ., m_b
    │ │ │ -0006c910: 7563 6b65 745f 7369 7a65 2862 7563 6b65  ucket_size(bucke
    │ │ │ -0006c920: 745f 7369 7a65 290a 7b0a 092f 2f20 6275  t_size).{..// bu
    │ │ │ -0006c930: 636b 6574 2073 697a 6573 206d 7573 7420  cket sizes must 
    │ │ │ -0006c940: 6265 2061 2070 6f77 6572 206f 6620 320a  be a power of 2.
    │ │ │ -0006c950: 0954 4f52 5245 4e54 5f41 5353 4552 545f  .TORRENT_ASSERT_
    │ │ │ -0006c960: 5641 4c28 2828 6275 636b 6574 5f73 697a  VAL(((bucket_siz
    │ │ │ -0006c970: 6520 2d20 3129 2026 616d 703b 2062 7563  e - 1) & buc
    │ │ │ -0006c980: 6b65 745f 7369 7a65 2920 3d3d 2030 2c20  ket_size) == 0, 
    │ │ │ -0006c990: 6275 636b 6574 5f73 697a 6529 3b0a 0954  bucket_size);..T
    │ │ │ -0006c9a0: 4f52 5245 4e54 5f55 4e55 5345 4428 6c6f  ORRENT_UNUSED(lo
    │ │ │ -0006c9b0: 6729 3b0a 096d 5f62 7563 6b65 7473 2e72  g);..m_buckets.r
    │ │ │ -0006c9c0: 6573 6572 7665 2833 3029 3b0a 7d0a 0a69  eserve(30);.}..i
    │ │ │ -0006c9d0: 6e74 2072 6f75 7469 6e67 5f74 6162 6c65  nt routing_table
    │ │ │ -0006c9e0: 3a3a 6275 636b 6574 5f6c 696d 6974 2869  ::bucket_limit(i
    │ │ │ -0006c9f0: 6e74 2062 7563 6b65 7429 2063 6f6e 7374  nt bucket) const
    │ │ │ -0006ca00: 0a7b 0a09 6966 2028 216d 5f73 6574 7469  .{..if (!m_setti
    │ │ │ -0006ca10: 6e67 732e 6765 745f 626f 6f6c 2873 6574  ngs.get_bool(set
    │ │ │ -0006ca20: 7469 6e67 735f 7061 636b 3a3a 6468 745f  tings_pack::dht_
    │ │ │ -0006ca30: 6578 7465 6e64 6564 5f72 6f75 7469 6e67  extended_routing
    │ │ │ -0006ca40: 5f74 6162 6c65 2929 2072 6574 7572 6e20  _table)) return 
    │ │ │ -0006ca50: 6d5f 6275 636b 6574 5f73 697a 653b 0a0a  m_bucket_size;..
    │ │ │ -0006ca60: 0973 7461 7469 6320 636f 6e73 7420 6175  .static const au
    │ │ │ -0006ca70: 783a 3a61 7272 6179 266c 743b 696e 742c  x::array<int,
    │ │ │ -0006ca80: 2034 2667 743b 2073 697a 655f 6578 6365   4> size_exce
    │ │ │ -0006ca90: 7074 696f 6e73 7b7b 7b31 362c 2038 2c20  ptions{{{16, 8, 
    │ │ │ -0006caa0: 342c 2032 7d7d 7d3b 0a09 6966 2028 6275  4, 2}}};..if (bu
    │ │ │ -0006cab0: 636b 6574 2026 6c74 3b20 7369 7a65 5f65  cket < size_e
    │ │ │ -0006cac0: 7863 6570 7469 6f6e 732e 656e 645f 696e  xceptions.end_in
    │ │ │ -0006cad0: 6465 7828 2929 0a09 0972 6574 7572 6e20  dex())...return 
    │ │ │ -0006cae0: 6d5f 6275 636b 6574 5f73 697a 6520 2a20  m_bucket_size * 
    │ │ │ -0006caf0: 7369 7a65 5f65 7863 6570 7469 6f6e 735b  size_exceptions[
    │ │ │ -0006cb00: 6275 636b 6574 5d3b 0a09 7265 7475 726e  bucket];..return
    │ │ │ -0006cb10: 206d 5f62 7563 6b65 745f 7369 7a65 3b0a   m_bucket_size;.
    │ │ │ -0006cb20: 7d0a 0a76 6f69 6420 726f 7574 696e 675f  }..void routing_
    │ │ │ -0006cb30: 7461 626c 653a 3a73 7461 7475 7328 7374  table::status(st
    │ │ │ -0006cb40: 643a 3a76 6563 746f 7226 6c74 3b64 6874  d::vector<dht
    │ │ │ -0006cb50: 5f72 6f75 7469 6e67 5f62 7563 6b65 7426  _routing_bucket&
    │ │ │ -0006cb60: 6774 3b26 616d 703b 2073 2920 636f 6e73  gt;& s) cons
    │ │ │ -0006cb70: 740a 7b0a 3c64 6976 2073 7479 6c65 3d22  t.{.
    .if (s.size() │ │ │ -0006cbb0: 2667 743b 206d 5f62 7563 6b65 7473 2e73 > m_buckets.s │ │ │ -0006cbc0: 697a 6528 2929 2072 6574 7572 6e3b 0a3c ize()) return;.< │ │ │ -0006cbd0: 2f64 6976 3e09 732e 636c 6561 7228 293b /div>.s.clear(); │ │ │ -0006cbe0: 0a09 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -0006cbf0: 7426 616d 703b 2069 203a 206d 5f62 7563 t& i : m_buc │ │ │ -0006cc00: 6b65 7473 290a 097b 0a09 0964 6874 5f72 kets)..{...dht_r │ │ │ -0006cc10: 6f75 7469 6e67 5f62 7563 6b65 7420 623b outing_bucket b; │ │ │ -0006cc20: 0a09 0962 2e6e 756d 5f6e 6f64 6573 203d ...b.num_nodes = │ │ │ -0006cc30: 2069 6e74 2869 2e6c 6976 655f 6e6f 6465 int(i.live_node │ │ │ -0006cc40: 732e 7369 7a65 2829 293b 0a09 0962 2e6e s.size());...b.n │ │ │ -0006cc50: 756d 5f72 6570 6c61 6365 6d65 6e74 7320 um_replacements │ │ │ -0006cc60: 3d20 696e 7428 692e 7265 706c 6163 656d = int(i.replacem │ │ │ -0006cc70: 656e 7473 2e73 697a 6528 2929 3b0a 0909 ents.size());... │ │ │ -0006cc80: 732e 7075 7368 5f62 6163 6b28 6229 3b0a s.push_back(b);. │ │ │ -0006cc90: 097d 0a7d 0a0a 2369 6620 544f 5252 454e .}.}..#if TORREN │ │ │ -0006cca0: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ -0006ccb0: 2031 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 1.
    │ │ │ -0006cce0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0006ccf0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -0006cd20: 2f73 7263 2f6b 6164 656d 6c69 612f 726f /src/kademlia/ro │ │ │ -0006cd30: 7574 696e 675f 7461 626c 652e 6370 703a uting_table.cpp: │ │ │ -0006cd40: 3238 363c 2f61 3e3c 2f74 643e 3c74 643e 286 │ │ │ -0006cd50: 6172 7669 646e 206e 6f74 6520 7768 656e arvidn note when │ │ │ -0006cd60: 2069 7427 7320 6163 726f 7373 2049 5076 it's across IPv │ │ │ -0006cd70: 3420 616e 6420 4950 7636 2c20 6164 6469 4 and IPv6, addi │ │ │ -0006cd80: 6e67 2028 6468 745f 676c 6f62 616c 5f6e ng (dht_global_n │ │ │ -0006cd90: 6f64 6573 2920 776f 756c 6420 6d61 6b65 odes) would make │ │ │ -0006cda0: 2073 656e 7365 2e20 696e 2074 6865 2066 sense. in the f │ │ │ -0006cdb0: 7574 7572 6520 7468 6f75 6768 2c20 7768 uture though, wh │ │ │ -0006cdc0: 6572 6520 7765 206d 6179 2068 6176 6520 ere we may have │ │ │ -0006cdd0: 6f6e 6520 4448 5420 6e6f 6465 2070 6572 one DHT node per │ │ │ -0006cde0: 2065 7874 6572 6e61 6c20 696e 7465 7266 external interf │ │ │ -0006cdf0: 6163 6520 2877 6869 6368 206d 6179 2062 ace (which may b │ │ │ -0006ce00: 6520 6d75 6c74 6970 6c65 206f 6620 7468 e multiple of th │ │ │ -0006ce10: 6520 7361 6d65 2061 6464 7265 7373 2066 e same address f │ │ │ -0006ce20: 616d 696c 7929 2c20 7468 656e 2069 7420 amily), then it │ │ │ -0006ce30: 6265 636f 6d65 7320 6120 6269 7420 7472 becomes a bit tr │ │ │ -0006ce40: 6963 6b69 6572 3c2f 7464 3e3c 2f74 723e ickier │ │ │ -0006ce50: 3c74 7220 6964 3d22 3235 3122 2073 7479 │ │ │ -0006ce80: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006ce90: 3c68 323e 6172 7669 646e 206e 6f74 650a

    arvidn note. │ │ │ -0006cea0: 7768 656e 2069 7427 7320 6163 726f 7373 when it's across │ │ │ -0006ceb0: 2049 5076 3420 616e 6420 4950 7636 2c20 IPv4 and IPv6, │ │ │ -0006cec0: 6164 6469 6e67 2028 6468 745f 676c 6f62 adding (dht_glob │ │ │ -0006ced0: 616c 5f6e 6f64 6573 2920 776f 756c 640a al_nodes) would. │ │ │ -0006cee0: 6d61 6b65 2073 656e 7365 2e20 696e 2074 make sense. in t │ │ │ -0006cef0: 6865 2066 7574 7572 6520 7468 6f75 6768 he future though │ │ │ -0006cf00: 2c20 7768 6572 6520 7765 206d 6179 2068 , where we may h │ │ │ -0006cf10: 6176 6520 6f6e 6520 4448 5420 6e6f 6465 ave one DHT node │ │ │ -0006cf20: 0a70 6572 2065 7874 6572 6e61 6c20 696e .per external in │ │ │ -0006cf30: 7465 7266 6163 6520 2877 6869 6368 206d terface (which m │ │ │ -0006cf40: 6179 2062 6520 6d75 6c74 6970 6c65 206f ay be multiple o │ │ │ -0006cf50: 6620 7468 6520 7361 6d65 2061 6464 7265 f the same addre │ │ │ -0006cf60: 7373 0a66 616d 696c 7929 2c20 7468 656e ss.family), then │ │ │ -0006cf70: 2069 7420 6265 636f 6d65 7320 6120 6269 it becomes a bi │ │ │ -0006cf80: 7420 7472 6963 6b69 6572 3c2f 6832 3e3c t trickier

    < │ │ │ -0006cf90: 6834 3e2e 2e2f 7372 632f 6b61 6465 6d6c h4>../src/kademl │ │ │ -0006cfa0: 6961 2f72 6f75 7469 6e67 5f74 6162 6c65 ia/routing_table │ │ │ -0006cfb0: 2e63 7070 3a32 3836 3c2f 6834 3e3c 7072 .cpp:286.void rou │ │ │ -0006d000: 7469 6e67 5f74 6162 6c65 3a3a 7374 6174 ting_table::stat │ │ │ -0006d010: 7573 2873 7464 3a3a 7665 6374 6f72 266c us(std::vector&l │ │ │ -0006d020: 743b 6468 745f 726f 7574 696e 675f 6275 t;dht_routing_bu │ │ │ -0006d030: 636b 6574 2667 743b 2661 6d70 3b20 7329 cket>& s) │ │ │ -0006d040: 2063 6f6e 7374 0a7b 0a09 6966 2028 732e const.{..if (s. │ │ │ -0006d050: 7369 7a65 2829 2026 6774 3b20 6d5f 6275 size() > m_bu │ │ │ -0006d060: 636b 6574 732e 7369 7a65 2829 2920 7265 ckets.size()) re │ │ │ -0006d070: 7475 726e 3b0a 0973 2e63 6c65 6172 2829 turn;..s.clear() │ │ │ -0006d080: 3b0a 0966 6f72 2028 6175 746f 2063 6f6e ;..for (auto con │ │ │ -0006d090: 7374 2661 6d70 3b20 6920 3a20 6d5f 6275 st& i : m_bu │ │ │ -0006d0a0: 636b 6574 7329 0a09 7b0a 0909 6468 745f ckets)..{...dht_ │ │ │ -0006d0b0: 726f 7574 696e 675f 6275 636b 6574 2062 routing_bucket b │ │ │ -0006d0c0: 3b0a 0909 622e 6e75 6d5f 6e6f 6465 7320 ;...b.num_nodes │ │ │ -0006d0d0: 3d20 696e 7428 692e 6c69 7665 5f6e 6f64 = int(i.live_nod │ │ │ -0006d0e0: 6573 2e73 697a 6528 2929 3b0a 0909 622e es.size());...b. │ │ │ -0006d0f0: 6e75 6d5f 7265 706c 6163 656d 656e 7473 num_replacements │ │ │ -0006d100: 203d 2069 6e74 2869 2e72 6570 6c61 6365 = int(i.replace │ │ │ -0006d110: 6d65 6e74 732e 7369 7a65 2829 293b 0a09 ments.size());.. │ │ │ -0006d120: 0973 2e70 7573 685f 6261 636b 2862 293b .s.push_back(b); │ │ │ -0006d130: 0a09 7d0a 7d0a 0a23 6966 2054 4f52 5245 ..}.}..#if TORRE │ │ │ -0006d140: 4e54 5f41 4249 5f56 4552 5349 4f4e 203d NT_ABI_VERSION = │ │ │ -0006d150: 3d20 310a 766f 6964 2072 6f75 7469 6e67 = 1.void routing │ │ │ -0006d160: 5f74 6162 6c65 3a3a 7374 6174 7573 2873 _table::status(s │ │ │ -0006d170: 6573 7369 6f6e 5f73 7461 7475 7326 616d ession_status&am │ │ │ -0006d180: 703b 2073 2920 636f 6e73 740a 7b0a 0961 p; s) const.{..a │ │ │ -0006d190: 7574 6f20 636f 6e73 7420 5b64 6874 5f6e uto const [dht_n │ │ │ -0006d1a0: 6f64 6573 2c20 6468 745f 6e6f 6465 5f63 odes, dht_node_c │ │ │ -0006d1b0: 6163 6865 2c20 6967 6e6f 7265 5d20 3d20 ache, ignore] = │ │ │ -0006d1c0: 7369 7a65 2829 3b0a 0973 2e64 6874 5f6e size();..s.dht_n │ │ │ -0006d1d0: 6f64 6573 202b 3d20 6468 745f 6e6f 6465 odes += dht_node │ │ │ -0006d1e0: 733b 0a09 732e 6468 745f 6e6f 6465 5f63 s;..s.dht_node_c │ │ │ -0006d1f0: 6163 6865 202b 3d20 6468 745f 6e6f 6465 ache += dht_node │ │ │ -0006d200: 5f63 6163 6865 3b0a 3c64 6976 2073 7479 _cache;.
    .s.dht_glo │ │ │ -0006d240: 6261 6c5f 6e6f 6465 7320 2b3d 206e 756d bal_nodes += num │ │ │ -0006d250: 5f67 6c6f 6261 6c5f 6e6f 6465 7328 293b _global_nodes(); │ │ │ -0006d260: 0a3c 2f64 6976 3e0a 0966 6f72 2028 6175 .
    ..for (au │ │ │ -0006d270: 746f 2063 6f6e 7374 2661 6d70 3b20 6920 to const& i │ │ │ -0006d280: 3a20 6d5f 6275 636b 6574 7329 0a09 7b0a : m_buckets)..{. │ │ │ -0006d290: 0909 6468 745f 726f 7574 696e 675f 6275 ..dht_routing_bu │ │ │ -0006d2a0: 636b 6574 2062 3b0a 0909 622e 6e75 6d5f cket b;...b.num_ │ │ │ -0006d2b0: 6e6f 6465 7320 3d20 696e 7428 692e 6c69 nodes = int(i.li │ │ │ -0006d2c0: 7665 5f6e 6f64 6573 2e73 697a 6528 2929 ve_nodes.size()) │ │ │ -0006d2d0: 3b0a 0909 622e 6e75 6d5f 7265 706c 6163 ;...b.num_replac │ │ │ -0006d2e0: 656d 656e 7473 203d 2069 6e74 2869 2e72 ements = int(i.r │ │ │ -0006d2f0: 6570 6c61 6365 6d65 6e74 732e 7369 7a65 eplacements.size │ │ │ -0006d300: 2829 293b 0a09 0962 2e6c 6173 745f 6163 ());...b.last_ac │ │ │ -0006d310: 7469 7665 203d 2030 3b0a 0909 732e 6468 tive = 0;...s.dh │ │ │ -0006d320: 745f 726f 7574 696e 675f 7461 626c 652e t_routing_table. │ │ │ -0006d330: 7075 7368 5f62 6163 6b28 6229 3b0a 097d push_back(b);..} │ │ │ -0006d340: 0a7d 0a23 656e 6469 660a 0a73 7464 3a3a .}.#endif..std:: │ │ │ -0006d350: 7475 706c 6526 6c74 3b69 6e74 2c20 696e tuple<int, in │ │ │ -0006d360: 742c 2069 6e74 2667 743b 2072 6f75 7469 t, int> routi │ │ │ -0006d370: 6e67 5f74 6162 6c65 3a3a 7369 7a65 2829 ng_table::size() │ │ │ -0006d380: 2063 6f6e 7374 0a7b 0a09 696e 7420 6e6f const.{..int no │ │ │ -0006d390: 6465 7320 3d20 303b 0a09 696e 7420 7265 des = 0;..int re │ │ │ -0006d3a0: 706c 6163 656d 656e 7473 203d 2030 3b0a placements = 0;. │ │ │ -0006d3b0: 0969 6e74 2063 6f6e 6669 726d 6564 203d .int confirmed = │ │ │ -0006d3c0: 2030 3b0a 0966 6f72 2028 6175 746f 2063 0;..for (auto c │ │ │ -0006d3d0: 6f6e 7374 2661 6d70 3b20 6920 3a20 6d5f onst& i : m_ │ │ │ -0006d3e0: 6275 636b 6574 7329 0a09 7b0a 0909 6e6f buckets)..{...no │ │ │ -0006d3f0: 6465 7320 2b3d 2069 6e74 2869 2e6c 6976 des += int(i.liv │ │ │ -0006d400: 655f 6e6f 6465 732e 7369 7a65 2829 293b e_nodes.size()); │ │ │ -0006d410: 0a09 0963 6f6e 6669 726d 6564 202b 3d20 ...confirmed += │ │ │ -0006d420: 7374 6174 6963 5f63 6173 7426 6c74 3b69 static_cast<i │ │ │ -0006d430: 6e74 2667 743b 2873 7464 3a3a 636f 756e nt>(std::coun │ │ │ -0006d440: 745f 6966 2869 2e6c 6976 655f 6e6f 6465 t_if(i.live_node │ │ │ -0006d450: 732e 6265 6769 6e28 292c 2069 2e6c 6976 s.begin(), i.liv │ │ │ -0006d460: 655f 6e6f 6465 732e 656e 6428 290a 0909 e_nodes.end()... │ │ │ -0006d470: 092c 205b 5d28 6e6f 6465 5f65 6e74 7279 ., [](node_entry │ │ │ -0006d480: 2063 6f6e 7374 2661 6d70 3b20 6b29 207b const& k) { │ │ │ -0006d490: 2072 6574 7572 6e20 6b2e 636f 6e66 6972 return k.confir │ │ │ -0006d4a0: 6d65 6428 293b 207d 2029 293b 0a0a 0909 med(); } ));.... │ │ │ -0006d4b0: 7265 706c 6163 656d 656e 7473 202b 3d20 replacements += │ │ │ -0006d4c0: 696e 7428 692e 7265 706c 6163 656d 656e int(i.replacemen │ │ │ -0006d4d0: 7473 2e73 697a 6528 2929 3b0a 097d 0a09 ts.size());..}.. │ │ │ -0006d4e0: 7265 7475 726e 2073 7464 3a3a 6d61 6b65 return std::make │ │ │ -0006d4f0: 5f74 7570 6c65 286e 6f64 6573 2c20 7265 _tuple(nodes, re │ │ │ -0006d500: 706c 6163 656d 656e 7473 2c20 636f 6e66 placements, conf │ │ │ -0006d510: 6972 6d65 6429 3b0a 7d0a 0a73 7464 3a3a irmed);.}..std:: │ │ │ -0006d520: 696e 7436 345f 7420 726f 7574 696e 675f int64_t routing_ │ │ │ -0006d530: 7461 626c 653a 3a6e 756d 5f67 6c6f 6261 table::num_globa │ │ │ -0006d540: 6c5f 6e6f 6465 7328 2920 636f 6e73 740a l_nodes() const. │ │ │ -0006d550: 7b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 {.< │ │ │ -0006d580: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0006d590: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0006d5c0: 7372 632f 6b61 6465 6d6c 6961 2f72 6f75 src/kademlia/rou │ │ │ -0006d5d0: 7469 6e67 5f74 6162 6c65 2e63 7070 3a34 ting_table.cpp:4 │ │ │ -0006d5e0: 3838 3c2f 613e 3c2f 7464 3e3c 7464 3e74 88t │ │ │ -0006d5f0: 6869 7320 6e65 6564 2074 6f20 7461 6b65 his need to take │ │ │ -0006d600: 2062 7563 6b65 7420 2270 7265 6669 7822 bucket "prefix" │ │ │ -0006d610: 2069 6e74 6f20 6163 636f 756e 742e 2049 into account. I │ │ │ -0006d620: 7420 7368 6f75 6c64 2062 6520 756e 6966 t should be unif │ │ │ -0006d630: 6965 6420 7769 7468 2061 6464 5f6e 6f64 ied with add_nod │ │ │ -0006d640: 655f 696d 706c 2829 3c2f 7464 3e3c 2f74 e_impl()

    this need │ │ │ -0006d6a0: 746f 2074 616b 6520 6275 636b 6574 2022 to take bucket " │ │ │ -0006d6b0: 7072 6566 6978 2220 696e 746f 2061 6363 prefix" into acc │ │ │ -0006d6c0: 6f75 6e74 2e20 4974 2073 686f 756c 6420 ount. It should │ │ │ -0006d6d0: 6265 2075 6e69 6669 6564 0a77 6974 6820 be unified.with │ │ │ -0006d6e0: 6164 645f 6e6f 6465 5f69 6d70 6c28 293c add_node_impl()< │ │ │ -0006d6f0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6b /h2>

    ../src/k │ │ │ -0006d700: 6164 656d 6c69 612f 726f 7574 696e 675f ademlia/routing_ │ │ │ -0006d710: 7461 626c 652e 6370 703a 3438 383c 2f68 table.cpp:488
    {..f
    │ │ │ -0006d760: 6f72 2028 6175 746f 2069 203d 206d 5f62  or (auto i = m_b
    │ │ │ -0006d770: 7563 6b65 7473 2e62 6567 696e 2829 202c  uckets.begin() ,
    │ │ │ -0006d780: 2065 6e64 286d 5f62 7563 6b65 7473 2e65   end(m_buckets.e
    │ │ │ -0006d790: 6e64 2829 293b 2069 2021 3d20 656e 643b  nd()); i != end;
    │ │ │ -0006d7a0: 202b 2b69 290a 097b 0a09 0966 6f72 2028   ++i)..{...for (
    │ │ │ -0006d7b0: 6175 746f 206a 203d 2069 2d26 6774 3b72  auto j = i->r
    │ │ │ -0006d7c0: 6570 6c61 6365 6d65 6e74 732e 6265 6769  eplacements.begi
    │ │ │ -0006d7d0: 6e28 293b 206a 2021 3d20 692d 2667 743b  n(); j != i->
    │ │ │ -0006d7e0: 7265 706c 6163 656d 656e 7473 2e65 6e64  replacements.end
    │ │ │ -0006d7f0: 2829 3b20 2b2b 6a29 0a09 097b 0a09 0909  (); ++j)...{....
    │ │ │ -0006d800: 6966 2028 6a2d 2667 743b 6164 6472 2829  if (j->addr()
    │ │ │ -0006d810: 2021 3d20 6570 2e61 6464 7265 7373 2829   != ep.address()
    │ │ │ -0006d820: 2920 636f 6e74 696e 7565 3b0a 0909 0969  ) continue;....i
    │ │ │ -0006d830: 6620 286a 2d26 6774 3b70 6f72 7428 2920  f (j->port() 
    │ │ │ -0006d840: 213d 2065 702e 706f 7274 2829 2920 636f  != ep.port()) co
    │ │ │ -0006d850: 6e74 696e 7565 3b0a 0909 0972 6574 7572  ntinue;....retur
    │ │ │ -0006d860: 6e20 7374 643a 3a6d 616b 655f 7475 706c  n std::make_tupl
    │ │ │ -0006d870: 6528 2661 6d70 3b2a 6a2c 2069 2c20 2661  e(&*j, i, &a
    │ │ │ -0006d880: 6d70 3b69 2d26 6774 3b72 6570 6c61 6365  mp;i->replace
    │ │ │ -0006d890: 6d65 6e74 7329 3b0a 0909 7d0a 0909 666f  ments);...}...fo
    │ │ │ -0006d8a0: 7220 2861 7574 6f20 6a20 3d20 692d 2667  r (auto j = i-&g
    │ │ │ -0006d8b0: 743b 6c69 7665 5f6e 6f64 6573 2e62 6567  t;live_nodes.beg
    │ │ │ -0006d8c0: 696e 2829 3b20 6a20 213d 2069 2d26 6774  in(); j != i->
    │ │ │ -0006d8d0: 3b6c 6976 655f 6e6f 6465 732e 656e 6428  ;live_nodes.end(
    │ │ │ -0006d8e0: 293b 202b 2b6a 290a 0909 7b0a 0909 0969  ); ++j)...{....i
    │ │ │ -0006d8f0: 6620 286a 2d26 6774 3b61 6464 7228 2920  f (j->addr() 
    │ │ │ -0006d900: 213d 2065 702e 6164 6472 6573 7328 2929  != ep.address())
    │ │ │ -0006d910: 2063 6f6e 7469 6e75 653b 0a09 0909 6966   continue;....if
    │ │ │ -0006d920: 2028 6a2d 2667 743b 706f 7274 2829 2021   (j->port() !
    │ │ │ -0006d930: 3d20 6570 2e70 6f72 7428 2929 2063 6f6e  = ep.port()) con
    │ │ │ -0006d940: 7469 6e75 653b 0a09 0909 7265 7475 726e  tinue;....return
    │ │ │ -0006d950: 2073 7464 3a3a 6d61 6b65 5f74 7570 6c65   std::make_tuple
    │ │ │ -0006d960: 2826 616d 703b 2a6a 2c20 692c 2026 616d  (&*j, i, &am
    │ │ │ -0006d970: 703b 692d 2667 743b 6c69 7665 5f6e 6f64  p;i->live_nod
    │ │ │ -0006d980: 6573 293b 0a09 097d 0a09 7d0a 0972 6574  es);...}..}..ret
    │ │ │ -0006d990: 7572 6e20 7374 643a 3a74 7570 6c65 266c  urn std::tuple&l
    │ │ │ -0006d9a0: 743b 6e6f 6465 5f65 6e74 7279 2a2c 2072  t;node_entry*, r
    │ │ │ -0006d9b0: 6f75 7469 6e67 5f74 6162 6c65 3a3a 7461  outing_table::ta
    │ │ │ -0006d9c0: 626c 655f 743a 3a69 7465 7261 746f 722c  ble_t::iterator,
    │ │ │ -0006d9d0: 2062 7563 6b65 745f 742a 2667 743b 0a09   bucket_t*>..
    │ │ │ -0006d9e0: 7b6e 756c 6c70 7472 2c20 6d5f 6275 636b  {nullptr, m_buck
    │ │ │ -0006d9f0: 6574 732e 656e 6428 292c 206e 756c 6c70  ets.end(), nullp
    │ │ │ -0006da00: 7472 7d3b 0a7d 0a0a 3c64 6976 2073 7479  tr};.}..
    void routi │ │ │ -0006da40: 6e67 5f74 6162 6c65 3a3a 6669 6c6c 5f66 ng_table::fill_f │ │ │ -0006da50: 726f 6d5f 7265 706c 6163 656d 656e 7473 rom_replacements │ │ │ -0006da60: 2874 6162 6c65 5f74 3a3a 6974 6572 6174 (table_t::iterat │ │ │ -0006da70: 6f72 2062 7563 6b65 7429 0a3c 2f64 6976 or bucket).
    {..bucket_t& │ │ │ -0006da90: 3b20 6220 3d20 6275 636b 6574 2d26 6774 ; b = bucket-> │ │ │ -0006daa0: 3b6c 6976 655f 6e6f 6465 733b 0a09 6275 ;live_nodes;..bu │ │ │ -0006dab0: 636b 6574 5f74 2661 6d70 3b20 7262 203d cket_t& rb = │ │ │ -0006dac0: 2062 7563 6b65 742d 2667 743b 7265 706c bucket->repl │ │ │ -0006dad0: 6163 656d 656e 7473 3b0a 0969 6e74 2063 acements;..int c │ │ │ -0006dae0: 6f6e 7374 2062 7563 6b65 745f 7369 7a65 onst bucket_size │ │ │ -0006daf0: 203d 2062 7563 6b65 745f 6c69 6d69 7428 = bucket_limit( │ │ │ -0006db00: 696e 7428 7374 643a 3a64 6973 7461 6e63 int(std::distanc │ │ │ -0006db10: 6528 6d5f 6275 636b 6574 732e 6265 6769 e(m_buckets.begi │ │ │ -0006db20: 6e28 292c 2062 7563 6b65 7429 2929 3b0a n(), bucket)));. │ │ │ -0006db30: 0a09 6966 2028 696e 7428 622e 7369 7a65 ..if (int(b.size │ │ │ -0006db40: 2829 2920 2667 743b 3d20 6275 636b 6574 ()) >= bucket │ │ │ -0006db50: 5f73 697a 6529 2072 6574 7572 6e3b 0a0a _size) return;.. │ │ │ -0006db60: 092f 2f20 736f 7274 2062 7920 5254 5420 .// sort by RTT │ │ │ -0006db70: 6669 7273 742c 2074 6f20 6669 6e64 2074 first, to find t │ │ │ -0006db80: 6865 206e 6f64 6520 7769 7468 2074 6865 he node with the │ │ │ -0006db90: 206c 6f77 6573 740a 092f 2f20 5254 5420 lowest..// RTT │ │ │ -0006dba0: 7468 6174 2069 7320 7069 6e67 6564 0a09 that is pinged.. │ │ │ -0006dbb0: 7374 643a 3a73 6f72 7428 7262 2e62 6567 std::sort(rb.beg │ │ │ -0006dbc0: 696e 2829 2c20 7262 2e65 6e64 2829 293b in(), rb.end()); │ │ │ -0006dbd0: 0a0a 0977 6869 6c65 2028 696e 7428 622e ...while (int(b. │ │ │ -0006dbe0: 7369 7a65 2829 2920 266c 743b 2062 7563 size()) < buc │ │ │ -0006dbf0: 6b65 745f 7369 7a65 2026 616d 703b 2661 ket_size &&a │ │ │ -0006dc00: 6d70 3b20 2172 622e 656d 7074 7928 2929 mp; !rb.empty()) │ │ │ -0006dc10: 0a09 7b0a 0909 6175 746f 206a 203d 2073 ..{...auto j = s │ │ │ -0006dc20: 7464 3a3a 6669 6e64 5f69 6628 7262 2e62 td::find_if(rb.b │ │ │ -0006dc30: 6567 696e 2829 2c20 7262 2e65 6e64 2829 egin(), rb.end() │ │ │ -0006dc40: 2c20 7374 643a 3a62 696e 6428 2661 6d70 , std::bind(& │ │ │ -0006dc50: 3b6e 6f64 655f 656e 7472 793a 3a70 696e ;node_entry::pin │ │ │ -0006dc60: 6765 642c 205f 3129 293b 0a09 0969 6620 ged, _1));...if │ │ │ -0006dc70: 286a 203d 3d20 7262 2e65 6e64 2829 2920 (j == rb.end()) │ │ │ -0006dc80: 6272 6561 6b3b 0a09 0962 2e70 7573 685f break;...b.push_ │ │ │ -0006dc90: 6261 636b 282a 6a29 3b0a 0909 7262 2e65 back(*j);...rb.e │ │ │ -0006dca0: 7261 7365 286a 293b 0a09 7d0a 7d0a 0a76 rase(j);..}.}..v │ │ │ -0006dcb0: 6f69 6420 726f 7574 696e 675f 7461 626c oid routing_tabl │ │ │ -0006dcc0: 653a 3a70 7275 6e65 5f65 6d70 7479 5f62 e::prune_empty_b │ │ │ -0006dcd0: 7563 6b65 7428 290a 7b0a 0969 6620 286d ucket().{..if (m │ │ │ -0006dce0: 5f62 7563 6b65 7473 2e62 6163 6b28 292e _buckets.back(). │ │ │ -0006dcf0: 6c69 7665 5f6e 6f64 6573 2e65 6d70 7479 live_nodes.empty │ │ │ -0006dd00: 2829 0a09 0926 616d 703b 2661 6d70 3b20 ()...&& │ │ │ -0006dd10: 6d5f 6275 636b 6574 732e 6261 636b 2829 m_buckets.back() │ │ │ -0006dd20: 2e72 6570 6c61 6365 6d65 6e74 732e 656d .replacements.em │ │ │ -0006dd30: 7074 7928 2929 0a09 7b0a 0909 6d5f 6275 pty())..{...m_bu │ │ │ -0006dd40: 636b 6574 732e 6572 6173 6528 6d5f 6275 ckets.erase(m_bu │ │ │ -0006dd50: 636b 6574 732e 656e 6428 2920 2d20 3129 ckets.end() - 1) │ │ │ -0006dd60: 3b0a 097d 0a7d 0a0a 766f 6964 2072 6f75 ;..}.}..void rou │ │ │ -0006dd70: 7469 6e67 5f74 6162 6c65 3a3a 7265 6d6f ting_table::remo │ │ │ -0006dd80: 7665 5f6e 6f64 6528 6e6f 6465 5f65 6e74 ve_node(node_ent │ │ │ -0006dd90: 7279 2a20 6e2c 2062 7563 6b65 745f 742a ry* n, bucket_t* │ │ │ -0006dda0: 2062 290a 3c2f 7072 653e 3c2f 7464 3e3c b).
    < │ │ │ -0006ddb0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0006dde0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0006de10: 2e2f 7372 632f 6b61 6465 6d6c 6961 2f64 ./src/kademlia/d │ │ │ -0006de20: 6874 5f74 7261 636b 6572 2e63 7070 3a32 ht_tracker.cpp:2 │ │ │ -0006de30: 3933 3c2f 613e 3c2f 7464 3e3c 7464 3e70 93p │ │ │ -0006de40: 6963 6b20 7468 6520 636c 6f73 6573 7420 ick the closest │ │ │ -0006de50: 6e6f 6465 2072 6174 6865 7220 7468 616e node rather than │ │ │ -0006de60: 2074 6865 2066 6972 7374 3c2f 7464 3e3c the first< │ │ │ -0006de70: 2f74 723e 3c74 7220 6964 3d22 3235 3322 /tr>

    pick the │ │ │ -0006dec0: 2063 6c6f 7365 7374 206e 6f64 6520 7261 closest node ra │ │ │ -0006ded0: 7468 6572 2074 6861 6e20 7468 6520 6669 ther than the fi │ │ │ -0006dee0: 7273 743c 2f68 323e 3c68 343e 2e2e 2f73 rst

    ../s │ │ │ -0006def0: 7263 2f6b 6164 656d 6c69 612f 6468 745f rc/kademlia/dht_ │ │ │ -0006df00: 7472 6163 6b65 722e 6370 703a 3239 333c tracker.cpp:293< │ │ │ -0006df10: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .#
    │ │ │ -0006df50: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -0006df60: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ -0006df70: 096d 5f6c 6f67 2d26 6774 3b6c 6f67 2864  .m_log->log(d
    │ │ │ -0006df80: 6874 5f6c 6f67 6765 723a 3a74 7261 636b  ht_logger::track
    │ │ │ -0006df90: 6572 2c20 222a 2a2a 206e 6577 2077 7269  er, "*** new wri
    │ │ │ -0006dfa0: 7465 206b 6579 2a2a 2a20 2564 206e 6f64  te key*** %d nod
    │ │ │ -0006dfb0: 6573 220a 0909 092c 2069 6e74 286d 5f6e  es"...., int(m_n
    │ │ │ -0006dfc0: 6f64 6573 2e73 697a 6528 2929 293b 0a23  odes.size()));.#
    │ │ │ -0006dfd0: 656e 6469 660a 097d 0a0a 0976 6f69 6420  endif..}...void 
    │ │ │ -0006dfe0: 6468 745f 7472 6163 6b65 723a 3a75 7064  dht_tracker::upd
    │ │ │ -0006dff0: 6174 655f 7374 6f72 6167 655f 6e6f 6465  ate_storage_node
    │ │ │ -0006e000: 5f69 6473 2829 0a09 7b0a 0909 7374 643a  _ids()..{...std:
    │ │ │ -0006e010: 3a76 6563 746f 7226 6c74 3b73 6861 315f  :vector<sha1_
    │ │ │ -0006e020: 6861 7368 2667 743b 2069 6473 3b0a 0909  hash> ids;...
    │ │ │ -0006e030: 666f 7220 2861 7574 6f26 616d 703b 206e  for (auto& n
    │ │ │ -0006e040: 203a 206d 5f6e 6f64 6573 290a 0909 0969   : m_nodes)....i
    │ │ │ -0006e050: 6473 2e70 7573 685f 6261 636b 286e 2e73  ds.push_back(n.s
    │ │ │ -0006e060: 6563 6f6e 642e 6468 742e 6e69 6428 2929  econd.dht.nid())
    │ │ │ -0006e070: 3b0a 0909 6d5f 7374 6f72 6167 652e 7570  ;...m_storage.up
    │ │ │ -0006e080: 6461 7465 5f6e 6f64 655f 6964 7328 6964  date_node_ids(id
    │ │ │ -0006e090: 7329 3b0a 097d 0a0a 096e 6f64 652a 2064  s);..}...node* d
    │ │ │ -0006e0a0: 6874 5f74 7261 636b 6572 3a3a 6765 745f  ht_tracker::get_
    │ │ │ -0006e0b0: 6e6f 6465 286e 6f64 655f 6964 2063 6f6e  node(node_id con
    │ │ │ -0006e0c0: 7374 2661 6d70 3b20 6964 2c20 7374 7269  st& id, stri
    │ │ │ -0006e0d0: 6e67 5f76 6965 7720 2066 616d 696c 795f  ng_view  family_
    │ │ │ -0006e0e0: 6e61 6d65 290a 097b 0a09 0954 4f52 5245  name)..{...TORRE
    │ │ │ -0006e0f0: 4e54 5f55 4e55 5345 4428 6964 293b 0a09  NT_UNUSED(id);..
    │ │ │ -0006e100: 0966 6f72 2028 6175 746f 2661 6d70 3b20  .for (auto& 
    │ │ │ -0006e110: 6e20 3a20 6d5f 6e6f 6465 7329 0a09 097b  n : m_nodes)...{
    │ │ │ -0006e120: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0006e150: 0909 6966 2028 6e2e 7365 636f 6e64 2e64 ..if (n.second.d │ │ │ -0006e160: 6874 2e70 726f 746f 636f 6c5f 6661 6d69 ht.protocol_fami │ │ │ -0006e170: 6c79 5f6e 616d 6528 2920 3d3d 2066 616d ly_name() == fam │ │ │ -0006e180: 696c 795f 6e61 6d65 290a 3c2f 6469 763e ily_name).
    │ │ │ -0006e190: 0909 0909 7265 7475 726e 2026 616d 703b ....return & │ │ │ -0006e1a0: 6e2e 7365 636f 6e64 2e64 6874 3b0a 0909 n.second.dht;... │ │ │ -0006e1b0: 7d0a 0a09 0972 6574 7572 6e20 6e75 6c6c }....return null │ │ │ -0006e1c0: 7074 723b 0a09 7d0a 0a09 766f 6964 2064 ptr;..}...void d │ │ │ -0006e1d0: 6874 5f74 7261 636b 6572 3a3a 6765 745f ht_tracker::get_ │ │ │ -0006e1e0: 7065 6572 7328 7368 6131 5f68 6173 6820 peers(sha1_hash │ │ │ -0006e1f0: 636f 6e73 7426 616d 703b 2069 680a 0909 const& ih... │ │ │ -0006e200: 2c20 7374 643a 3a66 756e 6374 696f 6e26 , std::function& │ │ │ -0006e210: 6c74 3b76 6f69 6428 7374 643a 3a76 6563 lt;void(std::vec │ │ │ -0006e220: 746f 7226 6c74 3b74 6370 3a3a 656e 6470 tor<tcp::endp │ │ │ -0006e230: 6f69 6e74 2667 743b 2063 6f6e 7374 2661 oint> const&a │ │ │ -0006e240: 6d70 3b29 2667 743b 2066 290a 097b 0a09 mp;)> f)..{.. │ │ │ -0006e250: 0966 6f72 2028 6175 746f 2661 6d70 3b20 .for (auto& │ │ │ -0006e260: 6e20 3a20 6d5f 6e6f 6465 7329 0a09 0909 n : m_nodes).... │ │ │ -0006e270: 6e2e 7365 636f 6e64 2e64 6874 2e67 6574 n.second.dht.get │ │ │ -0006e280: 5f70 6565 7273 2869 682c 2066 2c20 7b7d _peers(ih, f, {} │ │ │ -0006e290: 2c20 7b7d 293b 0a09 7d0a 0a09 766f 6964 , {});..}...void │ │ │ -0006e2a0: 2064 6874 5f74 7261 636b 6572 3a3a 616e dht_tracker::an │ │ │ -0006e2b0: 6e6f 756e 6365 2873 6861 315f 6861 7368 nounce(sha1_hash │ │ │ -0006e2c0: 2063 6f6e 7374 2661 6d70 3b20 6968 2c20 const& ih, │ │ │ -0006e2d0: 696e 7420 6c69 7374 656e 5f70 6f72 740a int listen_port. │ │ │ -0006e2e0: 0909 2c20 616e 6e6f 756e 6365 5f66 6c61 .., announce_fla │ │ │ -0006e2f0: 6773 5f74 2063 6f6e 7374 2066 6c61 6773 gs_t const flags │ │ │ -0006e300: 0a09 092c 2073 7464 3a3a 6675 6e63 7469 ..., std::functi │ │ │ -0006e310: 6f6e 266c 743b 766f 6964 2873 7464 3a3a on<void(std:: │ │ │ -0006e320: 7665 6374 6f72 266c 743b 7463 703a 3a65 vector<tcp::e │ │ │ -0006e330: 6e64 706f 696e 7426 6774 3b20 636f 6e73 ndpoint> cons │ │ │ -0006e340: 7426 616d 703b 2926 6774 3b20 6629 0a09 t&)> f).. │ │ │ -0006e350: 7b0a 0909 666f 7220 2861 7574 6f26 616d {...for (auto&am │ │ │ -0006e360: 703b 206e 203a 206d 5f6e 6f64 6573 290a p; n : m_nodes). │ │ │ -0006e370: 0909 096e 2e73 6563 6f6e 642e 6468 742e ...n.second.dht. │ │ │ -0006e380: 616e 6e6f 756e 6365 2869 682c 206c 6973 announce(ih, lis │ │ │ -0006e390: 7465 6e5f 706f 7274 2c20 666c 6167 732c ten_port, flags, │ │ │ -0006e3a0: 2066 293b 0a09 7d0a 0a09 766f 6964 2064 f);..}...void d │ │ │ -0006e3b0: 6874 5f74 7261 636b 6572 3a3a 7361 6d70 ht_tracker::samp │ │ │ -0006e3c0: 6c65 5f69 6e66 6f68 6173 6865 7328 7564 le_infohashes(ud │ │ │ -0006e3d0: 703a 3a65 6e64 706f 696e 7420 636f 6e73 p::endpoint cons │ │ │ -0006e3e0: 7426 616d 703b 2065 702c 2073 6861 315f t& ep, sha1_ │ │ │ -0006e3f0: 6861 7368 2063 6f6e 7374 2661 6d70 3b20 hash const& │ │ │ -0006e400: 7461 7267 6574 0a09 092c 2073 7464 3a3a target..., std:: │ │ │ -0006e410: 6675 6e63 7469 6f6e 266c 743b 766f 6964 function<void │ │ │ -0006e420: 286e 6f64 655f 6964 0a09 0909 2c20 7469 (node_id...., ti │ │ │ -0006e430: 6d65 5f64 7572 6174 696f 6e0a 0909 092c me_duration...., │ │ │ -0006e440: 2069 6e74 2c20 7374 643a 3a76 6563 746f int, std::vecto │ │ │ -0006e450: 7226 6c74 3b73 6861 315f 6861 7368 2667 r<sha1_hash&g │ │ │ -0006e460: 743b 0a09 0909 2c20 7374 643a 3a76 6563 t;...., std::vec │ │ │ -0006e470: 746f 7226 6c74 3b73 7464 3a3a 7061 6972 tor<std::pair │ │ │ -0006e480: 266c 743b 7368 6131 5f68 6173 682c 2075 <sha1_hash, u │ │ │ -0006e490: 6470 3a3a 656e 6470 6f69 6e74 2667 743b dp::endpoint> │ │ │ -0006e4a0: 2667 743b 2926 6774 3b20 6629 0a09 7b0a >)> f)..{. │ │ │ -0006e4b0: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ -0006e4c0: 206e 203a 206d 5f6e 6f64 6573 290a 0909 n : m_nodes)... │ │ │ -0006e4d0: 7b0a 0909 0969 6620 2865 702e 7072 6f74 {....if (ep.prot │ │ │ -0006e4e0: 6f63 6f6c 2829 2021 3d20 286e 2e66 6972 ocol() != (n.fir │ │ │ -0006e4f0: 7374 2e67 6574 5f65 7874 6572 6e61 6c5f st.get_external_ │ │ │ -0006e500: 6164 6472 6573 7328 292e 6973 5f76 3428 address().is_v4( │ │ │ -0006e510: 2920 3f20 7564 703a 3a76 3428 2920 3a20 ) ? udp::v4() : │ │ │ -0006e520: 7564 703a 3a76 3628 2929 290a 3c2f 7072 udp::v6())).rel │ │ │ -0006e560: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/ka │ │ │ -0006e5a0: 6465 6d6c 6961 2f6e 6f64 652e 6370 703a demlia/node.cpp: │ │ │ -0006e5b0: 3131 3534 3c2f 613e 3c2f 7464 3e3c 7464 1154keep the return │ │ │ -0006e5d0: 6564 2076 616c 7565 2074 6f20 7061 7373 ed value to pass │ │ │ -0006e5e0: 2061 7320 6120 6c69 6d69 7420 746f 2077 as a limit to w │ │ │ -0006e5f0: 7269 7465 5f6e 6f64 6573 5f65 6e74 7269 rite_nodes_entri │ │ │ -0006e600: 6573 2077 6865 6e20 696d 706c 656d 656e es when implemen │ │ │ -0006e610: 7465 643c 2f74 643e 3c2f 7472 3e3c 7472 ted

    keep the return │ │ │ -0006e670: 6564 2076 616c 7565 2074 6f20 7061 7373 ed value to pass │ │ │ -0006e680: 2061 7320 6120 6c69 6d69 740a 746f 2077 as a limit.to w │ │ │ -0006e690: 7269 7465 5f6e 6f64 6573 5f65 6e74 7269 rite_nodes_entri │ │ │ -0006e6a0: 6573 2077 6865 6e20 696d 706c 656d 656e es when implemen │ │ │ -0006e6b0: 7465 643c 2f68 323e 3c68 343e 2e2e 2f73 ted

    ../s │ │ │ -0006e6c0: 7263 2f6b 6164 656d 6c69 612f 6e6f 6465 rc/kademlia/node │ │ │ -0006e6d0: 2e63 7070 3a31 3135 343c 2f68 343e 3c70 .cpp:1154

    ..}..}.. │ │ │ -0006e720: 656c 7365 2069 6620 2871 7565 7279 203d else if (query = │ │ │ -0006e730: 3d20 2273 616d 706c 655f 696e 666f 6861 = "sample_infoha │ │ │ -0006e740: 7368 6573 2229 0a09 7b0a 0909 7374 6174 shes")..{...stat │ │ │ -0006e750: 6963 206b 6579 5f64 6573 635f 7420 636f ic key_desc_t co │ │ │ -0006e760: 6e73 7420 6d73 675f 6465 7363 5b5d 203d nst msg_desc[] = │ │ │ -0006e770: 207b 0a09 0909 7b22 7461 7267 6574 222c {....{"target", │ │ │ -0006e780: 2062 6465 636f 6465 5f6e 6f64 653a 3a73 bdecode_node::s │ │ │ -0006e790: 7472 696e 675f 742c 2032 302c 2030 7d2c tring_t, 20, 0}, │ │ │ -0006e7a0: 0a09 0909 7b22 7761 6e74 222c 2062 6465 ....{"want", bde │ │ │ -0006e7b0: 636f 6465 5f6e 6f64 653a 3a6c 6973 745f code_node::list_ │ │ │ -0006e7c0: 742c 2030 2c20 6b65 795f 6465 7363 5f74 t, 0, key_desc_t │ │ │ -0006e7d0: 3a3a 6f70 7469 6f6e 616c 7d2c 0a09 097d ::optional},...} │ │ │ -0006e7e0: 3b0a 0a09 0962 6465 636f 6465 5f6e 6f64 ;....bdecode_nod │ │ │ -0006e7f0: 6520 6d73 675f 6b65 7973 5b32 5d3b 0a09 e msg_keys[2];.. │ │ │ -0006e800: 0969 6620 2821 7665 7269 6679 5f6d 6573 .if (!verify_mes │ │ │ -0006e810: 7361 6765 2861 7267 5f65 6e74 2c20 6d73 sage(arg_ent, ms │ │ │ -0006e820: 675f 6465 7363 2c20 6d73 675f 6b65 7973 g_desc, msg_keys │ │ │ -0006e830: 2c20 6572 726f 725f 7374 7269 6e67 2929 , error_string)) │ │ │ -0006e840: 0a09 097b 0a09 0909 6d5f 636f 756e 7465 ...{....m_counte │ │ │ -0006e850: 7273 2e69 6e63 5f73 7461 7473 5f63 6f75 rs.inc_stats_cou │ │ │ -0006e860: 6e74 6572 2863 6f75 6e74 6572 733a 3a64 nter(counters::d │ │ │ -0006e870: 6874 5f69 6e76 616c 6964 5f73 616d 706c ht_invalid_sampl │ │ │ -0006e880: 655f 696e 666f 6861 7368 6573 293b 0a09 e_infohashes);.. │ │ │ -0006e890: 0909 696e 636f 6d69 6e67 5f65 7272 6f72 ..incoming_error │ │ │ -0006e8a0: 2865 2c20 6572 726f 725f 7374 7269 6e67 (e, error_string │ │ │ -0006e8b0: 293b 0a09 0909 7265 7475 726e 3b0a 0909 );....return;... │ │ │ -0006e8c0: 7d0a 0a09 096d 5f63 6f75 6e74 6572 732e }....m_counters. │ │ │ -0006e8d0: 696e 635f 7374 6174 735f 636f 756e 7465 inc_stats_counte │ │ │ -0006e8e0: 7228 636f 756e 7465 7273 3a3a 6468 745f r(counters::dht_ │ │ │ -0006e8f0: 7361 6d70 6c65 5f69 6e66 6f68 6173 6865 sample_infohashe │ │ │ -0006e900: 735f 696e 293b 0a09 0973 6861 315f 6861 s_in);...sha1_ha │ │ │ -0006e910: 7368 2063 6f6e 7374 2074 6172 6765 7428 sh const target( │ │ │ -0006e920: 6d73 675f 6b65 7973 5b30 5d2e 7374 7269 msg_keys[0].stri │ │ │ -0006e930: 6e67 5f70 7472 2829 293b 0a0a 3c64 6976 ng_ptr());..

    ..m_st │ │ │ -0006e970: 6f72 6167 652e 6765 745f 696e 666f 6861 orage.get_infoha │ │ │ -0006e980: 7368 6573 5f73 616d 706c 6528 7265 706c shes_sample(repl │ │ │ -0006e990: 7929 3b0a 3c2f 6469 763e 0a09 0977 7269 y);.
    ...wri │ │ │ -0006e9a0: 7465 5f6e 6f64 6573 5f65 6e74 7269 6573 te_nodes_entries │ │ │ -0006e9b0: 2874 6172 6765 742c 206d 7367 5f6b 6579 (target, msg_key │ │ │ -0006e9c0: 735b 315d 2c20 7265 706c 7929 3b0a 097d s[1], reply);..} │ │ │ -0006e9d0: 0a09 656c 7365 0a09 7b0a 0909 2f2f 2069 ..else..{...// i │ │ │ -0006e9e0: 6620 7765 2064 6f6e 2774 2072 6563 6f67 f we don't recog │ │ │ -0006e9f0: 6e69 7a65 2074 6865 206d 6573 7361 6765 nize the message │ │ │ -0006ea00: 2062 7574 2074 6865 7265 2773 2061 0a09 but there's a.. │ │ │ -0006ea10: 092f 2f20 2774 6172 6765 7427 206f 7220 .// 'target' or │ │ │ -0006ea20: 2769 6e66 6f5f 6861 7368 2720 696e 2074 'info_hash' in t │ │ │ -0006ea30: 6865 2061 7267 756d 656e 7473 2c20 7472 he arguments, tr │ │ │ -0006ea40: 6561 7420 6974 0a09 092f 2f20 6173 2066 eat it...// as f │ │ │ -0006ea50: 696e 645f 6e6f 6465 2074 6f20 6265 2066 ind_node to be f │ │ │ -0006ea60: 7574 7572 6520 636f 6d70 6174 6962 6c65 uture compatible │ │ │ -0006ea70: 0a09 0962 6465 636f 6465 5f6e 6f64 6520 ...bdecode_node │ │ │ -0006ea80: 7461 7267 6574 5f65 6e74 203d 2061 7267 target_ent = arg │ │ │ -0006ea90: 5f65 6e74 2e64 6963 745f 6669 6e64 5f73 _ent.dict_find_s │ │ │ -0006eaa0: 7472 696e 6728 2274 6172 6765 7422 293b tring("target"); │ │ │ -0006eab0: 0a09 0969 6620 2821 7461 7267 6574 5f65 ...if (!target_e │ │ │ -0006eac0: 6e74 207c 7c20 7461 7267 6574 5f65 6e74 nt || target_ent │ │ │ -0006ead0: 2e73 7472 696e 675f 6c65 6e67 7468 2829 .string_length() │ │ │ -0006eae0: 2021 3d20 3230 290a 0909 7b0a 0909 0974 != 20)...{....t │ │ │ -0006eaf0: 6172 6765 745f 656e 7420 3d20 6172 675f arget_ent = arg_ │ │ │ -0006eb00: 656e 742e 6469 6374 5f66 696e 645f 7374 ent.dict_find_st │ │ │ -0006eb10: 7269 6e67 2822 696e 666f 5f68 6173 6822 ring("info_hash" │ │ │ -0006eb20: 293b 0a09 0909 6966 2028 2174 6172 6765 );....if (!targe │ │ │ -0006eb30: 745f 656e 7420 7c7c 2074 6172 6765 745f t_ent || target_ │ │ │ -0006eb40: 656e 742e 7374 7269 6e67 5f6c 656e 6774 ent.string_lengt │ │ │ -0006eb50: 6828 2920 213d 2032 3029 0a09 0909 7b0a h() != 20)....{. │ │ │ -0006eb60: 0909 0909 696e 636f 6d69 6e67 5f65 7272 ....incoming_err │ │ │ -0006eb70: 6f72 2865 2c20 2275 6e6b 6e6f 776e 206d or(e, "unknown m │ │ │ -0006eb80: 6573 7361 6765 2229 3b0a 0909 0909 7265 essage");.....re │ │ │ -0006eb90: 7475 726e 3b0a 0909 097d 0a09 097d 0a0a turn;....}...}.. │ │ │ -0006eba0: 0909 7368 6131 5f68 6173 6820 636f 6e73 ..sha1_hash cons │ │ │ -0006ebb0: 7420 7461 7267 6574 2874 6172 6765 745f t target(target_ │ │ │ -0006ebc0: 656e 742e 7374 7269 6e67 5f70 7472 2829 ent.string_ptr() │ │ │ -0006ebd0: 293b 0a09 092f 2f20 616c 7761 7973 2072 );...// always r │ │ │ -0006ebe0: 6574 7572 6e20 6e6f 6465 7320 6173 2077 eturn nodes as w │ │ │ -0006ebf0: 656c 6c20 6173 2070 6565 7273 0a09 0977 ell as peers...w │ │ │ -0006ec00: 7269 7465 5f6e 6f64 6573 5f65 6e74 7269 rite_nodes_entri │ │ │ -0006ec10: 6573 2874 6172 6765 742c 2061 7267 5f65 es(target, arg_e │ │ │ -0006ec20: 6e74 2e64 6963 745f 6669 6e64 5f6c 6973 nt.dict_find_lis │ │ │ -0006ec30: 7428 2277 616e 7422 292c 2072 6570 6c79 t("want"), reply │ │ │ -0006ec40: 293b 0a09 7d0a 7d0a 0a3c 2f70 7265 3e3c );..}.}..
    < │ │ │ -0006ec50: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0006ec80: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0006ec90: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/kadem │ │ │ -0006ecc0: 6c69 612f 6e6f 6465 2e63 7070 3a31 3138 lia/node.cpp:118 │ │ │ -0006ecd0: 323c 2f61 3e3c 2f74 643e 3c74 643e 6c69 2li │ │ │ -0006ece0: 6d69 7420 6e75 6d62 6572 206f 6620 656e mit number of en │ │ │ -0006ecf0: 7472 6965 7320 696e 2074 6865 2072 6573 tries in the res │ │ │ -0006ed00: 756c 743c 2f74 643e 3c2f 7472 3e3c 7472 ult

    limit number of │ │ │ -0006ed60: 2065 6e74 7269 6573 2069 6e20 7468 6520 entries in the │ │ │ -0006ed70: 7265 7375 6c74 3c2f 6832 3e3c 6834 3e2e result

    . │ │ │ -0006ed80: 2e2f 7372 632f 6b61 6465 6d6c 6961 2f6e ./src/kademlia/n │ │ │ -0006ed90: 6f64 652e 6370 703a 3131 3832 3c2f 6834 ode.cpp:1182

    ..// 
    │ │ │ -0006ede0: 6966 2077 6520 646f 6e27 7420 7265 636f  if we don't reco
    │ │ │ -0006edf0: 676e 697a 6520 7468 6520 6d65 7373 6167  gnize the messag
    │ │ │ -0006ee00: 6520 6275 7420 7468 6572 6527 7320 610a  e but there's a.
    │ │ │ -0006ee10: 0909 2f2f 2027 7461 7267 6574 2720 6f72  ..// 'target' or
    │ │ │ -0006ee20: 2027 696e 666f 5f68 6173 6827 2069 6e20   'info_hash' in 
    │ │ │ -0006ee30: 7468 6520 6172 6775 6d65 6e74 732c 2074  the arguments, t
    │ │ │ -0006ee40: 7265 6174 2069 740a 0909 2f2f 2061 7320  reat it...// as 
    │ │ │ -0006ee50: 6669 6e64 5f6e 6f64 6520 746f 2062 6520  find_node to be 
    │ │ │ -0006ee60: 6675 7475 7265 2063 6f6d 7061 7469 626c  future compatibl
    │ │ │ -0006ee70: 650a 0909 6264 6563 6f64 655f 6e6f 6465  e...bdecode_node
    │ │ │ -0006ee80: 2074 6172 6765 745f 656e 7420 3d20 6172   target_ent = ar
    │ │ │ -0006ee90: 675f 656e 742e 6469 6374 5f66 696e 645f  g_ent.dict_find_
    │ │ │ -0006eea0: 7374 7269 6e67 2822 7461 7267 6574 2229  string("target")
    │ │ │ -0006eeb0: 3b0a 0909 6966 2028 2174 6172 6765 745f  ;...if (!target_
    │ │ │ -0006eec0: 656e 7420 7c7c 2074 6172 6765 745f 656e  ent || target_en
    │ │ │ -0006eed0: 742e 7374 7269 6e67 5f6c 656e 6774 6828  t.string_length(
    │ │ │ -0006eee0: 2920 213d 2032 3029 0a09 097b 0a09 0909  ) != 20)...{....
    │ │ │ -0006eef0: 7461 7267 6574 5f65 6e74 203d 2061 7267  target_ent = arg
    │ │ │ -0006ef00: 5f65 6e74 2e64 6963 745f 6669 6e64 5f73  _ent.dict_find_s
    │ │ │ -0006ef10: 7472 696e 6728 2269 6e66 6f5f 6861 7368  tring("info_hash
    │ │ │ -0006ef20: 2229 3b0a 0909 0969 6620 2821 7461 7267  ");....if (!targ
    │ │ │ -0006ef30: 6574 5f65 6e74 207c 7c20 7461 7267 6574  et_ent || target
    │ │ │ -0006ef40: 5f65 6e74 2e73 7472 696e 675f 6c65 6e67  _ent.string_leng
    │ │ │ -0006ef50: 7468 2829 2021 3d20 3230 290a 0909 097b  th() != 20)....{
    │ │ │ -0006ef60: 0a09 0909 0969 6e63 6f6d 696e 675f 6572  .....incoming_er
    │ │ │ -0006ef70: 726f 7228 652c 2022 756e 6b6e 6f77 6e20  ror(e, "unknown 
    │ │ │ -0006ef80: 6d65 7373 6167 6522 293b 0a09 0909 0972  message");.....r
    │ │ │ -0006ef90: 6574 7572 6e3b 0a09 0909 7d0a 0909 7d0a  eturn;....}...}.
    │ │ │ -0006efa0: 0a09 0973 6861 315f 6861 7368 2063 6f6e  ...sha1_hash con
    │ │ │ -0006efb0: 7374 2074 6172 6765 7428 7461 7267 6574  st target(target
    │ │ │ -0006efc0: 5f65 6e74 2e73 7472 696e 675f 7074 7228  _ent.string_ptr(
    │ │ │ -0006efd0: 2929 3b0a 0909 2f2f 2061 6c77 6179 7320  ));...// always 
    │ │ │ -0006efe0: 7265 7475 726e 206e 6f64 6573 2061 7320  return nodes as 
    │ │ │ -0006eff0: 7765 6c6c 2061 7320 7065 6572 730a 0909  well as peers...
    │ │ │ -0006f000: 7772 6974 655f 6e6f 6465 735f 656e 7472  write_nodes_entr
    │ │ │ -0006f010: 6965 7328 7461 7267 6574 2c20 6172 675f  ies(target, arg_
    │ │ │ -0006f020: 656e 742e 6469 6374 5f66 696e 645f 6c69  ent.dict_find_li
    │ │ │ -0006f030: 7374 2822 7761 6e74 2229 2c20 7265 706c  st("want"), repl
    │ │ │ -0006f040: 7929 3b0a 097d 0a7d 0a0a 3c64 6976 2073  y);..}.}..
    void nod │ │ │ -0006f080: 653a 3a77 7269 7465 5f6e 6f64 6573 5f65 e::write_nodes_e │ │ │ -0006f090: 6e74 7269 6573 2873 6861 315f 6861 7368 ntries(sha1_hash │ │ │ -0006f0a0: 2063 6f6e 7374 2661 6d70 3b20 696e 666f const& info │ │ │ -0006f0b0: 5f68 6173 680a 3c2f 6469 763e 092c 2062 _hash.
    ., b │ │ │ -0006f0c0: 6465 636f 6465 5f6e 6f64 6520 636f 6e73 decode_node cons │ │ │ -0006f0d0: 7426 616d 703b 2077 616e 742c 2065 6e74 t& want, ent │ │ │ -0006f0e0: 7279 2661 6d70 3b20 7229 0a7b 0a09 2f2f ry& r).{..// │ │ │ -0006f0f0: 2069 6620 6e6f 2077 616e 7473 2065 6e74 if no wants ent │ │ │ -0006f100: 7279 2077 6173 2073 7065 6369 6669 6564 ry was specified │ │ │ -0006f110: 2c20 696e 636c 7564 6520 6120 6e6f 6465 , include a node │ │ │ -0006f120: 730a 092f 2f20 656e 7472 7920 6261 7365 s..// entry base │ │ │ -0006f130: 6420 6f6e 2074 6865 2070 726f 746f 636f d on the protoco │ │ │ -0006f140: 6c20 7468 6520 7265 7175 6573 7420 6361 l the request ca │ │ │ -0006f150: 6d65 2069 6e20 7769 7468 0a09 6966 2028 me in with..if ( │ │ │ -0006f160: 7761 6e74 2e74 7970 6528 2920 213d 2062 want.type() != b │ │ │ -0006f170: 6465 636f 6465 5f6e 6f64 653a 3a6c 6973 decode_node::lis │ │ │ -0006f180: 745f 7429 0a09 7b0a 0909 7374 643a 3a76 t_t)..{...std::v │ │ │ -0006f190: 6563 746f 7226 6c74 3b6e 6f64 655f 656e ector<node_en │ │ │ -0006f1a0: 7472 7926 6774 3b20 636f 6e73 7420 6e20 try> const n │ │ │ -0006f1b0: 3d20 6d5f 7461 626c 652e 6669 6e64 5f6e = m_table.find_n │ │ │ -0006f1c0: 6f64 6528 696e 666f 5f68 6173 682c 207b ode(info_hash, { │ │ │ -0006f1d0: 7d29 3b0a 0909 725b 7072 6f74 6f63 6f6c });...r[protocol │ │ │ -0006f1e0: 5f6e 6f64 6573 5f6b 6579 2829 5d20 3d20 _nodes_key()] = │ │ │ -0006f1f0: 7772 6974 655f 6e6f 6465 735f 656e 7472 write_nodes_entr │ │ │ -0006f200: 7928 6e29 3b0a 0909 7265 7475 726e 3b0a y(n);...return;. │ │ │ -0006f210: 097d 0a0a 092f 2f20 6966 2074 6865 7265 .}...// if there │ │ │ -0006f220: 2069 7320 6120 7761 6e74 7320 656e 7472 is a wants entr │ │ │ -0006f230: 7920 7468 656e 2077 6520 6d61 7920 6e65 y then we may ne │ │ │ -0006f240: 6564 2074 6f20 7265 6163 6820 696e 746f ed to reach into │ │ │ -0006f250: 0a09 2f2f 2061 6e6f 7468 6572 206e 6f64 ..// another nod │ │ │ -0006f260: 6527 7320 726f 7574 696e 6720 7461 626c e's routing tabl │ │ │ -0006f270: 6520 746f 2067 6574 206e 6f64 6573 206f e to get nodes o │ │ │ -0006f280: 6620 7468 6520 7265 7175 6573 7465 6420 f the requested │ │ │ -0006f290: 7479 7065 0a09 2f2f 2077 6520 7573 6520 type..// we use │ │ │ -0006f2a0: 6120 6d61 7020 6d61 696e 7461 696e 6564 a map maintained │ │ │ -0006f2b0: 2062 7920 7468 6520 6f77 6e69 6e67 2064 by the owning d │ │ │ -0006f2c0: 6874 5f74 7261 636b 6572 2074 6f20 6669 ht_tracker to fi │ │ │ -0006f2d0: 6e64 2074 6865 0a09 2f2f 206e 6f64 6520 nd the..// node │ │ │ -0006f2e0: 6173 736f 6369 6174 6564 2077 6974 6820 associated with │ │ │ -0006f2f0: 6561 6368 2073 7472 696e 6720 696e 2074 each string in t │ │ │ -0006f300: 6865 2077 616e 7420 6c69 7374 2c20 7768 he want list, wh │ │ │ -0006f310: 6963 6820 6d61 790a 092f 2f20 696e 636c ich may..// incl │ │ │ -0006f320: 7564 6520 7468 6973 206e 6f64 650a 0966 ude this node..f │ │ │ -0006f330: 6f72 2028 696e 7420 6920 3d20 303b 2069 or (int i = 0; i │ │ │ -0006f340: 2026 6c74 3b20 7761 6e74 2e6c 6973 745f < want.list_ │ │ │ -0006f350: 7369 7a65 2829 3b20 2b2b 6929 0a09 7b0a size(); ++i)..{. │ │ │ -0006f360: 0909 6264 6563 6f64 655f 6e6f 6465 2077 ..bdecode_node w │ │ │ -0006f370: 616e 7465 6420 3d20 7761 6e74 2e6c 6973 anted = want.lis │ │ │ -0006f380: 745f 6174 2869 293b 0a09 0969 6620 2877 t_at(i);...if (w │ │ │ -0006f390: 616e 7465 642e 7479 7065 2829 2021 3d20 anted.type() != │ │ │ -0006f3a0: 6264 6563 6f64 655f 6e6f 6465 3a3a 7374 bdecode_node::st │ │ │ -0006f3b0: 7269 6e67 5f74 290a 0909 0963 6f6e 7469 ring_t)....conti │ │ │ -0006f3c0: 6e75 653b 0a09 096e 6f64 652a 2077 616e nue;...node* wan │ │ │ -0006f3d0: 7465 645f 6e6f 6465 203d 206d 5f67 6574 ted_node = m_get │ │ │ -0006f3e0: 5f66 6f72 6569 676e 5f6e 6f64 6528 696e _foreign_node(in │ │ │ -0006f3f0: 666f 5f68 6173 682c 2077 616e 7465 642e fo_hash, wanted. │ │ │ -0006f400: 7374 7269 6e67 5f76 616c 7565 2829 293b string_value()); │ │ │ -0006f410: 0a09 0969 6620 2821 7761 6e74 6564 5f6e ...if (!wanted_n │ │ │ -0006f420: 6f64 6529 2063 6f6e 7469 6e75 653b 0a09 ode) continue;.. │ │ │ -0006f430: 0973 7464 3a3a 7665 6374 6f72 266c 743b .std::vector< │ │ │ -0006f440: 6e6f 6465 5f65 6e74 7279 2667 743b 2063 node_entry> c │ │ │ -0006f450: 6f6e 7374 206e 203d 2077 616e 7465 645f onst n = wanted_ │ │ │ -0006f460: 6e6f 6465 2d26 6774 3b6d 5f74 6162 6c65 node->m_table │ │ │ -0006f470: 2e66 696e 645f 6e6f 6465 2869 6e66 6f5f .find_node(info_ │ │ │ -0006f480: 6861 7368 2c20 7b7d 293b 0a09 0972 5b77 hash, {});...r[w │ │ │ -0006f490: 616e 7465 645f 6e6f 6465 2d26 6774 3b70 anted_node->p │ │ │ -0006f4a0: 726f 746f 636f 6c5f 6e6f 6465 735f 6b65 rotocol_nodes_ke │ │ │ -0006f4b0: 7928 295d 203d 2077 7269 7465 5f6e 6f64 y()] = write_nod │ │ │ -0006f4c0: 6573 5f65 6e74 7279 286e 293b 0a09 7d0a es_entry(n);..}. │ │ │ -0006f4d0: 7d0a 0a6e 6f64 653a 3a70 726f 746f 636f }..node::protoco │ │ │ -0006f4e0: 6c5f 6465 7363 7269 7074 6f72 2063 6f6e l_descriptor con │ │ │ -0006f4f0: 7374 2661 6d70 3b20 6e6f 6465 3a3a 6d61 st& node::ma │ │ │ -0006f500: 705f 7072 6f74 6f63 6f6c 5f74 6f5f 6465 p_protocol_to_de │ │ │ -0006f510: 7363 7269 7074 6f72 2875 6470 2063 6f6e scriptor(udp con │ │ │ -0006f520: 7374 2070 726f 746f 636f 6c29 0a7b 0a3c st protocol).{.< │ │ │ -0006f530: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0006f540: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0006f550: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0006f560: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0006f570: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../inc │ │ │ -0006f5a0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -0006f5b0: 6669 6c65 5f73 746f 7261 6765 2e68 7070 file_storage.hpp │ │ │ -0006f5c0: 3a37 3035 3c2f 613e 3c2f 7464 3e3c 7464 :705can we remove s │ │ │ -0006f5e0: 6574 5f6e 616d 653f 3c2f 7464 3e3c 2f74 et_name?

    can we rem │ │ │ -0006f640: 6f76 6520 7365 745f 6e61 6d65 3f3c 2f68 ove set_name?

    ../include │ │ │ -0006f660: 2f6c 6962 746f 7272 656e 742f 6669 6c65 /libtorrent/file │ │ │ -0006f670: 5f73 746f 7261 6765 2e68 7070 3a37 3035 _storage.hpp:705 │ │ │ -0006f680: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ -0006f6c0: 656e 6469 660a 0909 092c 2073 7464 3a3a  endif...., std::
    │ │ │ -0006f6d0: 696e 7436 345f 7420 636f 6e73 7420 6d74  int64_t const mt
    │ │ │ -0006f6e0: 696d 652c 2073 7472 696e 675f 7669 6577  ime, string_view
    │ │ │ -0006f6f0: 2063 6f6e 7374 2073 796d 6c69 6e6b 5f70   const symlink_p
    │ │ │ -0006f700: 6174 680a 0909 092c 2063 6861 7220 636f  ath...., char co
    │ │ │ -0006f710: 6e73 742a 2072 6f6f 745f 6861 7368 293b  nst* root_hash);
    │ │ │ -0006f720: 0a0a 0909 7374 643a 3a73 7472 696e 6720  ....std::string 
    │ │ │ -0006f730: 696e 7465 726e 616c 5f66 696c 655f 7061  internal_file_pa
    │ │ │ -0006f740: 7468 2866 696c 655f 696e 6465 785f 7420  th(file_index_t 
    │ │ │ -0006f750: 696e 6465 7829 2063 6f6e 7374 3b0a 0909  index) const;...
    │ │ │ -0006f760: 6669 6c65 5f69 6e64 6578 5f74 206c 6173  file_index_t las
    │ │ │ -0006f770: 745f 6669 6c65 2829 2063 6f6e 7374 206e  t_file() const n
    │ │ │ -0006f780: 6f65 7863 6570 743b 0a0a 0909 6175 783a  oexcept;....aux:
    │ │ │ -0006f790: 3a70 6174 685f 696e 6465 785f 7420 6765  :path_index_t ge
    │ │ │ -0006f7a0: 745f 6f72 5f61 6464 5f70 6174 6828 7374  t_or_add_path(st
    │ │ │ -0006f7b0: 7269 6e67 5f76 6965 7720 7061 7468 293b  ring_view path);
    │ │ │ -0006f7c0: 0a0a 0909 2f2f 2074 6865 206e 756d 6265  ....// the numbe
    │ │ │ -0006f7d0: 7220 6f66 2062 7974 6573 2069 6e20 6120  r of bytes in a 
    │ │ │ -0006f7e0: 7265 6775 6c61 7220 7069 6563 650a 0909  regular piece...
    │ │ │ -0006f7f0: 2f2f 2028 692e 652e 206e 6f74 2074 6865  // (i.e. not the
    │ │ │ -0006f800: 2070 6f74 656e 7469 616c 6c79 2074 7275   potentially tru
    │ │ │ -0006f810: 6e63 6174 6564 206c 6173 7420 7069 6563  ncated last piec
    │ │ │ -0006f820: 6529 0a09 0969 6e74 206d 5f70 6965 6365  e)...int m_piece
    │ │ │ -0006f830: 5f6c 656e 6774 6820 3d20 303b 0a0a 0909  _length = 0;....
    │ │ │ -0006f840: 2f2f 2074 6865 206e 756d 6265 7220 6f66  // the number of
    │ │ │ -0006f850: 2070 6965 6365 7320 696e 2074 6865 2074   pieces in the t
    │ │ │ -0006f860: 6f72 7265 6e74 0a09 0969 6e74 206d 5f6e  orrent...int m_n
    │ │ │ -0006f870: 756d 5f70 6965 6365 7320 3d20 303b 0a0a  um_pieces = 0;..
    │ │ │ -0006f880: 0909 2f2f 2077 6865 7468 6572 2074 6869  ..// whether thi
    │ │ │ -0006f890: 7320 6973 2061 2076 3220 746f 7272 656e  s is a v2 torren
    │ │ │ -0006f8a0: 7420 6f72 206e 6f74 2e20 4164 6469 7469  t or not. Additi
    │ │ │ -0006f8b0: 6f6e 616c 2072 6571 7569 7265 6d65 6e74  onal requirement
    │ │ │ -0006f8c0: 7320 6170 706c 7920 746f 0a09 092f 2f20  s apply to...// 
    │ │ │ -0006f8d0: 7632 2074 6f72 7265 6e74 730a 0909 626f  v2 torrents...bo
    │ │ │ -0006f8e0: 6f6c 206d 5f76 3220 3d20 6661 6c73 653b  ol m_v2 = false;
    │ │ │ -0006f8f0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0006f920: 0909 766f 6964 2075 7064 6174 655f 7061 ..void update_pa │ │ │ -0006f930: 7468 5f69 6e64 6578 2861 7578 3a3a 6669 th_index(aux::fi │ │ │ -0006f940: 6c65 5f65 6e74 7279 2661 6d70 3b20 652c le_entry& e, │ │ │ -0006f950: 2073 7464 3a3a 7374 7269 6e67 2063 6f6e std::string con │ │ │ -0006f960: 7374 2661 6d70 3b20 7061 7468 0a3c 2f64 st& path...., bool set │ │ │ -0006f980: 5f6e 616d 6520 3d20 7472 7565 293b 0a0a _name = true);.. │ │ │ -0006f990: 0909 2f2f 2074 6865 206c 6973 7420 6f66 ..// the list of │ │ │ -0006f9a0: 2066 696c 6573 2074 6861 7420 7468 6973 files that this │ │ │ -0006f9b0: 2074 6f72 7265 6e74 2063 6f6e 7369 7374 torrent consist │ │ │ -0006f9c0: 7320 6f66 0a09 0961 7578 3a3a 7665 6374 s of...aux::vect │ │ │ -0006f9d0: 6f72 266c 743b 6175 783a 3a66 696c 655f or<aux::file_ │ │ │ -0006f9e0: 656e 7472 792c 2066 696c 655f 696e 6465 entry, file_inde │ │ │ -0006f9f0: 785f 7426 6774 3b20 6d5f 6669 6c65 733b x_t> m_files; │ │ │ -0006fa00: 0a0a 2369 6620 544f 5252 454e 545f 4142 ..#if TORRENT_AB │ │ │ -0006fa10: 495f 5645 5253 494f 4e20 266c 743b 2034 I_VERSION < 4 │ │ │ -0006fa20: 0a09 092f 2f20 6966 2074 6865 7265 2061 ...// if there a │ │ │ -0006fa30: 7265 2073 6861 3120 6861 7368 6573 2066 re sha1 hashes f │ │ │ -0006fa40: 6f72 2065 6163 6820 696e 6469 7669 6475 or each individu │ │ │ -0006fa50: 616c 2066 696c 6520 7468 6572 6520 6172 al file there ar │ │ │ -0006fa60: 6520 6173 206d 616e 790a 0909 2f2f 2065 e as many...// e │ │ │ -0006fa70: 6e74 7269 6573 2069 6e20 7468 6973 2061 ntries in this a │ │ │ -0006fa80: 7272 6179 2061 7320 7468 6520 6d5f 6669 rray as the m_fi │ │ │ -0006fa90: 6c65 7320 6172 7261 792e 2045 6163 6820 les array. Each │ │ │ -0006faa0: 656e 7472 7920 696e 206d 5f66 696c 6573 entry in m_files │ │ │ -0006fab0: 2068 6173 0a09 092f 2f20 6120 636f 7272 has...// a corr │ │ │ -0006fac0: 6573 706f 6e64 696e 6720 6861 7368 2070 esponding hash p │ │ │ -0006fad0: 6f69 6e74 6572 2069 6e20 7468 6973 2061 ointer in this a │ │ │ -0006fae0: 7272 6179 2e20 5468 6520 7265 6173 6f6e rray. The reason │ │ │ -0006faf0: 2074 6f20 7370 6c69 7420 6974 2075 700a to split it up. │ │ │ -0006fb00: 0909 2f2f 2069 6e20 7365 7061 7261 7465 ..// in separate │ │ │ -0006fb10: 2061 7272 6179 7320 6973 2074 6f20 7361 arrays is to sa │ │ │ -0006fb20: 7665 206d 656d 6f72 7920 696e 2063 6173 ve memory in cas │ │ │ -0006fb30: 6520 7468 6520 746f 7272 656e 7420 646f e the torrent do │ │ │ -0006fb40: 6573 6e27 7420 6861 7665 0a09 092f 2f20 esn't have...// │ │ │ -0006fb50: 6669 6c65 2068 6173 6865 730a 0909 2f2f file hashes...// │ │ │ -0006fb60: 2074 6865 2070 6f69 6e74 6572 7320 696e the pointers in │ │ │ -0006fb70: 2074 6869 7320 7665 6374 6f72 2061 7265 this vector are │ │ │ -0006fb80: 2070 6f69 6e74 696e 6720 696e 746f 2074 pointing into t │ │ │ -0006fb90: 6865 202e 746f 7272 656e 7420 6669 6c65 he .torrent file │ │ │ -0006fba0: 2069 6e0a 0909 2f2f 206d 656d 6f72 7920 in...// memory │ │ │ -0006fbb0: 7768 6963 6820 6973 205f 6e6f 745f 206f which is _not_ o │ │ │ -0006fbc0: 776e 6564 2062 7920 7468 6973 2066 696c wned by this fil │ │ │ -0006fbd0: 655f 7374 6f72 6167 6520 6f62 6a65 6374 e_storage object │ │ │ -0006fbe0: 2e20 4974 2773 2073 696d 706c 790a 0909 . It's simply... │ │ │ -0006fbf0: 2f2f 2061 206e 6f6e 2d6f 776e 696e 6720 // a non-owning │ │ │ -0006fc00: 706f 696e 7465 722e 2049 7420 6973 2074 pointer. It is t │ │ │ -0006fc10: 6865 2075 7365 7227 7320 7265 7370 6f6e he user's respon │ │ │ -0006fc20: 7369 6269 6c69 7479 2074 6861 7420 7468 sibility that th │ │ │ -0006fc30: 6520 6861 7368 0a09 092f 2f20 7374 6179 e hash...// stay │ │ │ -0006fc40: 7320 7661 6c69 6420 7468 726f 7567 686f s valid througho │ │ │ -0006fc50: 7574 2074 6865 206c 6966 6574 696d 6520 ut the lifetime │ │ │ -0006fc60: 6f66 2074 6869 7320 6669 6c65 5f73 746f of this file_sto │ │ │ -0006fc70: 7261 6765 206f 626a 6563 742e 0a09 0961 rage object....a │ │ │ -0006fc80: 7578 3a3a 7665 6374 6f72 266c 743b 6368 ux::vector<ch │ │ │ -0006fc90: 6172 2063 6f6e 7374 2a2c 2066 696c 655f ar const*, file_ │ │ │ -0006fca0: 696e 6465 785f 7426 6774 3b20 6d5f 6669 index_t> m_fi │ │ │ -0006fcb0: 6c65 5f68 6173 6865 733b 0a23 656e 6469 le_hashes;.#endi │ │ │ -0006fcc0: 660a 0a09 092f 2f20 666f 7220 6669 6c65 f....// for file │ │ │ -0006fcd0: 7320 7468 6174 2061 7265 2073 796d 6c69 s that are symli │ │ │ -0006fce0: 6e6b 732c 2074 6865 2073 796d 6c69 6e6b nks, the symlink │ │ │ -0006fcf0: 0a09 092f 2f20 7061 7468 5f69 6e64 6578 ...// path_index │ │ │ -0006fd00: 2069 6e20 7468 6520 6175 783a 3a66 696c in the aux::fil │ │ │ -0006fd10: 655f 656e 7472 7920 696e 6465 7865 730a e_entry indexes. │ │ │ -0006fd20: 0909 2f2f 2074 6869 7320 7665 6374 6f72 ..// this vector │ │ │ -0006fd30: 206f 6620 7374 7269 6e67 730a 0909 7374 of strings...st │ │ │ -0006fd40: 643a 3a76 6563 746f 7226 6c74 3b73 7464 d::vector<std │ │ │ -0006fd50: 3a3a 7374 7269 6e67 2667 743b 206d 5f73 ::string> m_s │ │ │ -0006fd60: 796d 6c69 6e6b 733b 0a0a 0909 2f2f 2074 ymlinks;....// t │ │ │ -0006fd70: 6865 206d 6f64 6966 6963 6174 696f 6e20 he modification │ │ │ -0006fd80: 7469 6d65 7320 6f66 2065 6163 6820 6669 times of each fi │ │ │ -0006fd90: 6c65 2e20 5468 6973 2076 6563 746f 720a le. This vector. │ │ │ -0006fda0: 0909 2f2f 2069 7320 656d 7074 7920 6966 ..// is empty if │ │ │ -0006fdb0: 206e 6f20 6669 6c65 2068 6176 6520 6120 no file have a │ │ │ -0006fdc0: 6d6f 6469 6669 6361 7469 6f6e 2074 696d modification tim │ │ │ -0006fdd0: 652e 0a09 092f 2f20 6561 6368 2065 6c65 e....// each ele │ │ │ -0006fde0: 6d65 6e74 2063 6f72 7265 7370 6f6e 6473 ment corresponds │ │ │ -0006fdf0: 2074 6f20 7468 6520 6669 6c65 2077 6974 to the file wit │ │ │ -0006fe00: 6820 7468 6520 7361 6d65 0a09 092f 2f20 h the same...// │ │ │ -0006fe10: 696e 6465 7820 696e 206d 5f66 696c 6573 index in m_files │ │ │ -0006fe20: 0a09 0961 7578 3a3a 7665 6374 6f72 266c ...aux::vector&l │ │ │ -0006fe30: 743b 7374 643a 3a74 696d 655f 742c 2066 t;std::time_t, f │ │ │ -0006fe40: 696c 655f 696e 6465 785f 7426 6774 3b20 ile_index_t> │ │ │ -0006fe50: 6d5f 6d74 696d 653b 0a0a 0909 2f2f 2061 m_mtime;....// a │ │ │ -0006fe60: 6c6c 2075 6e69 7175 6520 7061 7468 7320 ll unique paths │ │ │ -0006fe70: 6669 6c65 7320 6861 7665 2e20 5468 6520 files have. The │ │ │ -0006fe80: 6175 783a 3a66 696c 655f 656e 7472 793a aux::file_entry: │ │ │ -0006fe90: 3a70 6174 685f 696e 6465 780a 3c2f 7072 :path_index.rel │ │ │ -0006fed0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -0006ff10: 652f 6c69 6274 6f72 7265 6e74 2f73 6f63 e/libtorrent/soc │ │ │ -0006ff20: 6b65 745f 7479 7065 2e68 7070 3a33 393c ket_type.hpp:39< │ │ │ -0006ff30: 2f61 3e3c 2f74 643e 3c74 643e 6d6f 7665 /a>move │ │ │ -0006ff40: 2074 6f20 6175 783c 2f74 643e 3c2f 7472 to aux

    move to aux │ │ │ -0006ffa0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -0006ffb0: 7564 652f 6c69 6274 6f72 7265 6e74 2f73 ude/libtorrent/s │ │ │ -0006ffc0: 6f63 6b65 745f 7479 7065 2e68 7070 3a33 ocket_type.hpp:3 │ │ │ -0006ffd0: 393c 2f68 343e 3c70 7265 2073 7479 6c65 9

    │ │ │ -00070010: 0a2f 2f20 4120 7479 7065 2064 6573 6372  .// A type descr
    │ │ │ -00070020: 6962 696e 6720 6b69 6e64 7320 6f66 2073  ibing kinds of s
    │ │ │ -00070030: 6f63 6b65 7473 2069 6e76 6f6c 7665 6420  ockets involved 
    │ │ │ -00070040: 696e 2076 6172 696f 7573 206f 7065 7261  in various opera
    │ │ │ -00070050: 7469 6f6e 7320 6f72 2065 7665 6e74 732e  tions or events.
    │ │ │ -00070060: 0a65 6e75 6d20 636c 6173 7320 736f 636b  .enum class sock
    │ │ │ -00070070: 6574 5f74 7970 655f 7420 3a20 7374 643a  et_type_t : std:
    │ │ │ -00070080: 3a75 696e 7438 5f74 207b 0a09 7463 702c  :uint8_t {..tcp,
    │ │ │ -00070090: 0a09 736f 636b 7335 2c0a 0968 7474 702c  ..socks5,..http,
    │ │ │ -000700a0: 0a09 7574 702c 0a09 6932 702c 0a09 7274  ..utp,..i2p,..rt
    │ │ │ -000700b0: 632c 0a09 7463 705f 7373 6c2c 0a09 736f  c,..tcp_ssl,..so
    │ │ │ -000700c0: 636b 7335 5f73 736c 2c0a 0968 7474 705f  cks5_ssl,..http_
    │ │ │ -000700d0: 7373 6c2c 0a09 7574 705f 7373 6c2c 0a0a  ssl,..utp_ssl,..
    │ │ │ -000700e0: 2369 6620 544f 5252 454e 545f 4142 495f  #if TORRENT_ABI_
    │ │ │ -000700f0: 5645 5253 494f 4e20 266c 743b 3d20 320a  VERSION <= 2.
    │ │ │ -00070100: 0975 6470 2054 4f52 5245 4e54 5f44 4550  .udp TORRENT_DEP
    │ │ │ -00070110: 5245 4341 5445 445f 454e 554d 203d 2075  RECATED_ENUM = u
    │ │ │ -00070120: 7470 2c0a 2365 6e64 6966 0a7d 3b0a 0a2f  tp,.#endif.};../
    │ │ │ -00070130: 2f20 7265 7475 726e 2061 2073 686f 7274  / return a short
    │ │ │ -00070140: 2068 756d 616e 2072 6561 6461 626c 6520   human readable 
    │ │ │ -00070150: 6e61 6d65 2066 6f72 2074 7970 6573 206f  name for types o
    │ │ │ -00070160: 6620 736f 636b 6574 0a3c 6469 7620 7374  f socket.
    char cons │ │ │ -000701a0: 742a 2073 6f63 6b65 745f 7479 7065 5f6e t* socket_type_n │ │ │ -000701b0: 616d 6528 736f 636b 6574 5f74 7970 655f ame(socket_type_ │ │ │ -000701c0: 7429 3b0a 3c2f 6469 763e 0a7d 0a0a 2365 t);.
    .}..#e │ │ │ -000701d0: 6e64 6966 0a3c 2f70 7265 3e3c 2f74 643e ndif.
    │ │ │ -000701e0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00070210: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00070220: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00070230: 7074 3a65 7870 616e 6428 3235 3829 223e pt:expand(258)"> │ │ │ -00070240: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00070250: 7272 656e 742f 7065 7266 6f72 6d61 6e63 rrent/performanc │ │ │ -00070260: 655f 636f 756e 7465 7273 2e68 7070 3a35 e_counters.hpp:5 │ │ │ -00070270: 3230 3c2f 613e 3c2f 7464 3e3c 7464 3e73 20
    s │ │ │ -00070280: 6f6d 6520 7370 6163 6520 636f 756c 6420 ome space could │ │ │ -00070290: 6265 2073 6176 6564 2068 6572 6520 6279 be saved here by │ │ │ -000702a0: 206d 616b 696e 6720 6761 7567 6573 2033 making gauges 3 │ │ │ -000702b0: 3220 6269 7473 3c2f 7464 3e3c 2f74 723e 2 bits │ │ │ -000702c0: 3c74 7220 6964 3d22 3235 3822 2073 7479 │ │ │ -000702f0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00070300: 3c68 323e 736f 6d65 2073 7061 6365 2063

    some space c │ │ │ -00070310: 6f75 6c64 2062 6520 7361 7665 6420 6865 ould be saved he │ │ │ -00070320: 7265 2062 7920 6d61 6b69 6e67 2067 6175 re by making gau │ │ │ -00070330: 6765 7320 3332 2062 6974 733c 2f68 323e ges 32 bits

    │ │ │ -00070340: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00070350: 6962 746f 7272 656e 742f 7065 7266 6f72 ibtorrent/perfor │ │ │ -00070360: 6d61 6e63 655f 636f 756e 7465 7273 2e68 mance_counters.h │ │ │ -00070370: 7070 3a35 3230 3c2f 6834 3e3c 7072 6520 pp:520

    
    │ │ │ -000703c0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -000703f0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -00070400: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -00070410: 7074 3a65 7870 616e 6428 3235 3929 223e  pt:expand(259)">
    │ │ │ -00070420: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f  ../include/libto
    │ │ │ -00070430: 7272 656e 742f 7065 7266 6f72 6d61 6e63  rrent/performanc
    │ │ │ -00070440: 655f 636f 756e 7465 7273 2e68 7070 3a35  e_counters.hpp:5
    │ │ │ -00070450: 3231 3c2f 613e 3c2f 7464 3e3c 7464 3e72  21r
    │ │ │ -00070460: 6573 746f 7265 2074 6865 7365 2074 6f20  estore these to 
    │ │ │ -00070470: 7265 6775 6c61 7220 696e 7465 6765 7273  regular integers
    │ │ │ -00070480: 2e20 496e 7374 6561 6420 6861 7665 206f  . Instead have o
    │ │ │ -00070490: 6e65 2063 6f70 7920 6f66 2074 6865 2063  ne copy of the c
    │ │ │ -000704a0: 6f75 6e74 6572 7320 7065 7220 7468 7265  ounters per thre
    │ │ │ -000704b0: 6164 2061 6e64 2063 6f6c 6c65 6374 2074  ad and collect t
    │ │ │ -000704c0: 6865 6d20 6174 2063 6f6e 7665 6e69 656e  hem at convenien
    │ │ │ -000704d0: 7420 7379 6e63 6872 6f6e 697a 6174 696f  t synchronizatio
    │ │ │ -000704e0: 6e20 706f 696e 7473 3c2f 7464 3e3c 2f74  n points

    restore th │ │ │ -00070540: 6573 6520 746f 2072 6567 756c 6172 2069 ese to regular i │ │ │ -00070550: 6e74 6567 6572 732e 2049 6e73 7465 6164 ntegers. Instead │ │ │ -00070560: 2068 6176 6520 6f6e 6520 636f 7079 0a6f have one copy.o │ │ │ -00070570: 6620 7468 6520 636f 756e 7465 7273 2070 f the counters p │ │ │ -00070580: 6572 2074 6872 6561 6420 616e 6420 636f er thread and co │ │ │ -00070590: 6c6c 6563 7420 7468 656d 2061 7420 636f llect them at co │ │ │ -000705a0: 6e76 656e 6965 6e74 0a73 796e 6368 726f nvenient.synchro │ │ │ -000705b0: 6e69 7a61 7469 6f6e 2070 6f69 6e74 733c nization points< │ │ │ -000705c0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -000705d0: 6465 2f6c 6962 746f 7272 656e 742f 7065 de/libtorrent/pe │ │ │ -000705e0: 7266 6f72 6d61 6e63 655f 636f 756e 7465 rformance_counte │ │ │ -000705f0: 7273 2e68 7070 3a35 3231 3c2f 6834 3e3c rs.hpp:521

    < │ │ │ -00070600: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00070610: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00070620: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00070630: 7820 2364 6464 3b22 3e09 0963 6f75 6e74 x #ddd;">..count │ │ │ -00070640: 6572 7328 636f 756e 7465 7273 2063 6f6e ers(counters con │ │ │ -00070650: 7374 2661 6d70 3b29 2054 4f52 5245 4e54 st&) TORRENT │ │ │ -00070660: 5f43 4f55 4e54 4552 5f4e 4f45 5843 4550 _COUNTER_NOEXCEP │ │ │ -00070670: 543b 0a09 0963 6f75 6e74 6572 7326 616d T;...counters&am │ │ │ -00070680: 703b 206f 7065 7261 746f 723d 2863 6f75 p; operator=(cou │ │ │ -00070690: 6e74 6572 7320 636f 6e73 7426 616d 703b nters const& │ │ │ -000706a0: 2920 2661 6d70 3b20 544f 5252 454e 545f ) & TORRENT_ │ │ │ -000706b0: 434f 554e 5445 525f 4e4f 4558 4345 5054 COUNTER_NOEXCEPT │ │ │ -000706c0: 3b0a 0a09 092f 2f20 696e 6372 656d 656e ;....// incremen │ │ │ -000706d0: 7473 2074 6865 2063 6f75 6e74 6572 206f ts the counter o │ │ │ -000706e0: 7220 6761 7567 6520 6060 6360 6020 2861 r gauge ``c`` (a │ │ │ -000706f0: 6e20 696e 6465 7820 696e 746f 2074 6865 n index into the │ │ │ -00070700: 2063 6f75 6e74 6572 0a09 092f 2f20 6172 counter...// ar │ │ │ -00070710: 7261 7929 2062 7920 6060 7661 6c75 6560 ray) by ``value` │ │ │ -00070720: 6020 616e 6420 7265 7475 726e 7320 7468 ` and returns th │ │ │ -00070730: 6520 6e65 7720 7661 6c75 652e 0a09 0973 e new value....s │ │ │ -00070740: 7464 3a3a 696e 7436 345f 7420 696e 635f td::int64_t inc_ │ │ │ -00070750: 7374 6174 735f 636f 756e 7465 7228 696e stats_counter(in │ │ │ -00070760: 7420 632c 2073 7464 3a3a 696e 7436 345f t c, std::int64_ │ │ │ -00070770: 7420 7661 6c75 6520 3d20 3129 2054 4f52 t value = 1) TOR │ │ │ -00070780: 5245 4e54 5f43 4f55 4e54 4552 5f4e 4f45 RENT_COUNTER_NOE │ │ │ -00070790: 5843 4550 543b 0a0a 0909 2f2f 2072 6574 XCEPT;....// ret │ │ │ -000707a0: 7572 6e73 2074 6865 2063 7572 7265 6e74 urns the current │ │ │ -000707b0: 2076 616c 7565 206f 6620 636f 756e 7465 value of counte │ │ │ -000707c0: 7220 6f72 2067 6175 6765 2060 6069 6060 r or gauge ``i`` │ │ │ -000707d0: 2028 616e 2069 6e64 6578 2069 6e74 6f0a (an index into. │ │ │ -000707e0: 0909 2f2f 2074 6865 2063 6f75 6e74 6572 ..// the counter │ │ │ -000707f0: 2061 7272 6179 292e 0a09 0973 7464 3a3a array)....std:: │ │ │ -00070800: 696e 7436 345f 7420 6f70 6572 6174 6f72 int64_t operator │ │ │ -00070810: 5b5d 2869 6e74 2069 2920 636f 6e73 7420 [](int i) const │ │ │ -00070820: 544f 5252 454e 545f 434f 554e 5445 525f TORRENT_COUNTER_ │ │ │ -00070830: 4e4f 4558 4345 5054 3b0a 0a09 092f 2f20 NOEXCEPT;....// │ │ │ -00070840: 6f76 6572 7772 6974 6573 2074 6865 2076 overwrites the v │ │ │ -00070850: 616c 7565 206f 6620 636f 756e 7465 7220 alue of counter │ │ │ -00070860: 6f72 2067 6175 6765 2060 6063 6060 2028 or gauge ``c`` ( │ │ │ -00070870: 616e 2069 6e64 6578 2069 6e74 6f0a 0909 an index into... │ │ │ -00070880: 2f2f 2074 6865 2063 6f75 6e74 6572 2061 // the counter a │ │ │ -00070890: 7272 6179 292e 2060 6062 6c65 6e64 5f73 rray). ``blend_s │ │ │ -000708a0: 7461 7473 5f63 6f75 6e74 6572 2829 6060 tats_counter()`` │ │ │ -000708b0: 2061 646a 7573 7473 2074 6865 2073 7461 adjusts the sta │ │ │ -000708c0: 7420 7661 6c75 650a 0909 2f2f 2074 6f77 t value...// tow │ │ │ -000708d0: 6172 6420 7468 6520 7370 6563 6966 6965 ard the specifie │ │ │ -000708e0: 6420 6060 7661 6c75 6560 602c 2060 6072 d ``value``, ``r │ │ │ -000708f0: 6174 696f 6060 2073 7065 6369 6669 6573 atio`` specifies │ │ │ -00070900: 2074 6865 2070 6572 6365 6e74 206f 660a the percent of. │ │ │ -00070910: 0909 2f2f 2074 6865 206e 6577 2076 616c ..// the new val │ │ │ -00070920: 7565 2073 686f 756c 6420 6265 2069 6e66 ue should be inf │ │ │ -00070930: 6c75 656e 6365 6420 6279 2060 6076 616c luenced by ``val │ │ │ -00070940: 7565 6060 2e0a 0909 766f 6964 2073 6574 ue``....void set │ │ │ -00070950: 5f76 616c 7565 2869 6e74 2063 2c20 7374 _value(int c, st │ │ │ -00070960: 643a 3a69 6e74 3634 5f74 2076 616c 7565 d::int64_t value │ │ │ -00070970: 2920 544f 5252 454e 545f 434f 554e 5445 ) TORRENT_COUNTE │ │ │ -00070980: 525f 4e4f 4558 4345 5054 3b0a 0909 766f R_NOEXCEPT;...vo │ │ │ -00070990: 6964 2062 6c65 6e64 5f73 7461 7473 5f63 id blend_stats_c │ │ │ -000709a0: 6f75 6e74 6572 2869 6e74 2063 2c20 7374 ounter(int c, st │ │ │ -000709b0: 643a 3a69 6e74 3634 5f74 2076 616c 7565 d::int64_t value │ │ │ -000709c0: 2c20 696e 7420 7261 7469 6f29 2054 4f52 , int ratio) TOR │ │ │ -000709d0: 5245 4e54 5f43 4f55 4e54 4552 5f4e 4f45 RENT_COUNTER_NOE │ │ │ -000709e0: 5843 4550 543b 0a0a 0970 7269 7661 7465 XCEPT;...private │ │ │ -000709f0: 3a0a 0a3c 6469 7620 7374 796c 653d 2262 :..
    #ifdef ATOMIC_L │ │ │ -00070a30: 4c4f 4e47 5f4c 4f43 4b5f 4652 4545 0a3c LONG_LOCK_FREE.< │ │ │ -00070a40: 2f64 6976 3e09 0961 7578 3a3a 6172 7261 /div>..aux::arra │ │ │ -00070a50: 7926 6c74 3b73 7464 3a3a 6174 6f6d 6963 y<std::atomic │ │ │ -00070a60: 266c 743b 7374 643a 3a69 6e74 3634 5f74 <std::int64_t │ │ │ -00070a70: 2667 743b 2c20 6e75 6d5f 636f 756e 7465 >, num_counte │ │ │ -00070a80: 7273 2667 743b 206d 5f73 7461 7473 5f63 rs> m_stats_c │ │ │ -00070a90: 6f75 6e74 6572 3b0a 2365 6c73 650a 0909 ounter;.#else... │ │ │ -00070aa0: 2f2f 2069 6620 7468 6520 6174 6f6d 6963 // if the atomic │ │ │ -00070ab0: 2074 7970 6520 6973 6e27 7420 6c6f 636b type isn't lock │ │ │ -00070ac0: 2d66 7265 652c 2075 7365 2061 2073 696e -free, use a sin │ │ │ -00070ad0: 676c 6520 6c6f 636b 2069 6e73 7465 6164 gle lock instead │ │ │ -00070ae0: 2c20 666f 720a 0909 2f2f 2074 6865 2077 , for...// the w │ │ │ -00070af0: 686f 6c65 2061 7272 6179 0a09 096d 7574 hole array...mut │ │ │ -00070b00: 6162 6c65 2073 7464 3a3a 6d75 7465 7820 able std::mutex │ │ │ -00070b10: 6d5f 6d75 7465 783b 0a09 0961 7578 3a3a m_mutex;...aux:: │ │ │ -00070b20: 6172 7261 7926 6c74 3b73 7464 3a3a 696e array<std::in │ │ │ -00070b30: 7436 345f 742c 206e 756d 5f63 6f75 6e74 t64_t, num_count │ │ │ -00070b40: 6572 7326 6774 3b20 6d5f 7374 6174 735f ers> m_stats_ │ │ │ -00070b50: 636f 756e 7465 723b 0a23 656e 6469 660a counter;.#endif. │ │ │ -00070b60: 097d 3b0a 7d0a 0a23 656e 6469 660a 3c2f .};.}..#endif.r │ │ │ -00070ba0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00070bb0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -00070be0: 7564 652f 6c69 6274 6f72 7265 6e74 2f75 ude/libtorrent/u │ │ │ -00070bf0: 706e 702e 6870 703a 3134 323c 2f61 3e3c pnp.hpp:142< │ │ │ -00070c00: 2f74 643e 3c74 643e 7375 7070 6f72 7420 /td>support │ │ │ -00070c10: 7573 696e 6720 7468 6520 7769 6e64 6f77 using the window │ │ │ -00070c20: 7320 4150 4920 666f 7220 5550 6e50 206f s API for UPnP o │ │ │ -00070c30: 7065 7261 7469 6f6e 7320 6173 2077 656c perations as wel │ │ │ -00070c40: 6c3c 2f74 643e 3c2f 7472 3e3c 7472 2069 l

    s │ │ │ -00070c90: 7570 706f 7274 2075 7369 6e67 2074 6865 upport using the │ │ │ -00070ca0: 2077 696e 646f 7773 2041 5049 2066 6f72 windows API for │ │ │ -00070cb0: 2055 506e 5020 6f70 6572 6174 696f 6e73 UPnP operations │ │ │ -00070cc0: 2061 7320 7765 6c6c 3c2f 6832 3e3c 6834 as well

    ../include/libt │ │ │ -00070ce0: 6f72 7265 6e74 2f75 706e 702e 6870 703a orrent/upnp.hpp: │ │ │ -00070cf0: 3134 323c 2f68 343e 3c70 7265 2073 7479 142

    {..bool in_err
    │ │ │ -00070d40: 6f72 5f63 6f64 6520 3d20 6661 6c73 653b  or_code = false;
    │ │ │ -00070d50: 0a09 626f 6f6c 2065 7869 7420 3d20 6661  ..bool exit = fa
    │ │ │ -00070d60: 6c73 653b 0a09 696e 7420 6572 726f 725f  lse;..int error_
    │ │ │ -00070d70: 636f 6465 203d 202d 313b 0a7d 3b0a 0a73  code = -1;.};..s
    │ │ │ -00070d80: 7472 7563 7420 6970 5f61 6464 7265 7373  truct ip_address
    │ │ │ -00070d90: 5f70 6172 7365 5f73 7461 7465 3a20 6572  _parse_state: er
    │ │ │ -00070da0: 726f 725f 636f 6465 5f70 6172 7365 5f73  ror_code_parse_s
    │ │ │ -00070db0: 7461 7465 0a7b 0a09 626f 6f6c 2069 6e5f  tate.{..bool in_
    │ │ │ -00070dc0: 6970 5f61 6464 7265 7373 203d 2066 616c  ip_address = fal
    │ │ │ -00070dd0: 7365 3b0a 0973 7464 3a3a 7374 7269 6e67  se;..std::string
    │ │ │ -00070de0: 2069 705f 6164 6472 6573 733b 0a7d 3b0a   ip_address;.};.
    │ │ │ -00070df0: 0a54 4f52 5245 4e54 5f45 5854 5241 5f45  .TORRENT_EXTRA_E
    │ │ │ -00070e00: 5850 4f52 5420 766f 6964 2066 696e 645f  XPORT void find_
    │ │ │ -00070e10: 636f 6e74 726f 6c5f 7572 6c28 696e 7420  control_url(int 
    │ │ │ -00070e20: 7479 7065 2c20 7374 7269 6e67 5f76 6965  type, string_vie
    │ │ │ -00070e30: 772c 2070 6172 7365 5f73 7461 7465 2661  w, parse_state&a
    │ │ │ -00070e40: 6d70 3b20 7374 6174 6529 3b0a 0a54 4f52  mp; state);..TOR
    │ │ │ -00070e50: 5245 4e54 5f45 5854 5241 5f45 5850 4f52  RENT_EXTRA_EXPOR
    │ │ │ -00070e60: 5420 766f 6964 2066 696e 645f 6572 726f  T void find_erro
    │ │ │ -00070e70: 725f 636f 6465 2869 6e74 2074 7970 652c  r_code(int type,
    │ │ │ -00070e80: 2073 7472 696e 675f 7669 6577 2073 7472   string_view str
    │ │ │ -00070e90: 696e 670a 092c 2065 7272 6f72 5f63 6f64  ing.., error_cod
    │ │ │ -00070ea0: 655f 7061 7273 655f 7374 6174 6526 616d  e_parse_state&am
    │ │ │ -00070eb0: 703b 2073 7461 7465 293b 0a0a 544f 5252  p; state);..TORR
    │ │ │ -00070ec0: 454e 545f 4558 5452 415f 4558 504f 5254  ENT_EXTRA_EXPORT
    │ │ │ -00070ed0: 2076 6f69 6420 6669 6e64 5f69 705f 6164   void find_ip_ad
    │ │ │ -00070ee0: 6472 6573 7328 696e 7420 7479 7065 2c20  dress(int type, 
    │ │ │ -00070ef0: 7374 7269 6e67 5f76 6965 7720 7374 7269  string_view stri
    │ │ │ -00070f00: 6e67 0a09 2c20 6970 5f61 6464 7265 7373  ng.., ip_address
    │ │ │ -00070f10: 5f70 6172 7365 5f73 7461 7465 2661 6d70  _parse_state&
    │ │ │ -00070f20: 3b20 7374 6174 6529 3b0a 0a3c 6469 7620  ; state);..
    struct │ │ │ -00070f60: 544f 5252 454e 545f 4558 5452 415f 4558 TORRENT_EXTRA_EX │ │ │ -00070f70: 504f 5254 2075 706e 7020 6669 6e61 6c0a PORT upnp final. │ │ │ -00070f80: 3c2f 6469 763e 093a 2073 7464 3a3a 656e
    .: std::en │ │ │ -00070f90: 6162 6c65 5f73 6861 7265 645f 6672 6f6d able_shared_from │ │ │ -00070fa0: 5f74 6869 7326 6c74 3b75 706e 7026 6774 _this<upnp> │ │ │ -00070fb0: 3b0a 092c 2061 7578 3a3a 7369 6e67 6c65 ;.., aux::single │ │ │ -00070fc0: 5f74 6872 6561 6465 640a 7b0a 0975 706e _threaded.{..upn │ │ │ -00070fd0: 7028 696f 5f63 6f6e 7465 7874 2661 6d70 p(io_context& │ │ │ -00070fe0: 3b20 696f 730a 0909 2c20 6175 783a 3a73 ; ios..., aux::s │ │ │ -00070ff0: 6573 7369 6f6e 5f73 6574 7469 6e67 7320 ession_settings │ │ │ -00071000: 636f 6e73 7426 616d 703b 2073 6574 7469 const& setti │ │ │ -00071010: 6e67 730a 0909 2c20 6175 783a 3a70 6f72 ngs..., aux::por │ │ │ -00071020: 746d 6170 5f63 616c 6c62 6163 6b26 616d tmap_callback&am │ │ │ -00071030: 703b 2063 620a 0909 2c20 6164 6472 6573 p; cb..., addres │ │ │ -00071040: 735f 7634 206c 6973 7465 6e5f 6164 6472 s_v4 listen_addr │ │ │ -00071050: 6573 730a 0909 2c20 6164 6472 6573 735f ess..., address_ │ │ │ -00071060: 7634 206e 6574 6d61 736b 0a09 092c 2073 v4 netmask..., s │ │ │ -00071070: 7464 3a3a 7374 7269 6e67 206c 6973 7465 td::string liste │ │ │ -00071080: 6e5f 6465 7669 6365 0a09 092c 2061 7578 n_device..., aux │ │ │ -00071090: 3a3a 6c69 7374 656e 5f73 6f63 6b65 745f ::listen_socket_ │ │ │ -000710a0: 6861 6e64 6c65 206c 7329 3b0a 097e 7570 handle ls);..~up │ │ │ -000710b0: 6e70 2829 3b0a 0a09 766f 6964 2073 7461 np();...void sta │ │ │ -000710c0: 7274 2829 3b0a 0a09 2f2f 2041 7474 656d rt();...// Attem │ │ │ -000710d0: 7074 7320 746f 2061 6464 2061 2070 6f72 pts to add a por │ │ │ -000710e0: 7420 6d61 7070 696e 6720 666f 7220 7468 t mapping for th │ │ │ -000710f0: 6520 7370 6563 6966 6965 6420 7072 6f74 e specified prot │ │ │ -00071100: 6f63 6f6c 2e20 5661 6c69 6420 7072 6f74 ocol. Valid prot │ │ │ -00071110: 6f63 6f6c 7320 6172 650a 092f 2f20 6060 ocols are..// `` │ │ │ -00071120: 7570 6e70 3a3a 7463 7060 6020 616e 6420 upnp::tcp`` and │ │ │ -00071130: 6060 7570 6e70 3a3a 7564 7060 6020 666f ``upnp::udp`` fo │ │ │ -00071140: 7220 7468 6520 5550 6e50 2063 6c61 7373 r the UPnP class │ │ │ -00071150: 2061 6e64 2060 606e 6174 706d 703a 3a74 and ``natpmp::t │ │ │ -00071160: 6370 6060 2061 6e64 0a09 2f2f 2060 606e cp`` and..// ``n │ │ │ -00071170: 6174 706d 703a 3a75 6470 6060 2066 6f72 atpmp::udp`` for │ │ │ -00071180: 2074 6865 204e 4154 2d50 4d50 2063 6c61 the NAT-PMP cla │ │ │ -00071190: 7373 2e0a 092f 2f0a 092f 2f20 6060 6578 ss...//..// ``ex │ │ │ -000711a0: 7465 726e 616c 5f70 6f72 7460 6020 6973 ternal_port`` is │ │ │ -000711b0: 2074 6865 2070 6f72 7420 6f6e 2074 6865 the port on the │ │ │ -000711c0: 2065 7874 6572 6e61 6c20 6164 6472 6573 external addres │ │ │ -000711d0: 7320 7468 6174 2077 696c 6c20 6265 206d s that will be m │ │ │ -000711e0: 6170 7065 642e 2054 6869 730a 092f 2f20 apped. This..// │ │ │ -000711f0: 6973 2061 2068 696e 742c 2079 6f75 2061 is a hint, you a │ │ │ -00071200: 7265 206e 6f74 2067 7561 7261 6e74 6565 re not guarantee │ │ │ -00071210: 6420 7468 6174 2074 6869 7320 706f 7274 d that this port │ │ │ -00071220: 2077 696c 6c20 6265 2061 7661 696c 6162 will be availab │ │ │ -00071230: 6c65 2c20 616e 6420 6974 206d 6179 0a09 le, and it may.. │ │ │ -00071240: 2f2f 2065 6e64 2075 7020 6265 696e 6720 // end up being │ │ │ -00071250: 736f 6d65 7468 696e 6720 656c 7365 2e20 something else. │ │ │ -00071260: 496e 2074 6865 2070 6f72 746d 6170 5f61 In the portmap_a │ │ │ -00071270: 6c65 7274 5f20 6e6f 7469 6669 6361 7469 lert_ notificati │ │ │ -00071280: 6f6e 2c20 7468 6520 6163 7475 616c 0a09 on, the actual.. │ │ │ -00071290: 2f2f 2065 7874 6572 6e61 6c20 706f 7274 // external port │ │ │ -000712a0: 2069 7320 7265 706f 7274 6564 2e0a 092f is reported.../ │ │ │ -000712b0: 2f0a 092f 2f20 6060 6c6f 6361 6c5f 706f /..// ``local_po │ │ │ -000712c0: 7274 6060 2069 7320 7468 6520 706f 7274 rt`` is the port │ │ │ -000712d0: 2069 6e20 7468 6520 6c6f 6361 6c20 6d61 in the local ma │ │ │ -000712e0: 6368 696e 6520 7468 6174 2074 6865 206d chine that the m │ │ │ -000712f0: 6170 7069 6e67 2073 686f 756c 6420 666f apping should fo │ │ │ -00071300: 7277 6172 640a 092f 2f20 746f 2e0a 092f rward..// to.../ │ │ │ -00071310: 2f0a 092f 2f20 5468 6520 7265 7475 726e /..// The return │ │ │ -00071320: 2076 616c 7565 2069 7320 616e 2069 6e64 value is an ind │ │ │ -00071330: 6578 2074 6861 7420 6964 656e 7469 6669 ex that identifi │ │ │ -00071340: 6573 2074 6869 7320 706f 7274 206d 6170 es this port map │ │ │ -00071350: 7069 6e67 2e20 5468 6973 2069 7320 7573 ping. This is us │ │ │ -00071360: 6564 0a09 2f2f 2074 6f20 7265 6665 7220 ed..// to refer │ │ │ -00071370: 746f 206d 6170 7069 6e67 7320 7468 6174 to mappings that │ │ │ -00071380: 2066 6169 6c73 206f 7220 7375 6363 6565 fails or succee │ │ │ -00071390: 6473 2069 6e20 7468 6520 706f 7274 6d61 ds in the portma │ │ │ -000713a0: 705f 6572 726f 725f 616c 6572 745f 2061 p_error_alert_ a │ │ │ -000713b0: 6e64 0a09 2f2f 2070 6f72 746d 6170 5f61 nd..// portmap_a │ │ │ -000713c0: 6c65 7274 5f20 7265 7370 6563 7469 7665 lert_ respective │ │ │ -000713d0: 6c79 2e20 4966 2054 6865 206d 6170 7069 ly. If The mappi │ │ │ -000713e0: 6e67 2066 6169 6c73 2069 6d6d 6564 6961 ng fails immedia │ │ │ -000713f0: 7465 6c79 2c20 7468 6520 7265 7475 726e tely, the return │ │ │ -00071400: 2076 616c 7565 0a09 2f2f 2069 7320 2d31 value..// is -1 │ │ │ -00071410: 2c20 7768 6963 6820 6d65 616e 7320 6661 , which means fa │ │ │ -00071420: 696c 7572 652e 2054 6865 7265 2077 696c ilure. There wil │ │ │ -00071430: 6c20 6e6f 7420 6265 2061 6e79 2065 7272 l not be any err │ │ │ -00071440: 6f72 2061 6c65 7274 206e 6f74 6966 6963 or alert notific │ │ │ -00071450: 6174 696f 6e20 666f 720a 3c2f 7072 653e ation for.
    │ │ │ -00071460: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00071490: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -000714a0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -000714d0: 6c69 6274 6f72 7265 6e74 2f69 6465 6e74 libtorrent/ident │ │ │ -000714e0: 6966 795f 636c 6965 6e74 2e68 7070 3a32 ify_client.hpp:2 │ │ │ -000714f0: 333c 2f61 3e3c 2f74 643e 3c74 643e 6869 3hi │ │ │ -00071500: 6465 2074 6869 7320 6465 636c 6172 6174 de this declarat │ │ │ -00071510: 696f 6e20 7768 656e 2064 6570 7265 6361 ion when depreca │ │ │ -00071520: 7465 6420 6675 6e63 7469 6f6e 7320 6172 ted functions ar │ │ │ -00071530: 6520 6469 7361 626c 6564 2c20 616e 6420 e disabled, and │ │ │ -00071540: 7265 6d6f 7665 2069 7473 2069 6e74 6572 remove its inter │ │ │ -00071550: 6e61 6c20 7573 653c 2f74 643e 3c2f 7472 nal use

    hide this d │ │ │ -000715b0: 6563 6c61 7261 7469 6f6e 2077 6865 6e20 eclaration when │ │ │ -000715c0: 6465 7072 6563 6174 6564 2066 756e 6374 deprecated funct │ │ │ -000715d0: 696f 6e73 2061 7265 2064 6973 6162 6c65 ions are disable │ │ │ -000715e0: 642c 2061 6e64 0a72 656d 6f76 6520 6974 d, and.remove it │ │ │ -000715f0: 7320 696e 7465 726e 616c 2075 7365 3c2f s internal use

    ../includ │ │ │ -00071610: 652f 6c69 6274 6f72 7265 6e74 2f69 6465 e/libtorrent/ide │ │ │ -00071620: 6e74 6966 795f 636c 6965 6e74 2e68 7070 ntify_client.hpp │ │ │ -00071630: 3a32 333c 2f68 343e 3c70 7265 2073 7479 :23

    Copyright (c) 
    │ │ │ -00071680: 3230 3033 2c20 3230 3036 2c20 3230 3133  2003, 2006, 2013
    │ │ │ -00071690: 2d32 3032 312c 2041 7276 6964 204e 6f72  -2021, Arvid Nor
    │ │ │ -000716a0: 6265 7267 0a43 6f70 7972 6967 6874 2028  berg.Copyright (
    │ │ │ -000716b0: 6329 2032 3032 302c 2041 6c64 656e 2054  c) 2020, Alden T
    │ │ │ -000716c0: 6f72 7265 730a 416c 6c20 7269 6768 7473  orres.All rights
    │ │ │ -000716d0: 2072 6573 6572 7665 642e 0a0a 596f 7520   reserved...You 
    │ │ │ -000716e0: 6d61 7920 7573 652c 2064 6973 7472 6962  may use, distrib
    │ │ │ -000716f0: 7574 6520 616e 6420 6d6f 6469 6679 2074  ute and modify t
    │ │ │ -00071700: 6869 7320 636f 6465 2075 6e64 6572 2074  his code under t
    │ │ │ -00071710: 6865 2074 6572 6d73 206f 6620 7468 6520  he terms of the 
    │ │ │ -00071720: 4253 4420 6c69 6365 6e73 652c 0a73 6565  BSD license,.see
    │ │ │ -00071730: 204c 4943 454e 5345 2066 696c 652e 0a2a   LICENSE file..*
    │ │ │ -00071740: 2f0a 0a23 6966 6e64 6566 2054 4f52 5245  /..#ifndef TORRE
    │ │ │ -00071750: 4e54 5f49 4445 4e54 4946 595f 434c 4945  NT_IDENTIFY_CLIE
    │ │ │ -00071760: 4e54 5f48 5050 5f49 4e43 4c55 4445 440a  NT_HPP_INCLUDED.
    │ │ │ -00071770: 2364 6566 696e 6520 544f 5252 454e 545f  #define TORRENT_
    │ │ │ -00071780: 4944 454e 5449 4659 5f43 4c49 454e 545f  IDENTIFY_CLIENT_
    │ │ │ -00071790: 4850 505f 494e 434c 5544 4544 0a0a 2369  HPP_INCLUDED..#i
    │ │ │ -000717a0: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ -000717b0: 6e74 2f63 6f6e 6669 672e 6870 7022 0a0a  nt/config.hpp"..
    │ │ │ -000717c0: 2369 6620 544f 5252 454e 545f 4142 495f  #if TORRENT_ABI_
    │ │ │ -000717d0: 5645 5253 494f 4e20 3d3d 2031 0a23 696e  VERSION == 1.#in
    │ │ │ -000717e0: 636c 7564 6520 266c 743b 6f70 7469 6f6e  clude <option
    │ │ │ -000717f0: 616c 2667 743b 0a23 656e 6469 660a 0a23  al>.#endif..#
    │ │ │ -00071800: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00071810: 656e 742f 7065 6572 5f69 642e 6870 7022  ent/peer_id.hpp"
    │ │ │ -00071820: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ -00071830: 7272 656e 742f 6669 6e67 6572 7072 696e  rrent/fingerprin
    │ │ │ -00071840: 742e 6870 7022 0a0a 3c64 6976 2073 7479  t.hpp"..
    namespace │ │ │ -00071880: 6c69 6274 6f72 7265 6e74 207b 0a3c 2f64 libtorrent {..namespace au │ │ │ -000718a0: 7820 7b0a 0a09 544f 5252 454e 545f 4558 x {...TORRENT_EX │ │ │ -000718b0: 5452 415f 4558 504f 5254 0a09 7374 643a TRA_EXPORT..std: │ │ │ -000718c0: 3a73 7472 696e 6720 6964 656e 7469 6679 :string identify │ │ │ -000718d0: 5f63 6c69 656e 745f 696d 706c 2863 6f6e _client_impl(con │ │ │ -000718e0: 7374 2070 6565 725f 6964 2661 6d70 3b20 st peer_id& │ │ │ -000718f0: 7029 3b0a 0a7d 0a0a 092f 2f20 7468 6573 p);..}...// thes │ │ │ -00071900: 6520 6675 6e63 7469 6f6e 7320 646f 6e27 e functions don' │ │ │ -00071910: 7420 7265 616c 6c79 206e 6565 6420 746f t really need to │ │ │ -00071920: 2062 6520 7075 626c 6963 2e20 5468 6973 be public. This │ │ │ -00071930: 206d 6563 6861 6e69 736d 206f 660a 092f mechanism of../ │ │ │ -00071940: 2f20 6164 7665 7274 6973 696e 6720 636c / advertising cl │ │ │ -00071950: 6965 6e74 2073 6f66 7477 6172 6520 616e ient software an │ │ │ -00071960: 6420 7665 7273 696f 6e20 6973 2061 6c73 d version is als │ │ │ -00071970: 6f20 6f75 742d 6461 7465 642e 0a0a 092f o out-dated..../ │ │ │ -00071980: 2f20 5468 6973 2066 756e 6374 696f 6e20 / This function │ │ │ -00071990: 6361 6e20 6361 6e20 6265 2075 7365 6420 can can be used │ │ │ -000719a0: 746f 2065 7874 7261 6374 2061 2073 7472 to extract a str │ │ │ -000719b0: 696e 6720 6465 7363 7269 6269 6e67 2061 ing describing a │ │ │ -000719c0: 2063 6c69 656e 740a 092f 2f20 7665 7273 client..// vers │ │ │ -000719d0: 696f 6e20 6672 6f6d 2069 7473 2070 6565 ion from its pee │ │ │ -000719e0: 722d 6964 2e20 4974 2077 696c 6c20 7265 r-id. It will re │ │ │ -000719f0: 636f 676e 697a 6520 6d6f 7374 2063 6c69 cognize most cli │ │ │ -00071a00: 656e 7473 2074 6861 7420 6861 7665 2074 ents that have t │ │ │ -00071a10: 6869 730a 092f 2f20 6b69 6e64 206f 6620 his..// kind of │ │ │ -00071a20: 6964 656e 7469 6669 6361 7469 6f6e 2069 identification i │ │ │ -00071a30: 6e20 7468 6520 7065 6572 2d69 642e 0a09 n the peer-id... │ │ │ -00071a40: 544f 5252 454e 545f 4445 5052 4543 4154 TORRENT_DEPRECAT │ │ │ -00071a50: 4544 5f45 5850 4f52 540a 0973 7464 3a3a ED_EXPORT..std:: │ │ │ -00071a60: 7374 7269 6e67 2069 6465 6e74 6966 795f string identify_ │ │ │ -00071a70: 636c 6965 6e74 2863 6f6e 7374 2070 6565 client(const pee │ │ │ -00071a80: 725f 6964 2661 6d70 3b20 7029 3b0a 0a23 r_id& p);..# │ │ │ -00071a90: 6966 2054 4f52 5245 4e54 5f41 4249 5f56 if TORRENT_ABI_V │ │ │ -00071aa0: 4552 5349 4f4e 203d 3d20 310a 0a23 696e ERSION == 1..#in │ │ │ -00071ab0: 636c 7564 6520 226c 6962 746f 7272 656e clude "libtorren │ │ │ -00071ac0: 742f 6175 785f 2f64 6973 6162 6c65 5f64 t/aux_/disable_d │ │ │ -00071ad0: 6570 7265 6361 7469 6f6e 5f77 6172 6e69 eprecation_warni │ │ │ -00071ae0: 6e67 735f 7075 7368 2e68 7070 220a 0a09 ngs_push.hpp"... │ │ │ -00071af0: 2f2f 2052 6574 7572 6e73 2061 6e20 6f70 // Returns an op │ │ │ -00071b00: 7469 6f6e 616c 2066 696e 6765 7270 7269 tional fingerpri │ │ │ -00071b10: 6e74 2069 6620 616e 7920 6361 6e20 6265 nt if any can be │ │ │ -00071b20: 2069 6465 6e74 6966 6965 6420 6672 6f6d identified from │ │ │ -00071b30: 2074 6865 2070 6565 720a 092f 2f20 6964 the peer..// id │ │ │ -00071b40: 2e20 5468 6973 2063 616e 2062 6520 7573 . This can be us │ │ │ -00071b50: 6564 2074 6f20 6175 746f 6d61 7465 2074 ed to automate t │ │ │ -00071b60: 6865 2069 6465 6e74 6966 6963 6174 696f he identificatio │ │ │ -00071b70: 6e20 6f66 2063 6c69 656e 7473 2e20 4974 n of clients. It │ │ │ -00071b80: 2077 696c 6c0a 092f 2f20 6e6f 7420 6265 will..// not be │ │ │ -00071b90: 2061 626c 6520 746f 2069 6465 6e74 6966 able to identif │ │ │ -00071ba0: 7920 7065 6572 7320 7769 7468 206e 6f6e y peers with non │ │ │ -00071bb0: 2d20 7374 616e 6461 7264 2065 6e63 6f64 - standard encod │ │ │ -00071bc0: 696e 6773 2e20 4f6e 6c79 2041 7a75 7265 ings. Only Azure │ │ │ -00071bd0: 7573 0a09 2f2f 2073 7479 6c65 2c20 5368 us..// style, Sh │ │ │ -00071be0: 6164 6f77 2773 2073 7479 6c65 2061 6e64 adow's style and │ │ │ -00071bf0: 204d 6169 6e6c 696e 6520 7374 796c 652e Mainline style. │ │ │ -00071c00: 0a09 544f 5252 454e 545f 4445 5052 4543 ..TORRENT_DEPREC │ │ │ -00071c10: 4154 4544 5f45 5850 4f52 540a 0973 7464 ATED_EXPORT..std │ │ │ -00071c20: 3a3a 6f70 7469 6f6e 616c 266c 743b 6669 ::optional<fi │ │ │ -00071c30: 6e67 6572 7072 696e 7426 6774 3b0a 0909 ngerprint>... │ │ │ -00071c40: 636c 6965 6e74 5f66 696e 6765 7270 7269 client_fingerpri │ │ │ -00071c50: 6e74 2870 6565 725f 6964 2063 6f6e 7374 nt(peer_id const │ │ │ -00071c60: 2661 6d70 3b20 7029 3b0a 0a23 696e 636c & p);..#incl │ │ │ -00071c70: 7564 6520 226c 6962 746f 7272 656e 742f ude "libtorrent/ │ │ │ -00071c80: 6175 785f 2f64 6973 6162 6c65 5f77 6172 aux_/disable_war │ │ │ -00071c90: 6e69 6e67 735f 706f 702e 6870 7022 0a3c nings_pop.hpp".< │ │ │ -00071ca0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00071cb0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00071cc0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00071cd0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00071ce0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../inc │ │ │ -00071d10: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00071d20: 6932 705f 7374 7265 616d 2e68 7070 3a35 i2p_stream.hpp:5 │ │ │ -00071d30: 3130 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 10m │ │ │ -00071d40: 616b 6520 7468 6973 2061 2073 7472 696e ake this a strin │ │ │ -00071d50: 675f 7669 6577 3c2f 7464 3e3c 2f74 723e g_view │ │ │ -00071d60: 3c74 7220 6964 3d22 3236 3222 2073 7479 │ │ │ -00071d90: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00071da0: 3c68 323e 6d61 6b65 2074 6869 7320 6120

    make this a │ │ │ -00071db0: 7374 7269 6e67 5f76 6965 773c 2f68 323e string_view

    │ │ │ -00071dc0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00071dd0: 6962 746f 7272 656e 742f 6932 705f 7374 ibtorrent/i2p_st │ │ │ -00071de0: 7265 616d 2e68 7070 3a35 3130 3c2f 6834 ream.hpp:510

    ...ch
    │ │ │ -00071e30: 6172 2074 6d70 5b32 305d 3b0a 0909 6175  ar tmp[20];...au
    │ │ │ -00071e40: 783a 3a72 616e 646f 6d5f 6279 7465 7328  x::random_bytes(
    │ │ │ -00071e50: 746d 7029 3b0a 0909 6d5f 7365 7373 696f  tmp);...m_sessio
    │ │ │ -00071e60: 6e5f 6964 2e72 6573 697a 6528 7369 7a65  n_id.resize(size
    │ │ │ -00071e70: 6f66 2874 6d70 292a 3229 3b0a 0909 6175  of(tmp)*2);...au
    │ │ │ -00071e80: 783a 3a74 6f5f 6865 7828 746d 702c 2026  x::to_hex(tmp, &
    │ │ │ -00071e90: 616d 703b 6d5f 7365 7373 696f 6e5f 6964  amp;m_session_id
    │ │ │ -00071ea0: 5b30 5d29 3b0a 0a09 096d 5f73 616d 5f73  [0]);....m_sam_s
    │ │ │ -00071eb0: 6f63 6b65 7420 3d20 7374 643a 3a6d 616b  ocket = std::mak
    │ │ │ -00071ec0: 655f 7368 6172 6564 266c 743b 6932 705f  e_shared<i2p_
    │ │ │ -00071ed0: 7374 7265 616d 2667 743b 286d 5f69 6f5f  stream>(m_io_
    │ │ │ -00071ee0: 7365 7276 6963 6529 3b0a 0909 6d5f 7361  service);...m_sa
    │ │ │ -00071ef0: 6d5f 736f 636b 6574 2d26 6774 3b73 6574  m_socket->set
    │ │ │ -00071f00: 5f70 726f 7879 286d 5f68 6f73 746e 616d  _proxy(m_hostnam
    │ │ │ -00071f10: 652c 206d 5f70 6f72 7429 3b0a 0909 6d5f  e, m_port);...m_
    │ │ │ -00071f20: 7361 6d5f 736f 636b 6574 2d26 6774 3b73  sam_socket->s
    │ │ │ -00071f30: 6574 5f63 6f6d 6d61 6e64 2869 3270 5f73  et_command(i2p_s
    │ │ │ -00071f40: 7472 6561 6d3a 3a63 6d64 5f63 7265 6174  tream::cmd_creat
    │ │ │ -00071f50: 655f 7365 7373 696f 6e29 3b0a 0909 6d5f  e_session);...m_
    │ │ │ -00071f60: 7361 6d5f 736f 636b 6574 2d26 6774 3b73  sam_socket->s
    │ │ │ -00071f70: 6574 5f73 6573 7369 6f6e 5f69 6428 6d5f  et_session_id(m_
    │ │ │ -00071f80: 7365 7373 696f 6e5f 6964 2e63 5f73 7472  session_id.c_str
    │ │ │ -00071f90: 2829 293b 0a09 096d 5f73 616d 5f73 6f63  ());...m_sam_soc
    │ │ │ -00071fa0: 6b65 742d 2667 743b 7365 745f 7365 7373  ket->set_sess
    │ │ │ -00071fb0: 696f 6e5f 6f70 7469 6f6e 7328 7365 7373  ion_options(sess
    │ │ │ -00071fc0: 696f 6e5f 6f70 7469 6f6e 7329 3b0a 0a09  ion_options);...
    │ │ │ -00071fd0: 0941 4444 5f4f 5554 5354 414e 4449 4e47  .ADD_OUTSTANDING
    │ │ │ -00071fe0: 5f41 5359 4e43 2822 6932 705f 7374 7265  _ASYNC("i2p_stre
    │ │ │ -00071ff0: 616d 3a3a 6f6e 5f73 616d 5f63 6f6e 6e65  am::on_sam_conne
    │ │ │ -00072000: 6374 2229 3b0a 0909 6d5f 7361 6d5f 736f  ct");...m_sam_so
    │ │ │ -00072010: 636b 6574 2d26 6774 3b61 7379 6e63 5f63  cket->async_c
    │ │ │ -00072020: 6f6e 6e65 6374 2874 6370 3a3a 656e 6470  onnect(tcp::endp
    │ │ │ -00072030: 6f69 6e74 2829 2c20 6175 783a 3a77 7261  oint(), aux::wra
    │ │ │ -00072040: 705f 616c 6c6f 6361 746f 7228 0a09 0909  p_allocator(....
    │ │ │ -00072050: 5b74 6869 732c 733d 6d5f 7361 6d5f 736f  [this,s=m_sam_so
    │ │ │ -00072060: 636b 6574 5d28 6572 726f 725f 636f 6465  cket](error_code
    │ │ │ -00072070: 2063 6f6e 7374 2661 6d70 3b20 6563 2c20   const& ec, 
    │ │ │ -00072080: 4861 6e64 6c65 7220 686e 2920 7b0a 0909  Handler hn) {...
    │ │ │ -00072090: 0909 6f6e 5f73 616d 5f63 6f6e 6e65 6374  ..on_sam_connect
    │ │ │ -000720a0: 2865 632c 2073 2c20 7374 643a 3a6d 6f76  (ec, s, std::mov
    │ │ │ -000720b0: 6528 686e 2929 3b0a 0909 097d 2c20 7374  e(hn));....}, st
    │ │ │ -000720c0: 643a 3a6d 6f76 6528 6861 6e64 6c65 7229  d::move(handler)
    │ │ │ -000720d0: 2929 3b0a 097d 0a09 766f 6964 2063 6c6f  ));..}..void clo
    │ │ │ -000720e0: 7365 2865 7272 6f72 5f63 6f64 6526 616d  se(error_code&am
    │ │ │ -000720f0: 703b 293b 0a0a 3c64 6976 2073 7479 6c65  p;);..
    .char const* │ │ │ -00072130: 2073 6573 7369 6f6e 5f69 6428 2920 636f session_id() co │ │ │ -00072140: 6e73 7420 7b20 7265 7475 726e 206d 5f73 nst { return m_s │ │ │ -00072150: 6573 7369 6f6e 5f69 642e 635f 7374 7228 ession_id.c_str( │ │ │ -00072160: 293b 207d 0a3c 2f64 6976 3e09 7374 643a ); }.
    .std: │ │ │ -00072170: 3a73 7472 696e 6720 636f 6e73 7426 616d :string const&am │ │ │ -00072180: 703b 206c 6f63 616c 5f65 6e64 706f 696e p; local_endpoin │ │ │ -00072190: 7428 2920 636f 6e73 7420 7b20 7265 7475 t() const { retu │ │ │ -000721a0: 726e 206d 5f69 3270 5f6c 6f63 616c 5f65 rn m_i2p_local_e │ │ │ -000721b0: 6e64 706f 696e 743b 207d 0a0a 0974 656d ndpoint; }...tem │ │ │ -000721c0: 706c 6174 6520 266c 743b 7479 7065 6e61 plate <typena │ │ │ -000721d0: 6d65 2048 616e 646c 6572 2667 743b 0a09 me Handler>.. │ │ │ -000721e0: 766f 6964 2061 7379 6e63 5f6e 616d 655f void async_name_ │ │ │ -000721f0: 6c6f 6f6b 7570 2863 6861 7220 636f 6e73 lookup(char cons │ │ │ -00072200: 742a 206e 616d 652c 2048 616e 646c 6572 t* name, Handler │ │ │ -00072210: 2068 616e 646c 6572 290a 097b 0a09 0969 handler)..{...i │ │ │ -00072220: 6620 286d 5f73 7461 7465 203d 3d20 7361 f (m_state == sa │ │ │ -00072230: 6d5f 6964 6c65 2026 616d 703b 2661 6d70 m_idle && │ │ │ -00072240: 3b20 6d5f 6e61 6d65 5f6c 6f6f 6b75 702e ; m_name_lookup. │ │ │ -00072250: 656d 7074 7928 2920 2661 6d70 3b26 616d empty() &&am │ │ │ -00072260: 703b 2069 735f 6f70 656e 2829 290a 0909 p; is_open())... │ │ │ -00072270: 0964 6f5f 6e61 6d65 5f6c 6f6f 6b75 7028 .do_name_lookup( │ │ │ -00072280: 6e61 6d65 2c20 7374 643a 3a6d 6f76 6528 name, std::move( │ │ │ -00072290: 6861 6e64 6c65 7229 293b 0a09 0965 6c73 handler));...els │ │ │ -000722a0: 650a 0909 096d 5f6e 616d 655f 6c6f 6f6b e....m_name_look │ │ │ -000722b0: 7570 2e65 6d70 6c61 6365 5f62 6163 6b28 up.emplace_back( │ │ │ -000722c0: 7374 643a 3a73 7472 696e 6728 6e61 6d65 std::string(name │ │ │ -000722d0: 290a 0909 0909 2c20 7374 643a 3a6d 6f76 )....., std::mov │ │ │ -000722e0: 6528 6861 6e64 6c65 7229 293b 0a09 7d0a e(handler));..}. │ │ │ -000722f0: 0a70 7269 7661 7465 3a0a 0a09 7465 6d70 .private:...temp │ │ │ -00072300: 6c61 7465 2026 6c74 3b74 7970 656e 616d late <typenam │ │ │ -00072310: 6520 4861 6e64 6c65 7226 6774 3b0a 0976 e Handler>..v │ │ │ -00072320: 6f69 6420 6f6e 5f73 616d 5f63 6f6e 6e65 oid on_sam_conne │ │ │ -00072330: 6374 2865 7272 6f72 5f63 6f64 6520 636f ct(error_code co │ │ │ -00072340: 6e73 7426 616d 703b 2065 632c 2073 7464 nst& ec, std │ │ │ -00072350: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ -00072360: 6932 705f 7374 7265 616d 2667 743b 2c20 i2p_stream>, │ │ │ -00072370: 4861 6e64 6c65 7220 6829 0a09 7b0a 0909 Handler h)..{... │ │ │ -00072380: 434f 4d50 4c45 5445 5f41 5359 4e43 2822 COMPLETE_ASYNC(" │ │ │ -00072390: 6932 705f 7374 7265 616d 3a3a 6f6e 5f73 i2p_stream::on_s │ │ │ -000723a0: 616d 5f63 6f6e 6e65 6374 2229 3b0a 0909 am_connect");... │ │ │ -000723b0: 6d5f 7374 6174 6520 3d20 7361 6d5f 6964 m_state = sam_id │ │ │ -000723c0: 6c65 3b0a 0a09 0969 6620 2865 6329 0a09 le;....if (ec).. │ │ │ -000723d0: 097b 0a09 0909 6828 6563 293b 0a09 0909 .{....h(ec);.... │ │ │ -000723e0: 7265 7475 726e 3b0a 0909 7d0a 0a09 0964 return;...}....d │ │ │ -000723f0: 6f5f 6e61 6d65 5f6c 6f6f 6b75 7028 224d o_name_lookup("M │ │ │ -00072400: 4522 2c20 6175 783a 3a77 7261 705f 616c E", aux::wrap_al │ │ │ -00072410: 6c6f 6361 746f 7228 0a09 0909 5b74 6869 locator(....[thi │ │ │ -00072420: 735d 2865 7272 6f72 5f63 6f64 6520 636f s](error_code co │ │ │ -00072430: 6e73 7426 616d 703b 2065 2c20 6368 6172 nst& e, char │ │ │ -00072440: 2063 6f6e 7374 2a20 6473 742c 2048 616e const* dst, Han │ │ │ -00072450: 646c 6572 2068 6e29 207b 0a09 0909 0973 dler hn) {.....s │ │ │ -00072460: 6574 5f6c 6f63 616c 5f65 6e64 706f 696e et_local_endpoin │ │ │ -00072470: 7428 652c 2064 7374 2c20 7374 643a 3a6d t(e, dst, std::m │ │ │ -00072480: 6f76 6528 686e 2929 3b0a 0909 097d 2c20 ove(hn));....}, │ │ │ -00072490: 7374 643a 3a6d 6f76 6528 6829 2929 3b0a std::move(h)));. │ │ │ -000724a0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -000724b0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -000724e0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -00072510: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00072520: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e /peer_connection │ │ │ -00072530: 5f69 6e74 6572 6661 6365 2e68 7070 3a34 _interface.hpp:4 │ │ │ -00072540: 313c 2f61 3e3c 2f74 643e 3c74 643e 6d61 1ma │ │ │ -00072550: 6b65 2074 6869 7320 696e 7465 7266 6163 ke this interfac │ │ │ -00072560: 6520 736d 616c 6c65 7221 3c2f 7464 3e3c e smaller!< │ │ │ -00072570: 2f74 723e 3c74 7220 6964 3d22 3236 3322 /tr>

    make thi │ │ │ -000725c0: 7320 696e 7465 7266 6163 6520 736d 616c s interface smal │ │ │ -000725d0: 6c65 7221 3c2f 6832 3e3c 6834 3e2e 2e2f ler!

    ../ │ │ │ -000725e0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -000725f0: 6e74 2f70 6565 725f 636f 6e6e 6563 7469 nt/peer_connecti │ │ │ -00072600: 6f6e 5f69 6e74 6572 6661 6365 2e68 7070 on_interface.hpp │ │ │ -00072610: 3a34 313c 2f68 343e 3c70 7265 2073 7479 :41

    namespace libt
    │ │ │ -00072660: 6f72 7265 6e74 207b 0a0a 096e 616d 6573  orrent {...names
    │ │ │ -00072670: 7061 6365 2061 7578 207b 0a09 0973 7472  pace aux {...str
    │ │ │ -00072680: 7563 7420 746f 7272 656e 745f 7065 6572  uct torrent_peer
    │ │ │ -00072690: 3b0a 0909 636c 6173 7320 7374 6174 3b0a  ;...class stat;.
    │ │ │ -000726a0: 097d 0a0a 092f 2f20 636c 6173 7369 6669  .}...// classifi
    │ │ │ -000726b0: 6573 2061 2070 6565 7220 636f 6e6e 6563  es a peer connec
    │ │ │ -000726c0: 7469 6f6e 2062 7920 7468 6520 7072 6f74  tion by the prot
    │ │ │ -000726d0: 6f63 6f6c 2069 7420 7370 6561 6b73 2e0a  ocol it speaks..
    │ │ │ -000726e0: 0965 6e75 6d20 636c 6173 7320 636f 6e6e  .enum class conn
    │ │ │ -000726f0: 6563 7469 6f6e 5f74 7970 6520 3a20 7374  ection_type : st
    │ │ │ -00072700: 643a 3a75 696e 7438 5f74 0a09 7b0a 0909  d::uint8_t..{...
    │ │ │ -00072710: 2f2f 2074 6869 7320 6973 2061 2072 6567  // this is a reg
    │ │ │ -00072720: 756c 6172 2062 6974 746f 7272 656e 7420  ular bittorrent 
    │ │ │ -00072730: 7065 6572 2063 6f6e 6e65 6374 696f 6e0a  peer connection.
    │ │ │ -00072740: 0909 6269 7474 6f72 7265 6e74 2c0a 0909  ..bittorrent,...
    │ │ │ -00072750: 2f2f 2042 4550 2031 3920 7765 6220 7365  // BEP 19 web se
    │ │ │ -00072760: 6564 0a09 0975 726c 5f73 6565 642c 0a09  ed...url_seed,..
    │ │ │ -00072770: 092f 2f20 4245 5020 3137 2077 6562 2073  .// BEP 17 web s
    │ │ │ -00072780: 6565 6420 286e 6f20 6c6f 6e67 6572 2073  eed (no longer s
    │ │ │ -00072790: 7570 706f 7274 6564 290a 0909 6874 7470  upported)...http
    │ │ │ -000727a0: 5f73 6565 640a 097d 3b0a 0a09 7573 696e  _seed..};...usin
    │ │ │ -000727b0: 6720 6469 7363 6f6e 6e65 6374 5f73 6576  g disconnect_sev
    │ │ │ -000727c0: 6572 6974 795f 7420 3d20 6175 783a 3a73  erity_t = aux::s
    │ │ │ -000727d0: 7472 6f6e 675f 7479 7065 6465 6626 6c74  trong_typedef<
    │ │ │ -000727e0: 3b73 7464 3a3a 7569 6e74 385f 742c 2073  ;std::uint8_t, s
    │ │ │ -000727f0: 7472 7563 7420 6469 7363 6f6e 6e65 6374  truct disconnect
    │ │ │ -00072800: 5f73 6576 6572 6974 795f 7461 6726 6774  _severity_tag>
    │ │ │ -00072810: 3b3b 0a0a 3c64 6976 2073 7479 6c65 3d22  ;;..
    .struct TORREN │ │ │ -00072850: 545f 4558 5452 415f 4558 504f 5254 2070 T_EXTRA_EXPORT p │ │ │ -00072860: 6565 725f 636f 6e6e 6563 7469 6f6e 5f69 eer_connection_i │ │ │ -00072870: 6e74 6572 6661 6365 0a3c 2f64 6976 3e09 nterface.
    . │ │ │ -00072880: 7b0a 0909 7374 6174 6963 2069 6e6c 696e {...static inlin │ │ │ -00072890: 6520 636f 6e73 7465 7870 7220 6469 7363 e constexpr disc │ │ │ -000728a0: 6f6e 6e65 6374 5f73 6576 6572 6974 795f onnect_severity_ │ │ │ -000728b0: 7420 6e6f 726d 616c 7b30 7d3b 0a09 0973 t normal{0};...s │ │ │ -000728c0: 7461 7469 6320 696e 6c69 6e65 2063 6f6e tatic inline con │ │ │ -000728d0: 7374 6578 7072 2064 6973 636f 6e6e 6563 stexpr disconnec │ │ │ -000728e0: 745f 7365 7665 7269 7479 5f74 2066 6169 t_severity_t fai │ │ │ -000728f0: 6c75 7265 7b31 7d3b 0a09 0973 7461 7469 lure{1};...stati │ │ │ -00072900: 6320 696e 6c69 6e65 2063 6f6e 7374 6578 c inline constex │ │ │ -00072910: 7072 2064 6973 636f 6e6e 6563 745f 7365 pr disconnect_se │ │ │ -00072920: 7665 7269 7479 5f74 2070 6565 725f 6572 verity_t peer_er │ │ │ -00072930: 726f 727b 327d 3b0a 0a23 6966 2054 4f52 ror{2};..#if TOR │ │ │ -00072940: 5245 4e54 5f55 5345 5f49 3250 0a09 0976 RENT_USE_I2P...v │ │ │ -00072950: 6972 7475 616c 2073 7464 3a3a 7374 7269 irtual std::stri │ │ │ -00072960: 6e67 2063 6f6e 7374 2661 6d70 3b20 6465 ng const& de │ │ │ -00072970: 7374 696e 6174 696f 6e28 2920 636f 6e73 stination() cons │ │ │ -00072980: 7420 3d20 303b 0a09 0976 6972 7475 616c t = 0;...virtual │ │ │ -00072990: 2073 7464 3a3a 7374 7269 6e67 2063 6f6e std::string con │ │ │ -000729a0: 7374 2661 6d70 3b20 6c6f 6361 6c5f 6932 st& local_i2 │ │ │ -000729b0: 705f 656e 6470 6f69 6e74 2829 2063 6f6e p_endpoint() con │ │ │ -000729c0: 7374 203d 2030 3b0a 2365 6e64 6966 0a09 st = 0;.#endif.. │ │ │ -000729d0: 0976 6972 7475 616c 2074 6370 3a3a 656e .virtual tcp::en │ │ │ -000729e0: 6470 6f69 6e74 2063 6f6e 7374 2661 6d70 dpoint const& │ │ │ -000729f0: 3b20 7265 6d6f 7465 2829 2063 6f6e 7374 ; remote() const │ │ │ -00072a00: 203d 2030 3b0a 0909 7669 7274 7561 6c20 = 0;...virtual │ │ │ -00072a10: 7463 703a 3a65 6e64 706f 696e 7420 6c6f tcp::endpoint lo │ │ │ -00072a20: 6361 6c5f 656e 6470 6f69 6e74 2829 2063 cal_endpoint() c │ │ │ -00072a30: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -00072a40: 7561 6c20 766f 6964 2064 6973 636f 6e6e ual void disconn │ │ │ -00072a50: 6563 7428 6572 726f 725f 636f 6465 2063 ect(error_code c │ │ │ -00072a60: 6f6e 7374 2661 6d70 3b20 6563 0a09 0909 onst& ec.... │ │ │ -00072a70: 2c20 6f70 6572 6174 696f 6e5f 7420 6f70 , operation_t op │ │ │ -00072a80: 2c20 6469 7363 6f6e 6e65 6374 5f73 6576 , disconnect_sev │ │ │ -00072a90: 6572 6974 795f 7420 3d20 7065 6572 5f63 erity_t = peer_c │ │ │ -00072aa0: 6f6e 6e65 6374 696f 6e5f 696e 7465 7266 onnection_interf │ │ │ -00072ab0: 6163 653a 3a6e 6f72 6d61 6c29 203d 2030 ace::normal) = 0 │ │ │ -00072ac0: 3b0a 0909 7669 7274 7561 6c20 7065 6572 ;...virtual peer │ │ │ -00072ad0: 5f69 6420 636f 6e73 7426 616d 703b 2070 _id const& p │ │ │ -00072ae0: 6964 2829 2063 6f6e 7374 203d 2030 3b0a id() const = 0;. │ │ │ -00072af0: 0909 7669 7274 7561 6c20 7065 6572 5f69 ..virtual peer_i │ │ │ -00072b00: 6420 6f75 725f 7069 6428 2920 636f 6e73 d our_pid() cons │ │ │ -00072b10: 7420 3d20 303b 0a09 0976 6972 7475 616c t = 0;...virtual │ │ │ -00072b20: 2076 6f69 6420 7365 745f 686f 6c65 7075 void set_holepu │ │ │ -00072b30: 6e63 685f 6d6f 6465 2829 203d 2030 3b0a nch_mode() = 0;. │ │ │ -00072b40: 0909 7669 7274 7561 6c20 6175 783a 3a74 ..virtual aux::t │ │ │ -00072b50: 6f72 7265 6e74 5f70 6565 722a 2070 6565 orrent_peer* pee │ │ │ -00072b60: 725f 696e 666f 5f73 7472 7563 7428 2920 r_info_struct() │ │ │ -00072b70: 636f 6e73 7420 3d20 303b 0a09 0976 6972 const = 0;...vir │ │ │ -00072b80: 7475 616c 2076 6f69 6420 7365 745f 7065 tual void set_pe │ │ │ -00072b90: 6572 5f69 6e66 6f28 6175 783a 3a74 6f72 er_info(aux::tor │ │ │ -00072ba0: 7265 6e74 5f70 6565 722a 2070 6929 203d rent_peer* pi) = │ │ │ -00072bb0: 2030 3b0a 0909 7669 7274 7561 6c20 626f 0;...virtual bo │ │ │ -00072bc0: 6f6c 2069 735f 6f75 7467 6f69 6e67 2829 ol is_outgoing() │ │ │ -00072bd0: 2063 6f6e 7374 203d 2030 3b0a 0909 7669 const = 0;...vi │ │ │ -00072be0: 7274 7561 6c20 766f 6964 2061 6464 5f73 rtual void add_s │ │ │ -00072bf0: 7461 7428 7374 643a 3a69 6e74 3634 5f74 tat(std::int64_t │ │ │ -00072c00: 2064 6f77 6e6c 6f61 6465 642c 2073 7464 downloaded, std │ │ │ -00072c10: 3a3a 696e 7436 345f 7420 7570 6c6f 6164 ::int64_t upload │ │ │ -00072c20: 6564 2920 3d20 303b 0a09 0976 6972 7475 ed) = 0;...virtu │ │ │ -00072c30: 616c 2062 6f6f 6c20 6661 7374 5f72 6563 al bool fast_rec │ │ │ -00072c40: 6f6e 6e65 6374 2829 2063 6f6e 7374 203d onnect() const = │ │ │ -00072c50: 2030 3b0a 0909 7669 7274 7561 6c20 626f 0;...virtual bo │ │ │ -00072c60: 6f6c 2069 735f 6368 6f6b 6564 2829 2063 ol is_choked() c │ │ │ -00072c70: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -00072c80: 7561 6c20 626f 6f6c 2066 6169 6c65 6428 ual bool failed( │ │ │ -00072c90: 2920 636f 6e73 7420 3d20 303b 0a09 0976 ) const = 0;...v │ │ │ -00072ca0: 6972 7475 616c 2061 7578 3a3a 7374 6174 irtual aux::stat │ │ │ -00072cb0: 2063 6f6e 7374 2661 6d70 3b20 7374 6174 const& stat │ │ │ -00072cc0: 6973 7469 6373 2829 2063 6f6e 7374 203d istics() const = │ │ │ -00072cd0: 2030 3b0a 0909 7669 7274 7561 6c20 766f 0;...virtual vo │ │ │ -00072ce0: 6964 2067 6574 5f70 6565 725f 696e 666f id get_peer_info │ │ │ -00072cf0: 2870 6565 725f 696e 666f 2661 6d70 3b20 (peer_info& │ │ │ -00072d00: 7029 2063 6f6e 7374 203d 2030 3b0a 2369 p) const = 0;.#i │ │ │ -00072d10: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ -00072d20: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ -00072d30: 7669 7274 7561 6c20 626f 6f6c 2073 686f virtual bool sho │ │ │ -00072d40: 756c 645f 6c6f 6728 7065 6572 5f6c 6f67 uld_log(peer_log │ │ │ -00072d50: 5f61 6c65 7274 3a3a 6469 7265 6374 696f _alert::directio │ │ │ -00072d60: 6e5f 7420 6469 7265 6374 696f 6e29 2063 n_t direction) c │ │ │ -00072d70: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -00072d80: 7561 6c20 766f 6964 2070 6565 725f 6c6f ual void peer_lo │ │ │ -00072d90: 6728 7065 6572 5f6c 6f67 5f61 6c65 7274 g(peer_log_alert │ │ │ -00072da0: 3a3a 6469 7265 6374 696f 6e5f 7420 6469 ::direction_t di │ │ │ -00072db0: 7265 6374 696f 6e0a 0909 092c 2070 6565 rection...., pee │ │ │ -00072dc0: 725f 6c6f 675f 616c 6572 743a 3a65 7665 r_log_alert::eve │ │ │ -00072dd0: 6e74 5f74 2065 7665 6e74 2c20 6368 6172 nt_t event, char │ │ │ -00072de0: 2063 6f6e 7374 2a20 666d 7420 3d20 2222 const* fmt = "" │ │ │ -00072df0: 2c20 2e2e 2e29 2063 6f6e 7374 206e 6f65 , ...) const noe │ │ │ -00072e00: 7863 6570 7420 544f 5252 454e 545f 464f xcept TORRENT_FO │ │ │ -00072e10: 524d 4154 2834 2c35 2920 3d20 303b 0a23 RMAT(4,5) = 0;.# │ │ │ -00072e20: 656e 6469 660a 3c2f 7072 653e 3c2f 7464 endif.
    relevance │ │ │ -00072e60: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00072e70: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ -00072ea0: 6f72 7265 6e74 2f73 6f63 6b73 355f 7374 orrent/socks5_st │ │ │ -00072eb0: 7265 616d 2e68 7070 3a31 3736 3c2f 613e ream.hpp:176 │ │ │ -00072ec0: 3c2f 7464 3e3c 7464 3e77 6520 636f 756c we coul │ │ │ -00072ed0: 6420 6269 6e64 2074 6865 2073 6f63 6b65 d bind the socke │ │ │ -00072ee0: 7420 6865 7265 2c20 7369 6e63 6520 7765 t here, since we │ │ │ -00072ef0: 206b 6e6f 7720 7768 6174 2074 6865 2074 know what the t │ │ │ -00072f00: 6172 6765 7420 656e 6470 6f69 6e74 2069 arget endpoint i │ │ │ -00072f10: 7320 6f66 2074 6865 2070 726f 7879 3c2f s of the proxy

    we c │ │ │ -00072f70: 6f75 6c64 2062 696e 6420 7468 6520 736f ould bind the so │ │ │ -00072f80: 636b 6574 2068 6572 652c 2073 696e 6365 cket here, since │ │ │ -00072f90: 2077 6520 6b6e 6f77 2077 6861 7420 7468 we know what th │ │ │ -00072fa0: 650a 7461 7267 6574 2065 6e64 706f 696e e.target endpoin │ │ │ -00072fb0: 7420 6973 206f 6620 7468 6520 7072 6f78 t is of the prox │ │ │ -00072fc0: 793c 2f68 323e 3c68 343e 2e2e 2f69 6e63 y

    ../inc │ │ │ -00072fd0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00072fe0: 736f 636b 7335 5f73 7472 6561 6d2e 6870 socks5_stream.hp │ │ │ -00072ff0: 703a 3137 363c 2f68 343e 3c70 7265 2073 p:176

    ...}, std::m
    │ │ │ -00073040: 6f76 6528 6861 6e64 6c65 7229 2929 3b0a  ove(handler)));.
    │ │ │ -00073050: 097d 0a0a 7072 6976 6174 653a 0a0a 0974  .}..private:...t
    │ │ │ -00073060: 656d 706c 6174 6520 266c 743b 7479 7065  emplate <type
    │ │ │ -00073070: 6e61 6d65 2048 616e 646c 6572 2667 743b  name Handler>
    │ │ │ -00073080: 0a09 766f 6964 206e 616d 655f 6c6f 6f6b  ..void name_look
    │ │ │ -00073090: 7570 2865 7272 6f72 5f63 6f64 6520 636f  up(error_code co
    │ │ │ -000730a0: 6e73 7426 616d 703b 2065 2c20 7463 703a  nst& e, tcp:
    │ │ │ -000730b0: 3a72 6573 6f6c 7665 723a 3a72 6573 756c  :resolver::resul
    │ │ │ -000730c0: 7473 5f74 7970 6520 6970 730a 0909 2c20  ts_type ips..., 
    │ │ │ -000730d0: 4861 6e64 6c65 7220 6829 0a09 7b0a 0909  Handler h)..{...
    │ │ │ -000730e0: 434f 4d50 4c45 5445 5f41 5359 4e43 2822  COMPLETE_ASYNC("
    │ │ │ -000730f0: 736f 636b 7335 5f73 7472 6561 6d3a 3a6e  socks5_stream::n
    │ │ │ -00073100: 616d 655f 6c6f 6f6b 7570 2229 3b0a 0909  ame_lookup");...
    │ │ │ -00073110: 6966 2028 6861 6e64 6c65 5f65 7272 6f72  if (handle_error
    │ │ │ -00073120: 2865 2c20 7374 643a 3a6d 6f76 6528 6829  (e, std::move(h)
    │ │ │ -00073130: 2929 2072 6574 7572 6e3b 0a0a 0909 6175  )) return;....au
    │ │ │ -00073140: 746f 2069 203d 2069 7073 2e62 6567 696e  to i = ips.begin
    │ │ │ -00073150: 2829 3b0a 0909 6966 2028 216d 5f73 6f63  ();...if (!m_soc
    │ │ │ -00073160: 6b2e 6973 5f6f 7065 6e28 2929 0a09 097b  k.is_open())...{
    │ │ │ -00073170: 0a09 0909 6572 726f 725f 636f 6465 2065  ....error_code e
    │ │ │ -00073180: 633b 0a09 0909 6d5f 736f 636b 2e6f 7065  c;....m_sock.ope
    │ │ │ -00073190: 6e28 692d 2667 743b 656e 6470 6f69 6e74  n(i->endpoint
    │ │ │ -000731a0: 2829 2e70 726f 746f 636f 6c28 292c 2065  ().protocol(), e
    │ │ │ -000731b0: 6329 3b0a 0909 0969 6620 2868 616e 646c  c);....if (handl
    │ │ │ -000731c0: 655f 6572 726f 7228 6563 2c20 7374 643a  e_error(ec, std:
    │ │ │ -000731d0: 3a6d 6f76 6528 6829 2929 2072 6574 7572  :move(h))) retur
    │ │ │ -000731e0: 6e3b 0a09 097d 0a0a 3c64 6976 2073 7479  n;...}..
    ..ADD_OUTS │ │ │ -00073220: 5441 4e44 494e 475f 4153 594e 4328 2273 TANDING_ASYNC("s │ │ │ -00073230: 6f63 6b73 355f 7374 7265 616d 3a3a 636f ocks5_stream::co │ │ │ -00073240: 6e6e 6563 7465 6422 293b 0a3c 2f64 6976 nnected");.
    ..m_sock.async_ │ │ │ -00073260: 636f 6e6e 6563 7428 692d 2667 743b 656e connect(i->en │ │ │ -00073270: 6470 6f69 6e74 2829 2c20 6175 783a 3a77 dpoint(), aux::w │ │ │ -00073280: 7261 705f 616c 6c6f 6361 746f 7228 0a09 rap_allocator(.. │ │ │ -00073290: 0909 5b74 6869 735d 2865 7272 6f72 5f63 ..[this](error_c │ │ │ -000732a0: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ -000732b0: 632c 2048 616e 646c 6572 2068 6e29 0a09 c, Handler hn).. │ │ │ -000732c0: 0909 7b20 636f 6e6e 6563 7465 6428 6563 ..{ connected(ec │ │ │ -000732d0: 2c20 7374 643a 3a6d 6f76 6528 686e 2929 , std::move(hn)) │ │ │ -000732e0: 3b20 7d2c 2073 7464 3a3a 6d6f 7665 2868 ; }, std::move(h │ │ │ -000732f0: 2929 293b 0a09 7d0a 0a09 7465 6d70 6c61 )));..}...templa │ │ │ -00073300: 7465 2026 6c74 3b74 7970 656e 616d 6520 te <typename │ │ │ -00073310: 4861 6e64 6c65 7226 6774 3b0a 0976 6f69 Handler>..voi │ │ │ -00073320: 6420 636f 6e6e 6563 7465 6428 6572 726f d connected(erro │ │ │ -00073330: 725f 636f 6465 2063 6f6e 7374 2661 6d70 r_code const& │ │ │ -00073340: 3b20 652c 2048 616e 646c 6572 2068 290a ; e, Handler h). │ │ │ -00073350: 097b 0a09 0943 4f4d 504c 4554 455f 4153 .{...COMPLETE_AS │ │ │ -00073360: 594e 4328 2273 6f63 6b73 355f 7374 7265 YNC("socks5_stre │ │ │ -00073370: 616d 3a3a 636f 6e6e 6563 7465 6422 293b am::connected"); │ │ │ -00073380: 0a09 0969 6620 2868 616e 646c 655f 6572 ...if (handle_er │ │ │ -00073390: 726f 7228 652c 2073 7464 3a3a 6d6f 7665 ror(e, std::move │ │ │ -000733a0: 2868 2929 2920 7265 7475 726e 3b0a 0a09 (h))) return;... │ │ │ -000733b0: 0975 7369 6e67 206e 616d 6573 7061 6365 .using namespace │ │ │ -000733c0: 206c 6962 746f 7272 656e 743a 3a61 7578 libtorrent::aux │ │ │ -000733d0: 3b0a 0909 6966 2028 6d5f 7665 7273 696f ;...if (m_versio │ │ │ -000733e0: 6e20 3d3d 2035 290a 0909 7b0a 0909 092f n == 5)...{..../ │ │ │ -000733f0: 2f20 7365 6e64 2053 4f43 4b53 3520 6175 / send SOCKS5 au │ │ │ -00073400: 7468 656e 7469 6361 7469 6f6e 206d 6574 thentication met │ │ │ -00073410: 686f 6473 0a09 0909 6d5f 6275 6666 6572 hods....m_buffer │ │ │ -00073420: 2e72 6573 697a 6528 6d5f 7573 6572 2e65 .resize(m_user.e │ │ │ -00073430: 6d70 7479 2829 3f33 3a34 293b 0a09 0909 mpty()?3:4);.... │ │ │ -00073440: 6368 6172 2a20 7020 3d20 2661 6d70 3b6d char* p = &m │ │ │ -00073450: 5f62 7566 6665 725b 305d 3b0a 0909 0977 _buffer[0];....w │ │ │ -00073460: 7269 7465 5f75 696e 7438 2835 2c20 7029 rite_uint8(5, p) │ │ │ -00073470: 3b20 2f2f 2053 4f43 4b53 2056 4552 5349 ; // SOCKS VERSI │ │ │ -00073480: 4f4e 2035 0a09 0909 6966 2028 6d5f 7573 ON 5....if (m_us │ │ │ -00073490: 6572 2e65 6d70 7479 2829 290a 0909 097b er.empty())....{ │ │ │ -000734a0: 0a09 0909 0977 7269 7465 5f75 696e 7438 .....write_uint8 │ │ │ -000734b0: 2831 2c20 7029 3b20 2f2f 2031 2061 7574 (1, p); // 1 aut │ │ │ -000734c0: 6865 6e74 6963 6174 696f 6e20 6d65 7468 hentication meth │ │ │ -000734d0: 6f64 2028 6e6f 2061 7574 6829 0a09 0909 od (no auth).... │ │ │ -000734e0: 0977 7269 7465 5f75 696e 7438 2830 2c20 .write_uint8(0, │ │ │ -000734f0: 7029 3b20 2f2f 206e 6f20 6175 7468 656e p); // no authen │ │ │ -00073500: 7469 6361 7469 6f6e 0a09 0909 7d0a 0909 tication....}... │ │ │ -00073510: 0965 6c73 650a 0909 097b 0a09 0909 0977 .else....{.....w │ │ │ -00073520: 7269 7465 5f75 696e 7438 2832 2c20 7029 rite_uint8(2, p) │ │ │ -00073530: 3b20 2f2f 2032 2061 7574 6865 6e74 6963 ; // 2 authentic │ │ │ -00073540: 6174 696f 6e20 6d65 7468 6f64 730a 0909 ation methods... │ │ │ -00073550: 0909 7772 6974 655f 7569 6e74 3828 302c ..write_uint8(0, │ │ │ -00073560: 2070 293b 202f 2f20 6e6f 2061 7574 6865 p); // no authe │ │ │ -00073570: 6e74 6963 6174 696f 6e0a 0909 0909 7772 ntication.....wr │ │ │ -00073580: 6974 655f 7569 6e74 3828 322c 2070 293b ite_uint8(2, p); │ │ │ -00073590: 202f 2f20 7573 6572 6e61 6d65 2f70 6173 // username/pas │ │ │ -000735a0: 7377 6f72 640a 0909 097d 0a09 0909 4144 sword....}....AD │ │ │ -000735b0: 445f 4f55 5453 5441 4e44 494e 475f 4153 D_OUTSTANDING_AS │ │ │ -000735c0: 594e 4328 2273 6f63 6b73 355f 7374 7265 YNC("socks5_stre │ │ │ -000735d0: 616d 3a3a 6861 6e64 7368 616b 6531 2229 am::handshake1") │ │ │ -000735e0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ -00073610: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00073620: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00073650: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00073660: 6e74 2f61 6e6e 6f75 6e63 655f 656e 7472 nt/announce_entr │ │ │ -00073670: 792e 6870 703a 3539 3c2f 613e 3c2f 7464 y.hpp:59include the │ │ │ -00073690: 206e 756d 6265 7220 6f66 2070 6565 7273 number of peers │ │ │ -000736a0: 2072 6563 6569 7665 6420 6672 6f6d 2074 received from t │ │ │ -000736b0: 6869 7320 7472 6163 6b65 722c 2061 7420 his tracker, at │ │ │ -000736c0: 6c61 7374 2061 6e6e 6f75 6e63 653c 2f74 last announce

    inclu │ │ │ -00073720: 6465 2074 6865 206e 756d 6265 7220 6f66 de the number of │ │ │ -00073730: 2070 6565 7273 2072 6563 6569 7665 6420 peers received │ │ │ -00073740: 6672 6f6d 2074 6869 7320 7472 6163 6b65 from this tracke │ │ │ -00073750: 722c 2061 7420 6c61 7374 0a61 6e6e 6f75 r, at last.annou │ │ │ -00073760: 6e63 653c 2f68 323e 3c68 343e 2e2e 2f69 nce

    ../i │ │ │ -00073770: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00073780: 742f 616e 6e6f 756e 6365 5f65 6e74 7279 t/announce_entry │ │ │ -00073790: 2e68 7070 3a35 393c 2f68 343e 3c70 7265 .hpp:59

    // for eac
    │ │ │ -000737e0: 6820 7072 6f74 6f63 6f6c 2076 6572 7369  h protocol versi
    │ │ │ -000737f0: 6f6e 2e0a 7374 7275 6374 2054 4f52 5245  on..struct TORRE
    │ │ │ -00073800: 4e54 5f45 5850 4f52 5420 616e 6e6f 756e  NT_EXPORT announ
    │ │ │ -00073810: 6365 5f69 6e66 6f68 6173 680a 7b0a 092f  ce_infohash.{../
    │ │ │ -00073820: 2f20 696e 7465 726e 616c 0a09 544f 5252  / internal..TORR
    │ │ │ -00073830: 454e 545f 554e 4558 504f 5254 2061 6e6e  ENT_UNEXPORT ann
    │ │ │ -00073840: 6f75 6e63 655f 696e 666f 6861 7368 2829  ounce_infohash()
    │ │ │ -00073850: 3b0a 0a09 2f2f 2069 6620 7468 6973 2074  ;...// if this t
    │ │ │ -00073860: 7261 636b 6572 2068 6173 2072 6574 7572  racker has retur
    │ │ │ -00073870: 6e65 6420 616e 2065 7272 6f72 206f 7220  ned an error or 
    │ │ │ -00073880: 7761 726e 696e 6720 6d65 7373 6167 650a  warning message.
    │ │ │ -00073890: 092f 2f20 7468 6174 206d 6573 7361 6765  .// that message
    │ │ │ -000738a0: 2069 7320 7374 6f72 6564 2068 6572 650a   is stored here.
    │ │ │ -000738b0: 0973 7464 3a3a 7374 7269 6e67 206d 6573  .std::string mes
    │ │ │ -000738c0: 7361 6765 3b0a 0a09 2f2f 2069 6620 7468  sage;...// if th
    │ │ │ -000738d0: 6973 2074 7261 636b 6572 2066 6169 6c65  is tracker faile
    │ │ │ -000738e0: 6420 7468 6520 6c61 7374 2074 696d 6520  d the last time 
    │ │ │ -000738f0: 6974 2077 6173 2063 6f6e 7461 6374 6564  it was contacted
    │ │ │ -00073900: 0a09 2f2f 2074 6869 7320 6572 726f 7220  ..// this error 
    │ │ │ -00073910: 636f 6465 2073 7065 6369 6669 6573 2077  code specifies w
    │ │ │ -00073920: 6861 7420 6572 726f 7220 6f63 6375 7272  hat error occurr
    │ │ │ -00073930: 6564 0a09 6572 726f 725f 636f 6465 206c  ed..error_code l
    │ │ │ -00073940: 6173 745f 6572 726f 723b 0a0a 092f 2f20  ast_error;...// 
    │ │ │ -00073950: 7468 6520 7469 6d65 206f 6620 6e65 7874  the time of next
    │ │ │ -00073960: 2074 7261 636b 6572 2061 6e6e 6f75 6e63   tracker announc
    │ │ │ -00073970: 650a 0974 696d 655f 706f 696e 7433 3220  e..time_point32 
    │ │ │ -00073980: 6e65 7874 5f61 6e6e 6f75 6e63 6520 3d20  next_announce = 
    │ │ │ -00073990: 2874 696d 655f 706f 696e 7433 323a 3a6d  (time_point32::m
    │ │ │ -000739a0: 696e 2928 293b 0a0a 092f 2f20 6e6f 2061  in)();...// no a
    │ │ │ -000739b0: 6e6e 6f75 6e63 6573 2062 6566 6f72 6520  nnounces before 
    │ │ │ -000739c0: 7468 6973 2074 696d 650a 0974 696d 655f  this time..time_
    │ │ │ -000739d0: 706f 696e 7433 3220 6d69 6e5f 616e 6e6f  point32 min_anno
    │ │ │ -000739e0: 756e 6365 203d 2028 7469 6d65 5f70 6f69  unce = (time_poi
    │ │ │ -000739f0: 6e74 3332 3a3a 6d69 6e29 2829 3b0a 0a3c  nt32::min)();..<
    │ │ │ -00073a00: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -00073a10: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -00073a20: 7769 6474 683d 2231 3030 2522 3e0a 3c2f  width="100%">..// these ar
    │ │ │ -00073a40: 6520 6569 7468 6572 202d 3120 6f72 2074  e either -1 or t
    │ │ │ -00073a50: 6865 2073 6372 6170 6520 696e 666f 726d  he scrape inform
    │ │ │ -00073a60: 6174 696f 6e20 7468 6973 2074 7261 636b  ation this track
    │ │ │ -00073a70: 6572 206c 6173 740a 092f 2f20 7265 7370  er last..// resp
    │ │ │ -00073a80: 6f6e 6465 6420 7769 7468 2e20 2a69 6e63  onded with. *inc
    │ │ │ -00073a90: 6f6d 706c 6574 652a 2069 7320 7468 6520  omplete* is the 
    │ │ │ -00073aa0: 6375 7272 656e 7420 6e75 6d62 6572 206f  current number o
    │ │ │ -00073ab0: 6620 646f 776e 6c6f 6164 6572 7320 696e  f downloaders in
    │ │ │ -00073ac0: 0a09 2f2f 2074 6865 2073 7761 726d 2c20  ..// the swarm, 
    │ │ │ -00073ad0: 2a63 6f6d 706c 6574 652a 2069 7320 7468  *complete* is th
    │ │ │ -00073ae0: 6520 6375 7272 656e 7420 6e75 6d62 6572  e current number
    │ │ │ -00073af0: 206f 6620 7365 6564 7320 696e 2074 6865   of seeds in the
    │ │ │ -00073b00: 2073 7761 726d 2061 6e64 0a09 2f2f 202a   swarm and..// *
    │ │ │ -00073b10: 646f 776e 6c6f 6164 6564 2a20 6973 2074  downloaded* is t
    │ │ │ -00073b20: 6865 2063 756d 756c 6174 6976 6520 6e75  he cumulative nu
    │ │ │ -00073b30: 6d62 6572 206f 6620 636f 6d70 6c65 7465  mber of complete
    │ │ │ -00073b40: 6420 646f 776e 6c6f 6164 7320 6f66 2074  d downloads of t
    │ │ │ -00073b50: 6869 730a 092f 2f20 746f 7272 656e 742c  his..// torrent,
    │ │ │ -00073b60: 2073 696e 6365 2074 6865 2062 6567 696e   since the begin
    │ │ │ -00073b70: 6e69 6e67 206f 6620 7469 6d65 2028 6672  ning of time (fr
    │ │ │ -00073b80: 6f6d 2074 6869 7320 7472 6163 6b65 7227  om this tracker'
    │ │ │ -00073b90: 7320 706f 696e 7420 6f66 0a09 2f2f 2076  s point of..// v
    │ │ │ -00073ba0: 6965 7729 2e0a 0a09 2f2f 2069 6620 7468  iew)....// if th
    │ │ │ -00073bb0: 6973 2074 7261 636b 6572 2068 6173 2072  is tracker has r
    │ │ │ -00073bc0: 6574 7572 6e65 6420 7363 7261 7065 2064  eturned scrape d
    │ │ │ -00073bd0: 6174 612c 2074 6865 7365 2066 6965 6c64  ata, these field
    │ │ │ -00073be0: 7320 6172 6520 6669 6c6c 6564 2069 6e0a  s are filled in.
    │ │ │ -00073bf0: 092f 2f20 7769 7468 2076 616c 6964 206e  .// with valid n
    │ │ │ -00073c00: 756d 6265 7273 2e20 4f74 6865 7277 6973  umbers. Otherwis
    │ │ │ -00073c10: 6520 7468 6579 2061 7265 2073 6574 2074  e they are set t
    │ │ │ -00073c20: 6f20 2d31 2e20 6060 696e 636f 6d70 6c65  o -1. ``incomple
    │ │ │ -00073c30: 7465 6060 2063 6f75 6e74 730a 092f 2f20  te`` counts..// 
    │ │ │ -00073c40: 7468 6520 6e75 6d62 6572 206f 6620 6375  the number of cu
    │ │ │ -00073c50: 7272 656e 7420 646f 776e 6c6f 6164 6572  rrent downloader
    │ │ │ -00073c60: 732e 2060 6063 6f6d 706c 6574 6560 6020  s. ``complete`` 
    │ │ │ -00073c70: 636f 756e 7473 2074 6865 206e 756d 6265  counts the numbe
    │ │ │ -00073c80: 7220 6f66 0a09 2f2f 2063 7572 7265 6e74  r of..// current
    │ │ │ -00073c90: 2070 6565 7273 2063 6f6d 706c 6574 6564   peers completed
    │ │ │ -00073ca0: 2074 6865 2064 6f77 6e6c 6f61 642c 206f   the download, o
    │ │ │ -00073cb0: 7220 2273 6565 6473 222e 2060 6064 6f77  r "seeds". ``dow
    │ │ │ -00073cc0: 6e6c 6f61 6465 6460 6020 6973 2074 6865  nloaded`` is the
    │ │ │ -00073cd0: 0a09 2f2f 2063 756d 756c 6174 6976 6520  ..// cumulative 
    │ │ │ -00073ce0: 6e75 6d62 6572 206f 6620 636f 6d70 6c65  number of comple
    │ │ │ -00073cf0: 7465 6420 646f 776e 6c6f 6164 732e 0a09  ted downloads...
    │ │ │ -00073d00: 696e 7420 7363 7261 7065 5f69 6e63 6f6d  int scrape_incom
    │ │ │ -00073d10: 706c 6574 6520 3d20 2d31 3b0a 0969 6e74  plete = -1;..int
    │ │ │ -00073d20: 2073 6372 6170 655f 636f 6d70 6c65 7465   scrape_complete
    │ │ │ -00073d30: 203d 202d 313b 0a09 696e 7420 7363 7261   = -1;..int scra
    │ │ │ -00073d40: 7065 5f64 6f77 6e6c 6f61 6465 6420 3d20  pe_downloaded = 
    │ │ │ -00073d50: 2d31 3b0a 0a09 2f2f 2074 6865 206e 756d  -1;...// the num
    │ │ │ -00073d60: 6265 7220 6f66 2074 696d 6573 2069 6e20  ber of times in 
    │ │ │ -00073d70: 6120 726f 7720 7765 2068 6176 6520 6661  a row we have fa
    │ │ │ -00073d80: 696c 6564 2074 6f20 616e 6e6f 756e 6365  iled to announce
    │ │ │ -00073d90: 2074 6f20 7468 6973 0a09 2f2f 2074 7261   to this..// tra
    │ │ │ -00073da0: 636b 6572 2e0a 0973 7464 3a3a 7569 6e74  cker...std::uint
    │ │ │ -00073db0: 385f 7420 6661 696c 7320 3a20 373b 0a0a  8_t fails : 7;..
    │ │ │ -00073dc0: 092f 2f20 7472 7565 2077 6869 6c65 2077  .// true while w
    │ │ │ -00073dd0: 6527 7265 2077 6169 7469 6e67 2066 6f72  e're waiting for
    │ │ │ -00073de0: 2061 2072 6573 706f 6e73 6520 6672 6f6d   a response from
    │ │ │ -00073df0: 2074 6865 2074 7261 636b 6572 2e0a 0962   the tracker...b
    │ │ │ -00073e00: 6f6f 6c20 7570 6461 7469 6e67 203a 2031  ool updating : 1
    │ │ │ -00073e10: 3b0a 0a09 2f2f 2073 6574 2074 6f20 7472  ;...// set to tr
    │ │ │ -00073e20: 7565 2077 6865 6e20 7765 2067 6574 2061  ue when we get a
    │ │ │ -00073e30: 2076 616c 6964 2072 6573 706f 6e73 6520   valid response 
    │ │ │ -00073e40: 6672 6f6d 2061 6e20 616e 6e6f 756e 6365  from an announce
    │ │ │ -00073e50: 0a09 2f2f 2077 6974 6820 6576 656e 743d  ..// with event=
    │ │ │ -00073e60: 7374 6172 7465 642e 2049 6620 6974 2069  started. If it i
    │ │ │ -00073e70: 7320 7365 742c 2077 6520 776f 6e27 7420  s set, we won't 
    │ │ │ -00073e80: 7365 6e64 2073 7461 7274 2069 6e20 7468  send start in th
    │ │ │ -00073e90: 6520 7375 6273 6571 7565 6e74 0a09 2f2f  e subsequent..//
    │ │ │ -00073ea0: 2061 6e6e 6f75 6e63 6573 2e0a 0962 6f6f   announces...boo
    │ │ │ -00073eb0: 6c20 7374 6172 745f 7365 6e74 203a 2031  l start_sent : 1
    │ │ │ -00073ec0: 3b0a 0a09 2f2f 2073 6574 2074 6f20 7472  ;...// set to tr
    │ │ │ -00073ed0: 7565 2077 6865 6e20 7765 2073 656e 6420  ue when we send 
    │ │ │ -00073ee0: 6120 6576 656e 743d 636f 6d70 6c65 7465  a event=complete
    │ │ │ -00073ef0: 642e 0a09 626f 6f6c 2063 6f6d 706c 6574  d...bool complet
    │ │ │ -00073f00: 655f 7365 6e74 203a 2031 3b0a 3c2f 7072  e_sent : 1;.rel
    │ │ │ -00073f40: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../includ
    │ │ │ -00073f80: 652f 6c69 6274 6f72 7265 6e74 2f6b 6164  e/libtorrent/kad
    │ │ │ -00073f90: 656d 6c69 612f 6d73 672e 6870 703a 3634  emlia/msg.hpp:64
    │ │ │ -00073fa0: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 6f76  mov
    │ │ │ -00073fb0: 6520 7468 6973 2074 6f20 6974 7320 6f77  e this to its ow
    │ │ │ -00073fc0: 6e20 2e68 7070 2f2e 6370 7020 7061 6972  n .hpp/.cpp pair
    │ │ │ -00073fd0: 3f3c 2f74 643e 3c2f 7472 3e3c 7472 2069  ?

    m │ │ │ -00074020: 6f76 6520 7468 6973 2074 6f20 6974 7320 ove this to its │ │ │ -00074030: 6f77 6e20 2e68 7070 2f2e 6370 7020 7061 own .hpp/.cpp pa │ │ │ -00074040: 6972 3f3c 2f68 323e 3c68 343e 2e2e 2f69 ir?

    ../i │ │ │ -00074050: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00074060: 742f 6b61 6465 6d6c 6961 2f6d 7367 2e68 t/kademlia/msg.h │ │ │ -00074070: 7070 3a36 343c 2f68 343e 3c70 7265 2073 pp:64

    .int flags;.
    │ │ │ -000740c0: 0a09 656e 756d 207b 0a09 092f 2f20 7468  ..enum {...// th
    │ │ │ -000740d0: 6973 2061 7267 756d 656e 7420 6973 206f  is argument is o
    │ │ │ -000740e0: 7074 696f 6e61 6c2c 2070 6172 7369 6e67  ptional, parsing
    │ │ │ -000740f0: 2077 696c 6c20 6e6f 740a 0909 2f2f 2066   will not...// f
    │ │ │ -00074100: 6169 6c20 6966 2069 7427 7320 6e6f 7420  ail if it's not 
    │ │ │ -00074110: 7072 6573 656e 740a 0909 6f70 7469 6f6e  present...option
    │ │ │ -00074120: 616c 203d 2031 2c0a 0909 2f2f 2066 6f72  al = 1,...// for
    │ │ │ -00074130: 2064 6963 7469 6f6e 6172 6965 732c 2074   dictionaries, t
    │ │ │ -00074140: 6865 2066 6f6c 6c6f 7769 6e67 2065 6e74  he following ent
    │ │ │ -00074150: 7269 6573 2072 6566 6572 0a09 092f 2f20  ries refer...// 
    │ │ │ -00074160: 746f 2063 6869 6c64 206e 6f64 6573 2074  to child nodes t
    │ │ │ -00074170: 6f20 7468 6973 206e 6f64 652c 2075 7020  o this node, up 
    │ │ │ -00074180: 756e 7469 6c20 616e 6420 696e 636c 7564  until and includ
    │ │ │ -00074190: 696e 670a 0909 2f2f 2074 6865 206e 6578  ing...// the nex
    │ │ │ -000741a0: 7420 6974 656d 2074 6861 7420 6861 7320  t item that has 
    │ │ │ -000741b0: 7468 6520 6c61 7374 5f63 6869 6c64 2066  the last_child f
    │ │ │ -000741c0: 6c61 6720 7365 742e 0a09 092f 2f20 7468  lag set....// th
    │ │ │ -000741d0: 6573 6520 666c 6167 7320 6172 6520 6e65  ese flags are ne
    │ │ │ -000741e0: 7374 6162 6c65 0a09 0970 6172 7365 5f63  stable...parse_c
    │ │ │ -000741f0: 6869 6c64 7265 6e20 3d20 322c 0a09 092f  hildren = 2,.../
    │ │ │ -00074200: 2f20 7468 6973 2069 7320 7468 6520 6c61  / this is the la
    │ │ │ -00074210: 7374 2069 7465 6d20 696e 2061 2063 6869  st item in a chi
    │ │ │ -00074220: 6c64 2064 6963 7469 6f6e 6172 790a 0909  ld dictionary...
    │ │ │ -00074230: 6c61 7374 5f63 6869 6c64 203d 2034 2c0a  last_child = 4,.
    │ │ │ -00074240: 0909 2f2f 2074 6865 2073 697a 6520 6172  ..// the size ar
    │ │ │ -00074250: 6775 6d65 6e74 2072 6566 6572 7320 746f  gument refers to
    │ │ │ -00074260: 2074 6861 7420 7468 6520 7369 7a65 0a09   that the size..
    │ │ │ -00074270: 092f 2f20 6861 7320 746f 2062 6520 6469  .// has to be di
    │ │ │ -00074280: 7669 7369 626c 6520 6279 2074 6865 206e  visible by the n
    │ │ │ -00074290: 756d 6265 722c 2069 6e73 7465 6164 0a09  umber, instead..
    │ │ │ -000742a0: 092f 2f20 6f66 2068 6176 696e 6720 7468  .// of having th
    │ │ │ -000742b0: 6174 2065 7861 6374 2073 697a 650a 0909  at exact size...
    │ │ │ -000742c0: 7369 7a65 5f64 6976 6973 6962 6c65 203d  size_divisible =
    │ │ │ -000742d0: 2038 0a09 7d3b 0a7d 3b0a 0a3c 6469 7620   8..};.};..
    TORRENT │ │ │ -00074310: 5f45 5854 5241 5f45 5850 4f52 5420 626f _EXTRA_EXPORT bo │ │ │ -00074320: 6f6c 2076 6572 6966 795f 6d65 7373 6167 ol verify_messag │ │ │ -00074330: 655f 696d 706c 2862 6465 636f 6465 5f6e e_impl(bdecode_n │ │ │ -00074340: 6f64 6520 636f 6e73 7426 616d 703b 206d ode const& m │ │ │ -00074350: 6573 7361 6765 2c20 7370 616e 266c 743b essage, span< │ │ │ -00074360: 6b65 795f 6465 7363 5f74 2063 6f6e 7374 key_desc_t const │ │ │ -00074370: 2667 743b 2064 6573 630a 3c2f 6469 763e > desc.
    │ │ │ -00074380: 092c 2073 7061 6e26 6c74 3b62 6465 636f ., span<bdeco │ │ │ -00074390: 6465 5f6e 6f64 6526 6774 3b20 7265 742c de_node> ret, │ │ │ -000743a0: 2073 7061 6e26 6c74 3b63 6861 7226 6774 span<char> │ │ │ -000743b0: 3b20 6572 726f 7229 3b0a 0a2f 2f20 7665 ; error);..// ve │ │ │ -000743c0: 7269 6669 6573 2074 6861 7420 6120 6d65 rifies that a me │ │ │ -000743d0: 7373 6167 6520 6861 7320 616c 6c20 7468 ssage has all th │ │ │ -000743e0: 6520 7265 7175 6972 6564 0a2f 2f20 656e e required.// en │ │ │ -000743f0: 7472 6965 7320 616e 6420 7265 7475 726e tries and return │ │ │ -00074400: 7320 7468 656d 2069 6e20 7265 740a 7465 s them in ret.te │ │ │ -00074410: 6d70 6c61 7465 2026 6c74 3b69 6e74 2053 mplate <int S │ │ │ -00074420: 697a 6526 6774 3b0a 626f 6f6c 2076 6572 ize>.bool ver │ │ │ -00074430: 6966 795f 6d65 7373 6167 6528 6264 6563 ify_message(bdec │ │ │ -00074440: 6f64 655f 6e6f 6465 2063 6f6e 7374 2661 ode_node const&a │ │ │ -00074450: 6d70 3b20 6d73 672c 206b 6579 5f64 6573 mp; msg, key_des │ │ │ -00074460: 635f 7420 636f 6e73 7420 2826 616d 703b c_t const (& │ │ │ -00074470: 6465 7363 295b 5369 7a65 5d0a 092c 2062 desc)[Size].., b │ │ │ -00074480: 6465 636f 6465 5f6e 6f64 6520 2826 616d decode_node (&am │ │ │ -00074490: 703b 7265 7429 5b53 697a 655d 2c20 7370 p;ret)[Size], sp │ │ │ -000744a0: 616e 266c 743b 6368 6172 2667 743b 2065 an<char> e │ │ │ -000744b0: 7272 6f72 290a 7b0a 0972 6574 7572 6e20 rror).{..return │ │ │ -000744c0: 7665 7269 6679 5f6d 6573 7361 6765 5f69 verify_message_i │ │ │ -000744d0: 6d70 6c28 6d73 672c 2064 6573 632c 2072 mpl(msg, desc, r │ │ │ -000744e0: 6574 2c20 6572 726f 7229 3b0a 7d0a 0a7d et, error);.}..} │ │ │ -000744f0: 0a7d 0a0a 2365 6e64 6966 0a3c 2f70 7265 .}..#endif.
    rele │ │ │ -00074530: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -00074570: 2f6c 6962 746f 7272 656e 742f 6b61 6465 /libtorrent/kade │ │ │ -00074580: 6d6c 6961 2f69 7465 6d2e 6870 703a 3338 mlia/item.hpp:38 │ │ │ -00074590: 3c2f 613e 3c2f 7464 3e3c 7464 3e73 696e sin │ │ │ -000745a0: 6365 2074 6869 7320 6973 2061 2070 7562 ce this is a pub │ │ │ -000745b0: 6c69 6320 6675 6e63 7469 6f6e 2c20 6974 lic function, it │ │ │ -000745c0: 2073 686f 756c 6420 7072 6f62 6162 6c79 should probably │ │ │ -000745d0: 2062 6520 6d6f 7665 6420 6f75 7420 6f66 be moved out of │ │ │ -000745e0: 2074 6869 7320 6865 6164 6572 2061 6e64 this header and │ │ │ -000745f0: 2069 6e74 6f20 6f6e 6520 7769 7468 206f into one with o │ │ │ -00074600: 7468 6572 2070 7562 6c69 6320 6675 6e63 ther public func │ │ │ -00074610: 7469 6f6e 732e 3c2f 7464 3e3c 2f74 723e tions. │ │ │ -00074620: 3c74 7220 6964 3d22 3236 3722 2073 7479 │ │ │ -00074650: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00074660: 3c68 323e 7369 6e63 6520 7468 6973 2069

    since this i │ │ │ -00074670: 7320 6120 7075 626c 6963 2066 756e 6374 s a public funct │ │ │ -00074680: 696f 6e2c 2069 7420 7368 6f75 6c64 2070 ion, it should p │ │ │ -00074690: 726f 6261 626c 7920 6265 206d 6f76 6564 robably be moved │ │ │ -000746a0: 0a6f 7574 206f 6620 7468 6973 2068 6561 .out of this hea │ │ │ -000746b0: 6465 7220 616e 6420 696e 746f 206f 6e65 der and into one │ │ │ -000746c0: 2077 6974 6820 6f74 6865 7220 7075 626c with other publ │ │ │ -000746d0: 6963 2066 756e 6374 696f 6e73 2e3c 2f68 ic functions.

    ../include │ │ │ -000746f0: 2f6c 6962 746f 7272 656e 742f 6b61 6465 /libtorrent/kade │ │ │ -00074700: 6d6c 6961 2f69 7465 6d2e 6870 703a 3338 mlia/item.hpp:38 │ │ │ -00074710: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ -00074750: 696e 636c 7564 6520 266c 743b 6c69 6274  include <libt
    │ │ │ -00074760: 6f72 7265 6e74 2f73 7061 6e2e 6870 7026  orrent/span.hpp&
    │ │ │ -00074770: 6774 3b0a 2369 6e63 6c75 6465 2026 6c74  gt;.#include <
    │ │ │ -00074780: 3b6c 6962 746f 7272 656e 742f 6b61 6465  ;libtorrent/kade
    │ │ │ -00074790: 6d6c 6961 2f74 7970 6573 2e68 7070 2667  mlia/types.hpp&g
    │ │ │ -000747a0: 743b 0a0a 6e61 6d65 7370 6163 6520 6c69  t;..namespace li
    │ │ │ -000747b0: 6274 6f72 7265 6e74 207b 0a6e 616d 6573  btorrent {.names
    │ │ │ -000747c0: 7061 6365 2064 6874 207b 0a0a 2f2f 2063  pace dht {..// c
    │ │ │ -000747d0: 616c 6375 6c61 7465 2074 6865 2074 6172  alculate the tar
    │ │ │ -000747e0: 6765 7420 6861 7368 2066 6f72 2061 6e20  get hash for an 
    │ │ │ -000747f0: 696d 6d75 7461 626c 6520 6974 656d 2e0a  immutable item..
    │ │ │ -00074800: 544f 5252 454e 545f 4558 5452 415f 4558  TORRENT_EXTRA_EX
    │ │ │ -00074810: 504f 5254 2073 6861 315f 6861 7368 2069  PORT sha1_hash i
    │ │ │ -00074820: 7465 6d5f 7461 7267 6574 5f69 6428 7370  tem_target_id(sp
    │ │ │ -00074830: 616e 266c 743b 6368 6172 2063 6f6e 7374  an<char const
    │ │ │ -00074840: 2667 743b 2076 293b 0a0a 2f2f 2063 616c  > v);..// cal
    │ │ │ -00074850: 6375 6c61 7465 2074 6865 2074 6172 6765  culate the targe
    │ │ │ -00074860: 7420 6861 7368 2066 6f72 2061 206d 7574  t hash for a mut
    │ │ │ -00074870: 6162 6c65 2069 7465 6d2e 0a54 4f52 5245  able item..TORRE
    │ │ │ -00074880: 4e54 5f45 5854 5241 5f45 5850 4f52 5420  NT_EXTRA_EXPORT 
    │ │ │ -00074890: 7368 6131 5f68 6173 6820 6974 656d 5f74  sha1_hash item_t
    │ │ │ -000748a0: 6172 6765 745f 6964 2873 7061 6e26 6c74  arget_id(span<
    │ │ │ -000748b0: 3b63 6861 7220 636f 6e73 7426 6774 3b20  ;char const> 
    │ │ │ -000748c0: 7361 6c74 0a09 2c20 7075 626c 6963 5f6b  salt.., public_k
    │ │ │ -000748d0: 6579 2063 6f6e 7374 2661 6d70 3b20 706b  ey const& pk
    │ │ │ -000748e0: 293b 0a0a 544f 5252 454e 545f 4558 5452  );..TORRENT_EXTR
    │ │ │ -000748f0: 415f 4558 504f 5254 2062 6f6f 6c20 7665  A_EXPORT bool ve
    │ │ │ -00074900: 7269 6679 5f6d 7574 6162 6c65 5f69 7465  rify_mutable_ite
    │ │ │ -00074910: 6d28 0a09 7370 616e 266c 743b 6368 6172  m(..span<char
    │ │ │ -00074920: 2063 6f6e 7374 2667 743b 2076 0a09 2c20   const> v.., 
    │ │ │ -00074930: 7370 616e 266c 743b 6368 6172 2063 6f6e  span<char con
    │ │ │ -00074940: 7374 2667 743b 2073 616c 740a 092c 2073  st> salt.., s
    │ │ │ -00074950: 6571 7565 6e63 655f 6e75 6d62 6572 2073  equence_number s
    │ │ │ -00074960: 6571 0a09 2c20 7075 626c 6963 5f6b 6579  eq.., public_key
    │ │ │ -00074970: 2063 6f6e 7374 2661 6d70 3b20 706b 0a09   const& pk..
    │ │ │ -00074980: 2c20 7369 676e 6174 7572 6520 636f 6e73  , signature cons
    │ │ │ -00074990: 7426 616d 703b 2073 6967 293b 0a0a 3c64  t& sig);...// given a by
    │ │ │ -000749e0: 7465 2072 616e 6765 2060 6076 6060 2061  te range ``v`` a
    │ │ │ -000749f0: 6e64 2061 6e20 6f70 7469 6f6e 616c 2062  nd an optional b
    │ │ │ -00074a00: 7974 6520 7261 6e67 6520 6060 7361 6c74  yte range ``salt
    │ │ │ -00074a10: 6060 2c20 610a 2f2f 2073 6571 7565 6e63  ``, a.// sequenc
    │ │ │ -00074a20: 6520 6e75 6d62 6572 2c20 7075 626c 6963  e number, public
    │ │ │ -00074a30: 206b 6579 2060 6070 6b60 6020 286d 7573   key ``pk`` (mus
    │ │ │ -00074a40: 7420 6265 2033 3220 6279 7465 7329 2061  t be 32 bytes) a
    │ │ │ -00074a50: 6e64 2061 2073 6563 7265 7420 6b65 790a  nd a secret key.
    │ │ │ -00074a60: 2f2f 2060 6073 6b60 6020 286d 7573 7420  // ``sk`` (must 
    │ │ │ -00074a70: 6265 2036 3420 6279 7465 7329 2c20 7468  be 64 bytes), th
    │ │ │ -00074a80: 6973 2066 756e 6374 696f 6e20 7072 6f64  is function prod
    │ │ │ -00074a90: 7563 6573 2061 2073 6967 6e61 7475 7265  uces a signature
    │ │ │ -00074aa0: 2077 6869 6368 0a2f 2f20 6973 2077 7269   which.// is wri
    │ │ │ -00074ab0: 7474 656e 2069 6e74 6f20 6120 3634 2062  tten into a 64 b
    │ │ │ -00074ac0: 7974 6520 6275 6666 6572 2070 6f69 6e74  yte buffer point
    │ │ │ -00074ad0: 6564 2074 6f20 6279 2060 6073 6967 6060  ed to by ``sig``
    │ │ │ -00074ae0: 2e20 5468 6520 6361 6c6c 6572 0a2f 2f20  . The caller.// 
    │ │ │ -00074af0: 6973 2072 6573 706f 6e73 6962 6c65 2066  is responsible f
    │ │ │ -00074b00: 6f72 2061 6c6c 6f63 6174 696e 6720 7468  or allocating th
    │ │ │ -00074b10: 6520 6465 7374 696e 6174 696f 6e20 6275  e destination bu
    │ │ │ -00074b20: 6666 6572 2074 6861 7427 7320 7061 7373  ffer that's pass
    │ │ │ -00074b30: 6564 2069 6e0a 2f2f 2061 7320 7468 6520  ed in.// as the 
    │ │ │ -00074b40: 6060 7369 6760 6020 6172 6775 6d65 6e74  ``sig`` argument
    │ │ │ -00074b50: 2e20 5479 7069 6361 6c6c 7920 6974 2077  . Typically it w
    │ │ │ -00074b60: 6f75 6c64 2062 6520 616c 6c6f 6361 7465  ould be allocate
    │ │ │ -00074b70: 6420 6f6e 2074 6865 2073 7461 636b 2e0a  d on the stack..
    │ │ │ -00074b80: 544f 5252 454e 545f 4558 504f 5254 2073  TORRENT_EXPORT s
    │ │ │ -00074b90: 6967 6e61 7475 7265 2073 6967 6e5f 6d75  ignature sign_mu
    │ │ │ -00074ba0: 7461 626c 655f 6974 656d 280a 0973 7061  table_item(..spa
    │ │ │ -00074bb0: 6e26 6c74 3b63 6861 7220 636f 6e73 7426  n<char const&
    │ │ │ -00074bc0: 6774 3b20 760a 092c 2073 7061 6e26 6c74  gt; v.., span<
    │ │ │ -00074bd0: 3b63 6861 7220 636f 6e73 7426 6774 3b20  ;char const> 
    │ │ │ -00074be0: 7361 6c74 0a09 2c20 7365 7175 656e 6365  salt.., sequence
    │ │ │ -00074bf0: 5f6e 756d 6265 7220 7365 710a 092c 2070  _number seq.., p
    │ │ │ -00074c00: 7562 6c69 635f 6b65 7920 636f 6e73 7426  ublic_key const&
    │ │ │ -00074c10: 616d 703b 2070 6b0a 092c 2073 6563 7265  amp; pk.., secre
    │ │ │ -00074c20: 745f 6b65 7920 636f 6e73 7426 616d 703b  t_key const&
    │ │ │ -00074c30: 2073 6b29 3b0a 0a63 6c61 7373 2054 4f52   sk);..class TOR
    │ │ │ -00074c40: 5245 4e54 5f45 5854 5241 5f45 5850 4f52  RENT_EXTRA_EXPOR
    │ │ │ -00074c50: 5420 6974 656d 0a7b 0a70 7562 6c69 633a  T item.{.public:
    │ │ │ -00074c60: 0a09 6974 656d 2829 207b 7d0a 0969 7465  ..item() {}..ite
    │ │ │ -00074c70: 6d28 7075 626c 6963 5f6b 6579 2063 6f6e  m(public_key con
    │ │ │ -00074c80: 7374 2661 6d70 3b20 706b 2c20 7370 616e  st& pk, span
    │ │ │ -00074c90: 266c 743b 6368 6172 2063 6f6e 7374 2667  <char const&g
    │ │ │ -00074ca0: 743b 2073 616c 7429 3b0a 0965 7870 6c69  t; salt);..expli
    │ │ │ -00074cb0: 6369 7420 6974 656d 2865 6e74 7279 2076  cit item(entry v
    │ │ │ -00074cc0: 293b 0a09 6974 656d 2865 6e74 7279 2076  );..item(entry v
    │ │ │ -00074cd0: 0a09 092c 2073 7061 6e26 6c74 3b63 6861  ..., span<cha
    │ │ │ -00074ce0: 7220 636f 6e73 7426 6774 3b20 7361 6c74  r const> salt
    │ │ │ -00074cf0: 0a09 092c 2073 6571 7565 6e63 655f 6e75  ..., sequence_nu
    │ │ │ -00074d00: 6d62 6572 2073 6571 0a09 092c 2070 7562  mber seq..., pub
    │ │ │ -00074d10: 6c69 635f 6b65 7920 636f 6e73 7426 616d  lic_key const&am
    │ │ │ -00074d20: 703b 2070 6b0a 0909 2c20 7365 6372 6574  p; pk..., secret
    │ │ │ -00074d30: 5f6b 6579 2063 6f6e 7374 2661 6d70 3b20  _key const& 
    │ │ │ -00074d40: 736b 293b 0a09 6578 706c 6963 6974 2069  sk);..explicit i
    │ │ │ -00074d50: 7465 6d28 6264 6563 6f64 655f 6e6f 6465  tem(bdecode_node
    │ │ │ -00074d60: 2063 6f6e 7374 2661 6d70 3b20 7629 3b0a   const& v);.
    │ │ │ -00074d70: 0a09 766f 6964 2061 7373 6967 6e28 656e  ..void assign(en
    │ │ │ -00074d80: 7472 7920 7629 3b0a 0976 6f69 6420 6173  try v);..void as
    │ │ │ -00074d90: 7369 676e 2865 6e74 7279 2076 2c20 7370  sign(entry v, sp
    │ │ │ -00074da0: 616e 266c 743b 6368 6172 2063 6f6e 7374  an<char const
    │ │ │ -00074db0: 2667 743b 2073 616c 740a 0909 2c20 7365  > salt..., se
    │ │ │ -00074dc0: 7175 656e 6365 5f6e 756d 6265 7220 7365  quence_number se
    │ │ │ -00074dd0: 710a 0909 2c20 7075 626c 6963 5f6b 6579  q..., public_key
    │ │ │ -00074de0: 2063 6f6e 7374 2661 6d70 3b20 706b 0a3c   const& pk.<
    │ │ │ -00074df0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00074e00: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00074e10: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00074e20: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -00074e30: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../inc
    │ │ │ -00074e60: 6c75 6465 2f6c 6962 746f 7272 656e 742f  lude/libtorrent/
    │ │ │ -00074e70: 6175 785f 2f68 6173 685f 7069 636b 6572  aux_/hash_picker
    │ │ │ -00074e80: 2e68 7070 3a31 3333 3c2f 613e 3c2f 7464  .hpp:133support bat
    │ │ │ -00074ea0: 6368 6564 2061 6464 696e 6720 6f66 2062  ched adding of b
    │ │ │ -00074eb0: 6c6f 636b 2068 6173 6865 7320 666f 7220  lock hashes for 
    │ │ │ -00074ec0: 7265 6475 6365 6420 6f76 6572 6865 6164  reduced overhead
    │ │ │ -00074ed0: 3f3c 2f74 643e 3c2f 7472 3e3c 7472 2069  ?

    s │ │ │ -00074f20: 7570 706f 7274 2062 6174 6368 6564 2061 upport batched a │ │ │ -00074f30: 6464 696e 6720 6f66 2062 6c6f 636b 2068 dding of block h │ │ │ -00074f40: 6173 6865 7320 666f 7220 7265 6475 6365 ashes for reduce │ │ │ -00074f50: 6420 6f76 6572 6865 6164 3f3c 2f68 323e d overhead?

    │ │ │ -00074f60: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00074f70: 6962 746f 7272 656e 742f 6175 785f 2f68 ibtorrent/aux_/h │ │ │ -00074f80: 6173 685f 7069 636b 6572 2e68 7070 3a31 ash_picker.hpp:1 │ │ │ -00074f90: 3333 3c2f 6834 3e3c 7072 6520 7374 796c 33

    ..// the number
    │ │ │ -00074fe0: 206f 6620 6861 7368 6573 2069 6e20 7468   of hashes in th
    │ │ │ -00074ff0: 6520 7261 6e67 650a 0909 696e 7420 636f  e range...int co
    │ │ │ -00075000: 756e 7420 3d20 303b 0a09 0969 6e74 2070  unt = 0;...int p
    │ │ │ -00075010: 726f 6f66 5f6c 6179 6572 7320 3d20 303b  roof_layers = 0;
    │ │ │ -00075020: 0a09 7d3b 0a0a 092f 2f20 7661 6c69 6461  ..};...// valida
    │ │ │ -00075030: 7465 7320 7468 6520 6861 7368 5f72 6571  tes the hash_req
    │ │ │ -00075040: 7565 7374 2c20 746f 2065 6e73 7572 6520  uest, to ensure 
    │ │ │ -00075050: 6974 7320 696e 7661 7269 616e 7420 6173  its invariant as
    │ │ │ -00075060: 2077 656c 6c20 6173 206d 6174 6368 696e   well as matchin
    │ │ │ -00075070: 670a 092f 2f20 7468 6520 746f 7272 656e  g..// the torren
    │ │ │ -00075080: 7427 7320 6669 6c65 5f73 746f 7261 6765  t's file_storage
    │ │ │ -00075090: 2061 6e64 2074 6865 206e 756d 6265 7220   and the number 
    │ │ │ -000750a0: 6f66 2068 6173 6865 7320 6163 636f 6d70  of hashes accomp
    │ │ │ -000750b0: 616e 7969 6e67 2074 6865 0a09 2f2f 2072  anying the..// r
    │ │ │ -000750c0: 6571 7565 7374 0a09 544f 5252 454e 545f  equest..TORRENT_
    │ │ │ -000750d0: 4558 5452 415f 4558 504f 5254 0a09 626f  EXTRA_EXPORT..bo
    │ │ │ -000750e0: 6f6c 2076 616c 6964 6174 655f 6861 7368  ol validate_hash
    │ │ │ -000750f0: 5f72 6571 7565 7374 2868 6173 685f 7265  _request(hash_re
    │ │ │ -00075100: 7175 6573 7420 636f 6e73 7426 616d 703b  quest const&
    │ │ │ -00075110: 2068 722c 2066 696c 655f 7374 6f72 6167   hr, file_storag
    │ │ │ -00075120: 6520 636f 6e73 7426 616d 703b 2066 7329  e const& fs)
    │ │ │ -00075130: 3b0a 0a09 636c 6173 7320 544f 5252 454e  ;...class TORREN
    │ │ │ -00075140: 545f 4558 5452 415f 4558 504f 5254 2068  T_EXTRA_EXPORT h
    │ │ │ -00075150: 6173 685f 7069 636b 6572 0a09 7b0a 0970  ash_picker..{..p
    │ │ │ -00075160: 7562 6c69 633a 0a09 0968 6173 685f 7069  ublic:...hash_pi
    │ │ │ -00075170: 636b 6572 2866 696c 655f 7374 6f72 6167  cker(file_storag
    │ │ │ -00075180: 6520 636f 6e73 7426 616d 703b 2066 696c  e const& fil
    │ │ │ -00075190: 6573 0a09 0909 2c20 6175 783a 3a76 6563  es...., aux::vec
    │ │ │ -000751a0: 746f 7226 6c74 3b61 7578 3a3a 6d65 726b  tor<aux::merk
    │ │ │ -000751b0: 6c65 5f74 7265 652c 2066 696c 655f 696e  le_tree, file_in
    │ │ │ -000751c0: 6465 785f 7426 6774 3b26 616d 703b 2074  dex_t>& t
    │ │ │ -000751d0: 7265 6573 293b 0a0a 0909 6861 7368 5f72  rees);....hash_r
    │ │ │ -000751e0: 6571 7565 7374 2070 6963 6b5f 6861 7368  equest pick_hash
    │ │ │ -000751f0: 6573 2874 7970 6564 5f62 6974 6669 656c  es(typed_bitfiel
    │ │ │ -00075200: 6426 6c74 3b70 6965 6365 5f69 6e64 6578  d<piece_index
    │ │ │ -00075210: 5f74 2667 743b 2063 6f6e 7374 2661 6d70  _t> const&
    │ │ │ -00075220: 3b20 7069 6563 6573 293b 0a0a 0909 6164  ; pieces);....ad
    │ │ │ -00075230: 645f 6861 7368 6573 5f72 6573 756c 7420  d_hashes_result 
    │ │ │ -00075240: 6164 645f 6861 7368 6573 2868 6173 685f  add_hashes(hash_
    │ │ │ -00075250: 7265 7175 6573 7420 636f 6e73 7426 616d  request const&am
    │ │ │ -00075260: 703b 2072 6571 2c20 7370 616e 266c 743b  p; req, span<
    │ │ │ -00075270: 7368 6132 3536 5f68 6173 6820 636f 6e73  sha256_hash cons
    │ │ │ -00075280: 7426 6774 3b20 6861 7368 6573 293b 0a3c  t> hashes);.<
    │ │ │ -00075290: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -000752a0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -000752b0: 7769 6474 683d 2231 3030 2522 3e09 0973  width="100%">..s
    │ │ │ -000752c0: 6574 5f62 6c6f 636b 5f68 6173 685f 7265  et_block_hash_re
    │ │ │ -000752d0: 7375 6c74 2073 6574 5f62 6c6f 636b 5f68  sult set_block_h
    │ │ │ -000752e0: 6173 6828 7069 6563 655f 696e 6465 785f  ash(piece_index_
    │ │ │ -000752f0: 7420 7069 6563 652c 2069 6e74 206f 6666  t piece, int off
    │ │ │ -00075300: 7365 742c 2073 6861 3235 365f 6861 7368  set, sha256_hash
    │ │ │ -00075310: 2063 6f6e 7374 2661 6d70 3b20 6829 3b0a   const& h);.
    │ │ │ -00075320: 3c2f 6469 763e 0909 766f 6964 2068 6173  
    ..void has │ │ │ -00075330: 6865 735f 7265 6a65 6374 6564 2868 6173 hes_rejected(has │ │ │ -00075340: 685f 7265 7175 6573 7420 636f 6e73 7426 h_request const& │ │ │ -00075350: 616d 703b 2072 6571 293b 0a09 0976 6f69 amp; req);...voi │ │ │ -00075360: 6420 7665 7269 6679 5f62 6c6f 636b 5f68 d verify_block_h │ │ │ -00075370: 6173 6865 7328 7069 6563 655f 696e 6465 ashes(piece_inde │ │ │ -00075380: 785f 7420 696e 6465 7829 3b0a 0a09 092f x_t index);..../ │ │ │ -00075390: 2f20 646f 2077 6520 6b6e 6f77 2074 6865 / do we know the │ │ │ -000753a0: 2070 6965 6365 206c 6179 6572 2068 6173 piece layer has │ │ │ -000753b0: 6820 666f 7220 6120 7069 6563 650a 0909 h for a piece... │ │ │ -000753c0: 626f 6f6c 2068 6176 655f 6861 7368 2870 bool have_hash(p │ │ │ -000753d0: 6965 6365 5f69 6e64 6578 5f74 2069 6e64 iece_index_t ind │ │ │ -000753e0: 6578 2920 636f 6e73 743b 0a09 092f 2f20 ex) const;...// │ │ │ -000753f0: 646f 2077 6520 6b6e 6f77 2061 6c6c 2074 do we know all t │ │ │ -00075400: 6865 2062 6c6f 636b 2068 6173 6865 7320 he block hashes │ │ │ -00075410: 666f 7220 6120 6669 6c65 3f0a 0909 626f for a file?...bo │ │ │ -00075420: 6f6c 2068 6176 655f 616c 6c28 6669 6c65 ol have_all(file │ │ │ -00075430: 5f69 6e64 6578 5f74 2066 696c 6529 2063 _index_t file) c │ │ │ -00075440: 6f6e 7374 3b0a 0909 626f 6f6c 2068 6176 onst;...bool hav │ │ │ -00075450: 655f 616c 6c28 2920 636f 6e73 743b 0a09 e_all() const;.. │ │ │ -00075460: 0962 6f6f 6c20 7069 6563 655f 7665 7269 .bool piece_veri │ │ │ -00075470: 6669 6564 2870 6965 6365 5f69 6e64 6578 fied(piece_index │ │ │ -00075480: 5f74 2070 6965 6365 2920 636f 6e73 743b _t piece) const; │ │ │ -00075490: 0a0a 0909 696e 7420 7069 6563 655f 6c61 ....int piece_la │ │ │ -000754a0: 7965 7228 2920 636f 6e73 7420 7b20 7265 yer() const { re │ │ │ -000754b0: 7475 726e 206d 5f70 6965 6365 5f6c 6179 turn m_piece_lay │ │ │ -000754c0: 6572 3b20 7d0a 0a09 7072 6976 6174 653a er; }...private: │ │ │ -000754d0: 0a09 092f 2f20 7265 7475 726e 7320 7468 ...// returns th │ │ │ -000754e0: 6520 6e75 6d62 6572 206f 6620 7072 6f6f e number of proo │ │ │ -000754f0: 6620 6c61 7965 7273 206e 6565 6465 6420 f layers needed │ │ │ -00075500: 746f 2076 6572 6966 7920 7468 6520 6e6f to verify the no │ │ │ -00075510: 6465 2773 2068 6173 680a 0909 696e 7420 de's hash...int │ │ │ -00075520: 6c61 7965 7273 5f74 6f5f 7665 7269 6679 layers_to_verify │ │ │ -00075530: 286e 6f64 655f 696e 6465 7820 6964 7829 (node_index idx) │ │ │ -00075540: 2063 6f6e 7374 3b0a 0909 696e 7420 6669 const;...int fi │ │ │ -00075550: 6c65 5f6e 756d 5f6c 6179 6572 7328 6669 le_num_layers(fi │ │ │ -00075560: 6c65 5f69 6e64 6578 5f74 2069 6478 2920 le_index_t idx) │ │ │ -00075570: 636f 6e73 743b 0a0a 0909 7374 7275 6374 const;....struct │ │ │ -00075580: 2070 6965 6365 5f68 6173 685f 7265 7175 piece_hash_requ │ │ │ -00075590: 6573 740a 0909 7b0a 0909 0974 696d 655f est...{....time_ │ │ │ -000755a0: 706f 696e 7420 6c61 7374 5f72 6571 7565 point last_reque │ │ │ -000755b0: 7374 203d 206d 696e 5f74 696d 6528 293b st = min_time(); │ │ │ -000755c0: 0a09 0909 696e 7420 6e75 6d5f 7265 7175 ....int num_requ │ │ │ -000755d0: 6573 7473 203d 2030 3b0a 0909 0962 6f6f ests = 0;....boo │ │ │ -000755e0: 6c20 6861 7665 203d 2066 616c 7365 3b0a l have = false;. │ │ │ -000755f0: 0909 7d3b 0a0a 0909 7374 7275 6374 2070 ..};....struct p │ │ │ -00075600: 7269 6f72 6974 795f 626c 6f63 6b5f 7265 riority_block_re │ │ │ -00075610: 7175 6573 740a 0909 7b0a 0909 0970 7269 quest...{....pri │ │ │ -00075620: 6f72 6974 795f 626c 6f63 6b5f 7265 7175 ority_block_requ │ │ │ -00075630: 6573 7428 6669 6c65 5f69 6e64 6578 5f74 est(file_index_t │ │ │ -00075640: 2063 6f6e 7374 2066 2c20 696e 7420 636f const f, int co │ │ │ -00075650: 6e73 7420 6229 0a09 0909 093a 2066 696c nst b).....: fil │ │ │ -00075660: 6528 6629 2c20 626c 6f63 6b28 6229 207b e(f), block(b) { │ │ │ -00075670: 7d0a 0909 0966 696c 655f 696e 6465 785f }....file_index_ │ │ │ -00075680: 7420 6669 6c65 3b0a 0909 0969 6e74 2062 t file;....int b │ │ │ -00075690: 6c6f 636b 3b0a 3c2f 7072 653e 3c2f 7464 lock;.
    relevance │ │ │ -000756d0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -000756e0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ -00075710: 6f72 7265 6e74 2f61 7578 5f2f 7065 6572 orrent/aux_/peer │ │ │ -00075720: 2e68 7070 3a34 373c 2f61 3e3c 2f74 643e .hpp:47 │ │ │ -00075730: 3c74 643e 6974 2073 6565 6d73 2075 6e6e it seems unn │ │ │ -00075740: 6563 6573 7361 7279 2074 6f20 7772 6170 ecessary to wrap │ │ │ -00075750: 2074 6869 7320 6932 7020 6164 6472 6573 this i2p addres │ │ │ -00075760: 7320 696e 2061 2073 7472 7563 743c 2f74 s in a struct

    it se │ │ │ -000757c0: 656d 7320 756e 6e65 6365 7373 6172 7920 ems unnecessary │ │ │ -000757d0: 746f 2077 7261 7020 7468 6973 2069 3270 to wrap this i2p │ │ │ -000757e0: 2061 6464 7265 7373 2069 6e20 6120 7374 address in a st │ │ │ -000757f0: 7275 6374 3c2f 6832 3e3c 6834 3e2e 2e2f ruct

    ../ │ │ │ -00075800: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00075810: 6e74 2f61 7578 5f2f 7065 6572 2e68 7070 nt/aux_/peer.hpp │ │ │ -00075820: 3a34 373c 2f68 343e 3c70 7265 2073 7479 :47

    ..bool operato
    │ │ │ -00075870: 723d 3d28 636f 6e73 7420 7065 6572 5f65  r==(const peer_e
    │ │ │ -00075880: 6e74 7279 2661 6d70 3b20 7029 2063 6f6e  ntry& p) con
    │ │ │ -00075890: 7374 0a09 097b 2072 6574 7572 6e20 7069  st...{ return pi
    │ │ │ -000758a0: 6420 3d3d 2070 2e70 6964 3b20 7d0a 0a09  d == p.pid; }...
    │ │ │ -000758b0: 0962 6f6f 6c20 6f70 6572 6174 6f72 266c  .bool operator&l
    │ │ │ -000758c0: 743b 2863 6f6e 7374 2070 6565 725f 656e  t;(const peer_en
    │ │ │ -000758d0: 7472 7926 616d 703b 2070 2920 636f 6e73  try& p) cons
    │ │ │ -000758e0: 740a 0909 7b20 7265 7475 726e 2070 6964  t...{ return pid
    │ │ │ -000758f0: 2026 6c74 3b20 702e 7069 643b 207d 0a09   < p.pid; }..
    │ │ │ -00075900: 7d3b 0a0a 0973 7472 7563 7420 6970 7634  };...struct ipv4
    │ │ │ -00075910: 5f70 6565 725f 656e 7472 790a 097b 0a09  _peer_entry..{..
    │ │ │ -00075920: 0961 6464 7265 7373 5f76 343a 3a62 7974  .address_v4::byt
    │ │ │ -00075930: 6573 5f74 7970 6520 6970 3b0a 0909 7374  es_type ip;...st
    │ │ │ -00075940: 643a 3a75 696e 7431 365f 7420 706f 7274  d::uint16_t port
    │ │ │ -00075950: 3b0a 097d 3b0a 0a09 7374 7275 6374 2069  ;..};...struct i
    │ │ │ -00075960: 7076 365f 7065 6572 5f65 6e74 7279 0a09  pv6_peer_entry..
    │ │ │ -00075970: 7b0a 0909 6164 6472 6573 735f 7636 3a3a  {...address_v6::
    │ │ │ -00075980: 6279 7465 735f 7479 7065 2069 703b 0a09  bytes_type ip;..
    │ │ │ -00075990: 0973 7464 3a3a 7569 6e74 3136 5f74 2070  .std::uint16_t p
    │ │ │ -000759a0: 6f72 743b 0a09 7d3b 0a0a 2369 6620 544f  ort;..};..#if TO
    │ │ │ -000759b0: 5252 454e 545f 5553 455f 4932 500a 3c64  RRENT_USE_I2P..str
    │ │ │ -000759f0: 7563 7420 6932 705f 7065 6572 5f65 6e74  uct i2p_peer_ent
    │ │ │ -00075a00: 7279 0a3c 2f64 6976 3e09 7b0a 0909 7368  ry.
    .{...sh │ │ │ -00075a10: 6132 3536 5f68 6173 6820 6465 7374 696e a256_hash destin │ │ │ -00075a20: 6174 696f 6e3b 0a09 7d3b 0a23 656e 6469 ation;..};.#endi │ │ │ -00075a30: 660a 7d0a 0a23 656e 6469 6620 2f2f 2054 f.}..#endif // T │ │ │ -00075a40: 4f52 5245 4e54 5f50 4545 525f 4850 505f ORRENT_PEER_HPP_ │ │ │ -00075a50: 494e 434c 5544 4544 0a3c 2f70 7265 3e3c INCLUDED.
    < │ │ │ -00075a60: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00075a90: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00075aa0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/l │ │ │ -00075ad0: 6962 746f 7272 656e 742f 6175 785f 2f73 ibtorrent/aux_/s │ │ │ -00075ae0: 6573 7369 6f6e 5f69 6d70 6c2e 6870 703a ession_impl.hpp: │ │ │ -00075af0: 3233 393c 2f61 3e3c 2f74 643e 3c74 643e 239 │ │ │ -00075b00: 6d61 6b65 2074 6865 7365 2064 6972 6563 make these direc │ │ │ -00075b10: 7420 6d65 6d62 6572 7320 616e 6420 6765 t members and ge │ │ │ -00075b20: 6e65 7261 7465 2073 6861 7265 645f 7074 nerate shared_pt │ │ │ -00075b30: 7273 2074 6f20 7468 656d 2077 6869 6368 rs to them which │ │ │ -00075b40: 2061 6c69 6173 2074 6865 206c 6973 7465 alias the liste │ │ │ -00075b50: 6e5f 736f 636b 6574 5f74 2073 6861 7265 n_socket_t share │ │ │ -00075b60: 645f 7074 723c 2f74 643e 3c2f 7472 3e3c d_ptr< │ │ │ -00075b70: 7472 2069 643d 2232 3730 2220 7374 796c tr id="270" styl │ │ │ -00075b80: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00075b90: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00075ba0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00075bb0: 6832 3e6d 616b 6520 7468 6573 6520 6469 h2>make these di │ │ │ -00075bc0: 7265 6374 206d 656d 6265 7273 2061 6e64 rect members and │ │ │ -00075bd0: 2067 656e 6572 6174 6520 7368 6172 6564 generate shared │ │ │ -00075be0: 5f70 7472 7320 746f 2074 6865 6d0a 7768 _ptrs to them.wh │ │ │ -00075bf0: 6963 6820 616c 6961 7320 7468 6520 6c69 ich alias the li │ │ │ -00075c00: 7374 656e 5f73 6f63 6b65 745f 7420 7368 sten_socket_t sh │ │ │ -00075c10: 6172 6564 5f70 7472 3c2f 6832 3e3c 6834 ared_ptr

    ../include/libt │ │ │ -00075c30: 6f72 7265 6e74 2f61 7578 5f2f 7365 7373 orrent/aux_/sess │ │ │ -00075c40: 696f 6e5f 696d 706c 2e68 7070 3a32 3339 ion_impl.hpp:239 │ │ │ -00075c50: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00075c90: 0909 6966 2028 7564 705f 736f 636b 2920  ..if (udp_sock) 
    │ │ │ -00075ca0: 7265 7475 726e 2075 6470 5f73 6f63 6b2d  return udp_sock-
    │ │ │ -00075cb0: 2667 743b 736f 636b 2e6c 6f63 616c 5f70  >sock.local_p
    │ │ │ -00075cc0: 6f72 7428 293b 0a09 0909 7265 7475 726e  ort();....return
    │ │ │ -00075cd0: 2030 3b0a 0909 7d0a 0a09 092f 2f20 3020   0;...}....// 0 
    │ │ │ -00075ce0: 6973 206e 6174 706d 7020 3120 6973 2075  is natpmp 1 is u
    │ │ │ -00075cf0: 706e 700a 0909 2f2f 2074 6865 206f 7264  pnp...// the ord
    │ │ │ -00075d00: 6572 206f 6620 7468 6573 6520 6172 7261  er of these arra
    │ │ │ -00075d10: 7973 2064 6574 6572 6d69 6e65 7320 7468  ys determines th
    │ │ │ -00075d20: 6520 7072 696f 7269 7479 2069 6e0a 0909  e priority in...
    │ │ │ -00075d30: 2f2f 2077 6869 6368 2074 6865 6972 2070  // which their p
    │ │ │ -00075d40: 6f72 7473 2077 696c 6c20 6265 2061 6e6e  orts will be ann
    │ │ │ -00075d50: 6f75 6e63 6564 2074 6f20 7065 6572 730a  ounced to peers.
    │ │ │ -00075d60: 0909 6175 783a 3a61 7272 6179 266c 743b  ..aux::array<
    │ │ │ -00075d70: 6c69 7374 656e 5f70 6f72 745f 6d61 7070  listen_port_mapp
    │ │ │ -00075d80: 696e 672c 2032 2c20 706f 7274 6d61 705f  ing, 2, portmap_
    │ │ │ -00075d90: 7472 616e 7370 6f72 7426 6774 3b20 7463  transport> tc
    │ │ │ -00075da0: 705f 706f 7274 5f6d 6170 7069 6e67 3b0a  p_port_mapping;.
    │ │ │ -00075db0: 0909 6175 783a 3a61 7272 6179 266c 743b  ..aux::array<
    │ │ │ -00075dc0: 6c69 7374 656e 5f70 6f72 745f 6d61 7070  listen_port_mapp
    │ │ │ -00075dd0: 696e 672c 2032 2c20 706f 7274 6d61 705f  ing, 2, portmap_
    │ │ │ -00075de0: 7472 616e 7370 6f72 7426 6774 3b20 7564  transport> ud
    │ │ │ -00075df0: 705f 706f 7274 5f6d 6170 7069 6e67 3b0a  p_port_mapping;.
    │ │ │ -00075e00: 0a09 092f 2f20 696e 6469 6361 7465 7320  ...// indicates 
    │ │ │ -00075e10: 7768 6574 6865 7220 7468 6973 2069 7320  whether this is 
    │ │ │ -00075e20: 616e 2053 534c 206c 6973 7465 6e20 736f  an SSL listen so
    │ │ │ -00075e30: 636b 6574 206f 7220 6e6f 740a 0909 7472  cket or not...tr
    │ │ │ -00075e40: 616e 7370 6f72 7420 7373 6c20 3d20 7472  ansport ssl = tr
    │ │ │ -00075e50: 616e 7370 6f72 743a 3a70 6c61 696e 7465  ansport::plainte
    │ │ │ -00075e60: 7874 3b0a 0a09 096c 6973 7465 6e5f 736f  xt;....listen_so
    │ │ │ -00075e70: 636b 6574 5f66 6c61 6773 5f74 2066 6c61  cket_flags_t fla
    │ │ │ -00075e80: 6773 203d 2061 6363 6570 745f 696e 636f  gs = accept_inco
    │ │ │ -00075e90: 6d69 6e67 3b0a 0a09 092f 2f20 7468 6520  ming;....// the 
    │ │ │ -00075ea0: 6163 7475 616c 2073 6f63 6b65 7473 2028  actual sockets (
    │ │ │ -00075eb0: 5443 5020 6c69 7374 656e 2073 6f63 6b65  TCP listen socke
    │ │ │ -00075ec0: 7420 616e 6420 5544 5020 736f 636b 6574  t and UDP socket
    │ │ │ -00075ed0: 290a 0909 2f2f 2041 6e20 656e 7472 7920  )...// An entry 
    │ │ │ -00075ee0: 646f 6573 206e 6f74 206e 6563 6573 7361  does not necessa
    │ │ │ -00075ef0: 7269 6c79 2068 6176 6520 6120 5544 5020  rily have a UDP 
    │ │ │ -00075f00: 6f72 2054 4350 2073 6f63 6b65 742e 204f  or TCP socket. O
    │ │ │ -00075f10: 6e65 206f 6620 7468 6573 650a 0909 2f2f  ne of these...//
    │ │ │ -00075f20: 2070 6f69 6e74 6572 7320 6d61 7920 6265   pointers may be
    │ │ │ -00075f30: 206e 756c 6c70 7472 210a 0909 2f2f 2054   nullptr!...// T
    │ │ │ -00075f40: 6865 7365 206d 7573 7420 6265 2073 6861  hese must be sha
    │ │ │ -00075f50: 7265 645f 7074 7220 746f 2061 766f 6964  red_ptr to avoid
    │ │ │ -00075f60: 2061 2064 616e 676c 696e 6720 7265 6665   a dangling refe
    │ │ │ -00075f70: 7265 6e63 6520 6966 2061 6e0a 0909 2f2f  rence if an...//
    │ │ │ -00075f80: 2069 6e63 6f6d 696e 6720 7061 636b 6574   incoming packet
    │ │ │ -00075f90: 2069 7320 696e 2074 6865 2065 7665 6e74   is in the event
    │ │ │ -00075fa0: 2071 7565 7565 2077 6865 6e20 7468 6520   queue when the 
    │ │ │ -00075fb0: 736f 636b 6574 2069 7320 6572 6173 6564  socket is erased
    │ │ │ -00075fc0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00075ff0: 0973 7464 3a3a 7368 6172 6564 5f70 7472 .std::shared_ptr │ │ │ -00076000: 266c 743b 7463 703a 3a61 6363 6570 746f <tcp::accepto │ │ │ -00076010: 7226 6774 3b20 736f 636b 3b0a 3c2f 6469 r> sock;...std::shared_ │ │ │ -00076030: 7074 7226 6c74 3b61 7578 3a3a 7365 7373 ptr<aux::sess │ │ │ -00076040: 696f 6e5f 7564 705f 736f 636b 6574 2667 ion_udp_socket&g │ │ │ -00076050: 743b 2075 6470 5f73 6f63 6b3b 0a0a 0909 t; udp_sock;.... │ │ │ -00076060: 2f2f 2073 696e 6365 2075 6470 2070 6163 // since udp pac │ │ │ -00076070: 6b65 7473 2061 7265 2065 7870 6563 7465 kets are expecte │ │ │ -00076080: 6420 746f 2062 6520 6469 7370 6174 6368 d to be dispatch │ │ │ -00076090: 6564 2066 7265 7175 656e 746c 792c 2074 ed frequently, t │ │ │ -000760a0: 6869 7320 7361 7665 730a 0909 2f2f 2074 his saves...// t │ │ │ -000760b0: 696d 6520 6f6e 2068 616e 646c 6572 2061 ime on handler a │ │ │ -000760c0: 6c6c 6f63 6174 696f 6e20 6576 6572 7920 llocation every │ │ │ -000760d0: 7469 6d65 2077 6520 7265 6164 2061 6761 time we read aga │ │ │ -000760e0: 696e 2e0a 0909 6175 783a 3a68 616e 646c in....aux::handl │ │ │ -000760f0: 6572 5f73 746f 7261 6765 266c 743b 6175 er_storage<au │ │ │ -00076100: 783a 3a75 6470 5f68 616e 646c 6572 5f6d x::udp_handler_m │ │ │ -00076110: 6178 5f73 697a 652c 2061 7578 3a3a 7564 ax_size, aux::ud │ │ │ -00076120: 705f 6861 6e64 6c65 7226 6774 3b20 7564 p_handler> ud │ │ │ -00076130: 705f 6861 6e64 6c65 725f 7374 6f72 6167 p_handler_storag │ │ │ -00076140: 653b 0a0a 0909 7374 643a 3a73 6861 7265 e;....std::share │ │ │ -00076150: 645f 7074 7226 6c74 3b6e 6174 706d 7026 d_ptr<natpmp& │ │ │ -00076160: 6774 3b20 6e61 7470 6d70 5f6d 6170 7065 gt; natpmp_mappe │ │ │ -00076170: 723b 0a09 0973 7464 3a3a 7368 6172 6564 r;...std::shared │ │ │ -00076180: 5f70 7472 266c 743b 7570 6e70 2667 743b _ptr<upnp> │ │ │ -00076190: 2075 706e 705f 6d61 7070 6572 3b0a 0a09 upnp_mapper;... │ │ │ -000761a0: 0973 7464 3a3a 7368 6172 6564 5f70 7472 .std::shared_ptr │ │ │ -000761b0: 266c 743b 7374 7275 6374 206c 7364 2667 <struct lsd&g │ │ │ -000761c0: 743b 206c 7364 3b0a 0a09 092f 2f20 7365 t; lsd;....// se │ │ │ -000761d0: 7420 746f 2074 7275 6520 7768 656e 2077 t to true when w │ │ │ -000761e0: 6520 7265 6365 6976 6520 616e 2069 6e63 e receive an inc │ │ │ -000761f0: 6f6d 696e 6720 636f 6e6e 6563 7469 6f6e oming connection │ │ │ -00076200: 2066 726f 6d20 7468 6973 206c 6973 7465 from this liste │ │ │ -00076210: 6e0a 0909 2f2f 2073 6f63 6b65 740a 0909 n...// socket... │ │ │ -00076220: 626f 6f6c 2069 6e63 6f6d 696e 675f 636f bool incoming_co │ │ │ -00076230: 6e6e 6563 7469 6f6e 203d 2066 616c 7365 nnection = false │ │ │ -00076240: 3b0a 097d 3b0a 0a09 0973 7472 7563 7420 ;..};....struct │ │ │ -00076250: 544f 5252 454e 545f 4558 5452 415f 4558 TORRENT_EXTRA_EX │ │ │ -00076260: 504f 5254 206c 6973 7465 6e5f 656e 6470 PORT listen_endp │ │ │ -00076270: 6f69 6e74 5f74 0a09 097b 0a09 0909 6c69 oint_t...{....li │ │ │ -00076280: 7374 656e 5f65 6e64 706f 696e 745f 7428 sten_endpoint_t( │ │ │ -00076290: 6164 6472 6573 7320 636f 6e73 7426 616d address const&am │ │ │ -000762a0: 703b 2061 6472 2c20 696e 7420 702c 2073 p; adr, int p, s │ │ │ -000762b0: 7464 3a3a 7374 7269 6e67 2064 6576 2c20 td::string dev, │ │ │ -000762c0: 7472 616e 7370 6f72 7420 730a 0909 0909 transport s..... │ │ │ -000762d0: 2c20 6c69 7374 656e 5f73 6f63 6b65 745f , listen_socket_ │ │ │ -000762e0: 666c 6167 735f 7420 662c 2061 6464 7265 flags_t f, addre │ │ │ -000762f0: 7373 2063 6f6e 7374 2661 6d70 3b20 6e6d ss const& nm │ │ │ -00076300: 6173 6b20 3d20 6164 6472 6573 737b 7d29 ask = address{}) │ │ │ -00076310: 0a09 0909 093a 2061 6464 7228 6164 7229 .....: addr(adr) │ │ │ -00076320: 2c20 6e65 746d 6173 6b28 6e6d 6173 6b29 , netmask(nmask) │ │ │ -00076330: 2c20 706f 7274 2870 292c 2064 6576 6963 , port(p), devic │ │ │ -00076340: 6528 7374 643a 3a6d 6f76 6528 6465 7629 e(std::move(dev) │ │ │ -00076350: 292c 2073 736c 2873 292c 2066 6c61 6773 ), ssl(s), flags │ │ │ -00076360: 2866 2920 7b7d 0a0a 0909 0962 6f6f 6c20 (f) {}.....bool │ │ │ -00076370: 6f70 6572 6174 6f72 3d3d 286c 6973 7465 operator==(liste │ │ │ -00076380: 6e5f 656e 6470 6f69 6e74 5f74 2063 6f6e n_endpoint_t con │ │ │ -00076390: 7374 2661 6d70 3b20 6f29 2063 6f6e 7374 st& o) const │ │ │ -000763a0: 0a09 0909 7b0a 0909 0909 7265 7475 726e ....{.....return │ │ │ -000763b0: 2061 6464 7220 3d3d 206f 2e61 6464 720a addr == o.addr. │ │ │ -000763c0: 0909 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ -000763d0: 706f 7274 203d 3d20 6f2e 706f 7274 0a09 port == o.port.. │ │ │ -000763e0: 0909 0909 2661 6d70 3b26 616d 703b 2064 ....&& d │ │ │ -000763f0: 6576 6963 6520 3d3d 206f 2e64 6576 6963 evice == o.devic │ │ │ -00076400: 650a 0909 0909 0926 616d 703b 2661 6d70 e......&& │ │ │ -00076410: 3b20 7373 6c20 3d3d 206f 2e73 736c 0a09 ; ssl == o.ssl.. │ │ │ -00076420: 0909 0909 2661 6d70 3b26 616d 703b 2066 ....&& f │ │ │ -00076430: 6c61 6773 203d 3d20 6f2e 666c 6167 733b lags == o.flags; │ │ │ -00076440: 0a09 0909 7d0a 3c2f 7072 653e 3c2f 7464 ....}.
    relevance │ │ │ -00076480: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00076490: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ -000764c0: 6f72 7265 6e74 2f61 7578 5f2f 7365 7373 orrent/aux_/sess │ │ │ -000764d0: 696f 6e5f 696d 706c 2e68 7070 3a31 3038 ion_impl.hpp:108 │ │ │ -000764e0: 313c 2f61 3e3c 2f74 643e 3c74 643e 7265 1re │ │ │ -000764f0: 706c 6163 6520 7468 6973 2062 7920 6120 place this by a │ │ │ -00076500: 7072 6f70 6572 2061 7369 6f20 7469 6d65 proper asio time │ │ │ -00076510: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    r │ │ │ -00076560: 6570 6c61 6365 2074 6869 7320 6279 2061 eplace this by a │ │ │ -00076570: 2070 726f 7065 7220 6173 696f 2074 696d proper asio tim │ │ │ -00076580: 6572 3c2f 6832 3e3c 6834 3e2e 2e2f 696e er

    ../in │ │ │ -00076590: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -000765a0: 2f61 7578 5f2f 7365 7373 696f 6e5f 696d /aux_/session_im │ │ │ -000765b0: 706c 2e68 7070 3a31 3038 313c 2f68 343e pl.hpp:1081

    │ │ │ -000765c0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    #ifdef
    │ │ │ -00076600: 2054 4f52 5245 4e54 5f53 534c 5f50 4545   TORRENT_SSL_PEE
    │ │ │ -00076610: 5253 0a09 0909 766f 6964 206f 6e5f 696e  RS....void on_in
    │ │ │ -00076620: 636f 6d69 6e67 5f75 7470 5f73 736c 2873  coming_utp_ssl(s
    │ │ │ -00076630: 6f63 6b65 745f 7479 7065 2073 293b 0a09  ocket_type s);..
    │ │ │ -00076640: 0909 766f 6964 2073 736c 5f68 616e 6473  ..void ssl_hands
    │ │ │ -00076650: 6861 6b65 2865 7272 6f72 5f63 6f64 6520  hake(error_code 
    │ │ │ -00076660: 636f 6e73 7426 616d 703b 2065 632c 2073  const& ec, s
    │ │ │ -00076670: 6f63 6b65 745f 7479 7065 2a20 7329 3b0a  ocket_type* s);.
    │ │ │ -00076680: 2365 6e64 6966 0a0a 0909 092f 2f20 726f  #endif.....// ro
    │ │ │ -00076690: 756e 642d 726f 6269 6e20 696e 6465 7820  und-robin index 
    │ │ │ -000766a0: 696e 746f 206d 5f6f 7574 676f 696e 675f  into m_outgoing_
    │ │ │ -000766b0: 696e 7465 7266 6163 6573 0a09 0909 6d75  interfaces....mu
    │ │ │ -000766c0: 7461 626c 6520 7374 643a 3a75 696e 7438  table std::uint8
    │ │ │ -000766d0: 5f74 206d 5f69 6e74 6572 6661 6365 5f69  _t m_interface_i
    │ │ │ -000766e0: 6e64 6578 203d 2030 3b0a 0a09 0909 7374  ndex = 0;.....st
    │ │ │ -000766f0: 643a 3a73 6861 7265 645f 7074 7226 6c74  d::shared_ptr<
    │ │ │ -00076700: 3b6c 6973 7465 6e5f 736f 636b 6574 5f74  ;listen_socket_t
    │ │ │ -00076710: 2667 743b 2073 6574 7570 5f6c 6973 7465  > setup_liste
    │ │ │ -00076720: 6e65 7228 0a09 0909 096c 6973 7465 6e5f  ner(.....listen_
    │ │ │ -00076730: 656e 6470 6f69 6e74 5f74 2063 6f6e 7374  endpoint_t const
    │ │ │ -00076740: 2661 6d70 3b20 6c65 702c 2065 7272 6f72  & lep, error
    │ │ │ -00076750: 5f63 6f64 6526 616d 703b 2065 6329 3b0a  _code& ec);.
    │ │ │ -00076760: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -00076770: 5f44 4953 4142 4c45 5f44 4854 0a09 0909  _DISABLE_DHT....
    │ │ │ -00076780: 6468 743a 3a64 6874 5f73 7461 7465 206d  dht::dht_state m
    │ │ │ -00076790: 5f64 6874 5f73 7461 7465 3b0a 2365 6e64  _dht_state;.#end
    │ │ │ -000767a0: 6966 0a0a 0909 092f 2f20 7468 6973 2069  if.....// this i
    │ │ │ -000767b0: 7320 696e 6974 6961 6c69 7a65 6420 746f  s initialized to
    │ │ │ -000767c0: 2074 6865 2075 6e63 686f 6b65 5f69 6e74   the unchoke_int
    │ │ │ -000767d0: 6572 7661 6c0a 0909 092f 2f20 7365 7373  erval....// sess
    │ │ │ -000767e0: 696f 6e5f 7365 7474 696e 6720 616e 6420  ion_setting and 
    │ │ │ -000767f0: 6465 6372 6561 7365 6420 6576 6572 7920  decreased every 
    │ │ │ -00076800: 7365 636f 6e64 2e0a 0909 092f 2f20 7768  second.....// wh
    │ │ │ -00076810: 656e 2069 7420 7265 6163 6865 7320 7a65  en it reaches ze
    │ │ │ -00076820: 726f 2c20 6974 2069 7320 7265 7365 7420  ro, it is reset 
    │ │ │ -00076830: 746f 2074 6865 0a09 0909 2f2f 2075 6e63  to the....// unc
    │ │ │ -00076840: 686f 6b65 5f69 6e74 6572 7661 6c20 616e  hoke_interval an
    │ │ │ -00076850: 6420 7468 6520 756e 6368 6f6b 6520 7365  d the unchoke se
    │ │ │ -00076860: 7420 6973 0a09 0909 2f2f 2072 6563 6f6d  t is....// recom
    │ │ │ -00076870: 7075 7465 642e 0a3c 6469 7620 7374 796c  puted..
    ...int m_un │ │ │ -000768b0: 6368 6f6b 655f 7469 6d65 5f73 6361 6c65 choke_time_scale │ │ │ -000768c0: 7220 3d20 303b 0a3c 2f64 6976 3e0a 0909 r = 0;.
    ... │ │ │ -000768d0: 092f 2f20 7468 6973 2069 7320 7573 6564 .// this is used │ │ │ -000768e0: 2074 6f20 6465 6369 6465 2077 6865 6e20 to decide when │ │ │ -000768f0: 746f 2072 6563 616c 6375 6c61 7465 2077 to recalculate w │ │ │ -00076900: 6869 6368 0a09 0909 2f2f 2074 6f72 7265 hich....// torre │ │ │ -00076910: 6e74 7320 746f 206b 6565 7020 7175 6575 nts to keep queu │ │ │ -00076920: 6564 2061 6e64 2077 6869 6368 2074 6f20 ed and which to │ │ │ -00076930: 6163 7469 7661 7465 0a3c 2f70 7265 3e3c activate.
    < │ │ │ -00076940: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00076970: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00076980: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/l │ │ │ -000769b0: 6962 746f 7272 656e 742f 6175 785f 2f73 ibtorrent/aux_/s │ │ │ -000769c0: 6573 7369 6f6e 5f69 6d70 6c2e 6870 703a ession_impl.hpp: │ │ │ -000769d0: 3130 3836 3c2f 613e 3c2f 7464 3e3c 7464 1086replace this by │ │ │ -000769f0: 2061 2070 726f 7065 7220 6173 696f 2074 a proper asio t │ │ │ -00076a00: 696d 6572 3c2f 7464 3e3c 2f74 723e 3c74 imerreplace this b │ │ │ -00076a60: 7920 6120 7072 6f70 6572 2061 7369 6f20 y a proper asio │ │ │ -00076a70: 7469 6d65 723c 2f68 323e 3c68 343e 2e2e timer

    .. │ │ │ -00076a80: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00076a90: 656e 742f 6175 785f 2f73 6573 7369 6f6e ent/aux_/session │ │ │ -00076aa0: 5f69 6d70 6c2e 6870 703a 3130 3836 3c2f _impl.hpp:1086
    ...
    │ │ │ -00076af0: 092f 2f20 726f 756e 642d 726f 6269 6e20  .// round-robin 
    │ │ │ -00076b00: 696e 6465 7820 696e 746f 206d 5f6f 7574  index into m_out
    │ │ │ -00076b10: 676f 696e 675f 696e 7465 7266 6163 6573  going_interfaces
    │ │ │ -00076b20: 0a09 0909 6d75 7461 626c 6520 7374 643a  ....mutable std:
    │ │ │ -00076b30: 3a75 696e 7438 5f74 206d 5f69 6e74 6572  :uint8_t m_inter
    │ │ │ -00076b40: 6661 6365 5f69 6e64 6578 203d 2030 3b0a  face_index = 0;.
    │ │ │ -00076b50: 0a09 0909 7374 643a 3a73 6861 7265 645f  ....std::shared_
    │ │ │ -00076b60: 7074 7226 6c74 3b6c 6973 7465 6e5f 736f  ptr<listen_so
    │ │ │ -00076b70: 636b 6574 5f74 2667 743b 2073 6574 7570  cket_t> setup
    │ │ │ -00076b80: 5f6c 6973 7465 6e65 7228 0a09 0909 096c  _listener(.....l
    │ │ │ -00076b90: 6973 7465 6e5f 656e 6470 6f69 6e74 5f74  isten_endpoint_t
    │ │ │ -00076ba0: 2063 6f6e 7374 2661 6d70 3b20 6c65 702c   const& lep,
    │ │ │ -00076bb0: 2065 7272 6f72 5f63 6f64 6526 616d 703b   error_code&
    │ │ │ -00076bc0: 2065 6329 3b0a 0a23 6966 6e64 6566 2054   ec);..#ifndef T
    │ │ │ -00076bd0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f44  ORRENT_DISABLE_D
    │ │ │ -00076be0: 4854 0a09 0909 6468 743a 3a64 6874 5f73  HT....dht::dht_s
    │ │ │ -00076bf0: 7461 7465 206d 5f64 6874 5f73 7461 7465  tate m_dht_state
    │ │ │ -00076c00: 3b0a 2365 6e64 6966 0a0a 0909 092f 2f20  ;.#endif.....// 
    │ │ │ -00076c10: 7468 6973 2069 7320 696e 6974 6961 6c69  this is initiali
    │ │ │ -00076c20: 7a65 6420 746f 2074 6865 2075 6e63 686f  zed to the uncho
    │ │ │ -00076c30: 6b65 5f69 6e74 6572 7661 6c0a 0909 092f  ke_interval..../
    │ │ │ -00076c40: 2f20 7365 7373 696f 6e5f 7365 7474 696e  / session_settin
    │ │ │ -00076c50: 6720 616e 6420 6465 6372 6561 7365 6420  g and decreased 
    │ │ │ -00076c60: 6576 6572 7920 7365 636f 6e64 2e0a 0909  every second....
    │ │ │ -00076c70: 092f 2f20 7768 656e 2069 7420 7265 6163  .// when it reac
    │ │ │ -00076c80: 6865 7320 7a65 726f 2c20 6974 2069 7320  hes zero, it is 
    │ │ │ -00076c90: 7265 7365 7420 746f 2074 6865 0a09 0909  reset to the....
    │ │ │ -00076ca0: 2f2f 2075 6e63 686f 6b65 5f69 6e74 6572  // unchoke_inter
    │ │ │ -00076cb0: 7661 6c20 616e 6420 7468 6520 756e 6368  val and the unch
    │ │ │ -00076cc0: 6f6b 6520 7365 7420 6973 0a09 0909 2f2f  oke set is....//
    │ │ │ -00076cd0: 2072 6563 6f6d 7075 7465 642e 0a09 0909   recomputed.....
    │ │ │ -00076ce0: 696e 7420 6d5f 756e 6368 6f6b 655f 7469  int m_unchoke_ti
    │ │ │ -00076cf0: 6d65 5f73 6361 6c65 7220 3d20 303b 0a0a  me_scaler = 0;..
    │ │ │ -00076d00: 0909 092f 2f20 7468 6973 2069 7320 7573  ...// this is us
    │ │ │ -00076d10: 6564 2074 6f20 6465 6369 6465 2077 6865  ed to decide whe
    │ │ │ -00076d20: 6e20 746f 2072 6563 616c 6375 6c61 7465  n to recalculate
    │ │ │ -00076d30: 2077 6869 6368 0a09 0909 2f2f 2074 6f72   which....// tor
    │ │ │ -00076d40: 7265 6e74 7320 746f 206b 6565 7020 7175  rents to keep qu
    │ │ │ -00076d50: 6575 6564 2061 6e64 2077 6869 6368 2074  eued and which t
    │ │ │ -00076d60: 6f20 6163 7469 7661 7465 0a3c 6469 7620  o activate.
    ...int │ │ │ -00076da0: 6d5f 6175 746f 5f6d 616e 6167 655f 7469 m_auto_manage_ti │ │ │ -00076db0: 6d65 5f73 6361 6c65 7220 3d20 303b 0a3c me_scaler = 0;.< │ │ │ -00076dc0: 2f64 6976 3e0a 0909 092f 2f20 776f 726b /div>....// work │ │ │ -00076dd0: 7320 6c69 6b65 2075 6e63 686f 6b65 5f74 s like unchoke_t │ │ │ -00076de0: 696d 655f 7363 616c 6572 2062 7574 2069 ime_scaler but i │ │ │ -00076df0: 740a 0909 092f 2f20 6973 206f 6e6c 7920 t....// is only │ │ │ -00076e00: 6465 6372 6561 7365 6420 7768 656e 2074 decreased when t │ │ │ -00076e10: 6865 2075 6e63 686f 6b65 2073 6574 0a09 he unchoke set.. │ │ │ -00076e20: 0909 2f2f 2069 7320 7265 636f 6d70 7574 ..// is recomput │ │ │ -00076e30: 6564 2c20 616e 6420 7768 656e 2069 7420 ed, and when it │ │ │ -00076e40: 7265 6163 6865 7320 7a65 726f 2c0a 0909 reaches zero,... │ │ │ -00076e50: 092f 2f20 7468 6520 6f70 7469 6d69 7374 .// the optimist │ │ │ -00076e60: 6963 2075 6e63 686f 6b65 2069 7320 6d6f ic unchoke is mo │ │ │ -00076e70: 7665 6420 746f 2061 6e6f 7468 6572 2070 ved to another p │ │ │ -00076e80: 6565 722e 0a3c 2f70 7265 3e3c 2f74 643e eer..
    │ │ │ -00076e90: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00076ec0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00076ed0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00076ee0: 7074 3a65 7870 616e 6428 3237 3329 223e pt:expand(273)"> │ │ │ -00076ef0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00076f00: 7272 656e 742f 6175 785f 2f73 6573 7369 rrent/aux_/sessi │ │ │ -00076f10: 6f6e 5f69 6d70 6c2e 6870 703a 3130 3933 on_impl.hpp:1093 │ │ │ -00076f20: 3c2f 613e 3c2f 7464 3e3c 7464 3e72 6570 rep │ │ │ -00076f30: 6c61 6365 2074 6869 7320 6279 2061 2070 lace this by a p │ │ │ -00076f40: 726f 7065 7220 6173 696f 2074 696d 6572 roper asio timer │ │ │ -00076f50: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    re │ │ │ -00076fa0: 706c 6163 6520 7468 6973 2062 7920 6120 place this by a │ │ │ -00076fb0: 7072 6f70 6572 2061 7369 6f20 7469 6d65 proper asio time │ │ │ -00076fc0: 723c 2f68 323e 3c68 343e 2e2e 2f69 6e63 r

    ../inc │ │ │ -00076fd0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00076fe0: 6175 785f 2f73 6573 7369 6f6e 5f69 6d70 aux_/session_imp │ │ │ -00076ff0: 6c2e 6870 703a 3130 3933 3c2f 6834 3e3c l.hpp:1093

    < │ │ │ -00077000: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00077010: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00077020: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00077030: 7820 2364 6464 3b22 3e0a 2369 666e 6465 x #ddd;">.#ifnde │ │ │ -00077040: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ -00077050: 455f 4448 540a 0909 0964 6874 3a3a 6468 E_DHT....dht::dh │ │ │ -00077060: 745f 7374 6174 6520 6d5f 6468 745f 7374 t_state m_dht_st │ │ │ -00077070: 6174 653b 0a23 656e 6469 660a 0a09 0909 ate;.#endif..... │ │ │ -00077080: 2f2f 2074 6869 7320 6973 2069 6e69 7469 // this is initi │ │ │ -00077090: 616c 697a 6564 2074 6f20 7468 6520 756e alized to the un │ │ │ -000770a0: 6368 6f6b 655f 696e 7465 7276 616c 0a09 choke_interval.. │ │ │ -000770b0: 0909 2f2f 2073 6573 7369 6f6e 5f73 6574 ..// session_set │ │ │ -000770c0: 7469 6e67 2061 6e64 2064 6563 7265 6173 ting and decreas │ │ │ -000770d0: 6564 2065 7665 7279 2073 6563 6f6e 642e ed every second. │ │ │ -000770e0: 0a09 0909 2f2f 2077 6865 6e20 6974 2072 ....// when it r │ │ │ -000770f0: 6561 6368 6573 207a 6572 6f2c 2069 7420 eaches zero, it │ │ │ -00077100: 6973 2072 6573 6574 2074 6f20 7468 650a is reset to the. │ │ │ -00077110: 0909 092f 2f20 756e 6368 6f6b 655f 696e ...// unchoke_in │ │ │ -00077120: 7465 7276 616c 2061 6e64 2074 6865 2075 terval and the u │ │ │ -00077130: 6e63 686f 6b65 2073 6574 2069 730a 0909 nchoke set is... │ │ │ -00077140: 092f 2f20 7265 636f 6d70 7574 6564 2e0a .// recomputed.. │ │ │ -00077150: 0909 0969 6e74 206d 5f75 6e63 686f 6b65 ...int m_unchoke │ │ │ -00077160: 5f74 696d 655f 7363 616c 6572 203d 2030 _time_scaler = 0 │ │ │ -00077170: 3b0a 0a09 0909 2f2f 2074 6869 7320 6973 ;.....// this is │ │ │ -00077180: 2075 7365 6420 746f 2064 6563 6964 6520 used to decide │ │ │ -00077190: 7768 656e 2074 6f20 7265 6361 6c63 756c when to recalcul │ │ │ -000771a0: 6174 6520 7768 6963 680a 0909 092f 2f20 ate which....// │ │ │ -000771b0: 746f 7272 656e 7473 2074 6f20 6b65 6570 torrents to keep │ │ │ -000771c0: 2071 7565 7565 6420 616e 6420 7768 6963 queued and whic │ │ │ -000771d0: 6820 746f 2061 6374 6976 6174 650a 0909 h to activate... │ │ │ -000771e0: 0969 6e74 206d 5f61 7574 6f5f 6d61 6e61 .int m_auto_mana │ │ │ -000771f0: 6765 5f74 696d 655f 7363 616c 6572 203d ge_time_scaler = │ │ │ -00077200: 2030 3b0a 0a09 0909 2f2f 2077 6f72 6b73 0;.....// works │ │ │ -00077210: 206c 696b 6520 756e 6368 6f6b 655f 7469 like unchoke_ti │ │ │ -00077220: 6d65 5f73 6361 6c65 7220 6275 7420 6974 me_scaler but it │ │ │ -00077230: 0a09 0909 2f2f 2069 7320 6f6e 6c79 2064 ....// is only d │ │ │ -00077240: 6563 7265 6173 6564 2077 6865 6e20 7468 ecreased when th │ │ │ -00077250: 6520 756e 6368 6f6b 6520 7365 740a 0909 e unchoke set... │ │ │ -00077260: 092f 2f20 6973 2072 6563 6f6d 7075 7465 .// is recompute │ │ │ -00077270: 642c 2061 6e64 2077 6865 6e20 6974 2072 d, and when it r │ │ │ -00077280: 6561 6368 6573 207a 6572 6f2c 0a09 0909 eaches zero,.... │ │ │ -00077290: 2f2f 2074 6865 206f 7074 696d 6973 7469 // the optimisti │ │ │ -000772a0: 6320 756e 6368 6f6b 6520 6973 206d 6f76 c unchoke is mov │ │ │ -000772b0: 6564 2074 6f20 616e 6f74 6865 7220 7065 ed to another pe │ │ │ -000772c0: 6572 2e0a 3c64 6976 2073 7479 6c65 3d22 er..
    ...int m_optim │ │ │ -00077300: 6973 7469 635f 756e 6368 6f6b 655f 7469 istic_unchoke_ti │ │ │ -00077310: 6d65 5f73 6361 6c65 7220 3d20 303b 0a3c me_scaler = 0;.< │ │ │ -00077320: 2f64 6976 3e0a 0909 092f 2f20 776f 726b /div>....// work │ │ │ -00077330: 7320 6c69 6b65 2075 6e63 686f 6b65 5f74 s like unchoke_t │ │ │ -00077340: 696d 655f 7363 616c 6572 2e20 4561 6368 ime_scaler. Each │ │ │ -00077350: 2074 696d 650a 0909 092f 2f20 6974 2072 time....// it r │ │ │ -00077360: 6561 6368 6573 2030 2c20 616e 6420 616c eaches 0, and al │ │ │ -00077370: 6c20 7468 6520 636f 6e6e 6563 7469 6f6e l the connection │ │ │ -00077380: 7320 6172 650a 0909 092f 2f20 7573 6564 s are....// used │ │ │ -00077390: 2c20 7468 6520 776f 7273 7420 636f 6e6e , the worst conn │ │ │ -000773a0: 6563 7469 6f6e 2077 696c 6c20 6265 2064 ection will be d │ │ │ -000773b0: 6973 636f 6e6e 6563 7465 640a 0909 092f isconnected..../ │ │ │ -000773c0: 2f20 6672 6f6d 2074 6865 2074 6f72 7265 / from the torre │ │ │ -000773d0: 6e74 2077 6974 6820 7468 6520 6d6f 7374 nt with the most │ │ │ -000773e0: 2070 6565 7273 0a09 0909 696e 7420 6d5f peers....int m_ │ │ │ -000773f0: 6469 7363 6f6e 6e65 6374 5f74 696d 655f disconnect_time_ │ │ │ -00077400: 7363 616c 6572 203d 2039 303b 0a0a 0909 scaler = 90;.... │ │ │ -00077410: 092f 2f20 7768 656e 2074 6869 7320 7363 .// when this sc │ │ │ -00077420: 616c 6572 2072 6561 6368 6573 207a 6572 aler reaches zer │ │ │ -00077430: 6f2c 2069 7420 7769 6c6c 0a09 0909 2f2f o, it will....// │ │ │ -00077440: 2073 6372 6170 6520 6f6e 6520 6f66 2074 scrape one of t │ │ │ -00077450: 6865 2061 7574 6f20 6d61 6e61 6765 642c he auto managed, │ │ │ -00077460: 2070 6175 7365 642c 0a09 0909 2f2f 2074 paused,....// t │ │ │ -00077470: 6f72 7265 6e74 732e 0a09 0909 696e 7420 orrents.....int │ │ │ -00077480: 6d5f 6175 746f 5f73 6372 6170 655f 7469 m_auto_scrape_ti │ │ │ -00077490: 6d65 5f73 6361 6c65 7220 3d20 3138 303b me_scaler = 180; │ │ │ -000774a0: 0a0a 0909 092f 2f20 7374 6174 6973 7469 .....// statisti │ │ │ -000774b0: 6373 2067 6174 6865 7265 6420 6672 6f6d cs gathered from │ │ │ -000774c0: 2061 6c6c 2074 6f72 7265 6e74 732e 0a09 all torrents... │ │ │ -000774d0: 0909 7374 6174 206d 5f73 7461 743b 0a0a ..stat m_stat;.. │ │ │ -000774e0: 0909 092f 2f20 696d 706c 656d 656e 7473 ...// implements │ │ │ -000774f0: 2073 6573 7369 6f6e 5f69 6e74 6572 6661 session_interfa │ │ │ -00077500: 6365 0a09 0909 766f 6964 2073 656e 745f ce....void sent_ │ │ │ -00077510: 6279 7465 7328 696e 7420 6279 7465 735f bytes(int bytes_ │ │ │ -00077520: 7061 796c 6f61 642c 2069 6e74 2062 7974 payload, int byt │ │ │ -00077530: 6573 5f70 726f 746f 636f 6c29 206f 7665 es_protocol) ove │ │ │ -00077540: 7272 6964 653b 0a09 0909 766f 6964 2072 rride;....void r │ │ │ -00077550: 6563 6569 7665 645f 6279 7465 7328 696e eceived_bytes(in │ │ │ -00077560: 7420 6279 7465 735f 7061 796c 6f61 642c t bytes_payload, │ │ │ -00077570: 2069 6e74 2062 7974 6573 5f70 726f 746f int bytes_proto │ │ │ -00077580: 636f 6c29 206f 7665 7272 6964 653b 0a09 col) override;.. │ │ │ -00077590: 0909 766f 6964 2074 7261 6e63 6965 7665 ..void trancieve │ │ │ -000775a0: 5f69 705f 7061 636b 6574 2869 6e74 2062 _ip_packet(int b │ │ │ -000775b0: 7974 6573 2c20 626f 6f6c 2069 7076 3629 ytes, bool ipv6) │ │ │ -000775c0: 206f 7665 7272 6964 653b 0a09 0909 766f override;....vo │ │ │ -000775d0: 6964 2073 656e 745f 7379 6e28 626f 6f6c id sent_syn(bool │ │ │ -000775e0: 2069 7076 3629 206f 7665 7272 6964 653b ipv6) override; │ │ │ -000775f0: 0a09 0909 766f 6964 2072 6563 6569 7665 ....void receive │ │ │ -00077600: 645f 7379 6e61 636b 2862 6f6f 6c20 6970 d_synack(bool ip │ │ │ -00077610: 7636 2920 6f76 6572 7269 6465 3b0a 0a23 v6) override;..# │ │ │ -00077620: 6966 2054 4f52 5245 4e54 5f41 4249 5f56 if TORRENT_ABI_V │ │ │ -00077630: 4552 5349 4f4e 203d 3d20 310a 0909 0969 ERSION == 1....i │ │ │ -00077640: 6e74 206d 5f70 6561 6b5f 7570 5f72 6174 nt m_peak_up_rat │ │ │ -00077650: 6520 3d20 303b 0a23 656e 6469 660a 0a09 e = 0;.#endif... │ │ │ -00077660: 0909 766f 6964 206f 6e5f 7469 636b 2865 ..void on_tick(e │ │ │ -00077670: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ -00077680: 616d 703b 2065 293b 0a0a 0909 0976 6f69 amp; e);.....voi │ │ │ -00077690: 6420 7472 795f 636f 6e6e 6563 745f 6d6f d try_connect_mo │ │ │ -000776a0: 7265 5f70 6565 7273 2829 3b0a 0909 0976 re_peers();....v │ │ │ -000776b0: 6f69 6420 6175 746f 5f6d 616e 6167 655f oid auto_manage_ │ │ │ -000776c0: 6368 6563 6b69 6e67 5f74 6f72 7265 6e74 checking_torrent │ │ │ -000776d0: 7328 7374 643a 3a76 6563 746f 7226 6c74 s(std::vector< │ │ │ -000776e0: 3b74 6f72 7265 6e74 2a26 6774 3b26 616d ;torrent*>&am │ │ │ -000776f0: 703b 206c 6973 740a 3c2f 7072 653e 3c2f p; list.
    relevan │ │ │ -00077730: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -00077770: 6274 6f72 7265 6e74 2f61 7578 5f2f 6d65 btorrent/aux_/me │ │ │ -00077780: 726b 6c65 5f74 7265 652e 6870 703a 3632 rkle_tree.hpp:62 │ │ │ -00077790: 3c2f 613e 3c2f 7464 3e3c 7464 3e72 656d rem │ │ │ -000777a0: 6f76 6520 7468 6973 2063 6f6e 7374 7275 ove this constru │ │ │ -000777b0: 6374 6f72 2e20 446f 6e27 7420 7375 7070 ctor. Don't supp │ │ │ -000777c0: 6f72 7420 2275 6e69 6e69 7469 616c 697a ort "uninitializ │ │ │ -000777d0: 6564 2220 7472 6565 732e 2054 6869 7320 ed" trees. This │ │ │ -000777e0: 616c 736f 2072 6571 7569 7265 7320 6e6f also requires no │ │ │ -000777f0: 7420 636f 6e73 7472 7563 7469 6e67 2074 t constructing t │ │ │ -00077800: 6865 7365 2066 6f72 2070 6164 2d66 696c hese for pad-fil │ │ │ -00077810: 6573 2061 6e64 2073 6d61 6c6c 2066 696c es and small fil │ │ │ -00077820: 6573 2061 7320 7765 6c6c 2e20 536f 2c20 es as well. So, │ │ │ -00077830: 6120 7370 6172 7365 2068 6173 6820 6c69 a sparse hash li │ │ │ -00077840: 7374 2069 6e20 746f 7272 656e 745f 696e st in torrent_in │ │ │ -00077850: 666f 3c2f 7464 3e3c 2f74 723e 3c74 7220 fo

    │ │ │ -000778a0: 7265 6d6f 7665 2074 6869 7320 636f 6e73 remove this cons │ │ │ -000778b0: 7472 7563 746f 722e 2044 6f6e 2774 2073 tructor. Don't s │ │ │ -000778c0: 7570 706f 7274 2022 756e 696e 6974 6961 upport "uninitia │ │ │ -000778d0: 6c69 7a65 6422 2074 7265 6573 2e20 5468 lized" trees. Th │ │ │ -000778e0: 6973 0a61 6c73 6f20 7265 7175 6972 6573 is.also requires │ │ │ -000778f0: 206e 6f74 2063 6f6e 7374 7275 6374 696e not constructin │ │ │ -00077900: 6720 7468 6573 6520 666f 7220 7061 642d g these for pad- │ │ │ -00077910: 6669 6c65 7320 616e 6420 736d 616c 6c20 files and small │ │ │ -00077920: 6669 6c65 7320 6173 0a77 656c 6c2e 2053 files as.well. S │ │ │ -00077930: 6f2c 2061 2073 7061 7273 6520 6861 7368 o, a sparse hash │ │ │ -00077940: 206c 6973 7420 696e 2074 6f72 7265 6e74 list in torrent │ │ │ -00077950: 5f69 6e66 6f3c 2f68 323e 3c68 343e 2e2e _info

    .. │ │ │ -00077960: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00077970: 656e 742f 6175 785f 2f6d 6572 6b6c 655f ent/aux_/merkle_ │ │ │ -00077980: 7472 6565 2e68 7070 3a36 323c 2f68 343e tree.hpp:62

    │ │ │ -00077990: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    // The
    │ │ │ -000779d0: 2069 6e76 6172 6961 6e74 206f 6620 7468   invariant of th
    │ │ │ -000779e0: 6520 7472 6565 2069 7320 7468 6174 2061  e tree is that a
    │ │ │ -000779f0: 6c6c 2069 6e74 6572 696f 7220 6e6f 6465  ll interior node
    │ │ │ -00077a00: 7320 2869 2e65 2e20 616c 6c20 6275 7420  s (i.e. all but 
    │ │ │ -00077a10: 7468 6520 7665 7279 0a2f 2f20 626f 7474  the very.// bott
    │ │ │ -00077a20: 6f6d 206c 6561 6620 6e6f 6465 732c 2072  om leaf nodes, r
    │ │ │ -00077a30: 6570 7265 7365 6e74 696e 6720 626c 6f63  epresenting bloc
    │ │ │ -00077a40: 6b20 6861 7368 6573 2920 6172 6520 6569  k hashes) are ei
    │ │ │ -00077a50: 7468 6572 2073 6574 2061 6e64 2076 616c  ther set and val
    │ │ │ -00077a60: 6964 2c20 6f72 0a2f 2f20 636c 6561 722e  id, or.// clear.
    │ │ │ -00077a70: 204e 6f20 696e 7661 6c69 6420 6861 7368   No invalid hash
    │ │ │ -00077a80: 6573 2061 7265 2061 6c6c 6f77 6564 2c20  es are allowed, 
    │ │ │ -00077a90: 616e 6420 7468 6579 2063 616e 206f 6e6c  and they can onl
    │ │ │ -00077aa0: 7920 6265 2061 6464 6564 2062 7920 616c  y be added by al
    │ │ │ -00077ab0: 736f 0a2f 2f20 7072 6f76 6964 696e 6720  so.// providing 
    │ │ │ -00077ac0: 7072 6f6f 6620 6f66 2062 6569 6e67 2076  proof of being v
    │ │ │ -00077ad0: 616c 6964 2e0a 0a2f 2f20 5468 6520 6c65  alid...// The le
    │ │ │ -00077ae0: 6166 2062 6c6f 636b 7320 6f6e 2074 6865  af blocks on the
    │ │ │ -00077af0: 206f 7468 6572 2068 616e 642c 204d 4159   other hand, MAY
    │ │ │ -00077b00: 2062 6520 696e 7661 6c69 642e 2046 6f72   be invalid. For
    │ │ │ -00077b10: 2069 6e73 7461 6e63 652c 2077 6865 6e20   instance, when 
    │ │ │ -00077b20: 6164 6469 6e67 0a2f 2f20 6120 6d61 676e  adding.// a magn
    │ │ │ -00077b30: 6574 206c 696e 6b20 666f 7220 6120 746f  et link for a to
    │ │ │ -00077b40: 7272 656e 7420 7468 6174 2077 6520 616c  rrent that we al
    │ │ │ -00077b50: 7265 6164 7920 6861 7665 2066 696c 6573  ready have files
    │ │ │ -00077b60: 2066 6f72 2e20 4f6e 6365 2077 6520 6861   for. Once we ha
    │ │ │ -00077b70: 7665 2074 6865 0a2f 2f20 6d65 7461 6461  ve the.// metada
    │ │ │ -00077b80: 7461 2c20 7765 2068 6176 6520 6669 6c65  ta, we have file
    │ │ │ -00077b90: 7320 6f6e 2064 6973 6b20 6275 7420 6e6f  s on disk but no
    │ │ │ -00077ba0: 2068 6173 6865 732e 2057 6520 776f 6e27   hashes. We won'
    │ │ │ -00077bb0: 7420 6b6e 6f77 2077 6865 7468 6572 2074  t know whether t
    │ │ │ -00077bc0: 6865 2064 6174 610a 2f2f 206f 6e20 6469  he data.// on di
    │ │ │ -00077bd0: 736b 2069 7320 7661 6c69 6420 6f72 206e  sk is valid or n
    │ │ │ -00077be0: 6f74 2c20 756e 7469 6c20 7765 2776 6520  ot, until we've 
    │ │ │ -00077bf0: 646f 776e 6c6f 6164 6564 2074 6865 2068  downloaded the h
    │ │ │ -00077c00: 6173 6865 7320 746f 2076 616c 6964 6174  ashes to validat
    │ │ │ -00077c10: 6520 7468 656d 2e0a 0a2f 2f20 4964 6561  e them...// Idea
    │ │ │ -00077c20: 2066 6f72 2066 7574 7572 6520 7370 6163   for future spac
    │ │ │ -00077c30: 6520 6f70 7469 6d69 7a61 7469 6f6e 3a0a  e optimization:.
    │ │ │ -00077c40: 2f2f 2077 6869 6c65 2064 6f77 6e6c 6f61  // while downloa
    │ │ │ -00077c50: 6469 6e67 2c20 7765 206e 6565 6420 746f  ding, we need to
    │ │ │ -00077c60: 2073 746f 7265 2069 6e74 6572 696f 7220   store interior 
    │ │ │ -00077c70: 6e6f 6465 7320 6f66 2074 6869 7320 7472  nodes of this tr
    │ │ │ -00077c80: 6565 2e20 486f 7765 7665 722c 2077 650a  ee. However, we.
    │ │ │ -00077c90: 2f2f 2064 6f6e 2774 206e 6565 6420 746f  // don't need to
    │ │ │ -00077ca0: 2073 746f 7265 2074 6865 2070 6164 6469   store the paddi
    │ │ │ -00077cb0: 6e67 2e20 6120 5348 412d 3235 3620 6973  ng. a SHA-256 is
    │ │ │ -00077cc0: 2033 3220 6279 7465 732e 2049 6e73 7465   32 bytes. Inste
    │ │ │ -00077cd0: 6164 206f 6620 7374 6f72 696e 670a 2f2f  ad of storing.//
    │ │ │ -00077ce0: 2074 6865 2066 756c 6c20 2870 6164 6465   the full (padde
    │ │ │ -00077cf0: 6429 2074 7265 6520 6f66 2053 4841 2d32  d) tree of SHA-2
    │ │ │ -00077d00: 3536 2068 6173 6865 732c 2073 746f 7265  56 hashes, store
    │ │ │ -00077d10: 2074 6865 2066 756c 6c20 7472 6565 206f   the full tree o
    │ │ │ -00077d20: 6620 3332 2062 6974 0a2f 2f20 7369 676e  f 32 bit.// sign
    │ │ │ -00077d30: 6564 2069 6e74 6567 6572 732c 2062 6569  ed integers, bei
    │ │ │ -00077d40: 6e67 2069 6e64 6963 6573 2069 6e74 6f20  ng indices into 
    │ │ │ -00077d50: 7468 6520 6163 7475 616c 2073 746f 7261  the actual stora
    │ │ │ -00077d60: 6765 2066 6f72 2074 6865 2074 7265 652e  ge for the tree.
    │ │ │ -00077d70: 2057 6520 636f 756c 640a 2f2f 2065 7665   We could.// eve
    │ │ │ -00077d80: 6e20 6772 6f77 2074 6865 2073 746f 7261  n grow the stora
    │ │ │ -00077d90: 6765 206c 617a 696c 792e 2049 6e73 7465  ge lazily. Inste
    │ │ │ -00077da0: 6164 206f 6620 7374 6f72 696e 6720 7468  ad of storing th
    │ │ │ -00077db0: 6520 7061 6464 696e 6720 6861 7368 6573  e padding hashes
    │ │ │ -00077dc0: 2c20 7573 650a 2f2f 206e 6567 6174 6976  , use.// negativ
    │ │ │ -00077dd0: 6520 696e 6469 6365 7320 746f 2072 6566  e indices to ref
    │ │ │ -00077de0: 6572 2074 6f20 6669 7865 6420 5348 412d  er to fixed SHA-
    │ │ │ -00077df0: 3235 3628 3029 2c20 616e 6420 5348 412d  256(0), and SHA-
    │ │ │ -00077e00: 3235 3628 5348 412d 3235 3628 3029 2920  256(SHA-256(0)) 
    │ │ │ -00077e10: 616e 6420 736f 0a2f 2f20 6f6e 0a73 7472  and so.// on.str
    │ │ │ -00077e20: 7563 7420 544f 5252 454e 545f 4558 5452  uct TORRENT_EXTR
    │ │ │ -00077e30: 415f 4558 504f 5254 206d 6572 6b6c 655f  A_EXPORT merkle_
    │ │ │ -00077e40: 7472 6565 0a7b 0a3c 6469 7620 7374 796c  tree.{.
    .merkle_tre │ │ │ -00077e80: 6528 2920 3d20 6465 6661 756c 743b 0a3c e() = default;.< │ │ │ -00077e90: 2f64 6976 3e09 6d65 726b 6c65 5f74 7265 /div>.merkle_tre │ │ │ -00077ea0: 6528 696e 7420 6e75 6d5f 626c 6f63 6b73 e(int num_blocks │ │ │ -00077eb0: 2c20 696e 7420 626c 6f63 6b73 5f70 6572 , int blocks_per │ │ │ -00077ec0: 5f70 6965 6365 2c20 6368 6172 2063 6f6e _piece, char con │ │ │ -00077ed0: 7374 2a20 7229 3b0a 0a09 7368 6132 3536 st* r);...sha256 │ │ │ -00077ee0: 5f68 6173 6820 726f 6f74 2829 2063 6f6e _hash root() con │ │ │ -00077ef0: 7374 3b0a 0a09 766f 6964 206c 6f61 645f st;...void load_ │ │ │ -00077f00: 7472 6565 2873 7061 6e26 6c74 3b73 6861 tree(span<sha │ │ │ -00077f10: 3235 365f 6861 7368 2063 6f6e 7374 2667 256_hash const&g │ │ │ -00077f20: 743b 2074 2c20 6269 7466 6965 6c64 2063 t; t, bitfield c │ │ │ -00077f30: 6f6e 7374 2661 6d70 3b20 7665 7269 6669 onst& verifi │ │ │ -00077f40: 6564 293b 0a09 766f 6964 206c 6f61 645f ed);..void load_ │ │ │ -00077f50: 7370 6172 7365 5f74 7265 6528 7370 616e sparse_tree(span │ │ │ -00077f60: 266c 743b 7368 6132 3536 5f68 6173 6820 <sha256_hash │ │ │ -00077f70: 636f 6e73 7426 6774 3b20 742c 2062 6974 const> t, bit │ │ │ -00077f80: 6669 656c 6420 636f 6e73 7426 616d 703b field const& │ │ │ -00077f90: 206d 6173 6b0a 0909 2c20 6269 7466 6965 mask..., bitfie │ │ │ -00077fa0: 6c64 2063 6f6e 7374 2661 6d70 3b20 7665 ld const& ve │ │ │ -00077fb0: 7269 6669 6564 293b 0a09 766f 6964 206c rified);..void l │ │ │ -00077fc0: 6f61 645f 7665 7269 6669 6564 5f62 6974 oad_verified_bit │ │ │ -00077fd0: 7328 6269 7466 6965 6c64 2063 6f6e 7374 s(bitfield const │ │ │ -00077fe0: 2661 6d70 3b20 7665 7269 6669 6564 293b & verified); │ │ │ -00077ff0: 0a0a 0973 7464 3a3a 7369 7a65 5f74 2073 ...std::size_t s │ │ │ -00078000: 697a 6528 2920 636f 6e73 743b 0a09 696e ize() const;..in │ │ │ -00078010: 7420 656e 645f 696e 6465 7828 2920 636f t end_index() co │ │ │ -00078020: 6e73 7420 7b20 7265 7475 726e 2069 6e74 nst { return int │ │ │ -00078030: 2873 697a 6528 2929 3b20 7d0a 0a09 626f (size()); }...bo │ │ │ -00078040: 6f6c 2068 6173 5f6e 6f64 6528 696e 7420 ol has_node(int │ │ │ -00078050: 6964 7829 2063 6f6e 7374 3b0a 0a09 626f idx) const;...bo │ │ │ -00078060: 6f6c 2063 6f6d 7061 7265 5f6e 6f64 6528 ol compare_node( │ │ │ -00078070: 696e 7420 6964 782c 2073 6861 3235 365f int idx, sha256_ │ │ │ -00078080: 6861 7368 2063 6f6e 7374 2661 6d70 3b20 hash const& │ │ │ -00078090: 6829 2063 6f6e 7374 3b0a 0a09 7368 6132 h) const;...sha2 │ │ │ -000780a0: 3536 5f68 6173 6820 6f70 6572 6174 6f72 56_hash operator │ │ │ -000780b0: 5b5d 2869 6e74 2069 6478 2920 636f 6e73 [](int idx) cons │ │ │ -000780c0: 743b 0a0a 0973 7464 3a3a 7665 6374 6f72 t;...std::vector │ │ │ -000780d0: 266c 743b 7368 6132 3536 5f68 6173 6826 <sha256_hash& │ │ │ -000780e0: 6774 3b20 6275 696c 645f 7665 6374 6f72 gt; build_vector │ │ │ -000780f0: 2829 2063 6f6e 7374 3b0a 0973 7464 3a3a () const;..std:: │ │ │ -00078100: 7061 6972 266c 743b 7374 643a 3a76 6563 pair<std::vec │ │ │ -00078110: 746f 7226 6c74 3b73 6861 3235 365f 6861 tor<sha256_ha │ │ │ -00078120: 7368 2667 743b 2c20 6269 7466 6965 6c64 sh>, bitfield │ │ │ -00078130: 2667 743b 2062 7569 6c64 5f73 7061 7273 > build_spars │ │ │ -00078140: 655f 7665 6374 6f72 2829 2063 6f6e 7374 e_vector() const │ │ │ -00078150: 3b0a 0a09 2f2f 2067 6574 2062 6974 7320 ;...// get bits │ │ │ -00078160: 696e 6469 6361 7469 6e67 2069 6620 6561 indicating if ea │ │ │ -00078170: 6368 206c 6561 6620 6861 7368 2069 7320 ch leaf hash is │ │ │ -00078180: 7665 7269 6669 6564 0a09 6269 7466 6965 verified..bitfie │ │ │ -00078190: 6c64 2076 6572 6966 6965 645f 6c65 6166 ld verified_leaf │ │ │ -000781a0: 7328 2920 636f 6e73 743b 0a0a 092f 2f20 s() const;...// │ │ │ -000781b0: 7265 7475 726e 7320 7472 7565 2069 6620 returns true if │ │ │ -000781c0: 7468 6520 656e 7469 7265 2074 7265 6520 the entire tree │ │ │ -000781d0: 6973 206b 6e6f 776e 2061 6e64 2076 6572 is known and ver │ │ │ -000781e0: 6966 6965 640a 0962 6f6f 6c20 6973 5f63 ified..bool is_c │ │ │ -000781f0: 6f6d 706c 6574 6528 2920 636f 6e73 743b omplete() const; │ │ │ -00078200: 0a0a 092f 2f20 7265 7475 726e 7320 7472 ...// returns tr │ │ │ -00078210: 7565 2069 6620 616c 6c20 626c 6f63 6b20 ue if all block │ │ │ -00078220: 6861 7368 6573 2069 6e20 7468 6520 7370 hashes in the sp │ │ │ -00078230: 6563 6966 6965 6420 7261 6e67 6520 6861 ecified range ha │ │ │ -00078240: 7665 2062 6565 6e20 7665 7269 6669 6564 ve been verified │ │ │ -00078250: 0a09 626f 6f6c 2062 6c6f 636b 735f 7665 ..bool blocks_ve │ │ │ -00078260: 7269 6669 6564 2869 6e74 2062 6c6f 636b rified(int block │ │ │ -00078270: 5f69 6478 2c20 696e 7420 6e75 6d5f 626c _idx, int num_bl │ │ │ -00078280: 6f63 6b73 2920 636f 6e73 743b 0a0a 3c2f ocks) const;..r │ │ │ -000782c0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -000782d0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -00078300: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00078310: 7578 5f2f 6d65 726b 6c65 5f74 7265 652e ux_/merkle_tree. │ │ │ -00078320: 6870 703a 3135 323c 2f61 3e3c 2f74 643e hpp:152 │ │ │ -00078330: 3c74 643e 6d61 6b65 2074 6869 7320 6120 make this a │ │ │ -00078340: 7374 643a 3a75 6e69 7175 655f 7074 723c std::unique_ptr< │ │ │ -00078350: 7368 6132 3536 5f68 6173 685b 5d3e 3c2f sha256_hash[]>

    make │ │ │ -000783b0: 2074 6869 7320 6120 7374 643a 3a75 6e69 this a std::uni │ │ │ -000783c0: 7175 655f 7074 723c 7368 6132 3536 5f68 que_ptr

    . │ │ │ -000783e0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -000783f0: 7265 6e74 2f61 7578 5f2f 6d65 726b 6c65 rent/aux_/merkle │ │ │ -00078400: 5f74 7265 652e 6870 703a 3135 323c 2f68 _tree.hpp:152
    ..in
    │ │ │ -00078450: 7420 626c 6f63 6b73 5f70 6572 5f70 6965  t blocks_per_pie
    │ │ │ -00078460: 6365 2829 2063 6f6e 7374 207b 2072 6574  ce() const { ret
    │ │ │ -00078470: 7572 6e20 3120 266c 743b 266c 743b 206d  urn 1 << m
    │ │ │ -00078480: 5f62 6c6f 636b 735f 7065 725f 7069 6563  _blocks_per_piec
    │ │ │ -00078490: 655f 6c6f 673b 207d 0a09 2f2f 2074 6865  e_log; }..// the
    │ │ │ -000784a0: 206e 756d 6265 7220 7472 6565 206c 6576   number tree lev
    │ │ │ -000784b0: 656c 7320 7065 7220 7069 6563 652e 2054  els per piece. T
    │ │ │ -000784c0: 6869 7320 6973 2030 2069 6620 7468 6520  his is 0 if the 
    │ │ │ -000784d0: 626c 6f63 6b20 6c61 7965 7220 6973 2061  block layer is a
    │ │ │ -000784e0: 6c73 6f0a 092f 2f20 7468 6520 7069 6563  lso..// the piec
    │ │ │ -000784f0: 6520 6c61 7965 722e 0a09 696e 7420 7069  e layer...int pi
    │ │ │ -00078500: 6563 655f 6c65 7665 6c73 2829 2063 6f6e  ece_levels() con
    │ │ │ -00078510: 7374 207b 2072 6574 7572 6e20 6d5f 626c  st { return m_bl
    │ │ │ -00078520: 6f63 6b73 5f70 6572 5f70 6965 6365 5f6c  ocks_per_piece_l
    │ │ │ -00078530: 6f67 3b20 7d0a 0a09 696e 7420 626c 6f63  og; }...int bloc
    │ │ │ -00078540: 6b5f 6c61 7965 725f 7374 6172 7428 2920  k_layer_start() 
    │ │ │ -00078550: 636f 6e73 743b 0a09 696e 7420 7069 6563  const;..int piec
    │ │ │ -00078560: 655f 6c61 7965 725f 7374 6172 7428 2920  e_layer_start() 
    │ │ │ -00078570: 636f 6e73 743b 0a09 696e 7420 6e75 6d5f  const;..int num_
    │ │ │ -00078580: 7069 6563 6573 2829 2063 6f6e 7374 3b0a  pieces() const;.
    │ │ │ -00078590: 0969 6e74 206e 756d 5f6c 6561 6673 2829  .int num_leafs()
    │ │ │ -000785a0: 2063 6f6e 7374 3b0a 0a09 766f 6964 206f   const;...void o
    │ │ │ -000785b0: 7074 696d 697a 655f 7374 6f72 6167 6528  ptimize_storage(
    │ │ │ -000785c0: 293b 0a09 766f 6964 206f 7074 696d 697a  );..void optimiz
    │ │ │ -000785d0: 655f 7374 6f72 6167 655f 7069 6563 655f  e_storage_piece_
    │ │ │ -000785e0: 6c61 7965 7228 293b 0a09 766f 6964 2061  layer();..void a
    │ │ │ -000785f0: 6c6c 6f63 6174 655f 6675 6c6c 2829 3b0a  llocate_full();.
    │ │ │ -00078600: 0a09 2f2f 2061 2070 6f69 6e74 6572 2074  ..// a pointer t
    │ │ │ -00078610: 6f20 7468 6520 726f 6f74 2068 6173 6820  o the root hash 
    │ │ │ -00078620: 666f 7220 7468 6973 2066 696c 652e 0a09  for this file...
    │ │ │ -00078630: 6368 6172 2063 6f6e 7374 2a20 6d5f 726f  char const* m_ro
    │ │ │ -00078640: 6f74 203d 206e 756c 6c70 7472 3b0a 0a09  ot = nullptr;...
    │ │ │ -00078650: 2f2f 2074 6869 7320 6973 2065 6974 6865  // this is eithe
    │ │ │ -00078660: 7220 7468 6520 6675 6c6c 2074 7265 652c  r the full tree,
    │ │ │ -00078670: 206f 7220 736f 6d65 2073 7061 7273 6520   or some sparse 
    │ │ │ -00078680: 7265 7072 6573 656e 7461 7469 6f6e 206f  representation o
    │ │ │ -00078690: 6620 6974 2c0a 092f 2f20 6465 7065 6e64  f it,..// depend
    │ │ │ -000786a0: 696e 6720 6f6e 206d 5f6d 6f64 650a 3c64  ing on m_mode..aux
    │ │ │ -000786e0: 3a3a 7665 6374 6f72 266c 743b 7368 6132  ::vector<sha2
    │ │ │ -000786f0: 3536 5f68 6173 6826 6774 3b20 6d5f 7472  56_hash> m_tr
    │ │ │ -00078700: 6565 3b0a 3c2f 6469 763e 0a09 2f2f 2077  ee;.

    ..// w │ │ │ -00078710: 6865 6e20 7468 6520 6675 6c6c 2074 7265 hen the full tre │ │ │ -00078720: 6520 6973 2061 6c6c 6f63 6174 6564 2c20 e is allocated, │ │ │ -00078730: 7468 6973 2068 6173 206f 6e65 2062 6974 this has one bit │ │ │ -00078740: 2066 6f72 2065 6163 6820 626c 6f63 6b20 for each block │ │ │ -00078750: 6861 7368 2e20 610a 092f 2f20 3120 6d65 hash. a..// 1 me │ │ │ -00078760: 616e 7320 7765 2068 6176 6520 7665 7269 ans we have veri │ │ │ -00078770: 6669 6564 2074 6865 2062 6c6f 636b 2068 fied the block h │ │ │ -00078780: 6173 6820 746f 2062 6520 636f 7272 6563 ash to be correc │ │ │ -00078790: 742c 206f 7468 6572 7769 7365 2074 6865 t, otherwise the │ │ │ -000787a0: 2062 6c6f 636b 0a09 2f2f 2068 6173 6820 block..// hash │ │ │ -000787b0: 6d61 7920 7265 7072 6573 656e 7420 7768 may represent wh │ │ │ -000787c0: 6174 2773 206f 6e20 6469 736b 2c20 6275 at's on disk, bu │ │ │ -000787d0: 7420 7765 2068 6176 656e 2774 2062 6565 t we haven't bee │ │ │ -000787e0: 6e20 6162 6c65 2074 6f20 7665 7269 6679 n able to verify │ │ │ -000787f0: 2069 740a 092f 2f20 7965 740a 0962 6974 it..// yet..bit │ │ │ -00078800: 6669 656c 6420 6d5f 626c 6f63 6b5f 7665 field m_block_ve │ │ │ -00078810: 7269 6669 6564 3b0a 0a09 2f2f 206e 756d rified;...// num │ │ │ -00078820: 6265 7220 6f66 2062 6c6f 636b 7320 696e ber of blocks in │ │ │ -00078830: 2074 6865 2066 696c 6520 7468 6973 2074 the file this t │ │ │ -00078840: 7265 6520 7265 7072 6573 656e 7473 2e20 ree represents. │ │ │ -00078850: 5468 6520 6e75 6d62 6572 206f 6620 6c65 The number of le │ │ │ -00078860: 6166 7320 696e 0a09 2f2f 2074 6865 2074 afs in..// the t │ │ │ -00078870: 7265 6520 6973 2072 6f75 6e64 6564 2075 ree is rounded u │ │ │ -00078880: 7020 746f 2061 6e20 6576 656e 2070 6f77 p to an even pow │ │ │ -00078890: 6572 206f 6620 322e 0a09 696e 7420 6d5f er of 2...int m_ │ │ │ -000788a0: 6e75 6d5f 626c 6f63 6b73 203d 2030 3b0a num_blocks = 0;. │ │ │ -000788b0: 0a09 2f2f 2074 6865 206e 756d 6265 7220 ..// the number │ │ │ -000788c0: 6f66 2062 6c6f 636b 7320 7065 7220 7069 of blocks per pi │ │ │ -000788d0: 6563 652c 2073 7065 6369 6669 6564 2061 ece, specified a │ │ │ -000788e0: 7320 686f 7720 6d61 6e79 2073 7465 7073 s how many steps │ │ │ -000788f0: 2074 6f20 7368 6966 740a 092f 2f20 7269 to shift..// ri │ │ │ -00078900: 6768 7420 3120 746f 2067 6574 2074 6865 ght 1 to get the │ │ │ -00078910: 206e 756d 6265 7220 6f66 2062 6c6f 636b number of block │ │ │ -00078920: 7320 696e 206f 6e65 2070 6965 6365 2e20 s in one piece. │ │ │ -00078930: 5468 6973 2069 7320 6120 636f 6d70 6163 This is a compac │ │ │ -00078940: 740a 092f 2f20 7265 7072 6573 656e 7461 t..// representa │ │ │ -00078950: 7469 6f6e 2074 6861 7427 7320 7661 6c69 tion that's vali │ │ │ -00078960: 6420 6265 6361 7573 6520 7069 6563 6573 d because pieces │ │ │ -00078970: 2061 7265 2061 6c77 6179 7320 706f 7765 are always powe │ │ │ -00078980: 7273 206f 6620 322e 0a09 2f2f 2074 6869 rs of 2...// thi │ │ │ -00078990: 7320 6973 206e 6563 6573 7361 7279 2074 s is necessary t │ │ │ -000789a0: 6f20 6b6e 6f77 2077 6869 6368 206c 6179 o know which lay │ │ │ -000789b0: 6572 2069 6e20 7468 6520 7472 6565 2074 er in the tree t │ │ │ -000789c0: 6865 2070 6965 6365 206c 6179 6572 2069 he piece layer i │ │ │ -000789d0: 732e 0a09 7374 643a 3a75 696e 7438 5f74 s...std::uint8_t │ │ │ -000789e0: 206d 5f62 6c6f 636b 735f 7065 725f 7069 m_blocks_per_pi │ │ │ -000789f0: 6563 655f 6c6f 6720 3d20 303b 0a0a 0965 ece_log = 0;...e │ │ │ -00078a00: 6e75 6d20 636c 6173 7320 6d6f 6465 5f74 num class mode_t │ │ │ -00078a10: 203a 2073 7464 3a3a 7569 6e74 385f 740a : std::uint8_t. │ │ │ -00078a20: 097b 0a09 092f 2f20 6120 6465 6661 756c .{...// a defaul │ │ │ -00078a30: 7420 636f 6e73 7472 7563 7465 6420 7472 t constructed tr │ │ │ -00078a40: 6565 2069 7320 7472 756c 7920 656d 7074 ee is truly empt │ │ │ -00078a50: 792e 2049 7420 646f 6573 206e 6f74 2065 y. It does not e │ │ │ -00078a60: 7665 6e20 6861 7665 2061 0a09 092f 2f20 ven have a...// │ │ │ -00078a70: 726f 6f74 2068 6173 680a 0909 756e 696e root hash...unin │ │ │ -00078a80: 6974 6961 6c69 7a65 645f 7472 6565 2c0a itialized_tree,. │ │ │ -00078a90: 0a09 092f 2f20 7765 2064 6f6e 2774 2068 ...// we don't h │ │ │ -00078aa0: 6176 6520 616e 7920 6861 7368 6573 2069 ave any hashes i │ │ │ -00078ab0: 6e20 7468 6973 2074 7265 652e 206d 5f74 n this tree. m_t │ │ │ -00078ac0: 7265 6520 7368 6f75 6c64 2062 6520 656d ree should be em │ │ │ -00078ad0: 7074 790a 0909 2f2f 2061 6e20 656d 7074 pty...// an empt │ │ │ -00078ae0: 7920 7472 6565 2073 7469 6c6c 2061 6c77 y tree still alw │ │ │ -00078af0: 6179 7320 6861 7665 2074 6865 2072 6f6f ays have the roo │ │ │ -00078b00: 7420 6861 7368 2028 6176 6169 6c61 626c t hash (availabl │ │ │ -00078b10: 6520 6173 2072 6f6f 7428 2929 0a09 0965 e as root())...e │ │ │ -00078b20: 6d70 7479 5f74 7265 652c 0a0a 0909 2f2f mpty_tree,....// │ │ │ -00078b30: 2069 6e20 7468 6973 206d 6f64 652c 206d in this mode, m │ │ │ -00078b40: 5f74 7265 6520 7265 7072 6573 656e 7473 _tree represents │ │ │ -00078b50: 2074 6865 2066 756c 6c20 7472 6565 2c20 the full tree, │ │ │ -00078b60: 696e 636c 7564 696e 6720 7061 6464 696e including paddin │ │ │ -00078b70: 672e 0a09 0966 756c 6c5f 7472 6565 2c0a g....full_tree,. │ │ │ -00078b80: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00078bc0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -00078bf0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00078c00: 742f 6175 785f 2f72 6561 6477 7269 7465 t/aux_/readwrite │ │ │ -00078c10: 2e68 7070 3a32 3535 3c2f 613e 3c2f 7464 .hpp:255is it reall │ │ │ -00078c30: 7920 6e65 6365 7373 6172 7920 746f 206d y necessary to m │ │ │ -00078c40: 616b 6520 7477 6f20 636f 7069 6573 206f ake two copies o │ │ │ -00078c50: 6620 7468 6520 696f 7665 6373 3f20 5468 f the iovecs? Th │ │ │ -00078c60: 6520 6c6f 772d 6c65 7665 6c20 7379 7374 e low-level syst │ │ │ -00078c70: 656d 2063 616c 6c20 7769 6c6c 206e 6565 em call will nee │ │ │ -00078c80: 6420 746f 206d 616b 6520 6974 7320 6f77 d to make its ow │ │ │ -00078c90: 6e20 636f 7079 2061 7320 7765 6c6c 3c2f n copy as well

    is i │ │ │ -00078cf0: 7420 7265 616c 6c79 206e 6563 6573 7361 t really necessa │ │ │ -00078d00: 7279 2074 6f20 6d61 6b65 2074 776f 2063 ry to make two c │ │ │ -00078d10: 6f70 6965 7320 6f66 2074 6865 2069 6f76 opies of the iov │ │ │ -00078d20: 6563 733f 2054 6865 206c 6f77 2d6c 6576 ecs? The low-lev │ │ │ -00078d30: 656c 0a73 7973 7465 6d20 6361 6c6c 2077 el.system call w │ │ │ -00078d40: 696c 6c20 6e65 6564 2074 6f20 6d61 6b65 ill need to make │ │ │ -00078d50: 2069 7473 206f 776e 2063 6f70 7920 6173 its own copy as │ │ │ -00078d60: 2077 656c 6c3c 2f68 323e 3c68 343e 2e2e well

    .. │ │ │ -00078d70: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00078d80: 656e 742f 6175 785f 2f72 6561 6477 7269 ent/aux_/readwri │ │ │ -00078d90: 7465 2e68 7070 3a32 3535 3c2f 6834 3e3c te.hpp:255

    < │ │ │ -00078da0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00078db0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00078dc0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00078dd0: 7820 2364 6464 3b22 3e09 544f 5252 454e x #ddd;">.TORREN │ │ │ -00078de0: 545f 4153 5345 5254 2873 7461 7469 635f T_ASSERT(static_ │ │ │ -00078df0: 6361 7374 266c 743b 696e 7426 6774 3b28 cast<int>( │ │ │ -00078e00: 7069 6563 6529 202a 2073 7461 7469 635f piece) * static_ │ │ │ -00078e10: 6361 7374 266c 743b 7374 643a 3a69 6e74 cast<std::int │ │ │ -00078e20: 3634 5f74 2667 743b 2866 696c 6573 2e70 64_t>(files.p │ │ │ -00078e30: 6965 6365 5f6c 656e 6774 6828 2929 0a09 iece_length()).. │ │ │ -00078e40: 092b 206f 6666 7365 7420 2b20 7369 7a65 .+ offset + size │ │ │ -00078e50: 2026 6c74 3b3d 2066 696c 6573 2e74 6f74 <= files.tot │ │ │ -00078e60: 616c 5f73 697a 6528 2929 3b0a 0a09 2f2f al_size());...// │ │ │ -00078e70: 2066 696e 6420 7468 6520 6669 6c65 2069 find the file i │ │ │ -00078e80: 7465 7261 746f 7220 616e 6420 6669 6c65 terator and file │ │ │ -00078e90: 206f 6666 7365 740a 0973 7464 3a3a 696e offset..std::in │ │ │ -00078ea0: 7436 345f 7420 636f 6e73 7420 746f 7272 t64_t const torr │ │ │ -00078eb0: 656e 745f 6f66 6673 6574 203d 2073 7461 ent_offset = sta │ │ │ -00078ec0: 7469 635f 6361 7374 266c 743b 696e 7426 tic_cast<int& │ │ │ -00078ed0: 6774 3b28 7069 6563 6529 202a 2073 7464 gt;(piece) * std │ │ │ -00078ee0: 3a3a 696e 7436 345f 7428 6669 6c65 732e ::int64_t(files. │ │ │ -00078ef0: 7069 6563 655f 6c65 6e67 7468 2829 2920 piece_length()) │ │ │ -00078f00: 2b20 6f66 6673 6574 3b0a 0966 696c 655f + offset;..file_ │ │ │ -00078f10: 696e 6465 785f 7420 6669 6c65 5f69 6e64 index_t file_ind │ │ │ -00078f20: 6578 203d 2066 696c 6573 2e66 696c 655f ex = files.file_ │ │ │ -00078f30: 696e 6465 785f 6174 5f6f 6666 7365 7428 index_at_offset( │ │ │ -00078f40: 746f 7272 656e 745f 6f66 6673 6574 293b torrent_offset); │ │ │ -00078f50: 0a09 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -00078f60: 2874 6f72 7265 6e74 5f6f 6666 7365 7420 (torrent_offset │ │ │ -00078f70: 2667 743b 3d20 6669 6c65 732e 6669 6c65 >= files.file │ │ │ -00078f80: 5f6f 6666 7365 7428 6669 6c65 5f69 6e64 _offset(file_ind │ │ │ -00078f90: 6578 2929 3b0a 0954 4f52 5245 4e54 5f41 ex));..TORRENT_A │ │ │ -00078fa0: 5353 4552 5428 746f 7272 656e 745f 6f66 SSERT(torrent_of │ │ │ -00078fb0: 6673 6574 2026 6c74 3b20 6669 6c65 732e fset < files. │ │ │ -00078fc0: 6669 6c65 5f6f 6666 7365 7428 6669 6c65 file_offset(file │ │ │ -00078fd0: 5f69 6e64 6578 2920 2b20 6669 6c65 732e _index) + files. │ │ │ -00078fe0: 6669 6c65 5f73 697a 6528 6669 6c65 5f69 file_size(file_i │ │ │ -00078ff0: 6e64 6578 2929 3b0a 0973 7464 3a3a 696e ndex));..std::in │ │ │ -00079000: 7436 345f 7420 6669 6c65 5f6f 6666 7365 t64_t file_offse │ │ │ -00079010: 7420 3d20 746f 7272 656e 745f 6f66 6673 t = torrent_offs │ │ │ -00079020: 6574 202d 2066 696c 6573 2e66 696c 655f et - files.file_ │ │ │ -00079030: 6f66 6673 6574 2866 696c 655f 696e 6465 offset(file_inde │ │ │ -00079040: 7829 3b0a 0a09 2f2f 2074 6865 206e 756d x);...// the num │ │ │ -00079050: 6265 7220 6f66 2062 7974 6573 206c 6566 ber of bytes lef │ │ │ -00079060: 7420 6265 666f 7265 2074 6869 7320 7265 t before this re │ │ │ -00079070: 6164 206f 7220 7772 6974 6520 6f70 6572 ad or write oper │ │ │ -00079080: 6174 696f 6e20 6973 0a09 2f2f 2063 6f6d ation is..// com │ │ │ -00079090: 706c 6574 656c 7920 7361 7469 7366 6965 pletely satisfie │ │ │ -000790a0: 642e 0a09 696e 7420 6279 7465 735f 6c65 d...int bytes_le │ │ │ -000790b0: 6674 203d 2073 697a 653b 0a0a 0954 4f52 ft = size;...TOR │ │ │ -000790c0: 5245 4e54 5f41 5353 4552 5428 6279 7465 RENT_ASSERT(byte │ │ │ -000790d0: 735f 6c65 6674 2026 6774 3b3d 2030 293b s_left >= 0); │ │ │ -000790e0: 0a0a 092f 2f20 636f 7079 2074 6865 2069 ...// copy the i │ │ │ -000790f0: 6f76 6563 2061 7272 6179 2073 6f20 7765 ovec array so we │ │ │ -00079100: 2063 616e 2075 7365 2069 7420 746f 206b can use it to k │ │ │ -00079110: 6565 7020 7472 6163 6b20 6f66 206f 7572 eep track of our │ │ │ -00079120: 2063 7572 7265 6e74 0a09 2f2f 206c 6f63 current..// loc │ │ │ -00079130: 6174 696f 6e20 6279 2075 7064 6174 696e ation by updatin │ │ │ -00079140: 6720 7468 6520 6865 6164 2062 6173 6520 g the head base │ │ │ -00079150: 706f 696e 7465 7220 616e 6420 7369 7a65 pointer and size │ │ │ -00079160: 2e20 2873 6565 0a09 2f2f 2061 6476 616e . (see..// advan │ │ │ -00079170: 6365 5f62 7566 7328 2929 0a0a 3c64 6976 ce_bufs())..
    .TORRE │ │ │ -000791b0: 4e54 5f41 4c4c 4f43 4128 6375 7272 656e NT_ALLOCA(curren │ │ │ -000791c0: 745f 6275 662c 2073 7061 6e26 6c74 3b43 t_buf, span<C │ │ │ -000791d0: 6861 7226 6774 3b2c 2062 7566 732e 7369 har>, bufs.si │ │ │ -000791e0: 7a65 2829 293b 0a3c 2f64 6976 3e09 636f ze());.
    .co │ │ │ -000791f0: 7079 5f62 7566 7328 6275 6673 2c20 7369 py_bufs(bufs, si │ │ │ -00079200: 7a65 2c20 6375 7272 656e 745f 6275 6629 ze, current_buf) │ │ │ -00079210: 3b0a 0954 4f52 5245 4e54 5f41 5353 4552 ;..TORRENT_ASSER │ │ │ -00079220: 5428 636f 756e 745f 6275 6673 2863 7572 T(count_bufs(cur │ │ │ -00079230: 7265 6e74 5f62 7566 2c20 7369 7a65 2920 rent_buf, size) │ │ │ -00079240: 3d3d 2069 6e74 2862 7566 732e 7369 7a65 == int(bufs.size │ │ │ -00079250: 2829 2929 3b0a 0a09 544f 5252 454e 545f ()));...TORRENT_ │ │ │ -00079260: 414c 4c4f 4341 2874 6d70 5f62 7566 2c20 ALLOCA(tmp_buf, │ │ │ -00079270: 7370 616e 266c 743b 4368 6172 2667 743b span<Char> │ │ │ -00079280: 2c20 6275 6673 2e73 697a 6528 2929 3b0a , bufs.size());. │ │ │ -00079290: 0977 6869 6c65 2028 6279 7465 735f 6c65 .while (bytes_le │ │ │ -000792a0: 6674 2026 6774 3b20 3029 0a09 7b0a 0909 ft > 0)..{... │ │ │ -000792b0: 2f2f 2074 6865 206e 756d 6265 7220 6f66 // the number of │ │ │ -000792c0: 2062 7974 6573 206c 6566 7420 746f 2072 bytes left to r │ │ │ -000792d0: 6561 6420 696e 2074 6865 2063 7572 7265 ead in the curre │ │ │ -000792e0: 6e74 2066 696c 6520 2873 7065 6369 6669 nt file (specifi │ │ │ -000792f0: 6564 2062 790a 0909 2f2f 2066 696c 655f ed by...// file_ │ │ │ -00079300: 696e 6465 7829 2e20 5468 6973 2069 7320 index). This is │ │ │ -00079310: 7468 6520 6d69 6e69 6d75 6d20 6f66 2028 the minimum of ( │ │ │ -00079320: 6669 6c65 5f73 697a 6520 2d20 6669 6c65 file_size - file │ │ │ -00079330: 5f6f 6666 7365 7429 2061 6e64 0a09 092f _offset) and.../ │ │ │ -00079340: 2f20 6279 7465 735f 6c65 6674 2e0a 0909 / bytes_left.... │ │ │ -00079350: 696e 7420 6669 6c65 5f62 7974 6573 5f6c int file_bytes_l │ │ │ -00079360: 6566 7420 3d20 6279 7465 735f 6c65 6674 eft = bytes_left │ │ │ -00079370: 3b0a 0909 6966 2028 6669 6c65 5f6f 6666 ;...if (file_off │ │ │ -00079380: 7365 7420 2b20 6669 6c65 5f62 7974 6573 set + file_bytes │ │ │ -00079390: 5f6c 6566 7420 2667 743b 2066 696c 6573 _left > files │ │ │ -000793a0: 2e66 696c 655f 7369 7a65 2866 696c 655f .file_size(file_ │ │ │ -000793b0: 696e 6465 7829 290a 0909 0966 696c 655f index))....file_ │ │ │ -000793c0: 6279 7465 735f 6c65 6674 203d 2073 7464 bytes_left = std │ │ │ -000793d0: 3a3a 6d61 7828 7374 6174 6963 5f63 6173 ::max(static_cas │ │ │ -000793e0: 7426 6c74 3b69 6e74 2667 743b 2866 696c t<int>(fil │ │ │ -000793f0: 6573 2e66 696c 655f 7369 7a65 2866 696c es.file_size(fil │ │ │ -00079400: 655f 696e 6465 7829 202d 2066 696c 655f e_index) - file_ │ │ │ -00079410: 6f66 6673 6574 292c 2030 293b 0a0a 0909 offset), 0);.... │ │ │ -00079420: 2f2f 2074 6865 7265 2061 7265 206e 6f20 // there are no │ │ │ -00079430: 6279 7465 7320 6c65 6674 2069 6e20 7468 bytes left in th │ │ │ -00079440: 6973 2066 696c 652c 206d 6f76 6520 746f is file, move to │ │ │ -00079450: 2074 6865 206e 6578 7420 6f6e 650a 0909 the next one... │ │ │ -00079460: 2f2f 2074 6869 7320 6c6f 6f70 2073 6b69 // this loop ski │ │ │ -00079470: 7073 206f 7665 7220 656d 7074 7920 6669 ps over empty fi │ │ │ -00079480: 6c65 730a 0909 7768 696c 6520 2866 696c les...while (fil │ │ │ -00079490: 655f 6279 7465 735f 6c65 6674 203d 3d20 e_bytes_left == │ │ │ -000794a0: 3029 0a09 097b 0a09 0909 2b2b 6669 6c65 0)...{....++file │ │ │ -000794b0: 5f69 6e64 6578 3b0a 0909 0966 696c 655f _index;....file_ │ │ │ -000794c0: 6f66 6673 6574 203d 2030 3b0a 0909 0954 offset = 0;....T │ │ │ -000794d0: 4f52 5245 4e54 5f41 5353 4552 5428 6669 ORRENT_ASSERT(fi │ │ │ -000794e0: 6c65 5f69 6e64 6578 2026 6c74 3b20 6669 le_index < fi │ │ │ -000794f0: 6c65 732e 656e 645f 6669 6c65 2829 293b les.end_file()); │ │ │ -00079500: 0a0a 0909 092f 2f20 7468 6973 2073 686f .....// this sho │ │ │ -00079510: 756c 6420 6e6f 7420 6861 7070 656e 2e20 uld not happen. │ │ │ -00079520: 6279 7465 735f 6c65 6674 2073 686f 756c bytes_left shoul │ │ │ -00079530: 6420 6265 2063 6c61 6d70 6564 2062 7920 d be clamped by │ │ │ -00079540: 7468 6520 746f 7461 6c0a 0909 092f 2f20 the total....// │ │ │ -00079550: 7369 7a65 206f 6620 7468 6520 746f 7272 size of the torr │ │ │ -00079560: 656e 742c 2073 6f20 7765 2073 686f 756c ent, so we shoul │ │ │ -00079570: 6420 6e65 7665 7220 7275 6e20 6f66 6620 d never run off │ │ │ -00079580: 7468 6520 656e 6420 6f66 2069 740a 0909 the end of it... │ │ │ -00079590: 0969 6620 2866 696c 655f 696e 6465 7820 .if (file_index │ │ │ -000795a0: 2667 743b 3d20 6669 6c65 732e 656e 645f >= files.end_ │ │ │ -000795b0: 6669 6c65 2829 2920 7265 7475 726e 2073 file()) return s │ │ │ -000795c0: 697a 653b 0a0a 0909 0966 696c 655f 6279 ize;.....file_by │ │ │ -000795d0: 7465 735f 6c65 6674 203d 2062 7974 6573 tes_left = bytes │ │ │ -000795e0: 5f6c 6566 743b 0a0a 0909 0969 6620 2866 _left;.....if (f │ │ │ -000795f0: 696c 655f 6f66 6673 6574 202b 2066 696c ile_offset + fil │ │ │ -00079600: 655f 6279 7465 735f 6c65 6674 2026 6774 e_bytes_left > │ │ │ -00079610: 3b20 6669 6c65 732e 6669 6c65 5f73 697a ; files.file_siz │ │ │ -00079620: 6528 6669 6c65 5f69 6e64 6578 2929 0a09 e(file_index)).. │ │ │ -00079630: 0909 0966 696c 655f 6279 7465 735f 6c65 ...file_bytes_le │ │ │ -00079640: 6674 203d 2073 7464 3a3a 6d61 7828 7374 ft = std::max(st │ │ │ -00079650: 6174 6963 5f63 6173 7426 6c74 3b69 6e74 atic_cast<int │ │ │ -00079660: 2667 743b 2866 696c 6573 2e66 696c 655f >(files.file_ │ │ │ -00079670: 7369 7a65 2866 696c 655f 696e 6465 7829 size(file_index) │ │ │ -00079680: 202d 2066 696c 655f 6f66 6673 6574 292c - file_offset), │ │ │ -00079690: 2030 293b 0a09 097d 0a3c 2f70 7265 3e3c 0);...}.< │ │ │ -000796a0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000796d0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000796e0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/l │ │ │ -00079710: 6962 746f 7272 656e 742f 6175 785f 2f64 ibtorrent/aux_/d │ │ │ -00079720: 6973 6b5f 696f 5f74 6872 6561 645f 706f isk_io_thread_po │ │ │ -00079730: 6f6c 2e68 7070 3a33 303c 2f61 3e3c 2f74 ol.hpp:30
    move into │ │ │ -00079750: 6175 7820 6e61 6d65 7370 6163 653c 2f74 aux namespace

    move │ │ │ -000797b0: 696e 746f 2061 7578 206e 616d 6573 7061 into aux namespa │ │ │ -000797c0: 6365 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ce

    ../in │ │ │ -000797d0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -000797e0: 2f61 7578 5f2f 6469 736b 5f69 6f5f 7468 /aux_/disk_io_th │ │ │ -000797f0: 7265 6164 5f70 6f6f 6c2e 6870 703a 3330 read_pool.hpp:30 │ │ │ -00079800: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    *
    │ │ │ -00079840: 2f0a 0a23 6966 6e64 6566 2054 4f52 5245  /..#ifndef TORRE
    │ │ │ -00079850: 4e54 5f44 4953 4b5f 494f 5f54 4852 4541  NT_DISK_IO_THREA
    │ │ │ -00079860: 445f 504f 4f4c 0a23 6465 6669 6e65 2054  D_POOL.#define T
    │ │ │ -00079870: 4f52 5245 4e54 5f44 4953 4b5f 494f 5f54  ORRENT_DISK_IO_T
    │ │ │ -00079880: 4852 4541 445f 504f 4f4c 0a0a 2369 6e63  HREAD_POOL..#inc
    │ │ │ -00079890: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ -000798a0: 2f63 6f6e 6669 672e 6870 7022 0a23 696e  /config.hpp".#in
    │ │ │ -000798b0: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ -000798c0: 742f 6175 785f 2f65 7870 6f72 742e 6870  t/aux_/export.hp
    │ │ │ -000798d0: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ -000798e0: 746f 7272 656e 742f 6175 785f 2f64 6561  torrent/aux_/dea
    │ │ │ -000798f0: 646c 696e 655f 7469 6d65 722e 6870 7022  dline_timer.hpp"
    │ │ │ -00079900: 0a0a 2369 6e63 6c75 6465 2022 6c69 6274  ..#include "libt
    │ │ │ -00079910: 6f72 7265 6e74 2f61 7578 5f2f 6469 736b  orrent/aux_/disk
    │ │ │ -00079920: 5f6a 6f62 2e68 7070 220a 2369 6e63 6c75  _job.hpp".#inclu
    │ │ │ -00079930: 6465 2022 6c69 6274 6f72 7265 6e74 2f61  de "libtorrent/a
    │ │ │ -00079940: 7578 5f2f 6465 6275 672e 6870 7022 0a23  ux_/debug.hpp".#
    │ │ │ -00079950: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00079960: 656e 742f 696f 5f63 6f6e 7465 7874 2e68  ent/io_context.h
    │ │ │ -00079970: 7070 220a 2369 6e63 6c75 6465 2022 6c69  pp".#include "li
    │ │ │ -00079980: 6274 6f72 7265 6e74 2f65 7272 6f72 5f63  btorrent/error_c
    │ │ │ -00079990: 6f64 652e 6870 7022 0a0a 2369 6e63 6c75  ode.hpp"..#inclu
    │ │ │ -000799a0: 6465 2026 6c74 3b74 6872 6561 6426 6774  de <thread>
    │ │ │ -000799b0: 3b0a 2369 6e63 6c75 6465 2026 6c74 3b6d  ;.#include <m
    │ │ │ -000799c0: 7574 6578 2667 743b 0a23 696e 636c 7564  utex>.#includ
    │ │ │ -000799d0: 6520 266c 743b 6174 6f6d 6963 2667 743b  e <atomic>
    │ │ │ -000799e0: 0a23 696e 636c 7564 6520 266c 743b 636f  .#include <co
    │ │ │ -000799f0: 6e64 6974 696f 6e5f 7661 7269 6162 6c65  ndition_variable
    │ │ │ -00079a00: 2667 743b 0a0a 6e61 6d65 7370 6163 6520  >..namespace 
    │ │ │ -00079a10: 6c69 6274 6f72 7265 6e74 207b 0a3c 6469  libtorrent {..usin
    │ │ │ -00079a50: 6720 6a6f 6271 7565 7565 5f74 203d 2061  g jobqueue_t = a
    │ │ │ -00079a60: 7578 3a3a 7461 696c 7175 6575 6526 6c74  ux::tailqueue<
    │ │ │ -00079a70: 3b61 7578 3a3a 6469 736b 5f6a 6f62 2667  ;aux::disk_job&g
    │ │ │ -00079a80: 743b 3b0a 3c2f 6469 763e 7d0a 0a6e 616d  t;;.}..nam
    │ │ │ -00079a90: 6573 7061 6365 206c 6962 746f 7272 656e  espace libtorren
    │ │ │ -00079aa0: 743a 3a61 7578 207b 0a0a 0973 7472 7563  t::aux {...struc
    │ │ │ -00079ab0: 7420 6469 736b 5f69 6f5f 7468 7265 6164  t disk_io_thread
    │ │ │ -00079ac0: 5f70 6f6f 6c3b 0a0a 0975 7369 6e67 2064  _pool;...using d
    │ │ │ -00079ad0: 6973 6b5f 7468 7265 6164 5f66 756e 203d  isk_thread_fun =
    │ │ │ -00079ae0: 2073 7464 3a3a 6675 6e63 7469 6f6e 266c   std::function&l
    │ │ │ -00079af0: 743b 766f 6964 280a 0909 6175 783a 3a64  t;void(...aux::d
    │ │ │ -00079b00: 6973 6b5f 696f 5f74 6872 6561 645f 706f  isk_io_thread_po
    │ │ │ -00079b10: 6f6c 2661 6d70 3b2c 2065 7865 6375 746f  ol&, executo
    │ │ │ -00079b20: 725f 776f 726b 5f67 7561 7264 266c 743b  r_work_guard<
    │ │ │ -00079b30: 696f 5f63 6f6e 7465 7874 3a3a 6578 6563  io_context::exec
    │ │ │ -00079b40: 7574 6f72 5f74 7970 6526 6774 3b20 776f  utor_type> wo
    │ │ │ -00079b50: 726b 2926 6774 3b3b 0a0a 0965 6e75 6d20  rk)>;...enum 
    │ │ │ -00079b60: 636c 6173 7320 7761 6974 5f72 6573 756c  class wait_resul
    │ │ │ -00079b70: 743a 2073 7464 3a3a 7569 6e74 385f 740a  t: std::uint8_t.
    │ │ │ -00079b80: 097b 0a09 096e 6577 5f6a 6f62 2c0a 0909  .{...new_job,...
    │ │ │ -00079b90: 6578 6974 5f74 6872 6561 642c 0a09 0969  exit_thread,...i
    │ │ │ -00079ba0: 6e74 6572 7275 7074 2c0a 097d 3b0a 0a09  nterrupt,..};...
    │ │ │ -00079bb0: 2f2f 2074 6869 7320 636c 6173 7320 696d  // this class im
    │ │ │ -00079bc0: 706c 656d 656e 7473 2074 6865 2070 6f6c  plements the pol
    │ │ │ -00079bd0: 6963 7920 666f 7220 6372 6561 7469 6e67  icy for creating
    │ │ │ -00079be0: 2061 6e64 2064 6573 7472 6f79 696e 6720   and destroying 
    │ │ │ -00079bf0: 492f 4f20 7468 7265 6164 730a 092f 2f20  I/O threads..// 
    │ │ │ -00079c00: 7468 7265 6164 7320 6172 6520 6372 6561  threads are crea
    │ │ │ -00079c10: 7465 6420 7768 656e 206a 6f62 5f71 7565  ted when job_que
    │ │ │ -00079c20: 7565 6420 6973 2063 616c 6c65 6420 746f  ued is called to
    │ │ │ -00079c30: 2073 6967 6e61 6c20 7468 6520 6172 7269   signal the arri
    │ │ │ -00079c40: 7661 6c20 6f66 0a09 2f2f 206e 6577 206a  val of..// new j
    │ │ │ -00079c50: 6f62 730a 092f 2f20 6f6e 6365 2061 206d  obs..// once a m
    │ │ │ -00079c60: 696e 7574 6520 7468 7265 6164 7320 6172  inute threads ar
    │ │ │ -00079c70: 6520 6465 7374 726f 7965 6420 6966 2061  e destroyed if a
    │ │ │ -00079c80: 7420 6c65 6173 7420 6f6e 6520 7468 7265  t least one thre
    │ │ │ -00079c90: 6164 2068 6173 2062 6565 6e0a 092f 2f20  ad has been..// 
    │ │ │ -00079ca0: 6964 6c65 2066 6f72 2074 6865 2065 6e74  idle for the ent
    │ │ │ -00079cb0: 6972 6520 6d69 6e75 7465 0a09 2f2f 2074  ire minute..// t
    │ │ │ -00079cc0: 6865 2070 6f6f 6c5f 7468 7265 6164 5f69  he pool_thread_i
    │ │ │ -00079cd0: 6e74 6572 6661 6365 2069 7320 7573 6564  nterface is used
    │ │ │ -00079ce0: 2074 6f20 7370 6177 6e20 616e 6420 6e6f   to spawn and no
    │ │ │ -00079cf0: 7469 6679 2074 6865 2077 6f72 6b65 7220  tify the worker 
    │ │ │ -00079d00: 7468 7265 6164 730a 0973 7472 7563 7420  threads..struct 
    │ │ │ -00079d10: 544f 5252 454e 545f 4558 5452 415f 4558  TORRENT_EXTRA_EX
    │ │ │ -00079d20: 504f 5254 2064 6973 6b5f 696f 5f74 6872  PORT disk_io_thr
    │ │ │ -00079d30: 6561 645f 706f 6f6c 0a09 7b0a 0909 6469  ead_pool..{...di
    │ │ │ -00079d40: 736b 5f69 6f5f 7468 7265 6164 5f70 6f6f  sk_io_thread_poo
    │ │ │ -00079d50: 6c28 6469 736b 5f74 6872 6561 645f 6675  l(disk_thread_fu
    │ │ │ -00079d60: 6e20 7468 7265 6164 5f66 756e 2c20 696f  n thread_fun, io
    │ │ │ -00079d70: 5f63 6f6e 7465 7874 2661 6d70 3b20 696f  _context& io
    │ │ │ -00079d80: 7329 3b0a 0909 7e64 6973 6b5f 696f 5f74  s);...~disk_io_t
    │ │ │ -00079d90: 6872 6561 645f 706f 6f6c 2829 3b0a 0a09  hread_pool();...
    │ │ │ -00079da0: 092f 2f20 7365 7420 7468 6520 6d61 7869  .// set the maxi
    │ │ │ -00079db0: 6d75 6d20 6e75 6d62 6572 206f 6620 492f  mum number of I/
    │ │ │ -00079dc0: 4f20 7468 7265 6164 7320 7768 6963 6820  O threads which 
    │ │ │ -00079dd0: 6d61 7920 6265 2072 756e 6e69 6e67 0a09  may be running..
    │ │ │ -00079de0: 092f 2f20 7468 6520 6163 7475 616c 206e  .// the actual n
    │ │ │ -00079df0: 756d 6265 7220 6f66 2074 6872 6561 6473  umber of threads
    │ │ │ -00079e00: 2077 696c 6c20 6265 2026 6c74 3b3d 2074   will be <= t
    │ │ │ -00079e10: 6869 7320 6e75 6d62 6572 0a09 0976 6f69  his number...voi
    │ │ │ -00079e20: 6420 7365 745f 6d61 785f 7468 7265 6164  d set_max_thread
    │ │ │ -00079e30: 7328 696e 7420 6929 3b0a 3c2f 7072 653e  s(int i);.
    │ │ │ -00079e40: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00079e70: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00079e80: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -00079eb0: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00079ec0: 6469 736b 5f69 6f5f 7468 7265 6164 5f70 disk_io_thread_p │ │ │ -00079ed0: 6f6f 6c2e 6870 703a 3130 363c 2f61 3e3c ool.hpp:106< │ │ │ -00079ee0: 2f74 643e 3c74 643e 7468 6520 6a6f 6220 /td>the job │ │ │ -00079ef0: 6d75 7465 7820 6d75 7374 2062 6520 6865 mutex must be he │ │ │ -00079f00: 6c64 2077 6865 6e20 7468 6973 2069 7320 ld when this is │ │ │ -00079f10: 6361 6c6c 6564 3c2f 7464 3e3c 2f74 723e called │ │ │ -00079f20: 3c74 7220 6964 3d22 3237 3822 2073 7479 │ │ │ -00079f50: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00079f60: 3c68 323e 7468 6520 6a6f 6220 6d75 7465

    the job mute │ │ │ -00079f70: 7820 6d75 7374 2062 6520 6865 6c64 2077 x must be held w │ │ │ -00079f80: 6865 6e20 7468 6973 2069 7320 6361 6c6c hen this is call │ │ │ -00079f90: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ed

    ../in │ │ │ -00079fa0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00079fb0: 2f61 7578 5f2f 6469 736b 5f69 6f5f 7468 /aux_/disk_io_th │ │ │ -00079fc0: 7265 6164 5f70 6f6f 6c2e 6870 703a 3130 read_pool.hpp:10 │ │ │ -00079fd0: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ -0007a010: 0909 2f2f 2074 6869 7320 6973 2061 2077  ..// this is a w
    │ │ │ -0007a020: 6561 6b20 6368 6563 6b2c 2069 6620 6974  eak check, if it
    │ │ │ -0007a030: 2072 6574 7572 6e73 2074 7275 6520 7472   returns true tr
    │ │ │ -0007a040: 795f 7468 7265 6164 5f65 7869 7420 6d61  y_thread_exit ma
    │ │ │ -0007a050: 7920 7374 696c 6c0a 0909 2f2f 2072 6574  y still...// ret
    │ │ │ -0007a060: 7572 6e20 6661 6c73 650a 0909 626f 6f6c  urn false...bool
    │ │ │ -0007a070: 2073 686f 756c 645f 6578 6974 2829 207b   should_exit() {
    │ │ │ -0007a080: 2072 6574 7572 6e20 6d5f 7468 7265 6164   return m_thread
    │ │ │ -0007a090: 735f 746f 5f65 7869 7420 2667 743b 2030  s_to_exit > 0
    │ │ │ -0007a0a0: 3b20 7d0a 0909 2f2f 2074 6869 7320 7368  ; }...// this sh
    │ │ │ -0007a0b0: 6f75 6c64 2062 6520 7468 6520 6c61 7374  ould be the last
    │ │ │ -0007a0c0: 2066 756e 6374 696f 6e20 616e 2049 2f4f   function an I/O
    │ │ │ -0007a0d0: 2074 6872 6561 6420 6361 6c6c 7320 6265   thread calls be
    │ │ │ -0007a0e0: 666f 7265 2062 7265 616b 696e 670a 0909  fore breaking...
    │ │ │ -0007a0f0: 2f2f 206f 7574 206f 6620 6974 7320 7365  // out of its se
    │ │ │ -0007a100: 7276 6963 6520 6c6f 6f70 0a09 092f 2f20  rvice loop...// 
    │ │ │ -0007a110: 6966 2069 7420 7265 7475 726e 7320 7472  if it returns tr
    │ │ │ -0007a120: 7565 2074 6865 6e20 7468 6520 7468 7265  ue then the thre
    │ │ │ -0007a130: 6164 204d 5553 5420 6578 6974 0a09 092f  ad MUST exit.../
    │ │ │ -0007a140: 2f20 6966 2069 7420 7265 7475 726e 7320  / if it returns 
    │ │ │ -0007a150: 6661 6c73 6520 7468 6520 7468 7265 6164  false the thread
    │ │ │ -0007a160: 2073 686f 756c 6420 6e6f 7420 6578 6974   should not exit
    │ │ │ -0007a170: 0a09 0962 6f6f 6c20 7472 795f 7468 7265  ...bool try_thre
    │ │ │ -0007a180: 6164 5f65 7869 7428 7374 643a 3a74 6872  ad_exit(std::thr
    │ │ │ -0007a190: 6561 643a 3a69 6420 6964 293b 0a0a 0909  ead::id id);....
    │ │ │ -0007a1a0: 2f2f 2067 6574 2074 6865 2074 6872 6561  // get the threa
    │ │ │ -0007a1b0: 6420 6964 206f 6620 7468 6520 6669 7273  d id of the firs
    │ │ │ -0007a1c0: 7420 7468 7265 6164 2069 6e20 7468 6520  t thread in the 
    │ │ │ -0007a1d0: 696e 7465 726e 616c 2076 6563 746f 720a  internal vector.
    │ │ │ -0007a1e0: 0909 2f2f 2073 696e 6365 2074 6869 7320  ..// since this 
    │ │ │ -0007a1f0: 6973 2074 6865 2066 6972 7374 2074 6872  is the first thr
    │ │ │ -0007a200: 6561 6420 6974 2077 696c 6c20 7265 6d61  ead it will rema
    │ │ │ -0007a210: 696e 2074 6865 2073 616d 6520 756e 7469  in the same unti
    │ │ │ -0007a220: 6c20 7468 6520 6669 7273 740a 0909 2f2f  l the first...//
    │ │ │ -0007a230: 2074 6872 6561 6420 6578 6974 730a 0909   thread exits...
    │ │ │ -0007a240: 2f2f 2069 7420 6361 6e20 6265 2075 7365  // it can be use
    │ │ │ -0007a250: 6420 746f 2074 7269 6767 6572 206d 6169  d to trigger mai
    │ │ │ -0007a260: 6e74 656e 616e 6365 206a 6f62 7320 7768  ntenance jobs wh
    │ │ │ -0007a270: 6963 6820 7368 6f75 6c64 206f 6e6c 7920  ich should only 
    │ │ │ -0007a280: 7275 6e20 6f6e 206f 6e65 2074 6872 6561  run on one threa
    │ │ │ -0007a290: 640a 0909 7374 643a 3a74 6872 6561 643a  d...std::thread:
    │ │ │ -0007a2a0: 3a69 6420 6669 7273 745f 7468 7265 6164  :id first_thread
    │ │ │ -0007a2b0: 5f69 6428 293b 0a09 0969 6e74 206e 756d  _id();...int num
    │ │ │ -0007a2c0: 5f74 6872 6561 6473 2829 0a09 097b 0a09  _threads()...{..
    │ │ │ -0007a2d0: 0909 7374 643a 3a6c 6f63 6b5f 6775 6172  ..std::lock_guar
    │ │ │ -0007a2e0: 6426 6c74 3b73 7464 3a3a 6d75 7465 7826  d<std::mutex&
    │ │ │ -0007a2f0: 6774 3b20 6c28 6d5f 6d75 7465 7829 3b0a  gt; l(m_mutex);.
    │ │ │ -0007a300: 0909 0972 6574 7572 6e20 696e 7428 6d5f  ...return int(m_
    │ │ │ -0007a310: 7468 7265 6164 732e 7369 7a65 2829 293b  threads.size());
    │ │ │ -0007a320: 0a09 097d 0a0a 3c64 6976 2073 7479 6c65  ...}..
    ..void appen │ │ │ -0007a360: 6428 6a6f 6271 7565 7565 5f74 206a 6f62 d(jobqueue_t job │ │ │ -0007a370: 7329 0a3c 2f64 6976 3e09 097b 0a09 0909 s).
    ..{.... │ │ │ -0007a380: 6d5f 7175 6575 6564 5f6a 6f62 732e 6170 m_queued_jobs.ap │ │ │ -0007a390: 7065 6e64 2873 7464 3a3a 6d6f 7665 286a pend(std::move(j │ │ │ -0007a3a0: 6f62 7329 293b 0a09 097d 0a0a 3c2f 7072 obs));...}..rel │ │ │ -0007a3e0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -0007a420: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007a430: 5f2f 6469 736b 5f69 6f5f 7468 7265 6164 _/disk_io_thread │ │ │ -0007a440: 5f70 6f6f 6c2e 6870 703a 3131 323c 2f61 _pool.hpp:112the jo │ │ │ -0007a460: 6220 6d75 7465 7820 6d75 7374 2062 6520 b mutex must be │ │ │ -0007a470: 6865 6c64 2077 6865 6e20 7468 6973 2069 held when this i │ │ │ -0007a480: 7320 6361 6c6c 6564 3c2f 7464 3e3c 2f74 s called

    the job mu │ │ │ -0007a4e0: 7465 7820 6d75 7374 2062 6520 6865 6c64 tex must be held │ │ │ -0007a4f0: 2077 6865 6e20 7468 6973 2069 7320 6361 when this is ca │ │ │ -0007a500: 6c6c 6564 3c2f 6832 3e3c 6834 3e2e 2e2f lled

    ../ │ │ │ -0007a510: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007a520: 6e74 2f61 7578 5f2f 6469 736b 5f69 6f5f nt/aux_/disk_io_ │ │ │ -0007a530: 7468 7265 6164 5f70 6f6f 6c2e 6870 703a thread_pool.hpp: │ │ │ -0007a540: 3131 323c 2f68 343e 3c70 7265 2073 7479 112

    ..// if it ret
    │ │ │ -0007a590: 7572 6e73 2074 7275 6520 7468 656e 2074  urns true then t
    │ │ │ -0007a5a0: 6865 2074 6872 6561 6420 4d55 5354 2065  he thread MUST e
    │ │ │ -0007a5b0: 7869 740a 0909 2f2f 2069 6620 6974 2072  xit...// if it r
    │ │ │ -0007a5c0: 6574 7572 6e73 2066 616c 7365 2074 6865  eturns false the
    │ │ │ -0007a5d0: 2074 6872 6561 6420 7368 6f75 6c64 206e   thread should n
    │ │ │ -0007a5e0: 6f74 2065 7869 740a 0909 626f 6f6c 2074  ot exit...bool t
    │ │ │ -0007a5f0: 7279 5f74 6872 6561 645f 6578 6974 2873  ry_thread_exit(s
    │ │ │ -0007a600: 7464 3a3a 7468 7265 6164 3a3a 6964 2069  td::thread::id i
    │ │ │ -0007a610: 6429 3b0a 0a09 092f 2f20 6765 7420 7468  d);....// get th
    │ │ │ -0007a620: 6520 7468 7265 6164 2069 6420 6f66 2074  e thread id of t
    │ │ │ -0007a630: 6865 2066 6972 7374 2074 6872 6561 6420  he first thread 
    │ │ │ -0007a640: 696e 2074 6865 2069 6e74 6572 6e61 6c20  in the internal 
    │ │ │ -0007a650: 7665 6374 6f72 0a09 092f 2f20 7369 6e63  vector...// sinc
    │ │ │ -0007a660: 6520 7468 6973 2069 7320 7468 6520 6669  e this is the fi
    │ │ │ -0007a670: 7273 7420 7468 7265 6164 2069 7420 7769  rst thread it wi
    │ │ │ -0007a680: 6c6c 2072 656d 6169 6e20 7468 6520 7361  ll remain the sa
    │ │ │ -0007a690: 6d65 2075 6e74 696c 2074 6865 2066 6972  me until the fir
    │ │ │ -0007a6a0: 7374 0a09 092f 2f20 7468 7265 6164 2065  st...// thread e
    │ │ │ -0007a6b0: 7869 7473 0a09 092f 2f20 6974 2063 616e  xits...// it can
    │ │ │ -0007a6c0: 2062 6520 7573 6564 2074 6f20 7472 6967   be used to trig
    │ │ │ -0007a6d0: 6765 7220 6d61 696e 7465 6e61 6e63 6520  ger maintenance 
    │ │ │ -0007a6e0: 6a6f 6273 2077 6869 6368 2073 686f 756c  jobs which shoul
    │ │ │ -0007a6f0: 6420 6f6e 6c79 2072 756e 206f 6e20 6f6e  d only run on on
    │ │ │ -0007a700: 6520 7468 7265 6164 0a09 0973 7464 3a3a  e thread...std::
    │ │ │ -0007a710: 7468 7265 6164 3a3a 6964 2066 6972 7374  thread::id first
    │ │ │ -0007a720: 5f74 6872 6561 645f 6964 2829 3b0a 0909  _thread_id();...
    │ │ │ -0007a730: 696e 7420 6e75 6d5f 7468 7265 6164 7328  int num_threads(
    │ │ │ -0007a740: 290a 0909 7b0a 0909 0973 7464 3a3a 6c6f  )...{....std::lo
    │ │ │ -0007a750: 636b 5f67 7561 7264 266c 743b 7374 643a  ck_guard<std:
    │ │ │ -0007a760: 3a6d 7574 6578 2667 743b 206c 286d 5f6d  :mutex> l(m_m
    │ │ │ -0007a770: 7574 6578 293b 0a09 0909 7265 7475 726e  utex);....return
    │ │ │ -0007a780: 2069 6e74 286d 5f74 6872 6561 6473 2e73   int(m_threads.s
    │ │ │ -0007a790: 697a 6528 2929 3b0a 0909 7d0a 0a09 0976  ize());...}....v
    │ │ │ -0007a7a0: 6f69 6420 6170 7065 6e64 286a 6f62 7175  oid append(jobqu
    │ │ │ -0007a7b0: 6575 655f 7420 6a6f 6273 290a 0909 7b0a  eue_t jobs)...{.
    │ │ │ -0007a7c0: 0909 096d 5f71 7565 7565 645f 6a6f 6273  ...m_queued_jobs
    │ │ │ -0007a7d0: 2e61 7070 656e 6428 7374 643a 3a6d 6f76  .append(std::mov
    │ │ │ -0007a7e0: 6528 6a6f 6273 2929 3b0a 0909 7d0a 0a3c  e(jobs));...}..<
    │ │ │ -0007a7f0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0007a800: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0007a810: 7769 6474 683d 2231 3030 2522 3e09 0976  width="100%">..v
    │ │ │ -0007a820: 6f69 6420 7075 7368 5f62 6163 6b28 6175  oid push_back(au
    │ │ │ -0007a830: 783a 3a64 6973 6b5f 6a6f 622a 206a 290a  x::disk_job* j).
    │ │ │ -0007a840: 3c2f 6469 763e 0909 7b0a 0909 096d 5f71  ..{....m_q
    │ │ │ -0007a850: 7565 7565 645f 6a6f 6273 2e70 7573 685f  ueued_jobs.push_
    │ │ │ -0007a860: 6261 636b 286a 293b 0a09 097d 0a0a 3c2f  back(j);...}..r
    │ │ │ -0007a8a0: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -0007a8b0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../incl
    │ │ │ -0007a8e0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61  ude/libtorrent/a
    │ │ │ -0007a8f0: 7578 5f2f 6469 736b 5f69 6f5f 7468 7265  ux_/disk_io_thre
    │ │ │ -0007a900: 6164 5f70 6f6f 6c2e 6870 703a 3131 383c  ad_pool.hpp:118<
    │ │ │ -0007a910: 2f61 3e3c 2f74 643e 3c74 643e 7468 6520  /a>the 
    │ │ │ -0007a920: 6a6f 6220 6d75 7465 7820 6d75 7374 2062  job mutex must b
    │ │ │ -0007a930: 6520 6865 6c64 2077 6865 6e20 7468 6973  e held when this
    │ │ │ -0007a940: 2069 7320 6361 6c6c 6564 3c2f 7464 3e3c   is called<
    │ │ │ -0007a950: 2f74 723e 3c74 7220 6964 3d22 3238 3022  /tr>

    the job │ │ │ -0007a9a0: 6d75 7465 7820 6d75 7374 2062 6520 6865 mutex must be he │ │ │ -0007a9b0: 6c64 2077 6865 6e20 7468 6973 2069 7320 ld when this is │ │ │ -0007a9c0: 6361 6c6c 6564 3c2f 6832 3e3c 6834 3e2e called

    . │ │ │ -0007a9d0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0007a9e0: 7265 6e74 2f61 7578 5f2f 6469 736b 5f69 rent/aux_/disk_i │ │ │ -0007a9f0: 6f5f 7468 7265 6164 5f70 6f6f 6c2e 6870 o_thread_pool.hp │ │ │ -0007aa00: 703a 3131 383c 2f68 343e 3c70 7265 2073 p:118

    ..// since t
    │ │ │ -0007aa50: 6869 7320 6973 2074 6865 2066 6972 7374  his is the first
    │ │ │ -0007aa60: 2074 6872 6561 6420 6974 2077 696c 6c20   thread it will 
    │ │ │ -0007aa70: 7265 6d61 696e 2074 6865 2073 616d 6520  remain the same 
    │ │ │ -0007aa80: 756e 7469 6c20 7468 6520 6669 7273 740a  until the first.
    │ │ │ -0007aa90: 0909 2f2f 2074 6872 6561 6420 6578 6974  ..// thread exit
    │ │ │ -0007aaa0: 730a 0909 2f2f 2069 7420 6361 6e20 6265  s...// it can be
    │ │ │ -0007aab0: 2075 7365 6420 746f 2074 7269 6767 6572   used to trigger
    │ │ │ -0007aac0: 206d 6169 6e74 656e 616e 6365 206a 6f62   maintenance job
    │ │ │ -0007aad0: 7320 7768 6963 6820 7368 6f75 6c64 206f  s which should o
    │ │ │ -0007aae0: 6e6c 7920 7275 6e20 6f6e 206f 6e65 2074  nly run on one t
    │ │ │ -0007aaf0: 6872 6561 640a 0909 7374 643a 3a74 6872  hread...std::thr
    │ │ │ -0007ab00: 6561 643a 3a69 6420 6669 7273 745f 7468  ead::id first_th
    │ │ │ -0007ab10: 7265 6164 5f69 6428 293b 0a09 0969 6e74  read_id();...int
    │ │ │ -0007ab20: 206e 756d 5f74 6872 6561 6473 2829 0a09   num_threads()..
    │ │ │ -0007ab30: 097b 0a09 0909 7374 643a 3a6c 6f63 6b5f  .{....std::lock_
    │ │ │ -0007ab40: 6775 6172 6426 6c74 3b73 7464 3a3a 6d75  guard<std::mu
    │ │ │ -0007ab50: 7465 7826 6774 3b20 6c28 6d5f 6d75 7465  tex> l(m_mute
    │ │ │ -0007ab60: 7829 3b0a 0909 0972 6574 7572 6e20 696e  x);....return in
    │ │ │ -0007ab70: 7428 6d5f 7468 7265 6164 732e 7369 7a65  t(m_threads.size
    │ │ │ -0007ab80: 2829 293b 0a09 097d 0a0a 0909 766f 6964  ());...}....void
    │ │ │ -0007ab90: 2061 7070 656e 6428 6a6f 6271 7565 7565   append(jobqueue
    │ │ │ -0007aba0: 5f74 206a 6f62 7329 0a09 097b 0a09 0909  _t jobs)...{....
    │ │ │ -0007abb0: 6d5f 7175 6575 6564 5f6a 6f62 732e 6170  m_queued_jobs.ap
    │ │ │ -0007abc0: 7065 6e64 2873 7464 3a3a 6d6f 7665 286a  pend(std::move(j
    │ │ │ -0007abd0: 6f62 7329 293b 0a09 097d 0a0a 0909 766f  obs));...}....vo
    │ │ │ -0007abe0: 6964 2070 7573 685f 6261 636b 2861 7578  id push_back(aux
    │ │ │ -0007abf0: 3a3a 6469 736b 5f6a 6f62 2a20 6a29 0a09  ::disk_job* j)..
    │ │ │ -0007ac00: 097b 0a09 0909 6d5f 7175 6575 6564 5f6a  .{....m_queued_j
    │ │ │ -0007ac10: 6f62 732e 7075 7368 5f62 6163 6b28 6a29  obs.push_back(j)
    │ │ │ -0007ac20: 3b0a 0909 7d0a 0a3c 6469 7620 7374 796c  ;...}..
    ..aux::disk │ │ │ -0007ac60: 5f6a 6f62 2a20 706f 705f 6672 6f6e 7428 _job* pop_front( │ │ │ -0007ac70: 290a 3c2f 6469 763e 0909 7b0a 0909 0972 ).
    ..{....r │ │ │ -0007ac80: 6574 7572 6e20 6d5f 7175 6575 6564 5f6a eturn m_queued_j │ │ │ -0007ac90: 6f62 732e 706f 705f 6672 6f6e 7428 293b obs.pop_front(); │ │ │ -0007aca0: 0a09 097d 0a0a 3c2f 7072 653e 3c2f 7464 ...}..
    relevance │ │ │ -0007ace0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -0007acf0: 3c61 2068 7265 663d 226a 6176 6173 6372
    ../include/libt │ │ │ -0007ad20: 6f72 7265 6e74 2f61 7578 5f2f 6469 736b orrent/aux_/disk │ │ │ -0007ad30: 5f69 6f5f 7468 7265 6164 5f70 6f6f 6c2e _io_thread_pool. │ │ │ -0007ad40: 6870 703a 3132 343c 2f61 3e3c 2f74 643e hpp:124 │ │ │ -0007ad50: 3c74 643e 7468 6520 6a6f 6220 6d75 7465 the job mute │ │ │ -0007ad60: 7820 6d75 7374 2062 6520 6865 6c64 2077 x must be held w │ │ │ -0007ad70: 6865 6e20 7468 6973 2069 7320 6361 6c6c hen this is call │ │ │ -0007ad80: 6564 3c2f 7464 3e3c 2f74 723e 3c74 7220 ed

    │ │ │ -0007add0: 7468 6520 6a6f 6220 6d75 7465 7820 6d75 the job mutex mu │ │ │ -0007ade0: 7374 2062 6520 6865 6c64 2077 6865 6e20 st be held when │ │ │ -0007adf0: 7468 6973 2069 7320 6361 6c6c 6564 3c2f this is called

    ../includ │ │ │ -0007ae10: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007ae20: 5f2f 6469 736b 5f69 6f5f 7468 7265 6164 _/disk_io_thread │ │ │ -0007ae30: 5f70 6f6f 6c2e 6870 703a 3132 343c 2f68 _pool.hpp:124
    ..{.
    │ │ │ -0007ae80: 0909 0973 7464 3a3a 6c6f 636b 5f67 7561  ...std::lock_gua
    │ │ │ -0007ae90: 7264 266c 743b 7374 643a 3a6d 7574 6578  rd<std::mutex
    │ │ │ -0007aea0: 2667 743b 206c 286d 5f6d 7574 6578 293b  > l(m_mutex);
    │ │ │ -0007aeb0: 0a09 0909 7265 7475 726e 2069 6e74 286d  ....return int(m
    │ │ │ -0007aec0: 5f74 6872 6561 6473 2e73 697a 6528 2929  _threads.size())
    │ │ │ -0007aed0: 3b0a 0909 7d0a 0a09 0976 6f69 6420 6170  ;...}....void ap
    │ │ │ -0007aee0: 7065 6e64 286a 6f62 7175 6575 655f 7420  pend(jobqueue_t 
    │ │ │ -0007aef0: 6a6f 6273 290a 0909 7b0a 0909 096d 5f71  jobs)...{....m_q
    │ │ │ -0007af00: 7565 7565 645f 6a6f 6273 2e61 7070 656e  ueued_jobs.appen
    │ │ │ -0007af10: 6428 7374 643a 3a6d 6f76 6528 6a6f 6273  d(std::move(jobs
    │ │ │ -0007af20: 2929 3b0a 0909 7d0a 0a09 0976 6f69 6420  ));...}....void 
    │ │ │ -0007af30: 7075 7368 5f62 6163 6b28 6175 783a 3a64  push_back(aux::d
    │ │ │ -0007af40: 6973 6b5f 6a6f 622a 206a 290a 0909 7b0a  isk_job* j)...{.
    │ │ │ -0007af50: 0909 096d 5f71 7565 7565 645f 6a6f 6273  ...m_queued_jobs
    │ │ │ -0007af60: 2e70 7573 685f 6261 636b 286a 293b 0a09  .push_back(j);..
    │ │ │ -0007af70: 097d 0a0a 0909 6175 783a 3a64 6973 6b5f  .}....aux::disk_
    │ │ │ -0007af80: 6a6f 622a 2070 6f70 5f66 726f 6e74 2829  job* pop_front()
    │ │ │ -0007af90: 0a09 097b 0a09 0909 7265 7475 726e 206d  ...{....return m
    │ │ │ -0007afa0: 5f71 7565 7565 645f 6a6f 6273 2e70 6f70  _queued_jobs.pop
    │ │ │ -0007afb0: 5f66 726f 6e74 2829 3b0a 0909 7d0a 0a3c  _front();...}..<
    │ │ │ -0007afc0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0007afd0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0007afe0: 7769 6474 683d 2231 3030 2522 3e09 0962  width="100%">..b
    │ │ │ -0007aff0: 6f6f 6c20 656d 7074 7928 2920 636f 6e73  ool empty() cons
    │ │ │ -0007b000: 740a 3c2f 6469 763e 0909 7b0a 0909 0972  t...{....r
    │ │ │ -0007b010: 6574 7572 6e20 6d5f 7175 6575 6564 5f6a  eturn m_queued_j
    │ │ │ -0007b020: 6f62 732e 656d 7074 7928 293b 0a09 097d  obs.empty();...}
    │ │ │ -0007b030: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  ..
    < │ │ │ -0007b060: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0007b070: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0007b0a0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007b0b0: 6e74 2f61 7578 5f2f 6469 736b 5f69 6f5f nt/aux_/disk_io_ │ │ │ -0007b0c0: 7468 7265 6164 5f70 6f6f 6c2e 6870 703a thread_pool.hpp: │ │ │ -0007b0d0: 3133 303c 2f61 3e3c 2f74 643e 3c74 643e 130 │ │ │ -0007b0e0: 7468 6520 6a6f 6220 6d75 7465 7820 6d75 the job mutex mu │ │ │ -0007b0f0: 7374 2062 6520 6865 6c64 2077 6865 6e20 st be held when │ │ │ -0007b100: 7468 6973 2069 7320 6361 6c6c 6564 3c2f this is called

    the │ │ │ -0007b160: 6a6f 6220 6d75 7465 7820 6d75 7374 2062 job mutex must b │ │ │ -0007b170: 6520 6865 6c64 2077 6865 6e20 7468 6973 e held when this │ │ │ -0007b180: 2069 7320 6361 6c6c 6564 3c2f 6832 3e3c is called

    < │ │ │ -0007b190: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -0007b1a0: 6274 6f72 7265 6e74 2f61 7578 5f2f 6469 btorrent/aux_/di │ │ │ -0007b1b0: 736b 5f69 6f5f 7468 7265 6164 5f70 6f6f sk_io_thread_poo │ │ │ -0007b1c0: 6c2e 6870 703a 3133 303c 2f68 343e 3c70 l.hpp:130

    ..void a │ │ │ -0007b210: 7070 656e 6428 6a6f 6271 7565 7565 5f74 ppend(jobqueue_t │ │ │ -0007b220: 206a 6f62 7329 0a09 097b 0a09 0909 6d5f jobs)...{....m_ │ │ │ -0007b230: 7175 6575 6564 5f6a 6f62 732e 6170 7065 queued_jobs.appe │ │ │ -0007b240: 6e64 2873 7464 3a3a 6d6f 7665 286a 6f62 nd(std::move(job │ │ │ -0007b250: 7329 293b 0a09 097d 0a0a 0909 766f 6964 s));...}....void │ │ │ -0007b260: 2070 7573 685f 6261 636b 2861 7578 3a3a push_back(aux:: │ │ │ -0007b270: 6469 736b 5f6a 6f62 2a20 6a29 0a09 097b disk_job* j)...{ │ │ │ -0007b280: 0a09 0909 6d5f 7175 6575 6564 5f6a 6f62 ....m_queued_job │ │ │ -0007b290: 732e 7075 7368 5f62 6163 6b28 6a29 3b0a s.push_back(j);. │ │ │ -0007b2a0: 0909 7d0a 0a09 0961 7578 3a3a 6469 736b ..}....aux::disk │ │ │ -0007b2b0: 5f6a 6f62 2a20 706f 705f 6672 6f6e 7428 _job* pop_front( │ │ │ -0007b2c0: 290a 0909 7b0a 0909 0972 6574 7572 6e20 )...{....return │ │ │ -0007b2d0: 6d5f 7175 6575 6564 5f6a 6f62 732e 706f m_queued_jobs.po │ │ │ -0007b2e0: 705f 6672 6f6e 7428 293b 0a09 097d 0a0a p_front();...}.. │ │ │ -0007b2f0: 0909 626f 6f6c 2065 6d70 7479 2829 2063 ..bool empty() c │ │ │ -0007b300: 6f6e 7374 0a09 097b 0a09 0909 7265 7475 onst...{....retu │ │ │ -0007b310: 726e 206d 5f71 7565 7565 645f 6a6f 6273 rn m_queued_jobs │ │ │ -0007b320: 2e65 6d70 7479 2829 3b0a 0909 7d0a 0a3c .empty();...}..< │ │ │ -0007b330: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -0007b340: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -0007b350: 7769 6474 683d 2231 3030 2522 3e09 0969 width="100%">..i │ │ │ -0007b360: 6e74 2071 7565 7565 5f73 697a 6528 2920 nt queue_size() │ │ │ -0007b370: 636f 6e73 740a 3c2f 6469 763e 0909 7b0a const...{. │ │ │ -0007b380: 0909 0972 6574 7572 6e20 6d5f 7175 6575 ...return m_queu │ │ │ -0007b390: 6564 5f6a 6f62 732e 7369 7a65 2829 3b0a ed_jobs.size();. │ │ │ -0007b3a0: 0909 7d0a 0a3c 2f70 7265 3e3c 2f74 643e ..}..

    │ │ │ -0007b3b0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0007b3e0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0007b3f0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0007b400: 7074 3a65 7870 616e 6428 3238 3329 223e pt:expand(283)"> │ │ │ -0007b410: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0007b420: 7272 656e 742f 6175 785f 2f64 6973 6b5f rrent/aux_/disk_ │ │ │ -0007b430: 696f 5f74 6872 6561 645f 706f 6f6c 2e68 io_thread_pool.h │ │ │ -0007b440: 7070 3a31 3336 3c2f 613e 3c2f 7464 3e3c pp:136< │ │ │ -0007b450: 7464 3e74 6865 206a 6f62 206d 7574 6578 td>the job mutex │ │ │ -0007b460: 206d 7573 7420 6265 2068 656c 6420 7768 must be held wh │ │ │ -0007b470: 656e 2074 6869 7320 6973 2063 616c 6c65 en this is calle │ │ │ -0007b480: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    t │ │ │ -0007b4d0: 6865 206a 6f62 206d 7574 6578 206d 7573 he job mutex mus │ │ │ -0007b4e0: 7420 6265 2068 656c 6420 7768 656e 2074 t be held when t │ │ │ -0007b4f0: 6869 7320 6973 2063 616c 6c65 643c 2f68 his is called

    ../include │ │ │ -0007b510: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007b520: 2f64 6973 6b5f 696f 5f74 6872 6561 645f /disk_io_thread_ │ │ │ -0007b530: 706f 6f6c 2e68 7070 3a31 3336 3c2f 6834 pool.hpp:136

    ..voi
    │ │ │ -0007b580: 6420 7075 7368 5f62 6163 6b28 6175 783a  d push_back(aux:
    │ │ │ -0007b590: 3a64 6973 6b5f 6a6f 622a 206a 290a 0909  :disk_job* j)...
    │ │ │ -0007b5a0: 7b0a 0909 096d 5f71 7565 7565 645f 6a6f  {....m_queued_jo
    │ │ │ -0007b5b0: 6273 2e70 7573 685f 6261 636b 286a 293b  bs.push_back(j);
    │ │ │ -0007b5c0: 0a09 097d 0a0a 0909 6175 783a 3a64 6973  ...}....aux::dis
    │ │ │ -0007b5d0: 6b5f 6a6f 622a 2070 6f70 5f66 726f 6e74  k_job* pop_front
    │ │ │ -0007b5e0: 2829 0a09 097b 0a09 0909 7265 7475 726e  ()...{....return
    │ │ │ -0007b5f0: 206d 5f71 7565 7565 645f 6a6f 6273 2e70   m_queued_jobs.p
    │ │ │ -0007b600: 6f70 5f66 726f 6e74 2829 3b0a 0909 7d0a  op_front();...}.
    │ │ │ -0007b610: 0a09 0962 6f6f 6c20 656d 7074 7928 2920  ...bool empty() 
    │ │ │ -0007b620: 636f 6e73 740a 0909 7b0a 0909 0972 6574  const...{....ret
    │ │ │ -0007b630: 7572 6e20 6d5f 7175 6575 6564 5f6a 6f62  urn m_queued_job
    │ │ │ -0007b640: 732e 656d 7074 7928 293b 0a09 097d 0a0a  s.empty();...}..
    │ │ │ -0007b650: 0909 696e 7420 7175 6575 655f 7369 7a65  ..int queue_size
    │ │ │ -0007b660: 2829 2063 6f6e 7374 0a09 097b 0a09 0909  () const...{....
    │ │ │ -0007b670: 7265 7475 726e 206d 5f71 7565 7565 645f  return m_queued_
    │ │ │ -0007b680: 6a6f 6273 2e73 697a 6528 293b 0a09 097d  jobs.size();...}
    │ │ │ -0007b690: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0007b6c0: 0909 766f 6964 2073 7562 6d69 745f 6a6f ..void submit_jo │ │ │ -0007b6d0: 6273 2829 0a3c 2f64 6976 3e09 097b 0a09 bs().
    ..{.. │ │ │ -0007b6e0: 0909 6966 2028 6d5f 7175 6575 6564 5f6a ..if (m_queued_j │ │ │ -0007b6f0: 6f62 732e 656d 7074 7928 2929 2072 6574 obs.empty()) ret │ │ │ -0007b700: 7572 6e3b 0a09 0909 6e6f 7469 6679 5f61 urn;....notify_a │ │ │ -0007b710: 6c6c 2829 3b0a 0909 096a 6f62 5f71 7565 ll();....job_que │ │ │ -0007b720: 7565 6428 6d5f 7175 6575 6564 5f6a 6f62 ued(m_queued_job │ │ │ -0007b730: 732e 7369 7a65 2829 293b 0a09 097d 0a0a s.size());...}.. │ │ │ -0007b740: 0909 766f 6964 2069 6e74 6572 7275 7074 ..void interrupt │ │ │ -0007b750: 2829 0a09 097b 0a09 0909 6d5f 696e 7465 ()...{....m_inte │ │ │ -0007b760: 7272 7570 7420 3d20 7472 7565 3b0a 0909 rrupt = true;... │ │ │ -0007b770: 096d 5f6a 6f62 5f63 6f6e 642e 6e6f 7469 .m_job_cond.noti │ │ │ -0007b780: 6679 5f6f 6e65 2829 3b0a 0909 7d0a 0a09 fy_one();...}... │ │ │ -0007b790: 0974 656d 706c 6174 6526 6c74 3b74 7970 .template<typ │ │ │ -0007b7a0: 656e 616d 6520 4675 6e26 6774 3b0a 0909 ename Fun>... │ │ │ -0007b7b0: 766f 6964 2076 6973 6974 5f6a 6f62 7328 void visit_jobs( │ │ │ -0007b7c0: 4675 6e20 6629 0a09 097b 0a09 0909 666f Fun f)...{....fo │ │ │ -0007b7d0: 7220 2861 7574 6f20 6920 3d20 6d5f 7175 r (auto i = m_qu │ │ │ -0007b7e0: 6575 6564 5f6a 6f62 732e 6974 6572 6174 eued_jobs.iterat │ │ │ -0007b7f0: 6528 293b 2069 2e67 6574 2829 3b20 692e e(); i.get(); i. │ │ │ -0007b800: 6e65 7874 2829 290a 0909 0909 6628 692e next()).....f(i. │ │ │ -0007b810: 6765 7428 2929 3b0a 0909 7d0a 0a09 7072 get());...}...pr │ │ │ -0007b820: 6976 6174 653a 0a0a 0909 2f2f 2074 6869 ivate:....// thi │ │ │ -0007b830: 7320 7368 6f75 6c64 2062 6520 6361 6c6c s should be call │ │ │ -0007b840: 6564 2077 6865 6e65 7665 7220 6e65 7720 ed whenever new │ │ │ -0007b850: 6a6f 6273 2061 7265 2071 7565 7565 640a jobs are queued. │ │ │ -0007b860: 0909 2f2f 2071 7565 7565 5f73 697a 6520 ..// queue_size │ │ │ -0007b870: 6973 2074 6865 2063 7572 7265 6e74 2073 is the current s │ │ │ -0007b880: 697a 6520 6f66 2074 6865 206a 6f62 2071 ize of the job q │ │ │ -0007b890: 7565 7565 0a09 092f 2f20 6e6f 7420 7468 ueue...// not th │ │ │ -0007b8a0: 7265 6164 2073 6166 650a 0909 766f 6964 read safe...void │ │ │ -0007b8b0: 206a 6f62 5f71 7565 7565 6428 696e 7420 job_queued(int │ │ │ -0007b8c0: 7175 6575 655f 7369 7a65 293b 0a0a 0909 queue_size);.... │ │ │ -0007b8d0: 766f 6964 2072 6561 705f 6964 6c65 5f74 void reap_idle_t │ │ │ -0007b8e0: 6872 6561 6473 2865 7272 6f72 5f63 6f64 hreads(error_cod │ │ │ -0007b8f0: 6520 636f 6e73 7426 616d 703b 2065 6329 e const& ec) │ │ │ -0007b900: 3b0a 0a09 092f 2f20 7468 6520 6361 6c6c ;....// the call │ │ │ -0007b910: 6572 206d 7573 7420 686f 6c64 206d 5f6d er must hold m_m │ │ │ -0007b920: 7574 6578 0a09 0976 6f69 6420 7374 6f70 utex...void stop │ │ │ -0007b930: 5f74 6872 6561 6473 2869 6e74 206e 756d _threads(int num │ │ │ -0007b940: 5f74 6f5f 7374 6f70 293b 0a3c 2f70 7265 _to_stop);.
    rele │ │ │ -0007b980: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -0007b9c0: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007b9d0: 2f70 726f 7879 5f62 6173 652e 6870 703a /proxy_base.hpp: │ │ │ -0007b9e0: 3230 343c 2f61 3e3c 2f74 643e 3c74 643e 204 │ │ │ -0007b9f0: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ -0007ba00: 2074 6f20 7265 6d65 6d62 6572 2074 6865 to remember the │ │ │ -0007ba10: 2062 696e 6420 706f 7274 2061 6e64 2062 bind port and b │ │ │ -0007ba20: 696e 6420 6f6e 6365 2077 6520 6b6e 6f77 ind once we know │ │ │ -0007ba30: 2077 6865 7265 2074 6865 2070 726f 7879 where the proxy │ │ │ -0007ba40: 2069 7320 6d5f 736f 636b 2e62 696e 6428 is m_sock.bind( │ │ │ -0007ba50: 656e 6470 6f69 6e74 2c20 6563 293b 3c2f endpoint, ec);

    it w │ │ │ -0007bab0: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ -0007bac0: 7265 6d65 6d62 6572 2074 6865 2062 696e remember the bin │ │ │ -0007bad0: 6420 706f 7274 2061 6e64 2062 696e 6420 d port and bind │ │ │ -0007bae0: 6f6e 6365 2077 6520 6b6e 6f77 2077 6865 once we know whe │ │ │ -0007baf0: 7265 2074 6865 2070 726f 7879 2069 730a re the proxy is. │ │ │ -0007bb00: 6d5f 736f 636b 2e62 696e 6428 656e 6470 m_sock.bind(endp │ │ │ -0007bb10: 6f69 6e74 2c20 6563 293b 3c2f 6832 3e3c oint, ec);

    < │ │ │ -0007bb20: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -0007bb30: 6274 6f72 7265 6e74 2f61 7578 5f2f 7072 btorrent/aux_/pr │ │ │ -0007bb40: 6f78 795f 6261 7365 2e68 7070 3a32 3034 oxy_base.hpp:204 │ │ │ -0007bb50: 3c2f 6834 3e3c 7072 6520 7374 796c 653d
    .
    │ │ │ -0007bb90: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -0007bba0: 6d5f 6d61 6769 6320 3d3d 2030 7831 3333  m_magic == 0x133
    │ │ │ -0007bbb0: 3729 3b0a 0909 6d5f 736f 636b 2e63 616e  7);...m_sock.can
    │ │ │ -0007bbc0: 6365 6c28 293b 0a09 7d0a 0a09 766f 6964  cel();..}...void
    │ │ │ -0007bbd0: 2063 616e 6365 6c28 6572 726f 725f 636f   cancel(error_co
    │ │ │ -0007bbe0: 6465 2661 6d70 3b20 6563 290a 097b 0a09  de& ec)..{..
    │ │ │ -0007bbf0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -0007bc00: 6d5f 6d61 6769 6320 3d3d 2030 7831 3333  m_magic == 0x133
    │ │ │ -0007bc10: 3729 3b0a 0909 6d5f 736f 636b 2e63 616e  7);...m_sock.can
    │ │ │ -0007bc20: 6365 6c28 6563 293b 0a09 7d0a 0a09 766f  cel(ec);..}...vo
    │ │ │ -0007bc30: 6964 2062 696e 6428 656e 6470 6f69 6e74  id bind(endpoint
    │ │ │ -0007bc40: 5f74 7970 6520 636f 6e73 7426 616d 703b  _type const&
    │ │ │ -0007bc50: 202f 2a20 656e 6470 6f69 6e74 202a 2f2c   /* endpoint */,
    │ │ │ -0007bc60: 2065 7272 6f72 5f63 6f64 6526 616d 703b   error_code&
    │ │ │ -0007bc70: 202f 2a20 6563 202a 2f29 0a09 7b0a 0909   /* ec */)..{...
    │ │ │ -0007bc80: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ -0007bc90: 5f6d 6167 6963 203d 3d20 3078 3133 3337  _magic == 0x1337
    │ │ │ -0007bca0: 293b 0a09 092f 2f20 7468 6520 7265 6173  );...// the reas
    │ │ │ -0007bcb0: 6f6e 2077 6879 2077 6520 6967 6e6f 7265  on why we ignore
    │ │ │ -0007bcc0: 2062 696e 6473 2068 6572 6520 6973 2062   binds here is b
    │ │ │ -0007bcd0: 6563 6175 7365 2077 6520 646f 6e27 740a  ecause we don't.
    │ │ │ -0007bce0: 0909 2f2f 2028 6e65 6365 7373 6172 696c  ..// (necessaril
    │ │ │ -0007bcf0: 7929 2079 6574 206b 6e6f 7720 7768 6174  y) yet know what
    │ │ │ -0007bd00: 2061 6464 7265 7373 2066 616d 696c 7920   address family 
    │ │ │ -0007bd10: 7468 6520 7072 6f78 790a 0909 2f2f 2077  the proxy...// w
    │ │ │ -0007bd20: 696c 6c20 7265 736f 6c76 6520 746f 2c20  ill resolve to, 
    │ │ │ -0007bd30: 616e 6420 6269 6e64 696e 6720 746f 2074  and binding to t
    │ │ │ -0007bd40: 6865 2077 726f 6e67 206f 6e65 2077 6f75  he wrong one wou
    │ │ │ -0007bd50: 6c64 0a09 092f 2f20 6272 6561 6b20 6f75  ld...// break ou
    │ │ │ -0007bd60: 7220 636f 6e6e 6563 7469 6f6e 2061 7474  r connection att
    │ │ │ -0007bd70: 656d 7074 206c 6174 6572 2e20 5468 6520  empt later. The 
    │ │ │ -0007bd80: 6361 6c6c 6572 2068 6572 650a 0909 2f2f  caller here...//
    │ │ │ -0007bd90: 2064 6f65 736e 2774 206e 6563 6573 7361   doesn't necessa
    │ │ │ -0007bda0: 7269 6c79 206b 6e6f 7720 7468 6174 2077  rily know that w
    │ │ │ -0007bdb0: 6527 7265 2070 726f 7879 696e 672c 2073  e're proxying, s
    │ │ │ -0007bdc0: 6f20 7468 6973 0a09 092f 2f20 6269 6e64  o this...// bind
    │ │ │ -0007bdd0: 2061 6464 7265 7373 2069 7320 6261 7365   address is base
    │ │ │ -0007bde0: 6420 6f6e 2074 6865 2066 696e 616c 2065  d on the final e
    │ │ │ -0007bdf0: 6e64 706f 696e 742c 206e 6f74 2074 6865  ndpoint, not the
    │ │ │ -0007be00: 0a09 092f 2f20 7072 6f78 792e 0a3c 6469  ...// proxy...}..#ifndef BOO
    │ │ │ -0007be50: 5354 5f4e 4f5f 4558 4345 5054 494f 4e53  ST_NO_EXCEPTIONS
    │ │ │ -0007be60: 0a09 766f 6964 206f 7065 6e28 7072 6f74  ..void open(prot
    │ │ │ -0007be70: 6f63 6f6c 5f74 7970 6520 636f 6e73 7426  ocol_type const&
    │ │ │ -0007be80: 616d 703b 290a 097b 0a09 0954 4f52 5245  amp;)..{...TORRE
    │ │ │ -0007be90: 4e54 5f41 5353 4552 5428 6d5f 6d61 6769  NT_ASSERT(m_magi
    │ │ │ -0007bea0: 6320 3d3d 2030 7831 3333 3729 3b0a 2f2f  c == 0x1337);.//
    │ │ │ -0007beb0: 0909 6d5f 736f 636b 2e6f 7065 6e28 7029  ..m_sock.open(p)
    │ │ │ -0007bec0: 3b0a 097d 0a23 656e 6469 660a 0a09 766f  ;..}.#endif...vo
    │ │ │ -0007bed0: 6964 206f 7065 6e28 7072 6f74 6f63 6f6c  id open(protocol
    │ │ │ -0007bee0: 5f74 7970 6520 636f 6e73 7426 616d 703b  _type const&
    │ │ │ -0007bef0: 2c20 6572 726f 725f 636f 6465 2661 6d70  , error_code&
    │ │ │ -0007bf00: 3b29 0a09 7b0a 0909 544f 5252 454e 545f  ;)..{...TORRENT_
    │ │ │ -0007bf10: 4153 5345 5254 286d 5f6d 6167 6963 203d  ASSERT(m_magic =
    │ │ │ -0007bf20: 3d20 3078 3133 3337 293b 0a09 092f 2f20  = 0x1337);...// 
    │ │ │ -0007bf30: 7765 206e 6565 6420 746f 2069 676e 6f72  we need to ignor
    │ │ │ -0007bf40: 6520 7468 6973 2066 6f72 2074 6865 2073  e this for the s
    │ │ │ -0007bf50: 616d 6520 7265 6173 6f6e 2061 7320 7374  ame reason as st
    │ │ │ -0007bf60: 6174 6564 0a09 092f 2f20 666f 7220 6967  ated...// for ig
    │ │ │ -0007bf70: 6e6f 7269 6e67 2062 696e 6428 290a 2f2f  noring bind().//
    │ │ │ -0007bf80: 0909 6d5f 736f 636b 2e6f 7065 6e28 702c  ..m_sock.open(p,
    │ │ │ -0007bf90: 2065 6329 3b0a 097d 0a0a 2369 666e 6465   ec);..}..#ifnde
    │ │ │ -0007bfa0: 6620 424f 4f53 545f 4e4f 5f45 5843 4550  f BOOST_NO_EXCEP
    │ │ │ -0007bfb0: 5449 4f4e 530a 0976 6f69 6420 636c 6f73  TIONS..void clos
    │ │ │ -0007bfc0: 6528 290a 097b 0a09 0954 4f52 5245 4e54  e()..{...TORRENT
    │ │ │ -0007bfd0: 5f41 5353 4552 5428 6d5f 6d61 6769 6320  _ASSERT(m_magic 
    │ │ │ -0007bfe0: 3d3d 2030 7831 3333 3729 3b0a 0909 6d5f  == 0x1337);...m_
    │ │ │ -0007bff0: 7265 6d6f 7465 5f65 6e64 706f 696e 7420  remote_endpoint 
    │ │ │ -0007c000: 3d20 656e 6470 6f69 6e74 5f74 7970 6528  = endpoint_type(
    │ │ │ -0007c010: 293b 0a09 096d 5f73 6f63 6b2e 636c 6f73  );...m_sock.clos
    │ │ │ -0007c020: 6528 293b 0a09 096d 5f72 6573 6f6c 7665  e();...m_resolve
    │ │ │ -0007c030: 722e 6361 6e63 656c 2829 3b0a 097d 0a23  r.cancel();..}.#
    │ │ │ -0007c040: 656e 6469 660a 0a09 766f 6964 2063 6c6f  endif...void clo
    │ │ │ -0007c050: 7365 2865 7272 6f72 5f63 6f64 6526 616d  se(error_code&am
    │ │ │ -0007c060: 703b 2065 6329 0a09 7b0a 0909 544f 5252  p; ec)..{...TORR
    │ │ │ -0007c070: 454e 545f 4153 5345 5254 286d 5f6d 6167  ENT_ASSERT(m_mag
    │ │ │ -0007c080: 6963 203d 3d20 3078 3133 3337 293b 0a3c  ic == 0x1337);.<
    │ │ │ -0007c090: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -0007c0a0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -0007c0b0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -0007c0c0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -0007c0d0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../inc
    │ │ │ -0007c100: 6c75 6465 2f6c 6962 746f 7272 656e 742f  lude/libtorrent/
    │ │ │ -0007c110: 6175 785f 2f73 6573 7369 6f6e 5f69 6e74  aux_/session_int
    │ │ │ -0007c120: 6572 6661 6365 2e68 7070 3a31 3839 3c2f  erface.hpp:189it wo
    │ │ │ -0007c140: 756c 6420 6265 206e 6963 6520 746f 206e  uld be nice to n
    │ │ │ -0007c150: 6f74 2068 6176 6520 7468 6973 2062 6520  ot have this be 
    │ │ │ -0007c160: 7061 7274 206f 6620 7365 7373 696f 6e5f  part of session_
    │ │ │ -0007c170: 696e 7465 7266 6163 653c 2f74 643e 3c2f  interface

    it would │ │ │ -0007c1d0: 6265 206e 6963 6520 746f 206e 6f74 2068 be nice to not h │ │ │ -0007c1e0: 6176 6520 7468 6973 2062 6520 7061 7274 ave this be part │ │ │ -0007c1f0: 206f 6620 7365 7373 696f 6e5f 696e 7465 of session_inte │ │ │ -0007c200: 7266 6163 653c 2f68 323e 3c68 343e 2e2e rface

    .. │ │ │ -0007c210: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0007c220: 656e 742f 6175 785f 2f73 6573 7369 6f6e ent/aux_/session │ │ │ -0007c230: 5f69 6e74 6572 6661 6365 2e68 7070 3a31 _interface.hpp:1 │ │ │ -0007c240: 3839 3c2f 6834 3e3c 7072 6520 7374 796c 89

    ...virtual std:
    │ │ │ -0007c290: 3a75 696e 7431 365f 7420 6c69 7374 656e  :uint16_t listen
    │ │ │ -0007c2a0: 5f70 6f72 7428 2920 636f 6e73 7420 3d20  _port() const = 
    │ │ │ -0007c2b0: 303b 0a09 0976 6972 7475 616c 2073 7464  0;...virtual std
    │ │ │ -0007c2c0: 3a3a 7569 6e74 3136 5f74 2073 736c 5f6c  ::uint16_t ssl_l
    │ │ │ -0007c2d0: 6973 7465 6e5f 706f 7274 2829 2063 6f6e  isten_port() con
    │ │ │ -0007c2e0: 7374 203d 2030 3b0a 0a09 0976 6972 7475  st = 0;....virtu
    │ │ │ -0007c2f0: 616c 2069 6e74 206c 6973 7465 6e5f 706f  al int listen_po
    │ │ │ -0007c300: 7274 2861 7578 3a3a 7472 616e 7370 6f72  rt(aux::transpor
    │ │ │ -0007c310: 7420 7373 6c2c 2061 6464 7265 7373 2063  t ssl, address c
    │ │ │ -0007c320: 6f6e 7374 2661 6d70 3b20 6c6f 6361 6c5f  onst& local_
    │ │ │ -0007c330: 6164 6472 2920 636f 6e73 7420 3d20 303b  addr) const = 0;
    │ │ │ -0007c340: 0a0a 0909 7669 7274 7561 6c20 7374 643a  ....virtual std:
    │ │ │ -0007c350: 3a75 696e 7433 325f 7420 6c69 7374 656e  :uint32_t listen
    │ │ │ -0007c360: 5f73 6f63 6b65 745f 7665 7273 696f 6e28  _socket_version(
    │ │ │ -0007c370: 2920 636f 6e73 7420 3d20 303b 0a09 0976  ) const = 0;...v
    │ │ │ -0007c380: 6972 7475 616c 2076 6f69 6420 666f 725f  irtual void for_
    │ │ │ -0007c390: 6561 6368 5f6c 6973 7465 6e5f 736f 636b  each_listen_sock
    │ │ │ -0007c3a0: 6574 2873 7464 3a3a 6675 6e63 7469 6f6e  et(std::function
    │ │ │ -0007c3b0: 266c 743b 766f 6964 2861 7578 3a3a 6c69  <void(aux::li
    │ │ │ -0007c3c0: 7374 656e 5f73 6f63 6b65 745f 6861 6e64  sten_socket_hand
    │ │ │ -0007c3d0: 6c65 2063 6f6e 7374 2661 6d70 3b29 2667  le const&)&g
    │ │ │ -0007c3e0: 743b 2066 2920 636f 6e73 7420 3d20 303b  t; f) const = 0;
    │ │ │ -0007c3f0: 0a0a 0909 2f2f 2061 736b 2066 6f72 2077  ....// ask for w
    │ │ │ -0007c400: 6869 6368 2069 6e74 6572 6661 6365 2061  hich interface a
    │ │ │ -0007c410: 6e64 2070 6f72 7420 746f 2062 696e 6420  nd port to bind 
    │ │ │ -0007c420: 6f75 7467 6f69 6e67 2070 6565 7220 636f  outgoing peer co
    │ │ │ -0007c430: 6e6e 6563 7469 6f6e 7320 6f6e 0a09 0976  nnections on...v
    │ │ │ -0007c440: 6972 7475 616c 2074 6370 3a3a 656e 6470  irtual tcp::endp
    │ │ │ -0007c450: 6f69 6e74 2062 696e 645f 6f75 7467 6f69  oint bind_outgoi
    │ │ │ -0007c460: 6e67 5f73 6f63 6b65 7428 736f 636b 6574  ng_socket(socket
    │ │ │ -0007c470: 5f74 7970 6526 616d 703b 2073 2c20 6164  _type& s, ad
    │ │ │ -0007c480: 6472 6573 7320 636f 6e73 7426 616d 703b  dress const&
    │ │ │ -0007c490: 0a09 0909 7265 6d6f 7465 5f61 6464 7265  ....remote_addre
    │ │ │ -0007c4a0: 7373 2c20 6572 726f 725f 636f 6465 2661  ss, error_code&a
    │ │ │ -0007c4b0: 6d70 3b20 6563 2920 636f 6e73 7420 3d20  mp; ec) const = 
    │ │ │ -0007c4c0: 303b 0a09 0976 6972 7475 616c 2062 6f6f  0;...virtual boo
    │ │ │ -0007c4d0: 6c20 7665 7269 6679 5f62 6f75 6e64 5f61  l verify_bound_a
    │ │ │ -0007c4e0: 6464 7265 7373 2861 6464 7265 7373 2063  ddress(address c
    │ │ │ -0007c4f0: 6f6e 7374 2661 6d70 3b20 6164 6472 2c20  onst& addr, 
    │ │ │ -0007c500: 626f 6f6c 2075 7470 0a09 0909 2c20 6572  bool utp...., er
    │ │ │ -0007c510: 726f 725f 636f 6465 2661 6d70 3b20 6563  ror_code& ec
    │ │ │ -0007c520: 2920 3d20 303b 0a0a 2369 666e 6465 6620  ) = 0;..#ifndef 
    │ │ │ -0007c530: 544f 5252 454e 545f 4449 5341 424c 455f  TORRENT_DISABLE_
    │ │ │ -0007c540: 4d55 5441 424c 455f 544f 5252 454e 5453  MUTABLE_TORRENTS
    │ │ │ -0007c550: 0a09 0976 6972 7475 616c 2073 7464 3a3a  ...virtual std::
    │ │ │ -0007c560: 7665 6374 6f72 266c 743b 7374 643a 3a73  vector<std::s
    │ │ │ -0007c570: 6861 7265 645f 7074 7226 6c74 3b74 6f72  hared_ptr<tor
    │ │ │ -0007c580: 7265 6e74 2667 743b 2667 743b 2066 696e  rent>> fin
    │ │ │ -0007c590: 645f 636f 6c6c 6563 7469 6f6e 280a 0909  d_collection(...
    │ │ │ -0007c5a0: 0973 7464 3a3a 7374 7269 6e67 2063 6f6e  .std::string con
    │ │ │ -0007c5b0: 7374 2661 6d70 3b20 636f 6c6c 6563 7469  st& collecti
    │ │ │ -0007c5c0: 6f6e 2920 636f 6e73 7420 3d20 303b 0a23  on) const = 0;.#
    │ │ │ -0007c5d0: 656e 6469 660a 0a3c 6469 7620 7374 796c  endif..
    ..virtual p │ │ │ -0007c610: 726f 7879 5f73 6574 7469 6e67 7320 7072 roxy_settings pr │ │ │ -0007c620: 6f78 7928 2920 636f 6e73 7420 3d20 303b oxy() const = 0; │ │ │ -0007c630: 0a3c 2f64 6976 3e0a 2369 6620 544f 5252 .
    .#if TORR │ │ │ -0007c640: 454e 545f 5553 455f 4932 500a 0909 7669 ENT_USE_I2P...vi │ │ │ -0007c650: 7274 7561 6c20 6932 705f 636f 6e6e 6563 rtual i2p_connec │ │ │ -0007c660: 7469 6f6e 2661 6d70 3b20 6932 705f 636f tion& i2p_co │ │ │ -0007c670: 6e6e 2829 203d 2030 3b0a 0909 7669 7274 nn() = 0;...virt │ │ │ -0007c680: 7561 6c20 6368 6172 2063 6f6e 7374 2a20 ual char const* │ │ │ -0007c690: 6932 705f 7365 7373 696f 6e28 2920 636f i2p_session() co │ │ │ -0007c6a0: 6e73 7420 3d20 303b 0a09 0976 6972 7475 nst = 0;...virtu │ │ │ -0007c6b0: 616c 2073 7464 3a3a 7374 7269 6e67 2063 al std::string c │ │ │ -0007c6c0: 6f6e 7374 2661 6d70 3b20 6c6f 6361 6c5f onst& local_ │ │ │ -0007c6d0: 6932 705f 656e 6470 6f69 6e74 2829 2063 i2p_endpoint() c │ │ │ -0007c6e0: 6f6e 7374 203d 2030 3b0a 2365 6e64 6966 onst = 0;.#endif │ │ │ -0007c6f0: 0a0a 0909 7669 7274 7561 6c20 766f 6964 ....virtual void │ │ │ -0007c700: 2070 7269 6f72 6974 697a 655f 636f 6e6e prioritize_conn │ │ │ -0007c710: 6563 7469 6f6e 7328 7374 643a 3a77 6561 ections(std::wea │ │ │ -0007c720: 6b5f 7074 7226 6c74 3b74 6f72 7265 6e74 k_ptr<torrent │ │ │ -0007c730: 2667 743b 2074 2920 3d20 303b 0a0a 0909 > t) = 0;.... │ │ │ -0007c740: 7669 7274 7561 6c20 766f 6964 2074 7269 virtual void tri │ │ │ -0007c750: 6767 6572 5f61 7574 6f5f 6d61 6e61 6765 gger_auto_manage │ │ │ -0007c760: 2829 203d 2030 3b0a 0a09 0976 6972 7475 () = 0;....virtu │ │ │ -0007c770: 616c 2076 6f69 6420 6170 706c 795f 7365 al void apply_se │ │ │ -0007c780: 7474 696e 6773 5f70 6163 6b28 7374 643a ttings_pack(std: │ │ │ -0007c790: 3a73 6861 7265 645f 7074 7226 6c74 3b73 :shared_ptr<s │ │ │ -0007c7a0: 6574 7469 6e67 735f 7061 636b 2667 743b ettings_pack> │ │ │ -0007c7b0: 2070 6163 6b29 203d 2030 3b0a 0909 7669 pack) = 0;...vi │ │ │ -0007c7c0: 7274 7561 6c20 7365 7373 696f 6e5f 7365 rtual session_se │ │ │ -0007c7d0: 7474 696e 6773 2063 6f6e 7374 2661 6d70 ttings const& │ │ │ -0007c7e0: 3b20 7365 7474 696e 6773 2829 2063 6f6e ; settings() con │ │ │ -0007c7f0: 7374 203d 2030 3b0a 0a09 0976 6972 7475 st = 0;....virtu │ │ │ -0007c800: 616c 2076 6f69 6420 7175 6575 655f 7472 al void queue_tr │ │ │ -0007c810: 6163 6b65 725f 7265 7175 6573 7428 6175 acker_request(au │ │ │ -0007c820: 783a 3a74 7261 636b 6572 5f72 6571 7565 x::tracker_reque │ │ │ -0007c830: 7374 2072 6571 0a09 0909 2c20 7374 643a st req...., std: │ │ │ -0007c840: 3a77 6561 6b5f 7074 7226 6c74 3b61 7578 :weak_ptr<aux │ │ │ -0007c850: 3a3a 7265 7175 6573 745f 6361 6c6c 6261 ::request_callba │ │ │ -0007c860: 636b 2667 743b 2063 2920 3d20 303b 0a0a ck> c) = 0;.. │ │ │ -0007c870: 0909 2f2f 2070 6565 722d 636c 6173 7365 ..// peer-classe │ │ │ -0007c880: 730a 0909 7669 7274 7561 6c20 766f 6964 s...virtual void │ │ │ -0007c890: 2073 6574 5f70 6565 725f 636c 6173 7365 set_peer_classe │ │ │ -0007c8a0: 7328 7065 6572 5f63 6c61 7373 5f73 6574 s(peer_class_set │ │ │ -0007c8b0: 2a20 732c 2061 6464 7265 7373 2063 6f6e * s, address con │ │ │ -0007c8c0: 7374 2661 6d70 3b20 612c 2073 6f63 6b65 st& a, socke │ │ │ -0007c8d0: 745f 7479 7065 5f74 2073 7429 203d 2030 t_type_t st) = 0 │ │ │ -0007c8e0: 3b0a 0909 7669 7274 7561 6c20 7065 6572 ;...virtual peer │ │ │ -0007c8f0: 5f63 6c61 7373 5f70 6f6f 6c20 636f 6e73 _class_pool cons │ │ │ -0007c900: 7426 616d 703b 2070 6565 725f 636c 6173 t& peer_clas │ │ │ -0007c910: 7365 7328 2920 636f 6e73 7420 3d20 303b ses() const = 0; │ │ │ -0007c920: 0a09 0976 6972 7475 616c 2070 6565 725f ...virtual peer_ │ │ │ -0007c930: 636c 6173 735f 706f 6f6c 2661 6d70 3b20 class_pool& │ │ │ -0007c940: 7065 6572 5f63 6c61 7373 6573 2829 203d peer_classes() = │ │ │ -0007c950: 2030 3b0a 0909 7669 7274 7561 6c20 626f 0;...virtual bo │ │ │ -0007c960: 6f6c 2069 676e 6f72 655f 756e 6368 6f6b ol ignore_unchok │ │ │ -0007c970: 655f 736c 6f74 735f 7365 7428 7065 6572 e_slots_set(peer │ │ │ -0007c980: 5f63 6c61 7373 5f73 6574 2063 6f6e 7374 _class_set const │ │ │ -0007c990: 2661 6d70 3b20 7365 7429 2063 6f6e 7374 & set) const │ │ │ -0007c9a0: 203d 2030 3b0a 0909 7669 7274 7561 6c20 = 0;...virtual │ │ │ -0007c9b0: 696e 7420 636f 7079 5f70 6572 7469 6e65 int copy_pertine │ │ │ -0007c9c0: 6e74 5f63 6861 6e6e 656c 7328 7065 6572 nt_channels(peer │ │ │ -0007c9d0: 5f63 6c61 7373 5f73 6574 2063 6f6e 7374 _class_set const │ │ │ -0007c9e0: 2661 6d70 3b20 7365 740a 0909 092c 2069 & set...., i │ │ │ -0007c9f0: 6e74 2063 6861 6e6e 656c 2c20 6261 6e64 nt channel, band │ │ │ -0007ca00: 7769 6474 685f 6368 616e 6e65 6c2a 2a20 width_channel** │ │ │ -0007ca10: 6473 742c 2069 6e74 206d 2920 3d20 303b dst, int m) = 0; │ │ │ -0007ca20: 0a09 0976 6972 7475 616c 2073 7464 3a3a ...virtual std:: │ │ │ -0007ca30: 7569 6e74 385f 7420 7573 655f 7175 6f74 uint8_t use_quot │ │ │ -0007ca40: 615f 6f76 6572 6865 6164 2870 6565 725f a_overhead(peer_ │ │ │ -0007ca50: 636c 6173 735f 7365 7426 616d 703b 2073 class_set& s │ │ │ -0007ca60: 6574 2c20 696e 7420 616d 6f75 6e74 5f64 et, int amount_d │ │ │ -0007ca70: 6f77 6e2c 2069 6e74 2061 6d6f 756e 745f own, int amount_ │ │ │ -0007ca80: 7570 2920 3d20 303b 0a0a 0909 7669 7274 up) = 0;....virt │ │ │ -0007ca90: 7561 6c20 6261 6e64 7769 6474 685f 6d61 ual bandwidth_ma │ │ │ -0007caa0: 6e61 6765 722a 2067 6574 5f62 616e 6477 nager* get_bandw │ │ │ -0007cab0: 6964 7468 5f6d 616e 6167 6572 2869 6e74 idth_manager(int │ │ │ -0007cac0: 2063 6861 6e6e 656c 2920 3d20 303b 0a0a channel) = 0;.. │ │ │ -0007cad0: 0909 7669 7274 7561 6c20 766f 6964 2073 ..virtual void s │ │ │ -0007cae0: 656e 745f 6279 7465 7328 696e 7420 6279 ent_bytes(int by │ │ │ -0007caf0: 7465 735f 7061 796c 6f61 642c 2069 6e74 tes_payload, int │ │ │ -0007cb00: 2062 7974 6573 5f70 726f 746f 636f 6c29 bytes_protocol) │ │ │ -0007cb10: 203d 2030 3b0a 0909 7669 7274 7561 6c20 = 0;...virtual │ │ │ -0007cb20: 766f 6964 2072 6563 6569 7665 645f 6279 void received_by │ │ │ -0007cb30: 7465 7328 696e 7420 6279 7465 735f 7061 tes(int bytes_pa │ │ │ -0007cb40: 796c 6f61 642c 2069 6e74 2062 7974 6573 yload, int bytes │ │ │ -0007cb50: 5f70 726f 746f 636f 6c29 203d 2030 3b0a _protocol) = 0;. │ │ │ -0007cb60: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0007cb70: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0007cba0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../in │ │ │ -0007cbd0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007cbe0: 2f61 7578 5f2f 6465 7072 6563 6174 6564 /aux_/deprecated │ │ │ -0007cbf0: 2e68 7070 3a32 343c 2f61 3e3c 2f74 643e .hpp:24 │ │ │ -0007cc00: 3c74 643e 6669 6775 7265 206f 7574 2077 figure out w │ │ │ -0007cc10: 6869 6368 2076 6572 7369 6f6e 206f 6620 hich version of │ │ │ -0007cc20: 636c 616e 6720 7468 6973 2069 7320 7375 clang this is su │ │ │ -0007cc30: 7070 6f72 7465 6420 696e 3c2f 7464 3e3c pported in< │ │ │ -0007cc40: 2f74 723e 3c74 7220 6964 3d22 3238 3622 /tr>

    figure o │ │ │ -0007cc90: 7574 2077 6869 6368 2076 6572 7369 6f6e ut which version │ │ │ -0007cca0: 206f 6620 636c 616e 6720 7468 6973 2069 of clang this i │ │ │ -0007ccb0: 7320 7375 7070 6f72 7465 6420 696e 3c2f s supported in

    ../includ │ │ │ -0007ccd0: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007cce0: 5f2f 6465 7072 6563 6174 6564 2e68 7070 _/deprecated.hpp │ │ │ -0007ccf0: 3a32 343c 2f68 343e 3c70 7265 2073 7479 :24

    All rights res
    │ │ │ -0007cd40: 6572 7665 642e 0a0a 596f 7520 6d61 7920  erved...You may 
    │ │ │ -0007cd50: 7573 652c 2064 6973 7472 6962 7574 6520  use, distribute 
    │ │ │ -0007cd60: 616e 6420 6d6f 6469 6679 2074 6869 7320  and modify this 
    │ │ │ -0007cd70: 636f 6465 2075 6e64 6572 2074 6865 2074  code under the t
    │ │ │ -0007cd80: 6572 6d73 206f 6620 7468 6520 4253 4420  erms of the BSD 
    │ │ │ -0007cd90: 6c69 6365 6e73 652c 0a73 6565 204c 4943  license,.see LIC
    │ │ │ -0007cda0: 454e 5345 2066 696c 652e 0a2a 2f0a 0a23  ENSE file..*/..#
    │ │ │ -0007cdb0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -0007cdc0: 4550 5245 4341 5445 445f 4850 505f 494e  EPRECATED_HPP_IN
    │ │ │ -0007cdd0: 434c 5544 4544 0a23 6465 6669 6e65 2054  CLUDED.#define T
    │ │ │ -0007cde0: 4f52 5245 4e54 5f44 4550 5245 4341 5445  ORRENT_DEPRECATE
    │ │ │ -0007cdf0: 445f 4850 505f 494e 434c 5544 4544 0a0a  D_HPP_INCLUDED..
    │ │ │ -0007ce00: 2369 6620 2164 6566 696e 6564 2054 4f52  #if !defined TOR
    │ │ │ -0007ce10: 5245 4e54 5f42 5549 4c44 494e 475f 4c49  RENT_BUILDING_LI
    │ │ │ -0007ce20: 4252 4152 590a 2320 6465 6669 6e65 2054  BRARY.# define T
    │ │ │ -0007ce30: 4f52 5245 4e54 5f44 4550 5245 4341 5445  ORRENT_DEPRECATE
    │ │ │ -0007ce40: 4420 5b5b 6465 7072 6563 6174 6564 5d5d  D [[deprecated]]
    │ │ │ -0007ce50: 0a23 656c 7365 0a23 2064 6566 696e 6520  .#else.# define 
    │ │ │ -0007ce60: 544f 5252 454e 545f 4445 5052 4543 4154  TORRENT_DEPRECAT
    │ │ │ -0007ce70: 4544 0a23 656e 6469 660a 0a23 6966 2064  ED.#endif..#if d
    │ │ │ -0007ce80: 6566 696e 6564 205f 5f63 6c61 6e67 5f5f  efined __clang__
    │ │ │ -0007ce90: 0a0a 2f2f 203d 3d3d 3d3d 3d20 434c 414e  ..// ====== CLAN
    │ │ │ -0007cea0: 4720 3d3d 3d3d 3d3d 3d3d 0a0a 2320 6966  G ========..# if
    │ │ │ -0007ceb0: 2021 6465 6669 6e65 6420 544f 5252 454e   !defined TORREN
    │ │ │ -0007cec0: 545f 4255 494c 4449 4e47 5f4c 4942 5241  T_BUILDING_LIBRA
    │ │ │ -0007ced0: 5259 0a3c 6469 7620 7374 796c 653d 2262  RY.
    # define TORRE │ │ │ -0007cf10: 4e54 5f44 4550 5245 4341 5445 445f 454e NT_DEPRECATED_EN │ │ │ -0007cf20: 554d 205f 5f61 7474 7269 6275 7465 5f5f UM __attribute__ │ │ │ -0007cf30: 2028 2864 6570 7265 6361 7465 6429 290a ((deprecated)). │ │ │ -0007cf40: 3c2f 6469 763e 2320 656e 6469 660a 0a23
    # endif..# │ │ │ -0007cf50: 656c 6966 2064 6566 696e 6564 205f 5f47 elif defined __G │ │ │ -0007cf60: 4e55 435f 5f0a 0a2f 2f20 3d3d 3d3d 3d3d NUC__..// ====== │ │ │ -0007cf70: 3d3d 2047 4343 203d 3d3d 3d3d 3d3d 3d0a == GCC ========. │ │ │ -0007cf80: 0a2f 2f20 6465 7072 6563 6174 696f 6e20 .// deprecation │ │ │ -0007cf90: 6d61 726b 7570 2069 7320 6f6e 6c79 2065 markup is only e │ │ │ -0007cfa0: 6e61 626c 6564 2077 6865 6e20 6c69 6274 nabled when libt │ │ │ -0007cfb0: 6f72 7265 6e74 0a2f 2f20 6865 6164 6572 orrent.// header │ │ │ -0007cfc0: 7320 6172 6520 696e 636c 7564 6564 2062 s are included b │ │ │ -0007cfd0: 7920 636c 6965 6e74 732c 206e 6f74 2077 y clients, not w │ │ │ -0007cfe0: 6869 6c65 2062 7569 6c64 696e 670a 2f2f hile building.// │ │ │ -0007cff0: 206c 6962 746f 7272 656e 7420 6974 7365 libtorrent itse │ │ │ -0007d000: 6c66 0a23 2069 6620 5f5f 474e 5543 5f5f lf.# if __GNUC__ │ │ │ -0007d010: 2026 6774 3b3d 2036 2026 616d 703b 2661 >= 6 &&a │ │ │ -0007d020: 6d70 3b20 2164 6566 696e 6564 2054 4f52 mp; !defined TOR │ │ │ -0007d030: 5245 4e54 5f42 5549 4c44 494e 475f 4c49 RENT_BUILDING_LI │ │ │ -0007d040: 4252 4152 590a 2320 2064 6566 696e 6520 BRARY.# define │ │ │ -0007d050: 544f 5252 454e 545f 4445 5052 4543 4154 TORRENT_DEPRECAT │ │ │ -0007d060: 4544 5f45 4e55 4d20 5f5f 6174 7472 6962 ED_ENUM __attrib │ │ │ -0007d070: 7574 655f 5f20 2828 6465 7072 6563 6174 ute__ ((deprecat │ │ │ -0007d080: 6564 2929 0a23 2065 6e64 6966 0a0a 2365 ed)).# endif..#e │ │ │ -0007d090: 6e64 6966 0a0a 2369 666e 6465 6620 544f ndif..#ifndef TO │ │ │ -0007d0a0: 5252 454e 545f 4445 5052 4543 4154 4544 RRENT_DEPRECATED │ │ │ -0007d0b0: 5f45 4e55 4d0a 2364 6566 696e 6520 544f _ENUM.#define TO │ │ │ -0007d0c0: 5252 454e 545f 4445 5052 4543 4154 4544 RRENT_DEPRECATED │ │ │ -0007d0d0: 5f45 4e55 4d0a 2365 6e64 6966 0a0a 2365 _ENUM.#endif..#e │ │ │ -0007d0e0: 6e64 6966 0a3c 2f70 7265 3e3c 2f74 643e ndif.
    │ │ │ -0007d0f0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0007d120: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0007d130: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0007d140: 7074 3a65 7870 616e 6428 3238 3729 223e pt:expand(287)"> │ │ │ -0007d150: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0007d160: 7272 656e 742f 6175 785f 2f74 6f72 7265 rrent/aux_/torre │ │ │ -0007d170: 6e74 5f70 6565 722e 6870 703a 3232 383c nt_peer.hpp:228< │ │ │ -0007d180: 2f61 3e3c 2f74 643e 3c74 643e 5468 6973 /a>This │ │ │ -0007d190: 2064 6573 7469 6e61 7469 6f6e 2073 686f destination sho │ │ │ -0007d1a0: 756c 6420 7072 6f62 6162 6c79 2062 6520 uld probably be │ │ │ -0007d1b0: 6b65 7074 2069 6e20 6269 6e61 7279 2066 kept in binary f │ │ │ -0007d1c0: 6f72 6d20 2872 6174 6865 7220 7468 616e orm (rather than │ │ │ -0007d1d0: 2062 6173 6536 3429 2e20 5468 6520 7065 base64). The pe │ │ │ -0007d1e0: 6572 7320 7368 6f75 6c64 2070 7269 6d61 ers should prima │ │ │ -0007d1f0: 7269 6c79 2062 6520 6861 6e64 6c65 6420 rily be handled │ │ │ -0007d200: 6279 2074 6865 6972 2073 6861 3235 3620 by their sha256 │ │ │ -0007d210: 6861 7368 206f 6620 7468 6520 6465 7374 hash of the dest │ │ │ -0007d220: 696e 6174 696f 6e2c 2074 6861 7420 7368 ination, that sh │ │ │ -0007d230: 6f75 6c64 2062 6520 6b65 7074 2069 6e20 ould be kept in │ │ │ -0007d240: 6865 7265 2061 7320 7765 6c6c 2e3c 2f74 here as well.

    This │ │ │ -0007d2a0: 6465 7374 696e 6174 696f 6e20 7368 6f75 destination shou │ │ │ -0007d2b0: 6c64 2070 726f 6261 626c 7920 6265 206b ld probably be k │ │ │ -0007d2c0: 6570 7420 696e 2062 696e 6172 7920 666f ept in binary fo │ │ │ -0007d2d0: 726d 2028 7261 7468 6572 2074 6861 6e0a rm (rather than. │ │ │ -0007d2e0: 6261 7365 3634 292e 2054 6865 2070 6565 base64). The pee │ │ │ -0007d2f0: 7273 2073 686f 756c 6420 7072 696d 6172 rs should primar │ │ │ -0007d300: 696c 7920 6265 2068 616e 646c 6564 2062 ily be handled b │ │ │ -0007d310: 7920 7468 6569 7220 7368 6132 3536 2068 y their sha256 h │ │ │ -0007d320: 6173 680a 6f66 2074 6865 2064 6573 7469 ash.of the desti │ │ │ -0007d330: 6e61 7469 6f6e 2c20 7468 6174 2073 686f nation, that sho │ │ │ -0007d340: 756c 6420 6265 206b 6570 7420 696e 2068 uld be kept in h │ │ │ -0007d350: 6572 6520 6173 2077 656c 6c2e 3c2f 6832 ere as well.

    ../include/ │ │ │ -0007d370: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0007d380: 746f 7272 656e 745f 7065 6572 2e68 7070 torrent_peer.hpp │ │ │ -0007d390: 3a32 3238 3c2f 6834 3e3c 7072 6520 7374 :228

    .};...struct 
    │ │ │ -0007d3e0: 544f 5252 454e 545f 4558 5452 415f 4558  TORRENT_EXTRA_EX
    │ │ │ -0007d3f0: 504f 5254 2069 7076 345f 7065 6572 203a  PORT ipv4_peer :
    │ │ │ -0007d400: 2074 6f72 7265 6e74 5f70 6565 720a 097b   torrent_peer..{
    │ │ │ -0007d410: 0a09 0969 7076 345f 7065 6572 2874 6370  ...ipv4_peer(tcp
    │ │ │ -0007d420: 3a3a 656e 6470 6f69 6e74 2063 6f6e 7374  ::endpoint const
    │ │ │ -0007d430: 2661 6d70 3b20 6570 2c20 626f 6f6c 2063  & ep, bool c
    │ │ │ -0007d440: 6f6e 6e65 6374 6162 6c65 2c20 7065 6572  onnectable, peer
    │ │ │ -0007d450: 5f73 6f75 7263 655f 666c 6167 735f 7420  _source_flags_t 
    │ │ │ -0007d460: 7372 6329 3b0a 0909 6970 7634 5f70 6565  src);...ipv4_pee
    │ │ │ -0007d470: 7228 6970 7634 5f70 6565 7220 636f 6e73  r(ipv4_peer cons
    │ │ │ -0007d480: 7426 616d 703b 2070 293b 0a09 0969 7076  t& p);...ipv
    │ │ │ -0007d490: 345f 7065 6572 2661 6d70 3b20 6f70 6572  4_peer& oper
    │ │ │ -0007d4a0: 6174 6f72 3d28 6970 7634 5f70 6565 7220  ator=(ipv4_peer 
    │ │ │ -0007d4b0: 636f 6e73 7426 616d 703b 2070 2920 2661  const& p) &a
    │ │ │ -0007d4c0: 6d70 3b3b 0a0a 0909 6164 6472 6573 735f  mp;;....address_
    │ │ │ -0007d4d0: 7634 2061 6464 723b 0a09 7d3b 0a0a 2369  v4 addr;..};..#i
    │ │ │ -0007d4e0: 6620 544f 5252 454e 545f 5553 455f 4932  f TORRENT_USE_I2
    │ │ │ -0007d4f0: 500a 0973 7472 7563 7420 544f 5252 454e  P..struct TORREN
    │ │ │ -0007d500: 545f 4558 5452 415f 4558 504f 5254 2069  T_EXTRA_EXPORT i
    │ │ │ -0007d510: 3270 5f70 6565 7220 3a20 746f 7272 656e  2p_peer : torren
    │ │ │ -0007d520: 745f 7065 6572 0a09 7b0a 0909 6932 705f  t_peer..{...i2p_
    │ │ │ -0007d530: 7065 6572 2873 7472 696e 675f 7669 6577  peer(string_view
    │ │ │ -0007d540: 2064 6573 742c 2062 6f6f 6c20 636f 6e6e   dest, bool conn
    │ │ │ -0007d550: 6563 7461 626c 652c 2070 6565 725f 736f  ectable, peer_so
    │ │ │ -0007d560: 7572 6365 5f66 6c61 6773 5f74 2073 7263  urce_flags_t src
    │ │ │ -0007d570: 293b 0a09 0969 3270 5f70 6565 7228 6932  );...i2p_peer(i2
    │ │ │ -0007d580: 705f 7065 6572 2063 6f6e 7374 2661 6d70  p_peer const&
    │ │ │ -0007d590: 3b29 203d 2064 656c 6574 653b 0a09 0969  ;) = delete;...i
    │ │ │ -0007d5a0: 3270 5f70 6565 7226 616d 703b 206f 7065  2p_peer& ope
    │ │ │ -0007d5b0: 7261 746f 723d 2869 3270 5f70 6565 7220  rator=(i2p_peer 
    │ │ │ -0007d5c0: 636f 6e73 7426 616d 703b 2920 3d20 6465  const&) = de
    │ │ │ -0007d5d0: 6c65 7465 3b0a 0909 6932 705f 7065 6572  lete;...i2p_peer
    │ │ │ -0007d5e0: 2869 3270 5f70 6565 7226 616d 703b 2661  (i2p_peer&&a
    │ │ │ -0007d5f0: 6d70 3b29 203d 2064 6566 6175 6c74 3b0a  mp;) = default;.
    │ │ │ -0007d600: 0909 6932 705f 7065 6572 2661 6d70 3b20  ..i2p_peer& 
    │ │ │ -0007d610: 6f70 6572 6174 6f72 3d28 6932 705f 7065  operator=(i2p_pe
    │ │ │ -0007d620: 6572 2661 6d70 3b26 616d 703b 2920 2661  er&&) &a
    │ │ │ -0007d630: 6d70 3b20 3d20 6465 6661 756c 743b 0a0a  mp; = default;..
    │ │ │ -0007d640: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -0007d670: 6175 783a 3a73 7472 696e 675f 7074 7220 aux::string_ptr │ │ │ -0007d680: 6465 7374 696e 6174 696f 6e3b 0a3c 2f64 destination;..};.#endif..# │ │ │ -0007d6a0: 6966 2054 4f52 5245 4e54 5f55 5345 5f52 if TORRENT_USE_R │ │ │ -0007d6b0: 5443 0a09 7374 7275 6374 2054 4f52 5245 TC..struct TORRE │ │ │ -0007d6c0: 4e54 5f45 5854 5241 5f45 5850 4f52 5420 NT_EXTRA_EXPORT │ │ │ -0007d6d0: 7274 635f 7065 6572 203a 2074 6f72 7265 rtc_peer : torre │ │ │ -0007d6e0: 6e74 5f70 6565 720a 097b 0a09 0972 7463 nt_peer..{...rtc │ │ │ -0007d6f0: 5f70 6565 7228 7463 703a 3a65 6e64 706f _peer(tcp::endpo │ │ │ -0007d700: 696e 7420 6570 2c20 7065 6572 5f73 6f75 int ep, peer_sou │ │ │ -0007d710: 7263 655f 666c 6167 735f 7420 7372 6329 rce_flags_t src) │ │ │ -0007d720: 3b0a 0909 7274 635f 7065 6572 2872 7463 ;...rtc_peer(rtc │ │ │ -0007d730: 5f70 6565 7220 636f 6e73 7426 616d 703b _peer const& │ │ │ -0007d740: 2920 3d20 6465 6c65 7465 3b0a 0909 7274 ) = delete;...rt │ │ │ -0007d750: 635f 7065 6572 2661 6d70 3b20 6f70 6572 c_peer& oper │ │ │ -0007d760: 6174 6f72 3d28 7274 635f 7065 6572 2063 ator=(rtc_peer c │ │ │ -0007d770: 6f6e 7374 2661 6d70 3b29 203d 2064 656c onst&) = del │ │ │ -0007d780: 6574 653b 0a09 0972 7463 5f70 6565 7228 ete;...rtc_peer( │ │ │ -0007d790: 7274 635f 7065 6572 2661 6d70 3b26 616d rtc_peer&&am │ │ │ -0007d7a0: 703b 2920 3d20 6465 6661 756c 743b 0a09 p;) = default;.. │ │ │ -0007d7b0: 0972 7463 5f70 6565 7226 616d 703b 206f .rtc_peer& o │ │ │ -0007d7c0: 7065 7261 746f 723d 2872 7463 5f70 6565 perator=(rtc_pee │ │ │ -0007d7d0: 7226 616d 703b 2661 6d70 3b29 2026 616d r&&) &am │ │ │ -0007d7e0: 703b 203d 2064 6566 6175 6c74 3b0a 0a09 p; = default;... │ │ │ -0007d7f0: 0974 6370 3a3a 656e 6470 6f69 6e74 2065 .tcp::endpoint e │ │ │ -0007d800: 6e64 706f 696e 743b 0a09 7d3b 0a23 656e ndpoint;..};.#en │ │ │ -0007d810: 6469 660a 0a09 7374 7275 6374 2054 4f52 dif...struct TOR │ │ │ -0007d820: 5245 4e54 5f45 5854 5241 5f45 5850 4f52 RENT_EXTRA_EXPOR │ │ │ -0007d830: 5420 6970 7636 5f70 6565 7220 3a20 746f T ipv6_peer : to │ │ │ -0007d840: 7272 656e 745f 7065 6572 0a09 7b0a 0909 rrent_peer..{... │ │ │ -0007d850: 6970 7636 5f70 6565 7228 7463 703a 3a65 ipv6_peer(tcp::e │ │ │ -0007d860: 6e64 706f 696e 7420 636f 6e73 7426 616d ndpoint const&am │ │ │ -0007d870: 703b 2065 702c 2062 6f6f 6c20 636f 6e6e p; ep, bool conn │ │ │ -0007d880: 6563 7461 626c 652c 2070 6565 725f 736f ectable, peer_so │ │ │ -0007d890: 7572 6365 5f66 6c61 6773 5f74 2073 7263 urce_flags_t src │ │ │ -0007d8a0: 293b 0a09 0969 7076 365f 7065 6572 2869 );...ipv6_peer(i │ │ │ -0007d8b0: 7076 365f 7065 6572 2063 6f6e 7374 2661 pv6_peer const&a │ │ │ -0007d8c0: 6d70 3b20 7029 3b0a 0a09 0963 6f6e 7374 mp; p);....const │ │ │ -0007d8d0: 2061 6464 7265 7373 5f76 363a 3a62 7974 address_v6::byt │ │ │ -0007d8e0: 6573 5f74 7970 6520 6164 6472 3b0a 097d es_type addr;..} │ │ │ -0007d8f0: 3b0a 0a09 2f2f 2069 6620 7765 2068 6176 ;...// if we hav │ │ │ -0007d900: 6520 6932 7020 7065 6572 2061 6464 7265 e i2p peer addre │ │ │ -0007d910: 7373 6573 2c20 736f 7274 2074 6865 6d20 sses, sort them │ │ │ -0007d920: 2a61 6674 6572 2a20 616c 6c20 4950 2061 *after* all IP a │ │ │ -0007d930: 6464 7265 7373 6573 0a09 7374 7275 6374 ddresses..struct │ │ │ -0007d940: 2070 6565 725f 6164 6472 6573 735f 636f peer_address_co │ │ │ -0007d950: 6d70 6172 650a 097b 0a09 0962 6f6f 6c20 mpare..{...bool │ │ │ -0007d960: 6f70 6572 6174 6f72 2829 2874 6f72 7265 operator()(torre │ │ │ -0007d970: 6e74 5f70 6565 7220 636f 6e73 742a 206c nt_peer const* l │ │ │ -0007d980: 6873 2c20 6164 6472 6573 7320 636f 6e73 hs, address cons │ │ │ -0007d990: 7426 616d 703b 2072 6873 2920 636f 6e73 t& rhs) cons │ │ │ -0007d9a0: 740a 0909 7b0a 2369 6620 544f 5252 454e t...{.#if TORREN │ │ │ -0007d9b0: 545f 5553 455f 4932 500a 3c2f 7072 653e T_USE_I2P.
    │ │ │ -0007d9c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0007d9f0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0007da00: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -0007da30: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0007da40: 6469 736b 5f63 6163 6865 2e68 7070 3a33 disk_cache.hpp:3 │ │ │ -0007da50: 3431 3c2f 613e 3c2f 7464 3e3c 7464 3e69 41i │ │ │ -0007da60: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ -0007da70: 6966 2074 6869 7320 636f 756c 6420 6265 if this could be │ │ │ -0007da80: 2063 616c 6c65 6420 7769 7468 6f75 7420 called without │ │ │ -0007da90: 686f 6c64 696e 6720 7468 6520 6d75 7465 holding the mute │ │ │ -0007daa0: 782e 2049 7420 776f 756c 6420 7265 7175 x. It would requ │ │ │ -0007dab0: 6972 6520 6265 696e 6720 6162 6c65 2074 ire being able t │ │ │ -0007dac0: 6f20 6c6f 636b 2074 6865 2070 6965 6365 o lock the piece │ │ │ -0007dad0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ -0007db20: 2077 6f75 6c64 2062 6520 6e69 6365 2069 would be nice i │ │ │ -0007db30: 6620 7468 6973 2063 6f75 6c64 2062 6520 f this could be │ │ │ -0007db40: 6361 6c6c 6564 2077 6974 686f 7574 2068 called without h │ │ │ -0007db50: 6f6c 6469 6e67 0a74 6865 206d 7574 6578 olding.the mutex │ │ │ -0007db60: 2e20 4974 2077 6f75 6c64 2072 6571 7569 . It would requi │ │ │ -0007db70: 7265 2062 6569 6e67 2061 626c 6520 746f re being able to │ │ │ -0007db80: 206c 6f63 6b20 7468 6520 7069 6563 653c lock the piece< │ │ │ -0007db90: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -0007dba0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007dbb0: 785f 2f64 6973 6b5f 6361 6368 652e 6870 x_/disk_cache.hp │ │ │ -0007dbc0: 703a 3334 313c 2f68 343e 3c70 7265 2073 p:341

    ..mi::hashed
    │ │ │ -0007dc10: 5f75 6e69 7175 6526 6c74 3b6d 693a 3a6d  _unique<mi::m
    │ │ │ -0007dc20: 656d 6265 7226 6c74 3b63 6163 6865 645f  ember<cached_
    │ │ │ -0007dc30: 7069 6563 655f 656e 7472 792c 2070 6965  piece_entry, pie
    │ │ │ -0007dc40: 6365 5f6c 6f63 6174 696f 6e2c 2026 616d  ce_location, &am
    │ │ │ -0007dc50: 703b 6361 6368 6564 5f70 6965 6365 5f65  p;cached_piece_e
    │ │ │ -0007dc60: 6e74 7279 3a3a 7069 6563 6526 6774 3b26  ntry::piece>&
    │ │ │ -0007dc70: 6774 3b2c 0a09 092f 2f20 6f72 6465 7265  gt;,...// ordere
    │ │ │ -0007dc80: 6420 6279 2077 6865 7468 6572 2074 6865  d by whether the
    │ │ │ -0007dc90: 2070 6965 6365 206e 6565 6473 2069 7473   piece needs its
    │ │ │ -0007dca0: 2068 6173 6865 7220 6b69 636b 6564 2e0a   hasher kicked..
    │ │ │ -0007dcb0: 0909 2f2f 2074 7275 6520 6973 206f 7264  ..// true is ord
    │ │ │ -0007dcc0: 6572 6564 2062 6566 6f72 6520 6661 6c73  ered before fals
    │ │ │ -0007dcd0: 652c 2073 6f20 7069 6563 6573 206e 6565  e, so pieces nee
    │ │ │ -0007dce0: 6469 6e67 2061 206b 6963 6b20 636f 6d65  ding a kick come
    │ │ │ -0007dcf0: 2066 6972 7374 2e0a 0909 6d69 3a3a 6f72   first....mi::or
    │ │ │ -0007dd00: 6465 7265 645f 6e6f 6e5f 756e 6971 7565  dered_non_unique
    │ │ │ -0007dd10: 266c 743b 6d69 3a3a 636f 6e73 745f 6d65  <mi::const_me
    │ │ │ -0007dd20: 6d5f 6675 6e26 6c74 3b63 6163 6865 645f  m_fun<cached_
    │ │ │ -0007dd30: 7069 6563 655f 656e 7472 792c 2062 6f6f  piece_entry, boo
    │ │ │ -0007dd40: 6c2c 2026 616d 703b 6361 6368 6564 5f70  l, &cached_p
    │ │ │ -0007dd50: 6965 6365 5f65 6e74 7279 3a3a 6e65 6564  iece_entry::need
    │ │ │ -0007dd60: 735f 6861 7368 6572 5f6b 6963 6b26 6774  s_hasher_kick>
    │ │ │ -0007dd70: 3b2c 2073 7464 3a3a 6772 6561 7465 7226  ;, std::greater&
    │ │ │ -0007dd80: 6c74 3b76 6f69 6426 6774 3b26 6774 3b0a  lt;void>>.
    │ │ │ -0007dd90: 0909 2667 743b 0a09 2667 743b 3b0a 0a09  ..>..>;...
    │ │ │ -0007dda0: 7465 6d70 6c61 7465 2026 6c74 3b74 7970  template <typ
    │ │ │ -0007ddb0: 656e 616d 6520 4675 6e26 6774 3b0a 0962  ename Fun>..b
    │ │ │ -0007ddc0: 6f6f 6c20 6765 7428 7069 6563 655f 6c6f  ool get(piece_lo
    │ │ │ -0007ddd0: 6361 7469 6f6e 2063 6f6e 7374 206c 6f63  cation const loc
    │ │ │ -0007dde0: 2c20 696e 7420 636f 6e73 7420 626c 6f63  , int const bloc
    │ │ │ -0007ddf0: 6b5f 6964 782c 2046 756e 2066 2920 636f  k_idx, Fun f) co
    │ │ │ -0007de00: 6e73 740a 097b 0a09 0973 7464 3a3a 756e  nst..{...std::un
    │ │ │ -0007de10: 6971 7565 5f6c 6f63 6b26 6c74 3b73 7464  ique_lock<std
    │ │ │ -0007de20: 3a3a 6d75 7465 7826 6774 3b20 6c28 6d5f  ::mutex> l(m_
    │ │ │ -0007de30: 6d75 7465 7829 3b0a 0a09 0949 4e56 4152  mutex);....INVAR
    │ │ │ -0007de40: 4941 4e54 5f43 4845 434b 3b0a 0a09 0961  IANT_CHECK;....a
    │ │ │ -0007de50: 7574 6f26 616d 703b 2076 6965 7720 3d20  uto& view = 
    │ │ │ -0007de60: 6d5f 7069 6563 6573 2e74 656d 706c 6174  m_pieces.templat
    │ │ │ -0007de70: 6520 6765 7426 6c74 3b30 2667 743b 2829  e get<0>()
    │ │ │ -0007de80: 3b0a 0909 6175 746f 2069 203d 2076 6965  ;...auto i = vie
    │ │ │ -0007de90: 772e 6669 6e64 286c 6f63 293b 0a09 0969  w.find(loc);...i
    │ │ │ -0007dea0: 6620 2869 203d 3d20 7669 6577 2e65 6e64  f (i == view.end
    │ │ │ -0007deb0: 2829 2920 7265 7475 726e 2066 616c 7365  ()) return false
    │ │ │ -0007dec0: 3b0a 0a09 0969 6620 2869 2d26 6774 3b62  ;....if (i->b
    │ │ │ -0007ded0: 6c6f 636b 735b 626c 6f63 6b5f 6964 785d  locks[block_idx]
    │ │ │ -0007dee0: 2e64 6174 6128 2929 0a09 097b 0a3c 6469  .data())...{....in
    │ │ │ -0007df20: 7420 636f 6e73 7420 626c 6b5f 7369 7a65  t const blk_size
    │ │ │ -0007df30: 203d 2073 7464 3a3a 6d69 6e28 6465 6661   = std::min(defa
    │ │ │ -0007df40: 756c 745f 626c 6f63 6b5f 7369 7a65 0a3c  ult_block_size.<
    │ │ │ -0007df50: 2f64 6976 3e09 0909 092c 2069 2d26 6774  /div>...., i->
    │ │ │ -0007df60: 3b70 6965 6365 5f73 697a 6520 2d20 626c  ;piece_size - bl
    │ │ │ -0007df70: 6f63 6b5f 6964 7820 2a20 6465 6661 756c  ock_idx * defaul
    │ │ │ -0007df80: 745f 626c 6f63 6b5f 7369 7a65 293b 0a09  t_block_size);..
    │ │ │ -0007df90: 0909 6628 692d 2667 743b 626c 6f63 6b73  ..f(i->blocks
    │ │ │ -0007dfa0: 5b62 6c6f 636b 5f69 6478 5d2e 6275 6628  [block_idx].buf(
    │ │ │ -0007dfb0: 626c 6b5f 7369 7a65 2929 3b0a 0909 0972  blk_size));....r
    │ │ │ -0007dfc0: 6574 7572 6e20 7472 7565 3b0a 0909 7d0a  eturn true;...}.
    │ │ │ -0007dfd0: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ -0007dfe0: 097d 0a0a 0974 656d 706c 6174 6520 266c  .}...template &l
    │ │ │ -0007dff0: 743b 7479 7065 6e61 6d65 2046 756e 2667  t;typename Fun&g
    │ │ │ -0007e000: 743b 0a09 7368 6132 3536 5f68 6173 6820  t;..sha256_hash 
    │ │ │ -0007e010: 6861 7368 3228 7069 6563 655f 6c6f 6361  hash2(piece_loca
    │ │ │ -0007e020: 7469 6f6e 2063 6f6e 7374 206c 6f63 2c20  tion const loc, 
    │ │ │ -0007e030: 696e 7420 636f 6e73 7420 626c 6f63 6b5f  int const block_
    │ │ │ -0007e040: 6964 782c 2046 756e 2066 2920 636f 6e73  idx, Fun f) cons
    │ │ │ -0007e050: 740a 097b 0a09 0973 7464 3a3a 756e 6971  t..{...std::uniq
    │ │ │ -0007e060: 7565 5f6c 6f63 6b26 6c74 3b73 7464 3a3a  ue_lock<std::
    │ │ │ -0007e070: 6d75 7465 7826 6774 3b20 6c28 6d5f 6d75  mutex> l(m_mu
    │ │ │ -0007e080: 7465 7829 3b0a 0a09 0949 4e56 4152 4941  tex);....INVARIA
    │ │ │ -0007e090: 4e54 5f43 4845 434b 3b0a 0a09 0961 7574  NT_CHECK;....aut
    │ │ │ -0007e0a0: 6f26 616d 703b 2076 6965 7720 3d20 6d5f  o& view = m_
    │ │ │ -0007e0b0: 7069 6563 6573 2e74 656d 706c 6174 6520  pieces.template 
    │ │ │ -0007e0c0: 6765 7426 6c74 3b30 2667 743b 2829 3b0a  get<0>();.
    │ │ │ -0007e0d0: 0909 6175 746f 2069 203d 2076 6965 772e  ..auto i = view.
    │ │ │ -0007e0e0: 6669 6e64 286c 6f63 293b 0a09 0969 6620  find(loc);...if 
    │ │ │ -0007e0f0: 2869 203d 3d20 7669 6577 2e65 6e64 2829  (i == view.end()
    │ │ │ -0007e100: 290a 0909 7b0a 0909 096c 2e75 6e6c 6f63  )...{....l.unloc
    │ │ │ -0007e110: 6b28 293b 0a09 0909 7265 7475 726e 2066  k();....return f
    │ │ │ -0007e120: 2829 3b0a 0909 7d0a 0a09 092f 2f20 416e  ();...}....// An
    │ │ │ -0007e130: 6f74 6865 7220 7468 7265 6164 206d 6179  other thread may
    │ │ │ -0007e140: 2062 6520 6861 7368 696e 6720 7468 6973   be hashing this
    │ │ │ -0007e150: 2070 6965 6365 2072 6967 6874 206e 6f77   piece right now
    │ │ │ -0007e160: 2e20 496e 2074 6869 7320 6361 7365 2077  . In this case w
    │ │ │ -0007e170: 650a 0909 2f2f 206e 6565 6420 746f 2077  e...// need to w
    │ │ │ -0007e180: 6169 740a 3c2f 7072 653e 3c2f 7464 3e3c  ait.
    < │ │ │ -0007e190: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0007e1c0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0007e1f0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0007e200: 7265 6e74 2f61 7578 5f2f 6469 736b 5f63 rent/aux_/disk_c │ │ │ -0007e210: 6163 6865 2e68 7070 3a33 3638 3c2f 613e ache.hpp:368 │ │ │ -0007e220: 3c2f 7464 3e3c 7464 3e74 6865 7265 206d there m │ │ │ -0007e230: 6179 2062 6520 6120 6265 7474 6572 2077 ay be a better w │ │ │ -0007e240: 6179 2074 6f20 736f 6c76 6520 7468 6973 ay to solve this │ │ │ -0007e250: 2c20 6d61 7962 6520 6861 6e67 2074 6865 , maybe hang the │ │ │ -0007e260: 206a 6f62 206f 6e20 7468 6520 7069 6563 job on the piec │ │ │ -0007e270: 6520 616e 6420 7472 7920 6c61 7465 722e e and try later. │ │ │ -0007e280: 2042 7574 2069 7427 7320 6120 6269 6720 But it's a big │ │ │ -0007e290: 6368 616e 6765 2074 6f20 646f 2073 6f3c change to do so< │ │ │ -0007e2a0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    the │ │ │ -0007e2f0: 7265 206d 6179 2062 6520 6120 6265 7474 re may be a bett │ │ │ -0007e300: 6572 2077 6179 2074 6f20 736f 6c76 6520 er way to solve │ │ │ -0007e310: 7468 6973 2c20 6d61 7962 6520 6861 6e67 this, maybe hang │ │ │ -0007e320: 2074 6865 206a 6f62 206f 6e0a 7468 6520 the job on.the │ │ │ -0007e330: 7069 6563 6520 616e 6420 7472 7920 6c61 piece and try la │ │ │ -0007e340: 7465 722e 2042 7574 2069 7427 7320 6120 ter. But it's a │ │ │ -0007e350: 6269 6720 6368 616e 6765 2074 6f20 646f big change to do │ │ │ -0007e360: 2073 6f3c 2f68 323e 3c68 343e 2e2e 2f69 so

    ../i │ │ │ -0007e370: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0007e380: 742f 6175 785f 2f64 6973 6b5f 6361 6368 t/aux_/disk_cach │ │ │ -0007e390: 652e 6870 703a 3336 383c 2f68 343e 3c70 e.hpp:368

    ..return │ │ │ -0007e3e0: 2066 616c 7365 3b0a 097d 0a0a 0974 656d false;..}...tem │ │ │ -0007e3f0: 706c 6174 6520 266c 743b 7479 7065 6e61 plate <typena │ │ │ -0007e400: 6d65 2046 756e 2667 743b 0a09 7368 6132 me Fun>..sha2 │ │ │ -0007e410: 3536 5f68 6173 6820 6861 7368 3228 7069 56_hash hash2(pi │ │ │ -0007e420: 6563 655f 6c6f 6361 7469 6f6e 2063 6f6e ece_location con │ │ │ -0007e430: 7374 206c 6f63 2c20 696e 7420 636f 6e73 st loc, int cons │ │ │ -0007e440: 7420 626c 6f63 6b5f 6964 782c 2046 756e t block_idx, Fun │ │ │ -0007e450: 2066 2920 636f 6e73 740a 097b 0a09 0973 f) const..{...s │ │ │ -0007e460: 7464 3a3a 756e 6971 7565 5f6c 6f63 6b26 td::unique_lock& │ │ │ -0007e470: 6c74 3b73 7464 3a3a 6d75 7465 7826 6774 lt;std::mutex> │ │ │ -0007e480: 3b20 6c28 6d5f 6d75 7465 7829 3b0a 0a09 ; l(m_mutex);... │ │ │ -0007e490: 0949 4e56 4152 4941 4e54 5f43 4845 434b .INVARIANT_CHECK │ │ │ -0007e4a0: 3b0a 0a09 0961 7574 6f26 616d 703b 2076 ;....auto& v │ │ │ -0007e4b0: 6965 7720 3d20 6d5f 7069 6563 6573 2e74 iew = m_pieces.t │ │ │ -0007e4c0: 656d 706c 6174 6520 6765 7426 6c74 3b30 emplate get<0 │ │ │ -0007e4d0: 2667 743b 2829 3b0a 0909 6175 746f 2069 >();...auto i │ │ │ -0007e4e0: 203d 2076 6965 772e 6669 6e64 286c 6f63 = view.find(loc │ │ │ -0007e4f0: 293b 0a09 0969 6620 2869 203d 3d20 7669 );...if (i == vi │ │ │ -0007e500: 6577 2e65 6e64 2829 290a 0909 7b0a 0909 ew.end())...{... │ │ │ -0007e510: 096c 2e75 6e6c 6f63 6b28 293b 0a09 0909 .l.unlock();.... │ │ │ -0007e520: 7265 7475 726e 2066 2829 3b0a 0909 7d0a return f();...}. │ │ │ -0007e530: 0a09 092f 2f20 416e 6f74 6865 7220 7468 ...// Another th │ │ │ -0007e540: 7265 6164 206d 6179 2062 6520 6861 7368 read may be hash │ │ │ -0007e550: 696e 6720 7468 6973 2070 6965 6365 2072 ing this piece r │ │ │ -0007e560: 6967 6874 206e 6f77 2e20 496e 2074 6869 ight now. In thi │ │ │ -0007e570: 7320 6361 7365 2077 650a 0909 2f2f 206e s case we...// n │ │ │ -0007e580: 6565 6420 746f 2077 6169 740a 3c64 6976 eed to wait.

    ..whil │ │ │ -0007e5c0: 6520 2869 2d26 6774 3b66 6c61 6773 2026 e (i->flags & │ │ │ -0007e5d0: 616d 703b 2063 6163 6865 645f 7069 6563 amp; cached_piec │ │ │ -0007e5e0: 655f 656e 7472 793a 3a68 6173 6869 6e67 e_entry::hashing │ │ │ -0007e5f0: 5f66 6c61 6729 0a3c 2f64 6976 3e09 097b _flag).
    ..{ │ │ │ -0007e600: 0a09 0909 6c2e 756e 6c6f 636b 2829 3b0a ....l.unlock();. │ │ │ -0007e610: 0909 0973 7464 3a3a 7468 6973 5f74 6872 ...std::this_thr │ │ │ -0007e620: 6561 643a 3a79 6965 6c64 2829 3b0a 0909 ead::yield();... │ │ │ -0007e630: 096c 2e6c 6f63 6b28 293b 0a0a 0909 0969 .l.lock();.....i │ │ │ -0007e640: 203d 2076 6965 772e 6669 6e64 286c 6f63 = view.find(loc │ │ │ -0007e650: 293b 0a09 0909 6966 2028 6920 3d3d 2076 );....if (i == v │ │ │ -0007e660: 6965 772e 656e 6428 2929 0a09 0909 7b0a iew.end())....{. │ │ │ -0007e670: 0909 0909 6c2e 756e 6c6f 636b 2829 3b0a ....l.unlock();. │ │ │ -0007e680: 0909 0909 7265 7475 726e 2066 2829 3b0a ....return f();. │ │ │ -0007e690: 0909 097d 0a09 097d 0a09 0961 7574 6f20 ...}...}...auto │ │ │ -0007e6a0: 636f 6e73 7426 616d 703b 2063 6265 203d const& cbe = │ │ │ -0007e6b0: 2069 2d26 6774 3b62 6c6f 636b 735b 626c i->blocks[bl │ │ │ -0007e6c0: 6f63 6b5f 6964 785d 3b0a 0909 2f2f 2069 ock_idx];...// i │ │ │ -0007e6d0: 6e64 6570 656e 6465 6e74 206f 6620 6861 ndependent of ha │ │ │ -0007e6e0: 7368 6572 5f63 7572 736f 723a 2061 6e79 sher_cursor: any │ │ │ -0007e6f0: 2076 3220 626c 6f63 6b20 6d61 7920 6265 v2 block may be │ │ │ -0007e700: 2068 6173 6865 6420 696e 2061 6e79 0a09 hashed in any.. │ │ │ -0007e710: 092f 2f20 6f72 6465 722e 2050 7265 636f .// order. Preco │ │ │ -0007e720: 6d70 7574 6564 2076 3220 6861 7368 6573 mputed v2 hashes │ │ │ -0007e730: 206c 6976 6520 6f6e 2070 7265 6164 5f73 live on pread_s │ │ │ -0007e740: 746f 7261 6765 2061 6e64 2061 7265 0a09 torage and are.. │ │ │ -0007e750: 092f 2f20 636f 6e73 756c 7465 6420 6279 .// consulted by │ │ │ -0007e760: 2074 6865 2063 616c 6c65 7220 6265 666f the caller befo │ │ │ -0007e770: 7265 2072 6561 6368 696e 6720 6865 7265 re reaching here │ │ │ -0007e780: 2e0a 0909 6966 2028 6362 652e 6461 7461 ....if (cbe.data │ │ │ -0007e790: 2829 290a 0909 7b0a 0909 0969 6e74 2063 ())...{....int c │ │ │ -0007e7a0: 6f6e 7374 2062 6c6b 5f73 697a 6520 3d20 onst blk_size = │ │ │ -0007e7b0: 7374 643a 3a6d 696e 2864 6566 6175 6c74 std::min(default │ │ │ -0007e7c0: 5f62 6c6f 636b 5f73 697a 650a 0909 0909 _block_size..... │ │ │ -0007e7d0: 2c20 692d 2667 743b 7069 6563 655f 7369 , i->piece_si │ │ │ -0007e7e0: 7a65 3220 2d20 626c 6f63 6b5f 6964 7820 ze2 - block_idx │ │ │ -0007e7f0: 2a20 6465 6661 756c 745f 626c 6f63 6b5f * default_block_ │ │ │ -0007e800: 7369 7a65 293b 0a09 0909 6861 7368 6572 size);....hasher │ │ │ -0007e810: 3235 3620 683b 0a09 0909 682e 7570 6461 256 h;....h.upda │ │ │ -0007e820: 7465 2863 6265 2e62 7566 2862 6c6b 5f73 te(cbe.buf(blk_s │ │ │ -0007e830: 697a 6529 293b 0a09 0909 7265 7475 726e ize));....return │ │ │ -0007e840: 2068 2e66 696e 616c 2829 3b0a 0909 7d0a h.final();...}. │ │ │ -0007e850: 0909 6c2e 756e 6c6f 636b 2829 3b0a 0909 ..l.unlock();... │ │ │ -0007e860: 7265 7475 726e 2066 2829 3b0a 097d 0a0a return f();..}.. │ │ │ -0007e870: 0965 6e75 6d20 636c 6173 7320 6861 7368 .enum class hash │ │ │ -0007e880: 5f70 6965 6365 5f72 6573 756c 7420 7b20 _piece_result { │ │ │ -0007e890: 6e6f 745f 696e 5f63 6163 6865 2c20 636f not_in_cache, co │ │ │ -0007e8a0: 6d70 6c65 7465 642c 2064 6566 6572 7265 mpleted, deferre │ │ │ -0007e8b0: 6420 7d3b 0a0a 3c2f 7072 653e 3c2f 7464 d };..
    relevance │ │ │ -0007e8f0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -0007e900: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ -0007e930: 6f72 7265 6e74 2f61 7578 5f2f 706f 6f6c orrent/aux_/pool │ │ │ -0007e940: 2e68 7070 3a32 373c 2f61 3e3c 2f74 643e .hpp:27 │ │ │ -0007e950: 3c74 643e 656e 7375 7265 2074 6865 2061 ensure the a │ │ │ -0007e960: 6c69 676e 6d65 6e74 2069 7320 676f 6f64 lignment is good │ │ │ -0007e970: 2068 6572 653c 2f74 643e 3c2f 7472 3e3c here< │ │ │ -0007e980: 7472 2069 643d 2232 3930 2220 7374 796c tr id="290" styl │ │ │ -0007e990: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0007e9a0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0007e9b0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0007e9c0: 6832 3e65 6e73 7572 6520 7468 6520 616c h2>ensure the al │ │ │ -0007e9d0: 6967 6e6d 656e 7420 6973 2067 6f6f 6420 ignment is good │ │ │ -0007e9e0: 6865 7265 3c2f 6832 3e3c 6834 3e2e 2e2f here

    ../ │ │ │ -0007e9f0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007ea00: 6e74 2f61 7578 5f2f 706f 6f6c 2e68 7070 nt/aux_/pool.hpp │ │ │ -0007ea10: 3a32 373c 2f68 343e 3c70 7265 2073 7479 :27

    see LICENSE fi
    │ │ │ -0007ea60: 6c65 2e0a 2a2f 0a0a 2369 666e 6465 6620  le..*/..#ifndef 
    │ │ │ -0007ea70: 544f 5252 454e 545f 504f 4f4c 5f48 5050  TORRENT_POOL_HPP
    │ │ │ -0007ea80: 0a23 6465 6669 6e65 2054 4f52 5245 4e54  .#define TORRENT
    │ │ │ -0007ea90: 5f50 4f4f 4c5f 4850 500a 0a23 696e 636c  _POOL_HPP..#incl
    │ │ │ -0007eaa0: 7564 6520 226c 6962 746f 7272 656e 742f  ude "libtorrent/
    │ │ │ -0007eab0: 6175 785f 2f64 6973 6162 6c65 5f77 6172  aux_/disable_war
    │ │ │ -0007eac0: 6e69 6e67 735f 7075 7368 2e68 7070 220a  nings_push.hpp".
    │ │ │ -0007ead0: 2369 6e63 6c75 6465 2026 6c74 3b62 6f6f  #include <boo
    │ │ │ -0007eae0: 7374 2f70 6f6f 6c2f 706f 6f6c 2e68 7070  st/pool/pool.hpp
    │ │ │ -0007eaf0: 2667 743b 0a23 696e 636c 7564 6520 226c  >.#include "l
    │ │ │ -0007eb00: 6962 746f 7272 656e 742f 6175 785f 2f64  ibtorrent/aux_/d
    │ │ │ -0007eb10: 6973 6162 6c65 5f77 6172 6e69 6e67 735f  isable_warnings_
    │ │ │ -0007eb20: 706f 702e 6870 7022 0a0a 2369 6e63 6c75  pop.hpp"..#inclu
    │ │ │ -0007eb30: 6465 2026 6c74 3b63 7374 6464 6566 2667  de <cstddef&g
    │ │ │ -0007eb40: 743b 0a0a 6e61 6d65 7370 6163 6520 6c69  t;..namespace li
    │ │ │ -0007eb50: 6274 6f72 7265 6e74 207b 0a6e 616d 6573  btorrent {.names
    │ │ │ -0007eb60: 7061 6365 2061 7578 207b 0a0a 7374 7275  pace aux {..stru
    │ │ │ -0007eb70: 6374 2061 6c6c 6f63 6174 6f72 5f6e 6577  ct allocator_new
    │ │ │ -0007eb80: 5f64 656c 6574 650a 7b0a 0975 7369 6e67  _delete.{..using
    │ │ │ -0007eb90: 2073 697a 655f 7479 7065 203d 2073 7464   size_type = std
    │ │ │ -0007eba0: 3a3a 7369 7a65 5f74 3b0a 0975 7369 6e67  ::size_t;..using
    │ │ │ -0007ebb0: 2064 6966 6665 7265 6e63 655f 7479 7065   difference_type
    │ │ │ -0007ebc0: 203d 2073 7464 3a3a 7074 7264 6966 665f   = std::ptrdiff_
    │ │ │ -0007ebd0: 743b 0a0a 3c64 6976 2073 7479 6c65 3d22  t;..
    .static char* │ │ │ -0007ec10: 6d61 6c6c 6f63 2873 697a 655f 7479 7065 malloc(size_type │ │ │ -0007ec20: 2063 6f6e 7374 2062 7974 6573 290a 3c2f const bytes)..{ return ne │ │ │ -0007ec40: 7720 6368 6172 5b62 7974 6573 5d3b 207d w char[bytes]; } │ │ │ -0007ec50: 0a09 7374 6174 6963 2076 6f69 6420 6672 ..static void fr │ │ │ -0007ec60: 6565 2863 6861 722a 2063 6f6e 7374 2062 ee(char* const b │ │ │ -0007ec70: 6c6f 636b 290a 097b 2064 656c 6574 6520 lock)..{ delete │ │ │ -0007ec80: 5b5d 2062 6c6f 636b 3b20 7d0a 7d3b 0a0a [] block; }.};.. │ │ │ -0007ec90: 7573 696e 6720 706f 6f6c 203d 2062 6f6f using pool = boo │ │ │ -0007eca0: 7374 3a3a 706f 6f6c 266c 743b 616c 6c6f st::pool<allo │ │ │ -0007ecb0: 6361 746f 725f 6e65 775f 6465 6c65 7465 cator_new_delete │ │ │ -0007ecc0: 2667 743b 3b0a 7d0a 7d0a 0a23 656e 6469 >;.}.}..#endi │ │ │ -0007ecd0: 660a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 f.
    < │ │ │ -0007ed00: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0007ed10: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0007ed40: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007ed50: 6e74 2f61 7578 5f2f 7574 705f 7374 7265 nt/aux_/utp_stre │ │ │ -0007ed60: 616d 2e68 7070 3a36 3637 3c2f 613e 3c2f am.hpp:667it would │ │ │ -0007ed80: 6265 206e 6963 6520 746f 206d 616b 6520 be nice to make │ │ │ -0007ed90: 7468 6973 2070 7269 7661 7465 3c2f 7464 this private

    it wou │ │ │ -0007edf0: 6c64 2062 6520 6e69 6365 2074 6f20 6d61 ld be nice to ma │ │ │ -0007ee00: 6b65 2074 6869 7320 7072 6976 6174 653c ke this private< │ │ │ -0007ee10: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -0007ee20: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007ee30: 785f 2f75 7470 5f73 7472 6561 6d2e 6870 x_/utp_stream.hp │ │ │ -0007ee40: 703a 3636 373c 2f68 343e 3c70 7265 2073 p:667

    .bool consum
    │ │ │ -0007ee90: 655f 696e 636f 6d69 6e67 5f64 6174 6128  e_incoming_data(
    │ │ │ -0007eea0: 0a09 0975 7470 5f68 6561 6465 7220 636f  ...utp_header co
    │ │ │ -0007eeb0: 6e73 742a 2070 682c 2073 7464 3a3a 7569  nst* ph, std::ui
    │ │ │ -0007eec0: 6e74 385f 7420 636f 6e73 742a 2070 7472  nt8_t const* ptr
    │ │ │ -0007eed0: 2c20 696e 7420 7061 796c 6f61 645f 7369  , int payload_si
    │ │ │ -0007eee0: 7a65 2c20 7469 6d65 5f70 6f69 6e74 206e  ze, time_point n
    │ │ │ -0007eef0: 6f77 293b 0a09 766f 6964 2075 7064 6174  ow);..void updat
    │ │ │ -0007ef00: 655f 6d74 755f 6c69 6d69 7473 2829 3b0a  e_mtu_limits();.
    │ │ │ -0007ef10: 0976 6f69 6420 6578 7065 7269 656e 6365  .void experience
    │ │ │ -0007ef20: 645f 6c6f 7373 2873 7464 3a3a 7569 6e74  d_loss(std::uint
    │ │ │ -0007ef30: 3332 5f74 2073 6571 5f6e 722c 2074 696d  32_t seq_nr, tim
    │ │ │ -0007ef40: 655f 706f 696e 7420 6e6f 7729 3b0a 0a09  e_point now);...
    │ │ │ -0007ef50: 766f 6964 2073 656e 645f 6465 6665 7272  void send_deferr
    │ │ │ -0007ef60: 6564 5f61 636b 2829 3b0a 0976 6f69 6420  ed_ack();..void 
    │ │ │ -0007ef70: 736f 636b 6574 5f64 7261 696e 6564 2829  socket_drained()
    │ │ │ -0007ef80: 3b0a 0a09 766f 6964 2073 6574 5f75 7365  ;...void set_use
    │ │ │ -0007ef90: 7264 6174 6128 7574 705f 7374 7265 616d  rdata(utp_stream
    │ │ │ -0007efa0: 2a20 7329 207b 206d 5f75 7365 7264 6174  * s) { m_userdat
    │ │ │ -0007efb0: 6120 3d20 733b 207d 0a09 766f 6964 2061  a = s; }..void a
    │ │ │ -0007efc0: 626f 7274 2829 3b0a 0975 6470 3a3a 656e  bort();..udp::en
    │ │ │ -0007efd0: 6470 6f69 6e74 2072 656d 6f74 655f 656e  dpoint remote_en
    │ │ │ -0007efe0: 6470 6f69 6e74 2829 2063 6f6e 7374 3b0a  dpoint() const;.
    │ │ │ -0007eff0: 0a09 7374 643a 3a75 696e 7431 365f 7420  ..std::uint16_t 
    │ │ │ -0007f000: 7265 6365 6976 655f 6964 2829 2063 6f6e  receive_id() con
    │ │ │ -0007f010: 7374 207b 2072 6574 7572 6e20 6d5f 7265  st { return m_re
    │ │ │ -0007f020: 6376 5f69 643b 207d 0a09 626f 6f6c 206d  cv_id; }..bool m
    │ │ │ -0007f030: 6174 6368 2875 6470 3a3a 656e 6470 6f69  atch(udp::endpoi
    │ │ │ -0007f040: 6e74 2063 6f6e 7374 2661 6d70 3b20 6570  nt const& ep
    │ │ │ -0007f050: 2c20 7374 643a 3a75 696e 7431 365f 7420  , std::uint16_t 
    │ │ │ -0007f060: 6964 2920 636f 6e73 743b 0a0a 092f 2f20  id) const;...// 
    │ │ │ -0007f070: 6e6f 6e2d 636f 7079 6162 6c65 0a09 7574  non-copyable..ut
    │ │ │ -0007f080: 705f 736f 636b 6574 5f69 6d70 6c28 7574  p_socket_impl(ut
    │ │ │ -0007f090: 705f 736f 636b 6574 5f69 6d70 6c20 636f  p_socket_impl co
    │ │ │ -0007f0a0: 6e73 7426 616d 703b 2920 3d20 6465 6c65  nst&) = dele
    │ │ │ -0007f0b0: 7465 3b0a 0975 7470 5f73 6f63 6b65 745f  te;..utp_socket_
    │ │ │ -0007f0c0: 696d 706c 2063 6f6e 7374 2661 6d70 3b20  impl const& 
    │ │ │ -0007f0d0: 6f70 6572 6174 6f72 3d28 7574 705f 736f  operator=(utp_so
    │ │ │ -0007f0e0: 636b 6574 5f69 6d70 6c20 636f 6e73 7426  cket_impl const&
    │ │ │ -0007f0f0: 616d 703b 2920 3d20 6465 6c65 7465 3b0a  amp;) = delete;.
    │ │ │ -0007f100: 0a09 2f2f 2054 6865 2075 6e64 6572 6c79  ..// The underly
    │ │ │ -0007f110: 696e 6720 5544 5020 736f 636b 6574 2074  ing UDP socket t
    │ │ │ -0007f120: 6869 7320 7554 5020 736f 636b 6574 2069  his uTP socket i
    │ │ │ -0007f130: 7320 626f 756e 6420 746f 0a3c 6469 7620  s bound to.
    .std::w │ │ │ -0007f170: 6561 6b5f 7074 7226 6c74 3b75 7470 5f73 eak_ptr<utp_s │ │ │ -0007f180: 6f63 6b65 745f 696e 7465 7266 6163 6526 ocket_interface& │ │ │ -0007f190: 6774 3b20 6d5f 736f 636b 3b0a 3c2f 6469 gt; m_sock;...void add_wri │ │ │ -0007f1b0: 7465 5f62 7566 6665 7228 766f 6964 2063 te_buffer(void c │ │ │ -0007f1c0: 6f6e 7374 2a20 6275 662c 2069 6e74 206c onst* buf, int l │ │ │ -0007f1d0: 656e 293b 0a09 766f 6964 2061 6464 5f72 en);..void add_r │ │ │ -0007f1e0: 6561 645f 6275 6666 6572 2876 6f69 642a ead_buffer(void* │ │ │ -0007f1f0: 2062 7566 2c20 696e 7420 6c65 6e29 3b0a buf, int len);. │ │ │ -0007f200: 0a09 696e 7420 7365 6e64 5f64 656c 6179 ..int send_delay │ │ │ -0007f210: 2829 2063 6f6e 7374 207b 2072 6574 7572 () const { retur │ │ │ -0007f220: 6e20 6d5f 7365 6e64 5f64 656c 6179 3b20 n m_send_delay; │ │ │ -0007f230: 7d0a 0969 6e74 2072 6563 765f 6465 6c61 }..int recv_dela │ │ │ -0007f240: 7928 2920 636f 6e73 7420 7b20 7265 7475 y() const { retu │ │ │ -0007f250: 726e 206d 5f72 6563 765f 6465 6c61 793b rn m_recv_delay; │ │ │ -0007f260: 207d 0a0a 0976 6f69 6420 6973 7375 655f }...void issue_ │ │ │ -0007f270: 7265 6164 2829 3b0a 0976 6f69 6420 6973 read();..void is │ │ │ -0007f280: 7375 655f 7772 6974 6528 293b 0a09 766f sue_write();..vo │ │ │ -0007f290: 6964 2073 7562 7363 7269 6265 5f77 7269 id subscribe_wri │ │ │ -0007f2a0: 7465 6162 6c65 2829 3b0a 0a09 626f 6f6c teable();...bool │ │ │ -0007f2b0: 2063 6865 636b 5f66 696e 5f73 656e 7428 check_fin_sent( │ │ │ -0007f2c0: 2920 636f 6e73 743b 0a0a 0976 6f69 6420 ) const;...void │ │ │ -0007f2d0: 646f 5f63 6f6e 6e65 6374 2874 6370 3a3a do_connect(tcp:: │ │ │ -0007f2e0: 656e 6470 6f69 6e74 2063 6f6e 7374 2661 endpoint const&a │ │ │ -0007f2f0: 6d70 3b20 6570 293b 0a0a 0973 7464 3a3a mp; ep);...std:: │ │ │ -0007f300: 7369 7a65 5f74 2072 6561 645f 736f 6d65 size_t read_some │ │ │ -0007f310: 2862 6f6f 6c20 636f 6e73 7420 636c 6561 (bool const clea │ │ │ -0007f320: 725f 6275 6666 6572 732c 2065 7272 6f72 r_buffers, error │ │ │ -0007f330: 5f63 6f64 6526 616d 703b 2065 6329 3b0a _code& ec);. │ │ │ -0007f340: 0973 7464 3a3a 7369 7a65 5f74 2077 7269 .std::size_t wri │ │ │ -0007f350: 7465 5f73 6f6d 6528 626f 6f6c 2063 6f6e te_some(bool con │ │ │ -0007f360: 7374 2063 6c65 6172 5f62 7566 6665 7273 st clear_buffers │ │ │ -0007f370: 293b 202f 2f20 5761 726e 696e 673a 206e ); // Warning: n │ │ │ -0007f380: 6f6e 2d62 6c6f 636b 696e 670a 0969 6e74 on-blocking..int │ │ │ -0007f390: 2072 6563 6569 7665 5f62 7566 6665 725f receive_buffer_ │ │ │ -0007f3a0: 7369 7a65 2829 2063 6f6e 7374 207b 2072 size() const { r │ │ │ -0007f3b0: 6574 7572 6e20 6d5f 7265 6365 6976 655f eturn m_receive_ │ │ │ -0007f3c0: 6275 6666 6572 5f73 697a 653b 207d 0a0a buffer_size; }.. │ │ │ -0007f3d0: 0962 6f6f 6c20 6e75 6c6c 5f62 7566 6665 .bool null_buffe │ │ │ -0007f3e0: 7273 2829 2063 6f6e 7374 207b 2072 6574 rs() const { ret │ │ │ -0007f3f0: 7572 6e20 6d5f 6e75 6c6c 5f62 7566 6665 urn m_null_buffe │ │ │ -0007f400: 7273 3b20 7d0a 0a70 7269 7661 7465 3a0a rs; }..private:. │ │ │ -0007f410: 0a09 2f2f 2069 7427 7320 696d 706f 7274 ..// it's import │ │ │ -0007f420: 616e 7420 7468 6174 2074 6865 7365 206d ant that these m │ │ │ -0007f430: 6174 6368 2074 6865 2065 6e75 6d73 2069 atch the enums i │ │ │ -0007f440: 6e20 7065 7266 6f72 6d61 6e63 655f 636f n performance_co │ │ │ -0007f450: 756e 7465 7273 2066 6f72 0a09 2f2f 206e unters for..// n │ │ │ -0007f460: 756d 5f75 7470 5f69 646c 6520 6574 632e um_utp_idle etc. │ │ │ -0007f470: 0a09 656e 756d 2063 6c61 7373 2073 7461 ..enum class sta │ │ │ -0007f480: 7465 5f74 207b 0a09 092f 2f20 6e6f 7420 te_t {...// not │ │ │ -0007f490: 7965 7420 636f 6e6e 6563 7465 640a 0909 yet connected... │ │ │ -0007f4a0: 6e6f 6e65 2c0a 0909 2f2f 2073 656e 7420 none,...// sent │ │ │ -0007f4b0: 6120 7379 6e20 7061 636b 6574 2c20 6e6f a syn packet, no │ │ │ -0007f4c0: 7420 7265 6365 6976 6564 2061 6e79 2061 t received any a │ │ │ -0007f4d0: 636b 730a 0909 7379 6e5f 7365 6e74 2c0a cks...syn_sent,. │ │ │ -0007f4e0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0007f4f0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0007f520: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -0007f550: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007f560: 2f61 7578 5f2f 7069 6563 655f 7069 636b /aux_/piece_pick │ │ │ -0007f570: 6572 2e68 7070 3a38 3038 3c2f 613e 3c2f er.hpp:808should th │ │ │ -0007f590: 6973 2062 6520 616c 6c6f 6361 7465 6420 is be allocated │ │ │ -0007f5a0: 6c61 7a69 6c79 3f3c 2f74 643e 3c2f 7472 lazily?

    should this │ │ │ -0007f600: 2062 6520 616c 6c6f 6361 7465 6420 6c61 be allocated la │ │ │ -0007f610: 7a69 6c79 3f3c 2f68 323e 3c68 343e 2e2e zily?

    .. │ │ │ -0007f620: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0007f630: 656e 742f 6175 785f 2f70 6965 6365 5f70 ent/aux_/piece_p │ │ │ -0007f640: 6963 6b65 722e 6870 703a 3830 383c 2f68 icker.hpp:808
    ..//
    │ │ │ -0007f690: 2064 6f77 6e6c 6f61 6420 6c69 7374 2069   download list i
    │ │ │ -0007f6a0: 7420 6d61 7920 6c69 7665 2069 6e20 6e6f  t may live in no
    │ │ │ -0007f6b0: 770a 0909 7374 643a 3a76 6563 746f 7226  w...std::vector&
    │ │ │ -0007f6c0: 6c74 3b64 6f77 6e6c 6f61 6469 6e67 5f70  lt;downloading_p
    │ │ │ -0007f6d0: 6965 6365 2667 743b 3a3a 6974 6572 6174  iece>::iterat
    │ │ │ -0007f6e0: 6f72 2075 7064 6174 655f 7069 6563 655f  or update_piece_
    │ │ │ -0007f6f0: 7374 6174 6528 0a09 0909 7374 643a 3a76  state(....std::v
    │ │ │ -0007f700: 6563 746f 7226 6c74 3b64 6f77 6e6c 6f61  ector<downloa
    │ │ │ -0007f710: 6469 6e67 5f70 6965 6365 2667 743b 3a3a  ding_piece>::
    │ │ │ -0007f720: 6974 6572 6174 6f72 2064 7029 3b0a 0a09  iterator dp);...
    │ │ │ -0007f730: 7072 6976 6174 653a 0a0a 2369 6620 544f  private:..#if TO
    │ │ │ -0007f740: 5252 454e 545f 5553 455f 4153 5345 5254  RRENT_USE_ASSERT
    │ │ │ -0007f750: 5320 7c7c 2054 4f52 5245 4e54 5f55 5345  S || TORRENT_USE
    │ │ │ -0007f760: 5f49 4e56 4152 4941 4e54 5f43 4845 434b  _INVARIANT_CHECK
    │ │ │ -0007f770: 530a 0909 696e 6465 785f 7261 6e67 6526  S...index_range&
    │ │ │ -0007f780: 6c74 3b64 6f77 6e6c 6f61 645f 7175 6575  lt;download_queu
    │ │ │ -0007f790: 655f 7426 6774 3b20 6361 7465 676f 7269  e_t> categori
    │ │ │ -0007f7a0: 6573 2829 2063 6f6e 7374 0a09 097b 2072  es() const...{ r
    │ │ │ -0007f7b0: 6574 7572 6e20 7b7b 7d2c 2070 6965 6365  eturn {{}, piece
    │ │ │ -0007f7c0: 5f70 6963 6b65 723a 3a70 6965 6365 5f70  _picker::piece_p
    │ │ │ -0007f7d0: 6f73 3a3a 6e75 6d5f 646f 776e 6c6f 6164  os::num_download
    │ │ │ -0007f7e0: 5f63 6174 6567 6f72 6965 737d 3b20 7d0a  _categories}; }.
    │ │ │ -0007f7f0: 2365 6e64 6966 0a0a 0909 2f2f 2074 6865  #endif....// the
    │ │ │ -0007f800: 2066 6f6c 6c6f 7769 6e67 2076 6563 746f   following vecto
    │ │ │ -0007f810: 7273 2061 7265 206d 7574 6162 6c65 2062  rs are mutable b
    │ │ │ -0007f820: 6563 6175 7365 2074 6865 7920 736f 6d65  ecause they some
    │ │ │ -0007f830: 7469 6d65 7320 6d61 790a 0909 2f2f 2062  times may...// b
    │ │ │ -0007f840: 6520 7570 6461 7465 6420 6c61 7a69 6c79  e updated lazily
    │ │ │ -0007f850: 2c20 7472 6967 6765 7265 6420 6279 2063  , triggered by c
    │ │ │ -0007f860: 6f6e 7374 2066 756e 6374 696f 6e73 0a0a  onst functions..
    │ │ │ -0007f870: 0909 2f2f 2074 6869 7320 6d61 7073 2069  ..// this maps i
    │ │ │ -0007f880: 6e64 6963 6573 2074 6f20 6e75 6d62 6572  ndices to number
    │ │ │ -0007f890: 206f 6620 7065 6572 7320 7468 6174 2068   of peers that h
    │ │ │ -0007f8a0: 6173 2074 6869 7320 7069 6563 6520 616e  as this piece an
    │ │ │ -0007f8b0: 640a 0909 2f2f 2069 6e64 6578 2069 6e74  d...// index int
    │ │ │ -0007f8c0: 6f20 7468 6520 6d5f 7069 6563 655f 696e  o the m_piece_in
    │ │ │ -0007f8d0: 666f 2076 6563 746f 7273 2e0a 0909 2f2f  fo vectors....//
    │ │ │ -0007f8e0: 2070 6965 6365 5f70 6f73 3a3a 666c 7573   piece_pos::flus
    │ │ │ -0007f8f0: 6865 645f 696e 6465 7820 6d65 616e 7320  hed_index means 
    │ │ │ -0007f900: 7468 6520 7069 636b 6572 2068 6173 2066  the picker has f
    │ │ │ -0007f910: 696e 616c 697a 6564 2074 6865 0a09 092f  inalized the.../
    │ │ │ -0007f920: 2f20 7069 6563 652c 2073 6f20 6974 2064  / piece, so it d
    │ │ │ -0007f930: 6f65 736e 2774 2065 7869 7374 2069 6e20  oesn't exist in 
    │ │ │ -0007f940: 7468 6520 7069 6563 655f 696e 666f 2062  the piece_info b
    │ │ │ -0007f950: 7563 6b65 7473 0a09 092f 2f20 7069 6563  uckets...// piec
    │ │ │ -0007f960: 6573 2077 6974 6820 7468 6520 6669 6c74  es with the filt
    │ │ │ -0007f970: 6572 6564 2066 6c61 6720 7365 7420 646f  ered flag set do
    │ │ │ -0007f980: 6573 6e27 7420 6861 7665 2065 6e74 7269  esn't have entri
    │ │ │ -0007f990: 6573 2069 6e0a 0909 2f2f 2074 6865 206d  es in...// the m
    │ │ │ -0007f9a0: 5f70 6965 6365 5f69 6e66 6f20 6275 636b  _piece_info buck
    │ │ │ -0007f9b0: 6574 7320 6569 7468 6572 0a3c 6469 7620  ets either.
    ..mutab │ │ │ -0007f9f0: 6c65 2061 7578 3a3a 7665 6374 6f72 266c le aux::vector&l │ │ │ -0007fa00: 743b 7069 6563 655f 706f 732c 2070 6965 t;piece_pos, pie │ │ │ -0007fa10: 6365 5f69 6e64 6578 5f74 2667 743b 206d ce_index_t> m │ │ │ -0007fa20: 5f70 6965 6365 5f6d 6170 3b0a 3c2f 6469 _piece_map;....// tracks t │ │ │ -0007fa40: 6865 206e 756d 6265 7220 6f66 2062 7974 he number of byt │ │ │ -0007fa50: 6573 2069 6e20 6120 7370 6563 6966 6963 es in a specific │ │ │ -0007fa60: 2070 6965 6365 2074 6861 7420 6172 6520 piece that are │ │ │ -0007fa70: 7061 7274 206f 6620 6120 7061 640a 0909 part of a pad... │ │ │ -0007fa80: 2f2f 2066 696c 652e 2054 6865 2070 6164 // file. The pad │ │ │ -0007fa90: 6469 6e67 2069 7320 6173 7375 6d65 6420 ding is assumed │ │ │ -0007faa0: 746f 2062 6520 6174 2074 6865 2065 6e64 to be at the end │ │ │ -0007fab0: 206f 6620 7468 6520 7069 6563 652c 2061 of the piece, a │ │ │ -0007fac0: 6e64 2074 6865 0a09 092f 2f20 626c 6f63 nd the...// bloc │ │ │ -0007fad0: 6b73 2063 6f76 6572 6564 2062 7920 7468 ks covered by th │ │ │ -0007fae0: 6520 7061 6420 6279 7465 7320 6172 6520 e pad bytes are │ │ │ -0007faf0: 6e6f 7420 7069 636b 6564 2062 7920 7468 not picked by th │ │ │ -0007fb00: 6520 7069 6563 6520 7069 636b 6572 0a09 e piece picker.. │ │ │ -0007fb10: 0973 7464 3a3a 756e 6f72 6465 7265 645f .std::unordered_ │ │ │ -0007fb20: 6d61 7026 6c74 3b70 6965 6365 5f69 6e64 map<piece_ind │ │ │ -0007fb30: 6578 5f74 2c20 696e 7426 6774 3b20 6d5f ex_t, int> m_ │ │ │ -0007fb40: 7061 6473 5f69 6e5f 7069 6563 653b 0a0a pads_in_piece;.. │ │ │ -0007fb50: 0909 2f2f 2077 6865 6e20 7468 6520 6164 ..// when the ad │ │ │ -0007fb60: 6a61 6365 6e74 5f70 6965 6365 2061 6666 jacent_piece aff │ │ │ -0007fb70: 696e 6974 7920 6973 2065 6e61 626c 6564 inity is enabled │ │ │ -0007fb80: 2c20 7468 6973 2063 6f6e 7461 696e 7320 , this contains │ │ │ -0007fb90: 7468 6520 6d6f 7374 0a09 092f 2f20 7265 the most...// re │ │ │ -0007fba0: 6365 6e74 2022 6578 7465 6e74 7322 206f cent "extents" o │ │ │ -0007fbb0: 6620 6164 6a61 6365 6e74 2070 6965 6365 f adjacent piece │ │ │ -0007fbc0: 7320 7468 6174 2068 6176 6520 6265 656e s that have been │ │ │ -0007fbd0: 2072 6571 7565 7374 6564 2066 726f 6d0a requested from. │ │ │ -0007fbe0: 0909 2f2f 2074 6869 7320 6973 206d 7574 ..// this is mut │ │ │ -0007fbf0: 6162 6c65 2062 6563 6175 7365 2069 7427 able because it' │ │ │ -0007fc00: 7320 7570 6461 7465 6420 6279 2066 756e s updated by fun │ │ │ -0007fc10: 6374 696f 6e73 2074 6f20 7069 636b 2070 ctions to pick p │ │ │ -0007fc20: 6965 6365 732c 2077 6869 6368 0a09 092f ieces, which.../ │ │ │ -0007fc30: 2f20 6172 6520 636f 6e73 742e 2054 6861 / are const. Tha │ │ │ -0007fc40: 7427 7320 616e 2065 6666 6963 6965 6e74 t's an efficient │ │ │ -0007fc50: 2070 6c61 6365 2074 6f20 7570 6461 7465 place to update │ │ │ -0007fc60: 2069 742c 2073 696e 6365 2069 7427 7320 it, since it's │ │ │ -0007fc70: 6265 696e 670a 0909 2f2f 2074 7261 7665 being...// trave │ │ │ -0007fc80: 7273 6564 2061 6c72 6561 6479 2e0a 0909 rsed already.... │ │ │ -0007fc90: 6d75 7461 626c 6520 7374 643a 3a76 6563 mutable std::vec │ │ │ -0007fca0: 746f 7226 6c74 3b70 6965 6365 5f65 7874 tor<piece_ext │ │ │ -0007fcb0: 656e 745f 7426 6774 3b20 6d5f 7265 6365 ent_t> m_rece │ │ │ -0007fcc0: 6e74 5f65 7874 656e 7473 3b0a 0a09 092f nt_extents;..../ │ │ │ -0007fcd0: 2f20 7468 6520 6e75 6d62 6572 206f 6620 / the number of │ │ │ -0007fce0: 6279 7465 7320 6f66 2070 6164 2066 696c bytes of pad fil │ │ │ -0007fcf0: 6520 7365 7420 696e 2074 6869 7320 7069 e set in this pi │ │ │ -0007fd00: 6563 6520 7069 636b 6572 0a09 0973 7464 ece picker...std │ │ │ -0007fd10: 3a3a 696e 7436 345f 7420 6d5f 6e75 6d5f ::int64_t m_num_ │ │ │ -0007fd20: 7061 645f 6279 7465 7320 3d20 303b 0a0a pad_bytes = 0;.. │ │ │ -0007fd30: 0909 2f2f 2074 6865 206e 756d 6265 7220 ..// the number │ │ │ -0007fd40: 6f66 2070 6164 2062 6c6f 636b 7320 7468 of pad blocks th │ │ │ -0007fd50: 6174 2077 6520 616c 7265 6164 7920 6861 at we already ha │ │ │ -0007fd60: 7665 0a09 0973 7464 3a3a 696e 7436 345f ve...std::int64_ │ │ │ -0007fd70: 7420 6d5f 6861 7665 5f70 6164 5f62 7974 t m_have_pad_byt │ │ │ -0007fd80: 6573 203d 2030 3b0a 0a09 092f 2f20 7468 es = 0;....// th │ │ │ -0007fd90: 6520 6e75 6d62 6572 206f 6620 7061 6420 e number of pad │ │ │ -0007fda0: 626c 6f63 6b73 2070 6172 7420 6f66 2066 blocks part of f │ │ │ -0007fdb0: 696c 7465 7265 6420 7069 6563 6573 2077 iltered pieces w │ │ │ -0007fdc0: 6520 646f 6e27 7420 6861 7665 0a09 0973 e don't have...s │ │ │ -0007fdd0: 7464 3a3a 696e 7436 345f 7420 6d5f 6669 td::int64_t m_fi │ │ │ -0007fde0: 6c74 6572 6564 5f70 6164 5f62 7974 6573 ltered_pad_bytes │ │ │ -0007fdf0: 203d 2030 3b0a 0a09 092f 2f20 7468 6520 = 0;....// the │ │ │ -0007fe00: 6e75 6d62 6572 206f 6620 7061 6420 626c number of pad bl │ │ │ -0007fe10: 6f63 6b73 2077 6520 6861 7665 2074 6861 ocks we have tha │ │ │ -0007fe20: 7420 6172 6520 616c 736f 2066 696c 7465 t are also filte │ │ │ -0007fe30: 7265 640a 0909 7374 643a 3a69 6e74 3634 red...std::int64 │ │ │ -0007fe40: 5f74 206d 5f68 6176 655f 6669 6c74 6572 _t m_have_filter │ │ │ -0007fe50: 6564 5f70 6164 5f62 7974 6573 203d 2030 ed_pad_bytes = 0 │ │ │ -0007fe60: 3b0a 0a09 092f 2f20 7468 6520 6e75 6d62 ;....// the numb │ │ │ -0007fe70: 6572 206f 6620 7365 6564 732e 2054 6865 er of seeds. The │ │ │ -0007fe80: 7365 2061 7265 206e 6f74 2061 6464 6564 se are not added │ │ │ -0007fe90: 2074 6f0a 0909 2f2f 2074 6865 2061 7661 to...// the ava │ │ │ -0007fea0: 696c 6162 696c 6974 7920 636f 756e 7465 ilability counte │ │ │ -0007feb0: 7273 206f 6620 7468 6520 7069 6563 6573 rs of the pieces │ │ │ -0007fec0: 0a09 0969 6e74 206d 5f73 6565 6473 203d ...int m_seeds = │ │ │ -0007fed0: 2030 3b0a 0a09 092f 2f20 7468 6973 2076 0;....// this v │ │ │ -0007fee0: 6563 746f 7220 636f 6e74 6169 6e73 2061 ector contains a │ │ │ -0007fef0: 6c6c 2070 6965 6365 2069 6e64 6963 6573 ll piece indices │ │ │ -0007ff00: 2074 6861 7420 6172 6520 7069 636b 6162 that are pickab │ │ │ -0007ff10: 6c65 0a3c 2f70 7265 3e3c 2f74 643e 3c2f le.
    │ │ │ -0007ff40: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0007ff50: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -0007ff80: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0007ff90: 656e 742f 6175 785f 2f70 6965 6365 5f70 ent/aux_/piece_p │ │ │ -0007ffa0: 6963 6b65 722e 6870 703a 3838 303c 2f61 icker.hpp:880it wou │ │ │ -0007ffc0: 6c64 2062 6520 6d6f 7265 2069 6e74 7569 ld be more intui │ │ │ -0007ffd0: 7469 7665 2074 6f20 6163 636f 756e 7420 tive to account │ │ │ -0007ffe0: 2277 616e 7465 6422 2070 6965 6365 7320 "wanted" pieces │ │ │ -0007fff0: 696e 7374 6561 6420 6f66 2066 696c 7465 instead of filte │ │ │ -00080000: 7265 643c 2f74 643e 3c2f 7472 3e3c 7472 red

    it would be mor │ │ │ -00080060: 6520 696e 7475 6974 6976 6520 746f 2061 e intuitive to a │ │ │ -00080070: 6363 6f75 6e74 2022 7761 6e74 6564 2220 ccount "wanted" │ │ │ -00080080: 7069 6563 6573 0a69 6e73 7465 6164 206f pieces.instead o │ │ │ -00080090: 6620 6669 6c74 6572 6564 3c2f 6832 3e3c f filtered

    < │ │ │ -000800a0: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -000800b0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7069 btorrent/aux_/pi │ │ │ -000800c0: 6563 655f 7069 636b 6572 2e68 7070 3a38 ece_picker.hpp:8 │ │ │ -000800d0: 3830 3c2f 6834 3e3c 7072 6520 7374 796c 80
    ...// this hold
    │ │ │ -00080120: 7320 7468 6520 696e 666f 726d 6174 696f  s the informatio
    │ │ │ -00080130: 6e20 6f66 2074 6865 2062 6c6f 636b 7320  n of the blocks 
    │ │ │ -00080140: 696e 2070 6172 7469 616c 6c79 2064 6f77  in partially dow
    │ │ │ -00080150: 6e6c 6f61 6465 640a 0909 2f2f 2070 6965  nloaded...// pie
    │ │ │ -00080160: 6365 732e 2074 6865 2064 6f77 6e6c 6f61  ces. the downloa
    │ │ │ -00080170: 6469 6e67 5f70 6965 6365 3a3a 696e 666f  ding_piece::info
    │ │ │ -00080180: 2069 6e64 6578 2070 6f69 6e74 2069 6e74   index point int
    │ │ │ -00080190: 6f20 7468 6973 2076 6563 746f 7220 666f  o this vector fo
    │ │ │ -000801a0: 720a 0909 2f2f 2069 7473 2073 746f 7261  r...// its stora
    │ │ │ -000801b0: 6765 0a09 0961 7578 3a3a 7665 6374 6f72  ge...aux::vector
    │ │ │ -000801c0: 266c 743b 626c 6f63 6b5f 696e 666f 2667  <block_info&g
    │ │ │ -000801d0: 743b 206d 5f62 6c6f 636b 5f69 6e66 6f3b  t; m_block_info;
    │ │ │ -000801e0: 0a0a 0909 2f2f 2074 6865 7365 2061 7265  ....// these are
    │ │ │ -000801f0: 2062 6c6f 636b 2072 616e 6765 7320 696e   block ranges in
    │ │ │ -00080200: 206d 5f62 6c6f 636b 5f69 6e66 6f20 7468   m_block_info th
    │ │ │ -00080210: 6174 2061 7265 2066 7265 652e 2054 6865  at are free. The
    │ │ │ -00080220: 206e 756d 6265 7273 0a09 092f 2f20 696e   numbers...// in
    │ │ │ -00080230: 2068 6572 652c 2077 6865 6e20 6d75 6c74   here, when mult
    │ │ │ -00080240: 6970 6c69 6564 2062 7920 626c 6f63 6b73  iplied by blocks
    │ │ │ -00080250: 5f70 6572 5f70 6965 6365 2069 7320 7468  _per_piece is th
    │ │ │ -00080260: 6520 696e 6465 7820 746f 2074 6865 0a09  e index to the..
    │ │ │ -00080270: 092f 2f20 6669 7273 7420 626c 6f63 6b20  .// first block 
    │ │ │ -00080280: 696e 2074 6865 2072 616e 6765 2074 6861  in the range tha
    │ │ │ -00080290: 7427 7320 6672 6565 2074 6f20 7573 6520  t's free to use 
    │ │ │ -000802a0: 6279 2061 206e 6577 2064 6f77 6e6c 6f61  by a new downloa
    │ │ │ -000802b0: 6469 6e67 5f70 6965 6365 2e0a 0909 2f2f  ding_piece....//
    │ │ │ -000802c0: 2074 6869 7320 6973 2061 2066 7265 652d   this is a free-
    │ │ │ -000802d0: 6c69 7374 2e0a 0909 7374 643a 3a76 6563  list....std::vec
    │ │ │ -000802e0: 746f 7226 6c74 3b73 7464 3a3a 7569 6e74  tor<std::uint
    │ │ │ -000802f0: 3136 5f74 2667 743b 206d 5f66 7265 655f  16_t> m_free_
    │ │ │ -00080300: 626c 6f63 6b5f 696e 666f 733b 0a0a 0909  block_infos;....
    │ │ │ -00080310: 7374 643a 3a75 696e 7431 365f 7420 6d5f  std::uint16_t m_
    │ │ │ -00080320: 626c 6f63 6b73 5f69 6e5f 6c61 7374 5f70  blocks_in_last_p
    │ │ │ -00080330: 6965 6365 203d 2030 3b0a 0909 696e 7420  iece = 0;...int 
    │ │ │ -00080340: 6d5f 7069 6563 655f 7369 7a65 203d 2030  m_piece_size = 0
    │ │ │ -00080350: 3b0a 0909 7374 643a 3a69 6e74 3634 5f74  ;...std::int64_t
    │ │ │ -00080360: 206d 5f74 6f74 616c 5f73 697a 6520 3d20   m_total_size = 
    │ │ │ -00080370: 303b 0a0a 0909 2f2f 2074 6865 206e 756d  0;....// the num
    │ │ │ -00080380: 6265 7220 6f66 2066 696c 7465 7265 6420  ber of filtered 
    │ │ │ -00080390: 7069 6563 6573 2074 6861 7420 7765 2064  pieces that we d
    │ │ │ -000803a0: 6f6e 2774 2061 6c72 6561 6479 0a09 092f  on't already.../
    │ │ │ -000803b0: 2f20 6861 7665 2e20 746f 7461 6c5f 6e75  / have. total_nu
    │ │ │ -000803c0: 6d62 6572 5f6f 665f 7069 6563 6573 202d  mber_of_pieces -
    │ │ │ -000803d0: 206e 756d 6265 725f 6f66 5f70 6965 6365   number_of_piece
    │ │ │ -000803e0: 735f 7765 5f68 6176 650a 0909 2f2f 202d  s_we_have...// -
    │ │ │ -000803f0: 206e 756d 5f66 696c 7465 7265 6420 6973   num_filtered is
    │ │ │ -00080400: 2073 7570 706f 7365 6420 746f 2074 6865   supposed to the
    │ │ │ -00080410: 206e 756d 6265 7220 6f66 2070 6965 6365   number of piece
    │ │ │ -00080420: 730a 0909 2f2f 2077 6520 7374 696c 6c20  s...// we still 
    │ │ │ -00080430: 7761 6e74 2074 6f20 646f 776e 6c6f 6164  want to download
    │ │ │ -00080440: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00080470: 0969 6e74 206d 5f6e 756d 5f66 696c 7465 .int m_num_filte │ │ │ -00080480: 7265 6420 3d20 303b 0a3c 2f64 6976 3e0a red = 0;.
    . │ │ │ -00080490: 0909 2f2f 2074 6865 206e 756d 6265 7220 ..// the number │ │ │ -000804a0: 6f66 2070 6965 6365 7320 7765 2068 6176 of pieces we hav │ │ │ -000804b0: 6520 7468 6174 2061 6c73 6f20 6172 6520 e that also are │ │ │ -000804c0: 6669 6c74 6572 6564 0a09 0969 6e74 206d filtered...int m │ │ │ -000804d0: 5f6e 756d 5f68 6176 655f 6669 6c74 6572 _num_have_filter │ │ │ -000804e0: 6564 203d 2030 3b0a 0a09 092f 2f20 7765 ed = 0;....// we │ │ │ -000804f0: 2068 6176 6520 616c 6c20 7069 6563 6573 have all pieces │ │ │ -00080500: 2069 6e20 7468 6520 7261 6e67 6520 5b73 in the range [s │ │ │ -00080510: 7461 7274 5f72 616e 6765 2c20 6d5f 6375 tart_range, m_cu │ │ │ -00080520: 7273 6f72 290a 0909 2f2f 206d 5f63 7572 rsor)...// m_cur │ │ │ -00080530: 736f 7220 6973 2074 6865 2066 6972 7374 sor is the first │ │ │ -00080540: 2070 6965 6365 2077 6520 646f 6e27 7420 piece we don't │ │ │ -00080550: 6861 7665 2e0a 0909 2f2f 0a09 092f 2f20 have....//...// │ │ │ -00080560: 2268 6176 6522 2068 6572 6520 6973 2074 "have" here is t │ │ │ -00080570: 6865 2073 7472 6963 7420 6e6f 7469 6f6e he strict notion │ │ │ -00080580: 3a20 7069 6563 655f 706f 733a 3a66 6c75 : piece_pos::flu │ │ │ -00080590: 7368 6564 2829 2e20 5468 650a 0909 2f2f shed(). The...// │ │ │ -000805a0: 2063 7572 736f 7220 6973 206f 6e6c 7920 cursor is only │ │ │ -000805b0: 6164 7661 6e63 6564 2070 6173 7420 6120 advanced past a │ │ │ -000805c0: 7069 6563 6520 6279 2070 6965 6365 5f66 piece by piece_f │ │ │ -000805d0: 6c75 7368 6564 2829 2028 616e 640a 0909 lushed() (and... │ │ │ -000805e0: 2f2f 2074 6865 2063 7572 736f 7220 7761 // the cursor wa │ │ │ -000805f0: 6c6b 7320 696e 2073 6574 5f70 6965 6365 lks in set_piece │ │ │ -00080600: 5f70 7269 6f72 6974 7928 2920 7768 656e _priority() when │ │ │ -00080610: 2066 696c 7465 7269 6e67 2c20 7369 6e63 filtering, sinc │ │ │ -00080620: 650a 0909 2f2f 2066 696c 7465 7265 6420 e...// filtered │ │ │ -00080630: 7069 6563 6573 2061 7265 2061 6c73 6f20 pieces are also │ │ │ -00080640: 6f75 7420 6f66 2074 6865 2070 6963 6b65 out of the picke │ │ │ -00080650: 7227 7320 776f 726b 696e 6720 7365 7429 r's working set) │ │ │ -00080660: 2e20 410a 0909 2f2f 2070 6965 6365 2074 . A...// piece t │ │ │ -00080670: 6861 7420 6861 7320 6f6e 6c79 2070 6173 hat has only pas │ │ │ -00080680: 7365 645f 6861 7368 5f63 6865 636b 2062 sed_hash_check b │ │ │ -00080690: 7574 2069 7320 6e6f 7420 7965 7420 666c ut is not yet fl │ │ │ -000806a0: 7573 6865 640a 0909 2f2f 2077 696c 6c20 ushed...// will │ │ │ -000806b0: 6e6f 7420 6d6f 7665 2074 6865 2063 7572 not move the cur │ │ │ -000806c0: 736f 723b 2074 6865 2063 7572 736f 7220 sor; the cursor │ │ │ -000806d0: 6c61 6773 2075 6e74 696c 2070 6965 6365 lags until piece │ │ │ -000806e0: 5f66 6c75 7368 6564 2829 0a09 092f 2f20 _flushed()...// │ │ │ -000806f0: 7275 6e73 2028 7479 7069 6361 6c6c 7920 runs (typically │ │ │ -00080700: 6672 6f6d 206d 6172 6b5f 6173 5f66 696e from mark_as_fin │ │ │ -00080710: 6973 6865 6428 2920 6f6e 6365 2074 6865 ished() once the │ │ │ -00080720: 206c 6173 7420 626c 6f63 6b0a 0909 2f2f last block...// │ │ │ -00080730: 2063 6f6d 706c 6574 6573 292e 2054 6869 completes). Thi │ │ │ -00080740: 7320 6176 6f69 6473 206e 6565 6469 6e67 s avoids needing │ │ │ -00080750: 2074 6f20 7761 6c6b 2074 6865 2063 7572 to walk the cur │ │ │ -00080760: 736f 7220 6261 636b 7761 7264 730a 0909 sor backwards... │ │ │ -00080770: 2f2f 2069 6620 7772 6974 655f 6661 696c // if write_fail │ │ │ -00080780: 6564 2829 206c 6174 6572 2063 6c65 6172 ed() later clear │ │ │ -00080790: 7320 7061 7373 6564 5f68 6173 685f 6368 s passed_hash_ch │ │ │ -000807a0: 6563 6b2e 0a09 0970 6965 6365 5f69 6e64 eck....piece_ind │ │ │ -000807b0: 6578 5f74 206d 5f63 7572 736f 727b 307d ex_t m_cursor{0} │ │ │ -000807c0: 3b0a 0a09 092f 2f20 7765 2068 6176 6520 ;....// we have │ │ │ -000807d0: 616c 6c20 7069 6563 6573 2069 6e20 7468 all pieces in th │ │ │ -000807e0: 6520 7261 6e67 6520 5b6d 5f72 6576 6572 e range [m_rever │ │ │ -000807f0: 7365 5f63 7572 736f 722c 2065 6e64 5f72 se_cursor, end_r │ │ │ -00080800: 616e 6765 290a 0909 2f2f 206d 5f72 6576 ange)...// m_rev │ │ │ -00080810: 6572 7365 5f63 7572 736f 7220 6973 2074 erse_cursor is t │ │ │ -00080820: 6865 2066 6972 7374 2070 6965 6365 2077 he first piece w │ │ │ -00080830: 6865 7265 2077 6520 616c 736f 2068 6176 here we also hav │ │ │ -00080840: 650a 0909 2f2f 2061 6c6c 2074 6865 2073 e...// all the s │ │ │ -00080850: 7562 7365 7175 656e 7420 7069 6563 6573 ubsequent pieces │ │ │ -00080860: 2e0a 0909 2f2f 2053 616d 6520 7374 7269 ....// Same stri │ │ │ -00080870: 6374 2d66 6c75 7368 6564 2073 656d 616e ct-flushed seman │ │ │ -00080880: 7469 6373 2061 7320 6d5f 6375 7273 6f72 tics as m_cursor │ │ │ -00080890: 2061 626f 7665 2e0a 0909 7069 6563 655f above....piece_ │ │ │ -000808a0: 696e 6465 785f 7420 6d5f 7265 7665 7273 index_t m_revers │ │ │ -000808b0: 655f 6375 7273 6f72 7b30 7d3b 0a0a 0909 e_cursor{0};.... │ │ │ -000808c0: 2f2f 2074 6865 206e 756d 6265 7220 6f66 // the number of │ │ │ -000808d0: 2070 6965 6365 7320 7765 2068 6176 6520 pieces we have │ │ │ -000808e0: 2869 2e65 2e20 7061 7373 6564 2068 6173 (i.e. passed has │ │ │ -000808f0: 6820 6368 6563 6b29 2e0a 0909 2f2f 2054 h check)....// T │ │ │ -00080900: 6869 7320 696e 636c 7564 6573 2070 6965 his includes pie │ │ │ -00080910: 6365 7320 7468 6174 2077 6520 6861 7665 ces that we have │ │ │ -00080920: 2066 696c 7465 7265 6420 6275 7420 7374 filtered but st │ │ │ -00080930: 696c 6c20 6861 7665 0a09 0969 6e74 206d ill have...int m │ │ │ -00080940: 5f6e 756d 5f68 6176 6520 3d20 303b 0a0a _num_have = 0;.. │ │ │ -00080950: 0909 2f2f 2069 6620 7468 6973 2069 7320 ..// if this is │ │ │ -00080960: 7365 7420 746f 2074 7275 652c 2069 7420 set to true, it │ │ │ -00080970: 6d65 616e 7320 7570 6461 7465 5f70 6965 means update_pie │ │ │ -00080980: 6365 7328 290a 0909 2f2f 2068 6173 2074 ces()...// has t │ │ │ -00080990: 6f20 6265 2063 616c 6c65 6420 6265 666f o be called befo │ │ │ -000809a0: 7265 2061 6363 6573 7369 6e67 206d 5f70 re accessing m_p │ │ │ -000809b0: 6965 6365 732e 0a3c 2f70 7265 3e3c 2f74 ieces..
    relevanc │ │ │ -000809f0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ -00080a30: 746f 7272 656e 742f 6175 785f 2f74 6f72 torrent/aux_/tor │ │ │ -00080a40: 7265 6e74 2e68 7070 3a32 3532 3c2f 613e rent.hpp:252 │ │ │ -00080a50: 3c2f 7464 3e3c 7464 3e6d 616b 6520 7468 make th │ │ │ -00080a60: 6973 2061 2072 6177 2070 6f69 6e74 6572 is a raw pointer │ │ │ -00080a70: 2e20 7065 7268 6170 7320 6b65 6570 2074 . perhaps keep t │ │ │ -00080a80: 6865 2073 6861 7265 645f 7074 7220 6172 he shared_ptr ar │ │ │ -00080a90: 6f75 6e64 2066 7572 7468 6572 2064 6f77 ound further dow │ │ │ -00080aa0: 6e20 7468 6520 6f62 6a65 6374 2074 6f20 n the object to │ │ │ -00080ab0: 6d61 696e 7461 696e 2061 6e20 6f77 6e65 maintain an owne │ │ │ -00080ac0: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    m │ │ │ -00080b10: 616b 6520 7468 6973 2061 2072 6177 2070 ake this a raw p │ │ │ -00080b20: 6f69 6e74 6572 2e20 7065 7268 6170 7320 ointer. perhaps │ │ │ -00080b30: 6b65 6570 2074 6865 2073 6861 7265 645f keep the shared_ │ │ │ -00080b40: 7074 720a 6172 6f75 6e64 2066 7572 7468 ptr.around furth │ │ │ -00080b50: 6572 2064 6f77 6e20 7468 6520 6f62 6a65 er down the obje │ │ │ -00080b60: 6374 2074 6f20 6d61 696e 7461 696e 2061 ct to maintain a │ │ │ -00080b70: 6e20 6f77 6e65 723c 2f68 323e 3c68 343e n owner

    │ │ │ -00080b80: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00080b90: 7272 656e 742f 6175 785f 2f74 6f72 7265 rrent/aux_/torre │ │ │ -00080ba0: 6e74 2e68 7070 3a32 3532 3c2f 6834 3e3c nt.hpp:252

    < │ │ │ -00080bb0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00080bc0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00080bd0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00080be0: 7820 2364 6464 3b22 3e23 656e 6469 660a x #ddd;">#endif. │ │ │ -00080bf0: 097d 3b0a 0a09 7374 7275 6374 2054 4f52 .};...struct TOR │ │ │ -00080c00: 5245 4e54 5f45 5854 5241 5f45 5850 4f52 RENT_EXTRA_EXPOR │ │ │ -00080c10: 5420 746f 7272 656e 745f 686f 745f 6d65 T torrent_hot_me │ │ │ -00080c20: 6d62 6572 730a 097b 0a09 0974 6f72 7265 mbers..{...torre │ │ │ -00080c30: 6e74 5f68 6f74 5f6d 656d 6265 7273 2861 nt_hot_members(a │ │ │ -00080c40: 7578 3a3a 7365 7373 696f 6e5f 696e 7465 ux::session_inte │ │ │ -00080c50: 7266 6163 6526 616d 703b 2073 6573 0a09 rface& ses.. │ │ │ -00080c60: 0909 2c20 6164 645f 746f 7272 656e 745f .., add_torrent_ │ │ │ -00080c70: 7061 7261 6d73 2063 6f6e 7374 2661 6d70 params const& │ │ │ -00080c80: 3b20 702c 2062 6f6f 6c20 7365 7373 696f ; p, bool sessio │ │ │ -00080c90: 6e5f 7061 7573 6564 293b 0a0a 0970 726f n_paused);...pro │ │ │ -00080ca0: 7465 6374 6564 3a0a 0909 2f2f 2074 6865 tected:...// the │ │ │ -00080cb0: 2070 6965 6365 2070 6963 6b65 722e 2054 piece picker. T │ │ │ -00080cc0: 6869 7320 6973 2061 6c6c 6f63 6174 6564 his is allocated │ │ │ -00080cd0: 206c 617a 696c 792e 2057 6865 6e20 7765 lazily. When we │ │ │ -00080ce0: 2064 6f6e 2774 0a09 092f 2f20 6861 7665 don't...// have │ │ │ -00080cf0: 2061 6e79 7468 696e 6720 696e 2074 6865 anything in the │ │ │ -00080d00: 2074 6f72 7265 6e74 2028 666f 7220 696e torrent (for in │ │ │ -00080d10: 7374 616e 6365 2c20 6966 2069 7420 6861 stance, if it ha │ │ │ -00080d20: 736e 2774 0a09 092f 2f20 6265 656e 2073 sn't...// been s │ │ │ -00080d30: 7461 7274 6564 2079 6574 2920 6f72 2069 tarted yet) or i │ │ │ -00080d40: 6620 7765 2068 6176 6520 6576 6572 7974 f we have everyt │ │ │ -00080d50: 6869 6e67 2c20 7468 6572 6520 6973 206e hing, there is n │ │ │ -00080d60: 6f0a 0909 2f2f 2070 6963 6b65 722e 2049 o...// picker. I │ │ │ -00080d70: 7427 7320 616c 6c6f 6361 7465 6420 6f6e t's allocated on │ │ │ -00080d80: 2d64 656d 616e 6420 7468 6520 6669 7273 -demand the firs │ │ │ -00080d90: 7420 7469 6d65 2077 6520 6e65 6564 0a09 t time we need.. │ │ │ -00080da0: 092f 2f20 6974 2069 6e20 746f 7272 656e .// it in torren │ │ │ -00080db0: 743a 3a6e 6565 645f 7069 636b 6572 2829 t::need_picker() │ │ │ -00080dc0: 2e20 496e 206f 7264 6572 2074 6f20 7465 . In order to te │ │ │ -00080dd0: 6c6c 2074 6865 0a09 092f 2f20 6469 6666 ll the...// diff │ │ │ -00080de0: 6572 656e 6365 2062 6574 7765 656e 2068 erence between h │ │ │ -00080df0: 6176 696e 6720 6576 6572 7974 6869 6e67 aving everything │ │ │ -00080e00: 2061 6e64 206e 6f74 6869 6e67 2069 6e0a and nothing in. │ │ │ -00080e10: 0909 2f2f 2074 6865 2063 6173 6520 7468 ..// the case th │ │ │ -00080e20: 6572 6520 6973 206e 6f20 7069 6563 6520 ere is no piece │ │ │ -00080e30: 7069 636b 6572 2c20 7365 6520 6d5f 6861 picker, see m_ha │ │ │ -00080e40: 7665 5f61 6c6c 2e0a 0909 7374 643a 3a75 ve_all....std::u │ │ │ -00080e50: 6e69 7175 655f 7074 7226 6c74 3b70 6965 nique_ptr<pie │ │ │ -00080e60: 6365 5f70 6963 6b65 7226 6774 3b20 6d5f ce_picker> m_ │ │ │ -00080e70: 7069 636b 6572 3b0a 0a09 0973 7464 3a3a picker;....std:: │ │ │ -00080e80: 756e 6971 7565 5f70 7472 266c 743b 6861 unique_ptr<ha │ │ │ -00080e90: 7368 5f70 6963 6b65 7226 6774 3b20 6d5f sh_picker> m_ │ │ │ -00080ea0: 6861 7368 5f70 6963 6b65 723b 0a0a 3c64 hash_picker;..#if │ │ │ -00080ee0: 544f 5252 454e 545f 4142 495f 5645 5253 TORRENT_ABI_VERS │ │ │ -00080ef0: 494f 4e20 266c 743b 2034 0a3c 2f64 6976 ION < 4...std::shared_p │ │ │ -00080f10: 7472 266c 743b 746f 7272 656e 745f 696e tr<torrent_in │ │ │ -00080f20: 666f 2667 743b 206d 5f74 6f72 7265 6e74 fo> m_torrent │ │ │ -00080f30: 5f66 696c 653b 0a23 656c 7365 0a09 0973 _file;.#else...s │ │ │ -00080f40: 7464 3a3a 7368 6172 6564 5f70 7472 266c td::shared_ptr&l │ │ │ -00080f50: 743b 746f 7272 656e 745f 696e 666f 2063 t;torrent_info c │ │ │ -00080f60: 6f6e 7374 2667 743b 206d 5f74 6f72 7265 onst> m_torre │ │ │ -00080f70: 6e74 5f66 696c 653b 0a23 656e 6469 660a nt_file;.#endif. │ │ │ -00080f80: 0909 7265 6e61 6d65 645f 6669 6c65 7320 ..renamed_files │ │ │ -00080f90: 6d5f 7265 6e61 6d65 645f 6669 6c65 733b m_renamed_files; │ │ │ -00080fa0: 0a0a 0909 2f2f 2054 6869 7320 6973 2074 ....// This is t │ │ │ -00080fb0: 6865 2073 756d 206f 6620 616c 6c20 6e6f he sum of all no │ │ │ -00080fc0: 6e2d 7061 6420 6669 6c65 2073 697a 6573 n-pad file sizes │ │ │ -00080fd0: 2e20 496e 2074 6865 206e 6578 7420 6d61 . In the next ma │ │ │ -00080fe0: 6a6f 7220 7665 7273 696f 6e0a 0909 2f2f jor version...// │ │ │ -00080ff0: 2074 6869 7320 6973 2073 746f 7265 6420 this is stored │ │ │ -00081000: 696e 2066 696c 655f 7374 6f72 6167 6520 in file_storage │ │ │ -00081010: 616e 6420 6e6f 206c 6f6e 6765 7220 6e65 and no longer ne │ │ │ -00081020: 6564 2074 6f20 6265 206b 6570 7420 6865 ed to be kept he │ │ │ -00081030: 7265 2e0a 0909 7374 643a 3a69 6e74 3634 re....std::int64 │ │ │ -00081040: 5f74 206d 5f73 697a 655f 6f6e 5f64 6973 _t m_size_on_dis │ │ │ -00081050: 6b20 3d20 303b 0a0a 0909 2f2f 2061 2062 k = 0;....// a b │ │ │ -00081060: 6163 6b20 7265 6665 7265 6e63 6520 746f ack reference to │ │ │ -00081070: 2074 6865 2073 6573 7369 6f6e 0a09 092f the session.../ │ │ │ -00081080: 2f20 7468 6973 2074 6f72 7265 6e74 2062 / this torrent b │ │ │ -00081090: 656c 6f6e 6773 2074 6f2e 0a09 0961 7578 elongs to....aux │ │ │ -000810a0: 3a3a 7365 7373 696f 6e5f 696e 7465 7266 ::session_interf │ │ │ -000810b0: 6163 6526 616d 703b 206d 5f73 6573 3b0a ace& m_ses;. │ │ │ -000810c0: 0a09 092f 2f20 7468 6973 2076 6563 746f ...// this vecto │ │ │ -000810d0: 7220 6973 2073 6f72 7465 6420 6174 2061 r is sorted at a │ │ │ -000810e0: 6c6c 2074 696d 6573 2c20 6279 2074 6865 ll times, by the │ │ │ -000810f0: 2070 6f69 6e74 6572 2076 616c 7565 2e0a pointer value.. │ │ │ -00081100: 0909 2f2f 2075 7365 2073 6f72 7465 645f ..// use sorted_ │ │ │ -00081110: 696e 7365 7274 2829 2061 6e64 2073 6f72 insert() and sor │ │ │ -00081120: 7465 645f 6669 6e64 2829 206f 6e20 6974 ted_find() on it │ │ │ -00081130: 2e20 5468 6520 474e 5520 5354 4c0a 0909 . The GNU STL... │ │ │ -00081140: 2f2f 2069 6d70 6c65 6d65 6e74 6174 696f // implementatio │ │ │ -00081150: 6e20 6f6e 2044 6172 7769 6e20 7573 6573 n on Darwin uses │ │ │ -00081160: 2073 6967 6e69 6669 6361 6e74 6c79 206c significantly l │ │ │ -00081170: 6573 7320 6d65 6d6f 7279 2074 6f0a 0909 ess memory to... │ │ │ -00081180: 2f2f 2072 6570 7265 7365 6e74 2061 2076 // represent a v │ │ │ -00081190: 6563 746f 7220 7468 616e 2061 2073 6574 ector than a set │ │ │ -000811a0: 2c20 616e 6420 7468 6973 2073 6574 2069 , and this set i │ │ │ -000811b0: 7320 7479 7069 6361 6c6c 790a 0909 2f2f s typically...// │ │ │ -000811c0: 2072 656c 6174 6976 656c 7920 736d 616c relatively smal │ │ │ -000811d0: 6c2c 2061 6e64 2069 7427 7320 6368 6561 l, and it's chea │ │ │ -000811e0: 7020 746f 2063 6f70 7920 706f 696e 7465 p to copy pointe │ │ │ -000811f0: 7273 2e0a 0909 6175 783a 3a76 6563 746f rs....aux::vecto │ │ │ -00081200: 7226 6c74 3b70 6565 725f 636f 6e6e 6563 r<peer_connec │ │ │ -00081210: 7469 6f6e 2a26 6774 3b20 6d5f 636f 6e6e tion*> m_conn │ │ │ -00081220: 6563 7469 6f6e 733b 0a0a 0909 2f2f 2074 ections;....// t │ │ │ -00081230: 6865 2073 6372 6170 6520 6461 7461 2066 he scrape data f │ │ │ -00081240: 726f 6d20 7468 6520 7472 6163 6b65 7220 rom the tracker │ │ │ -00081250: 7265 7370 6f6e 7365 2c20 7468 6973 0a09 response, this.. │ │ │ -00081260: 092f 2f20 6973 206f 7074 696f 6e61 6c20 .// is optional │ │ │ -00081270: 616e 6420 6d61 7920 6265 2030 7866 6666 and may be 0xfff │ │ │ -00081280: 6666 660a 0909 7374 643a 3a75 696e 7433 fff...std::uint3 │ │ │ -00081290: 325f 7420 6d5f 636f 6d70 6c65 7465 3a32 2_t m_complete:2 │ │ │ -000812a0: 343b 0a0a 0909 2f2f 2073 6574 2074 6f20 4;....// set to │ │ │ -000812b0: 7472 7565 2077 6865 6e20 7468 6973 2074 true when this t │ │ │ -000812c0: 6f72 7265 6e74 206d 6179 206e 6f74 2064 orrent may not d │ │ │ -000812d0: 6f77 6e6c 6f61 6420 616e 7974 6869 6e67 ownload anything │ │ │ -000812e0: 0a09 0973 7464 3a3a 7569 6e74 3332 5f74 ...std::uint32_t │ │ │ -000812f0: 206d 5f75 706c 6f61 645f 6d6f 6465 3a31 m_upload_mode:1 │ │ │ -00081300: 3b0a 0a09 092f 2f20 7468 6973 2069 7320 ;....// this is │ │ │ -00081310: 7365 7420 746f 2066 616c 7365 2061 7320 set to false as │ │ │ -00081320: 6c6f 6e67 2061 7320 7468 6520 636f 6e6e long as the conn │ │ │ -00081330: 6563 7469 6f6e 730a 0909 2f2f 206f 6620 ections...// of │ │ │ -00081340: 7468 6973 2074 6f72 7265 6e74 2068 6176 this torrent hav │ │ │ -00081350: 656e 2774 2062 6565 6e20 696e 6974 6961 en't been initia │ │ │ -00081360: 6c69 7a65 642e 2049 6620 7765 0a3c 2f70 lized. If we.

    re │ │ │ -000813a0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ -000813e0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -000813f0: 785f 2f74 6f72 7265 6e74 2e68 7070 3a34 x_/torrent.hpp:4 │ │ │ -00081400: 3434 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 44m │ │ │ -00081410: 616b 6520 6772 6163 6566 756c 2070 6175 ake graceful pau │ │ │ -00081420: 7365 2061 6c73 6f20 6669 6e69 7368 2061 se also finish a │ │ │ -00081430: 6c6c 2073 656e 6469 6e67 2062 6c6f 636b ll sending block │ │ │ -00081440: 7320 6265 666f 7265 2064 6973 636f 6e6e s before disconn │ │ │ -00081450: 6563 7469 6e67 3c2f 7464 3e3c 2f74 723e ecting │ │ │ -00081460: 3c74 7220 6964 3d22 3239 3522 2073 7479 │ │ │ -00081490: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -000814a0: 3c68 323e 6d61 6b65 2067 7261 6365 6675

    make gracefu │ │ │ -000814b0: 6c20 7061 7573 6520 616c 736f 2066 696e l pause also fin │ │ │ -000814c0: 6973 6820 616c 6c20 7365 6e64 696e 6720 ish all sending │ │ │ -000814d0: 626c 6f63 6b73 0a62 6566 6f72 6520 6469 blocks.before di │ │ │ -000814e0: 7363 6f6e 6e65 6374 696e 673c 2f68 323e sconnecting

    │ │ │ -000814f0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00081500: 6962 746f 7272 656e 742f 6175 785f 2f74 ibtorrent/aux_/t │ │ │ -00081510: 6f72 7265 6e74 2e68 7070 3a34 3434 3c2f orrent.hpp:444
    ...
    │ │ │ -00081560: 766f 6964 206f 6e5f 7265 7375 6d65 5f64  void on_resume_d
    │ │ │ -00081570: 6174 615f 6368 6563 6b65 6428 7374 6174  ata_checked(stat
    │ │ │ -00081580: 7573 5f74 2073 7461 7475 732c 2073 746f  us_t status, sto
    │ │ │ -00081590: 7261 6765 5f65 7272 6f72 2063 6f6e 7374  rage_error const
    │ │ │ -000815a0: 2661 6d70 3b20 6572 726f 7229 3b0a 0909  & error);...
    │ │ │ -000815b0: 766f 6964 206f 6e5f 666f 7263 655f 7265  void on_force_re
    │ │ │ -000815c0: 6368 6563 6b28 7374 6174 7573 5f74 2073  check(status_t s
    │ │ │ -000815d0: 7461 7475 732c 2073 746f 7261 6765 5f65  tatus, storage_e
    │ │ │ -000815e0: 7272 6f72 2063 6f6e 7374 2661 6d70 3b20  rror const& 
    │ │ │ -000815f0: 6572 726f 7229 3b0a 0909 766f 6964 206f  error);...void o
    │ │ │ -00081600: 6e5f 7069 6563 655f 6861 7368 6564 2861  n_piece_hashed(a
    │ │ │ -00081610: 7578 3a3a 7665 6374 6f72 266c 743b 7368  ux::vector<sh
    │ │ │ -00081620: 6132 3536 5f68 6173 6826 6774 3b20 626c  a256_hash> bl
    │ │ │ -00081630: 6f63 6b5f 6861 7368 6573 0a09 0909 2c20  ock_hashes...., 
    │ │ │ -00081640: 7069 6563 655f 696e 6465 785f 7420 7069  piece_index_t pi
    │ │ │ -00081650: 6563 652c 2073 6861 315f 6861 7368 2063  ece, sha1_hash c
    │ │ │ -00081660: 6f6e 7374 2661 6d70 3b20 7069 6563 655f  onst& piece_
    │ │ │ -00081670: 6861 7368 0a09 0909 2c20 7374 6f72 6167  hash...., storag
    │ │ │ -00081680: 655f 6572 726f 7220 636f 6e73 7426 616d  e_error const&am
    │ │ │ -00081690: 703b 2065 7272 6f72 293b 0a09 0976 6f69  p; error);...voi
    │ │ │ -000816a0: 6420 6669 6c65 735f 6368 6563 6b65 6428  d files_checked(
    │ │ │ -000816b0: 293b 0a09 0976 6f69 6420 7374 6172 745f  );...void start_
    │ │ │ -000816c0: 6368 6563 6b69 6e67 2829 3b0a 0a09 0976  checking();....v
    │ │ │ -000816d0: 6f69 6420 7374 6172 745f 616e 6e6f 756e  oid start_announ
    │ │ │ -000816e0: 6369 6e67 2829 3b0a 0909 766f 6964 2073  cing();...void s
    │ │ │ -000816f0: 746f 705f 616e 6e6f 756e 6369 6e67 2829  top_announcing()
    │ │ │ -00081700: 3b0a 0a09 0976 6f69 6420 7365 6e64 5f75  ;....void send_u
    │ │ │ -00081710: 706c 6f61 645f 6f6e 6c79 2829 3b0a 0a23  pload_only();..#
    │ │ │ -00081720: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -00081730: 4953 4142 4c45 5f53 4841 5245 5f4d 4f44  ISABLE_SHARE_MOD
    │ │ │ -00081740: 450a 0909 766f 6964 2073 656e 645f 7368  E...void send_sh
    │ │ │ -00081750: 6172 655f 6d6f 6465 2829 3b0a 0909 766f  are_mode();...vo
    │ │ │ -00081760: 6964 2073 6574 5f73 6861 7265 5f6d 6f64  id set_share_mod
    │ │ │ -00081770: 6528 626f 6f6c 2073 293b 0a09 0962 6f6f  e(bool s);...boo
    │ │ │ -00081780: 6c20 7368 6172 655f 6d6f 6465 2829 2063  l share_mode() c
    │ │ │ -00081790: 6f6e 7374 207b 2072 6574 7572 6e20 6d5f  onst { return m_
    │ │ │ -000817a0: 7368 6172 655f 6d6f 6465 3b20 7d0a 2365  share_mode; }.#e
    │ │ │ -000817b0: 6e64 6966 0a0a 3c64 6976 2073 7479 6c65  ndif..
    ..bool grace │ │ │ -000817f0: 6675 6c5f 7061 7573 6528 2920 636f 6e73 ful_pause() cons │ │ │ -00081800: 7420 7b20 7265 7475 726e 206d 5f67 7261 t { return m_gra │ │ │ -00081810: 6365 6675 6c5f 7061 7573 655f 6d6f 6465 ceful_pause_mode │ │ │ -00081820: 3b20 7d0a 3c2f 6469 763e 0a09 0974 6f72 ; }.
    ...tor │ │ │ -00081830: 7265 6e74 5f66 6c61 6773 5f74 2066 6c61 rent_flags_t fla │ │ │ -00081840: 6773 2829 2063 6f6e 7374 3b0a 0909 766f gs() const;...vo │ │ │ -00081850: 6964 2073 6574 5f66 6c61 6773 2874 6f72 id set_flags(tor │ │ │ -00081860: 7265 6e74 5f66 6c61 6773 5f74 2066 6c61 rent_flags_t fla │ │ │ -00081870: 6773 2c20 746f 7272 656e 745f 666c 6167 gs, torrent_flag │ │ │ -00081880: 735f 7420 6d61 736b 293b 0a0a 0909 766f s_t mask);....vo │ │ │ -00081890: 6964 2073 6574 5f75 706c 6f61 645f 6d6f id set_upload_mo │ │ │ -000818a0: 6465 2862 6f6f 6c20 6229 3b0a 0909 626f de(bool b);...bo │ │ │ -000818b0: 6f6c 2075 706c 6f61 645f 6d6f 6465 2829 ol upload_mode() │ │ │ -000818c0: 2063 6f6e 7374 207b 2072 6574 7572 6e20 const { return │ │ │ -000818d0: 6d5f 7570 6c6f 6164 5f6d 6f64 6520 7c7c m_upload_mode || │ │ │ -000818e0: 206d 5f67 7261 6365 6675 6c5f 7061 7573 m_graceful_paus │ │ │ -000818f0: 655f 6d6f 6465 3b20 7d0a 0909 626f 6f6c e_mode; }...bool │ │ │ -00081900: 2069 735f 7570 6c6f 6164 5f6f 6e6c 7928 is_upload_only( │ │ │ -00081910: 2920 636f 6e73 7420 7b20 7265 7475 726e ) const { return │ │ │ -00081920: 2069 735f 6669 6e69 7368 6564 2829 207c is_finished() | │ │ │ -00081930: 7c20 7570 6c6f 6164 5f6d 6f64 6528 293b | upload_mode(); │ │ │ -00081940: 207d 0a0a 0909 696e 7420 7365 6564 5f72 }....int seed_r │ │ │ -00081950: 616e 6b28 6175 783a 3a73 6573 7369 6f6e ank(aux::session │ │ │ -00081960: 5f73 6574 7469 6e67 7320 636f 6e73 7426 _settings const& │ │ │ -00081970: 616d 703b 2073 2920 636f 6e73 743b 0a0a amp; s) const;.. │ │ │ -00081980: 0909 766f 6964 2061 6464 5f70 6965 6365 ..void add_piece │ │ │ -00081990: 2870 6965 6365 5f69 6e64 6578 5f74 2070 (piece_index_t p │ │ │ -000819a0: 6965 6365 2c20 6368 6172 2063 6f6e 7374 iece, char const │ │ │ -000819b0: 2a20 6461 7461 2c20 6164 645f 7069 6563 * data, add_piec │ │ │ -000819c0: 655f 666c 6167 735f 7420 666c 6167 7329 e_flags_t flags) │ │ │ -000819d0: 3b0a 0909 766f 6964 2061 6464 5f70 6965 ;...void add_pie │ │ │ -000819e0: 6365 5f61 7379 6e63 2870 6965 6365 5f69 ce_async(piece_i │ │ │ -000819f0: 6e64 6578 5f74 2070 6965 6365 2c20 7374 ndex_t piece, st │ │ │ -00081a00: 643a 3a76 6563 746f 7226 6c74 3b63 6861 d::vector<cha │ │ │ -00081a10: 7226 6774 3b20 6461 7461 2c20 6164 645f r> data, add_ │ │ │ -00081a20: 7069 6563 655f 666c 6167 735f 7420 666c piece_flags_t fl │ │ │ -00081a30: 6167 7329 3b0a 0909 766f 6964 206f 6e5f ags);...void on_ │ │ │ -00081a40: 6469 736b 5f77 7269 7465 5f63 6f6d 706c disk_write_compl │ │ │ -00081a50: 6574 6528 7374 6f72 6167 655f 6572 726f ete(storage_erro │ │ │ -00081a60: 7220 636f 6e73 7426 616d 703b 2065 7272 r const& err │ │ │ -00081a70: 6f72 0a09 0909 2c20 7065 6572 5f72 6571 or...., peer_req │ │ │ -00081a80: 7565 7374 2063 6f6e 7374 2661 6d70 3b20 uest const& │ │ │ -00081a90: 7029 3b0a 0a09 0976 6f69 6420 7365 745f p);....void set_ │ │ │ -00081aa0: 7072 6f67 7265 7373 5f70 706d 2869 6e74 progress_ppm(int │ │ │ -00081ab0: 2070 2920 7b20 6d5f 7072 6f67 7265 7373 p) { m_progress │ │ │ -00081ac0: 5f70 706d 203d 2073 7464 3a3a 7569 6e74 _ppm = std::uint │ │ │ -00081ad0: 3332 5f74 2870 293b 207d 0a09 0973 7472 32_t(p); }...str │ │ │ -00081ae0: 7563 7420 7265 6164 5f70 6965 6365 5f73 uct read_piece_s │ │ │ -00081af0: 7472 7563 740a 0909 7b0a 0909 0962 6f6f truct...{....boo │ │ │ -00081b00: 7374 3a3a 7368 6172 6564 5f61 7272 6179 st::shared_array │ │ │ -00081b10: 266c 743b 6368 6172 2667 743b 2070 6965 <char> pie │ │ │ -00081b20: 6365 5f64 6174 613b 0a09 0909 696e 7420 ce_data;....int │ │ │ -00081b30: 626c 6f63 6b73 5f6c 6566 743b 0a09 0909 blocks_left;.... │ │ │ -00081b40: 626f 6f6c 2066 6169 6c3b 0a09 0909 6572 bool fail;....er │ │ │ -00081b50: 726f 725f 636f 6465 2065 7272 6f72 3b0a ror_code error;. │ │ │ -00081b60: 0909 7d3b 0a09 0976 6f69 6420 7265 6164 ..};...void read │ │ │ -00081b70: 5f70 6965 6365 2870 6965 6365 5f69 6e64 _piece(piece_ind │ │ │ -00081b80: 6578 5f74 293b 0a09 0976 6f69 6420 7365 ex_t);...void se │ │ │ -00081b90: 745f 7365 7175 656e 7469 616c 5f72 616e t_sequential_ran │ │ │ -00081ba0: 6765 2870 6965 6365 5f69 6e64 6578 5f74 ge(piece_index_t │ │ │ -00081bb0: 2066 6972 7374 5f70 6965 6365 2c20 7069 first_piece, pi │ │ │ -00081bc0: 6563 655f 696e 6465 785f 7420 6c61 7374 ece_index_t last │ │ │ -00081bd0: 5f70 6965 6365 293b 0a09 0976 6f69 6420 _piece);...void │ │ │ -00081be0: 7365 745f 7365 7175 656e 7469 616c 5f72 set_sequential_r │ │ │ -00081bf0: 616e 6765 2870 6965 6365 5f69 6e64 6578 ange(piece_index │ │ │ -00081c00: 5f74 2066 6972 7374 5f70 6965 6365 293b _t first_piece); │ │ │ -00081c10: 0a09 0976 6f69 6420 6f6e 5f64 6973 6b5f ...void on_disk_ │ │ │ -00081c20: 7265 6164 5f63 6f6d 706c 6574 6528 6469 read_complete(di │ │ │ -00081c30: 736b 5f62 7566 6665 725f 686f 6c64 6572 sk_buffer_holder │ │ │ -00081c40: 2c20 7374 6f72 6167 655f 6572 726f 7220 , storage_error │ │ │ -00081c50: 636f 6e73 7426 616d 703b 0a09 0909 2c20 const&...., │ │ │ -00081c60: 7065 6572 5f72 6571 7565 7374 2063 6f6e peer_request con │ │ │ -00081c70: 7374 2661 6d70 3b2c 2073 7464 3a3a 7368 st&, std::sh │ │ │ -00081c80: 6172 6564 5f70 7472 266c 743b 7265 6164 ared_ptr<read │ │ │ -00081c90: 5f70 6965 6365 5f73 7472 7563 7426 6774 _piece_struct> │ │ │ -00081ca0: 3b29 3b0a 0a09 0973 746f 7261 6765 5f6d ;);....storage_m │ │ │ -00081cb0: 6f64 655f 7420 7374 6f72 6167 655f 6d6f ode_t storage_mo │ │ │ -00081cc0: 6465 2829 2063 6f6e 7374 3b0a 3c2f 7072 de() const;.rel │ │ │ -00081d00: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -00081d40: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -00081d50: 5f2f 746f 7272 656e 742e 6870 703a 3134 _/torrent.hpp:14 │ │ │ -00081d60: 3333 3c2f 613e 3c2f 7464 3e3c 7464 3e74 33t │ │ │ -00081d70: 6869 7320 7761 7374 6573 2035 2062 6974 his wastes 5 bit │ │ │ -00081d80: 7320 7065 7220 6669 6c65 3c2f 7464 3e3c s per file< │ │ │ -00081d90: 2f74 723e 3c74 7220 6964 3d22 3239 3622 /tr>

    this was │ │ │ -00081de0: 7465 7320 3520 6269 7473 2070 6572 2066 tes 5 bits per f │ │ │ -00081df0: 696c 653c 2f68 323e 3c68 343e 2e2e 2f69 ile

    ../i │ │ │ -00081e00: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00081e10: 742f 6175 785f 2f74 6f72 7265 6e74 2e68 t/aux_/torrent.h │ │ │ -00081e20: 7070 3a31 3433 333c 2f68 343e 3c70 7265 pp:1433

    #ifndef TO
    │ │ │ -00081e70: 5252 454e 545f 4449 5341 424c 455f 4558  RRENT_DISABLE_EX
    │ │ │ -00081e80: 5445 4e53 494f 4e53 0a09 0973 7464 3a3a  TENSIONS...std::
    │ │ │ -00081e90: 6c69 7374 266c 743b 7374 643a 3a73 6861  list<std::sha
    │ │ │ -00081ea0: 7265 645f 7074 7226 6c74 3b74 6f72 7265  red_ptr<torre
    │ │ │ -00081eb0: 6e74 5f70 6c75 6769 6e26 6774 3b26 6774  nt_plugin>>
    │ │ │ -00081ec0: 3b20 6d5f 6578 7465 6e73 696f 6e73 3b0a  ; m_extensions;.
    │ │ │ -00081ed0: 2365 6e64 6966 0a0a 0909 2f2f 2075 7365  #endif....// use
    │ │ │ -00081ee0: 6420 666f 7220 7472 6163 6b65 7220 616e  d for tracker an
    │ │ │ -00081ef0: 6e6f 756e 6365 730a 0909 6465 6164 6c69  nounces...deadli
    │ │ │ -00081f00: 6e65 5f74 696d 6572 206d 5f74 7261 636b  ne_timer m_track
    │ │ │ -00081f10: 6572 5f74 696d 6572 3b0a 0a09 092f 2f20  er_timer;....// 
    │ │ │ -00081f20: 7573 6564 2074 6f20 6465 7465 6374 2077  used to detect w
    │ │ │ -00081f30: 6865 6e20 7765 2061 7265 2061 6374 6976  hen we are activ
    │ │ │ -00081f40: 6520 6f72 2069 6e61 6374 6976 6520 666f  e or inactive fo
    │ │ │ -00081f50: 7220 6c6f 6e67 2065 6e6f 7567 680a 0909  r long enough...
    │ │ │ -00081f60: 2f2f 2074 6f20 7472 6967 6765 7220 7468  // to trigger th
    │ │ │ -00081f70: 6520 6175 746f 2d6d 616e 6167 6520 6c6f  e auto-manage lo
    │ │ │ -00081f80: 6769 630a 0909 6465 6164 6c69 6e65 5f74  gic...deadline_t
    │ │ │ -00081f90: 696d 6572 206d 5f69 6e61 6374 6976 6974  imer m_inactivit
    │ │ │ -00081fa0: 795f 7469 6d65 723b 0a0a 0909 2f2f 2074  y_timer;....// t
    │ │ │ -00081fb0: 6869 7320 6973 2074 6865 2075 706c 6f61  his is the uploa
    │ │ │ -00081fc0: 6420 616e 6420 646f 776e 6c6f 6164 2073  d and download s
    │ │ │ -00081fd0: 7461 7469 7374 6963 7320 666f 7220 7468  tatistics for th
    │ │ │ -00081fe0: 6520 7768 6f6c 6520 746f 7272 656e 742e  e whole torrent.
    │ │ │ -00081ff0: 0a09 092f 2f20 6974 2773 2075 7064 6174  ...// it's updat
    │ │ │ -00082000: 6564 2066 726f 6d20 616c 6c20 6974 7320  ed from all its 
    │ │ │ -00082010: 7065 6572 7320 6f6e 6365 2065 7665 7279  peers once every
    │ │ │ -00082020: 2073 6563 6f6e 642e 0a09 0973 7461 7420   second....stat 
    │ │ │ -00082030: 6d5f 7374 6174 3b0a 0a09 092f 2f20 2d2d  m_stat;....// --
    │ │ │ -00082040: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00082050: 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0a09 092f  -----------..../
    │ │ │ -00082060: 2f20 7468 6973 2076 6563 746f 7220 6973  / this vector is
    │ │ │ -00082070: 2061 6c6c 6f63 6174 6564 206c 617a 696c   allocated lazil
    │ │ │ -00082080: 792e 2049 6620 6e6f 2066 696c 6520 7072  y. If no file pr
    │ │ │ -00082090: 696f 7269 7469 6573 2061 7265 0a09 092f  iorities are.../
    │ │ │ -000820a0: 2f20 6576 6572 2063 6861 6e67 6564 2c20  / ever changed, 
    │ │ │ -000820b0: 7468 6973 2072 656d 6169 6e73 2065 6d70  this remains emp
    │ │ │ -000820c0: 7479 2e20 416e 7920 756e 616c 6c6f 6361  ty. Any unalloca
    │ │ │ -000820d0: 7465 6420 736c 6f74 0a09 092f 2f20 696d  ted slot...// im
    │ │ │ -000820e0: 706c 6963 6974 6c79 206d 6561 6e73 2074  plicitly means t
    │ │ │ -000820f0: 6865 2066 696c 6520 6861 7320 7072 696f  he file has prio
    │ │ │ -00082100: 7269 7479 2034 2e0a 3c64 6976 2073 7479  rity 4..
    ..aux::vec │ │ │ -00082140: 746f 7226 6c74 3b64 6f77 6e6c 6f61 645f tor<download_ │ │ │ -00082150: 7072 696f 7269 7479 5f74 2c20 6669 6c65 priority_t, file │ │ │ -00082160: 5f69 6e64 6578 5f74 2667 743b 206d 5f66 _index_t> m_f │ │ │ -00082170: 696c 655f 7072 696f 7269 7479 3b0a 3c2f ile_priority;....// any fi │ │ │ -00082190: 6c65 2070 7269 6f72 6974 7920 7570 6461 le priority upda │ │ │ -000821a0: 7465 7320 6174 7465 6d70 7465 6420 7768 tes attempted wh │ │ │ -000821b0: 696c 6520 616e 6f74 6865 7220 6669 6c65 ile another file │ │ │ -000821c0: 2070 7269 6f72 6974 7920 7570 6461 7465 priority update │ │ │ -000821d0: 0a09 092f 2f20 6973 2069 6e2d 7072 6f67 ...// is in-prog │ │ │ -000821e0: 7265 7373 2f6f 7574 7374 616e 6469 6e67 ress/outstanding │ │ │ -000821f0: 2077 6974 6820 7468 6520 6469 736b 2049 with the disk I │ │ │ -00082200: 2f4f 2074 6872 6561 642c 2061 7265 2071 /O thread, are q │ │ │ -00082210: 7565 7565 6420 7570 2069 6e0a 0909 2f2f ueued up in...// │ │ │ -00082220: 2074 6869 7320 6469 6374 696f 6e61 7279 this dictionary │ │ │ -00082230: 2e20 4f6e 6365 2074 6865 206f 7574 7374 . Once the outst │ │ │ -00082240: 616e 6469 6e67 2075 7064 6174 6520 636f anding update co │ │ │ -00082250: 6d65 7320 6261 636b 2c20 616c 6c20 6f66 mes back, all of │ │ │ -00082260: 2074 6865 7365 0a09 092f 2f20 6172 6520 these...// are │ │ │ -00082270: 6170 706c 6965 6420 696e 206f 6e65 2062 applied in one b │ │ │ -00082280: 6174 6368 0a09 0973 7464 3a3a 6d61 7026 atch...std::map& │ │ │ -00082290: 6c74 3b66 696c 655f 696e 6465 785f 742c lt;file_index_t, │ │ │ -000822a0: 2064 6f77 6e6c 6f61 645f 7072 696f 7269 download_priori │ │ │ -000822b0: 7479 5f74 2667 743b 206d 5f64 6566 6572 ty_t> m_defer │ │ │ -000822c0: 7265 645f 6669 6c65 5f70 7269 6f72 6974 red_file_priorit │ │ │ -000822d0: 6965 733b 0a0a 0909 2f2f 2074 6869 7320 ies;....// this │ │ │ -000822e0: 6f62 6a65 6374 2069 7320 7573 6564 2074 object is used t │ │ │ -000822f0: 6f20 7472 6163 6b20 646f 776e 6c6f 6164 o track download │ │ │ -00082300: 2070 726f 6772 6573 7320 6f66 2069 6e64 progress of ind │ │ │ -00082310: 6976 6964 7561 6c20 6669 6c65 730a 0909 ividual files... │ │ │ -00082320: 6175 783a 3a66 696c 655f 7072 6f67 7265 aux::file_progre │ │ │ -00082330: 7373 206d 5f66 696c 655f 7072 6f67 7265 ss m_file_progre │ │ │ -00082340: 7373 3b0a 0a09 092f 2f20 6120 7175 6575 ss;....// a queu │ │ │ -00082350: 6520 6f66 2074 6865 206d 6f73 7420 7265 e of the most re │ │ │ -00082360: 6365 6e74 206c 6f77 2d61 7661 696c 6162 cent low-availab │ │ │ -00082370: 696c 6974 7920 7069 6563 6573 2077 6520 ility pieces we │ │ │ -00082380: 6163 6365 7373 6564 206f 6e20 6469 736b accessed on disk │ │ │ -00082390: 2e0a 0909 2f2f 2054 6865 7365 2061 7265 ....// These are │ │ │ -000823a0: 2067 6f6f 6420 6361 6e64 6964 6174 6573 good candidates │ │ │ -000823b0: 2066 6f72 2073 7567 6765 7374 696e 6720 for suggesting │ │ │ -000823c0: 6f74 6865 7220 7065 6572 7320 746f 2072 other peers to r │ │ │ -000823d0: 6571 7565 7374 2066 726f 6d0a 0909 2f2f equest from...// │ │ │ -000823e0: 2075 732e 0a09 0961 7578 3a3a 7375 6767 us....aux::sugg │ │ │ -000823f0: 6573 745f 7069 6563 6520 6d5f 7375 6767 est_piece m_sugg │ │ │ -00082400: 6573 745f 7069 6563 6573 3b0a 0a09 0961 est_pieces;....a │ │ │ -00082410: 7578 3a3a 7472 6163 6b65 725f 6c69 7374 ux::tracker_list │ │ │ -00082420: 206d 5f74 7261 636b 6572 733b 0a0a 2369 m_trackers;..#i │ │ │ -00082430: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ -00082440: 5341 424c 455f 5354 5245 414d 494e 470a SABLE_STREAMING. │ │ │ -00082450: 0909 2f2f 2074 6869 7320 6c69 7374 2069 ..// this list i │ │ │ -00082460: 7320 736f 7274 6564 2062 7920 7469 6d65 s sorted by time │ │ │ -00082470: 5f63 7269 7469 6361 6c5f 7069 6563 653a _critical_piece: │ │ │ -00082480: 3a64 6561 646c 696e 650a 0909 7374 643a :deadline...std: │ │ │ -00082490: 3a76 6563 746f 7226 6c74 3b74 696d 655f :vector<time_ │ │ │ -000824a0: 6372 6974 6963 616c 5f70 6965 6365 2667 critical_piece&g │ │ │ -000824b0: 743b 206d 5f74 696d 655f 6372 6974 6963 t; m_time_critic │ │ │ -000824c0: 616c 5f70 6965 6365 733b 0a23 656e 6469 al_pieces;.#endi │ │ │ -000824d0: 660a 0a09 0973 7464 3a3a 7374 7269 6e67 f....std::string │ │ │ -000824e0: 206d 5f74 7261 636b 6572 6964 3b0a 2369 m_trackerid;.#i │ │ │ -000824f0: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ -00082500: 5253 494f 4e20 3d3d 2031 0a09 092f 2f20 RSION == 1...// │ │ │ -00082510: 6465 7072 6563 6174 6564 2069 6e20 312e deprecated in 1. │ │ │ -00082520: 310a 0909 7374 643a 3a73 7472 696e 6720 1...std::string │ │ │ -00082530: 6d5f 7573 6572 6e61 6d65 3b0a 0909 7374 m_username;...st │ │ │ -00082540: 643a 3a73 7472 696e 6720 6d5f 7061 7373 d::string m_pass │ │ │ -00082550: 776f 7264 3b0a 2365 6e64 6966 0a0a 0909 word;.#endif.... │ │ │ -00082560: 7374 643a 3a73 7472 696e 6720 6d5f 7361 std::string m_sa │ │ │ -00082570: 7665 5f70 6174 683b 0a3c 2f70 7265 3e3c ve_path;.
    < │ │ │ -00082580: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000825b0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000825c0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/l │ │ │ -000825f0: 6962 746f 7272 656e 742f 6175 785f 2f74 ibtorrent/aux_/t │ │ │ -00082600: 6f72 7265 6e74 2e68 7070 3a31 3736 353c orrent.hpp:1765< │ │ │ -00082610: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ -00082620: 206d 656d 6265 7220 6361 6e20 7072 6f62 member can prob │ │ │ -00082630: 6162 6c79 2062 6520 7265 6d6f 7665 643c ably be removed< │ │ │ -00082640: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    thi │ │ │ -00082690: 7320 6d65 6d62 6572 2063 616e 2070 726f s member can pro │ │ │ -000826a0: 6261 626c 7920 6265 2072 656d 6f76 6564 bably be removed │ │ │ -000826b0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -000826c0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -000826d0: 7578 5f2f 746f 7272 656e 742e 6870 703a ux_/torrent.hpp: │ │ │ -000826e0: 3137 3635 3c2f 6834 3e3c 7072 6520 7374 1765

    ...// 4 unuse
    │ │ │ -00082730: 6420 6269 7473 0a0a 0909 2f2f 2077 6865  d bits....// whe
    │ │ │ -00082740: 6e20 7468 6973 2069 7320 7472 7565 2c20  n this is true, 
    │ │ │ -00082750: 7468 6973 2074 6f72 7265 6e74 2073 7570  this torrent sup
    │ │ │ -00082760: 706f 7274 7320 7065 6572 2065 7863 6861  ports peer excha
    │ │ │ -00082770: 6e67 650a 0909 7374 643a 3a75 696e 7433  nge...std::uint3
    │ │ │ -00082780: 325f 7420 6d5f 656e 6162 6c65 5f70 6578  2_t m_enable_pex
    │ │ │ -00082790: 3a31 3b0a 0a09 092f 2f20 7365 7420 746f  :1;....// set to
    │ │ │ -000827a0: 2074 7275 6520 6966 2074 6865 2073 6573   true if the ses
    │ │ │ -000827b0: 7369 6f6e 2049 5020 6669 6c74 6572 2061  sion IP filter a
    │ │ │ -000827c0: 7070 6c69 6573 2074 6f20 7468 6973 0a09  pplies to this..
    │ │ │ -000827d0: 092f 2f20 746f 7272 656e 7420 6f72 206e  .// torrent or n
    │ │ │ -000827e0: 6f74 2e20 4465 6661 756c 7473 2074 6f20  ot. Defaults to 
    │ │ │ -000827f0: 7472 7565 2e0a 0909 7374 643a 3a75 696e  true....std::uin
    │ │ │ -00082800: 7433 325f 7420 6d5f 6170 706c 795f 6970  t32_t m_apply_ip
    │ │ │ -00082810: 5f66 696c 7465 723a 313b 0a0a 0909 2f2f  _filter:1;....//
    │ │ │ -00082820: 2074 6869 7320 6973 2074 7275 6520 7768   this is true wh
    │ │ │ -00082830: 656e 206f 7572 2065 6666 6563 7469 7665  en our effective
    │ │ │ -00082840: 2069 6e61 6374 6976 6520 7374 6174 6520   inactive state 
    │ │ │ -00082850: 6973 2064 6966 6665 7265 6e74 2066 726f  is different fro
    │ │ │ -00082860: 6d20 6f75 720a 0909 2f2f 2061 6374 7561  m our...// actua
    │ │ │ -00082870: 6c20 696e 6163 7469 7665 2073 7461 7465  l inactive state
    │ │ │ -00082880: 2e20 5768 656e 6576 6572 2074 6869 7320  . Whenever this 
    │ │ │ -00082890: 7374 6174 6520 6368 616e 6765 732c 2074  state changes, t
    │ │ │ -000828a0: 6865 7265 2069 7320 610a 0909 2f2f 2071  here is a...// q
    │ │ │ -000828b0: 7561 7261 6e74 696e 6520 7065 7269 6f64  uarantine period
    │ │ │ -000828c0: 2075 6e74 696c 2077 6520 6368 616e 6765   until we change
    │ │ │ -000828d0: 2074 6865 2065 6666 6563 7469 7665 2073   the effective s
    │ │ │ -000828e0: 7461 7465 2e20 5468 6973 2069 7320 746f  tate. This is to
    │ │ │ -000828f0: 2061 766f 6964 0a09 092f 2f20 666c 6170   avoid...// flap
    │ │ │ -00082900: 7069 6e67 2e20 4966 2074 6865 2073 7461  ping. If the sta
    │ │ │ -00082910: 7465 2063 6861 6e67 6573 2062 6163 6b20  te changes back 
    │ │ │ -00082920: 6475 7269 6e67 2074 6869 7320 7065 7269  during this peri
    │ │ │ -00082930: 6f64 2c20 7765 2063 616e 6365 6c20 7468  od, we cancel th
    │ │ │ -00082940: 650a 0909 2f2f 2071 7561 7261 6e74 696e  e...// quarantin
    │ │ │ -00082950: 650a 0909 7374 643a 3a75 696e 7433 325f  e...std::uint32_
    │ │ │ -00082960: 7420 6d5f 7065 6e64 696e 675f 6163 7469  t m_pending_acti
    │ │ │ -00082970: 7665 5f63 6861 6e67 653a 313b 0a0a 2369  ve_change:1;..#i
    │ │ │ -00082980: 6620 544f 5252 454e 545f 4142 495f 5645  f TORRENT_ABI_VE
    │ │ │ -00082990: 5253 494f 4e20 266c 743b 2034 0a09 092f  RSION < 4.../
    │ │ │ -000829a0: 2f20 7468 6973 2069 7320 7365 7420 746f  / this is set to
    │ │ │ -000829b0: 2074 7275 6520 6966 2061 6c6c 2070 6965   true if all pie
    │ │ │ -000829c0: 6365 206c 6179 6572 7320 7765 7265 2073  ce layers were s
    │ │ │ -000829d0: 7563 6365 7373 6675 6c6c 7920 6c6f 6164  uccessfully load
    │ │ │ -000829e0: 6564 2061 6e64 0a09 092f 2f20 7661 6c69  ed and...// vali
    │ │ │ -000829f0: 6461 7465 642e 204f 6e6c 7920 666f 7220  dated. Only for 
    │ │ │ -00082a00: 7632 2074 6f72 7265 6e74 730a 3c64 6976  v2 torrents.
    ..std: │ │ │ -00082a40: 3a75 696e 7433 325f 7420 6d5f 7632 5f70 :uint32_t m_v2_p │ │ │ -00082a50: 6965 6365 5f6c 6179 6572 735f 7661 6c69 iece_layers_vali │ │ │ -00082a60: 6461 7465 643a 313b 0a3c 2f64 6976 3e23 dated:1;.
    # │ │ │ -00082a70: 656e 6469 660a 0a2f 2f20 2d2d 2d2d 0a0a endif..// ----.. │ │ │ -00082a80: 0909 2f2f 2074 6869 7320 6973 2073 6574 ..// this is set │ │ │ -00082a90: 2074 6f20 7468 6520 636f 6e6e 6563 7420 to the connect │ │ │ -00082aa0: 626f 6f73 7420 7175 6f74 6120 666f 7220 boost quota for │ │ │ -00082ab0: 7468 6973 2074 6f72 7265 6e74 2e0a 0909 this torrent.... │ │ │ -00082ac0: 2f2f 2041 6674 6572 2068 6176 696e 6720 // After having │ │ │ -00082ad0: 7265 6365 6976 6564 2074 6869 7320 6d61 received this ma │ │ │ -00082ae0: 6e79 2070 7269 6f72 6974 7920 7065 6572 ny priority peer │ │ │ -00082af0: 2063 6f6e 6e65 6374 696f 6e20 6174 7465 connection atte │ │ │ -00082b00: 6d70 7473 2c20 6974 0a09 092f 2f20 6661 mpts, it...// fa │ │ │ -00082b10: 6c6c 7320 6261 636b 206f 6e74 6f20 7468 lls back onto th │ │ │ -00082b20: 6520 7374 6561 6479 2073 7461 7465 2070 e steady state p │ │ │ -00082b30: 6565 7220 636f 6e6e 6563 7469 6f6e 206c eer connection l │ │ │ -00082b40: 6f67 6963 2c20 6472 6976 656e 2062 7920 ogic, driven by │ │ │ -00082b50: 7468 650a 0909 2f2f 2073 6573 7369 6f6e the...// session │ │ │ -00082b60: 2074 6963 6b2e 2045 6163 6820 7472 6163 tick. Each trac │ │ │ -00082b70: 6b65 7220 7265 7370 6f6e 7365 2c20 6173 ker response, as │ │ │ -00082b80: 206c 6f6e 6720 6173 2074 6869 7320 6973 long as this is │ │ │ -00082b90: 206e 6f6e 2d7a 6572 6f2c 2077 696c 6c0a non-zero, will. │ │ │ -00082ba0: 0909 2f2f 2061 7474 656d 7074 2074 6f20 ..// attempt to │ │ │ -00082bb0: 636f 6e6e 6563 7420 746f 2070 6565 7273 connect to peers │ │ │ -00082bc0: 2069 6d6d 6564 6961 7465 6c79 2061 6e64 immediately and │ │ │ -00082bd0: 2064 6563 7265 6d65 6e74 2074 6865 2063 decrement the c │ │ │ -00082be0: 6f75 6e74 6572 2e0a 0909 2f2f 2057 6520 ounter....// We │ │ │ -00082bf0: 6769 7665 2074 6f72 7265 6e74 7320 6120 give torrents a │ │ │ -00082c00: 636f 6e6e 6563 7420 626f 6f73 7420 7768 connect boost wh │ │ │ -00082c10: 656e 2074 6865 7920 6172 6520 6669 7273 en they are firs │ │ │ -00082c20: 7420 6164 6465 6420 616e 6420 7468 656e t added and then │ │ │ -00082c30: 0a09 092f 2f20 6576 6572 7920 7469 6d65 ...// every time │ │ │ -00082c40: 2074 6865 7920 7265 7375 6d65 2066 726f they resume fro │ │ │ -00082c50: 6d20 6265 696e 6720 7061 7573 6564 2e0a m being paused.. │ │ │ -00082c60: 0909 7374 643a 3a75 696e 7438 5f74 206d ..std::uint8_t m │ │ │ -00082c70: 5f63 6f6e 6e65 6374 5f62 6f6f 7374 5f63 _connect_boost_c │ │ │ -00082c80: 6f75 6e74 6572 3b0a 0a2f 2f20 2d2d 2d2d ounter;..// ---- │ │ │ -00082c90: 0a0a 0909 2f2f 2074 6865 2073 6372 6170 ....// the scrap │ │ │ -00082ca0: 6520 6461 7461 2066 726f 6d20 7468 6520 e data from the │ │ │ -00082cb0: 7472 6163 6b65 7220 7265 7370 6f6e 7365 tracker response │ │ │ -00082cc0: 2c20 7468 6973 0a09 092f 2f20 6973 206f , this...// is o │ │ │ -00082cd0: 7074 696f 6e61 6c20 616e 6420 6d61 7920 ptional and may │ │ │ -00082ce0: 6265 2030 7866 6666 6666 660a 0909 7374 be 0xffffff...st │ │ │ -00082cf0: 643a 3a75 696e 7433 325f 7420 6d5f 696e d::uint32_t m_in │ │ │ -00082d00: 636f 6d70 6c65 7465 3a32 343b 0a0a 0909 complete:24;.... │ │ │ -00082d10: 2f2f 2074 7275 6520 7768 656e 2074 6865 // true when the │ │ │ -00082d20: 2074 6f72 7265 6e74 2073 686f 756c 6420 torrent should │ │ │ -00082d30: 616e 6e6f 756e 6365 2074 6f0a 0909 2f2f announce to...// │ │ │ -00082d40: 2074 6865 2044 4854 0a09 0973 7464 3a3a the DHT...std:: │ │ │ -00082d50: 7569 6e74 3332 5f74 206d 5f61 6e6e 6f75 uint32_t m_annou │ │ │ -00082d60: 6e63 655f 746f 5f64 6874 3a31 3b0a 0a09 nce_to_dht:1;... │ │ │ -00082d70: 092f 2f20 6576 656e 2069 6620 7765 2772 .// even if we'r │ │ │ -00082d80: 6520 6e6f 7420 6275 696c 7420 746f 2073 e not built to s │ │ │ -00082d90: 7570 706f 7274 2053 534c 2074 6f72 7265 upport SSL torre │ │ │ -00082da0: 6e74 732c 0a09 092f 2f20 7265 6d65 6d62 nts,...// rememb │ │ │ -00082db0: 6572 2074 6861 7420 7468 6973 2069 7320 er that this is │ │ │ -00082dc0: 616e 2053 534c 2074 6f72 7265 6e74 2c20 an SSL torrent, │ │ │ -00082dd0: 736f 2074 6861 7420 7765 2064 6f6e 2774 so that we don't │ │ │ -00082de0: 0a09 092f 2f20 6163 6369 6465 6e74 616c ...// accidental │ │ │ -00082df0: 6c79 2073 7461 7274 2073 6565 6469 6e67 ly start seeding │ │ │ -00082e00: 2069 7420 7769 7468 6f75 7420 616e 7920 it without any │ │ │ -00082e10: 6175 7468 656e 7469 6361 7469 6f6e 2e0a authentication.. │ │ │ -00082e20: 0909 7374 643a 3a75 696e 7433 325f 7420 ..std::uint32_t │ │ │ -00082e30: 6d5f 7373 6c5f 746f 7272 656e 743a 313b m_ssl_torrent:1; │ │ │ -00082e40: 0a0a 0909 2f2f 2074 6869 7320 6973 2073 ....// this is s │ │ │ -00082e50: 6574 2074 6f20 7472 7565 2069 6620 7765 et to true if we │ │ │ -00082e60: 2772 6520 7472 7969 6e67 2074 6f20 6465 're trying to de │ │ │ -00082e70: 6c65 7465 2074 6865 0a09 092f 2f20 6669 lete the...// fi │ │ │ -00082e80: 6c65 7320 6265 6c6f 6e67 696e 6720 746f les belonging to │ │ │ -00082e90: 2069 742e 2057 6865 6e20 7365 742c 2064 it. When set, d │ │ │ -00082ea0: 6f6e 2774 2077 7269 7465 2061 6e79 0a3c on't write any.< │ │ │ -00082eb0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00082ec0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00082ed0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00082ee0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00082ef0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../inc │ │ │ -00082f20: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00082f30: 6175 785f 2f73 746f 7265 5f62 7566 6665 aux_/store_buffe │ │ │ -00082f40: 722e 6870 703a 3834 3c2f 613e 3c2f 7464 r.hpp:84it would be │ │ │ -00082f60: 206e 6963 6520 6966 2074 6869 7320 636f nice if this co │ │ │ -00082f70: 756c 6420 6265 2063 616c 6c65 6420 7769 uld be called wi │ │ │ -00082f80: 7468 6f75 7420 686f 6c64 696e 6720 7468 thout holding th │ │ │ -00082f90: 6520 6d75 7465 782e 2049 7420 776f 756c e mutex. It woul │ │ │ -00082fa0: 6420 7265 7175 6972 6520 6120 7265 6665 d require a refe │ │ │ -00082fb0: 7265 6e63 6520 636f 756e 7465 7220 6f6e rence counter on │ │ │ -00082fc0: 2074 6865 2073 746f 7265 2062 7566 6665 the store buffe │ │ │ -00082fd0: 7220 656e 7472 6965 7320 616e 6420 7468 r entries and th │ │ │ -00082fe0: 6174 2077 6520 706f 7465 6e74 6961 6c6c at we potentiall │ │ │ -00082ff0: 7920 6572 6173 6573 2069 7420 6166 7465 y erases it afte │ │ │ -00083000: 7220 7468 6973 2063 616c 6c2e 2069 7420 r this call. it │ │ │ -00083010: 776f 756c 6420 616c 736f 2072 6571 7569 would also requi │ │ │ -00083020: 7265 2074 6865 2073 746f 7265 2062 7566 re the store buf │ │ │ -00083030: 6665 7220 6265 696e 6720 6162 6c65 2074 fer being able t │ │ │ -00083040: 6f20 7461 6b65 206f 7665 7220 6f77 6e65 o take over owne │ │ │ -00083050: 7273 6869 7020 6f66 2074 6865 2062 7566 rship of the buf │ │ │ -00083060: 6665 7220 7768 656e 2074 6865 206f 776e fer when the own │ │ │ -00083070: 6572 2065 7261 7365 7320 6974 2e20 5065 er erases it. Pe │ │ │ -00083080: 7268 6170 7320 6572 6173 6528 2920 636f rhaps erase() co │ │ │ -00083090: 756c 6420 6265 206d 6164 6520 746f 2074 uld be made to t │ │ │ -000830a0: 616b 6520 6120 6275 6666 6572 5f68 6f6c ake a buffer_hol │ │ │ -000830b0: 6465 722c 2077 6869 6368 2069 7320 6865 der, which is he │ │ │ -000830c0: 6c64 206f 6e74 6f20 6966 2074 6865 2072 ld onto if the r │ │ │ -000830d0: 6566 636f 756e 7420 3e20 303c 2f74 643e efcount > 0 │ │ │ -000830e0: 3c2f 7472 3e3c 7472 2069 643d 2232 3938

    it woul │ │ │ -00083130: 6420 6265 206e 6963 6520 6966 2074 6869 d be nice if thi │ │ │ -00083140: 7320 636f 756c 6420 6265 2063 616c 6c65 s could be calle │ │ │ -00083150: 6420 7769 7468 6f75 7420 686f 6c64 696e d without holdin │ │ │ -00083160: 670a 7468 6520 6d75 7465 782e 2049 7420 g.the mutex. It │ │ │ -00083170: 776f 756c 6420 7265 7175 6972 6520 6120 would require a │ │ │ -00083180: 7265 6665 7265 6e63 6520 636f 756e 7465 reference counte │ │ │ -00083190: 7220 6f6e 2074 6865 2073 746f 7265 0a62 r on the store.b │ │ │ -000831a0: 7566 6665 7220 656e 7472 6965 7320 616e uffer entries an │ │ │ -000831b0: 6420 7468 6174 2077 6520 706f 7465 6e74 d that we potent │ │ │ -000831c0: 6961 6c6c 7920 6572 6173 6573 2069 7420 ially erases it │ │ │ -000831d0: 6166 7465 7220 7468 6973 2063 616c 6c2e after this call. │ │ │ -000831e0: 0a69 7420 776f 756c 6420 616c 736f 2072 .it would also r │ │ │ -000831f0: 6571 7569 7265 2074 6865 2073 746f 7265 equire the store │ │ │ -00083200: 2062 7566 6665 7220 6265 696e 6720 6162 buffer being ab │ │ │ -00083210: 6c65 2074 6f20 7461 6b65 206f 7665 720a le to take over. │ │ │ -00083220: 6f77 6e65 7273 6869 7020 6f66 2074 6865 ownership of the │ │ │ -00083230: 2062 7566 6665 7220 7768 656e 2074 6865 buffer when the │ │ │ -00083240: 206f 776e 6572 2065 7261 7365 7320 6974 owner erases it │ │ │ -00083250: 2e20 5065 7268 6170 7320 6572 6173 6528 . Perhaps erase( │ │ │ -00083260: 290a 636f 756c 6420 6265 206d 6164 6520 ).could be made │ │ │ -00083270: 746f 2074 616b 6520 6120 6275 6666 6572 to take a buffer │ │ │ -00083280: 5f68 6f6c 6465 722c 2077 6869 6368 2069 _holder, which i │ │ │ -00083290: 7320 6865 6c64 206f 6e74 6f20 6966 2074 s held onto if t │ │ │ -000832a0: 6865 0a72 6566 636f 756e 7420 3e20 303c he.refcount > 0< │ │ │ -000832b0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -000832c0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -000832d0: 785f 2f73 746f 7265 5f62 7566 6665 722e x_/store_buffer. │ │ │ -000832e0: 6870 703a 3834 3c2f 6834 3e3c 7072 6520 hpp:84

    }..namespac
    │ │ │ -00083330: 6520 6c69 6274 6f72 7265 6e74 207b 0a6e  e libtorrent {.n
    │ │ │ -00083340: 616d 6573 7061 6365 2061 7578 207b 0a0a  amespace aux {..
    │ │ │ -00083350: 7374 7275 6374 2073 746f 7265 5f62 7566  struct store_buf
    │ │ │ -00083360: 6665 720a 7b0a 0973 746f 7265 5f62 7566  fer.{..store_buf
    │ │ │ -00083370: 6665 7228 696f 5f63 6f6e 7465 7874 2661  fer(io_context&a
    │ │ │ -00083380: 6d70 3b20 696f 7329 203a 206d 5f62 6163  mp; ios) : m_bac
    │ │ │ -00083390: 6b5f 7072 6573 7375 7265 2869 6f73 2920  k_pressure(ios) 
    │ │ │ -000833a0: 7b7d 0a0a 0976 6f69 6420 7365 745f 6d61  {}...void set_ma
    │ │ │ -000833b0: 785f 7369 7a65 2869 6e74 2063 6f6e 7374  x_size(int const
    │ │ │ -000833c0: 206d 6178 5f73 697a 6529 207b 0a09 096d   max_size) {...m
    │ │ │ -000833d0: 5f62 6163 6b5f 7072 6573 7375 7265 2e73  _back_pressure.s
    │ │ │ -000833e0: 6574 5f6d 6178 5f73 697a 6528 6d61 785f  et_max_size(max_
    │ │ │ -000833f0: 7369 7a65 293b 0a09 7d0a 0a09 7465 6d70  size);..}...temp
    │ │ │ -00083400: 6c61 7465 2026 6c74 3b74 7970 656e 616d  late <typenam
    │ │ │ -00083410: 6520 4675 6e26 6774 3b0a 0962 6f6f 6c20  e Fun>..bool 
    │ │ │ -00083420: 6765 7428 746f 7272 656e 745f 6c6f 6361  get(torrent_loca
    │ │ │ -00083430: 7469 6f6e 2063 6f6e 7374 206c 6f63 2c20  tion const loc, 
    │ │ │ -00083440: 4675 6e20 6629 2063 6f6e 7374 0a09 7b0a  Fun f) const..{.
    │ │ │ -00083450: 0909 7374 643a 3a75 6e69 7175 655f 6c6f  ..std::unique_lo
    │ │ │ -00083460: 636b 266c 743b 7374 643a 3a6d 7574 6578  ck<std::mutex
    │ │ │ -00083470: 2667 743b 206c 286d 5f6d 7574 6578 293b  > l(m_mutex);
    │ │ │ -00083480: 0a09 0961 7574 6f20 636f 6e73 7420 6974  ...auto const it
    │ │ │ -00083490: 203d 206d 5f73 746f 7265 5f62 7566 6665   = m_store_buffe
    │ │ │ -000834a0: 722e 6669 6e64 286c 6f63 293b 0a09 0969  r.find(loc);...i
    │ │ │ -000834b0: 6620 2869 7420 213d 206d 5f73 746f 7265  f (it != m_store
    │ │ │ -000834c0: 5f62 7566 6665 722e 656e 6428 2929 0a09  _buffer.end())..
    │ │ │ -000834d0: 097b 0a3c 6469 7620 7374 796c 653d 2262  .{.
    ...f(it->sec │ │ │ -00083510: 6f6e 6429 3b0a 3c2f 6469 763e 0909 0972 ond);.
    ...r │ │ │ -00083520: 6574 7572 6e20 7472 7565 3b0a 0909 7d0a eturn true;...}. │ │ │ -00083530: 0909 7265 7475 726e 2066 616c 7365 3b0a ..return false;. │ │ │ -00083540: 097d 0a0a 0974 656d 706c 6174 6520 266c .}...template &l │ │ │ -00083550: 743b 7479 7065 6e61 6d65 2046 756e 2667 t;typename Fun&g │ │ │ -00083560: 743b 0a09 696e 7420 6765 7432 2874 6f72 t;..int get2(tor │ │ │ -00083570: 7265 6e74 5f6c 6f63 6174 696f 6e20 636f rent_location co │ │ │ -00083580: 6e73 7420 6c6f 6331 2c20 746f 7272 656e nst loc1, torren │ │ │ -00083590: 745f 6c6f 6361 7469 6f6e 2063 6f6e 7374 t_location const │ │ │ -000835a0: 206c 6f63 322c 2046 756e 2066 2920 636f loc2, Fun f) co │ │ │ -000835b0: 6e73 740a 097b 0a09 0973 7464 3a3a 756e nst..{...std::un │ │ │ -000835c0: 6971 7565 5f6c 6f63 6b26 6c74 3b73 7464 ique_lock<std │ │ │ -000835d0: 3a3a 6d75 7465 7826 6774 3b20 6c28 6d5f ::mutex> l(m_ │ │ │ -000835e0: 6d75 7465 7829 3b0a 0909 6175 746f 2063 mutex);...auto c │ │ │ -000835f0: 6f6e 7374 2069 7431 203d 206d 5f73 746f onst it1 = m_sto │ │ │ -00083600: 7265 5f62 7566 6665 722e 6669 6e64 286c re_buffer.find(l │ │ │ -00083610: 6f63 3129 3b0a 0909 6175 746f 2063 6f6e oc1);...auto con │ │ │ -00083620: 7374 2069 7432 203d 206d 5f73 746f 7265 st it2 = m_store │ │ │ -00083630: 5f62 7566 6665 722e 6669 6e64 286c 6f63 _buffer.find(loc │ │ │ -00083640: 3229 3b0a 0909 6368 6172 2063 6f6e 7374 2);...char const │ │ │ -00083650: 2a20 6275 6631 203d 2028 6974 3120 3d3d * buf1 = (it1 == │ │ │ -00083660: 206d 5f73 746f 7265 5f62 7566 6665 722e m_store_buffer. │ │ │ -00083670: 656e 6428 2929 203f 206e 756c 6c70 7472 end()) ? nullptr │ │ │ -00083680: 203a 2069 7431 2d26 6774 3b73 6563 6f6e : it1->secon │ │ │ -00083690: 643b 0a09 0963 6861 7220 636f 6e73 742a d;...char const* │ │ │ -000836a0: 2062 7566 3220 3d20 2869 7432 203d 3d20 buf2 = (it2 == │ │ │ -000836b0: 6d5f 7374 6f72 655f 6275 6666 6572 2e65 m_store_buffer.e │ │ │ -000836c0: 6e64 2829 2920 3f20 6e75 6c6c 7074 7220 nd()) ? nullptr │ │ │ -000836d0: 3a20 6974 322d 2667 743b 7365 636f 6e64 : it2->second │ │ │ -000836e0: 3b0a 0a09 0969 6620 2862 7566 3120 3d3d ;....if (buf1 == │ │ │ -000836f0: 206e 756c 6c70 7472 2026 616d 703b 2661 nullptr &&a │ │ │ -00083700: 6d70 3b20 6275 6632 203d 3d20 6e75 6c6c mp; buf2 == null │ │ │ -00083710: 7074 7229 0a09 0909 7265 7475 726e 2030 ptr)....return 0 │ │ │ -00083720: 3b0a 0a09 0972 6574 7572 6e20 6628 6275 ;....return f(bu │ │ │ -00083730: 6631 2c20 6275 6632 293b 0a09 7d0a 0a09 f1, buf2);..}... │ │ │ -00083740: 2f2f 2072 6574 7572 6e73 2074 7275 6520 // returns true │ │ │ -00083750: 6966 2074 6865 7265 2773 2062 6163 6b2d if there's back- │ │ │ -00083760: 7072 6573 7375 7265 0a09 626f 6f6c 2069 pressure..bool i │ │ │ -00083770: 6e73 6572 7428 746f 7272 656e 745f 6c6f nsert(torrent_lo │ │ │ -00083780: 6361 7469 6f6e 2063 6f6e 7374 206c 6f63 cation const loc │ │ │ -00083790: 2c20 6368 6172 2063 6f6e 7374 2a20 6275 , char const* bu │ │ │ -000837a0: 662c 2073 7464 3a3a 7368 6172 6564 5f70 f, std::shared_p │ │ │ -000837b0: 7472 266c 743b 6469 736b 5f6f 6273 6572 tr<disk_obser │ │ │ -000837c0: 7665 7226 6774 3b20 6f20 3d20 6e75 6c6c ver> o = null │ │ │ -000837d0: 7074 7229 0a09 7b0a 0909 7374 643a 3a6c ptr)..{...std::l │ │ │ -000837e0: 6f63 6b5f 6775 6172 6426 6c74 3b73 7464 ock_guard<std │ │ │ -000837f0: 3a3a 6d75 7465 7826 6774 3b20 6c28 6d5f ::mutex> l(m_ │ │ │ -00083800: 6d75 7465 7829 3b0a 0909 6d5f 7374 6f72 mutex);...m_stor │ │ │ -00083810: 655f 6275 6666 6572 2e69 6e73 6572 7428 e_buffer.insert( │ │ │ -00083820: 7b6c 6f63 2c20 6275 667d 293b 0a09 0972 {loc, buf});...r │ │ │ -00083830: 6574 7572 6e20 6d5f 6261 636b 5f70 7265 eturn m_back_pre │ │ │ -00083840: 7373 7572 652e 6861 735f 6261 636b 5f70 ssure.has_back_p │ │ │ -00083850: 7265 7373 7572 6528 7374 6174 6963 5f63 ressure(static_c │ │ │ -00083860: 6173 7426 6c74 3b69 6e74 2667 743b 286d ast<int>(m │ │ │ -00083870: 5f73 746f 7265 5f62 7566 6665 722e 7369 _store_buffer.si │ │ │ -00083880: 7a65 2829 292c 206f 293b 0a09 7d0a 0a09 ze()), o);..}... │ │ │ -00083890: 766f 6964 2065 7261 7365 2874 6f72 7265 void erase(torre │ │ │ -000838a0: 6e74 5f6c 6f63 6174 696f 6e20 636f 6e73 nt_location cons │ │ │ -000838b0: 7420 6c6f 6329 0a09 7b0a 3c2f 7072 653e t loc)..{.
    │ │ │ -000838c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -000838f0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00083900: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -00083930: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00083940: 616e 6e6f 756e 6365 5f65 6e74 7279 2e68 announce_entry.h │ │ │ -00083950: 7070 3a35 363c 2f61 3e3c 2f74 643e 3c74 pp:56include the nu │ │ │ -00083970: 6d62 6572 206f 6620 7065 6572 7320 7265 mber of peers re │ │ │ -00083980: 6365 6976 6564 2066 726f 6d20 7468 6973 ceived from this │ │ │ -00083990: 2074 7261 636b 6572 2c20 6174 206c 6173 tracker, at las │ │ │ -000839a0: 7420 616e 6e6f 756e 6365 3c2f 7464 3e3c t announce< │ │ │ -000839b0: 2f74 723e 3c74 7220 6964 3d22 3239 3922 /tr>

    include │ │ │ -00083a00: 7468 6520 6e75 6d62 6572 206f 6620 7065 the number of pe │ │ │ -00083a10: 6572 7320 7265 6365 6976 6564 2066 726f ers received fro │ │ │ -00083a20: 6d20 7468 6973 2074 7261 636b 6572 2c20 m this tracker, │ │ │ -00083a30: 6174 206c 6173 740a 616e 6e6f 756e 6365 at last.announce │ │ │ -00083a40: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -00083a50: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00083a60: 7578 5f2f 616e 6e6f 756e 6365 5f65 6e74 ux_/announce_ent │ │ │ -00083a70: 7279 2e68 7070 3a35 363c 2f68 343e 3c70 ry.hpp:56

    .struct │ │ │ -00083ac0: 746f 7272 656e 743b 0a0a 0973 7472 7563 torrent;...struc │ │ │ -00083ad0: 7420 544f 5252 454e 545f 4558 5452 415f t TORRENT_EXTRA_ │ │ │ -00083ae0: 4558 504f 5254 2061 6e6e 6f75 6e63 655f EXPORT announce_ │ │ │ -00083af0: 696e 666f 6861 7368 0a09 7b0a 0909 616e infohash..{...an │ │ │ -00083b00: 6e6f 756e 6365 5f69 6e66 6f68 6173 6828 nounce_infohash( │ │ │ -00083b10: 293b 0a0a 0909 2f2f 2069 6620 7468 6973 );....// if this │ │ │ -00083b20: 2074 7261 636b 6572 2068 6173 2072 6574 tracker has ret │ │ │ -00083b30: 7572 6e65 6420 616e 2065 7272 6f72 206f urned an error o │ │ │ -00083b40: 7220 7761 726e 696e 6720 6d65 7373 6167 r warning messag │ │ │ -00083b50: 650a 0909 2f2f 2074 6861 7420 6d65 7373 e...// that mess │ │ │ -00083b60: 6167 6520 6973 2073 746f 7265 6420 6865 age is stored he │ │ │ -00083b70: 7265 0a09 0973 7464 3a3a 7374 7269 6e67 re...std::string │ │ │ -00083b80: 206d 6573 7361 6765 3b0a 0a09 092f 2f20 message;....// │ │ │ -00083b90: 6966 2074 6869 7320 7472 6163 6b65 7220 if this tracker │ │ │ -00083ba0: 6661 696c 6564 2074 6865 206c 6173 7420 failed the last │ │ │ -00083bb0: 7469 6d65 2069 7420 7761 7320 636f 6e74 time it was cont │ │ │ -00083bc0: 6163 7465 640a 0909 2f2f 2074 6869 7320 acted...// this │ │ │ -00083bd0: 6572 726f 7220 636f 6465 2073 7065 6369 error code speci │ │ │ -00083be0: 6669 6573 2077 6861 7420 6572 726f 7220 fies what error │ │ │ -00083bf0: 6f63 6375 7272 6564 0a09 0965 7272 6f72 occurred...error │ │ │ -00083c00: 5f63 6f64 6520 6c61 7374 5f65 7272 6f72 _code last_error │ │ │ -00083c10: 3b0a 0a09 092f 2f20 7468 6520 7469 6d65 ;....// the time │ │ │ -00083c20: 206f 6620 6e65 7874 2074 7261 636b 6572 of next tracker │ │ │ -00083c30: 2061 6e6e 6f75 6e63 650a 0909 7469 6d65 announce...time │ │ │ -00083c40: 5f70 6f69 6e74 3332 206e 6578 745f 616e _point32 next_an │ │ │ -00083c50: 6e6f 756e 6365 203d 2028 7469 6d65 5f70 nounce = (time_p │ │ │ -00083c60: 6f69 6e74 3332 3a3a 6d69 6e29 2829 3b0a oint32::min)();. │ │ │ -00083c70: 0a09 092f 2f20 6e6f 2061 6e6e 6f75 6e63 ...// no announc │ │ │ -00083c80: 6573 2062 6566 6f72 6520 7468 6973 2074 es before this t │ │ │ -00083c90: 696d 650a 0909 7469 6d65 5f70 6f69 6e74 ime...time_point │ │ │ -00083ca0: 3332 206d 696e 5f61 6e6e 6f75 6e63 6520 32 min_announce │ │ │ -00083cb0: 3d20 2874 696d 655f 706f 696e 7433 323a = (time_point32: │ │ │ -00083cc0: 3a6d 696e 2928 293b 0a0a 3c64 6976 2073 :min)();..

    .
    . │ │ │ -00083d00: 092f 2f20 7468 6573 6520 6172 6520 6569 .// these are ei │ │ │ -00083d10: 7468 6572 202d 3120 6f72 2074 6865 2073 ther -1 or the s │ │ │ -00083d20: 6372 6170 6520 696e 666f 726d 6174 696f crape informatio │ │ │ -00083d30: 6e20 7468 6973 2074 7261 636b 6572 206c n this tracker l │ │ │ -00083d40: 6173 740a 0909 2f2f 2072 6573 706f 6e64 ast...// respond │ │ │ -00083d50: 6564 2077 6974 682e 202a 696e 636f 6d70 ed with. *incomp │ │ │ -00083d60: 6c65 7465 2a20 6973 2074 6865 2063 7572 lete* is the cur │ │ │ -00083d70: 7265 6e74 206e 756d 6265 7220 6f66 2064 rent number of d │ │ │ -00083d80: 6f77 6e6c 6f61 6465 7273 2069 6e0a 0909 ownloaders in... │ │ │ -00083d90: 2f2f 2074 6865 2073 7761 726d 2c20 2a63 // the swarm, *c │ │ │ -00083da0: 6f6d 706c 6574 652a 2069 7320 7468 6520 omplete* is the │ │ │ -00083db0: 6375 7272 656e 7420 6e75 6d62 6572 206f current number o │ │ │ -00083dc0: 6620 7365 6564 7320 696e 2074 6865 2073 f seeds in the s │ │ │ -00083dd0: 7761 726d 2061 6e64 0a09 092f 2f20 2a64 warm and...// *d │ │ │ -00083de0: 6f77 6e6c 6f61 6465 642a 2069 7320 7468 ownloaded* is th │ │ │ -00083df0: 6520 6375 6d75 6c61 7469 7665 206e 756d e cumulative num │ │ │ -00083e00: 6265 7220 6f66 2063 6f6d 706c 6574 6564 ber of completed │ │ │ -00083e10: 2064 6f77 6e6c 6f61 6473 206f 6620 7468 downloads of th │ │ │ -00083e20: 6973 0a09 092f 2f20 746f 7272 656e 742c is...// torrent, │ │ │ -00083e30: 2073 696e 6365 2074 6865 2062 6567 696e since the begin │ │ │ -00083e40: 6e69 6e67 206f 6620 7469 6d65 2028 6672 ning of time (fr │ │ │ -00083e50: 6f6d 2074 6869 7320 7472 6163 6b65 7227 om this tracker' │ │ │ -00083e60: 7320 706f 696e 7420 6f66 0a09 092f 2f20 s point of...// │ │ │ -00083e70: 7669 6577 292e 0a0a 0909 2f2f 2069 6620 view).....// if │ │ │ -00083e80: 7468 6973 2074 7261 636b 6572 2068 6173 this tracker has │ │ │ -00083e90: 2072 6574 7572 6e65 6420 7363 7261 7065 returned scrape │ │ │ -00083ea0: 2064 6174 612c 2074 6865 7365 2066 6965 data, these fie │ │ │ -00083eb0: 6c64 7320 6172 6520 6669 6c6c 6564 2069 lds are filled i │ │ │ -00083ec0: 6e0a 0909 2f2f 2077 6974 6820 7661 6c69 n...// with vali │ │ │ -00083ed0: 6420 6e75 6d62 6572 732e 204f 7468 6572 d numbers. Other │ │ │ -00083ee0: 7769 7365 2074 6865 7920 6172 6520 7365 wise they are se │ │ │ -00083ef0: 7420 746f 202d 312e 2060 6069 6e63 6f6d t to -1. ``incom │ │ │ -00083f00: 706c 6574 6560 6020 636f 756e 7473 0a09 plete`` counts.. │ │ │ -00083f10: 092f 2f20 7468 6520 6e75 6d62 6572 206f .// the number o │ │ │ -00083f20: 6620 6375 7272 656e 7420 646f 776e 6c6f f current downlo │ │ │ -00083f30: 6164 6572 732e 2060 6063 6f6d 706c 6574 aders. ``complet │ │ │ -00083f40: 6560 6020 636f 756e 7473 2074 6865 206e e`` counts the n │ │ │ -00083f50: 756d 6265 7220 6f66 0a09 092f 2f20 6375 umber of...// cu │ │ │ -00083f60: 7272 656e 7420 7065 6572 7320 636f 6d70 rrent peers comp │ │ │ -00083f70: 6c65 7465 6420 7468 6520 646f 776e 6c6f leted the downlo │ │ │ -00083f80: 6164 2c20 6f72 2022 7365 6564 7322 2e20 ad, or "seeds". │ │ │ -00083f90: 6060 646f 776e 6c6f 6164 6564 6060 2069 ``downloaded`` i │ │ │ -00083fa0: 7320 7468 650a 0909 2f2f 2063 756d 756c s the...// cumul │ │ │ -00083fb0: 6174 6976 6520 6e75 6d62 6572 206f 6620 ative number of │ │ │ -00083fc0: 636f 6d70 6c65 7465 6420 646f 776e 6c6f completed downlo │ │ │ -00083fd0: 6164 732e 0a09 0969 6e74 2073 6372 6170 ads....int scrap │ │ │ -00083fe0: 655f 696e 636f 6d70 6c65 7465 203d 202d e_incomplete = - │ │ │ -00083ff0: 313b 0a09 0969 6e74 2073 6372 6170 655f 1;...int scrape_ │ │ │ -00084000: 636f 6d70 6c65 7465 203d 202d 313b 0a09 complete = -1;.. │ │ │ -00084010: 0969 6e74 2073 6372 6170 655f 646f 776e .int scrape_down │ │ │ -00084020: 6c6f 6164 6564 203d 202d 313b 0a0a 0909 loaded = -1;.... │ │ │ -00084030: 2f2f 2074 6865 206e 756d 6265 7220 6f66 // the number of │ │ │ -00084040: 2074 696d 6573 2069 6e20 6120 726f 7720 times in a row │ │ │ -00084050: 7765 2068 6176 6520 6661 696c 6564 2074 we have failed t │ │ │ -00084060: 6f20 616e 6e6f 756e 6365 2074 6f20 7468 o announce to th │ │ │ -00084070: 6973 0a09 092f 2f20 7472 6163 6b65 722e is...// tracker. │ │ │ -00084080: 0a09 0973 7464 3a3a 7569 6e74 385f 7420 ...std::uint8_t │ │ │ -00084090: 6661 696c 7320 3a20 373b 0a0a 0909 2f2f fails : 7;....// │ │ │ -000840a0: 2074 7275 6520 7768 696c 6520 7765 2772 true while we'r │ │ │ -000840b0: 6520 7761 6974 696e 6720 666f 7220 6120 e waiting for a │ │ │ -000840c0: 7265 7370 6f6e 7365 2066 726f 6d20 7468 response from th │ │ │ -000840d0: 6520 7472 6163 6b65 722e 0a09 0962 6f6f e tracker....boo │ │ │ -000840e0: 6c20 7570 6461 7469 6e67 203a 2031 3b0a l updating : 1;. │ │ │ -000840f0: 0a09 092f 2f20 7365 7420 746f 2074 7275 ...// set to tru │ │ │ -00084100: 6520 7768 656e 2077 6520 6765 7420 6120 e when we get a │ │ │ -00084110: 7661 6c69 6420 7265 7370 6f6e 7365 2066 valid response f │ │ │ -00084120: 726f 6d20 616e 2061 6e6e 6f75 6e63 650a rom an announce. │ │ │ -00084130: 0909 2f2f 2077 6974 6820 6576 656e 743d ..// with event= │ │ │ -00084140: 7374 6172 7465 642e 2049 6620 6974 2069 started. If it i │ │ │ -00084150: 7320 7365 742c 2077 6520 776f 6e27 7420 s set, we won't │ │ │ -00084160: 7365 6e64 2073 7461 7274 2069 6e20 7468 send start in th │ │ │ -00084170: 6520 7375 6273 6571 7565 6e74 0a09 092f e subsequent.../ │ │ │ -00084180: 2f20 616e 6e6f 756e 6365 732e 0a09 0962 / announces....b │ │ │ -00084190: 6f6f 6c20 7374 6172 745f 7365 6e74 203a ool start_sent : │ │ │ -000841a0: 2031 3b0a 0a09 092f 2f20 7365 7420 746f 1;....// set to │ │ │ -000841b0: 2074 7275 6520 7768 656e 2077 6520 7365 true when we se │ │ │ -000841c0: 6e64 2061 2065 7665 6e74 3d63 6f6d 706c nd a event=compl │ │ │ -000841d0: 6574 6564 2e0a 0909 626f 6f6c 2063 6f6d eted....bool com │ │ │ -000841e0: 706c 6574 655f 7365 6e74 203a 2031 3b0a plete_sent : 1;. │ │ │ -000841f0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00084200: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00084230: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -00084260: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00084270: 2f61 7578 5f2f 7065 6572 5f63 6f6e 6e65 /aux_/peer_conne │ │ │ -00084280: 6374 696f 6e2e 6870 703a 3139 353c 2f61 ction.hpp:195make t │ │ │ -000842a0: 6869 7320 6120 7261 7720 706f 696e 7465 his a raw pointe │ │ │ -000842b0: 7220 2874 6f20 7361 7665 2073 697a 6520 r (to save size │ │ │ -000842c0: 696e 2074 6865 2066 6972 7374 2063 6163 in the first cac │ │ │ -000842d0: 6865 206c 696e 6529 2061 6e64 206d 616b he line) and mak │ │ │ -000842e0: 6520 7468 6520 636f 6e73 7472 7563 746f e the constructo │ │ │ -000842f0: 7220 7461 6b65 2061 2072 6177 2070 6f69 r take a raw poi │ │ │ -00084300: 6e74 6572 2e20 746f 7272 656e 7420 6f62 nter. torrent ob │ │ │ -00084310: 6a65 6374 7320 7368 6f75 6c64 2061 6c77 jects should alw │ │ │ -00084320: 6179 7320 6f75 746c 6976 6520 7468 6569 ays outlive thei │ │ │ -00084330: 7220 7065 6572 733c 2f74 643e 3c2f 7472 r peers

    make this a │ │ │ -00084390: 2072 6177 2070 6f69 6e74 6572 2028 746f raw pointer (to │ │ │ -000843a0: 2073 6176 6520 7369 7a65 2069 6e0a 7468 save size in.th │ │ │ -000843b0: 6520 6669 7273 7420 6361 6368 6520 6c69 e first cache li │ │ │ -000843c0: 6e65 2920 616e 6420 6d61 6b65 2074 6865 ne) and make the │ │ │ -000843d0: 2063 6f6e 7374 7275 6374 6f72 0a74 616b constructor.tak │ │ │ -000843e0: 6520 6120 7261 7720 706f 696e 7465 722e e a raw pointer. │ │ │ -000843f0: 2074 6f72 7265 6e74 206f 626a 6563 7473 torrent objects │ │ │ -00084400: 2073 686f 756c 6420 616c 7761 7973 0a6f should always.o │ │ │ -00084410: 7574 6c69 7665 2074 6865 6972 2070 6565 utlive their pee │ │ │ -00084420: 7273 3c2f 6832 3e3c 6834 3e2e 2e2f 696e rs

    ../in │ │ │ -00084430: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00084440: 2f61 7578 5f2f 7065 6572 5f63 6f6e 6e65 /aux_/peer_conne │ │ │ -00084450: 6374 696f 6e2e 6870 703a 3139 353c 2f68 ction.hpp:195
    ...,
    │ │ │ -000844a0: 206d 5f73 6e75 6262 6564 2866 616c 7365   m_snubbed(false
    │ │ │ -000844b0: 290a 0909 092c 206d 5f69 6e74 6572 6573  )...., m_interes
    │ │ │ -000844c0: 7469 6e67 2866 616c 7365 290a 0909 092c  ting(false)....,
    │ │ │ -000844d0: 206d 5f63 686f 6b65 6428 7472 7565 290a   m_choked(true).
    │ │ │ -000844e0: 0909 092c 206d 5f69 676e 6f72 655f 7374  ..., m_ignore_st
    │ │ │ -000844f0: 6174 7328 6661 6c73 6529 0a09 097b 7d0a  ats(false)...{}.
    │ │ │ -00084500: 0a09 092f 2f20 6578 706c 6963 6974 6c79  ...// explicitly
    │ │ │ -00084510: 2064 6973 616c 6c6f 7720 6173 7369 676e   disallow assign
    │ │ │ -00084520: 6d65 6e74 2c20 746f 2073 696c 656e 6365  ment, to silence
    │ │ │ -00084530: 206d 7376 6320 7761 726e 696e 670a 0909   msvc warning...
    │ │ │ -00084540: 7065 6572 5f63 6f6e 6e65 6374 696f 6e5f  peer_connection_
    │ │ │ -00084550: 686f 745f 6d65 6d62 6572 7326 616d 703b  hot_members&
    │ │ │ -00084560: 206f 7065 7261 746f 723d 2870 6565 725f   operator=(peer_
    │ │ │ -00084570: 636f 6e6e 6563 7469 6f6e 5f68 6f74 5f6d  connection_hot_m
    │ │ │ -00084580: 656d 6265 7273 2063 6f6e 7374 2661 6d70  embers const&
    │ │ │ -00084590: 3b29 203d 2064 656c 6574 653b 0a0a 0970  ;) = delete;...p
    │ │ │ -000845a0: 726f 7465 6374 6564 3a0a 0a09 092f 2f20  rotected:....// 
    │ │ │ -000845b0: 7468 6520 7069 6563 6573 2074 6865 206f  the pieces the o
    │ │ │ -000845c0: 7468 6572 2065 6e64 2068 6176 650a 0909  ther end have...
    │ │ │ -000845d0: 7479 7065 645f 6269 7466 6965 6c64 266c  typed_bitfield&l
    │ │ │ -000845e0: 743b 7069 6563 655f 696e 6465 785f 7426  t;piece_index_t&
    │ │ │ -000845f0: 6774 3b20 6d5f 6861 7665 5f70 6965 6365  gt; m_have_piece
    │ │ │ -00084600: 3b0a 0a09 092f 2f20 7468 6973 2069 7320  ;....// this is 
    │ │ │ -00084610: 7468 6520 746f 7272 656e 7420 7468 6973  the torrent this
    │ │ │ -00084620: 2063 6f6e 6e65 6374 696f 6e20 6973 0a09   connection is..
    │ │ │ -00084630: 092f 2f20 6173 736f 6369 6174 6564 2077  .// associated w
    │ │ │ -00084640: 6974 682e 2049 6620 7468 6520 636f 6e6e  ith. If the conn
    │ │ │ -00084650: 6563 7469 6f6e 2069 7320 616e 0a09 092f  ection is an.../
    │ │ │ -00084660: 2f20 696e 636f 6d69 6e67 2063 6f6e 6e65  / incoming conne
    │ │ │ -00084670: 6374 696f 6e2c 2074 6869 7320 6973 2073  ction, this is s
    │ │ │ -00084680: 6574 2074 6f20 7a65 726f 0a09 092f 2f20  et to zero...// 
    │ │ │ -00084690: 756e 7469 6c20 7468 6520 696e 666f 5f68  until the info_h
    │ │ │ -000846a0: 6173 6820 6973 2072 6563 6569 7665 642e  ash is received.
    │ │ │ -000846b0: 2054 6865 6e20 6974 2773 0a09 092f 2f20   Then it's...// 
    │ │ │ -000846c0: 7365 7420 746f 2074 6865 2074 6f72 7265  set to the torre
    │ │ │ -000846d0: 6e74 2069 7420 6265 6c6f 6e67 7320 746f  nt it belongs to
    │ │ │ -000846e0: 2e0a 0a3c 6469 7620 7374 796c 653d 2262  ...
    ..std::weak_ptr │ │ │ -00084720: 266c 743b 6175 783a 3a74 6f72 7265 6e74 <aux::torrent │ │ │ -00084730: 2667 743b 206d 5f74 6f72 7265 6e74 3b0a > m_torrent;. │ │ │ -00084740: 3c2f 6469 763e 0a09 7075 626c 6963 3a0a
    ..public:. │ │ │ -00084750: 0a09 092f 2f20 6120 6261 636b 2072 6566 ...// a back ref │ │ │ -00084760: 6572 656e 6365 2074 6f20 7468 6520 7365 erence to the se │ │ │ -00084770: 7373 696f 6e0a 0909 2f2f 2074 6865 2070 ssion...// the p │ │ │ -00084780: 6565 7220 6265 6c6f 6e67 7320 746f 2e0a eer belongs to.. │ │ │ -00084790: 0909 6175 783a 3a73 6573 7369 6f6e 5f69 ..aux::session_i │ │ │ -000847a0: 6e74 6572 6661 6365 2661 6d70 3b20 6d5f nterface& m_ │ │ │ -000847b0: 7365 733b 0a0a 0909 2f2f 2073 6574 7469 ses;....// setti │ │ │ -000847c0: 6e67 7320 7468 6174 2061 7070 6c79 2074 ngs that apply t │ │ │ -000847d0: 6f20 7468 6973 2070 6565 720a 0909 6175 o this peer...au │ │ │ -000847e0: 783a 3a73 6573 7369 6f6e 5f73 6574 7469 x::session_setti │ │ │ -000847f0: 6e67 7320 636f 6e73 7426 616d 703b 206d ngs const& m │ │ │ -00084800: 5f73 6574 7469 6e67 733b 0a0a 0970 726f _settings;...pro │ │ │ -00084810: 7465 6374 6564 3a0a 0a09 092f 2f20 7468 tected:....// th │ │ │ -00084820: 6973 2069 7320 7472 7565 2069 6620 7468 is is true if th │ │ │ -00084830: 6973 2063 6f6e 6e65 6374 696f 6e20 6861 is connection ha │ │ │ -00084840: 7320 6265 656e 2061 6464 6564 0a09 092f s been added.../ │ │ │ -00084850: 2f20 746f 2074 6865 206c 6973 7420 6f66 / to the list of │ │ │ -00084860: 2063 6f6e 6e65 6374 696f 6e73 2074 6861 connections tha │ │ │ -00084870: 7420 7769 6c6c 2062 6520 636c 6f73 6564 t will be closed │ │ │ -00084880: 2e0a 0909 626f 6f6c 206d 5f64 6973 636f ....bool m_disco │ │ │ -00084890: 6e6e 6563 7469 6e67 3a31 3b0a 0a09 092f nnecting:1;..../ │ │ │ -000848a0: 2f20 7468 6973 2069 7320 7472 7565 2075 / this is true u │ │ │ -000848b0: 6e74 696c 2074 6869 7320 736f 636b 6574 ntil this socket │ │ │ -000848c0: 2068 6173 2062 6563 6f6d 650a 0909 2f2f has become...// │ │ │ -000848d0: 2077 7269 7461 626c 6520 666f 7220 7468 writable for th │ │ │ -000848e0: 6520 6669 7273 7420 7469 6d65 2028 692e e first time (i. │ │ │ -000848f0: 652e 2074 6865 0a09 092f 2f20 636f 6e6e e. the...// conn │ │ │ -00084900: 6563 7469 6f6e 2063 6f6d 706c 6574 6564 ection completed │ │ │ -00084910: 292e 2057 6869 6c65 2063 6f6e 6e65 6374 ). While connect │ │ │ -00084920: 696e 670a 0909 2f2f 2074 6865 2074 696d ing...// the tim │ │ │ -00084930: 656f 7574 2077 696c 6c20 6e6f 7420 6265 eout will not be │ │ │ -00084940: 2074 7269 6767 6572 6564 2e20 5468 6973 triggered. This │ │ │ -00084950: 2069 730a 0909 2f2f 2062 6563 6175 7365 is...// because │ │ │ -00084960: 2077 696e 646f 7773 2058 5020 5350 3220 windows XP SP2 │ │ │ -00084970: 6d61 7920 6465 6c61 7920 636f 6e6e 6563 may delay connec │ │ │ -00084980: 7469 6f6e 0a09 092f 2f20 6174 7465 6d70 tion...// attemp │ │ │ -00084990: 7473 2c20 7768 6963 6820 6d65 616e 7320 ts, which means │ │ │ -000849a0: 7468 6174 2074 6865 2063 6f6e 6e65 6374 that the connect │ │ │ -000849b0: 696f 6e0a 0909 2f2f 206d 6179 206e 6f74 ion...// may not │ │ │ -000849c0: 2065 7665 6e20 6861 7665 2062 6565 6e20 even have been │ │ │ -000849d0: 6174 7465 6d70 7465 6420 7768 656e 2074 attempted when t │ │ │ -000849e0: 6865 0a09 092f 2f20 7469 6d65 206f 7574 he...// time out │ │ │ -000849f0: 2069 7320 7265 6163 6865 642e 0a09 0962 is reached....b │ │ │ -00084a00: 6f6f 6c20 6d5f 636f 6e6e 6563 7469 6e67 ool m_connecting │ │ │ -00084a10: 3a31 3b0a 0a09 092f 2f20 7468 6973 2069 :1;....// this i │ │ │ -00084a20: 7320 7365 7420 746f 2074 7275 6520 6966 s set to true if │ │ │ -00084a30: 2074 6865 206c 6173 7420 7469 6d65 2077 the last time w │ │ │ -00084a40: 6520 7472 6965 6420 746f 0a09 092f 2f20 e tried to...// │ │ │ -00084a50: 7069 636b 2061 2070 6965 6365 2074 6f20 pick a piece to │ │ │ -00084a60: 646f 776e 6c6f 6164 2c20 7765 2063 6f75 download, we cou │ │ │ -00084a70: 6c64 206f 6e6c 7920 6669 6e64 0a09 092f ld only find.../ │ │ │ -00084a80: 2f20 626c 6f63 6b73 2074 6861 7420 7765 / blocks that we │ │ │ -00084a90: 7265 2061 6c72 6561 6479 2072 6571 7565 re already reque │ │ │ -00084aa0: 7374 6564 2066 726f 6d20 6f74 6865 720a sted from other. │ │ │ -00084ab0: 0909 2f2f 2070 6565 7273 2e20 496e 2074 ..// peers. In t │ │ │ -00084ac0: 6869 7320 6361 7365 2c20 7765 2073 686f his case, we sho │ │ │ -00084ad0: 756c 6420 6e6f 7420 7472 7920 746f 2070 uld not try to p │ │ │ -00084ae0: 6963 6b0a 3c2f 7072 653e 3c2f 7464 3e3c ick.
    < │ │ │ -00084af0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00084b20: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00084b50: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00084b60: 7265 6e74 2f61 7578 5f2f 7065 6572 5f63 rent/aux_/peer_c │ │ │ -00084b70: 6f6e 6e65 6374 696f 6e2e 6870 703a 3130 onnection.hpp:10 │ │ │ -00084b80: 3030 3c2f 613e 3c2f 7464 3e3c 7464 3e66 00f │ │ │ -00084b90: 6163 746f 7220 7468 6973 206f 7574 2069 actor this out i │ │ │ -00084ba0: 6e74 6f20 6974 7320 6f77 6e20 636c 6173 nto its own clas │ │ │ -00084bb0: 7320 7769 7468 2061 2076 6972 7475 616c s with a virtual │ │ │ -00084bc0: 2069 6e74 6572 6661 6365 2074 6f72 7265 interface torre │ │ │ -00084bd0: 6e74 2061 6e64 2073 6573 7369 6f6e 2073 nt and session s │ │ │ -00084be0: 686f 756c 6420 696d 706c 656d 656e 7420 hould implement │ │ │ -00084bf0: 7468 6973 2069 6e74 6572 6661 6365 3c2f this interface

    fact │ │ │ -00084c50: 6f72 2074 6869 7320 6f75 7420 696e 746f or this out into │ │ │ -00084c60: 2069 7473 206f 776e 2063 6c61 7373 2077 its own class w │ │ │ -00084c70: 6974 6820 6120 7669 7274 7561 6c20 696e ith a virtual in │ │ │ -00084c80: 7465 7266 6163 650a 746f 7272 656e 7420 terface.torrent │ │ │ -00084c90: 616e 6420 7365 7373 696f 6e20 7368 6f75 and session shou │ │ │ -00084ca0: 6c64 2069 6d70 6c65 6d65 6e74 2074 6869 ld implement thi │ │ │ -00084cb0: 7320 696e 7465 7266 6163 653c 2f68 323e s interface

    │ │ │ -00084cc0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00084cd0: 6962 746f 7272 656e 742f 6175 785f 2f70 ibtorrent/aux_/p │ │ │ -00084ce0: 6565 725f 636f 6e6e 6563 7469 6f6e 2e68 eer_connection.h │ │ │ -00084cf0: 7070 3a31 3030 303c 2f68 343e 3c70 7265 pp:1000

    ...// the 
    │ │ │ -00084d40: 6c6f 6361 6c20 656e 6470 6f69 6e74 2066  local endpoint f
    │ │ │ -00084d50: 6f72 2074 6869 7320 7065 6572 2c20 692e  or this peer, i.
    │ │ │ -00084d60: 652e 206f 7572 2061 6464 7265 7373 0a09  e. our address..
    │ │ │ -00084d70: 092f 2f20 616e 6420 6f75 7220 706f 7274  .// and our port
    │ │ │ -00084d80: 2e20 4966 2074 6869 7320 6973 2073 6574  . If this is set
    │ │ │ -00084d90: 2066 6f72 206f 7574 676f 696e 6720 636f   for outgoing co
    │ │ │ -00084da0: 6e6e 6563 7469 6f6e 730a 0909 2f2f 2062  nnections...// b
    │ │ │ -00084db0: 6566 6f72 6520 7468 6520 636f 6e6e 6563  efore the connec
    │ │ │ -00084dc0: 7469 6f6e 2063 6f6d 706c 6574 6573 2c20  tion completes, 
    │ │ │ -00084dd0: 6974 206d 6561 6e73 2077 6520 7761 6e74  it means we want
    │ │ │ -00084de0: 2074 6f0a 0909 2f2f 2066 6f72 6365 2074   to...// force t
    │ │ │ -00084df0: 6865 2063 6f6e 6e65 6374 696f 6e20 746f  he connection to
    │ │ │ -00084e00: 2062 6520 626f 756e 6420 746f 2074 6865   be bound to the
    │ │ │ -00084e10: 2073 7065 6369 6669 6564 2069 6e74 6572   specified inter
    │ │ │ -00084e20: 6661 6365 2e0a 0909 2f2f 2069 6620 6974  face....// if it
    │ │ │ -00084e30: 2065 6e64 7320 7570 2062 6569 6e67 2062   ends up being b
    │ │ │ -00084e40: 6f75 6e64 2074 6f20 6120 6469 6666 6572  ound to a differ
    │ │ │ -00084e50: 656e 7420 6c6f 6361 6c20 4950 2c20 7468  ent local IP, th
    │ │ │ -00084e60: 6520 636f 6e6e 6563 7469 6f6e 0a09 092f  e connection.../
    │ │ │ -00084e70: 2f20 6973 2063 6c6f 7365 642e 0a09 0974  / is closed....t
    │ │ │ -00084e80: 6370 3a3a 656e 6470 6f69 6e74 206d 5f6c  cp::endpoint m_l
    │ │ │ -00084e90: 6f63 616c 3b0a 0a09 092f 2f20 7265 6d6f  ocal;....// remo
    │ │ │ -00084ea0: 7465 2070 6565 7227 7320 6964 0a09 0970  te peer's id...p
    │ │ │ -00084eb0: 6565 725f 6964 206d 5f70 6565 725f 6964  eer_id m_peer_id
    │ │ │ -00084ec0: 3b0a 0a09 7072 6f74 6563 7465 643a 0a0a  ;...protected:..
    │ │ │ -00084ed0: 0909 7465 6d70 6c61 7465 2026 6c74 3b74  ..template <t
    │ │ │ -00084ee0: 7970 656e 616d 6520 4675 6e2c 2074 7970  ypename Fun, typ
    │ │ │ -00084ef0: 656e 616d 652e 2e2e 2041 7267 7326 6774  ename... Args>
    │ │ │ -00084f00: 3b0a 0909 766f 6964 2077 7261 7028 4675  ;...void wrap(Fu
    │ │ │ -00084f10: 6e20 662c 2041 7267 7326 616d 703b 2661  n f, Args&&a
    │ │ │ -00084f20: 6d70 3b2e 2e2e 2061 293b 0a0a 0909 2f2f  mp;... a);....//
    │ │ │ -00084f30: 2073 7461 7469 7374 6963 7320 6162 6f75   statistics abou
    │ │ │ -00084f40: 7420 7570 6c6f 6164 2061 6e64 2064 6f77  t upload and dow
    │ │ │ -00084f50: 6e6c 6f61 6420 7370 6565 6473 0a09 092f  nload speeds.../
    │ │ │ -00084f60: 2f20 616e 6420 746f 7461 6c20 616d 6f75  / and total amou
    │ │ │ -00084f70: 6e74 206f 6620 7570 6c6f 6164 7320 616e  nt of uploads an
    │ │ │ -00084f80: 6420 646f 776e 6c6f 6164 7320 666f 720a  d downloads for.
    │ │ │ -00084f90: 0909 2f2f 2074 6869 7320 7065 6572 0a3c  ..// this peer.<
    │ │ │ -00084fa0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -00084fb0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -00084fc0: 7769 6474 683d 2231 3030 2522 3e09 0961  width="100%">..a
    │ │ │ -00084fd0: 7578 3a3a 7374 6174 206d 5f73 7461 7469  ux::stat m_stati
    │ │ │ -00084fe0: 7374 6963 733b 0a3c 2f64 6976 3e0a 0909  stics;....
    │ │ │ -00084ff0: 2f2f 2074 6865 206e 756d 6265 7220 6f66  // the number of
    │ │ │ -00085000: 206f 7574 7374 616e 6469 6e67 2062 7974   outstanding byt
    │ │ │ -00085010: 6573 2065 7870 6563 7465 640a 0909 2f2f  es expected...//
    │ │ │ -00085020: 2074 6f20 6265 2072 6563 6569 7665 6420   to be received 
    │ │ │ -00085030: 6279 2065 7874 656e 7369 6f6e 730a 0909  by extensions...
    │ │ │ -00085040: 696e 7420 6d5f 6578 7465 6e73 696f 6e5f  int m_extension_
    │ │ │ -00085050: 6f75 7473 7461 6e64 696e 675f 6279 7465  outstanding_byte
    │ │ │ -00085060: 7320 3d20 303b 0a0a 0909 2f2f 2074 6865  s = 0;....// the
    │ │ │ -00085070: 206e 756d 6265 7220 6f66 2074 696d 6520   number of time 
    │ │ │ -00085080: 6372 6974 6963 616c 2072 6571 7565 7374  critical request
    │ │ │ -00085090: 730a 0909 2f2f 2071 7565 7565 6420 7570  s...// queued up
    │ │ │ -000850a0: 2069 6e20 7468 6520 6d5f 7265 7175 6573   in the m_reques
    │ │ │ -000850b0: 745f 7175 6575 6520 7468 6174 0a09 092f  t_queue that.../
    │ │ │ -000850c0: 2f20 736f 6f6e 2077 696c 6c20 6265 2063  / soon will be c
    │ │ │ -000850d0: 6f6d 6d69 7474 6564 2074 6f20 7468 6520  ommitted to the 
    │ │ │ -000850e0: 646f 776e 6c6f 6164 0a09 092f 2f20 7175  download...// qu
    │ │ │ -000850f0: 6575 652e 2054 6869 7320 6973 2069 6e63  eue. This is inc
    │ │ │ -00085100: 6c75 6465 6420 696e 2064 6f77 6e6c 6f61  luded in downloa
    │ │ │ -00085110: 645f 7175 6575 655f 7469 6d65 2829 0a09  d_queue_time()..
    │ │ │ -00085120: 092f 2f20 736f 2074 6861 7420 6974 2063  .// so that it c
    │ │ │ -00085130: 616e 2062 6520 7573 6564 2077 6869 6c65  an be used while
    │ │ │ -00085140: 2061 6464 696e 6720 6d6f 7265 0a09 092f   adding more.../
    │ │ │ -00085150: 2f20 7265 7175 6573 7473 2061 6e64 2074  / requests and t
    │ │ │ -00085160: 616b 6520 7468 6520 7072 6576 696f 7573  ake the previous
    │ │ │ -00085170: 2072 6571 7565 7374 730a 0909 2f2f 2069   requests...// i
    │ │ │ -00085180: 6e74 6f20 6163 636f 756e 7420 7769 7468  nto account with
    │ │ │ -00085190: 6f75 7420 7375 626d 6974 7469 6e67 2069  out submitting i
    │ │ │ -000851a0: 7420 616c 6c0a 0909 2f2f 2069 6d6d 6564  t all...// immed
    │ │ │ -000851b0: 6961 7465 6c79 0a09 0973 7464 3a3a 7569  iately...std::ui
    │ │ │ -000851c0: 6e74 3136 5f74 206d 5f71 7565 7565 645f  nt16_t m_queued_
    │ │ │ -000851d0: 7469 6d65 5f63 7269 7469 6361 6c20 3d20  time_critical = 
    │ │ │ -000851e0: 303b 0a0a 0909 2f2f 2074 6865 206e 756d  0;....// the num
    │ │ │ -000851f0: 6265 7220 6f66 2062 7974 6573 2077 6520  ber of bytes we 
    │ │ │ -00085200: 6172 6520 6375 7272 656e 746c 7920 7265  are currently re
    │ │ │ -00085210: 6164 696e 670a 0909 2f2f 2066 726f 6d20  ading...// from 
    │ │ │ -00085220: 6469 736b 2c20 7468 6174 2077 696c 6c20  disk, that will 
    │ │ │ -00085230: 6265 2061 6464 6564 2074 6f20 7468 6520  be added to the 
    │ │ │ -00085240: 7365 6e64 0a09 092f 2f20 6275 6666 6572  send...// buffer
    │ │ │ -00085250: 2061 7320 736f 6f6e 2061 7320 7468 6579   as soon as they
    │ │ │ -00085260: 2063 6f6d 706c 6574 650a 0909 696e 7420   complete...int 
    │ │ │ -00085270: 6d5f 7265 6164 696e 675f 6279 7465 7320  m_reading_bytes 
    │ │ │ -00085280: 3d20 303b 0a0a 0909 2f2f 206f 7074 696f  = 0;....// optio
    │ │ │ -00085290: 6e73 2075 7365 6420 666f 7220 7468 6520  ns used for the 
    │ │ │ -000852a0: 7069 6563 6520 7069 636b 6572 2e20 5468  piece picker. Th
    │ │ │ -000852b0: 6573 6520 666c 6167 7320 7769 6c6c 0a09  ese flags will..
    │ │ │ -000852c0: 092f 2f20 6265 2061 7567 6d65 6e74 6564  .// be augmented
    │ │ │ -000852d0: 2077 6974 6820 666c 6167 7320 636f 6e74   with flags cont
    │ │ │ -000852e0: 726f 6c6c 6564 2062 7920 6f74 6865 7220  rolled by other 
    │ │ │ -000852f0: 7365 7474 696e 6773 0a09 092f 2f20 6c69  settings...// li
    │ │ │ -00085300: 6b65 2073 6571 7565 6e74 6961 6c20 646f  ke sequential do
    │ │ │ -00085310: 776e 6c6f 6164 2065 7463 2e20 5468 6573  wnload etc. Thes
    │ │ │ -00085320: 6520 6172 6520 6865 7265 2074 6f0a 0909  e are here to...
    │ │ │ -00085330: 2f2f 206c 6574 2070 6c75 6769 6e73 2063  // let plugins c
    │ │ │ -00085340: 6f6e 7472 6f6c 2066 6c61 6773 2074 6861  ontrol flags tha
    │ │ │ -00085350: 7420 7368 6f75 6c64 2061 6c77 6179 7320  t should always 
    │ │ │ -00085360: 6265 2073 6574 0a09 0970 6963 6b65 725f  be set...picker_
    │ │ │ -00085370: 6f70 7469 6f6e 735f 7420 6d5f 7069 636b  options_t m_pick
    │ │ │ -00085380: 6572 5f6f 7074 696f 6e73 7b7d 3b0a 0a09  er_options{};...
    │ │ │ -00085390: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -000853a0: 6620 696e 7661 6c69 6420 7069 6563 652d  f invalid piece-
    │ │ │ -000853b0: 7265 7175 6573 7473 0a09 092f 2f20 7765  requests...// we
    │ │ │ -000853c0: 2068 6176 6520 676f 7420 6672 6f6d 2074   have got from t
    │ │ │ -000853d0: 6869 7320 7065 6572 2e20 4966 2074 6865  his peer. If the
    │ │ │ -000853e0: 2072 6571 7565 7374 0a09 092f 2f20 7175   request...// qu
    │ │ │ -000853f0: 6575 6520 6765 7473 2065 6d70 7479 2c20  eue gets empty, 
    │ │ │ -00085400: 616e 6420 7468 6572 6520 6861 7665 2062  and there have b
    │ │ │ -00085410: 6565 6e0a 0909 2f2f 2069 6e76 616c 6964  een...// invalid
    │ │ │ -00085420: 2072 6571 7565 7374 732c 2077 6520 6361   requests, we ca
    │ │ │ -00085430: 6e20 6173 7375 6d65 2074 6865 0a3c 2f70  n assume the.

    re │ │ │ -00085470: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ -000854b0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -000854c0: 785f 2f74 7261 636b 6572 5f6c 6973 742e x_/tracker_list. │ │ │ -000854d0: 6870 703a 3734 3c2f 613e 3c2f 7464 3e3c hpp:74< │ │ │ -000854e0: 7464 3e6d 616b 6520 7468 6573 6520 6974 td>make these it │ │ │ -000854f0: 6572 6174 6f72 7320 636f 6e73 743c 2f74 erators const

    make │ │ │ -00085550: 7468 6573 6520 6974 6572 6174 6f72 7320 these iterators │ │ │ -00085560: 636f 6e73 743c 2f68 323e 3c68 343e 2e2e const

    .. │ │ │ -00085570: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00085580: 656e 742f 6175 785f 2f74 7261 636b 6572 ent/aux_/tracker │ │ │ -00085590: 5f6c 6973 742e 6870 703a 3734 3c2f 6834 _list.hpp:74

    .std:
    │ │ │ -000855e0: 3a73 7472 696e 6720 6c61 7374 5f77 6f72  :string last_wor
    │ │ │ -000855f0: 6b69 6e67 5f75 726c 2829 2063 6f6e 7374  king_url() const
    │ │ │ -00085600: 3b0a 0961 7578 3a3a 616e 6e6f 756e 6365  ;..aux::announce
    │ │ │ -00085610: 5f65 6e74 7279 2a20 6c61 7374 5f77 6f72  _entry* last_wor
    │ │ │ -00085620: 6b69 6e67 2829 3b0a 0961 7578 3a3a 616e  king();..aux::an
    │ │ │ -00085630: 6e6f 756e 6365 5f65 6e74 7279 2a20 6669  nounce_entry* fi
    │ │ │ -00085640: 7273 7428 293b 0a0a 0976 6f69 6420 7265  rst();...void re
    │ │ │ -00085650: 636f 7264 5f77 6f72 6b69 6e67 2861 7578  cord_working(aux
    │ │ │ -00085660: 3a3a 616e 6e6f 756e 6365 5f65 6e74 7279  ::announce_entry
    │ │ │ -00085670: 2063 6f6e 7374 2a20 6165 293b 0a0a 0976   const* ae);...v
    │ │ │ -00085680: 6f69 6420 7265 706c 6163 6528 7374 643a  oid replace(std:
    │ │ │ -00085690: 3a76 6563 746f 7226 6c74 3b6c 743a 3a61  :vector<lt::a
    │ │ │ -000856a0: 6e6e 6f75 6e63 655f 656e 7472 7926 6774  nnounce_entry>
    │ │ │ -000856b0: 3b20 636f 6e73 7426 616d 703b 2061 6573  ; const& aes
    │ │ │ -000856c0: 293b 0a0a 0976 6f69 6420 656e 6162 6c65  );...void enable
    │ │ │ -000856d0: 5f61 6c6c 2829 3b0a 0a09 766f 6964 2063  _all();...void c
    │ │ │ -000856e0: 6f6d 706c 6574 6564 2874 696d 655f 706f  ompleted(time_po
    │ │ │ -000856f0: 696e 7433 3220 6e6f 7729 3b0a 0a09 766f  int32 now);...vo
    │ │ │ -00085700: 6964 2073 6574 5f63 6f6d 706c 6574 655f  id set_complete_
    │ │ │ -00085710: 7365 6e74 2829 3b0a 0a09 766f 6964 2072  sent();...void r
    │ │ │ -00085720: 6573 6574 2829 3b0a 0a09 766f 6964 2073  eset();...void s
    │ │ │ -00085730: 746f 705f 616e 6e6f 756e 6369 6e67 2874  top_announcing(t
    │ │ │ -00085740: 696d 655f 706f 696e 7433 3220 6e6f 7729  ime_point32 now)
    │ │ │ -00085750: 3b0a 0a09 626f 6f6c 2061 6e79 5f76 6572  ;...bool any_ver
    │ │ │ -00085760: 6966 6965 6428 2920 636f 6e73 743b 0a0a  ified() const;..
    │ │ │ -00085770: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .i │ │ │ -000857a0: 7465 7261 746f 7220 6265 6769 6e28 2920 terator begin() │ │ │ -000857b0: 7b20 7265 7475 726e 206d 5f74 7261 636b { return m_track │ │ │ -000857c0: 6572 732e 6265 6769 6e28 293b 207d 0a3c ers.begin(); }.< │ │ │ -000857d0: 2f64 6976 3e09 6974 6572 6174 6f72 2065 /div>.iterator e │ │ │ -000857e0: 6e64 2829 207b 2072 6574 7572 6e20 6d5f nd() { return m_ │ │ │ -000857f0: 7472 6163 6b65 7273 2e65 6e64 2829 3b20 trackers.end(); │ │ │ -00085800: 7d0a 0a09 636f 6e73 745f 6974 6572 6174 }...const_iterat │ │ │ -00085810: 6f72 2062 6567 696e 2829 2063 6f6e 7374 or begin() const │ │ │ -00085820: 207b 2072 6574 7572 6e20 6d5f 7472 6163 { return m_trac │ │ │ -00085830: 6b65 7273 2e62 6567 696e 2829 3b20 7d0a kers.begin(); }. │ │ │ -00085840: 0963 6f6e 7374 5f69 7465 7261 746f 7220 .const_iterator │ │ │ -00085850: 656e 6428 2920 636f 6e73 7420 7b20 7265 end() const { re │ │ │ -00085860: 7475 726e 206d 5f74 7261 636b 6572 732e turn m_trackers. │ │ │ -00085870: 656e 6428 293b 207d 0a0a 0961 7578 3a3a end(); }...aux:: │ │ │ -00085880: 616e 6e6f 756e 6365 5f65 6e74 7279 2063 announce_entry c │ │ │ -00085890: 6f6e 7374 2a20 6669 6e64 2869 6e74 2063 onst* find(int c │ │ │ -000858a0: 6f6e 7374 2069 6478 2920 636f 6e73 743b onst idx) const; │ │ │ -000858b0: 0a09 6175 783a 3a61 6e6e 6f75 6e63 655f ..aux::announce_ │ │ │ -000858c0: 656e 7472 792a 2066 696e 6428 696e 7420 entry* find(int │ │ │ -000858d0: 636f 6e73 7420 6964 7829 3b0a 0a70 7269 const idx);..pri │ │ │ -000858e0: 7661 7465 3a0a 0a23 6966 2054 4f52 5245 vate:..#if TORRE │ │ │ -000858f0: 4e54 5f55 5345 5f49 4e56 4152 4941 4e54 NT_USE_INVARIANT │ │ │ -00085900: 5f43 4845 434b 530a 0966 7269 656e 6420 _CHECKS..friend │ │ │ -00085910: 7374 7275 6374 206c 6962 746f 7272 656e struct libtorren │ │ │ -00085920: 743a 3a69 6e76 6172 6961 6e74 5f61 6363 t::invariant_acc │ │ │ -00085930: 6573 733b 0a09 766f 6964 2063 6865 636b ess;..void check │ │ │ -00085940: 5f69 6e76 6172 6961 6e74 2829 2063 6f6e _invariant() con │ │ │ -00085950: 7374 3b0a 2365 6e64 6966 0a0a 0962 6f6f st;.#endif...boo │ │ │ -00085960: 7374 3a3a 6f62 6a65 6374 5f70 6f6f 6c26 st::object_pool& │ │ │ -00085970: 6c74 3b61 7578 3a3a 616e 6e6f 756e 6365 lt;aux::announce │ │ │ -00085980: 5f65 6e74 7279 2667 743b 206d 5f73 746f _entry> m_sto │ │ │ -00085990: 7261 6765 3b0a 0974 7261 636b 6572 735f rage;..trackers_ │ │ │ -000859a0: 7420 6d5f 7472 6163 6b65 7273 3b0a 0973 t m_trackers;..s │ │ │ -000859b0: 7464 3a3a 756e 6f72 6465 7265 645f 6d61 td::unordered_ma │ │ │ -000859c0: 7026 6c74 3b73 7472 696e 675f 7669 6577 p<string_view │ │ │ -000859d0: 2c20 6175 783a 3a61 6e6e 6f75 6e63 655f , aux::announce_ │ │ │ -000859e0: 656e 7472 792a 2667 743b 206d 5f75 726c entry*> m_url │ │ │ -000859f0: 5f69 6e64 6578 3b0a 0a09 2f2f 2074 6865 _index;...// the │ │ │ -00085a00: 2069 6e64 6578 2074 6f20 7468 6520 6c61 index to the la │ │ │ -00085a10: 7374 2074 7261 636b 6572 2074 6861 7420 st tracker that │ │ │ -00085a20: 776f 726b 6564 0a09 6175 783a 3a61 6e6e worked..aux::ann │ │ │ -00085a30: 6f75 6e63 655f 656e 7472 792a 206d 5f6c ounce_entry* m_l │ │ │ -00085a40: 6173 745f 776f 726b 696e 675f 7472 6163 ast_working_trac │ │ │ -00085a50: 6b65 7220 3d20 6e75 6c6c 7074 723b 0a7d ker = nullptr;.} │ │ │ -00085a60: 3b0a 0a7d 0a23 656e 6469 660a 0a3c 2f70 ;..}.#endif..

    │ │ │ +0003b810: 223e 2e2e 2f73 7263 2f70 6163 6b65 745f ">../src/packet_ │ │ │ +0003b820: 6275 6666 6572 2e63 7070 3a31 3334 3c2f buffer.cpp:134use c │ │ │ +0003b840: 6f6d 7061 7265 5f6c 6573 735f 7772 6170 ompare_less_wrap │ │ │ +0003b850: 2066 6f72 2074 6869 7320 636f 6d70 6172 for this compar │ │ │ +0003b860: 6973 6f6e 2061 7320 7765 6c6c 3c2f 7464 ison as well

    use co │ │ │ +0003b8c0: 6d70 6172 655f 6c65 7373 5f77 7261 7020 mpare_less_wrap │ │ │ +0003b8d0: 666f 7220 7468 6973 2063 6f6d 7061 7269 for this compari │ │ │ +0003b8e0: 736f 6e20 6173 2077 656c 6c3c 2f68 323e son as well

    │ │ │ +0003b8f0: 3c68 343e 2e2e 2f73 7263 2f70 6163 6b65

    ../src/packe │ │ │ +0003b900: 745f 6275 6666 6572 2e63 7070 3a31 3334 t_buffer.cpp:134 │ │ │ +0003b910: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0003b950: 7b0a 0909 494e 5641 5249 414e 545f 4348  {...INVARIANT_CH
    │ │ │ +0003b960: 4543 4b3b 0a09 0954 4f52 5245 4e54 5f41  ECK;...TORRENT_A
    │ │ │ +0003b970: 5353 4552 545f 5641 4c28 7369 7a65 2026  SSERT_VAL(size &
    │ │ │ +0003b980: 6c74 3b3d 2030 7866 6666 662c 2073 697a  lt;= 0xffff, siz
    │ │ │ +0003b990: 6529 3b0a 0909 7374 643a 3a75 696e 7433  e);...std::uint3
    │ │ │ +0003b9a0: 325f 7420 6e65 775f 7369 7a65 203d 206d  2_t new_size = m
    │ │ │ +0003b9b0: 5f63 6170 6163 6974 7920 3d3d 2030 203f  _capacity == 0 ?
    │ │ │ +0003b9c0: 2031 3620 3a20 6d5f 6361 7061 6369 7479   16 : m_capacity
    │ │ │ +0003b9d0: 3b0a 0a09 0977 6869 6c65 2028 6e65 775f  ;....while (new_
    │ │ │ +0003b9e0: 7369 7a65 2026 6c74 3b20 7369 7a65 290a  size < size).
    │ │ │ +0003b9f0: 0909 096e 6577 5f73 697a 6520 266c 743b  ...new_size <
    │ │ │ +0003ba00: 266c 743b 3d20 313b 0a0a 0909 6175 746f  <= 1;....auto
    │ │ │ +0003ba10: 206e 6577 5f73 746f 7261 6765 203d 2061   new_storage = a
    │ │ │ +0003ba20: 7578 3a3a 6d61 6b65 5f75 6e69 7175 6526  ux::make_unique&
    │ │ │ +0003ba30: 6c74 3b70 6163 6b65 745f 7074 725b 5d2c  lt;packet_ptr[],
    │ │ │ +0003ba40: 2069 6e64 6578 5f74 7970 6526 6774 3b28   index_type>(
    │ │ │ +0003ba50: 6e65 775f 7369 7a65 293b 0a0a 0909 666f  new_size);....fo
    │ │ │ +0003ba60: 7220 2869 6e64 6578 5f74 7970 6520 6920  r (index_type i 
    │ │ │ +0003ba70: 3d20 6d5f 6669 7273 743b 2069 2026 6c74  = m_first; i <
    │ │ │ +0003ba80: 3b20 286d 5f66 6972 7374 202b 206d 5f63  ; (m_first + m_c
    │ │ │ +0003ba90: 6170 6163 6974 7929 3b20 2b2b 6929 0a09  apacity); ++i)..
    │ │ │ +0003baa0: 0909 6e65 775f 7374 6f72 6167 655b 6920  ..new_storage[i 
    │ │ │ +0003bab0: 2661 6d70 3b20 286e 6577 5f73 697a 6520  & (new_size 
    │ │ │ +0003bac0: 2d20 3129 5d20 3d20 7374 643a 3a6d 6f76  - 1)] = std::mov
    │ │ │ +0003bad0: 6528 6d5f 7374 6f72 6167 655b 6920 2661  e(m_storage[i &a
    │ │ │ +0003bae0: 6d70 3b20 286d 5f63 6170 6163 6974 7920  mp; (m_capacity 
    │ │ │ +0003baf0: 2d20 3129 5d29 3b0a 0a09 096d 5f73 746f  - 1)]);....m_sto
    │ │ │ +0003bb00: 7261 6765 203d 2073 7464 3a3a 6d6f 7665  rage = std::move
    │ │ │ +0003bb10: 286e 6577 5f73 746f 7261 6765 293b 0a09  (new_storage);..
    │ │ │ +0003bb20: 096d 5f63 6170 6163 6974 7920 3d20 6e65  .m_capacity = ne
    │ │ │ +0003bb30: 775f 7369 7a65 3b0a 097d 0a0a 0970 6163  w_size;..}...pac
    │ │ │ +0003bb40: 6b65 745f 7074 7220 7061 636b 6574 5f62  ket_ptr packet_b
    │ │ │ +0003bb50: 7566 6665 723a 3a72 656d 6f76 6528 696e  uffer::remove(in
    │ │ │ +0003bb60: 6465 785f 7479 7065 2069 6478 290a 097b  dex_type idx)..{
    │ │ │ +0003bb70: 0a09 0949 4e56 4152 4941 4e54 5f43 4845  ...INVARIANT_CHE
    │ │ │ +0003bb80: 434b 3b0a 3c64 6976 2073 7479 6c65 3d22  CK;.
    ..if (idx > │ │ │ +0003bbc0: 3d20 6d5f 6669 7273 7420 2b20 6d5f 6361 = m_first + m_ca │ │ │ +0003bbd0: 7061 6369 7479 290a 3c2f 6469 763e 0909 pacity).
    .. │ │ │ +0003bbe0: 0972 6574 7572 6e20 7b7d 3b0a 0a09 0969 .return {};....i │ │ │ +0003bbf0: 6620 2863 6f6d 7061 7265 5f6c 6573 735f f (compare_less_ │ │ │ +0003bc00: 7772 6170 2869 6478 2c20 6d5f 6669 7273 wrap(idx, m_firs │ │ │ +0003bc10: 742c 2030 7866 6666 6629 290a 0909 0972 t, 0xffff))....r │ │ │ +0003bc20: 6574 7572 6e20 7b7d 3b0a 0a09 0973 7464 eturn {};....std │ │ │ +0003bc30: 3a3a 7369 7a65 5f74 2063 6f6e 7374 206d ::size_t const m │ │ │ +0003bc40: 6173 6b20 3d20 6d5f 6361 7061 6369 7479 ask = m_capacity │ │ │ +0003bc50: 202d 2031 3b0a 0909 7061 636b 6574 5f70 - 1;...packet_p │ │ │ +0003bc60: 7472 206f 6c64 5f76 616c 7565 203d 2073 tr old_value = s │ │ │ +0003bc70: 7464 3a3a 6d6f 7665 286d 5f73 746f 7261 td::move(m_stora │ │ │ +0003bc80: 6765 5b69 6478 2026 616d 703b 206d 6173 ge[idx & mas │ │ │ +0003bc90: 6b5d 293b 0a09 096d 5f73 746f 7261 6765 k]);...m_storage │ │ │ +0003bca0: 5b69 6478 2026 616d 703b 206d 6173 6b5d [idx & mask] │ │ │ +0003bcb0: 2e72 6573 6574 2829 3b0a 0a09 0969 6620 .reset();....if │ │ │ +0003bcc0: 286f 6c64 5f76 616c 7565 290a 0909 7b0a (old_value)...{. │ │ │ +0003bcd0: 0909 092d 2d6d 5f73 697a 653b 0a09 0909 ...--m_size;.... │ │ │ +0003bce0: 6966 2028 6d5f 7369 7a65 203d 3d20 3029 if (m_size == 0) │ │ │ +0003bcf0: 206d 5f6c 6173 7420 3d20 6d5f 6669 7273 m_last = m_firs │ │ │ +0003bd00: 743b 0a09 097d 0a0a 0909 6966 2028 6964 t;...}....if (id │ │ │ +0003bd10: 7820 3d3d 206d 5f66 6972 7374 2026 616d x == m_first &am │ │ │ +0003bd20: 703b 2661 6d70 3b20 6d5f 7369 7a65 2021 p;& m_size ! │ │ │ +0003bd30: 3d20 3029 0a09 097b 0a09 0909 2b2b 6d5f = 0)...{....++m_ │ │ │ +0003bd40: 6669 7273 743b 0a09 0909 666f 7220 2869 first;....for (i │ │ │ +0003bd50: 6e64 6578 5f74 7970 6520 6920 3d20 303b ndex_type i = 0; │ │ │ +0003bd60: 2069 2026 6c74 3b20 6d5f 6361 7061 6369 i < m_capaci │ │ │ +0003bd70: 7479 3b20 2b2b 692c 202b 2b6d 5f66 6972 ty; ++i, ++m_fir │ │ │ +0003bd80: 7374 290a 0909 0909 6966 2028 6d5f 7374 st).....if (m_st │ │ │ +0003bd90: 6f72 6167 655b 6d5f 6669 7273 7420 2661 orage[m_first &a │ │ │ +0003bda0: 6d70 3b20 6d61 736b 5d29 2062 7265 616b mp; mask]) break │ │ │ +0003bdb0: 3b0a 0909 096d 5f66 6972 7374 2026 616d ;....m_first &am │ │ │ +0003bdc0: 703b 3d20 3078 6666 6666 3b0a 0909 7d0a p;= 0xffff;...}. │ │ │ +0003bdd0: 0a09 0969 6620 2828 2869 6478 202b 2031 ...if (((idx + 1 │ │ │ +0003bde0: 2920 2661 6d70 3b20 3078 6666 6666 2920 ) & 0xffff) │ │ │ +0003bdf0: 3d3d 206d 5f6c 6173 7420 2661 6d70 3b26 == m_last && │ │ │ +0003be00: 616d 703b 206d 5f73 697a 6520 213d 2030 amp; m_size != 0 │ │ │ +0003be10: 290a 0909 7b0a 0909 092d 2d6d 5f6c 6173 )...{....--m_las │ │ │ +0003be20: 743b 0a09 0909 666f 7220 2869 6e64 6578 t;....for (index │ │ │ +0003be30: 5f74 7970 6520 6920 3d20 303b 2069 2026 _type i = 0; i & │ │ │ +0003be40: 6c74 3b20 6d5f 6361 7061 6369 7479 3b20 lt; m_capacity; │ │ │ +0003be50: 2b2b 692c 202d 2d6d 5f6c 6173 7429 0a09 ++i, --m_last).. │ │ │ +0003be60: 0909 0969 6620 286d 5f73 746f 7261 6765 ...if (m_storage │ │ │ +0003be70: 5b6d 5f6c 6173 7420 2661 6d70 3b20 6d61 [m_last & ma │ │ │ +0003be80: 736b 5d29 2062 7265 616b 3b0a 0909 092b sk]) break;....+ │ │ │ +0003be90: 2b6d 5f6c 6173 743b 0a09 0909 6d5f 6c61 +m_last;....m_la │ │ │ +0003bea0: 7374 2026 616d 703b 3d20 3078 6666 6666 st &= 0xffff │ │ │ +0003beb0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +0003bee0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0003bef0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0003bf20: 7372 632f 7365 7474 696e 6773 5f70 6163 src/settings_pac │ │ │ +0003bf30: 6b2e 6370 703a 3238 353c 2f61 3e3c 2f74 k.cpp:285deprecate │ │ │ +0003bf50: 7468 6973 3c2f 7464 3e3c 2f74 723e 3c74 thisdeprecate this │ │ │ +0003bfb0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0003bfc0: 7365 7474 696e 6773 5f70 6163 6b2e 6370 settings_pack.cp │ │ │ +0003bfd0: 703a 3238 353c 2f68 343e 3c70 7265 2073 p:285

    ..SET(outgoi
    │ │ │ +0003c020: 6e67 5f70 6f72 742c 2030 2c20 6e75 6c6c  ng_port, 0, null
    │ │ │ +0003c030: 7074 7229 2c0a 0909 5345 5428 6e75 6d5f  ptr),...SET(num_
    │ │ │ +0003c040: 6f75 7467 6f69 6e67 5f70 6f72 7473 2c20  outgoing_ports, 
    │ │ │ +0003c050: 302c 206e 756c 6c70 7472 292c 0a09 0953  0, nullptr),...S
    │ │ │ +0003c060: 4554 2870 6565 725f 6473 6370 2c20 3078  ET(peer_dscp, 0x
    │ │ │ +0003c070: 3031 2c20 2661 6d70 3b73 6573 7369 6f6e  01, &session
    │ │ │ +0003c080: 5f69 6d70 6c3a 3a75 7064 6174 655f 7065  _impl::update_pe
    │ │ │ +0003c090: 6572 5f64 7363 7029 2c0a 0909 5345 5428  er_dscp),...SET(
    │ │ │ +0003c0a0: 6163 7469 7665 5f64 6f77 6e6c 6f61 6473  active_downloads
    │ │ │ +0003c0b0: 2c20 332c 2026 616d 703b 7365 7373 696f  , 3, &sessio
    │ │ │ +0003c0c0: 6e5f 696d 706c 3a3a 7472 6967 6765 725f  n_impl::trigger_
    │ │ │ +0003c0d0: 6175 746f 5f6d 616e 6167 6529 2c0a 0909  auto_manage),...
    │ │ │ +0003c0e0: 5345 5428 6163 7469 7665 5f73 6565 6473  SET(active_seeds
    │ │ │ +0003c0f0: 2c20 352c 2026 616d 703b 7365 7373 696f  , 5, &sessio
    │ │ │ +0003c100: 6e5f 696d 706c 3a3a 7472 6967 6765 725f  n_impl::trigger_
    │ │ │ +0003c110: 6175 746f 5f6d 616e 6167 6529 2c0a 0909  auto_manage),...
    │ │ │ +0003c120: 5345 5428 6163 7469 7665 5f63 6865 636b  SET(active_check
    │ │ │ +0003c130: 696e 672c 2031 2c20 2661 6d70 3b73 6573  ing, 1, &ses
    │ │ │ +0003c140: 7369 6f6e 5f69 6d70 6c3a 3a74 7269 6767  sion_impl::trigg
    │ │ │ +0003c150: 6572 5f61 7574 6f5f 6d61 6e61 6765 292c  er_auto_manage),
    │ │ │ +0003c160: 0a09 0953 4554 2861 6374 6976 655f 6468  ...SET(active_dh
    │ │ │ +0003c170: 745f 6c69 6d69 742c 2038 382c 206e 756c  t_limit, 88, nul
    │ │ │ +0003c180: 6c70 7472 292c 0a09 0953 4554 2861 6374  lptr),...SET(act
    │ │ │ +0003c190: 6976 655f 7472 6163 6b65 725f 6c69 6d69  ive_tracker_limi
    │ │ │ +0003c1a0: 742c 2031 3630 302c 206e 756c 6c70 7472  t, 1600, nullptr
    │ │ │ +0003c1b0: 292c 0a09 0953 4554 2861 6374 6976 655f  ),...SET(active_
    │ │ │ +0003c1c0: 6c73 645f 6c69 6d69 742c 2036 302c 206e  lsd_limit, 60, n
    │ │ │ +0003c1d0: 756c 6c70 7472 292c 0a09 0953 4554 2861  ullptr),...SET(a
    │ │ │ +0003c1e0: 6374 6976 655f 6c69 6d69 742c 2035 3030  ctive_limit, 500
    │ │ │ +0003c1f0: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69  , &session_i
    │ │ │ +0003c200: 6d70 6c3a 3a74 7269 6767 6572 5f61 7574  mpl::trigger_aut
    │ │ │ +0003c210: 6f5f 6d61 6e61 6765 292c 0a09 0944 4550  o_manage),...DEP
    │ │ │ +0003c220: 5245 4341 5445 445f 5345 5428 6163 7469  RECATED_SET(acti
    │ │ │ +0003c230: 7665 5f6c 6f61 6465 645f 6c69 6d69 742c  ve_loaded_limit,
    │ │ │ +0003c240: 2030 2c20 2661 6d70 3b73 6573 7369 6f6e   0, &session
    │ │ │ +0003c250: 5f69 6d70 6c3a 3a74 7269 6767 6572 5f61  _impl::trigger_a
    │ │ │ +0003c260: 7574 6f5f 6d61 6e61 6765 292c 0a09 0953  uto_manage),...S
    │ │ │ +0003c270: 4554 2861 7574 6f5f 6d61 6e61 6765 5f69  ET(auto_manage_i
    │ │ │ +0003c280: 6e74 6572 7661 6c2c 2033 302c 206e 756c  nterval, 30, nul
    │ │ │ +0003c290: 6c70 7472 292c 0a09 0953 4554 2873 6565  lptr),...SET(see
    │ │ │ +0003c2a0: 645f 7469 6d65 5f6c 696d 6974 2c20 3234  d_time_limit, 24
    │ │ │ +0003c2b0: 202a 2036 3020 2a20 3630 2c20 6e75 6c6c   * 60 * 60, null
    │ │ │ +0003c2c0: 7074 7229 2c0a 0909 5345 5428 6175 746f  ptr),...SET(auto
    │ │ │ +0003c2d0: 5f73 6372 6170 655f 696e 7465 7276 616c  _scrape_interval
    │ │ │ +0003c2e0: 2c20 3138 3030 2c20 6e75 6c6c 7074 7229  , 1800, nullptr)
    │ │ │ +0003c2f0: 2c0a 0909 5345 5428 6175 746f 5f73 6372  ,...SET(auto_scr
    │ │ │ +0003c300: 6170 655f 6d69 6e5f 696e 7465 7276 616c  ape_min_interval
    │ │ │ +0003c310: 2c20 3330 302c 206e 756c 6c70 7472 292c  , 300, nullptr),
    │ │ │ +0003c320: 0a09 0953 4554 286d 6178 5f70 6565 726c  ...SET(max_peerl
    │ │ │ +0003c330: 6973 745f 7369 7a65 2c20 3330 3030 2c20  ist_size, 3000, 
    │ │ │ +0003c340: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428  nullptr),...SET(
    │ │ │ +0003c350: 6d61 785f 7061 7573 6564 5f70 6565 726c  max_paused_peerl
    │ │ │ +0003c360: 6973 745f 7369 7a65 2c20 3130 3030 2c20  ist_size, 1000, 
    │ │ │ +0003c370: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428  nullptr),...SET(
    │ │ │ +0003c380: 6d69 6e5f 616e 6e6f 756e 6365 5f69 6e74  min_announce_int
    │ │ │ +0003c390: 6572 7661 6c2c 2035 202a 2036 302c 206e  erval, 5 * 60, n
    │ │ │ +0003c3a0: 756c 6c70 7472 292c 0a09 0953 4554 2861  ullptr),...SET(a
    │ │ │ +0003c3b0: 7574 6f5f 6d61 6e61 6765 5f73 7461 7274  uto_manage_start
    │ │ │ +0003c3c0: 7570 2c20 3630 2c20 6e75 6c6c 7074 7229  up, 60, nullptr)
    │ │ │ +0003c3d0: 2c0a 0909 5345 5428 7365 6564 696e 675f  ,...SET(seeding_
    │ │ │ +0003c3e0: 7069 6563 655f 7175 6f74 612c 2032 302c  piece_quota, 20,
    │ │ │ +0003c3f0: 206e 756c 6c70 7472 292c 0a3c 6469 7620   nullptr),.
    ..SET(m │ │ │ +0003c430: 6178 5f72 656a 6563 7473 2c20 3530 2c20 ax_rejects, 50, │ │ │ +0003c440: 6e75 6c6c 7074 7229 2c0a 3c2f 6469 763e nullptr),.
    │ │ │ +0003c450: 0909 5345 5428 7265 6376 5f73 6f63 6b65 ..SET(recv_socke │ │ │ +0003c460: 745f 6275 6666 6572 5f73 697a 652c 2030 t_buffer_size, 0 │ │ │ +0003c470: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69 , &session_i │ │ │ +0003c480: 6d70 6c3a 3a75 7064 6174 655f 736f 636b mpl::update_sock │ │ │ +0003c490: 6574 5f62 7566 6665 725f 7369 7a65 292c et_buffer_size), │ │ │ +0003c4a0: 0a09 0953 4554 2873 656e 645f 736f 636b ...SET(send_sock │ │ │ +0003c4b0: 6574 5f62 7566 6665 725f 7369 7a65 2c20 et_buffer_size, │ │ │ +0003c4c0: 302c 2026 616d 703b 7365 7373 696f 6e5f 0, &session_ │ │ │ +0003c4d0: 696d 706c 3a3a 7570 6461 7465 5f73 6f63 impl::update_soc │ │ │ +0003c4e0: 6b65 745f 6275 6666 6572 5f73 697a 6529 ket_buffer_size) │ │ │ +0003c4f0: 2c0a 0909 5345 5428 6d61 785f 7065 6572 ,...SET(max_peer │ │ │ +0003c500: 5f72 6563 765f 6275 6666 6572 5f73 697a _recv_buffer_siz │ │ │ +0003c510: 652c 2032 202a 2031 3032 3420 2a20 3130 e, 2 * 1024 * 10 │ │ │ +0003c520: 3234 2c20 6e75 6c6c 7074 7229 2c0a 0909 24, nullptr),... │ │ │ +0003c530: 4445 5052 4543 4154 4544 5f53 4554 2866 DEPRECATED_SET(f │ │ │ +0003c540: 696c 655f 6368 6563 6b73 5f64 656c 6179 ile_checks_delay │ │ │ +0003c550: 5f70 6572 5f62 6c6f 636b 2c20 302c 206e _per_block, 0, n │ │ │ +0003c560: 756c 6c70 7472 292c 0a09 0944 4550 5245 ullptr),...DEPRE │ │ │ +0003c570: 4341 5445 4432 5f53 4554 2872 6561 645f CATED2_SET(read_ │ │ │ +0003c580: 6361 6368 655f 6c69 6e65 5f73 697a 652c cache_line_size, │ │ │ +0003c590: 2033 322c 206e 756c 6c70 7472 292c 0a09 32, nullptr),.. │ │ │ +0003c5a0: 0944 4550 5245 4341 5445 4432 5f53 4554 .DEPRECATED2_SET │ │ │ +0003c5b0: 2877 7269 7465 5f63 6163 6865 5f6c 696e (write_cache_lin │ │ │ +0003c5c0: 655f 7369 7a65 2c20 3136 2c20 6e75 6c6c e_size, 16, null │ │ │ +0003c5d0: 7074 7229 2c0a 0909 5345 5428 6f70 7469 ptr),...SET(opti │ │ │ +0003c5e0: 6d69 7374 6963 5f64 6973 6b5f 7265 7472 mistic_disk_retr │ │ │ +0003c5f0: 792c 2031 3020 2a20 3630 2c20 6e75 6c6c y, 10 * 60, null │ │ │ +0003c600: 7074 7229 2c0a 0909 5345 5428 6d61 785f ptr),...SET(max_ │ │ │ +0003c610: 7375 6767 6573 745f 7069 6563 6573 2c20 suggest_pieces, │ │ │ +0003c620: 3136 2c20 6e75 6c6c 7074 7229 2c0a 0909 16, nullptr),... │ │ │ +0003c630: 5345 5428 6c6f 6361 6c5f 7365 7276 6963 SET(local_servic │ │ │ +0003c640: 655f 616e 6e6f 756e 6365 5f69 6e74 6572 e_announce_inter │ │ │ +0003c650: 7661 6c2c 2035 202a 2036 302c 206e 756c val, 5 * 60, nul │ │ │ +0003c660: 6c70 7472 292c 0a09 0953 4554 2864 6874 lptr),...SET(dht │ │ │ +0003c670: 5f61 6e6e 6f75 6e63 655f 696e 7465 7276 _announce_interv │ │ │ +0003c680: 616c 2c20 3135 202a 2036 302c 2026 616d al, 15 * 60, &am │ │ │ +0003c690: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0003c6a0: 7570 6461 7465 5f64 6874 5f61 6e6e 6f75 update_dht_annou │ │ │ +0003c6b0: 6e63 655f 696e 7465 7276 616c 292c 0a09 nce_interval),.. │ │ │ +0003c6c0: 0953 4554 2875 6470 5f74 7261 636b 6572 .SET(udp_tracker │ │ │ +0003c6d0: 5f74 6f6b 656e 5f65 7870 6972 792c 2036 _token_expiry, 6 │ │ │ +0003c6e0: 302c 206e 756c 6c70 7472 292c 0a09 0944 0, nullptr),...D │ │ │ +0003c6f0: 4550 5245 4341 5445 445f 5345 5428 6465 EPRECATED_SET(de │ │ │ +0003c700: 6661 756c 745f 6361 6368 655f 6d69 6e5f fault_cache_min_ │ │ │ +0003c710: 6167 652c 2031 2c20 6e75 6c6c 7074 7229 age, 1, nullptr) │ │ │ +0003c720: 2c0a 0909 5345 5428 6e75 6d5f 6f70 7469 ,...SET(num_opti │ │ │ +0003c730: 6d69 7374 6963 5f75 6e63 686f 6b65 5f73 mistic_unchoke_s │ │ │ +0003c740: 6c6f 7473 2c20 302c 206e 756c 6c70 7472 lots, 0, nullptr │ │ │ +0003c750: 292c 0a09 0944 4550 5245 4341 5445 445f ),...DEPRECATED_ │ │ │ +0003c760: 5345 5428 6465 6661 756c 745f 6573 745f SET(default_est_ │ │ │ +0003c770: 7265 6369 7072 6f63 6174 696f 6e5f 7261 reciprocation_ra │ │ │ +0003c780: 7465 2c20 3136 3030 302c 206e 756c 6c70 te, 16000, nullp │ │ │ +0003c790: 7472 292c 0a09 0944 4550 5245 4341 5445 tr),...DEPRECATE │ │ │ +0003c7a0: 445f 5345 5428 696e 6372 6561 7365 5f65 D_SET(increase_e │ │ │ +0003c7b0: 7374 5f72 6563 6970 726f 6361 7469 6f6e st_reciprocation │ │ │ +0003c7c0: 5f72 6174 652c 2032 302c 206e 756c 6c70 _rate, 20, nullp │ │ │ +0003c7d0: 7472 292c 0a09 0944 4550 5245 4341 5445 tr),...DEPRECATE │ │ │ +0003c7e0: 445f 5345 5428 6465 6372 6561 7365 5f65 D_SET(decrease_e │ │ │ +0003c7f0: 7374 5f72 6563 6970 726f 6361 7469 6f6e st_reciprocation │ │ │ +0003c800: 5f72 6174 652c 2033 2c20 6e75 6c6c 7074 _rate, 3, nullpt │ │ │ +0003c810: 7229 2c0a 0909 5345 5428 6d61 785f 7065 r),...SET(max_pe │ │ │ +0003c820: 785f 7065 6572 732c 2035 302c 206e 756c x_peers, 50, nul │ │ │ +0003c830: 6c70 7472 292c 0a09 0953 4554 2874 6963 lptr),...SET(tic │ │ │ +0003c840: 6b5f 696e 7465 7276 616c 2c20 3530 302c k_interval, 500, │ │ │ +0003c850: 206e 756c 6c70 7472 292c 0a09 0953 4554 nullptr),...SET │ │ │ +0003c860: 2873 6861 7265 5f6d 6f64 655f 7461 7267 (share_mode_targ │ │ │ +0003c870: 6574 2c20 332c 206e 756c 6c70 7472 292c et, 3, nullptr), │ │ │ +0003c880: 0a09 0953 4554 2875 706c 6f61 645f 7261 ...SET(upload_ra │ │ │ +0003c890: 7465 5f6c 696d 6974 2c20 302c 2026 616d te_limit, 0, &am │ │ │ +0003c8a0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0003c8b0: 7570 6461 7465 5f75 706c 6f61 645f 7261 update_upload_ra │ │ │ +0003c8c0: 7465 292c 0a09 0953 4554 2864 6f77 6e6c te),...SET(downl │ │ │ +0003c8d0: 6f61 645f 7261 7465 5f6c 696d 6974 2c20 oad_rate_limit, │ │ │ +0003c8e0: 302c 2026 616d 703b 7365 7373 696f 6e5f 0, &session_ │ │ │ +0003c8f0: 696d 706c 3a3a 7570 6461 7465 5f64 6f77 impl::update_dow │ │ │ +0003c900: 6e6c 6f61 645f 7261 7465 292c 0a09 0944 nload_rate),...D │ │ │ +0003c910: 4550 5245 4341 5445 445f 5345 5428 6c6f EPRECATED_SET(lo │ │ │ +0003c920: 6361 6c5f 7570 6c6f 6164 5f72 6174 655f cal_upload_rate_ │ │ │ +0003c930: 6c69 6d69 742c 2030 2c20 2661 6d70 3b73 limit, 0, &s │ │ │ +0003c940: 6573 7369 6f6e 5f69 6d70 6c3a 3a75 7064 ession_impl::upd │ │ │ +0003c950: 6174 655f 6c6f 6361 6c5f 7570 6c6f 6164 ate_local_upload │ │ │ +0003c960: 5f72 6174 6529 2c0a 0909 4445 5052 4543 _rate),...DEPREC │ │ │ +0003c970: 4154 4544 5f53 4554 286c 6f63 616c 5f64 ATED_SET(local_d │ │ │ +0003c980: 6f77 6e6c 6f61 645f 7261 7465 5f6c 696d ownload_rate_lim │ │ │ +0003c990: 6974 2c20 302c 2026 616d 703b 7365 7373 it, 0, &sess │ │ │ +0003c9a0: 696f 6e5f 696d 706c 3a3a 7570 6461 7465 ion_impl::update │ │ │ +0003c9b0: 5f6c 6f63 616c 5f64 6f77 6e6c 6f61 645f _local_download_ │ │ │ +0003c9c0: 7261 7465 292c 0a09 0953 4554 2864 6874 rate),...SET(dht │ │ │ +0003c9d0: 5f75 706c 6f61 645f 7261 7465 5f6c 696d _upload_rate_lim │ │ │ +0003c9e0: 6974 2c20 3830 3030 2c20 2661 6d70 3b73 it, 8000, &s │ │ │ +0003c9f0: 6573 7369 6f6e 5f69 6d70 6c3a 3a75 7064 ession_impl::upd │ │ │ +0003ca00: 6174 655f 6468 745f 7570 6c6f 6164 5f72 ate_dht_upload_r │ │ │ +0003ca10: 6174 655f 6c69 6d69 7429 2c0a 0909 5345 ate_limit),...SE │ │ │ +0003ca20: 5428 756e 6368 6f6b 655f 736c 6f74 735f T(unchoke_slots_ │ │ │ +0003ca30: 6c69 6d69 742c 2038 2c20 2661 6d70 3b73 limit, 8, &s │ │ │ +0003ca40: 6573 7369 6f6e 5f69 6d70 6c3a 3a75 7064 ession_impl::upd │ │ │ +0003ca50: 6174 655f 756e 6368 6f6b 655f 6c69 6d69 ate_unchoke_limi │ │ │ +0003ca60: 7429 2c0a 0909 4445 5052 4543 4154 4544 t),...DEPRECATED │ │ │ +0003ca70: 5f53 4554 2868 616c 665f 6f70 656e 5f6c _SET(half_open_l │ │ │ +0003ca80: 696d 6974 2c20 302c 206e 756c 6c70 7472 imit, 0, nullptr │ │ │ +0003ca90: 292c 0a09 0953 4554 2863 6f6e 6e65 6374 ),...SET(connect │ │ │ +0003caa0: 696f 6e73 5f6c 696d 6974 2c20 3230 302c ions_limit, 200, │ │ │ +0003cab0: 2026 616d 703b 7365 7373 696f 6e5f 696d &session_im │ │ │ +0003cac0: 706c 3a3a 7570 6461 7465 5f63 6f6e 6e65 pl::update_conne │ │ │ +0003cad0: 6374 696f 6e73 5f6c 696d 6974 292c 0a09 ctions_limit),.. │ │ │ +0003cae0: 0953 4554 2863 6f6e 6e65 6374 696f 6e73 .SET(connections │ │ │ +0003caf0: 5f73 6c61 636b 2c20 3130 2c20 6e75 6c6c _slack, 10, null │ │ │ +0003cb00: 7074 7229 2c0a 0909 5345 5428 7574 705f ptr),...SET(utp_ │ │ │ +0003cb10: 7461 7267 6574 5f64 656c 6179 2c20 3130 target_delay, 10 │ │ │ +0003cb20: 302c 206e 756c 6c70 7472 292c 0a09 0953 0, nullptr),...S │ │ │ +0003cb30: 4554 2875 7470 5f67 6169 6e5f 6661 6374 ET(utp_gain_fact │ │ │ +0003cb40: 6f72 2c20 3330 3030 2c20 6e75 6c6c 7074 or, 3000, nullpt │ │ │ +0003cb50: 7229 2c0a 3c2f 7072 653e 3c2f 7464 3e3c r),.
    < │ │ │ +0003cb60: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0003cb90: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0003cbc0: 2e2f 7372 632f 7365 7474 696e 6773 5f70 ./src/settings_p │ │ │ +0003cbd0: 6163 6b2e 6370 703a 3537 343c 2f61 3e3c ack.cpp:574< │ │ │ +0003cbe0: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ +0003cbf0: 2062 6520 6e69 6365 2074 6f20 7265 7365 be nice to rese │ │ │ +0003cc00: 7276 6528 2920 7468 6573 6520 7665 6374 rve() these vect │ │ │ +0003cc10: 6f72 7320 7570 2066 726f 6e74 3c2f 7464 ors up front

    it wou │ │ │ +0003cc70: 6c64 2062 6520 6e69 6365 2074 6f20 7265 ld be nice to re │ │ │ +0003cc80: 7365 7276 6528 2920 7468 6573 6520 7665 serve() these ve │ │ │ +0003cc90: 6374 6f72 7320 7570 2066 726f 6e74 3c2f ctors up front

    ../src/se │ │ │ +0003ccb0: 7474 696e 6773 5f70 6163 6b2e 6370 703a ttings_pack.cpp: │ │ │ +0003ccc0: 3537 343c 2f68 343e 3c70 7265 2073 7479 574

    ...s.set_str(s
    │ │ │ +0003cd10: 6574 7469 6e67 735f 7061 636b 3a3a 7374  ettings_pack::st
    │ │ │ +0003cd20: 7269 6e67 5f74 7970 655f 6261 7365 207c  ring_type_base |
    │ │ │ +0003cd30: 2069 2c20 7374 725f 7365 7474 696e 6773   i, str_settings
    │ │ │ +0003cd40: 5b69 5d2e 6465 6661 756c 745f 7661 6c75  [i].default_valu
    │ │ │ +0003cd50: 6529 3b0a 0909 0954 4f52 5245 4e54 5f41  e);....TORRENT_A
    │ │ │ +0003cd60: 5353 4552 5428 732e 6765 745f 7374 7228  SSERT(s.get_str(
    │ │ │ +0003cd70: 7365 7474 696e 6773 5f70 6163 6b3a 3a73  settings_pack::s
    │ │ │ +0003cd80: 7472 696e 675f 7479 7065 5f62 6173 6520  tring_type_base 
    │ │ │ +0003cd90: 2b20 6929 203d 3d20 7374 725f 7365 7474  + i) == str_sett
    │ │ │ +0003cda0: 696e 6773 5b69 5d2e 6465 6661 756c 745f  ings[i].default_
    │ │ │ +0003cdb0: 7661 6c75 6529 3b0a 0909 7d0a 0a09 0966  value);...}....f
    │ │ │ +0003cdc0: 6f72 2028 696e 7420 6920 3d20 303b 2069  or (int i = 0; i
    │ │ │ +0003cdd0: 2026 6c74 3b20 7365 7474 696e 6773 5f70   < settings_p
    │ │ │ +0003cde0: 6163 6b3a 3a6e 756d 5f69 6e74 5f73 6574  ack::num_int_set
    │ │ │ +0003cdf0: 7469 6e67 733b 202b 2b69 290a 0909 7b0a  tings; ++i)...{.
    │ │ │ +0003ce00: 0909 0973 2e73 6574 5f69 6e74 2873 6574  ...s.set_int(set
    │ │ │ +0003ce10: 7469 6e67 735f 7061 636b 3a3a 696e 745f  tings_pack::int_
    │ │ │ +0003ce20: 7479 7065 5f62 6173 6520 7c20 692c 2069  type_base | i, i
    │ │ │ +0003ce30: 6e74 5f73 6574 7469 6e67 735b 695d 2e64  nt_settings[i].d
    │ │ │ +0003ce40: 6566 6175 6c74 5f76 616c 7565 293b 0a09  efault_value);..
    │ │ │ +0003ce50: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +0003ce60: 2873 2e67 6574 5f69 6e74 2873 6574 7469  (s.get_int(setti
    │ │ │ +0003ce70: 6e67 735f 7061 636b 3a3a 696e 745f 7479  ngs_pack::int_ty
    │ │ │ +0003ce80: 7065 5f62 6173 6520 2b20 6929 203d 3d20  pe_base + i) == 
    │ │ │ +0003ce90: 696e 745f 7365 7474 696e 6773 5b69 5d2e  int_settings[i].
    │ │ │ +0003cea0: 6465 6661 756c 745f 7661 6c75 6529 3b0a  default_value);.
    │ │ │ +0003ceb0: 0909 7d0a 0a09 0966 6f72 2028 696e 7420  ..}....for (int 
    │ │ │ +0003cec0: 6920 3d20 303b 2069 2026 6c74 3b20 7365  i = 0; i < se
    │ │ │ +0003ced0: 7474 696e 6773 5f70 6163 6b3a 3a6e 756d  ttings_pack::num
    │ │ │ +0003cee0: 5f62 6f6f 6c5f 7365 7474 696e 6773 3b20  _bool_settings; 
    │ │ │ +0003cef0: 2b2b 6929 0a09 097b 0a09 0909 732e 7365  ++i)...{....s.se
    │ │ │ +0003cf00: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ +0003cf10: 7061 636b 3a3a 626f 6f6c 5f74 7970 655f  pack::bool_type_
    │ │ │ +0003cf20: 6261 7365 207c 2069 2c20 626f 6f6c 5f73  base | i, bool_s
    │ │ │ +0003cf30: 6574 7469 6e67 735b 695d 2e64 6566 6175  ettings[i].defau
    │ │ │ +0003cf40: 6c74 5f76 616c 7565 293b 0a09 0909 544f  lt_value);....TO
    │ │ │ +0003cf50: 5252 454e 545f 4153 5345 5254 2873 2e67  RRENT_ASSERT(s.g
    │ │ │ +0003cf60: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ +0003cf70: 5f70 6163 6b3a 3a62 6f6f 6c5f 7479 7065  _pack::bool_type
    │ │ │ +0003cf80: 5f62 6173 6520 2b20 6929 203d 3d20 626f  _base + i) == bo
    │ │ │ +0003cf90: 6f6c 5f73 6574 7469 6e67 735b 695d 2e64  ol_settings[i].d
    │ │ │ +0003cfa0: 6566 6175 6c74 5f76 616c 7565 293b 0a09  efault_value);..
    │ │ │ +0003cfb0: 097d 0a09 7d0a 0a09 7365 7474 696e 6773  .}..}...settings
    │ │ │ +0003cfc0: 5f70 6163 6b20 6465 6661 756c 745f 7365  _pack default_se
    │ │ │ +0003cfd0: 7474 696e 6773 2829 0a09 7b0a 0909 7365  ttings()..{...se
    │ │ │ +0003cfe0: 7474 696e 6773 5f70 6163 6b20 7265 743b  ttings_pack ret;
    │ │ │ +0003cff0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0003d020: 0966 6f72 2028 696e 7420 6920 3d20 303b .for (int i = 0; │ │ │ +0003d030: 2069 2026 6c74 3b20 7365 7474 696e 6773 i < settings │ │ │ +0003d040: 5f70 6163 6b3a 3a6e 756d 5f73 7472 696e _pack::num_strin │ │ │ +0003d050: 675f 7365 7474 696e 6773 3b20 2b2b 6929 g_settings; ++i) │ │ │ +0003d060: 0a3c 2f64 6976 3e09 097b 0a09 0909 6966 .
    ..{....if │ │ │ +0003d070: 2028 7374 725f 7365 7474 696e 6773 5b69 (str_settings[i │ │ │ +0003d080: 5d2e 6465 6661 756c 745f 7661 6c75 652e ].default_value. │ │ │ +0003d090: 656d 7074 7928 2929 2063 6f6e 7469 6e75 empty()) continu │ │ │ +0003d0a0: 653b 0a09 0909 7265 742e 7365 745f 7374 e;....ret.set_st │ │ │ +0003d0b0: 7228 7365 7474 696e 6773 5f70 6163 6b3a r(settings_pack: │ │ │ +0003d0c0: 3a73 7472 696e 675f 7479 7065 5f62 6173 :string_type_bas │ │ │ +0003d0d0: 6520 2b20 692c 2073 7472 5f73 6574 7469 e + i, str_setti │ │ │ +0003d0e0: 6e67 735b 695d 2e64 6566 6175 6c74 5f76 ngs[i].default_v │ │ │ +0003d0f0: 616c 7565 293b 0a09 097d 0a0a 0909 666f alue);...}....fo │ │ │ +0003d100: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ +0003d110: 266c 743b 2073 6574 7469 6e67 735f 7061 < settings_pa │ │ │ +0003d120: 636b 3a3a 6e75 6d5f 696e 745f 7365 7474 ck::num_int_sett │ │ │ +0003d130: 696e 6773 3b20 2b2b 6929 0a09 097b 0a09 ings; ++i)...{.. │ │ │ +0003d140: 0909 7265 742e 7365 745f 696e 7428 7365 ..ret.set_int(se │ │ │ +0003d150: 7474 696e 6773 5f70 6163 6b3a 3a69 6e74 ttings_pack::int │ │ │ +0003d160: 5f74 7970 655f 6261 7365 202b 2069 2c20 _type_base + i, │ │ │ +0003d170: 696e 745f 7365 7474 696e 6773 5b69 5d2e int_settings[i]. │ │ │ +0003d180: 6465 6661 756c 745f 7661 6c75 6529 3b0a default_value);. │ │ │ +0003d190: 0909 7d0a 0a09 0966 6f72 2028 696e 7420 ..}....for (int │ │ │ +0003d1a0: 6920 3d20 303b 2069 2026 6c74 3b20 7365 i = 0; i < se │ │ │ +0003d1b0: 7474 696e 6773 5f70 6163 6b3a 3a6e 756d ttings_pack::num │ │ │ +0003d1c0: 5f62 6f6f 6c5f 7365 7474 696e 6773 3b20 _bool_settings; │ │ │ +0003d1d0: 2b2b 6929 0a09 097b 0a09 0909 7265 742e ++i)...{....ret. │ │ │ +0003d1e0: 7365 745f 626f 6f6c 2873 6574 7469 6e67 set_bool(setting │ │ │ +0003d1f0: 735f 7061 636b 3a3a 626f 6f6c 5f74 7970 s_pack::bool_typ │ │ │ +0003d200: 655f 6261 7365 202b 2069 2c20 626f 6f6c e_base + i, bool │ │ │ +0003d210: 5f73 6574 7469 6e67 735b 695d 2e64 6566 _settings[i].def │ │ │ +0003d220: 6175 6c74 5f76 616c 7565 293b 0a09 097d ault_value);...} │ │ │ +0003d230: 0a09 0972 6574 7572 6e20 7265 743b 0a09 ...return ret;.. │ │ │ +0003d240: 7d0a 0a09 766f 6964 2061 7070 6c79 5f70 }...void apply_p │ │ │ +0003d250: 6163 6b28 7365 7474 696e 6773 5f70 6163 ack(settings_pac │ │ │ +0003d260: 6b20 636f 6e73 742a 2070 6163 6b2c 2061 k const* pack, a │ │ │ +0003d270: 7578 3a3a 7365 7373 696f 6e5f 7365 7474 ux::session_sett │ │ │ +0003d280: 696e 6773 2661 6d70 3b20 7365 7474 0a09 ings& sett.. │ │ │ +0003d290: 092c 2061 7578 3a3a 7365 7373 696f 6e5f ., aux::session_ │ │ │ +0003d2a0: 696d 706c 2a20 7365 7329 0a09 7b0a 0909 impl* ses)..{... │ │ │ +0003d2b0: 7573 696e 6720 6675 6e5f 7420 3d20 766f using fun_t = vo │ │ │ +0003d2c0: 6964 2028 6175 783a 3a73 6573 7369 6f6e id (aux::session │ │ │ +0003d2d0: 5f69 6d70 6c3a 3a2a 2928 293b 0a09 0973 _impl::*)();...s │ │ │ +0003d2e0: 7464 3a3a 7665 6374 6f72 266c 743b 6675 td::vector<fu │ │ │ +0003d2f0: 6e5f 7426 6774 3b20 6361 6c6c 6261 636b n_t> callback │ │ │ +0003d300: 733b 0a0a 0909 7365 7474 2e62 756c 6b5f s;....sett.bulk_ │ │ │ +0003d310: 7365 7428 5b26 616d 703b 5d28 6175 783a set([&](aux: │ │ │ +0003d320: 3a73 6573 7369 6f6e 5f73 6574 7469 6e67 :session_setting │ │ │ +0003d330: 735f 7369 6e67 6c65 5f74 6872 6561 6426 s_single_thread& │ │ │ +0003d340: 616d 703b 2073 290a 0909 7b0a 0909 0961 amp; s)...{....a │ │ │ +0003d350: 7070 6c79 5f70 6163 6b5f 696d 706c 2870 pply_pack_impl(p │ │ │ +0003d360: 6163 6b2c 2073 2c20 7365 7320 3f20 2661 ack, s, ses ? &a │ │ │ +0003d370: 6d70 3b63 616c 6c62 6163 6b73 203a 206e mp;callbacks : n │ │ │ +0003d380: 756c 6c70 7472 293b 0a09 097d 293b 0a0a ullptr);...});.. │ │ │ +0003d390: 0909 2f2f 2063 616c 6c20 7468 6520 6361 ..// call the ca │ │ │ +0003d3a0: 6c6c 6261 636b 7320 6f6e 6365 2061 6c6c llbacks once all │ │ │ +0003d3b0: 2074 6865 2073 6574 7469 6e67 7320 6861 the settings ha │ │ │ +0003d3c0: 7665 2062 6565 6e20 6170 706c 6965 642c ve been applied, │ │ │ +0003d3d0: 2061 6e64 0a09 092f 2f20 6f6e 6c79 206f and...// only o │ │ │ +0003d3e0: 6e63 6520 7065 7220 6361 6c6c 6261 636b nce per callback │ │ │ +0003d3f0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0003d430: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +0003d460: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +0003d470: 6370 703a 3538 323c 2f61 3e3c 2f74 643e cpp:582 │ │ │ +0003d480: 3c74 643e 636f 6d65 2075 7020 7769 7468 come up with │ │ │ +0003d490: 2073 6f6d 6520 6162 7374 7261 6374 696f some abstractio │ │ │ +0003d4a0: 6e20 746f 2064 6f20 7468 6973 2066 6f72 n to do this for │ │ │ +0003d4b0: 2067 6e75 746c 7320 6173 2077 656c 6c20 gnutls as well │ │ │ +0003d4c0: 6c6f 6164 2063 6572 7469 6669 6361 7465 load certificate │ │ │ +0003d4d0: 7320 6672 6f6d 2074 6865 2077 696e 646f s from the windo │ │ │ +0003d4e0: 7773 2073 7973 7465 6d20 6365 7274 6966 ws system certif │ │ │ +0003d4f0: 6963 6174 6520 7374 6f72 653c 2f74 643e icate store │ │ │ +0003d500: 3c2f 7472 3e3c 7472 2069 643d 2231 3534

    come up │ │ │ +0003d550: 2077 6974 6820 736f 6d65 2061 6273 7472 with some abstr │ │ │ +0003d560: 6163 7469 6f6e 2074 6f20 646f 2074 6869 action to do thi │ │ │ +0003d570: 7320 666f 7220 676e 7574 6c73 2061 7320 s for gnutls as │ │ │ +0003d580: 7765 6c6c 0a6c 6f61 6420 6365 7274 6966 well.load certif │ │ │ +0003d590: 6963 6174 6573 2066 726f 6d20 7468 6520 icates from the │ │ │ +0003d5a0: 7769 6e64 6f77 7320 7379 7374 656d 2063 windows system c │ │ │ +0003d5b0: 6572 7469 6669 6361 7465 2073 746f 7265 ertificate store │ │ │ +0003d5c0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0003d5d0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +0003d5e0: 3a35 3832 3c2f 6834 3e3c 7072 6520 7374 :582

    ..pause();..}
    │ │ │ +0003d630: 0a23 656e 6469 660a 0a09 2f2f 2054 6869  .#endif...// Thi
    │ │ │ +0003d640: 7320 6675 6e63 7469 6f6e 2069 7320 6361  s function is ca
    │ │ │ +0003d650: 6c6c 6564 2062 7920 7468 6520 6372 6561  lled by the crea
    │ │ │ +0003d660: 7469 6e67 2074 6872 6561 642c 206e 6f74  ting thread, not
    │ │ │ +0003d670: 2069 6e20 7468 6520 6d65 7373 6167 6520   in the message 
    │ │ │ +0003d680: 6c6f 6f70 2773 0a09 2f2f 2069 6f5f 636f  loop's..// io_co
    │ │ │ +0003d690: 6e74 6578 7420 7468 7265 6164 2e0a 0976  ntext thread...v
    │ │ │ +0003d6a0: 6f69 6420 7365 7373 696f 6e5f 696d 706c  oid session_impl
    │ │ │ +0003d6b0: 3a3a 7374 6172 745f 7365 7373 696f 6e28  ::start_session(
    │ │ │ +0003d6c0: 290a 097b 0a23 6966 6e64 6566 2054 4f52  )..{.#ifndef TOR
    │ │ │ +0003d6d0: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ +0003d6e0: 4749 4e47 0a09 0973 6573 7369 6f6e 5f6c  GING...session_l
    │ │ │ +0003d6f0: 6f67 2822 7374 6172 7420 7365 7373 696f  og("start sessio
    │ │ │ +0003d700: 6e22 293b 0a23 656e 6469 660a 0a23 6966  n");.#endif..#if
    │ │ │ +0003d710: 2054 4f52 5245 4e54 5f55 5345 5f53 534c   TORRENT_USE_SSL
    │ │ │ +0003d720: 0a09 0965 7272 6f72 5f63 6f64 6520 6563  ...error_code ec
    │ │ │ +0003d730: 3b0a 0909 6d5f 7373 6c5f 6374 782e 7365  ;...m_ssl_ctx.se
    │ │ │ +0003d740: 745f 6465 6661 756c 745f 7665 7269 6679  t_default_verify
    │ │ │ +0003d750: 5f70 6174 6873 2865 6329 3b0a 2369 666e  _paths(ec);.#ifn
    │ │ │ +0003d760: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0003d770: 424c 455f 4c4f 4747 494e 470a 0909 6966  BLE_LOGGING...if
    │ │ │ +0003d780: 2028 6563 2920 7365 7373 696f 6e5f 6c6f   (ec) session_lo
    │ │ │ +0003d790: 6728 2253 534c 2073 6574 5f64 6566 6175  g("SSL set_defau
    │ │ │ +0003d7a0: 6c74 2076 6572 6966 795f 7061 7468 7320  lt verify_paths 
    │ │ │ +0003d7b0: 6661 696c 6564 3a20 2573 222c 2065 632e  failed: %s", ec.
    │ │ │ +0003d7c0: 6d65 7373 6167 6528 292e 635f 7374 7228  message().c_str(
    │ │ │ +0003d7d0: 2929 3b0a 0909 6563 2e63 6c65 6172 2829  ));...ec.clear()
    │ │ │ +0003d7e0: 3b0a 2365 6e64 6966 0a23 6966 2064 6566  ;.#endif.#if def
    │ │ │ +0003d7f0: 696e 6564 2054 4f52 5245 4e54 5f57 494e  ined TORRENT_WIN
    │ │ │ +0003d800: 444f 5753 2026 616d 703b 2661 6d70 3b20  DOWS && 
    │ │ │ +0003d810: 6465 6669 6e65 6420 544f 5252 454e 545f  defined TORRENT_
    │ │ │ +0003d820: 5553 455f 4f50 454e 5353 4c20 2661 6d70  USE_OPENSSL &
    │ │ │ +0003d830: 3b26 616d 703b 2021 6465 6669 6e65 6420  ;& !defined 
    │ │ │ +0003d840: 544f 5252 454e 545f 5749 4e52 540a 3c64  TORRENT_WINRT...X5
    │ │ │ +0003d880: 3039 5f53 544f 5245 2a20 7374 6f72 6520  09_STORE* store 
    │ │ │ +0003d890: 3d20 5835 3039 5f53 544f 5245 5f6e 6577  = X509_STORE_new
    │ │ │ +0003d8a0: 2829 3b0a 3c2f 6469 763e 0909 6966 2028  ();...if (
    │ │ │ +0003d8b0: 7374 6f72 6529 0a09 097b 0a09 0909 4843  store)...{....HC
    │ │ │ +0003d8c0: 4552 5453 544f 5245 2073 7973 7465 6d5f  ERTSTORE system_
    │ │ │ +0003d8d0: 7374 6f72 6520 3d20 4365 7274 4f70 656e  store = CertOpen
    │ │ │ +0003d8e0: 5379 7374 656d 5374 6f72 6541 2830 2c20  SystemStoreA(0, 
    │ │ │ +0003d8f0: 2252 4f4f 5422 293b 0a09 0909 2f2f 2074  "ROOT");....// t
    │ │ │ +0003d900: 6869 7320 6973 2062 6573 7420 6566 666f  his is best effo
    │ │ │ +0003d910: 7274 0a09 0909 6966 2028 7379 7374 656d  rt....if (system
    │ │ │ +0003d920: 5f73 746f 7265 290a 0909 097b 0a09 0909  _store)....{....
    │ │ │ +0003d930: 0943 4552 545f 434f 4e54 4558 5420 636f  .CERT_CONTEXT co
    │ │ │ +0003d940: 6e73 742a 2063 7478 203d 206e 756c 6c70  nst* ctx = nullp
    │ │ │ +0003d950: 7472 3b0a 0909 0909 7768 696c 6520 2828  tr;.....while ((
    │ │ │ +0003d960: 6374 7820 3d20 4365 7274 456e 756d 4365  ctx = CertEnumCe
    │ │ │ +0003d970: 7274 6966 6963 6174 6573 496e 5374 6f72  rtificatesInStor
    │ │ │ +0003d980: 6528 7379 7374 656d 5f73 746f 7265 2c20  e(system_store, 
    │ │ │ +0003d990: 6374 7829 2920 213d 206e 756c 6c70 7472  ctx)) != nullptr
    │ │ │ +0003d9a0: 290a 0909 0909 7b0a 0909 0909 0975 6e73  ).....{......uns
    │ │ │ +0003d9b0: 6967 6e65 6420 6368 6172 2063 6f6e 7374  igned char const
    │ │ │ +0003d9c0: 2a20 6365 7274 5f70 7472 203d 2072 6569  * cert_ptr = rei
    │ │ │ +0003d9d0: 6e74 6572 7072 6574 5f63 6173 7426 6c74  nterpret_cast<
    │ │ │ +0003d9e0: 3b75 6e73 6967 6e65 6420 6368 6172 2063  ;unsigned char c
    │ │ │ +0003d9f0: 6f6e 7374 2a26 6774 3b28 6374 782d 2667  onst*>(ctx-&g
    │ │ │ +0003da00: 743b 7062 4365 7274 456e 636f 6465 6429  t;pbCertEncoded)
    │ │ │ +0003da10: 3b0a 0909 0909 0958 3530 392a 2078 3530  ;......X509* x50
    │ │ │ +0003da20: 3920 3d20 6432 695f 5835 3039 286e 756c  9 = d2i_X509(nul
    │ │ │ +0003da30: 6c70 7472 2c20 2661 6d70 3b63 6572 745f  lptr, &cert_
    │ │ │ +0003da40: 7074 722c 2063 7478 2d26 6774 3b63 6243  ptr, ctx->cbC
    │ │ │ +0003da50: 6572 7445 6e63 6f64 6564 293b 0a09 0909  ertEncoded);....
    │ │ │ +0003da60: 0909 2f2f 2074 6869 7320 6973 2062 6573  ..// this is bes
    │ │ │ +0003da70: 7420 6566 666f 7274 0a09 0909 0909 6966  t effort......if
    │ │ │ +0003da80: 2028 2178 3530 3929 2063 6f6e 7469 6e75   (!x509) continu
    │ │ │ +0003da90: 653b 0a09 0909 0909 5835 3039 5f53 544f  e;......X509_STO
    │ │ │ +0003daa0: 5245 5f61 6464 5f63 6572 7428 7374 6f72  RE_add_cert(stor
    │ │ │ +0003dab0: 652c 2078 3530 3929 3b0a 0909 0909 0958  e, x509);......X
    │ │ │ +0003dac0: 3530 395f 6672 6565 2878 3530 3929 3b0a  509_free(x509);.
    │ │ │ +0003dad0: 0909 0909 7d0a 0909 0909 4365 7274 4672  ....}.....CertFr
    │ │ │ +0003dae0: 6565 4365 7274 6966 6963 6174 6543 6f6e  eeCertificateCon
    │ │ │ +0003daf0: 7465 7874 2863 7478 293b 0a09 0909 0943  text(ctx);.....C
    │ │ │ +0003db00: 6572 7443 6c6f 7365 5374 6f72 6528 7379  ertCloseStore(sy
    │ │ │ +0003db10: 7374 656d 5f73 746f 7265 2c20 3029 3b0a  stem_store, 0);.
    │ │ │ +0003db20: 0909 097d 0a09 097d 0a0a 0909 5353 4c5f  ...}...}....SSL_
    │ │ │ +0003db30: 4354 582a 2073 736c 5f63 7478 203d 206d  CTX* ssl_ctx = m
    │ │ │ +0003db40: 5f73 736c 5f63 7478 2e6e 6174 6976 655f  _ssl_ctx.native_
    │ │ │ +0003db50: 6861 6e64 6c65 2829 3b0a 0909 5353 4c5f  handle();...SSL_
    │ │ │ +0003db60: 4354 585f 7365 745f 6365 7274 5f73 746f  CTX_set_cert_sto
    │ │ │ +0003db70: 7265 2873 736c 5f63 7478 2c20 7374 6f72  re(ssl_ctx, stor
    │ │ │ +0003db80: 6529 3b0a 2365 6e64 6966 0a23 6966 6465  e);.#endif.#ifde
    │ │ │ +0003db90: 6620 5f5f 4150 504c 455f 5f0a 0909 6d5f  f __APPLE__...m_
    │ │ │ +0003dba0: 7373 6c5f 6374 782e 6c6f 6164 5f76 6572  ssl_ctx.load_ver
    │ │ │ +0003dbb0: 6966 795f 6669 6c65 2822 2f65 7463 2f73  ify_file("/etc/s
    │ │ │ +0003dbc0: 736c 2f63 6572 742e 7065 6d22 2c20 6563  sl/cert.pem", ec
    │ │ │ +0003dbd0: 293b 0a23 6966 6e64 6566 2054 4f52 5245  );.#ifndef TORRE
    │ │ │ +0003dbe0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749  NT_DISABLE_LOGGI
    │ │ │ +0003dbf0: 4e47 0a09 0969 6620 2865 6329 2073 6573  NG...if (ec) ses
    │ │ │ +0003dc00: 7369 6f6e 5f6c 6f67 2822 5353 4c20 6c6f  sion_log("SSL lo
    │ │ │ +0003dc10: 6164 5f76 6572 6966 795f 6669 6c65 2066  ad_verify_file f
    │ │ │ +0003dc20: 6169 6c65 643a 2025 7322 2c20 6563 2e6d  ailed: %s", ec.m
    │ │ │ +0003dc30: 6573 7361 6765 2829 2e63 5f73 7472 2829  essage().c_str()
    │ │ │ +0003dc40: 293b 0a23 656e 6469 660a 0909 6563 2e63  );.#endif...ec.c
    │ │ │ +0003dc50: 6c65 6172 2829 3b0a 3c2f 7072 653e 3c2f  lear();.
    relevan │ │ │ +0003dc90: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/sessio │ │ │ +0003dcd0: 6e5f 696d 706c 2e63 7070 3a31 3435 343c n_impl.cpp:1454< │ │ │ +0003dce0: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ +0003dcf0: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ +0003dd00: 7265 7365 7276 6528 2920 7468 6573 6520 reserve() these │ │ │ +0003dd10: 7665 6374 6f72 7320 7570 2066 726f 6e74 vectors up front │ │ │ +0003dd20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ +0003dd70: 2077 6f75 6c64 2062 6520 6e69 6365 2074 would be nice t │ │ │ +0003dd80: 6f20 7265 7365 7276 6528 2920 7468 6573 o reserve() thes │ │ │ +0003dd90: 6520 7665 6374 6f72 7320 7570 2066 726f e vectors up fro │ │ │ +0003dda0: 6e74 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 nt

    ../sr │ │ │ +0003ddb0: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +0003ddc0: 7070 3a31 3435 343c 2f68 343e 3c70 7265 pp:1454

    ...bandwid
    │ │ │ +0003de10: 7468 5f63 6861 6e6e 656c 2a20 6368 203d  th_channel* ch =
    │ │ │ +0003de20: 2026 616d 703b 702d 2667 743b 6368 616e   &p->chan
    │ │ │ +0003de30: 6e65 6c5b 7065 6572 5f63 6f6e 6e65 6374  nel[peer_connect
    │ │ │ +0003de40: 696f 6e3a 3a64 6f77 6e6c 6f61 645f 6368  ion::download_ch
    │ │ │ +0003de50: 616e 6e65 6c5d 3b0a 0909 0969 6620 2875  annel];....if (u
    │ │ │ +0003de60: 7365 5f71 756f 7461 5f6f 7665 7268 6561  se_quota_overhea
    │ │ │ +0003de70: 6428 6368 2c20 616d 6f75 6e74 5f64 6f77  d(ch, amount_dow
    │ │ │ +0003de80: 6e29 290a 0909 0909 7265 7420 7c3d 2031  n)).....ret |= 1
    │ │ │ +0003de90: 7520 266c 743b 266c 743b 2070 6565 725f  u << peer_
    │ │ │ +0003dea0: 636f 6e6e 6563 7469 6f6e 3a3a 646f 776e  connection::down
    │ │ │ +0003deb0: 6c6f 6164 5f63 6861 6e6e 656c 3b0a 0909  load_channel;...
    │ │ │ +0003dec0: 0963 6820 3d20 2661 6d70 3b70 2d26 6774  .ch = &p->
    │ │ │ +0003ded0: 3b63 6861 6e6e 656c 5b70 6565 725f 636f  ;channel[peer_co
    │ │ │ +0003dee0: 6e6e 6563 7469 6f6e 3a3a 7570 6c6f 6164  nnection::upload
    │ │ │ +0003def0: 5f63 6861 6e6e 656c 5d3b 0a09 0909 6966  _channel];....if
    │ │ │ +0003df00: 2028 7573 655f 7175 6f74 615f 6f76 6572   (use_quota_over
    │ │ │ +0003df10: 6865 6164 2863 682c 2061 6d6f 756e 745f  head(ch, amount_
    │ │ │ +0003df20: 7570 2929 0a09 0909 0972 6574 207c 3d20  up)).....ret |= 
    │ │ │ +0003df30: 3175 2026 6c74 3b26 6c74 3b20 7065 6572  1u << peer
    │ │ │ +0003df40: 5f63 6f6e 6e65 6374 696f 6e3a 3a75 706c  _connection::upl
    │ │ │ +0003df50: 6f61 645f 6368 616e 6e65 6c3b 0a09 097d  oad_channel;...}
    │ │ │ +0003df60: 0a09 0972 6574 7572 6e20 7265 743b 0a09  ...return ret;..
    │ │ │ +0003df70: 7d0a 0a09 2f2f 2073 6573 7369 6f6e 5f69  }...// session_i
    │ │ │ +0003df80: 6d70 6c20 6973 2072 6573 706f 6e73 6962  mpl is responsib
    │ │ │ +0003df90: 6c65 2066 6f72 2064 656c 6574 696e 6720  le for deleting 
    │ │ │ +0003dfa0: 2770 6163 6b27 0a09 766f 6964 2073 6573  'pack'..void ses
    │ │ │ +0003dfb0: 7369 6f6e 5f69 6d70 6c3a 3a61 7070 6c79  sion_impl::apply
    │ │ │ +0003dfc0: 5f73 6574 7469 6e67 735f 7061 636b 2873  _settings_pack(s
    │ │ │ +0003dfd0: 7464 3a3a 7368 6172 6564 5f70 7472 266c  td::shared_ptr&l
    │ │ │ +0003dfe0: 743b 7365 7474 696e 6773 5f70 6163 6b26  t;settings_pack&
    │ │ │ +0003dff0: 6774 3b20 7061 636b 290a 097b 0a09 0949  gt; pack)..{...I
    │ │ │ +0003e000: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a  NVARIANT_CHECK;.
    │ │ │ +0003e010: 0909 6170 706c 795f 7365 7474 696e 6773  ..apply_settings
    │ │ │ +0003e020: 5f70 6163 6b5f 696d 706c 282a 7061 636b  _pack_impl(*pack
    │ │ │ +0003e030: 293b 0a09 7d0a 0a09 7365 7474 696e 6773  );..}...settings
    │ │ │ +0003e040: 5f70 6163 6b20 7365 7373 696f 6e5f 696d  _pack session_im
    │ │ │ +0003e050: 706c 3a3a 6765 745f 7365 7474 696e 6773  pl::get_settings
    │ │ │ +0003e060: 2829 2063 6f6e 7374 0a09 7b0a 0909 7365  () const..{...se
    │ │ │ +0003e070: 7474 696e 6773 5f70 6163 6b20 7265 743b  ttings_pack ret;
    │ │ │ +0003e080: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0003e0b0: 0966 6f72 2028 696e 7420 6920 3d20 7365 .for (int i = se │ │ │ +0003e0c0: 7474 696e 6773 5f70 6163 6b3a 3a73 7472 ttings_pack::str │ │ │ +0003e0d0: 696e 675f 7479 7065 5f62 6173 653b 0a3c ing_type_base;.< │ │ │ +0003e0e0: 2f64 6976 3e09 0909 6920 266c 743b 2073 /div>...i < s │ │ │ +0003e0f0: 6574 7469 6e67 735f 7061 636b 3a3a 6d61 ettings_pack::ma │ │ │ +0003e100: 785f 7374 7269 6e67 5f73 6574 7469 6e67 x_string_setting │ │ │ +0003e110: 5f69 6e74 6572 6e61 6c3b 202b 2b69 290a _internal; ++i). │ │ │ +0003e120: 0909 7b0a 0909 0972 6574 2e73 6574 5f73 ..{....ret.set_s │ │ │ +0003e130: 7472 2869 2c20 6d5f 7365 7474 696e 6773 tr(i, m_settings │ │ │ +0003e140: 2e67 6574 5f73 7472 2869 2929 3b0a 0909 .get_str(i));... │ │ │ +0003e150: 7d0a 0909 666f 7220 2869 6e74 2069 203d }...for (int i = │ │ │ +0003e160: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ +0003e170: 696e 745f 7479 7065 5f62 6173 653b 0a09 int_type_base;.. │ │ │ +0003e180: 0909 6920 266c 743b 2073 6574 7469 6e67 ..i < setting │ │ │ +0003e190: 735f 7061 636b 3a3a 6d61 785f 696e 745f s_pack::max_int_ │ │ │ +0003e1a0: 7365 7474 696e 675f 696e 7465 726e 616c setting_internal │ │ │ +0003e1b0: 3b20 2b2b 6929 0a09 097b 0a09 0909 7265 ; ++i)...{....re │ │ │ +0003e1c0: 742e 7365 745f 696e 7428 692c 206d 5f73 t.set_int(i, m_s │ │ │ +0003e1d0: 6574 7469 6e67 732e 6765 745f 696e 7428 ettings.get_int( │ │ │ +0003e1e0: 6929 293b 0a09 097d 0a09 0966 6f72 2028 i));...}...for ( │ │ │ +0003e1f0: 696e 7420 6920 3d20 7365 7474 696e 6773 int i = settings │ │ │ +0003e200: 5f70 6163 6b3a 3a62 6f6f 6c5f 7479 7065 _pack::bool_type │ │ │ +0003e210: 5f62 6173 653b 0a09 0909 6920 266c 743b _base;....i < │ │ │ +0003e220: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ +0003e230: 6d61 785f 626f 6f6c 5f73 6574 7469 6e67 max_bool_setting │ │ │ +0003e240: 5f69 6e74 6572 6e61 6c3b 202b 2b69 290a _internal; ++i). │ │ │ +0003e250: 0909 7b0a 0909 0972 6574 2e73 6574 5f62 ..{....ret.set_b │ │ │ +0003e260: 6f6f 6c28 692c 206d 5f73 6574 7469 6e67 ool(i, m_setting │ │ │ +0003e270: 732e 6765 745f 626f 6f6c 2869 2929 3b0a s.get_bool(i));. │ │ │ +0003e280: 0909 7d0a 0909 7265 7475 726e 2072 6574 ..}...return ret │ │ │ +0003e290: 3b0a 097d 0a0a 6e61 6d65 7370 6163 6520 ;..}..namespace │ │ │ +0003e2a0: 7b0a 0974 656d 706c 6174 6520 266c 743b {..template < │ │ │ +0003e2b0: 7479 7065 6e61 6d65 2050 6163 6b26 6774 typename Pack> │ │ │ +0003e2c0: 3b0a 0969 6e74 2067 6574 5f73 6574 7469 ;..int get_setti │ │ │ +0003e2d0: 6e67 5f69 6d70 6c28 5061 636b 2063 6f6e ng_impl(Pack con │ │ │ +0003e2e0: 7374 2661 6d70 3b20 702c 2069 6e74 206e st& p, int n │ │ │ +0003e2f0: 616d 652c 2069 6e74 2a29 0a09 7b20 7265 ame, int*)..{ re │ │ │ +0003e300: 7475 726e 2070 2e67 6574 5f69 6e74 286e turn p.get_int(n │ │ │ +0003e310: 616d 6529 3b20 7d0a 0a09 7465 6d70 6c61 ame); }...templa │ │ │ +0003e320: 7465 2026 6c74 3b74 7970 656e 616d 6520 te <typename │ │ │ +0003e330: 5061 636b 2667 743b 0a09 626f 6f6c 2067 Pack>..bool g │ │ │ +0003e340: 6574 5f73 6574 7469 6e67 5f69 6d70 6c28 et_setting_impl( │ │ │ +0003e350: 5061 636b 2063 6f6e 7374 2661 6d70 3b20 Pack const& │ │ │ +0003e360: 702c 2069 6e74 206e 616d 652c 2062 6f6f p, int name, boo │ │ │ +0003e370: 6c2a 290a 097b 2072 6574 7572 6e20 702e l*)..{ return p. │ │ │ +0003e380: 6765 745f 626f 6f6c 286e 616d 6529 3b20 get_bool(name); │ │ │ +0003e390: 7d0a 0a09 7465 6d70 6c61 7465 2026 6c74 }...template < │ │ │ +0003e3a0: 3b74 7970 656e 616d 6520 5061 636b 2667 ;typename Pack&g │ │ │ +0003e3b0: 743b 0a09 7374 643a 3a73 7472 696e 6720 t;..std::string │ │ │ +0003e3c0: 6765 745f 7365 7474 696e 675f 696d 706c get_setting_impl │ │ │ +0003e3d0: 2850 6163 6b20 636f 6e73 7426 616d 703b (Pack const& │ │ │ +0003e3e0: 2070 2c20 696e 7420 6e61 6d65 2c20 7374 p, int name, st │ │ │ +0003e3f0: 643a 3a73 7472 696e 672a 290a 097b 2072 d::string*)..{ r │ │ │ +0003e400: 6574 7572 6e20 702e 6765 745f 7374 7228 eturn p.get_str( │ │ │ +0003e410: 6e61 6d65 293b 207d 0a0a 3c2f 7072 653e name); }..
    │ │ │ +0003e420: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0003e450: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0003e460: 3c74 643e 3c61 2068 7265 663d 226a 6176
    ../src/sess │ │ │ +0003e490: 696f 6e5f 696d 706c 2e63 7070 3a31 3938 ion_impl.cpp:198 │ │ │ +0003e4a0: 393c 2f61 3e3c 2f74 643e 3c74 643e 636f 9co │ │ │ +0003e4b0: 756c 6420 7468 6973 2066 756e 6374 696f uld this functio │ │ │ +0003e4c0: 6e20 6265 206d 6572 6765 6420 7769 7468 n be merged with │ │ │ +0003e4d0: 2065 7870 616e 645f 756e 7370 6563 6966 expand_unspecif │ │ │ +0003e4e0: 6965 645f 6164 6472 6573 7365 733f 2072 ied_addresses? r │ │ │ +0003e4f0: 6967 6874 206e 6f77 2062 6f74 6820 6c69 ight now both li │ │ │ +0003e500: 7374 656e 5f65 6e64 706f 696e 745f 7420 sten_endpoint_t │ │ │ +0003e510: 616e 6420 6c69 7374 656e 5f69 6e74 6572 and listen_inter │ │ │ +0003e520: 6661 6365 5f74 2061 7265 2061 6c6d 6f73 face_t are almos │ │ │ +0003e530: 7420 6964 656e 7469 6361 6c2c 206d 6179 t identical, may │ │ │ +0003e540: 6265 2074 6865 206c 6174 7465 7220 636f be the latter co │ │ │ +0003e550: 756c 6420 6265 2072 656d 6f76 6564 2074 uld be removed t │ │ │ +0003e560: 6f6f 3c2f 7464 3e3c 2f74 723e 3c74 7220 oo

    │ │ │ +0003e5b0: 636f 756c 6420 7468 6973 2066 756e 6374 could this funct │ │ │ +0003e5c0: 696f 6e20 6265 206d 6572 6765 6420 7769 ion be merged wi │ │ │ +0003e5d0: 7468 2065 7870 616e 645f 756e 7370 6563 th expand_unspec │ │ │ +0003e5e0: 6966 6965 645f 6164 6472 6573 7365 733f ified_addresses? │ │ │ +0003e5f0: 0a72 6967 6874 206e 6f77 2062 6f74 6820 .right now both │ │ │ +0003e600: 6c69 7374 656e 5f65 6e64 706f 696e 745f listen_endpoint_ │ │ │ +0003e610: 7420 616e 6420 6c69 7374 656e 5f69 6e74 t and listen_int │ │ │ +0003e620: 6572 6661 6365 5f74 2061 7265 2061 6c6d erface_t are alm │ │ │ +0003e630: 6f73 740a 6964 656e 7469 6361 6c2c 206d ost.identical, m │ │ │ +0003e640: 6179 6265 2074 6865 206c 6174 7465 7220 aybe the latter │ │ │ +0003e650: 636f 756c 6420 6265 2072 656d 6f76 6564 could be removed │ │ │ +0003e660: 2074 6f6f 3c2f 6832 3e3c 6834 3e2e 2e2f too

    ../ │ │ │ +0003e670: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ +0003e680: 2e63 7070 3a31 3938 393c 2f68 343e 3c70 .cpp:1989

    ..sessio │ │ │ +0003e6d0: 6e5f 6c6f 6728 2246 4154 414c 2053 4553 n_log("FATAL SES │ │ │ +0003e6e0: 5349 4f4e 2045 5252 4f52 2028 2573 203a SION ERROR (%s : │ │ │ +0003e6f0: 2025 6429 205b 2573 5d22 0a09 0909 2c20 %d) [%s]"...., │ │ │ +0003e700: 6563 2e63 6174 6567 6f72 7928 292e 6e61 ec.category().na │ │ │ +0003e710: 6d65 2829 2c20 6563 2e76 616c 7565 2829 me(), ec.value() │ │ │ +0003e720: 2c20 6563 2e6d 6573 7361 6765 2829 2e63 , ec.message().c │ │ │ +0003e730: 5f73 7472 2829 293b 0a23 656e 6469 660a _str());.#endif. │ │ │ +0003e740: 0909 7468 6973 2d26 6774 3b61 626f 7274 ..this->abort │ │ │ +0003e750: 2829 3b0a 097d 0a0a 0976 6f69 6420 7365 ();..}...void se │ │ │ +0003e760: 7373 696f 6e5f 696d 706c 3a3a 6f6e 5f69 ssion_impl::on_i │ │ │ +0003e770: 705f 6368 616e 6765 2865 7272 6f72 5f63 p_change(error_c │ │ │ +0003e780: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ +0003e790: 6329 0a09 7b0a 2369 666e 6465 6620 544f c)..{.#ifndef TO │ │ │ +0003e7a0: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ +0003e7b0: 4747 494e 470a 0909 6966 2028 2165 6329 GGING...if (!ec) │ │ │ +0003e7c0: 0a09 0909 7365 7373 696f 6e5f 6c6f 6728 ....session_log( │ │ │ +0003e7d0: 2272 6563 6569 7665 6420 6970 2063 6861 "received ip cha │ │ │ +0003e7e0: 6e67 6520 6672 6f6d 2069 6e74 6572 6e61 nge from interna │ │ │ +0003e7f0: 6c20 6970 5f6e 6f74 6966 6965 7222 293b l ip_notifier"); │ │ │ +0003e800: 0a09 0965 6c73 650a 0909 0973 6573 7369 ...else....sessi │ │ │ +0003e810: 6f6e 5f6c 6f67 2822 7265 6365 6976 6564 on_log("received │ │ │ +0003e820: 2065 7272 6f72 206f 6e5f 6970 5f63 6861 error on_ip_cha │ │ │ +0003e830: 6e67 653a 2025 642c 2025 7322 2c20 6563 nge: %d, %s", ec │ │ │ +0003e840: 2e76 616c 7565 2829 2c20 6563 2e6d 6573 .value(), ec.mes │ │ │ +0003e850: 7361 6765 2829 2e63 5f73 7472 2829 293b sage().c_str()); │ │ │ +0003e860: 0a23 656e 6469 660a 0909 6966 2028 6563 .#endif...if (ec │ │ │ +0003e870: 207c 7c20 6d5f 6162 6f72 7420 7c7c 2021 || m_abort || ! │ │ │ +0003e880: 6d5f 6970 5f6e 6f74 6966 6965 7229 2072 m_ip_notifier) r │ │ │ +0003e890: 6574 7572 6e3b 0a09 096d 5f69 705f 6e6f eturn;...m_ip_no │ │ │ +0003e8a0: 7469 6669 6572 2d26 6774 3b61 7379 6e63 tifier->async │ │ │ +0003e8b0: 5f77 6169 7428 5b74 6869 735d 2028 6572 _wait([this] (er │ │ │ +0003e8c0: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ +0003e8d0: 6d70 3b20 6529 0a09 0909 7b20 7772 6170 mp; e)....{ wrap │ │ │ +0003e8e0: 2826 616d 703b 7365 7373 696f 6e5f 696d (&session_im │ │ │ +0003e8f0: 706c 3a3a 6f6e 5f69 705f 6368 616e 6765 pl::on_ip_change │ │ │ +0003e900: 2c20 6529 3b20 7d29 3b0a 0909 7265 6f70 , e); });...reop │ │ │ +0003e910: 656e 5f6e 6574 776f 726b 5f73 6f63 6b65 en_network_socke │ │ │ +0003e920: 7473 287b 7d29 3b0a 097d 0a0a 3c64 6976 ts({});..}..

    .void │ │ │ +0003e960: 696e 7465 7266 6163 655f 746f 5f65 6e64 interface_to_end │ │ │ +0003e970: 706f 696e 7473 286c 6973 7465 6e5f 696e points(listen_in │ │ │ +0003e980: 7465 7266 6163 655f 7420 636f 6e73 7426 terface_t const& │ │ │ +0003e990: 616d 703b 2069 6661 6365 0a3c 2f64 6976 amp; iface.
    .., listen_sock │ │ │ +0003e9b0: 6574 5f66 6c61 6773 5f74 2066 6c61 6773 et_flags_t flags │ │ │ +0003e9c0: 0a09 092c 2073 7061 6e26 6c74 3b69 705f ..., span<ip_ │ │ │ +0003e9d0: 696e 7465 7266 6163 6520 636f 6e73 7426 interface const& │ │ │ +0003e9e0: 6774 3b20 636f 6e73 7420 6966 730a 0909 gt; const ifs... │ │ │ +0003e9f0: 2c20 7374 643a 3a76 6563 746f 7226 6c74 , std::vector< │ │ │ +0003ea00: 3b6c 6973 7465 6e5f 656e 6470 6f69 6e74 ;listen_endpoint │ │ │ +0003ea10: 5f74 2667 743b 2661 6d70 3b20 6570 7329 _t>& eps) │ │ │ +0003ea20: 0a09 7b0a 0909 666c 6167 7320 7c3d 2069 ..{...flags |= i │ │ │ +0003ea30: 6661 6365 2e6c 6f63 616c 203f 206c 6973 face.local ? lis │ │ │ +0003ea40: 7465 6e5f 736f 636b 6574 5f74 3a3a 6c6f ten_socket_t::lo │ │ │ +0003ea50: 6361 6c5f 6e65 7477 6f72 6b20 3a20 6c69 cal_network : li │ │ │ +0003ea60: 7374 656e 5f73 6f63 6b65 745f 666c 6167 sten_socket_flag │ │ │ +0003ea70: 735f 747b 7d3b 0a09 0974 7261 6e73 706f s_t{};...transpo │ │ │ +0003ea80: 7274 2063 6f6e 7374 2073 736c 203d 2069 rt const ssl = i │ │ │ +0003ea90: 6661 6365 2e73 736c 203f 2074 7261 6e73 face.ssl ? trans │ │ │ +0003eaa0: 706f 7274 3a3a 7373 6c20 3a20 7472 616e port::ssl : tran │ │ │ +0003eab0: 7370 6f72 743a 3a70 6c61 696e 7465 7874 sport::plaintext │ │ │ +0003eac0: 3b0a 0a09 092f 2f20 4669 7273 742c 2063 ;....// First, c │ │ │ +0003ead0: 6865 636b 2074 6f20 7365 6520 6966 2069 heck to see if i │ │ │ +0003eae0: 7427 7320 616e 2049 5020 6164 6472 6573 t's an IP addres │ │ │ +0003eaf0: 730a 0909 6572 726f 725f 636f 6465 2065 s...error_code e │ │ │ +0003eb00: 7272 3b0a 0909 6164 6472 6573 7320 636f rr;...address co │ │ │ +0003eb10: 6e73 7420 6164 7220 3d20 6d61 6b65 5f61 nst adr = make_a │ │ │ +0003eb20: 6464 7265 7373 2869 6661 6365 2e64 6576 ddress(iface.dev │ │ │ +0003eb30: 6963 652e 635f 7374 7228 292c 2065 7272 ice.c_str(), err │ │ │ +0003eb40: 293b 0a09 0969 6620 2821 6572 7229 0a09 );...if (!err).. │ │ │ +0003eb50: 097b 0a09 0909 6570 732e 656d 706c 6163 .{....eps.emplac │ │ │ +0003eb60: 655f 6261 636b 2861 6472 2c20 6966 6163 e_back(adr, ifac │ │ │ +0003eb70: 652e 706f 7274 2c20 7374 643a 3a73 7472 e.port, std::str │ │ │ +0003eb80: 696e 677b 7d2c 2073 736c 2c20 666c 6167 ing{}, ssl, flag │ │ │ +0003eb90: 7329 3b0a 0909 7d0a 0909 656c 7365 0a09 s);...}...else.. │ │ │ +0003eba0: 097b 0a09 0909 666c 6167 7320 7c3d 206c .{....flags |= l │ │ │ +0003ebb0: 6973 7465 6e5f 736f 636b 6574 5f74 3a3a isten_socket_t:: │ │ │ +0003ebc0: 7761 735f 6578 7061 6e64 6564 3b0a 0a09 was_expanded;... │ │ │ +0003ebd0: 0909 2f2f 2074 6869 7320 6973 2074 6865 ..// this is the │ │ │ +0003ebe0: 2063 6173 6520 7768 6572 6520 6465 7669 case where devi │ │ │ +0003ebf0: 6365 206e 616d 6573 2061 206e 6574 776f ce names a netwo │ │ │ +0003ec00: 726b 2064 6576 6963 652e 2057 6520 6e65 rk device. We ne │ │ │ +0003ec10: 6564 2074 6f0a 0909 092f 2f20 656e 756d ed to....// enum │ │ │ +0003ec20: 6572 6174 6520 616c 6c20 4950 7320 6173 erate all IPs as │ │ │ +0003ec30: 736f 6369 6174 6564 2077 6974 6820 7468 sociated with th │ │ │ +0003ec40: 6973 2064 6576 6963 650a 0909 0966 6f72 is device....for │ │ │ +0003ec50: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ +0003ec60: 3b20 6970 6661 6365 203a 2069 6673 290a ; ipface : ifs). │ │ │ +0003ec70: 0909 097b 0a09 0909 092f 2f20 7765 2772 ...{.....// we'r │ │ │ +0003ec80: 6520 6c6f 6f6b 696e 6720 666f 7220 6120 e looking for a │ │ │ +0003ec90: 7370 6563 6966 6963 2069 6e74 6572 6661 specific interfa │ │ │ +0003eca0: 6365 2c20 616e 6420 6974 7320 6164 6472 ce, and its addr │ │ │ +0003ecb0: 6573 730a 0909 0909 2f2f 2028 7768 6963 ess.....// (whic │ │ │ +0003ecc0: 6820 6d75 7374 2062 6520 6f66 2074 6865 h must be of the │ │ │ +0003ecd0: 2073 616d 6520 6661 6d69 6c79 2061 7320 same family as │ │ │ +0003ece0: 7468 6520 6164 6472 6573 7320 7765 2772 the address we'r │ │ │ +0003ecf0: 650a 0909 0909 2f2f 2063 6f6e 6e65 6374 e.....// connect │ │ │ +0003ed00: 696e 6720 746f 290a 0909 0909 6966 2028 ing to).....if ( │ │ │ +0003ed10: 6966 6163 652e 6465 7669 6365 2021 3d20 iface.device != │ │ │ +0003ed20: 6970 6661 6365 2e6e 616d 6529 2063 6f6e ipface.name) con │ │ │ +0003ed30: 7469 6e75 653b 0a0a 0909 0909 626f 6f6c tinue;......bool │ │ │ +0003ed40: 2063 6f6e 7374 206c 6f63 616c 203d 2069 const local = i │ │ │ +0003ed50: 6661 6365 2e6c 6f63 616c 0a09 0909 0909 face.local...... │ │ │ +0003ed60: 7c7c 2069 7066 6163 652e 696e 7465 7266 || ipface.interf │ │ │ +0003ed70: 6163 655f 6164 6472 6573 732e 6973 5f6c ace_address.is_l │ │ │ +0003ed80: 6f6f 7062 6163 6b28 290a 0909 0909 097c oopback()......| │ │ │ +0003ed90: 7c20 6973 5f6c 696e 6b5f 6c6f 6361 6c28 | is_link_local( │ │ │ +0003eda0: 6970 6661 6365 2e69 6e74 6572 6661 6365 ipface.interface │ │ │ +0003edb0: 5f61 6464 7265 7373 293b 0a3c 2f70 7265 _address);.
    rele │ │ │ +0003edf0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ +0003ee30: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3233 sion_impl.cpp:23 │ │ │ +0003ee40: 3031 3c2f 613e 3c2f 7464 3e3c 7464 3e69 01i │ │ │ +0003ee50: 7420 776f 756c 6420 7072 6f62 6162 6c79 t would probably │ │ │ +0003ee60: 2062 6520 6265 7474 6572 2074 6f20 646f be better to do │ │ │ +0003ee70: 2074 6869 7320 6279 2068 6176 696e 6720 this by having │ │ │ +0003ee80: 6120 6c69 7374 656e 2d73 6f63 6b65 7420 a listen-socket │ │ │ +0003ee90: 2276 6572 7369 6f6e 2220 6e75 6d62 6572 "version" number │ │ │ +0003eea0: 2074 6861 7420 6765 7473 2062 756d 7065 that gets bumpe │ │ │ +0003eeb0: 642e 2041 6e64 2069 6e73 7465 6164 206f d. And instead o │ │ │ +0003eec0: 6620 7365 7474 696e 6720 6120 626f 6f6c f setting a bool │ │ │ +0003eed0: 2074 6f20 6469 7361 626c 6520 6120 7472 to disable a tr │ │ │ +0003eee0: 6163 6b65 722c 2077 6520 7365 7420 7468 acker, we set th │ │ │ +0003eef0: 6520 7665 7273 696f 6e20 6e75 6d62 6572 e version number │ │ │ +0003ef00: 2074 6861 7420 6974 2077 6173 2064 6973 that it was dis │ │ │ +0003ef10: 6162 6c65 6420 6174 2e20 5468 6973 2063 abled at. This c │ │ │ +0003ef20: 6861 6e67 6520 776f 756c 6420 6166 6665 hange would affe │ │ │ +0003ef30: 6374 2074 6865 2041 4249 2069 6e20 312e ct the ABI in 1. │ │ │ +0003ef40: 322c 2073 6f20 7368 6f75 6c64 2062 6520 2, so should be │ │ │ +0003ef50: 646f 6e65 2069 6e20 322e 3020 6f72 206c done in 2.0 or l │ │ │ +0003ef60: 6174 6572 3c2f 7464 3e3c 2f74 723e 3c74 aterit would proba │ │ │ +0003efc0: 626c 7920 6265 2062 6574 7465 7220 746f bly be better to │ │ │ +0003efd0: 2064 6f20 7468 6973 2062 7920 6861 7669 do this by havi │ │ │ +0003efe0: 6e67 2061 0a6c 6973 7465 6e2d 736f 636b ng a.listen-sock │ │ │ +0003eff0: 6574 2022 7665 7273 696f 6e22 206e 756d et "version" num │ │ │ +0003f000: 6265 7220 7468 6174 2067 6574 7320 6275 ber that gets bu │ │ │ +0003f010: 6d70 6564 2e20 416e 6420 696e 7374 6561 mped. And instea │ │ │ +0003f020: 6420 6f66 0a73 6574 7469 6e67 2061 2062 d of.setting a b │ │ │ +0003f030: 6f6f 6c20 746f 2064 6973 6162 6c65 2061 ool to disable a │ │ │ +0003f040: 2074 7261 636b 6572 2c20 7765 2073 6574 tracker, we set │ │ │ +0003f050: 2074 6865 2076 6572 7369 6f6e 206e 756d the version num │ │ │ +0003f060: 6265 7220 7468 6174 0a69 7420 7761 7320 ber that.it was │ │ │ +0003f070: 6469 7361 626c 6564 2061 742e 2054 6869 disabled at. Thi │ │ │ +0003f080: 7320 6368 616e 6765 2077 6f75 6c64 2061 s change would a │ │ │ +0003f090: 6666 6563 7420 7468 6520 4142 4920 696e ffect the ABI in │ │ │ +0003f0a0: 2031 2e32 2c20 736f 0a73 686f 756c 6420 1.2, so.should │ │ │ +0003f0b0: 6265 2064 6f6e 6520 696e 2032 2e30 206f be done in 2.0 o │ │ │ +0003f0c0: 7220 6c61 7465 723c 2f68 323e 3c68 343e r later

    │ │ │ +0003f0d0: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ +0003f0e0: 6d70 6c2e 6370 703a 3233 3031 3c2f 6834 mpl.cpp:2301

    ..{..
    │ │ │ +0003f130: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ +0003f140: 7426 616d 703b 2073 203a 206d 5f6c 6973  t& s : m_lis
    │ │ │ +0003f150: 7465 6e5f 736f 636b 6574 7329 0a09 0909  ten_sockets)....
    │ │ │ +0003f160: 0972 656d 6170 5f70 6f72 7473 2872 656d  .remap_ports(rem
    │ │ │ +0003f170: 6170 5f6e 6174 706d 705f 616e 645f 7570  ap_natpmp_and_up
    │ │ │ +0003f180: 6e70 2c20 2a73 293b 0a09 097d 0a09 0965  np, *s);...}...e
    │ │ │ +0003f190: 6c73 650a 0909 7b0a 0909 092f 2f20 6e65  lse...{....// ne
    │ │ │ +0003f1a0: 7720 736f 636b 6574 7320 6e65 6564 2074  w sockets need t
    │ │ │ +0003f1b0: 6f20 6d61 7020 706f 7274 7320 6576 656e  o map ports even
    │ │ │ +0003f1c0: 2069 6620 7468 6520 6361 6c6c 6572 2064   if the caller d
    │ │ │ +0003f1d0: 6964 206e 6f74 2072 6571 7565 7374 0a09  id not request..
    │ │ │ +0003f1e0: 0909 2f2f 2072 652d 6d61 7070 696e 670a  ..// re-mapping.
    │ │ │ +0003f1f0: 0909 0966 6f72 2028 6175 746f 2063 6f6e  ...for (auto con
    │ │ │ +0003f200: 7374 2661 6d70 3b20 7320 3a20 6e65 775f  st& s : new_
    │ │ │ +0003f210: 736f 636b 6574 7329 0a09 0909 0972 656d  sockets).....rem
    │ │ │ +0003f220: 6170 5f70 6f72 7473 2872 656d 6170 5f6e  ap_ports(remap_n
    │ │ │ +0003f230: 6174 706d 705f 616e 645f 7570 6e70 2c20  atpmp_and_upnp, 
    │ │ │ +0003f240: 2a73 293b 0a09 097d 0a0a 0909 7570 6461  *s);...}....upda
    │ │ │ +0003f250: 7465 5f6c 7364 2829 3b0a 0a23 6966 2054  te_lsd();..#if T
    │ │ │ +0003f260: 4f52 5245 4e54 5f55 5345 5f49 3250 0a09  ORRENT_USE_I2P..
    │ │ │ +0003f270: 096f 7065 6e5f 6e65 775f 696e 636f 6d69  .open_new_incomi
    │ │ │ +0003f280: 6e67 5f69 3270 5f63 6f6e 6e65 6374 696f  ng_i2p_connectio
    │ │ │ +0003f290: 6e28 293b 0a23 656e 6469 660a 0a09 092f  n();.#endif..../
    │ │ │ +0003f2a0: 2f20 7472 6163 6b65 7273 2074 6861 7420  / trackers that 
    │ │ │ +0003f2b0: 7765 7265 206e 6f74 2072 6561 6368 6162  were not reachab
    │ │ │ +0003f2c0: 6c65 2c20 6d61 7920 6861 7665 2062 6563  le, may have bec
    │ │ │ +0003f2d0: 6f6d 6520 7265 6163 6861 626c 6520 6e6f  ome reachable no
    │ │ │ +0003f2e0: 772e 0a09 092f 2f20 736f 2063 6c65 6172  w....// so clear
    │ │ │ +0003f2f0: 2074 6865 2022 6469 7361 626c 6564 2220   the "disabled" 
    │ │ │ +0003f300: 666c 6167 7320 746f 206c 6574 2074 6865  flags to let the
    │ │ │ +0003f310: 6d20 6265 2074 7269 6564 206f 6e65 206d  m be tried one m
    │ │ │ +0003f320: 6f72 6520 7469 6d65 0a3c 6469 7620 7374  ore time.
    ..for (au │ │ │ +0003f360: 746f 2661 6d70 3b20 7420 3a20 6d5f 746f to& t : m_to │ │ │ +0003f370: 7272 656e 7473 290a 3c2f 6469 763e 0909 rrents).
    .. │ │ │ +0003f380: 0974 2d26 6774 3b65 6e61 626c 655f 616c .t->enable_al │ │ │ +0003f390: 6c5f 7472 6163 6b65 7273 2829 3b0a 097d l_trackers();..} │ │ │ +0003f3a0: 0a0a 0976 6f69 6420 7365 7373 696f 6e5f ...void session_ │ │ │ +0003f3b0: 696d 706c 3a3a 7265 6f70 656e 5f6e 6574 impl::reopen_net │ │ │ +0003f3c0: 776f 726b 5f73 6f63 6b65 7473 2872 656f work_sockets(reo │ │ │ +0003f3d0: 7065 6e5f 6e65 7477 6f72 6b5f 666c 6167 pen_network_flag │ │ │ +0003f3e0: 735f 7420 636f 6e73 7420 6f70 7469 6f6e s_t const option │ │ │ +0003f3f0: 7329 0a09 7b0a 0909 7265 6f70 656e 5f6c s)..{...reopen_l │ │ │ +0003f400: 6973 7465 6e5f 736f 636b 6574 7328 626f isten_sockets(bo │ │ │ +0003f410: 6f6c 286f 7074 696f 6e73 2026 616d 703b ol(options & │ │ │ +0003f420: 2073 6573 7369 6f6e 5f68 616e 646c 653a session_handle: │ │ │ +0003f430: 3a72 656f 7065 6e5f 6d61 705f 706f 7274 :reopen_map_port │ │ │ +0003f440: 7329 293b 0a09 7d0a 0a09 6e61 6d65 7370 s));..}...namesp │ │ │ +0003f450: 6163 6520 7b0a 0909 7465 6d70 6c61 7465 ace {...template │ │ │ +0003f460: 2026 6c74 3b74 7970 656e 616d 6520 4d61 <typename Ma │ │ │ +0003f470: 7050 726f 746f 636f 6c2c 2074 7970 656e pProtocol, typen │ │ │ +0003f480: 616d 6520 5072 6f74 6f54 7970 652c 2074 ame ProtoType, t │ │ │ +0003f490: 7970 656e 616d 6520 456e 6470 6f69 6e74 ypename Endpoint │ │ │ +0003f4a0: 5479 7065 2667 743b 0a09 0976 6f69 6420 Type>...void │ │ │ +0003f4b0: 6d61 705f 706f 7274 284d 6170 5072 6f74 map_port(MapProt │ │ │ +0003f4c0: 6f63 6f6c 2661 6d70 3b20 6d2c 2050 726f ocol& m, Pro │ │ │ +0003f4d0: 746f 5479 7065 2070 726f 746f 636f 6c2c toType protocol, │ │ │ +0003f4e0: 2045 6e64 706f 696e 7454 7970 6520 636f EndpointType co │ │ │ +0003f4f0: 6e73 7426 616d 703b 2065 700a 0909 092c nst& ep...., │ │ │ +0003f500: 2070 6f72 745f 6d61 7070 696e 675f 7426 port_mapping_t& │ │ │ +0003f510: 616d 703b 206d 6170 5f68 616e 646c 652c amp; map_handle, │ │ │ +0003f520: 2073 7464 3a3a 7374 7269 6e67 2063 6f6e std::string con │ │ │ +0003f530: 7374 2661 6d70 3b20 6465 7669 6365 290a st& device). │ │ │ +0003f540: 0909 7b0a 0909 0969 6620 286d 6170 5f68 ..{....if (map_h │ │ │ +0003f550: 616e 646c 6520 213d 2070 6f72 745f 6d61 andle != port_ma │ │ │ +0003f560: 7070 696e 675f 747b 2d31 7d29 206d 2e64 pping_t{-1}) m.d │ │ │ +0003f570: 656c 6574 655f 6d61 7070 696e 6728 6d61 elete_mapping(ma │ │ │ +0003f580: 705f 6861 6e64 6c65 293b 0a09 0909 6d61 p_handle);....ma │ │ │ +0003f590: 705f 6861 6e64 6c65 203d 2070 6f72 745f p_handle = port_ │ │ │ +0003f5a0: 6d61 7070 696e 675f 747b 2d31 7d3b 0a0a mapping_t{-1};.. │ │ │ +0003f5b0: 0909 0961 6464 7265 7373 2063 6f6e 7374 ...address const │ │ │ +0003f5c0: 2061 6464 7220 3d20 6570 2e61 6464 7265 addr = ep.addre │ │ │ +0003f5d0: 7373 2829 3b0a 0909 092f 2f20 7769 7468 ss();....// with │ │ │ +0003f5e0: 2049 5076 3420 7468 6520 696e 7465 7266 IPv4 the interf │ │ │ +0003f5f0: 6163 6520 6d69 6768 7420 6265 2062 6568 ace might be beh │ │ │ +0003f600: 696e 6420 4e41 5420 736f 2077 6520 6361 ind NAT so we ca │ │ │ +0003f610: 6e27 7420 736b 6970 2074 6865 6d0a 0909 n't skip them... │ │ │ +0003f620: 092f 2f20 6261 7365 6420 6f6e 2074 6865 .// based on the │ │ │ +0003f630: 2073 636f 7065 206f 6620 7468 6520 6c6f scope of the lo │ │ │ +0003f640: 6361 6c20 6164 6472 6573 730a 0909 0969 cal address....i │ │ │ +0003f650: 6620 2861 6464 722e 6973 5f76 3628 2920 f (addr.is_v6() │ │ │ +0003f660: 2661 6d70 3b26 616d 703b 2069 735f 6c6f && is_lo │ │ │ +0003f670: 6361 6c28 6164 6472 2929 0a09 0909 0972 cal(addr)).....r │ │ │ +0003f680: 6574 7572 6e3b 0a0a 0909 092f 2f20 6f6e eturn;.....// on │ │ │ +0003f690: 6c79 2075 7064 6174 6520 7468 6973 206d ly update this m │ │ │ +0003f6a0: 6170 7069 6e67 2069 6620 7765 2061 6374 apping if we act │ │ │ +0003f6b0: 7561 6c6c 7920 6861 7665 2061 2073 6f63 ually have a soc │ │ │ +0003f6c0: 6b65 7420 6c69 7374 656e 696e 670a 0909 ket listening... │ │ │ +0003f6d0: 0969 6620 2865 7020 213d 2045 6e64 706f .if (ep != Endpo │ │ │ +0003f6e0: 696e 7454 7970 6528 2929 0a09 0909 096d intType()).....m │ │ │ +0003f6f0: 6170 5f68 616e 646c 6520 3d20 6d2e 6164 ap_handle = m.ad │ │ │ +0003f700: 645f 6d61 7070 696e 6728 7072 6f74 6f63 d_mapping(protoc │ │ │ +0003f710: 6f6c 2c20 6570 2e70 6f72 7428 292c 2065 ol, ep.port(), e │ │ │ +0003f720: 702c 2064 6576 6963 6529 3b0a 0909 7d0a p, device);...}. │ │ │ +0003f730: 097d 0a0a 0976 6f69 6420 7365 7373 696f .}...void sessio │ │ │ +0003f740: 6e5f 696d 706c 3a3a 7265 6d61 705f 706f n_impl::remap_po │ │ │ +0003f750: 7274 7328 7265 6d61 705f 706f 7274 5f6d rts(remap_port_m │ │ │ +0003f760: 6173 6b5f 7420 636f 6e73 7420 6d61 736b ask_t const mask │ │ │ +0003f770: 0a09 092c 206c 6973 7465 6e5f 736f 636b ..., listen_sock │ │ │ +0003f780: 6574 5f74 2661 6d70 3b20 7329 0a3c 2f70 et_t& s).

    re │ │ │ +0003f7c0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/s │ │ │ +0003f800: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ +0003f810: 3239 3430 3c2f 613e 3c2f 7464 3e3c 7464 2940this size need │ │ │ +0003f830: 746f 2062 6520 6361 7070 6564 3c2f 7464 to be capped

    this s │ │ │ +0003f890: 697a 6520 6e65 6564 2074 6f20 6265 2063 ize need to be c │ │ │ +0003f8a0: 6170 7065 643c 2f68 323e 3c68 343e 2e2e apped

    .. │ │ │ +0003f8b0: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +0003f8c0: 6c2e 6370 703a 3239 3430 3c2f 6834 3e3c l.cpp:2940

    < │ │ │ +0003f8d0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0003f8e0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0003f8f0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0003f900: 7820 2364 6464 3b22 3e09 0909 092f 2f20 x #ddd;">....// │ │ │ +0003f910: 6861 6e64 7368 616b 696e 670a 0909 0909 handshaking..... │ │ │ +0003f920: 7265 7475 726e 2073 6f63 6b65 745f 7479 return socket_ty │ │ │ +0003f930: 7065 2873 736c 5f73 7472 6561 6d26 6c74 pe(ssl_stream< │ │ │ +0003f940: 3b74 6370 3a3a 736f 636b 6574 2667 743b ;tcp::socket> │ │ │ +0003f950: 2874 6370 3a3a 736f 636b 6574 2873 7464 (tcp::socket(std │ │ │ +0003f960: 3a3a 6d6f 7665 2873 2929 2c20 6d5f 7065 ::move(s)), m_pe │ │ │ +0003f970: 6572 5f73 736c 5f63 7478 2929 3b0a 0909 er_ssl_ctx));... │ │ │ +0003f980: 097d 0a09 0909 656c 7365 0a23 656e 6469 .}....else.#endi │ │ │ +0003f990: 660a 0909 097b 0a09 0909 0972 6574 7572 f....{.....retur │ │ │ +0003f9a0: 6e20 736f 636b 6574 5f74 7970 6528 7463 n socket_type(tc │ │ │ +0003f9b0: 703a 3a73 6f63 6b65 7428 7374 643a 3a6d p::socket(std::m │ │ │ +0003f9c0: 6f76 6528 7329 2929 3b0a 0909 097d 0a09 ove(s)));....}.. │ │ │ +0003f9d0: 097d 2829 3b0a 0a23 6966 6465 6620 544f .}();..#ifdef TO │ │ │ +0003f9e0: 5252 454e 545f 5353 4c5f 5045 4552 530a RRENT_SSL_PEERS. │ │ │ +0003f9f0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0003fa00: 2828 7373 6c20 3d3d 2074 7261 6e73 706f ((ssl == transpo │ │ │ +0003fa10: 7274 3a3a 7373 6c29 203d 3d20 6973 5f73 rt::ssl) == is_s │ │ │ +0003fa20: 736c 2863 2929 3b0a 2365 6e64 6966 0a0a sl(c));.#endif.. │ │ │ +0003fa30: 2369 6664 6566 2054 4f52 5245 4e54 5f53 #ifdef TORRENT_S │ │ │ +0003fa40: 534c 5f50 4545 5253 0a09 0969 6620 2873 SL_PEERS...if (s │ │ │ +0003fa50: 736c 203d 3d20 7472 616e 7370 6f72 743a sl == transport: │ │ │ +0003fa60: 3a73 736c 290a 0909 7b0a 0909 0954 4f52 :ssl)...{....TOR │ │ │ +0003fa70: 5245 4e54 5f41 5353 4552 5428 6973 5f73 RENT_ASSERT(is_s │ │ │ +0003fa80: 736c 2863 2929 3b0a 0a09 0909 2f2f 2073 sl(c));.....// s │ │ │ +0003fa90: 6176 6520 7468 6520 736f 636b 6574 2073 ave the socket s │ │ │ +0003faa0: 6f20 7765 2063 616e 2063 616e 6365 6c20 o we can cancel │ │ │ +0003fab0: 7468 6520 6861 6e64 7368 616b 650a 3c64 the handshake....a │ │ │ +0003faf0: 7574 6f20 6974 6572 203d 206d 5f69 6e63 uto iter = m_inc │ │ │ +0003fb00: 6f6d 696e 675f 736f 636b 6574 732e 656d oming_sockets.em │ │ │ +0003fb10: 706c 6163 6528 7374 643a 3a6d 616b 655f place(std::make_ │ │ │ +0003fb20: 756e 6971 7565 266c 743b 736f 636b 6574 unique<socket │ │ │ +0003fb30: 5f74 7970 6526 6774 3b28 7374 643a 3a6d _type>(std::m │ │ │ +0003fb40: 6f76 6528 6329 2929 2e66 6972 7374 3b0a ove(c))).first;. │ │ │ +0003fb50: 3c2f 6469 763e 0a09 0909 6175 746f 2073 ....auto s │ │ │ +0003fb60: 6f63 6b20 3d20 6974 6572 2d26 6774 3b67 ock = iter->g │ │ │ +0003fb70: 6574 2829 3b0a 0909 092f 2f20 666f 7220 et();....// for │ │ │ +0003fb80: 5353 4c20 636f 6e6e 6563 7469 6f6e 732c SSL connections, │ │ │ +0003fb90: 2069 6e63 6f6d 696e 675f 636f 6e6e 6563 incoming_connec │ │ │ +0003fba0: 7469 6f6e 2829 2069 7320 6361 6c6c 6564 tion() is called │ │ │ +0003fbb0: 0a09 0909 2f2f 2061 6674 6572 2074 6865 ....// after the │ │ │ +0003fbc0: 2068 616e 6473 6861 6b65 2069 7320 646f handshake is do │ │ │ +0003fbd0: 6e65 0a09 0909 4144 445f 4f55 5453 5441 ne....ADD_OUTSTA │ │ │ +0003fbe0: 4e44 494e 475f 4153 594e 4328 2273 6573 NDING_ASYNC("ses │ │ │ +0003fbf0: 7369 6f6e 5f69 6d70 6c3a 3a73 736c 5f68 sion_impl::ssl_h │ │ │ +0003fc00: 616e 6473 6861 6b65 2229 3b0a 0909 0973 andshake");....s │ │ │ +0003fc10: 7464 3a3a 6765 7426 6c74 3b73 736c 5f73 td::get<ssl_s │ │ │ +0003fc20: 7472 6561 6d26 6c74 3b74 6370 3a3a 736f tream<tcp::so │ │ │ +0003fc30: 636b 6574 2667 743b 2667 743b 282a 2a69 cket>>(**i │ │ │ +0003fc40: 7465 7229 2e61 7379 6e63 5f61 6363 6570 ter).async_accep │ │ │ +0003fc50: 745f 6861 6e64 7368 616b 6528 0a09 0909 t_handshake(.... │ │ │ +0003fc60: 095b 7468 6973 2c20 736f 636b 5d20 2865 .[this, sock] (e │ │ │ +0003fc70: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ +0003fc80: 616d 703b 2065 7272 2920 7b20 7373 6c5f amp; err) { ssl_ │ │ │ +0003fc90: 6861 6e64 7368 616b 6528 6572 722c 2073 handshake(err, s │ │ │ +0003fca0: 6f63 6b29 3b20 7d29 3b0a 0909 7d0a 0909 ock); });...}... │ │ │ +0003fcb0: 656c 7365 0a23 656e 6469 660a 0909 7b0a else.#endif...{. │ │ │ +0003fcc0: 0909 0969 6e63 6f6d 696e 675f 636f 6e6e ...incoming_conn │ │ │ +0003fcd0: 6563 7469 6f6e 2873 7464 3a3a 6d6f 7665 ection(std::move │ │ │ +0003fce0: 2863 2929 3b0a 0909 7d0a 097d 0a0a 2369 (c));...}..}..#i │ │ │ +0003fcf0: 6664 6566 2054 4f52 5245 4e54 5f53 534c fdef TORRENT_SSL │ │ │ +0003fd00: 5f50 4545 5253 0a0a 0976 6f69 6420 7365 _PEERS...void se │ │ │ +0003fd10: 7373 696f 6e5f 696d 706c 3a3a 6f6e 5f69 ssion_impl::on_i │ │ │ +0003fd20: 6e63 6f6d 696e 675f 7574 705f 7373 6c28 ncoming_utp_ssl( │ │ │ +0003fd30: 736f 636b 6574 5f74 7970 6520 7329 0a09 socket_type s).. │ │ │ +0003fd40: 7b0a 0909 544f 5252 454e 545f 4153 5345 {...TORRENT_ASSE │ │ │ +0003fd50: 5254 2869 735f 7373 6c28 7329 293b 0a0a RT(is_ssl(s));.. │ │ │ +0003fd60: 0909 2f2f 2073 6176 6520 7468 6520 736f ..// save the so │ │ │ +0003fd70: 636b 6574 2073 6f20 7765 2063 616e 2063 cket so we can c │ │ │ +0003fd80: 616e 6365 6c20 7468 6520 6861 6e64 7368 ancel the handsh │ │ │ +0003fd90: 616b 650a 0a3c 2f70 7265 3e3c 2f74 643e ake..
    │ │ │ +0003fda0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +0003fdd0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +0003fde0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +0003fdf0: 7074 3a65 7870 616e 6428 3135 3929 223e pt:expand(159)"> │ │ │ +0003fe00: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ +0003fe10: 6d70 6c2e 6370 703a 3239 3635 3c2f 613e mpl.cpp:2965 │ │ │ +0003fe20: 3c2f 7464 3e3c 7464 3e74 6869 7320 7369 this si │ │ │ +0003fe30: 7a65 206e 6565 6420 746f 2062 6520 6361 ze need to be ca │ │ │ +0003fe40: 7070 6564 3c2f 7464 3e3c 2f74 723e 3c74 ppedthis size need │ │ │ +0003fea0: 2074 6f20 6265 2063 6170 7065 643c 2f68 to be capped

    ../src/ses │ │ │ +0003fec0: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3239 sion_impl.cpp:29 │ │ │ +0003fed0: 3635 3c2f 6834 3e3c 7072 6520 7374 796c 65

    ...// after the
    │ │ │ +0003ff20: 2068 616e 6473 6861 6b65 2069 7320 646f   handshake is do
    │ │ │ +0003ff30: 6e65 0a09 0909 4144 445f 4f55 5453 5441  ne....ADD_OUTSTA
    │ │ │ +0003ff40: 4e44 494e 475f 4153 594e 4328 2273 6573  NDING_ASYNC("ses
    │ │ │ +0003ff50: 7369 6f6e 5f69 6d70 6c3a 3a73 736c 5f68  sion_impl::ssl_h
    │ │ │ +0003ff60: 616e 6473 6861 6b65 2229 3b0a 0909 0973  andshake");....s
    │ │ │ +0003ff70: 7464 3a3a 6765 7426 6c74 3b73 736c 5f73  td::get<ssl_s
    │ │ │ +0003ff80: 7472 6561 6d26 6c74 3b74 6370 3a3a 736f  tream<tcp::so
    │ │ │ +0003ff90: 636b 6574 2667 743b 2667 743b 282a 2a69  cket>>(**i
    │ │ │ +0003ffa0: 7465 7229 2e61 7379 6e63 5f61 6363 6570  ter).async_accep
    │ │ │ +0003ffb0: 745f 6861 6e64 7368 616b 6528 0a09 0909  t_handshake(....
    │ │ │ +0003ffc0: 095b 7468 6973 2c20 736f 636b 5d20 2865  .[this, sock] (e
    │ │ │ +0003ffd0: 7272 6f72 5f63 6f64 6520 636f 6e73 7426  rror_code const&
    │ │ │ +0003ffe0: 616d 703b 2065 7272 2920 7b20 7373 6c5f  amp; err) { ssl_
    │ │ │ +0003fff0: 6861 6e64 7368 616b 6528 6572 722c 2073  handshake(err, s
    │ │ │ +00040000: 6f63 6b29 3b20 7d29 3b0a 0909 7d0a 0909  ock); });...}...
    │ │ │ +00040010: 656c 7365 0a23 656e 6469 660a 0909 7b0a  else.#endif...{.
    │ │ │ +00040020: 0909 0969 6e63 6f6d 696e 675f 636f 6e6e  ...incoming_conn
    │ │ │ +00040030: 6563 7469 6f6e 2873 7464 3a3a 6d6f 7665  ection(std::move
    │ │ │ +00040040: 2863 2929 3b0a 0909 7d0a 097d 0a0a 2369  (c));...}..}..#i
    │ │ │ +00040050: 6664 6566 2054 4f52 5245 4e54 5f53 534c  fdef TORRENT_SSL
    │ │ │ +00040060: 5f50 4545 5253 0a0a 0976 6f69 6420 7365  _PEERS...void se
    │ │ │ +00040070: 7373 696f 6e5f 696d 706c 3a3a 6f6e 5f69  ssion_impl::on_i
    │ │ │ +00040080: 6e63 6f6d 696e 675f 7574 705f 7373 6c28  ncoming_utp_ssl(
    │ │ │ +00040090: 736f 636b 6574 5f74 7970 6520 7329 0a09  socket_type s)..
    │ │ │ +000400a0: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ +000400b0: 5254 2869 735f 7373 6c28 7329 293b 0a0a  RT(is_ssl(s));..
    │ │ │ +000400c0: 0909 2f2f 2073 6176 6520 7468 6520 736f  ..// save the so
    │ │ │ +000400d0: 636b 6574 2073 6f20 7765 2063 616e 2063  cket so we can c
    │ │ │ +000400e0: 616e 6365 6c20 7468 6520 6861 6e64 7368  ancel the handsh
    │ │ │ +000400f0: 616b 650a 0a3c 6469 7620 7374 796c 653d  ake..
    ..auto iter = │ │ │ +00040130: 206d 5f69 6e63 6f6d 696e 675f 736f 636b m_incoming_sock │ │ │ +00040140: 6574 732e 656d 706c 6163 6528 7374 643a ets.emplace(std: │ │ │ +00040150: 3a6d 616b 655f 756e 6971 7565 266c 743b :make_unique< │ │ │ +00040160: 736f 636b 6574 5f74 7970 6526 6774 3b28 socket_type>( │ │ │ +00040170: 7374 643a 3a6d 6f76 6528 7329 2929 2e66 std::move(s))).f │ │ │ +00040180: 6972 7374 3b0a 3c2f 6469 763e 0909 6175 irst;.
    ..au │ │ │ +00040190: 746f 2073 6f63 6b20 3d20 6974 6572 2d26 to sock = iter-& │ │ │ +000401a0: 6774 3b67 6574 2829 3b0a 0a09 092f 2f20 gt;get();....// │ │ │ +000401b0: 666f 7220 5353 4c20 636f 6e6e 6563 7469 for SSL connecti │ │ │ +000401c0: 6f6e 732c 2069 6e63 6f6d 696e 675f 636f ons, incoming_co │ │ │ +000401d0: 6e6e 6563 7469 6f6e 2829 2069 7320 6361 nnection() is ca │ │ │ +000401e0: 6c6c 6564 0a09 092f 2f20 6166 7465 7220 lled...// after │ │ │ +000401f0: 7468 6520 6861 6e64 7368 616b 6520 6973 the handshake is │ │ │ +00040200: 2064 6f6e 650a 0909 4144 445f 4f55 5453 done...ADD_OUTS │ │ │ +00040210: 5441 4e44 494e 475f 4153 594e 4328 2273 TANDING_ASYNC("s │ │ │ +00040220: 6573 7369 6f6e 5f69 6d70 6c3a 3a73 736c ession_impl::ssl │ │ │ +00040230: 5f68 616e 6473 6861 6b65 2229 3b0a 0909 _handshake");... │ │ │ +00040240: 7374 643a 3a67 6574 266c 743b 7373 6c5f std::get<ssl_ │ │ │ +00040250: 7374 7265 616d 266c 743b 7574 705f 7374 stream<utp_st │ │ │ +00040260: 7265 616d 2667 743b 2667 743b 282a 2a69 ream>>(**i │ │ │ +00040270: 7465 7229 2e61 7379 6e63 5f61 6363 6570 ter).async_accep │ │ │ +00040280: 745f 6861 6e64 7368 616b 6528 0a09 0909 t_handshake(.... │ │ │ +00040290: 5b74 6869 732c 2073 6f63 6b5d 2028 6572 [this, sock] (er │ │ │ +000402a0: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ +000402b0: 6d70 3b20 6572 7229 207b 2073 736c 5f68 mp; err) { ssl_h │ │ │ +000402c0: 616e 6473 6861 6b65 2865 7272 2c20 736f andshake(err, so │ │ │ +000402d0: 636b 293b 207d 293b 0a09 7d0a 0a09 2f2f ck); });..}...// │ │ │ +000402e0: 2074 6f20 7465 7374 2053 534c 2063 6f6e to test SSL con │ │ │ +000402f0: 6e65 6374 696f 6e73 2c20 6f6e 6520 6361 nections, one ca │ │ │ +00040300: 6e20 7573 6520 7468 6973 206f 7065 6e73 n use this opens │ │ │ +00040310: 736c 2063 6f6d 6d61 6e64 2074 656d 706c sl command templ │ │ │ +00040320: 6174 653a 0a09 2f2f 0a09 2f2f 206f 7065 ate:..//..// ope │ │ │ +00040330: 6e73 736c 2073 5f63 6c69 656e 7420 2d63 nssl s_client -c │ │ │ +00040340: 6572 7420 266c 743b 636c 6965 6e74 2d63 ert <client-c │ │ │ +00040350: 6572 7426 6774 3b2e 7065 6d20 2d6b 6579 ert>.pem -key │ │ │ +00040360: 2026 6c74 3b63 6c69 656e 742d 7072 6976 <client-priv │ │ │ +00040370: 6174 652d 6b65 7926 6774 3b2e 7065 6d0a ate-key>.pem. │ │ │ +00040380: 092f 2f20 2020 2d43 4166 696c 6520 266c .// -CAfile &l │ │ │ +00040390: 743b 746f 7272 656e 742d 6365 7274 2667 t;torrent-cert&g │ │ │ +000403a0: 743b 2e70 656d 2020 2d64 6562 7567 202d t;.pem -debug - │ │ │ +000403b0: 636f 6e6e 6563 7420 3132 372e 302e 302e connect 127.0.0. │ │ │ +000403c0: 313a 3434 3333 202d 746c 7331 0a09 2f2f 1:4433 -tls1..// │ │ │ +000403d0: 2020 202d 7365 7276 6572 6e61 6d65 2026 -servername & │ │ │ +000403e0: 6c74 3b68 6578 2d65 6e63 6f64 6564 2d69 lt;hex-encoded-i │ │ │ +000403f0: 6e66 6f2d 6861 7368 2667 743b 0a0a 0976 nfo-hash>...v │ │ │ +00040400: 6f69 6420 7365 7373 696f 6e5f 696d 706c oid session_impl │ │ │ +00040410: 3a3a 7373 6c5f 6861 6e64 7368 616b 6528 ::ssl_handshake( │ │ │ +00040420: 6572 726f 725f 636f 6465 2063 6f6e 7374 error_code const │ │ │ +00040430: 2661 6d70 3b20 6563 2c20 736f 636b 6574 & ec, socket │ │ │ +00040440: 5f74 7970 652a 2073 6f63 6b29 0a09 7b0a _type* sock)..{. │ │ │ +00040450: 0909 434f 4d50 4c45 5445 5f41 5359 4e43 ..COMPLETE_ASYNC │ │ │ +00040460: 2822 7365 7373 696f 6e5f 696d 706c 3a3a ("session_impl:: │ │ │ +00040470: 7373 6c5f 6861 6e64 7368 616b 6522 293b ssl_handshake"); │ │ │ +00040480: 0a0a 0909 6175 746f 2069 7465 7220 3d20 ....auto iter = │ │ │ +00040490: 6d5f 696e 636f 6d69 6e67 5f73 6f63 6b65 m_incoming_socke │ │ │ +000404a0: 7473 2e66 696e 6428 736f 636b 293b 0a0a ts.find(sock);.. │ │ │ +000404b0: 0909 2f2f 2074 6869 7320 6861 7070 656e ..// this happen │ │ │ +000404c0: 7320 6966 2074 6865 2053 534c 2063 6f6e s if the SSL con │ │ │ +000404d0: 6e65 6374 696f 6e20 6973 2061 626f 7274 nection is abort │ │ │ +000404e0: 6564 2062 6563 6175 7365 2077 6527 7265 ed because we're │ │ │ +000404f0: 2073 6875 7474 696e 670a 0909 2f2f 2064 shutting...// d │ │ │ +00040500: 6f77 6e0a 0909 6966 2028 6974 6572 203d own...if (iter = │ │ │ +00040510: 3d20 6d5f 696e 636f 6d69 6e67 5f73 6f63 = m_incoming_soc │ │ │ +00040520: 6b65 7473 2e65 6e64 2829 2920 7265 7475 kets.end()) retu │ │ │ +00040530: 726e 3b0a 0a09 0973 6f63 6b65 745f 7479 rn;....socket_ty │ │ │ +00040540: 7065 2073 2873 7464 3a3a 6d6f 7665 282a pe s(std::move(* │ │ │ +00040550: 2a69 7465 7229 293b 0a09 0954 4f52 5245 *iter));...TORRE │ │ │ +00040560: 4e54 5f41 5353 4552 5428 6973 5f73 736c NT_ASSERT(is_ssl │ │ │ +00040570: 2873 2929 3b0a 0909 6d5f 696e 636f 6d69 (s));...m_incomi │ │ │ +00040580: 6e67 5f73 6f63 6b65 7473 2e65 7261 7365 ng_sockets.erase │ │ │ +00040590: 2869 7465 7229 3b0a 0a09 0965 7272 6f72 (iter);....error │ │ │ +000405a0: 5f63 6f64 6520 653b 0a3c 2f70 7265 3e3c _code e;.
    < │ │ │ +000405b0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +000405e0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +000405f0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/sessi │ │ │ +00040620: 6f6e 5f69 6d70 6c2e 6370 703a 3336 3838 on_impl.cpp:3688 │ │ │ +00040630: 3c2f 613e 3c2f 7464 3e3c 7464 3e68 6176 hav │ │ │ +00040640: 6520 6120 7365 7061 7261 7465 206c 6973 e a separate lis │ │ │ +00040650: 7420 666f 7220 7468 6573 6520 636f 6e6e t for these conn │ │ │ +00040660: 6563 7469 6f6e 732c 2069 6e73 7465 6164 ections, instead │ │ │ +00040670: 206f 6620 6861 7669 6e67 2074 6f20 6c6f of having to lo │ │ │ +00040680: 6f70 2074 6872 6f75 6768 2061 6c6c 206f op through all o │ │ │ +00040690: 6620 7468 656d 3c2f 7464 3e3c 2f74 723e f them │ │ │ +000406a0: 3c74 7220 6964 3d22 3136 3022 2073 7479 │ │ │ +000406d0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +000406e0: 3c68 323e 6861 7665 2061 2073 6570 6172

    have a separ │ │ │ +000406f0: 6174 6520 6c69 7374 2066 6f72 2074 6865 ate list for the │ │ │ +00040700: 7365 2063 6f6e 6e65 6374 696f 6e73 2c20 se connections, │ │ │ +00040710: 696e 7374 6561 6420 6f66 2068 6176 696e instead of havin │ │ │ +00040720: 6720 746f 206c 6f6f 7020 7468 726f 7567 g to loop throug │ │ │ +00040730: 6820 616c 6c20 6f66 2074 6865 6d3c 2f68 h all of them

    ../src/ses │ │ │ +00040750: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3336 sion_impl.cpp:36 │ │ │ +00040760: 3838 3c2f 6834 3e3c 7072 6520 7374 796c 88

    ..// ----------
    │ │ │ +000407b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000407c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000407d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000407e0: 2d2d 2d2d 0a09 0969 6620 2821 6d5f 7061  ----...if (!m_pa
    │ │ │ +000407f0: 7573 6564 2920 6d5f 6175 746f 5f6d 616e  used) m_auto_man
    │ │ │ +00040800: 6167 655f 7469 6d65 5f73 6361 6c65 722d  age_time_scaler-
    │ │ │ +00040810: 2d3b 0a09 0969 6620 286d 5f61 7574 6f5f  -;...if (m_auto_
    │ │ │ +00040820: 6d61 6e61 6765 5f74 696d 655f 7363 616c  manage_time_scal
    │ │ │ +00040830: 6572 2026 6c74 3b20 3029 0a09 097b 0a09  er < 0)...{..
    │ │ │ +00040840: 0909 6d5f 6175 746f 5f6d 616e 6167 655f  ..m_auto_manage_
    │ │ │ +00040850: 7469 6d65 5f73 6361 6c65 7220 3d20 7365  time_scaler = se
    │ │ │ +00040860: 7474 696e 6773 2829 2e67 6574 5f69 6e74  ttings().get_int
    │ │ │ +00040870: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ +00040880: 6175 746f 5f6d 616e 6167 655f 696e 7465  auto_manage_inte
    │ │ │ +00040890: 7276 616c 293b 0a09 0909 7265 6361 6c63  rval);....recalc
    │ │ │ +000408a0: 756c 6174 655f 6175 746f 5f6d 616e 6167  ulate_auto_manag
    │ │ │ +000408b0: 6564 5f74 6f72 7265 6e74 7328 293b 0a09  ed_torrents();..
    │ │ │ +000408c0: 097d 0a0a 0909 2f2f 202d 2d2d 2d2d 2d2d  .}....// -------
    │ │ │ +000408d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000408e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000408f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040900: 2d2d 2d2d 2d2d 2d0a 0909 2f2f 2063 6865  -------...// che
    │ │ │ +00040910: 636b 2066 6f72 2069 6e63 6f6d 696e 6720  ck for incoming 
    │ │ │ +00040920: 636f 6e6e 6563 7469 6f6e 7320 7468 6174  connections that
    │ │ │ +00040930: 206d 6967 6874 2068 6176 6520 7469 6d65   might have time
    │ │ │ +00040940: 6420 6f75 740a 0909 2f2f 202d 2d2d 2d2d  d out...// -----
    │ │ │ +00040950: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040960: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040970: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040980: 2d2d 2d2d 2d2d 2d2d 2d0a 0a09 0966 6f72  ---------....for
    │ │ │ +00040990: 2028 6175 746f 2069 203d 206d 5f63 6f6e   (auto i = m_con
    │ │ │ +000409a0: 6e65 6374 696f 6e73 2e62 6567 696e 2829  nections.begin()
    │ │ │ +000409b0: 3b20 6920 213d 206d 5f63 6f6e 6e65 6374  ; i != m_connect
    │ │ │ +000409c0: 696f 6e73 2e65 6e64 2829 3b29 0a09 097b  ions.end();)...{
    │ │ │ +000409d0: 0a09 0909 7065 6572 5f63 6f6e 6e65 6374  ....peer_connect
    │ │ │ +000409e0: 696f 6e2a 2070 203d 2028 2a69 292e 6765  ion* p = (*i).ge
    │ │ │ +000409f0: 7428 293b 0a09 0909 2b2b 693b 0a09 0909  t();....++i;....
    │ │ │ +00040a00: 2f2f 2069 676e 6f72 6520 636f 6e6e 6563  // ignore connec
    │ │ │ +00040a10: 7469 6f6e 7320 7468 6174 2061 6c72 6561  tions that alrea
    │ │ │ +00040a20: 6479 2068 6176 6520 6120 746f 7272 656e  dy have a torren
    │ │ │ +00040a30: 742c 2073 696e 6365 2074 6865 790a 0909  t, since they...
    │ │ │ +00040a40: 092f 2f20 6172 6520 7469 636b 6564 2074  .// are ticked t
    │ │ │ +00040a50: 6872 6f75 6768 2074 6865 2074 6f72 7265  hrough the torre
    │ │ │ +00040a60: 6e74 7327 2073 6563 6f6e 645f 7469 636b  nts' second_tick
    │ │ │ +00040a70: 0a09 0909 6966 2028 2170 2d26 6774 3b61  ....if (!p->a
    │ │ │ +00040a80: 7373 6f63 6961 7465 645f 746f 7272 656e  ssociated_torren
    │ │ │ +00040a90: 7428 292e 6578 7069 7265 6428 2929 2063  t().expired()) c
    │ │ │ +00040aa0: 6f6e 7469 6e75 653b 0a0a 3c64 6976 2073  ontinue;..
    ...int t │ │ │ +00040ae0: 696d 656f 7574 203d 206d 5f73 6574 7469 imeout = m_setti │ │ │ +00040af0: 6e67 732e 6765 745f 696e 7428 7365 7474 ngs.get_int(sett │ │ │ +00040b00: 696e 6773 5f70 6163 6b3a 3a68 616e 6473 ings_pack::hands │ │ │ +00040b10: 6861 6b65 5f74 696d 656f 7574 293b 0a3c hake_timeout);.< │ │ │ +00040b20: 2f64 6976 3e23 6966 2054 4f52 5245 4e54 /div>#if TORRENT │ │ │ +00040b30: 5f55 5345 5f49 3250 0a09 0909 7469 6d65 _USE_I2P....time │ │ │ +00040b40: 6f75 7420 2a3d 2069 735f 6932 7028 702d out *= is_i2p(p- │ │ │ +00040b50: 2667 743b 6765 745f 736f 636b 6574 2829 >get_socket() │ │ │ +00040b60: 2920 3f20 3420 3a20 313b 0a23 656e 6469 ) ? 4 : 1;.#endi │ │ │ +00040b70: 660a 0909 0969 6620 286d 5f6c 6173 745f f....if (m_last_ │ │ │ +00040b80: 7469 636b 202d 2070 2d26 6774 3b63 6f6e tick - p->con │ │ │ +00040b90: 6e65 6374 6564 5f74 696d 6520 2829 2026 nected_time () & │ │ │ +00040ba0: 6774 3b20 7365 636f 6e64 7328 7469 6d65 gt; seconds(time │ │ │ +00040bb0: 6f75 7429 290a 0909 0909 702d 2667 743b out)).....p-> │ │ │ +00040bc0: 6469 7363 6f6e 6e65 6374 2865 7272 6f72 disconnect(error │ │ │ +00040bd0: 733a 3a74 696d 6564 5f6f 7574 2c20 6f70 s::timed_out, op │ │ │ +00040be0: 6572 6174 696f 6e5f 743a 3a62 6974 746f eration_t::bitto │ │ │ +00040bf0: 7272 656e 7429 3b0a 0909 7d0a 0a09 092f rrent);...}..../ │ │ │ +00040c00: 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d / -------------- │ │ │ +00040c10: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040c20: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040c30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040c40: 0a09 092f 2f20 7365 636f 6e64 5f74 6963 ...// second_tic │ │ │ +00040c50: 6b20 6576 6572 7920 746f 7272 656e 7420 k every torrent │ │ │ +00040c60: 2874 6861 7420 7761 6e74 7320 6974 290a (that wants it). │ │ │ +00040c70: 0909 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2d2d ..// ----------- │ │ │ +00040c80: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040c90: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040ca0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040cb0: 2d2d 2d0a 0a23 6966 2054 4f52 5245 4e54 ---..#if TORRENT │ │ │ +00040cc0: 5f44 4542 5547 5f53 5452 4541 4d49 4e47 _DEBUG_STREAMING │ │ │ +00040cd0: 2026 6774 3b20 300a 0909 7374 643a 3a70 > 0...std::p │ │ │ +00040ce0: 7269 6e74 6628 225c 3033 335b 324a 5c30 rintf("\033[2J\0 │ │ │ +00040cf0: 3333 5b30 3b30 4822 293b 0a23 656e 6469 33[0;0H");.#endi │ │ │ +00040d00: 660a 0a09 0961 7578 3a3a 7665 6374 6f72 f....aux::vector │ │ │ +00040d10: 266c 743b 746f 7272 656e 742a 2667 743b <torrent*> │ │ │ +00040d20: 2661 6d70 3b20 7761 6e74 5f74 6963 6b20 & want_tick │ │ │ +00040d30: 3d20 6d5f 746f 7272 656e 745f 6c69 7374 = m_torrent_list │ │ │ +00040d40: 735b 746f 7272 656e 745f 7761 6e74 5f74 s[torrent_want_t │ │ │ +00040d50: 6963 6b5d 3b0a 0909 666f 7220 2869 6e74 ick];...for (int │ │ │ +00040d60: 2069 203d 2030 3b20 6920 266c 743b 2069 i = 0; i < i │ │ │ +00040d70: 6e74 2877 616e 745f 7469 636b 2e73 697a nt(want_tick.siz │ │ │ +00040d80: 6528 2929 3b20 2b2b 6929 0a09 097b 0a09 e()); ++i)...{.. │ │ │ +00040d90: 0909 746f 7272 656e 7426 616d 703b 2074 ..torrent& t │ │ │ +00040da0: 203d 202a 7761 6e74 5f74 6963 6b5b 695d = *want_tick[i] │ │ │ +00040db0: 3b0a 0909 0954 4f52 5245 4e54 5f41 5353 ;....TORRENT_ASS │ │ │ +00040dc0: 4552 5428 742e 7761 6e74 5f74 6963 6b28 ERT(t.want_tick( │ │ │ +00040dd0: 2929 3b0a 0909 0954 4f52 5245 4e54 5f41 ));....TORRENT_A │ │ │ +00040de0: 5353 4552 5428 2174 2e69 735f 6162 6f72 SSERT(!t.is_abor │ │ │ +00040df0: 7465 6428 2929 3b0a 0a09 0909 742e 7365 ted());.....t.se │ │ │ +00040e00: 636f 6e64 5f74 6963 6b28 7469 636b 5f69 cond_tick(tick_i │ │ │ +00040e10: 6e74 6572 7661 6c5f 6d73 293b 0a0a 0909 nterval_ms);.... │ │ │ +00040e20: 092f 2f20 6966 2074 6865 2063 616c 6c20 .// if the call │ │ │ +00040e30: 746f 2073 6563 6f6e 645f 7469 636b 2063 to second_tick c │ │ │ +00040e40: 6175 7365 6420 7468 6520 746f 7272 656e aused the torren │ │ │ +00040e50: 740a 0909 092f 2f20 746f 206e 6f20 6c6f t....// to no lo │ │ │ +00040e60: 6e67 6572 2077 616e 7420 746f 2062 6520 nger want to be │ │ │ +00040e70: 7469 636b 6564 2028 692e 652e 2069 7420 ticked (i.e. it │ │ │ +00040e80: 7761 730a 0909 092f 2f20 7265 6d6f 7665 was....// remove │ │ │ +00040e90: 6420 6672 6f6d 2074 6865 206c 6973 7429 d from the list) │ │ │ +00040ea0: 2077 6520 6e65 6564 2074 6f20 6261 636b we need to back │ │ │ +00040eb0: 2075 7020 7468 6520 636f 756e 7465 720a up the counter. │ │ │ +00040ec0: 0909 092f 2f20 746f 206e 6f74 206d 6973 ...// to not mis │ │ │ +00040ed0: 7320 7468 6520 746f 7272 656e 7420 6166 s the torrent af │ │ │ +00040ee0: 7465 7220 6974 0a09 0909 6966 2028 2174 ter it....if (!t │ │ │ +00040ef0: 2e77 616e 745f 7469 636b 2829 2920 2d2d .want_tick()) -- │ │ │ +00040f00: 693b 0a09 097d 0a3c 2f70 7265 3e3c 2f74 i;...}.
    relevanc │ │ │ +00040f40: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/session │ │ │ +00040f80: 5f69 6d70 6c2e 6370 703a 3337 3231 3c2f _impl.cpp:3721this │ │ │ +00040fa0: 7368 6f75 6c64 2061 7070 6c79 2074 6f20 should apply to │ │ │ +00040fb0: 616c 6c20 6261 6e64 7769 6474 6820 6368 all bandwidth ch │ │ │ +00040fc0: 616e 6e65 6c73 3c2f 7464 3e3c 2f74 723e annels │ │ │ +00040fd0: 3c74 7220 6964 3d22 3136 3122 2073 7479 │ │ │ +00041000: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00041010: 3c68 323e 7468 6973 2073 686f 756c 6420

    this should │ │ │ +00041020: 6170 706c 7920 746f 2061 6c6c 2062 616e apply to all ban │ │ │ +00041030: 6477 6964 7468 2063 6861 6e6e 656c 733c dwidth channels< │ │ │ +00041040: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ +00041050: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ +00041060: 3337 3231 3c2f 6834 3e3c 7072 6520 7374 3721

    #if TORRENT_D
    │ │ │ +000410b0: 4542 5547 5f53 5452 4541 4d49 4e47 2026  EBUG_STREAMING &
    │ │ │ +000410c0: 6774 3b20 300a 0909 7374 643a 3a70 7269  gt; 0...std::pri
    │ │ │ +000410d0: 6e74 6628 225c 3033 335b 324a 5c30 3333  ntf("\033[2J\033
    │ │ │ +000410e0: 5b30 3b30 4822 293b 0a23 656e 6469 660a  [0;0H");.#endif.
    │ │ │ +000410f0: 0a09 0961 7578 3a3a 7665 6374 6f72 266c  ...aux::vector&l
    │ │ │ +00041100: 743b 746f 7272 656e 742a 2667 743b 2661  t;torrent*>&a
    │ │ │ +00041110: 6d70 3b20 7761 6e74 5f74 6963 6b20 3d20  mp; want_tick = 
    │ │ │ +00041120: 6d5f 746f 7272 656e 745f 6c69 7374 735b  m_torrent_lists[
    │ │ │ +00041130: 746f 7272 656e 745f 7761 6e74 5f74 6963  torrent_want_tic
    │ │ │ +00041140: 6b5d 3b0a 0909 666f 7220 2869 6e74 2069  k];...for (int i
    │ │ │ +00041150: 203d 2030 3b20 6920 266c 743b 2069 6e74   = 0; i < int
    │ │ │ +00041160: 2877 616e 745f 7469 636b 2e73 697a 6528  (want_tick.size(
    │ │ │ +00041170: 2929 3b20 2b2b 6929 0a09 097b 0a09 0909  )); ++i)...{....
    │ │ │ +00041180: 746f 7272 656e 7426 616d 703b 2074 203d  torrent& t =
    │ │ │ +00041190: 202a 7761 6e74 5f74 6963 6b5b 695d 3b0a   *want_tick[i];.
    │ │ │ +000411a0: 0909 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +000411b0: 5428 742e 7761 6e74 5f74 6963 6b28 2929  T(t.want_tick())
    │ │ │ +000411c0: 3b0a 0909 0954 4f52 5245 4e54 5f41 5353  ;....TORRENT_ASS
    │ │ │ +000411d0: 4552 5428 2174 2e69 735f 6162 6f72 7465  ERT(!t.is_aborte
    │ │ │ +000411e0: 6428 2929 3b0a 0a09 0909 742e 7365 636f  d());.....t.seco
    │ │ │ +000411f0: 6e64 5f74 6963 6b28 7469 636b 5f69 6e74  nd_tick(tick_int
    │ │ │ +00041200: 6572 7661 6c5f 6d73 293b 0a0a 0909 092f  erval_ms);...../
    │ │ │ +00041210: 2f20 6966 2074 6865 2063 616c 6c20 746f  / if the call to
    │ │ │ +00041220: 2073 6563 6f6e 645f 7469 636b 2063 6175   second_tick cau
    │ │ │ +00041230: 7365 6420 7468 6520 746f 7272 656e 740a  sed the torrent.
    │ │ │ +00041240: 0909 092f 2f20 746f 206e 6f20 6c6f 6e67  ...// to no long
    │ │ │ +00041250: 6572 2077 616e 7420 746f 2062 6520 7469  er want to be ti
    │ │ │ +00041260: 636b 6564 2028 692e 652e 2069 7420 7761  cked (i.e. it wa
    │ │ │ +00041270: 730a 0909 092f 2f20 7265 6d6f 7665 6420  s....// removed 
    │ │ │ +00041280: 6672 6f6d 2074 6865 206c 6973 7429 2077  from the list) w
    │ │ │ +00041290: 6520 6e65 6564 2074 6f20 6261 636b 2075  e need to back u
    │ │ │ +000412a0: 7020 7468 6520 636f 756e 7465 720a 0909  p the counter...
    │ │ │ +000412b0: 092f 2f20 746f 206e 6f74 206d 6973 7320  .// to not miss 
    │ │ │ +000412c0: 7468 6520 746f 7272 656e 7420 6166 7465  the torrent afte
    │ │ │ +000412d0: 7220 6974 0a09 0909 6966 2028 2174 2e77  r it....if (!t.w
    │ │ │ +000412e0: 616e 745f 7469 636b 2829 2920 2d2d 693b  ant_tick()) --i;
    │ │ │ +000412f0: 0a09 097d 0a0a 3c64 6976 2073 7479 6c65  ...}..
    ..if (m_sett │ │ │ +00041330: 696e 6773 2e67 6574 5f62 6f6f 6c28 7365 ings.get_bool(se │ │ │ +00041340: 7474 696e 6773 5f70 6163 6b3a 3a72 6174 ttings_pack::rat │ │ │ +00041350: 655f 6c69 6d69 745f 6970 5f6f 7665 7268 e_limit_ip_overh │ │ │ +00041360: 6561 6429 290a 3c2f 6469 763e 0909 7b0a ead)).
    ..{. │ │ │ +00041370: 0909 0969 6e74 2063 6f6e 7374 2075 705f ...int const up_ │ │ │ +00041380: 6c69 6d69 7420 3d20 7570 6c6f 6164 5f72 limit = upload_r │ │ │ +00041390: 6174 655f 6c69 6d69 7428 6d5f 676c 6f62 ate_limit(m_glob │ │ │ +000413a0: 616c 5f63 6c61 7373 293b 0a09 0909 696e al_class);....in │ │ │ +000413b0: 7420 636f 6e73 7420 646f 776e 5f6c 696d t const down_lim │ │ │ +000413c0: 6974 203d 2064 6f77 6e6c 6f61 645f 7261 it = download_ra │ │ │ +000413d0: 7465 5f6c 696d 6974 286d 5f67 6c6f 6261 te_limit(m_globa │ │ │ +000413e0: 6c5f 636c 6173 7329 3b0a 0a09 0909 6966 l_class);.....if │ │ │ +000413f0: 2028 646f 776e 5f6c 696d 6974 2026 6774 (down_limit > │ │ │ +00041400: 3b20 300a 0909 0909 2661 6d70 3b26 616d ; 0.....&&am │ │ │ +00041410: 703b 206d 5f73 7461 742e 646f 776e 6c6f p; m_stat.downlo │ │ │ +00041420: 6164 5f69 705f 6f76 6572 6865 6164 2829 ad_ip_overhead() │ │ │ +00041430: 2026 6774 3b3d 2064 6f77 6e5f 6c69 6d69 >= down_limi │ │ │ +00041440: 740a 0909 0909 2661 6d70 3b26 616d 703b t.....&& │ │ │ +00041450: 206d 5f61 6c65 7274 732e 7368 6f75 6c64 m_alerts.should │ │ │ +00041460: 5f70 6f73 7426 6c74 3b70 6572 666f 726d _post<perform │ │ │ +00041470: 616e 6365 5f61 6c65 7274 2667 743b 2829 ance_alert>() │ │ │ +00041480: 290a 0909 097b 0a09 0909 096d 5f61 6c65 )....{.....m_ale │ │ │ +00041490: 7274 732e 656d 706c 6163 655f 616c 6572 rts.emplace_aler │ │ │ +000414a0: 7426 6c74 3b70 6572 666f 726d 616e 6365 t<performance │ │ │ +000414b0: 5f61 6c65 7274 2667 743b 2874 6f72 7265 _alert>(torre │ │ │ +000414c0: 6e74 5f68 616e 646c 6528 290a 0909 0909 nt_handle()..... │ │ │ +000414d0: 092c 2070 6572 666f 726d 616e 6365 5f61 ., performance_a │ │ │ +000414e0: 6c65 7274 3a3a 646f 776e 6c6f 6164 5f6c lert::download_l │ │ │ +000414f0: 696d 6974 5f74 6f6f 5f6c 6f77 293b 0a09 imit_too_low);.. │ │ │ +00041500: 0909 7d0a 0a09 0909 6966 2028 7570 5f6c ..}.....if (up_l │ │ │ +00041510: 696d 6974 2026 6774 3b20 300a 0909 0909 imit > 0..... │ │ │ +00041520: 2661 6d70 3b26 616d 703b 206d 5f73 7461 && m_sta │ │ │ +00041530: 742e 7570 6c6f 6164 5f69 705f 6f76 6572 t.upload_ip_over │ │ │ +00041540: 6865 6164 2829 2026 6774 3b3d 2075 705f head() >= up_ │ │ │ +00041550: 6c69 6d69 740a 0909 0909 2661 6d70 3b26 limit.....&& │ │ │ +00041560: 616d 703b 206d 5f61 6c65 7274 732e 7368 amp; m_alerts.sh │ │ │ +00041570: 6f75 6c64 5f70 6f73 7426 6c74 3b70 6572 ould_post<per │ │ │ +00041580: 666f 726d 616e 6365 5f61 6c65 7274 2667 formance_alert&g │ │ │ +00041590: 743b 2829 290a 0909 097b 0a09 0909 096d t;())....{.....m │ │ │ +000415a0: 5f61 6c65 7274 732e 656d 706c 6163 655f _alerts.emplace_ │ │ │ +000415b0: 616c 6572 7426 6c74 3b70 6572 666f 726d alert<perform │ │ │ +000415c0: 616e 6365 5f61 6c65 7274 2667 743b 2874 ance_alert>(t │ │ │ +000415d0: 6f72 7265 6e74 5f68 616e 646c 6528 290a orrent_handle(). │ │ │ +000415e0: 0909 0909 092c 2070 6572 666f 726d 616e ....., performan │ │ │ +000415f0: 6365 5f61 6c65 7274 3a3a 7570 6c6f 6164 ce_alert::upload │ │ │ +00041600: 5f6c 696d 6974 5f74 6f6f 5f6c 6f77 293b _limit_too_low); │ │ │ +00041610: 0a09 0909 7d0a 0909 7d0a 0a23 6966 2054 ....}...}..#if T │ │ │ +00041620: 4f52 5245 4e54 5f41 4249 5f56 4552 5349 ORRENT_ABI_VERSI │ │ │ +00041630: 4f4e 203d 3d20 310a 0909 6d5f 7065 616b ON == 1...m_peak │ │ │ +00041640: 5f75 705f 7261 7465 203d 2073 7464 3a3a _up_rate = std:: │ │ │ +00041650: 6d61 7828 6d5f 7374 6174 2e75 706c 6f61 max(m_stat.uploa │ │ │ +00041660: 645f 7261 7465 2829 2c20 6d5f 7065 616b d_rate(), m_peak │ │ │ +00041670: 5f75 705f 7261 7465 293b 0a23 656e 6469 _up_rate);.#endi │ │ │ +00041680: 660a 0a09 096d 5f73 7461 742e 7365 636f f....m_stat.seco │ │ │ +00041690: 6e64 5f74 6963 6b28 7469 636b 5f69 6e74 nd_tick(tick_int │ │ │ +000416a0: 6572 7661 6c5f 6d73 293b 0a0a 0909 2f2f erval_ms);....// │ │ │ +000416b0: 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d --------------- │ │ │ +000416c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000416d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000416e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a ---------------. │ │ │ +000416f0: 0909 2f2f 2073 6372 6170 6520 7061 7573 ..// scrape paus │ │ │ +00041700: 6564 2074 6f72 7265 6e74 7320 7468 6174 ed torrents that │ │ │ +00041710: 2061 7265 2061 7574 6f20 6d61 6e61 6765 are auto manage │ │ │ +00041720: 640a 0909 2f2f 2028 756e 6c65 7373 2074 d...// (unless t │ │ │ +00041730: 6865 2073 6573 7369 6f6e 2069 7320 7061 he session is pa │ │ │ +00041740: 7573 6564 290a 3c2f 7072 653e 3c2f 7464 used).
    relevance │ │ │ +00041780: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00041790: 3c61 2068 7265 663d 226a 6176 6173 6372
    ../src/session_ │ │ │ +000417c0: 696d 706c 2e63 7070 3a34 3437 363c 2f61 impl.cpp:4476use a │ │ │ +000417e0: 6c6f 7765 7220 6c69 6d69 7420 7468 616e lower limit than │ │ │ +000417f0: 206d 5f73 6574 7469 6e67 732e 636f 6e6e m_settings.conn │ │ │ +00041800: 6563 7469 6f6e 735f 6c69 6d69 7420 746f ections_limit to │ │ │ +00041810: 2061 6c6c 6f63 6174 6520 7468 6520 746f allocate the to │ │ │ +00041820: 2031 3025 206f 7220 736f 206f 6620 636f 10% or so of co │ │ │ +00041830: 6e6e 6563 7469 6f6e 2073 6c6f 7473 2066 nnection slots f │ │ │ +00041840: 6f72 2069 6e63 6f6d 696e 6720 636f 6e6e or incoming conn │ │ │ +00041850: 6563 7469 6f6e 7320 6361 7020 7468 6973 ections cap this │ │ │ +00041860: 2061 7420 6d61 7820 2d20 312c 2073 696e at max - 1, sin │ │ │ +00041870: 6365 2077 6520 6d61 7920 6164 6420 6f6e ce we may add on │ │ │ +00041880: 6520 6265 6c6f 773c 2f74 643e 3c2f 7472 e below

    use a lower │ │ │ +000418e0: 206c 696d 6974 2074 6861 6e20 6d5f 7365 limit than m_se │ │ │ +000418f0: 7474 696e 6773 2e63 6f6e 6e65 6374 696f ttings.connectio │ │ │ +00041900: 6e73 5f6c 696d 6974 0a74 6f20 616c 6c6f ns_limit.to allo │ │ │ +00041910: 6361 7465 2074 6865 2074 6f20 3130 2520 cate the to 10% │ │ │ +00041920: 6f72 2073 6f20 6f66 2063 6f6e 6e65 6374 or so of connect │ │ │ +00041930: 696f 6e20 736c 6f74 7320 666f 7220 696e ion slots for in │ │ │ +00041940: 636f 6d69 6e67 0a63 6f6e 6e65 6374 696f coming.connectio │ │ │ +00041950: 6e73 0a63 6170 2074 6869 7320 6174 206d ns.cap this at m │ │ │ +00041960: 6178 202d 2031 2c20 7369 6e63 6520 7765 ax - 1, since we │ │ │ +00041970: 206d 6179 2061 6464 206f 6e65 2062 656c may add one bel │ │ │ +00041980: 6f77 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ow

    ../sr │ │ │ +00041990: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +000419a0: 7070 3a34 3437 363c 2f68 343e 3c70 7265 pp:4476

    ..// boost
    │ │ │ +000419f0: 2c20 7768 6963 6820 6172 6520 646f 6e65  , which are done
    │ │ │ +00041a00: 2069 6d6d 6564 6961 7465 6c79 206f 6e20   immediately on 
    │ │ │ +00041a10: 6120 7472 6163 6b65 7220 7265 7370 6f6e  a tracker respon
    │ │ │ +00041a20: 7365 2e20 5468 6573 650a 0909 2f2f 2063  se. These...// c
    │ │ │ +00041a30: 6f6e 6e65 6374 696f 6e73 206e 6565 6473  onnections needs
    │ │ │ +00041a40: 2074 6f20 6265 2064 6564 7563 7465 6420   to be deducted 
    │ │ │ +00041a50: 6672 6f6d 2074 6865 2072 6567 756c 6172  from the regular
    │ │ │ +00041a60: 2063 6f6e 6e65 6374 696f 6e20 6174 7465   connection atte
    │ │ │ +00041a70: 6d70 740a 0909 2f2f 2071 756f 7461 2066  mpt...// quota f
    │ │ │ +00041a80: 6f72 2074 6869 7320 7469 636b 0a09 0969  or this tick...i
    │ │ │ +00041a90: 6620 286d 5f62 6f6f 7374 5f63 6f6e 6e65  f (m_boost_conne
    │ │ │ +00041aa0: 6374 696f 6e73 2026 6774 3b20 3029 0a09  ctions > 0)..
    │ │ │ +00041ab0: 097b 0a09 0909 6966 2028 6d5f 626f 6f73  .{....if (m_boos
    │ │ │ +00041ac0: 745f 636f 6e6e 6563 7469 6f6e 7320 2667  t_connections &g
    │ │ │ +00041ad0: 743b 206d 6178 5f63 6f6e 6e65 6374 696f  t; max_connectio
    │ │ │ +00041ae0: 6e73 290a 0909 097b 0a09 0909 096d 5f62  ns)....{.....m_b
    │ │ │ +00041af0: 6f6f 7374 5f63 6f6e 6e65 6374 696f 6e73  oost_connections
    │ │ │ +00041b00: 202d 3d20 6d61 785f 636f 6e6e 6563 7469   -= max_connecti
    │ │ │ +00041b10: 6f6e 733b 0a09 0909 096d 6178 5f63 6f6e  ons;.....max_con
    │ │ │ +00041b20: 6e65 6374 696f 6e73 203d 2030 3b0a 0909  nections = 0;...
    │ │ │ +00041b30: 097d 0a09 0909 656c 7365 0a09 0909 7b0a  .}....else....{.
    │ │ │ +00041b40: 0909 0909 6d61 785f 636f 6e6e 6563 7469  ....max_connecti
    │ │ │ +00041b50: 6f6e 7320 2d3d 206d 5f62 6f6f 7374 5f63  ons -= m_boost_c
    │ │ │ +00041b60: 6f6e 6e65 6374 696f 6e73 3b0a 0909 0909  onnections;.....
    │ │ │ +00041b70: 6d5f 626f 6f73 745f 636f 6e6e 6563 7469  m_boost_connecti
    │ │ │ +00041b80: 6f6e 7320 3d20 303b 0a09 0909 7d0a 0909  ons = 0;....}...
    │ │ │ +00041b90: 7d0a 0a09 092f 2f20 7a65 726f 2063 6f6e  }....// zero con
    │ │ │ +00041ba0: 6e65 6374 696f 6e73 2073 7065 6564 7320  nections speeds 
    │ │ │ +00041bb0: 6172 6520 616c 6c6f 7765 642c 2077 6520  are allowed, we 
    │ │ │ +00041bc0: 6a75 7374 2077 6f6e 2774 206d 616b 6520  just won't make 
    │ │ │ +00041bd0: 616e 7920 636f 6e6e 6563 7469 6f6e 730a  any connections.
    │ │ │ +00041be0: 0909 6966 2028 6d61 785f 636f 6e6e 6563  ..if (max_connec
    │ │ │ +00041bf0: 7469 6f6e 7320 266c 743b 3d20 3029 2072  tions <= 0) r
    │ │ │ +00041c00: 6574 7572 6e3b 0a0a 3c64 6976 2073 7479  eturn;..
    ..int cons │ │ │ +00041c40: 7420 6c69 6d69 7420 3d20 7374 643a 3a6d t limit = std::m │ │ │ +00041c50: 696e 286d 5f73 6574 7469 6e67 732e 6765 in(m_settings.ge │ │ │ +00041c60: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ +00041c70: 6163 6b3a 3a63 6f6e 6e65 6374 696f 6e73 ack::connections │ │ │ +00041c80: 5f6c 696d 6974 290a 3c2f 6469 763e 0909 _limit).
    .. │ │ │ +00041c90: 092d 206e 756d 5f63 6f6e 6e65 6374 696f .- num_connectio │ │ │ +00041ca0: 6e73 2829 2c20 7374 643a 3a6e 756d 6572 ns(), std::numer │ │ │ +00041cb0: 6963 5f6c 696d 6974 7326 6c74 3b69 6e74 ic_limits<int │ │ │ +00041cc0: 2667 743b 3a3a 6d61 7828 2920 2d20 3129 >::max() - 1) │ │ │ +00041cd0: 3b0a 0a09 092f 2f20 7468 6973 206c 6f67 ;....// this log │ │ │ +00041ce0: 6963 2069 7320 6865 7265 2074 6f20 736d ic is here to sm │ │ │ +00041cf0: 6f6f 7468 206f 7574 2074 6865 206e 756d ooth out the num │ │ │ +00041d00: 6265 7220 6f66 206e 6577 2063 6f6e 6e65 ber of new conne │ │ │ +00041d10: 6374 696f 6e0a 0909 2f2f 2061 7474 656d ction...// attem │ │ │ +00041d20: 7074 7320 6f76 6572 2074 696d 652c 2074 pts over time, t │ │ │ +00041d30: 6f20 7072 6576 656e 7420 636f 6e6e 6563 o prevent connec │ │ │ +00041d40: 7469 6e67 2061 206c 6172 6765 206e 756d ting a large num │ │ │ +00041d50: 6265 7220 6f66 0a09 092f 2f20 736f 636b ber of...// sock │ │ │ +00041d60: 6574 732c 2077 6169 7420 3130 2073 6563 ets, wait 10 sec │ │ │ +00041d70: 6f6e 6473 2c20 616e 6420 7468 656e 2074 onds, and then t │ │ │ +00041d80: 7279 2061 6761 696e 0a09 0969 6620 286d ry again...if (m │ │ │ +00041d90: 5f73 6574 7469 6e67 732e 6765 745f 626f _settings.get_bo │ │ │ +00041da0: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ +00041db0: 3a3a 736d 6f6f 7468 5f63 6f6e 6e65 6374 ::smooth_connect │ │ │ +00041dc0: 7329 2026 616d 703b 2661 6d70 3b20 6d61 s) && ma │ │ │ +00041dd0: 785f 636f 6e6e 6563 7469 6f6e 7320 2667 x_connections &g │ │ │ +00041de0: 743b 2028 6c69 6d69 742b 3129 202f 2032 t; (limit+1) / 2 │ │ │ +00041df0: 290a 0909 096d 6178 5f63 6f6e 6e65 6374 )....max_connect │ │ │ +00041e00: 696f 6e73 203d 2028 6c69 6d69 7420 2b20 ions = (limit + │ │ │ +00041e10: 3129 202f 2032 3b0a 0a09 0961 7578 3a3a 1) / 2;....aux:: │ │ │ +00041e20: 7665 6374 6f72 266c 743b 746f 7272 656e vector<torren │ │ │ +00041e30: 742a 2667 743b 2661 6d70 3b20 7761 6e74 t*>& want │ │ │ +00041e40: 5f70 6565 7273 5f64 6f77 6e6c 6f61 6420 _peers_download │ │ │ +00041e50: 3d20 6d5f 746f 7272 656e 745f 6c69 7374 = m_torrent_list │ │ │ +00041e60: 735b 746f 7272 656e 745f 7761 6e74 5f70 s[torrent_want_p │ │ │ +00041e70: 6565 7273 5f64 6f77 6e6c 6f61 645d 3b0a eers_download];. │ │ │ +00041e80: 0909 6175 783a 3a76 6563 746f 7226 6c74 ..aux::vector< │ │ │ +00041e90: 3b74 6f72 7265 6e74 2a26 6774 3b26 616d ;torrent*>&am │ │ │ +00041ea0: 703b 2077 616e 745f 7065 6572 735f 6669 p; want_peers_fi │ │ │ +00041eb0: 6e69 7368 6564 203d 206d 5f74 6f72 7265 nished = m_torre │ │ │ +00041ec0: 6e74 5f6c 6973 7473 5b74 6f72 7265 6e74 nt_lists[torrent │ │ │ +00041ed0: 5f77 616e 745f 7065 6572 735f 6669 6e69 _want_peers_fini │ │ │ +00041ee0: 7368 6564 5d3b 0a0a 0909 2f2f 2069 6620 shed];....// if │ │ │ +00041ef0: 6e6f 2074 6f72 7265 6e74 2077 616e 7420 no torrent want │ │ │ +00041f00: 616e 7920 7065 6572 732c 206a 7573 7420 any peers, just │ │ │ +00041f10: 7265 7475 726e 0a09 0969 6620 2877 616e return...if (wan │ │ │ +00041f20: 745f 7065 6572 735f 646f 776e 6c6f 6164 t_peers_download │ │ │ +00041f30: 2e65 6d70 7479 2829 2026 616d 703b 2661 .empty() &&a │ │ │ +00041f40: 6d70 3b20 7761 6e74 5f70 6565 7273 5f66 mp; want_peers_f │ │ │ +00041f50: 696e 6973 6865 642e 656d 7074 7928 2929 inished.empty()) │ │ │ +00041f60: 2072 6574 7572 6e3b 0a0a 0909 2f2f 2069 return;....// i │ │ │ +00041f70: 6620 7765 2064 6f6e 2774 2068 6176 6520 f we don't have │ │ │ +00041f80: 616e 7920 636f 6e6e 6563 7469 6f6e 2061 any connection a │ │ │ +00041f90: 7474 656d 7074 2071 756f 7461 2c20 7265 ttempt quota, re │ │ │ +00041fa0: 7475 726e 0a09 0969 6620 286d 6178 5f63 turn...if (max_c │ │ │ +00041fb0: 6f6e 6e65 6374 696f 6e73 2026 6c74 3b3d onnections <= │ │ │ +00041fc0: 2030 2920 7265 7475 726e 3b0a 0a09 0969 0) return;....i │ │ │ +00041fd0: 6e74 2073 7465 7073 5f73 696e 6365 5f6c nt steps_since_l │ │ │ +00041fe0: 6173 745f 636f 6e6e 6563 7420 3d20 303b ast_connect = 0; │ │ │ +00041ff0: 0a09 0969 6e74 2063 6f6e 7374 206e 756d ...int const num │ │ │ +00042000: 5f74 6f72 7265 6e74 7320 3d20 696e 7428 _torrents = int( │ │ │ +00042010: 7761 6e74 5f70 6565 7273 5f66 696e 6973 want_peers_finis │ │ │ +00042020: 6865 642e 7369 7a65 2829 202b 2077 616e hed.size() + wan │ │ │ +00042030: 745f 7065 6572 735f 646f 776e 6c6f 6164 t_peers_download │ │ │ +00042040: 2e73 697a 6528 2929 3b0a 0909 666f 7220 .size());...for │ │ │ +00042050: 283b 3b29 0a09 097b 0a09 0909 6966 2028 (;;)...{....if ( │ │ │ +00042060: 6d5f 6e65 7874 5f64 6f77 6e6c 6f61 6469 m_next_downloadi │ │ │ +00042070: 6e67 5f63 6f6e 6e65 6374 5f74 6f72 7265 ng_connect_torre │ │ │ +00042080: 6e74 2026 6774 3b3d 2069 6e74 2877 616e nt >= int(wan │ │ │ +00042090: 745f 7065 6572 735f 646f 776e 6c6f 6164 t_peers_download │ │ │ +000420a0: 2e73 697a 6528 2929 290a 0909 0909 6d5f .size())).....m_ │ │ │ +000420b0: 6e65 7874 5f64 6f77 6e6c 6f61 6469 6e67 next_downloading │ │ │ +000420c0: 5f63 6f6e 6e65 6374 5f74 6f72 7265 6e74 _connect_torrent │ │ │ +000420d0: 203d 2030 3b0a 0a09 0909 6966 2028 6d5f = 0;.....if (m_ │ │ │ +000420e0: 6e65 7874 5f66 696e 6973 6865 645f 636f next_finished_co │ │ │ +000420f0: 6e6e 6563 745f 746f 7272 656e 7420 2667 nnect_torrent &g │ │ │ +00042100: 743b 3d20 696e 7428 7761 6e74 5f70 6565 t;= int(want_pee │ │ │ +00042110: 7273 5f66 696e 6973 6865 642e 7369 7a65 rs_finished.size │ │ │ +00042120: 2829 2929 0a09 0909 096d 5f6e 6578 745f ())).....m_next_ │ │ │ +00042130: 6669 6e69 7368 6564 5f63 6f6e 6e65 6374 finished_connect │ │ │ +00042140: 5f74 6f72 7265 6e74 203d 2030 3b0a 0a09 _torrent = 0;... │ │ │ +00042150: 0909 746f 7272 656e 742a 2074 203d 206e ..torrent* t = n │ │ │ +00042160: 756c 6c70 7472 3b0a 0909 092f 2f20 7468 ullptr;....// th │ │ │ +00042170: 6572 6520 6172 6520 7072 696f 7269 7469 ere are prioriti │ │ │ +00042180: 7a65 6420 746f 7272 656e 7473 2e20 5069 zed torrents. Pi │ │ │ +00042190: 636b 206f 6e65 206f 6620 7468 6f73 650a ck one of those. │ │ │ +000421a0: 0909 0977 6869 6c65 2028 216d 5f70 7269 ...while (!m_pri │ │ │ +000421b0: 6f5f 746f 7272 656e 7473 2e65 6d70 7479 o_torrents.empty │ │ │ +000421c0: 2829 290a 3c2f 7072 653e 3c2f 7464 3e3c ()).
    < │ │ │ +000421d0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00042200: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00042230: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00042240: 706c 2e63 7070 3a34 3632 313c 2f61 3e3c pl.cpp:4621< │ │ │ +00042250: 2f74 643e 3c74 643e 706f 7374 2061 206d /td>post a m │ │ │ +00042260: 6573 7361 6765 2074 6f20 6861 7665 2074 essage to have t │ │ │ +00042270: 6869 7320 6861 7070 656e 2069 6d6d 6564 his happen immed │ │ │ +00042280: 6961 7465 6c79 2069 6e73 7465 6164 206f iately instead o │ │ │ +00042290: 6620 7761 6974 696e 6720 666f 7220 7468 f waiting for th │ │ │ +000422a0: 6520 6e65 7874 2074 6963 6b3c 2f74 643e e next tick │ │ │ +000422b0: 3c2f 7472 3e3c 7472 2069 643d 2231 3633

    post a │ │ │ +00042300: 6d65 7373 6167 6520 746f 2068 6176 6520 message to have │ │ │ +00042310: 7468 6973 2068 6170 7065 6e0a 696d 6d65 this happen.imme │ │ │ +00042320: 6469 6174 656c 7920 696e 7374 6561 6420 diately instead │ │ │ +00042330: 6f66 2077 6169 7469 6e67 2066 6f72 2074 of waiting for t │ │ │ +00042340: 6865 206e 6578 7420 7469 636b 3c2f 6832 he next tick

    ../src/sess │ │ │ +00042360: 696f 6e5f 696d 706c 2e63 7070 3a34 3632 ion_impl.cpp:462 │ │ │ +00042370: 313c 2f68 343e 3c70 7265 2073 7479 6c65 1

    │ │ │ +000423b0: 0909 0909 636f 6e74 696e 7565 3b0a 0909  ....continue;...
    │ │ │ +000423c0: 097d 0a0a 0909 0969 6620 2821 702d 2667  .}.....if (!p-&g
    │ │ │ +000423d0: 743b 6973 5f70 6565 725f 696e 7465 7265  t;is_peer_intere
    │ │ │ +000423e0: 7374 6564 2829 0a09 0909 097c 7c20 702d  sted().....|| p-
    │ │ │ +000423f0: 2667 743b 6973 5f64 6973 636f 6e6e 6563  >is_disconnec
    │ │ │ +00042400: 7469 6e67 2829 0a09 0909 097c 7c20 702d  ting().....|| p-
    │ │ │ +00042410: 2667 743b 6973 5f63 6f6e 6e65 6374 696e  >is_connectin
    │ │ │ +00042420: 6728 2929 0a09 0909 7b0a 0909 0909 2f2f  g())....{.....//
    │ │ │ +00042430: 2074 6869 7320 7065 6572 2069 7320 6e6f   this peer is no
    │ │ │ +00042440: 7420 756e 6368 6f6b 6162 6c65 2e20 536f  t unchokable. So
    │ │ │ +00042450: 2c20 6966 2069 7427 7320 756e 6368 6f6b  , if it's unchok
    │ │ │ +00042460: 6564 0a09 0909 092f 2f20 616c 7265 6164  ed.....// alread
    │ │ │ +00042470: 792c 206d 616b 6520 7375 7265 2074 6f20  y, make sure to 
    │ │ │ +00042480: 6368 6f6b 6520 6974 2e0a 0909 0909 6966  choke it......if
    │ │ │ +00042490: 2028 702d 2667 743b 6973 5f63 686f 6b65   (p->is_choke
    │ │ │ +000424a0: 6428 2929 0a09 0909 097b 0a09 0909 0909  d()).....{......
    │ │ │ +000424b0: 702d 2667 743b 7265 7365 745f 6368 6f6b  p->reset_chok
    │ │ │ +000424c0: 655f 636f 756e 7465 7273 2829 3b0a 0909  e_counters();...
    │ │ │ +000424d0: 0909 0963 6f6e 7469 6e75 653b 0a09 0909  ...continue;....
    │ │ │ +000424e0: 097d 0a09 0909 0969 6620 2870 6920 2661  .}.....if (pi &a
    │ │ │ +000424f0: 6d70 3b26 616d 703b 2070 692d 2667 743b  mp;& pi->
    │ │ │ +00042500: 6f70 7469 6d69 7374 6963 616c 6c79 5f75  optimistically_u
    │ │ │ +00042510: 6e63 686f 6b65 6429 0a09 0909 097b 0a09  nchoked).....{..
    │ │ │ +00042520: 0909 0909 6d5f 7374 6174 735f 636f 756e  ....m_stats_coun
    │ │ │ +00042530: 7465 7273 2e69 6e63 5f73 7461 7473 5f63  ters.inc_stats_c
    │ │ │ +00042540: 6f75 6e74 6572 2863 6f75 6e74 6572 733a  ounter(counters:
    │ │ │ +00042550: 3a6e 756d 5f70 6565 7273 5f75 705f 756e  :num_peers_up_un
    │ │ │ +00042560: 6368 6f6b 6564 5f6f 7074 696d 6973 7469  choked_optimisti
    │ │ │ +00042570: 632c 202d 3129 3b0a 0909 0909 0970 692d  c, -1);......pi-
    │ │ │ +00042580: 2667 743b 6f70 7469 6d69 7374 6963 616c  >optimistical
    │ │ │ +00042590: 6c79 5f75 6e63 686f 6b65 6420 3d20 6661  ly_unchoked = fa
    │ │ │ +000425a0: 6c73 653b 0a09 0909 0909 2f2f 2066 6f72  lse;......// for
    │ │ │ +000425b0: 6365 2061 206e 6577 206f 7074 696d 6973  ce a new optimis
    │ │ │ +000425c0: 7469 6320 756e 6368 6f6b 650a 0909 0909  tic unchoke.....
    │ │ │ +000425d0: 096d 5f6f 7074 696d 6973 7469 635f 756e  .m_optimistic_un
    │ │ │ +000425e0: 6368 6f6b 655f 7469 6d65 5f73 6361 6c65  choke_time_scale
    │ │ │ +000425f0: 7220 3d20 303b 0a3c 6469 7620 7374 796c  r = 0;.
    ....}.
    ....t->choke │ │ │ +00042640: 5f70 6565 7228 2a70 293b 0a09 0909 0970 _peer(*p);.....p │ │ │ +00042650: 2d26 6774 3b72 6573 6574 5f63 686f 6b65 ->reset_choke │ │ │ +00042660: 5f63 6f75 6e74 6572 7328 293b 0a09 0909 _counters();.... │ │ │ +00042670: 0963 6f6e 7469 6e75 653b 0a09 0909 7d0a .continue;....}. │ │ │ +00042680: 0a09 0909 7065 6572 732e 7075 7368 5f62 ....peers.push_b │ │ │ +00042690: 6163 6b28 702e 6765 7428 2929 3b0a 0909 ack(p.get());... │ │ │ +000426a0: 7d0a 0a09 0969 6e74 2063 6f6e 7374 2061 }....int const a │ │ │ +000426b0: 6c6c 6f77 6564 5f75 706c 6f61 645f 736c llowed_upload_sl │ │ │ +000426c0: 6f74 7320 3d20 756e 6368 6f6b 655f 736f ots = unchoke_so │ │ │ +000426d0: 7274 2870 6565 7273 0a09 0909 2c20 756e rt(peers...., un │ │ │ +000426e0: 6368 6f6b 655f 696e 7465 7276 616c 2c20 choke_interval, │ │ │ +000426f0: 6d5f 7365 7474 696e 6773 293b 0a0a 0909 m_settings);.... │ │ │ +00042700: 6966 2028 6d5f 7365 7474 696e 6773 2e67 if (m_settings.g │ │ │ +00042710: 6574 5f69 6e74 2873 6574 7469 6e67 735f et_int(settings_ │ │ │ +00042720: 7061 636b 3a3a 6368 6f6b 696e 675f 616c pack::choking_al │ │ │ +00042730: 676f 7269 7468 6d29 203d 3d20 7365 7474 gorithm) == sett │ │ │ +00042740: 696e 6773 5f70 6163 6b3a 3a66 6978 6564 ings_pack::fixed │ │ │ +00042750: 5f73 6c6f 7473 5f63 686f 6b65 7229 0a09 _slots_choker).. │ │ │ +00042760: 097b 0a09 0909 696e 7420 636f 6e73 7420 .{....int const │ │ │ +00042770: 7570 6c6f 6164 5f73 6c6f 7473 203d 2067 upload_slots = g │ │ │ +00042780: 6574 5f69 6e74 5f73 6574 7469 6e67 2873 et_int_setting(s │ │ │ +00042790: 6574 7469 6e67 735f 7061 636b 3a3a 756e ettings_pack::un │ │ │ +000427a0: 6368 6f6b 655f 736c 6f74 735f 6c69 6d69 choke_slots_limi │ │ │ +000427b0: 7429 3b0a 0909 096d 5f73 7461 7473 5f63 t);....m_stats_c │ │ │ +000427c0: 6f75 6e74 6572 732e 7365 745f 7661 6c75 ounters.set_valu │ │ │ +000427d0: 6528 636f 756e 7465 7273 3a3a 6e75 6d5f e(counters::num_ │ │ │ +000427e0: 756e 6368 6f6b 655f 736c 6f74 732c 2075 unchoke_slots, u │ │ │ +000427f0: 706c 6f61 645f 736c 6f74 7329 3b0a 0909 pload_slots);... │ │ │ +00042800: 7d0a 0909 656c 7365 0a09 097b 0a09 0909 }...else...{.... │ │ │ +00042810: 6d5f 7374 6174 735f 636f 756e 7465 7273 m_stats_counters │ │ │ +00042820: 2e73 6574 5f76 616c 7565 2863 6f75 6e74 .set_value(count │ │ │ +00042830: 6572 733a 3a6e 756d 5f75 6e63 686f 6b65 ers::num_unchoke │ │ │ +00042840: 5f73 6c6f 7473 0a09 0909 092c 2061 6c6c _slots....., all │ │ │ +00042850: 6f77 6564 5f75 706c 6f61 645f 736c 6f74 owed_upload_slot │ │ │ +00042860: 7329 3b0a 0909 7d0a 0a23 6966 6e64 6566 s);...}..#ifndef │ │ │ +00042870: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +00042880: 5f4c 4f47 4749 4e47 0a09 0969 6620 2873 _LOGGING...if (s │ │ │ +00042890: 686f 756c 645f 6c6f 6728 2929 0a09 097b hould_log())...{ │ │ │ +000428a0: 0a09 0909 7365 7373 696f 6e5f 6c6f 6728 ....session_log( │ │ │ +000428b0: 2252 4543 414c 4355 4c41 5445 2055 4e43 "RECALCULATE UNC │ │ │ +000428c0: 484f 4b45 2053 4c4f 5453 3a20 5b20 7065 HOKE SLOTS: [ pe │ │ │ +000428d0: 6572 733a 2025 6420 220a 0909 0909 2265 ers: %d "....."e │ │ │ +000428e0: 6c69 6769 626c 652d 7065 6572 733a 2025 ligible-peers: % │ │ │ +000428f0: 6422 0a09 0909 0922 2061 6c6c 6f77 6564 d"....." allowed │ │ │ +00042900: 2d73 6c6f 7473 3a20 2564 205d 220a 0909 -slots: %d ]"... │ │ │ +00042910: 0909 2c20 696e 7428 6d5f 636f 6e6e 6563 .., int(m_connec │ │ │ +00042920: 7469 6f6e 732e 7369 7a65 2829 290a 0909 tions.size())... │ │ │ +00042930: 0909 2c20 696e 7428 7065 6572 732e 7369 .., int(peers.si │ │ │ +00042940: 7a65 2829 290a 3c2f 7072 653e 3c2f 7464 ze()).
    relevance │ │ │ +00042980: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00042990: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/session_ │ │ │ +000429c0: 696d 706c 2e63 7070 3a34 3934 383c 2f61 impl.cpp:4948it mig │ │ │ +000429e0: 6874 2062 6520 6120 6e69 6365 2066 6561 ht be a nice fea │ │ │ +000429f0: 7475 7265 2068 6572 6520 746f 206c 696d ture here to lim │ │ │ +00042a00: 6974 2074 6865 206e 756d 6265 7220 6f66 it the number of │ │ │ +00042a10: 2074 6f72 7265 6e74 7320 746f 2073 656e torrents to sen │ │ │ +00042a20: 6420 696e 2061 2073 696e 676c 6520 7570 d in a single up │ │ │ +00042a30: 6461 7465 2e20 4279 206a 7573 7420 706f date. By just po │ │ │ +00042a40: 7374 696e 6720 7468 6520 6669 7273 7420 sting the first │ │ │ +00042a50: 6e20 746f 7272 656e 7473 2c20 7468 6579 n torrents, they │ │ │ +00042a60: 2077 6f75 6c64 206e 6963 656c 7920 6265 would nicely be │ │ │ +00042a70: 2072 6f75 6e64 2d72 6f62 696e 6564 2062 round-robined b │ │ │ +00042a80: 6563 6175 7365 2074 6865 2074 6f72 7265 ecause the torre │ │ │ +00042a90: 6e74 206c 6973 7473 2061 7265 2061 6c77 nt lists are alw │ │ │ +00042aa0: 6179 7320 7075 7368 6564 2062 6163 6b2e ays pushed back. │ │ │ +00042ab0: 2050 6572 6861 7073 2074 6865 2073 7461 Perhaps the sta │ │ │ +00042ac0: 7475 735f 7570 6461 7465 5f61 6c65 7274 tus_update_alert │ │ │ +00042ad0: 2063 6f75 6c64 2065 7665 6e20 6861 7665 could even have │ │ │ +00042ae0: 2061 2066 6978 6564 2061 7272 6179 206f a fixed array o │ │ │ +00042af0: 6620 6e20 656e 7472 6965 7320 7261 7468 f n entries rath │ │ │ +00042b00: 6572 2074 6861 6e20 6120 7665 6374 6f72 er than a vector │ │ │ +00042b10: 2c20 746f 2066 7572 7468 6572 2069 6d70 , to further imp │ │ │ +00042b20: 726f 7665 206d 656d 6f72 7920 6c6f 6361 rove memory loca │ │ │ +00042b30: 6c69 7479 2e3c 2f74 643e 3c2f 7472 3e3c lity.< │ │ │ +00042b40: 7472 2069 643d 2231 3634 2220 7374 796c tr id="164" styl │ │ │ +00042b50: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00042b60: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00042b70: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00042b80: 6832 3e69 7420 6d69 6768 7420 6265 2061 h2>it might be a │ │ │ +00042b90: 206e 6963 6520 6665 6174 7572 6520 6865 nice feature he │ │ │ +00042ba0: 7265 2074 6f20 6c69 6d69 7420 7468 6520 re to limit the │ │ │ +00042bb0: 6e75 6d62 6572 206f 6620 746f 7272 656e number of torren │ │ │ +00042bc0: 7473 0a74 6f20 7365 6e64 2069 6e20 6120 ts.to send in a │ │ │ +00042bd0: 7369 6e67 6c65 2075 7064 6174 652e 2042 single update. B │ │ │ +00042be0: 7920 6a75 7374 2070 6f73 7469 6e67 2074 y just posting t │ │ │ +00042bf0: 6865 2066 6972 7374 206e 2074 6f72 7265 he first n torre │ │ │ +00042c00: 6e74 732c 2074 6865 790a 776f 756c 6420 nts, they.would │ │ │ +00042c10: 6e69 6365 6c79 2062 6520 726f 756e 642d nicely be round- │ │ │ +00042c20: 726f 6269 6e65 6420 6265 6361 7573 6520 robined because │ │ │ +00042c30: 7468 6520 746f 7272 656e 7420 6c69 7374 the torrent list │ │ │ +00042c40: 7320 6172 6520 616c 7761 7973 0a70 7573 s are always.pus │ │ │ +00042c50: 6865 6420 6261 636b 2e20 5065 7268 6170 hed back. Perhap │ │ │ +00042c60: 7320 7468 6520 7374 6174 7573 5f75 7064 s the status_upd │ │ │ +00042c70: 6174 655f 616c 6572 7420 636f 756c 6420 ate_alert could │ │ │ +00042c80: 6576 656e 2068 6176 6520 6120 6669 7865 even have a fixe │ │ │ +00042c90: 640a 6172 7261 7920 6f66 206e 2065 6e74 d.array of n ent │ │ │ +00042ca0: 7269 6573 2072 6174 6865 7220 7468 616e ries rather than │ │ │ +00042cb0: 2061 2076 6563 746f 722c 2074 6f20 6675 a vector, to fu │ │ │ +00042cc0: 7274 6865 7220 696d 7072 6f76 6520 6d65 rther improve me │ │ │ +00042cd0: 6d6f 7279 0a6c 6f63 616c 6974 792e 3c2f mory.locality.

    ../src/se │ │ │ +00042cf0: 7373 696f 6e5f 696d 706c 2e63 7070 3a34 ssion_impl.cpp:4 │ │ │ +00042d00: 3934 383c 2f68 343e 3c70 7265 2073 7479 948

    ...t->statu
    │ │ │ +00042d50: 7328 2661 6d70 3b73 742c 2066 6c61 6773  s(&st, flags
    │ │ │ +00042d60: 293b 0a09 097d 0a09 7d0a 0a09 766f 6964  );...}..}...void
    │ │ │ +00042d70: 2073 6573 7369 6f6e 5f69 6d70 6c3a 3a70   session_impl::p
    │ │ │ +00042d80: 6f73 745f 746f 7272 656e 745f 7570 6461  ost_torrent_upda
    │ │ │ +00042d90: 7465 7328 7374 6174 7573 5f66 6c61 6773  tes(status_flags
    │ │ │ +00042da0: 5f74 2063 6f6e 7374 2066 6c61 6773 290a  _t const flags).
    │ │ │ +00042db0: 097b 0a09 0949 4e56 4152 4941 4e54 5f43  .{...INVARIANT_C
    │ │ │ +00042dc0: 4845 434b 3b0a 0a09 0954 4f52 5245 4e54  HECK;....TORRENT
    │ │ │ +00042dd0: 5f41 5353 4552 5428 6973 5f73 696e 676c  _ASSERT(is_singl
    │ │ │ +00042de0: 655f 7468 7265 6164 2829 293b 0a0a 0909  e_thread());....
    │ │ │ +00042df0: 7374 643a 3a76 6563 746f 7226 6c74 3b74  std::vector<t
    │ │ │ +00042e00: 6f72 7265 6e74 2a26 6774 3b26 616d 703b  orrent*>&
    │ │ │ +00042e10: 2073 7461 7465 5f75 7064 6174 6573 0a09   state_updates..
    │ │ │ +00042e20: 0909 3d20 6d5f 746f 7272 656e 745f 6c69  ..= m_torrent_li
    │ │ │ +00042e30: 7374 735b 6175 783a 3a73 6573 7369 6f6e  sts[aux::session
    │ │ │ +00042e40: 5f69 6d70 6c3a 3a74 6f72 7265 6e74 5f73  _impl::torrent_s
    │ │ │ +00042e50: 7461 7465 5f75 7064 6174 6573 5d3b 0a0a  tate_updates];..
    │ │ │ +00042e60: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ +00042e70: 4153 5345 5254 530a 0909 6d5f 706f 7374  ASSERTS...m_post
    │ │ │ +00042e80: 696e 675f 746f 7272 656e 745f 7570 6461  ing_torrent_upda
    │ │ │ +00042e90: 7465 7320 3d20 7472 7565 3b0a 2365 6e64  tes = true;.#end
    │ │ │ +00042ea0: 6966 0a0a 0909 7374 643a 3a76 6563 746f  if....std::vecto
    │ │ │ +00042eb0: 7226 6c74 3b74 6f72 7265 6e74 5f73 7461  r<torrent_sta
    │ │ │ +00042ec0: 7475 7326 6774 3b20 7374 6174 7573 3b0a  tus> status;.
    │ │ │ +00042ed0: 0909 7374 6174 7573 2e72 6573 6572 7665  ..status.reserve
    │ │ │ +00042ee0: 2873 7461 7465 5f75 7064 6174 6573 2e73  (state_updates.s
    │ │ │ +00042ef0: 697a 6528 2929 3b0a 0a3c 6469 7620 7374  ize());..
    ..for (au │ │ │ +00042f30: 746f 2661 6d70 3b20 7420 3a20 7374 6174 to& t : stat │ │ │ +00042f40: 655f 7570 6461 7465 7329 0a3c 2f64 6976 e_updates).
    ..{....TORRENT_ │ │ │ +00042f60: 4153 5345 5254 2874 2d26 6774 3b6d 5f6c ASSERT(t->m_l │ │ │ +00042f70: 696e 6b73 5b61 7578 3a3a 7365 7373 696f inks[aux::sessio │ │ │ +00042f80: 6e5f 696d 706c 3a3a 746f 7272 656e 745f n_impl::torrent_ │ │ │ +00042f90: 7374 6174 655f 7570 6461 7465 735d 2e69 state_updates].i │ │ │ +00042fa0: 6e5f 6c69 7374 2829 293b 0a09 0909 7374 n_list());....st │ │ │ +00042fb0: 6174 7573 2e65 6d70 6c61 6365 5f62 6163 atus.emplace_bac │ │ │ +00042fc0: 6b28 293b 0a09 0909 2f2f 2071 7565 7279 k();....// query │ │ │ +00042fd0: 696e 6720 6163 6375 7261 7465 2064 6f77 ing accurate dow │ │ │ +00042fe0: 6e6c 6f61 6420 636f 756e 7465 7273 206d nload counters m │ │ │ +00042ff0: 6179 2072 6571 7569 7265 0a09 0909 2f2f ay require....// │ │ │ +00043000: 2074 6865 2074 6f72 7265 6e74 2074 6f20 the torrent to │ │ │ +00043010: 6265 206c 6f61 6465 642e 204c 6f61 6469 be loaded. Loadi │ │ │ +00043020: 6e67 2061 2074 6f72 7265 6e74 2c20 616e ng a torrent, an │ │ │ +00043030: 6420 6576 6963 7469 6e67 2061 6e6f 7468 d evicting anoth │ │ │ +00043040: 6572 0a09 0909 2f2f 206f 6e65 2077 696c er....// one wil │ │ │ +00043050: 6c20 6c65 6164 2074 6f20 6361 6c6c 696e l lead to callin │ │ │ +00043060: 6720 7374 6174 655f 7570 6461 7465 6428 g state_updated( │ │ │ +00043070: 292c 2077 6869 6368 2073 6372 6577 7320 ), which screws │ │ │ +00043080: 7769 7468 0a09 0909 2f2f 2074 6869 7320 with....// this │ │ │ +00043090: 6c69 7374 2077 6869 6c65 2077 6527 7265 list while we're │ │ │ +000430a0: 2077 6f72 6b69 6e67 206f 6e20 6974 2c20 working on it, │ │ │ +000430b0: 616e 6420 6272 6561 6b20 7468 696e 6773 and break things │ │ │ +000430c0: 0a09 0909 742d 2667 743b 7374 6174 7573 ....t->status │ │ │ +000430d0: 2826 616d 703b 7374 6174 7573 2e62 6163 (&status.bac │ │ │ +000430e0: 6b28 292c 2066 6c61 6773 293b 0a09 0909 k(), flags);.... │ │ │ +000430f0: 742d 2667 743b 636c 6561 725f 696e 5f73 t->clear_in_s │ │ │ +00043100: 7461 7465 5f75 7064 6174 6528 293b 0a09 tate_update();.. │ │ │ +00043110: 097d 0a09 0973 7461 7465 5f75 7064 6174 .}...state_updat │ │ │ +00043120: 6573 2e63 6c65 6172 2829 3b0a 0a23 6966 es.clear();..#if │ │ │ +00043130: 2054 4f52 5245 4e54 5f55 5345 5f41 5353 TORRENT_USE_ASS │ │ │ +00043140: 4552 5453 0a09 096d 5f70 6f73 7469 6e67 ERTS...m_posting │ │ │ +00043150: 5f74 6f72 7265 6e74 5f75 7064 6174 6573 _torrent_updates │ │ │ +00043160: 203d 2066 616c 7365 3b0a 2365 6e64 6966 = false;.#endif │ │ │ +00043170: 0a0a 0909 6d5f 616c 6572 7473 2e65 6d70 ....m_alerts.emp │ │ │ +00043180: 6c61 6365 5f61 6c65 7274 266c 743b 7374 lace_alert<st │ │ │ +00043190: 6174 655f 7570 6461 7465 5f61 6c65 7274 ate_update_alert │ │ │ +000431a0: 2667 743b 2873 7464 3a3a 6d6f 7665 2873 >(std::move(s │ │ │ +000431b0: 7461 7475 7329 293b 0a09 7d0a 0a09 766f tatus));..}...vo │ │ │ +000431c0: 6964 2073 6573 7369 6f6e 5f69 6d70 6c3a id session_impl: │ │ │ +000431d0: 3a70 6f73 745f 7365 7373 696f 6e5f 7374 :post_session_st │ │ │ +000431e0: 6174 7328 290a 097b 0a09 0969 6620 2821 ats()..{...if (! │ │ │ +000431f0: 6d5f 706f 7374 6564 5f73 7461 7473 5f68 m_posted_stats_h │ │ │ +00043200: 6561 6465 7229 0a09 097b 0a09 0909 6d5f eader)...{....m_ │ │ │ +00043210: 706f 7374 6564 5f73 7461 7473 5f68 6561 posted_stats_hea │ │ │ +00043220: 6465 7220 3d20 7472 7565 3b0a 0909 096d der = true;....m │ │ │ +00043230: 5f61 6c65 7274 732e 656d 706c 6163 655f _alerts.emplace_ │ │ │ +00043240: 616c 6572 7426 6c74 3b73 6573 7369 6f6e alert<session │ │ │ +00043250: 5f73 7461 7473 5f68 6561 6465 725f 616c _stats_header_al │ │ │ +00043260: 6572 7426 6774 3b28 293b 0a09 097d 0a09 ert>();...}.. │ │ │ +00043270: 096d 5f64 6973 6b5f 7468 7265 6164 2d26 .m_disk_thread-& │ │ │ +00043280: 6774 3b75 7064 6174 655f 7374 6174 735f gt;update_stats_ │ │ │ +00043290: 636f 756e 7465 7273 286d 5f73 7461 7473 counters(m_stats │ │ │ +000432a0: 5f63 6f75 6e74 6572 7329 3b0a 0a23 6966 _counters);..#if │ │ │ +000432b0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +000432c0: 4142 4c45 5f44 4854 0a09 0969 6620 286d ABLE_DHT...if (m │ │ │ +000432d0: 5f64 6874 290a 3c2f 7072 653e 3c2f 7464 _dht).
    relevance │ │ │ +00043310: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00043320: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/session_ │ │ │ +00043350: 696d 706c 2e63 7070 3a35 3334 323c 2f61 impl.cpp:5342factor │ │ │ +00043370: 206f 7574 2074 6869 7320 6c6f 6769 6320 out this logic │ │ │ +00043380: 696e 746f 2061 2073 6570 6172 6174 6520 into a separate │ │ │ +00043390: 6675 6e63 7469 6f6e 2066 6f72 2075 6e69 function for uni │ │ │ +000433a0: 7420 7465 7374 696e 673c 2f74 643e 3c2f t testing

    factor ou │ │ │ +00043400: 7420 7468 6973 206c 6f67 6963 2069 6e74 t this logic int │ │ │ +00043410: 6f20 6120 7365 7061 7261 7465 2066 756e o a separate fun │ │ │ +00043420: 6374 696f 6e20 666f 7220 756e 6974 0a74 ction for unit.t │ │ │ +00043430: 6573 7469 6e67 3c2f 6832 3e3c 6834 3e2e esting

    . │ │ │ +00043440: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00043450: 706c 2e63 7070 3a35 3334 323c 2f68 343e pl.cpp:5342

    │ │ │ +00043460: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..if (
    │ │ │ +000434a0: 6d5f 7365 7474 696e 6773 2e67 6574 5f69  m_settings.get_i
    │ │ │ +000434b0: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ +000434c0: 3a3a 6f75 7467 6f69 6e67 5f70 6f72 7429  ::outgoing_port)
    │ │ │ +000434d0: 2026 6774 3b20 3029 0a09 097b 0a23 6966   > 0)...{.#if
    │ │ │ +000434e0: 6465 6620 544f 5252 454e 545f 5749 4e44  def TORRENT_WIND
    │ │ │ +000434f0: 4f57 530a 0909 0973 2e73 6574 5f6f 7074  OWS....s.set_opt
    │ │ │ +00043500: 696f 6e28 6578 636c 7573 6976 655f 6164  ion(exclusive_ad
    │ │ │ +00043510: 6472 6573 735f 7573 6528 7472 7565 292c  dress_use(true),
    │ │ │ +00043520: 2065 6329 3b0a 2365 6c73 650a 0909 0973   ec);.#else....s
    │ │ │ +00043530: 2e73 6574 5f6f 7074 696f 6e28 7463 703a  .set_option(tcp:
    │ │ │ +00043540: 3a61 6363 6570 746f 723a 3a72 6575 7365  :acceptor::reuse
    │ │ │ +00043550: 5f61 6464 7265 7373 2874 7275 6529 2c20  _address(true), 
    │ │ │ +00043560: 6563 293b 0a23 656e 6469 660a 0909 092f  ec);.#endif..../
    │ │ │ +00043570: 2f20 6967 6e6f 7265 2065 7272 6f72 7320  / ignore errors 
    │ │ │ +00043580: 6265 6361 7573 6520 7468 6520 756e 6465  because the unde
    │ │ │ +00043590: 726c 7969 6e67 2073 6f63 6b65 7420 6d61  rlying socket ma
    │ │ │ +000435a0: 7920 6e6f 740a 0909 092f 2f20 6265 206f  y not....// be o
    │ │ │ +000435b0: 7065 6e65 6420 7965 742e 2054 6869 7320  pened yet. This 
    │ │ │ +000435c0: 6861 7070 656e 7320 7768 656e 2077 6527  happens when we'
    │ │ │ +000435d0: 7265 2072 6f75 7469 6e67 2074 6872 6f75  re routing throu
    │ │ │ +000435e0: 6768 0a09 0909 2f2f 2061 2070 726f 7879  gh....// a proxy
    │ │ │ +000435f0: 2e20 496e 2074 6861 7420 6361 7365 2c20  . In that case, 
    │ │ │ +00043600: 7765 2064 6f6e 2774 2079 6574 206b 6e6f  we don't yet kno
    │ │ │ +00043610: 7720 7468 6520 6164 6472 6573 7320 6f66  w the address of
    │ │ │ +00043620: 0a09 0909 2f2f 2074 6865 2070 726f 7879  ....// the proxy
    │ │ │ +00043630: 2073 6572 7665 722c 2061 6e64 206d 6f72   server, and mor
    │ │ │ +00043640: 6520 696d 706f 7274 616e 746c 792c 2077  e importantly, w
    │ │ │ +00043650: 6520 646f 6e27 7420 6b6e 6f77 0a09 0909  e don't know....
    │ │ │ +00043660: 2f2f 2074 6865 2061 6464 7265 7373 2066  // the address f
    │ │ │ +00043670: 616d 696c 7920 6f66 2069 7473 2061 6464  amily of its add
    │ │ │ +00043680: 7265 7373 2e20 5468 6973 206d 6561 6e73  ress. This means
    │ │ │ +00043690: 2077 6520 6361 6e27 740a 0909 092f 2f20   we can't....// 
    │ │ │ +000436a0: 6f70 656e 2074 6865 2073 6f63 6b65 7420  open the socket 
    │ │ │ +000436b0: 7965 742e 2054 6865 2073 6f63 6b73 2061  yet. The socks a
    │ │ │ +000436c0: 6273 7472 6163 7469 6f6e 206c 6179 6572  bstraction layer
    │ │ │ +000436d0: 2064 6566 6572 730a 0909 092f 2f20 6f70   defers....// op
    │ │ │ +000436e0: 656e 696e 6720 6974 2e0a 0909 0965 632e  ening it.....ec.
    │ │ │ +000436f0: 636c 6561 7228 293b 0a09 0909 6269 6e64  clear();....bind
    │ │ │ +00043700: 5f65 702e 706f 7274 2873 7464 3a3a 7569  _ep.port(std::ui
    │ │ │ +00043710: 6e74 3136 5f74 286e 6578 745f 706f 7274  nt16_t(next_port
    │ │ │ +00043720: 2829 2929 3b0a 0909 7d0a 0a09 0969 6620  ()));...}....if 
    │ │ │ +00043730: 2869 735f 7574 7028 7329 290a 0909 7b0a  (is_utp(s))...{.
    │ │ │ +00043740: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ +00043770: 2f64 6976 3e09 0909 7574 705f 736f 636b /div>...utp_sock │ │ │ +00043780: 6574 5f69 6d70 6c2a 2069 6d70 6c20 3d20 et_impl* impl = │ │ │ +00043790: 6e75 6c6c 7074 723b 0a09 0909 7472 616e nullptr;....tran │ │ │ +000437a0: 7370 6f72 7420 7373 6c20 3d20 7472 616e sport ssl = tran │ │ │ +000437b0: 7370 6f72 743a 3a70 6c61 696e 7465 7874 sport::plaintext │ │ │ +000437c0: 3b0a 2369 6620 544f 5252 454e 545f 5553 ;.#if TORRENT_US │ │ │ +000437d0: 455f 5353 4c0a 0909 0969 6620 2873 7464 E_SSL....if (std │ │ │ +000437e0: 3a3a 6765 745f 6966 266c 743b 7373 6c5f ::get_if<ssl_ │ │ │ +000437f0: 7374 7265 616d 266c 743b 7574 705f 7374 stream<utp_st │ │ │ +00043800: 7265 616d 2667 743b 2667 743b 2826 616d ream>>(&am │ │ │ +00043810: 703b 732e 7661 7228 2929 2021 3d20 6e75 p;s.var()) != nu │ │ │ +00043820: 6c6c 7074 7229 0a09 0909 7b0a 0909 0909 llptr)....{..... │ │ │ +00043830: 696d 706c 203d 2073 7464 3a3a 6765 7426 impl = std::get& │ │ │ +00043840: 6c74 3b73 736c 5f73 7472 6561 6d26 6c74 lt;ssl_stream< │ │ │ +00043850: 3b75 7470 5f73 7472 6561 6d26 6774 3b26 ;utp_stream>& │ │ │ +00043860: 6774 3b28 7329 2e6e 6578 745f 6c61 7965 gt;(s).next_laye │ │ │ +00043870: 7228 292e 6765 745f 696d 706c 2829 3b0a r().get_impl();. │ │ │ +00043880: 0909 0909 7373 6c20 3d20 7472 616e 7370 ....ssl = transp │ │ │ +00043890: 6f72 743a 3a73 736c 3b0a 0909 097d 0a09 ort::ssl;....}.. │ │ │ +000438a0: 0909 656c 7365 0a23 656e 6469 660a 0909 ..else.#endif... │ │ │ +000438b0: 0909 696d 706c 203d 2073 7464 3a3a 6765 ..impl = std::ge │ │ │ +000438c0: 7426 6c74 3b75 7470 5f73 7472 6561 6d26 t<utp_stream& │ │ │ +000438d0: 6774 3b28 7329 2e67 6574 5f69 6d70 6c28 gt;(s).get_impl( │ │ │ +000438e0: 293b 0a0a 0909 0973 7464 3a3a 7665 6374 );.....std::vect │ │ │ +000438f0: 6f72 266c 743b 7374 643a 3a73 6861 7265 or<std::share │ │ │ +00043900: 645f 7074 7226 6c74 3b6c 6973 7465 6e5f d_ptr<listen_ │ │ │ +00043910: 736f 636b 6574 5f74 2667 743b 2667 743b socket_t>> │ │ │ +00043920: 2077 6974 685f 6761 7465 7761 7973 3b0a with_gateways;. │ │ │ +00043930: 0909 0973 7464 3a3a 7368 6172 6564 5f70 ...std::shared_p │ │ │ +00043940: 7472 266c 743b 6c69 7374 656e 5f73 6f63 tr<listen_soc │ │ │ +00043950: 6b65 745f 7426 6774 3b20 6d61 7463 683b ket_t> match; │ │ │ +00043960: 0a09 0909 666f 7220 2861 7574 6f20 636f ....for (auto co │ │ │ +00043970: 6e73 7426 616d 703b 206c 7320 3a20 6d5f nst& ls : m_ │ │ │ +00043980: 6c69 7374 656e 5f73 6f63 6b65 7473 290a listen_sockets). │ │ │ +00043990: 0909 097b 0a09 0909 092f 2f20 7468 6973 ...{.....// this │ │ │ +000439a0: 2069 7320 616c 6d6f 7374 2c20 6275 7420 is almost, but │ │ │ +000439b0: 6e6f 7420 7175 6974 652c 206c 696b 6520 not quite, like │ │ │ +000439c0: 6361 6e5f 726f 7574 6528 290a 0909 0909 can_route()..... │ │ │ +000439d0: 6966 2028 2128 6c73 2d26 6774 3b66 6c61 if (!(ls->fla │ │ │ +000439e0: 6773 2026 616d 703b 206c 6973 7465 6e5f gs & listen_ │ │ │ +000439f0: 736f 636b 6574 5f74 3a3a 7072 6f78 7929 socket_t::proxy) │ │ │ +00043a00: 0a09 0909 0909 2661 6d70 3b26 616d 703b ......&& │ │ │ +00043a10: 2069 735f 7634 286c 732d 2667 743b 6c6f is_v4(ls->lo │ │ │ +00043a20: 6361 6c5f 656e 6470 6f69 6e74 2920 213d cal_endpoint) != │ │ │ +00043a30: 2072 656d 6f74 655f 6164 6472 6573 732e remote_address. │ │ │ +00043a40: 6973 5f76 3428 2929 0a09 0909 0909 636f is_v4())......co │ │ │ +00043a50: 6e74 696e 7565 3b0a 0909 0909 6966 2028 ntinue;.....if ( │ │ │ +00043a60: 6c73 2d26 6774 3b73 736c 2021 3d20 7373 ls->ssl != ss │ │ │ +00043a70: 6c29 2063 6f6e 7469 6e75 653b 0a09 0909 l) continue;.... │ │ │ +00043a80: 0969 6620 2821 286c 732d 2667 743b 666c .if (!(ls->fl │ │ │ +00043a90: 6167 7320 2661 6d70 3b20 6c69 7374 656e ags & listen │ │ │ +00043aa0: 5f73 6f63 6b65 745f 743a 3a6c 6f63 616c _socket_t::local │ │ │ +00043ab0: 5f6e 6574 776f 726b 2929 0a09 0909 0909 _network))...... │ │ │ +00043ac0: 7769 7468 5f67 6174 6577 6179 732e 7075 with_gateways.pu │ │ │ +00043ad0: 7368 5f62 6163 6b28 6c73 293b 0a0a 0909 sh_back(ls);.... │ │ │ +00043ae0: 0909 6966 2028 6c73 2d26 6774 3b66 6c61 ..if (ls->fla │ │ │ +00043af0: 6773 2026 616d 703b 206c 6973 7465 6e5f gs & listen_ │ │ │ +00043b00: 736f 636b 6574 5f74 3a3a 7072 6f78 790a socket_t::proxy. │ │ │ +00043b10: 0909 0909 097c 7c20 6d61 7463 685f 6164 .....|| match_ad │ │ │ +00043b20: 6472 5f6d 6173 6b28 6c73 2d26 6774 3b6c dr_mask(ls->l │ │ │ +00043b30: 6f63 616c 5f65 6e64 706f 696e 742e 6164 ocal_endpoint.ad │ │ │ +00043b40: 6472 6573 7328 292c 2072 656d 6f74 655f dress(), remote_ │ │ │ +00043b50: 6164 6472 6573 732c 206c 732d 2667 743b address, ls-> │ │ │ +00043b60: 6e65 746d 6173 6b29 290a 0909 0909 7b0a netmask)).....{. │ │ │ +00043b70: 0909 0909 092f 2f20 6973 2074 6869 7320 .....// is this │ │ │ +00043b80: 6265 7474 6572 2074 6861 6e20 7468 6520 better than the │ │ │ +00043b90: 7072 6576 696f 7573 206d 6174 6368 3f0a previous match?. │ │ │ +00043ba0: 0909 0909 096d 6174 6368 203d 206c 733b .....match = ls; │ │ │ +00043bb0: 0a09 0909 097d 0a3c 2f70 7265 3e3c 2f74 .....}.
    relevanc │ │ │ +00043bf0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/session │ │ │ +00043c30: 5f69 6d70 6c2e 6370 703a 3630 3730 3c2f _impl.cpp:6070refac │ │ │ +00043c50: 746f 722c 206d 6f76 6520 7468 6520 7374 tor, move the st │ │ │ +00043c60: 6f72 6167 6520 746f 2064 6874 5f74 7261 orage to dht_tra │ │ │ +00043c70: 636b 6572 3c2f 7464 3e3c 2f74 723e 3c74 ckerrefactor, move │ │ │ +00043cd0: 2074 6865 2073 746f 7261 6765 2074 6f20 the storage to │ │ │ +00043ce0: 6468 745f 7472 6163 6b65 723c 2f68 323e dht_tracker │ │ │ +00043cf0: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ +00043d00: 6f6e 5f69 6d70 6c2e 6370 703a 3630 3730 on_impl.cpp:6070 │ │ │ +00043d10: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ +00043d50: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ +00043d60: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ +00043d70: 0909 7365 7373 696f 6e5f 6c6f 6728 226e  ..session_log("n
    │ │ │ +00043d80: 6f74 2073 7461 7274 696e 6720 4448 542c  ot starting DHT,
    │ │ │ +00043d90: 206f 7574 7374 616e 6469 6e67 2072 6f75   outstanding rou
    │ │ │ +00043da0: 7465 7220 6c6f 6f6b 7570 733a 2025 6422  ter lookups: %d"
    │ │ │ +00043db0: 0a09 0909 092c 206d 5f6f 7574 7374 616e  ....., m_outstan
    │ │ │ +00043dc0: 6469 6e67 5f72 6f75 7465 725f 6c6f 6f6b  ding_router_look
    │ │ │ +00043dd0: 7570 7329 3b0a 2365 6e64 6966 0a09 0909  ups);.#endif....
    │ │ │ +00043de0: 7265 7475 726e 3b0a 0909 7d0a 0a09 0969  return;...}....i
    │ │ │ +00043df0: 6620 286d 5f61 626f 7274 290a 0909 7b0a  f (m_abort)...{.
    │ │ │ +00043e00: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +00043e10: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +00043e20: 0909 0973 6573 7369 6f6e 5f6c 6f67 2822  ...session_log("
    │ │ │ +00043e30: 6e6f 7420 7374 6172 7469 6e67 2044 4854  not starting DHT
    │ │ │ +00043e40: 2c20 6162 6f72 7469 6e67 2229 3b0a 2365  , aborting");.#e
    │ │ │ +00043e50: 6e64 6966 0a09 0909 7265 7475 726e 3b0a  ndif....return;.
    │ │ │ +00043e60: 0909 7d0a 0a23 6966 6e64 6566 2054 4f52  ..}..#ifndef TOR
    │ │ │ +00043e70: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ +00043e80: 4749 4e47 0a09 0973 6573 7369 6f6e 5f6c  GING...session_l
    │ │ │ +00043e90: 6f67 2822 7374 6172 7469 6e67 2044 4854  og("starting DHT
    │ │ │ +00043ea0: 2c20 7275 6e6e 696e 673a 2025 732c 2072  , running: %s, r
    │ │ │ +00043eb0: 6f75 7465 7220 6c6f 6f6b 7570 733a 2025  outer lookups: %
    │ │ │ +00043ec0: 6422 0a09 0909 2c20 6d5f 6468 7420 3f20  d"...., m_dht ? 
    │ │ │ +00043ed0: 2274 7275 6522 203a 2022 6661 6c73 6522  "true" : "false"
    │ │ │ +00043ee0: 2c20 6d5f 6f75 7473 7461 6e64 696e 675f  , m_outstanding_
    │ │ │ +00043ef0: 726f 7574 6572 5f6c 6f6f 6b75 7073 293b  router_lookups);
    │ │ │ +00043f00: 0a23 656e 6469 660a 0a3c 6469 7620 7374  .#endif..
    ..m_dht_s │ │ │ +00043f40: 746f 7261 6765 203d 206d 5f64 6874 5f73 torage = m_dht_s │ │ │ +00043f50: 746f 7261 6765 5f63 6f6e 7374 7275 6374 torage_construct │ │ │ +00043f60: 6f72 286d 5f73 6574 7469 6e67 7329 3b0a or(m_settings);. │ │ │ +00043f70: 3c2f 6469 763e 0909 6d5f 6468 7420 3d20
    ..m_dht = │ │ │ +00043f80: 7374 643a 3a6d 616b 655f 7368 6172 6564 std::make_shared │ │ │ +00043f90: 266c 743b 6468 743a 3a64 6874 5f74 7261 <dht::dht_tra │ │ │ +00043fa0: 636b 6572 2667 743b 280a 0909 0973 7461 cker>(....sta │ │ │ +00043fb0: 7469 635f 6361 7374 266c 743b 6468 743a tic_cast<dht: │ │ │ +00043fc0: 3a64 6874 5f6f 6273 6572 7665 722a 2667 :dht_observer*&g │ │ │ +00043fd0: 743b 2874 6869 7329 0a09 0909 2c20 6d5f t;(this)...., m_ │ │ │ +00043fe0: 696f 5f63 6f6e 7465 7874 0a09 0909 2c20 io_context...., │ │ │ +00043ff0: 5b74 6869 735d 2861 7578 3a3a 6c69 7374 [this](aux::list │ │ │ +00044000: 656e 5f73 6f63 6b65 745f 6861 6e64 6c65 en_socket_handle │ │ │ +00044010: 2063 6f6e 7374 2661 6d70 3b20 736f 636b const& sock │ │ │ +00044020: 0a09 0909 092c 2075 6470 3a3a 656e 6470 ....., udp::endp │ │ │ +00044030: 6f69 6e74 2063 6f6e 7374 2661 6d70 3b20 oint const& │ │ │ +00044040: 6570 0a09 0909 092c 2073 7061 6e26 6c74 ep....., span< │ │ │ +00044050: 3b63 6861 7220 636f 6e73 7426 6774 3b20 ;char const> │ │ │ +00044060: 700a 0909 0909 2c20 6572 726f 725f 636f p....., error_co │ │ │ +00044070: 6465 2661 6d70 3b20 6563 0a09 0909 092c de& ec....., │ │ │ +00044080: 2075 6470 5f73 656e 645f 666c 6167 735f udp_send_flags_ │ │ │ +00044090: 7420 636f 6e73 7420 666c 6167 7329 0a09 t const flags).. │ │ │ +000440a0: 0909 097b 2073 656e 645f 7564 705f 7061 ...{ send_udp_pa │ │ │ +000440b0: 636b 6574 5f6c 6973 7465 6e28 736f 636b cket_listen(sock │ │ │ +000440c0: 2c20 6570 2c20 702c 2065 632c 2066 6c61 , ep, p, ec, fla │ │ │ +000440d0: 6773 293b 207d 0a09 0909 2c20 6d5f 7365 gs); }...., m_se │ │ │ +000440e0: 7474 696e 6773 0a09 0909 2c20 6d5f 7374 ttings...., m_st │ │ │ +000440f0: 6174 735f 636f 756e 7465 7273 0a09 0909 ats_counters.... │ │ │ +00044100: 2c20 2a6d 5f64 6874 5f73 746f 7261 6765 , *m_dht_storage │ │ │ +00044110: 0a09 0909 2c20 7374 643a 3a6d 6f76 6528 ...., std::move( │ │ │ +00044120: 6d5f 6468 745f 7374 6174 6529 293b 0a0a m_dht_state));.. │ │ │ +00044130: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ +00044140: 2073 203a 206d 5f6c 6973 7465 6e5f 736f s : m_listen_so │ │ │ +00044150: 636b 6574 7329 0a09 097b 0a09 0909 6966 ckets)...{....if │ │ │ +00044160: 2028 732d 2667 743b 7373 6c20 213d 2074 (s->ssl != t │ │ │ +00044170: 7261 6e73 706f 7274 3a3a 7373 6c0a 0909 ransport::ssl... │ │ │ +00044180: 0909 2661 6d70 3b26 616d 703b 2021 2873 ..&& !(s │ │ │ +00044190: 2d26 6774 3b66 6c61 6773 2026 616d 703b ->flags & │ │ │ +000441a0: 206c 6973 7465 6e5f 736f 636b 6574 5f74 listen_socket_t │ │ │ +000441b0: 3a3a 6c6f 6361 6c5f 6e65 7477 6f72 6b29 ::local_network) │ │ │ +000441c0: 290a 0909 097b 0a09 0909 096d 5f64 6874 )....{.....m_dht │ │ │ +000441d0: 2d26 6774 3b6e 6577 5f73 6f63 6b65 7428 ->new_socket( │ │ │ +000441e0: 7329 3b0a 0909 097d 0a09 097d 0a0a 0909 s);....}...}.... │ │ │ +000441f0: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ +00044200: 616d 703b 206e 203a 206d 5f64 6874 5f72 amp; n : m_dht_r │ │ │ +00044210: 6f75 7465 725f 6e6f 6465 7329 0a09 097b outer_nodes)...{ │ │ │ +00044220: 0a09 0909 6d5f 6468 742d 2667 743b 6164 ....m_dht->ad │ │ │ +00044230: 645f 726f 7574 6572 5f6e 6f64 6528 6e29 d_router_node(n) │ │ │ +00044240: 3b0a 0909 7d0a 0a09 0966 6f72 2028 6175 ;...}....for (au │ │ │ +00044250: 746f 2063 6f6e 7374 2661 6d70 3b20 6e20 to const& n │ │ │ +00044260: 3a20 6d5f 6468 745f 6e6f 6465 7329 0a09 : m_dht_nodes).. │ │ │ +00044270: 097b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .{.
    │ │ │ +000442a0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +000442b0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0
    .. │ │ │ +000442e0: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +000442f0: 6c2e 6370 703a 3634 3533 3c2f 613e 3c2f l.cpp:6453asserts t │ │ │ +00044310: 6861 7420 6e6f 206f 7574 7374 616e 6469 hat no outstandi │ │ │ +00044320: 6e67 2061 7379 6e63 206f 7065 7261 7469 ng async operati │ │ │ +00044330: 6f6e 7320 6172 6520 7374 696c 6c20 696e ons are still in │ │ │ +00044340: 2066 6c69 6768 743c 2f74 643e 3c2f 7472 flight

    asserts tha │ │ │ +000443a0: 7420 6e6f 206f 7574 7374 616e 6469 6e67 t no outstanding │ │ │ +000443b0: 2061 7379 6e63 206f 7065 7261 7469 6f6e async operation │ │ │ +000443c0: 7320 6172 6520 7374 696c 6c20 696e 2066 s are still in f │ │ │ +000443d0: 6c69 6768 743c 2f68 323e 3c68 343e 2e2e light

    .. │ │ │ +000443e0: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +000443f0: 6c2e 6370 703a 3634 3533 3c2f 6834 3e3c l.cpp:6453

    < │ │ │ +00044400: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00044410: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00044420: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00044430: 7820 2364 6464 3b22 3e09 0969 6620 2821 x #ddd;">..if (! │ │ │ +00044440: 6d5f 6468 7429 2072 6574 7572 6e3b 0a09 m_dht) return;.. │ │ │ +00044450: 096d 5f64 6874 2d26 6774 3b64 6972 6563 .m_dht->direc │ │ │ +00044460: 745f 7265 7175 6573 7428 6570 2c20 652c t_request(ep, e, │ │ │ +00044470: 2073 7464 3a3a 6269 6e64 2826 616d 703b std::bind(& │ │ │ +00044480: 6f6e 5f64 6972 6563 745f 7265 7370 6f6e on_direct_respon │ │ │ +00044490: 7365 2c20 7374 643a 3a72 6566 286d 5f61 se, std::ref(m_a │ │ │ +000444a0: 6c65 7274 7329 2c20 7573 6572 6461 7461 lerts), userdata │ │ │ +000444b0: 2c20 5f31 2929 3b0a 097d 0a0a 2365 6e64 , _1));..}..#end │ │ │ +000444c0: 6966 0a0a 0962 6f6f 6c20 7365 7373 696f if...bool sessio │ │ │ +000444d0: 6e5f 696d 706c 3a3a 6973 5f6c 6973 7465 n_impl::is_liste │ │ │ +000444e0: 6e69 6e67 2829 2063 6f6e 7374 0a09 7b0a ning() const..{. │ │ │ +000444f0: 0909 7265 7475 726e 2021 6d5f 6c69 7374 ..return !m_list │ │ │ +00044500: 656e 5f73 6f63 6b65 7473 2e65 6d70 7479 en_sockets.empty │ │ │ +00044510: 2829 3b0a 097d 0a0a 0973 6573 7369 6f6e ();..}...session │ │ │ +00044520: 5f69 6d70 6c3a 3a7e 7365 7373 696f 6e5f _impl::~session_ │ │ │ +00044530: 696d 706c 2829 0a09 7b0a 0909 2f2f 2073 impl()..{...// s │ │ │ +00044540: 696e 6365 2077 6527 7265 2064 6573 7472 ince we're destr │ │ │ +00044550: 7563 7469 6e67 2074 6865 2073 6573 7369 ucting the sessi │ │ │ +00044560: 6f6e 2c20 6e6f 206d 6f72 6520 616c 6572 on, no more aler │ │ │ +00044570: 7473 2077 696c 6c20 6d61 6b65 2069 7420 ts will make it │ │ │ +00044580: 6f75 7420 746f 0a09 092f 2f20 7468 6520 out to...// the │ │ │ +00044590: 7573 6572 2e20 536f 2073 746f 7020 706f user. So stop po │ │ │ +000445a0: 7374 696e 6720 7468 656d 206e 6f77 0a09 sting them now.. │ │ │ +000445b0: 096d 5f61 6c65 7274 732e 7365 745f 616c .m_alerts.set_al │ │ │ +000445c0: 6572 745f 6d61 736b 287b 7d29 3b0a 0909 ert_mask({});... │ │ │ +000445d0: 6d5f 616c 6572 7473 2e73 6574 5f6e 6f74 m_alerts.set_not │ │ │ +000445e0: 6966 795f 6675 6e63 7469 6f6e 287b 7d29 ify_function({}) │ │ │ +000445f0: 3b0a 0a09 092f 2f20 7468 6973 2069 7320 ;....// this is │ │ │ +00044600: 6e6f 7420 616c 6c6f 7765 6420 746f 2062 not allowed to b │ │ │ +00044610: 6520 7468 6520 6e65 7477 6f72 6b20 7468 e the network th │ │ │ +00044620: 7265 6164 210a 2f2f 0909 544f 5252 454e read!.//..TORREN │ │ │ +00044630: 545f 4153 5345 5254 2869 735f 6e6f 745f T_ASSERT(is_not_ │ │ │ +00044640: 7468 7265 6164 2829 293b 0a3c 6469 7620 thread());.
    .
    │ │ │ +00044680: 0909 2f2f 2074 6869 7320 6361 6e20 6861 ..// this can ha │ │ │ +00044690: 7070 656e 2069 6620 7765 2065 6e64 2074 ppen if we end t │ │ │ +000446a0: 6865 2069 6f5f 636f 6e74 6578 7420 7275 he io_context ru │ │ │ +000446b0: 6e20 6c6f 6f70 2077 6974 6820 616e 2065 n loop with an e │ │ │ +000446c0: 7863 6570 7469 6f6e 0a09 096d 5f63 6f6e xception...m_con │ │ │ +000446d0: 6e65 6374 696f 6e73 2e63 6c65 6172 2829 nections.clear() │ │ │ +000446e0: 3b0a 0909 666f 7220 2861 7574 6f26 616d ;...for (auto&am │ │ │ +000446f0: 703b 2074 203a 206d 5f74 6f72 7265 6e74 p; t : m_torrent │ │ │ +00044700: 7329 0a09 097b 0a09 0909 742d 2667 743b s)...{....t-> │ │ │ +00044710: 7061 6e69 6328 293b 0a09 0909 742d 2667 panic();....t-&g │ │ │ +00044720: 743b 6162 6f72 7428 293b 0a09 097d 0a09 t;abort();...}.. │ │ │ +00044730: 096d 5f74 6f72 7265 6e74 732e 636c 6561 .m_torrents.clea │ │ │ +00044740: 7228 293b 0a0a 0909 2f2f 2074 6869 7320 r();....// this │ │ │ +00044750: 6861 7320 7072 6f62 6162 6c79 2062 6565 has probably bee │ │ │ +00044760: 6e20 6361 6c6c 6564 2061 6c72 6561 6479 n called already │ │ │ +00044770: 2c20 6275 7420 696e 2063 6173 6520 6f66 , but in case of │ │ │ +00044780: 2073 7564 6465 6e0a 0909 2f2f 2074 6572 sudden...// ter │ │ │ +00044790: 6d69 6e61 7469 6f6e 2074 6872 6f75 6768 mination through │ │ │ +000447a0: 2061 6e20 6578 6365 7074 696f 6e2c 2069 an exception, i │ │ │ +000447b0: 7420 6d61 7920 6e6f 7420 6861 7665 2062 t may not have b │ │ │ +000447c0: 6565 6e20 646f 6e65 0a09 0961 626f 7274 een done...abort │ │ │ +000447d0: 5f73 7461 6765 3228 293b 0a0a 2369 6620 _stage2();..#if │ │ │ +000447e0: 6465 6669 6e65 6420 544f 5252 454e 545f defined TORRENT_ │ │ │ +000447f0: 4153 494f 5f44 4542 5547 4749 4e47 0a09 ASIO_DEBUGGING.. │ │ │ +00044800: 0946 494c 452a 2066 203d 2066 6f70 656e .FILE* f = fopen │ │ │ +00044810: 2822 7761 6b65 7570 732e 6c6f 6722 2c20 ("wakeups.log", │ │ │ +00044820: 2277 2b22 293b 0a09 0969 6620 2866 2021 "w+");...if (f ! │ │ │ +00044830: 3d20 6e75 6c6c 7074 7229 0a09 097b 0a09 = nullptr)...{.. │ │ │ +00044840: 0909 7469 6d65 5f70 6f69 6e74 206d 203d ..time_point m = │ │ │ +00044850: 206d 696e 5f74 696d 6528 293b 0a09 0909 min_time();.... │ │ │ +00044860: 6966 2028 215f 7761 6b65 7570 732e 656d if (!_wakeups.em │ │ │ +00044870: 7074 7928 2929 206d 203d 205f 7761 6b65 pty()) m = _wake │ │ │ +00044880: 7570 735b 305d 2e74 696d 6573 7461 6d70 ups[0].timestamp │ │ │ +00044890: 3b0a 0909 0974 696d 655f 706f 696e 7420 ;....time_point │ │ │ +000448a0: 7072 6576 203d 206d 3b0a 0909 0973 7464 prev = m;....std │ │ │ +000448b0: 3a3a 7569 6e74 3634 5f74 2070 7265 765f ::uint64_t prev_ │ │ │ +000448c0: 6373 7720 3d20 303b 0a09 0909 6966 2028 csw = 0;....if ( │ │ │ +000448d0: 215f 7761 6b65 7570 732e 656d 7074 7928 !_wakeups.empty( │ │ │ +000448e0: 2929 2070 7265 765f 6373 7720 3d20 5f77 )) prev_csw = _w │ │ │ +000448f0: 616b 6575 7073 5b30 5d2e 636f 6e74 6578 akeups[0].contex │ │ │ +00044900: 745f 7377 6974 6368 6573 3b0a 0909 0973 t_switches;....s │ │ │ +00044910: 7464 3a3a 6670 7269 6e74 6628 662c 2022 td::fprintf(f, " │ │ │ +00044920: 6162 732e 2074 696d 655c 7472 656c 2e20 abs. time\trel. │ │ │ +00044930: 7469 6d65 5c74 6374 7820 7377 6974 6368 time\tctx switch │ │ │ +00044940: 5c74 6964 6c65 2d77 616b 6575 705c 746f \tidle-wakeup\to │ │ │ +00044950: 7065 7261 7469 6f6e 5c6e 2229 3b0a 0909 peration\n");... │ │ │ +00044960: 0966 6f72 2028 7761 6b65 7570 5f74 2063 .for (wakeup_t c │ │ │ +00044970: 6f6e 7374 2661 6d70 3b20 7720 3a20 5f77 onst& w : _w │ │ │ +00044980: 616b 6575 7073 290a 0909 097b 0a09 0909 akeups)....{.... │ │ │ +00044990: 0962 6f6f 6c20 636f 6e73 7420 6964 6c65 .bool const idle │ │ │ +000449a0: 5f77 616b 6575 7020 3d20 772e 636f 6e74 _wakeup = w.cont │ │ │ +000449b0: 6578 745f 7377 6974 6368 6573 2026 6774 ext_switches > │ │ │ +000449c0: 3b20 7072 6576 5f63 7377 3b0a 0909 0909 ; prev_csw;..... │ │ │ +000449d0: 7374 643a 3a66 7072 696e 7466 2866 2c20 std::fprintf(f, │ │ │ +000449e0: 2225 2220 5052 4964 3634 2022 5c74 2522 "%" PRId64 "\t%" │ │ │ +000449f0: 2050 5249 6436 3420 225c 7425 2220 5052 PRId64 "\t%" PR │ │ │ +00044a00: 4964 3634 2022 5c74 2563 5c74 2573 5c6e Id64 "\t%c\t%s\n │ │ │ +00044a10: 220a 0909 0909 092c 2074 6f74 616c 5f6d "......, total_m │ │ │ +00044a20: 6963 726f 7365 636f 6e64 7328 772e 7469 icroseconds(w.ti │ │ │ +00044a30: 6d65 7374 616d 7020 2d20 6d29 0a09 0909 mestamp - m).... │ │ │ +00044a40: 0909 2c20 746f 7461 6c5f 6d69 6372 6f73 .., total_micros │ │ │ +00044a50: 6563 6f6e 6473 2877 2e74 696d 6573 7461 econds(w.timesta │ │ │ +00044a60: 6d70 202d 2070 7265 7629 0a09 0909 0909 mp - prev)...... │ │ │ +00044a70: 2c20 772e 636f 6e74 6578 745f 7377 6974 , w.context_swit │ │ │ +00044a80: 6368 6573 0a3c 2f70 7265 3e3c 2f74 643e ches. │ │ │ +00044a90: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00044ac0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00044ad0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00044ae0: 7074 3a65 7870 616e 6428 3136 3829 223e pt:expand(168)"> │ │ │ +00044af0: 2e2e 2f73 7263 2f75 6470 5f73 6f63 6b65 ../src/udp_socke │ │ │ +00044b00: 742e 6370 703a 3634 333c 2f61 3e3c 2f74 t.cpp:643
    perhaps an │ │ │ +00044b20: 2061 7474 656d 7074 2073 686f 756c 6420 attempt should │ │ │ +00044b30: 6265 206d 6164 6520 746f 2062 696e 6420 be made to bind │ │ │ +00044b40: 6d5f 736f 636b 7335 5f73 6f63 6b20 746f m_socks5_sock to │ │ │ +00044b50: 2074 6865 2064 6576 6963 6520 6f66 206d the device of m │ │ │ +00044b60: 5f6c 6973 7465 6e5f 736f 636b 6574 3c2f _listen_socket

    perh │ │ │ +00044bc0: 6170 7320 616e 2061 7474 656d 7074 2073 aps an attempt s │ │ │ +00044bd0: 686f 756c 6420 6265 206d 6164 6520 746f hould be made to │ │ │ +00044be0: 2062 696e 6420 6d5f 736f 636b 7335 5f73 bind m_socks5_s │ │ │ +00044bf0: 6f63 6b20 746f 2074 6865 0a64 6576 6963 ock to the.devic │ │ │ +00044c00: 6520 6f66 206d 5f6c 6973 7465 6e5f 736f e of m_listen_so │ │ │ +00044c10: 636b 6574 3c2f 6832 3e3c 6834 3e2e 2e2f cket

    ../ │ │ │ +00044c20: 7372 632f 7564 705f 736f 636b 6574 2e63 src/udp_socket.c │ │ │ +00044c30: 7070 3a36 3433 3c2f 6834 3e3c 7072 6520 pp:643

    .if (ec)..{
    │ │ │ +00044c80: 0a09 0969 6620 286d 5f61 6c65 7274 732e  ...if (m_alerts.
    │ │ │ +00044c90: 7368 6f75 6c64 5f70 6f73 7426 6c74 3b73  should_post<s
    │ │ │ +00044ca0: 6f63 6b73 355f 616c 6572 7426 6774 3b28  ocks5_alert>(
    │ │ │ +00044cb0: 2929 0a09 0909 6d5f 616c 6572 7473 2e65  ))....m_alerts.e
    │ │ │ +00044cc0: 6d70 6c61 6365 5f61 6c65 7274 266c 743b  mplace_alert<
    │ │ │ +00044cd0: 736f 636b 7335 5f61 6c65 7274 2667 743b  socks5_alert>
    │ │ │ +00044ce0: 286d 5f70 726f 7879 5f61 6464 722c 206f  (m_proxy_addr, o
    │ │ │ +00044cf0: 7065 7261 7469 6f6e 5f74 3a3a 736f 636b  peration_t::sock
    │ │ │ +00044d00: 5f6f 7074 696f 6e2c 2065 6329 3b0a 0909  _option, ec);...
    │ │ │ +00044d10: 6563 2e63 6c65 6172 2829 3b0a 097d 0a23  ec.clear();..}.#
    │ │ │ +00044d20: 656e 6469 660a 2365 6e64 6966 0a0a 0974  endif.#endif...t
    │ │ │ +00044d30: 6370 3a3a 656e 6470 6f69 6e74 2063 6f6e  cp::endpoint con
    │ │ │ +00044d40: 7374 2062 696e 645f 6570 286d 5f6c 6973  st bind_ep(m_lis
    │ │ │ +00044d50: 7465 6e5f 736f 636b 6574 2e67 6574 5f6c  ten_socket.get_l
    │ │ │ +00044d60: 6f63 616c 5f65 6e64 706f 696e 7428 292e  ocal_endpoint().
    │ │ │ +00044d70: 6164 6472 6573 7328 292c 2030 293b 0a09  address(), 0);..
    │ │ │ +00044d80: 6d5f 736f 636b 7335 5f73 6f63 6b2e 6269  m_socks5_sock.bi
    │ │ │ +00044d90: 6e64 2862 696e 645f 6570 2c20 6563 293b  nd(bind_ep, ec);
    │ │ │ +00044da0: 0a09 6966 2028 6563 290a 097b 0a09 0969  ..if (ec)..{...i
    │ │ │ +00044db0: 6620 286d 5f61 6c65 7274 732e 7368 6f75  f (m_alerts.shou
    │ │ │ +00044dc0: 6c64 5f70 6f73 7426 6c74 3b73 6f63 6b73  ld_post<socks
    │ │ │ +00044dd0: 355f 616c 6572 7426 6774 3b28 2929 0a09  5_alert>())..
    │ │ │ +00044de0: 0909 6d5f 616c 6572 7473 2e65 6d70 6c61  ..m_alerts.empla
    │ │ │ +00044df0: 6365 5f61 6c65 7274 266c 743b 736f 636b  ce_alert<sock
    │ │ │ +00044e00: 7335 5f61 6c65 7274 2667 743b 286d 5f70  s5_alert>(m_p
    │ │ │ +00044e10: 726f 7879 5f61 6464 722c 206f 7065 7261  roxy_addr, opera
    │ │ │ +00044e20: 7469 6f6e 5f74 3a3a 736f 636b 5f62 696e  tion_t::sock_bin
    │ │ │ +00044e30: 642c 2065 6329 3b0a 0909 2b2b 6d5f 6661  d, ec);...++m_fa
    │ │ │ +00044e40: 696c 7572 6573 3b0a 0909 7265 7472 795f  ilures;...retry_
    │ │ │ +00044e50: 636f 6e6e 6563 7469 6f6e 2829 3b0a 0909  connection();...
    │ │ │ +00044e60: 7265 7475 726e 3b0a 097d 0a0a 3c64 6976  return;..}..
    .
    .ADD_OUTSTANDIN │ │ │ +00044eb0: 475f 4153 594e 4328 2273 6f63 6b73 353a G_ASYNC("socks5: │ │ │ +00044ec0: 3a6f 6e5f 636f 6e6e 6563 7465 6422 293b :on_connected"); │ │ │ +00044ed0: 0a09 6d5f 736f 636b 7335 5f73 6f63 6b2e ..m_socks5_sock. │ │ │ +00044ee0: 6173 796e 635f 636f 6e6e 6563 7428 6d5f async_connect(m_ │ │ │ +00044ef0: 7072 6f78 795f 6164 6472 0a09 092c 2073 proxy_addr..., s │ │ │ +00044f00: 7464 3a3a 6269 6e64 2826 616d 703b 736f td::bind(&so │ │ │ +00044f10: 636b 7335 3a3a 6f6e 5f63 6f6e 6e65 6374 cks5::on_connect │ │ │ +00044f20: 6564 2c20 7365 6c66 2829 2c20 5f31 2929 ed, self(), _1)) │ │ │ +00044f30: 3b0a 0a09 4144 445f 4f55 5453 5441 4e44 ;...ADD_OUTSTAND │ │ │ +00044f40: 494e 475f 4153 594e 4328 2273 6f63 6b73 ING_ASYNC("socks │ │ │ +00044f50: 353a 3a6f 6e5f 636f 6e6e 6563 745f 7469 5::on_connect_ti │ │ │ +00044f60: 6d65 6f75 7422 293b 0a09 6d5f 7469 6d65 meout");..m_time │ │ │ +00044f70: 722e 6578 7069 7265 735f 6166 7465 7228 r.expires_after( │ │ │ +00044f80: 7365 636f 6e64 7328 3130 2929 3b0a 096d seconds(10));..m │ │ │ +00044f90: 5f74 696d 6572 2e61 7379 6e63 5f77 6169 _timer.async_wai │ │ │ +00044fa0: 7428 7374 643a 3a62 696e 6428 2661 6d70 t(std::bind(& │ │ │ +00044fb0: 3b73 6f63 6b73 353a 3a6f 6e5f 636f 6e6e ;socks5::on_conn │ │ │ +00044fc0: 6563 745f 7469 6d65 6f75 740a 0909 2c20 ect_timeout..., │ │ │ +00044fd0: 7365 6c66 2829 2c20 5f31 2929 3b0a 7d0a self(), _1));.}. │ │ │ +00044fe0: 0a76 6f69 6420 736f 636b 7335 3a3a 6f6e .void socks5::on │ │ │ +00044ff0: 5f63 6f6e 6e65 6374 5f74 696d 656f 7574 _connect_timeout │ │ │ +00045000: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ +00045010: 7426 616d 703b 2065 290a 7b0a 0943 4f4d t& e).{..COM │ │ │ +00045020: 504c 4554 455f 4153 594e 4328 2273 6f63 PLETE_ASYNC("soc │ │ │ +00045030: 6b73 353a 3a6f 6e5f 636f 6e6e 6563 745f ks5::on_connect_ │ │ │ +00045040: 7469 6d65 6f75 7422 293b 0a0a 0969 6620 timeout");...if │ │ │ +00045050: 2865 203d 3d20 626f 6f73 743a 3a61 7369 (e == boost::asi │ │ │ +00045060: 6f3a 3a65 7272 6f72 3a3a 6f70 6572 6174 o::error::operat │ │ │ +00045070: 696f 6e5f 6162 6f72 7465 6429 2072 6574 ion_aborted) ret │ │ │ +00045080: 7572 6e3b 0a0a 0969 6620 286d 5f61 626f urn;...if (m_abo │ │ │ +00045090: 7274 2920 7265 7475 726e 3b0a 0a09 6966 rt) return;...if │ │ │ +000450a0: 2028 6d5f 616c 6572 7473 2e73 686f 756c (m_alerts.shoul │ │ │ +000450b0: 645f 706f 7374 266c 743b 736f 636b 7335 d_post<socks5 │ │ │ +000450c0: 5f61 6c65 7274 2667 743b 2829 290a 0909 _alert>())... │ │ │ +000450d0: 6d5f 616c 6572 7473 2e65 6d70 6c61 6365 m_alerts.emplace │ │ │ +000450e0: 5f61 6c65 7274 266c 743b 736f 636b 7335 _alert<socks5 │ │ │ +000450f0: 5f61 6c65 7274 2667 743b 286d 5f70 726f _alert>(m_pro │ │ │ +00045100: 7879 5f61 6464 722c 206f 7065 7261 7469 xy_addr, operati │ │ │ +00045110: 6f6e 5f74 3a3a 636f 6e6e 6563 742c 2065 on_t::connect, e │ │ │ +00045120: 7272 6f72 733a 3a74 696d 6564 5f6f 7574 rrors::timed_out │ │ │ +00045130: 293b 0a0a 0965 7272 6f72 5f63 6f64 6520 );...error_code │ │ │ +00045140: 6967 6e6f 7265 3b0a 096d 5f73 6f63 6b73 ignore;..m_socks │ │ │ +00045150: 355f 736f 636b 2e63 6c6f 7365 2869 676e 5_sock.close(ign │ │ │ +00045160: 6f72 6529 3b0a 0a09 2b2b 6d5f 6661 696c ore);...++m_fail │ │ │ +00045170: 7572 6573 3b0a 0972 6574 7279 5f63 6f6e ures;..retry_con │ │ │ +00045180: 6e65 6374 696f 6e28 293b 0a7d 0a0a 766f nection();.}..vo │ │ │ +00045190: 6964 2073 6f63 6b73 353a 3a6f 6e5f 636f id socks5::on_co │ │ │ +000451a0: 6e6e 6563 7465 6428 6572 726f 725f 636f nnected(error_co │ │ │ +000451b0: 6465 2063 6f6e 7374 2661 6d70 3b20 6529 de const& e) │ │ │ +000451c0: 0a7b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .{.
    │ │ │ +000451f0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00045200: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00045230: 2f73 7263 2f70 6565 725f 636f 6e6e 6563 /src/peer_connec │ │ │ +00045240: 7469 6f6e 2e63 7070 3a31 3037 313c 2f61 tion.cpp:1071this s │ │ │ +00045260: 686f 756c 6420 6265 2074 6865 2067 6c6f hould be the glo │ │ │ +00045270: 6261 6c20 646f 776e 6c6f 6164 2072 6174 bal download rat │ │ │ +00045280: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069 e

    t │ │ │ +000452d0: 6869 7320 7368 6f75 6c64 2062 6520 7468 his should be th │ │ │ +000452e0: 6520 676c 6f62 616c 2064 6f77 6e6c 6f61 e global downloa │ │ │ +000452f0: 6420 7261 7465 3c2f 6832 3e3c 6834 3e2e d rate

    . │ │ │ +00045300: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ +00045310: 6374 696f 6e2e 6370 703a 3130 3731 3c2f ction.cpp:1071
    ...
    │ │ │ +00045360: 696e 7420 7261 7465 203d 2030 3b0a 0a09  int rate = 0;...
    │ │ │ +00045370: 092f 2f20 6966 2077 6520 6861 7665 6e27  .// if we haven'
    │ │ │ +00045380: 7420 7265 6365 6976 6564 2061 6e79 2064  t received any d
    │ │ │ +00045390: 6174 6120 7265 6365 6e74 6c79 2c20 7468  ata recently, th
    │ │ │ +000453a0: 6520 6375 7272 656e 7420 646f 776e 6c6f  e current downlo
    │ │ │ +000453b0: 6164 2072 6174 650a 0909 2f2f 2069 7320  ad rate...// is 
    │ │ │ +000453c0: 6e6f 7420 7265 7072 6573 656e 7461 7469  not representati
    │ │ │ +000453d0: 7665 0a09 0969 6620 2861 7578 3a3a 7469  ve...if (aux::ti
    │ │ │ +000453e0: 6d65 5f6e 6f77 2829 202d 206d 5f6c 6173  me_now() - m_las
    │ │ │ +000453f0: 745f 7069 6563 652e 6765 7428 6d5f 636f  t_piece.get(m_co
    │ │ │ +00045400: 6e6e 6563 7429 2026 6774 3b20 7365 636f  nnect) > seco
    │ │ │ +00045410: 6e64 7328 3330 2920 2661 6d70 3b26 616d  nds(30) &&am
    │ │ │ +00045420: 703b 206d 5f64 6f77 6e6c 6f61 645f 7261  p; m_download_ra
    │ │ │ +00045430: 7465 5f70 6561 6b20 2667 743b 2030 290a  te_peak > 0).
    │ │ │ +00045440: 0909 7b0a 0909 0972 6174 6520 3d20 6d5f  ..{....rate = m_
    │ │ │ +00045450: 646f 776e 6c6f 6164 5f72 6174 655f 7065  download_rate_pe
    │ │ │ +00045460: 616b 3b0a 0909 7d0a 0909 656c 7365 2069  ak;...}...else i
    │ │ │ +00045470: 6620 2861 7578 3a3a 7469 6d65 5f6e 6f77  f (aux::time_now
    │ │ │ +00045480: 2829 202d 206d 5f6c 6173 745f 756e 6368  () - m_last_unch
    │ │ │ +00045490: 6f6b 6564 2e67 6574 286d 5f63 6f6e 6e65  oked.get(m_conne
    │ │ │ +000454a0: 6374 2920 266c 743b 2073 6563 6f6e 6473  ct) < seconds
    │ │ │ +000454b0: 2835 290a 0909 0926 616d 703b 2661 6d70  (5)....&&
    │ │ │ +000454c0: 3b20 6d5f 7374 6174 6973 7469 6373 2e74  ; m_statistics.t
    │ │ │ +000454d0: 6f74 616c 5f70 6179 6c6f 6164 5f75 706c  otal_payload_upl
    │ │ │ +000454e0: 6f61 6428 2920 266c 743b 2032 202a 2030  oad() < 2 * 0
    │ │ │ +000454f0: 7834 3030 3029 0a09 097b 0a09 0909 2f2f  x4000)...{....//
    │ │ │ +00045500: 2069 6620 7765 2772 6520 6861 7665 206f   if we're have o
    │ │ │ +00045510: 6e6c 7920 6265 656e 2075 6e63 686f 6b65  nly been unchoke
    │ │ │ +00045520: 6420 666f 7220 6120 7368 6f72 7420 7065  d for a short pe
    │ │ │ +00045530: 7269 6f64 206f 6620 7469 6d65 2c0a 0909  riod of time,...
    │ │ │ +00045540: 092f 2f20 7765 2064 6f6e 2774 206b 6e6f  .// we don't kno
    │ │ │ +00045550: 7720 7768 6174 2072 6174 6520 7765 2063  w what rate we c
    │ │ │ +00045560: 616e 2067 6574 2066 726f 6d20 7468 6973  an get from this
    │ │ │ +00045570: 2070 6565 722e 2049 6e73 7465 6164 206f   peer. Instead o
    │ │ │ +00045580: 6620 6173 7375 6d69 6e67 0a09 0909 2f2f  f assuming....//
    │ │ │ +00045590: 2074 6865 206c 6f77 6573 7420 706f 7373   the lowest poss
    │ │ │ +000455a0: 6962 6c65 2072 6174 652c 2061 7373 756d  ible rate, assum
    │ │ │ +000455b0: 6520 7468 6520 6176 6572 6167 652e 0a0a  e the average...
    │ │ │ +000455c0: 0909 0969 6e74 2070 6565 7273 5f77 6974  ...int peers_wit
    │ │ │ +000455d0: 685f 7265 7175 6573 7473 203d 2069 6e74  h_requests = int
    │ │ │ +000455e0: 2873 7461 7473 5f63 6f75 6e74 6572 7328  (stats_counters(
    │ │ │ +000455f0: 295b 636f 756e 7465 7273 3a3a 6e75 6d5f  )[counters::num_
    │ │ │ +00045600: 7065 6572 735f 646f 776e 5f72 6571 7565  peers_down_reque
    │ │ │ +00045610: 7374 735d 293b 0a09 0909 2f2f 2061 766f  sts]);....// avo
    │ │ │ +00045620: 6964 2064 6976 6973 696f 6e20 6279 2030  id division by 0
    │ │ │ +00045630: 0a09 0909 6966 2028 7065 6572 735f 7769  ....if (peers_wi
    │ │ │ +00045640: 7468 5f72 6571 7565 7374 7320 3d3d 2030  th_requests == 0
    │ │ │ +00045650: 2920 7065 6572 735f 7769 7468 5f72 6571  ) peers_with_req
    │ │ │ +00045660: 7565 7374 7320 3d20 313b 0a0a 3c64 6976  uests = 1;..
    ...rat │ │ │ +000456a0: 6520 3d20 742d 2667 743b 7374 6174 6973 e = t->statis │ │ │ +000456b0: 7469 6373 2829 2e74 7261 6e73 6665 725f tics().transfer_ │ │ │ +000456c0: 7261 7465 2861 7578 3a3a 7374 6174 3a3a rate(aux::stat:: │ │ │ +000456d0: 646f 776e 6c6f 6164 5f70 6179 6c6f 6164 download_payload │ │ │ +000456e0: 2920 2f20 7065 6572 735f 7769 7468 5f72 ) / peers_with_r │ │ │ +000456f0: 6571 7565 7374 733b 0a3c 2f64 6976 3e09 equests;.
    . │ │ │ +00045700: 097d 0a09 0965 6c73 650a 0909 7b0a 0909 .}...else...{... │ │ │ +00045710: 092f 2f20 6375 7272 656e 7420 646f 776e .// current down │ │ │ +00045720: 6c6f 6164 2072 6174 6520 696e 2062 7974 load rate in byt │ │ │ +00045730: 6573 2070 6572 2073 6563 6f6e 6473 0a09 es per seconds.. │ │ │ +00045740: 0909 7261 7465 203d 206d 5f73 7461 7469 ..rate = m_stati │ │ │ +00045750: 7374 6963 732e 7472 616e 7366 6572 5f72 stics.transfer_r │ │ │ +00045760: 6174 6528 6175 783a 3a73 7461 743a 3a64 ate(aux::stat::d │ │ │ +00045770: 6f77 6e6c 6f61 645f 7061 796c 6f61 6429 ownload_payload) │ │ │ +00045780: 3b0a 0909 7d0a 0a09 092f 2f20 6176 6f69 ;...}....// avoi │ │ │ +00045790: 6420 6469 7669 7369 6f6e 2062 7920 7a65 d division by ze │ │ │ +000457a0: 726f 0a09 0969 6620 2872 6174 6520 266c ro...if (rate &l │ │ │ +000457b0: 743b 2035 3029 2072 6174 6520 3d20 3530 t; 50) rate = 50 │ │ │ +000457c0: 3b0a 0a09 092f 2f20 6176 6572 6167 6520 ;....// average │ │ │ +000457d0: 6f66 2063 7572 7265 6e74 2072 6174 6520 of current rate │ │ │ +000457e0: 616e 6420 7065 616b 0a2f 2f09 0972 6174 and peak.//..rat │ │ │ +000457f0: 6520 3d20 2872 6174 6520 2b20 6d5f 646f e = (rate + m_do │ │ │ +00045800: 776e 6c6f 6164 5f72 6174 655f 7065 616b wnload_rate_peak │ │ │ +00045810: 2920 2f20 323b 0a0a 0909 7265 7475 726e ) / 2;....return │ │ │ +00045820: 206d 696c 6c69 7365 636f 6e64 7328 2873 milliseconds((s │ │ │ +00045830: 7464 3a3a 696e 7436 345f 7428 6d5f 6f75 td::int64_t(m_ou │ │ │ +00045840: 7473 7461 6e64 696e 675f 6279 7465 7329 tstanding_bytes) │ │ │ +00045850: 202b 2065 7874 7261 5f62 7974 6573 0a09 + extra_bytes.. │ │ │ +00045860: 0909 0909 0909 092b 206d 5f71 7565 7565 .......+ m_queue │ │ │ +00045870: 645f 7469 6d65 5f63 7269 7469 6361 6c20 d_time_critical │ │ │ +00045880: 2a20 742d 2667 743b 626c 6f63 6b5f 7369 * t->block_si │ │ │ +00045890: 7a65 2829 202a 2031 3030 3029 0a09 0909 ze() * 1000).... │ │ │ +000458a0: 2f20 7261 7465 293b 0a09 7d0a 0a09 766f / rate);..}...vo │ │ │ +000458b0: 6964 2070 6565 725f 636f 6e6e 6563 7469 id peer_connecti │ │ │ +000458c0: 6f6e 3a3a 6164 645f 7374 6174 2873 7464 on::add_stat(std │ │ │ +000458d0: 3a3a 696e 7436 345f 7420 636f 6e73 7420 ::int64_t const │ │ │ +000458e0: 646f 776e 6c6f 6164 6564 2c20 7374 643a downloaded, std: │ │ │ +000458f0: 3a69 6e74 3634 5f74 2063 6f6e 7374 2075 :int64_t const u │ │ │ +00045900: 706c 6f61 6465 6429 0a09 7b0a 0909 544f ploaded)..{...TO │ │ │ +00045910: 5252 454e 545f 4153 5345 5254 2869 735f RRENT_ASSERT(is_ │ │ │ +00045920: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ +00045930: 3b0a 0909 6d5f 7374 6174 6973 7469 6373 ;...m_statistics │ │ │ +00045940: 2e61 6464 5f73 7461 7428 646f 776e 6c6f .add_stat(downlo │ │ │ +00045950: 6164 6564 2c20 7570 6c6f 6164 6564 293b aded, uploaded); │ │ │ +00045960: 0a09 7d0a 0a09 7368 6131 5f68 6173 6820 ..}...sha1_hash │ │ │ +00045970: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a peer_connection: │ │ │ +00045980: 3a61 7373 6f63 6961 7465 645f 696e 666f :associated_info │ │ │ +00045990: 5f68 6173 6828 2920 636f 6e73 740a 097b _hash() const..{ │ │ │ +000459a0: 0a09 0961 7574 6f20 7420 3d20 6173 736f ...auto t = asso │ │ │ +000459b0: 6369 6174 6564 5f74 6f72 7265 6e74 2829 ciated_torrent() │ │ │ +000459c0: 2e6c 6f63 6b28 293b 0a09 0954 4f52 5245 .lock();...TORRE │ │ │ +000459d0: 4e54 5f41 5353 4552 5428 7429 3b0a 0909 NT_ASSERT(t);... │ │ │ +000459e0: 6175 746f 2063 6f6e 7374 2661 6d70 3b20 auto const& │ │ │ +000459f0: 6968 203d 2074 2d26 6774 3b69 6e66 6f5f ih = t->info_ │ │ │ +00045a00: 6861 7368 2829 3b0a 0909 2f2f 2069 6620 hash();...// if │ │ │ +00045a10: 7072 6f74 6f63 6f6c 5f76 3220 6973 2073 protocol_v2 is s │ │ │ +00045a20: 6574 206f 6e20 7468 6520 7065 6572 2c20 et on the peer, │ │ │ +00045a30: 7468 6973 2062 6574 7465 7220 6265 2061 this better be a │ │ │ +00045a40: 2076 3220 746f 7272 656e 742c 0a3c 2f70 v2 torrent,.

    re │ │ │ +00045a80: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/p │ │ │ +00045ac0: 6565 725f 636f 6e6e 6563 7469 6f6e 2e63 eer_connection.c │ │ │ +00045ad0: 7070 3a31 3137 343c 2f61 3e3c 2f74 643e pp:1174 │ │ │ +00045ae0: 3c74 643e 7374 6f72 6520 7468 6520 7361 store the sa │ │ │ +00045af0: 6832 3536 2068 6173 6820 6f66 2074 6865 h256 hash of the │ │ │ +00045b00: 2064 6573 7469 6e61 7469 6f6e 2069 6e20 destination in │ │ │ +00045b10: 7468 6520 6932 705f 7065 6572 2073 7472 the i2p_peer str │ │ │ +00045b20: 7563 742c 2073 6f20 7765 2064 6f6e 2774 uct, so we don't │ │ │ +00045b30: 2068 6176 6520 746f 2072 6563 6f6d 7075 have to recompu │ │ │ +00045b40: 7465 2069 7420 6576 6572 7920 7469 6d65 te it every time │ │ │ +00045b50: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    st │ │ │ +00045ba0: 6f72 6520 7468 6520 7361 6832 3536 2068 ore the sah256 h │ │ │ +00045bb0: 6173 6820 6f66 2074 6865 2064 6573 7469 ash of the desti │ │ │ +00045bc0: 6e61 7469 6f6e 2069 6e20 7468 650a 6932 nation in the.i2 │ │ │ +00045bd0: 705f 7065 6572 2073 7472 7563 742c 2073 p_peer struct, s │ │ │ +00045be0: 6f20 7765 2064 6f6e 2774 2068 6176 6520 o we don't have │ │ │ +00045bf0: 746f 2072 6563 6f6d 7075 7465 2069 7420 to recompute it │ │ │ +00045c00: 6576 6572 7920 7469 6d65 3c2f 6832 3e3c every time

    < │ │ │ +00045c10: 6834 3e2e 2e2f 7372 632f 7065 6572 5f63 h4>../src/peer_c │ │ │ +00045c20: 6f6e 6e65 6374 696f 6e2e 6370 703a 3131 onnection.cpp:11 │ │ │ +00045c30: 3734 3c2f 6834 3e3c 7072 6520 7374 796c 74

    ..auto t = m_to
    │ │ │ +00045c80: 7272 656e 742e 6c6f 636b 2829 3b0a 0909  rrent.lock();...
    │ │ │ +00045c90: 6966 2028 2174 2920 7265 7475 726e 3b0a  if (!t) return;.
    │ │ │ +00045ca0: 0909 742d 2667 743b 7365 6e74 5f73 796e  ..t->sent_syn
    │ │ │ +00045cb0: 2869 7076 3629 3b0a 097d 0a0a 0976 6f69  (ipv6);..}...voi
    │ │ │ +00045cc0: 6420 7065 6572 5f63 6f6e 6e65 6374 696f  d peer_connectio
    │ │ │ +00045cd0: 6e3a 3a72 6563 6569 7665 645f 7379 6e61  n::received_syna
    │ │ │ +00045ce0: 636b 2862 6f6f 6c20 636f 6e73 7420 6970  ck(bool const ip
    │ │ │ +00045cf0: 7636 290a 097b 0a09 0954 4f52 5245 4e54  v6)..{...TORRENT
    │ │ │ +00045d00: 5f41 5353 4552 5428 6973 5f73 696e 676c  _ASSERT(is_singl
    │ │ │ +00045d10: 655f 7468 7265 6164 2829 293b 0a09 096d  e_thread());...m
    │ │ │ +00045d20: 5f73 7461 7469 7374 6963 732e 7265 6365  _statistics.rece
    │ │ │ +00045d30: 6976 6564 5f73 796e 6163 6b28 6970 7636  ived_synack(ipv6
    │ │ │ +00045d40: 293b 0a09 0969 6620 286d 5f69 676e 6f72  );...if (m_ignor
    │ │ │ +00045d50: 655f 7374 6174 7329 2072 6574 7572 6e3b  e_stats) return;
    │ │ │ +00045d60: 0a09 0961 7574 6f20 7420 3d20 6d5f 746f  ...auto t = m_to
    │ │ │ +00045d70: 7272 656e 742e 6c6f 636b 2829 3b0a 0909  rrent.lock();...
    │ │ │ +00045d80: 6966 2028 2174 2920 7265 7475 726e 3b0a  if (!t) return;.
    │ │ │ +00045d90: 0909 742d 2667 743b 7265 6365 6976 6564  ..t->received
    │ │ │ +00045da0: 5f73 796e 6163 6b28 6970 7636 293b 0a09  _synack(ipv6);..
    │ │ │ +00045db0: 7d0a 0a09 7065 6572 5f65 6e64 706f 696e  }...peer_endpoin
    │ │ │ +00045dc0: 745f 7420 7065 6572 5f63 6f6e 6e65 6374  t_t peer_connect
    │ │ │ +00045dd0: 696f 6e3a 3a72 656d 6f74 655f 656e 6470  ion::remote_endp
    │ │ │ +00045de0: 6f69 6e74 2829 2063 6f6e 7374 0a09 7b0a  oint() const..{.
    │ │ │ +00045df0: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ +00045e00: 4932 500a 0909 6966 2028 6175 746f 2073  I2P...if (auto s
    │ │ │ +00045e10: 203d 2073 7464 3a3a 6765 745f 6966 266c   = std::get_if&l
    │ │ │ +00045e20: 743b 6932 705f 7374 7265 616d 2667 743b  t;i2p_stream>
    │ │ │ +00045e30: 2826 616d 703b 6d5f 736f 636b 6574 2929  (&m_socket))
    │ │ │ +00045e40: 0a09 097b 0a3c 6469 7620 7374 796c 653d  ...{.
    ...return has │ │ │ +00045e80: 6865 7232 3536 2862 6173 6536 3464 6563 her256(base64dec │ │ │ +00045e90: 6f64 655f 6932 7028 732d 2667 743b 6465 ode_i2p(s->de │ │ │ +00045ea0: 7374 696e 6174 696f 6e28 2929 292e 6669 stination())).fi │ │ │ +00045eb0: 6e61 6c28 293b 0a3c 2f64 6976 3e09 097d nal();.
    ..} │ │ │ +00045ec0: 0a23 656e 6469 660a 0909 7265 7475 726e .#endif...return │ │ │ +00045ed0: 206d 5f72 656d 6f74 653b 0a09 7d0a 0a23 m_remote;..}..# │ │ │ +00045ee0: 6966 2054 4f52 5245 4e54 5f55 5345 5f49 if TORRENT_USE_I │ │ │ +00045ef0: 3250 0a09 7374 643a 3a73 7472 696e 6720 2P..std::string │ │ │ +00045f00: 636f 6e73 7426 616d 703b 2070 6565 725f const& peer_ │ │ │ +00045f10: 636f 6e6e 6563 7469 6f6e 3a3a 6465 7374 connection::dest │ │ │ +00045f20: 696e 6174 696f 6e28 2920 636f 6e73 740a ination() const. │ │ │ +00045f30: 097b 0a09 0973 7461 7469 6320 7374 643a .{...static std: │ │ │ +00045f40: 3a73 7472 696e 6720 636f 6e73 7420 656d :string const em │ │ │ +00045f50: 7074 793b 0a09 0961 7574 6f20 7320 3d20 pty;...auto s = │ │ │ +00045f60: 7374 643a 3a67 6574 5f69 6626 6c74 3b69 std::get_if<i │ │ │ +00045f70: 3270 5f73 7472 6561 6d26 6774 3b28 2661 2p_stream>(&a │ │ │ +00045f80: 6d70 3b6d 5f73 6f63 6b65 7429 3b0a 0909 mp;m_socket);... │ │ │ +00045f90: 7265 7475 726e 2073 203f 2073 2d26 6774 return s ? s-> │ │ │ +00045fa0: 3b64 6573 7469 6e61 7469 6f6e 2829 203a ;destination() : │ │ │ +00045fb0: 2065 6d70 7479 3b0a 097d 0a0a 0973 7464 empty;..}...std │ │ │ +00045fc0: 3a3a 7374 7269 6e67 2063 6f6e 7374 2661 ::string const&a │ │ │ +00045fd0: 6d70 3b20 7065 6572 5f63 6f6e 6e65 6374 mp; peer_connect │ │ │ +00045fe0: 696f 6e3a 3a6c 6f63 616c 5f69 3270 5f65 ion::local_i2p_e │ │ │ +00045ff0: 6e64 706f 696e 7428 2920 636f 6e73 740a ndpoint() const. │ │ │ +00046000: 097b 0a09 0973 7461 7469 6320 7374 643a .{...static std: │ │ │ +00046010: 3a73 7472 696e 6720 636f 6e73 7420 656d :string const em │ │ │ +00046020: 7074 793b 0a09 0961 7574 6f20 7320 3d20 pty;...auto s = │ │ │ +00046030: 7374 643a 3a67 6574 5f69 6626 6c74 3b69 std::get_if<i │ │ │ +00046040: 3270 5f73 7472 6561 6d26 6774 3b28 2661 2p_stream>(&a │ │ │ +00046050: 6d70 3b6d 5f73 6f63 6b65 7429 3b0a 0909 mp;m_socket);... │ │ │ +00046060: 7265 7475 726e 2073 203f 2073 2d26 6774 return s ? s-> │ │ │ +00046070: 3b6c 6f63 616c 5f69 3270 5f65 6e64 706f ;local_i2p_endpo │ │ │ +00046080: 696e 7428 2920 3a20 656d 7074 793b 0a09 int() : empty;.. │ │ │ +00046090: 7d0a 2365 6e64 6966 0a0a 0974 7970 6564 }.#endif...typed │ │ │ +000460a0: 5f62 6974 6669 656c 6426 6c74 3b70 6965 _bitfield<pie │ │ │ +000460b0: 6365 5f69 6e64 6578 5f74 2667 743b 2063 ce_index_t> c │ │ │ +000460c0: 6f6e 7374 2661 6d70 3b20 7065 6572 5f63 onst& peer_c │ │ │ +000460d0: 6f6e 6e65 6374 696f 6e3a 3a67 6574 5f62 onnection::get_b │ │ │ +000460e0: 6974 6669 656c 6428 2920 636f 6e73 740a itfield() const. │ │ │ +000460f0: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ +00046100: 4552 5428 6973 5f73 696e 676c 655f 7468 ERT(is_single_th │ │ │ +00046110: 7265 6164 2829 293b 0a09 0972 6574 7572 read());...retur │ │ │ +00046120: 6e20 6d5f 6861 7665 5f70 6965 6365 3b0a n m_have_piece;. │ │ │ +00046130: 097d 0a0a 0976 6f69 6420 7065 6572 5f63 .}...void peer_c │ │ │ +00046140: 6f6e 6e65 6374 696f 6e3a 3a72 6563 6569 onnection::recei │ │ │ +00046150: 7665 645f 7661 6c69 645f 6461 7461 2870 ved_valid_data(p │ │ │ +00046160: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e iece_index_t con │ │ │ +00046170: 7374 2069 6e64 6578 290a 097b 0a09 0954 st index)..{...T │ │ │ +00046180: 4f52 5245 4e54 5f41 5353 4552 5428 6973 ORRENT_ASSERT(is │ │ │ +00046190: 5f73 696e 676c 655f 7468 7265 6164 2829 _single_thread() │ │ │ +000461a0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ +000461d0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +000461e0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00046210: 2f73 7263 2f70 6565 725f 636f 6e6e 6563 /src/peer_connec │ │ │ +00046220: 7469 6f6e 2e63 7070 3a33 3533 343c 2f61 tion.cpp:3534sort t │ │ │ +00046240: 6865 2061 6c6c 6f77 6564 2066 6173 7420 he allowed fast │ │ │ +00046250: 7365 7420 696e 2070 7269 6f72 6974 7920 set in priority │ │ │ +00046260: 6f72 6465 723c 2f74 643e 3c2f 7472 3e3c order< │ │ │ +00046270: 7472 2069 643d 2231 3731 2220 7374 796c tr id="171" styl │ │ │ +00046280: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00046290: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +000462a0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +000462b0: 6832 3e73 6f72 7420 7468 6520 616c 6c6f h2>sort the allo │ │ │ +000462c0: 7765 6420 6661 7374 2073 6574 2069 6e20 wed fast set in │ │ │ +000462d0: 7072 696f 7269 7479 206f 7264 6572 3c2f priority order

    ../src/pe │ │ │ +000462f0: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ +00046300: 703a 3335 3334 3c2f 6834 3e3c 7072 6520 p:3534

    ...// if th
    │ │ │ +00046350: 6520 7065 6572 2068 6173 2074 6865 2070  e peer has the p
    │ │ │ +00046360: 6965 6365 2061 6e64 2077 6520 7761 6e74  iece and we want
    │ │ │ +00046370: 0a09 092f 2f20 746f 2064 6f77 6e6c 6f61  ...// to downloa
    │ │ │ +00046380: 6420 6974 2c20 7265 7175 6573 7420 6974  d it, request it
    │ │ │ +00046390: 0a09 0969 6620 2869 6e64 6578 2026 6c74  ...if (index <
    │ │ │ +000463a0: 3b20 6d5f 6861 7665 5f70 6965 6365 2e65  ; m_have_piece.e
    │ │ │ +000463b0: 6e64 5f69 6e64 6578 2829 0a09 0909 2661  nd_index()....&a
    │ │ │ +000463c0: 6d70 3b26 616d 703b 206d 5f68 6176 655f  mp;& m_have_
    │ │ │ +000463d0: 7069 6563 655b 696e 6465 785d 0a09 0909  piece[index]....
    │ │ │ +000463e0: 2661 6d70 3b26 616d 703b 2021 742d 2667  && !t-&g
    │ │ │ +000463f0: 743b 6861 7665 5f70 6965 6365 2869 6e64  t;have_piece(ind
    │ │ │ +00046400: 6578 290a 0909 0926 616d 703b 2661 6d70  ex)....&&
    │ │ │ +00046410: 3b20 742d 2667 743b 7661 6c69 645f 6d65  ; t->valid_me
    │ │ │ +00046420: 7461 6461 7461 2829 0a09 0909 2661 6d70  tadata()....&
    │ │ │ +00046430: 3b26 616d 703b 2074 2d26 6774 3b68 6173  ;& t->has
    │ │ │ +00046440: 5f70 6963 6b65 7228 290a 0909 0926 616d  _picker()....&am
    │ │ │ +00046450: 703b 2661 6d70 3b20 742d 2667 743b 7069  p;& t->pi
    │ │ │ +00046460: 636b 6572 2829 2e70 6965 6365 5f70 7269  cker().piece_pri
    │ │ │ +00046470: 6f72 6974 7928 696e 6465 7829 2026 6774  ority(index) >
    │ │ │ +00046480: 3b20 646f 6e74 5f64 6f77 6e6c 6f61 6429  ; dont_download)
    │ │ │ +00046490: 0a09 097b 0a09 0909 742d 2667 743b 7065  ...{....t->pe
    │ │ │ +000464a0: 6572 5f69 735f 696e 7465 7265 7374 696e  er_is_interestin
    │ │ │ +000464b0: 6728 2a74 6869 7329 3b0a 0909 7d0a 097d  g(*this);...}..}
    │ │ │ +000464c0: 0a0a 0973 7464 3a3a 7665 6374 6f72 266c  ...std::vector&l
    │ │ │ +000464d0: 743b 7069 6563 655f 696e 6465 785f 7426  t;piece_index_t&
    │ │ │ +000464e0: 6774 3b20 636f 6e73 7426 616d 703b 2070  gt; const& p
    │ │ │ +000464f0: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ +00046500: 616c 6c6f 7765 645f 6661 7374 2829 0a09  allowed_fast()..
    │ │ │ +00046510: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ +00046520: 5254 2869 735f 7369 6e67 6c65 5f74 6872  RT(is_single_thr
    │ │ │ +00046530: 6561 6428 2929 3b0a 0909 6175 746f 2074  ead());...auto t
    │ │ │ +00046540: 203d 206d 5f74 6f72 7265 6e74 2e6c 6f63   = m_torrent.loc
    │ │ │ +00046550: 6b28 293b 0a09 0954 4f52 5245 4e54 5f41  k();...TORRENT_A
    │ │ │ +00046560: 5353 4552 5428 7429 3b0a 0a3c 6469 7620  SSERT(t);..
    ..retur │ │ │ +000465a0: 6e20 6d5f 616c 6c6f 7765 645f 6661 7374 n m_allowed_fast │ │ │ +000465b0: 3b0a 3c2f 6469 763e 097d 0a0a 0962 6f6f ;.
    .}...boo │ │ │ +000465c0: 6c20 7065 6572 5f63 6f6e 6e65 6374 696f l peer_connectio │ │ │ +000465d0: 6e3a 3a63 616e 5f72 6571 7565 7374 5f74 n::can_request_t │ │ │ +000465e0: 696d 655f 6372 6974 6963 616c 2829 2063 ime_critical() c │ │ │ +000465f0: 6f6e 7374 0a09 7b0a 0909 544f 5252 454e onst..{...TORREN │ │ │ +00046600: 545f 4153 5345 5254 2869 735f 7369 6e67 T_ASSERT(is_sing │ │ │ +00046610: 6c65 5f74 6872 6561 6428 2929 3b0a 0909 le_thread());... │ │ │ +00046620: 6966 2028 6861 735f 7065 6572 5f63 686f if (has_peer_cho │ │ │ +00046630: 6b65 6428 2920 7c7c 2021 6973 5f69 6e74 ked() || !is_int │ │ │ +00046640: 6572 6573 7469 6e67 2829 2920 7265 7475 eresting()) retu │ │ │ +00046650: 726e 2066 616c 7365 3b0a 0909 6966 2028 rn false;...if ( │ │ │ +00046660: 696e 7428 6d5f 646f 776e 6c6f 6164 5f71 int(m_download_q │ │ │ +00046670: 7565 7565 2e73 697a 6528 2929 202b 2069 ueue.size()) + i │ │ │ +00046680: 6e74 286d 5f72 6571 7565 7374 5f71 7565 nt(m_request_que │ │ │ +00046690: 7565 2e73 697a 6528 2929 0a09 0909 2667 ue.size())....&g │ │ │ +000466a0: 743b 206d 5f64 6573 6972 6564 5f71 7565 t; m_desired_que │ │ │ +000466b0: 7565 5f73 697a 6520 2a20 3229 2072 6574 ue_size * 2) ret │ │ │ +000466c0: 7572 6e20 6661 6c73 653b 0a09 0969 6620 urn false;...if │ │ │ +000466d0: 286f 6e5f 7061 726f 6c65 2829 2920 7265 (on_parole()) re │ │ │ +000466e0: 7475 726e 2066 616c 7365 3b0a 0909 6966 turn false;...if │ │ │ +000466f0: 2028 6d5f 6469 7363 6f6e 6e65 6374 696e (m_disconnectin │ │ │ +00046700: 6729 2072 6574 7572 6e20 6661 6c73 653b g) return false; │ │ │ +00046710: 0a09 0961 7574 6f20 7420 3d20 6d5f 746f ...auto t = m_to │ │ │ +00046720: 7272 656e 742e 6c6f 636b 2829 3b0a 0909 rrent.lock();... │ │ │ +00046730: 544f 5252 454e 545f 4153 5345 5254 2874 TORRENT_ASSERT(t │ │ │ +00046740: 293b 0a09 0969 6620 2874 2d26 6774 3b75 );...if (t->u │ │ │ +00046750: 706c 6f61 645f 6d6f 6465 2829 2920 7265 pload_mode()) re │ │ │ +00046760: 7475 726e 2066 616c 7365 3b0a 0a09 092f turn false;..../ │ │ │ +00046770: 2f20 6967 6e6f 7265 2073 6e75 6262 6564 / ignore snubbed │ │ │ +00046780: 2070 6565 7273 2c20 7369 6e63 6520 7468 peers, since th │ │ │ +00046790: 6579 2772 6520 6e6f 7420 6c69 6b65 6c79 ey're not likely │ │ │ +000467a0: 2074 6f20 7265 7475 726e 2070 6965 6365 to return piece │ │ │ +000467b0: 7320 696e 2061 0a09 092f 2f20 7469 6d65 s in a...// time │ │ │ +000467c0: 6c79 206d 616e 6e65 7220 616e 7977 6179 ly manner anyway │ │ │ +000467d0: 0a09 0969 6620 286d 5f73 6e75 6262 6564 ...if (m_snubbed │ │ │ +000467e0: 2920 7265 7475 726e 2066 616c 7365 3b0a ) return false;. │ │ │ +000467f0: 0909 7265 7475 726e 2074 7275 653b 0a09 ..return true;.. │ │ │ +00046800: 7d0a 0a09 626f 6f6c 2070 6565 725f 636f }...bool peer_co │ │ │ +00046810: 6e6e 6563 7469 6f6e 3a3a 6d61 6b65 5f74 nnection::make_t │ │ │ +00046820: 696d 655f 6372 6974 6963 616c 2870 6965 ime_critical(pie │ │ │ +00046830: 6365 5f62 6c6f 636b 2063 6f6e 7374 2661 ce_block const&a │ │ │ +00046840: 6d70 3b20 626c 6f63 6b29 0a09 7b0a 0909 mp; block)..{... │ │ │ +00046850: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ +00046860: 735f 7369 6e67 6c65 5f74 6872 6561 6428 s_single_thread( │ │ │ +00046870: 2929 3b0a 0909 6175 746f 2063 6f6e 7374 ));...auto const │ │ │ +00046880: 2072 6974 203d 2073 7464 3a3a 6669 6e64 rit = std::find │ │ │ +00046890: 5f69 6628 6d5f 7265 7175 6573 745f 7175 _if(m_request_qu │ │ │ +000468a0: 6575 652e 6265 6769 6e28 290a 0909 092c eue.begin()...., │ │ │ +000468b0: 206d 5f72 6571 7565 7374 5f71 7565 7565 m_request_queue │ │ │ +000468c0: 2e65 6e64 2829 2c20 6175 783a 3a68 6173 .end(), aux::has │ │ │ +000468d0: 5f62 6c6f 636b 2862 6c6f 636b 2929 3b0a _block(block));. │ │ │ +000468e0: 0909 6966 2028 7269 7420 3d3d 206d 5f72 ..if (rit == m_r │ │ │ +000468f0: 6571 7565 7374 5f71 7565 7565 2e65 6e64 equest_queue.end │ │ │ +00046900: 2829 2920 7265 7475 726e 2066 616c 7365 ()) return false │ │ │ +00046910: 3b0a 2369 6620 544f 5252 454e 545f 5553 ;.#if TORRENT_US │ │ │ +00046920: 455f 4153 5345 5254 530a 0909 6175 746f E_ASSERTS...auto │ │ │ +00046930: 2074 203d 206d 5f74 6f72 7265 6e74 2e6c t = m_torrent.l │ │ │ +00046940: 6f63 6b28 293b 0a09 0954 4f52 5245 4e54 ock();...TORRENT │ │ │ +00046950: 5f41 5353 4552 5428 7429 3b0a 0909 544f _ASSERT(t);...TO │ │ │ +00046960: 5252 454e 545f 4153 5345 5254 2874 2d26 RRENT_ASSERT(t-& │ │ │ +00046970: 6774 3b68 6173 5f70 6963 6b65 7228 2929 gt;has_picker()) │ │ │ +00046980: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +000469b0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +000469c0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +000469f0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +00046a00: 3230 3934 3c2f 613e 3c2f 7464 3e3c 7464 2094this could be o │ │ │ +00046a20: 7074 696d 697a 6564 2062 7920 6c6f 6f6b ptimized by look │ │ │ +00046a30: 696e 6720 7570 2077 6869 6368 2066 696c ing up which fil │ │ │ +00046a40: 6573 2061 7265 2063 6f6d 706c 6574 6520 es are complete │ │ │ +00046a50: 616e 6420 6a75 7374 206c 6f6f 6b20 6174 and just look at │ │ │ +00046a60: 2074 686f 7365 3c2f 7464 3e3c 2f74 723e those │ │ │ +00046a70: 3c74 7220 6964 3d22 3137 3222 2073 7479 │ │ │ +00046aa0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00046ab0: 3c68 323e 7468 6973 2063 6f75 6c64 2062

    this could b │ │ │ +00046ac0: 6520 6f70 7469 6d69 7a65 6420 6279 206c e optimized by l │ │ │ +00046ad0: 6f6f 6b69 6e67 2075 7020 7768 6963 6820 ooking up which │ │ │ +00046ae0: 6669 6c65 7320 6172 650a 636f 6d70 6c65 files are.comple │ │ │ +00046af0: 7465 2061 6e64 206a 7573 7420 6c6f 6f6b te and just look │ │ │ +00046b00: 2061 7420 7468 6f73 653c 2f68 323e 3c68 at those

    ../src/torrent │ │ │ +00046b20: 2e63 7070 3a32 3039 343c 2f68 343e 3c70 .cpp:2094

    //....TO │ │ │ +00046b70: 5252 454e 545f 4153 5345 5254 2870 6963 RRENT_ASSERT(pic │ │ │ +00046b80: 6b65 7228 292e 6861 7665 5f70 6965 6365 ker().have_piece │ │ │ +00046b90: 2869 2929 3b0a 0909 0909 7765 5f68 6176 (i));.....we_hav │ │ │ +00046ba0: 6528 6929 3b0a 0909 097d 0a09 097d 0a0a e(i);....}...}.. │ │ │ +00046bb0: 0909 7365 745f 7374 6174 6528 746f 7272 ..set_state(torr │ │ │ +00046bc0: 656e 745f 7374 6174 7573 3a3a 6368 6563 ent_status::chec │ │ │ +00046bd0: 6b69 6e67 5f72 6573 756d 655f 6461 7461 king_resume_data │ │ │ +00046be0: 293b 0a0a 0909 6175 783a 3a76 6563 746f );....aux::vecto │ │ │ +00046bf0: 7226 6c74 3b73 7464 3a3a 7374 7269 6e67 r<std::string │ │ │ +00046c00: 2c20 6669 6c65 5f69 6e64 6578 5f74 2667 , file_index_t&g │ │ │ +00046c10: 743b 206c 696e 6b73 3b0a 2369 666e 6465 t; links;.#ifnde │ │ │ +00046c20: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +00046c30: 455f 4d55 5441 424c 455f 544f 5252 454e E_MUTABLE_TORREN │ │ │ +00046c40: 5453 0a09 0969 6620 2821 6d5f 746f 7272 TS...if (!m_torr │ │ │ +00046c50: 656e 745f 6669 6c65 2d26 6774 3b73 696d ent_file->sim │ │ │ +00046c60: 696c 6172 5f74 6f72 7265 6e74 7328 292e ilar_torrents(). │ │ │ +00046c70: 656d 7074 7928 290a 0909 097c 7c20 216d empty()....|| !m │ │ │ +00046c80: 5f74 6f72 7265 6e74 5f66 696c 652d 2667 _torrent_file-&g │ │ │ +00046c90: 743b 636f 6c6c 6563 7469 6f6e 7328 292e t;collections(). │ │ │ +00046ca0: 656d 7074 7928 2929 0a09 097b 0a09 0909 empty())...{.... │ │ │ +00046cb0: 7265 736f 6c76 655f 6c69 6e6b 7320 7265 resolve_links re │ │ │ +00046cc0: 7328 6d5f 746f 7272 656e 745f 6669 6c65 s(m_torrent_file │ │ │ +00046cd0: 293b 0a0a 0909 0966 6f72 2028 6175 746f );.....for (auto │ │ │ +00046ce0: 2063 6f6e 7374 2661 6d70 3b20 6968 203a const& ih : │ │ │ +00046cf0: 206d 5f74 6f72 7265 6e74 5f66 696c 652d m_torrent_file- │ │ │ +00046d00: 2667 743b 7369 6d69 6c61 725f 746f 7272 >similar_torr │ │ │ +00046d10: 656e 7473 2829 290a 0909 097b 0a09 0909 ents())....{.... │ │ │ +00046d20: 0973 7464 3a3a 7368 6172 6564 5f70 7472 .std::shared_ptr │ │ │ +00046d30: 266c 743b 746f 7272 656e 7426 6774 3b20 <torrent> │ │ │ +00046d40: 7420 3d20 6d5f 7365 732e 6669 6e64 5f74 t = m_ses.find_t │ │ │ +00046d50: 6f72 7265 6e74 2869 6e66 6f5f 6861 7368 orrent(info_hash │ │ │ +00046d60: 5f74 2869 6829 292e 6c6f 636b 2829 3b0a _t(ih)).lock();. │ │ │ +00046d70: 0909 0909 6966 2028 2174 2920 636f 6e74 ....if (!t) cont │ │ │ +00046d80: 696e 7565 3b0a 0a09 0909 092f 2f20 4f6e inue;......// On │ │ │ +00046d90: 6c79 2061 7474 656d 7074 2074 6f20 7265 ly attempt to re │ │ │ +00046da0: 7573 6520 6669 6c65 7320 6672 6f6d 2074 use files from t │ │ │ +00046db0: 6f72 7265 6e74 7320 7468 6174 2061 7265 orrents that are │ │ │ +00046dc0: 2073 6565 6469 6e67 2e0a 3c64 6976 2073 seeding..

    ....if ( │ │ │ +00046e00: 2174 2d26 6774 3b69 735f 7365 6564 2829 !t->is_seed() │ │ │ +00046e10: 2920 636f 6e74 696e 7565 3b0a 3c2f 6469 ) continue;......auto ti = │ │ │ +00046e30: 2074 2d26 6774 3b67 6574 5f74 6f72 7265 t->get_torre │ │ │ +00046e40: 6e74 5f66 696c 6528 293b 0a09 0909 0972 nt_file();.....r │ │ │ +00046e50: 6573 2e6d 6174 6368 282a 7469 2c20 6669 es.match(*ti, fi │ │ │ +00046e60: 6c65 6e61 6d65 7328 7469 2d26 6774 3b6c lenames(ti->l │ │ │ +00046e70: 6179 6f75 7428 292c 2074 2d26 6774 3b6d ayout(), t->m │ │ │ +00046e80: 5f72 656e 616d 6564 5f66 696c 6573 292c _renamed_files), │ │ │ +00046e90: 2074 2d26 6774 3b73 6176 655f 7061 7468 t->save_path │ │ │ +00046ea0: 2829 293b 0a09 0909 7d0a 0909 0966 6f72 ());....}....for │ │ │ +00046eb0: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ +00046ec0: 3b20 6320 3a20 6d5f 746f 7272 656e 745f ; c : m_torrent_ │ │ │ +00046ed0: 6669 6c65 2d26 6774 3b63 6f6c 6c65 6374 file->collect │ │ │ +00046ee0: 696f 6e73 2829 290a 0909 097b 0a09 0909 ions())....{.... │ │ │ +00046ef0: 0973 7464 3a3a 7665 6374 6f72 266c 743b .std::vector< │ │ │ +00046f00: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ +00046f10: 6c74 3b74 6f72 7265 6e74 2667 743b 2667 lt;torrent>&g │ │ │ +00046f20: 743b 2074 7320 3d20 6d5f 7365 732e 6669 t; ts = m_ses.fi │ │ │ +00046f30: 6e64 5f63 6f6c 6c65 6374 696f 6e28 6329 nd_collection(c) │ │ │ +00046f40: 3b0a 0a09 0909 0966 6f72 2028 6175 746f ;......for (auto │ │ │ +00046f50: 2063 6f6e 7374 2661 6d70 3b20 7420 3a20 const& t : │ │ │ +00046f60: 7473 290a 0909 0909 7b0a 0909 0909 092f ts).....{....../ │ │ │ +00046f70: 2f20 4f6e 6c79 2061 7474 656d 7074 2074 / Only attempt t │ │ │ +00046f80: 6f20 7265 7573 6520 6669 6c65 7320 6672 o reuse files fr │ │ │ +00046f90: 6f6d 2074 6f72 7265 6e74 7320 7468 6174 om torrents that │ │ │ +00046fa0: 2061 7265 2073 6565 6469 6e67 2e0a 3c2f are seeding..r │ │ │ +00046fe0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00046ff0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00047020: 746f 7272 656e 742e 6370 703a 3231 3038 torrent.cpp:2108 │ │ │ +00047030: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6869 thi │ │ │ +00047040: 7320 636f 756c 6420 6265 206f 7074 696d s could be optim │ │ │ +00047050: 697a 6564 2062 7920 6c6f 6f6b 696e 6720 ized by looking │ │ │ +00047060: 7570 2077 6869 6368 2066 696c 6573 2061 up which files a │ │ │ +00047070: 7265 2063 6f6d 706c 6574 6520 616e 6420 re complete and │ │ │ +00047080: 6a75 7374 206c 6f6f 6b20 6174 2074 686f just look at tho │ │ │ +00047090: 7365 3c2f 7464 3e3c 2f74 723e 3c74 7220 se

    │ │ │ +000470e0: 7468 6973 2063 6f75 6c64 2062 6520 6f70 this could be op │ │ │ +000470f0: 7469 6d69 7a65 6420 6279 206c 6f6f 6b69 timized by looki │ │ │ +00047100: 6e67 2075 7020 7768 6963 6820 6669 6c65 ng up which file │ │ │ +00047110: 7320 6172 650a 636f 6d70 6c65 7465 2061 s are.complete a │ │ │ +00047120: 6e64 206a 7573 7420 6c6f 6f6b 2061 7420 nd just look at │ │ │ +00047130: 7468 6f73 653c 2f68 323e 3c68 343e 2e2e those

    .. │ │ │ +00047140: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ +00047150: 3a32 3130 383c 2f68 343e 3c70 7265 2073 :2108

    ...resolve_l
    │ │ │ +000471a0: 696e 6b73 2072 6573 286d 5f74 6f72 7265  inks res(m_torre
    │ │ │ +000471b0: 6e74 5f66 696c 6529 3b0a 0a09 0909 666f  nt_file);.....fo
    │ │ │ +000471c0: 7220 2861 7574 6f20 636f 6e73 7426 616d  r (auto const&am
    │ │ │ +000471d0: 703b 2069 6820 3a20 6d5f 746f 7272 656e  p; ih : m_torren
    │ │ │ +000471e0: 745f 6669 6c65 2d26 6774 3b73 696d 696c  t_file->simil
    │ │ │ +000471f0: 6172 5f74 6f72 7265 6e74 7328 2929 0a09  ar_torrents())..
    │ │ │ +00047200: 0909 7b0a 0909 0909 7374 643a 3a73 6861  ..{.....std::sha
    │ │ │ +00047210: 7265 645f 7074 7226 6c74 3b74 6f72 7265  red_ptr<torre
    │ │ │ +00047220: 6e74 2667 743b 2074 203d 206d 5f73 6573  nt> t = m_ses
    │ │ │ +00047230: 2e66 696e 645f 746f 7272 656e 7428 696e  .find_torrent(in
    │ │ │ +00047240: 666f 5f68 6173 685f 7428 6968 2929 2e6c  fo_hash_t(ih)).l
    │ │ │ +00047250: 6f63 6b28 293b 0a09 0909 0969 6620 2821  ock();.....if (!
    │ │ │ +00047260: 7429 2063 6f6e 7469 6e75 653b 0a0a 0909  t) continue;....
    │ │ │ +00047270: 0909 2f2f 204f 6e6c 7920 6174 7465 6d70  ..// Only attemp
    │ │ │ +00047280: 7420 746f 2072 6575 7365 2066 696c 6573  t to reuse files
    │ │ │ +00047290: 2066 726f 6d20 746f 7272 656e 7473 2074   from torrents t
    │ │ │ +000472a0: 6861 7420 6172 6520 7365 6564 696e 672e  hat are seeding.
    │ │ │ +000472b0: 0a09 0909 0969 6620 2821 742d 2667 743b  .....if (!t->
    │ │ │ +000472c0: 6973 5f73 6565 6428 2929 2063 6f6e 7469  is_seed()) conti
    │ │ │ +000472d0: 6e75 653b 0a0a 0909 0909 6175 746f 2074  nue;......auto t
    │ │ │ +000472e0: 6920 3d20 742d 2667 743b 6765 745f 746f  i = t->get_to
    │ │ │ +000472f0: 7272 656e 745f 6669 6c65 2829 3b0a 0909  rrent_file();...
    │ │ │ +00047300: 0909 7265 732e 6d61 7463 6828 2a74 692c  ..res.match(*ti,
    │ │ │ +00047310: 2066 696c 656e 616d 6573 2874 692d 2667   filenames(ti-&g
    │ │ │ +00047320: 743b 6c61 796f 7574 2829 2c20 742d 2667  t;layout(), t-&g
    │ │ │ +00047330: 743b 6d5f 7265 6e61 6d65 645f 6669 6c65  t;m_renamed_file
    │ │ │ +00047340: 7329 2c20 742d 2667 743b 7361 7665 5f70  s), t->save_p
    │ │ │ +00047350: 6174 6828 2929 3b0a 0909 097d 0a09 0909  ath());....}....
    │ │ │ +00047360: 666f 7220 2861 7574 6f20 636f 6e73 7426  for (auto const&
    │ │ │ +00047370: 616d 703b 2063 203a 206d 5f74 6f72 7265  amp; c : m_torre
    │ │ │ +00047380: 6e74 5f66 696c 652d 2667 743b 636f 6c6c  nt_file->coll
    │ │ │ +00047390: 6563 7469 6f6e 7328 2929 0a09 0909 7b0a  ections())....{.
    │ │ │ +000473a0: 0909 0909 7374 643a 3a76 6563 746f 7226  ....std::vector&
    │ │ │ +000473b0: 6c74 3b73 7464 3a3a 7368 6172 6564 5f70  lt;std::shared_p
    │ │ │ +000473c0: 7472 266c 743b 746f 7272 656e 7426 6774  tr<torrent>
    │ │ │ +000473d0: 3b26 6774 3b20 7473 203d 206d 5f73 6573  ;> ts = m_ses
    │ │ │ +000473e0: 2e66 696e 645f 636f 6c6c 6563 7469 6f6e  .find_collection
    │ │ │ +000473f0: 2863 293b 0a0a 0909 0909 666f 7220 2861  (c);......for (a
    │ │ │ +00047400: 7574 6f20 636f 6e73 7426 616d 703b 2074  uto const& t
    │ │ │ +00047410: 203a 2074 7329 0a09 0909 097b 0a09 0909   : ts).....{....
    │ │ │ +00047420: 0909 2f2f 204f 6e6c 7920 6174 7465 6d70  ..// Only attemp
    │ │ │ +00047430: 7420 746f 2072 6575 7365 2066 696c 6573  t to reuse files
    │ │ │ +00047440: 2066 726f 6d20 746f 7272 656e 7473 2074   from torrents t
    │ │ │ +00047450: 6861 7420 6172 6520 7365 6564 696e 672e  hat are seeding.
    │ │ │ +00047460: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00047490: 0909 0909 6966 2028 2174 2d26 6774 3b69 ....if (!t->i │ │ │ +000474a0: 735f 7365 6564 2829 2920 636f 6e74 696e s_seed()) contin │ │ │ +000474b0: 7565 3b0a 3c2f 6469 763e 0a09 0909 0909 ue;.
    ...... │ │ │ +000474c0: 6175 746f 2074 6920 3d20 742d 2667 743b auto ti = t-> │ │ │ +000474d0: 6765 745f 746f 7272 656e 745f 6669 6c65 get_torrent_file │ │ │ +000474e0: 2829 3b0a 0909 0909 0972 6573 2e6d 6174 ();......res.mat │ │ │ +000474f0: 6368 282a 7469 2c20 6669 6c65 6e61 6d65 ch(*ti, filename │ │ │ +00047500: 7328 7469 2d26 6774 3b6c 6179 6f75 7428 s(ti->layout( │ │ │ +00047510: 292c 2074 2d26 6774 3b6d 5f72 656e 616d ), t->m_renam │ │ │ +00047520: 6564 5f66 696c 6573 292c 2074 2d26 6774 ed_files), t-> │ │ │ +00047530: 3b73 6176 655f 7061 7468 2829 293b 0a09 ;save_path());.. │ │ │ +00047540: 0909 097d 0a09 0909 7d0a 0a09 0909 6c69 ...}....}.....li │ │ │ +00047550: 6e6b 7320 3d20 7374 643a 3a6d 6f76 6528 nks = std::move( │ │ │ +00047560: 7265 7329 2e67 6574 5f6c 696e 6b73 2829 res).get_links() │ │ │ +00047570: 3b0a 0909 7d0a 2365 6e64 6966 202f 2f20 ;...}.#endif // │ │ │ +00047580: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +00047590: 4d55 5441 424c 455f 544f 5252 454e 5453 MUTABLE_TORRENTS │ │ │ +000475a0: 0a0a 2369 6620 544f 5252 454e 545f 5553 ..#if TORRENT_US │ │ │ +000475b0: 455f 4153 5345 5254 530a 0909 544f 5252 E_ASSERTS...TORR │ │ │ +000475c0: 454e 545f 4153 5345 5254 286d 5f6f 7574 ENT_ASSERT(m_out │ │ │ +000475d0: 7374 616e 6469 6e67 5f63 6865 636b 5f66 standing_check_f │ │ │ +000475e0: 696c 6573 203d 3d20 6661 6c73 6529 3b0a iles == false);. │ │ │ +000475f0: 0909 6d5f 6f75 7473 7461 6e64 696e 675f ..m_outstanding_ │ │ │ +00047600: 6368 6563 6b5f 6669 6c65 7320 3d20 7472 check_files = tr │ │ │ +00047610: 7565 3b0a 2365 6e64 6966 0a0a 0909 6966 ue;.#endif....if │ │ │ +00047620: 2028 216d 5f61 6464 5f74 6f72 7265 6e74 (!m_add_torrent │ │ │ +00047630: 5f70 6172 616d 7320 7c7c 2021 286d 5f61 _params || !(m_a │ │ │ +00047640: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ +00047650: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ +00047660: 3b20 746f 7272 656e 745f 666c 6167 733a ; torrent_flags: │ │ │ +00047670: 3a6e 6f5f 7665 7269 6679 5f66 696c 6573 :no_verify_files │ │ │ +00047680: 2929 0a09 097b 0a09 0909 6d5f 7365 732e ))...{....m_ses. │ │ │ +00047690: 6469 736b 5f74 6872 6561 6428 292e 6173 disk_thread().as │ │ │ +000476a0: 796e 635f 6368 6563 6b5f 6669 6c65 7328 ync_check_files( │ │ │ +000476b0: 0a09 0909 096d 5f73 746f 7261 6765 2c20 .....m_storage, │ │ │ +000476c0: 6d5f 6164 645f 746f 7272 656e 745f 7061 m_add_torrent_pa │ │ │ +000476d0: 7261 6d73 203f 206d 5f61 6464 5f74 6f72 rams ? m_add_tor │ │ │ +000476e0: 7265 6e74 5f70 6172 616d 732e 6765 7428 rent_params.get( │ │ │ +000476f0: 2920 3a20 6e75 6c6c 7074 720a 0909 0909 ) : nullptr..... │ │ │ +00047700: 2c20 7374 643a 3a6d 6f76 6528 6c69 6e6b , std::move(link │ │ │ +00047710: 7329 2c20 5b73 656c 6620 3d20 7368 6172 s), [self = shar │ │ │ +00047720: 6564 5f66 726f 6d5f 7468 6973 2829 5d28 ed_from_this()]( │ │ │ +00047730: 7374 6174 7573 5f74 2073 742c 2073 746f status_t st, sto │ │ │ +00047740: 7261 6765 5f65 7272 6f72 2063 6f6e 7374 rage_error const │ │ │ +00047750: 2661 6d70 3b20 6572 726f 7229 0a09 0909 & error).... │ │ │ +00047760: 097b 2073 656c 662d 2667 743b 6f6e 5f72 .{ self->on_r │ │ │ +00047770: 6573 756d 655f 6461 7461 5f63 6865 636b esume_data_check │ │ │ +00047780: 6564 2873 742c 2065 7272 6f72 293b 207d ed(st, error); } │ │ │ +00047790: 293b 0a23 6966 6e64 6566 2054 4f52 5245 );.#ifndef TORRE │ │ │ +000477a0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ +000477b0: 4e47 0a09 0909 6465 6275 675f 6c6f 6728 NG....debug_log( │ │ │ +000477c0: 2269 6e69 742c 2061 7379 6e63 5f63 6865 "init, async_che │ │ │ +000477d0: 636b 5f66 696c 6573 2229 3b0a 2365 6e64 ck_files");.#end │ │ │ +000477e0: 6966 0a09 0909 6d5f 7365 732e 6465 6665 if....m_ses.defe │ │ │ +000477f0: 7272 6564 5f73 7562 6d69 745f 6a6f 6273 rred_submit_jobs │ │ │ +00047800: 2829 3b0a 0909 7d0a 0909 656c 7365 0a09 ();...}...else.. │ │ │ +00047810: 097b 0a09 0909 6f6e 5f72 6573 756d 655f .{....on_resume_ │ │ │ +00047820: 6461 7461 5f63 6865 636b 6564 287b 7d2c data_checked({}, │ │ │ +00047830: 2073 746f 7261 6765 5f65 7272 6f72 7b7d storage_error{} │ │ │ +00047840: 293b 0a09 097d 0a3c 2f70 7265 3e3c 2f74 );...}.
    relevanc │ │ │ +00047880: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ +000478c0: 2e63 7070 3a32 3837 393c 2f61 3e3c 2f74 .cpp:2879this patte │ │ │ +000478e0: 726e 2069 7320 7265 7065 6174 6564 2069 rn is repeated i │ │ │ +000478f0: 6e20 6120 6665 7720 706c 6163 6573 2e20 n a few places. │ │ │ +00047900: 4661 6374 6f72 2074 6869 7320 696e 746f Factor this into │ │ │ +00047910: 2061 2066 756e 6374 696f 6e20 616e 6420 a function and │ │ │ +00047920: 6765 6e65 7261 6c69 7a65 2074 6865 2063 generalize the c │ │ │ +00047930: 6f6e 6365 7074 206f 6620 6120 746f 7272 oncept of a torr │ │ │ +00047940: 656e 7420 6861 7669 6e67 2061 2064 6564 ent having a ded │ │ │ +00047950: 6963 6174 6564 206c 6973 7465 6e20 706f icated listen po │ │ │ +00047960: 7274 3c2f 7464 3e3c 2f74 723e 3c74 7220 rt

    │ │ │ +000479b0: 7468 6973 2070 6174 7465 726e 2069 7320 this pattern is │ │ │ +000479c0: 7265 7065 6174 6564 2069 6e20 6120 6665 repeated in a fe │ │ │ +000479d0: 7720 706c 6163 6573 2e20 4661 6374 6f72 w places. Factor │ │ │ +000479e0: 2074 6869 7320 696e 746f 0a61 2066 756e this into.a fun │ │ │ +000479f0: 6374 696f 6e20 616e 6420 6765 6e65 7261 ction and genera │ │ │ +00047a00: 6c69 7a65 2074 6865 2063 6f6e 6365 7074 lize the concept │ │ │ +00047a10: 206f 6620 6120 746f 7272 656e 7420 6861 of a torrent ha │ │ │ +00047a20: 7669 6e67 2061 0a64 6564 6963 6174 6564 ving a.dedicated │ │ │ +00047a30: 206c 6973 7465 6e20 706f 7274 3c2f 6832 listen port

    ../src/torr │ │ │ +00047a50: 656e 742e 6370 703a 3238 3739 3c2f 6834 ent.cpp:2879

    ..// 
    │ │ │ +00047aa0: 6e6f 7420 7265 6164 7920 666f 7220 7065  not ready for pe
    │ │ │ +00047ab0: 6572 732e 2045 7863 6570 742c 2069 6620  ers. Except, if 
    │ │ │ +00047ac0: 7765 2064 6f6e 2774 2068 6176 6520 6d65  we don't have me
    │ │ │ +00047ad0: 7461 6461 7461 2c0a 0909 2f2f 2077 6520  tadata,...// we 
    │ │ │ +00047ae0: 6e65 6564 2070 6565 7273 2074 6f20 646f  need peers to do
    │ │ │ +00047af0: 776e 6c6f 6164 2066 726f 6d0a 0909 6966  wnload from...if
    │ │ │ +00047b00: 2028 216d 5f66 696c 6573 5f63 6865 636b   (!m_files_check
    │ │ │ +00047b10: 6564 2026 616d 703b 2661 6d70 3b20 7661  ed && va
    │ │ │ +00047b20: 6c69 645f 6d65 7461 6461 7461 2829 2920  lid_metadata()) 
    │ │ │ +00047b30: 7265 7475 726e 3b0a 0a09 0969 6620 2821  return;....if (!
    │ │ │ +00047b40: 6d5f 616e 6e6f 756e 6365 5f74 6f5f 6c73  m_announce_to_ls
    │ │ │ +00047b50: 6429 2072 6574 7572 6e3b 0a0a 0909 2f2f  d) return;....//
    │ │ │ +00047b60: 2070 7269 7661 7465 2074 6f72 7265 6e74   private torrent
    │ │ │ +00047b70: 7320 6172 6520 6e65 7665 7220 616e 6e6f  s are never anno
    │ │ │ +00047b80: 756e 6365 6420 6f6e 204c 5344 0a09 0969  unced on LSD...i
    │ │ │ +00047b90: 6620 286d 5f74 6f72 7265 6e74 5f66 696c  f (m_torrent_fil
    │ │ │ +00047ba0: 652d 2667 743b 6973 5f76 616c 6964 2829  e->is_valid()
    │ │ │ +00047bb0: 2026 616d 703b 2661 6d70 3b20 6d5f 746f   && m_to
    │ │ │ +00047bc0: 7272 656e 745f 6669 6c65 2d26 6774 3b70  rrent_file->p
    │ │ │ +00047bd0: 7269 7628 2929 2072 6574 7572 6e3b 0a0a  riv()) return;..
    │ │ │ +00047be0: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ +00047bf0: 4932 500a 0909 2f2f 2069 3270 2074 6f72  I2P...// i2p tor
    │ │ │ +00047c00: 7265 6e74 7320 6172 6520 616c 736f 206e  rents are also n
    │ │ │ +00047c10: 6576 6572 2061 6e6e 6f75 6e63 6564 206f  ever announced o
    │ │ │ +00047c20: 6e20 4c53 440a 0909 2f2f 2075 6e6c 6573  n LSD...// unles
    │ │ │ +00047c30: 7320 7765 2061 6c6c 6f77 206d 6978 6564  s we allow mixed
    │ │ │ +00047c40: 2073 7761 726d 730a 0909 6966 2028 6973   swarms...if (is
    │ │ │ +00047c50: 5f69 3270 2829 2026 616d 703b 2661 6d70  _i2p() &&
    │ │ │ +00047c60: 3b20 2173 6574 7469 6e67 7328 292e 6765  ; !settings().ge
    │ │ │ +00047c70: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ +00047c80: 7061 636b 3a3a 616c 6c6f 775f 6932 705f  pack::allow_i2p_
    │ │ │ +00047c90: 6d69 7865 6429 290a 0909 0972 6574 7572  mixed))....retur
    │ │ │ +00047ca0: 6e3b 0a23 656e 6469 660a 0a09 0969 6620  n;.#endif....if 
    │ │ │ +00047cb0: 2869 735f 7061 7573 6564 2829 2920 7265  (is_paused()) re
    │ │ │ +00047cc0: 7475 726e 3b0a 0a09 0969 6620 2821 6d5f  turn;....if (!m_
    │ │ │ +00047cd0: 7365 732e 6861 735f 6c73 6428 2929 2072  ses.has_lsd()) r
    │ │ │ +00047ce0: 6574 7572 6e3b 0a0a 3c64 6976 2073 7479  eturn;..
    #ifdef TOR │ │ │ +00047d20: 5245 4e54 5f53 534c 5f50 4545 5253 0a3c RENT_SSL_PEERS.< │ │ │ +00047d30: 2f64 6976 3e09 0969 6e74 2070 6f72 7420 /div>..int port │ │ │ +00047d40: 3d20 6973 5f73 736c 5f74 6f72 7265 6e74 = is_ssl_torrent │ │ │ +00047d50: 2829 203f 206d 5f73 6573 2e73 736c 5f6c () ? m_ses.ssl_l │ │ │ +00047d60: 6973 7465 6e5f 706f 7274 2829 203a 206d isten_port() : m │ │ │ +00047d70: 5f73 6573 2e6c 6973 7465 6e5f 706f 7274 _ses.listen_port │ │ │ +00047d80: 2829 3b0a 2365 6c73 650a 0909 696e 7420 ();.#else...int │ │ │ +00047d90: 706f 7274 203d 206d 5f73 6573 2e6c 6973 port = m_ses.lis │ │ │ +00047da0: 7465 6e5f 706f 7274 2829 3b0a 2365 6e64 ten_port();.#end │ │ │ +00047db0: 6966 0a0a 0909 2f2f 2061 6e6e 6f75 6e63 if....// announc │ │ │ +00047dc0: 6520 7769 7468 2074 6865 206c 6f63 616c e with the local │ │ │ +00047dd0: 2064 6973 636f 7665 7279 2073 6572 7669 discovery servi │ │ │ +00047de0: 6365 0a09 096d 5f74 6f72 7265 6e74 5f66 ce...m_torrent_f │ │ │ +00047df0: 696c 652d 2667 743b 696e 666f 5f68 6173 ile->info_has │ │ │ +00047e00: 6865 7328 292e 666f 725f 6561 6368 285b hes().for_each([ │ │ │ +00047e10: 2661 6d70 3b5d 2873 6861 315f 6861 7368 &](sha1_hash │ │ │ +00047e20: 2063 6f6e 7374 2661 6d70 3b20 6968 2c20 const& ih, │ │ │ +00047e30: 7072 6f74 6f63 6f6c 5f76 6572 7369 6f6e protocol_version │ │ │ +00047e40: 290a 0909 7b0a 0909 096d 5f73 6573 2e61 )...{....m_ses.a │ │ │ +00047e50: 6e6e 6f75 6e63 655f 6c73 6428 6968 2c20 nnounce_lsd(ih, │ │ │ +00047e60: 706f 7274 293b 0a09 097d 293b 0a09 7d0a port);...});..}. │ │ │ +00047e70: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ +00047e80: 5f44 4953 4142 4c45 5f44 4854 0a0a 0976 _DISABLE_DHT...v │ │ │ +00047e90: 6f69 6420 746f 7272 656e 743a 3a64 6874 oid torrent::dht │ │ │ +00047ea0: 5f61 6e6e 6f75 6e63 6528 290a 097b 0a09 _announce()..{.. │ │ │ +00047eb0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00047ec0: 6973 5f73 696e 676c 655f 7468 7265 6164 is_single_thread │ │ │ +00047ed0: 2829 293b 0a09 0969 6620 2821 6d5f 7365 ());...if (!m_se │ │ │ +00047ee0: 732e 6468 7428 2929 0a09 097b 0a23 6966 s.dht())...{.#if │ │ │ +00047ef0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +00047f00: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0909 ABLE_LOGGING.... │ │ │ +00047f10: 6465 6275 675f 6c6f 6728 2244 4854 3a20 debug_log("DHT: │ │ │ +00047f20: 6e6f 2064 6874 2069 6e69 7469 616c 697a no dht initializ │ │ │ +00047f30: 6564 2229 3b0a 2365 6e64 6966 0a09 0909 ed");.#endif.... │ │ │ +00047f40: 7265 7475 726e 3b0a 0909 7d0a 0909 6966 return;...}...if │ │ │ +00047f50: 2028 2173 686f 756c 645f 616e 6e6f 756e (!should_announ │ │ │ +00047f60: 6365 5f64 6874 2829 290a 0909 7b0a 2369 ce_dht())...{.#i │ │ │ +00047f70: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +00047f80: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ +00047f90: 0969 6620 2873 686f 756c 645f 6c6f 6728 .if (should_log( │ │ │ +00047fa0: 2929 0a09 0909 7b0a 2369 6620 544f 5252 ))....{.#if TORR │ │ │ +00047fb0: 454e 545f 5553 455f 4932 500a 3c2f 7072 ENT_USE_I2P.rel │ │ │ +00047ff0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/to │ │ │ +00048030: 7272 656e 742e 6370 703a 3332 3234 3c2f rrent.cpp:3224it wo │ │ │ +00048050: 756c 6420 6265 206e 6963 6520 746f 2072 uld be nice to r │ │ │ +00048060: 6169 7365 2074 6865 2061 6273 7472 6163 aise the abstrac │ │ │ +00048070: 7469 6f6e 206c 6576 656c 206f 6620 7468 tion level of th │ │ │ +00048080: 6520 7472 6163 6b65 725f 6c69 7374 206f e tracker_list o │ │ │ +00048090: 7220 7472 6163 6b65 7273 2061 2062 6974 r trackers a bit │ │ │ +000480a0: 2068 6572 653c 2f74 643e 3c2f 7472 3e3c here< │ │ │ +000480b0: 7472 2069 643d 2231 3735 2220 7374 796c tr id="175" styl │ │ │ +000480c0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +000480d0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +000480e0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +000480f0: 6832 3e69 7420 776f 756c 6420 6265 206e h2>it would be n │ │ │ +00048100: 6963 6520 746f 2072 6169 7365 2074 6865 ice to raise the │ │ │ +00048110: 2061 6273 7472 6163 7469 6f6e 206c 6576 abstraction lev │ │ │ +00048120: 656c 206f 6620 7468 650a 7472 6163 6b65 el of the.tracke │ │ │ +00048130: 725f 6c69 7374 206f 7220 7472 6163 6b65 r_list or tracke │ │ │ +00048140: 7273 2061 2062 6974 2068 6572 653c 2f68 rs a bit here

    ../src/tor │ │ │ +00048160: 7265 6e74 2e63 7070 3a33 3232 343c 2f68 rent.cpp:3224
    ..ti
    │ │ │ +000481b0: 6d65 5f70 6f69 6e74 3332 2063 6f6e 7374  me_point32 const
    │ │ │ +000481c0: 206e 6f77 203d 2061 7578 3a3a 7469 6d65   now = aux::time
    │ │ │ +000481d0: 5f6e 6f77 3332 2829 3b0a 0a09 092f 2f20  _now32();....// 
    │ │ │ +000481e0: 6561 6368 206c 6973 7465 6e20 736f 636b  each listen sock
    │ │ │ +000481f0: 6574 2067 6574 7320 6974 7320 6f77 6e20  et gets its own 
    │ │ │ +00048200: 616e 6e6f 756e 6365 2073 7461 7465 0a09  announce state..
    │ │ │ +00048210: 092f 2f20 736f 2074 6861 7420 6561 6368  .// so that each
    │ │ │ +00048220: 206f 6e65 2073 686f 756c 6420 6765 7420   one should get 
    │ │ │ +00048230: 6174 206c 6561 7374 206f 6e65 2061 6e6e  at least one ann
    │ │ │ +00048240: 6f75 6e63 650a 0909 7374 643a 3a76 6563  ounce...std::vec
    │ │ │ +00048250: 746f 7226 6c74 3b61 6e6e 6f75 6e63 655f  tor<announce_
    │ │ │ +00048260: 7374 6174 6526 6774 3b20 6c69 7374 656e  state> listen
    │ │ │ +00048270: 5f73 6f63 6b65 745f 7374 6174 6573 3b0a  _socket_states;.
    │ │ │ +00048280: 0a09 0962 6f6f 6c20 636f 6e73 7420 616e  ...bool const an
    │ │ │ +00048290: 6e6f 756e 6365 5f74 6f5f 616c 6c5f 7469  nounce_to_all_ti
    │ │ │ +000482a0: 6572 7320 3d20 7365 7474 696e 6773 2829  ers = settings()
    │ │ │ +000482b0: 2e67 6574 5f62 6f6f 6c28 7365 7474 696e  .get_bool(settin
    │ │ │ +000482c0: 6773 5f70 6163 6b3a 3a61 6e6e 6f75 6e63  gs_pack::announc
    │ │ │ +000482d0: 655f 746f 5f61 6c6c 5f74 6965 7273 293b  e_to_all_tiers);
    │ │ │ +000482e0: 0a09 0962 6f6f 6c20 636f 6e73 7420 616e  ...bool const an
    │ │ │ +000482f0: 6e6f 756e 6365 5f74 6f5f 616c 6c5f 7472  nounce_to_all_tr
    │ │ │ +00048300: 6163 6b65 7273 203d 2073 6574 7469 6e67  ackers = setting
    │ │ │ +00048310: 7328 292e 6765 745f 626f 6f6c 2873 6574  s().get_bool(set
    │ │ │ +00048320: 7469 6e67 735f 7061 636b 3a3a 616e 6e6f  tings_pack::anno
    │ │ │ +00048330: 756e 6365 5f74 6f5f 616c 6c5f 7472 6163  unce_to_all_trac
    │ │ │ +00048340: 6b65 7273 293b 0a23 6966 6e64 6566 2054  kers);.#ifndef T
    │ │ │ +00048350: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c  ORRENT_DISABLE_L
    │ │ │ +00048360: 4f47 4749 4e47 0a09 0969 6e74 2069 6478  OGGING...int idx
    │ │ │ +00048370: 203d 202d 313b 0a09 0969 6620 2873 686f   = -1;...if (sho
    │ │ │ +00048380: 756c 645f 6c6f 6728 2929 0a09 097b 0a09  uld_log())...{..
    │ │ │ +00048390: 0909 6465 6275 675f 6c6f 6728 222a 2a2a  ..debug_log("***
    │ │ │ +000483a0: 2061 6e6e 6f75 6e63 653a 2022 0a09 0909   announce: "....
    │ │ │ +000483b0: 0922 5b20 616e 6e6f 756e 6365 5f74 6f5f  ."[ announce_to_
    │ │ │ +000483c0: 616c 6c5f 7469 6572 733a 2025 6420 616e  all_tiers: %d an
    │ │ │ +000483d0: 6e6f 756e 6365 5f74 6f5f 616c 6c5f 7472  nounce_to_all_tr
    │ │ │ +000483e0: 6163 6b65 7273 3a20 2564 206e 756d 5f74  ackers: %d num_t
    │ │ │ +000483f0: 7261 636b 6572 733a 2025 6420 5d22 0a09  rackers: %d ]"..
    │ │ │ +00048400: 0909 092c 2061 6e6e 6f75 6e63 655f 746f  ..., announce_to
    │ │ │ +00048410: 5f61 6c6c 5f74 6965 7273 0a09 0909 092c  _all_tiers.....,
    │ │ │ +00048420: 2061 6e6e 6f75 6e63 655f 746f 5f61 6c6c   announce_to_all
    │ │ │ +00048430: 5f74 7261 636b 6572 730a 0909 0909 2c20  _trackers....., 
    │ │ │ +00048440: 696e 7428 6d5f 7472 6163 6b65 7273 2e73  int(m_trackers.s
    │ │ │ +00048450: 697a 6528 2929 293b 0a09 097d 0a23 656e  ize()));...}.#en
    │ │ │ +00048460: 6469 660a 0a3c 6469 7620 7374 796c 653d  dif..
    ..for (auto&a │ │ │ +000484a0: 6d70 3b20 6165 203a 206d 5f74 7261 636b mp; ae : m_track │ │ │ +000484b0: 6572 7329 0a3c 2f64 6976 3e09 097b 0a23 ers).
    ..{.# │ │ │ +000484c0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +000484d0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ +000484e0: 0909 2b2b 6964 783b 0a23 656e 6469 660a ..++idx;.#endif. │ │ │ +000484f0: 0909 0972 6566 7265 7368 5f65 6e64 706f ...refresh_endpo │ │ │ +00048500: 696e 745f 6c69 7374 286d 5f73 6573 2c20 int_list(m_ses, │ │ │ +00048510: 6973 5f73 736c 5f74 6f72 7265 6e74 2829 is_ssl_torrent() │ │ │ +00048520: 2c20 626f 6f6c 286d 5f63 6f6d 706c 6574 , bool(m_complet │ │ │ +00048530: 655f 7365 6e74 292c 2061 6529 3b0a 0a09 e_sent), ae);... │ │ │ +00048540: 0909 2f2f 2069 6620 7472 6163 6b65 7269 ..// if trackeri │ │ │ +00048550: 6420 6973 206e 6f74 2073 7065 6369 6669 d is not specifi │ │ │ +00048560: 6564 2066 6f72 2074 7261 636b 6572 2075 ed for tracker u │ │ │ +00048570: 7365 2064 6566 6175 6c74 206f 6e65 2c20 se default one, │ │ │ +00048580: 7072 6f62 6162 6c79 2073 6574 2065 7870 probably set exp │ │ │ +00048590: 6c69 6369 746c 790a 0909 0972 6571 2e74 licitly....req.t │ │ │ +000485a0: 7261 636b 6572 6964 203d 2061 652e 7472 rackerid = ae.tr │ │ │ +000485b0: 6163 6b65 7269 642e 656d 7074 7928 2920 ackerid.empty() │ │ │ +000485c0: 3f20 6d5f 7472 6163 6b65 7269 6420 3a20 ? m_trackerid : │ │ │ +000485d0: 6165 2e74 7261 636b 6572 6964 3b0a 0909 ae.trackerid;... │ │ │ +000485e0: 0972 6571 2e75 726c 203d 2061 652e 7572 .req.url = ae.ur │ │ │ +000485f0: 6c3b 0a0a 2369 6620 544f 5252 454e 545f l;..#if TORRENT_ │ │ │ +00048600: 5553 455f 4932 500a 0909 092f 2f20 6966 USE_I2P....// if │ │ │ +00048610: 2077 6520 646f 6e27 7420 616c 6c6f 7720 we don't allow │ │ │ +00048620: 6d69 7869 6e67 206e 6f72 6d61 6c20 7065 mixing normal pe │ │ │ +00048630: 6572 7320 696e 746f 2074 6869 7320 6932 ers into this i2 │ │ │ +00048640: 7020 746f 7272 656e 742c 0a09 0909 2f2f p torrent,....// │ │ │ +00048650: 2073 6b69 7020 6e6f 6e2d 6932 7020 7472 skip non-i2p tr │ │ │ +00048660: 6163 6b65 7273 2e20 7570 6461 7465 5f74 ackers. update_t │ │ │ +00048670: 7261 636b 6572 5f74 696d 6572 2829 2061 racker_timer() a │ │ │ +00048680: 7070 6c69 6573 2074 6865 0a09 0909 2f2f pplies the....// │ │ │ +00048690: 2073 616d 6520 736b 6970 2073 6f20 7468 same skip so th │ │ │ +000486a0: 6520 7469 6d65 7220 646f 6573 6e27 7420 e timer doesn't │ │ │ +000486b0: 6b65 6570 2066 6972 696e 6720 666f 7220 keep firing for │ │ │ +000486c0: 7472 6163 6b65 7273 2077 6527 6c6c 0a09 trackers we'll.. │ │ │ +000486d0: 0909 2f2f 206e 6576 6572 2063 6f6e 7461 ..// never conta │ │ │ +000486e0: 6374 2e0a 0909 0969 6620 2821 6932 705f ct.....if (!i2p_ │ │ │ +000486f0: 636f 6d70 6174 6962 6c65 5f74 7261 636b compatible_track │ │ │ +00048700: 6572 2861 6529 2920 636f 6e74 696e 7565 er(ae)) continue │ │ │ +00048710: 3b0a 0909 092f 2f20 7265 7120 6973 2072 ;....// req is r │ │ │ +00048720: 6575 7365 6420 6163 726f 7373 2069 7465 eused across ite │ │ │ +00048730: 7261 7469 6f6e 732c 2073 6f20 7365 7420 rations, so set │ │ │ +00048740: 7468 6520 6932 7020 6269 7420 746f 206d the i2p bit to m │ │ │ +00048750: 6174 6368 0a09 0909 2f2f 2074 6869 7320 atch....// this │ │ │ +00048760: 7472 6163 6b65 7220 7261 7468 6572 2074 tracker rather t │ │ │ +00048770: 6861 6e20 6f6e 6c79 2065 7665 7220 4f52 han only ever OR │ │ │ +00048780: 2d69 6e67 2069 7420 696e 2e0a 0909 0969 -ing it in.....i │ │ │ +00048790: 6620 2861 652e 6932 7029 0a09 0909 0972 f (ae.i2p).....r │ │ │ +000487a0: 6571 2e6b 696e 6420 7c3d 2074 7261 636b eq.kind |= track │ │ │ +000487b0: 6572 5f72 6571 7565 7374 3a3a 6932 703b er_request::i2p; │ │ │ +000487c0: 0a09 0909 656c 7365 0a09 0909 0972 6571 ....else.....req │ │ │ +000487d0: 2e6b 696e 6420 2661 6d70 3b3d 207e 7472 .kind &= ~tr │ │ │ +000487e0: 6163 6b65 725f 7265 7175 6573 743a 3a69 acker_request::i │ │ │ +000487f0: 3270 3b0a 2365 6e64 6966 0a0a 0909 0966 2p;.#endif.....f │ │ │ +00048800: 6f72 2028 6175 746f 2661 6d70 3b20 6165 or (auto& ae │ │ │ +00048810: 7020 3a20 6165 2e65 6e64 706f 696e 7473 p : ae.endpoints │ │ │ +00048820: 290a 0909 097b 0a09 0909 092f 2f20 646f )....{.....// do │ │ │ +00048830: 206e 6f74 2061 6464 2063 6f64 6520 7768 not add code wh │ │ │ +00048840: 6963 6820 636f 6e74 696e 7565 7320 746f ich continues to │ │ │ +00048850: 2074 6865 206e 6578 7420 656e 6470 6f69 the next endpoi │ │ │ +00048860: 6e74 2068 6572 6521 0a09 0909 092f 2f20 nt here!.....// │ │ │ +00048870: 6c69 7374 656e 5f73 6f63 6b65 745f 7374 listen_socket_st │ │ │ +00048880: 6174 6573 206e 6565 6473 2074 6f20 6265 ates needs to be │ │ │ +00048890: 2070 6f70 756c 6174 6564 2065 7665 6e20 populated even │ │ │ +000488a0: 6966 206e 6f6e 6520 6f66 2074 6865 2065 if none of the e │ │ │ +000488b0: 6e64 706f 696e 7473 0a09 0909 092f 2f20 ndpoints.....// │ │ │ +000488c0: 7769 6c6c 2062 6520 616e 6e6f 756e 6369 will be announci │ │ │ +000488d0: 6e67 2066 6f72 2074 6869 7320 7472 6163 ng for this trac │ │ │ +000488e0: 6b65 720a 0909 0909 2f2f 206f 7468 6572 ker.....// other │ │ │ +000488f0: 7769 7365 2074 6865 2065 6172 6c79 2062 wise the early b │ │ │ +00048900: 6169 6c20 6f75 7420 7768 656e 206e 6569 ail out when nei │ │ │ +00048910: 7468 6572 2061 6e6e 6f75 6e63 655f 746f ther announce_to │ │ │ +00048920: 5f61 6c6c 5f74 7261 636b 6572 730a 3c2f _all_trackers.r │ │ │ +00048960: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00048970: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>
    ../src/ │ │ │ +000489a0: 746f 7272 656e 742e 6370 703a 3337 3538 torrent.cpp:3758 │ │ │ +000489b0: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 6f76 mov │ │ │ +000489c0: 6520 7468 6973 2069 6e74 6f20 6120 6675 e this into a fu │ │ │ +000489d0: 6e63 7469 6f6e 206f 6e20 7472 6163 6b65 nction on tracke │ │ │ +000489e0: 725f 6c69 7374 3c2f 7464 3e3c 2f74 723e r_list │ │ │ +000489f0: 3c74 7220 6964 3d22 3137 3622 2073 7479 │ │ │ +00048a20: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00048a30: 3c68 323e 6d6f 7665 2074 6869 7320 696e

    move this in │ │ │ +00048a40: 746f 2061 2066 756e 6374 696f 6e20 6f6e to a function on │ │ │ +00048a50: 2074 7261 636b 6572 5f6c 6973 743c 2f68 tracker_list

    ../src/tor │ │ │ +00048a70: 7265 6e74 2e63 7070 3a33 3735 383c 2f68 rent.cpp:3758
    .., 
    │ │ │ +00048ac0: 7374 7275 6374 2074 7261 636b 6572 5f72  struct tracker_r
    │ │ │ +00048ad0: 6573 706f 6e73 6520 636f 6e73 7426 616d  esponse const&am
    │ │ │ +00048ae0: 703b 2072 6573 7029 0a09 7b0a 0909 544f  p; resp)..{...TO
    │ │ │ +00048af0: 5252 454e 545f 4153 5345 5254 2869 735f  RRENT_ASSERT(is_
    │ │ │ +00048b00: 7369 6e67 6c65 5f74 6872 6561 6428 2929  single_thread())
    │ │ │ +00048b10: 3b0a 0a09 0949 4e56 4152 4941 4e54 5f43  ;....INVARIANT_C
    │ │ │ +00048b20: 4845 434b 3b0a 0909 544f 5252 454e 545f  HECK;...TORRENT_
    │ │ │ +00048b30: 4153 5345 5254 2821 2872 2e6b 696e 6420  ASSERT(!(r.kind 
    │ │ │ +00048b40: 2661 6d70 3b20 7472 6163 6b65 725f 7265  & tracker_re
    │ │ │ +00048b50: 7175 6573 743a 3a73 6372 6170 655f 7265  quest::scrape_re
    │ │ │ +00048b60: 7175 6573 7429 293b 0a0a 0909 2f2f 2069  quest));....// i
    │ │ │ +00048b70: 6620 7468 6520 7472 6163 6b65 7220 746f  f the tracker to
    │ │ │ +00048b80: 6c64 2075 7320 7768 6174 206f 7572 2065  ld us what our e
    │ │ │ +00048b90: 7874 6572 6e61 6c20 4950 2061 6464 7265  xternal IP addre
    │ │ │ +00048ba0: 7373 2069 732c 2072 6563 6f72 6420 6974  ss is, record it
    │ │ │ +00048bb0: 2077 6974 680a 0909 2f2f 206f 7574 2065   with...// out e
    │ │ │ +00048bc0: 7874 6572 6e61 6c20 4950 2063 6f75 6e74  xternal IP count
    │ │ │ +00048bd0: 6572 2028 616e 6420 7061 7373 2061 6c6f  er (and pass alo
    │ │ │ +00048be0: 6e67 2074 6865 2049 5020 6f66 2074 6865  ng the IP of the
    │ │ │ +00048bf0: 2074 7261 636b 6572 2074 6f20 6b6e 6f77   tracker to know
    │ │ │ +00048c00: 0a09 092f 2f20 7768 6f20 746f 2061 7474  ...// who to att
    │ │ │ +00048c10: 7269 6275 7465 2074 6869 7320 766f 7465  ribute this vote
    │ │ │ +00048c20: 2074 6f29 0a09 0969 6620 2872 6573 702e   to)...if (resp.
    │ │ │ +00048c30: 6578 7465 726e 616c 5f69 7020 213d 2061  external_ip != a
    │ │ │ +00048c40: 6464 7265 7373 2829 2026 616d 703b 2661  ddress() &&a
    │ │ │ +00048c50: 6d70 3b20 2174 7261 636b 6572 5f69 702e  mp; !tracker_ip.
    │ │ │ +00048c60: 6973 5f75 6e73 7065 6369 6669 6564 2829  is_unspecified()
    │ │ │ +00048c70: 2026 616d 703b 2661 6d70 3b20 722e 6f75   && r.ou
    │ │ │ +00048c80: 7467 6f69 6e67 5f73 6f63 6b65 7429 0a09  tgoing_socket)..
    │ │ │ +00048c90: 0909 6d5f 7365 732e 7365 745f 6578 7465  ..m_ses.set_exte
    │ │ │ +00048ca0: 726e 616c 5f61 6464 7265 7373 2872 2e6f  rnal_address(r.o
    │ │ │ +00048cb0: 7574 676f 696e 675f 736f 636b 6574 2e67  utgoing_socket.g
    │ │ │ +00048cc0: 6574 5f6c 6f63 616c 5f65 6e64 706f 696e  et_local_endpoin
    │ │ │ +00048cd0: 7428 290a 0909 0909 2c20 7265 7370 2e65  t()....., resp.e
    │ │ │ +00048ce0: 7874 6572 6e61 6c5f 6970 0a09 0909 092c  xternal_ip.....,
    │ │ │ +00048cf0: 2061 7578 3a3a 7365 7373 696f 6e5f 696e   aux::session_in
    │ │ │ +00048d00: 7465 7266 6163 653a 3a73 6f75 7263 655f  terface::source_
    │ │ │ +00048d10: 7472 6163 6b65 722c 2074 7261 636b 6572  tracker, tracker
    │ │ │ +00048d20: 5f69 7029 3b0a 0a09 0974 696d 655f 706f  _ip);....time_po
    │ │ │ +00048d30: 696e 7433 3220 636f 6e73 7420 6e6f 7720  int32 const now 
    │ │ │ +00048d40: 3d20 6175 783a 3a74 696d 655f 6e6f 7733  = aux::time_now3
    │ │ │ +00048d50: 3228 293b 0a0a 0909 7072 6f74 6f63 6f6c  2();....protocol
    │ │ │ +00048d60: 5f76 6572 7369 6f6e 2063 6f6e 7374 2076  _version const v
    │ │ │ +00048d70: 203d 2072 2e69 6e66 6f5f 6861 7368 203d   = r.info_hash =
    │ │ │ +00048d80: 3d20 746f 7272 656e 745f 6669 6c65 2829  = torrent_file()
    │ │ │ +00048d90: 2e69 6e66 6f5f 6861 7368 6573 2829 2e76  .info_hashes().v
    │ │ │ +00048da0: 310a 0909 093f 2070 726f 746f 636f 6c5f  1....? protocol_
    │ │ │ +00048db0: 7665 7273 696f 6e3a 3a56 3120 3a20 7072  version::V1 : pr
    │ │ │ +00048dc0: 6f74 6f63 6f6c 5f76 6572 7369 6f6e 3a3a  otocol_version::
    │ │ │ +00048dd0: 5632 3b0a 0a3c 6469 7620 7374 796c 653d  V2;..
    ..aux::announ │ │ │ +00048e10: 6365 5f65 6e74 7279 2a20 6165 203d 206d ce_entry* ae = m │ │ │ +00048e20: 5f74 7261 636b 6572 732e 6669 6e64 5f74 _trackers.find_t │ │ │ +00048e30: 7261 636b 6572 2872 2e75 726c 293b 0a3c racker(r.url);.< │ │ │ +00048e40: 2f64 6976 3e0a 0909 7463 703a 3a65 6e64 /div>...tcp::end │ │ │ +00048e50: 706f 696e 7420 6c6f 6361 6c5f 656e 6470 point local_endp │ │ │ +00048e60: 6f69 6e74 3b0a 0909 6966 2028 6165 290a oint;...if (ae). │ │ │ +00048e70: 0909 7b0a 0909 0961 7574 6f2a 2061 6570 ..{....auto* aep │ │ │ +00048e80: 203d 2061 652d 2667 743b 6669 6e64 5f65 = ae->find_e │ │ │ +00048e90: 6e64 706f 696e 7428 722e 6f75 7467 6f69 ndpoint(r.outgoi │ │ │ +00048ea0: 6e67 5f73 6f63 6b65 7429 3b0a 0909 0969 ng_socket);....i │ │ │ +00048eb0: 6620 2861 6570 290a 0909 097b 0a09 0909 f (aep)....{.... │ │ │ +00048ec0: 0961 7574 6f26 616d 703b 2061 203d 2061 .auto& a = a │ │ │ +00048ed0: 6570 2d26 6774 3b69 6e66 6f5f 6861 7368 ep->info_hash │ │ │ +00048ee0: 6573 5b76 5d3b 0a0a 0909 0909 6c6f 6361 es[v];......loca │ │ │ +00048ef0: 6c5f 656e 6470 6f69 6e74 203d 2061 6570 l_endpoint = aep │ │ │ +00048f00: 2d26 6774 3b6c 6f63 616c 5f65 6e64 706f ->local_endpo │ │ │ +00048f10: 696e 743b 0a09 0909 0969 6620 2872 6573 int;.....if (res │ │ │ +00048f20: 702e 696e 636f 6d70 6c65 7465 2026 6774 p.incomplete > │ │ │ +00048f30: 3b3d 2030 2920 612e 7363 7261 7065 5f69 ;= 0) a.scrape_i │ │ │ +00048f40: 6e63 6f6d 706c 6574 6520 3d20 7265 7370 ncomplete = resp │ │ │ +00048f50: 2e69 6e63 6f6d 706c 6574 653b 0a09 0909 .incomplete;.... │ │ │ +00048f60: 0969 6620 2872 6573 702e 636f 6d70 6c65 .if (resp.comple │ │ │ +00048f70: 7465 2026 6774 3b3d 2030 2920 612e 7363 te >= 0) a.sc │ │ │ +00048f80: 7261 7065 5f63 6f6d 706c 6574 6520 3d20 rape_complete = │ │ │ +00048f90: 7265 7370 2e63 6f6d 706c 6574 653b 0a09 resp.complete;.. │ │ │ +00048fa0: 0909 0969 6620 2872 6573 702e 646f 776e ...if (resp.down │ │ │ +00048fb0: 6c6f 6164 6564 2026 6774 3b3d 2030 2920 loaded >= 0) │ │ │ +00048fc0: 612e 7363 7261 7065 5f64 6f77 6e6c 6f61 a.scrape_downloa │ │ │ +00048fd0: 6465 6420 3d20 7265 7370 2e64 6f77 6e6c ded = resp.downl │ │ │ +00048fe0: 6f61 6465 643b 0a09 0909 0969 6620 2821 oaded;.....if (! │ │ │ +00048ff0: 612e 7374 6172 745f 7365 6e74 2026 616d a.start_sent &am │ │ │ +00049000: 703b 2661 6d70 3b20 722e 6576 656e 7420 p;& r.event │ │ │ +00049010: 3d3d 2065 7665 6e74 5f74 3a3a 7374 6172 == event_t::star │ │ │ +00049020: 7465 6429 0a09 0909 0909 612e 7374 6172 ted)......a.star │ │ │ +00049030: 745f 7365 6e74 203d 2074 7275 653b 0a09 t_sent = true;.. │ │ │ +00049040: 0909 0969 6620 2821 612e 636f 6d70 6c65 ...if (!a.comple │ │ │ +00049050: 7465 5f73 656e 7420 2661 6d70 3b26 616d te_sent &&am │ │ │ +00049060: 703b 2072 2e65 7665 6e74 203d 3d20 6576 p; r.event == ev │ │ │ +00049070: 656e 745f 743a 3a63 6f6d 706c 6574 6564 ent_t::completed │ │ │ +00049080: 290a 0909 0909 7b0a 0909 0909 0961 2e63 ).....{......a.c │ │ │ +00049090: 6f6d 706c 6574 655f 7365 6e74 203d 2074 omplete_sent = t │ │ │ +000490a0: 7275 653b 0a09 0909 0909 2f2f 2077 6520 rue;......// we │ │ │ +000490b0: 7375 6363 6573 7366 756c 6c79 2072 6570 successfully rep │ │ │ +000490c0: 6f72 7465 6420 6576 656e 743d 636f 6d70 orted event=comp │ │ │ +000490d0: 6c65 7465 6420 746f 206f 6e65 2074 7261 leted to one tra │ │ │ +000490e0: 636b 6572 2e20 446f 6e27 740a 0909 0909 cker. Don't..... │ │ │ +000490f0: 092f 2f20 7365 6e64 2069 7420 746f 2061 .// send it to a │ │ │ +00049100: 6e79 206f 7468 6572 206f 6e65 7320 6672 ny other ones fr │ │ │ +00049110: 6f6d 206e 6f77 206f 6e20 2874 6865 7265 om now on (there │ │ │ +00049120: 206d 6179 2062 6520 6f74 6865 720a 0909 may be other... │ │ │ +00049130: 0909 092f 2f20 616e 6e6f 756e 6365 7320 ...// announces │ │ │ +00049140: 6f75 7473 7461 6e64 696e 6720 7269 6768 outstanding righ │ │ │ +00049150: 7420 6e6f 7720 7468 6f75 6768 290a 0909 t now though)... │ │ │ +00049160: 0909 096d 5f63 6f6d 706c 6574 655f 7365 ...m_complete_se │ │ │ +00049170: 6e74 203d 2074 7275 653b 0a09 0909 097d nt = true;.....} │ │ │ +00049180: 0a09 0909 0961 652d 2667 743b 7665 7269 .....ae->veri │ │ │ +00049190: 6669 6564 203d 2074 7275 653b 0a09 0909 fied = true;.... │ │ │ +000491a0: 0961 2e6e 6578 745f 616e 6e6f 756e 6365 .a.next_announce │ │ │ +000491b0: 203d 206e 6f77 202b 2072 6573 702e 696e = now + resp.in │ │ │ +000491c0: 7465 7276 616c 3b0a 0909 0909 612e 6d69 terval;.....a.mi │ │ │ +000491d0: 6e5f 616e 6e6f 756e 6365 203d 206e 6f77 n_announce = now │ │ │ +000491e0: 202b 2072 6573 702e 6d69 6e5f 696e 7465 + resp.min_inte │ │ │ +000491f0: 7276 616c 3b0a 0909 0909 612e 7570 6461 rval;.....a.upda │ │ │ +00049200: 7469 6e67 203d 2066 616c 7365 3b0a 0909 ting = false;... │ │ │ +00049210: 0909 612e 6661 696c 7320 3d20 303b 0a09 ..a.fails = 0;.. │ │ │ +00049220: 0909 0961 2e6c 6173 745f 6572 726f 722e ...a.last_error. │ │ │ +00049230: 636c 6561 7228 293b 0a09 0909 0961 2e6d clear();.....a.m │ │ │ +00049240: 6573 7361 6765 203d 2021 7265 7370 2e77 essage = !resp.w │ │ │ +00049250: 6172 6e69 6e67 5f6d 6573 7361 6765 2e65 arning_message.e │ │ │ +00049260: 6d70 7479 2829 203f 2072 6573 702e 7761 mpty() ? resp.wa │ │ │ +00049270: 726e 696e 675f 6d65 7373 6167 6520 3a20 rning_message : │ │ │ +00049280: 7374 643a 3a73 7472 696e 6728 293b 0a3c std::string();.< │ │ │ +00049290: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +000492a0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +000492b0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +000492c0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000492d0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +00049300: 2f74 6f72 7265 6e74 2e63 7070 3a33 3835 /torrent.cpp:385 │ │ │ +00049310: 323c 2f61 3e3c 2f74 643e 3c74 643e 7468 2th │ │ │ +00049320: 6520 6465 7374 696e 6174 696f 6e20 7374 e destination st │ │ │ +00049330: 7269 6e67 2073 686f 756c 6420 6265 2062 ring should be b │ │ │ +00049340: 6173 6536 3420 6465 636f 6465 6420 616e ase64 decoded an │ │ │ +00049350: 6420 7368 6132 3536 2068 6173 6865 6420 d sha256 hashed │ │ │ +00049360: 746f 2066 6f72 6d20 7468 6520 6465 7374 to form the dest │ │ │ +00049370: 696e 6174 696f 6e20 6164 6472 6573 7320 ination address │ │ │ +00049380: 616e 6420 7374 6f72 6520 7468 6174 2069 and store that i │ │ │ +00049390: 6e20 7468 6520 6932 705f 7065 6572 206f n the i2p_peer o │ │ │ +000493a0: 626a 6563 7420 6469 7265 6374 6c79 3c2f bject directly

    the │ │ │ +00049400: 6465 7374 696e 6174 696f 6e20 7374 7269 destination stri │ │ │ +00049410: 6e67 2073 686f 756c 6420 6265 2062 6173 ng should be bas │ │ │ +00049420: 6536 3420 6465 636f 6465 6420 616e 640a e64 decoded and. │ │ │ +00049430: 7368 6132 3536 2068 6173 6865 6420 746f sha256 hashed to │ │ │ +00049440: 2066 6f72 6d20 7468 6520 6465 7374 696e form the destin │ │ │ +00049450: 6174 696f 6e20 6164 6472 6573 7320 616e ation address an │ │ │ +00049460: 6420 7374 6f72 650a 7468 6174 2069 6e20 d store.that in │ │ │ +00049470: 7468 6520 6932 705f 7065 6572 206f 626a the i2p_peer obj │ │ │ +00049480: 6563 7420 6469 7265 6374 6c79 3c2f 6832 ect directly

    ../src/torr │ │ │ +000494a0: 656e 742e 6370 703a 3338 3532 3c2f 6834 ent.cpp:3852

    ..for
    │ │ │ +000494f0: 2028 6175 746f 2063 6f6e 7374 2661 6d70   (auto const&
    │ │ │ +00049500: 3b20 6920 3a20 7265 7370 2e70 6565 7273  ; i : resp.peers
    │ │ │ +00049510: 290a 0909 7b0a 0909 092f 2f20 646f 6e27  )...{....// don'
    │ │ │ +00049520: 7420 6d61 6b65 2063 6f6e 6e65 6374 696f  t make connectio
    │ │ │ +00049530: 6e73 2074 6f20 6f75 7273 656c 660a 0909  ns to ourself...
    │ │ │ +00049540: 0969 6620 2869 2e70 6964 203d 3d20 6d5f  .if (i.pid == m_
    │ │ │ +00049550: 7065 6572 5f69 6429 0a09 0909 0963 6f6e  peer_id).....con
    │ │ │ +00049560: 7469 6e75 653b 0a0a 2369 6620 544f 5252  tinue;..#if TORR
    │ │ │ +00049570: 454e 545f 5553 455f 4932 500a 0909 0969  ENT_USE_I2P....i
    │ │ │ +00049580: 6620 2872 2e69 3270 636f 6e6e 290a 0909  f (r.i2pconn)...
    │ │ │ +00049590: 097b 0a09 0909 092f 2f20 7468 6973 2069  .{.....// this i
    │ │ │ +000495a0: 7320 616e 2069 3270 206e 616d 652c 2077  s an i2p name, w
    │ │ │ +000495b0: 6520 6e65 6564 2074 6f20 7573 6520 7468  e need to use th
    │ │ │ +000495c0: 6520 5341 4d20 636f 6e6e 6563 7469 6f6e  e SAM connection
    │ │ │ +000495d0: 0a09 0909 092f 2f20 746f 2064 6f20 7468  .....// to do th
    │ │ │ +000495e0: 6520 6e61 6d65 206c 6f6f 6b75 700a 0909  e name lookup...
    │ │ │ +000495f0: 0909 6966 2028 7374 7269 6e67 5f65 6e64  ..if (string_end
    │ │ │ +00049600: 735f 7769 7468 2869 2e68 6f73 746e 616d  s_with(i.hostnam
    │ │ │ +00049610: 652c 2022 2e69 3270 2229 290a 0909 0909  e, ".i2p")).....
    │ │ │ +00049620: 7b0a 0909 0909 0941 4444 5f4f 5554 5354  {......ADD_OUTST
    │ │ │ +00049630: 414e 4449 4e47 5f41 5359 4e43 2822 746f  ANDING_ASYNC("to
    │ │ │ +00049640: 7272 656e 743a 3a6f 6e5f 6932 705f 7265  rrent::on_i2p_re
    │ │ │ +00049650: 736f 6c76 6522 293b 0a09 0909 0909 722e  solve");......r.
    │ │ │ +00049660: 6932 7063 6f6e 6e2d 2667 743b 6173 796e  i2pconn->asyn
    │ │ │ +00049670: 635f 6e61 6d65 5f6c 6f6f 6b75 7028 692e  c_name_lookup(i.
    │ │ │ +00049680: 686f 7374 6e61 6d65 2e63 5f73 7472 2829  hostname.c_str()
    │ │ │ +00049690: 0a09 0909 0909 092c 205b 7365 6c66 203d  ......., [self =
    │ │ │ +000496a0: 2073 6861 7265 645f 6672 6f6d 5f74 6869   shared_from_thi
    │ │ │ +000496b0: 7328 295d 2028 6572 726f 725f 636f 6465  s()] (error_code
    │ │ │ +000496c0: 2063 6f6e 7374 2661 6d70 3b20 6563 2c20   const& ec, 
    │ │ │ +000496d0: 6368 6172 2063 6f6e 7374 2a20 6465 7374  char const* dest
    │ │ │ +000496e0: 290a 0909 0909 0909 7b20 7365 6c66 2d26  ).......{ self-&
    │ │ │ +000496f0: 6774 3b74 6f72 7265 6e74 3a3a 6f6e 5f69  gt;torrent::on_i
    │ │ │ +00049700: 3270 5f72 6573 6f6c 7665 2865 632c 2064  2p_resolve(ec, d
    │ │ │ +00049710: 6573 742c 2070 6565 725f 696e 666f 3a3a  est, peer_info::
    │ │ │ +00049720: 7472 6163 6b65 7229 3b20 7d29 3b0a 0909  tracker); });...
    │ │ │ +00049730: 0909 7d0a 0909 0909 656c 7365 0a09 0909  ..}.....else....
    │ │ │ +00049740: 097b 0a3c 6469 7620 7374 796c 653d 2262  .{.
    .....torrent_st │ │ │ +00049780: 6174 6520 7374 203d 2067 6574 5f70 6565 ate st = get_pee │ │ │ +00049790: 725f 6c69 7374 5f73 7461 7465 2829 3b0a r_list_state();. │ │ │ +000497a0: 3c2f 6469 763e 0909 0909 096e 6565 645f
    .....need_ │ │ │ +000497b0: 7065 6572 5f6c 6973 7428 293b 0a09 0909 peer_list();.... │ │ │ +000497c0: 0909 6966 2028 6d5f 7065 6572 5f6c 6973 ..if (m_peer_lis │ │ │ +000497d0: 742d 2667 743b 6164 645f 6932 705f 7065 t->add_i2p_pe │ │ │ +000497e0: 6572 2869 2e68 6f73 746e 616d 652c 2070 er(i.hostname, p │ │ │ +000497f0: 6565 725f 696e 666f 3a3a 7472 6163 6b65 eer_info::tracke │ │ │ +00049800: 722c 207b 7d2c 2026 616d 703b 7374 2929 r, {}, &st)) │ │ │ +00049810: 0a09 0909 0909 0973 7461 7465 5f75 7064 .......state_upd │ │ │ +00049820: 6174 6564 2829 3b0a 0909 0909 0970 6565 ated();......pee │ │ │ +00049830: 7273 5f65 7261 7365 6428 7374 2e65 7261 rs_erased(st.era │ │ │ +00049840: 7365 6429 3b0a 0909 0909 7d0a 0909 097d sed);.....}....} │ │ │ +00049850: 0a09 0909 656c 7365 0a23 656e 6469 660a ....else.#endif. │ │ │ +00049860: 0909 097b 0a09 0909 0941 4444 5f4f 5554 ...{.....ADD_OUT │ │ │ +00049870: 5354 414e 4449 4e47 5f41 5359 4e43 2822 STANDING_ASYNC(" │ │ │ +00049880: 746f 7272 656e 743a 3a6f 6e5f 7065 6572 torrent::on_peer │ │ │ +00049890: 5f6e 616d 655f 6c6f 6f6b 7570 2229 3b0a _name_lookup");. │ │ │ +000498a0: 0909 0909 6d5f 7365 732e 6765 745f 7265 ....m_ses.get_re │ │ │ +000498b0: 736f 6c76 6572 2829 2e61 7379 6e63 5f72 solver().async_r │ │ │ +000498c0: 6573 6f6c 7665 2869 2e68 6f73 746e 616d esolve(i.hostnam │ │ │ +000498d0: 652c 2061 7578 3a3a 7265 736f 6c76 6572 e, aux::resolver │ │ │ +000498e0: 5f69 6e74 6572 6661 6365 3a3a 6162 6f72 _interface::abor │ │ │ +000498f0: 745f 6f6e 5f73 6875 7464 6f77 6e0a 0909 t_on_shutdown... │ │ │ +00049900: 0909 092c 2073 7464 3a3a 6269 6e64 2826 ..., std::bind(& │ │ │ +00049910: 616d 703b 746f 7272 656e 743a 3a6f 6e5f amp;torrent::on_ │ │ │ +00049920: 7065 6572 5f6e 616d 655f 6c6f 6f6b 7570 peer_name_lookup │ │ │ +00049930: 2c20 7368 6172 6564 5f66 726f 6d5f 7468 , shared_from_th │ │ │ +00049940: 6973 2829 2c20 5f31 2c20 5f32 2c20 692e is(), _1, _2, i. │ │ │ +00049950: 706f 7274 2c20 7629 293b 0a09 0909 7d0a port, v));....}. │ │ │ +00049960: 0909 7d0a 0a23 6966 2054 4f52 5245 4e54 ..}..#if TORRENT │ │ │ +00049970: 5f55 5345 5f49 3250 0a09 0969 6620 2872 _USE_I2P...if (r │ │ │ +00049980: 2e69 3270 636f 6e6e 290a 0909 7b0a 0909 .i2pconn)...{... │ │ │ +00049990: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ +000499a0: 2661 6d70 3b20 6920 3a20 7265 7370 2e69 & i : resp.i │ │ │ +000499b0: 3270 5f70 6565 7273 290a 0909 097b 0a09 2p_peers)....{.. │ │ │ +000499c0: 0909 0961 6464 5f69 3270 5f70 6565 7228 ...add_i2p_peer( │ │ │ +000499d0: 692e 6465 7374 696e 6174 696f 6e2c 2070 i.destination, p │ │ │ +000499e0: 6565 725f 696e 666f 3a3a 7472 6163 6b65 eer_info::tracke │ │ │ +000499f0: 7229 3b0a 0909 097d 0a09 097d 0a23 656e r);....}...}.#en │ │ │ +00049a00: 6469 660a 0a09 092f 2f20 7468 6572 6520 dif....// there │ │ │ +00049a10: 6172 6520 3220 7265 6173 6f6e 7320 746f are 2 reasons to │ │ │ +00049a20: 2061 6c6c 6f77 206c 6f63 616c 2049 5073 allow local IPs │ │ │ +00049a30: 2074 6f20 6265 2072 6574 7572 6e65 6420 to be returned │ │ │ +00049a40: 6672 6f6d 2061 0a09 092f 2f20 6e6f 6e2d from a...// non- │ │ │ +00049a50: 6c6f 6361 6c20 7472 6163 6b65 720a 0909 local tracker... │ │ │ +00049a60: 2f2f 2031 2e20 7265 7472 6163 6b65 7273 // 1. retrackers │ │ │ +00049a70: 2061 7265 2070 6f70 756c 6172 2069 6e20 are popular in │ │ │ +00049a80: 7275 7373 6961 2c20 7768 6572 6520 616e russia, where an │ │ │ +00049a90: 2049 5350 2072 756e 7320 6120 7472 6163 ISP runs a trac │ │ │ +00049aa0: 6b65 7220 7769 7468 696e 0a09 092f 2f20 ker within...// │ │ │ +00049ab0: 2020 2074 6865 2041 5320 2862 7574 206e the AS (but n │ │ │ +00049ac0: 6f74 206f 6e20 7468 6520 6c6f 6361 6c20 ot on the local │ │ │ +00049ad0: 6e65 7477 6f72 6b29 2067 6976 696e 6720 network) giving │ │ │ +00049ae0: 6f75 7420 7065 6572 7320 6f6e 6c79 2066 out peers only f │ │ │ +00049af0: 726f 6d20 7468 650a 0909 2f2f 2020 2020 rom the...// │ │ │ +00049b00: 6c6f 6361 6c20 6e65 7477 6f72 6b0a 3c2f local network.r │ │ │ +00049b40: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00049b50: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00049b80: 746f 7272 656e 742e 6370 703a 3431 3736 torrent.cpp:4176 │ │ │ +00049b90: 3c2f 613e 3c2f 7464 3e3c 7464 3e73 746f sto │ │ │ +00049ba0: 7265 2069 3270 2061 6464 7265 7373 6573 re i2p addresses │ │ │ +00049bb0: 2061 7320 6120 3332 2062 7974 6520 7368 as a 32 byte sh │ │ │ +00049bc0: 6132 3536 2068 6173 6820 696e 2074 6865 a256 hash in the │ │ │ +00049bd0: 2069 3270 5f70 6565 7220 6f62 6a65 6374 i2p_peer object │ │ │ +00049be0: 2c20 7261 7468 6572 2074 6861 6e20 7265 , rather than re │ │ │ +00049bf0: 736f 6c76 696e 6720 6974 2069 6e74 6f20 solving it into │ │ │ +00049c00: 7468 6520 6675 6c6c 2076 6173 6536 3420 the full vase64 │ │ │ +00049c10: 6465 7374 696e 6174 696f 6e2e 2057 6520 destination. We │ │ │ +00049c20: 7368 6f75 6c64 206b 6565 7020 7468 6520 should keep the │ │ │ +00049c30: 6675 6c6c 2064 6573 7469 6e61 7469 6f6e full destination │ │ │ +00049c40: 2061 7320 6120 6361 6368 6520 696e 2074 as a cache in t │ │ │ +00049c50: 6865 2069 3270 5f70 6565 7220 6f62 6a65 he i2p_peer obje │ │ │ +00049c60: 6374 2073 7469 6c6c 2e3c 2f74 643e 3c2f ct still.

    store i2p │ │ │ +00049cc0: 2061 6464 7265 7373 6573 2061 7320 6120 addresses as a │ │ │ +00049cd0: 3332 2062 7974 6520 7368 6132 3536 2068 32 byte sha256 h │ │ │ +00049ce0: 6173 6820 696e 2074 6865 0a69 3270 5f70 ash in the.i2p_p │ │ │ +00049cf0: 6565 7220 6f62 6a65 6374 2c20 7261 7468 eer object, rath │ │ │ +00049d00: 6572 2074 6861 6e20 7265 736f 6c76 696e er than resolvin │ │ │ +00049d10: 6720 6974 2069 6e74 6f20 7468 6520 6675 g it into the fu │ │ │ +00049d20: 6c6c 2076 6173 6536 340a 6465 7374 696e ll vase64.destin │ │ │ +00049d30: 6174 696f 6e2e 2057 6520 7368 6f75 6c64 ation. We should │ │ │ +00049d40: 206b 6565 7020 7468 6520 6675 6c6c 2064 keep the full d │ │ │ +00049d50: 6573 7469 6e61 7469 6f6e 2061 7320 6120 estination as a │ │ │ +00049d60: 6361 6368 6520 696e 2074 6865 0a69 3270 cache in the.i2p │ │ │ +00049d70: 5f70 6565 7220 6f62 6a65 6374 2073 7469 _peer object sti │ │ │ +00049d80: 6c6c 2e3c 2f68 323e 3c68 343e 2e2e 2f73 ll.

    ../s │ │ │ +00049d90: 7263 2f74 6f72 7265 6e74 2e63 7070 3a34 rc/torrent.cpp:4 │ │ │ +00049da0: 3137 363c 2f68 343e 3c70 7265 2073 7479 176

    #ifndef TORREN
    │ │ │ +00049df0: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ +00049e00: 470a 0909 656c 7365 0a09 097b 0a09 0909  G...else...{....
    │ │ │ +00049e10: 6465 6275 675f 6c6f 6728 222a 2a2a 2066  debug_log("*** f
    │ │ │ +00049e20: 6f75 6e64 206e 6f20 7472 6163 6b65 7220  ound no tracker 
    │ │ │ +00049e30: 656e 6470 6f69 6e74 7320 746f 2061 6e6e  endpoints to ann
    │ │ │ +00049e40: 6f75 6e63 6522 293b 0a09 097d 0a23 656e  ounce");...}.#en
    │ │ │ +00049e50: 6469 660a 097d 0a0a 2369 6620 544f 5252  dif..}..#if TORR
    │ │ │ +00049e60: 454e 545f 4142 495f 5645 5253 494f 4e20  ENT_ABI_VERSION 
    │ │ │ +00049e70: 3d3d 2031 0a09 766f 6964 2074 6f72 7265  == 1..void torre
    │ │ │ +00049e80: 6e74 3a3a 7365 745f 7472 6163 6b65 725f  nt::set_tracker_
    │ │ │ +00049e90: 6c6f 6769 6e28 7374 643a 3a73 7472 696e  login(std::strin
    │ │ │ +00049ea0: 6720 636f 6e73 7426 616d 703b 206e 616d  g const& nam
    │ │ │ +00049eb0: 650a 0909 2c20 7374 643a 3a73 7472 696e  e..., std::strin
    │ │ │ +00049ec0: 6720 636f 6e73 7426 616d 703b 2070 7729  g const& pw)
    │ │ │ +00049ed0: 0a09 7b0a 0909 6d5f 7573 6572 6e61 6d65  ..{...m_username
    │ │ │ +00049ee0: 203d 206e 616d 653b 0a09 096d 5f70 6173   = name;...m_pas
    │ │ │ +00049ef0: 7377 6f72 6420 3d20 7077 3b0a 097d 0a23  sword = pw;..}.#
    │ │ │ +00049f00: 656e 6469 660a 0a23 6966 2054 4f52 5245  endif..#if TORRE
    │ │ │ +00049f10: 4e54 5f55 5345 5f49 3250 0a09 766f 6964  NT_USE_I2P..void
    │ │ │ +00049f20: 2074 6f72 7265 6e74 3a3a 6164 645f 6932   torrent::add_i2
    │ │ │ +00049f30: 705f 7065 6572 2873 6861 3235 365f 6861  p_peer(sha256_ha
    │ │ │ +00049f40: 7368 2063 6f6e 7374 2661 6d70 3b20 6465  sh const& de
    │ │ │ +00049f50: 7374 2c20 7065 6572 5f73 6f75 7263 655f  st, peer_source_
    │ │ │ +00049f60: 666c 6167 735f 7420 636f 6e73 7420 736f  flags_t const so
    │ │ │ +00049f70: 7572 6365 290a 097b 0a3c 6469 7620 7374  urce)..{.
    ..i2p_con │ │ │ +00049fb0: 6e65 6374 696f 6e26 616d 703b 2069 3270 nection& i2p │ │ │ +00049fc0: 636f 6e6e 203d 2073 6573 7369 6f6e 2829 conn = session() │ │ │ +00049fd0: 2e69 3270 5f63 6f6e 6e28 293b 0a3c 2f64 .i2p_conn();...if (!i2pcon │ │ │ +00049ff0: 6e2e 6973 5f6f 7065 6e28 2929 2072 6574 n.is_open()) ret │ │ │ +0004a000: 7572 6e3b 0a0a 0909 7374 643a 3a73 7472 urn;....std::str │ │ │ +0004a010: 696e 6720 6465 7374 696e 6174 696f 6e20 ing destination │ │ │ +0004a020: 3d20 6261 7365 3332 656e 636f 6465 5f69 = base32encode_i │ │ │ +0004a030: 3270 2864 6573 7429 3b0a 0909 6465 7374 2p(dest);...dest │ │ │ +0004a040: 696e 6174 696f 6e20 2b3d 2022 2e62 3332 ination += ".b32 │ │ │ +0004a050: 2e69 3270 223b 0a0a 0909 4144 445f 4f55 .i2p";....ADD_OU │ │ │ +0004a060: 5453 5441 4e44 494e 475f 4153 594e 4328 TSTANDING_ASYNC( │ │ │ +0004a070: 2274 6f72 7265 6e74 3a3a 6f6e 5f69 3270 "torrent::on_i2p │ │ │ +0004a080: 5f72 6573 6f6c 7665 2229 3b0a 0909 6932 _resolve");...i2 │ │ │ +0004a090: 7063 6f6e 6e2e 6173 796e 635f 6e61 6d65 pconn.async_name │ │ │ +0004a0a0: 5f6c 6f6f 6b75 7028 6465 7374 696e 6174 _lookup(destinat │ │ │ +0004a0b0: 696f 6e2e 635f 7374 7228 290a 0909 092c ion.c_str()...., │ │ │ +0004a0c0: 205b 7365 6c66 203d 2073 6861 7265 645f [self = shared_ │ │ │ +0004a0d0: 6672 6f6d 5f74 6869 7328 292c 2073 6f75 from_this(), sou │ │ │ +0004a0e0: 7263 655d 2028 6572 726f 725f 636f 6465 rce] (error_code │ │ │ +0004a0f0: 2063 6f6e 7374 2661 6d70 3b20 6563 2c20 const& ec, │ │ │ +0004a100: 6368 6172 2063 6f6e 7374 2a20 6429 0a09 char const* d).. │ │ │ +0004a110: 0909 7b20 7365 6c66 2d26 6774 3b74 6f72 ..{ self->tor │ │ │ +0004a120: 7265 6e74 3a3a 6f6e 5f69 3270 5f72 6573 rent::on_i2p_res │ │ │ +0004a130: 6f6c 7665 2865 632c 2064 2c20 736f 7572 olve(ec, d, sour │ │ │ +0004a140: 6365 293b 207d 293b 0a09 7d0a 0a09 766f ce); });..}...vo │ │ │ +0004a150: 6964 2074 6f72 7265 6e74 3a3a 6f6e 5f69 id torrent::on_i │ │ │ +0004a160: 3270 5f72 6573 6f6c 7665 2865 7272 6f72 2p_resolve(error │ │ │ +0004a170: 5f63 6f64 6520 636f 6e73 7426 616d 703b _code const& │ │ │ +0004a180: 2065 632c 2063 6861 7220 636f 6e73 742a ec, char const* │ │ │ +0004a190: 2064 6573 742c 2070 6565 725f 736f 7572 dest, peer_sour │ │ │ +0004a1a0: 6365 5f66 6c61 6773 5f74 2063 6f6e 7374 ce_flags_t const │ │ │ +0004a1b0: 2073 6f75 7263 6529 2074 7279 0a09 7b0a source) try..{. │ │ │ +0004a1c0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0004a1d0: 2869 735f 7369 6e67 6c65 5f74 6872 6561 (is_single_threa │ │ │ +0004a1e0: 6428 2929 3b0a 0a09 0949 4e56 4152 4941 d());....INVARIA │ │ │ +0004a1f0: 4e54 5f43 4845 434b 3b0a 0a09 0943 4f4d NT_CHECK;....COM │ │ │ +0004a200: 504c 4554 455f 4153 594e 4328 2274 6f72 PLETE_ASYNC("tor │ │ │ +0004a210: 7265 6e74 3a3a 6f6e 5f69 3270 5f72 6573 rent::on_i2p_res │ │ │ +0004a220: 6f6c 7665 2229 3b0a 2369 666e 6465 6620 olve");.#ifndef │ │ │ +0004a230: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +0004a240: 4c4f 4747 494e 470a 0909 6966 2028 6563 LOGGING...if (ec │ │ │ +0004a250: 2026 616d 703b 2661 6d70 3b20 7368 6f75 && shou │ │ │ +0004a260: 6c64 5f6c 6f67 2829 290a 0909 0964 6562 ld_log())....deb │ │ │ +0004a270: 7567 5f6c 6f67 2822 6932 705f 7265 736f ug_log("i2p_reso │ │ │ +0004a280: 6c76 6520 6572 726f 723a 2025 7322 2c20 lve error: %s", │ │ │ +0004a290: 6563 2e6d 6573 7361 6765 2829 2e63 5f73 ec.message().c_s │ │ │ +0004a2a0: 7472 2829 293b 0a23 656e 6469 660a 0909 tr());.#endif... │ │ │ +0004a2b0: 6966 2028 6563 207c 7c20 6d5f 6162 6f72 if (ec || m_abor │ │ │ +0004a2c0: 7420 7c7c 206d 5f73 6573 2e69 735f 6162 t || m_ses.is_ab │ │ │ +0004a2d0: 6f72 7465 6428 2929 2072 6574 7572 6e3b orted()) return; │ │ │ +0004a2e0: 0a0a 0909 6e65 6564 5f70 6565 725f 6c69 ....need_peer_li │ │ │ +0004a2f0: 7374 2829 3b0a 0909 746f 7272 656e 745f st();...torrent_ │ │ │ +0004a300: 7374 6174 6520 7374 203d 2067 6574 5f70 state st = get_p │ │ │ +0004a310: 6565 725f 6c69 7374 5f73 7461 7465 2829 eer_list_state() │ │ │ +0004a320: 3b0a 0909 6966 2028 6d5f 7065 6572 5f6c ;...if (m_peer_l │ │ │ +0004a330: 6973 742d 2667 743b 6164 645f 6932 705f ist->add_i2p_ │ │ │ +0004a340: 7065 6572 2864 6573 742c 2073 6f75 7263 peer(dest, sourc │ │ │ +0004a350: 652c 207b 7d2c 2026 616d 703b 7374 2929 e, {}, &st)) │ │ │ +0004a360: 0a09 0909 7374 6174 655f 7570 6461 7465 ....state_update │ │ │ +0004a370: 6428 293b 0a09 0970 6565 7273 5f65 7261 d();...peers_era │ │ │ +0004a380: 7365 6428 7374 2e65 7261 7365 6429 3b0a sed(st.erased);. │ │ │ +0004a390: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0004a3d0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +0004a400: 7263 2f74 6f72 7265 6e74 2e63 7070 3a34 rc/torrent.cpp:4 │ │ │ +0004a410: 3233 333c 2f61 3e3c 2f74 643e 3c74 643e 233 │ │ │ +0004a420: 6164 6420 6f6e 6520 7065 6572 2070 6572 add one peer per │ │ │ +0004a430: 2049 5020 7468 6520 686f 7374 6e61 6d65 IP the hostname │ │ │ +0004a440: 2072 6573 6f6c 7665 7320 746f 3c2f 7464 resolves to

    add on │ │ │ +0004a4a0: 6520 7065 6572 2070 6572 2049 5020 7468 e peer per IP th │ │ │ +0004a4b0: 6520 686f 7374 6e61 6d65 2072 6573 6f6c e hostname resol │ │ │ +0004a4c0: 7665 7320 746f 3c2f 6832 3e3c 6834 3e2e ves to

    . │ │ │ +0004a4d0: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +0004a4e0: 703a 3432 3333 3c2f 6834 3e3c 7072 6520 p:4233

    .catch (...
    │ │ │ +0004a530: 2920 7b20 6861 6e64 6c65 5f65 7863 6570  ) { handle_excep
    │ │ │ +0004a540: 7469 6f6e 2829 3b20 7d0a 2365 6e64 6966  tion(); }.#endif
    │ │ │ +0004a550: 0a0a 0976 6f69 6420 746f 7272 656e 743a  ...void torrent:
    │ │ │ +0004a560: 3a6f 6e5f 7065 6572 5f6e 616d 655f 6c6f  :on_peer_name_lo
    │ │ │ +0004a570: 6f6b 7570 2865 7272 6f72 5f63 6f64 6520  okup(error_code 
    │ │ │ +0004a580: 636f 6e73 7426 616d 703b 2065 0a09 092c  const& e...,
    │ │ │ +0004a590: 2073 7464 3a3a 7665 6374 6f72 266c 743b   std::vector<
    │ │ │ +0004a5a0: 6164 6472 6573 7326 6774 3b20 636f 6e73  address> cons
    │ │ │ +0004a5b0: 7426 616d 703b 2068 6f73 745f 6c69 7374  t& host_list
    │ │ │ +0004a5c0: 2c20 696e 7420 636f 6e73 7420 706f 7274  , int const port
    │ │ │ +0004a5d0: 0a09 092c 2070 726f 746f 636f 6c5f 7665  ..., protocol_ve
    │ │ │ +0004a5e0: 7273 696f 6e20 636f 6e73 7420 7629 2074  rsion const v) t
    │ │ │ +0004a5f0: 7279 0a09 7b0a 0909 544f 5252 454e 545f  ry..{...TORRENT_
    │ │ │ +0004a600: 4153 5345 5254 2869 735f 7369 6e67 6c65  ASSERT(is_single
    │ │ │ +0004a610: 5f74 6872 6561 6428 2929 3b0a 0a09 0949  _thread());....I
    │ │ │ +0004a620: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a  NVARIANT_CHECK;.
    │ │ │ +0004a630: 0a09 0943 4f4d 504c 4554 455f 4153 594e  ...COMPLETE_ASYN
    │ │ │ +0004a640: 4328 2274 6f72 7265 6e74 3a3a 6f6e 5f70  C("torrent::on_p
    │ │ │ +0004a650: 6565 725f 6e61 6d65 5f6c 6f6f 6b75 7022  eer_name_lookup"
    │ │ │ +0004a660: 293b 0a0a 2369 666e 6465 6620 544f 5252  );..#ifndef TORR
    │ │ │ +0004a670: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ +0004a680: 494e 470a 0909 6966 2028 6520 2661 6d70  ING...if (e &
    │ │ │ +0004a690: 3b26 616d 703b 2073 686f 756c 645f 6c6f  ;& should_lo
    │ │ │ +0004a6a0: 6728 2929 0a09 0909 6465 6275 675f 6c6f  g())....debug_lo
    │ │ │ +0004a6b0: 6728 2270 6565 7220 6e61 6d65 206c 6f6f  g("peer name loo
    │ │ │ +0004a6c0: 6b75 7020 6572 726f 723a 2025 7322 2c20  kup error: %s", 
    │ │ │ +0004a6d0: 652e 6d65 7373 6167 6528 292e 635f 7374  e.message().c_st
    │ │ │ +0004a6e0: 7228 2929 3b0a 2365 6e64 6966 0a0a 0909  r());.#endif....
    │ │ │ +0004a6f0: 6966 2028 6520 7c7c 206d 5f61 626f 7274  if (e || m_abort
    │ │ │ +0004a700: 207c 7c20 686f 7374 5f6c 6973 742e 656d   || host_list.em
    │ │ │ +0004a710: 7074 7928 2920 7c7c 206d 5f73 6573 2e69  pty() || m_ses.i
    │ │ │ +0004a720: 735f 6162 6f72 7465 6428 2929 2072 6574  s_aborted()) ret
    │ │ │ +0004a730: 7572 6e3b 0a0a 3c64 6976 2073 7479 6c65  urn;..
    ..tcp::endpo │ │ │ +0004a770: 696e 7420 686f 7374 2868 6f73 745f 6c69 int host(host_li │ │ │ +0004a780: 7374 2e66 726f 6e74 2829 2c20 7374 643a st.front(), std: │ │ │ +0004a790: 3a75 696e 7431 365f 7428 706f 7274 2929 :uint16_t(port)) │ │ │ +0004a7a0: 3b0a 3c2f 6469 763e 0a09 0969 6620 286d ;.
    ...if (m │ │ │ +0004a7b0: 5f69 705f 6669 6c74 6572 2026 616d 703b _ip_filter & │ │ │ +0004a7c0: 2661 6d70 3b20 6d5f 6970 5f66 696c 7465 & m_ip_filte │ │ │ +0004a7d0: 722d 2667 743b 6163 6365 7373 2868 6f73 r->access(hos │ │ │ +0004a7e0: 742e 6164 6472 6573 7328 2929 2026 616d t.address()) &am │ │ │ +0004a7f0: 703b 2069 705f 6669 6c74 6572 3a3a 626c p; ip_filter::bl │ │ │ +0004a800: 6f63 6b65 6429 0a09 097b 0a23 6966 6e64 ocked)...{.#ifnd │ │ │ +0004a810: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ +0004a820: 4c45 5f4c 4f47 4749 4e47 0a09 0909 6966 LE_LOGGING....if │ │ │ +0004a830: 2028 7368 6f75 6c64 5f6c 6f67 2829 290a (should_log()). │ │ │ +0004a840: 0909 097b 0a09 0909 0964 6562 7567 5f6c ...{.....debug_l │ │ │ +0004a850: 6f67 2822 626c 6f63 6b65 6420 6970 2066 og("blocked ip f │ │ │ +0004a860: 726f 6d20 7472 6163 6b65 723a 2025 7322 rom tracker: %s" │ │ │ +0004a870: 2c20 686f 7374 2e61 6464 7265 7373 2829 , host.address() │ │ │ +0004a880: 2e74 6f5f 7374 7269 6e67 2829 2e63 5f73 .to_string().c_s │ │ │ +0004a890: 7472 2829 293b 0a09 0909 7d0a 2365 6e64 tr());....}.#end │ │ │ +0004a8a0: 6966 0a09 0909 6966 2028 6d5f 7365 732e if....if (m_ses. │ │ │ +0004a8b0: 616c 6572 7473 2829 2e73 686f 756c 645f alerts().should_ │ │ │ +0004a8c0: 706f 7374 266c 743b 7065 6572 5f62 6c6f post<peer_blo │ │ │ +0004a8d0: 636b 6564 5f61 6c65 7274 2667 743b 2829 cked_alert>() │ │ │ +0004a8e0: 290a 0909 0909 6d5f 7365 732e 616c 6572 ).....m_ses.aler │ │ │ +0004a8f0: 7473 2829 2e65 6d70 6c61 6365 5f61 6c65 ts().emplace_ale │ │ │ +0004a900: 7274 266c 743b 7065 6572 5f62 6c6f 636b rt<peer_block │ │ │ +0004a910: 6564 5f61 6c65 7274 2667 743b 2867 6574 ed_alert>(get │ │ │ +0004a920: 5f68 616e 646c 6528 290a 0909 0909 092c _handle()......, │ │ │ +0004a930: 2068 6f73 742c 2070 6565 725f 626c 6f63 host, peer_bloc │ │ │ +0004a940: 6b65 645f 616c 6572 743a 3a69 705f 6669 ked_alert::ip_fi │ │ │ +0004a950: 6c74 6572 293b 0a09 0909 7265 7475 726e lter);....return │ │ │ +0004a960: 3b0a 0909 7d0a 0a09 0969 6620 2861 6464 ;...}....if (add │ │ │ +0004a970: 5f70 6565 7228 686f 7374 2c20 7065 6572 _peer(host, peer │ │ │ +0004a980: 5f69 6e66 6f3a 3a74 7261 636b 6572 2c20 _info::tracker, │ │ │ +0004a990: 7620 3d3d 2070 726f 746f 636f 6c5f 7665 v == protocol_ve │ │ │ +0004a9a0: 7273 696f 6e3a 3a56 3220 3f20 7065 785f rsion::V2 ? pex_ │ │ │ +0004a9b0: 6c74 5f76 3220 3a20 7065 785f 666c 6167 lt_v2 : pex_flag │ │ │ +0004a9c0: 735f 7428 3029 2929 0a09 097b 0a09 0909 s_t(0)))...{.... │ │ │ +0004a9d0: 7374 6174 655f 7570 6461 7465 6428 293b state_updated(); │ │ │ +0004a9e0: 0a0a 2369 666e 6465 6620 544f 5252 454e ..#ifndef TORREN │ │ │ +0004a9f0: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ +0004aa00: 470a 0909 0969 6620 2873 686f 756c 645f G....if (should_ │ │ │ +0004aa10: 6c6f 6728 2929 0a09 0909 7b0a 0909 0909 log())....{..... │ │ │ +0004aa20: 6465 6275 675f 6c6f 6728 226e 616d 652d debug_log("name- │ │ │ +0004aa30: 6c6f 6f6b 7570 2061 6464 5f70 6565 7228 lookup add_peer( │ │ │ +0004aa40: 2920 5b20 2573 205d 2063 6f6e 6e65 6374 ) [ %s ] connect │ │ │ +0004aa50: 2d63 616e 6469 6461 7465 733a 2025 6422 -candidates: %d" │ │ │ +0004aa60: 0a09 0909 0909 2c20 686f 7374 2e61 6464 ......, host.add │ │ │ +0004aa70: 7265 7373 2829 2e74 6f5f 7374 7269 6e67 ress().to_string │ │ │ +0004aa80: 2829 2e63 5f73 7472 2829 0a09 0909 0909 ().c_str()...... │ │ │ +0004aa90: 2c20 6d5f 7065 6572 5f6c 6973 7420 3f20 , m_peer_list ? │ │ │ +0004aaa0: 6d5f 7065 6572 5f6c 6973 742d 2667 743b m_peer_list-> │ │ │ +0004aab0: 6e75 6d5f 636f 6e6e 6563 745f 6361 6e64 num_connect_cand │ │ │ +0004aac0: 6964 6174 6573 2829 203a 202d 3129 3b0a idates() : -1);. │ │ │ +0004aad0: 0909 097d 0a23 656e 6469 660a 0909 7d0a ...}.#endif...}. │ │ │ +0004aae0: 0909 7570 6461 7465 5f77 616e 745f 7065 ..update_want_pe │ │ │ +0004aaf0: 6572 7328 293b 0a09 7d0a 3c2f 7072 653e ers();..}.
    │ │ │ +0004ab00: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0004ab30: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0004ab40: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ +0004ab70: 656e 742e 6370 703a 3439 3531 3c2f 613e ent.cpp:4951 │ │ │ +0004ab80: 3c2f 7464 3e3c 7464 3e6f 6e6c 7920 646f only do │ │ │ +0004ab90: 2074 6869 7320 6966 2074 6865 2070 6965 this if the pie │ │ │ +0004aba0: 6365 2073 697a 6520 3e20 3120 626c 6f63 ce size > 1 bloc │ │ │ +0004abb0: 6b73 2054 6869 7320 6973 2061 2076 3220 ks This is a v2 │ │ │ +0004abc0: 746f 7272 656e 7420 736f 2077 6520 6361 torrent so we ca │ │ │ +0004abd0: 6e20 7265 7175 6573 7420 6765 7420 626c n request get bl │ │ │ +0004abe0: 6f63 6b20 6c65 7665 6c20 6861 7368 6573 ock level hashes │ │ │ +0004abf0: 2e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 .

    o │ │ │ +0004ac40: 6e6c 7920 646f 2074 6869 7320 6966 2074 nly do this if t │ │ │ +0004ac50: 6865 2070 6965 6365 2073 697a 6520 3e20 he piece size > │ │ │ +0004ac60: 3120 626c 6f63 6b73 0a54 6869 7320 6973 1 blocks.This is │ │ │ +0004ac70: 2061 2076 3220 746f 7272 656e 7420 736f a v2 torrent so │ │ │ +0004ac80: 2077 6520 6361 6e20 7265 7175 6573 7420 we can request │ │ │ +0004ac90: 6765 7420 626c 6f63 6b0a 6c65 7665 6c20 get block.level │ │ │ +0004aca0: 6861 7368 6573 2e3c 2f68 323e 3c68 343e hashes.

    │ │ │ +0004acb0: 2e2e 2f73 7263 2f74 6f72 7265 6e74 2e63 ../src/torrent.c │ │ │ +0004acc0: 7070 3a34 3935 313c 2f68 343e 3c70 7265 pp:4951

    ..{....std
    │ │ │ +0004ad10: 3a3a 7365 7426 6c74 3b74 6f72 7265 6e74  ::set<torrent
    │ │ │ +0004ad20: 5f70 6565 722a 2667 743b 2072 6574 3b0a  _peer*> ret;.
    │ │ │ +0004ad30: 0909 0969 6620 2821 626c 6f63 6b73 2e65  ...if (!blocks.e
    │ │ │ +0004ad40: 6d70 7479 2829 2026 616d 703b 2661 6d70  mpty() &&
    │ │ │ +0004ad50: 3b20 2164 6f77 6e6c 6f61 6465 7273 2e65  ; !downloaders.e
    │ │ │ +0004ad60: 6d70 7479 2829 290a 0909 097b 0a09 0909  mpty())....{....
    │ │ │ +0004ad70: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ +0004ad80: 2062 203a 2062 6c6f 636b 7329 2072 6574   b : blocks) ret
    │ │ │ +0004ad90: 2e69 6e73 6572 7428 646f 776e 6c6f 6164  .insert(download
    │ │ │ +0004ada0: 6572 735b 7374 643a 3a73 697a 655f 7428  ers[std::size_t(
    │ │ │ +0004adb0: 6229 5d29 3b0a 0909 097d 0a09 0909 656c  b)]);....}....el
    │ │ │ +0004adc0: 7365 0a09 0909 7b0a 0909 0909 7374 643a  se....{.....std:
    │ │ │ +0004add0: 3a63 6f70 7928 646f 776e 6c6f 6164 6572  :copy(downloader
    │ │ │ +0004ade0: 732e 6265 6769 6e28 292c 2064 6f77 6e6c  s.begin(), downl
    │ │ │ +0004adf0: 6f61 6465 7273 2e65 6e64 2829 2c20 7374  oaders.end(), st
    │ │ │ +0004ae00: 643a 3a69 6e73 6572 7465 7228 7265 742c  d::inserter(ret,
    │ │ │ +0004ae10: 2072 6574 2e62 6567 696e 2829 2929 3b0a   ret.begin()));.
    │ │ │ +0004ae20: 0909 097d 0a09 0909 7265 7475 726e 2072  ...}....return r
    │ │ │ +0004ae30: 6574 3b0a 0909 7d28 293b 0a0a 0909 2f2f  et;...}();....//
    │ │ │ +0004ae40: 2069 6620 7468 6973 2070 6965 6365 2077   if this piece w
    │ │ │ +0004ae50: 6173 6e27 7420 646f 776e 6c6f 6164 6564  asn't downloaded
    │ │ │ +0004ae60: 2066 726f 6d20 7065 6572 732c 2077 6520   from peers, we 
    │ │ │ +0004ae70: 6a75 7374 2066 6f75 6e64 2069 7420 6f6e  just found it on
    │ │ │ +0004ae80: 2064 6973 6b2e 0a09 092f 2f20 496e 2074   disk....// In t
    │ │ │ +0004ae90: 6861 7420 6361 7365 2c20 7765 2073 686f  hat case, we sho
    │ │ │ +0004aea0: 756c 6420 6a75 7374 2063 6f6e 7369 6465  uld just conside
    │ │ │ +0004aeb0: 7220 6974 2061 7320 226e 6f74 2d68 6176  r it as "not-hav
    │ │ │ +0004aec0: 6522 2061 6e64 2074 6865 7265 2773 206e  e" and there's n
    │ │ │ +0004aed0: 6f0a 0909 2f2f 206e 6565 6420 746f 2074  o...// need to t
    │ │ │ +0004aee0: 7279 2074 6f20 6765 7420 6869 6768 6572  ry to get higher
    │ │ │ +0004aef0: 2066 6964 656c 6974 7920 6861 7368 6573   fidelity hashes
    │ │ │ +0004af00: 2028 7965 7429 0a09 0962 6f6f 6c20 636f   (yet)...bool co
    │ │ │ +0004af10: 6e73 7420 666f 756e 645f 6f6e 5f64 6973  nst found_on_dis
    │ │ │ +0004af20: 6b20 3d20 7065 6572 732e 7369 7a65 2829  k = peers.size()
    │ │ │ +0004af30: 203d 3d20 3120 2661 6d70 3b26 616d 703b   == 1 &&
    │ │ │ +0004af40: 2070 6565 7273 2e63 6f75 6e74 286e 756c   peers.count(nul
    │ │ │ +0004af50: 6c70 7472 293b 0a0a 0909 6966 2028 746f  lptr);....if (to
    │ │ │ +0004af60: 7272 656e 745f 6669 6c65 2829 2e69 6e66  rrent_file().inf
    │ │ │ +0004af70: 6f5f 6861 7368 6573 2829 2e68 6173 5f76  o_hashes().has_v
    │ │ │ +0004af80: 3228 2920 2661 6d70 3b26 616d 703b 2062  2() && b
    │ │ │ +0004af90: 6c6f 636b 732e 656d 7074 7928 2920 2661  locks.empty() &a
    │ │ │ +0004afa0: 6d70 3b26 616d 703b 2021 666f 756e 645f  mp;& !found_
    │ │ │ +0004afb0: 6f6e 5f64 6973 6b29 0a09 097b 0a3c 6469  on_disk)...{....ve
    │ │ │ +0004aff0: 7269 6679 5f62 6c6f 636b 5f68 6173 6865  rify_block_hashe
    │ │ │ +0004b000: 7328 696e 6465 7829 3b0a 3c2f 6469 763e  s(index);.
    │ │ │ +0004b010: 0909 7d0a 0a09 092f 2f20 7468 6520 6265 ..}....// the be │ │ │ +0004b020: 6c6f 7720 636f 6465 2069 7320 7065 6e61 low code is pena │ │ │ +0004b030: 6c69 7a69 6e67 2070 6565 7273 2074 6861 lizing peers tha │ │ │ +0004b040: 7420 7365 6e74 2075 7365 2062 6164 2064 t sent use bad d │ │ │ +0004b050: 6174 612e 0a09 092f 2f20 696e 6372 6561 ata....// increa │ │ │ +0004b060: 7365 2074 6865 2074 6f74 616c 2061 6d6f se the total amo │ │ │ +0004b070: 756e 7420 6f66 2066 6169 6c65 6420 6279 unt of failed by │ │ │ +0004b080: 7465 730a 0909 6966 2028 2166 6f75 6e64 tes...if (!found │ │ │ +0004b090: 5f6f 6e5f 6469 736b 290a 0909 7b0a 0909 _on_disk)...{... │ │ │ +0004b0a0: 0969 6620 2862 6c6f 636b 732e 656d 7074 .if (blocks.empt │ │ │ +0004b0b0: 7928 2929 0a09 0909 0961 6464 5f66 6169 y()).....add_fai │ │ │ +0004b0c0: 6c65 645f 6279 7465 7328 6d5f 746f 7272 led_bytes(m_torr │ │ │ +0004b0d0: 656e 745f 6669 6c65 2d26 6774 3b70 6965 ent_file->pie │ │ │ +0004b0e0: 6365 5f73 697a 6528 696e 6465 7829 293b ce_size(index)); │ │ │ +0004b0f0: 0a09 0909 656c 7365 0a09 0909 0961 6464 ....else.....add │ │ │ +0004b100: 5f66 6169 6c65 645f 6279 7465 7328 7374 _failed_bytes(st │ │ │ +0004b110: 6174 6963 5f63 6173 7426 6c74 3b69 6e74 atic_cast<int │ │ │ +0004b120: 2667 743b 2862 6c6f 636b 732e 7369 7a65 >(blocks.size │ │ │ +0004b130: 2829 2920 2a20 6465 6661 756c 745f 626c ()) * default_bl │ │ │ +0004b140: 6f63 6b5f 7369 7a65 293b 0a0a 2369 666e ock_size);..#ifn │ │ │ +0004b150: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +0004b160: 424c 455f 4558 5445 4e53 494f 4e53 0a09 BLE_EXTENSIONS.. │ │ │ +0004b170: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ +0004b180: 2065 7874 203a 206d 5f65 7874 656e 7369 ext : m_extensi │ │ │ +0004b190: 6f6e 7329 0a09 0909 7b0a 0909 0909 6578 ons)....{.....ex │ │ │ +0004b1a0: 742d 2667 743b 6f6e 5f70 6965 6365 5f66 t->on_piece_f │ │ │ +0004b1b0: 6169 6c65 6428 696e 6465 7829 3b0a 0909 ailed(index);... │ │ │ +0004b1c0: 097d 0a23 656e 6469 660a 0a09 0909 2f2f .}.#endif.....// │ │ │ +0004b1d0: 2064 6964 2077 6520 7265 6365 6976 6520 did we receive │ │ │ +0004b1e0: 7468 6973 2070 6965 6365 2066 726f 6d20 this piece from │ │ │ +0004b1f0: 6120 7369 6e67 6c65 2070 6565 723f 0a09 a single peer?.. │ │ │ +0004b200: 0909 2f2f 2069 6620 7765 206b 6e6f 7720 ..// if we know │ │ │ +0004b210: 6578 6163 746c 7920 7768 6963 6820 626c exactly which bl │ │ │ +0004b220: 6f63 6b73 2066 6169 6c65 6420 7468 6520 ocks failed the │ │ │ +0004b230: 6861 7368 2c20 7765 2063 616e 2061 6c73 hash, we can als │ │ │ +0004b240: 6f20 6265 2063 6572 7461 696e 0a09 0909 o be certain.... │ │ │ +0004b250: 2f2f 2074 6861 7420 616c 6c20 7065 6572 // that all peer │ │ │ +0004b260: 7320 696e 2074 6865 206c 6973 7420 7365 s in the list se │ │ │ +0004b270: 6e74 2075 7320 6261 6420 6461 7461 0a09 nt us bad data.. │ │ │ +0004b280: 0909 626f 6f6c 2063 6f6e 7374 206b 6e6f ..bool const kno │ │ │ +0004b290: 776e 5f62 6164 5f70 6565 7220 3d20 7065 wn_bad_peer = pe │ │ │ +0004b2a0: 6572 732e 7369 7a65 2829 203d 3d20 3120 ers.size() == 1 │ │ │ +0004b2b0: 7c7c 2021 626c 6f63 6b73 2e65 6d70 7479 || !blocks.empty │ │ │ +0004b2c0: 2829 3b0a 0a09 0909 7065 6e61 6c69 7a65 ();.....penalize │ │ │ +0004b2d0: 5f70 6565 7273 2870 6565 7273 2c20 696e _peers(peers, in │ │ │ +0004b2e0: 6465 782c 206b 6e6f 776e 5f62 6164 5f70 dex, known_bad_p │ │ │ +0004b2f0: 6565 7229 3b0a 0909 7d0a 0a09 092f 2f20 eer);...}....// │ │ │ +0004b300: 4966 206d 5f73 746f 7261 6765 2069 736e If m_storage isn │ │ │ +0004b310: 2774 2073 6574 2068 6572 652c 2069 7420 't set here, it │ │ │ +0004b320: 6d65 616e 7320 7765 2772 6520 7368 7574 means we're shut │ │ │ +0004b330: 7469 6e67 2064 6f77 6e0a 0909 6966 2028 ting down...if ( │ │ │ +0004b340: 6d5f 7374 6f72 6167 6529 0a09 097b 0a09 m_storage)...{.. │ │ │ +0004b350: 0909 2f2f 2069 7420 646f 6573 6e27 7420 ..// it doesn't │ │ │ +0004b360: 6d61 6b65 206d 7563 6820 7365 6e73 6520 make much sense │ │ │ +0004b370: 746f 2066 6169 6c20 746f 2068 6173 6820 to fail to hash │ │ │ +0004b380: 6120 7069 6563 650a 3c2f 7072 653e 3c2f a piece.
    relevan │ │ │ +0004b3c0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ +0004b400: 742e 6370 703a 3739 3037 3c2f 613e 3c2f t.cpp:7907come up w │ │ │ +0004b420: 6974 6820 6120 6265 7474 6572 2077 6179 ith a better way │ │ │ +0004b430: 206f 6620 646f 696e 6720 7468 6973 2c20 of doing this, │ │ │ +0004b440: 696e 7374 6561 6420 6f66 2061 6e20 696d instead of an im │ │ │ +0004b450: 6d65 6469 6174 656c 7920 696e 766f 6b65 mediately invoke │ │ │ +0004b460: 6420 6c61 6d62 6461 2065 7870 7265 7373 d lambda express │ │ │ +0004b470: 696f 6e2e 3c2f 7464 3e3c 2f74 723e 3c74 ion.come up with a │ │ │ +0004b4d0: 2062 6574 7465 7220 7761 7920 6f66 2064 better way of d │ │ │ +0004b4e0: 6f69 6e67 2074 6869 732c 2069 6e73 7465 oing this, inste │ │ │ +0004b4f0: 6164 206f 6620 616e 0a69 6d6d 6564 6961 ad of an.immedia │ │ │ +0004b500: 7465 6c79 2069 6e76 6f6b 6564 206c 616d tely invoked lam │ │ │ +0004b510: 6264 6120 6578 7072 6573 7369 6f6e 2e3c bda expression.< │ │ │ +0004b520: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ +0004b530: 6f72 7265 6e74 2e63 7070 3a37 3930 373c orrent.cpp:7907< │ │ │ +0004b540: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0004b580: 0909 097c 7c20 7065 6572 696e 666f 2d26  ...|| peerinfo-&
    │ │ │ +0004b590: 6774 3b63 6f6e 6669 726d 6564 5f73 7570  gt;confirmed_sup
    │ │ │ +0004b5a0: 706f 7274 735f 7574 7029 290a 0909 097b  ports_utp))....{
    │ │ │ +0004b5b0: 0a09 0909 0973 6d20 3d20 6d5f 7365 732e  .....sm = m_ses.
    │ │ │ +0004b5c0: 7574 705f 736f 636b 6574 5f6d 616e 6167  utp_socket_manag
    │ │ │ +0004b5d0: 6572 2829 3b0a 0909 097d 0a0a 0909 092f  er();....}...../
    │ │ │ +0004b5e0: 2f20 646f 6e27 7420 6d61 6b65 2061 2054  / don't make a T
    │ │ │ +0004b5f0: 4350 2063 6f6e 6e65 6374 696f 6e20 6966  CP connection if
    │ │ │ +0004b600: 2069 7427 7320 6469 7361 626c 6564 0a09   it's disabled..
    │ │ │ +0004b610: 0909 6966 2028 736d 203d 3d20 6e75 6c6c  ..if (sm == null
    │ │ │ +0004b620: 7074 7220 2661 6d70 3b26 616d 703b 2021  ptr && !
    │ │ │ +0004b630: 7365 7474 696e 6773 2829 2e67 6574 5f62  settings().get_b
    │ │ │ +0004b640: 6f6f 6c28 7365 7474 696e 6773 5f70 6163  ool(settings_pac
    │ │ │ +0004b650: 6b3a 3a65 6e61 626c 655f 6f75 7467 6f69  k::enable_outgoi
    │ │ │ +0004b660: 6e67 5f74 6370 2929 0a09 0909 7b0a 2369  ng_tcp))....{.#i
    │ │ │ +0004b670: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ +0004b680: 5341 424c 455f 4c4f 4747 494e 470a 0909  SABLE_LOGGING...
    │ │ │ +0004b690: 0909 6966 2028 7368 6f75 6c64 5f6c 6f67  ..if (should_log
    │ │ │ +0004b6a0: 2829 290a 0909 0909 7b0a 0909 0909 0964  ()).....{......d
    │ │ │ +0004b6b0: 6562 7567 5f6c 6f67 2822 6469 7363 6172  ebug_log("discar
    │ │ │ +0004b6c0: 6469 6e67 2070 6565 7220 5c22 2573 5c22  ding peer \"%s\"
    │ │ │ +0004b6d0: 3a20 5443 5020 636f 6e6e 6563 7469 6f6e  : TCP connection
    │ │ │ +0004b6e0: 7320 6469 7361 626c 6564 2022 0a09 0909  s disabled "....
    │ │ │ +0004b6f0: 0909 0922 5b20 7375 7070 6f72 7473 2d75  ..."[ supports-u
    │ │ │ +0004b700: 7470 3a20 2564 205d 222c 2070 6565 7269  tp: %d ]", peeri
    │ │ │ +0004b710: 6e66 6f2d 2667 743b 746f 5f73 7472 696e  nfo->to_strin
    │ │ │ +0004b720: 6728 292e 635f 7374 7228 290a 0909 0909  g().c_str().....
    │ │ │ +0004b730: 0909 2c20 7065 6572 696e 666f 2d26 6774  .., peerinfo->
    │ │ │ +0004b740: 3b73 7570 706f 7274 735f 7574 7029 3b0a  ;supports_utp);.
    │ │ │ +0004b750: 0909 0909 7d0a 2365 6e64 6966 0a09 0909  ....}.#endif....
    │ │ │ +0004b760: 0972 6574 7572 6e20 6661 6c73 653b 0a09  .return false;..
    │ │ │ +0004b770: 0909 7d0a 0909 7d0a 0a3c 6469 7620 7374  ..}...}..
    ..aux::so │ │ │ +0004b7b0: 636b 6574 5f74 7970 6520 7320 3d20 5b26 cket_type s = [& │ │ │ +0004b7c0: 616d 703b 5d20 7b0a 3c2f 6469 763e 0a23 amp;] {.
    .# │ │ │ +0004b7d0: 6966 2054 4f52 5245 4e54 5f55 5345 5f49 if TORRENT_USE_I │ │ │ +0004b7e0: 3250 0a09 0969 6620 2870 6565 7269 6e66 2P...if (peerinf │ │ │ +0004b7f0: 6f2d 2667 743b 6973 5f69 3270 5f61 6464 o->is_i2p_add │ │ │ +0004b800: 7229 0a09 097b 0a09 0909 2f2f 2049 7427 r)...{....// It' │ │ │ +0004b810: 7320 6e6f 7420 656e 7469 7265 6c79 206f s not entirely o │ │ │ +0004b820: 6276 696f 7573 2077 6879 2074 6869 7320 bvious why this │ │ │ +0004b830: 7065 6572 2063 6f6e 6e65 6374 696f 6e20 peer connection │ │ │ +0004b840: 6973 206e 6f74 206d 6172 6b65 6420 6173 is not marked as │ │ │ +0004b850: 0a09 0909 2f2f 206f 6e65 2e20 5468 6520 ....// one. The │ │ │ +0004b860: 6d61 696e 2066 6561 7475 7265 206f 6620 main feature of │ │ │ +0004b870: 6120 7065 6572 2063 6f6e 6e65 6374 696f a peer connectio │ │ │ +0004b880: 6e20 6973 2074 6861 7420 7768 6574 6865 n is that whethe │ │ │ +0004b890: 7220 6f72 206e 6f74 2077 650a 0909 092f r or not we..../ │ │ │ +0004b8a0: 2f20 7072 6f78 7920 6974 2069 7320 636f / proxy it is co │ │ │ +0004b8b0: 6e66 6967 7572 6162 6c65 2e20 5768 656e nfigurable. When │ │ │ +0004b8c0: 2077 6520 7573 6520 6932 702c 2077 6520 we use i2p, we │ │ │ +0004b8d0: 7761 6e74 2074 6f20 616c 7761 7973 2070 want to always p │ │ │ +0004b8e0: 726f 780a 0909 092f 2f20 6576 6572 7974 rox....// everyt │ │ │ +0004b8f0: 6869 6e67 2076 6961 2069 3270 2e0a 0a09 hing via i2p.... │ │ │ +0004b900: 0909 6175 783a 3a70 726f 7879 5f73 6574 ..aux::proxy_set │ │ │ +0004b910: 7469 6e67 7320 7072 6f78 793b 0a09 0909 tings proxy;.... │ │ │ +0004b920: 7072 6f78 792e 686f 7374 6e61 6d65 203d proxy.hostname = │ │ │ +0004b930: 2073 6574 7469 6e67 7328 292e 6765 745f settings().get_ │ │ │ +0004b940: 7374 7228 7365 7474 696e 6773 5f70 6163 str(settings_pac │ │ │ +0004b950: 6b3a 3a69 3270 5f68 6f73 746e 616d 6529 k::i2p_hostname) │ │ │ +0004b960: 3b0a 0909 0970 726f 7879 2e70 6f72 7420 ;....proxy.port │ │ │ +0004b970: 3d20 7374 643a 3a75 696e 7431 365f 7428 = std::uint16_t( │ │ │ +0004b980: 7365 7474 696e 6773 2829 2e67 6574 5f69 settings().get_i │ │ │ +0004b990: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ +0004b9a0: 3a3a 6932 705f 706f 7274 2929 3b0a 0909 ::i2p_port));... │ │ │ +0004b9b0: 0970 726f 7879 2e74 7970 6520 3d20 7365 .proxy.type = se │ │ │ +0004b9c0: 7474 696e 6773 5f70 6163 6b3a 3a69 3270 ttings_pack::i2p │ │ │ +0004b9d0: 5f70 726f 7879 3b0a 0a09 0909 6175 783a _proxy;.....aux: │ │ │ +0004b9e0: 3a73 6f63 6b65 745f 7479 7065 2072 6574 :socket_type ret │ │ │ +0004b9f0: 203d 2069 6e73 7461 6e74 6961 7465 5f63 = instantiate_c │ │ │ +0004ba00: 6f6e 6e65 6374 696f 6e28 6d5f 7365 732e onnection(m_ses. │ │ │ +0004ba10: 6765 745f 636f 6e74 6578 7428 290a 0909 get_context()... │ │ │ +0004ba20: 0909 2c20 7072 6f78 792c 206e 756c 6c70 .., proxy, nullp │ │ │ +0004ba30: 7472 2c20 6e75 6c6c 7074 722c 2066 616c tr, nullptr, fal │ │ │ +0004ba40: 7365 2c20 6661 6c73 6529 3b0a 0909 0961 se, false);....a │ │ │ +0004ba50: 7574 6f26 616d 703b 2073 7472 203d 2073 uto& str = s │ │ │ +0004ba60: 7464 3a3a 6765 7426 6c74 3b69 3270 5f73 td::get<i2p_s │ │ │ +0004ba70: 7472 6561 6d26 6774 3b28 7265 7429 3b0a tream>(ret);. │ │ │ +0004ba80: 0909 0973 7472 2e73 6574 5f6c 6f63 616c ...str.set_local │ │ │ +0004ba90: 5f69 3270 5f65 6e64 706f 696e 7428 6d5f _i2p_endpoint(m_ │ │ │ +0004baa0: 7365 732e 6c6f 6361 6c5f 6932 705f 656e ses.local_i2p_en │ │ │ +0004bab0: 6470 6f69 6e74 2829 293b 0a09 0909 7374 dpoint());....st │ │ │ +0004bac0: 722e 7365 745f 6465 7374 696e 6174 696f r.set_destinatio │ │ │ +0004bad0: 6e28 7374 6174 6963 5f63 6173 7426 6c74 n(static_cast< │ │ │ +0004bae0: 3b69 3270 5f70 6565 722a 2667 743b 2870 ;i2p_peer*>(p │ │ │ +0004baf0: 6565 7269 6e66 6f29 2d26 6774 3b64 6573 eerinfo)->des │ │ │ +0004bb00: 7428 2929 3b0a 0909 0973 7472 2e73 6574 t());....str.set │ │ │ +0004bb10: 5f63 6f6d 6d61 6e64 2869 3270 5f73 7472 _command(i2p_str │ │ │ +0004bb20: 6561 6d3a 3a63 6d64 5f63 6f6e 6e65 6374 eam::cmd_connect │ │ │ +0004bb30: 293b 0a09 0909 7374 722e 7365 745f 7365 );....str.set_se │ │ │ +0004bb40: 7373 696f 6e5f 6964 286d 5f73 6573 2e69 ssion_id(m_ses.i │ │ │ +0004bb50: 3270 5f73 6573 7369 6f6e 2829 293b 0a09 2p_session());.. │ │ │ +0004bb60: 0909 7265 7475 726e 2072 6574 3b0a 0909 ..return ret;... │ │ │ +0004bb70: 7d0a 0909 656c 7365 0a23 656e 6469 660a }...else.#endif. │ │ │ +0004bb80: 0909 7b0a 0909 0976 6f69 642a 2075 7365 ..{....void* use │ │ │ +0004bb90: 7264 6174 6120 3d20 6e75 6c6c 7074 723b rdata = nullptr; │ │ │ +0004bba0: 0a23 6966 6465 6620 544f 5252 454e 545f .#ifdef TORRENT_ │ │ │ +0004bbb0: 5353 4c5f 5045 4552 530a 0909 0969 6620 SSL_PEERS....if │ │ │ +0004bbc0: 2869 735f 7373 6c5f 746f 7272 656e 7428 (is_ssl_torrent( │ │ │ +0004bbd0: 2929 0a09 0909 7b0a 3c2f 7072 653e 3c2f ))....{.
    relevan │ │ │ +0004bc10: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ +0004bc50: 742e 6370 703a 3935 3636 3c2f 613e 3c2f t.cpp:9566perhaps 0 │ │ │ +0004bc70: 2073 686f 756c 6420 6163 7475 616c 6c79 should actually │ │ │ +0004bc80: 206d 6561 6e20 303c 2f74 643e 3c2f 7472 mean 0

    perhaps 0 s │ │ │ +0004bce0: 686f 756c 6420 6163 7475 616c 6c79 206d hould actually m │ │ │ +0004bcf0: 6561 6e20 303c 2f68 323e 3c68 343e 2e2e ean 0

    .. │ │ │ +0004bd00: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ +0004bd10: 3a39 3536 363c 2f68 343e 3c70 7265 2073 :9566

    ..// finishe
    │ │ │ +0004bd60: 6420 746f 7272 656e 7473 206d 6179 206e  d torrents may n
    │ │ │ +0004bd70: 6f74 2063 6861 6e67 6520 7468 6569 7220  ot change their 
    │ │ │ +0004bd80: 7175 6575 6520 706f 7369 7469 6f6e 732c  queue positions,
    │ │ │ +0004bd90: 2061 7320 6974 2773 2073 6574 2074 6f0a   as it's set to.
    │ │ │ +0004bda0: 0909 2f2f 202d 310a 0909 6966 2028 286d  ..// -1...if ((m
    │ │ │ +0004bdb0: 5f61 626f 7274 207c 7c20 6973 5f66 696e  _abort || is_fin
    │ │ │ +0004bdc0: 6973 6865 6428 2929 2026 616d 703b 2661  ished()) &&a
    │ │ │ +0004bdd0: 6d70 3b20 7020 213d 206e 6f5f 706f 7329  mp; p != no_pos)
    │ │ │ +0004bde0: 2072 6574 7572 6e3b 0a0a 0909 544f 5252   return;....TORR
    │ │ │ +0004bdf0: 454e 545f 4153 5345 5254 2828 7020 3d3d  ENT_ASSERT((p ==
    │ │ │ +0004be00: 206e 6f5f 706f 7329 203d 3d20 6973 5f66   no_pos) == is_f
    │ │ │ +0004be10: 696e 6973 6865 6428 290a 0909 097c 7c20  inished()....|| 
    │ │ │ +0004be20: 2821 6d5f 6175 746f 5f6d 616e 6167 6564  (!m_auto_managed
    │ │ │ +0004be30: 2026 616d 703b 2661 6d70 3b20 7020 3d3d   && p ==
    │ │ │ +0004be40: 206e 6f5f 706f 7329 0a09 0909 7c7c 2028   no_pos)....|| (
    │ │ │ +0004be50: 6d5f 6162 6f72 7420 2661 6d70 3b26 616d  m_abort &&am
    │ │ │ +0004be60: 703b 2070 203d 3d20 6e6f 5f70 6f73 290a  p; p == no_pos).
    │ │ │ +0004be70: 0909 097c 7c20 2821 6d5f 6164 6465 6420  ...|| (!m_added 
    │ │ │ +0004be80: 2661 6d70 3b26 616d 703b 2070 203d 3d20  && p == 
    │ │ │ +0004be90: 6e6f 5f70 6f73 2929 3b0a 0909 6966 2028  no_pos));...if (
    │ │ │ +0004bea0: 7020 3d3d 206d 5f73 6571 7565 6e63 655f  p == m_sequence_
    │ │ │ +0004beb0: 6e75 6d62 6572 2920 7265 7475 726e 3b0a  number) return;.
    │ │ │ +0004bec0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +0004bed0: 5428 7020 2667 743b 3d20 6e6f 5f70 6f73  T(p >= no_pos
    │ │ │ +0004bee0: 293b 0a0a 0909 7374 6174 655f 7570 6461  );....state_upda
    │ │ │ +0004bef0: 7465 6428 293b 0a0a 0909 6d5f 7365 732e  ted();....m_ses.
    │ │ │ +0004bf00: 7365 745f 7175 6575 655f 706f 7369 7469  set_queue_positi
    │ │ │ +0004bf10: 6f6e 2874 6869 732c 2070 293b 0a09 7d0a  on(this, p);..}.
    │ │ │ +0004bf20: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a  ..void torrent::
    │ │ │ +0004bf30: 7365 745f 6d61 785f 7570 6c6f 6164 7328  set_max_uploads(
    │ │ │ +0004bf40: 696e 7420 6c69 6d69 742c 2062 6f6f 6c20  int limit, bool 
    │ │ │ +0004bf50: 636f 6e73 7420 7374 6174 655f 7570 6461  const state_upda
    │ │ │ +0004bf60: 7465 290a 097b 0a09 0954 4f52 5245 4e54  te)..{...TORRENT
    │ │ │ +0004bf70: 5f41 5353 4552 5428 6973 5f73 696e 676c  _ASSERT(is_singl
    │ │ │ +0004bf80: 655f 7468 7265 6164 2829 293b 0a3c 6469  e_thread());...if 
    │ │ │ +0004bfc0: 286c 696d 6974 2026 6c74 3b3d 2030 2920  (limit <= 0) 
    │ │ │ +0004bfd0: 6c69 6d69 7420 3d20 2831 2026 6c74 3b26  limit = (1 <&
    │ │ │ +0004bfe0: 6c74 3b20 3234 2920 2d20 313b 0a3c 2f64  lt; 24) - 1;...if (int(m_m
    │ │ │ +0004c000: 6178 5f75 706c 6f61 6473 2920 3d3d 206c  ax_uploads) == l
    │ │ │ +0004c010: 696d 6974 2920 7265 7475 726e 3b0a 0909  imit) return;...
    │ │ │ +0004c020: 6966 2028 7374 6174 655f 7570 6461 7465  if (state_update
    │ │ │ +0004c030: 2920 7374 6174 655f 7570 6461 7465 6428  ) state_updated(
    │ │ │ +0004c040: 293b 0a09 096d 5f6d 6178 5f75 706c 6f61  );...m_max_uploa
    │ │ │ +0004c050: 6473 203d 2061 7578 3a3a 6e75 6d65 7269  ds = aux::numeri
    │ │ │ +0004c060: 635f 6361 7374 266c 743b 7374 643a 3a75  c_cast<std::u
    │ │ │ +0004c070: 696e 7433 325f 7426 6774 3b28 6c69 6d69  int32_t>(limi
    │ │ │ +0004c080: 7429 3b0a 2369 666e 6465 6620 544f 5252  t);.#ifndef TORR
    │ │ │ +0004c090: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ +0004c0a0: 494e 470a 0909 6966 2028 7368 6f75 6c64  ING...if (should
    │ │ │ +0004c0b0: 5f6c 6f67 2829 2026 616d 703b 2661 6d70  _log() &&
    │ │ │ +0004c0c0: 3b20 7374 6174 655f 7570 6461 7465 290a  ; state_update).
    │ │ │ +0004c0d0: 0909 0964 6562 7567 5f6c 6f67 2822 2a2a  ...debug_log("**
    │ │ │ +0004c0e0: 2a20 7365 742d 6d61 782d 7570 6c6f 6164  * set-max-upload
    │ │ │ +0004c0f0: 733a 2025 6422 2c20 6d5f 6d61 785f 7570  s: %d", m_max_up
    │ │ │ +0004c100: 6c6f 6164 7329 3b0a 2365 6e64 6966 0a0a  loads);.#endif..
    │ │ │ +0004c110: 0909 6966 2028 7374 6174 655f 7570 6461  ..if (state_upda
    │ │ │ +0004c120: 7465 290a 0909 0973 6574 5f6e 6565 645f  te)....set_need_
    │ │ │ +0004c130: 7361 7665 5f72 6573 756d 6528 746f 7272  save_resume(torr
    │ │ │ +0004c140: 656e 745f 6861 6e64 6c65 3a3a 6966 5f63  ent_handle::if_c
    │ │ │ +0004c150: 6f6e 6669 675f 6368 616e 6765 6429 3b0a  onfig_changed);.
    │ │ │ +0004c160: 097d 0a0a 0976 6f69 6420 746f 7272 656e  .}...void torren
    │ │ │ +0004c170: 743a 3a73 6574 5f6d 6178 5f63 6f6e 6e65  t::set_max_conne
    │ │ │ +0004c180: 6374 696f 6e73 2869 6e74 206c 696d 6974  ctions(int limit
    │ │ │ +0004c190: 2c20 626f 6f6c 2063 6f6e 7374 2073 7461  , bool const sta
    │ │ │ +0004c1a0: 7465 5f75 7064 6174 6529 0a09 7b0a 0909  te_update)..{...
    │ │ │ +0004c1b0: 544f 5252 454e 545f 4153 5345 5254 2869  TORRENT_ASSERT(i
    │ │ │ +0004c1c0: 735f 7369 6e67 6c65 5f74 6872 6561 6428  s_single_thread(
    │ │ │ +0004c1d0: 2929 3b0a 3c2f 7072 653e 3c2f 7464 3e3c  ));.
    < │ │ │ +0004c1e0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0004c210: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0004c240: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +0004c250: 703a 3935 3833 3c2f 613e 3c2f 7464 3e3c p:9583< │ │ │ +0004c260: 7464 3e70 6572 6861 7073 2030 2073 686f td>perhaps 0 sho │ │ │ +0004c270: 756c 6420 6163 7475 616c 6c79 206d 6561 uld actually mea │ │ │ +0004c280: 6e20 303c 2f74 643e 3c2f 7472 3e3c 7472 n 0

    perhaps 0 shoul │ │ │ +0004c2e0: 6420 6163 7475 616c 6c79 206d 6561 6e20 d actually mean │ │ │ +0004c2f0: 303c 2f68 323e 3c68 343e 2e2e 2f73 7263 0

    ../src │ │ │ +0004c300: 2f74 6f72 7265 6e74 2e63 7070 3a39 3538 /torrent.cpp:958 │ │ │ +0004c310: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ +0004c350: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a  ..void torrent::
    │ │ │ +0004c360: 7365 745f 6d61 785f 7570 6c6f 6164 7328  set_max_uploads(
    │ │ │ +0004c370: 696e 7420 6c69 6d69 742c 2062 6f6f 6c20  int limit, bool 
    │ │ │ +0004c380: 636f 6e73 7420 7374 6174 655f 7570 6461  const state_upda
    │ │ │ +0004c390: 7465 290a 097b 0a09 0954 4f52 5245 4e54  te)..{...TORRENT
    │ │ │ +0004c3a0: 5f41 5353 4552 5428 6973 5f73 696e 676c  _ASSERT(is_singl
    │ │ │ +0004c3b0: 655f 7468 7265 6164 2829 293b 0a09 0969  e_thread());...i
    │ │ │ +0004c3c0: 6620 286c 696d 6974 2026 6c74 3b3d 2030  f (limit <= 0
    │ │ │ +0004c3d0: 2920 6c69 6d69 7420 3d20 2831 2026 6c74  ) limit = (1 <
    │ │ │ +0004c3e0: 3b26 6c74 3b20 3234 2920 2d20 313b 0a09  ;< 24) - 1;..
    │ │ │ +0004c3f0: 0969 6620 2869 6e74 286d 5f6d 6178 5f75  .if (int(m_max_u
    │ │ │ +0004c400: 706c 6f61 6473 2920 3d3d 206c 696d 6974  ploads) == limit
    │ │ │ +0004c410: 2920 7265 7475 726e 3b0a 0909 6966 2028  ) return;...if (
    │ │ │ +0004c420: 7374 6174 655f 7570 6461 7465 2920 7374  state_update) st
    │ │ │ +0004c430: 6174 655f 7570 6461 7465 6428 293b 0a09  ate_updated();..
    │ │ │ +0004c440: 096d 5f6d 6178 5f75 706c 6f61 6473 203d  .m_max_uploads =
    │ │ │ +0004c450: 2061 7578 3a3a 6e75 6d65 7269 635f 6361   aux::numeric_ca
    │ │ │ +0004c460: 7374 266c 743b 7374 643a 3a75 696e 7433  st<std::uint3
    │ │ │ +0004c470: 325f 7426 6774 3b28 6c69 6d69 7429 3b0a  2_t>(limit);.
    │ │ │ +0004c480: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +0004c490: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +0004c4a0: 0909 6966 2028 7368 6f75 6c64 5f6c 6f67  ..if (should_log
    │ │ │ +0004c4b0: 2829 2026 616d 703b 2661 6d70 3b20 7374  () && st
    │ │ │ +0004c4c0: 6174 655f 7570 6461 7465 290a 0909 0964  ate_update)....d
    │ │ │ +0004c4d0: 6562 7567 5f6c 6f67 2822 2a2a 2a20 7365  ebug_log("*** se
    │ │ │ +0004c4e0: 742d 6d61 782d 7570 6c6f 6164 733a 2025  t-max-uploads: %
    │ │ │ +0004c4f0: 6422 2c20 6d5f 6d61 785f 7570 6c6f 6164  d", m_max_upload
    │ │ │ +0004c500: 7329 3b0a 2365 6e64 6966 0a0a 0909 6966  s);.#endif....if
    │ │ │ +0004c510: 2028 7374 6174 655f 7570 6461 7465 290a   (state_update).
    │ │ │ +0004c520: 0909 0973 6574 5f6e 6565 645f 7361 7665  ...set_need_save
    │ │ │ +0004c530: 5f72 6573 756d 6528 746f 7272 656e 745f  _resume(torrent_
    │ │ │ +0004c540: 6861 6e64 6c65 3a3a 6966 5f63 6f6e 6669  handle::if_confi
    │ │ │ +0004c550: 675f 6368 616e 6765 6429 3b0a 097d 0a0a  g_changed);..}..
    │ │ │ +0004c560: 0976 6f69 6420 746f 7272 656e 743a 3a73  .void torrent::s
    │ │ │ +0004c570: 6574 5f6d 6178 5f63 6f6e 6e65 6374 696f  et_max_connectio
    │ │ │ +0004c580: 6e73 2869 6e74 206c 696d 6974 2c20 626f  ns(int limit, bo
    │ │ │ +0004c590: 6f6c 2063 6f6e 7374 2073 7461 7465 5f75  ol const state_u
    │ │ │ +0004c5a0: 7064 6174 6529 0a09 7b0a 0909 544f 5252  pdate)..{...TORR
    │ │ │ +0004c5b0: 454e 545f 4153 5345 5254 2869 735f 7369  ENT_ASSERT(is_si
    │ │ │ +0004c5c0: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a  ngle_thread());.
    │ │ │ +0004c5d0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +0004c600: 6966 2028 6c69 6d69 7420 266c 743b 3d20 if (limit <= │ │ │ +0004c610: 3029 206c 696d 6974 203d 2028 3120 266c 0) limit = (1 &l │ │ │ +0004c620: 743b 266c 743b 2032 3429 202d 2031 3b0a t;< 24) - 1;. │ │ │ +0004c630: 3c2f 6469 763e 0909 6966 2028 696e 7428
    ..if (int( │ │ │ +0004c640: 6d5f 6d61 785f 636f 6e6e 6563 7469 6f6e m_max_connection │ │ │ +0004c650: 7329 203d 3d20 6c69 6d69 7429 2072 6574 s) == limit) ret │ │ │ +0004c660: 7572 6e3b 0a09 0969 6620 2873 7461 7465 urn;...if (state │ │ │ +0004c670: 5f75 7064 6174 6529 2073 7461 7465 5f75 _update) state_u │ │ │ +0004c680: 7064 6174 6564 2829 3b0a 0909 6d5f 6d61 pdated();...m_ma │ │ │ +0004c690: 785f 636f 6e6e 6563 7469 6f6e 7320 3d20 x_connections = │ │ │ +0004c6a0: 6175 783a 3a6e 756d 6572 6963 5f63 6173 aux::numeric_cas │ │ │ +0004c6b0: 7426 6c74 3b73 7464 3a3a 7569 6e74 3332 t<std::uint32 │ │ │ +0004c6c0: 5f74 2667 743b 286c 696d 6974 293b 0a09 _t>(limit);.. │ │ │ +0004c6d0: 0975 7064 6174 655f 7761 6e74 5f70 6565 .update_want_pee │ │ │ +0004c6e0: 7273 2829 3b0a 0a23 6966 6e64 6566 2054 rs();..#ifndef T │ │ │ +0004c6f0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ +0004c700: 4f47 4749 4e47 0a09 0969 6620 2873 686f OGGING...if (sho │ │ │ +0004c710: 756c 645f 6c6f 6728 2920 2661 6d70 3b26 uld_log() && │ │ │ +0004c720: 616d 703b 2073 7461 7465 5f75 7064 6174 amp; state_updat │ │ │ +0004c730: 6529 0a09 0909 6465 6275 675f 6c6f 6728 e)....debug_log( │ │ │ +0004c740: 222a 2a2a 2073 6574 2d6d 6178 2d63 6f6e "*** set-max-con │ │ │ +0004c750: 6e65 6374 696f 6e73 3a20 2564 222c 206d nections: %d", m │ │ │ +0004c760: 5f6d 6178 5f63 6f6e 6e65 6374 696f 6e73 _max_connections │ │ │ +0004c770: 293b 0a23 656e 6469 660a 0a09 0969 6620 );.#endif....if │ │ │ +0004c780: 286e 756d 5f70 6565 7273 2829 2026 6774 (num_peers() > │ │ │ +0004c790: 3b20 696e 7428 6d5f 6d61 785f 636f 6e6e ; int(m_max_conn │ │ │ +0004c7a0: 6563 7469 6f6e 7329 290a 0909 7b0a 0909 ections))...{... │ │ │ +0004c7b0: 0964 6973 636f 6e6e 6563 745f 7065 6572 .disconnect_peer │ │ │ +0004c7c0: 7328 6e75 6d5f 7065 6572 7328 2920 2d20 s(num_peers() - │ │ │ +0004c7d0: 6d5f 6d61 785f 636f 6e6e 6563 7469 6f6e m_max_connection │ │ │ +0004c7e0: 730a 0909 0909 2c20 6572 726f 7273 3a3a s....., errors:: │ │ │ +0004c7f0: 746f 6f5f 6d61 6e79 5f63 6f6e 6e65 6374 too_many_connect │ │ │ +0004c800: 696f 6e73 293b 0a09 097d 0a0a 0909 6966 ions);...}....if │ │ │ +0004c810: 2028 7374 6174 655f 7570 6461 7465 290a (state_update). │ │ │ +0004c820: 0909 0973 6574 5f6e 6565 645f 7361 7665 ...set_need_save │ │ │ +0004c830: 5f72 6573 756d 6528 746f 7272 656e 745f _resume(torrent_ │ │ │ +0004c840: 6861 6e64 6c65 3a3a 6966 5f63 6f6e 6669 handle::if_confi │ │ │ +0004c850: 675f 6368 616e 6765 6429 3b0a 097d 0a0a g_changed);..}.. │ │ │ +0004c860: 0976 6f69 6420 746f 7272 656e 743a 3a73 .void torrent::s │ │ │ +0004c870: 6574 5f75 706c 6f61 645f 6c69 6d69 7428 et_upload_limit( │ │ │ +0004c880: 696e 7420 636f 6e73 7420 6c69 6d69 7429 int const limit) │ │ │ +0004c890: 0a09 7b0a 0909 7365 745f 6c69 6d69 745f ..{...set_limit_ │ │ │ +0004c8a0: 696d 706c 286c 696d 6974 2c20 7065 6572 impl(limit, peer │ │ │ +0004c8b0: 5f63 6f6e 6e65 6374 696f 6e3a 3a75 706c _connection::upl │ │ │ +0004c8c0: 6f61 645f 6368 616e 6e65 6c29 3b0a 2369 oad_channel);.#i │ │ │ +0004c8d0: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +0004c8e0: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ +0004c8f0: 6465 6275 675f 6c6f 6728 222a 2a2a 2073 debug_log("*** s │ │ │ +0004c900: 6574 2d75 706c 6f61 642d 6c69 6d69 743a et-upload-limit: │ │ │ +0004c910: 2025 6422 2c20 6c69 6d69 7429 3b0a 2365 %d", limit);.#e │ │ │ +0004c920: 6e64 6966 0a09 7d0a 0a09 766f 6964 2074 ndif..}...void t │ │ │ +0004c930: 6f72 7265 6e74 3a3a 7365 745f 646f 776e orrent::set_down │ │ │ +0004c940: 6c6f 6164 5f6c 696d 6974 2869 6e74 2063 load_limit(int c │ │ │ +0004c950: 6f6e 7374 206c 696d 6974 290a 097b 0a3c onst limit)..{.< │ │ │ +0004c960: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0004c970: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0004c980: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +0004c990: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +0004c9a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +0004c9d0: 2f74 6f72 7265 6e74 2e63 7070 3a31 3135 /torrent.cpp:115 │ │ │ +0004c9e0: 3233 3c2f 613e 3c2f 7464 3e3c 7464 3e69 23i │ │ │ +0004c9f0: 6e73 7465 6164 206f 6620 7265 736f 7274 nstead of resort │ │ │ +0004ca00: 696e 6720 7468 6520 7768 6f6c 6520 6c69 ing the whole li │ │ │ +0004ca10: 7374 2c20 696e 7365 7274 2074 6865 2070 st, insert the p │ │ │ +0004ca20: 6565 7273 2064 6972 6563 746c 7920 696e eers directly in │ │ │ +0004ca30: 746f 2074 6865 2072 6967 6874 2070 6c61 to the right pla │ │ │ +0004ca40: 6365 3c2f 7464 3e3c 2f74 723e 3c74 7220 ce

    │ │ │ +0004ca90: 696e 7374 6561 6420 6f66 2072 6573 6f72 instead of resor │ │ │ +0004caa0: 7469 6e67 2074 6865 2077 686f 6c65 206c ting the whole l │ │ │ +0004cab0: 6973 742c 2069 6e73 6572 7420 7468 6520 ist, insert the │ │ │ +0004cac0: 7065 6572 730a 6469 7265 6374 6c79 2069 peers.directly i │ │ │ +0004cad0: 6e74 6f20 7468 6520 7269 6768 7420 706c nto the right pl │ │ │ +0004cae0: 6163 653c 2f68 323e 3c68 343e 2e2e 2f73 ace

    ../s │ │ │ +0004caf0: 7263 2f74 6f72 7265 6e74 2e63 7070 3a31 rc/torrent.cpp:1 │ │ │ +0004cb00: 3135 3233 3c2f 6834 3e3c 7072 6520 7374 1523

    ....std::prin
    │ │ │ +0004cb50: 7466 2822 7469 6d65 6420 6f75 7420 5b61  tf("timed out [a
    │ │ │ +0004cb60: 7665 7261 6765 2d70 6965 6365 2d74 696d  verage-piece-tim
    │ │ │ +0004cb70: 653a 2025 6420 6d73 205d 5c6e 220a 0909  e: %d ms ]\n"...
    │ │ │ +0004cb80: 0909 092c 206d 5f61 7665 7261 6765 5f70  ..., m_average_p
    │ │ │ +0004cb90: 6965 6365 5f74 696d 6529 3b0a 2365 6e64  iece_time);.#end
    │ │ │ +0004cba0: 6966 0a09 0909 7d0a 0a09 0909 2f2f 2070  if....}.....// p
    │ │ │ +0004cbb0: 6963 6b20 616c 6c20 626c 6f63 6b73 2066  ick all blocks f
    │ │ │ +0004cbc0: 6f72 2074 6869 7320 7069 6563 652e 2074  or this piece. t
    │ │ │ +0004cbd0: 6865 2070 6565 7273 206c 6973 7420 6973  he peers list is
    │ │ │ +0004cbe0: 206b 6570 7420 7570 2074 6f20 6461 7465   kept up to date
    │ │ │ +0004cbf0: 0a09 0909 2f2f 2061 6e64 2073 6f72 7465  ....// and sorte
    │ │ │ +0004cc00: 642e 2077 6865 6e20 7765 2069 7373 7565  d. when we issue
    │ │ │ +0004cc10: 2061 2072 6571 7565 7374 2074 6f20 6120   a request to a 
    │ │ │ +0004cc20: 7065 6572 2c20 6974 7320 646f 776e 6c6f  peer, its downlo
    │ │ │ +0004cc30: 6164 2071 7565 7565 0a09 0909 2f2f 2074  ad queue....// t
    │ │ │ +0004cc40: 696d 6520 7769 6c6c 2069 6e63 7265 6173  ime will increas
    │ │ │ +0004cc50: 6520 616e 6420 6974 206d 6179 206e 6565  e and it may nee
    │ │ │ +0004cc60: 6420 746f 2062 6520 6275 6d70 6564 2069  d to be bumped i
    │ │ │ +0004cc70: 6e20 7468 6520 7065 6572 7320 6c69 7374  n the peers list
    │ │ │ +0004cc80: 2c0a 0909 092f 2f20 7369 6e63 6520 6974  ,....// since it
    │ │ │ +0004cc90: 2773 206f 7264 6572 6564 2062 7920 646f  's ordered by do
    │ │ │ +0004cca0: 776e 6c6f 6164 2071 7565 7565 2074 696d  wnload queue tim
    │ │ │ +0004ccb0: 650a 0909 0970 6963 6b5f 7469 6d65 5f63  e....pick_time_c
    │ │ │ +0004ccc0: 7269 7469 6361 6c5f 626c 6f63 6b28 7065  ritical_block(pe
    │ │ │ +0004ccd0: 6572 732c 2069 676e 6f72 655f 7065 6572  ers, ignore_peer
    │ │ │ +0004cce0: 730a 0909 0909 2c20 7065 6572 735f 7769  s....., peers_wi
    │ │ │ +0004ccf0: 7468 5f72 6571 7565 7374 730a 0909 0909  th_requests.....
    │ │ │ +0004cd00: 2c20 7069 2c20 2661 6d70 3b69 2c20 6d5f  , pi, &i, m_
    │ │ │ +0004cd10: 7069 636b 6572 2e67 6574 2829 0a09 0909  picker.get()....
    │ │ │ +0004cd20: 092c 2062 6c6f 636b 735f 696e 5f70 6965  ., blocks_in_pie
    │ │ │ +0004cd30: 6365 2c20 7469 6d65 645f 6f75 7429 3b0a  ce, timed_out);.
    │ │ │ +0004cd40: 0a09 0909 2f2f 2070 7574 2062 6163 6b20  ....// put back 
    │ │ │ +0004cd50: 7468 6520 7065 6572 7320 7765 2069 676e  the peers we ign
    │ │ │ +0004cd60: 6f72 6564 2069 6e74 6f20 7468 6520 7065  ored into the pe
    │ │ │ +0004cd70: 6572 206c 6973 7420 666f 7220 7468 6520  er list for the 
    │ │ │ +0004cd80: 6e65 7874 2070 6965 6365 0a09 0909 6966  next piece....if
    │ │ │ +0004cd90: 2028 2169 676e 6f72 655f 7065 6572 732e   (!ignore_peers.
    │ │ │ +0004cda0: 656d 7074 7928 2929 0a09 0909 7b0a 0909  empty())....{...
    │ │ │ +0004cdb0: 0909 7065 6572 732e 696e 7365 7274 2870  ..peers.insert(p
    │ │ │ +0004cdc0: 6565 7273 2e62 6567 696e 2829 2c20 6967  eers.begin(), ig
    │ │ │ +0004cdd0: 6e6f 7265 5f70 6565 7273 2e62 6567 696e  nore_peers.begin
    │ │ │ +0004cde0: 2829 2c20 6967 6e6f 7265 5f70 6565 7273  (), ignore_peers
    │ │ │ +0004cdf0: 2e65 6e64 2829 293b 0a09 0909 0969 676e  .end());.....ign
    │ │ │ +0004ce00: 6f72 655f 7065 6572 732e 636c 6561 7228  ore_peers.clear(
    │ │ │ +0004ce10: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22  );..
    ....std::sort( │ │ │ +0004ce50: 7065 6572 732e 6265 6769 6e28 292c 2070 peers.begin(), p │ │ │ +0004ce60: 6565 7273 2e65 6e64 2829 0a3c 2f64 6976 eers.end().
    ....., [] (peer │ │ │ +0004ce80: 5f63 6f6e 6e65 6374 696f 6e20 636f 6e73 _connection cons │ │ │ +0004ce90: 742a 206c 6873 2c20 7065 6572 5f63 6f6e t* lhs, peer_con │ │ │ +0004cea0: 6e65 6374 696f 6e20 636f 6e73 742a 2072 nection const* r │ │ │ +0004ceb0: 6873 290a 0909 0909 097b 2072 6574 7572 hs)......{ retur │ │ │ +0004cec0: 6e20 6c68 732d 2667 743b 646f 776e 6c6f n lhs->downlo │ │ │ +0004ced0: 6164 5f71 7565 7565 5f74 696d 6528 3136 ad_queue_time(16 │ │ │ +0004cee0: 2a31 3032 3429 2026 6c74 3b20 7268 732d *1024) < rhs- │ │ │ +0004cef0: 2667 743b 646f 776e 6c6f 6164 5f71 7565 >download_que │ │ │ +0004cf00: 7565 5f74 696d 6528 3136 2a31 3032 3429 ue_time(16*1024) │ │ │ +0004cf10: 3b20 7d29 3b0a 0909 097d 0a0a 0909 092f ; });....}...../ │ │ │ +0004cf20: 2f20 6966 2074 6869 7320 7065 6572 2773 / if this peer's │ │ │ +0004cf30: 2064 6f77 6e6c 6f61 6420 7469 6d65 2065 download time e │ │ │ +0004cf40: 7863 6565 6473 2032 2073 6563 6f6e 6473 xceeds 2 seconds │ │ │ +0004cf50: 2c20 7765 2772 6520 646f 6e65 2e0a 0909 , we're done.... │ │ │ +0004cf60: 092f 2f20 5765 2064 6f6e 2774 2077 616e .// We don't wan │ │ │ +0004cf70: 7420 746f 2062 7569 6c64 2075 6e72 6561 t to build unrea │ │ │ +0004cf80: 736f 6e61 626c 7920 6c6f 6e67 2072 6571 sonably long req │ │ │ +0004cf90: 7565 7374 2071 7565 7565 730a 0909 0969 uest queues....i │ │ │ +0004cfa0: 6620 2821 7065 6572 732e 656d 7074 7928 f (!peers.empty( │ │ │ +0004cfb0: 2920 2661 6d70 3b26 616d 703b 2070 6565 ) && pee │ │ │ +0004cfc0: 7273 5b30 5d2d 2667 743b 646f 776e 6c6f rs[0]->downlo │ │ │ +0004cfd0: 6164 5f71 7565 7565 5f74 696d 6528 2920 ad_queue_time() │ │ │ +0004cfe0: 2667 743b 206d 696c 6c69 7365 636f 6e64 > millisecond │ │ │ +0004cff0: 7328 3230 3030 2929 0a09 0909 0962 7265 s(2000)).....bre │ │ │ +0004d000: 616b 3b0a 0909 7d0a 0a09 092f 2f20 636f ak;...}....// co │ │ │ +0004d010: 6d6d 6974 2061 6c6c 2074 6865 2074 696d mmit all the tim │ │ │ +0004d020: 6520 6372 6974 6963 616c 2072 6571 7565 e critical reque │ │ │ +0004d030: 7374 730a 0909 666f 7220 2861 7574 6f2a sts...for (auto* │ │ │ +0004d040: 2070 203a 2070 6565 7273 5f77 6974 685f p : peers_with_ │ │ │ +0004d050: 7265 7175 6573 7473 290a 0909 7b0a 0909 requests)...{... │ │ │ +0004d060: 0970 2d26 6774 3b73 656e 645f 626c 6f63 .p->send_bloc │ │ │ +0004d070: 6b5f 7265 7175 6573 7473 2829 3b0a 0909 k_requests();... │ │ │ +0004d080: 7d0a 097d 0a23 656e 6469 6620 2f2f 2054 }..}.#endif // T │ │ │ +0004d090: 4f52 5245 4e54 5f44 4953 4142 4c45 5f53 ORRENT_DISABLE_S │ │ │ +0004d0a0: 5452 4541 4d49 4e47 0a0a 0973 7464 3a3a TREAMING...std:: │ │ │ +0004d0b0: 7365 7426 6c74 3b73 7464 3a3a 7374 7269 set<std::stri │ │ │ +0004d0c0: 6e67 2667 743b 2074 6f72 7265 6e74 3a3a ng> torrent:: │ │ │ +0004d0d0: 7765 625f 7365 6564 7328 2920 636f 6e73 web_seeds() cons │ │ │ +0004d0e0: 740a 097b 0a09 0954 4f52 5245 4e54 5f41 t..{...TORRENT_A │ │ │ +0004d0f0: 5353 4552 5428 6973 5f73 696e 676c 655f SSERT(is_single_ │ │ │ +0004d100: 7468 7265 6164 2829 293b 0a09 0973 7464 thread());...std │ │ │ +0004d110: 3a3a 7365 7426 6c74 3b73 7464 3a3a 7374 ::set<std::st │ │ │ +0004d120: 7269 6e67 2667 743b 2072 6574 3b0a 0909 ring> ret;... │ │ │ +0004d130: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ +0004d140: 616d 703b 2073 203a 206d 5f77 6562 5f73 amp; s : m_web_s │ │ │ +0004d150: 6565 6473 290a 0909 7b0a 0909 0969 6620 eeds)...{....if │ │ │ +0004d160: 2873 2e70 6565 725f 696e 666f 2e62 616e (s.peer_info.ban │ │ │ +0004d170: 6e65 6429 2063 6f6e 7469 6e75 653b 0a09 ned) continue;.. │ │ │ +0004d180: 0909 6966 2028 732e 7265 6d6f 7665 6429 ..if (s.removed) │ │ │ +0004d190: 2063 6f6e 7469 6e75 653b 0a09 0909 7265 continue;....re │ │ │ +0004d1a0: 742e 696e 7365 7274 2873 2e75 726c 293b t.insert(s.url); │ │ │ +0004d1b0: 0a09 097d 0a09 0972 6574 7572 6e20 7265 ...}...return re │ │ │ +0004d1c0: 743b 0a09 7d0a 3c2f 7072 653e 3c2f 7464 t;..}.
    relevance │ │ │ +0004d200: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0004d210: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/web_conn │ │ │ +0004d240: 6563 7469 6f6e 5f62 6173 652e 6370 703a ection_base.cpp: │ │ │ +0004d250: 3530 3c2f 613e 3c2f 7464 3e3c 7464 3e69 50i │ │ │ +0004d260: 6e74 726f 6475 6365 2061 2077 6562 2d73 ntroduce a web-s │ │ │ +0004d270: 6565 6420 6465 6661 756c 7420 636c 6173 eed default clas │ │ │ +0004d280: 7320 7768 6963 6820 6861 7320 6120 6c6f s which has a lo │ │ │ +0004d290: 7720 646f 776e 6c6f 6164 2070 7269 6f72 w download prior │ │ │ +0004d2a0: 6974 793c 2f74 643e 3c2f 7472 3e3c 7472 ity

    introduce a web │ │ │ +0004d300: 2d73 6565 6420 6465 6661 756c 7420 636c -seed default cl │ │ │ +0004d310: 6173 7320 7768 6963 6820 6861 7320 6120 ass which has a │ │ │ +0004d320: 6c6f 7720 646f 776e 6c6f 6164 2070 7269 low download pri │ │ │ +0004d330: 6f72 6974 793c 2f68 323e 3c68 343e 2e2e ority

    .. │ │ │ +0004d340: 2f73 7263 2f77 6562 5f63 6f6e 6e65 6374 /src/web_connect │ │ │ +0004d350: 696f 6e5f 6261 7365 2e63 7070 3a35 303c ion_base.cpp:50< │ │ │ +0004d360: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0004d3a0: 3a20 7065 6572 5f63 6f6e 6e65 6374 696f  : peer_connectio
    │ │ │ +0004d3b0: 6e28 7061 636b 290a 0909 2c20 6d5f 6669  n(pack)..., m_fi
    │ │ │ +0004d3c0: 7273 745f 7265 7175 6573 7428 7472 7565  rst_request(true
    │ │ │ +0004d3d0: 290a 0909 2c20 6d5f 7373 6c28 6661 6c73  )..., m_ssl(fals
    │ │ │ +0004d3e0: 6529 0a09 092c 206d 5f65 7874 6572 6e61  e)..., m_externa
    │ │ │ +0004d3f0: 6c5f 6175 7468 2877 6562 2e61 7574 6829  l_auth(web.auth)
    │ │ │ +0004d400: 0a09 092c 206d 5f65 7874 7261 5f68 6561  ..., m_extra_hea
    │ │ │ +0004d410: 6465 7273 2877 6562 2e65 7874 7261 5f68  ders(web.extra_h
    │ │ │ +0004d420: 6561 6465 7273 290a 0909 2c20 6d5f 7061  eaders)..., m_pa
    │ │ │ +0004d430: 7273 6572 2861 7578 3a3a 6874 7470 5f70  rser(aux::http_p
    │ │ │ +0004d440: 6172 7365 723a 3a64 6f6e 745f 7061 7273  arser::dont_pars
    │ │ │ +0004d450: 655f 6368 756e 6b73 290a 0909 2c20 6d5f  e_chunks)..., m_
    │ │ │ +0004d460: 626f 6479 5f73 7461 7274 2830 290a 097b  body_start(0)..{
    │ │ │ +0004d470: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +0004d480: 5428 2661 6d70 3b77 6562 2e70 6565 725f  T(&web.peer_
    │ │ │ +0004d490: 696e 666f 203d 3d20 7061 636b 2e70 6565  info == pack.pee
    │ │ │ +0004d4a0: 7269 6e66 6f29 3b0a 0909 2f2f 2077 6865  rinfo);...// whe
    │ │ │ +0004d4b0: 6e20 676f 696e 6720 7468 726f 7567 6820  n going through 
    │ │ │ +0004d4c0: 6120 7072 6f78 792c 2077 6520 646f 6e27  a proxy, we don'
    │ │ │ +0004d4d0: 7420 6e65 6365 7373 6172 696c 7920 6861  t necessarily ha
    │ │ │ +0004d4e0: 7665 2061 6e20 656e 6470 6f69 6e74 2068  ve an endpoint h
    │ │ │ +0004d4f0: 6572 652c 0a09 092f 2f20 7369 6e63 6520  ere,...// since 
    │ │ │ +0004d500: 7468 6520 7072 6f78 7920 6d69 6768 7420  the proxy might 
    │ │ │ +0004d510: 6265 2072 6573 6f6c 7669 6e67 2074 6865  be resolving the
    │ │ │ +0004d520: 2068 6f73 746e 616d 652c 206e 6f74 2075   hostname, not u
    │ │ │ +0004d530: 730a 0909 544f 5252 454e 545f 4153 5345  s...TORRENT_ASSE
    │ │ │ +0004d540: 5254 2877 6562 2e65 6e64 706f 696e 7473  RT(web.endpoints
    │ │ │ +0004d550: 2e65 6d70 7479 2829 207c 7c20 7765 622e  .empty() || web.
    │ │ │ +0004d560: 656e 6470 6f69 6e74 732e 6672 6f6e 7428  endpoints.front(
    │ │ │ +0004d570: 2920 3d3d 2070 6163 6b2e 656e 6470 293b  ) == pack.endp);
    │ │ │ +0004d580: 0a0a 0909 494e 5641 5249 414e 545f 4348  ....INVARIANT_CH
    │ │ │ +0004d590: 4543 4b3b 0a0a 0909 544f 5252 454e 545f  ECK;....TORRENT_
    │ │ │ +0004d5a0: 4153 5345 5254 2869 735f 6f75 7467 6f69  ASSERT(is_outgoi
    │ │ │ +0004d5b0: 6e67 2829 293b 0a0a 0909 544f 5252 454e  ng());....TORREN
    │ │ │ +0004d5c0: 545f 4153 5345 5254 2821 6d5f 746f 7272  T_ASSERT(!m_torr
    │ │ │ +0004d5d0: 656e 742e 6c6f 636b 2829 2d26 6774 3b69  ent.lock()->i
    │ │ │ +0004d5e0: 735f 7570 6c6f 6164 5f6f 6e6c 7928 2929  s_upload_only())
    │ │ │ +0004d5f0: 3b0a 0a09 092f 2f20 7765 206f 6e6c 7920  ;....// we only 
    │ │ │ +0004d600: 7761 6e74 206c 6566 742d 6f76 6572 2062  want left-over b
    │ │ │ +0004d610: 616e 6477 6964 7468 0a3c 6469 7620 7374  andwidth.
    .
    .. │ │ │ +0004d650: 7374 643a 3a73 7472 696e 6720 7072 6f74 std::string prot │ │ │ +0004d660: 6f63 6f6c 3b0a 0909 6572 726f 725f 636f ocol;...error_co │ │ │ +0004d670: 6465 2065 633b 0a09 0973 7464 3a3a 7469 de ec;...std::ti │ │ │ +0004d680: 6528 7072 6f74 6f63 6f6c 2c20 6d5f 6261 e(protocol, m_ba │ │ │ +0004d690: 7369 635f 6175 7468 2c20 6d5f 686f 7374 sic_auth, m_host │ │ │ +0004d6a0: 2c20 6d5f 706f 7274 2c20 6d5f 7061 7468 , m_port, m_path │ │ │ +0004d6b0: 290a 0909 093d 2070 6172 7365 5f75 726c )....= parse_url │ │ │ +0004d6c0: 5f63 6f6d 706f 6e65 6e74 7328 7765 622e _components(web. │ │ │ +0004d6d0: 7572 6c2c 2065 6329 3b0a 0909 544f 5252 url, ec);...TORR │ │ │ +0004d6e0: 454e 545f 4153 5345 5254 2821 6563 293b ENT_ASSERT(!ec); │ │ │ +0004d6f0: 0a0a 0909 6966 2028 6d5f 706f 7274 203d ....if (m_port = │ │ │ +0004d700: 3d20 2d31 2026 616d 703b 2661 6d70 3b20 = -1 && │ │ │ +0004d710: 7072 6f74 6f63 6f6c 203d 3d20 2268 7474 protocol == "htt │ │ │ +0004d720: 7022 290a 0909 096d 5f70 6f72 7420 3d20 p")....m_port = │ │ │ +0004d730: 3830 3b0a 0a23 6966 2054 4f52 5245 4e54 80;..#if TORRENT │ │ │ +0004d740: 5f55 5345 5f53 534c 0a09 0969 6620 2870 _USE_SSL...if (p │ │ │ +0004d750: 726f 746f 636f 6c20 3d3d 2022 6874 7470 rotocol == "http │ │ │ +0004d760: 7322 290a 0909 7b0a 0909 096d 5f73 736c s")...{....m_ssl │ │ │ +0004d770: 203d 2074 7275 653b 0a09 0909 6966 2028 = true;....if ( │ │ │ +0004d780: 6d5f 706f 7274 203d 3d20 2d31 2920 6d5f m_port == -1) m_ │ │ │ +0004d790: 706f 7274 203d 2034 3433 3b0a 0909 7d0a port = 443;...}. │ │ │ +0004d7a0: 2365 6e64 6966 0a0a 0909 6966 2028 216d #endif....if (!m │ │ │ +0004d7b0: 5f62 6173 6963 5f61 7574 682e 656d 7074 _basic_auth.empt │ │ │ +0004d7c0: 7928 2929 0a09 0909 6d5f 6261 7369 635f y())....m_basic_ │ │ │ +0004d7d0: 6175 7468 203d 2062 6173 6536 3465 6e63 auth = base64enc │ │ │ +0004d7e0: 6f64 6528 6d5f 6261 7369 635f 6175 7468 ode(m_basic_auth │ │ │ +0004d7f0: 293b 0a0a 0909 6d5f 7365 7276 6572 5f73 );....m_server_s │ │ │ +0004d800: 7472 696e 6720 3d20 6d5f 686f 7374 3b0a tring = m_host;. │ │ │ +0004d810: 0909 6175 783a 3a76 6572 6966 795f 656e ..aux::verify_en │ │ │ +0004d820: 636f 6469 6e67 286d 5f73 6572 7665 725f coding(m_server_ │ │ │ +0004d830: 7374 7269 6e67 293b 0a09 7d0a 0a09 696e string);..}...in │ │ │ +0004d840: 7420 7765 625f 636f 6e6e 6563 7469 6f6e t web_connection │ │ │ +0004d850: 5f62 6173 653a 3a74 696d 656f 7574 2829 _base::timeout() │ │ │ +0004d860: 2063 6f6e 7374 0a09 7b0a 0909 2f2f 2073 const..{...// s │ │ │ +0004d870: 696e 6365 2074 6869 7320 6973 2061 2077 ince this is a w │ │ │ +0004d880: 6562 2073 6565 642c 2063 6861 6e67 6520 eb seed, change │ │ │ +0004d890: 7468 6520 7469 6d65 6f75 740a 0909 2f2f the timeout...// │ │ │ +0004d8a0: 2061 6363 6f72 6469 6e67 2074 6f20 7468 according to th │ │ │ +0004d8b0: 6520 7365 7474 696e 6773 2e0a 0909 7265 e settings....re │ │ │ +0004d8c0: 7475 726e 206d 5f73 6574 7469 6e67 732e turn m_settings. │ │ │ +0004d8d0: 6765 745f 696e 7428 7365 7474 696e 6773 get_int(settings │ │ │ +0004d8e0: 5f70 6163 6b3a 3a75 726c 7365 6564 5f74 _pack::urlseed_t │ │ │ +0004d8f0: 696d 656f 7574 293b 0a09 7d0a 3c2f 7072 imeout);..}.rel │ │ │ +0004d930: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/st │ │ │ +0004d970: 6f72 6167 655f 7574 696c 732e 6370 703a orage_utils.cpp: │ │ │ +0004d980: 3132 333c 2f61 3e3c 2f74 643e 3c74 643e 123 │ │ │ +0004d990: 6964 6561 6c6c 792c 2069 6620 7765 2065 ideally, if we e │ │ │ +0004d9a0: 6e64 2075 7020 636f 7079 696e 6720 6669 nd up copying fi │ │ │ +0004d9b0: 6c65 7320 6265 6361 7573 6520 6f66 2061 les because of a │ │ │ +0004d9c0: 206d 6f76 6520 6163 726f 7373 2076 6f6c move across vol │ │ │ +0004d9d0: 756d 6573 2c20 7468 6520 736f 7572 6365 umes, the source │ │ │ +0004d9e0: 2073 686f 756c 6420 6e6f 7420 6265 2064 should not be d │ │ │ +0004d9f0: 656c 6574 6564 2075 6e74 696c 2074 6865 eleted until the │ │ │ +0004da00: 7927 7665 2061 6c6c 2062 6565 6e20 636f y've all been co │ │ │ +0004da10: 7069 6564 2e20 5468 6174 2077 6f75 6c64 pied. That would │ │ │ +0004da20: 206c 6574 2075 7320 726f 6c6c 6261 636b let us rollback │ │ │ +0004da30: 2077 6974 6820 6869 6768 6572 2063 6f6e with higher con │ │ │ +0004da40: 6669 6465 6e63 652e 3c2f 7464 3e3c 2f74 fidence.

    ideally, i │ │ │ +0004daa0: 6620 7765 2065 6e64 2075 7020 636f 7079 f we end up copy │ │ │ +0004dab0: 696e 6720 6669 6c65 7320 6265 6361 7573 ing files becaus │ │ │ +0004dac0: 6520 6f66 2061 206d 6f76 6520 6163 726f e of a move acro │ │ │ +0004dad0: 7373 0a76 6f6c 756d 6573 2c20 7468 6520 ss.volumes, the │ │ │ +0004dae0: 736f 7572 6365 2073 686f 756c 6420 6e6f source should no │ │ │ +0004daf0: 7420 6265 2064 656c 6574 6564 2075 6e74 t be deleted unt │ │ │ +0004db00: 696c 2074 6865 7927 7665 2061 6c6c 2062 il they've all b │ │ │ +0004db10: 6565 6e0a 636f 7069 6564 2e20 5468 6174 een.copied. That │ │ │ +0004db20: 2077 6f75 6c64 206c 6574 2075 7320 726f would let us ro │ │ │ +0004db30: 6c6c 6261 636b 2077 6974 6820 6869 6768 llback with high │ │ │ +0004db40: 6572 2063 6f6e 6669 6465 6e63 652e 3c2f er confidence.

    ../src/st │ │ │ +0004db60: 6f72 6167 655f 7574 696c 732e 6370 703a orage_utils.cpp: │ │ │ +0004db70: 3132 333c 2f68 343e 3c70 7265 2073 7479 123

    ..// later...a
    │ │ │ +0004dbc0: 7578 3a3a 7665 6374 6f72 266c 743b 626f  ux::vector<bo
    │ │ │ +0004dbd0: 6f6c 2c20 6669 6c65 5f69 6e64 6578 5f74  ol, file_index_t
    │ │ │ +0004dbe0: 2667 743b 2063 6f70 6965 645f 6669 6c65  > copied_file
    │ │ │ +0004dbf0: 7328 7374 643a 3a73 697a 655f 7428 662e  s(std::size_t(f.
    │ │ │ +0004dc00: 6e75 6d5f 6669 6c65 7328 2929 2c20 6661  num_files()), fa
    │ │ │ +0004dc10: 6c73 6529 3b0a 0a09 092f 2f20 7472 6163  lse);....// trac
    │ │ │ +0004dc20: 6b20 686f 7720 6661 7220 7765 2067 6f74  k how far we got
    │ │ │ +0004dc30: 2069 6e20 6361 7365 206f 6620 616e 2065   in case of an e
    │ │ │ +0004dc40: 7272 6f72 0a09 0966 696c 655f 696e 6465  rror...file_inde
    │ │ │ +0004dc50: 785f 7420 6669 6c65 5f69 6e64 6578 7b7d  x_t file_index{}
    │ │ │ +0004dc60: 3b0a 0909 666f 7220 2861 7574 6f20 636f  ;...for (auto co
    │ │ │ +0004dc70: 6e73 7420 6920 3a20 662e 6669 6c65 5f72  nst i : f.file_r
    │ │ │ +0004dc80: 616e 6765 2829 290a 0909 7b0a 0909 092f  ange())...{..../
    │ │ │ +0004dc90: 2f20 6669 6c65 7320 6d6f 7665 6420 6f75  / files moved ou
    │ │ │ +0004dca0: 7420 746f 2061 6273 6f6c 7574 6520 7061  t to absolute pa
    │ │ │ +0004dcb0: 7468 7320 6172 6520 6e6f 7420 6d6f 7665  ths are not move
    │ │ │ +0004dcc0: 640a 0909 0969 6620 2866 2e66 696c 655f  d....if (f.file_
    │ │ │ +0004dcd0: 6162 736f 6c75 7465 5f70 6174 6828 6929  absolute_path(i)
    │ │ │ +0004dce0: 2920 636f 6e74 696e 7565 3b0a 0a09 0909  ) continue;.....
    │ │ │ +0004dcf0: 7374 643a 3a73 7472 696e 6720 636f 6e73  std::string cons
    │ │ │ +0004dd00: 7420 6f6c 645f 7061 7468 203d 2063 6f6d  t old_path = com
    │ │ │ +0004dd10: 6269 6e65 5f70 6174 6828 7361 7665 5f70  bine_path(save_p
    │ │ │ +0004dd20: 6174 682c 2066 2e66 696c 655f 7061 7468  ath, f.file_path
    │ │ │ +0004dd30: 2869 2929 3b0a 0909 0973 7464 3a3a 7374  (i));....std::st
    │ │ │ +0004dd40: 7269 6e67 2063 6f6e 7374 206e 6577 5f70  ring const new_p
    │ │ │ +0004dd50: 6174 6820 3d20 636f 6d62 696e 655f 7061  ath = combine_pa
    │ │ │ +0004dd60: 7468 286e 6577 5f73 6176 655f 7061 7468  th(new_save_path
    │ │ │ +0004dd70: 2c20 662e 6669 6c65 5f70 6174 6828 6929  , f.file_path(i)
    │ │ │ +0004dd80: 293b 0a0a 0909 0965 7272 6f72 5f63 6f64  );.....error_cod
    │ │ │ +0004dd90: 6520 6967 6e6f 7265 3b0a 0909 0969 6620  e ignore;....if 
    │ │ │ +0004dda0: 2866 6c61 6773 203d 3d20 6d6f 7665 5f66  (flags == move_f
    │ │ │ +0004ddb0: 6c61 6773 5f74 3a3a 646f 6e74 5f72 6570  lags_t::dont_rep
    │ │ │ +0004ddc0: 6c61 6365 2026 616d 703b 2661 6d70 3b20  lace && 
    │ │ │ +0004ddd0: 6578 6973 7473 286e 6577 5f70 6174 682c  exists(new_path,
    │ │ │ +0004dde0: 2069 676e 6f72 6529 290a 0909 097b 0a09   ignore))....{..
    │ │ │ +0004ddf0: 0909 0972 6574 207c 3d20 6469 736b 5f73  ...ret |= disk_s
    │ │ │ +0004de00: 7461 7475 733a 3a6e 6565 645f 6675 6c6c  tatus::need_full
    │ │ │ +0004de10: 5f63 6865 636b 3b0a 0909 0909 636f 6e74  _check;.....cont
    │ │ │ +0004de20: 696e 7565 3b0a 0909 097d 0a0a 3c64 6976  inue;....}..
    ...mov │ │ │ +0004de60: 655f 6669 6c65 286f 6c64 5f70 6174 682c e_file(old_path, │ │ │ +0004de70: 206e 6577 5f70 6174 682c 2065 6329 3b0a new_path, ec);. │ │ │ +0004de80: 3c2f 6469 763e 0a09 0909 2f2f 2069 6620
    ....// if │ │ │ +0004de90: 7468 6520 736f 7572 6365 2066 696c 6520 the source file │ │ │ +0004dea0: 646f 6573 6e27 7420 6578 6973 742e 2054 doesn't exist. T │ │ │ +0004deb0: 6861 7427 7320 6e6f 7420 6120 7072 6f62 hat's not a prob │ │ │ +0004dec0: 6c65 6d0a 0909 092f 2f20 7765 206a 7573 lem....// we jus │ │ │ +0004ded0: 7420 6967 6e6f 7265 2074 6861 7420 6669 t ignore that fi │ │ │ +0004dee0: 6c65 0a09 0909 6966 2028 6563 2e65 6320 le....if (ec.ec │ │ │ +0004def0: 3d3d 2062 6f6f 7374 3a3a 7379 7374 656d == boost::system │ │ │ +0004df00: 3a3a 6572 7263 3a3a 6e6f 5f73 7563 685f ::errc::no_such_ │ │ │ +0004df10: 6669 6c65 5f6f 725f 6469 7265 6374 6f72 file_or_director │ │ │ +0004df20: 7929 0a09 0909 0965 632e 6563 2e63 6c65 y).....ec.ec.cle │ │ │ +0004df30: 6172 2829 3b0a 0909 0965 6c73 6520 6966 ar();....else if │ │ │ +0004df40: 2028 6563 0a09 0909 0926 616d 703b 2661 (ec.....&&a │ │ │ +0004df50: 6d70 3b20 6563 2e65 6320 213d 2062 6f6f mp; ec.ec != boo │ │ │ +0004df60: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ +0004df70: 3a3a 696e 7661 6c69 645f 6172 6775 6d65 ::invalid_argume │ │ │ +0004df80: 6e74 0a09 0909 0926 616d 703b 2661 6d70 nt.....&& │ │ │ +0004df90: 3b20 6563 2e65 6320 213d 2062 6f6f 7374 ; ec.ec != boost │ │ │ +0004dfa0: 3a3a 7379 7374 656d 3a3a 6572 7263 3a3a ::system::errc:: │ │ │ +0004dfb0: 7065 726d 6973 7369 6f6e 5f64 656e 6965 permission_denie │ │ │ +0004dfc0: 6429 0a09 0909 7b0a 0909 0909 2f2f 206d d)....{.....// m │ │ │ +0004dfd0: 6f76 696e 6720 7468 6520 6669 6c65 2066 oving the file f │ │ │ +0004dfe0: 6169 6c65 640a 0909 0909 2f2f 206f 6e20 ailed.....// on │ │ │ +0004dff0: 4f53 582c 2074 6865 2065 7272 6f72 2077 OSX, the error w │ │ │ +0004e000: 6865 6e20 7472 7969 6e67 2074 6f20 7265 hen trying to re │ │ │ +0004e010: 6e61 6d65 2061 2066 696c 6520 6163 726f name a file acro │ │ │ +0004e020: 7373 2064 6966 6665 7265 6e74 0a09 0909 ss different.... │ │ │ +0004e030: 092f 2f20 766f 6c75 6d65 7320 6973 2045 .// volumes is E │ │ │ +0004e040: 5844 4556 2c20 7768 6963 6820 7769 6c6c XDEV, which will │ │ │ +0004e050: 206d 616b 6520 6974 2066 616c 6c20 6261 make it fall ba │ │ │ +0004e060: 636b 2074 6f20 636f 7079 696e 672e 0a09 ck to copying... │ │ │ +0004e070: 0909 0965 632e 6563 2e63 6c65 6172 2829 ...ec.ec.clear() │ │ │ +0004e080: 3b0a 0909 0909 636f 7079 5f66 696c 6528 ;.....copy_file( │ │ │ +0004e090: 6f6c 645f 7061 7468 2c20 6e65 775f 7061 old_path, new_pa │ │ │ +0004e0a0: 7468 2c20 6563 293b 0a09 0909 0969 6620 th, ec);.....if │ │ │ +0004e0b0: 2821 6563 2920 636f 7069 6564 5f66 696c (!ec) copied_fil │ │ │ +0004e0c0: 6573 5b69 5d20 3d20 7472 7565 3b0a 0909 es[i] = true;... │ │ │ +0004e0d0: 097d 0a0a 0909 0969 6620 2865 6329 0a09 .}.....if (ec).. │ │ │ +0004e0e0: 0909 7b0a 0909 0909 6563 2e66 696c 6528 ..{.....ec.file( │ │ │ +0004e0f0: 6929 3b0a 0909 0909 6669 6c65 5f69 6e64 i);.....file_ind │ │ │ +0004e100: 6578 203d 2069 3b0a 0909 0909 6272 6561 ex = i;.....brea │ │ │ +0004e110: 6b3b 0a09 0909 7d0a 0909 7d0a 0a09 0969 k;....}...}....i │ │ │ +0004e120: 6620 2821 6563 2026 616d 703b 2661 6d70 f (!ec && │ │ │ +0004e130: 3b20 6d6f 7665 5f70 6172 7466 696c 6529 ; move_partfile) │ │ │ +0004e140: 0a09 097b 0a09 0909 6572 726f 725f 636f ...{....error_co │ │ │ +0004e150: 6465 2065 3b0a 0909 096d 6f76 655f 7061 de e;....move_pa │ │ │ +0004e160: 7274 6669 6c65 286e 6577 5f73 6176 655f rtfile(new_save_ │ │ │ +0004e170: 7061 7468 2c20 6529 3b0a 0909 0969 6620 path, e);....if │ │ │ +0004e180: 2865 290a 3c2f 7072 653e 3c2f 7464 3e3c (e).
    < │ │ │ +0004e190: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0004e1c0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0004e1f0: 2e2f 7372 632f 7374 6f72 6167 655f 7574 ./src/storage_ut │ │ │ +0004e200: 696c 732e 6370 703a 3433 313c 2f61 3e3c ils.cpp:431< │ │ │ +0004e210: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ +0004e220: 2073 6565 6d20 7265 6173 6f6e 6162 6c65 seem reasonable │ │ │ +0004e230: 2074 6f2c 2069 6e73 7465 6164 2c20 7365 to, instead, se │ │ │ +0004e240: 7420 7468 6520 6861 7665 5f70 6965 6365 t the have_piece │ │ │ +0004e250: 7320 6269 7473 2066 6f72 2074 6865 2070 s bits for the p │ │ │ +0004e260: 6965 6365 7320 7265 7072 6573 656e 7469 ieces representi │ │ │ +0004e270: 6e67 2074 6865 7365 2066 696c 6573 2c20 ng these files, │ │ │ +0004e280: 616e 6420 7265 7375 6d65 2077 6974 6820 and resume with │ │ │ +0004e290: 7468 6520 6e6f 726d 616c 206c 6f67 6963 the normal logic │ │ │ +0004e2a0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ +0004e2f0: 2077 6f75 6c64 2073 6565 6d20 7265 6173 would seem reas │ │ │ +0004e300: 6f6e 6162 6c65 2074 6f2c 2069 6e73 7465 onable to, inste │ │ │ +0004e310: 6164 2c20 7365 7420 7468 6520 6861 7665 ad, set the have │ │ │ +0004e320: 5f70 6965 6365 7320 6269 7473 0a66 6f72 _pieces bits.for │ │ │ +0004e330: 2074 6865 2070 6965 6365 7320 7265 7072 the pieces repr │ │ │ +0004e340: 6573 656e 7469 6e67 2074 6865 7365 2066 esenting these f │ │ │ +0004e350: 696c 6573 2c20 616e 6420 7265 7375 6d65 iles, and resume │ │ │ +0004e360: 2077 6974 6820 7468 6520 6e6f 726d 616c with the normal │ │ │ +0004e370: 0a6c 6f67 6963 3c2f 6832 3e3c 6834 3e2e .logic

    . │ │ │ +0004e380: 2e2f 7372 632f 7374 6f72 6167 655f 7574 ./src/storage_ut │ │ │ +0004e390: 696c 732e 6370 703a 3433 313c 2f68 343e ils.cpp:431

    │ │ │ +0004e3a0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .....c
    │ │ │ +0004e3e0: 6f6e 7469 6e75 653b 0a0a 0909 0909 7374  ontinue;......st
    │ │ │ +0004e3f0: 643a 3a69 6e74 3634 5f74 2063 6f6e 7374  d::int64_t const
    │ │ │ +0004e400: 2073 697a 6520 3d20 6765 745f 6669 6c65   size = get_file
    │ │ │ +0004e410: 7369 7a65 2873 7461 742c 2066 696c 655f  size(stat, file_
    │ │ │ +0004e420: 696e 6465 782c 2066 730a 0909 0909 092c  index, fs......,
    │ │ │ +0004e430: 2073 6176 655f 7061 7468 2c20 6563 293b   save_path, ec);
    │ │ │ +0004e440: 0a09 0909 0969 6620 2873 697a 6520 266c  .....if (size &l
    │ │ │ +0004e450: 743b 2030 2920 7265 7475 726e 2066 616c  t; 0) return fal
    │ │ │ +0004e460: 7365 3b0a 0a09 0909 0969 6620 2873 697a  se;......if (siz
    │ │ │ +0004e470: 6520 266c 743b 2066 732e 6669 6c65 5f73  e < fs.file_s
    │ │ │ +0004e480: 697a 6528 6669 6c65 5f69 6e64 6578 2929  ize(file_index))
    │ │ │ +0004e490: 0a09 0909 097b 0a09 0909 0909 6563 2e65  .....{......ec.e
    │ │ │ +0004e4a0: 6320 3d20 6572 726f 7273 3a3a 6d69 736d  c = errors::mism
    │ │ │ +0004e4b0: 6174 6368 696e 675f 6669 6c65 5f73 697a  atching_file_siz
    │ │ │ +0004e4c0: 653b 0a09 0909 0909 6563 2e66 696c 6528  e;......ec.file(
    │ │ │ +0004e4d0: 6669 6c65 5f69 6e64 6578 293b 0a09 0909  file_index);....
    │ │ │ +0004e4e0: 0909 6563 2e6f 7065 7261 7469 6f6e 203d  ..ec.operation =
    │ │ │ +0004e4f0: 206f 7065 7261 7469 6f6e 5f74 3a3a 6368   operation_t::ch
    │ │ │ +0004e500: 6563 6b5f 7265 7375 6d65 3b0a 0909 0909  eck_resume;.....
    │ │ │ +0004e510: 0972 6574 7572 6e20 6661 6c73 653b 0a09  .return false;..
    │ │ │ +0004e520: 0909 097d 0a09 0909 7d0a 0909 0972 6574  ...}....}....ret
    │ │ │ +0004e530: 7572 6e20 7472 7565 3b0a 0909 7d0a 0a23  urn true;...}..#
    │ │ │ +0004e540: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ +0004e550: 4953 4142 4c45 5f4d 5554 4142 4c45 5f54  ISABLE_MUTABLE_T
    │ │ │ +0004e560: 4f52 5245 4e54 530a 0909 2f2f 2061 6c77  ORRENTS...// alw
    │ │ │ +0004e570: 6179 7320 7472 6967 6765 7220 6120 6675  ays trigger a fu
    │ │ │ +0004e580: 6c6c 2072 6563 6865 636b 2077 6865 6e20  ll recheck when 
    │ │ │ +0004e590: 7765 2070 756c 6c20 696e 2066 696c 6573  we pull in files
    │ │ │ +0004e5a0: 2066 726f 6d20 6f74 6865 720a 0909 2f2f   from other...//
    │ │ │ +0004e5b0: 2074 6f72 7265 6e74 732c 2076 6961 2068   torrents, via h
    │ │ │ +0004e5c0: 6172 6420 6c69 6e6b 730a 3c64 6976 2073  ard links.
    ..if (ad │ │ │ +0004e600: 6465 645f 6669 6c65 7329 2072 6574 7572 ded_files) retur │ │ │ +0004e610: 6e20 6661 6c73 653b 0a3c 2f64 6976 3e23 n false;.
    # │ │ │ +0004e620: 656e 6469 660a 0a09 092f 2f20 7061 7273 endif....// pars │ │ │ +0004e630: 6520 6861 7665 2062 6974 6d61 736b 2e20 e have bitmask. │ │ │ +0004e640: 5665 7269 6679 2074 6861 7420 6669 6c65 Verify that file │ │ │ +0004e650: 7320 746f 7563 6865 6420 6279 2063 6f6d s touched by com │ │ │ +0004e660: 706c 6574 6564 2070 6965 6365 730a 0909 pleted pieces... │ │ │ +0004e670: 2f2f 2061 6374 7561 6c6c 7920 6578 6973 // actually exis │ │ │ +0004e680: 742e 2041 2063 6f6d 706c 6574 6564 2070 t. A completed p │ │ │ +0004e690: 6965 6365 206d 6179 2073 7061 6e20 6d75 iece may span mu │ │ │ +0004e6a0: 6c74 6970 6c65 2066 696c 6573 2e0a 0909 ltiple files.... │ │ │ +0004e6b0: 666f 7220 2866 696c 655f 696e 6465 785f for (file_index_ │ │ │ +0004e6c0: 7420 636f 6e73 7420 6669 6c65 5f69 6e64 t const file_ind │ │ │ +0004e6d0: 6578 203a 2066 732e 6669 6c65 5f72 616e ex : fs.file_ran │ │ │ +0004e6e0: 6765 2829 290a 0909 7b0a 0909 092f 2f20 ge())...{....// │ │ │ +0004e6f0: 6669 6c65 7320 7769 7468 2070 7269 6f72 files with prior │ │ │ +0004e700: 6974 7920 7a65 726f 206d 6179 206e 6f74 ity zero may not │ │ │ +0004e710: 2068 6176 6520 6265 656e 2073 6176 6564 have been saved │ │ │ +0004e720: 2074 6f20 6469 736b 2061 7420 7468 6569 to disk at thei │ │ │ +0004e730: 720a 0909 092f 2f20 6578 7065 6374 6564 r....// expected │ │ │ +0004e740: 206c 6f63 6174 696f 6e2c 2062 7574 2069 location, but i │ │ │ +0004e750: 7320 6c69 6b65 6c79 2074 6f20 6265 2069 s likely to be i │ │ │ +0004e760: 6e20 6120 7061 7274 6669 6c65 2e20 4a75 n a partfile. Ju │ │ │ +0004e770: 7374 2065 7865 6d70 7420 6974 0a09 0909 st exempt it.... │ │ │ +0004e780: 2f2f 2066 726f 6d20 6368 6563 6b69 6e67 // from checking │ │ │ +0004e790: 0a09 0909 6966 2028 6669 6c65 5f69 6e64 ....if (file_ind │ │ │ +0004e7a0: 6578 2026 6c74 3b20 6669 6c65 5f70 7269 ex < file_pri │ │ │ +0004e7b0: 6f72 6974 792e 656e 645f 696e 6465 7828 ority.end_index( │ │ │ +0004e7c0: 290a 0909 0909 2661 6d70 3b26 616d 703b ).....&& │ │ │ +0004e7d0: 2066 696c 655f 7072 696f 7269 7479 5b66 file_priority[f │ │ │ +0004e7e0: 696c 655f 696e 6465 785d 203d 3d20 646f ile_index] == do │ │ │ +0004e7f0: 6e74 5f64 6f77 6e6c 6f61 6429 0a09 0909 nt_download).... │ │ │ +0004e800: 0963 6f6e 7469 6e75 653b 0a0a 0909 0969 .continue;.....i │ │ │ +0004e810: 6620 2866 732e 7061 645f 6669 6c65 5f61 f (fs.pad_file_a │ │ │ +0004e820: 7428 6669 6c65 5f69 6e64 6578 2929 2063 t(file_index)) c │ │ │ +0004e830: 6f6e 7469 6e75 653b 0a09 0909 6966 2028 ontinue;....if ( │ │ │ +0004e840: 6673 2e66 696c 655f 7369 7a65 2866 696c fs.file_size(fil │ │ │ +0004e850: 655f 696e 6465 7829 203d 3d20 3029 2063 e_index) == 0) c │ │ │ +0004e860: 6f6e 7469 6e75 653b 0a0a 0909 0961 7574 ontinue;.....aut │ │ │ +0004e870: 6f20 636f 6e73 7420 7069 6563 655f 7261 o const piece_ra │ │ │ +0004e880: 6e67 6520 3d20 6175 783a 3a66 696c 655f nge = aux::file_ │ │ │ +0004e890: 7069 6563 655f 7261 6e67 655f 696e 636c piece_range_incl │ │ │ +0004e8a0: 7573 6976 6528 6673 2c20 6669 6c65 5f69 usive(fs, file_i │ │ │ +0004e8b0: 6e64 6578 293b 0a09 0909 7069 6563 655f ndex);....piece_ │ │ │ +0004e8c0: 696e 6465 785f 7420 636f 6e73 7420 7374 index_t const st │ │ │ +0004e8d0: 6172 745f 7069 6563 6520 3d20 7069 6563 art_piece = piec │ │ │ +0004e8e0: 655f 7261 6e67 652e 5f62 6567 696e 3b0a e_range._begin;. │ │ │ +0004e8f0: 0a09 0909 7069 6563 655f 696e 6465 785f ....piece_index_ │ │ │ +0004e900: 7420 636f 6e73 7420 656e 645f 7069 6563 t const end_piec │ │ │ +0004e910: 6520 3d20 7374 643a 3a6d 696e 2870 6965 e = std::min(pie │ │ │ +0004e920: 6365 5f72 616e 6765 2e5f 656e 642c 2072 ce_range._end, r │ │ │ +0004e930: 642e 6861 7665 5f70 6965 6365 732e 656e d.have_pieces.en │ │ │ +0004e940: 645f 696e 6465 7828 2929 3b0a 0a09 0909 d_index());..... │ │ │ +0004e950: 626f 6f6c 2068 6173 5f63 6f6d 706c 6574 bool has_complet │ │ │ +0004e960: 6564 5f72 6573 756d 655f 7069 6563 6520 ed_resume_piece │ │ │ +0004e970: 3d20 6661 6c73 653b 0a09 0909 666f 7220 = false;....for │ │ │ +0004e980: 2870 6965 6365 5f69 6e64 6578 5f74 2070 (piece_index_t p │ │ │ +0004e990: 6965 6365 203d 2073 7461 7274 5f70 6965 iece = start_pie │ │ │ +0004e9a0: 6365 3b20 7069 6563 6520 266c 743b 2065 ce; piece < e │ │ │ +0004e9b0: 6e64 5f70 6965 6365 3b20 2b2b 7069 6563 nd_piece; ++piec │ │ │ +0004e9c0: 6529 0a09 0909 7b0a 0909 0909 6966 2028 e)....{.....if ( │ │ │ +0004e9d0: 2172 642e 6861 7665 5f70 6965 6365 732e !rd.have_pieces. │ │ │ +0004e9e0: 6765 745f 6269 7428 7069 6563 6529 2920 get_bit(piece)) │ │ │ +0004e9f0: 636f 6e74 696e 7565 3b0a 0909 0909 6861 continue;.....ha │ │ │ +0004ea00: 735f 636f 6d70 6c65 7465 645f 7265 7375 s_completed_resu │ │ │ +0004ea10: 6d65 5f70 6965 6365 203d 2074 7275 653b me_piece = true; │ │ │ +0004ea20: 0a09 0909 0962 7265 616b 3b0a 0909 097d .....break;....} │ │ │ +0004ea30: 0a0a 0909 0969 6620 2821 6861 735f 636f .....if (!has_co │ │ │ +0004ea40: 6d70 6c65 7465 645f 7265 7375 6d65 5f70 mpleted_resume_p │ │ │ +0004ea50: 6965 6365 2920 636f 6e74 696e 7565 3b0a iece) continue;. │ │ │ +0004ea60: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0004ea70: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0004eaa0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +0004ead0: 632f 656e 756d 5f6e 6574 2e63 7070 3a32 c/enum_net.cpp:2 │ │ │ +0004eae0: 3436 3c2f 613e 3c2f 7464 3e3c 7464 3e69 46i │ │ │ +0004eaf0: 6620 7765 2067 6574 2068 6572 652c 2074 f we get here, t │ │ │ +0004eb00: 6865 2063 616c 6c65 7220 7374 696c 6c20 he caller still │ │ │ +0004eb10: 6173 7375 6d65 7320 7468 6520 6572 726f assumes the erro │ │ │ +0004eb20: 7220 636f 6465 2069 7320 7265 706f 7274 r code is report │ │ │ +0004eb30: 6564 2076 6961 2065 7272 6e6f 3c2f 7464 ed via errno

    if we │ │ │ +0004eb90: 6765 7420 6865 7265 2c20 7468 6520 6361 get here, the ca │ │ │ +0004eba0: 6c6c 6572 2073 7469 6c6c 2061 7373 756d ller still assum │ │ │ +0004ebb0: 6573 2074 6865 2065 7272 6f72 2063 6f64 es the error cod │ │ │ +0004ebc0: 650a 6973 2072 6570 6f72 7465 6420 7669 e.is reported vi │ │ │ +0004ebd0: 6120 6572 726e 6f3c 2f68 323e 3c68 343e a errno

    │ │ │ +0004ebe0: 2e2e 2f73 7263 2f65 6e75 6d5f 6e65 742e ../src/enum_net. │ │ │ +0004ebf0: 6370 703a 3234 363c 2f68 343e 3c70 7265 cpp:246

    ..;..}.#en
    │ │ │ +0004ec40: 6469 660a 0a23 6966 2054 4f52 5245 4e54  dif..#if TORRENT
    │ │ │ +0004ec50: 5f55 5345 5f4e 4554 4c49 4e4b 0a0a 0969  _USE_NETLINK...i
    │ │ │ +0004ec60: 6e74 2072 6561 645f 6e6c 5f73 6f63 6b28  nt read_nl_sock(
    │ │ │ +0004ec70: 696e 7420 736f 636b 2c20 7374 643a 3a75  int sock, std::u
    │ │ │ +0004ec80: 696e 7433 325f 7420 636f 6e73 7420 7365  int32_t const se
    │ │ │ +0004ec90: 712c 2073 7464 3a3a 7569 6e74 3332 5f74  q, std::uint32_t
    │ │ │ +0004eca0: 2063 6f6e 7374 2070 6964 0a09 092c 2073   const pid..., s
    │ │ │ +0004ecb0: 7464 3a3a 6675 6e63 7469 6f6e 266c 743b  td::function<
    │ │ │ +0004ecc0: 766f 6964 286e 6c6d 7367 6864 7220 636f  void(nlmsghdr co
    │ │ │ +0004ecd0: 6e73 742a 2926 6774 3b20 6f6e 5f6d 7367  nst*)> on_msg
    │ │ │ +0004ece0: 290a 097b 0a09 0973 7464 3a3a 6172 7261  )..{...std::arra
    │ │ │ +0004ecf0: 7926 6c74 3b63 6861 722c 2034 3039 3626  y<char, 4096&
    │ │ │ +0004ed00: 6774 3b20 6275 663b 0a09 0966 6f72 2028  gt; buf;...for (
    │ │ │ +0004ed10: 3b3b 290a 0909 7b0a 0909 0969 6e74 2063  ;;)...{....int c
    │ │ │ +0004ed20: 6f6e 7374 2072 6561 645f 6c65 6e20 3d20  onst read_len = 
    │ │ │ +0004ed30: 696e 7428 7265 6376 2873 6f63 6b2c 2062  int(recv(sock, b
    │ │ │ +0004ed40: 7566 2e64 6174 6128 292c 2062 7566 2e73  uf.data(), buf.s
    │ │ │ +0004ed50: 697a 6528 292c 2030 2929 3b0a 0909 0969  ize(), 0));....i
    │ │ │ +0004ed60: 6620 2872 6561 645f 6c65 6e20 266c 743b  f (read_len <
    │ │ │ +0004ed70: 2030 2920 7265 7475 726e 202d 313b 0a0a   0) return -1;..
    │ │ │ +0004ed80: 0909 0961 7574 6f20 636f 6e73 742a 206e  ...auto const* n
    │ │ │ +0004ed90: 6c5f 6864 7220 3d20 7265 696e 7465 7270  l_hdr = reinterp
    │ │ │ +0004eda0: 7265 745f 6361 7374 266c 743b 6e6c 6d73  ret_cast<nlms
    │ │ │ +0004edb0: 6768 6472 2063 6f6e 7374 2a26 6774 3b28  ghdr const*>(
    │ │ │ +0004edc0: 6275 662e 6461 7461 2829 293b 0a09 0909  buf.data());....
    │ │ │ +0004edd0: 696e 7420 6c65 6e20 3d20 7265 6164 5f6c  int len = read_l
    │ │ │ +0004ede0: 656e 3b0a 0a09 0909 666f 7220 283b 206c  en;.....for (; l
    │ │ │ +0004edf0: 656e 2026 6774 3b20 3020 2661 6d70 3b26  en > 0 &&
    │ │ │ +0004ee00: 616d 703b 2061 7578 3a3a 6e6c 6d73 675f  amp; aux::nlmsg_
    │ │ │ +0004ee10: 6f6b 286e 6c5f 6864 722c 206c 656e 293b  ok(nl_hdr, len);
    │ │ │ +0004ee20: 206e 6c5f 6864 7220 3d20 6175 783a 3a6e   nl_hdr = aux::n
    │ │ │ +0004ee30: 6c6d 7367 5f6e 6578 7428 6e6c 5f68 6472  lmsg_next(nl_hdr
    │ │ │ +0004ee40: 2c20 6c65 6e29 290a 0909 097b 0a3c 6469  , len))....{.....i
    │ │ │ +0004ee80: 6620 2828 6175 783a 3a6e 6c6d 7367 5f6f  f ((aux::nlmsg_o
    │ │ │ +0004ee90: 6b28 6e6c 5f68 6472 2c20 7265 6164 5f6c  k(nl_hdr, read_l
    │ │ │ +0004eea0: 656e 2920 3d3d 2030 2920 7c7c 2028 6e6c  en) == 0) || (nl
    │ │ │ +0004eeb0: 5f68 6472 2d26 6774 3b6e 6c6d 7367 5f74  _hdr->nlmsg_t
    │ │ │ +0004eec0: 7970 6520 3d3d 204e 4c4d 5347 5f45 5252  ype == NLMSG_ERR
    │ │ │ +0004eed0: 4f52 2929 0a3c 2f64 6976 3e09 0909 0909  OR)).

    ..... │ │ │ +0004eee0: 7265 7475 726e 202d 313b 0a09 0909 092f return -1;...../ │ │ │ +0004eef0: 2f20 7468 6973 2066 756e 6374 696f 6e20 / this function │ │ │ +0004ef00: 646f 6573 6e27 7420 6861 6e64 6c65 206d doesn't handle m │ │ │ +0004ef10: 756c 7469 706c 6520 7265 7175 6573 7473 ultiple requests │ │ │ +0004ef20: 2061 7420 7468 6520 7361 6d65 2074 696d at the same tim │ │ │ +0004ef30: 650a 0909 0909 2f2f 2073 6f20 7265 706f e.....// so repo │ │ │ +0004ef40: 7274 2061 6e20 6572 726f 7220 6966 2074 rt an error if t │ │ │ +0004ef50: 6865 206d 6573 7361 6765 2064 6f65 7320 he message does │ │ │ +0004ef60: 6e6f 7420 6861 7665 2074 6865 2065 7870 not have the exp │ │ │ +0004ef70: 6563 7465 6420 7365 7120 616e 6420 7069 ected seq and pi │ │ │ +0004ef80: 640a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 d.
    < │ │ │ +0004efb0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0004efc0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0004eff0: 7372 632f 656e 756d 5f6e 6574 2e63 7070 src/enum_net.cpp │ │ │ +0004f000: 3a32 3532 3c2f 613e 3c2f 7464 3e3c 7464 :252if we get here, │ │ │ +0004f020: 2074 6865 2063 616c 6c65 7220 7374 696c the caller stil │ │ │ +0004f030: 6c20 6173 7375 6d65 7320 7468 6520 6572 l assumes the er │ │ │ +0004f040: 726f 7220 636f 6465 2069 7320 7265 706f ror code is repo │ │ │ +0004f050: 7274 6564 2076 6961 2065 7272 6e6f 3c2f rted via errno

    if w │ │ │ +0004f0b0: 6520 6765 7420 6865 7265 2c20 7468 6520 e get here, the │ │ │ +0004f0c0: 6361 6c6c 6572 2073 7469 6c6c 2061 7373 caller still ass │ │ │ +0004f0d0: 756d 6573 2074 6865 2065 7272 6f72 2063 umes the error c │ │ │ +0004f0e0: 6f64 650a 6973 2072 6570 6f72 7465 6420 ode.is reported │ │ │ +0004f0f0: 7669 6120 6572 726e 6f3c 2f68 323e 3c68 via errno

    ../src/enum_ne │ │ │ +0004f110: 742e 6370 703a 3235 323c 2f68 343e 3c70 t.cpp:252

    #if TORR │ │ │ +0004f160: 454e 545f 5553 455f 4e45 544c 494e 4b0a ENT_USE_NETLINK. │ │ │ +0004f170: 0a09 696e 7420 7265 6164 5f6e 6c5f 736f ..int read_nl_so │ │ │ +0004f180: 636b 2869 6e74 2073 6f63 6b2c 2073 7464 ck(int sock, std │ │ │ +0004f190: 3a3a 7569 6e74 3332 5f74 2063 6f6e 7374 ::uint32_t const │ │ │ +0004f1a0: 2073 6571 2c20 7374 643a 3a75 696e 7433 seq, std::uint3 │ │ │ +0004f1b0: 325f 7420 636f 6e73 7420 7069 640a 0909 2_t const pid... │ │ │ +0004f1c0: 2c20 7374 643a 3a66 756e 6374 696f 6e26 , std::function& │ │ │ +0004f1d0: 6c74 3b76 6f69 6428 6e6c 6d73 6768 6472 lt;void(nlmsghdr │ │ │ +0004f1e0: 2063 6f6e 7374 2a29 2667 743b 206f 6e5f const*)> on_ │ │ │ +0004f1f0: 6d73 6729 0a09 7b0a 0909 7374 643a 3a61 msg)..{...std::a │ │ │ +0004f200: 7272 6179 266c 743b 6368 6172 2c20 3430 rray<char, 40 │ │ │ +0004f210: 3936 2667 743b 2062 7566 3b0a 0909 666f 96> buf;...fo │ │ │ +0004f220: 7220 283b 3b29 0a09 097b 0a09 0909 696e r (;;)...{....in │ │ │ +0004f230: 7420 636f 6e73 7420 7265 6164 5f6c 656e t const read_len │ │ │ +0004f240: 203d 2069 6e74 2872 6563 7628 736f 636b = int(recv(sock │ │ │ +0004f250: 2c20 6275 662e 6461 7461 2829 2c20 6275 , buf.data(), bu │ │ │ +0004f260: 662e 7369 7a65 2829 2c20 3029 293b 0a09 f.size(), 0));.. │ │ │ +0004f270: 0909 6966 2028 7265 6164 5f6c 656e 2026 ..if (read_len & │ │ │ +0004f280: 6c74 3b20 3029 2072 6574 7572 6e20 2d31 lt; 0) return -1 │ │ │ +0004f290: 3b0a 0a09 0909 6175 746f 2063 6f6e 7374 ;.....auto const │ │ │ +0004f2a0: 2a20 6e6c 5f68 6472 203d 2072 6569 6e74 * nl_hdr = reint │ │ │ +0004f2b0: 6572 7072 6574 5f63 6173 7426 6c74 3b6e erpret_cast<n │ │ │ +0004f2c0: 6c6d 7367 6864 7220 636f 6e73 742a 2667 lmsghdr const*&g │ │ │ +0004f2d0: 743b 2862 7566 2e64 6174 6128 2929 3b0a t;(buf.data());. │ │ │ +0004f2e0: 0909 0969 6e74 206c 656e 203d 2072 6561 ...int len = rea │ │ │ +0004f2f0: 645f 6c65 6e3b 0a0a 0909 0966 6f72 2028 d_len;.....for ( │ │ │ +0004f300: 3b20 6c65 6e20 2667 743b 2030 2026 616d ; len > 0 &am │ │ │ +0004f310: 703b 2661 6d70 3b20 6175 783a 3a6e 6c6d p;& aux::nlm │ │ │ +0004f320: 7367 5f6f 6b28 6e6c 5f68 6472 2c20 6c65 sg_ok(nl_hdr, le │ │ │ +0004f330: 6e29 3b20 6e6c 5f68 6472 203d 2061 7578 n); nl_hdr = aux │ │ │ +0004f340: 3a3a 6e6c 6d73 675f 6e65 7874 286e 6c5f ::nlmsg_next(nl_ │ │ │ +0004f350: 6864 722c 206c 656e 2929 0a09 0909 7b0a hdr, len))....{. │ │ │ +0004f360: 0909 0909 6966 2028 2861 7578 3a3a 6e6c ....if ((aux::nl │ │ │ +0004f370: 6d73 675f 6f6b 286e 6c5f 6864 722c 2072 msg_ok(nl_hdr, r │ │ │ +0004f380: 6561 645f 6c65 6e29 203d 3d20 3029 207c ead_len) == 0) | │ │ │ +0004f390: 7c20 286e 6c5f 6864 722d 2667 743b 6e6c | (nl_hdr->nl │ │ │ +0004f3a0: 6d73 675f 7479 7065 203d 3d20 4e4c 4d53 msg_type == NLMS │ │ │ +0004f3b0: 475f 4552 524f 5229 290a 0909 0909 0972 G_ERROR))......r │ │ │ +0004f3c0: 6574 7572 6e20 2d31 3b0a 0909 0909 2f2f eturn -1;.....// │ │ │ +0004f3d0: 2074 6869 7320 6675 6e63 7469 6f6e 2064 this function d │ │ │ +0004f3e0: 6f65 736e 2774 2068 616e 646c 6520 6d75 oesn't handle mu │ │ │ +0004f3f0: 6c74 6970 6c65 2072 6571 7565 7374 7320 ltiple requests │ │ │ +0004f400: 6174 2074 6865 2073 616d 6520 7469 6d65 at the same time │ │ │ +0004f410: 0a09 0909 092f 2f20 736f 2072 6570 6f72 .....// so repor │ │ │ +0004f420: 7420 616e 2065 7272 6f72 2069 6620 7468 t an error if th │ │ │ +0004f430: 6520 6d65 7373 6167 6520 646f 6573 206e e message does n │ │ │ +0004f440: 6f74 2068 6176 6520 7468 6520 6578 7065 ot have the expe │ │ │ +0004f450: 6374 6564 2073 6571 2061 6e64 2070 6964 cted seq and pid │ │ │ +0004f460: 0a3c 6469 7620 7374 796c 653d 2262 6163 .

    . │ │ │ +0004f490: 0909 0969 6620 286e 6c5f 6864 722d 2667 ...if (nl_hdr-&g │ │ │ +0004f4a0: 743b 6e6c 6d73 675f 7365 7120 213d 2073 t;nlmsg_seq != s │ │ │ +0004f4b0: 6571 207c 7c20 6e6c 5f68 6472 2d26 6774 eq || nl_hdr-> │ │ │ +0004f4c0: 3b6e 6c6d 7367 5f70 6964 2021 3d20 7069 ;nlmsg_pid != pi │ │ │ +0004f4d0: 6429 0a3c 2f64 6976 3e09 0909 0909 7265 d).
    .....re │ │ │ +0004f4e0: 7475 726e 202d 313b 0a0a 0909 0909 6966 turn -1;......if │ │ │ +0004f4f0: 2028 6e6c 5f68 6472 2d26 6774 3b6e 6c6d (nl_hdr->nlm │ │ │ +0004f500: 7367 5f74 7970 6520 3d3d 204e 4c4d 5347 sg_type == NLMSG │ │ │ +0004f510: 5f44 4f4e 4529 2072 6574 7572 6e20 303b _DONE) return 0; │ │ │ +0004f520: 0a0a 0909 0909 6f6e 5f6d 7367 286e 6c5f ......on_msg(nl_ │ │ │ +0004f530: 6864 7229 3b0a 0a09 0909 0969 6620 2828 hdr);......if (( │ │ │ +0004f540: 6e6c 5f68 6472 2d26 6774 3b6e 6c6d 7367 nl_hdr->nlmsg │ │ │ +0004f550: 5f66 6c61 6773 2026 616d 703b 204e 4c4d _flags & NLM │ │ │ +0004f560: 5f46 5f4d 554c 5449 2920 3d3d 2030 2920 _F_MULTI) == 0) │ │ │ +0004f570: 7265 7475 726e 2030 3b0a 0909 097d 0a09 return 0;....}.. │ │ │ +0004f580: 097d 0a2f 2f09 0972 6574 7572 6e20 303b .}.//..return 0; │ │ │ +0004f590: 0a09 7d0a 0a09 696e 7420 6e6c 5f64 756d ..}...int nl_dum │ │ │ +0004f5a0: 705f 7265 7175 6573 7428 696e 7420 636f p_request(int co │ │ │ +0004f5b0: 6e73 7420 736f 636b 2c20 7374 643a 3a75 nst sock, std::u │ │ │ +0004f5c0: 696e 7433 325f 7420 636f 6e73 7420 7365 int32_t const se │ │ │ +0004f5d0: 710a 0909 2c20 6e6c 6d73 6768 6472 2a20 q..., nlmsghdr* │ │ │ +0004f5e0: 636f 6e73 7420 7265 7175 6573 745f 6d73 const request_ms │ │ │ +0004f5f0: 672c 2073 7464 3a3a 6675 6e63 7469 6f6e g, std::function │ │ │ +0004f600: 266c 743b 766f 6964 286e 6c6d 7367 6864 <void(nlmsghd │ │ │ +0004f610: 7220 636f 6e73 742a 2926 6774 3b20 6f6e r const*)> on │ │ │ +0004f620: 5f6d 7367 290a 097b 0a09 0972 6571 7565 _msg)..{...reque │ │ │ +0004f630: 7374 5f6d 7367 2d26 6774 3b6e 6c6d 7367 st_msg->nlmsg │ │ │ +0004f640: 5f66 6c61 6773 203d 204e 4c4d 5f46 5f44 _flags = NLM_F_D │ │ │ +0004f650: 554d 5020 7c20 4e4c 4d5f 465f 5245 5155 UMP | NLM_F_REQU │ │ │ +0004f660: 4553 543b 0a09 0972 6571 7565 7374 5f6d EST;...request_m │ │ │ +0004f670: 7367 2d26 6774 3b6e 6c6d 7367 5f73 6571 sg->nlmsg_seq │ │ │ +0004f680: 203d 2073 6571 3b0a 0909 2f2f 2069 6e20 = seq;...// in │ │ │ +0004f690: 7468 656f 7279 206e 6c6d 7367 5f70 6964 theory nlmsg_pid │ │ │ +0004f6a0: 2073 686f 756c 6420 6265 2073 6574 2074 should be set t │ │ │ +0004f6b0: 6f20 7468 6520 6e65 746c 696e 6b20 706f o the netlink po │ │ │ +0004f6c0: 7274 2049 4420 284e 4f54 2074 6865 2070 rt ID (NOT the p │ │ │ +0004f6d0: 726f 6365 7373 2049 4429 0a09 092f 2f20 rocess ID)...// │ │ │ +0004f6e0: 6f66 2074 6865 2073 656e 6465 722c 2062 of the sender, b │ │ │ +0004f6f0: 7574 2074 6865 206b 6572 6e65 6c20 6967 ut the kernel ig │ │ │ +0004f700: 6e6f 7265 7320 7468 6973 2066 6965 6c64 nores this field │ │ │ +0004f710: 2073 6f20 6974 2069 7320 7479 7069 6361 so it is typica │ │ │ +0004f720: 6c6c 7920 7365 7420 746f 0a09 092f 2f20 lly set to...// │ │ │ +0004f730: 7a65 726f 0a09 0972 6571 7565 7374 5f6d zero...request_m │ │ │ +0004f740: 7367 2d26 6774 3b6e 6c6d 7367 5f70 6964 sg->nlmsg_pid │ │ │ +0004f750: 203d 2030 3b0a 0a09 0969 6620 283a 3a73 = 0;....if (::s │ │ │ +0004f760: 656e 6428 736f 636b 2c20 7265 7175 6573 end(sock, reques │ │ │ +0004f770: 745f 6d73 672c 2072 6571 7565 7374 5f6d t_msg, request_m │ │ │ +0004f780: 7367 2d26 6774 3b6e 6c6d 7367 5f6c 656e sg->nlmsg_len │ │ │ +0004f790: 2c20 3029 2026 6c74 3b20 3029 0a09 0909 , 0) < 0).... │ │ │ +0004f7a0: 7265 7475 726e 202d 313b 0a0a 0909 2f2f return -1;....// │ │ │ +0004f7b0: 2067 6574 2074 6865 2073 6f63 6b65 7427 get the socket' │ │ │ +0004f7c0: 7320 706f 7274 2049 4420 736f 2074 6861 s port ID so tha │ │ │ +0004f7d0: 7420 7765 2063 616e 2076 6572 6966 7920 t we can verify │ │ │ +0004f7e0: 6974 2069 6e20 7468 6520 7265 7370 6f6e it in the respon │ │ │ +0004f7f0: 7365 0a09 0973 6f63 6b61 6464 725f 6e6c se...sockaddr_nl │ │ │ +0004f800: 2073 6f63 6b5f 6164 6472 3b0a 0909 736f sock_addr;...so │ │ │ +0004f810: 636b 6c65 6e5f 7420 736f 636b 5f61 6464 cklen_t sock_add │ │ │ +0004f820: 725f 6c65 6e20 3d20 7369 7a65 6f66 2873 r_len = sizeof(s │ │ │ +0004f830: 6f63 6b5f 6164 6472 293b 0a09 0969 6620 ock_addr);...if │ │ │ +0004f840: 283a 3a67 6574 736f 636b 6e61 6d65 2873 (::getsockname(s │ │ │ +0004f850: 6f63 6b2c 2072 6569 6e74 6572 7072 6574 ock, reinterpret │ │ │ +0004f860: 5f63 6173 7426 6c74 3b73 6f63 6b61 6464 _cast<sockadd │ │ │ +0004f870: 722a 2667 743b 2826 616d 703b 736f 636b r*>(&sock │ │ │ +0004f880: 5f61 6464 7229 2c20 2661 6d70 3b73 6f63 _addr), &soc │ │ │ +0004f890: 6b5f 6164 6472 5f6c 656e 2920 266c 743b k_addr_len) < │ │ │ +0004f8a0: 2030 290a 0909 0972 6574 7572 6e20 2d31 0)....return -1 │ │ │ +0004f8b0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.< │ │ │ +0004f8e0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0004f8f0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0004f920: 7372 632f 7072 6561 645f 6469 736b 5f69 src/pread_disk_i │ │ │ +0004f930: 6f2e 6370 703a 3734 313c 2f61 3e3c 2f74 o.cpp:741back-press │ │ │ +0004f950: 7572 6520 2874 6865 2064 6973 6b5f 6f62 ure (the disk_ob │ │ │ +0004f960: 7365 7276 6572 206f 2920 6973 2064 726f server o) is dro │ │ │ +0004f970: 7070 6564 206f 6e20 7468 6520 626c 6f63 pped on the bloc │ │ │ +0004f980: 6b65 6420 7061 7468 2e20 6173 796e 635f ked path. async_ │ │ │ +0004f990: 7772 6974 6520 7265 7475 726e 7320 6661 write returns fa │ │ │ +0004f9a0: 6c73 6520 286b 6565 7020 7772 6974 696e lse (keep writin │ │ │ +0004f9b0: 6729 2062 7574 2074 6865 2063 6163 6865 g) but the cache │ │ │ +0004f9c0: 2773 2062 6163 6b2d 7072 6573 7375 7265 's back-pressure │ │ │ +0004f9d0: 2028 6472 6976 656e 206f 6666 206d 5f62 (driven off m_b │ │ │ +0004f9e0: 6c6f 636b 7329 2063 616e 2774 2073 6565 locks) can't see │ │ │ +0004f9f0: 2074 6865 2070 6172 6b65 6420 7772 6974 the parked writ │ │ │ +0004fa00: 6573 2c20 736f 2061 206c 6f6e 672d 6c69 es, so a long-li │ │ │ +0004fa10: 7665 6420 6665 6e63 6520 2865 2e67 2e20 ved fence (e.g. │ │ │ +0004fa20: 6d6f 7665 5f73 746f 7261 6765 2920 6f6e move_storage) on │ │ │ +0004fa30: 2061 2062 7573 7920 746f 7272 656e 7420 a busy torrent │ │ │ +0004fa40: 6361 6e20 6772 6f77 206d 5f62 6c6f 636b can grow m_block │ │ │ +0004fa50: 6564 5f6a 6f62 7320 756e 626f 756e 6465 ed_jobs unbounde │ │ │ +0004fa60: 642e 2043 6172 7279 2074 6865 206f 6273 d. Carry the obs │ │ │ +0004fa70: 6572 7665 7220 7468 726f 7567 6820 746f erver through to │ │ │ +0004fa80: 2074 6872 6f74 746c 6520 7468 6520 7065 throttle the pe │ │ │ +0004fa90: 6572 2077 6869 6c65 2069 7473 2077 7269 er while its wri │ │ │ +0004faa0: 7465 7320 6172 6520 7061 726b 6564 2e3c tes are parked.< │ │ │ +0004fab0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    bac │ │ │ +0004fb00: 6b2d 7072 6573 7375 7265 2028 7468 6520 k-pressure (the │ │ │ +0004fb10: 6469 736b 5f6f 6273 6572 7665 7220 6f29 disk_observer o) │ │ │ +0004fb20: 2069 7320 6472 6f70 7065 6420 6f6e 2074 is dropped on t │ │ │ +0004fb30: 6865 2062 6c6f 636b 6564 2070 6174 682e he blocked path. │ │ │ +0004fb40: 0a61 7379 6e63 5f77 7269 7465 2072 6574 .async_write ret │ │ │ +0004fb50: 7572 6e73 2066 616c 7365 2028 6b65 6570 urns false (keep │ │ │ +0004fb60: 2077 7269 7469 6e67 2920 6275 7420 7468 writing) but th │ │ │ +0004fb70: 6520 6361 6368 6527 7320 6261 636b 2d70 e cache's back-p │ │ │ +0004fb80: 7265 7373 7572 650a 2864 7269 7665 6e20 ressure.(driven │ │ │ +0004fb90: 6f66 6620 6d5f 626c 6f63 6b73 2920 6361 off m_blocks) ca │ │ │ +0004fba0: 6e27 7420 7365 6520 7468 6520 7061 726b n't see the park │ │ │ +0004fbb0: 6564 2077 7269 7465 732c 2073 6f20 6120 ed writes, so a │ │ │ +0004fbc0: 6c6f 6e67 2d6c 6976 6564 2066 656e 6365 long-lived fence │ │ │ +0004fbd0: 0a28 652e 672e 206d 6f76 655f 7374 6f72 .(e.g. move_stor │ │ │ +0004fbe0: 6167 6529 206f 6e20 6120 6275 7379 2074 age) on a busy t │ │ │ +0004fbf0: 6f72 7265 6e74 2063 616e 2067 726f 7720 orrent can grow │ │ │ +0004fc00: 6d5f 626c 6f63 6b65 645f 6a6f 6273 2075 m_blocked_jobs u │ │ │ +0004fc10: 6e62 6f75 6e64 6564 2e0a 4361 7272 7920 nbounded..Carry │ │ │ +0004fc20: 7468 6520 6f62 7365 7276 6572 2074 6872 the observer thr │ │ │ +0004fc30: 6f75 6768 2074 6f20 7468 726f 7474 6c65 ough to throttle │ │ │ +0004fc40: 2074 6865 2070 6565 7220 7768 696c 6520 the peer while │ │ │ +0004fc50: 6974 7320 7772 6974 6573 2061 7265 2070 its writes are p │ │ │ +0004fc60: 6172 6b65 642e 3c2f 6832 3e3c 6834 3e2e arked.

    . │ │ │ +0004fc70: 2e2f 7372 632f 7072 6561 645f 6469 736b ./src/pread_disk │ │ │ +0004fc80: 5f69 6f2e 6370 703a 3734 313c 2f68 343e _io.cpp:741

    │ │ │ +0004fc90: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .// st
    │ │ │ +0004fcd0: 6f72 6167 6527 7320 6f75 7473 7461 6e64  orage's outstand
    │ │ │ +0004fce0: 696e 672d 6a6f 6220 636f 756e 742e 2069  ing-job count. i
    │ │ │ +0004fcf0: 735f 626c 6f63 6b65 6428 2920 6861 7320  s_blocked() has 
    │ │ │ +0004fd00: 6e6f 7420 7275 6e2c 2073 6f20 6a20 6973  not run, so j is
    │ │ │ +0004fd10: 206e 6f74 0a09 2f2f 2069 6e5f 7072 6f67   not..// in_prog
    │ │ │ +0004fd20: 7265 7373 2061 6e64 206d 7573 7420 6e6f  ress and must no
    │ │ │ +0004fd30: 7420 6265 206a 6f62 5f63 6f6d 706c 6574  t be job_complet
    │ │ │ +0004fd40: 6528 2964 202d 2d20 6162 6f72 7420 6974  e()d -- abort it
    │ │ │ +0004fd50: 2064 6972 6563 746c 792e 0a09 6966 2028   directly...if (
    │ │ │ +0004fd60: 6d5f 6162 6f72 7429 0a09 7b0a 0909 6d5f  m_abort)..{...m_
    │ │ │ +0004fd70: 636f 6d70 6c65 7465 645f 6a6f 6273 2e61  completed_jobs.a
    │ │ │ +0004fd80: 626f 7274 5f6a 6f62 286d 5f69 6f73 2c20  bort_job(m_ios, 
    │ │ │ +0004fd90: 6a29 3b0a 0909 7265 7475 726e 2066 616c  j);...return fal
    │ │ │ +0004fda0: 7365 3b0a 097d 0a0a 092f 2f20 6120 7772  se;..}...// a wr
    │ │ │ +0004fdb0: 6974 6520 636f 756e 7473 2061 7320 616e  ite counts as an
    │ │ │ +0004fdc0: 206f 7574 7374 616e 6469 6e67 206a 6f62   outstanding job
    │ │ │ +0004fdd0: 206f 6e20 7468 6520 7374 6f72 6167 6520   on the storage 
    │ │ │ +0004fde0: 286c 696b 6520 6120 7265 6164 206f 7220  (like a read or 
    │ │ │ +0004fdf0: 6861 7368 292c 0a09 2f2f 2073 6f20 6120  hash),..// so a 
    │ │ │ +0004fe00: 6665 6e63 6520 7761 6974 7320 666f 7220  fence waits for 
    │ │ │ +0004fe10: 6275 6666 6572 6564 2077 7269 7465 7320  buffered writes 
    │ │ │ +0004fe20: 616e 6420 7468 6569 7220 696e 2d66 6c69  and their in-fli
    │ │ │ +0004fe30: 6768 7420 666c 7573 6820 6265 666f 7265  ght flush before
    │ │ │ +0004fe40: 2069 740a 092f 2f20 7275 6e73 2c20 7261   it..// runs, ra
    │ │ │ +0004fe50: 7468 6572 2074 6861 6e20 7465 6172 696e  ther than tearin
    │ │ │ +0004fe60: 6720 7468 6520 7374 6f72 6167 6520 646f  g the storage do
    │ │ │ +0004fe70: 776e 2075 6e64 6572 2061 2066 6c75 7368  wn under a flush
    │ │ │ +0004fe80: 2e20 5468 6973 2064 6f65 7320 6e6f 740a  . This does not.
    │ │ │ +0004fe90: 092f 2f20 6465 6164 6c6f 636b 2074 6865  .// deadlock the
    │ │ │ +0004fea0: 2066 656e 6365 3a20 6164 645f 6665 6e63   fence: add_fenc
    │ │ │ +0004feb0: 655f 6a6f 6228 2920 6861 6e64 7320 6120  e_job() hands a 
    │ │ │ +0004fec0: 7374 6f72 6167 6520 7769 7468 206f 7574  storage with out
    │ │ │ +0004fed0: 7374 616e 6469 6e67 2077 7269 7465 730a  standing writes.
    │ │ │ +0004fee0: 092f 2f20 746f 2061 2067 656e 6572 6963  .// to a generic
    │ │ │ +0004fef0: 2074 6872 6561 6420 746f 2066 6c75 7368   thread to flush
    │ │ │ +0004ff00: 2c20 6472 6169 6e69 6e67 2074 6865 2077  , draining the w
    │ │ │ +0004ff10: 7269 7465 7320 7468 6520 6665 6e63 6520  rites the fence 
    │ │ │ +0004ff20: 7761 6974 7320 6f6e 2e0a 092f 2f0a 092f  waits on...//../
    │ │ │ +0004ff30: 2f20 7768 656e 2061 2066 656e 6365 2069  / when a fence i
    │ │ │ +0004ff40: 7320 7570 2c20 6973 5f62 6c6f 636b 6564  s up, is_blocked
    │ │ │ +0004ff50: 2829 2070 6172 6b73 2074 6865 206a 6f62  () parks the job
    │ │ │ +0004ff60: 2069 6e20 7468 6520 6665 6e63 6527 7320   in the fence's 
    │ │ │ +0004ff70: 626c 6f63 6b65 6420 7175 6575 650a 092f  blocked queue../
    │ │ │ +0004ff80: 2f20 746f 2062 6520 7265 706f 7374 6564  / to be reposted
    │ │ │ +0004ff90: 2069 6e74 6f20 7468 6520 6361 6368 6520   into the cache 
    │ │ │ +0004ffa0: 6f6e 6365 2074 6865 2066 656e 6365 206c  once the fence l
    │ │ │ +0004ffb0: 6f77 6572 7320 2861 6464 5f63 6f6d 706c  owers (add_compl
    │ │ │ +0004ffc0: 6574 6564 5f6a 6f62 735f 696d 706c 292e  eted_jobs_impl).
    │ │ │ +0004ffd0: 0a09 2f2f 2049 6e73 6572 7469 6e67 206e  ..// Inserting n
    │ │ │ +0004ffe0: 6f77 2077 6f75 6c64 2072 6163 6520 7465  ow would race te
    │ │ │ +0004fff0: 6172 646f 776e 3a20 666f 7220 636c 6561  ardown: for clea
    │ │ │ +00050000: 725f 7069 6563 6520 7468 6520 6370 6520  r_piece the cpe 
    │ │ │ +00050010: 6973 2061 626f 7574 2074 6f20 6265 0a09  is about to be..
    │ │ │ +00050020: 2f2f 2072 6573 6574 2c20 666f 7220 7374  // reset, for st
    │ │ │ +00050030: 6f72 6167 652d 7769 6465 2066 656e 6365  orage-wide fence
    │ │ │ +00050040: 7320 7468 6520 7374 6f72 6167 6520 6973  s the storage is
    │ │ │ +00050050: 2061 626f 7574 2074 6f20 676f 2061 7761   about to go awa
    │ │ │ +00050060: 792e 2050 6172 6b69 6e67 0a09 2f2f 206b  y. Parking..// k
    │ │ │ +00050070: 6565 7073 2074 6865 2062 6c6f 636b 2022  eeps the block "
    │ │ │ +00050080: 7772 6974 696e 6722 2069 6e20 7468 6520  writing" in the 
    │ │ │ +00050090: 7069 636b 6572 2773 2076 6965 772c 2073  picker's view, s
    │ │ │ +000500a0: 6f20 7468 6520 7069 6563 6520 6973 6e27  o the piece isn'
    │ │ │ +000500b0: 7420 7265 706f 7274 6564 0a09 2f2f 2066  t reported..// f
    │ │ │ +000500c0: 696e 6973 6865 6420 616e 6420 6974 7320  inished and its 
    │ │ │ +000500d0: 6861 7368 2069 736e 2774 2072 6571 7565  hash isn't reque
    │ │ │ +000500e0: 7374 6564 2062 6566 6f72 6520 7468 6520  sted before the 
    │ │ │ +000500f0: 626c 6f63 6b20 6861 7320 6265 656e 2069  block has been i
    │ │ │ +00050100: 6e73 6572 7465 642e 0a3c 6469 7620 7374  nserted..
    .if (j-&g │ │ │ +00050140: 743b 7374 6f72 6167 652d 2667 743b 6973 t;storage->is │ │ │ +00050150: 5f62 6c6f 636b 6564 286a 2c20 6d5f 7374 _blocked(j, m_st │ │ │ +00050160: 6174 735f 636f 756e 7465 7273 2929 0a3c ats_counters)).< │ │ │ +00050170: 2f64 6976 3e09 7b0a 0909 7265 7475 726e /div>.{...return │ │ │ +00050180: 2066 616c 7365 3b0a 097d 0a0a 092f 2f20 false;..}...// │ │ │ +00050190: 6973 5f62 6c6f 636b 6564 2829 206d 6172 is_blocked() mar │ │ │ +000501a0: 6b65 6420 6a20 696e 5f70 726f 6772 6573 ked j in_progres │ │ │ +000501b0: 7320 616e 6420 636f 756e 7465 6420 6974 s and counted it │ │ │ +000501c0: 2061 7320 6f75 7473 7461 6e64 696e 672e as outstanding. │ │ │ +000501d0: 0a09 626f 6f6c 2063 6f6e 7374 2065 7863 ..bool const exc │ │ │ +000501e0: 6565 6465 6420 3d20 6164 645f 7772 6974 eeded = add_writ │ │ │ +000501f0: 655f 746f 5f63 6163 6865 286a 2c20 7374 e_to_cache(j, st │ │ │ +00050200: 643a 3a6d 6f76 6528 6f29 293b 0a09 7363 d::move(o));..sc │ │ │ +00050210: 6865 6475 6c65 5f66 6c75 7368 2829 3b0a hedule_flush();. │ │ │ +00050220: 0972 6574 7572 6e20 6578 6365 6564 6564 .return exceeded │ │ │ +00050230: 3b0a 7d0a 0a61 7578 3a3a 696e 7365 7274 ;.}..aux::insert │ │ │ +00050240: 5f72 6573 756c 745f 666c 6167 7320 7072 _result_flags pr │ │ │ +00050250: 6561 645f 6469 736b 5f69 6f3a 3a69 6e73 ead_disk_io::ins │ │ │ +00050260: 6572 745f 7772 6974 6528 0a09 6175 783a ert_write(..aux: │ │ │ +00050270: 3a70 7265 6164 5f64 6973 6b5f 6a6f 622a :pread_disk_job* │ │ │ +00050280: 206a 2c20 7374 643a 3a73 6861 7265 645f j, std::shared_ │ │ │ +00050290: 7074 7226 6c74 3b64 6973 6b5f 6f62 7365 ptr<disk_obse │ │ │ +000502a0: 7276 6572 2667 743b 206f 290a 7b0a 0961 rver> o).{..a │ │ │ +000502b0: 7574 6f20 636f 6e73 7426 616d 703b 2061 uto const& a │ │ │ +000502c0: 203d 2073 7464 3a3a 6765 7426 6c74 3b61 = std::get<a │ │ │ +000502d0: 7578 3a3a 6a6f 623a 3a77 7269 7465 2667 ux::job::write&g │ │ │ +000502e0: 743b 286a 2d26 6774 3b61 6374 696f 6e29 t;(j->action) │ │ │ +000502f0: 3b0a 0970 6965 6365 5f69 6e64 6578 5f74 ;..piece_index_t │ │ │ +00050300: 2063 6f6e 7374 2070 6965 6365 203d 2061 const piece = a │ │ │ +00050310: 2e70 6965 6365 3b0a 0969 6e74 2063 6f6e .piece;..int con │ │ │ +00050320: 7374 206f 6666 7365 7420 3d20 612e 6f66 st offset = a.of │ │ │ +00050330: 6673 6574 3b0a 0a09 444c 4f47 2822 6173 fset;...DLOG("as │ │ │ +00050340: 796e 635f 7772 6974 653a 2070 6965 6365 ync_write: piece │ │ │ +00050350: 3a20 2564 206f 6666 7365 743a 2025 6420 : %d offset: %d │ │ │ +00050360: 666c 6167 733a 2025 785c 6e22 2c0a 0909 flags: %x\n",... │ │ │ +00050370: 696e 7428 7069 6563 6529 2c0a 0909 696e int(piece),...in │ │ │ +00050380: 7428 6f66 6673 6574 292c 0a09 0973 7461 t(offset),...sta │ │ │ +00050390: 7469 635f 6361 7374 266c 743b 7374 643a tic_cast<std: │ │ │ +000503a0: 3a75 696e 7438 5f74 2667 743b 286a 2d26 :uint8_t>(j-& │ │ │ +000503b0: 6774 3b66 6c61 6773 2929 3b0a 0962 6f6f gt;flags));..boo │ │ │ +000503c0: 6c20 636f 6e73 7420 666f 7263 655f 666c l const force_fl │ │ │ +000503d0: 7573 6820 3d20 626f 6f6c 286a 2d26 6774 ush = bool(j-> │ │ │ +000503e0: 3b66 6c61 6773 2026 616d 703b 2066 6c75 ;flags & flu │ │ │ +000503f0: 7368 5f70 6965 6365 293b 0a09 6669 6c65 sh_piece);..file │ │ │ +00050400: 5f73 746f 7261 6765 2063 6f6e 7374 2661 _storage const&a │ │ │ +00050410: 6d70 3b20 6673 203d 206a 2d26 6774 3b73 mp; fs = j->s │ │ │ +00050420: 746f 7261 6765 2d26 6774 3b66 696c 6573 torage->files │ │ │ +00050430: 2829 3b0a 092f 2f20 696e 206f 7264 6572 ();..// in order │ │ │ +00050440: 2074 6f20 636f 6d70 7574 6520 7631 2068 to compute v1 h │ │ │ +00050450: 6173 6865 732c 2077 6520 6e65 6564 2074 ashes, we need t │ │ │ +00050460: 6865 2066 756c 6c20 7069 6563 652c 2069 he full piece, i │ │ │ +00050470: 6e63 6c75 6469 6e67 2070 6164 0a09 2f2f ncluding pad..// │ │ │ +00050480: 2066 696c 6573 2e20 4576 656e 2074 686f files. Even tho │ │ │ +00050490: 7567 6820 7632 2074 6f72 7265 6e74 7320 ugh v2 torrents │ │ │ +000504a0: 6775 6172 616e 7465 6520 7468 6174 2074 guarantee that t │ │ │ +000504b0: 6865 7920 6172 6520 7a65 726f 2e0a 0969 hey are zero...i │ │ │ +000504c0: 6e74 2063 6f6e 7374 2070 6965 6365 5f73 nt const piece_s │ │ │ +000504d0: 697a 6520 3d20 6a2d 2667 743b 7374 6f72 ize = j->stor │ │ │ +000504e0: 6167 652d 2667 743b 7631 2829 203f 2066 age->v1() ? f │ │ │ +000504f0: 732e 7069 6563 655f 7369 7a65 2870 6965 s.piece_size(pie │ │ │ +00050500: 6365 2920 3a20 6673 2e70 6965 6365 5f73 ce) : fs.piece_s │ │ │ +00050510: 697a 6532 2870 6965 6365 293b 0a09 544f ize2(piece);..TO │ │ │ +00050520: 5252 454e 545f 4153 5345 5254 2861 2e62 RRENT_ASSERT(a.b │ │ │ +00050530: 7566 6665 725f 7369 7a65 203d 3d20 7374 uffer_size == st │ │ │ +00050540: 643a 3a6d 696e 2870 6965 6365 5f73 697a d::min(piece_siz │ │ │ +00050550: 6520 2d20 6f66 6673 6574 2c20 6465 6661 e - offset, defa │ │ │ +00050560: 756c 745f 626c 6f63 6b5f 7369 7a65 2929 ult_block_size)) │ │ │ +00050570: 3b0a 0961 7578 3a3a 6469 736b 5f63 6163 ;..aux::disk_cac │ │ │ +00050580: 6865 3a3a 7069 6563 655f 656e 7472 795f he::piece_entry_ │ │ │ +00050590: 7061 7261 6d73 2063 6f6e 7374 2070 6965 params const pie │ │ │ +000505a0: 6365 5f70 6172 616d 737b 0a09 0966 732e ce_params{...fs. │ │ │ +000505b0: 7069 6563 655f 7369 7a65 3228 7069 6563 piece_size2(piec │ │ │ +000505c0: 6529 2c20 7069 6563 655f 7369 7a65 2c20 e), piece_size, │ │ │ +000505d0: 6a2d 2667 743b 7374 6f72 6167 652d 2667 j->storage-&g │ │ │ +000505e0: 743b 7631 2829 2c20 6a2d 2667 743b 7374 t;v1(), j->st │ │ │ +000505f0: 6f72 6167 652d 2667 743b 7632 2829 2c20 orage->v2(), │ │ │ +00050600: 6a2d 2667 743b 7374 6f72 6167 657d 3b0a j->storage};. │ │ │ +00050610: 0972 6574 7572 6e20 6d5f 6361 6368 652e .return m_cache. │ │ │ +00050620: 696e 7365 7274 287b 6a2d 2667 743b 7374 insert({j->st │ │ │ +00050630: 6f72 6167 652d 2667 743b 7374 6f72 6167 orage->storag │ │ │ +00050640: 655f 696e 6465 7828 292c 2070 6965 6365 e_index(), piece │ │ │ +00050650: 7d2c 0a3c 2f70 7265 3e3c 2f74 643e 3c2f },.
    │ │ │ +00050680: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00050690: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +000506c0: 2f73 7263 2f70 7265 6164 5f64 6973 6b5f /src/pread_disk_ │ │ │ +000506d0: 696f 2e63 7070 3a39 3235 3c2f 613e 3c2f io.cpp:925we may no │ │ │ +000506f0: 7420 6e65 6564 2074 6f20 646f 2074 6869 t need to do thi │ │ │ +00050700: 732c 2074 6865 2063 6163 6865 2063 6f75 s, the cache cou │ │ │ +00050710: 6c64 2074 656c 6c20 7573 2074 6869 7320 ld tell us this │ │ │ +00050720: 7069 6563 6520 7368 6f75 6c64 2062 6520 piece should be │ │ │ +00050730: 666c 7573 6865 6420 746f 2064 6973 6b20 flushed to disk │ │ │ +00050740: 6e6f 772e 3c2f 7464 3e3c 2f74 723e 3c74 now.we may not nee │ │ │ +000507a0: 6420 746f 2064 6f20 7468 6973 2c20 7468 d to do this, th │ │ │ +000507b0: 6520 6361 6368 6520 636f 756c 6420 7465 e cache could te │ │ │ +000507c0: 6c6c 2075 730a 7468 6973 2070 6965 6365 ll us.this piece │ │ │ +000507d0: 2073 686f 756c 6420 6265 2066 6c75 7368 should be flush │ │ │ +000507e0: 6564 2074 6f20 6469 736b 206e 6f77 2e3c ed to disk now.< │ │ │ +000507f0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00050800: 7265 6164 5f64 6973 6b5f 696f 2e63 7070 read_disk_io.cpp │ │ │ +00050810: 3a39 3235 3c2f 6834 3e3c 7072 6520 7374 :925

    ...fill_preco
    │ │ │ +00050860: 6d70 7574 6564 5f76 3228 0a09 0909 0961  mputed_v2(.....a
    │ │ │ +00050870: 2e62 6c6f 636b 5f68 6173 6865 732c 206a  .block_hashes, j
    │ │ │ +00050880: 2d26 6774 3b73 746f 7261 6765 2d26 6774  ->storage->
    │ │ │ +00050890: 3b74 616b 655f 7072 6563 6f6d 7075 7465  ;take_precompute
    │ │ │ +000508a0: 645f 7632 2870 6965 6365 292c 2062 6c6f  d_v2(piece), blo
    │ │ │ +000508b0: 636b 735f 696e 5f70 6965 6365 3229 3b0a  cks_in_piece2);.
    │ │ │ +000508c0: 0a09 0909 666f 7220 2869 6e74 2069 203d  ....for (int i =
    │ │ │ +000508d0: 2030 3b20 6920 266c 743b 2062 6c6f 636b   0; i < block
    │ │ │ +000508e0: 735f 696e 5f70 6965 6365 323b 202b 2b69  s_in_piece2; ++i
    │ │ │ +000508f0: 290a 0909 097b 0a09 0909 0969 6620 2869  )....{.....if (i
    │ │ │ +00050900: 2026 6774 3b3d 2069 6e74 2861 2e62 6c6f   >= int(a.blo
    │ │ │ +00050910: 636b 5f68 6173 6865 732e 7369 7a65 2829  ck_hashes.size()
    │ │ │ +00050920: 2920 7c7c 2061 2e62 6c6f 636b 5f68 6173  ) || a.block_has
    │ │ │ +00050930: 6865 735b 695d 2e69 735f 616c 6c5f 7a65  hes[i].is_all_ze
    │ │ │ +00050940: 726f 7328 2929 0a09 0909 097b 0a09 0909  ros()).....{....
    │ │ │ +00050950: 0909 6e65 6564 5f64 6973 6b5f 6661 6c6c  ..need_disk_fall
    │ │ │ +00050960: 6261 636b 203d 2074 7275 653b 0a09 0909  back = true;....
    │ │ │ +00050970: 0909 6272 6561 6b3b 0a09 0909 097d 0a09  ..break;.....}..
    │ │ │ +00050980: 0909 7d0a 0909 7d0a 0a09 0969 6620 286e  ..}...}....if (n
    │ │ │ +00050990: 6565 645f 6469 736b 5f66 616c 6c62 6163  eed_disk_fallbac
    │ │ │ +000509a0: 6b29 0a09 097b 0a09 0909 444c 4f47 2822  k)...{....DLOG("
    │ │ │ +000509b0: 6173 796e 635f 6861 7368 3a20 7632 2068  async_hash: v2 h
    │ │ │ +000509c0: 6173 6865 7320 696e 636f 6d70 6c65 7465  ashes incomplete
    │ │ │ +000509d0: 2c20 6661 6c6c 696e 6720 6261 636b 2074  , falling back t
    │ │ │ +000509e0: 6f20 646f 5f6a 6f62 2868 6173 6829 5c6e  o do_job(hash)\n
    │ │ │ +000509f0: 2229 3b0a 0909 0961 6464 5f6a 6f62 286a  ");....add_job(j
    │ │ │ +00050a00: 293b 0a09 0909 7265 7475 726e 3b0a 0909  );....return;...
    │ │ │ +00050a10: 7d0a 0a3c 6469 7620 7374 796c 653d 2262  }..
    ..m_generic_thr │ │ │ +00050a50: 6561 6473 2e69 6e74 6572 7275 7074 2829 eads.interrupt() │ │ │ +00050a60: 3b0a 3c2f 6469 763e 0a09 096a 6f62 7175 ;.
    ...jobqu │ │ │ +00050a70: 6575 655f 7420 6a6f 6273 3b0a 0909 6a6f eue_t jobs;...jo │ │ │ +00050a80: 6273 2e70 7573 685f 6261 636b 286a 293b bs.push_back(j); │ │ │ +00050a90: 0a09 0961 6464 5f63 6f6d 706c 6574 6564 ...add_completed │ │ │ +00050aa0: 5f6a 6f62 7328 7374 643a 3a6d 6f76 6528 _jobs(std::move( │ │ │ +00050ab0: 6a6f 6273 2929 3b0a 0909 7265 7475 726e jobs));...return │ │ │ +00050ac0: 3b0a 097d 0a0a 092f 2f20 496e 2074 6869 ;..}...// In thi │ │ │ +00050ad0: 7320 6361 7365 2074 6865 206a 6f62 2068 s case the job h │ │ │ +00050ae0: 6173 2062 6565 6e20 7175 6575 6564 206f as been queued o │ │ │ +00050af0: 6e20 7468 6520 7069 6563 652c 2061 6e64 n the piece, and │ │ │ +00050b00: 2077 696c 6c20 6265 2070 6f73 7465 640a will be posted. │ │ │ +00050b10: 092f 2f20 6f6e 6365 2074 6865 2068 6173 .// once the has │ │ │ +00050b20: 6869 6e67 2063 6f6d 706c 6574 6573 0a09 hing completes.. │ │ │ +00050b30: 6966 2028 7265 7420 3d3d 2061 7578 3a3a if (ret == aux:: │ │ │ +00050b40: 6469 736b 5f63 6163 6865 3a3a 6a6f 625f disk_cache::job_ │ │ │ +00050b50: 7175 6575 6564 290a 0909 7265 7475 726e queued)...return │ │ │ +00050b60: 3b0a 0a09 6164 645f 6a6f 6228 6a29 3b0a ;...add_job(j);. │ │ │ +00050b70: 7d0a 0a76 6f69 6420 7072 6561 645f 6469 }..void pread_di │ │ │ +00050b80: 736b 5f69 6f3a 3a61 7379 6e63 5f68 6173 sk_io::async_has │ │ │ +00050b90: 6832 2873 746f 7261 6765 5f69 6e64 6578 h2(storage_index │ │ │ +00050ba0: 5f74 2063 6f6e 7374 2073 746f 7261 6765 _t const storage │ │ │ +00050bb0: 0a09 2c20 7069 6563 655f 696e 6465 785f .., piece_index_ │ │ │ +00050bc0: 7420 636f 6e73 7420 7069 6563 652c 2069 t const piece, i │ │ │ +00050bd0: 6e74 2063 6f6e 7374 206f 6666 7365 742c nt const offset, │ │ │ +00050be0: 2064 6973 6b5f 6a6f 625f 666c 6167 735f disk_job_flags_ │ │ │ +00050bf0: 7420 636f 6e73 7420 666c 6167 730a 092c t const flags.., │ │ │ +00050c00: 2073 7464 3a3a 6675 6e63 7469 6f6e 266c std::function&l │ │ │ +00050c10: 743b 766f 6964 2870 6965 6365 5f69 6e64 t;void(piece_ind │ │ │ +00050c20: 6578 5f74 2c20 7368 6132 3536 5f68 6173 ex_t, sha256_has │ │ │ +00050c30: 6820 636f 6e73 7426 616d 703b 2c20 7374 h const&, st │ │ │ +00050c40: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ +00050c50: 7426 616d 703b 2926 6774 3b20 6861 6e64 t&)> hand │ │ │ +00050c60: 6c65 7229 0a7b 0a09 544f 5252 454e 545f ler).{..TORRENT_ │ │ │ +00050c70: 4153 5345 5254 2876 616c 6964 5f66 6c61 ASSERT(valid_fla │ │ │ +00050c80: 6773 2866 6c61 6773 2929 3b0a 0961 7578 gs(flags));..aux │ │ │ +00050c90: 3a3a 7072 6561 645f 6469 736b 5f6a 6f62 ::pread_disk_job │ │ │ +00050ca0: 2a20 6a20 3d20 6d5f 6a6f 625f 706f 6f6c * j = m_job_pool │ │ │ +00050cb0: 2e61 6c6c 6f63 6174 655f 6a6f 6226 6c74 .allocate_job< │ │ │ +00050cc0: 3b61 7578 3a3a 6a6f 623a 3a68 6173 6832 ;aux::job::hash2 │ │ │ +00050cd0: 2667 743b 280a 0909 666c 6167 732c 0a09 >(...flags,.. │ │ │ +00050ce0: 096d 5f74 6f72 7265 6e74 735b 7374 6f72 .m_torrents[stor │ │ │ +00050cf0: 6167 655d 2d26 6774 3b73 6861 7265 645f age]->shared_ │ │ │ +00050d00: 6672 6f6d 5f74 6869 7328 292c 0a09 0973 from_this(),...s │ │ │ +00050d10: 7464 3a3a 6d6f 7665 2868 616e 646c 6572 td::move(handler │ │ │ +00050d20: 292c 0a09 0970 6965 6365 2c0a 0909 6f66 ),...piece,...of │ │ │ +00050d30: 6673 6574 2c0a 0909 7368 6132 3536 5f68 fset,...sha256_h │ │ │ +00050d40: 6173 687b 7d0a 0929 3b0a 0a09 2f2f 2049 ash{}..);...// I │ │ │ +00050d50: 6e20 7468 656f 7279 2c20 7765 2063 6f75 n theory, we cou │ │ │ +00050d60: 6c64 2063 6865 636b 2074 6865 2063 6163 ld check the cac │ │ │ +00050d70: 6865 2066 6f72 2074 6869 7320 626c 6f63 he for this bloc │ │ │ +00050d80: 6b20 6861 7368 2c20 6275 7420 7765 0a3c k hash, but we.< │ │ │ +00050d90: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00050da0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00050db0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00050dc0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00050dd0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +00050e00: 2f70 7265 6164 5f64 6973 6b5f 696f 2e63 /pread_disk_io.c │ │ │ +00050e10: 7070 3a31 3336 313c 2f61 3e3c 2f74 643e pp:1361 │ │ │ +00050e20: 3c74 643e 6d61 7962 6520 7765 2064 6f6e maybe we don │ │ │ +00050e30: 2774 206e 6565 6420 746f 2077 7269 7465 't need to write │ │ │ +00050e40: 2074 6f20 6669 6c65 7320 7765 2772 6520 to files we're │ │ │ +00050e50: 6162 6f75 7420 746f 2064 656c 6574 653c about to delete< │ │ │ +00050e60: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    may │ │ │ +00050eb0: 6265 2077 6520 646f 6e27 7420 6e65 6564 be we don't need │ │ │ +00050ec0: 2074 6f20 7772 6974 6520 746f 2066 696c to write to fil │ │ │ +00050ed0: 6573 2077 6527 7265 2061 626f 7574 2074 es we're about t │ │ │ +00050ee0: 6f20 6465 6c65 7465 3c2f 6832 3e3c 6834 o delete

    ../src/pread_di │ │ │ +00050f00: 736b 5f69 6f2e 6370 703a 3133 3631 3c2f sk_io.cpp:1361
    .a.
    │ │ │ +00050f50: 7061 7468 203d 2073 7464 3a3a 6d6f 7665  path = std::move
    │ │ │ +00050f60: 2870 293b 0a09 7265 7475 726e 2072 6574  (p);..return ret
    │ │ │ +00050f70: 3b0a 7d0a 0a73 7461 7475 735f 7420 7072  ;.}..status_t pr
    │ │ │ +00050f80: 6561 645f 6469 736b 5f69 6f3a 3a64 6f5f  ead_disk_io::do_
    │ │ │ +00050f90: 6a6f 6228 6175 783a 3a6a 6f62 3a3a 7265  job(aux::job::re
    │ │ │ +00050fa0: 6c65 6173 655f 6669 6c65 7326 616d 703b  lease_files&
    │ │ │ +00050fb0: 2c20 6175 783a 3a70 7265 6164 5f64 6973  , aux::pread_dis
    │ │ │ +00050fc0: 6b5f 6a6f 622a 206a 290a 7b0a 092f 2f20  k_job* j).{..// 
    │ │ │ +00050fd0: 6966 2074 6869 7320 6173 7365 7274 2066  if this assert f
    │ │ │ +00050fe0: 6169 6c73 2c20 736f 6d65 7468 696e 6727  ails, something'
    │ │ │ +00050ff0: 7320 7772 6f6e 6720 7769 7468 2074 6865  s wrong with the
    │ │ │ +00051000: 2066 656e 6365 206c 6f67 6963 0a09 544f   fence logic..TO
    │ │ │ +00051010: 5252 454e 545f 4153 5345 5254 286a 2d26  RRENT_ASSERT(j-&
    │ │ │ +00051020: 6774 3b73 746f 7261 6765 2d26 6774 3b6e  gt;storage->n
    │ │ │ +00051030: 756d 5f6f 7574 7374 616e 6469 6e67 5f6a  um_outstanding_j
    │ │ │ +00051040: 6f62 7328 2920 3d3d 2031 293b 0a09 666c  obs() == 1);..fl
    │ │ │ +00051050: 7573 685f 7374 6f72 6167 6528 6a2d 2667  ush_storage(j-&g
    │ │ │ +00051060: 743b 7374 6f72 6167 6529 3b0a 096a 2d26  t;storage);..j-&
    │ │ │ +00051070: 6774 3b73 746f 7261 6765 2d26 6774 3b72  gt;storage->r
    │ │ │ +00051080: 656c 6561 7365 5f66 696c 6573 286a 2d26  elease_files(j-&
    │ │ │ +00051090: 6774 3b65 7272 6f72 293b 0a09 7265 7475  gt;error);..retu
    │ │ │ +000510a0: 726e 206a 2d26 6774 3b65 7272 6f72 203f  rn j->error ?
    │ │ │ +000510b0: 2064 6973 6b5f 7374 6174 7573 3a3a 6661   disk_status::fa
    │ │ │ +000510c0: 7461 6c5f 6469 736b 5f65 7272 6f72 203a  tal_disk_error :
    │ │ │ +000510d0: 2073 7461 7475 735f 747b 7d3b 0a7d 0a0a   status_t{};.}..
    │ │ │ +000510e0: 7374 6174 7573 5f74 2070 7265 6164 5f64  status_t pread_d
    │ │ │ +000510f0: 6973 6b5f 696f 3a3a 646f 5f6a 6f62 2861  isk_io::do_job(a
    │ │ │ +00051100: 7578 3a3a 6a6f 623a 3a64 656c 6574 655f  ux::job::delete_
    │ │ │ +00051110: 6669 6c65 7326 616d 703b 2061 2c20 6175  files& a, au
    │ │ │ +00051120: 783a 3a70 7265 6164 5f64 6973 6b5f 6a6f  x::pread_disk_jo
    │ │ │ +00051130: 622a 206a 290a 7b0a 0954 4f52 5245 4e54  b* j).{..TORRENT
    │ │ │ +00051140: 5f41 5353 4552 5428 612e 666c 6167 7329  _ASSERT(a.flags)
    │ │ │ +00051150: 3b0a 0a09 2f2f 2069 6620 7468 6973 2061  ;...// if this a
    │ │ │ +00051160: 7373 6572 7420 6661 696c 732c 2073 6f6d  ssert fails, som
    │ │ │ +00051170: 6574 6869 6e67 2773 2077 726f 6e67 2077  ething's wrong w
    │ │ │ +00051180: 6974 6820 7468 6520 6665 6e63 6520 6c6f  ith the fence lo
    │ │ │ +00051190: 6769 630a 0954 4f52 5245 4e54 5f41 5353  gic..TORRENT_ASS
    │ │ │ +000511a0: 4552 5428 6a2d 2667 743b 7374 6f72 6167  ERT(j->storag
    │ │ │ +000511b0: 652d 2667 743b 6e75 6d5f 6f75 7473 7461  e->num_outsta
    │ │ │ +000511c0: 6e64 696e 675f 6a6f 6273 2829 203d 3d20  nding_jobs() == 
    │ │ │ +000511d0: 3129 3b0a 0a3c 6469 7620 7374 796c 653d  1);..
    .flush_storag │ │ │ +00051210: 6528 6a2d 2667 743b 7374 6f72 6167 6529 e(j->storage) │ │ │ +00051220: 3b0a 3c2f 6469 763e 0a09 6a2d 2667 743b ;.
    ..j-> │ │ │ +00051230: 7374 6f72 6167 652d 2667 743b 6465 6c65 storage->dele │ │ │ +00051240: 7465 5f66 696c 6573 2861 2e66 6c61 6773 te_files(a.flags │ │ │ +00051250: 2c20 6a2d 2667 743b 6572 726f 7229 3b0a , j->error);. │ │ │ +00051260: 0972 6574 7572 6e20 6a2d 2667 743b 6572 .return j->er │ │ │ +00051270: 726f 7220 3f20 6469 736b 5f73 7461 7475 ror ? disk_statu │ │ │ +00051280: 733a 3a66 6174 616c 5f64 6973 6b5f 6572 s::fatal_disk_er │ │ │ +00051290: 726f 7220 3a20 7374 6174 7573 5f74 7b7d ror : status_t{} │ │ │ +000512a0: 3b0a 7d0a 0a73 7461 7475 735f 7420 7072 ;.}..status_t pr │ │ │ +000512b0: 6561 645f 6469 736b 5f69 6f3a 3a64 6f5f ead_disk_io::do_ │ │ │ +000512c0: 6a6f 6228 6175 783a 3a6a 6f62 3a3a 6368 job(aux::job::ch │ │ │ +000512d0: 6563 6b5f 6661 7374 7265 7375 6d65 2661 eck_fastresume&a │ │ │ +000512e0: 6d70 3b20 612c 2061 7578 3a3a 7072 6561 mp; a, aux::prea │ │ │ +000512f0: 645f 6469 736b 5f6a 6f62 2a20 6a29 0a7b d_disk_job* j).{ │ │ │ +00051300: 0a09 2f2f 2069 6620 7468 6973 2061 7373 ..// if this ass │ │ │ +00051310: 6572 7420 6661 696c 732c 2073 6f6d 6574 ert fails, somet │ │ │ +00051320: 6869 6e67 2773 2077 726f 6e67 2077 6974 hing's wrong wit │ │ │ +00051330: 6820 7468 6520 6665 6e63 6520 6c6f 6769 h the fence logi │ │ │ +00051340: 630a 0954 4f52 5245 4e54 5f41 5353 4552 c..TORRENT_ASSER │ │ │ +00051350: 5428 6a2d 2667 743b 7374 6f72 6167 652d T(j->storage- │ │ │ +00051360: 2667 743b 6e75 6d5f 6f75 7473 7461 6e64 >num_outstand │ │ │ +00051370: 696e 675f 6a6f 6273 2829 203d 3d20 3129 ing_jobs() == 1) │ │ │ +00051380: 3b0a 0966 6c75 7368 5f73 746f 7261 6765 ;..flush_storage │ │ │ +00051390: 286a 2d26 6774 3b73 746f 7261 6765 293b (j->storage); │ │ │ +000513a0: 0a09 6164 645f 746f 7272 656e 745f 7061 ..add_torrent_pa │ │ │ +000513b0: 7261 6d73 2063 6f6e 7374 2a20 7264 203d rams const* rd = │ │ │ +000513c0: 2061 2e72 6573 756d 655f 6461 7461 3b0a a.resume_data;. │ │ │ +000513d0: 0961 6464 5f74 6f72 7265 6e74 5f70 6172 .add_torrent_par │ │ │ +000513e0: 616d 7320 746d 703b 0a09 6966 2028 7264 ams tmp;..if (rd │ │ │ +000513f0: 203d 3d20 6e75 6c6c 7074 7229 2072 6420 == nullptr) rd │ │ │ +00051400: 3d20 2661 6d70 3b74 6d70 3b0a 0a09 7374 = &tmp;...st │ │ │ +00051410: 643a 3a75 6e69 7175 655f 7074 7226 6c74 d::unique_ptr< │ │ │ +00051420: 3b61 7578 3a3a 7665 6374 6f72 266c 743b ;aux::vector< │ │ │ +00051430: 7374 643a 3a73 7472 696e 672c 2066 696c std::string, fil │ │ │ +00051440: 655f 696e 6465 785f 7426 6774 3b26 6774 e_index_t>> │ │ │ +00051450: 3b20 6c69 6e6b 7328 612e 6c69 6e6b 7329 ; links(a.links) │ │ │ +00051460: 3b0a 092f 2f20 6368 6563 6b20 6966 2074 ;..// check if t │ │ │ +00051470: 6865 2066 6173 7472 6573 756d 6520 6461 he fastresume da │ │ │ +00051480: 7461 2069 7320 7570 2074 6f20 6461 7465 ta is up to date │ │ │ +00051490: 0a09 2f2f 2069 6620 6974 2069 732c 2075 ..// if it is, u │ │ │ +000514a0: 7365 2069 7420 616e 6420 7265 7475 726e se it and return │ │ │ +000514b0: 2074 7275 652e 2049 6620 6974 0a09 2f2f true. If it..// │ │ │ +000514c0: 2069 736e 2774 2072 6574 7572 6e20 6661 isn't return fa │ │ │ +000514d0: 6c73 6520 616e 6420 7468 6520 6675 6c6c lse and the full │ │ │ +000514e0: 2063 6865 636b 0a09 2f2f 2077 696c 6c20 check..// will │ │ │ +000514f0: 6265 2072 756e 2e20 4966 2074 6865 206c be run. If the l │ │ │ +00051500: 696e 6b73 2070 6f69 6e74 6572 2069 7320 inks pointer is │ │ │ +00051510: 6e6f 6e2d 656d 7074 792c 2069 7420 6861 non-empty, it ha │ │ │ +00051520: 7320 7468 6520 7361 6d65 206e 756d 6265 s the same numbe │ │ │ +00051530: 720a 092f 2f20 6f66 2065 6c65 6d65 6e74 r..// of element │ │ │ +00051540: 7320 6173 2074 6865 7265 2061 7265 2066 s as there are f │ │ │ +00051550: 696c 6573 2e20 4561 6368 2065 6c65 6d65 iles. Each eleme │ │ │ +00051560: 6e74 2069 7320 6569 7468 6572 2065 6d70 nt is either emp │ │ │ +00051570: 7479 206f 7220 636f 6e74 6169 6e73 0a09 ty or contains.. │ │ │ +00051580: 2f2f 2074 6865 2061 6273 6f6c 7574 6520 // the absolute │ │ │ +00051590: 7061 7468 2074 6f20 6120 6669 6c65 2069 path to a file i │ │ │ +000515a0: 6465 6e74 6963 616c 2074 6f20 7468 6520 dentical to the │ │ │ +000515b0: 636f 7272 6573 706f 6e64 696e 6720 6669 corresponding fi │ │ │ +000515c0: 6c65 2069 6e20 7468 6973 0a09 2f2f 2074 le in this..// t │ │ │ +000515d0: 6f72 7265 6e74 2e20 5468 6520 7374 6f72 orrent. The stor │ │ │ +000515e0: 6167 6520 6d75 7374 2063 7265 6174 6520 age must create │ │ │ +000515f0: 6861 7264 206c 696e 6b73 2028 6f72 2063 hard links (or c │ │ │ +00051600: 6f70 7929 2074 686f 7365 2066 696c 6573 opy) those files │ │ │ +00051610: 2e20 4966 0a09 2f2f 2061 6e79 2066 696c . If..// any fil │ │ │ +00051620: 6520 646f 6573 206e 6f74 2065 7869 7374 e does not exist │ │ │ +00051630: 206f 7220 6973 2069 6e61 6363 6573 7369 or is inaccessi │ │ │ +00051640: 626c 652c 2074 6865 2064 6973 6b20 6a6f ble, the disk jo │ │ │ +00051650: 6220 6d75 7374 2066 6169 6c2e 0a0a 0954 b must fail....T │ │ │ +00051660: 4f52 5245 4e54 5f41 5353 4552 5428 6a2d ORRENT_ASSERT(j- │ │ │ +00051670: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ +00051680: 6669 6c65 7328 292e 7069 6563 655f 6c65 files().piece_le │ │ │ +00051690: 6e67 7468 2829 2026 6774 3b20 3029 3b0a ngth() > 0);. │ │ │ +000516a0: 0a09 2f2f 2061 6c77 6179 7320 696e 6974 ..// always init │ │ │ +000516b0: 6961 6c69 7a65 2074 6865 2073 746f 7261 ialize the stora │ │ │ +000516c0: 6765 0a09 6175 746f 2063 6f6e 7374 2072 ge..auto const r │ │ │ +000516d0: 6574 5f66 6c61 6720 3d20 6a2d 2667 743b et_flag = j-> │ │ │ +000516e0: 7374 6f72 6167 652d 2667 743b 696e 6974 storage->init │ │ │ +000516f0: 6961 6c69 7a65 286d 5f73 6574 7469 6e67 ialize(m_setting │ │ │ +00051700: 732c 206a 2d26 6774 3b65 7272 6f72 293b s, j->error); │ │ │ +00051710: 0a09 6966 2028 6a2d 2667 743b 6572 726f ..if (j->erro │ │ │ +00051720: 7229 2072 6574 7572 6e20 6469 736b 5f73 r) return disk_s │ │ │ +00051730: 7461 7475 733a 3a66 6174 616c 5f64 6973 tatus::fatal_dis │ │ │ +00051740: 6b5f 6572 726f 7220 7c20 7265 745f 666c k_error | ret_fl │ │ │ +00051750: 6167 3b0a 0a3c 2f70 7265 3e3c 2f74 643e ag;..
    │ │ │ +00051760: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00051790: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +000517a0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +000517b0: 7074 3a65 7870 616e 6428 3139 3329 223e pt:expand(193)"> │ │ │ +000517c0: 2e2e 2f73 7263 2f70 6f73 6978 5f70 6172 ../src/posix_par │ │ │ +000517d0: 745f 6669 6c65 2e63 7070 3a33 3136 3c2f t_file.cpp:316what │ │ │ +000517f0: 646f 2077 6520 646f 2069 6620 736f 6d65 do we do if some │ │ │ +00051800: 6f6e 6520 6973 2063 7572 7265 6e74 6c79 one is currently │ │ │ +00051810: 2072 6561 6469 6e67 2066 726f 6d20 7468 reading from th │ │ │ +00051820: 6520 6469 736b 2066 726f 6d20 7468 6973 e disk from this │ │ │ +00051830: 2070 6965 6365 3f20 646f 6573 2069 7420 piece? does it │ │ │ +00051840: 6d61 7474 6572 3f20 5369 6e63 6520 7765 matter? Since we │ │ │ +00051850: 2077 6f6e 2774 2061 6374 6976 656c 7920 won't actively │ │ │ +00051860: 6572 6173 6520 7468 6520 6461 7461 2066 erase the data f │ │ │ +00051870: 726f 6d20 6469 736b 2c20 6275 7420 6974 rom disk, but it │ │ │ +00051880: 206d 6179 2062 6520 6f76 6572 7772 6974 may be overwrit │ │ │ +00051890: 7465 6e20 736f 6f6e 2c20 6974 2773 2070 ten soon, it's p │ │ │ +000518a0: 726f 6261 626c 7920 6e6f 7420 7468 6174 robably not that │ │ │ +000518b0: 2062 6967 206f 6620 6120 6465 616c 3c2f big of a deal

    what │ │ │ +00051910: 2064 6f20 7765 2064 6f20 6966 2073 6f6d do we do if som │ │ │ +00051920: 656f 6e65 2069 7320 6375 7272 656e 746c eone is currentl │ │ │ +00051930: 7920 7265 6164 696e 6720 6672 6f6d 2074 y reading from t │ │ │ +00051940: 6865 2064 6973 6b0a 6672 6f6d 2074 6869 he disk.from thi │ │ │ +00051950: 7320 7069 6563 653f 2064 6f65 7320 6974 s piece? does it │ │ │ +00051960: 206d 6174 7465 723f 2053 696e 6365 2077 matter? Since w │ │ │ +00051970: 6520 776f 6e27 7420 6163 7469 7665 6c79 e won't actively │ │ │ +00051980: 2065 7261 7365 2074 6865 0a64 6174 6120 erase the.data │ │ │ +00051990: 6672 6f6d 2064 6973 6b2c 2062 7574 2069 from disk, but i │ │ │ +000519a0: 7420 6d61 7920 6265 206f 7665 7277 7269 t may be overwri │ │ │ +000519b0: 7474 656e 2073 6f6f 6e2c 2069 7427 7320 tten soon, it's │ │ │ +000519c0: 7072 6f62 6162 6c79 206e 6f74 2074 6861 probably not tha │ │ │ +000519d0: 740a 6269 6720 6f66 2061 2064 6561 6c3c t.big of a deal< │ │ │ +000519e0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +000519f0: 6f73 6978 5f70 6172 745f 6669 6c65 2e63 osix_part_file.c │ │ │ +00051a00: 7070 3a33 3136 3c2f 6834 3e3c 7072 6520 pp:316

    ....if (ec)
    │ │ │ +00051a50: 2072 6574 7572 6e20 7b7d 3b0a 0a23 6966   return {};..#if
    │ │ │ +00051a60: 6465 6620 544f 5252 454e 545f 5749 4e44  def TORRENT_WIND
    │ │ │ +00051a70: 4f57 530a 0909 0972 6574 203d 2066 696c  OWS....ret = fil
    │ │ │ +00051a80: 655f 706f 696e 7465 7228 3a3a 5f77 666f  e_pointer(::_wfo
    │ │ │ +00051a90: 7065 6e28 636f 6e76 6572 745f 746f 5f6e  pen(convert_to_n
    │ │ │ +00051aa0: 6174 6976 655f 7061 7468 5f73 7472 696e  ative_path_strin
    │ │ │ +00051ab0: 6728 666e 292e 635f 7374 7228 292c 204c  g(fn).c_str(), L
    │ │ │ +00051ac0: 2277 622b 2229 293b 0a23 656c 7365 0a09  "wb+"));.#else..
    │ │ │ +00051ad0: 0909 7265 7420 3d20 6669 6c65 5f70 6f69  ..ret = file_poi
    │ │ │ +00051ae0: 6e74 6572 283a 3a66 6f70 656e 2866 6e2e  nter(::fopen(fn.
    │ │ │ +00051af0: 635f 7374 7228 292c 2022 7762 2b22 2929  c_str(), "wb+"))
    │ │ │ +00051b00: 3b0a 2365 6e64 6966 0a09 0909 6966 2028  ;.#endif....if (
    │ │ │ +00051b10: 7265 742e 6669 6c65 2829 203d 3d20 6e75  ret.file() == nu
    │ │ │ +00051b20: 6c6c 7074 7229 0a09 0909 0965 632e 6173  llptr).....ec.as
    │ │ │ +00051b30: 7369 676e 2865 7272 6e6f 2c20 6765 6e65  sign(errno, gene
    │ │ │ +00051b40: 7269 635f 6361 7465 676f 7279 2829 293b  ric_category());
    │ │ │ +00051b50: 0a09 097d 0a09 0969 6620 2865 6329 2072  ...}...if (ec) r
    │ │ │ +00051b60: 6574 7572 6e20 7b7d 3b0a 0909 7265 7475  eturn {};...retu
    │ │ │ +00051b70: 726e 2072 6574 3b0a 097d 0a0a 0976 6f69  rn ret;..}...voi
    │ │ │ +00051b80: 6420 706f 7369 785f 7061 7274 5f66 696c  d posix_part_fil
    │ │ │ +00051b90: 653a 3a66 7265 655f 7069 6563 6528 7069  e::free_piece(pi
    │ │ │ +00051ba0: 6563 655f 696e 6465 785f 7420 636f 6e73  ece_index_t cons
    │ │ │ +00051bb0: 7420 7069 6563 6529 0a09 7b0a 0909 6175  t piece)..{...au
    │ │ │ +00051bc0: 746f 2063 6f6e 7374 2069 203d 206d 5f70  to const i = m_p
    │ │ │ +00051bd0: 6965 6365 5f6d 6170 2e66 696e 6428 7069  iece_map.find(pi
    │ │ │ +00051be0: 6563 6529 3b0a 0909 6966 2028 6920 3d3d  ece);...if (i ==
    │ │ │ +00051bf0: 206d 5f70 6965 6365 5f6d 6170 2e65 6e64   m_piece_map.end
    │ │ │ +00051c00: 2829 2920 7265 7475 726e 3b0a 0a3c 6469  ()) return;.....m_free_slots
    │ │ │ +00051c50: 2e70 7573 685f 6261 636b 2869 2d26 6774  .push_back(i->
    │ │ │ +00051c60: 3b73 6563 6f6e 6429 3b0a 0909 6d5f 7069  ;second);...m_pi
    │ │ │ +00051c70: 6563 655f 6d61 702e 6572 6173 6528 6929  ece_map.erase(i)
    │ │ │ +00051c80: 3b0a 0909 6d5f 6469 7274 795f 6d65 7461  ;...m_dirty_meta
    │ │ │ +00051c90: 6461 7461 203d 2074 7275 653b 0a09 7d0a  data = true;..}.
    │ │ │ +00051ca0: 0a09 766f 6964 2070 6f73 6978 5f70 6172  ..void posix_par
    │ │ │ +00051cb0: 745f 6669 6c65 3a3a 6d6f 7665 5f70 6172  t_file::move_par
    │ │ │ +00051cc0: 7466 696c 6528 7374 643a 3a73 7472 696e  tfile(std::strin
    │ │ │ +00051cd0: 6720 636f 6e73 7426 616d 703b 2070 6174  g const& pat
    │ │ │ +00051ce0: 682c 2065 7272 6f72 5f63 6f64 6526 616d  h, error_code&am
    │ │ │ +00051cf0: 703b 2065 6329 0a09 7b0a 0909 666c 7573  p; ec)..{...flus
    │ │ │ +00051d00: 685f 6d65 7461 6461 7461 5f69 6d70 6c28  h_metadata_impl(
    │ │ │ +00051d10: 6563 293b 0a09 0969 6620 2865 6329 2072  ec);...if (ec) r
    │ │ │ +00051d20: 6574 7572 6e3b 0a0a 0909 6966 2028 216d  eturn;....if (!m
    │ │ │ +00051d30: 5f70 6965 6365 5f6d 6170 2e65 6d70 7479  _piece_map.empty
    │ │ │ +00051d40: 2829 290a 0909 7b0a 0909 0973 7464 3a3a  ())...{....std::
    │ │ │ +00051d50: 7374 7269 6e67 206f 6c64 5f70 6174 6820  string old_path 
    │ │ │ +00051d60: 3d20 636f 6d62 696e 655f 7061 7468 286d  = combine_path(m
    │ │ │ +00051d70: 5f70 6174 682c 206d 5f6e 616d 6529 3b0a  _path, m_name);.
    │ │ │ +00051d80: 0909 0973 7464 3a3a 7374 7269 6e67 206e  ...std::string n
    │ │ │ +00051d90: 6577 5f70 6174 6820 3d20 636f 6d62 696e  ew_path = combin
    │ │ │ +00051da0: 655f 7061 7468 2870 6174 682c 206d 5f6e  e_path(path, m_n
    │ │ │ +00051db0: 616d 6529 3b0a 0a09 0909 7265 6e61 6d65  ame);.....rename
    │ │ │ +00051dc0: 286f 6c64 5f70 6174 682c 206e 6577 5f70  (old_path, new_p
    │ │ │ +00051dd0: 6174 682c 2065 6329 3b0a 0909 0969 6620  ath, ec);....if 
    │ │ │ +00051de0: 2865 6320 3d3d 2062 6f6f 7374 3a3a 7379  (ec == boost::sy
    │ │ │ +00051df0: 7374 656d 3a3a 6572 7263 3a3a 6e6f 5f73  stem::errc::no_s
    │ │ │ +00051e00: 7563 685f 6669 6c65 5f6f 725f 6469 7265  uch_file_or_dire
    │ │ │ +00051e10: 6374 6f72 7929 0a09 0909 0965 632e 636c  ctory).....ec.cl
    │ │ │ +00051e20: 6561 7228 293b 0a0a 0909 0969 6620 2865  ear();.....if (e
    │ │ │ +00051e30: 6329 0a09 0909 7b0a 0909 0909 7374 6f72  c)....{.....stor
    │ │ │ +00051e40: 6167 655f 6572 726f 7220 7365 3b0a 0909  age_error se;...
    │ │ │ +00051e50: 0909 6175 783a 3a63 6f70 795f 6669 6c65  ..aux::copy_file
    │ │ │ +00051e60: 286f 6c64 5f70 6174 682c 206e 6577 5f70  (old_path, new_p
    │ │ │ +00051e70: 6174 682c 2073 6529 3b0a 0909 0909 6563  ath, se);.....ec
    │ │ │ +00051e80: 203d 2073 652e 6563 3b0a 0909 0909 6966   = se.ec;.....if
    │ │ │ +00051e90: 2028 6563 2920 7265 7475 726e 3b0a 0909   (ec) return;...
    │ │ │ +00051ea0: 0909 7265 6d6f 7665 286f 6c64 5f70 6174  ..remove(old_pat
    │ │ │ +00051eb0: 682c 2065 6329 3b0a 0909 097d 0a09 097d  h, ec);....}...}
    │ │ │ +00051ec0: 0a09 096d 5f70 6174 6820 3d20 7061 7468  ...m_path = path
    │ │ │ +00051ed0: 3b0a 097d 0a3c 2f70 7265 3e3c 2f74 643e  ;..}.
    │ │ │ +00051ee0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00051f10: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00051f20: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00051f30: 7074 3a65 7870 616e 6428 3139 3429 223e pt:expand(194)"> │ │ │ +00051f40: 2e2e 2f73 7263 2f70 6f73 6978 5f70 6172 ../src/posix_par │ │ │ +00051f50: 745f 6669 6c65 2e63 7070 3a34 3038 3c2f t_file.cpp:408inste │ │ │ +00051f70: 6164 206f 6620 7265 6275 696c 6469 6e67 ad of rebuilding │ │ │ +00051f80: 2074 6865 2077 686f 6c65 2066 696c 6520 the whole file │ │ │ +00051f90: 6865 6164 6572 2061 6e64 2066 6c75 7368 header and flush │ │ │ +00051fa0: 696e 6720 6974 2c20 7570 6461 7465 2074 ing it, update t │ │ │ +00051fb0: 6865 2073 6c6f 7420 656e 7472 6965 7320 he slot entries │ │ │ +00051fc0: 6173 2077 6520 676f 3c2f 7464 3e3c 2f74 as we go

    instead of │ │ │ +00052020: 2072 6562 7569 6c64 696e 6720 7468 6520 rebuilding the │ │ │ +00052030: 7768 6f6c 6520 6669 6c65 2068 6561 6465 whole file heade │ │ │ +00052040: 720a 616e 6420 666c 7573 6869 6e67 2069 r.and flushing i │ │ │ +00052050: 742c 2075 7064 6174 6520 7468 6520 736c t, update the sl │ │ │ +00052060: 6f74 2065 6e74 7269 6573 2061 7320 7765 ot entries as we │ │ │ +00052070: 2067 6f3c 2f68 323e 3c68 343e 2e2e 2f73 go

    ../s │ │ │ +00052080: 7263 2f70 6f73 6978 5f70 6172 745f 6669 rc/posix_part_fi │ │ │ +00052090: 6c65 2e63 7070 3a34 3038 3c2f 6834 3e3c le.cpp:408

    < │ │ │ +000520a0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +000520b0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +000520c0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +000520d0: 7820 2364 6464 3b22 3e09 0909 0909 0965 x #ddd;">......e │ │ │ +000520e0: 632e 6173 7369 676e 2865 7272 6e6f 2c20 c.assign(errno, │ │ │ +000520f0: 6765 6e65 7269 635f 6361 7465 676f 7279 generic_category │ │ │ +00052100: 2829 293b 0a09 0909 0909 656c 7365 0a09 ());......else.. │ │ │ +00052110: 0909 0909 0965 632e 6173 7369 676e 2865 .....ec.assign(e │ │ │ +00052120: 7272 6f72 733a 3a66 696c 655f 746f 6f5f rrors::file_too_ │ │ │ +00052130: 7368 6f72 742c 206c 6962 746f 7272 656e short, libtorren │ │ │ +00052140: 745f 6361 7465 676f 7279 2829 293b 0a09 t_category());.. │ │ │ +00052150: 0909 097d 0a0a 0909 0909 6966 2028 6563 ...}......if (ec │ │ │ +00052160: 2920 7265 7475 726e 3b0a 0a09 0909 0966 ) return;......f │ │ │ +00052170: 2866 696c 655f 6f66 6673 6574 2c20 7b62 (file_offset, {b │ │ │ +00052180: 7566 2e67 6574 2829 2c20 626c 6f63 6b5f uf.get(), block_ │ │ │ +00052190: 746f 5f63 6f70 797d 293b 0a09 0909 7d0a to_copy});....}. │ │ │ +000521a0: 0909 0966 696c 655f 6f66 6673 6574 202b ...file_offset + │ │ │ +000521b0: 3d20 626c 6f63 6b5f 746f 5f63 6f70 793b = block_to_copy; │ │ │ +000521c0: 0a09 0909 7069 6563 655f 6f66 6673 6574 ....piece_offset │ │ │ +000521d0: 203d 2030 3b0a 0909 0973 697a 6520 2d3d = 0;....size -= │ │ │ +000521e0: 2062 6c6f 636b 5f74 6f5f 636f 7079 3b0a block_to_copy;. │ │ │ +000521f0: 0909 7d0a 097d 0a0a 0976 6f69 6420 706f ..}..}...void po │ │ │ +00052200: 7369 785f 7061 7274 5f66 696c 653a 3a66 six_part_file::f │ │ │ +00052210: 6c75 7368 5f6d 6574 6164 6174 6128 6572 lush_metadata(er │ │ │ +00052220: 726f 725f 636f 6465 2661 6d70 3b20 6563 ror_code& ec │ │ │ +00052230: 290a 097b 0a09 0966 6c75 7368 5f6d 6574 )..{...flush_met │ │ │ +00052240: 6164 6174 615f 696d 706c 2865 6329 3b0a adata_impl(ec);. │ │ │ +00052250: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22 .}..
    .void posix_pa │ │ │ +00052290: 7274 5f66 696c 653a 3a66 6c75 7368 5f6d rt_file::flush_m │ │ │ +000522a0: 6574 6164 6174 615f 696d 706c 2865 7272 etadata_impl(err │ │ │ +000522b0: 6f72 5f63 6f64 6526 616d 703b 2065 6329 or_code& ec) │ │ │ +000522c0: 0a3c 2f64 6976 3e09 7b0a 0909 2f2f 2064 .
    .{...// d │ │ │ +000522d0: 6f20 7765 206e 6565 6420 746f 2066 6c75 o we need to flu │ │ │ +000522e0: 7368 2074 6865 206d 6574 6164 6174 613f sh the metadata? │ │ │ +000522f0: 0a09 0969 6620 286d 5f64 6972 7479 5f6d ...if (m_dirty_m │ │ │ +00052300: 6574 6164 6174 6120 3d3d 2066 616c 7365 etadata == false │ │ │ +00052310: 2920 7265 7475 726e 3b0a 0a09 0969 6620 ) return;....if │ │ │ +00052320: 286d 5f70 6965 6365 5f6d 6170 2e65 6d70 (m_piece_map.emp │ │ │ +00052330: 7479 2829 290a 0909 7b0a 0909 092f 2f20 ty())...{....// │ │ │ +00052340: 6966 2077 6520 646f 6e27 7420 6861 7665 if we don't have │ │ │ +00052350: 2061 6e79 2070 6965 6365 7320 6c65 6674 any pieces left │ │ │ +00052360: 2069 6e20 7468 650a 0909 092f 2f20 7061 in the....// pa │ │ │ +00052370: 7274 2066 696c 652c 2072 656d 6f76 6520 rt file, remove │ │ │ +00052380: 6974 0a09 0909 7374 643a 3a73 7472 696e it....std::strin │ │ │ +00052390: 6720 636f 6e73 7420 7020 3d20 636f 6d62 g const p = comb │ │ │ +000523a0: 696e 655f 7061 7468 286d 5f70 6174 682c ine_path(m_path, │ │ │ +000523b0: 206d 5f6e 616d 6529 3b0a 0909 0972 656d m_name);....rem │ │ │ +000523c0: 6f76 6528 702c 2065 6329 3b0a 0a09 0909 ove(p, ec);..... │ │ │ +000523d0: 6966 2028 6563 203d 3d20 626f 6f73 743a if (ec == boost: │ │ │ +000523e0: 3a73 7973 7465 6d3a 3a65 7272 633a 3a6e :system::errc::n │ │ │ +000523f0: 6f5f 7375 6368 5f66 696c 655f 6f72 5f64 o_such_file_or_d │ │ │ +00052400: 6972 6563 746f 7279 290a 0909 0909 6563 irectory).....ec │ │ │ +00052410: 2e63 6c65 6172 2829 3b0a 0909 0972 6574 .clear();....ret │ │ │ +00052420: 7572 6e3b 0a09 097d 0a0a 0909 6175 746f urn;...}....auto │ │ │ +00052430: 2066 203d 206f 7065 6e5f 6669 6c65 286f f = open_file(o │ │ │ +00052440: 7065 6e5f 6d6f 6465 3a3a 7265 6164 5f77 pen_mode::read_w │ │ │ +00052450: 7269 7465 2c20 6563 293b 0a09 0969 6620 rite, ec);...if │ │ │ +00052460: 2865 6329 2072 6574 7572 6e3b 0a0a 0909 (ec) return;.... │ │ │ +00052470: 7374 643a 3a76 6563 746f 7226 6c74 3b63 std::vector<c │ │ │ +00052480: 6861 7226 6774 3b20 6865 6164 6572 2873 har> header(s │ │ │ +00052490: 7461 7469 635f 6361 7374 266c 743b 7374 tatic_cast<st │ │ │ +000524a0: 643a 3a73 697a 655f 7426 6774 3b28 6d5f d::size_t>(m_ │ │ │ +000524b0: 6865 6164 6572 5f73 697a 6529 293b 0a0a header_size));.. │ │ │ +000524c0: 0909 7573 696e 6720 6e61 6d65 7370 6163 ..using namespac │ │ │ +000524d0: 6520 6c69 6274 6f72 7265 6e74 3a3a 6175 e libtorrent::au │ │ │ +000524e0: 783b 0a0a 0909 6368 6172 2a20 7074 7220 x;....char* ptr │ │ │ +000524f0: 3d20 6865 6164 6572 2e64 6174 6128 293b = header.data(); │ │ │ +00052500: 0a09 0977 7269 7465 5f75 696e 7433 3228 ...write_uint32( │ │ │ +00052510: 6d5f 6d61 785f 7069 6563 6573 2c20 7074 m_max_pieces, pt │ │ │ +00052520: 7229 3b0a 0909 7772 6974 655f 7569 6e74 r);...write_uint │ │ │ +00052530: 3332 286d 5f70 6965 6365 5f73 697a 652c 32(m_piece_size, │ │ │ +00052540: 2070 7472 293b 0a0a 0909 666f 7220 2870 ptr);....for (p │ │ │ +00052550: 6965 6365 5f69 6e64 6578 5f74 2070 6965 iece_index_t pie │ │ │ +00052560: 6365 2830 293b 2070 6965 6365 2026 6c74 ce(0); piece < │ │ │ +00052570: 3b20 7069 6563 655f 696e 6465 785f 7428 ; piece_index_t( │ │ │ +00052580: 6d5f 6d61 785f 7069 6563 6573 293b 202b m_max_pieces); + │ │ │ +00052590: 2b70 6965 6365 290a 0909 7b0a 0909 0961 +piece)...{....a │ │ │ +000525a0: 7574 6f20 636f 6e73 7420 6920 3d20 6d5f uto const i = m_ │ │ │ +000525b0: 7069 6563 655f 6d61 702e 6669 6e64 2870 piece_map.find(p │ │ │ +000525c0: 6965 6365 293b 0a3c 2f70 7265 3e3c 2f74 iece);.
    relevanc │ │ │ +00052600: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ +00052640: 5f70 6565 722e 6370 703a 3136 373c 2f61 _peer.cpp:167how do │ │ │ +00052660: 2077 6520 6465 616c 2077 6974 6820 6f75 we deal with ou │ │ │ +00052670: 7220 6578 7465 726e 616c 2061 6464 7265 r external addre │ │ │ +00052680: 7373 2063 6861 6e67 696e 673f 3c2f 7464 ss changing?

    how do │ │ │ +000526e0: 2077 6520 6465 616c 2077 6974 6820 6f75 we deal with ou │ │ │ +000526f0: 7220 6578 7465 726e 616c 2061 6464 7265 r external addre │ │ │ +00052700: 7373 2063 6861 6e67 696e 673f 3c2f 6832 ss changing?

    ../src/torr │ │ │ +00052720: 656e 745f 7065 6572 2e63 7070 3a31 3637 ent_peer.cpp:167 │ │ │ +00052730: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ +00052770: 656e 6469 660a 0909 2c20 6973 5f76 365f  endif..., is_v6_
    │ │ │ +00052780: 6164 6472 2866 616c 7365 290a 2369 6620  addr(false).#if 
    │ │ │ +00052790: 544f 5252 454e 545f 5553 455f 4932 500a  TORRENT_USE_I2P.
    │ │ │ +000527a0: 0909 2c20 6973 5f69 3270 5f61 6464 7228  .., is_i2p_addr(
    │ │ │ +000527b0: 6661 6c73 6529 0a23 656e 6469 660a 2369  false).#endif.#i
    │ │ │ +000527c0: 6620 544f 5252 454e 545f 5553 455f 5254  f TORRENT_USE_RT
    │ │ │ +000527d0: 430a 0909 2c20 6973 5f72 7463 5f61 6464  C..., is_rtc_add
    │ │ │ +000527e0: 7228 6661 6c73 6529 0a23 656e 6469 660a  r(false).#endif.
    │ │ │ +000527f0: 0909 2c20 6f6e 5f70 6172 6f6c 6528 6661  .., on_parole(fa
    │ │ │ +00052800: 6c73 6529 0a09 092c 2062 616e 6e65 6428  lse)..., banned(
    │ │ │ +00052810: 6661 6c73 6529 0a09 092c 2073 7570 706f  false)..., suppo
    │ │ │ +00052820: 7274 735f 7574 7028 7472 7565 2920 2f2f  rts_utp(true) //
    │ │ │ +00052830: 2061 7373 756d 6520 7065 6572 7320 7375   assume peers su
    │ │ │ +00052840: 7070 6f72 7420 7574 700a 0909 2c20 636f  pport utp..., co
    │ │ │ +00052850: 6e66 6972 6d65 645f 7375 7070 6f72 7473  nfirmed_supports
    │ │ │ +00052860: 5f75 7470 2866 616c 7365 290a 0909 2c20  _utp(false)..., 
    │ │ │ +00052870: 7375 7070 6f72 7473 5f68 6f6c 6570 756e  supports_holepun
    │ │ │ +00052880: 6368 2866 616c 7365 290a 0909 2c20 7765  ch(false)..., we
    │ │ │ +00052890: 625f 7365 6564 2866 616c 7365 290a 0909  b_seed(false)...
    │ │ │ +000528a0: 2c20 7072 6f74 6f63 6f6c 5f76 3228 6661  , protocol_v2(fa
    │ │ │ +000528b0: 6c73 6529 0a09 7b7d 0a0a 0973 7464 3a3a  lse)..{}...std::
    │ │ │ +000528c0: 7569 6e74 3332 5f74 2074 6f72 7265 6e74  uint32_t torrent
    │ │ │ +000528d0: 5f70 6565 723a 3a72 616e 6b28 6175 783a  _peer::rank(aux:
    │ │ │ +000528e0: 3a65 7874 6572 6e61 6c5f 6970 2063 6f6e  :external_ip con
    │ │ │ +000528f0: 7374 2661 6d70 3b20 6578 7465 726e 616c  st& external
    │ │ │ +00052900: 2c20 696e 7420 6578 7465 726e 616c 5f70  , int external_p
    │ │ │ +00052910: 6f72 7429 2063 6f6e 7374 0a09 7b0a 0909  ort) const..{...
    │ │ │ +00052920: 544f 5252 454e 545f 4153 5345 5254 2869  TORRENT_ASSERT(i
    │ │ │ +00052930: 6e5f 7573 6529 3b0a 3c64 6976 2073 7479  n_use);.
    ..if (peer │ │ │ +00052970: 5f72 616e 6b20 3d3d 2030 290a 3c2f 6469 _rank == 0)....peer_rank = │ │ │ +00052990: 2070 6565 725f 7072 696f 7269 7479 280a peer_priority(. │ │ │ +000529a0: 0909 0909 7463 703a 3a65 6e64 706f 696e ....tcp::endpoin │ │ │ +000529b0: 7428 6578 7465 726e 616c 2e65 7874 6572 t(external.exter │ │ │ +000529c0: 6e61 6c5f 6164 6472 6573 7328 7468 6973 nal_address(this │ │ │ +000529d0: 2d26 6774 3b61 6464 7265 7373 2829 292c ->address()), │ │ │ +000529e0: 2073 7464 3a3a 7569 6e74 3136 5f74 2865 std::uint16_t(e │ │ │ +000529f0: 7874 6572 6e61 6c5f 706f 7274 2929 0a09 xternal_port)).. │ │ │ +00052a00: 0909 092c 2074 6370 3a3a 656e 6470 6f69 ..., tcp::endpoi │ │ │ +00052a10: 6e74 2874 6869 732d 2667 743b 6164 6472 nt(this->addr │ │ │ +00052a20: 6573 7328 292c 2074 6869 732d 2667 743b ess(), this-> │ │ │ +00052a30: 706f 7274 2929 3b0a 0909 7265 7475 726e port));...return │ │ │ +00052a40: 2070 6565 725f 7261 6e6b 3b0a 097d 0a0a peer_rank;..}.. │ │ │ +00052a50: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +00052a60: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ +00052a70: 0973 7464 3a3a 7374 7269 6e67 2074 6f72 .std::string tor │ │ │ +00052a80: 7265 6e74 5f70 6565 723a 3a74 6f5f 7374 rent_peer::to_st │ │ │ +00052a90: 7269 6e67 2829 2063 6f6e 7374 0a09 7b0a ring() const..{. │ │ │ +00052aa0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00052ab0: 2869 6e5f 7573 6529 3b0a 2369 6620 544f (in_use);.#if TO │ │ │ +00052ac0: 5252 454e 545f 5553 455f 4932 500a 0909 RRENT_USE_I2P... │ │ │ +00052ad0: 6966 2028 6973 5f69 3270 5f61 6464 7229 if (is_i2p_addr) │ │ │ +00052ae0: 2072 6574 7572 6e20 7374 643a 3a73 7472 return std::str │ │ │ +00052af0: 696e 6728 6465 7374 2829 293b 0a23 656e ing(dest());.#en │ │ │ +00052b00: 6469 660a 0909 7265 7475 726e 2061 6464 dif...return add │ │ │ +00052b10: 7265 7373 2829 2e74 6f5f 7374 7269 6e67 ress().to_string │ │ │ +00052b20: 2829 3b0a 097d 0a23 656e 6469 660a 0a09 ();..}.#endif... │ │ │ +00052b30: 7374 643a 3a69 6e74 3634 5f74 2074 6f72 std::int64_t tor │ │ │ +00052b40: 7265 6e74 5f70 6565 723a 3a74 6f74 616c rent_peer::total │ │ │ +00052b50: 5f64 6f77 6e6c 6f61 6428 2920 636f 6e73 _download() cons │ │ │ +00052b60: 740a 097b 0a09 0954 4f52 5245 4e54 5f41 t..{...TORRENT_A │ │ │ +00052b70: 5353 4552 5428 696e 5f75 7365 293b 0a09 SSERT(in_use);.. │ │ │ +00052b80: 0969 6620 2863 6f6e 6e65 6374 696f 6e20 .if (connection │ │ │ +00052b90: 213d 206e 756c 6c70 7472 290a 0909 7b0a != nullptr)...{. │ │ │ +00052ba0: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00052bb0: 5428 7072 6576 5f61 6d6f 756e 745f 646f T(prev_amount_do │ │ │ +00052bc0: 776e 6c6f 6164 203d 3d20 3029 3b0a 0909 wnload == 0);... │ │ │ +00052bd0: 0972 6574 7572 6e20 636f 6e6e 6563 7469 .return connecti │ │ │ +00052be0: 6f6e 2d26 6774 3b73 7461 7469 7374 6963 on->statistic │ │ │ +00052bf0: 7328 292e 746f 7461 6c5f 7061 796c 6f61 s().total_payloa │ │ │ +00052c00: 645f 646f 776e 6c6f 6164 2829 3b0a 0909 d_download();... │ │ │ +00052c10: 7d0a 0909 656c 7365 0a09 097b 0a09 0909 }...else...{.... │ │ │ +00052c20: 7265 7475 726e 2073 7464 3a3a 696e 7436 return std::int6 │ │ │ +00052c30: 345f 7428 7072 6576 5f61 6d6f 756e 745f 4_t(prev_amount_ │ │ │ +00052c40: 646f 776e 6c6f 6164 2920 2a20 3130 3234 download) * 1024 │ │ │ +00052c50: 3b0a 0909 7d0a 097d 0a3c 2f70 7265 3e3c ;...}..}.
    < │ │ │ +00052c60: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00052c90: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00052ca0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/magne │ │ │ +00052cd0: 745f 7572 692e 6370 703a 3432 353c 2f61 t_uri.cpp:425what's │ │ │ +00052cf0: 2074 6865 2072 6967 6874 206e 756d 6265 the right numbe │ │ │ +00052d00: 7220 6865 7265 3f3c 2f74 643e 3c2f 7472 r here?

    what's the │ │ │ +00052d60: 7269 6768 7420 6e75 6d62 6572 2068 6572 right number her │ │ │ +00052d70: 653f 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 e?

    ../sr │ │ │ +00052d80: 632f 6d61 676e 6574 5f75 7269 2e63 7070 c/magnet_uri.cpp │ │ │ +00052d90: 3a34 3235 3c2f 6834 3e3c 7072 6520 7374 :425

    ...}....else 
    │ │ │ +00052de0: 6966 2028 6175 783a 3a73 7472 696e 675f  if (aux::string_
    │ │ │ +00052df0: 6571 7561 6c5f 6e6f 5f63 6173 6528 6e61  equal_no_case(na
    │ │ │ +00052e00: 6d65 2c20 2273 6f22 5f73 7629 2920 2f2f  me, "so"_sv)) //
    │ │ │ +00052e10: 2073 656c 6563 742d 6f6e 6c79 2028 6669   select-only (fi
    │ │ │ +00052e20: 6c65 7329 0a09 0909 7b0a 0909 0909 2f2f  les)....{.....//
    │ │ │ +00052e30: 2061 6363 6570 7420 6f6e 6c79 2064 6967   accept only dig
    │ │ │ +00052e40: 6974 732c 2027 2d27 2061 6e64 2027 2c27  its, '-' and ','
    │ │ │ +00052e50: 0a09 0909 0969 6620 2873 7464 3a3a 616e  .....if (std::an
    │ │ │ +00052e60: 795f 6f66 2876 616c 7565 2e62 6567 696e  y_of(value.begin
    │ │ │ +00052e70: 2829 2c20 7661 6c75 652e 656e 6428 292c  (), value.end(),
    │ │ │ +00052e80: 205b 5d28 6368 6172 2063 290a 0909 0909   [](char c).....
    │ │ │ +00052e90: 097b 2072 6574 7572 6e20 2161 7578 3a3a  .{ return !aux::
    │ │ │ +00052ea0: 6973 5f64 6967 6974 2863 2920 2661 6d70  is_digit(c) &
    │ │ │ +00052eb0: 3b26 616d 703b 2063 2021 3d20 272d 2720  ;& c != '-' 
    │ │ │ +00052ec0: 2661 6d70 3b26 616d 703b 2063 2021 3d20  && c != 
    │ │ │ +00052ed0: 272c 273b 207d 2929 0a09 0909 0909 636f  ','; }))......co
    │ │ │ +00052ee0: 6e74 696e 7565 3b0a 0a09 0909 092f 2f20  ntinue;......// 
    │ │ │ +00052ef0: 6d61 6b65 2073 7572 6520 616c 6c20 6669  make sure all fi
    │ │ │ +00052f00: 6c65 2070 7269 6f72 6974 6965 7320 6172  le priorities ar
    │ │ │ +00052f10: 6520 7365 7420 746f 2030 2c20 6578 6365  e set to 0, exce
    │ │ │ +00052f20: 7074 2074 6865 206f 6e65 730a 0909 0909  pt the ones.....
    │ │ │ +00052f30: 2f2f 2077 6520 7370 6563 6966 7920 696e  // we specify in
    │ │ │ +00052f40: 2074 6865 2066 696c 655f 7072 696f 7269   the file_priori
    │ │ │ +00052f50: 7469 6573 0a09 0909 0970 2e66 6c61 6773  ties.....p.flags
    │ │ │ +00052f60: 207c 3d20 746f 7272 656e 745f 666c 6167   |= torrent_flag
    │ │ │ +00052f70: 733a 3a64 6566 6175 6c74 5f64 6f6e 745f  s::default_dont_
    │ │ │ +00052f80: 646f 776e 6c6f 6164 3b0a 0a09 0909 0964  download;......d
    │ │ │ +00052f90: 6f0a 0909 0909 7b0a 0909 0909 0973 7472  o.....{......str
    │ │ │ +00052fa0: 696e 675f 7669 6577 2074 6f6b 656e 3b0a  ing_view token;.
    │ │ │ +00052fb0: 0909 0909 0973 7464 3a3a 7469 6528 746f  .....std::tie(to
    │ │ │ +00052fc0: 6b65 6e2c 2076 616c 7565 2920 3d20 6175  ken, value) = au
    │ │ │ +00052fd0: 783a 3a73 706c 6974 5f73 7472 696e 6728  x::split_string(
    │ │ │ +00052fe0: 7661 6c75 652c 2027 2c27 293b 0a0a 0909  value, ',');....
    │ │ │ +00052ff0: 0909 0969 6620 2874 6f6b 656e 2e65 6d70  ...if (token.emp
    │ │ │ +00053000: 7479 2829 2920 636f 6e74 696e 7565 3b0a  ty()) continue;.
    │ │ │ +00053010: 0a09 0909 0909 696e 7420 6964 7831 2c20  ......int idx1, 
    │ │ │ +00053020: 6964 7832 3b0a 3c64 6976 2073 7479 6c65  idx2;.
    .....constex │ │ │ +00053060: 7072 2069 6e74 206d 6178 5f69 6e64 6578 pr int max_index │ │ │ +00053070: 203d 2031 3030 3030 3b20 2f2f 2063 616e = 10000; // can │ │ │ +00053080: 2774 2072 6973 6b20 6f75 7420 6f66 206d 't risk out of m │ │ │ +00053090: 656d 6f72 790a 3c2f 6469 763e 0a09 0909 emory.
    .... │ │ │ +000530a0: 0909 6175 746f 2063 6f6e 7374 2064 6976 ..auto const div │ │ │ +000530b0: 6964 6572 203d 2074 6f6b 656e 2e66 696e ider = token.fin │ │ │ +000530c0: 645f 6669 7273 745f 6f66 2827 2d27 293b d_first_of('-'); │ │ │ +000530d0: 0a09 0909 0909 6966 2028 6469 7669 6465 ......if (divide │ │ │ +000530e0: 7220 213d 2073 7464 3a3a 7374 7269 6e67 r != std::string │ │ │ +000530f0: 3a3a 6e70 6f73 2920 2f2f 2069 7427 7320 ::npos) // it's │ │ │ +00053100: 6120 7261 6e67 650a 0909 0909 097b 0a09 a range......{.. │ │ │ +00053110: 0909 0909 0969 6620 2864 6976 6964 6572 .....if (divider │ │ │ +00053120: 203d 3d20 3029 202f 2f20 6e6f 2073 7461 == 0) // no sta │ │ │ +00053130: 7274 2069 6e64 6578 0a09 0909 0909 0909 rt index........ │ │ │ +00053140: 636f 6e74 696e 7565 3b0a 0909 0909 0909 continue;....... │ │ │ +00053150: 6966 2028 6469 7669 6465 7220 3d3d 2074 if (divider == t │ │ │ +00053160: 6f6b 656e 2e73 697a 6528 2920 2d20 3129 oken.size() - 1) │ │ │ +00053170: 202f 2f20 6e6f 2065 6e64 2069 6e64 6578 // no end index │ │ │ +00053180: 0a09 0909 0909 0909 636f 6e74 696e 7565 ........continue │ │ │ +00053190: 3b0a 0a09 0909 0909 0969 6478 3120 3d20 ;........idx1 = │ │ │ +000531a0: 7374 643a 3a61 746f 6928 7374 643a 3a73 std::atoi(std::s │ │ │ +000531b0: 7472 696e 6728 746f 6b65 6e2e 7375 6273 tring(token.subs │ │ │ +000531c0: 7472 2830 2c20 6469 7669 6465 7229 292e tr(0, divider)). │ │ │ +000531d0: 635f 7374 7228 2929 3b0a 0909 0909 0909 c_str());....... │ │ │ +000531e0: 6966 2028 6964 7831 2026 6c74 3b20 3020 if (idx1 < 0 │ │ │ +000531f0: 7c7c 2069 6478 3120 2667 743b 206d 6178 || idx1 > max │ │ │ +00053200: 5f69 6e64 6578 2920 2f2f 2069 6e76 616c _index) // inval │ │ │ +00053210: 6964 2069 6e64 6578 0a09 0909 0909 0909 id index........ │ │ │ +00053220: 636f 6e74 696e 7565 3b0a 0909 0909 0909 continue;....... │ │ │ +00053230: 6964 7832 203d 2073 7464 3a3a 6174 6f69 idx2 = std::atoi │ │ │ +00053240: 2873 7464 3a3a 7374 7269 6e67 2874 6f6b (std::string(tok │ │ │ +00053250: 656e 2e73 7562 7374 7228 6469 7669 6465 en.substr(divide │ │ │ +00053260: 7220 2b20 3129 292e 635f 7374 7228 2929 r + 1)).c_str()) │ │ │ +00053270: 3b0a 0909 0909 0909 6966 2028 6964 7832 ;.......if (idx2 │ │ │ +00053280: 2026 6c74 3b20 3020 7c7c 2069 6478 3220 < 0 || idx2 │ │ │ +00053290: 2667 743b 206d 6178 5f69 6e64 6578 2920 > max_index) │ │ │ +000532a0: 2f2f 2069 6e76 616c 6964 2069 6e64 6578 // invalid index │ │ │ +000532b0: 0a09 0909 0909 0909 636f 6e74 696e 7565 ........continue │ │ │ +000532c0: 3b0a 0a09 0909 0909 0969 6620 2869 6478 ;........if (idx │ │ │ +000532d0: 3120 2667 743b 2069 6478 3229 202f 2f20 1 > idx2) // │ │ │ +000532e0: 7772 6f6e 6720 7261 6e67 6520 6c69 6d69 wrong range limi │ │ │ +000532f0: 7473 0a09 0909 0909 0909 636f 6e74 696e ts........contin │ │ │ +00053300: 7565 3b0a 0909 0909 097d 0a09 0909 0909 ue;......}...... │ │ │ +00053310: 656c 7365 202f 2f20 6974 2773 2061 6e20 else // it's an │ │ │ +00053320: 696e 6465 780a 0909 0909 097b 0a09 0909 index......{.... │ │ │ +00053330: 0909 0969 6478 3120 3d20 7374 643a 3a61 ...idx1 = std::a │ │ │ +00053340: 746f 6928 7374 643a 3a73 7472 696e 6728 toi(std::string( │ │ │ +00053350: 746f 6b65 6e29 2e63 5f73 7472 2829 293b token).c_str()); │ │ │ +00053360: 0a09 0909 0909 0969 6620 2869 6478 3120 .......if (idx1 │ │ │ +00053370: 266c 743b 2030 207c 7c20 6964 7831 2026 < 0 || idx1 & │ │ │ +00053380: 6774 3b20 6d61 785f 696e 6465 7829 202f gt; max_index) / │ │ │ +00053390: 2f20 696e 7661 6c69 6420 696e 6465 780a / invalid index. │ │ │ +000533a0: 0909 0909 0909 0963 6f6e 7469 6e75 653b .......continue; │ │ │ +000533b0: 0a09 0909 0909 0969 6478 3220 3d20 6964 .......idx2 = id │ │ │ +000533c0: 7831 3b0a 0909 0909 097d 0a0a 0909 0909 x1;......}...... │ │ │ +000533d0: 0969 6620 2869 6e74 2870 2e66 696c 655f .if (int(p.file_ │ │ │ +000533e0: 7072 696f 7269 7469 6573 2e73 697a 6528 priorities.size( │ │ │ +000533f0: 2929 2026 6c74 3b3d 2069 6478 3229 0a09 )) <= idx2).. │ │ │ +00053400: 0909 0909 0970 2e66 696c 655f 7072 696f .....p.file_prio │ │ │ +00053410: 7269 7469 6573 2e72 6573 697a 6528 7374 rities.resize(st │ │ │ +00053420: 6174 6963 5f63 6173 7426 6c74 3b73 7464 atic_cast<std │ │ │ +00053430: 3a3a 7369 7a65 5f74 2667 743b 2869 6478 ::size_t>(idx │ │ │ +00053440: 3229 202b 2031 2c20 646f 6e74 5f64 6f77 2) + 1, dont_dow │ │ │ +00053450: 6e6c 6f61 6429 3b0a 0a3c 2f70 7265 3e3c nload);..
    < │ │ │ +00053460: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00053490: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +000534a0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/resol │ │ │ +000534d0: 7665 5f64 7570 6c69 6361 7465 5f66 696c ve_duplicate_fil │ │ │ +000534e0: 656e 616d 6573 2e63 7070 3a31 3538 3c2f enames.cpp:158this │ │ │ +00053500: 6361 6e20 6265 206d 6f72 6520 6566 6669 can be more effi │ │ │ +00053510: 6369 656e 7420 666f 7220 7632 2074 6f72 cient for v2 tor │ │ │ +00053520: 7265 6e74 733c 2f74 643e 3c2f 7472 3e3c rents< │ │ │ +00053530: 7472 2069 643d 2231 3937 2220 7374 796c tr id="197" styl │ │ │ +00053540: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00053550: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00053560: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00053570: 6832 3e74 6869 7320 6361 6e20 6265 206d h2>this can be m │ │ │ +00053580: 6f72 6520 6566 6669 6369 656e 7420 666f ore efficient fo │ │ │ +00053590: 7220 7632 2074 6f72 7265 6e74 733c 2f68 r v2 torrents

    ../src/res │ │ │ +000535b0: 6f6c 7665 5f64 7570 6c69 6361 7465 5f66 olve_duplicate_f │ │ │ +000535c0: 696c 656e 616d 6573 2e63 7070 3a31 3538 ilenames.cpp:158 │ │ │ +000535d0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00053610: 0909 097d 0a09 0909 092b 2b6e 756d 5f63  ...}.....++num_c
    │ │ │ +00053620: 6f6c 6c69 7369 6f6e 733b 0a09 0909 0969  ollisions;.....i
    │ │ │ +00053630: 6620 286e 756d 5f63 6f6c 6c69 7369 6f6e  f (num_collision
    │ │ │ +00053640: 7320 2667 743b 206d 6178 5f64 7570 6c69  s > max_dupli
    │ │ │ +00053650: 6361 7465 5f66 696c 656e 616d 6573 290a  cate_filenames).
    │ │ │ +00053660: 0909 0909 7b0a 0909 0909 0965 6320 3d20  ....{......ec = 
    │ │ │ +00053670: 6572 726f 7273 3a3a 746f 6f5f 6d61 6e79  errors::too_many
    │ │ │ +00053680: 5f64 7570 6c69 6361 7465 5f66 696c 656e  _duplicate_filen
    │ │ │ +00053690: 616d 6573 3b0a 0909 0909 0972 6574 7572  ames;......retur
    │ │ │ +000536a0: 6e20 7b7d 3b0a 0909 0909 7d0a 0909 097d  n {};.....}....}
    │ │ │ +000536b0: 0a09 0909 7265 742e 696e 7365 7274 287b  ....ret.insert({
    │ │ │ +000536c0: 692c 2066 696c 656e 616d 657d 293b 0a09  i, filename});..
    │ │ │ +000536d0: 097d 0a09 0972 6574 7572 6e20 7265 743b  .}...return ret;
    │ │ │ +000536e0: 0a09 7d0a 0a7d 0a0a 0973 7464 3a3a 6d61  ..}..}...std::ma
    │ │ │ +000536f0: 7026 6c74 3b66 696c 655f 696e 6465 785f  p<file_index_
    │ │ │ +00053700: 742c 2073 7464 3a3a 7374 7269 6e67 2667  t, std::string&g
    │ │ │ +00053710: 743b 2072 6573 6f6c 7665 5f64 7570 6c69  t; resolve_dupli
    │ │ │ +00053720: 6361 7465 5f66 696c 656e 616d 6573 280a  cate_filenames(.
    │ │ │ +00053730: 0909 6669 6c65 5f73 746f 7261 6765 2063  ..file_storage c
    │ │ │ +00053740: 6f6e 7374 2661 6d70 3b20 6673 0a09 092c  onst& fs...,
    │ │ │ +00053750: 2069 6e74 2063 6f6e 7374 206d 6178 5f64   int const max_d
    │ │ │ +00053760: 7570 6c69 6361 7465 5f66 696c 656e 616d  uplicate_filenam
    │ │ │ +00053770: 6573 0a09 092c 2065 7272 6f72 5f63 6f64  es..., error_cod
    │ │ │ +00053780: 6526 616d 703b 2065 6329 0a09 7b0a 3c64  e& ec)..{...st
    │ │ │ +000537c0: 643a 3a75 6e6f 7264 6572 6564 5f73 6574  d::unordered_set
    │ │ │ +000537d0: 266c 743b 7374 643a 3a75 696e 7433 325f  <std::uint32_
    │ │ │ +000537e0: 7426 6774 3b20 6669 6c65 733b 0a3c 2f64  t> files;....std::strin
    │ │ │ +00053800: 6720 636f 6e73 7420 656d 7074 795f 7374  g const empty_st
    │ │ │ +00053810: 723b 0a0a 0909 2f2f 2069 6e73 6572 7420  r;....// insert 
    │ │ │ +00053820: 616c 6c20 6469 7265 6374 6f72 6965 7320  all directories 
    │ │ │ +00053830: 6669 7273 742c 2074 6f20 6d61 6b65 2073  first, to make s
    │ │ │ +00053840: 7572 6520 6e6f 2066 696c 6573 0a09 092f  ure no files.../
    │ │ │ +00053850: 2f20 6172 6520 616c 6c6f 7765 6420 746f  / are allowed to
    │ │ │ +00053860: 2063 6f6c 6c69 6564 2077 6974 6820 7468   collied with th
    │ │ │ +00053870: 656d 0a09 0966 732e 616c 6c5f 7061 7468  em...fs.all_path
    │ │ │ +00053880: 5f68 6173 6865 7328 6669 6c65 7329 3b0a  _hashes(files);.
    │ │ │ +00053890: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ +000538a0: 7420 6920 3a20 6673 2e66 696c 655f 7261  t i : fs.file_ra
    │ │ │ +000538b0: 6e67 6528 2929 0a09 097b 0a09 0909 2f2f  nge())...{....//
    │ │ │ +000538c0: 2061 7320 6c6f 6e67 2061 7320 7468 6973   as long as this
    │ │ │ +000538d0: 2066 696c 6520 616c 7265 6164 7920 6578   file already ex
    │ │ │ +000538e0: 6973 7473 0a09 0909 2f2f 2069 6e63 7265  ists....// incre
    │ │ │ +000538f0: 6173 6520 7468 6520 636f 756e 7465 720a  ase the counter.
    │ │ │ +00053900: 0909 0973 7464 3a3a 7569 6e74 3332 5f74  ...std::uint32_t
    │ │ │ +00053910: 2063 6f6e 7374 2068 203d 2066 732e 6669   const h = fs.fi
    │ │ │ +00053920: 6c65 5f70 6174 685f 6861 7368 2869 2c20  le_path_hash(i, 
    │ │ │ +00053930: 656d 7074 795f 7374 7229 3b0a 0909 0969  empty_str);....i
    │ │ │ +00053940: 6620 2821 6669 6c65 732e 696e 7365 7274  f (!files.insert
    │ │ │ +00053950: 2868 292e 7365 636f 6e64 290a 0909 097b  (h).second)....{
    │ │ │ +00053960: 0a09 0909 092f 2f20 5468 6973 2066 696c  .....// This fil
    │ │ │ +00053970: 656e 616d 6520 6170 7065 6172 7320 746f  ename appears to
    │ │ │ +00053980: 2061 6c72 6561 6479 2065 7869 7374 210a   already exist!.
    │ │ │ +00053990: 0909 0909 2f2f 2049 6620 7468 6973 2068  ....// If this h
    │ │ │ +000539a0: 6170 7065 6e73 2c20 6a75 7374 2073 7461  appens, just sta
    │ │ │ +000539b0: 7274 206f 7665 7220 616e 6420 646f 2069  rt over and do i
    │ │ │ +000539c0: 7420 7468 6520 736c 6f77 2077 6179 2c0a  t the slow way,.
    │ │ │ +000539d0: 0909 0909 2f2f 2063 6f6d 7061 7269 6e67  ....// comparing
    │ │ │ +000539e0: 2066 756c 6c20 6669 6c65 206e 616d 6573   full file names
    │ │ │ +000539f0: 2061 6e64 2063 6f6d 6520 7570 2077 6974   and come up wit
    │ │ │ +00053a00: 6820 6e65 7720 6e61 6d65 730a 0909 0909  h new names.....
    │ │ │ +00053a10: 7265 7475 726e 2072 6573 6f6c 7665 5f64  return resolve_d
    │ │ │ +00053a20: 7570 6c69 6361 7465 5f66 696c 656e 616d  uplicate_filenam
    │ │ │ +00053a30: 6573 5f73 6c6f 7728 6673 2c20 6d61 785f  es_slow(fs, max_
    │ │ │ +00053a40: 6475 706c 6963 6174 655f 6669 6c65 6e61  duplicate_filena
    │ │ │ +00053a50: 6d65 732c 2065 6329 3b0a 0909 097d 0a09  mes, ec);....}..
    │ │ │ +00053a60: 097d 0a09 0972 6574 7572 6e20 7b7d 3b0a  .}...return {};.
    │ │ │ +00053a70: 097d 0a0a 7d0a 3c2f 7072 653e 3c2f 7464  .}..}.
    relevance │ │ │ +00053ab0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00053ac0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/fingerpr │ │ │ +00053af0: 696e 742e 6370 703a 3535 3c2f 613e 3c2f int.cpp:55the finge │ │ │ +00053b10: 7270 7269 6e74 2063 6f6e 7374 7275 6374 rprint construct │ │ │ +00053b20: 6f72 2073 686f 756c 6420 7461 6b65 2061 or should take a │ │ │ +00053b30: 2073 7472 696e 675f 7669 6577 3c2f 7464 string_view

    the fi │ │ │ +00053b90: 6e67 6572 7072 696e 7420 636f 6e73 7472 ngerprint constr │ │ │ +00053ba0: 7563 746f 7220 7368 6f75 6c64 2074 616b uctor should tak │ │ │ +00053bb0: 6520 6120 7374 7269 6e67 5f76 6965 773c e a string_view< │ │ │ +00053bc0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f66 /h2>

    ../src/f │ │ │ +00053bd0: 696e 6765 7270 7269 6e74 2e63 7070 3a35 ingerprint.cpp:5 │ │ │ +00053be0: 353c 2f68 343e 3c70 7265 2073 7479 6c65 5

    │ │ │ +00053c20: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +00053c30: 5f50 5245 434f 4e44 286d 696e 6f72 2026  _PRECOND(minor &
    │ │ │ +00053c40: 6774 3b3d 2030 293b 0a09 0954 4f52 5245  gt;= 0);...TORRE
    │ │ │ +00053c50: 4e54 5f41 5353 4552 545f 5052 4543 4f4e  NT_ASSERT_PRECON
    │ │ │ +00053c60: 4428 7265 7669 7369 6f6e 2026 6774 3b3d  D(revision >=
    │ │ │ +00053c70: 2030 293b 0a09 0954 4f52 5245 4e54 5f41   0);...TORRENT_A
    │ │ │ +00053c80: 5353 4552 545f 5052 4543 4f4e 4428 7461  SSERT_PRECOND(ta
    │ │ │ +00053c90: 6720 2667 743b 3d20 3029 3b0a 0909 544f  g >= 0);...TO
    │ │ │ +00053ca0: 5252 454e 545f 4153 5345 5254 5f50 5245  RRENT_ASSERT_PRE
    │ │ │ +00053cb0: 434f 4e44 286e 616d 652e 7369 7a65 2829  COND(name.size()
    │ │ │ +00053cc0: 203d 3d20 3229 3b0a 0909 6966 2028 6e61   == 2);...if (na
    │ │ │ +00053cd0: 6d65 2e73 697a 6528 2920 266c 743b 2032  me.size() < 2
    │ │ │ +00053ce0: 2920 6e61 6d65 203d 2022 2d2d 223b 0a0a  ) name = "--";..
    │ │ │ +00053cf0: 0909 7374 643a 3a73 7472 696e 6720 7265  ..std::string re
    │ │ │ +00053d00: 743b 0a09 0972 6574 2e72 6573 697a 6528  t;...ret.resize(
    │ │ │ +00053d10: 3829 3b0a 0909 7265 745b 305d 203d 2027  8);...ret[0] = '
    │ │ │ +00053d20: 2d27 3b0a 0909 7265 745b 315d 203d 206e  -';...ret[1] = n
    │ │ │ +00053d30: 616d 655b 305d 3b0a 0909 7265 745b 325d  ame[0];...ret[2]
    │ │ │ +00053d40: 203d 206e 616d 655b 315d 3b0a 0909 7265   = name[1];...re
    │ │ │ +00053d50: 745b 335d 203d 2076 6572 7369 6f6e 5f74  t[3] = version_t
    │ │ │ +00053d60: 6f5f 6368 6172 286d 616a 6f72 293b 0a09  o_char(major);..
    │ │ │ +00053d70: 0972 6574 5b34 5d20 3d20 7665 7273 696f  .ret[4] = versio
    │ │ │ +00053d80: 6e5f 746f 5f63 6861 7228 6d69 6e6f 7229  n_to_char(minor)
    │ │ │ +00053d90: 3b0a 0909 7265 745b 355d 203d 2076 6572  ;...ret[5] = ver
    │ │ │ +00053da0: 7369 6f6e 5f74 6f5f 6368 6172 2872 6576  sion_to_char(rev
    │ │ │ +00053db0: 6973 696f 6e29 3b0a 0909 7265 745b 365d  ision);...ret[6]
    │ │ │ +00053dc0: 203d 2076 6572 7369 6f6e 5f74 6f5f 6368   = version_to_ch
    │ │ │ +00053dd0: 6172 2874 6167 293b 0a09 0972 6574 5b37  ar(tag);...ret[7
    │ │ │ +00053de0: 5d20 3d20 272d 273b 0a09 0972 6574 7572  ] = '-';...retur
    │ │ │ +00053df0: 6e20 7265 743b 0a09 7d0a 0a23 6966 6465  n ret;..}..#ifde
    │ │ │ +00053e00: 6620 5f5f 636c 616e 675f 5f0a 3c64 6976  f __clang__.
    #pragm │ │ │ +00053e40: 6120 636c 616e 6720 6469 6167 6e6f 7374 a clang diagnost │ │ │ +00053e50: 6963 2070 7573 680a 3c2f 6469 763e 2370 ic push.
    #p │ │ │ +00053e60: 7261 676d 6120 636c 616e 6720 6469 6167 ragma clang diag │ │ │ +00053e70: 6e6f 7374 6963 2069 676e 6f72 6564 2022 nostic ignored " │ │ │ +00053e80: 2d57 756e 6b6e 6f77 6e2d 7761 726e 696e -Wunknown-warnin │ │ │ +00053e90: 672d 6f70 7469 6f6e 220a 2370 7261 676d g-option".#pragm │ │ │ +00053ea0: 6120 636c 616e 6720 6469 6167 6e6f 7374 a clang diagnost │ │ │ +00053eb0: 6963 2069 676e 6f72 6564 2022 2d57 756e ic ignored "-Wun │ │ │ +00053ec0: 7361 6665 2d62 7566 6665 722d 7573 6167 safe-buffer-usag │ │ │ +00053ed0: 6522 0a23 656e 6469 660a 0a09 6669 6e67 e".#endif...fing │ │ │ +00053ee0: 6572 7072 696e 743a 3a66 696e 6765 7270 erprint::fingerp │ │ │ +00053ef0: 7269 6e74 2863 6f6e 7374 2063 6861 722a rint(const char* │ │ │ +00053f00: 2069 645f 7374 7269 6e67 2c20 696e 7420 id_string, int │ │ │ +00053f10: 6d61 6a6f 722c 2069 6e74 206d 696e 6f72 major, int minor │ │ │ +00053f20: 0a09 092c 2069 6e74 2072 6576 6973 696f ..., int revisio │ │ │ +00053f30: 6e2c 2069 6e74 2074 6167 290a 0909 3a20 n, int tag)...: │ │ │ +00053f40: 6d61 6a6f 725f 7665 7273 696f 6e28 6d61 major_version(ma │ │ │ +00053f50: 6a6f 7229 0a09 092c 206d 696e 6f72 5f76 jor)..., minor_v │ │ │ +00053f60: 6572 7369 6f6e 286d 696e 6f72 290a 0909 ersion(minor)... │ │ │ +00053f70: 2c20 7265 7669 7369 6f6e 5f76 6572 7369 , revision_versi │ │ │ +00053f80: 6f6e 2872 6576 6973 696f 6e29 0a09 092c on(revision)..., │ │ │ +00053f90: 2074 6167 5f76 6572 7369 6f6e 2874 6167 tag_version(tag │ │ │ +00053fa0: 290a 097b 0a09 0954 4f52 5245 4e54 5f41 )..{...TORRENT_A │ │ │ +00053fb0: 5353 4552 5428 6964 5f73 7472 696e 6729 SSERT(id_string) │ │ │ +00053fc0: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ +00053fd0: 5254 286d 616a 6f72 2026 6774 3b3d 2030 RT(major >= 0 │ │ │ +00053fe0: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ +00053ff0: 4552 5428 6d69 6e6f 7220 2667 743b 3d20 ERT(minor >= │ │ │ +00054000: 3029 3b0a 0909 544f 5252 454e 545f 4153 0);...TORRENT_AS │ │ │ +00054010: 5345 5254 2872 6576 6973 696f 6e20 2667 SERT(revision &g │ │ │ +00054020: 743b 3d20 3029 3b0a 0909 544f 5252 454e t;= 0);...TORREN │ │ │ +00054030: 545f 4153 5345 5254 2874 6167 2026 6774 T_ASSERT(tag > │ │ │ +00054040: 3b3d 2030 293b 0a09 0954 4f52 5245 4e54 ;= 0);...TORRENT │ │ │ +00054050: 5f41 5353 4552 5428 7374 643a 3a73 7472 _ASSERT(std::str │ │ │ +00054060: 6c65 6e28 6964 5f73 7472 696e 6729 203d len(id_string) = │ │ │ +00054070: 3d20 3229 3b0a 0909 6e61 6d65 5b30 5d20 = 2);...name[0] │ │ │ +00054080: 3d20 6964 5f73 7472 696e 675b 305d 3b0a = id_string[0];. │ │ │ +00054090: 0909 6e61 6d65 5b31 5d20 3d20 6964 5f73 ..name[1] = id_s │ │ │ +000540a0: 7472 696e 675b 315d 3b0a 097d 0a0a 2369 tring[1];..}..#i │ │ │ +000540b0: 6664 6566 205f 5f63 6c61 6e67 5f5f 0a23 fdef __clang__.# │ │ │ +000540c0: 7072 6167 6d61 2063 6c61 6e67 2064 6961 pragma clang dia │ │ │ +000540d0: 676e 6f73 7469 6320 706f 700a 2365 6e64 gnostic pop.#end │ │ │ +000540e0: 6966 0a0a 2369 6620 544f 5252 454e 545f if..#if TORRENT_ │ │ │ +000540f0: 4142 495f 5645 5253 494f 4e20 3d3d 2031 ABI_VERSION == 1 │ │ │ +00054100: 0a09 7374 643a 3a73 7472 696e 6720 6669 ..std::string fi │ │ │ +00054110: 6e67 6572 7072 696e 743a 3a74 6f5f 7374 ngerprint::to_st │ │ │ +00054120: 7269 6e67 2829 2063 6f6e 7374 0a09 7b0a ring() const..{. │ │ │ +00054130: 0909 7265 7475 726e 2067 656e 6572 6174 ..return generat │ │ │ +00054140: 655f 6669 6e67 6572 7072 696e 7428 7374 e_fingerprint(st │ │ │ +00054150: 643a 3a73 7472 696e 6728 6e61 6d65 2c20 d::string(name, │ │ │ +00054160: 3229 2c20 6d61 6a6f 725f 7665 7273 696f 2), major_versio │ │ │ +00054170: 6e2c 206d 696e 6f72 5f76 6572 7369 6f6e n, minor_version │ │ │ +00054180: 0a09 0909 2c20 7265 7669 7369 6f6e 5f76 ...., revision_v │ │ │ +00054190: 6572 7369 6f6e 2c20 7461 675f 7665 7273 ersion, tag_vers │ │ │ +000541a0: 696f 6e29 3b0a 3c2f 7072 653e 3c2f 7464 ion);.
    relevance │ │ │ +000541e0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +000541f0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/random.c │ │ │ +00054220: 7070 3a31 3137 3c2f 613e 3c2f 7464 3e3c pp:117< │ │ │ +00054230: 7464 3e69 6d70 726f 7665 2063 616c 6c69 td>improve calli │ │ │ +00054240: 6e67 2052 414e 445f 6279 7465 7320 6d75 ng RAND_bytes mu │ │ │ +00054250: 6c74 6970 6c65 2074 696d 6573 2c20 7573 ltiple times, us │ │ │ +00054260: 696e 6720 6661 6c6c 6261 636b 2066 6f72 ing fallback for │ │ │ +00054270: 206e 6f77 3c2f 7464 3e3c 2f74 723e 3c74 nowimprove callin │ │ │ +000542d0: 6720 5241 4e44 5f62 7974 6573 206d 756c g RAND_bytes mul │ │ │ +000542e0: 7469 706c 6520 7469 6d65 732c 2075 7369 tiple times, usi │ │ │ +000542f0: 6e67 2066 616c 6c62 6163 6b20 666f 7220 ng fallback for │ │ │ +00054300: 6e6f 773c 2f68 323e 3c68 343e 2e2e 2f73 now

    ../s │ │ │ +00054310: 7263 2f72 616e 646f 6d2e 6370 703a 3131 rc/random.cpp:11 │ │ │ +00054320: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ +00054360: 2365 6c73 650a 0909 0973 7464 3a3a 6765  #else....std::ge
    │ │ │ +00054370: 6e65 7261 7465 2862 7566 6665 722e 6265  nerate(buffer.be
    │ │ │ +00054380: 6769 6e28 292c 2062 7566 6665 722e 656e  gin(), buffer.en
    │ │ │ +00054390: 6428 292c 205b 5d20 7b20 7265 7475 726e  d(), [] { return
    │ │ │ +000543a0: 2063 6861 7228 7261 6e64 6f6d 2830 7866   char(random(0xf
    │ │ │ +000543b0: 6629 293b 207d 293b 0a23 656e 6469 660a  f)); });.#endif.
    │ │ │ +000543c0: 0909 7d0a 0a09 0976 6f69 6420 6372 7970  ..}....void cryp
    │ │ │ +000543d0: 746f 5f72 616e 646f 6d5f 6279 7465 7328  to_random_bytes(
    │ │ │ +000543e0: 7370 616e 266c 743b 6368 6172 2667 743b  span<char>
    │ │ │ +000543f0: 2062 7566 6665 7229 0a09 097b 0a23 6966   buffer)...{.#if
    │ │ │ +00054400: 6465 6620 544f 5252 454e 545f 4255 494c  def TORRENT_BUIL
    │ │ │ +00054410: 445f 5349 4d55 4c41 544f 520a 0909 092f  D_SIMULATOR..../
    │ │ │ +00054420: 2f20 496e 2074 6865 2073 696d 756c 6174  / In the simulat
    │ │ │ +00054430: 6f72 2077 6520 7761 6e74 2064 6574 6572  or we want deter
    │ │ │ +00054440: 6d69 6e69 7374 6963 2072 616e 646f 6d20  ministic random 
    │ │ │ +00054450: 6e75 6d62 6572 730a 0909 0973 7464 3a3a  numbers....std::
    │ │ │ +00054460: 6765 6e65 7261 7465 2862 7566 6665 722e  generate(buffer.
    │ │ │ +00054470: 6265 6769 6e28 292c 2062 7566 6665 722e  begin(), buffer.
    │ │ │ +00054480: 656e 6428 292c 205b 5d20 7b20 7265 7475  end(), [] { retu
    │ │ │ +00054490: 726e 2063 6861 7228 7261 6e64 6f6d 2830  rn char(random(0
    │ │ │ +000544a0: 7866 6629 293b 207d 293b 0a23 656c 6966  xff)); });.#elif
    │ │ │ +000544b0: 2054 4f52 5245 4e54 5f55 5345 5f43 4e47   TORRENT_USE_CNG
    │ │ │ +000544c0: 0a09 0909 6175 783a 3a63 6e67 5f67 656e  ....aux::cng_gen
    │ │ │ +000544d0: 5f72 616e 646f 6d28 6275 6666 6572 293b  _random(buffer);
    │ │ │ +000544e0: 0a23 656c 6966 2054 4f52 5245 4e54 5f55  .#elif TORRENT_U
    │ │ │ +000544f0: 5345 5f43 5259 5054 4f41 5049 0a09 0909  SE_CRYPTOAPI....
    │ │ │ +00054500: 2f2f 2077 696e 646f 7773 0a09 0909 6175  // windows....au
    │ │ │ +00054510: 783a 3a63 7279 7074 5f67 656e 5f72 616e  x::crypt_gen_ran
    │ │ │ +00054520: 646f 6d28 6275 6666 6572 293b 0a23 656c  dom(buffer);.#el
    │ │ │ +00054530: 6966 2064 6566 696e 6564 2054 4f52 5245  if defined TORRE
    │ │ │ +00054540: 4e54 5f55 5345 5f4c 4942 4352 5950 544f  NT_USE_LIBCRYPTO
    │ │ │ +00054550: 2026 616d 703b 2661 6d70 3b20 2164 6566   && !def
    │ │ │ +00054560: 696e 6564 2054 4f52 5245 4e54 5f55 5345  ined TORRENT_USE
    │ │ │ +00054570: 5f57 4f4c 4653 534c 0a2f 2f20 776f 6c66  _WOLFSSL.// wolf
    │ │ │ +00054580: 5353 4c20 7573 6573 2077 635f 524e 475f  SSL uses wc_RNG_
    │ │ │ +00054590: 4765 6e65 7261 7465 426c 6f63 6b20 6173  GenerateBlock as
    │ │ │ +000545a0: 2074 6865 2069 6e74 6572 6e61 6c20 6675   the internal fu
    │ │ │ +000545b0: 6e63 7469 6f6e 2066 6f72 2074 6865 0a2f  nction for the./
    │ │ │ +000545c0: 2f20 6f70 656e 7373 6c20 636f 6d70 6174  / openssl compat
    │ │ │ +000545d0: 6962 696c 6974 7920 6c61 7965 722e 2054  ibility layer. T
    │ │ │ +000545e0: 6869 7320 6675 6e63 7469 6f6e 2041 5049  his function API
    │ │ │ +000545f0: 2064 6f65 7320 6e6f 7420 7375 7070 6f72   does not suppor
    │ │ │ +00054600: 740a 2f2f 2061 6e20 6172 6269 7472 6172  t.// an arbitrar
    │ │ │ +00054610: 7920 6275 6666 6572 2073 697a 6520 286f  y buffer size (o
    │ │ │ +00054620: 7065 6e73 736c 2064 6f65 7329 2c20 6974  penssl does), it
    │ │ │ +00054630: 2069 7320 6c69 6d69 7465 6420 6279 2074   is limited by t
    │ │ │ +00054640: 6865 0a2f 2f20 636f 6e73 7461 6e74 2052  he.// constant R
    │ │ │ +00054650: 4e47 5f4d 4158 5f42 4c4f 434b 5f4c 454e  NG_MAX_BLOCK_LEN
    │ │ │ +00054660: 2e0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00054690: 0a3c 2f64 6976 3e09 0909 2f2f 206f 7065 .
    ...// ope │ │ │ +000546a0: 6e73 736c 0a09 0909 696e 7420 7220 3d20 nssl....int r = │ │ │ +000546b0: 5241 4e44 5f62 7974 6573 2872 6569 6e74 RAND_bytes(reint │ │ │ +000546c0: 6572 7072 6574 5f63 6173 7426 6c74 3b75 erpret_cast<u │ │ │ +000546d0: 6e73 6967 6e65 6420 6368 6172 2a26 6774 nsigned char*> │ │ │ +000546e0: 3b28 6275 6666 6572 2e64 6174 6128 2929 ;(buffer.data()) │ │ │ +000546f0: 0a09 0909 092c 2069 6e74 2862 7566 6665 ....., int(buffe │ │ │ +00054700: 722e 7369 7a65 2829 2929 3b0a 0909 0969 r.size()));....i │ │ │ +00054710: 6620 2872 2021 3d20 3129 2061 7578 3a3a f (r != 1) aux:: │ │ │ +00054720: 7468 726f 775f 6578 266c 743b 7379 7374 throw_ex<syst │ │ │ +00054730: 656d 5f65 7272 6f72 2667 743b 2865 7272 em_error>(err │ │ │ +00054740: 6f72 733a 3a6e 6f5f 656e 7472 6f70 7929 ors::no_entropy) │ │ │ +00054750: 3b0a 2365 6c69 6620 544f 5252 454e 545f ;.#elif TORRENT_ │ │ │ +00054760: 5553 455f 4745 5452 414e 444f 4d0a 0909 USE_GETRANDOM... │ │ │ +00054770: 0973 7369 7a65 5f74 2063 6f6e 7374 2072 .ssize_t const r │ │ │ +00054780: 203d 203a 3a67 6574 7261 6e64 6f6d 2862 = ::getrandom(b │ │ │ +00054790: 7566 6665 722e 6461 7461 2829 2c20 7374 uffer.data(), st │ │ │ +000547a0: 6174 6963 5f63 6173 7426 6c74 3b73 7464 atic_cast<std │ │ │ +000547b0: 3a3a 7369 7a65 5f74 2667 743b 2862 7566 ::size_t>(buf │ │ │ +000547c0: 6665 722e 7369 7a65 2829 292c 2030 293b fer.size()), 0); │ │ │ +000547d0: 0a09 0909 6966 2028 7220 3d3d 2073 7369 ....if (r == ssi │ │ │ +000547e0: 7a65 5f74 2862 7566 6665 722e 7369 7a65 ze_t(buffer.size │ │ │ +000547f0: 2829 2929 2072 6574 7572 6e3b 0a09 0909 ())) return;.... │ │ │ +00054800: 6966 2028 7220 3d3d 202d 3120 2661 6d70 if (r == -1 & │ │ │ +00054810: 3b26 616d 703b 2065 7272 6e6f 2021 3d20 ;& errno != │ │ │ +00054820: 454e 4f53 5953 2920 6175 783a 3a74 6872 ENOSYS) aux::thr │ │ │ +00054830: 6f77 5f65 7826 6c74 3b73 7973 7465 6d5f ow_ex<system_ │ │ │ +00054840: 6572 726f 7226 6774 3b28 6572 726f 725f error>(error_ │ │ │ +00054850: 636f 6465 2865 7272 6e6f 2c20 6765 6e65 code(errno, gene │ │ │ +00054860: 7269 635f 6361 7465 676f 7279 2829 2929 ric_category())) │ │ │ +00054870: 3b0a 0909 0973 7461 7469 6320 6465 765f ;....static dev_ │ │ │ +00054880: 7261 6e64 6f6d 2064 6576 3b0a 0909 0964 random dev;....d │ │ │ +00054890: 6576 2e72 6561 6428 6275 6666 6572 293b ev.read(buffer); │ │ │ +000548a0: 0a23 656c 6966 2054 4f52 5245 4e54 5f55 .#elif TORRENT_U │ │ │ +000548b0: 5345 5f44 4556 5f52 414e 444f 4d0a 0909 SE_DEV_RANDOM... │ │ │ +000548c0: 0973 7461 7469 6320 6465 765f 7261 6e64 .static dev_rand │ │ │ +000548d0: 6f6d 2064 6576 3b0a 0909 0964 6576 2e72 om dev;....dev.r │ │ │ +000548e0: 6561 6428 6275 6666 6572 293b 0a23 656c ead(buffer);.#el │ │ │ +000548f0: 7365 0a0a 2369 6620 544f 5252 454e 545f se..#if TORRENT_ │ │ │ +00054900: 4252 4f4b 454e 5f52 414e 444f 4d5f 4445 BROKEN_RANDOM_DE │ │ │ +00054910: 5649 4345 0a09 0909 2f2f 2065 7665 6e20 VICE....// even │ │ │ +00054920: 7073 6575 646f 2072 616e 646f 6d20 6e75 pseudo random nu │ │ │ +00054930: 6d62 6572 7320 7265 6c79 206f 6e20 6265 mbers rely on be │ │ │ +00054940: 696e 6720 6162 6c65 2074 6f20 7365 6564 ing able to seed │ │ │ +00054950: 2074 6865 2072 616e 646f 6d0a 0909 092f the random..../ │ │ │ +00054960: 2f20 6765 6e65 7261 746f 720a 2365 7272 / generator.#err │ │ │ +00054970: 6f72 2022 6e6f 2065 6e74 726f 7079 2073 or "no entropy s │ │ │ +00054980: 6f75 7263 6520 6176 6169 6c61 626c 6522 ource available" │ │ │ +00054990: 0a23 656c 7365 0a23 6966 6465 6620 544f .#else.#ifdef TO │ │ │ +000549a0: 5252 454e 545f 495f 5741 4e54 5f49 4e53 RRENT_I_WANT_INS │ │ │ +000549b0: 4543 5552 455f 5241 4e44 4f4d 5f4e 554d ECURE_RANDOM_NUM │ │ │ +000549c0: 4245 5253 0a09 0909 7374 643a 3a67 656e BERS....std::gen │ │ │ +000549d0: 6572 6174 6528 6275 6666 6572 2e62 6567 erate(buffer.beg │ │ │ +000549e0: 696e 2829 2c20 6275 6666 6572 2e65 6e64 in(), buffer.end │ │ │ +000549f0: 2829 2c20 5b5d 207b 2072 6574 7572 6e20 (), [] { return │ │ │ +00054a00: 6368 6172 2872 616e 646f 6d28 3078 6666 char(random(0xff │ │ │ +00054a10: 2929 3b20 7d29 3b0a 2365 6c73 650a 2365 )); });.#else.#e │ │ │ +00054a20: 7272 6f72 2022 6e6f 2073 6563 7572 6520 rror "no secure │ │ │ +00054a30: 656e 7472 6f70 7920 736f 7572 6365 2061 entropy source a │ │ │ +00054a40: 7661 696c 6162 6c65 2e20 4966 2079 6f75 vailable. If you │ │ │ +00054a50: 2072 6561 6c6c 7920 7761 6e74 2069 6e73 really want ins │ │ │ +00054a60: 6563 7572 6520 7261 6e64 6f6d 206e 756d ecure random num │ │ │ +00054a70: 6265 7273 2c20 6465 6669 6e65 2054 4f52 bers, define TOR │ │ │ +00054a80: 5245 4e54 5f49 5f57 414e 545f 494e 5345 RENT_I_WANT_INSE │ │ │ +00054a90: 4355 5245 5f52 414e 444f 4d5f 4e55 4d42 CURE_RANDOM_NUMB │ │ │ +00054aa0: 4552 5322 0a23 656e 6469 660a 2365 6e64 ERS".#endif.#end │ │ │ +00054ab0: 6966 0a0a 2365 6e64 6966 0a09 097d 0a0a if..#endif...}.. │ │ │ +00054ac0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00054ad0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00054b00: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00054b30: 632f 746f 7272 656e 745f 6861 6e64 6c65 c/torrent_handle │ │ │ +00054b40: 2e63 7070 3a35 3534 3c2f 613e 3c2f 7464 .cpp:554support mov │ │ │ +00054b60: 696e 6720 6669 6c65 7320 696e 746f 2074 ing files into t │ │ │ +00054b70: 6869 7320 6361 6c6c 3c2f 7464 3e3c 2f74 his call

    support mo │ │ │ +00054bd0: 7669 6e67 2066 696c 6573 2069 6e74 6f20 ving files into │ │ │ +00054be0: 7468 6973 2063 616c 6c3c 2f68 323e 3c68 this call

    ../src/torrent │ │ │ +00054c00: 5f68 616e 646c 652e 6370 703a 3535 343c _handle.cpp:554< │ │ │ +00054c10: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00054c50: 6175 746f 2a20 636f 6e73 7420 7265 7470  auto* const retp
    │ │ │ +00054c60: 203d 2026 616d 703b 7072 696f 3b0a 0909   = &prio;...
    │ │ │ +00054c70: 7379 6e63 5f63 616c 6c28 2661 6d70 3b61  sync_call(&a
    │ │ │ +00054c80: 7578 3a3a 746f 7272 656e 743a 3a70 6965  ux::torrent::pie
    │ │ │ +00054c90: 6365 5f70 7269 6f72 6974 6965 732c 2072  ce_priorities, r
    │ │ │ +00054ca0: 6574 7029 3b0a 0909 7374 643a 3a76 6563  etp);...std::vec
    │ │ │ +00054cb0: 746f 7226 6c74 3b69 6e74 2667 743b 2072  tor<int> r
    │ │ │ +00054cc0: 6574 3b0a 0909 7265 742e 7265 7365 7276  et;...ret.reserv
    │ │ │ +00054cd0: 6528 7072 696f 2e73 697a 6528 2929 3b0a  e(prio.size());.
    │ │ │ +00054ce0: 0909 666f 7220 2861 7574 6f20 7020 3a20  ..for (auto p : 
    │ │ │ +00054cf0: 7072 696f 290a 0909 0972 6574 2e70 7573  prio)....ret.pus
    │ │ │ +00054d00: 685f 6261 636b 2869 6e74 2873 7461 7469  h_back(int(stati
    │ │ │ +00054d10: 635f 6361 7374 266c 743b 7374 643a 3a75  c_cast<std::u
    │ │ │ +00054d20: 696e 7438 5f74 2667 743b 2870 2929 293b  int8_t>(p)));
    │ │ │ +00054d30: 0a09 0972 6574 7572 6e20 7265 743b 0a09  ...return ret;..
    │ │ │ +00054d40: 7d0a 2365 6e64 6966 0a0a 0976 6f69 6420  }.#endif...void 
    │ │ │ +00054d50: 746f 7272 656e 745f 6861 6e64 6c65 3a3a  torrent_handle::
    │ │ │ +00054d60: 6669 6c65 5f70 7269 6f72 6974 7928 6669  file_priority(fi
    │ │ │ +00054d70: 6c65 5f69 6e64 6578 5f74 2069 6e64 6578  le_index_t index
    │ │ │ +00054d80: 2c20 646f 776e 6c6f 6164 5f70 7269 6f72  , download_prior
    │ │ │ +00054d90: 6974 795f 7420 7072 696f 7269 7479 2920  ity_t priority) 
    │ │ │ +00054da0: 636f 6e73 740a 097b 0a09 0961 7379 6e63  const..{...async
    │ │ │ +00054db0: 5f63 616c 6c28 2661 6d70 3b61 7578 3a3a  _call(&aux::
    │ │ │ +00054dc0: 746f 7272 656e 743a 3a73 6574 5f66 696c  torrent::set_fil
    │ │ │ +00054dd0: 655f 7072 696f 7269 7479 2c20 696e 6465  e_priority, inde
    │ │ │ +00054de0: 782c 2070 7269 6f72 6974 7929 3b0a 097d  x, priority);..}
    │ │ │ +00054df0: 0a0a 0964 6f77 6e6c 6f61 645f 7072 696f  ...download_prio
    │ │ │ +00054e00: 7269 7479 5f74 2074 6f72 7265 6e74 5f68  rity_t torrent_h
    │ │ │ +00054e10: 616e 646c 653a 3a66 696c 655f 7072 696f  andle::file_prio
    │ │ │ +00054e20: 7269 7479 2866 696c 655f 696e 6465 785f  rity(file_index_
    │ │ │ +00054e30: 7420 696e 6465 7829 2063 6f6e 7374 0a09  t index) const..
    │ │ │ +00054e40: 7b0a 0909 7265 7475 726e 2073 796e 635f  {...return sync_
    │ │ │ +00054e50: 6361 6c6c 5f72 6574 266c 743b 646f 776e  call_ret<down
    │ │ │ +00054e60: 6c6f 6164 5f70 7269 6f72 6974 795f 7426  load_priority_t&
    │ │ │ +00054e70: 6774 3b28 646f 6e74 5f64 6f77 6e6c 6f61  gt;(dont_downloa
    │ │ │ +00054e80: 642c 2026 616d 703b 6175 783a 3a74 6f72  d, &aux::tor
    │ │ │ +00054e90: 7265 6e74 3a3a 6669 6c65 5f70 7269 6f72  rent::file_prior
    │ │ │ +00054ea0: 6974 792c 2069 6e64 6578 293b 0a09 7d0a  ity, index);..}.
    │ │ │ +00054eb0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00054ee0: 766f 6964 2074 6f72 7265 6e74 5f68 616e void torrent_han │ │ │ +00054ef0: 646c 653a 3a70 7269 6f72 6974 697a 655f dle::prioritize_ │ │ │ +00054f00: 6669 6c65 7328 7374 643a 3a76 6563 746f files(std::vecto │ │ │ +00054f10: 7226 6c74 3b64 6f77 6e6c 6f61 645f 7072 r<download_pr │ │ │ +00054f20: 696f 7269 7479 5f74 2667 743b 2063 6f6e iority_t> con │ │ │ +00054f30: 7374 2661 6d70 3b20 6669 6c65 7329 2063 st& files) c │ │ │ +00054f40: 6f6e 7374 0a3c 2f64 6976 3e09 7b0a 0909 onst.
    .{... │ │ │ +00054f50: 6173 796e 635f 6361 6c6c 2826 616d 703b async_call(& │ │ │ +00054f60: 6175 783a 3a74 6f72 7265 6e74 3a3a 7072 aux::torrent::pr │ │ │ +00054f70: 696f 7269 7469 7a65 5f66 696c 6573 0a09 ioritize_files.. │ │ │ +00054f80: 0909 2c20 7374 6174 6963 5f63 6173 7426 .., static_cast& │ │ │ +00054f90: 6c74 3b61 7578 3a3a 7665 6374 6f72 266c lt;aux::vector&l │ │ │ +00054fa0: 743b 646f 776e 6c6f 6164 5f70 7269 6f72 t;download_prior │ │ │ +00054fb0: 6974 795f 742c 2066 696c 655f 696e 6465 ity_t, file_inde │ │ │ +00054fc0: 785f 7426 6774 3b20 636f 6e73 7426 616d x_t> const&am │ │ │ +00054fd0: 703b 2667 743b 2866 696c 6573 2929 3b0a p;>(files));. │ │ │ +00054fe0: 097d 0a0a 0976 6f69 6420 746f 7272 656e .}...void torren │ │ │ +00054ff0: 745f 6861 6e64 6c65 3a3a 706f 7374 5f66 t_handle::post_f │ │ │ +00055000: 696c 655f 7072 696f 7269 7469 6573 2829 ile_priorities() │ │ │ +00055010: 2063 6f6e 7374 0a09 7b0a 0909 6173 796e const..{...asyn │ │ │ +00055020: 635f 6361 6c6c 2826 616d 703b 6175 783a c_call(&aux: │ │ │ +00055030: 3a74 6f72 7265 6e74 3a3a 706f 7374 5f66 :torrent::post_f │ │ │ +00055040: 696c 655f 7072 696f 7269 7469 6573 293b ile_priorities); │ │ │ +00055050: 0a09 7d0a 0a09 7374 643a 3a76 6563 746f ..}...std::vecto │ │ │ +00055060: 7226 6c74 3b64 6f77 6e6c 6f61 645f 7072 r<download_pr │ │ │ +00055070: 696f 7269 7479 5f74 2667 743b 2074 6f72 iority_t> tor │ │ │ +00055080: 7265 6e74 5f68 616e 646c 653a 3a67 6574 rent_handle::get │ │ │ +00055090: 5f66 696c 655f 7072 696f 7269 7469 6573 _file_priorities │ │ │ +000550a0: 2829 2063 6f6e 7374 0a09 7b0a 0909 6175 () const..{...au │ │ │ +000550b0: 783a 3a76 6563 746f 7226 6c74 3b64 6f77 x::vector<dow │ │ │ +000550c0: 6e6c 6f61 645f 7072 696f 7269 7479 5f74 nload_priority_t │ │ │ +000550d0: 2c20 6669 6c65 5f69 6e64 6578 5f74 2667 , file_index_t&g │ │ │ +000550e0: 743b 2072 6574 3b0a 0909 6175 746f 2a20 t; ret;...auto* │ │ │ +000550f0: 636f 6e73 7420 7265 7470 203d 2026 616d const retp = &am │ │ │ +00055100: 703b 7265 743b 0a09 0973 796e 635f 6361 p;ret;...sync_ca │ │ │ +00055110: 6c6c 2826 616d 703b 6175 783a 3a74 6f72 ll(&aux::tor │ │ │ +00055120: 7265 6e74 3a3a 6669 6c65 5f70 7269 6f72 rent::file_prior │ │ │ +00055130: 6974 6965 732c 2072 6574 7029 3b0a 0909 ities, retp);... │ │ │ +00055140: 7265 7475 726e 2054 4f52 5245 4e54 5f52 return TORRENT_R │ │ │ +00055150: 564f 2872 6574 293b 0a09 7d0a 0a23 6966 VO(ret);..}..#if │ │ │ +00055160: 2054 4f52 5245 4e54 5f41 4249 5f56 4552 TORRENT_ABI_VER │ │ │ +00055170: 5349 4f4e 203d 3d20 310a 0a2f 2f20 3d3d SION == 1..// == │ │ │ +00055180: 3d3d 3d3d 3d3d 3d3d 3d3d 2073 7461 7274 ========== start │ │ │ +00055190: 2064 6570 7265 6361 7469 6f6e 203d 3d3d deprecation === │ │ │ +000551a0: 3d3d 3d3d 3d3d 3d3d 3d3d 3d3d 0a0a 0976 ============...v │ │ │ +000551b0: 6f69 6420 746f 7272 656e 745f 6861 6e64 oid torrent_hand │ │ │ +000551c0: 6c65 3a3a 7072 696f 7269 7469 7a65 5f66 le::prioritize_f │ │ │ +000551d0: 696c 6573 2873 7464 3a3a 7665 6374 6f72 iles(std::vector │ │ │ +000551e0: 266c 743b 696e 7426 6774 3b20 636f 6e73 <int> cons │ │ │ +000551f0: 7426 616d 703b 2066 696c 6573 2920 636f t& files) co │ │ │ +00055200: 6e73 740a 097b 0a09 0961 7578 3a3a 7665 nst..{...aux::ve │ │ │ +00055210: 6374 6f72 266c 743b 646f 776e 6c6f 6164 ctor<download │ │ │ +00055220: 5f70 7269 6f72 6974 795f 742c 2066 696c _priority_t, fil │ │ │ +00055230: 655f 696e 6465 785f 7426 6774 3b20 6669 e_index_t> fi │ │ │ +00055240: 6c65 5f70 7269 6f3b 0a09 0966 696c 655f le_prio;...file_ │ │ │ +00055250: 7072 696f 2e72 6573 6572 7665 2866 696c prio.reserve(fil │ │ │ +00055260: 6573 2e73 697a 6528 2929 3b0a 0909 666f es.size());...fo │ │ │ +00055270: 7220 2861 7574 6f20 636f 6e73 7420 7020 r (auto const p │ │ │ +00055280: 3a20 6669 6c65 7329 207b 0a09 0909 6669 : files) {....fi │ │ │ +00055290: 6c65 5f70 7269 6f2e 7075 7368 5f62 6163 le_prio.push_bac │ │ │ +000552a0: 6b28 646f 776e 6c6f 6164 5f70 7269 6f72 k(download_prior │ │ │ +000552b0: 6974 795f 7428 7374 6174 6963 5f63 6173 ity_t(static_cas │ │ │ +000552c0: 7426 6c74 3b73 7464 3a3a 7569 6e74 385f t<std::uint8_ │ │ │ +000552d0: 7426 6774 3b28 7029 2929 3b0a 0909 7d0a t>(p)));...}. │ │ │ +000552e0: 0909 6173 796e 635f 6361 6c6c 2826 616d ..async_call(&am │ │ │ +000552f0: 703b 6175 783a 3a74 6f72 7265 6e74 3a3a p;aux::torrent:: │ │ │ +00055300: 7072 696f 7269 7469 7a65 5f66 696c 6573 prioritize_files │ │ │ +00055310: 2c20 6669 6c65 5f70 7269 6f29 3b0a 3c2f , file_prio);.r │ │ │ +00055350: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00055360: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00055390: 746f 7272 656e 745f 6861 6e64 6c65 2e63 torrent_handle.c │ │ │ +000553a0: 7070 3a38 3339 3c2f 613e 3c2f 7464 3e3c pp:839< │ │ │ +000553b0: 7464 3e64 6570 7265 6361 7465 2074 6865 td>deprecate the │ │ │ +000553c0: 206f 7665 726c 6f61 6420 7468 6174 2074 overload that t │ │ │ +000553d0: 616b 6573 2061 6e20 696e 6465 783c 2f74 akes an index

    depre │ │ │ +00055430: 6361 7465 2074 6865 206f 7665 726c 6f61 cate the overloa │ │ │ +00055440: 6420 7468 6174 2074 616b 6573 2061 6e20 d that takes an │ │ │ +00055450: 696e 6465 783c 2f68 323e 3c68 343e 2e2e index

    .. │ │ │ +00055460: 2f73 7263 2f74 6f72 7265 6e74 5f68 616e /src/torrent_han │ │ │ +00055470: 646c 652e 6370 703a 3833 393c 2f68 343e dle.cpp:839

    │ │ │ +00055480: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...aut
    │ │ │ +000554c0: 6f20 7420 3d20 6d5f 746f 7272 656e 742e  o t = m_torrent.
    │ │ │ +000554d0: 6c6f 636b 2829 3b0a 0909 6966 2028 2174  lock();...if (!t
    │ │ │ +000554e0: 207c 7c20 2174 2d26 6774 3b68 6173 5f73   || !t->has_s
    │ │ │ +000554f0: 746f 7261 6765 2829 2920 7265 7475 726e  torage()) return
    │ │ │ +00055500: 3b0a 0909 6175 746f 2661 6d70 3b20 7365  ;...auto& se
    │ │ │ +00055510: 7320 3d20 7374 6174 6963 5f63 6173 7426  s = static_cast&
    │ │ │ +00055520: 6c74 3b73 6573 7369 6f6e 5f69 6d70 6c26  lt;session_impl&
    │ │ │ +00055530: 616d 703b 2667 743b 2874 2d26 6774 3b73  amp;>(t->s
    │ │ │ +00055540: 6573 7369 6f6e 2829 293b 0a09 0973 7461  ession());...sta
    │ │ │ +00055550: 7475 7320 3d20 7365 732e 6469 736b 5f74  tus = ses.disk_t
    │ │ │ +00055560: 6872 6561 6428 292e 6765 745f 7374 6174  hread().get_stat
    │ │ │ +00055570: 7573 2874 2d26 6774 3b73 746f 7261 6765  us(t->storage
    │ │ │ +00055580: 2829 293b 0a09 7d0a 2365 6e64 6966 0a0a  ());..}.#endif..
    │ │ │ +00055590: 0976 6f69 6420 746f 7272 656e 745f 6861  .void torrent_ha
    │ │ │ +000555a0: 6e64 6c65 3a3a 666f 7263 655f 6468 745f  ndle::force_dht_
    │ │ │ +000555b0: 616e 6e6f 756e 6365 2829 2063 6f6e 7374  announce() const
    │ │ │ +000555c0: 0a09 7b0a 2369 666e 6465 6620 544f 5252  ..{.#ifndef TORR
    │ │ │ +000555d0: 454e 545f 4449 5341 424c 455f 4448 540a  ENT_DISABLE_DHT.
    │ │ │ +000555e0: 0909 6173 796e 635f 6361 6c6c 2826 616d  ..async_call(&am
    │ │ │ +000555f0: 703b 6175 783a 3a74 6f72 7265 6e74 3a3a  p;aux::torrent::
    │ │ │ +00055600: 6468 745f 616e 6e6f 756e 6365 293b 0a23  dht_announce);.#
    │ │ │ +00055610: 656e 6469 660a 097d 0a0a 0976 6f69 6420  endif..}...void 
    │ │ │ +00055620: 746f 7272 656e 745f 6861 6e64 6c65 3a3a  torrent_handle::
    │ │ │ +00055630: 666f 7263 655f 6c73 645f 616e 6e6f 756e  force_lsd_announ
    │ │ │ +00055640: 6365 2829 2063 6f6e 7374 0a09 7b0a 0909  ce() const..{...
    │ │ │ +00055650: 6173 796e 635f 6361 6c6c 2826 616d 703b  async_call(&
    │ │ │ +00055660: 6175 783a 3a74 6f72 7265 6e74 3a3a 6c73  aux::torrent::ls
    │ │ │ +00055670: 645f 616e 6e6f 756e 6365 293b 0a09 7d0a  d_announce);..}.
    │ │ │ +00055680: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +000556b0: 766f 6964 2074 6f72 7265 6e74 5f68 616e void torrent_han │ │ │ +000556c0: 646c 653a 3a66 6f72 6365 5f72 6561 6e6e dle::force_reann │ │ │ +000556d0: 6f75 6e63 6528 696e 7420 636f 6e73 7420 ounce(int const │ │ │ +000556e0: 732c 2069 6e74 2063 6f6e 7374 2069 6478 s, int const idx │ │ │ +000556f0: 2c20 7265 616e 6e6f 756e 6365 5f66 6c61 , reannounce_fla │ │ │ +00055700: 6773 5f74 2063 6f6e 7374 2066 6c61 6773 gs_t const flags │ │ │ +00055710: 2920 636f 6e73 740a 3c2f 6469 763e 097b ) const.
    .{ │ │ │ +00055720: 0a09 0961 7379 6e63 5f63 616c 6c28 2661 ...async_call(&a │ │ │ +00055730: 6d70 3b61 7578 3a3a 746f 7272 656e 743a mp;aux::torrent: │ │ │ +00055740: 3a66 6f72 6365 5f74 7261 636b 6572 5f72 :force_tracker_r │ │ │ +00055750: 6571 7565 7374 2c20 6175 783a 3a74 696d equest, aux::tim │ │ │ +00055760: 655f 6e6f 7728 2920 2b20 7365 636f 6e64 e_now() + second │ │ │ +00055770: 7328 7329 2c20 6964 782c 2066 6c61 6773 s(s), idx, flags │ │ │ +00055780: 293b 0a09 7d0a 0a09 766f 6964 2074 6f72 );..}...void tor │ │ │ +00055790: 7265 6e74 5f68 616e 646c 653a 3a66 6f72 rent_handle::for │ │ │ +000557a0: 6365 5f72 6561 6e6e 6f75 6e63 6528 696e ce_reannounce(in │ │ │ +000557b0: 7420 636f 6e73 7420 732c 2073 7464 3a3a t const s, std:: │ │ │ +000557c0: 7374 7269 6e67 2063 6f6e 7374 2661 6d70 string const& │ │ │ +000557d0: 3b20 7572 6c2c 2072 6561 6e6e 6f75 6e63 ; url, reannounc │ │ │ +000557e0: 655f 666c 6167 735f 7420 636f 6e73 7420 e_flags_t const │ │ │ +000557f0: 666c 6167 7329 2063 6f6e 7374 0a09 7b0a flags) const..{. │ │ │ +00055800: 0909 6173 796e 635f 6361 6c6c 2826 616d ..async_call(&am │ │ │ +00055810: 703b 6175 783a 3a74 6f72 7265 6e74 3a3a p;aux::torrent:: │ │ │ +00055820: 666f 7263 655f 7472 6163 6b65 725f 7265 force_tracker_re │ │ │ +00055830: 7175 6573 745f 7572 6c2c 2061 7578 3a3a quest_url, aux:: │ │ │ +00055840: 7469 6d65 5f6e 6f77 2829 202b 2073 6563 time_now() + sec │ │ │ +00055850: 6f6e 6473 2873 292c 2075 726c 2c20 666c onds(s), url, fl │ │ │ +00055860: 6167 7329 3b0a 097d 0a0a 0976 6f69 6420 ags);..}...void │ │ │ +00055870: 746f 7272 656e 745f 6861 6e64 6c65 3a3a torrent_handle:: │ │ │ +00055880: 666f 7263 655f 7265 616e 6e6f 756e 6365 force_reannounce │ │ │ +00055890: 2869 6e74 2063 6f6e 7374 2073 2c20 7265 (int const s, re │ │ │ +000558a0: 616e 6e6f 756e 6365 5f66 6c61 6773 5f74 announce_flags_t │ │ │ +000558b0: 2063 6f6e 7374 2066 6c61 6773 2920 636f const flags) co │ │ │ +000558c0: 6e73 740a 097b 0a09 0961 7379 6e63 5f63 nst..{...async_c │ │ │ +000558d0: 616c 6c28 2661 6d70 3b61 7578 3a3a 746f all(&aux::to │ │ │ +000558e0: 7272 656e 743a 3a66 6f72 6365 5f74 7261 rrent::force_tra │ │ │ +000558f0: 636b 6572 5f72 6571 7565 7374 2c20 6175 cker_request, au │ │ │ +00055900: 783a 3a74 696d 655f 6e6f 7728 2920 2b20 x::time_now() + │ │ │ +00055910: 7365 636f 6e64 7328 7329 2c20 2d31 2c20 seconds(s), -1, │ │ │ +00055920: 666c 6167 7329 3b0a 097d 0a0a 0973 7464 flags);..}...std │ │ │ +00055930: 3a3a 7665 6374 6f72 266c 743b 6f70 656e ::vector<open │ │ │ +00055940: 5f66 696c 655f 7374 6174 6526 6774 3b20 _file_state> │ │ │ +00055950: 746f 7272 656e 745f 6861 6e64 6c65 3a3a torrent_handle:: │ │ │ +00055960: 6669 6c65 5f73 7461 7475 7328 2920 636f file_status() co │ │ │ +00055970: 6e73 740a 097b 0a09 0961 7574 6f20 7420 nst..{...auto t │ │ │ +00055980: 3d20 6d5f 746f 7272 656e 742e 6c6f 636b = m_torrent.lock │ │ │ +00055990: 2829 3b0a 0909 6966 2028 2174 207c 7c20 ();...if (!t || │ │ │ +000559a0: 2174 2d26 6774 3b68 6173 5f73 746f 7261 !t->has_stora │ │ │ +000559b0: 6765 2829 2920 7265 7475 726e 207b 7d3b ge()) return {}; │ │ │ +000559c0: 0a09 0961 7574 6f26 616d 703b 2073 6573 ...auto& ses │ │ │ +000559d0: 203d 2073 7461 7469 635f 6361 7374 266c = static_cast&l │ │ │ +000559e0: 743b 7365 7373 696f 6e5f 696d 706c 2661 t;session_impl&a │ │ │ +000559f0: 6d70 3b26 6774 3b28 742d 2667 743b 7365 mp;>(t->se │ │ │ +00055a00: 7373 696f 6e28 2929 3b0a 0909 7265 7475 ssion());...retu │ │ │ +00055a10: 726e 2073 6573 2e64 6973 6b5f 7468 7265 rn ses.disk_thre │ │ │ +00055a20: 6164 2829 2e67 6574 5f73 7461 7475 7328 ad().get_status( │ │ │ +00055a30: 742d 2667 743b 7374 6f72 6167 6528 2929 t->storage()) │ │ │ +00055a40: 3b0a 097d 0a0a 0976 6f69 6420 746f 7272 ;..}...void torr │ │ │ +00055a50: 656e 745f 6861 6e64 6c65 3a3a 706f 7374 ent_handle::post │ │ │ +00055a60: 5f66 696c 655f 7374 6174 7573 2829 2063 _file_status() c │ │ │ +00055a70: 6f6e 7374 0a09 7b0a 0909 6173 796e 635f onst..{...async_ │ │ │ +00055a80: 6361 6c6c 2826 616d 703b 6175 783a 3a74 call(&aux::t │ │ │ +00055a90: 6f72 7265 6e74 3a3a 706f 7374 5f66 696c orrent::post_fil │ │ │ +00055aa0: 655f 7374 6174 7573 293b 0a09 7d0a 0a09 e_status);..}... │ │ │ +00055ab0: 766f 6964 2074 6f72 7265 6e74 5f68 616e void torrent_han │ │ │ +00055ac0: 646c 653a 3a73 6372 6170 655f 7472 6163 dle::scrape_trac │ │ │ +00055ad0: 6b65 7228 696e 7420 6964 7829 2063 6f6e ker(int idx) con │ │ │ +00055ae0: 7374 0a09 7b0a 0909 6173 796e 635f 6361 st..{...async_ca │ │ │ +00055af0: 6c6c 2826 616d 703b 6175 783a 3a74 6f72 ll(&aux::tor │ │ │ +00055b00: 7265 6e74 3a3a 7363 7261 7065 5f74 7261 rent::scrape_tra │ │ │ +00055b10: 636b 6572 2c20 6964 782c 2074 7275 6529 cker, idx, true) │ │ │ +00055b20: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +00055b50: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00055b60: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00055b90: 7372 632f 7061 7274 5f66 696c 652e 6370 src/part_file.cp │ │ │ +00055ba0: 703a 3239 343c 2f61 3e3c 2f74 643e 3c74 p:294what do we do │ │ │ +00055bc0: 6966 2073 6f6d 656f 6e65 2069 7320 6375 if someone is cu │ │ │ +00055bd0: 7272 656e 746c 7920 7265 6164 696e 6720 rrently reading │ │ │ +00055be0: 6672 6f6d 2074 6865 2064 6973 6b20 6672 from the disk fr │ │ │ +00055bf0: 6f6d 2074 6869 7320 7069 6563 653f 2064 om this piece? d │ │ │ +00055c00: 6f65 7320 6974 206d 6174 7465 723f 2053 oes it matter? S │ │ │ +00055c10: 696e 6365 2077 6520 776f 6e27 7420 6163 ince we won't ac │ │ │ +00055c20: 7469 7665 6c79 2065 7261 7365 2074 6865 tively erase the │ │ │ +00055c30: 2064 6174 6120 6672 6f6d 2064 6973 6b2c data from disk, │ │ │ +00055c40: 2062 7574 2069 7420 6d61 7920 6265 206f but it may be o │ │ │ +00055c50: 7665 7277 7269 7474 656e 2073 6f6f 6e2c verwritten soon, │ │ │ +00055c60: 2069 7427 7320 7072 6f62 6162 6c79 206e it's probably n │ │ │ +00055c70: 6f74 2074 6861 7420 6269 6720 6f66 2061 ot that big of a │ │ │ +00055c80: 2064 6561 6c3c 2f74 643e 3c2f 7472 3e3c deal< │ │ │ +00055c90: 7472 2069 643d 2232 3032 2220 7374 796c tr id="202" styl │ │ │ +00055ca0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00055cb0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00055cc0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00055cd0: 6832 3e77 6861 7420 646f 2077 6520 646f h2>what do we do │ │ │ +00055ce0: 2069 6620 736f 6d65 6f6e 6520 6973 2063 if someone is c │ │ │ +00055cf0: 7572 7265 6e74 6c79 2072 6561 6469 6e67 urrently reading │ │ │ +00055d00: 2066 726f 6d20 7468 6520 6469 736b 0a66 from the disk.f │ │ │ +00055d10: 726f 6d20 7468 6973 2070 6965 6365 3f20 rom this piece? │ │ │ +00055d20: 646f 6573 2069 7420 6d61 7474 6572 3f20 does it matter? │ │ │ +00055d30: 5369 6e63 6520 7765 2077 6f6e 2774 2061 Since we won't a │ │ │ +00055d40: 6374 6976 656c 7920 6572 6173 6520 7468 ctively erase th │ │ │ +00055d50: 650a 6461 7461 2066 726f 6d20 6469 736b e.data from disk │ │ │ +00055d60: 2c20 6275 7420 6974 206d 6179 2062 6520 , but it may be │ │ │ +00055d70: 6f76 6572 7772 6974 7465 6e20 736f 6f6e overwritten soon │ │ │ +00055d80: 2c20 6974 2773 2070 726f 6261 626c 7920 , it's probably │ │ │ +00055d90: 6e6f 7420 7468 6174 0a62 6967 206f 6620 not that.big of │ │ │ +00055da0: 6120 6465 616c 3c2f 6832 3e3c 6834 3e2e a deal

    . │ │ │ +00055db0: 2e2f 7372 632f 7061 7274 5f66 696c 652e ./src/part_file. │ │ │ +00055dc0: 6370 703a 3239 343c 2f68 343e 3c70 7265 cpp:294

    ....create
    │ │ │ +00055e10: 5f64 6972 6563 746f 7269 6573 286d 5f70  _directories(m_p
    │ │ │ +00055e20: 6174 682c 2065 6329 3b0a 0909 0909 6966  ath, ec);.....if
    │ │ │ +00055e30: 2028 6563 2920 7265 7475 726e 207b 7d3b   (ec) return {};
    │ │ │ +00055e40: 0a09 0909 0972 6574 7572 6e20 7b66 6e2c  .....return {fn,
    │ │ │ +00055e50: 2030 2c20 6d6f 6465 7d3b 0a09 0909 7d0a   0, mode};....}.
    │ │ │ +00055e60: 0909 0972 6574 7572 6e20 7b7d 3b0a 0909  ...return {};...
    │ │ │ +00055e70: 7d0a 097d 0a09 6361 7463 6820 2873 746f  }..}..catch (sto
    │ │ │ +00055e80: 7261 6765 5f65 7272 6f72 2063 6f6e 7374  rage_error const
    │ │ │ +00055e90: 2661 6d70 3b20 6529 0a09 7b0a 0909 6563  & e)..{...ec
    │ │ │ +00055ea0: 203d 2065 2e65 633b 0a09 0972 6574 7572   = e.ec;...retur
    │ │ │ +00055eb0: 6e20 7b7d 3b0a 097d 0a0a 0976 6f69 6420  n {};..}...void 
    │ │ │ +00055ec0: 7061 7274 5f66 696c 653a 3a66 7265 655f  part_file::free_
    │ │ │ +00055ed0: 7069 6563 6528 7069 6563 655f 696e 6465  piece(piece_inde
    │ │ │ +00055ee0: 785f 7420 636f 6e73 7420 7069 6563 6529  x_t const piece)
    │ │ │ +00055ef0: 0a09 7b0a 0909 7374 643a 3a6c 6f63 6b5f  ..{...std::lock_
    │ │ │ +00055f00: 6775 6172 6426 6c74 3b73 7464 3a3a 6d75  guard<std::mu
    │ │ │ +00055f10: 7465 7826 6774 3b20 6c28 6d5f 6d75 7465  tex> l(m_mute
    │ │ │ +00055f20: 7829 3b0a 0a09 0961 7574 6f20 636f 6e73  x);....auto cons
    │ │ │ +00055f30: 7420 6920 3d20 6d5f 7069 6563 655f 6d61  t i = m_piece_ma
    │ │ │ +00055f40: 702e 6669 6e64 2870 6965 6365 293b 0a09  p.find(piece);..
    │ │ │ +00055f50: 0969 6620 2869 203d 3d20 6d5f 7069 6563  .if (i == m_piec
    │ │ │ +00055f60: 655f 6d61 702e 656e 6428 2929 2072 6574  e_map.end()) ret
    │ │ │ +00055f70: 7572 6e3b 0a0a 3c64 6976 2073 7479 6c65  urn;..
    .
    ..m_f │ │ │ +00055fb0: 7265 655f 736c 6f74 732e 7075 7368 5f62 ree_slots.push_b │ │ │ +00055fc0: 6163 6b28 692d 2667 743b 7365 636f 6e64 ack(i->second │ │ │ +00055fd0: 293b 0a09 096d 5f70 6965 6365 5f6d 6170 );...m_piece_map │ │ │ +00055fe0: 2e65 7261 7365 2869 293b 0a09 096d 5f64 .erase(i);...m_d │ │ │ +00055ff0: 6972 7479 5f6d 6574 6164 6174 6120 3d20 irty_metadata = │ │ │ +00056000: 7472 7565 3b0a 097d 0a0a 0976 6f69 6420 true;..}...void │ │ │ +00056010: 7061 7274 5f66 696c 653a 3a6d 6f76 655f part_file::move_ │ │ │ +00056020: 7061 7274 6669 6c65 2873 7464 3a3a 7374 partfile(std::st │ │ │ +00056030: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ +00056040: 7061 7468 2c20 6572 726f 725f 636f 6465 path, error_code │ │ │ +00056050: 2661 6d70 3b20 6563 290a 097b 0a09 0973 & ec)..{...s │ │ │ +00056060: 7464 3a3a 6c6f 636b 5f67 7561 7264 266c td::lock_guard&l │ │ │ +00056070: 743b 7374 643a 3a6d 7574 6578 2667 743b t;std::mutex> │ │ │ +00056080: 206c 286d 5f6d 7574 6578 293b 0a0a 0909 l(m_mutex);.... │ │ │ +00056090: 666c 7573 685f 6d65 7461 6461 7461 5f69 flush_metadata_i │ │ │ +000560a0: 6d70 6c28 6563 293b 0a09 0969 6620 2865 mpl(ec);...if (e │ │ │ +000560b0: 6329 2072 6574 7572 6e3b 0a0a 0909 6966 c) return;....if │ │ │ +000560c0: 2028 216d 5f70 6965 6365 5f6d 6170 2e65 (!m_piece_map.e │ │ │ +000560d0: 6d70 7479 2829 290a 0909 7b0a 0909 0973 mpty())...{....s │ │ │ +000560e0: 7464 3a3a 7374 7269 6e67 206f 6c64 5f70 td::string old_p │ │ │ +000560f0: 6174 6820 3d20 636f 6d62 696e 655f 7061 ath = combine_pa │ │ │ +00056100: 7468 286d 5f70 6174 682c 206d 5f6e 616d th(m_path, m_nam │ │ │ +00056110: 6529 3b0a 0909 0973 7464 3a3a 7374 7269 e);....std::stri │ │ │ +00056120: 6e67 206e 6577 5f70 6174 6820 3d20 636f ng new_path = co │ │ │ +00056130: 6d62 696e 655f 7061 7468 2870 6174 682c mbine_path(path, │ │ │ +00056140: 206d 5f6e 616d 6529 3b0a 0a09 0909 7265 m_name);.....re │ │ │ +00056150: 6e61 6d65 286f 6c64 5f70 6174 682c 206e name(old_path, n │ │ │ +00056160: 6577 5f70 6174 682c 2065 6329 3b0a 0909 ew_path, ec);... │ │ │ +00056170: 0969 6620 2865 6320 3d3d 2062 6f6f 7374 .if (ec == boost │ │ │ +00056180: 3a3a 7379 7374 656d 3a3a 6572 7263 3a3a ::system::errc:: │ │ │ +00056190: 6e6f 5f73 7563 685f 6669 6c65 5f6f 725f no_such_file_or_ │ │ │ +000561a0: 6469 7265 6374 6f72 7929 0a09 0909 0965 directory).....e │ │ │ +000561b0: 632e 636c 6561 7228 293b 0a0a 0909 0969 c.clear();.....i │ │ │ +000561c0: 6620 2865 6329 0a09 0909 7b0a 0909 0909 f (ec)....{..... │ │ │ +000561d0: 7374 6f72 6167 655f 6572 726f 7220 7365 storage_error se │ │ │ +000561e0: 3b0a 0909 0909 6175 783a 3a63 6f70 795f ;.....aux::copy_ │ │ │ +000561f0: 6669 6c65 286f 6c64 5f70 6174 682c 206e file(old_path, n │ │ │ +00056200: 6577 5f70 6174 682c 2073 6529 3b0a 0909 ew_path, se);... │ │ │ +00056210: 0909 6563 203d 2073 652e 6563 3b0a 0909 ..ec = se.ec;... │ │ │ +00056220: 0909 6966 2028 6563 2920 7265 7475 726e ..if (ec) return │ │ │ +00056230: 3b0a 0909 0909 7265 6d6f 7665 286f 6c64 ;.....remove(old │ │ │ +00056240: 5f70 6174 682c 2065 6329 3b0a 0909 097d _path, ec);....} │ │ │ +00056250: 0a09 097d 0a3c 2f70 7265 3e3c 2f74 643e ...}.
    │ │ │ +00056260: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00056290: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +000562a0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +000562b0: 7074 3a65 7870 616e 6428 3230 3329 223e pt:expand(203)"> │ │ │ +000562c0: 2e2e 2f73 7263 2f70 6172 745f 6669 6c65 ../src/part_file │ │ │ +000562d0: 2e63 7070 3a34 3035 3c2f 613e 3c2f 7464 .cpp:405instead of │ │ │ +000562f0: 7265 6275 696c 6469 6e67 2074 6865 2077 rebuilding the w │ │ │ +00056300: 686f 6c65 2066 696c 6520 6865 6164 6572 hole file header │ │ │ +00056310: 2061 6e64 2066 6c75 7368 696e 6720 6974 and flushing it │ │ │ +00056320: 2c20 7570 6461 7465 2074 6865 2073 6c6f , update the slo │ │ │ +00056330: 7420 656e 7472 6965 7320 6173 2077 6520 t entries as we │ │ │ +00056340: 676f 3c2f 7464 3e3c 2f74 723e 3c74 7220 go

    │ │ │ +00056390: 696e 7374 6561 6420 6f66 2072 6562 7569 instead of rebui │ │ │ +000563a0: 6c64 696e 6720 7468 6520 7768 6f6c 6520 lding the whole │ │ │ +000563b0: 6669 6c65 2068 6561 6465 720a 616e 6420 file header.and │ │ │ +000563c0: 666c 7573 6869 6e67 2069 742c 2075 7064 flushing it, upd │ │ │ +000563d0: 6174 6520 7468 6520 736c 6f74 2065 6e74 ate the slot ent │ │ │ +000563e0: 7269 6573 2061 7320 7765 2067 6f3c 2f68 ries as we go

    ../src/par │ │ │ +00056400: 745f 6669 6c65 2e63 7070 3a34 3035 3c2f t_file.cpp:405
    ...
    │ │ │ +00056450: 0909 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +00056460: 5428 6a2d 2667 743b 7365 636f 6e64 203d  T(j->second =
    │ │ │ +00056470: 3d20 736c 6f74 293b 0a09 0909 0909 096d  = slot);.......m
    │ │ │ +00056480: 5f66 7265 655f 736c 6f74 732e 7075 7368  _free_slots.push
    │ │ │ +00056490: 5f62 6163 6b28 6a2d 2667 743b 7365 636f  _back(j->seco
    │ │ │ +000564a0: 6e64 293b 0a09 0909 0909 096d 5f70 6965  nd);.......m_pie
    │ │ │ +000564b0: 6365 5f6d 6170 2e65 7261 7365 286a 293b  ce_map.erase(j);
    │ │ │ +000564c0: 0a09 0909 0909 096d 5f64 6972 7479 5f6d  .......m_dirty_m
    │ │ │ +000564d0: 6574 6164 6174 6120 3d20 7472 7565 3b0a  etadata = true;.
    │ │ │ +000564e0: 0909 0909 097d 0a09 0909 097d 0a09 0909  .....}.....}....
    │ │ │ +000564f0: 7d0a 0909 0966 696c 655f 6f66 6673 6574  }....file_offset
    │ │ │ +00056500: 202b 3d20 626c 6f63 6b5f 746f 5f63 6f70   += block_to_cop
    │ │ │ +00056510: 793b 0a09 0909 7069 6563 655f 6f66 6673  y;....piece_offs
    │ │ │ +00056520: 6574 203d 2030 3b0a 0909 0973 697a 6520  et = 0;....size 
    │ │ │ +00056530: 2d3d 2062 6c6f 636b 5f74 6f5f 636f 7079  -= block_to_copy
    │ │ │ +00056540: 3b0a 0909 7d0a 097d 0a0a 0976 6f69 6420  ;...}..}...void 
    │ │ │ +00056550: 7061 7274 5f66 696c 653a 3a66 6c75 7368  part_file::flush
    │ │ │ +00056560: 5f6d 6574 6164 6174 6128 6572 726f 725f  _metadata(error_
    │ │ │ +00056570: 636f 6465 2661 6d70 3b20 6563 290a 097b  code& ec)..{
    │ │ │ +00056580: 0a09 0973 7464 3a3a 6c6f 636b 5f67 7561  ...std::lock_gua
    │ │ │ +00056590: 7264 266c 743b 7374 643a 3a6d 7574 6578  rd<std::mutex
    │ │ │ +000565a0: 2667 743b 206c 286d 5f6d 7574 6578 293b  > l(m_mutex);
    │ │ │ +000565b0: 0a0a 0909 666c 7573 685f 6d65 7461 6461  ....flush_metada
    │ │ │ +000565c0: 7461 5f69 6d70 6c28 6563 293b 0a09 7d0a  ta_impl(ec);..}.
    │ │ │ +000565d0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00056600: 766f 6964 2070 6172 745f 6669 6c65 3a3a void part_file:: │ │ │ +00056610: 666c 7573 685f 6d65 7461 6461 7461 5f69 flush_metadata_i │ │ │ +00056620: 6d70 6c28 6572 726f 725f 636f 6465 2661 mpl(error_code&a │ │ │ +00056630: 6d70 3b20 6563 290a 3c2f 6469 763e 097b mp; ec).
    .{ │ │ │ +00056640: 0a09 092f 2f20 646f 2077 6520 6e65 6564 ...// do we need │ │ │ +00056650: 2074 6f20 666c 7573 6820 7468 6520 6d65 to flush the me │ │ │ +00056660: 7461 6461 7461 3f0a 0909 6966 2028 6d5f tadata?...if (m_ │ │ │ +00056670: 6469 7274 795f 6d65 7461 6461 7461 203d dirty_metadata = │ │ │ +00056680: 3d20 6661 6c73 6529 2072 6574 7572 6e3b = false) return; │ │ │ +00056690: 0a0a 0909 6966 2028 6d5f 7069 6563 655f ....if (m_piece_ │ │ │ +000566a0: 6d61 702e 656d 7074 7928 2929 0a09 097b map.empty())...{ │ │ │ +000566b0: 0a09 0909 2f2f 2069 6620 7765 2064 6f6e ....// if we don │ │ │ +000566c0: 2774 2068 6176 6520 616e 7920 7069 6563 't have any piec │ │ │ +000566d0: 6573 206c 6566 7420 696e 2074 6865 0a09 es left in the.. │ │ │ +000566e0: 0909 2f2f 2070 6172 7420 6669 6c65 2c20 ..// part file, │ │ │ +000566f0: 7265 6d6f 7665 2069 740a 0909 0973 7464 remove it....std │ │ │ +00056700: 3a3a 7374 7269 6e67 2063 6f6e 7374 2070 ::string const p │ │ │ +00056710: 203d 2063 6f6d 6269 6e65 5f70 6174 6828 = combine_path( │ │ │ +00056720: 6d5f 7061 7468 2c20 6d5f 6e61 6d65 293b m_path, m_name); │ │ │ +00056730: 0a09 0909 7265 6d6f 7665 2870 2c20 6563 ....remove(p, ec │ │ │ +00056740: 293b 0a0a 0909 0969 6620 2865 6320 3d3d );.....if (ec == │ │ │ +00056750: 2062 6f6f 7374 3a3a 7379 7374 656d 3a3a boost::system:: │ │ │ +00056760: 6572 7263 3a3a 6e6f 5f73 7563 685f 6669 errc::no_such_fi │ │ │ +00056770: 6c65 5f6f 725f 6469 7265 6374 6f72 7929 le_or_directory) │ │ │ +00056780: 0a09 0909 0965 632e 636c 6561 7228 293b .....ec.clear(); │ │ │ +00056790: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a ....return;...}. │ │ │ +000567a0: 0a09 0961 7574 6f20 6620 3d20 6f70 656e ...auto f = open │ │ │ +000567b0: 5f66 696c 6528 6175 783a 3a6f 7065 6e5f _file(aux::open_ │ │ │ +000567c0: 6d6f 6465 3a3a 7772 6974 6520 7c20 6175 mode::write | au │ │ │ +000567d0: 783a 3a6f 7065 6e5f 6d6f 6465 3a3a 6869 x::open_mode::hi │ │ │ +000567e0: 6464 656e 2c20 6563 293b 0a09 0969 6620 dden, ec);...if │ │ │ +000567f0: 2865 6329 2072 6574 7572 6e3b 0a0a 0909 (ec) return;.... │ │ │ +00056800: 7374 643a 3a76 6563 746f 7226 6c74 3b63 std::vector<c │ │ │ +00056810: 6861 7226 6774 3b20 6865 6164 6572 2873 har> header(s │ │ │ +00056820: 7461 7469 635f 6361 7374 266c 743b 7374 tatic_cast<st │ │ │ +00056830: 643a 3a73 697a 655f 7426 6774 3b28 6d5f d::size_t>(m_ │ │ │ +00056840: 6865 6164 6572 5f73 697a 6529 293b 0a0a header_size));.. │ │ │ +00056850: 0909 7573 696e 6720 6e61 6d65 7370 6163 ..using namespac │ │ │ +00056860: 6520 6c69 6274 6f72 7265 6e74 3a3a 6175 e libtorrent::au │ │ │ +00056870: 783b 0a0a 0909 6368 6172 2a20 7074 7220 x;....char* ptr │ │ │ +00056880: 3d20 6865 6164 6572 2e64 6174 6128 293b = header.data(); │ │ │ +00056890: 0a09 0977 7269 7465 5f75 696e 7433 3228 ...write_uint32( │ │ │ +000568a0: 6d5f 6d61 785f 7069 6563 6573 2c20 7074 m_max_pieces, pt │ │ │ +000568b0: 7229 3b0a 0909 7772 6974 655f 7569 6e74 r);...write_uint │ │ │ +000568c0: 3332 286d 5f70 6965 6365 5f73 697a 652c 32(m_piece_size, │ │ │ +000568d0: 2070 7472 293b 0a0a 0909 666f 7220 2870 ptr);....for (p │ │ │ +000568e0: 6965 6365 5f69 6e64 6578 5f74 2070 6965 iece_index_t pie │ │ │ +000568f0: 6365 2830 293b 2070 6965 6365 2026 6c74 ce(0); piece < │ │ │ +00056900: 3b20 7069 6563 655f 696e 6465 785f 7428 ; piece_index_t( │ │ │ +00056910: 6d5f 6d61 785f 7069 6563 6573 293b 202b m_max_pieces); + │ │ │ +00056920: 2b70 6965 6365 290a 0909 7b0a 0909 0961 +piece)...{....a │ │ │ +00056930: 7574 6f20 636f 6e73 7420 6920 3d20 6d5f uto const i = m_ │ │ │ +00056940: 7069 6563 655f 6d61 702e 6669 6e64 2870 piece_map.find(p │ │ │ +00056950: 6965 6365 293b 0a3c 2f70 7265 3e3c 2f74 iece);.
    relevanc │ │ │ +00056990: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/add_tor │ │ │ +000569d0: 7265 6e74 5f70 6172 616d 732e 6370 703a rent_params.cpp: │ │ │ +000569e0: 3331 3c2f 613e 3c2f 7464 3e3c 7464 3e69 31i │ │ │ +000569f0: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ +00056a00: 6966 2074 6869 7320 7761 7320 6e6f 7468 if this was noth │ │ │ +00056a10: 726f 7720 6465 6661 756c 7420 636f 6e73 row default cons │ │ │ +00056a20: 7472 7563 7469 626c 6520 7374 6174 6963 tructible static │ │ │ +00056a30: 5f61 7373 6572 7428 7374 643a 3a69 735f _assert(std::is_ │ │ │ +00056a40: 6e6f 7468 726f 775f 6465 6661 756c 745f nothrow_default_ │ │ │ +00056a50: 636f 6e73 7472 7563 7469 626c 653c 6164 constructible::value , "shou │ │ │ +00056a80: 6c64 2062 6520 6e6f 7468 726f 7720 6465 ld be nothrow de │ │ │ +00056a90: 6661 756c 7420 636f 6e73 7472 7563 7469 fault constructi │ │ │ +00056aa0: 626c 6522 293b 3c2f 7464 3e3c 2f74 723e ble"); │ │ │ +00056ab0: 3c74 7220 6964 3d22 3230 3422 2073 7479 │ │ │ +00056ae0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00056af0: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ +00056b00: 6e69 6365 2069 6620 7468 6973 2077 6173 nice if this was │ │ │ +00056b10: 206e 6f74 6872 6f77 2064 6566 6175 6c74 nothrow default │ │ │ +00056b20: 2063 6f6e 7374 7275 6374 6962 6c65 0a73 constructible.s │ │ │ +00056b30: 7461 7469 635f 6173 7365 7274 2873 7464 tatic_assert(std │ │ │ +00056b40: 3a3a 6973 5f6e 6f74 6872 6f77 5f64 6566 ::is_nothrow_def │ │ │ +00056b50: 6175 6c74 5f63 6f6e 7374 7275 6374 6962 ault_constructib │ │ │ +00056b60: 6c65 3c61 6464 5f74 6f72 7265 6e74 5f70 le::value., │ │ │ +00056b80: 2273 686f 756c 6420 6265 206e 6f74 6872 "should be nothr │ │ │ +00056b90: 6f77 2064 6566 6175 6c74 2063 6f6e 7374 ow default const │ │ │ +00056ba0: 7275 6374 6962 6c65 2229 3b3c 2f68 323e ructible");

    │ │ │ +00056bb0: 3c68 343e 2e2e 2f73 7263 2f61 6464 5f74

    ../src/add_t │ │ │ +00056bc0: 6f72 7265 6e74 5f70 6172 616d 732e 6370 orrent_params.cp │ │ │ +00056bd0: 703a 3331 3c2f 6834 3e3c 7072 6520 7374 p:31

    #include "lib
    │ │ │ +00056c20: 746f 7272 656e 742f 6164 645f 746f 7272  torrent/add_torr
    │ │ │ +00056c30: 656e 745f 7061 7261 6d73 2e68 7070 220a  ent_params.hpp".
    │ │ │ +00056c40: 0a6e 616d 6573 7061 6365 206c 6962 746f  .namespace libto
    │ │ │ +00056c50: 7272 656e 7420 7b0a 0a09 6164 645f 746f  rrent {...add_to
    │ │ │ +00056c60: 7272 656e 745f 7061 7261 6d73 3a3a 6164  rrent_params::ad
    │ │ │ +00056c70: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ +00056c80: 2829 203d 2064 6566 6175 6c74 3b0a 0961  () = default;..a
    │ │ │ +00056c90: 6464 5f74 6f72 7265 6e74 5f70 6172 616d  dd_torrent_param
    │ │ │ +00056ca0: 733a 3a7e 6164 645f 746f 7272 656e 745f  s::~add_torrent_
    │ │ │ +00056cb0: 7061 7261 6d73 2829 203d 2064 6566 6175  params() = defau
    │ │ │ +00056cc0: 6c74 3b0a 0961 6464 5f74 6f72 7265 6e74  lt;..add_torrent
    │ │ │ +00056cd0: 5f70 6172 616d 733a 3a61 6464 5f74 6f72  _params::add_tor
    │ │ │ +00056ce0: 7265 6e74 5f70 6172 616d 7328 6164 645f  rent_params(add_
    │ │ │ +00056cf0: 746f 7272 656e 745f 7061 7261 6d73 2661  torrent_params&a
    │ │ │ +00056d00: 6d70 3b26 616d 703b 2920 6e6f 6578 6365  mp;&) noexce
    │ │ │ +00056d10: 7074 203d 2064 6566 6175 6c74 3b0a 0961  pt = default;..a
    │ │ │ +00056d20: 6464 5f74 6f72 7265 6e74 5f70 6172 616d  dd_torrent_param
    │ │ │ +00056d30: 7326 616d 703b 2061 6464 5f74 6f72 7265  s& add_torre
    │ │ │ +00056d40: 6e74 5f70 6172 616d 733a 3a6f 7065 7261  nt_params::opera
    │ │ │ +00056d50: 746f 723d 2861 6464 5f74 6f72 7265 6e74  tor=(add_torrent
    │ │ │ +00056d60: 5f70 6172 616d 7326 616d 703b 2661 6d70  _params&&
    │ │ │ +00056d70: 3b29 2026 616d 703b 206e 6f65 7863 6570  ;) & noexcep
    │ │ │ +00056d80: 7420 3d20 6465 6661 756c 743b 0a09 6164  t = default;..ad
    │ │ │ +00056d90: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ +00056da0: 3a3a 6164 645f 746f 7272 656e 745f 7061  ::add_torrent_pa
    │ │ │ +00056db0: 7261 6d73 2861 6464 5f74 6f72 7265 6e74  rams(add_torrent
    │ │ │ +00056dc0: 5f70 6172 616d 7320 636f 6e73 7426 616d  _params const&am
    │ │ │ +00056dd0: 703b 2920 3d20 6465 6661 756c 743b 0a09  p;) = default;..
    │ │ │ +00056de0: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ +00056df0: 6d73 2661 6d70 3b20 6164 645f 746f 7272  ms& add_torr
    │ │ │ +00056e00: 656e 745f 7061 7261 6d73 3a3a 6f70 6572  ent_params::oper
    │ │ │ +00056e10: 6174 6f72 3d28 6164 645f 746f 7272 656e  ator=(add_torren
    │ │ │ +00056e20: 745f 7061 7261 6d73 2063 6f6e 7374 2661  t_params const&a
    │ │ │ +00056e30: 6d70 3b29 2026 616d 703b 203d 2064 6566  mp;) & = def
    │ │ │ +00056e40: 6175 6c74 3b0a 0a09 7374 6174 6963 5f61  ault;...static_a
    │ │ │ +00056e50: 7373 6572 7428 7374 643a 3a69 735f 6e6f  ssert(std::is_no
    │ │ │ +00056e60: 7468 726f 775f 6d6f 7665 5f63 6f6e 7374  throw_move_const
    │ │ │ +00056e70: 7275 6374 6962 6c65 266c 743b 6164 645f  ructible<add_
    │ │ │ +00056e80: 746f 7272 656e 745f 7061 7261 6d73 2667  torrent_params&g
    │ │ │ +00056e90: 743b 3a3a 7661 6c75 650a 0909 2c20 2273  t;::value..., "s
    │ │ │ +00056ea0: 686f 756c 6420 6265 206e 6f74 6872 6f77  hould be nothrow
    │ │ │ +00056eb0: 206d 6f76 6520 636f 6e73 7472 7563 7469   move constructi
    │ │ │ +00056ec0: 626c 6522 293b 0a0a 0973 7461 7469 635f  ble");...static_
    │ │ │ +00056ed0: 6173 7365 7274 2873 7464 3a3a 6973 5f6e  assert(std::is_n
    │ │ │ +00056ee0: 6f74 6872 6f77 5f6d 6f76 655f 636f 6e73  othrow_move_cons
    │ │ │ +00056ef0: 7472 7563 7469 626c 6526 6c74 3b73 7464  tructible<std
    │ │ │ +00056f00: 3a3a 7374 7269 6e67 2667 743b 3a3a 7661  ::string>::va
    │ │ │ +00056f10: 6c75 650a 0909 2c20 2273 686f 756c 6420  lue..., "should 
    │ │ │ +00056f20: 6265 206e 6f74 6872 6f77 206d 6f76 6520  be nothrow move 
    │ │ │ +00056f30: 636f 6e73 7472 7563 7469 626c 6522 293b  constructible");
    │ │ │ +00056f40: 0a0a 0973 7461 7469 635f 6173 7365 7274  ...static_assert
    │ │ │ +00056f50: 2873 7464 3a3a 6973 5f6e 6f74 6872 6f77  (std::is_nothrow
    │ │ │ +00056f60: 5f6d 6f76 655f 6173 7369 676e 6162 6c65  _move_assignable
    │ │ │ +00056f70: 266c 743b 6164 645f 746f 7272 656e 745f  <add_torrent_
    │ │ │ +00056f80: 7061 7261 6d73 2667 743b 3a3a 7661 6c75  params>::valu
    │ │ │ +00056f90: 650a 0909 2c20 2273 686f 756c 6420 6265  e..., "should be
    │ │ │ +00056fa0: 206e 6f74 6872 6f77 206d 6f76 6520 6173   nothrow move as
    │ │ │ +00056fb0: 7369 676e 6162 6c65 2229 3b0a 0a3c 6469  signable");...namespace aux 
    │ │ │ +00057000: 7b0a 0a09 2f2f 2072 6574 7572 6e73 2077  {...// returns w
    │ │ │ +00057010: 6865 7468 6572 2074 6869 7320 6164 645f  hether this add_
    │ │ │ +00057020: 746f 7272 656e 745f 7061 7261 6d73 206f  torrent_params o
    │ │ │ +00057030: 626a 6563 7420 6861 7320 2272 6573 756d  bject has "resum
    │ │ │ +00057040: 652d 6461 7461 222c 2069 2e65 2e0a 092f  e-data", i.e.../
    │ │ │ +00057050: 2f20 696e 666f 726d 6174 696f 6e20 6162  / information ab
    │ │ │ +00057060: 6f75 7420 7768 6963 6820 7069 6563 6573  out which pieces
    │ │ │ +00057070: 2077 6520 6861 7665 2e0a 0962 6f6f 6c20   we have...bool 
    │ │ │ +00057080: 636f 6e74 6169 6e73 5f72 6573 756d 655f  contains_resume_
    │ │ │ +00057090: 6461 7461 2861 6464 5f74 6f72 7265 6e74  data(add_torrent
    │ │ │ +000570a0: 5f70 6172 616d 7320 636f 6e73 7426 616d  _params const&am
    │ │ │ +000570b0: 703b 2061 7470 290a 097b 0a09 0972 6574  p; atp)..{...ret
    │ │ │ +000570c0: 7572 6e20 2161 7470 2e68 6176 655f 7069  urn !atp.have_pi
    │ │ │ +000570d0: 6563 6573 2e65 6d70 7479 2829 0a09 0909  eces.empty()....
    │ │ │ +000570e0: 7c7c 2028 6174 702e 666c 6167 7320 2661  || (atp.flags &a
    │ │ │ +000570f0: 6d70 3b20 746f 7272 656e 745f 666c 6167  mp; torrent_flag
    │ │ │ +00057100: 733a 3a73 6565 645f 6d6f 6465 293b 0a09  s::seed_mode);..
    │ │ │ +00057110: 7d0a 7d0a 0a7d 0a3c 2f70 7265 3e3c 2f74  }.}..}.
    relevanc │ │ │ +00057150: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/choker. │ │ │ +00057190: 6370 703a 3233 353c 2f61 3e3c 2f74 643e cpp:235 │ │ │ +000571a0: 3c74 643e 6d61 6b65 2063 6f6e 6669 6775 make configu │ │ │ +000571b0: 7261 626c 653c 2f74 643e 3c2f 7472 3e3c rable< │ │ │ +000571c0: 7472 2069 643d 2232 3035 2220 7374 796c tr id="205" styl │ │ │ +000571d0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +000571e0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +000571f0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00057200: 6832 3e6d 616b 6520 636f 6e66 6967 7572 h2>make configur │ │ │ +00057210: 6162 6c65 3c2f 6832 3e3c 6834 3e2e 2e2f able

    ../ │ │ │ +00057220: 7372 632f 6368 6f6b 6572 2e63 7070 3a32 src/choker.cpp:2 │ │ │ +00057230: 3335 3c2f 6834 3e3c 7072 6520 7374 796c 35

    ...// first res
    │ │ │ +00057280: 6574 2074 6865 206e 756d 6265 7220 6f66  et the number of
    │ │ │ +00057290: 2075 6e63 686f 6b65 2073 6c6f 7473 2c20   unchoke slots, 
    │ │ │ +000572a0: 6265 6361 7573 6520 7765 276c 6c20 6361  because we'll ca
    │ │ │ +000572b0: 6c63 756c 6174 650a 0909 092f 2f20 6974  lculate....// it
    │ │ │ +000572c0: 2070 7572 656c 7920 6261 7365 6420 6f6e   purely based on
    │ │ │ +000572d0: 2074 6865 2063 7572 7265 6e74 2073 7461   the current sta
    │ │ │ +000572e0: 7465 206f 6620 6f75 7220 7065 6572 732e  te of our peers.
    │ │ │ +000572f0: 0a09 0909 7570 6c6f 6164 5f73 6c6f 7473  ....upload_slots
    │ │ │ +00057300: 203d 2030 3b0a 0a09 0909 696e 7420 7261   = 0;.....int ra
    │ │ │ +00057310: 7465 5f74 6872 6573 686f 6c64 203d 2073  te_threshold = s
    │ │ │ +00057320: 6574 742e 6765 745f 696e 7428 7365 7474  ett.get_int(sett
    │ │ │ +00057330: 696e 6773 5f70 6163 6b3a 3a72 6174 655f  ings_pack::rate_
    │ │ │ +00057340: 6368 6f6b 6572 5f69 6e69 7469 616c 5f74  choker_initial_t
    │ │ │ +00057350: 6872 6573 686f 6c64 293b 0a0a 0909 0973  hreshold);.....s
    │ │ │ +00057360: 7464 3a3a 736f 7274 2870 6565 7273 2e62  td::sort(peers.b
    │ │ │ +00057370: 6567 696e 2829 2c20 7065 6572 732e 656e  egin(), peers.en
    │ │ │ +00057380: 6428 290a 0909 0909 2c20 5b5d 2870 6565  d()....., [](pee
    │ │ │ +00057390: 725f 636f 6e6e 6563 7469 6f6e 2063 6f6e  r_connection con
    │ │ │ +000573a0: 7374 2a20 6c68 732c 2070 6565 725f 636f  st* lhs, peer_co
    │ │ │ +000573b0: 6e6e 6563 7469 6f6e 2063 6f6e 7374 2a20  nnection const* 
    │ │ │ +000573c0: 7268 7329 0a09 0909 097b 2072 6574 7572  rhs).....{ retur
    │ │ │ +000573d0: 6e20 7570 6c6f 6164 5f72 6174 655f 636f  n upload_rate_co
    │ │ │ +000573e0: 6d70 6172 6528 6c68 732c 2072 6873 293b  mpare(lhs, rhs);
    │ │ │ +000573f0: 207d 293b 0a0a 0909 0966 6f72 2028 6175   });.....for (au
    │ │ │ +00057400: 746f 2063 6f6e 7374 2a20 7020 3a20 7065  to const* p : pe
    │ │ │ +00057410: 6572 7329 0a09 0909 7b0a 0909 0909 696e  ers)....{.....in
    │ │ │ +00057420: 7420 636f 6e73 7420 7261 7465 203d 2069  t const rate = i
    │ │ │ +00057430: 6e74 2870 2d26 6774 3b75 706c 6f61 6465  nt(p->uploade
    │ │ │ +00057440: 645f 696e 5f6c 6173 745f 726f 756e 6428  d_in_last_round(
    │ │ │ +00057450: 290a 0909 0909 092a 2031 3030 3020 2f20  )......* 1000 / 
    │ │ │ +00057460: 746f 7461 6c5f 6d69 6c6c 6973 6563 6f6e  total_millisecon
    │ │ │ +00057470: 6473 2875 6e63 686f 6b65 5f69 6e74 6572  ds(unchoke_inter
    │ │ │ +00057480: 7661 6c29 293b 0a0a 0909 0909 2f2f 2061  val));......// a
    │ │ │ +00057490: 6c77 6179 7320 6861 7665 2061 7420 6c65  lways have at le
    │ │ │ +000574a0: 6173 7420 3120 756e 6368 6f6b 6520 736c  ast 1 unchoke sl
    │ │ │ +000574b0: 6f74 0a09 0909 0969 6620 2872 6174 6520  ot.....if (rate 
    │ │ │ +000574c0: 266c 743b 2072 6174 655f 7468 7265 7368  < rate_thresh
    │ │ │ +000574d0: 6f6c 6429 2062 7265 616b 3b0a 0a09 0909  old) break;.....
    │ │ │ +000574e0: 092b 2b75 706c 6f61 645f 736c 6f74 733b  .++upload_slots;
    │ │ │ +000574f0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00057520: 0909 0909 7261 7465 5f74 6872 6573 686f ....rate_thresho │ │ │ +00057530: 6c64 202b 3d20 3230 3438 3b0a 3c2f 6469 ld += 2048;....}....++uplo │ │ │ +00057550: 6164 5f73 6c6f 7473 3b0a 0909 7d0a 0a09 ad_slots;...}... │ │ │ +00057560: 092f 2f20 736f 7274 7320 7468 6520 7065 .// sorts the pe │ │ │ +00057570: 6572 7320 7468 6174 2061 7265 2065 6c69 ers that are eli │ │ │ +00057580: 6769 626c 6520 666f 7220 756e 6368 6f6b gible for unchok │ │ │ +00057590: 6520 6279 2064 6f77 6e6c 6f61 6420 7261 e by download ra │ │ │ +000575a0: 7465 2061 6e64 0a09 092f 2f20 7365 636f te and...// seco │ │ │ +000575b0: 6e64 6172 7920 6279 2074 6f74 616c 2075 ndary by total u │ │ │ +000575c0: 706c 6f61 642e 2054 6865 2072 6561 736f pload. The reaso │ │ │ +000575d0: 6e20 666f 7220 7468 6973 2069 732c 2069 n for this is, i │ │ │ +000575e0: 6620 616c 6c20 746f 7272 656e 7473 2061 f all torrents a │ │ │ +000575f0: 7265 0a09 092f 2f20 6265 696e 6720 7365 re...// being se │ │ │ +00057600: 6564 6564 2c20 7468 6520 646f 776e 6c6f eded, the downlo │ │ │ +00057610: 6164 2072 6174 6520 7769 6c6c 2062 6520 ad rate will be │ │ │ +00057620: 302c 2061 6e64 2074 6865 2070 6565 7273 0, and the peers │ │ │ +00057630: 2077 6520 6861 7665 2073 656e 740a 0909 we have sent... │ │ │ +00057640: 2f2f 2074 6865 206c 6561 7374 2074 6f20 // the least to │ │ │ +00057650: 7368 6f75 6c64 2062 6520 756e 6368 6f6b should be unchok │ │ │ +00057660: 6564 0a0a 0909 2f2f 2077 6520 7573 6520 ed....// we use │ │ │ +00057670: 7061 7274 6961 6c20 736f 7274 2068 6572 partial sort her │ │ │ +00057680: 652c 2062 6563 6175 7365 2077 6520 6f6e e, because we on │ │ │ +00057690: 6c79 2063 6172 6520 6162 6f75 7420 7468 ly care about th │ │ │ +000576a0: 6520 746f 700a 0909 2f2f 2075 706c 6f61 e top...// uploa │ │ │ +000576b0: 645f 736c 6f74 7320 7065 6572 732e 0a0a d_slots peers... │ │ │ +000576c0: 0909 696e 7420 636f 6e73 7420 736c 6f74 ..int const slot │ │ │ +000576d0: 7320 3d20 7374 643a 3a6d 696e 2875 706c s = std::min(upl │ │ │ +000576e0: 6f61 645f 736c 6f74 732c 2069 6e74 2870 oad_slots, int(p │ │ │ +000576f0: 6565 7273 2e73 697a 6528 2929 293b 0a0a eers.size()));.. │ │ │ +00057700: 0909 6966 2028 7365 7474 2e67 6574 5f69 ..if (sett.get_i │ │ │ +00057710: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ +00057720: 3a3a 7365 6564 5f63 686f 6b69 6e67 5f61 ::seed_choking_a │ │ │ +00057730: 6c67 6f72 6974 686d 290a 0909 093d 3d20 lgorithm)....== │ │ │ +00057740: 7365 7474 696e 6773 5f70 6163 6b3a 3a72 settings_pack::r │ │ │ +00057750: 6f75 6e64 5f72 6f62 696e 290a 0909 7b0a ound_robin)...{. │ │ │ +00057760: 0909 0969 6e74 2063 6f6e 7374 2070 6965 ...int const pie │ │ │ +00057770: 6365 7320 3d20 7365 7474 2e67 6574 5f69 ces = sett.get_i │ │ │ +00057780: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ +00057790: 3a3a 7365 6564 696e 675f 7069 6563 655f ::seeding_piece_ │ │ │ +000577a0: 7175 6f74 6129 3b0a 0a09 0909 7374 643a quota);.....std: │ │ │ +000577b0: 3a6e 7468 5f65 6c65 6d65 6e74 2870 6565 :nth_element(pee │ │ │ +000577c0: 7273 2e62 6567 696e 2829 2c20 7065 6572 rs.begin(), peer │ │ │ +000577d0: 732e 6265 6769 6e28 290a 0909 0909 2b20 s.begin().....+ │ │ │ +000577e0: 736c 6f74 732c 2070 6565 7273 2e65 6e64 slots, peers.end │ │ │ +000577f0: 2829 0a09 0909 092c 205b 7069 6563 6573 ()....., [pieces │ │ │ +00057800: 5d28 7065 6572 5f63 6f6e 6e65 6374 696f ](peer_connectio │ │ │ +00057810: 6e20 636f 6e73 742a 206c 6873 2c20 7065 n const* lhs, pe │ │ │ +00057820: 6572 5f63 6f6e 6e65 6374 696f 6e20 636f er_connection co │ │ │ +00057830: 6e73 742a 2072 6873 290a 0909 0909 7b20 nst* rhs).....{ │ │ │ +00057840: 7265 7475 726e 2075 6e63 686f 6b65 5f63 return unchoke_c │ │ │ +00057850: 6f6d 7061 7265 5f72 7228 6c68 732c 2072 ompare_rr(lhs, r │ │ │ +00057860: 6873 2c20 7069 6563 6573 293b 207d 293b hs, pieces); }); │ │ │ +00057870: 0a09 097d 0a09 0965 6c73 6520 6966 2028 ...}...else if ( │ │ │ +00057880: 7365 7474 2e67 6574 5f69 6e74 2873 6574 sett.get_int(set │ │ │ +00057890: 7469 6e67 735f 7061 636b 3a3a 7365 6564 tings_pack::seed │ │ │ +000578a0: 5f63 686f 6b69 6e67 5f61 6c67 6f72 6974 _choking_algorit │ │ │ +000578b0: 686d 290a 0909 093d 3d20 7365 7474 696e hm)....== settin │ │ │ +000578c0: 6773 5f70 6163 6b3a 3a66 6173 7465 7374 gs_pack::fastest │ │ │ +000578d0: 5f75 706c 6f61 6429 0a09 097b 0a09 0909 _upload)...{.... │ │ │ +000578e0: 7374 643a 3a6e 7468 5f65 6c65 6d65 6e74 std::nth_element │ │ │ +000578f0: 2870 6565 7273 2e62 6567 696e 2829 2c20 (peers.begin(), │ │ │ +00057900: 7065 6572 732e 6265 6769 6e28 290a 0909 peers.begin()... │ │ │ +00057910: 0909 2b20 736c 6f74 732c 2070 6565 7273 ..+ slots, peers │ │ │ +00057920: 2e65 6e64 2829 0a09 0909 092c 205b 5d28 .end()....., []( │ │ │ +00057930: 7065 6572 5f63 6f6e 6e65 6374 696f 6e20 peer_connection │ │ │ +00057940: 636f 6e73 742a 206c 6873 2c20 7065 6572 const* lhs, peer │ │ │ +00057950: 5f63 6f6e 6e65 6374 696f 6e20 636f 6e73 _connection cons │ │ │ +00057960: 742a 2072 6873 290a 3c2f 7072 653e 3c2f t* rhs).
    relevan │ │ │ +000579a0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/merkle │ │ │ +000579e0: 5f74 7265 652e 6370 703a 3838 3c2f 613e _tree.cpp:88 │ │ │ +000579f0: 3c2f 7464 3e3c 7464 3e69 6e20 432b 2b32 in C++2 │ │ │ +00057a00: 302c 2075 7365 2073 7464 3a3a 6964 656e 0, use std::iden │ │ │ +00057a10: 7469 7479 3c2f 7464 3e3c 2f74 723e 3c74 tityin C++20, use │ │ │ +00057a70: 7374 643a 3a69 6465 6e74 6974 793c 2f68 std::identity

    ../src/mer │ │ │ +00057a90: 6b6c 655f 7472 6565 2e63 7070 3a38 383c kle_tree.cpp:88< │ │ │ +00057aa0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00057ae0: 616c 6c6f 6361 7465 5f66 756c 6c28 293b  allocate_full();
    │ │ │ +00057af0: 0a0a 0909 6d65 726b 6c65 5f76 616c 6964  ....merkle_valid
    │ │ │ +00057b00: 6174 655f 636f 7079 2874 2c20 6d5f 7472  ate_copy(t, m_tr
    │ │ │ +00057b10: 6565 2c20 726f 6f74 2829 2c20 6d5f 626c  ee, root(), m_bl
    │ │ │ +00057b20: 6f63 6b5f 7665 7269 6669 6564 293b 0a0a  ock_verified);..
    │ │ │ +00057b30: 0909 6c6f 6164 5f76 6572 6966 6965 645f  ..load_verified_
    │ │ │ +00057b40: 6269 7473 2876 6572 6966 6965 6429 3b0a  bits(verified);.
    │ │ │ +00057b50: 0a09 096f 7074 696d 697a 655f 7374 6f72  ...optimize_stor
    │ │ │ +00057b60: 6167 6528 293b 0a09 096f 7074 696d 697a  age();...optimiz
    │ │ │ +00057b70: 655f 7374 6f72 6167 655f 7069 6563 655f  e_storage_piece_
    │ │ │ +00057b80: 6c61 7965 7228 293b 0a09 7d0a 0a09 766f  layer();..}...vo
    │ │ │ +00057b90: 6964 206d 6572 6b6c 655f 7472 6565 3a3a  id merkle_tree::
    │ │ │ +00057ba0: 636c 6561 7228 290a 097b 0a09 096d 5f74  clear()..{...m_t
    │ │ │ +00057bb0: 7265 652e 636c 6561 7228 293b 0a09 096d  ree.clear();...m
    │ │ │ +00057bc0: 5f74 7265 652e 7368 7269 6e6b 5f74 6f5f  _tree.shrink_to_
    │ │ │ +00057bd0: 6669 7428 293b 0a09 096d 5f62 6c6f 636b  fit();...m_block
    │ │ │ +00057be0: 5f76 6572 6966 6965 642e 636c 6561 7228  _verified.clear(
    │ │ │ +00057bf0: 293b 0a09 096d 5f6d 6f64 6520 3d20 6d6f  );...m_mode = mo
    │ │ │ +00057c00: 6465 5f74 3a3a 656d 7074 795f 7472 6565  de_t::empty_tree
    │ │ │ +00057c10: 3b0a 097d 0a0a 6e61 6d65 7370 6163 6520  ;..}..namespace 
    │ │ │ +00057c20: 7b0a 0a3c 6469 7620 7374 796c 653d 2262  {..
    .struct identit │ │ │ +00057c60: 790a 3c2f 6469 763e 097b 0a09 0962 6f6f y.
    .{...boo │ │ │ +00057c70: 6c20 6f70 6572 6174 6f72 2829 2862 6f6f l operator()(boo │ │ │ +00057c80: 6c20 6229 2063 6f6e 7374 207b 2072 6574 l b) const { ret │ │ │ +00057c90: 7572 6e20 623b 207d 0a09 7d3b 0a7d 0a0a urn b; }..};.}.. │ │ │ +00057ca0: 0976 6f69 6420 6d65 726b 6c65 5f74 7265 .void merkle_tre │ │ │ +00057cb0: 653a 3a6c 6f61 645f 7370 6172 7365 5f74 e::load_sparse_t │ │ │ +00057cc0: 7265 6528 7370 616e 266c 743b 7368 6132 ree(span<sha2 │ │ │ +00057cd0: 3536 5f68 6173 6820 636f 6e73 7426 6774 56_hash const> │ │ │ +00057ce0: 3b20 740a 0909 2c20 6269 7466 6965 6c64 ; t..., bitfield │ │ │ +00057cf0: 2063 6f6e 7374 2661 6d70 3b20 6d61 736b const& mask │ │ │ +00057d00: 0a09 092c 2062 6974 6669 656c 6420 636f ..., bitfield co │ │ │ +00057d10: 6e73 7426 616d 703b 2076 6572 6966 6965 nst& verifie │ │ │ +00057d20: 6429 0a09 7b0a 0909 494e 5641 5249 414e d)..{...INVARIAN │ │ │ +00057d30: 545f 4348 4543 4b3b 0a0a 0909 2f2f 2054 T_CHECK;....// T │ │ │ +00057d40: 6865 2073 697a 6520 6f66 2074 6865 206d he size of the m │ │ │ +00057d50: 6173 6b20 7368 6f75 6c64 206e 6f74 2065 ask should not e │ │ │ +00057d60: 7863 6565 6420 7468 6520 7369 7a65 206f xceed the size o │ │ │ +00057d70: 6620 7468 6520 7472 6565 2c20 6275 7420 f the tree, but │ │ │ +00057d80: 6120 6d61 736b 206c 6172 6765 7220 7468 a mask larger th │ │ │ +00057d90: 616e 0a09 092f 2f20 7468 6520 7472 6565 an...// the tree │ │ │ +00057da0: 2063 616e 2062 6520 656e 636f 756e 7465 can be encounte │ │ │ +00057db0: 7265 6420 696e 2074 6865 2022 7265 7375 red in the "resu │ │ │ +00057dc0: 6d65 2064 6174 6122 2066 6f72 2073 6f6d me data" for som │ │ │ +00057dd0: 6520 7265 6173 6f6e 2c20 7065 7268 6170 e reason, perhap │ │ │ +00057de0: 7320 7468 6572 6520 6973 0a09 092f 2f20 s there is...// │ │ │ +00057df0: 6120 6275 6720 696e 2074 6865 2022 7265 a bug in the "re │ │ │ +00057e00: 7375 6d65 2064 6174 6122 2067 656e 6572 sume data" gener │ │ │ +00057e10: 6174 696f 6e20 616c 676f 7269 7468 6d2e ation algorithm. │ │ │ +00057e20: 0a09 092f 2f20 536f 2077 6520 6a75 7374 ...// So we just │ │ │ +00057e30: 2070 726f 6365 7373 206d 6173 6b20 6974 process mask it │ │ │ +00057e40: 656d 7320 636f 756e 7420 7570 2074 6f20 ems count up to │ │ │ +00057e50: 7472 6565 2073 697a 652e 0a09 0969 6e74 tree size....int │ │ │ +00057e60: 2063 6f6e 7374 206d 6173 6b5f 7369 7a65 const mask_size │ │ │ +00057e70: 203d 2073 7464 3a3a 6d69 6e28 6d61 736b = std::min(mask │ │ │ +00057e80: 2e73 697a 6528 292c 2069 6e74 2873 697a .size(), int(siz │ │ │ +00057e90: 6528 2929 293b 0a0a 0909 696e 7420 636f e()));....int co │ │ │ +00057ea0: 6e73 7420 6669 7273 745f 626c 6f63 6b20 nst first_block │ │ │ +00057eb0: 3d20 626c 6f63 6b5f 6c61 7965 725f 7374 = block_layer_st │ │ │ +00057ec0: 6172 7428 293b 0a09 0969 6e74 2063 6f6e art();...int con │ │ │ +00057ed0: 7374 2065 6e64 5f62 6c6f 636b 203d 2066 st end_block = f │ │ │ +00057ee0: 6972 7374 5f62 6c6f 636b 202b 206d 5f6e irst_block + m_n │ │ │ +00057ef0: 756d 5f62 6c6f 636b 733b 0a0a 0909 544f um_blocks;....TO │ │ │ +00057f00: 5252 454e 545f 4153 5345 5254 2866 6972 RRENT_ASSERT(fir │ │ │ +00057f10: 7374 5f62 6c6f 636b 2026 6c74 3b20 696e st_block < in │ │ │ +00057f20: 7428 7369 7a65 2829 2929 3b0a 0909 544f t(size()));...TO │ │ │ +00057f30: 5252 454e 545f 4153 5345 5254 2865 6e64 RRENT_ASSERT(end │ │ │ +00057f40: 5f62 6c6f 636b 2026 6c74 3b3d 2069 6e74 _block <= int │ │ │ +00057f50: 2873 697a 6528 2929 293b 0a0a 0909 2f2f (size()));....// │ │ │ +00057f60: 2069 6620 7468 6520 6d61 736b 2063 6f76 if the mask cov │ │ │ +00057f70: 6572 7320 616c 6c20 626c 6f63 6b73 2c20 ers all blocks, │ │ │ +00057f80: 676f 2073 7472 6169 6768 7420 746f 2062 go straight to b │ │ │ +00057f90: 6c6f 636b 5f6c 6179 6572 0a09 092f 2f20 lock_layer...// │ │ │ +00057fa0: 6d6f 6465 2c20 616e 6420 7661 6c69 6461 mode, and valida │ │ │ +00057fb0: 7465 0a09 0969 6620 2828 6669 7273 745f te...if ((first_ │ │ │ +00057fc0: 626c 6f63 6b20 266c 743b 206d 6173 6b5f block < mask_ │ │ │ +00057fd0: 7369 7a65 2920 2661 6d70 3b26 616d 703b size) && │ │ │ +00057fe0: 2028 656e 645f 626c 6f63 6b20 266c 743b (end_block < │ │ │ +00057ff0: 3d20 6d61 736b 5f73 697a 6529 0a09 0909 = mask_size).... │ │ │ +00058000: 2661 6d70 3b26 616d 703b 2073 7464 3a3a && std:: │ │ │ +00058010: 616c 6c5f 6f66 286d 6173 6b2e 6265 6769 all_of(mask.begi │ │ │ +00058020: 6e28 2920 2b20 6669 7273 745f 626c 6f63 n() + first_bloc │ │ │ +00058030: 6b2c 206d 6173 6b2e 6265 6769 6e28 2920 k, mask.begin() │ │ │ +00058040: 2b20 656e 645f 626c 6f63 6b2c 2069 6465 + end_block, ide │ │ │ +00058050: 6e74 6974 7928 2929 290a 0909 7b0a 0909 ntity()))...{... │ │ │ +00058060: 092f 2f20 7468 6520 696e 6465 7820 696e .// the index in │ │ │ +00058070: 2074 2074 6861 7420 706f 696e 7473 2074 t that points t │ │ │ +00058080: 6f20 6669 7273 745f 626c 6f63 6b0a 0909 o first_block... │ │ │ +00058090: 0961 7574 6f20 636f 6e73 7420 626c 6f63 .auto const bloc │ │ │ +000580a0: 6b5f 696e 6465 7820 3d20 7374 643a 3a63 k_index = std::c │ │ │ +000580b0: 6f75 6e74 5f69 6628 6d61 736b 2e62 6567 ount_if(mask.beg │ │ │ +000580c0: 696e 2829 2c20 6d61 736b 2e62 6567 696e in(), mask.begin │ │ │ +000580d0: 2829 202b 2066 6972 7374 5f62 6c6f 636b () + first_block │ │ │ +000580e0: 2c20 6964 656e 7469 7479 2829 293b 0a3c , identity());.< │ │ │ +000580f0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00058100: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00058110: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00058120: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00058130: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +00058160: 2f6d 6572 6b6c 655f 7472 6565 2e63 7070 /merkle_tree.cpp │ │ │ +00058170: 3a33 3037 3c2f 613e 3c2f 7464 3e3c 7464 :307this can be opt │ │ │ +00058190: 696d 697a 6564 2062 7920 7573 696e 6720 imized by using │ │ │ +000581a0: 6d5f 7472 6565 2061 7320 7374 6f72 6167 m_tree as storag │ │ │ +000581b0: 6520 746f 2066 696c 6c20 7468 6973 2074 e to fill this t │ │ │ +000581c0: 7265 6520 696e 746f 2c20 616e 6420 7468 ree into, and th │ │ │ +000581d0: 656e 2063 6c65 6172 2069 7420 6966 2074 en clear it if t │ │ │ +000581e0: 6865 2068 6173 6865 7320 6661 696c 3c2f he hashes fail

    this │ │ │ +00058240: 2063 616e 2062 6520 6f70 7469 6d69 7a65 can be optimize │ │ │ +00058250: 6420 6279 2075 7369 6e67 206d 5f74 7265 d by using m_tre │ │ │ +00058260: 6520 6173 2073 746f 7261 6765 2074 6f20 e as storage to │ │ │ +00058270: 6669 6c6c 2074 6869 730a 7472 6565 2069 fill this.tree i │ │ │ +00058280: 6e74 6f2c 2061 6e64 2074 6865 6e20 636c nto, and then cl │ │ │ +00058290: 6561 7220 6974 2069 6620 7468 6520 6861 ear it if the ha │ │ │ +000582a0: 7368 6573 2066 6169 6c3c 2f68 323e 3c68 shes fail

    ../src/merkle_ │ │ │ +000582c0: 7472 6565 2e63 7070 3a33 3037 3c2f 6834 tree.cpp:307

    .{...
    │ │ │ +00058310: 494e 5641 5249 414e 545f 4348 4543 4b3b  INVARIANT_CHECK;
    │ │ │ +00058320: 0a0a 0909 2f2f 2061 7320 7765 2073 6574  ....// as we set
    │ │ │ +00058330: 2074 6865 2068 6173 6865 7320 6f66 2069   the hashes of i
    │ │ │ +00058340: 6e74 6572 696f 7220 6e6f 6465 732c 2077  nterior nodes, w
    │ │ │ +00058350: 6520 6d61 7920 6265 2061 626c 6520 746f  e may be able to
    │ │ │ +00058360: 2076 616c 6964 6174 650a 0909 2f2f 2062   validate...// b
    │ │ │ +00058370: 6c6f 636b 2068 6173 6865 7320 7468 6174  lock hashes that
    │ │ │ +00058380: 2077 6520 6861 6420 7369 6e63 6520 6561   we had since ea
    │ │ │ +00058390: 726c 6965 722e 2041 6e79 2062 6c6f 636b  rlier. Any block
    │ │ │ +000583a0: 7320 7468 6174 2063 616e 2062 650a 0909  s that can be...
    │ │ │ +000583b0: 2f2f 2076 616c 6964 6174 6564 2c20 616e  // validated, an
    │ │ │ +000583c0: 6420 6661 696c 6564 2c20 6172 6520 6164  d failed, are ad
    │ │ │ +000583d0: 6465 6420 746f 2074 6869 7320 6c69 7374  ded to this list
    │ │ │ +000583e0: 0a09 0961 6464 5f68 6173 6865 735f 7265  ...add_hashes_re
    │ │ │ +000583f0: 7375 6c74 5f74 2072 6574 3b0a 0a09 092f  sult_t ret;..../
    │ │ │ +00058400: 2f20 7765 2061 6c72 6561 6479 2068 6176  / we already hav
    │ │ │ +00058410: 6520 616c 6c20 6861 7368 6573 0a09 0969  e all hashes...i
    │ │ │ +00058420: 6620 286d 5f6d 6f64 6520 3d3d 206d 6f64  f (m_mode == mod
    │ │ │ +00058430: 655f 743a 3a62 6c6f 636b 5f6c 6179 6572  e_t::block_layer
    │ │ │ +00058440: 290a 0909 7b0a 0909 092f 2f20 7369 6e63  )...{....// sinc
    │ │ │ +00058450: 6520 7765 2772 6520 616c 7265 6164 7920  e we're already 
    │ │ │ +00058460: 6f6e 2074 6865 2062 6c6f 636b 206c 6179  on the block lay
    │ │ │ +00058470: 6572 206d 6f64 652c 2077 6520 6861 7665  er mode, we have
    │ │ │ +00058480: 2074 6865 2077 686f 6c65 0a09 0909 2f2f   the whole....//
    │ │ │ +00058490: 2074 7265 652c 2061 6e64 2077 6527 7665   tree, and we've
    │ │ │ +000584a0: 2061 6c72 6561 6479 2072 6570 6f72 7465   already reporte
    │ │ │ +000584b0: 6420 616e 7920 7069 6563 6573 2061 7320  d any pieces as 
    │ │ │ +000584c0: 7061 7373 696e 6720 7468 6174 206d 6179  passing that may
    │ │ │ +000584d0: 0a09 0909 2f2f 2068 6176 6520 6578 6973  ....// have exis
    │ │ │ +000584e0: 7465 6420 696e 2074 6865 2074 7265 6520  ted in the tree 
    │ │ │ +000584f0: 7768 656e 2077 6520 636f 6d70 6c65 7465  when we complete
    │ │ │ +00058500: 6420 6974 2e20 4174 2074 6869 7320 706f  d it. At this po
    │ │ │ +00058510: 696e 7420 6e6f 0a09 0909 2f2f 206d 6f72  int no....// mor
    │ │ │ +00058520: 6520 7069 6563 6573 2073 686f 756c 6420  e pieces should 
    │ │ │ +00058530: 6265 2072 6570 6f72 7465 6420 6173 2070  be reported as p
    │ │ │ +00058540: 6173 7365 640a 0909 0972 6574 7572 6e20  assed....return 
    │ │ │ +00058550: 7265 743b 0a09 097d 0a0a 0909 616c 6c6f  ret;...}....allo
    │ │ │ +00058560: 6361 7465 5f66 756c 6c28 293b 0a0a 3c64  cate_full();....in
    │ │ │ +000585a0: 7420 636f 6e73 7420 6c65 6166 5f63 6f75  t const leaf_cou
    │ │ │ +000585b0: 6e74 203d 206d 6572 6b6c 655f 6e75 6d5f  nt = merkle_num_
    │ │ │ +000585c0: 6c65 6166 7328 696e 7428 6861 7368 6573  leafs(int(hashes
    │ │ │ +000585d0: 2e73 697a 6528 2929 293b 0a3c 2f64 6976  .size()));.
    ..aux::vector&l │ │ │ +000585f0: 743b 7368 6132 3536 5f68 6173 6826 6774 t;sha256_hash> │ │ │ +00058600: 3b20 7472 6565 286d 6572 6b6c 655f 6e75 ; tree(merkle_nu │ │ │ +00058610: 6d5f 6e6f 6465 7328 6c65 6166 5f63 6f75 m_nodes(leaf_cou │ │ │ +00058620: 6e74 2929 3b0a 0909 7374 643a 3a63 6f70 nt));...std::cop │ │ │ +00058630: 7928 6861 7368 6573 2e62 6567 696e 2829 y(hashes.begin() │ │ │ +00058640: 2c20 6861 7368 6573 2e65 6e64 2829 2c20 , hashes.end(), │ │ │ +00058650: 7472 6565 2e65 6e64 2829 202d 206c 6561 tree.end() - lea │ │ │ +00058660: 665f 636f 756e 7429 3b0a 0a09 092f 2f20 f_count);....// │ │ │ +00058670: 7468 6520 656e 6420 6f66 2061 2066 696c the end of a fil │ │ │ +00058680: 6520 6973 2061 2073 7065 6369 616c 2063 e is a special c │ │ │ +00058690: 6173 652c 2077 6520 6d61 7920 6e65 6564 ase, we may need │ │ │ +000586a0: 2074 6f20 7061 6420 7468 6520 6c65 6166 to pad the leaf │ │ │ +000586b0: 206c 6179 6572 0a09 0969 6620 286c 6561 layer...if (lea │ │ │ +000586c0: 665f 636f 756e 7420 2667 743b 2068 6173 f_count > has │ │ │ +000586d0: 6865 732e 7369 7a65 2829 290a 0909 7b0a hes.size())...{. │ │ │ +000586e0: 0909 0969 6e74 2063 6f6e 7374 206c 6561 ...int const lea │ │ │ +000586f0: 665f 6c61 7965 725f 7369 7a65 203d 206e f_layer_size = n │ │ │ +00058700: 756d 5f6c 6561 6673 2829 3b0a 0909 092f um_leafs();..../ │ │ │ +00058710: 2f20 6173 7375 6d69 6e67 2075 6e63 6c65 / assuming uncle │ │ │ +00058720: 5f68 6173 6865 7320 6c65 6164 2061 6c6c _hashes lead all │ │ │ +00058730: 2074 6865 2077 6179 2074 6f20 7468 6520 the way to the │ │ │ +00058740: 726f 6f74 2c20 7468 6579 2074 656c 6c20 root, they tell │ │ │ +00058750: 7573 0a09 0909 2f2f 2068 6f77 206d 616e us....// how man │ │ │ +00058760: 7920 6c61 7965 7273 2064 6f77 6e20 7765 y layers down we │ │ │ +00058770: 2061 7265 0a09 0909 696e 7420 636f 6e73 are....int cons │ │ │ +00058780: 7420 696e 7365 7274 5f6c 6179 6572 5f73 t insert_layer_s │ │ │ +00058790: 697a 6520 3d20 6c65 6166 5f63 6f75 6e74 ize = leaf_count │ │ │ +000587a0: 2026 6c74 3b26 6c74 3b20 756e 636c 655f << uncle_ │ │ │ +000587b0: 6861 7368 6573 2e73 697a 6528 293b 0a09 hashes.size();.. │ │ │ +000587c0: 0909 6966 2028 6c65 6166 5f6c 6179 6572 ..if (leaf_layer │ │ │ +000587d0: 5f73 697a 6520 213d 2069 6e73 6572 745f _size != insert_ │ │ │ +000587e0: 6c61 7965 725f 7369 7a65 290a 0909 097b layer_size)....{ │ │ │ +000587f0: 0a09 0909 0973 6861 3235 365f 6861 7368 .....sha256_hash │ │ │ +00058800: 2063 6f6e 7374 2070 6164 5f68 6173 6820 const pad_hash │ │ │ +00058810: 3d20 6d65 726b 6c65 5f70 6164 286c 6561 = merkle_pad(lea │ │ │ +00058820: 665f 6c61 7965 725f 7369 7a65 2c20 696e f_layer_size, in │ │ │ +00058830: 7365 7274 5f6c 6179 6572 5f73 697a 6529 sert_layer_size) │ │ │ +00058840: 3b0a 0909 0909 666f 7220 2869 6e74 2069 ;.....for (int i │ │ │ +00058850: 203d 2069 6e74 2868 6173 6865 732e 7369 = int(hashes.si │ │ │ +00058860: 7a65 2829 293b 2069 2026 6c74 3b20 6c65 ze()); i < le │ │ │ +00058870: 6166 5f63 6f75 6e74 3b20 2b2b 6929 0a09 af_count; ++i).. │ │ │ +00058880: 0909 0909 7472 6565 5b74 7265 652e 656e ....tree[tree.en │ │ │ +00058890: 645f 696e 6465 7828 2920 2d20 6c65 6166 d_index() - leaf │ │ │ +000588a0: 5f63 6f75 6e74 202b 2069 5d20 3d20 7061 _count + i] = pa │ │ │ +000588b0: 645f 6861 7368 3b0a 0909 097d 0a09 097d d_hash;....}...} │ │ │ +000588c0: 0a0a 0909 6d65 726b 6c65 5f66 696c 6c5f ....merkle_fill_ │ │ │ +000588d0: 7472 6565 2874 7265 652c 206c 6561 665f tree(tree, leaf_ │ │ │ +000588e0: 636f 756e 7429 3b0a 0a09 0969 6e74 2063 count);....int c │ │ │ +000588f0: 6f6e 7374 2062 6173 655f 6e75 6d5f 6c61 onst base_num_la │ │ │ +00058900: 7965 7273 203d 206d 6572 6b6c 655f 6e75 yers = merkle_nu │ │ │ +00058910: 6d5f 6c61 7965 7273 286c 6561 665f 636f m_layers(leaf_co │ │ │ +00058920: 756e 7429 3b0a 0a09 092f 2f20 7468 6973 unt);....// this │ │ │ +00058930: 2069 7320 7468 6520 696e 6465 7820 6f66 is the index of │ │ │ +00058940: 2074 6865 206e 6f64 6520 7768 6572 6520 the node where │ │ │ +00058950: 7765 276c 6c20 696e 7365 7274 2074 6865 we'll insert the │ │ │ +00058960: 2072 6f6f 7420 6f66 2074 6865 0a09 092f root of the.../ │ │ │ +00058970: 2f20 7375 6274 7265 6520 2874 7265 6529 / subtree (tree) │ │ │ +00058980: 2e20 4974 2773 2061 6c73 6f20 7468 6520 . It's also the │ │ │ +00058990: 6861 7368 2074 6865 2075 6e63 6c65 5f68 hash the uncle_h │ │ │ +000589a0: 6173 6865 7320 6172 6520 6865 7265 2074 ashes are here t │ │ │ +000589b0: 6f20 7072 6f76 650a 0909 2f2f 2069 7320 o prove...// is │ │ │ +000589c0: 7661 6c69 642e 0a09 0969 6e74 2063 6f6e valid....int con │ │ │ +000589d0: 7374 2069 6e73 6572 745f 726f 6f74 5f69 st insert_root_i │ │ │ +000589e0: 6478 203d 2064 6573 745f 7374 6172 745f dx = dest_start_ │ │ │ +000589f0: 6964 7820 2667 743b 2667 743b 2062 6173 idx >> bas │ │ │ +00058a00: 655f 6e75 6d5f 6c61 7965 7273 3b0a 0a09 e_num_layers;... │ │ │ +00058a10: 092f 2f20 7374 6172 7420 7769 7468 2076 .// start with v │ │ │ +00058a20: 616c 6964 6174 696e 6720 7468 6520 7072 alidating the pr │ │ │ +00058a30: 6f6f 6673 2c20 616e 6420 696e 7365 7274 oofs, and insert │ │ │ +00058a40: 696e 6720 7468 656d 2061 7320 7765 2067 ing them as we g │ │ │ +00058a50: 6f2e 0a09 0969 6620 2821 6d65 726b 6c65 o....if (!merkle │ │ │ +00058a60: 5f76 616c 6964 6174 655f 616e 645f 696e _validate_and_in │ │ │ +00058a70: 7365 7274 5f70 726f 6f66 7328 6d5f 7472 sert_proofs(m_tr │ │ │ +00058a80: 6565 2c20 696e 7365 7274 5f72 6f6f 745f ee, insert_root_ │ │ │ +00058a90: 6964 782c 2074 7265 655b 305d 2c20 756e idx, tree[0], un │ │ │ +00058aa0: 636c 655f 6861 7368 6573 2929 0a09 0909 cle_hashes)).... │ │ │ +00058ab0: 7265 7475 726e 207b 7d3b 0a3c 2f70 7265 return {};.rele │ │ │ +00058af0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/mer │ │ │ +00058b30: 6b6c 655f 7472 6565 2e63 7070 3a33 3535 kle_tree.cpp:355 │ │ │ +00058b40: 3c2f 613e 3c2f 7464 3e3c 7464 3e61 2070 a p │ │ │ +00058b50: 6965 6365 206f 7574 7369 6465 206f 6620 iece outside of │ │ │ +00058b60: 7468 6973 2072 616e 6765 206d 6179 2061 this range may a │ │ │ +00058b70: 6c73 6f20 6661 696c 2c20 6966 206f 6e65 lso fail, if one │ │ │ +00058b80: 206f 6620 7468 6520 756e 636c 6520 6861 of the uncle ha │ │ │ +00058b90: 7368 6573 2069 7320 6174 2074 6865 206c shes is at the l │ │ │ +00058ba0: 6179 6572 2072 6967 6874 2061 626f 7665 ayer right above │ │ │ +00058bb0: 2074 6865 2062 6c6f 636b 2068 6173 6865 the block hashe │ │ │ +00058bc0: 733c 2f74 643e 3c2f 7472 3e3c 7472 2069 s

    a │ │ │ +00058c10: 2070 6965 6365 206f 7574 7369 6465 206f piece outside o │ │ │ +00058c20: 6620 7468 6973 2072 616e 6765 206d 6179 f this range may │ │ │ +00058c30: 2061 6c73 6f20 6661 696c 2c20 6966 206f also fail, if o │ │ │ +00058c40: 6e65 206f 6620 7468 6520 756e 636c 650a ne of the uncle. │ │ │ +00058c50: 6861 7368 6573 2069 7320 6174 2074 6865 hashes is at the │ │ │ +00058c60: 206c 6179 6572 2072 6967 6874 2061 626f layer right abo │ │ │ +00058c70: 7665 2074 6865 2062 6c6f 636b 2068 6173 ve the block has │ │ │ +00058c80: 6865 733c 2f68 323e 3c68 343e 2e2e 2f73 hes

    ../s │ │ │ +00058c90: 7263 2f6d 6572 6b6c 655f 7472 6565 2e63 rc/merkle_tree.c │ │ │ +00058ca0: 7070 3a33 3535 3c2f 6834 3e3c 7072 6520 pp:355

    ..int const
    │ │ │ +00058cf0: 2069 6e73 6572 745f 726f 6f74 5f69 6478   insert_root_idx
    │ │ │ +00058d00: 203d 2064 6573 745f 7374 6172 745f 6964   = dest_start_id
    │ │ │ +00058d10: 7820 2667 743b 2667 743b 2062 6173 655f  x >> base_
    │ │ │ +00058d20: 6e75 6d5f 6c61 7965 7273 3b0a 0a09 092f  num_layers;..../
    │ │ │ +00058d30: 2f20 7374 6172 7420 7769 7468 2076 616c  / start with val
    │ │ │ +00058d40: 6964 6174 696e 6720 7468 6520 7072 6f6f  idating the proo
    │ │ │ +00058d50: 6673 2c20 616e 6420 696e 7365 7274 696e  fs, and insertin
    │ │ │ +00058d60: 6720 7468 656d 2061 7320 7765 2067 6f2e  g them as we go.
    │ │ │ +00058d70: 0a09 0969 6620 2821 6d65 726b 6c65 5f76  ...if (!merkle_v
    │ │ │ +00058d80: 616c 6964 6174 655f 616e 645f 696e 7365  alidate_and_inse
    │ │ │ +00058d90: 7274 5f70 726f 6f66 7328 6d5f 7472 6565  rt_proofs(m_tree
    │ │ │ +00058da0: 2c20 696e 7365 7274 5f72 6f6f 745f 6964  , insert_root_id
    │ │ │ +00058db0: 782c 2074 7265 655b 305d 2c20 756e 636c  x, tree[0], uncl
    │ │ │ +00058dc0: 655f 6861 7368 6573 2929 0a09 0909 7265  e_hashes))....re
    │ │ │ +00058dd0: 7475 726e 207b 7d3b 0a0a 0909 2f2f 2066  turn {};....// f
    │ │ │ +00058de0: 6972 7374 2066 696c 6c20 696e 2074 6865  irst fill in the
    │ │ │ +00058df0: 2073 7562 7472 6565 206f 6620 6b6e 6f77   subtree of know
    │ │ │ +00058e00: 6e20 6861 7368 6573 2066 726f 6d20 7468  n hashes from th
    │ │ │ +00058e10: 6520 6261 7365 206c 6179 6572 0a09 0961  e base layer...a
    │ │ │ +00058e20: 7574 6f20 636f 6e73 7420 6e75 6d5f 6c65  uto const num_le
    │ │ │ +00058e30: 6166 7320 3d20 6d65 726b 6c65 5f6e 756d  afs = merkle_num
    │ │ │ +00058e40: 5f6c 6561 6673 286d 5f6e 756d 5f62 6c6f  _leafs(m_num_blo
    │ │ │ +00058e50: 636b 7329 3b0a 0909 6175 746f 2063 6f6e  cks);...auto con
    │ │ │ +00058e60: 7374 2066 6972 7374 5f6c 6561 6620 3d20  st first_leaf = 
    │ │ │ +00058e70: 6d65 726b 6c65 5f66 6972 7374 5f6c 6561  merkle_first_lea
    │ │ │ +00058e80: 6628 6e75 6d5f 6c65 6166 7329 3b0a 0a09  f(num_leafs);...
    │ │ │ +00058e90: 092f 2f20 7468 6973 2069 7320 7468 6520  .// this is the 
    │ │ │ +00058ea0: 7374 6172 7420 6f66 2074 6865 206c 6561  start of the lea
    │ │ │ +00058eb0: 6620 6c61 7965 7220 6f66 2022 7472 6565  f layer of "tree
    │ │ │ +00058ec0: 222e 2057 6527 6c6c 2075 7365 2074 6869  ". We'll use thi
    │ │ │ +00058ed0: 730a 0909 2f2f 2076 6172 6961 626c 6520  s...// variable 
    │ │ │ +00058ee0: 746f 2073 7465 7020 7570 7761 7264 7320  to step upwards 
    │ │ │ +00058ef0: 746f 7761 7264 7320 7468 6520 726f 6f74  towards the root
    │ │ │ +00058f00: 0a09 0969 6e74 2073 6f75 7263 655f 6375  ...int source_cu
    │ │ │ +00058f10: 7273 6f72 203d 2069 6e74 2874 7265 652e  rsor = int(tree.
    │ │ │ +00058f20: 7369 7a65 2829 2920 2d20 6c65 6166 5f63  size()) - leaf_c
    │ │ │ +00058f30: 6f75 6e74 3b0a 0909 2f2f 2074 6865 2072  ount;...// the r
    │ │ │ +00058f40: 756e 6e69 6e67 2069 6e64 6578 2069 6e20  unning index in 
    │ │ │ +00058f50: 7468 6520 6c6f 6f70 0a09 0969 6e74 2064  the loop...int d
    │ │ │ +00058f60: 6573 745f 6375 7273 6f72 203d 2064 6573  est_cursor = des
    │ │ │ +00058f70: 745f 7374 6172 745f 6964 783b 0a0a 0909  t_start_idx;....
    │ │ │ +00058f80: 2f2f 2074 6865 206e 756d 6265 7220 6f66  // the number of
    │ │ │ +00058f90: 2074 7265 6520 6c65 7665 6c73 2069 6e20   tree levels in 
    │ │ │ +00058fa0: 6120 7069 6563 6520 6861 7368 2e20 3020  a piece hash. 0 
    │ │ │ +00058fb0: 6d65 616e 7320 7468 6520 626c 6f63 6b20  means the block 
    │ │ │ +00058fc0: 6c61 7965 7220 6973 0a09 092f 2f20 7468  layer is...// th
    │ │ │ +00058fd0: 6520 7361 6d65 2061 7320 7468 6520 7069  e same as the pi
    │ │ │ +00058fe0: 6563 6520 6c61 7965 720a 0909 696e 7420  ece layer...int 
    │ │ │ +00058ff0: 636f 6e73 7420 6261 7365 203d 2070 6965  const base = pie
    │ │ │ +00059000: 6365 5f6c 6576 656c 7328 293b 0a0a 3c64  ce_levels();....fo
    │ │ │ +00059040: 7220 2869 6e74 206c 6179 6572 5f73 697a  r (int layer_siz
    │ │ │ +00059050: 6520 3d20 6c65 6166 5f63 6f75 6e74 3b20  e = leaf_count; 
    │ │ │ +00059060: 6c61 7965 725f 7369 7a65 2021 3d20 303b  layer_size != 0;
    │ │ │ +00059070: 206c 6179 6572 5f73 697a 6520 2f3d 2032   layer_size /= 2
    │ │ │ +00059080: 290a 3c2f 6469 763e 0909 7b0a 0909 0966  )...{....f
    │ │ │ +00059090: 6f72 2028 696e 7420 6920 3d20 303b 2069  or (int i = 0; i
    │ │ │ +000590a0: 2026 6c74 3b20 6c61 7965 725f 7369 7a65   < layer_size
    │ │ │ +000590b0: 3b20 2b2b 6929 0a09 0909 7b0a 0909 0909  ; ++i)....{.....
    │ │ │ +000590c0: 696e 7420 636f 6e73 7420 6473 745f 6964  int const dst_id
    │ │ │ +000590d0: 7820 3d20 6465 7374 5f63 7572 736f 7220  x = dest_cursor 
    │ │ │ +000590e0: 2b20 693b 0a09 0909 0969 6e74 2063 6f6e  + i;.....int con
    │ │ │ +000590f0: 7374 2073 7263 5f69 6478 203d 2073 6f75  st src_idx = sou
    │ │ │ +00059100: 7263 655f 6375 7273 6f72 202b 2069 3b0a  rce_cursor + i;.
    │ │ │ +00059110: 0909 0909 6966 2028 6861 735f 6e6f 6465  ....if (has_node
    │ │ │ +00059120: 2864 7374 5f69 6478 2929 0a09 0909 097b  (dst_idx)).....{
    │ │ │ +00059130: 0a09 0909 0909 6966 2028 6d5f 7472 6565  ......if (m_tree
    │ │ │ +00059140: 5b64 7374 5f69 6478 5d20 213d 2074 7265  [dst_idx] != tre
    │ │ │ +00059150: 655b 7372 635f 6964 785d 290a 0909 0909  e[src_idx]).....
    │ │ │ +00059160: 097b 0a09 0909 0909 092f 2f20 7468 6973  .{.......// this
    │ │ │ +00059170: 206d 7573 7420 6265 2061 2062 6c6f 636b   must be a block
    │ │ │ +00059180: 2068 6173 6820 6265 6361 7573 6520 696e   hash because in
    │ │ │ +00059190: 6e65 7220 6e6f 6465 7320 6172 6520 6e6f  ner nodes are no
    │ │ │ +000591a0: 7420 6669 6c6c 6564 2069 6e20 756e 7469  t filled in unti
    │ │ │ +000591b0: 6c0a 0909 0909 0909 2f2f 2074 6865 7920  l.......// they 
    │ │ │ +000591c0: 6361 6e20 6265 2076 6572 6966 6965 642e  can be verified.
    │ │ │ +000591d0: 2054 6869 7320 6173 7365 7274 2065 6e73   This assert ens
    │ │ │ +000591e0: 7572 6573 2077 6527 7265 2061 7420 7468  ures we're at th
    │ │ │ +000591f0: 650a 0909 0909 0909 2f2f 206c 6561 6620  e.......// leaf 
    │ │ │ +00059200: 6c61 7965 7220 6f66 2074 6865 2066 696c  layer of the fil
    │ │ │ +00059210: 6520 7472 6565 0a09 0909 0909 0954 4f52  e tree.......TOR
    │ │ │ +00059220: 5245 4e54 5f41 5353 4552 5428 6473 745f  RENT_ASSERT(dst_
    │ │ │ +00059230: 6964 7820 2667 743b 3d20 6669 7273 745f  idx >= first_
    │ │ │ +00059240: 6c65 6166 293b 0a0a 0909 0909 0909 696e  leaf);........in
    │ │ │ +00059250: 7420 636f 6e73 7420 706f 7320 3d20 6473  t const pos = ds
    │ │ │ +00059260: 745f 6964 7820 2d20 6669 7273 745f 6c65  t_idx - first_le
    │ │ │ +00059270: 6166 3b0a 0909 0909 0909 6175 746f 2063  af;.......auto c
    │ │ │ +00059280: 6f6e 7374 2070 6965 6365 203d 2070 6965  onst piece = pie
    │ │ │ +00059290: 6365 5f69 6e64 6578 5f74 7b70 6f73 2026  ce_index_t{pos &
    │ │ │ +000592a0: 6774 3b26 6774 3b20 6d5f 626c 6f63 6b73  gt;> m_blocks
    │ │ │ +000592b0: 5f70 6572 5f70 6965 6365 5f6c 6f67 7d20  _per_piece_log} 
    │ │ │ +000592c0: 2b20 6669 6c65 5f70 6965 6365 5f6f 6666  + file_piece_off
    │ │ │ +000592d0: 7365 743b 0a09 0909 0909 0969 6e74 2063  set;.......int c
    │ │ │ +000592e0: 6f6e 7374 2062 6c6f 636b 203d 2070 6f73  onst block = pos
    │ │ │ +000592f0: 2026 616d 703b 2028 2831 2026 6c74 3b26   & ((1 <&
    │ │ │ +00059300: 6c74 3b20 6d5f 626c 6f63 6b73 5f70 6572  lt; m_blocks_per
    │ │ │ +00059310: 5f70 6965 6365 5f6c 6f67 2920 2d20 3129  _piece_log) - 1)
    │ │ │ +00059320: 3b0a 0a09 0909 0909 0954 4f52 5245 4e54  ;........TORRENT
    │ │ │ +00059330: 5f41 5353 4552 5428 706f 7320 266c 743b  _ASSERT(pos <
    │ │ │ +00059340: 206d 5f6e 756d 5f62 6c6f 636b 7329 3b0a   m_num_blocks);.
    │ │ │ +00059350: 0909 0909 0909 6966 2028 2172 6574 2e66  ......if (!ret.f
    │ │ │ +00059360: 6169 6c65 642e 656d 7074 7928 2920 2661  ailed.empty() &a
    │ │ │ +00059370: 6d70 3b26 616d 703b 2072 6574 2e66 6169  mp;& ret.fai
    │ │ │ +00059380: 6c65 642e 6261 636b 2829 2e66 6972 7374  led.back().first
    │ │ │ +00059390: 203d 3d20 7069 6563 6529 0a09 0909 0909   == piece)......
    │ │ │ +000593a0: 0909 7265 742e 6661 696c 6564 2e62 6163  ..ret.failed.bac
    │ │ │ +000593b0: 6b28 292e 7365 636f 6e64 2e70 7573 685f  k().second.push_
    │ │ │ +000593c0: 6261 636b 2862 6c6f 636b 293b 0a09 0909  back(block);....
    │ │ │ +000593d0: 0909 0965 6c73 650a 0909 0909 0909 0972  ...else........r
    │ │ │ +000593e0: 6574 2e66 6169 6c65 642e 656d 706c 6163  et.failed.emplac
    │ │ │ +000593f0: 655f 6261 636b 2870 6965 6365 2c20 7374  e_back(piece, st
    │ │ │ +00059400: 643a 3a76 6563 746f 7226 6c74 3b69 6e74  d::vector<int
    │ │ │ +00059410: 2667 743b 7b62 6c6f 636b 7d29 3b0a 0a09  >{block});...
    │ │ │ +00059420: 0909 0909 092f 2f20 6e6f 7720 7468 6174  .....// now that
    │ │ │ +00059430: 2074 6869 7320 6861 7368 2068 6173 2062   this hash has b
    │ │ │ +00059440: 6565 6e20 7265 706f 7274 6564 2061 7320  een reported as 
    │ │ │ +00059450: 6661 696c 696e 672c 2077 650a 0909 0909  failing, we.....
    │ │ │ +00059460: 0909 2f2f 2063 616e 2063 6c65 6172 2069  ..// can clear i
    │ │ │ +00059470: 742e 2054 6869 7320 7769 6c6c 2070 7265  t. This will pre
    │ │ │ +00059480: 7665 6e74 2069 7420 6672 6f6d 2062 6569  vent it from bei
    │ │ │ +00059490: 6e67 0a09 0909 0909 092f 2f20 7265 706f  ng.......// repo
    │ │ │ +000594a0: 7274 6564 2061 7320 6661 696c 696e 6720  rted as failing 
    │ │ │ +000594b0: 6167 6169 6e2e 0a09 0909 0909 096d 5f74  again........m_t
    │ │ │ +000594c0: 7265 655b 6473 745f 6964 785d 2e63 6c65  ree[dst_idx].cle
    │ │ │ +000594d0: 6172 2829 3b0a 0909 0909 097d 0a09 0909  ar();......}....
    │ │ │ +000594e0: 0909 656c 7365 2069 6620 2864 7374 5f69  ..else if (dst_i
    │ │ │ +000594f0: 6478 2026 6774 3b3d 2066 6972 7374 5f6c  dx >= first_l
    │ │ │ +00059500: 6561 6629 0a3c 2f70 7265 3e3c 2f74 643e  eaf).
    │ │ │ +00059510: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00059540: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00059550: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00059560: 7074 3a65 7870 616e 6428 3230 3929 223e pt:expand(209)"> │ │ │ +00059570: 2e2e 2f73 7263 2f6d 6572 6b6c 655f 7472 ../src/merkle_tr │ │ │ +00059580: 6565 2e63 7070 3a34 3335 3c2f 613e 3c2f ee.cpp:435instead o │ │ │ +000595a0: 6620 6f76 6572 7772 6974 696e 6720 7468 f overwriting th │ │ │ +000595b0: 6520 726f 6f74 2061 6e64 2063 6f6d 7061 e root and compa │ │ │ +000595c0: 7269 6e67 2069 7420 6167 6169 6e73 7420 ring it against │ │ │ +000595d0: 6861 7368 6573 5b5d 2c20 7772 6974 6520 hashes[], write │ │ │ +000595e0: 6120 6675 6e63 7469 6f6e 7320 7468 6174 a functions that │ │ │ +000595f0: 202a 7661 6c69 6461 7465 732a 2061 2074 *validates* a t │ │ │ +00059600: 7265 6520 6279 206a 7573 7420 6669 6c6c ree by just fill │ │ │ +00059610: 696e 6720 6974 2075 7020 746f 2074 6865 ing it up to the │ │ │ +00059620: 206c 6576 656c 2062 656c 6f77 2074 6865 level below the │ │ │ +00059630: 2072 6f6f 7420 616e 6420 7468 656e 2076 root and then v │ │ │ +00059640: 616c 6964 6174 6573 2069 742e 3c2f 7464 alidates it.

    instea │ │ │ +000596a0: 6420 6f66 206f 7665 7277 7269 7469 6e67 d of overwriting │ │ │ +000596b0: 2074 6865 2072 6f6f 7420 616e 6420 636f the root and co │ │ │ +000596c0: 6d70 6172 696e 6720 6974 0a61 6761 696e mparing it.again │ │ │ +000596d0: 7374 2068 6173 6865 735b 5d2c 2077 7269 st hashes[], wri │ │ │ +000596e0: 7465 2061 2066 756e 6374 696f 6e73 2074 te a functions t │ │ │ +000596f0: 6861 7420 2a76 616c 6964 6174 6573 2a20 hat *validates* │ │ │ +00059700: 6120 7472 6565 0a62 7920 6a75 7374 2066 a tree.by just f │ │ │ +00059710: 696c 6c69 6e67 2069 7420 7570 2074 6f20 illing it up to │ │ │ +00059720: 7468 6520 6c65 7665 6c20 6265 6c6f 7720 the level below │ │ │ +00059730: 7468 6520 726f 6f74 2061 6e64 2074 6865 the root and the │ │ │ +00059740: 6e0a 7661 6c69 6461 7465 7320 6974 2e3c n.validates it.< │ │ │ +00059750: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6d /h2>

    ../src/m │ │ │ +00059760: 6572 6b6c 655f 7472 6565 2e63 7070 3a34 erkle_tree.cpp:4 │ │ │ +00059770: 3335 3c2f 6834 3e3c 7072 6520 7374 796c 35

    ...&& d
    │ │ │ +000597c0: 6573 745f 7374 6172 745f 6964 7820 266c  est_start_idx &l
    │ │ │ +000597d0: 743b 2066 6972 7374 5f70 6965 6365 5f69  t; first_piece_i
    │ │ │ +000597e0: 6478 202b 206e 756d 5f70 6965 6365 7328  dx + num_pieces(
    │ │ │ +000597f0: 2929 0a09 097b 0a09 0909 696e 7420 636f  ))...{....int co
    │ │ │ +00059800: 6e73 7420 626c 6f63 6b73 5f69 6e5f 7069  nst blocks_in_pi
    │ │ │ +00059810: 6563 6520 3d20 3120 266c 743b 266c 743b  ece = 1 <<
    │ │ │ +00059820: 2062 6173 653b 0a0a 0909 092f 2f20 6974   base;.....// it
    │ │ │ +00059830: 206d 6179 206e 6f77 2062 6520 706f 7373   may now be poss
    │ │ │ +00059840: 6962 6c65 2074 6f20 7665 7269 6679 2074  ible to verify t
    │ │ │ +00059850: 6865 2068 6173 6865 7320 6f66 2070 7265  he hashes of pre
    │ │ │ +00059860: 7669 6f75 736c 7920 7265 6365 6976 6564  viously received
    │ │ │ +00059870: 2062 6c6f 636b 730a 0909 092f 2f20 7472   blocks....// tr
    │ │ │ +00059880: 7920 746f 2076 6572 6966 7920 6173 206d  y to verify as m
    │ │ │ +00059890: 616e 7920 6368 696c 6420 6e6f 6465 7320  any child nodes 
    │ │ │ +000598a0: 6f66 2074 6865 2072 6563 6569 7665 6420  of the received 
    │ │ │ +000598b0: 6861 7368 6573 2061 7320 706f 7373 6962  hashes as possib
    │ │ │ +000598c0: 6c65 0a09 0909 666f 7220 2869 6e74 2069  le....for (int i
    │ │ │ +000598d0: 203d 2030 3b20 6920 266c 743b 2069 6e74   = 0; i < int
    │ │ │ +000598e0: 2868 6173 6865 732e 7369 7a65 2829 293b  (hashes.size());
    │ │ │ +000598f0: 202b 2b69 290a 0909 097b 0a09 0909 0969   ++i)....{.....i
    │ │ │ +00059900: 6e74 2063 6f6e 7374 2070 6965 6365 203d  nt const piece =
    │ │ │ +00059910: 2064 6573 745f 7374 6172 745f 6964 7820   dest_start_idx 
    │ │ │ +00059920: 2b20 693b 0a09 0909 0969 6620 2870 6965  + i;.....if (pie
    │ │ │ +00059930: 6365 202d 2066 6972 7374 5f70 6965 6365  ce - first_piece
    │ │ │ +00059940: 5f69 6478 2026 6774 3b3d 206e 756d 5f70  _idx >= num_p
    │ │ │ +00059950: 6965 6365 7328 2929 0a09 0909 0909 6272  ieces())......br
    │ │ │ +00059960: 6561 6b3b 0a09 0909 092f 2f20 7468 6520  eak;.....// the 
    │ │ │ +00059970: 6669 7273 7420 626c 6f63 6b20 696e 2074  first block in t
    │ │ │ +00059980: 6869 7320 7069 6563 650a 0909 0909 696e  his piece.....in
    │ │ │ +00059990: 7420 636f 6e73 7420 626c 6f63 6b5f 6964  t const block_id
    │ │ │ +000599a0: 7820 3d20 6d65 726b 6c65 5f67 6574 5f66  x = merkle_get_f
    │ │ │ +000599b0: 6972 7374 5f63 6869 6c64 2870 6965 6365  irst_child(piece
    │ │ │ +000599c0: 2c20 6261 7365 293b 0a0a 0909 0909 696e  , base);......in
    │ │ │ +000599d0: 7420 636f 6e73 7420 626c 6f63 6b5f 656e  t const block_en
    │ │ │ +000599e0: 645f 6964 7820 3d20 7374 643a 3a6d 696e  d_idx = std::min
    │ │ │ +000599f0: 2862 6c6f 636b 5f69 6478 202b 2062 6c6f  (block_idx + blo
    │ │ │ +00059a00: 636b 735f 696e 5f70 6965 6365 2c20 6669  cks_in_piece, fi
    │ │ │ +00059a10: 7273 745f 6c65 6166 202b 206d 5f6e 756d  rst_leaf + m_num
    │ │ │ +00059a20: 5f62 6c6f 636b 7329 3b0a 0909 0909 6966  _blocks);.....if
    │ │ │ +00059a30: 2028 7374 643a 3a61 6e79 5f6f 6628 6d5f   (std::any_of(m_
    │ │ │ +00059a40: 7472 6565 2e62 6567 696e 2829 202b 2062  tree.begin() + b
    │ │ │ +00059a50: 6c6f 636b 5f69 6478 0a09 0909 0909 2c20  lock_idx......, 
    │ │ │ +00059a60: 6d5f 7472 6565 2e62 6567 696e 2829 202b  m_tree.begin() +
    │ │ │ +00059a70: 2062 6c6f 636b 5f65 6e64 5f69 6478 0a09   block_end_idx..
    │ │ │ +00059a80: 0909 0909 2c20 5b5d 2873 6861 3235 365f  ...., [](sha256_
    │ │ │ +00059a90: 6861 7368 2063 6f6e 7374 2661 6d70 3b20  hash const& 
    │ │ │ +00059aa0: 6829 207b 2072 6574 7572 6e20 682e 6973  h) { return h.is
    │ │ │ +00059ab0: 5f61 6c6c 5f7a 6572 6f73 2829 3b20 7d29  _all_zeros(); })
    │ │ │ +00059ac0: 290a 0909 0909 0963 6f6e 7469 6e75 653b  )......continue;
    │ │ │ +00059ad0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00059b00: 0909 0909 6d65 726b 6c65 5f66 696c 6c5f ....merkle_fill_ │ │ │ +00059b10: 7472 6565 286d 5f74 7265 652c 2062 6c6f tree(m_tree, blo │ │ │ +00059b20: 636b 735f 696e 5f70 6965 6365 2c20 626c cks_in_piece, bl │ │ │ +00059b30: 6f63 6b5f 6964 7829 3b0a 3c2f 6469 763e ock_idx);.
    │ │ │ +00059b40: 0909 0909 6966 2028 6d5f 7472 6565 5b70 ....if (m_tree[p │ │ │ +00059b50: 6965 6365 5d20 213d 2068 6173 6865 735b iece] != hashes[ │ │ │ +00059b60: 695d 290a 0909 0909 7b0a 0909 0909 096d i]).....{......m │ │ │ +00059b70: 6572 6b6c 655f 636c 6561 725f 7472 6565 erkle_clear_tree │ │ │ +00059b80: 286d 5f74 7265 652c 2062 6c6f 636b 735f (m_tree, blocks_ │ │ │ +00059b90: 696e 5f70 6965 6365 2c20 626c 6f63 6b5f in_piece, block_ │ │ │ +00059ba0: 6964 7829 3b0a 0909 0909 092f 2f20 7772 idx);......// wr │ │ │ +00059bb0: 6974 6520 6261 636b 2074 6865 2063 6f72 ite back the cor │ │ │ +00059bc0: 7265 6374 2068 6173 680a 0909 0909 096d rect hash......m │ │ │ +00059bd0: 5f74 7265 655b 7069 6563 655d 203d 2068 _tree[piece] = h │ │ │ +00059be0: 6173 6865 735b 695d 3b0a 0909 0909 0954 ashes[i];......T │ │ │ +00059bf0: 4f52 5245 4e54 5f41 5353 4552 5428 626c ORRENT_ASSERT(bl │ │ │ +00059c00: 6f63 6b73 5f69 6e5f 7069 6563 6520 3d3d ocks_in_piece == │ │ │ +00059c10: 2062 6c6f 636b 735f 7065 725f 7069 6563 blocks_per_piec │ │ │ +00059c20: 6528 2929 3b0a 0a09 0909 0909 2f2f 2061 e());.......// a │ │ │ +00059c30: 6e20 656d 7074 7920 626c 6f63 6b73 2076 n empty blocks v │ │ │ +00059c40: 6563 746f 7220 696e 6469 6361 7465 7320 ector indicates │ │ │ +00059c50: 7468 6174 2077 6520 646f 6e27 7420 6861 that we don't ha │ │ │ +00059c60: 7665 2074 6865 0a09 0909 0909 2f2f 2062 ve the......// b │ │ │ +00059c70: 6c6f 636b 2068 6173 6865 732c 2061 6e64 lock hashes, and │ │ │ +00059c80: 2077 6520 6361 6e27 7420 6b6e 6f77 2077 we can't know w │ │ │ +00059c90: 6869 6368 2062 6c6f 636b 2066 6169 6c65 hich block faile │ │ │ +00059ca0: 640a 0909 0909 092f 2f20 7468 6973 2077 d......// this w │ │ │ +00059cb0: 696c 6c20 6361 7573 6520 7468 6520 626c ill cause the bl │ │ │ +00059cc0: 6f63 6b20 6861 7368 6573 2074 6f20 6265 ock hashes to be │ │ │ +00059cd0: 2072 6571 7565 7374 6564 0a09 0909 0909 requested...... │ │ │ +00059ce0: 7265 742e 6661 696c 6564 2e65 6d70 6c61 ret.failed.empla │ │ │ +00059cf0: 6365 5f62 6163 6b28 7069 6563 655f 696e ce_back(piece_in │ │ │ +00059d00: 6465 785f 747b 7069 6563 6520 2d20 6669 dex_t{piece - fi │ │ │ +00059d10: 7273 745f 7069 6563 655f 6964 787d 202b rst_piece_idx} + │ │ │ +00059d20: 2066 696c 655f 7069 6563 655f 6f66 6673 file_piece_offs │ │ │ +00059d30: 6574 0a09 0909 0909 092c 2073 7464 3a3a et......., std:: │ │ │ +00059d40: 7665 6374 6f72 266c 743b 696e 7426 6774 vector<int> │ │ │ +00059d50: 3b28 2929 3b0a 0909 0909 7d0a 0909 0909 ;());.....}..... │ │ │ +00059d60: 656c 7365 0a09 0909 097b 0a09 0909 0909 else.....{...... │ │ │ +00059d70: 7265 742e 7061 7373 6564 2e70 7573 685f ret.passed.push_ │ │ │ +00059d80: 6261 636b 2870 6965 6365 5f69 6e64 6578 back(piece_index │ │ │ +00059d90: 5f74 7b70 6965 6365 202d 2066 6972 7374 _t{piece - first │ │ │ +00059da0: 5f70 6965 6365 5f69 6478 7d20 2b20 6669 _piece_idx} + fi │ │ │ +00059db0: 6c65 5f70 6965 6365 5f6f 6666 7365 7429 le_piece_offset) │ │ │ +00059dc0: 3b0a 0909 0909 092f 2f20 7265 636f 7264 ;......// record │ │ │ +00059dd0: 2074 6861 7420 7468 6573 6520 626c 6f63 that these bloc │ │ │ +00059de0: 6b20 6861 7368 6573 2061 7265 2063 6f72 k hashes are cor │ │ │ +00059df0: 7265 6374 210a 0909 0909 0969 6e74 2063 rect!......int c │ │ │ +00059e00: 6f6e 7374 206c 6561 6673 5f73 7461 7274 onst leafs_start │ │ │ +00059e10: 203d 2062 6c6f 636b 5f69 6478 202d 2062 = block_idx - b │ │ │ +00059e20: 6c6f 636b 5f6c 6179 6572 5f73 7461 7274 lock_layer_start │ │ │ +00059e30: 2829 3b0a 0909 0909 0969 6e74 2063 6f6e ();......int con │ │ │ +00059e40: 7374 206c 6561 6673 5f65 6e64 203d 2073 st leafs_end = s │ │ │ +00059e50: 7464 3a3a 6d69 6e28 6d5f 6e75 6d5f 626c td::min(m_num_bl │ │ │ +00059e60: 6f63 6b73 2c20 6c65 6166 735f 7374 6172 ocks, leafs_star │ │ │ +00059e70: 7420 2b20 626c 6f63 6b73 5f69 6e5f 7069 t + blocks_in_pi │ │ │ +00059e80: 6563 6529 3b0a 3c2f 7072 653e 3c2f 7464 ece);.
    relevance │ │ │ +00059ec0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00059ed0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/merkle_t │ │ │ +00059f00: 7265 652e 6370 703a 3435 393c 2f61 3e3c ree.cpp:459< │ │ │ +00059f10: 2f74 643e 3c74 643e 7468 6973 2063 6f75 /td>this cou │ │ │ +00059f20: 6c64 2062 6520 646f 6e65 206d 6f72 6520 ld be done more │ │ │ +00059f30: 6566 6669 6369 656e 746c 7920 6966 2062 efficiently if b │ │ │ +00059f40: 6974 6669 656c 6420 6861 6420 6120 6675 itfield had a fu │ │ │ +00059f50: 6e63 7469 6f6e 2074 6f20 7365 7420 6120 nction to set a │ │ │ +00059f60: 7261 6e67 6520 6f66 2062 6974 733c 2f74 range of bits

    this │ │ │ +00059fc0: 636f 756c 6420 6265 2064 6f6e 6520 6d6f could be done mo │ │ │ +00059fd0: 7265 2065 6666 6963 6965 6e74 6c79 2069 re efficiently i │ │ │ +00059fe0: 6620 6269 7466 6965 6c64 2068 6164 2061 f bitfield had a │ │ │ +00059ff0: 2066 756e 6374 696f 6e0a 746f 2073 6574 function.to set │ │ │ +0005a000: 2061 2072 616e 6765 206f 6620 6269 7473 a range of bits │ │ │ +0005a010: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0005a020: 6d65 726b 6c65 5f74 7265 652e 6370 703a merkle_tree.cpp: │ │ │ +0005a030: 3435 393c 2f68 343e 3c70 7265 2073 7479 459

    ....merkle_fil
    │ │ │ +0005a080: 6c5f 7472 6565 286d 5f74 7265 652c 2062  l_tree(m_tree, b
    │ │ │ +0005a090: 6c6f 636b 735f 696e 5f70 6965 6365 2c20  locks_in_piece, 
    │ │ │ +0005a0a0: 626c 6f63 6b5f 6964 7829 3b0a 0909 0909  block_idx);.....
    │ │ │ +0005a0b0: 6966 2028 6d5f 7472 6565 5b70 6965 6365  if (m_tree[piece
    │ │ │ +0005a0c0: 5d20 213d 2068 6173 6865 735b 695d 290a  ] != hashes[i]).
    │ │ │ +0005a0d0: 0909 0909 7b0a 0909 0909 096d 6572 6b6c  ....{......merkl
    │ │ │ +0005a0e0: 655f 636c 6561 725f 7472 6565 286d 5f74  e_clear_tree(m_t
    │ │ │ +0005a0f0: 7265 652c 2062 6c6f 636b 735f 696e 5f70  ree, blocks_in_p
    │ │ │ +0005a100: 6965 6365 2c20 626c 6f63 6b5f 6964 7829  iece, block_idx)
    │ │ │ +0005a110: 3b0a 0909 0909 092f 2f20 7772 6974 6520  ;......// write 
    │ │ │ +0005a120: 6261 636b 2074 6865 2063 6f72 7265 6374  back the correct
    │ │ │ +0005a130: 2068 6173 680a 0909 0909 096d 5f74 7265   hash......m_tre
    │ │ │ +0005a140: 655b 7069 6563 655d 203d 2068 6173 6865  e[piece] = hashe
    │ │ │ +0005a150: 735b 695d 3b0a 0909 0909 0954 4f52 5245  s[i];......TORRE
    │ │ │ +0005a160: 4e54 5f41 5353 4552 5428 626c 6f63 6b73  NT_ASSERT(blocks
    │ │ │ +0005a170: 5f69 6e5f 7069 6563 6520 3d3d 2062 6c6f  _in_piece == blo
    │ │ │ +0005a180: 636b 735f 7065 725f 7069 6563 6528 2929  cks_per_piece())
    │ │ │ +0005a190: 3b0a 0a09 0909 0909 2f2f 2061 6e20 656d  ;.......// an em
    │ │ │ +0005a1a0: 7074 7920 626c 6f63 6b73 2076 6563 746f  pty blocks vecto
    │ │ │ +0005a1b0: 7220 696e 6469 6361 7465 7320 7468 6174  r indicates that
    │ │ │ +0005a1c0: 2077 6520 646f 6e27 7420 6861 7665 2074   we don't have t
    │ │ │ +0005a1d0: 6865 0a09 0909 0909 2f2f 2062 6c6f 636b  he......// block
    │ │ │ +0005a1e0: 2068 6173 6865 732c 2061 6e64 2077 6520   hashes, and we 
    │ │ │ +0005a1f0: 6361 6e27 7420 6b6e 6f77 2077 6869 6368  can't know which
    │ │ │ +0005a200: 2062 6c6f 636b 2066 6169 6c65 640a 0909   block failed...
    │ │ │ +0005a210: 0909 092f 2f20 7468 6973 2077 696c 6c20  ...// this will 
    │ │ │ +0005a220: 6361 7573 6520 7468 6520 626c 6f63 6b20  cause the block 
    │ │ │ +0005a230: 6861 7368 6573 2074 6f20 6265 2072 6571  hashes to be req
    │ │ │ +0005a240: 7565 7374 6564 0a09 0909 0909 7265 742e  uested......ret.
    │ │ │ +0005a250: 6661 696c 6564 2e65 6d70 6c61 6365 5f62  failed.emplace_b
    │ │ │ +0005a260: 6163 6b28 7069 6563 655f 696e 6465 785f  ack(piece_index_
    │ │ │ +0005a270: 747b 7069 6563 6520 2d20 6669 7273 745f  t{piece - first_
    │ │ │ +0005a280: 7069 6563 655f 6964 787d 202b 2066 696c  piece_idx} + fil
    │ │ │ +0005a290: 655f 7069 6563 655f 6f66 6673 6574 0a09  e_piece_offset..
    │ │ │ +0005a2a0: 0909 0909 092c 2073 7464 3a3a 7665 6374  ....., std::vect
    │ │ │ +0005a2b0: 6f72 266c 743b 696e 7426 6774 3b28 2929  or<int>())
    │ │ │ +0005a2c0: 3b0a 0909 0909 7d0a 0909 0909 656c 7365  ;.....}.....else
    │ │ │ +0005a2d0: 0a09 0909 097b 0a09 0909 0909 7265 742e  .....{......ret.
    │ │ │ +0005a2e0: 7061 7373 6564 2e70 7573 685f 6261 636b  passed.push_back
    │ │ │ +0005a2f0: 2870 6965 6365 5f69 6e64 6578 5f74 7b70  (piece_index_t{p
    │ │ │ +0005a300: 6965 6365 202d 2066 6972 7374 5f70 6965  iece - first_pie
    │ │ │ +0005a310: 6365 5f69 6478 7d20 2b20 6669 6c65 5f70  ce_idx} + file_p
    │ │ │ +0005a320: 6965 6365 5f6f 6666 7365 7429 3b0a 0909  iece_offset);...
    │ │ │ +0005a330: 0909 092f 2f20 7265 636f 7264 2074 6861  ...// record tha
    │ │ │ +0005a340: 7420 7468 6573 6520 626c 6f63 6b20 6861  t these block ha
    │ │ │ +0005a350: 7368 6573 2061 7265 2063 6f72 7265 6374  shes are correct
    │ │ │ +0005a360: 210a 0909 0909 0969 6e74 2063 6f6e 7374  !......int const
    │ │ │ +0005a370: 206c 6561 6673 5f73 7461 7274 203d 2062   leafs_start = b
    │ │ │ +0005a380: 6c6f 636b 5f69 6478 202d 2062 6c6f 636b  lock_idx - block
    │ │ │ +0005a390: 5f6c 6179 6572 5f73 7461 7274 2829 3b0a  _layer_start();.
    │ │ │ +0005a3a0: 0909 0909 0969 6e74 2063 6f6e 7374 206c  .....int const l
    │ │ │ +0005a3b0: 6561 6673 5f65 6e64 203d 2073 7464 3a3a  eafs_end = std::
    │ │ │ +0005a3c0: 6d69 6e28 6d5f 6e75 6d5f 626c 6f63 6b73  min(m_num_blocks
    │ │ │ +0005a3d0: 2c20 6c65 6166 735f 7374 6172 7420 2b20  , leafs_start + 
    │ │ │ +0005a3e0: 626c 6f63 6b73 5f69 6e5f 7069 6563 6529  blocks_in_piece)
    │ │ │ +0005a3f0: 3b0a 3c64 6976 2073 7479 6c65 3d22 6261  ;.
    │ │ │ +0005a420: 0909 0909 0966 6f72 2028 696e 7420 6b20 .....for (int k │ │ │ +0005a430: 3d20 6c65 6166 735f 7374 6172 743b 206b = leafs_start; k │ │ │ +0005a440: 2026 6c74 3b20 6c65 6166 735f 656e 643b < leafs_end; │ │ │ +0005a450: 202b 2b6b 290a 3c2f 6469 763e 0909 0909 ++k).
    .... │ │ │ +0005a460: 0909 6d5f 626c 6f63 6b5f 7665 7269 6669 ..m_block_verifi │ │ │ +0005a470: 6564 2e73 6574 5f62 6974 286b 293b 0a09 ed.set_bit(k);.. │ │ │ +0005a480: 0909 097d 0a09 0909 0954 4f52 5245 4e54 ...}.....TORRENT │ │ │ +0005a490: 5f41 5353 4552 5428 2870 6965 6365 202d _ASSERT((piece - │ │ │ +0005a4a0: 2066 6972 7374 5f70 6965 6365 5f69 6478 first_piece_idx │ │ │ +0005a4b0: 2920 2667 743b 3d20 3029 3b0a 0909 097d ) >= 0);....} │ │ │ +0005a4c0: 0a09 097d 0a0a 0909 6f70 7469 6d69 7a65 ...}....optimize │ │ │ +0005a4d0: 5f73 746f 7261 6765 2829 3b0a 0a09 0972 _storage();....r │ │ │ +0005a4e0: 6574 7572 6e20 7265 743b 0a09 7d0a 0a09 eturn ret;..}... │ │ │ +0005a4f0: 7374 643a 3a74 7570 6c65 266c 743b 6d65 std::tuple<me │ │ │ +0005a500: 726b 6c65 5f74 7265 653a 3a73 6574 5f62 rkle_tree::set_b │ │ │ +0005a510: 6c6f 636b 5f72 6573 756c 742c 2069 6e74 lock_result, int │ │ │ +0005a520: 2c20 696e 7426 6774 3b20 6d65 726b 6c65 , int> merkle │ │ │ +0005a530: 5f74 7265 653a 3a73 6574 5f62 6c6f 636b _tree::set_block │ │ │ +0005a540: 2869 6e74 2063 6f6e 7374 2062 6c6f 636b (int const block │ │ │ +0005a550: 5f69 6e64 6578 0a09 092c 2073 6861 3235 _index..., sha25 │ │ │ +0005a560: 365f 6861 7368 2063 6f6e 7374 2661 6d70 6_hash const& │ │ │ +0005a570: 3b20 6829 0a09 7b0a 2369 6664 6566 2054 ; h)..{.#ifdef T │ │ │ +0005a580: 4f52 5245 4e54 5f45 5850 454e 5349 5645 ORRENT_EXPENSIVE │ │ │ +0005a590: 5f49 4e56 4152 4941 4e54 5f43 4845 434b _INVARIANT_CHECK │ │ │ +0005a5a0: 530a 0909 494e 5641 5249 414e 545f 4348 S...INVARIANT_CH │ │ │ +0005a5b0: 4543 4b3b 0a23 656e 6469 660a 0909 544f ECK;.#endif...TO │ │ │ +0005a5c0: 5252 454e 545f 4153 5345 5254 2862 6c6f RRENT_ASSERT(blo │ │ │ +0005a5d0: 636b 5f69 6e64 6578 2026 6c74 3b20 6d5f ck_index < m_ │ │ │ +0005a5e0: 6e75 6d5f 626c 6f63 6b73 293b 0a0a 0909 num_blocks);.... │ │ │ +0005a5f0: 6175 746f 2063 6f6e 7374 206e 756d 5f6c auto const num_l │ │ │ +0005a600: 6561 6673 203d 206d 6572 6b6c 655f 6e75 eafs = merkle_nu │ │ │ +0005a610: 6d5f 6c65 6166 7328 6d5f 6e75 6d5f 626c m_leafs(m_num_bl │ │ │ +0005a620: 6f63 6b73 293b 0a09 0961 7574 6f20 636f ocks);...auto co │ │ │ +0005a630: 6e73 7420 6669 7273 745f 6c65 6166 203d nst first_leaf = │ │ │ +0005a640: 206d 6572 6b6c 655f 6669 7273 745f 6c65 merkle_first_le │ │ │ +0005a650: 6166 286e 756d 5f6c 6561 6673 293b 0a09 af(num_leafs);.. │ │ │ +0005a660: 0961 7574 6f20 636f 6e73 7420 626c 6f63 .auto const bloc │ │ │ +0005a670: 6b5f 7472 6565 5f69 6e64 6578 203d 2066 k_tree_index = f │ │ │ +0005a680: 6972 7374 5f6c 6561 6620 2b20 626c 6f63 irst_leaf + bloc │ │ │ +0005a690: 6b5f 696e 6465 783b 0a0a 0909 6966 2028 k_index;....if ( │ │ │ +0005a6a0: 626c 6f63 6b73 5f76 6572 6966 6965 6428 blocks_verified( │ │ │ +0005a6b0: 626c 6f63 6b5f 696e 6465 782c 2031 2929 block_index, 1)) │ │ │ +0005a6c0: 0a09 097b 0a09 0909 2f2f 2069 6620 7468 ...{....// if th │ │ │ +0005a6d0: 6973 2062 6c6f 636b 7327 7320 6861 7368 is blocks's hash │ │ │ +0005a6e0: 2069 7320 616c 7265 6164 7920 6b6e 6f77 is already know │ │ │ +0005a6f0: 6e2c 2063 6865 636b 2074 6865 2070 6173 n, check the pas │ │ │ +0005a700: 7365 642d 696e 2068 6173 6820 6167 6169 sed-in hash agai │ │ │ +0005a710: 6e73 7420 6974 0a09 0909 6966 2028 636f nst it....if (co │ │ │ +0005a720: 6d70 6172 655f 6e6f 6465 2862 6c6f 636b mpare_node(block │ │ │ +0005a730: 5f74 7265 655f 696e 6465 782c 2068 2929 _tree_index, h)) │ │ │ +0005a740: 0a09 0909 0972 6574 7572 6e20 7374 643a .....return std: │ │ │ +0005a750: 3a6d 616b 655f 7475 706c 6528 7365 745f :make_tuple(set_ │ │ │ +0005a760: 626c 6f63 6b5f 7265 7375 6c74 3a3a 6f6b block_result::ok │ │ │ +0005a770: 2c20 626c 6f63 6b5f 696e 6465 782c 2031 , block_index, 1 │ │ │ +0005a780: 293b 0a09 0909 656c 7365 0a09 0909 0972 );....else.....r │ │ │ +0005a790: 6574 7572 6e20 7374 643a 3a6d 616b 655f eturn std::make_ │ │ │ +0005a7a0: 7475 706c 6528 7365 745f 626c 6f63 6b5f tuple(set_block_ │ │ │ +0005a7b0: 7265 7375 6c74 3a3a 626c 6f63 6b5f 6861 result::block_ha │ │ │ +0005a7c0: 7368 5f66 6169 6c65 642c 2062 6c6f 636b sh_failed, block │ │ │ +0005a7d0: 5f69 6e64 6578 2c20 3129 3b0a 3c2f 7072 _index, 1);.rel │ │ │ +0005a810: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/me │ │ │ +0005a850: 726b 6c65 5f74 7265 652e 6370 703a 3532 rkle_tree.cpp:52 │ │ │ +0005a860: 333c 2f61 3e3c 2f74 643e 3c74 643e 7468 3th │ │ │ +0005a870: 6973 2063 6f75 6c64 2062 6520 646f 6e65 is could be done │ │ │ +0005a880: 206d 6f72 6520 6566 6669 6369 656e 746c more efficientl │ │ │ +0005a890: 7920 6966 2062 6974 6669 656c 6420 6861 y if bitfield ha │ │ │ +0005a8a0: 6420 6120 6675 6e63 7469 6f6e 2074 6f20 d a function to │ │ │ +0005a8b0: 7365 7420 6120 7261 6e67 6520 6f66 2062 set a range of b │ │ │ +0005a8c0: 6974 733c 2f74 643e 3c2f 7472 3e3c 7472 its

    this could be d │ │ │ +0005a920: 6f6e 6520 6d6f 7265 2065 6666 6963 6965 one more efficie │ │ │ +0005a930: 6e74 6c79 2069 6620 6269 7466 6965 6c64 ntly if bitfield │ │ │ +0005a940: 2068 6164 2061 2066 756e 6374 696f 6e0a had a function. │ │ │ +0005a950: 746f 2073 6574 2061 2072 616e 6765 206f to set a range o │ │ │ +0005a960: 6620 6269 7473 3c2f 6832 3e3c 6834 3e2e f bits

    . │ │ │ +0005a970: 2e2f 7372 632f 6d65 726b 6c65 5f74 7265 ./src/merkle_tre │ │ │ +0005a980: 652e 6370 703a 3532 333c 2f68 343e 3c70 e.cpp:523

    ...merkl │ │ │ +0005a9d0: 655f 6669 6e64 5f6b 6e6f 776e 5f73 7562 e_find_known_sub │ │ │ +0005a9e0: 7472 6565 286d 5f74 7265 652c 2062 6c6f tree(m_tree, blo │ │ │ +0005a9f0: 636b 5f69 6e64 6578 2c20 6d5f 6e75 6d5f ck_index, m_num_ │ │ │ +0005aa00: 626c 6f63 6b73 293b 0a0a 0909 2f2f 2069 blocks);....// i │ │ │ +0005aa10: 6620 7468 6520 726f 6f74 206e 6f64 6520 f the root node │ │ │ +0005aa20: 6973 2075 6e6b 6e6f 776e 2074 6865 2068 is unknown the h │ │ │ +0005aa30: 6173 6865 7320 6361 6e6e 6f74 2062 6520 ashes cannot be │ │ │ +0005aa40: 7665 7269 6669 6564 2079 6574 0a09 0969 verified yet...i │ │ │ +0005aa50: 6620 286d 5f74 7265 655b 726f 6f74 5f69 f (m_tree[root_i │ │ │ +0005aa60: 6e64 6578 5d2e 6973 5f61 6c6c 5f7a 6572 ndex].is_all_zer │ │ │ +0005aa70: 6f73 2829 290a 0909 0972 6574 7572 6e20 os())....return │ │ │ +0005aa80: 7374 643a 3a6d 616b 655f 7475 706c 6528 std::make_tuple( │ │ │ +0005aa90: 7365 745f 626c 6f63 6b5f 7265 7375 6c74 set_block_result │ │ │ +0005aaa0: 3a3a 756e 6b6e 6f77 6e2c 206c 6561 6673 ::unknown, leafs │ │ │ +0005aab0: 5f73 7461 7274 2c20 6c65 6166 735f 7369 _start, leafs_si │ │ │ +0005aac0: 7a65 293b 0a0a 0909 2f2f 2073 6176 6520 ze);....// save │ │ │ +0005aad0: 7468 6520 726f 6f74 2068 6173 6820 6265 the root hash be │ │ │ +0005aae0: 6361 7573 6520 6d65 726b 6c65 5f66 696c cause merkle_fil │ │ │ +0005aaf0: 6c5f 7472 6565 2077 696c 6c20 6f76 6572 l_tree will over │ │ │ +0005ab00: 7772 6974 6520 6974 0a09 0973 6861 3235 write it...sha25 │ │ │ +0005ab10: 365f 6861 7368 2063 6f6e 7374 2072 6f6f 6_hash const roo │ │ │ +0005ab20: 7420 3d20 6d5f 7472 6565 5b72 6f6f 745f t = m_tree[root_ │ │ │ +0005ab30: 696e 6465 785d 3b0a 0909 6d65 726b 6c65 index];...merkle │ │ │ +0005ab40: 5f66 696c 6c5f 7472 6565 286d 5f74 7265 _fill_tree(m_tre │ │ │ +0005ab50: 652c 206c 6561 6673 5f73 697a 652c 2066 e, leafs_size, f │ │ │ +0005ab60: 6972 7374 5f6c 6561 6620 2b20 6c65 6166 irst_leaf + leaf │ │ │ +0005ab70: 735f 7374 6172 7429 3b0a 0a09 0969 6620 s_start);....if │ │ │ +0005ab80: 2872 6f6f 7420 213d 206d 5f74 7265 655b (root != m_tree[ │ │ │ +0005ab90: 726f 6f74 5f69 6e64 6578 5d29 0a09 097b root_index])...{ │ │ │ +0005aba0: 0a09 0909 2f2f 2068 6173 6820 6661 696c ....// hash fail │ │ │ +0005abb0: 7572 652c 2063 6c65 6172 2061 6c6c 2074 ure, clear all t │ │ │ +0005abc0: 6865 2069 6e74 6572 6e61 6c20 6e6f 6465 he internal node │ │ │ +0005abd0: 730a 0909 092f 2f20 7468 6520 7768 6f6c s....// the whol │ │ │ +0005abe0: 6520 7069 6563 6520 6661 696c 6564 2074 e piece failed t │ │ │ +0005abf0: 6865 2068 6173 6820 6368 6563 6b2e 2043 he hash check. C │ │ │ +0005ac00: 6c65 6172 2061 6c6c 2062 6c6f 636b 2068 lear all block h │ │ │ +0005ac10: 6173 6865 730a 0909 092f 2f20 696e 2074 ashes....// in t │ │ │ +0005ac20: 6869 7320 7069 6563 6520 616e 6420 7265 his piece and re │ │ │ +0005ac30: 706f 7274 2061 2068 6173 6820 6661 696c port a hash fail │ │ │ +0005ac40: 7572 650a 0909 096d 6572 6b6c 655f 636c ure....merkle_cl │ │ │ +0005ac50: 6561 725f 7472 6565 286d 5f74 7265 652c ear_tree(m_tree, │ │ │ +0005ac60: 206c 6561 6673 5f73 697a 652c 2066 6972 leafs_size, fir │ │ │ +0005ac70: 7374 5f6c 6561 6620 2b20 6c65 6166 735f st_leaf + leafs_ │ │ │ +0005ac80: 7374 6172 7429 3b0a 0909 096d 5f74 7265 start);....m_tre │ │ │ +0005ac90: 655b 726f 6f74 5f69 6e64 6578 5d20 3d20 e[root_index] = │ │ │ +0005aca0: 726f 6f74 3b0a 0909 0972 6574 7572 6e20 root;....return │ │ │ +0005acb0: 7374 643a 3a6d 616b 655f 7475 706c 6528 std::make_tuple( │ │ │ +0005acc0: 7365 745f 626c 6f63 6b5f 7265 7375 6c74 set_block_result │ │ │ +0005acd0: 3a3a 6861 7368 5f66 6169 6c65 642c 206c ::hash_failed, l │ │ │ +0005ace0: 6561 6673 5f73 7461 7274 2c20 6c65 6166 eafs_start, leaf │ │ │ +0005acf0: 735f 7369 7a65 293b 0a09 097d 0a0a 3c64 s_size);...}....in │ │ │ +0005ad30: 7420 636f 6e73 7420 6c65 6166 735f 656e t const leafs_en │ │ │ +0005ad40: 6420 3d20 7374 643a 3a6d 696e 286d 5f6e d = std::min(m_n │ │ │ +0005ad50: 756d 5f62 6c6f 636b 732c 206c 6561 6673 um_blocks, leafs │ │ │ +0005ad60: 5f73 7461 7274 202b 206c 6561 6673 5f73 _start + leafs_s │ │ │ +0005ad70: 697a 6529 3b0a 3c2f 6469 763e 0909 666f ize);...fo │ │ │ +0005ad80: 7220 2869 6e74 2069 203d 206c 6561 6673 r (int i = leafs │ │ │ +0005ad90: 5f73 7461 7274 3b20 6920 266c 743b 206c _start; i < l │ │ │ +0005ada0: 6561 6673 5f65 6e64 3b20 2b2b 6929 0a09 eafs_end; ++i).. │ │ │ +0005adb0: 0909 6d5f 626c 6f63 6b5f 7665 7269 6669 ..m_block_verifi │ │ │ +0005adc0: 6564 2e73 6574 5f62 6974 2869 293b 0a0a ed.set_bit(i);.. │ │ │ +0005add0: 0909 2f2f 2061 7474 656d 7074 696e 6720 ..// attempting │ │ │ +0005ade0: 746f 206f 7074 696d 697a 6520 7374 6f72 to optimize stor │ │ │ +0005adf0: 6167 6520 6973 2071 7569 7465 2063 6f73 age is quite cos │ │ │ +0005ae00: 746c 792c 206f 6e6c 7920 646f 2069 7420 tly, only do it │ │ │ +0005ae10: 6966 2077 6520 6861 7665 0a09 092f 2f20 if we have...// │ │ │ +0005ae20: 6120 7265 6173 6f6e 2074 6f20 6265 6c69 a reason to beli │ │ │ +0005ae30: 6576 6520 6974 206d 6967 6874 2068 6176 eve it might hav │ │ │ +0005ae40: 6520 616e 2065 6666 6563 740a 0909 6966 e an effect...if │ │ │ +0005ae50: 2028 626c 6f63 6b5f 696e 6465 7820 3d3d (block_index == │ │ │ +0005ae60: 206d 5f6e 756d 5f62 6c6f 636b 7320 2d20 m_num_blocks - │ │ │ +0005ae70: 3120 7c7c 2021 6d5f 7472 6565 5b62 6c6f 1 || !m_tree[blo │ │ │ +0005ae80: 636b 5f74 7265 655f 696e 6465 7820 2b20 ck_tree_index + │ │ │ +0005ae90: 315d 2e69 735f 616c 6c5f 7a65 726f 7328 1].is_all_zeros( │ │ │ +0005aea0: 2929 0a09 0909 6f70 7469 6d69 7a65 5f73 ))....optimize_s │ │ │ +0005aeb0: 746f 7261 6765 2829 3b0a 0a09 0972 6574 torage();....ret │ │ │ +0005aec0: 7572 6e20 7374 643a 3a6d 616b 655f 7475 urn std::make_tu │ │ │ +0005aed0: 706c 6528 7365 745f 626c 6f63 6b5f 7265 ple(set_block_re │ │ │ +0005aee0: 7375 6c74 3a3a 6f6b 2c20 6c65 6166 735f sult::ok, leafs_ │ │ │ +0005aef0: 7374 6172 742c 206c 6561 6673 5f73 697a start, leafs_siz │ │ │ +0005af00: 6529 3b0a 097d 0a0a 0973 7464 3a3a 7369 e);..}...std::si │ │ │ +0005af10: 7a65 5f74 206d 6572 6b6c 655f 7472 6565 ze_t merkle_tree │ │ │ +0005af20: 3a3a 7369 7a65 2829 2063 6f6e 7374 0a09 ::size() const.. │ │ │ +0005af30: 7b0a 0909 7265 7475 726e 2073 7461 7469 {...return stati │ │ │ +0005af40: 635f 6361 7374 266c 743b 7374 643a 3a73 c_cast<std::s │ │ │ +0005af50: 697a 655f 7426 6774 3b28 6d65 726b 6c65 ize_t>(merkle │ │ │ +0005af60: 5f6e 756d 5f6e 6f64 6573 286d 6572 6b6c _num_nodes(merkl │ │ │ +0005af70: 655f 6e75 6d5f 6c65 6166 7328 6d5f 6e75 e_num_leafs(m_nu │ │ │ +0005af80: 6d5f 626c 6f63 6b73 2929 293b 0a09 7d0a m_blocks)));..}. │ │ │ +0005af90: 0a09 696e 7420 6d65 726b 6c65 5f74 7265 ..int merkle_tre │ │ │ +0005afa0: 653a 3a6e 756d 5f70 6965 6365 7328 2920 e::num_pieces() │ │ │ +0005afb0: 636f 6e73 740a 097b 0a09 0969 6e74 2063 const..{...int c │ │ │ +0005afc0: 6f6e 7374 2070 7320 3d20 626c 6f63 6b73 onst ps = blocks │ │ │ +0005afd0: 5f70 6572 5f70 6965 6365 2829 3b0a 0909 _per_piece();... │ │ │ +0005afe0: 544f 5252 454e 545f 4153 5345 5254 2870 TORRENT_ASSERT(p │ │ │ +0005aff0: 7320 2667 743b 2030 293b 0a09 0972 6574 s > 0);...ret │ │ │ +0005b000: 7572 6e20 286d 5f6e 756d 5f62 6c6f 636b urn (m_num_block │ │ │ +0005b010: 7320 2b20 7073 202d 2031 2920 2667 743b s + ps - 1) > │ │ │ +0005b020: 2667 743b 206d 5f62 6c6f 636b 735f 7065 > m_blocks_pe │ │ │ +0005b030: 725f 7069 6563 655f 6c6f 673b 0a09 7d0a r_piece_log;..}. │ │ │ +0005b040: 0a09 696e 7420 6d65 726b 6c65 5f74 7265 ..int merkle_tre │ │ │ +0005b050: 653a 3a62 6c6f 636b 5f6c 6179 6572 5f73 e::block_layer_s │ │ │ +0005b060: 7461 7274 2829 2063 6f6e 7374 0a09 7b0a tart() const..{. │ │ │ +0005b070: 0909 696e 7420 636f 6e73 7420 6e75 6d5f ..int const num_ │ │ │ +0005b080: 6c65 6166 7320 3d20 6d65 726b 6c65 5f6e leafs = merkle_n │ │ │ +0005b090: 756d 5f6c 6561 6673 286d 5f6e 756d 5f62 um_leafs(m_num_b │ │ │ +0005b0a0: 6c6f 636b 7329 3b0a 0909 544f 5252 454e locks);...TORREN │ │ │ +0005b0b0: 545f 4153 5345 5254 286e 756d 5f6c 6561 T_ASSERT(num_lea │ │ │ +0005b0c0: 6673 2026 6774 3b20 3029 3b0a 0909 7265 fs > 0);...re │ │ │ +0005b0d0: 7475 726e 206d 6572 6b6c 655f 6669 7273 turn merkle_firs │ │ │ +0005b0e0: 745f 6c65 6166 286e 756d 5f6c 6561 6673 t_leaf(num_leafs │ │ │ +0005b0f0: 293b 0a09 7d0a 0a3c 2f70 7265 3e3c 2f74 );..}..

    relevanc │ │ │ +0005b130: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ +0005b170: 5f69 6e66 6f2e 6370 703a 3136 3335 3c2f _info.cpp:1635colle │ │ │ +0005b190: 6374 696f 6e73 3c2f 7464 3e3c 2f74 723e ctions │ │ │ +0005b1a0: 3c74 7220 6964 3d22 3231 3222 2073 7479 │ │ │ +0005b1d0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0005b1e0: 3c68 323e 636f 6c6c 6563 7469 6f6e 733c

    collections< │ │ │ +0005b1f0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ +0005b200: 6f72 7265 6e74 5f69 6e66 6f2e 6370 703a orrent_info.cpp: │ │ │ +0005b210: 3136 3335 3c2f 6834 3e3c 7072 6520 7374 1635

    
    │ │ │ +0005b280: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ +0005b290: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0
    .. │ │ │ +0005b2c0: 2f73 7263 2f74 6f72 7265 6e74 5f69 6e66 /src/torrent_inf │ │ │ +0005b2d0: 6f2e 6370 703a 3136 3336 3c2f 613e 3c2f o.cpp:1636similar

    simi │ │ │ +0005b340: 6c61 723c 2f68 323e 3c68 343e 2e2e 2f73 lar

    ../s │ │ │ +0005b350: 7263 2f74 6f72 7265 6e74 5f69 6e66 6f2e rc/torrent_info. │ │ │ +0005b360: 6370 703a 3136 3336 3c2f 6834 3e3c 7072 cpp:1636

    ...for (a │ │ │ +0005b3b0: 7574 6f20 636f 6e73 7426 616d 703b 2075 uto const& u │ │ │ +0005b3c0: 726c 203a 2061 7470 2e75 726c 5f73 6565 rl : atp.url_see │ │ │ +0005b3d0: 6473 290a 0909 7b0a 0909 0977 6562 5f73 ds)...{....web_s │ │ │ +0005b3e0: 6565 645f 656e 7472 7920 656e 7428 7572 eed_entry ent(ur │ │ │ +0005b3f0: 6c29 3b0a 0909 0965 6e74 2e74 7970 6520 l);....ent.type │ │ │ +0005b400: 3d20 7765 625f 7365 6564 5f65 6e74 7279 = web_seed_entry │ │ │ +0005b410: 3a3a 7572 6c5f 7365 6564 3b0a 0909 096d ::url_seed;....m │ │ │ +0005b420: 5f77 6562 5f73 6565 6473 2e70 7573 685f _web_seeds.push_ │ │ │ +0005b430: 6261 636b 2873 7464 3a3a 6d6f 7665 2865 back(std::move(e │ │ │ +0005b440: 6e74 2929 3b0a 0909 7d0a 0a09 0966 6f72 nt));...}....for │ │ │ +0005b450: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ +0005b460: 3b20 7572 6c20 3a20 6174 702e 6874 7470 ; url : atp.http │ │ │ +0005b470: 5f73 6565 6473 290a 0909 7b0a 0909 0977 _seeds)...{....w │ │ │ +0005b480: 6562 5f73 6565 645f 656e 7472 7920 656e eb_seed_entry en │ │ │ +0005b490: 7428 7572 6c29 3b0a 0909 0965 6e74 2e74 t(url);....ent.t │ │ │ +0005b4a0: 7970 6520 3d20 7765 625f 7365 6564 5f65 ype = web_seed_e │ │ │ +0005b4b0: 6e74 7279 3a3a 6874 7470 5f73 6565 643b ntry::http_seed; │ │ │ +0005b4c0: 0a09 0909 6d5f 7765 625f 7365 6564 732e ....m_web_seeds. │ │ │ +0005b4d0: 7075 7368 5f62 6163 6b28 7374 643a 3a6d push_back(std::m │ │ │ +0005b4e0: 6f76 6528 656e 7429 293b 0a09 097d 0a0a ove(ent));...}.. │ │ │ +0005b4f0: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ +0005b500: 7426 616d 703b 206e 203a 2061 7470 2e64 t& n : atp.d │ │ │ +0005b510: 6874 5f6e 6f64 6573 290a 0909 7b0a 0909 ht_nodes)...{... │ │ │ +0005b520: 096d 5f6e 6f64 6573 2e65 6d70 6c61 6365 .m_nodes.emplace │ │ │ +0005b530: 5f62 6163 6b28 6e29 3b0a 0909 7d0a 0a3c _back(n);...}..< │ │ │ +0005b540: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ +0005b550: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ +0005b560: 7769 6474 683d 2231 3030 2522 3e09 0972 width="100%">..r │ │ │ +0005b570: 6574 7572 6e20 7472 7565 3b0a 3c2f 6469 eturn true;..}...void torr │ │ │ +0005b590: 656e 745f 696e 666f 3a3a 6164 645f 7472 ent_info::add_tr │ │ │ +0005b5a0: 6163 6b65 7228 7374 643a 3a73 7472 696e acker(std::strin │ │ │ +0005b5b0: 6720 636f 6e73 7426 616d 703b 2075 726c g const& url │ │ │ +0005b5c0: 2c20 696e 7420 636f 6e73 7420 7469 6572 , int const tier │ │ │ +0005b5d0: 290a 097b 0a09 0961 6464 5f74 7261 636b )..{...add_track │ │ │ +0005b5e0: 6572 2875 726c 2c20 7469 6572 2c20 616e er(url, tier, an │ │ │ +0005b5f0: 6e6f 756e 6365 5f65 6e74 7279 3a3a 736f nounce_entry::so │ │ │ +0005b600: 7572 6365 5f63 6c69 656e 7429 3b0a 097d urce_client);..} │ │ │ +0005b610: 0a0a 0976 6f69 6420 746f 7272 656e 745f ...void torrent_ │ │ │ +0005b620: 696e 666f 3a3a 6164 645f 7472 6163 6b65 info::add_tracke │ │ │ +0005b630: 7228 7374 643a 3a73 7472 696e 6720 636f r(std::string co │ │ │ +0005b640: 6e73 7426 616d 703b 2075 726c 2c20 696e nst& url, in │ │ │ +0005b650: 7420 636f 6e73 7420 7469 6572 0a09 092c t const tier..., │ │ │ +0005b660: 2061 6e6e 6f75 6e63 655f 656e 7472 793a announce_entry: │ │ │ +0005b670: 3a74 7261 636b 6572 5f73 6f75 7263 6520 :tracker_source │ │ │ +0005b680: 636f 6e73 7420 736f 7572 6365 290a 097b const source)..{ │ │ │ +0005b690: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0005b6a0: 545f 5052 4543 4f4e 4428 2175 726c 2e65 T_PRECOND(!url.e │ │ │ +0005b6b0: 6d70 7479 2829 293b 0a09 0961 7574 6f20 mpty());...auto │ │ │ +0005b6c0: 636f 6e73 7420 6920 3d20 7374 643a 3a66 const i = std::f │ │ │ +0005b6d0: 696e 645f 6966 286d 5f75 726c 732e 6265 ind_if(m_urls.be │ │ │ +0005b6e0: 6769 6e28 292c 206d 5f75 726c 732e 656e gin(), m_urls.en │ │ │ +0005b6f0: 6428 290a 0909 092c 205b 2661 6d70 3b75 d()...., [&u │ │ │ +0005b700: 726c 5d28 616e 6e6f 756e 6365 5f65 6e74 rl](announce_ent │ │ │ +0005b710: 7279 2063 6f6e 7374 2661 6d70 3b20 6165 ry const& ae │ │ │ +0005b720: 2920 7b20 7265 7475 726e 2061 652e 7572 ) { return ae.ur │ │ │ +0005b730: 6c20 3d3d 2075 726c 3b20 7d29 3b0a 0909 l == url; });... │ │ │ +0005b740: 6966 2028 6920 213d 206d 5f75 726c 732e if (i != m_urls. │ │ │ +0005b750: 656e 6428 2929 2072 6574 7572 6e3b 0a09 end()) return;.. │ │ │ +0005b760: 0969 6620 2821 6c74 3a3a 6175 783a 3a69 .if (!lt::aux::i │ │ │ +0005b770: 735f 7661 6c69 645f 7472 6163 6b65 725f s_valid_tracker_ │ │ │ +0005b780: 7572 6c28 7572 6c29 2920 7265 7475 726e url(url)) return │ │ │ +0005b790: 3b0a 0a09 0961 6e6e 6f75 6e63 655f 656e ;....announce_en │ │ │ +0005b7a0: 7472 7920 6528 7572 6c29 3b0a 0909 652e try e(url);...e. │ │ │ +0005b7b0: 7469 6572 203d 2073 7464 3a3a 7569 6e74 tier = std::uint │ │ │ +0005b7c0: 385f 7428 7469 6572 293b 0a09 0965 2e73 8_t(tier);...e.s │ │ │ +0005b7d0: 6f75 7263 6520 3d20 736f 7572 6365 3b0a ource = source;. │ │ │ +0005b7e0: 0909 6d5f 7572 6c73 2e70 7573 685f 6261 ..m_urls.push_ba │ │ │ +0005b7f0: 636b 2865 293b 0a0a 0909 7374 643a 3a73 ck(e);....std::s │ │ │ +0005b800: 6f72 7428 6d5f 7572 6c73 2e62 6567 696e ort(m_urls.begin │ │ │ +0005b810: 2829 2c20 6d5f 7572 6c73 2e65 6e64 2829 (), m_urls.end() │ │ │ +0005b820: 0a09 0909 2c20 5b5d 2028 616e 6e6f 756e ...., [] (announ │ │ │ +0005b830: 6365 5f65 6e74 7279 2063 6f6e 7374 2661 ce_entry const&a │ │ │ +0005b840: 6d70 3b20 6c68 732c 2061 6e6e 6f75 6e63 mp; lhs, announc │ │ │ +0005b850: 655f 656e 7472 7920 636f 6e73 7426 616d e_entry const&am │ │ │ +0005b860: 703b 2072 6873 290a 0909 097b 2072 6574 p; rhs)....{ ret │ │ │ +0005b870: 7572 6e20 6c68 732e 7469 6572 2026 6c74 urn lhs.tier < │ │ │ +0005b880: 3b20 7268 732e 7469 6572 3b20 7d29 3b0a ; rhs.tier; });. │ │ │ +0005b890: 097d 0a0a 0976 6f69 6420 746f 7272 656e .}...void torren │ │ │ +0005b8a0: 745f 696e 666f 3a3a 636c 6561 725f 7472 t_info::clear_tr │ │ │ +0005b8b0: 6163 6b65 7273 2829 0a09 7b0a 0909 6d5f ackers()..{...m_ │ │ │ +0005b8c0: 7572 6c73 2e63 6c65 6172 2829 3b0a 097d urls.clear();..} │ │ │ +0005b8d0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ +0005b910: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +0005b940: 7263 2f63 7075 6964 2e63 7070 3a31 3134 rc/cpuid.cpp:114 │ │ │ +0005b950: 3c2f 613e 3c2f 7464 3e3c 7464 3e65 6e61 ena │ │ │ +0005b960: 626c 6520 7768 656e 2061 6172 6368 3634 ble when aarch64 │ │ │ +0005b970: 2069 7320 7265 616c 6c79 2074 6573 7465 is really teste │ │ │ +0005b980: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    e │ │ │ +0005b9d0: 6e61 626c 6520 7768 656e 2061 6172 6368 nable when aarch │ │ │ +0005b9e0: 3634 2069 7320 7265 616c 6c79 2074 6573 64 is really tes │ │ │ +0005b9f0: 7465 643c 2f68 323e 3c68 343e 2e2e 2f73 ted

    ../s │ │ │ +0005ba00: 7263 2f63 7075 6964 2e63 7070 3a31 3134 rc/cpuid.cpp:114 │ │ │ +0005ba10: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0005ba50: 626f 6f6c 2073 7570 706f 7274 735f 6d6d  bool supports_mm
    │ │ │ +0005ba60: 7828 2920 6e6f 6578 6365 7074 0a09 7b0a  x() noexcept..{.
    │ │ │ +0005ba70: 2369 6620 544f 5252 454e 545f 4841 535f  #if TORRENT_HAS_
    │ │ │ +0005ba80: 5353 450a 0909 7374 643a 3a75 696e 7433  SSE...std::uint3
    │ │ │ +0005ba90: 325f 7420 6370 7569 5b34 5d20 3d20 7b30  2_t cpui[4] = {0
    │ │ │ +0005baa0: 7d3b 0a09 0963 7075 6964 2863 7075 692c  };...cpuid(cpui,
    │ │ │ +0005bab0: 2031 293b 0a09 0972 6574 7572 6e20 2863   1);...return (c
    │ │ │ +0005bac0: 7075 695b 325d 2026 616d 703b 2028 3120  pui[2] & (1 
    │ │ │ +0005bad0: 266c 743b 266c 743b 2032 3329 2920 213d  << 23)) !=
    │ │ │ +0005bae0: 2030 3b0a 2365 6c73 650a 0909 7265 7475   0;.#else...retu
    │ │ │ +0005baf0: 726e 2066 616c 7365 3b0a 2365 6e64 6966  rn false;.#endif
    │ │ │ +0005bb00: 0a09 7d0a 0a09 626f 6f6c 2073 7570 706f  ..}...bool suppo
    │ │ │ +0005bb10: 7274 735f 6172 6d5f 6e65 6f6e 2829 206e  rts_arm_neon() n
    │ │ │ +0005bb20: 6f65 7863 6570 740a 097b 0a23 6966 2054  oexcept..{.#if T
    │ │ │ +0005bb30: 4f52 5245 4e54 5f48 4153 5f41 524d 5f4e  ORRENT_HAS_ARM_N
    │ │ │ +0005bb40: 454f 4e20 2661 6d70 3b26 616d 703b 2054  EON && T
    │ │ │ +0005bb50: 4f52 5245 4e54 5f48 4153 5f41 5558 560a  ORRENT_HAS_AUXV.
    │ │ │ +0005bb60: 2369 6620 6465 6669 6e65 6420 5f5f 6172  #if defined __ar
    │ │ │ +0005bb70: 6d5f 5f0a 0909 2f2f 7265 7475 726e 2028  m__...//return (
    │ │ │ +0005bb80: 6765 7461 7578 7661 6c28 4154 5f48 5743  getauxval(AT_HWC
    │ │ │ +0005bb90: 4150 2920 2661 6d70 3b20 4857 4341 505f  AP) & HWCAP_
    │ │ │ +0005bba0: 4e45 4f4e 293b 0a09 0972 6574 7572 6e20  NEON);...return 
    │ │ │ +0005bbb0: 2868 656c 7065 725f 6765 7461 7578 7661  (helper_getauxva
    │ │ │ +0005bbc0: 6c28 3136 2920 2661 6d70 3b20 2831 2026  l(16) & (1 &
    │ │ │ +0005bbd0: 6c74 3b26 6c74 3b20 3132 2929 3b0a 2365  lt;< 12));.#e
    │ │ │ +0005bbe0: 6c69 6620 6465 6669 6e65 6420 5f5f 6161  lif defined __aa
    │ │ │ +0005bbf0: 7263 6836 345f 5f0a 0909 2f2f 7265 7475  rch64__...//retu
    │ │ │ +0005bc00: 726e 2028 6765 7461 7578 7661 6c28 4154  rn (getauxval(AT
    │ │ │ +0005bc10: 5f48 5743 4150 2920 2661 6d70 3b20 4857  _HWCAP) & HW
    │ │ │ +0005bc20: 4341 505f 4153 494d 4429 3b0a 0909 2f2f  CAP_ASIMD);...//
    │ │ │ +0005bc30: 7265 7475 726e 2028 6765 7461 7578 7661  return (getauxva
    │ │ │ +0005bc40: 6c28 3136 2920 2661 6d70 3b20 2831 2026  l(16) & (1 &
    │ │ │ +0005bc50: 6c74 3b26 6c74 3b20 3129 293b 0a3c 6469  lt;< 1));...ret
    │ │ │ +0005bc90: 7572 6e20 6661 6c73 653b 0a3c 2f64 6976  urn false;.#endif.#else...
    │ │ │ +0005bcb0: 7265 7475 726e 2066 616c 7365 3b0a 2365  return false;.#e
    │ │ │ +0005bcc0: 6e64 6966 0a09 7d0a 0a09 626f 6f6c 2073  ndif..}...bool s
    │ │ │ +0005bcd0: 7570 706f 7274 735f 6172 6d5f 6372 6333  upports_arm_crc3
    │ │ │ +0005bce0: 3263 2829 206e 6f65 7863 6570 740a 097b  2c() noexcept..{
    │ │ │ +0005bcf0: 0a23 6966 2054 4f52 5245 4e54 5f48 4153  .#if TORRENT_HAS
    │ │ │ +0005bd00: 5f41 524d 5f43 5243 3332 2026 616d 703b  _ARM_CRC32 &
    │ │ │ +0005bd10: 2661 6d70 3b20 544f 5252 454e 545f 4841  & TORRENT_HA
    │ │ │ +0005bd20: 535f 4155 5856 0a23 6966 2064 6566 696e  S_AUXV.#if defin
    │ │ │ +0005bd30: 6564 2054 4f52 5245 4e54 5f46 4f52 4345  ed TORRENT_FORCE
    │ │ │ +0005bd40: 5f41 524d 5f43 5243 3332 0a09 0972 6574  _ARM_CRC32...ret
    │ │ │ +0005bd50: 7572 6e20 7472 7565 3b0a 2365 6c69 6620  urn true;.#elif 
    │ │ │ +0005bd60: 6465 6669 6e65 6420 5f5f 6172 6d5f 5f0a  defined __arm__.
    │ │ │ +0005bd70: 0909 2f2f 7265 7475 726e 2028 6765 7461  ..//return (geta
    │ │ │ +0005bd80: 7578 7661 6c28 4154 5f48 5743 4150 3229  uxval(AT_HWCAP2)
    │ │ │ +0005bd90: 2026 616d 703b 2048 5743 4150 325f 4352   & HWCAP2_CR
    │ │ │ +0005bda0: 4333 3229 3b0a 0909 7265 7475 726e 2028  C32);...return (
    │ │ │ +0005bdb0: 6865 6c70 6572 5f67 6574 6175 7876 616c  helper_getauxval
    │ │ │ +0005bdc0: 2832 3629 2026 616d 703b 2028 3120 266c  (26) & (1 &l
    │ │ │ +0005bdd0: 743b 266c 743b 2034 2929 3b0a 2365 6c69  t;< 4));.#eli
    │ │ │ +0005bde0: 6620 6465 6669 6e65 6420 5f5f 6161 7263  f defined __aarc
    │ │ │ +0005bdf0: 6836 345f 5f0a 0909 2f2f 7265 7475 726e  h64__...//return
    │ │ │ +0005be00: 2028 6765 7461 7578 7661 6c28 4154 5f48   (getauxval(AT_H
    │ │ │ +0005be10: 5743 4150 2920 2661 6d70 3b20 4857 4341  WCAP) & HWCA
    │ │ │ +0005be20: 505f 4352 4333 3229 3b0a 0909 7265 7475  P_CRC32);...retu
    │ │ │ +0005be30: 726e 2028 6865 6c70 6572 5f67 6574 6175  rn (helper_getau
    │ │ │ +0005be40: 7876 616c 2831 3629 2026 616d 703b 2028  xval(16) & (
    │ │ │ +0005be50: 3120 266c 743b 266c 743b 2037 2929 3b0a  1 << 7));.
    │ │ │ +0005be60: 2365 6e64 6966 0a23 656c 7365 0a09 0972  #endif.#else...r
    │ │ │ +0005be70: 6574 7572 6e20 6661 6c73 653b 0a23 656e  eturn false;.#en
    │ │ │ +0005be80: 6469 660a 097d 0a0a 2369 6664 6566 205f  dif..}..#ifdef _
    │ │ │ +0005be90: 5f63 6c61 6e67 5f5f 0a23 7072 6167 6d61  _clang__.#pragma
    │ │ │ +0005bea0: 2063 6c61 6e67 2064 6961 676e 6f73 7469   clang diagnosti
    │ │ │ +0005beb0: 6320 706f 700a 2365 6e64 6966 0a0a 7d20  c pop.#endif..} 
    │ │ │ +0005bec0: 2f2f 2061 6e6f 6e79 6d6f 7573 206e 616d  // anonymous nam
    │ │ │ +0005bed0: 6573 7061 6365 0a0a 0962 6f6f 6c20 636f  espace...bool co
    │ │ │ +0005bee0: 6e73 7420 7373 6534 325f 7375 7070 6f72  nst sse42_suppor
    │ │ │ +0005bef0: 7420 3d20 7375 7070 6f72 7473 5f73 7365  t = supports_sse
    │ │ │ +0005bf00: 3432 2829 3b0a 3c2f 7072 653e 3c2f 7464  42();.
    relevance │ │ │ +0005bf40: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0005bf50: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/session. │ │ │ +0005bf80: 6370 703a 3236 313c 2f61 3e3c 2f74 643e cpp:261 │ │ │ +0005bf90: 3c74 643e 7374 6172 7428 2920 7368 6f75 start() shou │ │ │ +0005bfa0: 6c64 206a 7573 7420 7573 6520 666c 6167 ld just use flag │ │ │ +0005bfb0: 7320 6f75 7420 6f66 2074 6865 2073 6573 s out of the ses │ │ │ +0005bfc0: 7369 6f6e 5f70 6172 616d 7320 6f62 6a65 sion_params obje │ │ │ +0005bfd0: 6374 2c3c 2f74 643e 3c2f 7472 3e3c 7472 ct,

    start() should │ │ │ +0005c030: 6a75 7374 2075 7365 2066 6c61 6773 206f just use flags o │ │ │ +0005c040: 7574 206f 6620 7468 6520 7365 7373 696f ut of the sessio │ │ │ +0005c050: 6e5f 7061 7261 6d73 206f 626a 6563 742c n_params object, │ │ │ +0005c060: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0005c070: 7365 7373 696f 6e2e 6370 703a 3236 313c session.cpp:261< │ │ │ +0005c080: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0005c0c0: 5345 545f 424f 4f4c 2872 6573 7472 6963  SET_BOOL(restric
    │ │ │ +0005c0d0: 745f 726f 7574 696e 675f 6970 7329 3b0a  t_routing_ips);.
    │ │ │ +0005c0e0: 0909 5345 545f 424f 4f4c 2872 6573 7472  ..SET_BOOL(restr
    │ │ │ +0005c0f0: 6963 745f 7365 6172 6368 5f69 7073 293b  ict_search_ips);
    │ │ │ +0005c100: 0a09 0953 4554 5f42 4f4f 4c28 6578 7465  ...SET_BOOL(exte
    │ │ │ +0005c110: 6e64 6564 5f72 6f75 7469 6e67 5f74 6162  nded_routing_tab
    │ │ │ +0005c120: 6c65 293b 0a09 0953 4554 5f42 4f4f 4c28  le);...SET_BOOL(
    │ │ │ +0005c130: 6167 6772 6573 7369 7665 5f6c 6f6f 6b75  aggressive_looku
    │ │ │ +0005c140: 7073 293b 0a09 0953 4554 5f42 4f4f 4c28  ps);...SET_BOOL(
    │ │ │ +0005c150: 7072 6976 6163 795f 6c6f 6f6b 7570 7329  privacy_lookups)
    │ │ │ +0005c160: 3b0a 0909 5345 545f 424f 4f4c 2865 6e66  ;...SET_BOOL(enf
    │ │ │ +0005c170: 6f72 6365 5f6e 6f64 655f 6964 293b 0a09  orce_node_id);..
    │ │ │ +0005c180: 0953 4554 5f42 4f4f 4c28 6967 6e6f 7265  .SET_BOOL(ignore
    │ │ │ +0005c190: 5f64 6172 6b5f 696e 7465 726e 6574 293b  _dark_internet);
    │ │ │ +0005c1a0: 0a09 0953 4554 5f49 4e54 2862 6c6f 636b  ...SET_INT(block
    │ │ │ +0005c1b0: 5f74 696d 656f 7574 293b 0a09 0953 4554  _timeout);...SET
    │ │ │ +0005c1c0: 5f49 4e54 2862 6c6f 636b 5f72 6174 656c  _INT(block_ratel
    │ │ │ +0005c1d0: 696d 6974 293b 0a09 0953 4554 5f42 4f4f  imit);...SET_BOO
    │ │ │ +0005c1e0: 4c28 7265 6164 5f6f 6e6c 7929 3b0a 0909  L(read_only);...
    │ │ │ +0005c1f0: 5345 545f 494e 5428 6974 656d 5f6c 6966  SET_INT(item_lif
    │ │ │ +0005c200: 6574 696d 6529 3b0a 0909 5345 545f 494e  etime);...SET_IN
    │ │ │ +0005c210: 5428 7570 6c6f 6164 5f72 6174 655f 6c69  T(upload_rate_li
    │ │ │ +0005c220: 6d69 7429 3b0a 0909 5345 545f 494e 5428  mit);...SET_INT(
    │ │ │ +0005c230: 7361 6d70 6c65 5f69 6e66 6f68 6173 6865  sample_infohashe
    │ │ │ +0005c240: 735f 696e 7465 7276 616c 293b 0a09 0953  s_interval);...S
    │ │ │ +0005c250: 4554 5f49 4e54 286d 6178 5f69 6e66 6f68  ET_INT(max_infoh
    │ │ │ +0005c260: 6173 6865 735f 7361 6d70 6c65 5f63 6f75  ashes_sample_cou
    │ │ │ +0005c270: 6e74 293b 0a23 756e 6465 6620 5345 545f  nt);.#undef SET_
    │ │ │ +0005c280: 424f 4f4c 0a23 756e 6465 6620 5345 545f  BOOL.#undef SET_
    │ │ │ +0005c290: 494e 540a 0909 7d0a 2365 6e64 6966 0a23  INT...}.#endif.#
    │ │ │ +0005c2a0: 656e 6469 660a 0a3c 6469 7620 7374 796c  endif..
    ..m_impl = │ │ │ +0005c2e0: 7374 643a 3a6d 616b 655f 7368 6172 6564 std::make_shared │ │ │ +0005c2f0: 266c 743b 6175 783a 3a73 6573 7369 6f6e <aux::session │ │ │ +0005c300: 5f69 6d70 6c26 6774 3b28 7374 643a 3a72 _impl>(std::r │ │ │ +0005c310: 6566 282a 696f 7329 0a3c 2f64 6976 3e09 ef(*ios).
    . │ │ │ +0005c320: 0909 2c20 7374 643a 3a6d 6f76 6528 7061 .., std::move(pa │ │ │ +0005c330: 7261 6d73 2e73 6574 7469 6e67 7329 0a09 rams.settings).. │ │ │ +0005c340: 0909 2c20 7374 643a 3a6d 6f76 6528 7061 .., std::move(pa │ │ │ +0005c350: 7261 6d73 2e64 6973 6b5f 696f 5f63 6f6e rams.disk_io_con │ │ │ +0005c360: 7374 7275 6374 6f72 290a 0909 092c 2066 structor)...., f │ │ │ +0005c370: 6c61 6773 293b 0a09 092a 7374 6174 6963 lags);...*static │ │ │ +0005c380: 5f63 6173 7426 6c74 3b73 6573 7369 6f6e _cast<session │ │ │ +0005c390: 5f68 616e 646c 652a 2667 743b 2874 6869 _handle*>(thi │ │ │ +0005c3a0: 7329 203d 2073 6573 7369 6f6e 5f68 616e s) = session_han │ │ │ +0005c3b0: 646c 6528 6d5f 696d 706c 293b 0a0a 2369 dle(m_impl);..#i │ │ │ +0005c3c0: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +0005c3d0: 5341 424c 455f 4558 5445 4e53 494f 4e53 SABLE_EXTENSIONS │ │ │ +0005c3e0: 0a09 0966 6f72 2028 6175 746f 2661 6d70 ...for (auto& │ │ │ +0005c3f0: 3b20 6578 7420 3a20 7061 7261 6d73 2e65 ; ext : params.e │ │ │ +0005c400: 7874 656e 7369 6f6e 7329 0a09 097b 0a09 xtensions)...{.. │ │ │ +0005c410: 0909 6578 742d 2667 743b 6c6f 6164 5f73 ..ext->load_s │ │ │ +0005c420: 7461 7465 2870 6172 616d 732e 6578 745f tate(params.ext_ │ │ │ +0005c430: 7374 6174 6529 3b0a 0909 096d 5f69 6d70 state);....m_imp │ │ │ +0005c440: 6c2d 2667 743b 6164 645f 7365 735f 6578 l->add_ses_ex │ │ │ +0005c450: 7465 6e73 696f 6e28 7374 643a 3a6d 6f76 tension(std::mov │ │ │ +0005c460: 6528 6578 7429 293b 0a09 097d 0a23 656e e(ext));...}.#en │ │ │ +0005c470: 6469 660a 0a23 6966 6e64 6566 2054 4f52 dif..#ifndef TOR │ │ │ +0005c480: 5245 4e54 5f44 4953 4142 4c45 5f44 4854 RENT_DISABLE_DHT │ │ │ +0005c490: 0a09 096d 5f69 6d70 6c2d 2667 743b 7365 ...m_impl->se │ │ │ +0005c4a0: 745f 6468 745f 7374 6174 6528 7374 643a t_dht_state(std: │ │ │ +0005c4b0: 3a6d 6f76 6528 7061 7261 6d73 2e64 6874 :move(params.dht │ │ │ +0005c4c0: 5f73 7461 7465 2929 3b0a 0a09 0954 4f52 _state));....TOR │ │ │ +0005c4d0: 5245 4e54 5f41 5353 4552 5428 7061 7261 RENT_ASSERT(para │ │ │ +0005c4e0: 6d73 2e64 6874 5f73 746f 7261 6765 5f63 ms.dht_storage_c │ │ │ +0005c4f0: 6f6e 7374 7275 6374 6f72 293b 0a09 096d onstructor);...m │ │ │ +0005c500: 5f69 6d70 6c2d 2667 743b 7365 745f 6468 _impl->set_dh │ │ │ +0005c510: 745f 7374 6f72 6167 6528 7374 643a 3a6d t_storage(std::m │ │ │ +0005c520: 6f76 6528 7061 7261 6d73 2e64 6874 5f73 ove(params.dht_s │ │ │ +0005c530: 746f 7261 6765 5f63 6f6e 7374 7275 6374 torage_construct │ │ │ +0005c540: 6f72 2929 3b0a 2365 6e64 6966 0a0a 0909 or));.#endif.... │ │ │ +0005c550: 6966 2028 2170 6172 616d 732e 6970 5f66 if (!params.ip_f │ │ │ +0005c560: 696c 7465 722e 656d 7074 7928 2929 0a09 ilter.empty()).. │ │ │ +0005c570: 097b 0a09 0909 7374 643a 3a73 6861 7265 .{....std::share │ │ │ +0005c580: 645f 7074 7226 6c74 3b69 705f 6669 6c74 d_ptr<ip_filt │ │ │ +0005c590: 6572 2667 743b 2063 6f70 7920 3d20 7374 er> copy = st │ │ │ +0005c5a0: 643a 3a6d 616b 655f 7368 6172 6564 266c d::make_shared&l │ │ │ +0005c5b0: 743b 6970 5f66 696c 7465 7226 6774 3b28 t;ip_filter>( │ │ │ +0005c5c0: 7374 643a 3a6d 6f76 6528 7061 7261 6d73 std::move(params │ │ │ +0005c5d0: 2e69 705f 6669 6c74 6572 2929 3b0a 0909 .ip_filter));... │ │ │ +0005c5e0: 096d 5f69 6d70 6c2d 2667 743b 7365 745f .m_impl->set_ │ │ │ +0005c5f0: 6970 5f66 696c 7465 7228 7374 643a 3a6d ip_filter(std::m │ │ │ +0005c600: 6f76 6528 636f 7079 2929 3b0a 0909 7d0a ove(copy));...}. │ │ │ +0005c610: 0a09 096d 5f69 6d70 6c2d 2667 743b 7374 ...m_impl->st │ │ │ +0005c620: 6172 745f 7365 7373 696f 6e28 293b 0a0a art_session();.. │ │ │ +0005c630: 0909 6966 2028 696e 7465 726e 616c 5f65 ..if (internal_e │ │ │ +0005c640: 7865 6375 746f 7229 0a09 097b 0a3c 2f70 xecutor)...{.

    re │ │ │ +0005c680: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/u │ │ │ +0005c6c0: 7470 5f73 6f63 6b65 745f 6d61 6e61 6765 tp_socket_manage │ │ │ +0005c6d0: 722e 6370 703a 3138 303c 2f61 3e3c 2f74 r.cpp:180this shoul │ │ │ +0005c6f0: 6420 6e6f 7420 6265 2068 6561 7020 616c d not be heap al │ │ │ +0005c700: 6c6f 6361 7465 642c 2073 6f63 6b65 7473 located, sockets │ │ │ +0005c710: 2073 686f 756c 6420 6265 206d 6f76 6162 should be movab │ │ │ +0005c720: 6c65 3c2f 7464 3e3c 2f74 723e 3c74 7220 le

    │ │ │ +0005c770: 7468 6973 2073 686f 756c 6420 6e6f 7420 this should not │ │ │ +0005c780: 6265 2068 6561 7020 616c 6c6f 6361 7465 be heap allocate │ │ │ +0005c790: 642c 2073 6f63 6b65 7473 2073 686f 756c d, sockets shoul │ │ │ +0005c7a0: 6420 6265 206d 6f76 6162 6c65 3c2f 6832 d be movable

    ../src/utp_ │ │ │ +0005c7c0: 736f 636b 6574 5f6d 616e 6167 6572 2e63 socket_manager.c │ │ │ +0005c7d0: 7070 3a31 3830 3c2f 6834 3e3c 7072 6520 pp:180

    .//..UTP_LO
    │ │ │ +0005c820: 4756 2822 696e 636f 6d69 6e67 2070 6163  GV("incoming pac
    │ │ │ +0005c830: 6b65 7420 6964 3a25 6420 736f 7572 6365  ket id:%d source
    │ │ │ +0005c840: 3a25 735c 6e22 2c20 6964 2c20 7072 696e  :%s\n", id, prin
    │ │ │ +0005c850: 745f 656e 6470 6f69 6e74 2865 7029 2e63  t_endpoint(ep).c
    │ │ │ +0005c860: 5f73 7472 2829 293b 0a0a 0909 6966 2028  _str());....if (
    │ │ │ +0005c870: 216d 5f73 6574 742e 6765 745f 626f 6f6c  !m_sett.get_bool
    │ │ │ +0005c880: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ +0005c890: 656e 6162 6c65 5f69 6e63 6f6d 696e 675f  enable_incoming_
    │ │ │ +0005c8a0: 7574 7029 290a 0909 0972 6574 7572 6e20  utp))....return 
    │ │ │ +0005c8b0: 6661 6c73 653b 0a0a 0909 2f2f 2069 6620  false;....// if 
    │ │ │ +0005c8c0: 6e6f 7420 666f 756e 642c 2073 6565 2069  not found, see i
    │ │ │ +0005c8d0: 6620 6974 2773 2061 2053 594e 2070 6163  f it's a SYN pac
    │ │ │ +0005c8e0: 6b65 742c 2069 6620 6974 2069 732c 0a09  ket, if it is,..
    │ │ │ +0005c8f0: 092f 2f20 6372 6561 7465 2061 206e 6577  .// create a new
    │ │ │ +0005c900: 2075 7470 5f73 7472 6561 6d0a 0909 6966   utp_stream...if
    │ │ │ +0005c910: 2028 7068 2d26 6774 3b67 6574 5f74 7970   (ph->get_typ
    │ │ │ +0005c920: 6528 2920 3d3d 2053 545f 5359 4e29 0a09  e() == ST_SYN)..
    │ │ │ +0005c930: 097b 0a09 0909 2f2f 2070 6f73 7369 626c  .{....// possibl
    │ │ │ +0005c940: 6520 5359 4e20 666c 6f6f 642e 204a 7573  e SYN flood. Jus
    │ │ │ +0005c950: 7420 6967 6e6f 7265 0a09 0909 6966 2028  t ignore....if (
    │ │ │ +0005c960: 696e 7428 6d5f 7574 705f 736f 636b 6574  int(m_utp_socket
    │ │ │ +0005c970: 732e 7369 7a65 2829 2920 2667 743b 206d  s.size()) > m
    │ │ │ +0005c980: 5f73 6574 742e 6765 745f 696e 7428 7365  _sett.get_int(se
    │ │ │ +0005c990: 7474 696e 6773 5f70 6163 6b3a 3a63 6f6e  ttings_pack::con
    │ │ │ +0005c9a0: 6e65 6374 696f 6e73 5f6c 696d 6974 2920  nections_limit) 
    │ │ │ +0005c9b0: 2a20 3229 0a09 0909 0972 6574 7572 6e20  * 2).....return 
    │ │ │ +0005c9c0: 6661 6c73 653b 0a0a 0909 0954 4f52 5245  false;.....TORRE
    │ │ │ +0005c9d0: 4e54 5f41 5353 4552 5428 6d5f 6e65 775f  NT_ASSERT(m_new_
    │ │ │ +0005c9e0: 636f 6e6e 6563 7469 6f6e 203d 3d20 2d31  connection == -1
    │ │ │ +0005c9f0: 293b 0a09 0909 2f2f 2063 7265 6174 6520  );....// create 
    │ │ │ +0005ca00: 7468 6520 6e65 7720 736f 636b 6574 2077  the new socket w
    │ │ │ +0005ca10: 6974 6820 7468 6973 2049 440a 0909 096d  ith this ID....m
    │ │ │ +0005ca20: 5f6e 6577 5f63 6f6e 6e65 6374 696f 6e20  _new_connection 
    │ │ │ +0005ca30: 3d20 6964 3b0a 0a2f 2f09 0909 5554 505f  = id;..//...UTP_
    │ │ │ +0005ca40: 4c4f 4756 2822 6e6f 7420 666f 756e 642c  LOGV("not found,
    │ │ │ +0005ca50: 206e 6577 2063 6f6e 6e65 6374 696f 6e20   new connection 
    │ │ │ +0005ca60: 6964 3a25 645c 6e22 2c20 6d5f 6e65 775f  id:%d\n", m_new_
    │ │ │ +0005ca70: 636f 6e6e 6563 7469 6f6e 293b 0a0a 3c64  connection);.....a
    │ │ │ +0005cab0: 7578 3a3a 736f 636b 6574 5f74 7970 6520  ux::socket_type 
    │ │ │ +0005cac0: 6328 6175 783a 3a69 6e73 7461 6e74 6961  c(aux::instantia
    │ │ │ +0005cad0: 7465 5f63 6f6e 6e65 6374 696f 6e28 6d5f  te_connection(m_
    │ │ │ +0005cae0: 696f 732c 2061 7578 3a3a 7072 6f78 795f  ios, aux::proxy_
    │ │ │ +0005caf0: 7365 7474 696e 6773 2829 2c20 6d5f 7373  settings(), m_ss
    │ │ │ +0005cb00: 6c5f 636f 6e74 6578 742c 2074 6869 732c  l_context, this,
    │ │ │ +0005cb10: 2074 7275 652c 2066 616c 7365 2929 3b0a   true, false));.
    │ │ │ +0005cb20: 3c2f 6469 763e 0a09 0909 7574 705f 7374  ....utp_st
    │ │ │ +0005cb30: 7265 616d 2a20 7374 7220 3d20 6e75 6c6c  ream* str = null
    │ │ │ +0005cb40: 7074 723b 0a23 6966 6465 6620 544f 5252  ptr;.#ifdef TORR
    │ │ │ +0005cb50: 454e 545f 5353 4c5f 5045 4552 530a 0909  ENT_SSL_PEERS...
    │ │ │ +0005cb60: 0969 6620 2869 735f 7373 6c28 6329 290a  .if (is_ssl(c)).
    │ │ │ +0005cb70: 0909 0909 7374 7220 3d20 2661 6d70 3b73  ....str = &s
    │ │ │ +0005cb80: 7464 3a3a 6765 7426 6c74 3b73 736c 5f73  td::get<ssl_s
    │ │ │ +0005cb90: 7472 6561 6d26 6c74 3b75 7470 5f73 7472  tream<utp_str
    │ │ │ +0005cba0: 6561 6d26 6774 3b26 6774 3b28 6329 2e6e  eam>>(c).n
    │ │ │ +0005cbb0: 6578 745f 6c61 7965 7228 293b 0a09 0909  ext_layer();....
    │ │ │ +0005cbc0: 656c 7365 0a23 656e 6469 660a 0909 0909  else.#endif.....
    │ │ │ +0005cbd0: 7374 7220 3d20 7374 643a 3a67 6574 5f69  str = std::get_i
    │ │ │ +0005cbe0: 6626 6c74 3b75 7470 5f73 7472 6561 6d26  f<utp_stream&
    │ │ │ +0005cbf0: 6774 3b28 2661 6d70 3b63 293b 0a0a 0909  gt;(&c);....
    │ │ │ +0005cc00: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +0005cc10: 7374 7229 3b0a 0909 0969 6e74 2063 6f6e  str);....int con
    │ │ │ +0005cc20: 7374 206d 7475 203d 206d 7475 5f66 6f72  st mtu = mtu_for
    │ │ │ +0005cc30: 5f64 6573 7428 6570 2e61 6464 7265 7373  _dest(ep.address
    │ │ │ +0005cc40: 2829 293b 0a09 0909 7374 722d 2667 743b  ());....str->
    │ │ │ +0005cc50: 6765 745f 696d 706c 2829 2d26 6774 3b69  get_impl()->i
    │ │ │ +0005cc60: 6e69 745f 6d74 7528 6d74 7529 3b0a 0909  nit_mtu(mtu);...
    │ │ │ +0005cc70: 0973 7472 2d26 6774 3b67 6574 5f69 6d70  .str->get_imp
    │ │ │ +0005cc80: 6c28 292d 2667 743b 6d5f 736f 636b 203d  l()->m_sock =
    │ │ │ +0005cc90: 2073 7464 3a3a 6d6f 7665 2873 6f63 6b65   std::move(socke
    │ │ │ +0005cca0: 7429 3b0a 0909 0962 6f6f 6c20 636f 6e73  t);....bool cons
    │ │ │ +0005ccb0: 7420 7265 7420 3d20 7374 722d 2667 743b  t ret = str->
    │ │ │ +0005ccc0: 6765 745f 696d 706c 2829 2d26 6774 3b69  get_impl()->i
    │ │ │ +0005ccd0: 6e63 6f6d 696e 675f 7061 636b 6574 2870  ncoming_packet(p
    │ │ │ +0005cce0: 2c20 6570 2c20 7265 6365 6976 655f 7469  , ep, receive_ti
    │ │ │ +0005ccf0: 6d65 293b 0a09 0909 6966 2028 2172 6574  me);....if (!ret
    │ │ │ +0005cd00: 2920 7265 7475 726e 2066 616c 7365 3b0a  ) return false;.
    │ │ │ +0005cd10: 0909 096d 5f6c 6173 745f 736f 636b 6574  ...m_last_socket
    │ │ │ +0005cd20: 203d 2073 7472 2d26 6774 3b67 6574 5f69   = str->get_i
    │ │ │ +0005cd30: 6d70 6c28 293b 0a09 0909 6d5f 6362 2873  mpl();....m_cb(s
    │ │ │ +0005cd40: 7464 3a3a 6d6f 7665 2863 2929 3b0a 0909  td::move(c));...
    │ │ │ +0005cd50: 092f 2f20 7468 6520 636f 6e6e 6563 7469  .// the connecti
    │ │ │ +0005cd60: 6f6e 206d 6f73 7420 6c69 6b65 6c79 2063  on most likely c
    │ │ │ +0005cd70: 6861 6e67 6564 2069 7473 2063 6f6e 6e65  hanged its conne
    │ │ │ +0005cd80: 6374 696f 6e20 4944 2068 6572 650a 0909  ction ID here...
    │ │ │ +0005cd90: 092f 2f20 7765 206e 6565 6420 746f 206d  .// we need to m
    │ │ │ +0005cda0: 6f76 6520 6974 2074 6f20 7468 6520 636f  ove it to the co
    │ │ │ +0005cdb0: 7272 6563 7420 4944 0a09 0909 7265 7475  rrect ID....retu
    │ │ │ +0005cdc0: 726e 2074 7275 653b 0a09 097d 0a0a 0909  rn true;...}....
    │ │ │ +0005cdd0: 6966 2028 7068 2d26 6774 3b67 6574 5f74  if (ph->get_t
    │ │ │ +0005cde0: 7970 6528 2920 3d3d 2053 545f 5245 5345  ype() == ST_RESE
    │ │ │ +0005cdf0: 5429 2072 6574 7572 6e20 6661 6c73 653b  T) return false;
    │ │ │ +0005ce00: 0a0a 0909 2f2f 2023 6572 726f 7220 7365  ....// #error se
    │ │ │ +0005ce10: 6e64 2072 6573 6574 0a0a 0909 7265 7475  nd reset....retu
    │ │ │ +0005ce20: 726e 2066 616c 7365 3b0a 097d 0a0a 0976  rn false;..}...v
    │ │ │ +0005ce30: 6f69 6420 7574 705f 736f 636b 6574 5f6d  oid utp_socket_m
    │ │ │ +0005ce40: 616e 6167 6572 3a3a 7375 6273 6372 6962  anager::subscrib
    │ │ │ +0005ce50: 655f 7772 6974 6162 6c65 2875 7470 5f73  e_writable(utp_s
    │ │ │ +0005ce60: 6f63 6b65 745f 696d 706c 2a20 7329 0a3c  ocket_impl* s).<
    │ │ │ +0005ce70: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +0005ce80: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +0005ce90: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +0005cea0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +0005ceb0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../src
    │ │ │ +0005cee0: 2f73 6d61 7274 5f62 616e 2e63 7070 3a31  /smart_ban.cpp:1
    │ │ │ +0005cef0: 3538 3c2f 613e 3c2f 7464 3e3c 7464 3e72  58r
    │ │ │ +0005cf00: 6570 6c61 6365 2077 6974 6820 7374 643a  eplace with std:
    │ │ │ +0005cf10: 3a65 7261 7365 5f69 6628 2920 6f6e 6365  :erase_if() once
    │ │ │ +0005cf20: 2077 6520 7265 7175 6972 6520 432b 2b32   we require C++2
    │ │ │ +0005cf30: 303c 2f74 643e 3c2f 7472 3e3c 7472 2069  0

    r │ │ │ +0005cf80: 6570 6c61 6365 2077 6974 6820 7374 643a eplace with std: │ │ │ +0005cf90: 3a65 7261 7365 5f69 6628 2920 6f6e 6365 :erase_if() once │ │ │ +0005cfa0: 2077 6520 7265 7175 6972 6520 432b 2b32 we require C++2 │ │ │ +0005cfb0: 303c 2f68 323e 3c68 343e 2e2e 2f73 7263 0

    ../src │ │ │ +0005cfc0: 2f73 6d61 7274 5f62 616e 2e63 7070 3a31 /smart_ban.cpp:1 │ │ │ +0005cfd0: 3538 3c2f 6834 3e3c 7072 6520 7374 796c 58

    ......, disk_in
    │ │ │ +0005d020: 7465 7266 6163 653a 3a66 6f72 6365 5f63  terface::force_c
    │ │ │ +0005d030: 6f70 7929 3b0a 0909 0909 7d0a 0a09 0909  opy);.....}.....
    │ │ │ +0005d040: 0972 2e73 7461 7274 202b 3d20 3136 2a31  .r.start += 16*1
    │ │ │ +0005d050: 3032 343b 0a09 0909 0973 697a 6520 2d3d  024;.....size -=
    │ │ │ +0005d060: 2031 362a 3130 3234 3b0a 0909 0909 722e   16*1024;.....r.
    │ │ │ +0005d070: 6c65 6e67 7468 203d 2073 7464 3a3a 6d69  length = std::mi
    │ │ │ +0005d080: 6e28 3136 2a31 3032 342c 2073 697a 6529  n(16*1024, size)
    │ │ │ +0005d090: 3b0a 0909 0909 2b2b 7062 2e62 6c6f 636b  ;.....++pb.block
    │ │ │ +0005d0a0: 5f69 6e64 6578 3b0a 0909 097d 0a09 0909  _index;....}....
    │ │ │ +0005d0b0: 544f 5252 454e 545f 4153 5345 5254 2873  TORRENT_ASSERT(s
    │ │ │ +0005d0c0: 697a 6520 266c 743b 3d20 3029 3b0a 0909  ize <= 0);...
    │ │ │ +0005d0d0: 7d0a 0a09 092f 2f20 6e6f 7420 6465 636c  }....// not decl
    │ │ │ +0005d0e0: 6172 6564 206f 6e20 746f 7272 656e 745f  ared on torrent_
    │ │ │ +0005d0f0: 706c 7567 696e 2028 776f 756c 6420 7265  plugin (would re
    │ │ │ +0005d100: 7175 6972 6520 616e 2041 4249 2d62 7265  quire an ABI-bre
    │ │ │ +0005d110: 616b 696e 6720 6e65 770a 0909 2f2f 2076  aking new...// v
    │ │ │ +0005d120: 6972 7475 616c 292e 2043 616c 6c65 6420  irtual). Called 
    │ │ │ +0005d130: 7669 6120 6120 646f 776e 6361 7374 2069  via a downcast i
    │ │ │ +0005d140: 6e20 746f 7272 656e 743a 3a70 6565 7273  n torrent::peers
    │ │ │ +0005d150: 5f65 7261 7365 6428 2920 e280 9420 7365  _erased() ... se
    │ │ │ +0005d160: 650a 0909 2f2f 2073 6d61 7274 5f62 616e  e...// smart_ban
    │ │ │ +0005d170: 5f6e 6f74 6966 795f 6572 6173 655f 7065  _notify_erase_pe
    │ │ │ +0005d180: 6572 7328 2920 6265 6c6f 770a 0909 766f  ers() below...vo
    │ │ │ +0005d190: 6964 206f 6e5f 6572 6173 655f 7065 6572  id on_erase_peer
    │ │ │ +0005d1a0: 7328 7370 616e 266c 743b 6175 783a 3a74  s(span<aux::t
    │ │ │ +0005d1b0: 6f72 7265 6e74 5f70 6565 722a 2063 6f6e  orrent_peer* con
    │ │ │ +0005d1c0: 7374 2667 743b 2070 6565 7273 290a 0909  st> peers)...
    │ │ │ +0005d1d0: 7b0a 0909 0969 6620 286d 5f62 6c6f 636b  {....if (m_block
    │ │ │ +0005d1e0: 5f68 6173 6865 732e 656d 7074 7928 2920  _hashes.empty() 
    │ │ │ +0005d1f0: 7c7c 2070 6565 7273 2e65 6d70 7479 2829  || peers.empty()
    │ │ │ +0005d200: 2920 7265 7475 726e 3b0a 0a09 0909 7374  ) return;.....st
    │ │ │ +0005d210: 643a 3a76 6563 746f 7226 6c74 3b61 7578  d::vector<aux
    │ │ │ +0005d220: 3a3a 746f 7272 656e 745f 7065 6572 2a26  ::torrent_peer*&
    │ │ │ +0005d230: 6774 3b20 6572 6173 6564 2870 6565 7273  gt; erased(peers
    │ │ │ +0005d240: 2e62 6567 696e 2829 2c20 7065 6572 732e  .begin(), peers.
    │ │ │ +0005d250: 656e 6428 2929 3b0a 0909 0973 7464 3a3a  end());....std::
    │ │ │ +0005d260: 736f 7274 2865 7261 7365 642e 6265 6769  sort(erased.begi
    │ │ │ +0005d270: 6e28 292c 2065 7261 7365 642e 656e 6428  n(), erased.end(
    │ │ │ +0005d280: 2929 3b0a 3c64 6976 2073 7479 6c65 3d22  ));.
    ...for (auto i │ │ │ +0005d2c0: 203d 206d 5f62 6c6f 636b 5f68 6173 6865 = m_block_hashe │ │ │ +0005d2d0: 732e 6265 6769 6e28 293b 2069 2021 3d20 s.begin(); i != │ │ │ +0005d2e0: 6d5f 626c 6f63 6b5f 6861 7368 6573 2e65 m_block_hashes.e │ │ │ +0005d2f0: 6e64 2829 3b29 0a3c 2f64 6976 3e09 0909 nd();).
    ... │ │ │ +0005d300: 7b0a 0909 0909 6966 2028 7374 643a 3a62 {.....if (std::b │ │ │ +0005d310: 696e 6172 795f 7365 6172 6368 2865 7261 inary_search(era │ │ │ +0005d320: 7365 642e 6265 6769 6e28 292c 2065 7261 sed.begin(), era │ │ │ +0005d330: 7365 642e 656e 6428 292c 2069 2d26 6774 sed.end(), i-> │ │ │ +0005d340: 3b73 6563 6f6e 642e 7065 6572 2929 0a09 ;second.peer)).. │ │ │ +0005d350: 0909 0909 6920 3d20 6d5f 626c 6f63 6b5f ....i = m_block_ │ │ │ +0005d360: 6861 7368 6573 2e65 7261 7365 2869 293b hashes.erase(i); │ │ │ +0005d370: 0a09 0909 0965 6c73 650a 0909 0909 092b .....else......+ │ │ │ +0005d380: 2b69 3b0a 0909 097d 0a09 097d 0a0a 0970 +i;....}...}...p │ │ │ +0005d390: 7269 7661 7465 3a0a 0a09 092f 2f20 7468 rivate:....// th │ │ │ +0005d3a0: 6973 2065 6e74 7279 2074 6965 7320 6120 is entry ties a │ │ │ +0005d3b0: 7370 6563 6966 6963 2062 6c6f 636b 2043 specific block C │ │ │ +0005d3c0: 5243 2074 6f0a 0909 2f2f 2061 2070 6565 RC to...// a pee │ │ │ +0005d3d0: 722e 0a09 0973 7472 7563 7420 626c 6f63 r....struct bloc │ │ │ +0005d3e0: 6b5f 656e 7472 790a 0909 7b0a 0909 0961 k_entry...{....a │ │ │ +0005d3f0: 7578 3a3a 746f 7272 656e 745f 7065 6572 ux::torrent_peer │ │ │ +0005d400: 2a20 7065 6572 3b0a 0909 0973 6861 315f * peer;....sha1_ │ │ │ +0005d410: 6861 7368 2064 6967 6573 743b 0a09 097d hash digest;...} │ │ │ +0005d420: 3b0a 0a09 0976 6f69 6420 6f6e 5f72 6561 ;....void on_rea │ │ │ +0005d430: 645f 6661 696c 6564 5f62 6c6f 636b 2870 d_failed_block(p │ │ │ +0005d440: 6965 6365 5f62 6c6f 636b 2063 6f6e 7374 iece_block const │ │ │ +0005d450: 2062 2c20 6164 6472 6573 7320 636f 6e73 b, address cons │ │ │ +0005d460: 7420 610a 0909 092c 2064 6973 6b5f 6275 t a...., disk_bu │ │ │ +0005d470: 6666 6572 5f68 6f6c 6465 7220 6275 6666 ffer_holder buff │ │ │ +0005d480: 6572 2c20 696e 7420 636f 6e73 7420 626c er, int const bl │ │ │ +0005d490: 6f63 6b5f 7369 7a65 0a09 0909 2c20 7374 ock_size...., st │ │ │ +0005d4a0: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ +0005d4b0: 7426 616d 703b 2065 7272 6f72 290a 0909 t& error)... │ │ │ +0005d4c0: 7b0a 0909 0954 4f52 5245 4e54 5f41 5353 {....TORRENT_ASS │ │ │ +0005d4d0: 4552 5428 6d5f 746f 7272 656e 742e 7365 ERT(m_torrent.se │ │ │ +0005d4e0: 7373 696f 6e28 292e 6973 5f73 696e 676c ssion().is_singl │ │ │ +0005d4f0: 655f 7468 7265 6164 2829 293b 0a0a 0909 e_thread());.... │ │ │ +0005d500: 092f 2f20 6967 6e6f 7265 2072 6561 6420 .// ignore read │ │ │ +0005d510: 6572 726f 7273 0a09 0909 6966 2028 6572 errors....if (er │ │ │ +0005d520: 726f 7229 2072 6574 7572 6e3b 0a0a 0909 ror) return;.... │ │ │ +0005d530: 0968 6173 6865 7220 683b 0a09 0909 682e .hasher h;....h. │ │ │ +0005d540: 7570 6461 7465 287b 6275 6666 6572 2e64 update({buffer.d │ │ │ +0005d550: 6174 6128 292c 2062 6c6f 636b 5f73 697a ata(), block_siz │ │ │ +0005d560: 657d 293b 0a0a 3c2f 7072 653e 3c2f 7464 e});..
    relevance │ │ │ +0005d5a0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0005d5b0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/tracker_ │ │ │ +0005d5e0: 6d61 6e61 6765 722e 6370 703a 3331 363c manager.cpp:316< │ │ │ +0005d5f0: 2f61 3e3c 2f74 643e 3c74 643e 696e 7472 /a>intr │ │ │ +0005d600: 6f64 7563 6520 6120 7365 7474 696e 6720 oduce a setting │ │ │ +0005d610: 666f 7220 6d61 785f 6f66 6665 7273 3c2f for max_offers

    intr │ │ │ +0005d670: 6f64 7563 6520 6120 7365 7474 696e 6720 oduce a setting │ │ │ +0005d680: 666f 7220 6d61 785f 6f66 6665 7273 3c2f for max_offers

    ../src/tr │ │ │ +0005d6a0: 6163 6b65 725f 6d61 6e61 6765 722e 6370 acker_manager.cp │ │ │ +0005d6b0: 703a 3331 363c 2f68 343e 3c70 7265 2073 p:316

    ....{......m
    │ │ │ +0005d700: 5f71 7565 7565 642e 7075 7368 5f62 6163  _queued.push_bac
    │ │ │ +0005d710: 6b28 7374 643a 3a6d 6f76 6528 636f 6e29  k(std::move(con)
    │ │ │ +0005d720: 293b 0a09 0909 097d 0a09 0909 096d 5f73  );.....}.....m_s
    │ │ │ +0005d730: 7461 7473 5f63 6f75 6e74 6572 732e 7365  tats_counters.se
    │ │ │ +0005d740: 745f 7661 6c75 6528 636f 756e 7465 7273  t_value(counters
    │ │ │ +0005d750: 3a3a 6e75 6d5f 7175 6575 6564 5f74 7261  ::num_queued_tra
    │ │ │ +0005d760: 636b 6572 5f61 6e6e 6f75 6e63 6573 2c20  cker_announces, 
    │ │ │ +0005d770: 7374 643a 3a69 6e74 3634 5f74 286d 5f71  std::int64_t(m_q
    │ │ │ +0005d780: 7565 7565 642e 7369 7a65 2829 2929 3b0a  ueued.size()));.
    │ │ │ +0005d790: 0909 097d 0a09 0909 7265 7475 726e 3b0a  ...}....return;.
    │ │ │ +0005d7a0: 0909 7d0a 0909 656c 7365 2069 6620 2870  ..}...else if (p
    │ │ │ +0005d7b0: 726f 746f 636f 6c20 3d3d 2022 7564 7022  rotocol == "udp"
    │ │ │ +0005d7c0: 290a 0909 7b0a 0909 0961 7574 6f20 636f  )...{....auto co
    │ │ │ +0005d7d0: 6e20 3d20 7374 643a 3a6d 616b 655f 7368  n = std::make_sh
    │ │ │ +0005d7e0: 6172 6564 266c 743b 6175 783a 3a75 6470  ared<aux::udp
    │ │ │ +0005d7f0: 5f74 7261 636b 6572 5f63 6f6e 6e65 6374  _tracker_connect
    │ │ │ +0005d800: 696f 6e26 6774 3b28 696f 732c 202a 7468  ion>(ios, *th
    │ │ │ +0005d810: 6973 2c20 7374 643a 3a6d 6f76 6528 7265  is, std::move(re
    │ │ │ +0005d820: 7129 2c20 6329 3b0a 0909 096d 5f75 6470  q), c);....m_udp
    │ │ │ +0005d830: 5f63 6f6e 6e73 5b63 6f6e 2d26 6774 3b74  _conns[con->t
    │ │ │ +0005d840: 7261 6e73 6163 7469 6f6e 5f69 6428 295d  ransaction_id()]
    │ │ │ +0005d850: 203d 2063 6f6e 3b0a 0909 0963 6f6e 2d26   = con;....con-&
    │ │ │ +0005d860: 6774 3b73 7461 7274 2829 3b0a 0909 0972  gt;start();....r
    │ │ │ +0005d870: 6574 7572 6e3b 0a20 2020 2020 2020 207d  eturn;.        }
    │ │ │ +0005d880: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +0005d890: 5f52 5443 0a20 2020 2020 2020 2065 6c73  _RTC.        els
    │ │ │ +0005d8a0: 6520 6966 2028 7072 6f74 6f63 6f6c 203d  e if (protocol =
    │ │ │ +0005d8b0: 3d20 2277 7322 207c 7c20 7072 6f74 6f63  = "ws" || protoc
    │ │ │ +0005d8c0: 6f6c 203d 3d20 2277 7373 2229 0a20 2020  ol == "wss").   
    │ │ │ +0005d8d0: 2020 2020 207b 0a09 0909 7374 643a 3a73       {....std::s
    │ │ │ +0005d8e0: 6861 7265 645f 7074 7226 6c74 3b72 6571  hared_ptr<req
    │ │ │ +0005d8f0: 7565 7374 5f63 616c 6c62 6163 6b26 6774  uest_callback>
    │ │ │ +0005d900: 3b20 6362 203d 2063 2e6c 6f63 6b28 293b  ; cb = c.lock();
    │ │ │ +0005d910: 0a09 0909 6966 2028 2163 6229 2072 6574  ....if (!cb) ret
    │ │ │ +0005d920: 7572 6e3b 0a0a 3c64 6976 2073 7479 6c65  urn;..
    ...const int │ │ │ +0005d960: 206d 6178 5f6f 6666 6572 7320 3d20 3130 max_offers = 10 │ │ │ +0005d970: 3b0a 3c2f 6469 763e 0909 0972 6571 2e6e ;.
    ...req.n │ │ │ +0005d980: 756d 5f77 616e 7420 3d20 7374 643a 3a6d um_want = std::m │ │ │ +0005d990: 696e 2872 6571 2e6e 756d 5f77 616e 742c in(req.num_want, │ │ │ +0005d9a0: 206d 6178 5f6f 6666 6572 7329 3b0a 0909 max_offers);... │ │ │ +0005d9b0: 0969 6620 2872 6571 2e6e 756d 5f77 616e .if (req.num_wan │ │ │ +0005d9c0: 7420 3d3d 2030 290a 0909 097b 0a09 0909 t == 0)....{.... │ │ │ +0005d9d0: 092f 2f20 7768 656e 2077 6527 7265 2073 .// when we're s │ │ │ +0005d9e0: 6875 7474 696e 6720 646f 776e 2c20 7765 hutting down, we │ │ │ +0005d9f0: 2064 6f6e 2774 2072 6561 6c6c 7920 7761 don't really wa │ │ │ +0005da00: 6e74 2074 6f0a 0909 0909 2f2f 2072 652d nt to.....// re- │ │ │ +0005da10: 6573 7461 626c 6973 6820 7468 6520 7065 establish the pe │ │ │ +0005da20: 7273 6973 7465 6e74 2077 6562 736f 636b rsistent websock │ │ │ +0005da30: 6574 2063 6f6e 6e65 6374 696f 6e20 6a75 et connection ju │ │ │ +0005da40: 7374 2074 6f0a 0909 0909 2f2f 2061 6e6e st to.....// ann │ │ │ +0005da50: 6f75 6e63 6520 2273 746f 7070 6564 222c ounce "stopped", │ │ │ +0005da60: 2061 6e64 2061 6476 6572 7469 7365 2030 and advertise 0 │ │ │ +0005da70: 206f 6666 6572 732e 2049 7420 6d61 7920 offers. It may │ │ │ +0005da80: 6861 6e67 0a09 0909 092f 2f20 7368 7574 hang.....// shut │ │ │ +0005da90: 646f 776e 2e0a 0909 0909 706f 7374 2869 down......post(i │ │ │ +0005daa0: 6f73 2c20 7374 643a 3a62 696e 6428 2661 os, std::bind(&a │ │ │ +0005dab0: 6d70 3b72 6571 7565 7374 5f63 616c 6c62 mp;request_callb │ │ │ +0005dac0: 6163 6b3a 3a74 7261 636b 6572 5f72 6571 ack::tracker_req │ │ │ +0005dad0: 7565 7374 5f65 7272 6f72 2c20 6362 2c20 uest_error, cb, │ │ │ +0005dae0: 7374 643a 3a6d 6f76 6528 7265 7129 0a09 std::move(req).. │ │ │ +0005daf0: 0909 0909 2c20 6572 726f 7273 3a3a 746f ...., errors::to │ │ │ +0005db00: 7272 656e 745f 6162 6f72 7465 642c 206f rrent_aborted, o │ │ │ +0005db10: 7065 7261 7469 6f6e 5f74 3a3a 636f 6e6e peration_t::conn │ │ │ +0005db20: 6563 740a 0909 0909 092c 2022 222c 2073 ect......, "", s │ │ │ +0005db30: 6563 6f6e 6473 3332 2830 2929 293b 0a09 econds32(0)));.. │ │ │ +0005db40: 0909 0972 6574 7572 6e3b 0a09 0909 7d0a ...return;....}. │ │ │ +0005db50: 0909 0963 622d 2667 743b 6765 6e65 7261 ...cb->genera │ │ │ +0005db60: 7465 5f72 7463 5f6f 6666 6572 7328 7265 te_rtc_offers(re │ │ │ +0005db70: 712e 6e75 6d5f 7761 6e74 0a09 0909 092c q.num_want....., │ │ │ +0005db80: 205b 7468 6973 2c20 2661 6d70 3b69 6f73 [this, &ios │ │ │ +0005db90: 2c20 7265 7175 6573 7420 3d20 7374 643a , request = std: │ │ │ +0005dba0: 3a6d 6f76 6528 7265 7129 2c20 635d 2865 :move(req), c](e │ │ │ +0005dbb0: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ +0005dbc0: 616d 703b 2065 630a 0909 0909 092c 2073 amp; ec......, s │ │ │ +0005dbd0: 7464 3a3a 7665 6374 6f72 266c 743b 6175 td::vector<au │ │ │ +0005dbe0: 783a 3a72 7463 5f6f 6666 6572 2667 743b x::rtc_offer> │ │ │ +0005dbf0: 206f 6666 6572 7329 206d 7574 6162 6c65 offers) mutable │ │ │ +0005dc00: 0a09 0909 7b0a 0909 0909 6966 2028 2165 ....{.....if (!e │ │ │ +0005dc10: 6329 2072 6571 7565 7374 2e6f 6666 6572 c) request.offer │ │ │ +0005dc20: 7320 3d20 7374 643a 3a6d 6f76 6528 6f66 s = std::move(of │ │ │ +0005dc30: 6665 7273 293b 0a0a 0909 0909 6175 746f fers);......auto │ │ │ +0005dc40: 2069 7420 3d20 6d5f 7765 6273 6f63 6b65 it = m_websocke │ │ │ +0005dc50: 745f 636f 6e6e 732e 6669 6e64 2872 6571 t_conns.find(req │ │ │ +0005dc60: 7565 7374 2e75 726c 293b 0a09 0909 0969 uest.url);.....i │ │ │ +0005dc70: 6620 2869 7420 213d 206d 5f77 6562 736f f (it != m_webso │ │ │ +0005dc80: 636b 6574 5f63 6f6e 6e73 2e65 6e64 2829 cket_conns.end() │ │ │ +0005dc90: 2026 616d 703b 2661 6d70 3b20 6974 2d26 && it-& │ │ │ +0005dca0: 6774 3b73 6563 6f6e 642d 2667 743b 6973 gt;second->is │ │ │ +0005dcb0: 5f73 7461 7274 6564 2829 2920 7b0a 0909 _started()) {... │ │ │ +0005dcc0: 0909 0969 742d 2667 743b 7365 636f 6e64 ...it->second │ │ │ +0005dcd0: 2d26 6774 3b71 7565 7565 5f72 6571 7565 ->queue_reque │ │ │ +0005dce0: 7374 2873 7464 3a3a 6d6f 7665 2872 6571 st(std::move(req │ │ │ +0005dcf0: 7565 7374 292c 2063 293b 0a09 0909 097d uest), c);.....} │ │ │ +0005dd00: 2065 6c73 6520 7b0a 0909 0909 0961 7574 else {......aut │ │ │ +0005dd10: 6f20 636f 6e20 3d20 7374 643a 3a6d 616b o con = std::mak │ │ │ +0005dd20: 655f 7368 6172 6564 266c 743b 6175 783a e_shared<aux: │ │ │ +0005dd30: 3a77 6562 736f 636b 6574 5f74 7261 636b :websocket_track │ │ │ +0005dd40: 6572 5f63 6f6e 6e65 6374 696f 6e26 6774 er_connection> │ │ │ +0005dd50: 3b28 0a09 0909 0909 0909 696f 732c 202a ;(........ios, * │ │ │ +0005dd60: 7468 6973 2c20 7374 643a 3a6d 6f76 6528 this, std::move( │ │ │ +0005dd70: 7265 7175 6573 7429 2c20 6329 3b0a 0909 request), c);... │ │ │ +0005dd80: 0909 0963 6f6e 2d26 6774 3b73 7461 7274 ...con->start │ │ │ +0005dd90: 2829 3b0a 0909 0909 096d 5f77 6562 736f ();......m_webso │ │ │ +0005dda0: 636b 6574 5f63 6f6e 6e73 5b72 6571 7565 cket_conns[reque │ │ │ +0005ddb0: 7374 2e75 726c 5d20 3d20 636f 6e3b 0a09 st.url] = con;.. │ │ │ +0005ddc0: 0909 097d 0a09 0909 7d29 3b0a 0909 0972 ...}....});....r │ │ │ +0005ddd0: 6574 7572 6e3b 0a20 2020 2020 2020 207d eturn;. } │ │ │ +0005dde0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0005de20: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0
    ../s │ │ │ +0005de50: 7263 2f75 745f 6d65 7461 6461 7461 2e63 rc/ut_metadata.c │ │ │ +0005de60: 7070 3a32 3536 3c2f 613e 3c2f 7464 3e3c pp:256< │ │ │ +0005de70: 7464 3e77 6520 7265 616c 6c79 206e 6565 td>we really nee │ │ │ +0005de80: 6420 746f 2069 6e63 7265 6d65 6e74 2074 d to increment t │ │ │ +0005de90: 6865 2072 6566 636f 756e 7465 7220 6f6e he refcounter on │ │ │ +0005dea0: 2074 6865 2074 6f72 7265 6e74 2077 6869 the torrent whi │ │ │ +0005deb0: 6c65 2074 6869 7320 6275 6666 6572 2069 le this buffer i │ │ │ +0005dec0: 7320 7374 696c 6c20 696e 2074 6865 2070 s still in the p │ │ │ +0005ded0: 6565 7227 7320 7365 6e64 2062 7566 6665 eer's send buffe │ │ │ +0005dee0: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    w │ │ │ +0005df30: 6520 7265 616c 6c79 206e 6565 6420 746f e really need to │ │ │ +0005df40: 2069 6e63 7265 6d65 6e74 2074 6865 2072 increment the r │ │ │ +0005df50: 6566 636f 756e 7465 7220 6f6e 2074 6865 efcounter on the │ │ │ +0005df60: 2074 6f72 7265 6e74 0a77 6869 6c65 2074 torrent.while t │ │ │ +0005df70: 6869 7320 6275 6666 6572 2069 7320 7374 his buffer is st │ │ │ +0005df80: 696c 6c20 696e 2074 6865 2070 6565 7227 ill in the peer' │ │ │ +0005df90: 7320 7365 6e64 2062 7566 6665 723c 2f68 s send buffer

    ../src/ut_ │ │ │ +0005dfb0: 6d65 7461 6461 7461 2e63 7070 3a32 3536 metadata.cpp:256 │ │ │ +0005dfc0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0005e000: 0909 0969 6e74 2063 6f6e 7374 206f 6666  ...int const off
    │ │ │ +0005e010: 7365 7420 3d20 7069 6563 6520 2a20 3136  set = piece * 16
    │ │ │ +0005e020: 202a 2031 3032 343b 0a09 0909 096d 6574   * 1024;.....met
    │ │ │ +0005e030: 6164 6174 6120 3d20 6d5f 7470 2e6d 6574  adata = m_tp.met
    │ │ │ +0005e040: 6164 6174 6128 292e 6461 7461 2829 202b  adata().data() +
    │ │ │ +0005e050: 206f 6666 7365 743b 0a09 0909 096d 6574   offset;.....met
    │ │ │ +0005e060: 6164 6174 615f 7069 6563 655f 7369 7a65  adata_piece_size
    │ │ │ +0005e070: 203d 2073 7464 3a3a 6d69 6e28 0a09 0909   = std::min(....
    │ │ │ +0005e080: 0909 696e 7428 6d5f 7470 2e6d 6574 6164  ..int(m_tp.metad
    │ │ │ +0005e090: 6174 6128 292e 7369 7a65 2829 2920 2d20  ata().size()) - 
    │ │ │ +0005e0a0: 6f66 6673 6574 2c20 3136 202a 2031 3032  offset, 16 * 102
    │ │ │ +0005e0b0: 3429 3b0a 0909 0909 544f 5252 454e 545f  4);.....TORRENT_
    │ │ │ +0005e0c0: 4153 5345 5254 286d 6574 6164 6174 615f  ASSERT(metadata_
    │ │ │ +0005e0d0: 7069 6563 655f 7369 7a65 2026 6774 3b20  piece_size > 
    │ │ │ +0005e0e0: 3029 3b0a 0909 0909 544f 5252 454e 545f  0);.....TORRENT_
    │ │ │ +0005e0f0: 4153 5345 5254 286f 6666 7365 7420 2667  ASSERT(offset &g
    │ │ │ +0005e100: 743b 3d20 3029 3b0a 0909 0909 544f 5252  t;= 0);.....TORR
    │ │ │ +0005e110: 454e 545f 4153 5345 5254 286f 6666 7365  ENT_ASSERT(offse
    │ │ │ +0005e120: 7420 2b20 6d65 7461 6461 7461 5f70 6965  t + metadata_pie
    │ │ │ +0005e130: 6365 5f73 697a 6520 266c 743b 3d20 6d5f  ce_size <= m_
    │ │ │ +0005e140: 7470 2e6d 6574 6164 6174 6128 292e 7369  tp.metadata().si
    │ │ │ +0005e150: 7a65 2829 293b 0a09 0909 7d0a 0a09 0909  ze());....}.....
    │ │ │ +0005e160: 6368 6172 206d 7367 5b32 3030 5d3b 0a09  char msg[200];..
    │ │ │ +0005e170: 0909 6368 6172 2a20 6865 6164 6572 203d  ..char* header =
    │ │ │ +0005e180: 206d 7367 3b0a 0909 0963 6861 722a 2070   msg;....char* p
    │ │ │ +0005e190: 203d 2026 616d 703b 6d73 675b 365d 3b0a   = &msg[6];.
    │ │ │ +0005e1a0: 0909 0969 6e74 2063 6f6e 7374 206c 656e  ...int const len
    │ │ │ +0005e1b0: 203d 2062 656e 636f 6465 2870 2c20 6529   = bencode(p, e)
    │ │ │ +0005e1c0: 3b0a 0909 0969 6e74 2063 6f6e 7374 2074  ;....int const t
    │ │ │ +0005e1d0: 6f74 616c 5f73 697a 6520 3d20 3220 2b20  otal_size = 2 + 
    │ │ │ +0005e1e0: 6c65 6e20 2b20 6d65 7461 6461 7461 5f70  len + metadata_p
    │ │ │ +0005e1f0: 6965 6365 5f73 697a 653b 0a09 0909 6e61  iece_size;....na
    │ │ │ +0005e200: 6d65 7370 6163 6520 696f 203d 2061 7578  mespace io = aux
    │ │ │ +0005e210: 3b0a 0909 0969 6f3a 3a77 7269 7465 5f75  ;....io::write_u
    │ │ │ +0005e220: 696e 7433 3228 746f 7461 6c5f 7369 7a65  int32(total_size
    │ │ │ +0005e230: 2c20 6865 6164 6572 293b 0a09 0909 696f  , header);....io
    │ │ │ +0005e240: 3a3a 7772 6974 655f 7569 6e74 3828 6175  ::write_uint8(au
    │ │ │ +0005e250: 783a 3a62 745f 7065 6572 5f63 6f6e 6e65  x::bt_peer_conne
    │ │ │ +0005e260: 6374 696f 6e3a 3a6d 7367 5f65 7874 656e  ction::msg_exten
    │ │ │ +0005e270: 6465 642c 2068 6561 6465 7229 3b0a 0909  ded, header);...
    │ │ │ +0005e280: 0969 6f3a 3a77 7269 7465 5f75 696e 7438  .io::write_uint8
    │ │ │ +0005e290: 286d 5f6d 6573 7361 6765 5f69 6e64 6578  (m_message_index
    │ │ │ +0005e2a0: 2c20 6865 6164 6572 293b 0a0a 0909 096d  , header);.....m
    │ │ │ +0005e2b0: 5f70 632e 7365 6e64 5f62 7566 6665 7228  _pc.send_buffer(
    │ │ │ +0005e2c0: 7b6d 7367 2c20 6c65 6e20 2b20 367d 293b  {msg, len + 6});
    │ │ │ +0005e2d0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0005e300: 0909 6966 2028 6d65 7461 6461 7461 5f70 ..if (metadata_p │ │ │ +0005e310: 6965 6365 5f73 697a 6529 0a3c 2f64 6976 iece_size).
    ...{.....m_pc.a │ │ │ +0005e330: 7070 656e 645f 636f 6e73 745f 7365 6e64 ppend_const_send │ │ │ +0005e340: 5f62 7566 6665 7228 0a09 0909 0909 7370 _buffer(......sp │ │ │ +0005e350: 616e 266c 743b 6368 6172 2667 743b 2863 an<char>(c │ │ │ +0005e360: 6f6e 7374 5f63 6173 7426 6c74 3b63 6861 onst_cast<cha │ │ │ +0005e370: 722a 2667 743b 286d 6574 6164 6174 6129 r*>(metadata) │ │ │ +0005e380: 2c20 6d65 7461 6461 7461 5f70 6965 6365 , metadata_piece │ │ │ +0005e390: 5f73 697a 6529 2c20 6d65 7461 6461 7461 _size), metadata │ │ │ +0005e3a0: 5f70 6965 6365 5f73 697a 6529 3b0a 0909 _piece_size);... │ │ │ +0005e3b0: 097d 0a0a 0909 096d 5f70 632e 7374 6174 .}.....m_pc.stat │ │ │ +0005e3c0: 735f 636f 756e 7465 7273 2829 2e69 6e63 s_counters().inc │ │ │ +0005e3d0: 5f73 7461 7473 5f63 6f75 6e74 6572 2863 _stats_counter(c │ │ │ +0005e3e0: 6f75 6e74 6572 733a 3a6e 756d 5f6f 7574 ounters::num_out │ │ │ +0005e3f0: 676f 696e 675f 6578 7465 6e64 6564 293b going_extended); │ │ │ +0005e400: 0a09 0909 6d5f 7063 2e73 7461 7473 5f63 ....m_pc.stats_c │ │ │ +0005e410: 6f75 6e74 6572 7328 292e 696e 635f 7374 ounters().inc_st │ │ │ +0005e420: 6174 735f 636f 756e 7465 7228 636f 756e ats_counter(coun │ │ │ +0005e430: 7465 7273 3a3a 6e75 6d5f 6f75 7467 6f69 ters::num_outgoi │ │ │ +0005e440: 6e67 5f6d 6574 6164 6174 6129 3b0a 0909 ng_metadata);... │ │ │ +0005e450: 7d0a 0a09 0962 6f6f 6c20 6f6e 5f65 7874 }....bool on_ext │ │ │ +0005e460: 656e 6465 6428 696e 7420 636f 6e73 7420 ended(int const │ │ │ +0005e470: 6c65 6e67 7468 0a09 0909 2c20 696e 7420 length...., int │ │ │ +0005e480: 636f 6e73 7420 6578 7465 6e64 6564 5f6d const extended_m │ │ │ +0005e490: 7367 2c20 7370 616e 266c 743b 6368 6172 sg, span<char │ │ │ +0005e4a0: 2063 6f6e 7374 2667 743b 2062 6f64 7929 const> body) │ │ │ +0005e4b0: 206f 7665 7272 6964 650a 0909 7b0a 0909 override...{... │ │ │ +0005e4c0: 0969 6620 2865 7874 656e 6465 645f 6d73 .if (extended_ms │ │ │ +0005e4d0: 6720 213d 2032 2920 7265 7475 726e 2066 g != 2) return f │ │ │ +0005e4e0: 616c 7365 3b0a 0909 0969 6620 286d 5f6d alse;....if (m_m │ │ │ +0005e4f0: 6573 7361 6765 5f69 6e64 6578 203d 3d20 essage_index == │ │ │ +0005e500: 3029 2072 6574 7572 6e20 6661 6c73 653b 0) return false; │ │ │ +0005e510: 0a0a 0909 0969 6620 286c 656e 6774 6820 .....if (length │ │ │ +0005e520: 2667 743b 2031 3720 2a20 3130 3234 290a > 17 * 1024). │ │ │ +0005e530: 0909 097b 0a23 6966 6e64 6566 2054 4f52 ...{.#ifndef TOR │ │ │ +0005e540: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ +0005e550: 4749 4e47 0a09 0909 096d 5f70 632e 7065 GING.....m_pc.pe │ │ │ +0005e560: 6572 5f6c 6f67 2870 6565 725f 6c6f 675f er_log(peer_log_ │ │ │ +0005e570: 616c 6572 743a 3a69 6e63 6f6d 696e 675f alert::incoming_ │ │ │ +0005e580: 6d65 7373 6167 652c 2070 6565 725f 6c6f message, peer_lo │ │ │ +0005e590: 675f 616c 6572 743a 3a75 745f 6d65 7461 g_alert::ut_meta │ │ │ +0005e5a0: 6461 7461 0a09 0909 0909 2c20 2270 6163 data......, "pac │ │ │ +0005e5b0: 6b65 7420 746f 6f20 6269 6720 2564 222c ket too big %d", │ │ │ +0005e5c0: 206c 656e 6774 6829 3b0a 2365 6e64 6966 length);.#endif │ │ │ +0005e5d0: 0a09 0909 096d 5f70 632e 6469 7363 6f6e .....m_pc.discon │ │ │ +0005e5e0: 6e65 6374 2865 7272 6f72 733a 3a69 6e76 nect(errors::inv │ │ │ +0005e5f0: 616c 6964 5f6d 6574 6164 6174 615f 6d65 alid_metadata_me │ │ │ +0005e600: 7373 6167 652c 206f 7065 7261 7469 6f6e ssage, operation │ │ │ +0005e610: 5f74 3a3a 6269 7474 6f72 7265 6e74 2c20 _t::bittorrent, │ │ │ +0005e620: 7065 6572 5f63 6f6e 6e65 6374 696f 6e5f peer_connection_ │ │ │ +0005e630: 696e 7465 7266 6163 653a 3a70 6565 725f interface::peer_ │ │ │ +0005e640: 6572 726f 7229 3b0a 0909 0909 7265 7475 error);.....retu │ │ │ +0005e650: 726e 2074 7275 653b 0a09 0909 7d0a 0a09 rn true;....}... │ │ │ +0005e660: 0909 6966 2028 216d 5f70 632e 7061 636b ..if (!m_pc.pack │ │ │ +0005e670: 6574 5f66 696e 6973 6865 6428 2929 2072 et_finished()) r │ │ │ +0005e680: 6574 7572 6e20 7472 7565 3b0a 0a09 0909 eturn true;..... │ │ │ +0005e690: 6572 726f 725f 636f 6465 2065 633b 0a09 error_code ec;.. │ │ │ +0005e6a0: 0909 6264 6563 6f64 655f 6e6f 6465 206d ..bdecode_node m │ │ │ +0005e6b0: 7367 203d 2062 6465 636f 6465 2862 6f64 sg = bdecode(bod │ │ │ +0005e6c0: 792c 2065 6329 3b0a 0909 0969 6620 286d y, ec);....if (m │ │ │ +0005e6d0: 7367 2e74 7970 6528 2920 213d 2062 6465 sg.type() != bde │ │ │ +0005e6e0: 636f 6465 5f6e 6f64 653a 3a64 6963 745f code_node::dict_ │ │ │ +0005e6f0: 7429 0a3c 2f70 7265 3e3c 2f74 643e 3c2f t).
    │ │ │ +0005e720: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0005e730: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +0005e760: 2f73 7263 2f64 6973 6162 6c65 645f 6469 /src/disabled_di │ │ │ +0005e770: 736b 5f69 6f2e 6370 703a 3833 3c2f 613e sk_io.cpp:83 │ │ │ +0005e780: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ +0005e790: 6420 6265 206e 6963 6520 746f 2072 6574 d be nice to ret │ │ │ +0005e7a0: 7572 6e20 6120 7661 6c69 6420 6861 7368 urn a valid hash │ │ │ +0005e7b0: 206f 6620 7a65 726f 6573 2068 6572 653c of zeroes here< │ │ │ +0005e7c0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ +0005e810: 776f 756c 6420 6265 206e 6963 6520 746f would be nice to │ │ │ +0005e820: 2072 6574 7572 6e20 6120 7661 6c69 6420 return a valid │ │ │ +0005e830: 6861 7368 206f 6620 7a65 726f 6573 2068 hash of zeroes h │ │ │ +0005e840: 6572 653c 2f68 323e 3c68 343e 2e2e 2f73 ere

    ../s │ │ │ +0005e850: 7263 2f64 6973 6162 6c65 645f 6469 736b rc/disabled_disk │ │ │ +0005e860: 5f69 6f2e 6370 703a 3833 3c2f 6834 3e3c _io.cpp:83

    < │ │ │ +0005e870: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0005e880: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0005e890: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0005e8a0: 7820 2364 6464 3b22 3e09 097d 293b 0a09 x #ddd;">..});.. │ │ │ +0005e8b0: 7d0a 0a09 626f 6f6c 2061 7379 6e63 5f77 }...bool async_w │ │ │ +0005e8c0: 7269 7465 2873 746f 7261 6765 5f69 6e64 rite(storage_ind │ │ │ +0005e8d0: 6578 5f74 0a09 092c 2070 6565 725f 7265 ex_t..., peer_re │ │ │ +0005e8e0: 7175 6573 7420 636f 6e73 7426 616d 703b quest const& │ │ │ +0005e8f0: 2072 0a09 092c 2063 6861 7220 636f 6e73 r..., char cons │ │ │ +0005e900: 742a 2c20 7374 643a 3a73 6861 7265 645f t*, std::shared_ │ │ │ +0005e910: 7074 7226 6c74 3b64 6973 6b5f 6f62 7365 ptr<disk_obse │ │ │ +0005e920: 7276 6572 2667 743b 0a09 092c 2073 7464 rver>..., std │ │ │ +0005e930: 3a3a 6675 6e63 7469 6f6e 266c 743b 766f ::function<vo │ │ │ +0005e940: 6964 2873 746f 7261 6765 5f65 7272 6f72 id(storage_error │ │ │ +0005e950: 2063 6f6e 7374 2661 6d70 3b29 2667 743b const&)> │ │ │ +0005e960: 2068 616e 646c 6572 0a09 092c 2064 6973 handler..., dis │ │ │ +0005e970: 6b5f 6a6f 625f 666c 6167 735f 7429 206f k_job_flags_t) o │ │ │ +0005e980: 7665 7272 6964 650a 097b 0a09 0954 4f52 verride..{...TOR │ │ │ +0005e990: 5245 4e54 5f41 5353 4552 5428 722e 6c65 RENT_ASSERT(r.le │ │ │ +0005e9a0: 6e67 7468 2026 6c74 3b3d 2064 6566 6175 ngth <= defau │ │ │ +0005e9b0: 6c74 5f62 6c6f 636b 5f73 697a 6529 3b0a lt_block_size);. │ │ │ +0005e9c0: 0909 544f 5252 454e 545f 554e 5553 4544 ..TORRENT_UNUSED │ │ │ +0005e9d0: 2872 293b 0a0a 0909 706f 7374 286d 5f69 (r);....post(m_i │ │ │ +0005e9e0: 6f73 2c20 5b68 203d 2073 7464 3a3a 6d6f os, [h = std::mo │ │ │ +0005e9f0: 7665 2868 616e 646c 6572 295d 207b 2068 ve(handler)] { h │ │ │ +0005ea00: 2873 746f 7261 6765 5f65 7272 6f72 7b7d (storage_error{} │ │ │ +0005ea10: 293b 207d 293b 0a09 0972 6574 7572 6e20 ); });...return │ │ │ +0005ea20: 6661 6c73 653b 0a09 7d0a 0a09 766f 6964 false;..}...void │ │ │ +0005ea30: 2061 7379 6e63 5f68 6173 6828 7374 6f72 async_hash(stor │ │ │ +0005ea40: 6167 655f 696e 6465 785f 740a 0909 2c20 age_index_t..., │ │ │ +0005ea50: 7069 6563 655f 696e 6465 785f 7420 7069 piece_index_t pi │ │ │ +0005ea60: 6563 652c 2073 7061 6e26 6c74 3b73 6861 ece, span<sha │ │ │ +0005ea70: 3235 365f 6861 7368 2667 743b 2c20 6469 256_hash>, di │ │ │ +0005ea80: 736b 5f6a 6f62 5f66 6c61 6773 5f74 0a09 sk_job_flags_t.. │ │ │ +0005ea90: 092c 2073 7464 3a3a 6675 6e63 7469 6f6e ., std::function │ │ │ +0005eaa0: 266c 743b 766f 6964 2870 6965 6365 5f69 <void(piece_i │ │ │ +0005eab0: 6e64 6578 5f74 2c20 7368 6131 5f68 6173 ndex_t, sha1_has │ │ │ +0005eac0: 6820 636f 6e73 7426 616d 703b 2c20 7374 h const&, st │ │ │ +0005ead0: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ +0005eae0: 7426 616d 703b 2926 6774 3b20 6861 6e64 t&)> hand │ │ │ +0005eaf0: 6c65 7229 206f 7665 7272 6964 650a 097b ler) override..{ │ │ │ +0005eb00: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ +0005eb30: 0970 6f73 7428 6d5f 696f 732c 205b 6820 .post(m_ios, [h │ │ │ +0005eb40: 3d20 7374 643a 3a6d 6f76 6528 6861 6e64 = std::move(hand │ │ │ +0005eb50: 6c65 7229 2c20 7069 6563 655d 207b 2068 ler), piece] { h │ │ │ +0005eb60: 2870 6965 6365 2c20 7368 6131 5f68 6173 (piece, sha1_has │ │ │ +0005eb70: 687b 7d2c 2073 746f 7261 6765 5f65 7272 h{}, storage_err │ │ │ +0005eb80: 6f72 7b7d 293b 207d 293b 0a3c 2f64 6976 or{}); });.
    .}...void async │ │ │ +0005eba0: 5f68 6173 6832 2873 746f 7261 6765 5f69 _hash2(storage_i │ │ │ +0005ebb0: 6e64 6578 5f74 2c20 7069 6563 655f 696e ndex_t, piece_in │ │ │ +0005ebc0: 6465 785f 7420 7069 6563 652c 2069 6e74 dex_t piece, int │ │ │ +0005ebd0: 0a09 092c 2064 6973 6b5f 6a6f 625f 666c ..., disk_job_fl │ │ │ +0005ebe0: 6167 735f 740a 0909 2c20 7374 643a 3a66 ags_t..., std::f │ │ │ +0005ebf0: 756e 6374 696f 6e26 6c74 3b76 6f69 6428 unction<void( │ │ │ +0005ec00: 7069 6563 655f 696e 6465 785f 742c 2073 piece_index_t, s │ │ │ +0005ec10: 6861 3235 365f 6861 7368 2063 6f6e 7374 ha256_hash const │ │ │ +0005ec20: 2661 6d70 3b2c 2073 746f 7261 6765 5f65 &, storage_e │ │ │ +0005ec30: 7272 6f72 2063 6f6e 7374 2661 6d70 3b29 rror const&) │ │ │ +0005ec40: 2667 743b 2068 616e 646c 6572 2920 6f76 > handler) ov │ │ │ +0005ec50: 6572 7269 6465 0a09 7b0a 0909 706f 7374 erride..{...post │ │ │ +0005ec60: 286d 5f69 6f73 2c20 5b68 203d 2073 7464 (m_ios, [h = std │ │ │ +0005ec70: 3a3a 6d6f 7665 2868 616e 646c 6572 292c ::move(handler), │ │ │ +0005ec80: 2070 6965 6365 5d28 2920 7b20 6828 7069 piece]() { h(pi │ │ │ +0005ec90: 6563 652c 2073 6861 3235 365f 6861 7368 ece, sha256_hash │ │ │ +0005eca0: 7b7d 2c20 7374 6f72 6167 655f 6572 726f {}, storage_erro │ │ │ +0005ecb0: 727b 7d29 3b20 7d29 3b0a 097d 0a0a 0976 r{}); });..}...v │ │ │ +0005ecc0: 6f69 6420 6173 796e 635f 6d6f 7665 5f73 oid async_move_s │ │ │ +0005ecd0: 746f 7261 6765 2873 746f 7261 6765 5f69 torage(storage_i │ │ │ +0005ece0: 6e64 6578 5f74 0a09 092c 2073 7464 3a3a ndex_t..., std:: │ │ │ +0005ecf0: 7374 7269 6e67 2070 2c20 6d6f 7665 5f66 string p, move_f │ │ │ +0005ed00: 6c61 6773 5f74 0a09 092c 2073 7464 3a3a lags_t..., std:: │ │ │ +0005ed10: 6675 6e63 7469 6f6e 266c 743b 766f 6964 function<void │ │ │ +0005ed20: 2873 7461 7475 735f 742c 2073 7464 3a3a (status_t, std:: │ │ │ +0005ed30: 7374 7269 6e67 2063 6f6e 7374 2661 6d70 string const& │ │ │ +0005ed40: 3b2c 2073 746f 7261 6765 5f65 7272 6f72 ;, storage_error │ │ │ +0005ed50: 2063 6f6e 7374 2661 6d70 3b29 2667 743b const&)> │ │ │ +0005ed60: 2068 616e 646c 6572 2920 6f76 6572 7269 handler) overri │ │ │ +0005ed70: 6465 0a09 7b0a 0909 706f 7374 286d 5f69 de..{...post(m_i │ │ │ +0005ed80: 6f73 2c20 5b68 203d 2073 7464 3a3a 6d6f os, [h = std::mo │ │ │ +0005ed90: 7665 2868 616e 646c 6572 292c 2070 6174 ve(handler), pat │ │ │ +0005eda0: 6820 3d20 7374 643a 3a6d 6f76 6528 7029 h = std::move(p) │ │ │ +0005edb0: 5d20 2829 206d 7574 6162 6c65 0a09 0909 ] () mutable.... │ │ │ +0005edc0: 7b20 6828 7374 6174 7573 5f74 7b7d 2c20 { h(status_t{}, │ │ │ +0005edd0: 7374 643a 3a6d 6f76 6528 7061 7468 292c std::move(path), │ │ │ +0005ede0: 2073 746f 7261 6765 5f65 7272 6f72 7b7d storage_error{} │ │ │ +0005edf0: 293b 207d 293b 0a09 7d0a 0a09 766f 6964 ); });..}...void │ │ │ +0005ee00: 2061 7379 6e63 5f72 656c 6561 7365 5f66 async_release_f │ │ │ +0005ee10: 696c 6573 2873 746f 7261 6765 5f69 6e64 iles(storage_ind │ │ │ +0005ee20: 6578 5f74 2c20 7374 643a 3a66 756e 6374 ex_t, std::funct │ │ │ +0005ee30: 696f 6e26 6c74 3b76 6f69 6428 2926 6774 ion<void()> │ │ │ +0005ee40: 3b20 6861 6e64 6c65 7229 206f 7665 7272 ; handler) overr │ │ │ +0005ee50: 6964 650a 097b 0a09 0970 6f73 7428 6d5f ide..{...post(m_ │ │ │ +0005ee60: 696f 732c 205b 6820 3d20 7374 643a 3a6d ios, [h = std::m │ │ │ +0005ee70: 6f76 6528 6861 6e64 6c65 7229 5d20 7b20 ove(handler)] { │ │ │ +0005ee80: 6828 293b 207d 293b 0a09 7d0a 0a09 766f h(); });..}...vo │ │ │ +0005ee90: 6964 2061 7379 6e63 5f64 656c 6574 655f id async_delete_ │ │ │ +0005eea0: 6669 6c65 7328 7374 6f72 6167 655f 696e files(storage_in │ │ │ +0005eeb0: 6465 785f 740a 0909 2c20 7265 6d6f 7665 dex_t..., remove │ │ │ +0005eec0: 5f66 6c61 6773 5f74 2c20 7374 643a 3a66 _flags_t, std::f │ │ │ +0005eed0: 756e 6374 696f 6e26 6c74 3b76 6f69 6428 unction<void( │ │ │ +0005eee0: 7374 6f72 6167 655f 6572 726f 7220 636f storage_error co │ │ │ +0005eef0: 6e73 7426 616d 703b 2926 6774 3b20 6861 nst&)> ha │ │ │ +0005ef00: 6e64 6c65 7229 206f 7665 7272 6964 650a ndler) override. │ │ │ +0005ef10: 097b 0a09 0970 6f73 7428 6d5f 696f 732c .{...post(m_ios, │ │ │ +0005ef20: 205b 6820 3d20 7374 643a 3a6d 6f76 6528 [h = std::move( │ │ │ +0005ef30: 6861 6e64 6c65 7229 5d20 7b20 6828 7374 handler)] { h(st │ │ │ +0005ef40: 6f72 6167 655f 6572 726f 727b 7d29 3b20 orage_error{}); │ │ │ +0005ef50: 7d29 3b0a 097d 0a0a 0976 6f69 6420 6173 });..}...void as │ │ │ +0005ef60: 796e 635f 6368 6563 6b5f 6669 6c65 7328 ync_check_files( │ │ │ +0005ef70: 7374 6f72 6167 655f 696e 6465 785f 740a storage_index_t. │ │ │ +0005ef80: 0909 2c20 6164 645f 746f 7272 656e 745f .., add_torrent_ │ │ │ +0005ef90: 7061 7261 6d73 2063 6f6e 7374 2a0a 3c2f params const*.r │ │ │ +0005efd0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0005efe0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0005f010: 6469 736b 5f63 6163 6865 2e63 7070 3a37 disk_cache.cpp:7 │ │ │ +0005f020: 3035 3c2f 613e 3c2f 7464 3e3c 7464 3e70 05p │ │ │ +0005f030: 6173 7320 7468 6520 626c 6f63 6b20 6f66 ass the block of │ │ │ +0005f040: 6673 6574 2061 7320 6120 7061 7261 6d65 fset as a parame │ │ │ +0005f050: 7465 7220 696e 7374 6561 6420 6f66 2063 ter instead of c │ │ │ +0005f060: 6f6d 7075 7469 6e67 2069 7420 6c69 6b65 omputing it like │ │ │ +0005f070: 2074 6869 733c 2f74 643e 3c2f 7472 3e3c this< │ │ │ +0005f080: 7472 2069 643d 2232 3231 2220 7374 796c tr id="221" styl │ │ │ +0005f090: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0005f0a0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0005f0b0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0005f0c0: 6832 3e70 6173 7320 7468 6520 626c 6f63 h2>pass the bloc │ │ │ +0005f0d0: 6b20 6f66 6673 6574 2061 7320 6120 7061 k offset as a pa │ │ │ +0005f0e0: 7261 6d65 7465 7220 696e 7374 6561 6420 rameter instead │ │ │ +0005f0f0: 6f66 2063 6f6d 7075 7469 6e67 2069 7420 of computing it │ │ │ +0005f100: 6c69 6b65 2074 6869 733c 2f68 323e 3c68 like this

    ../src/disk_ca │ │ │ +0005f120: 6368 652e 6370 703a 3730 353c 2f68 343e che.cpp:705 │ │ │ +0005f130: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    templa
    │ │ │ +0005f170: 7465 2026 6c74 3b74 7970 656e 616d 6520  te <typename 
    │ │ │ +0005f180: 4974 6572 2c20 7479 7065 6e61 6d65 2056  Iter, typename V
    │ │ │ +0005f190: 6965 7726 6774 3b0a 4974 6572 2064 6973  iew>.Iter dis
    │ │ │ +0005f1a0: 6b5f 6361 6368 653a 3a66 6c75 7368 5f70  k_cache::flush_p
    │ │ │ +0005f1b0: 6965 6365 5f69 6d70 6c28 5669 6577 2661  iece_impl(View&a
    │ │ │ +0005f1c0: 6d70 3b20 7669 6577 2c0a 0949 7465 7220  mp; view,..Iter 
    │ │ │ +0005f1d0: 7069 6563 655f 6974 6572 2c0a 0973 7464  piece_iter,..std
    │ │ │ +0005f1e0: 3a3a 6675 6e63 7469 6f6e 266c 743b 696e  ::function<in
    │ │ │ +0005f1f0: 7428 6269 7466 6965 6c64 2661 6d70 3b2c  t(bitfield&,
    │ │ │ +0005f200: 2073 7061 6e26 6c74 3b64 6973 6b5f 6a6f   span<disk_jo
    │ │ │ +0005f210: 622a 2063 6f6e 7374 2667 743b 2926 6774  b* const>)>
    │ │ │ +0005f220: 3b20 636f 6e73 7426 616d 703b 2066 2c0a  ; const& f,.
    │ │ │ +0005f230: 0973 7464 3a3a 756e 6971 7565 5f6c 6f63  .std::unique_loc
    │ │ │ +0005f240: 6b26 6c74 3b73 7464 3a3a 6d75 7465 7826  k<std::mutex&
    │ │ │ +0005f250: 6774 3b26 616d 703b 206c 2c0a 0973 7061  gt;& l,..spa
    │ │ │ +0005f260: 6e26 6c74 3b63 6163 6865 645f 626c 6f63  n<cached_bloc
    │ │ │ +0005f270: 6b5f 656e 7472 7926 6774 3b20 636f 6e73  k_entry> cons
    │ │ │ +0005f280: 7420 626c 6f63 6b73 2c0a 0973 7464 3a3a  t blocks,..std::
    │ │ │ +0005f290: 6675 6e63 7469 6f6e 266c 743b 766f 6964  function<void
    │ │ │ +0005f2a0: 286a 6f62 7175 6575 655f 742c 2064 6973  (jobqueue_t, dis
    │ │ │ +0005f2b0: 6b5f 6a6f 622a 2926 6774 3b20 636c 6561  k_job*)> clea
    │ │ │ +0005f2c0: 725f 7069 6563 655f 6675 6e29 0a7b 0a09  r_piece_fun).{..
    │ │ │ +0005f2d0: 544f 5252 454e 545f 4153 5345 5254 286c  TORRENT_ASSERT(l
    │ │ │ +0005f2e0: 2e6f 776e 735f 6c6f 636b 2829 293b 0a09  .owns_lock());..
    │ │ │ +0005f2f0: 2f2f 2077 6865 6e20 2262 6c6f 636b 7322  // when "blocks"
    │ │ │ +0005f300: 2063 6f76 6572 7320 7468 6520 7768 6f6c   covers the whol
    │ │ │ +0005f310: 6520 7069 6563 6520 7765 2063 616e 2075  e piece we can u
    │ │ │ +0005f320: 7365 2074 6865 206d 6169 6e74 6169 6e65  se the maintaine
    │ │ │ +0005f330: 6420 7065 722d 7069 6563 650a 092f 2f20  d per-piece..// 
    │ │ │ +0005f340: 636f 756e 7465 7220 696e 7374 6561 6420  counter instead 
    │ │ │ +0005f350: 6f66 2073 6361 6e6e 696e 672e 2041 2073  of scanning. A s
    │ │ │ +0005f360: 7562 7370 616e 2028 7468 6520 6368 6561  ubspan (the chea
    │ │ │ +0005f370: 702d 666c 7573 6820 7061 7373 2920 7374  p-flush pass) st
    │ │ │ +0005f380: 696c 6c20 6e65 6564 730a 092f 2f20 746f  ill needs..// to
    │ │ │ +0005f390: 2063 6f75 6e74 2074 6865 2077 7269 7465   count the write
    │ │ │ +0005f3a0: 206a 6f62 7320 7769 7468 696e 2074 6861   jobs within tha
    │ │ │ +0005f3b0: 7420 7261 6e67 652e 0a09 696e 7420 636f  t range...int co
    │ │ │ +0005f3c0: 6e73 7420 6e75 6d5f 626c 6f63 6b73 203d  nst num_blocks =
    │ │ │ +0005f3d0: 2028 626c 6f63 6b73 2e73 697a 6528 2920   (blocks.size() 
    │ │ │ +0005f3e0: 3d3d 2070 6965 6365 5f69 7465 722d 2667  == piece_iter-&g
    │ │ │ +0005f3f0: 743b 626c 6f63 6b73 5f69 6e5f 7069 6563  t;blocks_in_piec
    │ │ │ +0005f400: 6528 2929 0a09 093f 2069 6e74 2870 6965  e())...? int(pie
    │ │ │ +0005f410: 6365 5f69 7465 722d 2667 743b 6e75 6d5f  ce_iter->num_
    │ │ │ +0005f420: 6a6f 6273 290a 0909 3a20 636f 756e 745f  jobs)...: count_
    │ │ │ +0005f430: 6a6f 6273 2862 6c6f 636b 7329 3b0a 0954  jobs(blocks);..T
    │ │ │ +0005f440: 4f52 5245 4e54 5f41 5353 4552 5428 6e75  ORRENT_ASSERT(nu
    │ │ │ +0005f450: 6d5f 626c 6f63 6b73 203d 3d20 636f 756e  m_blocks == coun
    │ │ │ +0005f460: 745f 6a6f 6273 2862 6c6f 636b 7329 293b  t_jobs(blocks));
    │ │ │ +0005f470: 0a09 6966 2028 6e75 6d5f 626c 6f63 6b73  ..if (num_blocks
    │ │ │ +0005f480: 2026 6c74 3b3d 2030 290a 0909 7265 7475   <= 0)...retu
    │ │ │ +0005f490: 726e 2073 7464 3a3a 6e65 7874 2870 6965  rn std::next(pie
    │ │ │ +0005f4a0: 6365 5f69 7465 7229 3b0a 0a09 2f2f 2062  ce_iter);...// b
    │ │ │ +0005f4b0: 6c6f 636b 7320 6d61 7920 6265 2061 2073  locks may be a s
    │ │ │ +0005f4c0: 7562 7370 616e 206f 6620 616c 6c20 7468  ubspan of all th
    │ │ │ +0005f4d0: 6520 626c 6f63 6b73 2069 6e20 7468 6520  e blocks in the 
    │ │ │ +0005f4e0: 7069 6563 652c 2073 6f20 7768 656e 2063  piece, so when c
    │ │ │ +0005f4f0: 6f6d 7061 7269 6e67 2066 6c75 7368 6564  omparing flushed
    │ │ │ +0005f500: 5f63 7572 736f 7220 616e 6420 6861 7368  _cursor and hash
    │ │ │ +0005f510: 6572 5f63 7572 736f 722c 2077 6520 6e65  er_cursor, we ne
    │ │ │ +0005f520: 6564 2074 6f20 6164 6420 7468 6520 6f66  ed to add the of
    │ │ │ +0005f530: 6673 6574 2e0a 3c64 6976 2073 7479 6c65  fset..
    .int const b │ │ │ +0005f570: 6c6f 636b 5f6f 6666 7365 7420 3d20 7374 lock_offset = st │ │ │ +0005f580: 6174 6963 5f63 6173 7426 6c74 3b69 6e74 atic_cast<int │ │ │ +0005f590: 2667 743b 2862 6c6f 636b 732e 6461 7461 >(blocks.data │ │ │ +0005f5a0: 2829 202d 2070 6965 6365 5f69 7465 722d () - piece_iter- │ │ │ +0005f5b0: 2667 743b 6765 745f 626c 6f63 6b73 2829 >get_blocks() │ │ │ +0005f5c0: 2e64 6174 6128 2929 3b0a 3c2f 6469 763e .data());.
    │ │ │ +0005f5d0: 0a09 7669 6577 2e6d 6f64 6966 7928 7069 ..view.modify(pi │ │ │ +0005f5e0: 6563 655f 6974 6572 2c20 5b5d 2863 6163 ece_iter, [](cac │ │ │ +0005f5f0: 6865 645f 7069 6563 655f 656e 7472 7926 hed_piece_entry& │ │ │ +0005f600: 616d 703b 2065 2920 7b0a 0909 544f 5252 amp; e) {...TORR │ │ │ +0005f610: 454e 545f 4153 5345 5254 2821 2865 2e66 ENT_ASSERT(!(e.f │ │ │ +0005f620: 6c61 6773 2026 616d 703b 2063 6163 6865 lags & cache │ │ │ +0005f630: 645f 7069 6563 655f 656e 7472 793a 3a66 d_piece_entry::f │ │ │ +0005f640: 6c75 7368 696e 675f 666c 6167 2929 3b0a lushing_flag));. │ │ │ +0005f650: 0909 652e 666c 6167 7320 7c3d 2063 6163 ..e.flags |= cac │ │ │ +0005f660: 6865 645f 7069 6563 655f 656e 7472 793a hed_piece_entry: │ │ │ +0005f670: 3a66 6c75 7368 696e 675f 666c 6167 3b0a :flushing_flag;. │ │ │ +0005f680: 097d 293b 0a0a 092f 2f20 536e 6170 7368 .});...// Snapsh │ │ │ +0005f690: 6f74 2074 6865 2070 656e 6469 6e67 2077 ot the pending w │ │ │ +0005f6a0: 7269 7465 5f6a 6f62 2070 6f69 6e74 6572 rite_job pointer │ │ │ +0005f6b0: 2066 6f72 2065 6163 6820 626c 6f63 6b20 for each block │ │ │ +0005f6c0: 7768 696c 6520 7765 2073 7469 6c6c 0a09 while we still.. │ │ │ +0005f6d0: 2f2f 2068 6f6c 6420 7468 6520 6d75 7465 // hold the mute │ │ │ +0005f6e0: 782e 2066 6c75 7368 696e 675f 666c 6167 x. flushing_flag │ │ │ +0005f6f0: 2070 7265 7665 6e74 7320 6f74 6865 7220 prevents other │ │ │ +0005f700: 7468 7265 6164 7320 6672 6f6d 2066 6c75 threads from flu │ │ │ +0005f710: 7368 696e 670a 092f 2f20 7468 6973 2070 shing..// this p │ │ │ +0005f720: 6965 6365 2c20 6275 7420 6469 736b 5f63 iece, but disk_c │ │ │ +0005f730: 6163 6865 3a3a 696e 7365 7274 2829 206d ache::insert() m │ │ │ +0005f740: 6179 2073 7469 6c6c 2070 6f70 756c 6174 ay still populat │ │ │ +0005f750: 6520 7072 6576 696f 7573 6c79 0a09 2f2f e previously..// │ │ │ +0005f760: 2065 6d70 7479 2074 7261 696c 696e 6720 empty trailing │ │ │ +0005f770: 736c 6f74 7320 2869 6e73 6572 7420 6f6e slots (insert on │ │ │ +0005f780: 6c79 2072 6571 7569 7265 7320 626c 6f63 ly requires bloc │ │ │ +0005f790: 6b5f 6964 7820 2667 743b 3d20 6861 7368 k_idx >= hash │ │ │ +0005f7a0: 6572 5f63 7572 736f 7229 2e0a 092f 2f20 er_cursor)...// │ │ │ +0005f7b0: 5265 6164 696e 6720 6361 6368 6564 5f62 Reading cached_b │ │ │ +0005f7c0: 6c6f 636b 5f65 6e74 7279 3a3a 7772 6974 lock_entry::writ │ │ │ +0005f7d0: 655f 7374 6174 6520 6672 6f6d 206f 7574 e_state from out │ │ │ +0005f7e0: 7369 6465 2074 6865 206c 6f63 6b20 776f side the lock wo │ │ │ +0005f7f0: 756c 640a 092f 2f20 7261 6365 2077 6974 uld..// race wit │ │ │ +0005f800: 6820 7468 6174 2e20 4f6e 6365 2061 2073 h that. Once a s │ │ │ +0005f810: 6c6f 7420 686f 6c64 7320 6120 6469 736b lot holds a disk │ │ │ +0005f820: 5f6a 6f62 2074 6865 206e 6574 776f 726b _job the network │ │ │ +0005f830: 2074 6872 6561 6420 776f 6e27 740a 092f thread won't../ │ │ │ +0005f840: 2f20 746f 7563 6820 6974 2028 6e6f 7220 / touch it (nor │ │ │ +0005f850: 7468 6520 6a6f 6227 7320 636f 6e74 656e the job's conten │ │ │ +0005f860: 7473 2920 756e 7469 6c20 7468 6520 6469 ts) until the di │ │ │ +0005f870: 736b 2074 6872 6561 6420 7461 6b65 7320 sk thread takes │ │ │ +0005f880: 6974 0a09 2f2f 2062 6163 6b2c 2073 6f20 it..// back, so │ │ │ +0005f890: 7468 6520 736e 6170 7368 6f74 7465 6420 the snapshotted │ │ │ +0005f8a0: 706f 696e 7465 7273 2061 6e64 2074 6865 pointers and the │ │ │ +0005f8b0: 2062 7566 6665 7273 2074 6865 7920 7265 buffers they re │ │ │ +0005f8c0: 6665 7265 6e63 6520 7374 6179 0a09 2f2f ference stay..// │ │ │ +0005f8d0: 2076 616c 6964 2066 6f72 2074 6865 2065 valid for the e │ │ │ +0005f8e0: 6e74 6972 6520 756e 6c6f 636b 6564 2072 ntire unlocked r │ │ │ +0005f8f0: 6567 696f 6e20 6265 6c6f 772e 0a09 544f egion below...TO │ │ │ +0005f900: 5252 454e 545f 414c 4c4f 4341 2873 6e61 RRENT_ALLOCA(sna │ │ │ +0005f910: 7073 686f 742c 2064 6973 6b5f 6a6f 622a pshot, disk_job* │ │ │ +0005f920: 2c20 626c 6f63 6b73 2e73 697a 6528 2929 , blocks.size()) │ │ │ +0005f930: 3b0a 0966 6f72 2028 696e 7420 6920 3d20 ;..for (int i = │ │ │ +0005f940: 303b 2069 2026 6c74 3b20 626c 6f63 6b73 0; i < blocks │ │ │ +0005f950: 2e73 697a 6528 293b 202b 2b69 290a 0909 .size(); ++i)... │ │ │ +0005f960: 736e 6170 7368 6f74 5b69 5d20 3d20 626c snapshot[i] = bl │ │ │ +0005f970: 6f63 6b73 5b69 5d2e 6765 745f 7772 6974 ocks[i].get_writ │ │ │ +0005f980: 655f 6a6f 6228 293b 0a0a 092f 2f20 7765 e_job();...// we │ │ │ +0005f990: 2068 6176 6520 746f 2072 656c 6561 7365 have to release │ │ │ +0005f9a0: 2074 6865 206c 6f63 6b20 7768 696c 6520 the lock while │ │ │ +0005f9b0: 666c 7573 6869 6e67 2c20 6275 7420 7369 flushing, but si │ │ │ +0005f9c0: 6e63 6520 7765 2073 6574 2074 6865 0a09 nce we set the.. │ │ │ +0005f9d0: 2f2f 2022 666c 7573 6869 6e67 2220 6d65 // "flushing" me │ │ │ +0005f9e0: 6d62 6572 2074 6f20 7472 7565 2c20 7468 mber to true, th │ │ │ +0005f9f0: 6973 2070 6965 6365 2069 7320 7069 6e6e is piece is pinn │ │ │ +0005fa00: 6564 2074 6f20 7468 6520 6361 6368 650a ed to the cache. │ │ │ +0005fa10: 096c 2e75 6e6c 6f63 6b28 293b 0a0a 0969 .l.unlock();...i │ │ │ +0005fa20: 6e74 2063 6f75 6e74 203d 2030 3b0a 0962 nt count = 0;..b │ │ │ +0005fa30: 6974 6669 656c 6420 666c 7573 6865 645f itfield flushed_ │ │ │ +0005fa40: 626c 6f63 6b73 3b0a 097b 0a09 0961 7574 blocks;..{...aut │ │ │ +0005fa50: 6f20 7365 203d 2073 636f 7065 5f65 6e64 o se = scope_end │ │ │ +0005fa60: 285b 2661 6d70 3b5d 207b 0a09 0909 6c2e ([&] {....l. │ │ │ +0005fa70: 6c6f 636b 2829 3b0a 0909 0962 6f6f 6c20 lock();....bool │ │ │ +0005fa80: 6e6f 7469 6679 203d 2066 616c 7365 3b0a notify = false;. │ │ │ +0005fa90: 0909 0976 6965 772e 6d6f 6469 6679 2870 ...view.modify(p │ │ │ +0005faa0: 6965 6365 5f69 7465 722c 205b 2661 6d70 iece_iter, [& │ │ │ +0005fab0: 3b6e 6f74 6966 795d 2863 6163 6865 645f ;notify](cached_ │ │ │ +0005fac0: 7069 6563 655f 656e 7472 7926 616d 703b piece_entry& │ │ │ +0005fad0: 2065 2920 7b0a 3c2f 7072 653e 3c2f 7464 e) {.
    relevance │ │ │ +0005fb10: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0005fb20: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/piece_pi │ │ │ +0005fb50: 636b 6572 2e63 7070 3a31 3030 3c2f 613e cker.cpp:100 │ │ │ +0005fb60: 3c2f 7464 3e3c 7464 3e66 696e 6420 6120 find a │ │ │ +0005fb70: 6265 7474 6572 2070 6c61 6365 2066 6f72 better place for │ │ │ +0005fb80: 2074 6869 733c 2f74 643e 3c2f 7472 3e3c this< │ │ │ +0005fb90: 7472 2069 643d 2232 3232 2220 7374 796c tr id="222" styl │ │ │ +0005fba0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0005fbb0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0005fbc0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0005fbd0: 6832 3e66 696e 6420 6120 6265 7474 6572 h2>find a better │ │ │ +0005fbe0: 2070 6c61 6365 2066 6f72 2074 6869 733c place for this< │ │ │ +0005fbf0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +0005fc00: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ +0005fc10: 3130 303c 2f68 343e 3c70 7265 2073 7479 100

    ...{.....std::
    │ │ │ +0005fc60: 6365 7272 2026 6c74 3b26 6c74 3b20 2220  cerr << " 
    │ │ │ +0005fc70: 2e2e 2e22 3b0a 0909 0909 6272 6561 6b3b  ...";.....break;
    │ │ │ +0005fc80: 0a09 0909 7d0a 0909 0969 6620 282a 6920  ....}....if (*i 
    │ │ │ +0005fc90: 3d3d 202d 3129 2062 7265 616b 3b0a 0909  == -1) break;...
    │ │ │ +0005fca0: 0977 6869 6c65 2028 6a20 213d 2070 2e6d  .while (j != p.m
    │ │ │ +0005fcb0: 5f70 7269 6f72 6974 795f 626f 756e 6461  _priority_bounda
    │ │ │ +0005fcc0: 7269 6573 2e65 6e64 2829 2026 616d 703b  ries.end() &
    │ │ │ +0005fcd0: 2661 6d70 3b20 2a6a 2026 6c74 3b3d 2069  & *j <= i
    │ │ │ +0005fce0: 6e64 6578 290a 0909 097b 0a09 0909 0973  ndex)....{.....s
    │ │ │ +0005fcf0: 7464 3a3a 6365 7272 2026 6c74 3b26 6c74  td::cerr <<
    │ │ │ +0005fd00: 3b20 227c 2022 3b0a 0909 0909 2b2b 6a3b  ; "| ";.....++j;
    │ │ │ +0005fd10: 0a09 0909 7d0a 0909 0973 7464 3a3a 6365  ....}....std::ce
    │ │ │ +0005fd20: 7272 2026 6c74 3b26 6c74 3b20 2a69 2026  rr << *i &
    │ │ │ +0005fd30: 6c74 3b26 6c74 3b20 2228 2220 266c 743b  lt;< "(" <
    │ │ │ +0005fd40: 266c 743b 2070 2e6d 5f70 6965 6365 5f6d  < p.m_piece_m
    │ │ │ +0005fd50: 6170 5b2a 695d 2e69 6e64 6578 2026 6c74  ap[*i].index <
    │ │ │ +0005fd60: 3b26 6c74 3b20 2229 2022 3b0a 0909 092d  ;< ") ";....-
    │ │ │ +0005fd70: 2d6c 696d 6974 3b0a 0909 7d0a 0909 7374  -limit;...}...st
    │ │ │ +0005fd80: 643a 3a63 6572 7220 266c 743b 266c 743b  d::cerr <<
    │ │ │ +0005fd90: 2073 7464 3a3a 656e 646c 3b0a 097d 0a7d   std::endl;..}.}
    │ │ │ +0005fda0: 0a23 656e 6469 6620 2f2f 2054 4f52 5245  .#endif // TORRE
    │ │ │ +0005fdb0: 4e54 5f50 4943 4b45 525f 4c4f 470a 0a6e  NT_PICKER_LOG..n
    │ │ │ +0005fdc0: 616d 6573 7061 6365 206c 6962 746f 7272  amespace libtorr
    │ │ │ +0005fdd0: 656e 7420 7b0a 0a3c 6469 7620 7374 796c  ent {..
    .const piec │ │ │ +0005fe10: 655f 626c 6f63 6b20 7069 6563 655f 626c e_block piece_bl │ │ │ +0005fe20: 6f63 6b3a 3a69 6e76 616c 6964 280a 3c2f ock::invalid(...std::numer │ │ │ +0005fe40: 6963 5f6c 696d 6974 7326 6c74 3b70 6965 ic_limits<pie │ │ │ +0005fe50: 6365 5f69 6e64 6578 5f74 2667 743b 3a3a ce_index_t>:: │ │ │ +0005fe60: 6d61 7828 290a 0909 2c20 7374 643a 3a6e max()..., std::n │ │ │ +0005fe70: 756d 6572 6963 5f6c 696d 6974 7326 6c74 umeric_limits< │ │ │ +0005fe80: 3b69 6e74 2667 743b 3a3a 6d61 7828 2929 ;int>::max()) │ │ │ +0005fe90: 3b0a 7d0a 0a6e 616d 6573 7061 6365 206c ;.}..namespace l │ │ │ +0005fea0: 6962 746f 7272 656e 743a 3a61 7578 207b ibtorrent::aux { │ │ │ +0005feb0: 0a0a 092f 2f20 7468 6520 6d61 7820 6e75 ...// the max nu │ │ │ +0005fec0: 6d62 6572 206f 6620 626c 6f63 6b73 2074 mber of blocks t │ │ │ +0005fed0: 6f20 6372 6561 7465 2061 6e20 6166 6669 o create an affi │ │ │ +0005fee0: 6e69 7479 2066 6f72 0a09 636f 6e73 7465 nity for..conste │ │ │ +0005fef0: 7870 7220 696e 7420 6d61 785f 7069 6563 xpr int max_piec │ │ │ +0005ff00: 655f 6166 6669 6e69 7479 5f65 7874 656e e_affinity_exten │ │ │ +0005ff10: 7420 3d20 3420 2a20 3130 3234 202a 2031 t = 4 * 1024 * 1 │ │ │ +0005ff20: 3032 3420 2f20 6465 6661 756c 745f 626c 024 / default_bl │ │ │ +0005ff30: 6f63 6b5f 7369 7a65 3b0a 0a09 7069 6563 ock_size;...piec │ │ │ +0005ff40: 655f 7069 636b 6572 3a3a 7069 6563 655f e_picker::piece_ │ │ │ +0005ff50: 7069 636b 6572 2873 7464 3a3a 696e 7436 picker(std::int6 │ │ │ +0005ff60: 345f 7420 636f 6e73 7420 746f 7461 6c5f 4_t const total_ │ │ │ +0005ff70: 7369 7a65 2c20 696e 7420 636f 6e73 7420 size, int const │ │ │ +0005ff80: 7069 6563 655f 7369 7a65 290a 0909 3a20 piece_size)...: │ │ │ +0005ff90: 6d5f 7072 696f 7269 7479 5f62 6f75 6e64 m_priority_bound │ │ │ +0005ffa0: 6172 6965 7328 312c 206d 5f70 6965 6365 aries(1, m_piece │ │ │ +0005ffb0: 732e 656e 645f 696e 6465 7828 2929 0a09 s.end_index()).. │ │ │ +0005ffc0: 7b0a 0909 544f 5252 454e 545f 4153 5345 {...TORRENT_ASSE │ │ │ +0005ffd0: 5254 2874 6f74 616c 5f73 697a 6520 2667 RT(total_size &g │ │ │ +0005ffe0: 743b 2030 293b 0a09 0954 4f52 5245 4e54 t; 0);...TORRENT │ │ │ +0005fff0: 5f41 5353 4552 5428 7069 6563 655f 7369 _ASSERT(piece_si │ │ │ +00060000: 7a65 2026 6774 3b20 3029 3b0a 2369 6664 ze > 0);.#ifd │ │ │ +00060010: 6566 2054 4f52 5245 4e54 5f50 4943 4b45 ef TORRENT_PICKE │ │ │ +00060020: 525f 4c4f 470a 0909 7374 643a 3a63 6572 R_LOG...std::cer │ │ │ +00060030: 7220 266c 743b 266c 743b 2022 5b22 2026 r << "[" & │ │ │ +00060040: 6c74 3b26 6c74 3b20 7468 6973 2026 6c74 lt;< this < │ │ │ +00060050: 3b26 6c74 3b20 225d 2022 2026 6c74 3b26 ;< "] " <& │ │ │ +00060060: 6c74 3b20 226e 6577 2070 6965 6365 5f70 lt; "new piece_p │ │ │ +00060070: 6963 6b65 7222 2026 6c74 3b26 6c74 3b20 icker" << │ │ │ +00060080: 7374 643a 3a65 6e64 6c3b 0a23 656e 6469 std::endl;.#endi │ │ │ +00060090: 660a 2369 6620 544f 5252 454e 545f 5553 f.#if TORRENT_US │ │ │ +000600a0: 455f 494e 5641 5249 414e 545f 4348 4543 E_INVARIANT_CHEC │ │ │ +000600b0: 4b53 0a09 0963 6865 636b 5f69 6e76 6172 KS...check_invar │ │ │ +000600c0: 6961 6e74 2829 3b0a 2365 6e64 6966 0a0a iant();.#endif.. │ │ │ +000600d0: 0909 7265 7369 7a65 2874 6f74 616c 5f73 ..resize(total_s │ │ │ +000600e0: 697a 652c 2070 6965 6365 5f73 697a 6529 ize, piece_size) │ │ │ +000600f0: 3b0a 097d 0a0a 0976 6f69 6420 7069 6563 ;..}...void piec │ │ │ +00060100: 655f 7069 636b 6572 3a3a 7265 7369 7a65 e_picker::resize │ │ │ +00060110: 2873 7464 3a3a 696e 7436 345f 7420 636f (std::int64_t co │ │ │ +00060120: 6e73 7420 746f 7461 6c5f 7369 7a65 2c20 nst total_size, │ │ │ +00060130: 696e 7420 636f 6e73 7420 7069 6563 655f int const piece_ │ │ │ +00060140: 7369 7a65 290a 097b 0a09 0954 4f52 5245 size)..{...TORRE │ │ │ +00060150: 4e54 5f41 5353 4552 5428 746f 7461 6c5f NT_ASSERT(total_ │ │ │ +00060160: 7369 7a65 2026 6774 3b20 3029 3b0a 0909 size > 0);... │ │ │ +00060170: 544f 5252 454e 545f 4153 5345 5254 2870 TORRENT_ASSERT(p │ │ │ +00060180: 6965 6365 5f73 697a 6520 2667 743b 2030 iece_size > 0 │ │ │ +00060190: 293b 0a0a 0909 6d5f 746f 7461 6c5f 7369 );....m_total_si │ │ │ +000601a0: 7a65 203d 2074 6f74 616c 5f73 697a 653b ze = total_size; │ │ │ +000601b0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +000601f0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +00060220: 7263 2f70 6965 6365 5f70 6963 6b65 722e rc/piece_picker. │ │ │ +00060230: 6370 703a 3230 3533 3c2f 613e 3c2f 7464 cpp:2053this could │ │ │ +00060250: 7072 6f62 6162 6c79 2062 6520 6f70 7469 probably be opti │ │ │ +00060260: 6d69 7a65 6420 6279 2069 6e63 7265 6d65 mized by increme │ │ │ +00060270: 6e74 616c 6c79 2063 616c 6c69 6e67 2070 ntally calling p │ │ │ +00060280: 6172 7469 616c 5f73 6f72 7420 746f 2073 artial_sort to s │ │ │ +00060290: 6f72 7420 6f6e 6520 6d6f 7265 2065 6c65 ort one more ele │ │ │ +000602a0: 6d65 6e74 2069 6e20 7468 6520 6c69 7374 ment in the list │ │ │ +000602b0: 2e20 4265 6361 7573 6520 6368 616e 6365 . Because chance │ │ │ +000602c0: 7320 6172 6520 7468 6174 2077 6527 6c6c s are that we'll │ │ │ +000602d0: 206a 7573 7420 6e65 6564 2061 2073 696e just need a sin │ │ │ +000602e0: 676c 6520 7069 6563 652c 2061 6e64 206f gle piece, and o │ │ │ +000602f0: 6e63 6520 7765 2776 6520 7069 636b 6564 nce we've picked │ │ │ +00060300: 2066 726f 6d20 6974 2077 6527 7265 2064 from it we're d │ │ │ +00060310: 6f6e 652e 2053 6f72 7469 6e67 2074 6865 one. Sorting the │ │ │ +00060320: 2072 6573 7420 6f66 2074 6865 206c 6973 rest of the lis │ │ │ +00060330: 7420 696e 2074 6861 7420 6361 7365 2069 t in that case i │ │ │ +00060340: 7320 6120 7761 7374 6520 6f66 2074 696d s a waste of tim │ │ │ +00060350: 652e 3c2f 7464 3e3c 2f74 723e 3c74 7220 e.

    │ │ │ +000603a0: 7468 6973 2063 6f75 6c64 2070 726f 6261 this could proba │ │ │ +000603b0: 626c 7920 6265 206f 7074 696d 697a 6564 bly be optimized │ │ │ +000603c0: 2062 7920 696e 6372 656d 656e 7461 6c6c by incrementall │ │ │ +000603d0: 790a 6361 6c6c 696e 6720 7061 7274 6961 y.calling partia │ │ │ +000603e0: 6c5f 736f 7274 2074 6f20 736f 7274 206f l_sort to sort o │ │ │ +000603f0: 6e65 206d 6f72 6520 656c 656d 656e 7420 ne more element │ │ │ +00060400: 696e 2074 6865 206c 6973 742e 2042 6563 in the list. Bec │ │ │ +00060410: 6175 7365 0a63 6861 6e63 6573 2061 7265 ause.chances are │ │ │ +00060420: 2074 6861 7420 7765 276c 6c20 6a75 7374 that we'll just │ │ │ +00060430: 206e 6565 6420 6120 7369 6e67 6c65 2070 need a single p │ │ │ +00060440: 6965 6365 2c20 616e 6420 6f6e 6365 2077 iece, and once w │ │ │ +00060450: 6527 7665 0a70 6963 6b65 6420 6672 6f6d e've.picked from │ │ │ +00060460: 2069 7420 7765 2772 6520 646f 6e65 2e20 it we're done. │ │ │ +00060470: 536f 7274 696e 6720 7468 6520 7265 7374 Sorting the rest │ │ │ +00060480: 206f 6620 7468 6520 6c69 7374 2069 6e20 of the list in │ │ │ +00060490: 7468 6174 0a63 6173 6520 6973 2061 2077 that.case is a w │ │ │ +000604a0: 6173 7465 206f 6620 7469 6d65 2e3c 2f68 aste of time.

    ../src/pie │ │ │ +000604c0: 6365 5f70 6963 6b65 722e 6370 703a 3230 ce_picker.cpp:20 │ │ │ +000604d0: 3533 3c2f 6834 3e3c 7072 6520 7374 796c 53

    ...// now, copy
    │ │ │ +00060520: 206f 7665 7220 7468 6520 706f 696e 7465   over the pointe
    │ │ │ +00060530: 7273 2e20 5765 2061 6c73 6f20 6170 706c  rs. We also appl
    │ │ │ +00060540: 7920 6120 6669 6c74 6572 2068 6572 6520  y a filter here 
    │ │ │ +00060550: 746f 206e 6f74 0a09 0909 2f2f 2069 6e63  to not....// inc
    │ │ │ +00060560: 6c75 6465 2069 6e65 6c69 6769 626c 6520  lude ineligible 
    │ │ │ +00060570: 7069 6563 6573 2069 6e20 6365 7274 6169  pieces in certai
    │ │ │ +00060580: 6e20 6d6f 6465 732e 2046 6f72 2069 6e73  n modes. For ins
    │ │ │ +00060590: 7461 6e63 652c 2061 2070 6965 6365 0a09  tance, a piece..
    │ │ │ +000605a0: 0909 2f2f 2074 6861 7420 7468 6520 6375  ..// that the cu
    │ │ │ +000605b0: 7272 656e 7420 7065 6572 2064 6f65 736e  rrent peer doesn
    │ │ │ +000605c0: 2774 2068 6176 6520 6973 206e 6f74 2069  't have is not i
    │ │ │ +000605d0: 6e63 6c75 6465 642e 0a09 0909 666f 7220  ncluded.....for 
    │ │ │ +000605e0: 2861 7574 6f20 636f 6e73 7426 616d 703b  (auto const&
    │ │ │ +000605f0: 2064 7020 3a20 6d5f 646f 776e 6c6f 6164   dp : m_download
    │ │ │ +00060600: 735b 7069 6563 655f 706f 733a 3a70 6965  s[piece_pos::pie
    │ │ │ +00060610: 6365 5f64 6f77 6e6c 6f61 6469 6e67 5d29  ce_downloading])
    │ │ │ +00060620: 0a09 0909 7b0a 0909 0909 7063 2e69 6e63  ....{.....pc.inc
    │ │ │ +00060630: 5f73 7461 7473 5f63 6f75 6e74 6572 2863  _stats_counter(c
    │ │ │ +00060640: 6f75 6e74 6572 733a 3a70 6965 6365 5f70  ounters::piece_p
    │ │ │ +00060650: 6963 6b65 725f 7061 7274 6961 6c5f 6c6f  icker_partial_lo
    │ │ │ +00060660: 6f70 7329 3b0a 0a09 0909 0969 6620 2821  ops);......if (!
    │ │ │ +00060670: 6973 5f70 6965 6365 5f66 7265 6528 6470  is_piece_free(dp
    │ │ │ +00060680: 2e69 6e64 6578 2c20 7069 6563 6573 2929  .index, pieces))
    │ │ │ +00060690: 2063 6f6e 7469 6e75 653b 0a0a 0909 0909   continue;......
    │ │ │ +000606a0: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ +000606b0: 5f70 6965 6365 5f6d 6170 5b64 702e 696e  _piece_map[dp.in
    │ │ │ +000606c0: 6465 785d 2e64 6f77 6e6c 6f61 645f 7175  dex].download_qu
    │ │ │ +000606d0: 6575 6528 290a 0909 0909 093d 3d20 7069  eue()......== pi
    │ │ │ +000606e0: 6563 655f 706f 733a 3a70 6965 6365 5f64  ece_pos::piece_d
    │ │ │ +000606f0: 6f77 6e6c 6f61 6469 6e67 293b 0a0a 0909  ownloading);....
    │ │ │ +00060700: 0909 6f72 6465 7265 645f 7061 7274 6961  ..ordered_partia
    │ │ │ +00060710: 6c73 5b6e 756d 5f6f 7264 6572 6564 5f70  ls[num_ordered_p
    │ │ │ +00060720: 6172 7469 616c 732b 2b5d 203d 2026 616d  artials++] = &am
    │ │ │ +00060730: 703b 6470 3b0a 0909 097d 0a0a 0909 092f  p;dp;....}...../
    │ │ │ +00060740: 2f20 6e6f 772c 2073 6f72 7420 7468 6520  / now, sort the 
    │ │ │ +00060750: 6c69 7374 2e0a 0909 0969 6620 286f 7074  list.....if (opt
    │ │ │ +00060760: 696f 6e73 2026 616d 703b 2072 6172 6573  ions & rares
    │ │ │ +00060770: 745f 6669 7273 7429 0a09 0909 7b0a 0909  t_first)....{...
    │ │ │ +00060780: 0909 7265 7420 7c3d 2070 6963 6b65 725f  ..ret |= picker_
    │ │ │ +00060790: 6c6f 675f 616c 6572 743a 3a72 6172 6573  log_alert::rares
    │ │ │ +000607a0: 745f 6669 7273 745f 7061 7274 6961 6c73  t_first_partials
    │ │ │ +000607b0: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ....std::sort(o │ │ │ +000607f0: 7264 6572 6564 5f70 6172 7469 616c 732e rdered_partials. │ │ │ +00060800: 6265 6769 6e28 292c 206f 7264 6572 6564 begin(), ordered │ │ │ +00060810: 5f70 6172 7469 616c 732e 6265 6769 6e28 _partials.begin( │ │ │ +00060820: 2920 2b20 6e75 6d5f 6f72 6465 7265 645f ) + num_ordered_ │ │ │ +00060830: 7061 7274 6961 6c73 0a3c 2f64 6976 3e09 partials.
    . │ │ │ +00060840: 0909 0909 2c20 7374 643a 3a62 696e 6428 ...., std::bind( │ │ │ +00060850: 2661 6d70 3b70 6965 6365 5f70 6963 6b65 &piece_picke │ │ │ +00060860: 723a 3a70 6172 7469 616c 5f63 6f6d 7061 r::partial_compa │ │ │ +00060870: 7265 5f72 6172 6573 745f 6669 7273 742c re_rarest_first, │ │ │ +00060880: 2074 6869 730a 0909 0909 0909 2c20 5f31 this......., _1 │ │ │ +00060890: 2c20 5f32 2929 3b0a 0909 097d 0a0a 0909 , _2));....}.... │ │ │ +000608a0: 0966 6f72 2028 696e 7420 6920 3d20 303b .for (int i = 0; │ │ │ +000608b0: 2069 2026 6c74 3b20 6e75 6d5f 6f72 6465 i < num_orde │ │ │ +000608c0: 7265 645f 7061 7274 6961 6c73 3b20 2b2b red_partials; ++ │ │ │ +000608d0: 6929 0a09 0909 7b0a 0909 0909 7265 7420 i)....{.....ret │ │ │ +000608e0: 7c3d 2070 6963 6b65 725f 6c6f 675f 616c |= picker_log_al │ │ │ +000608f0: 6572 743a 3a70 7269 6f72 6974 697a 655f ert::prioritize_ │ │ │ +00060900: 7061 7274 6961 6c73 3b0a 0a09 0909 096e partials;......n │ │ │ +00060910: 756d 5f62 6c6f 636b 7320 3d20 6164 645f um_blocks = add_ │ │ │ +00060920: 626c 6f63 6b73 5f64 6f77 6e6c 6f61 6469 blocks_downloadi │ │ │ +00060930: 6e67 282a 6f72 6465 7265 645f 7061 7274 ng(*ordered_part │ │ │ +00060940: 6961 6c73 5b69 5d2c 2070 6965 6365 730a ials[i], pieces. │ │ │ +00060950: 0909 0909 092c 2069 6e74 6572 6573 7469 ....., interesti │ │ │ +00060960: 6e67 5f62 6c6f 636b 732c 2062 6163 6b75 ng_blocks, backu │ │ │ +00060970: 705f 626c 6f63 6b73 0a09 0909 0909 2c20 p_blocks......, │ │ │ +00060980: 6e75 6d5f 626c 6f63 6b73 2c20 7072 6566 num_blocks, pref │ │ │ +00060990: 6572 5f63 6f6e 7469 6775 6f75 735f 626c er_contiguous_bl │ │ │ +000609a0: 6f63 6b73 2c20 7065 6572 2c20 6f70 7469 ocks, peer, opti │ │ │ +000609b0: 6f6e 7329 3b0a 0909 0909 6966 2028 6e75 ons);.....if (nu │ │ │ +000609c0: 6d5f 626c 6f63 6b73 2026 6c74 3b3d 2030 m_blocks <= 0 │ │ │ +000609d0: 2920 7265 7475 726e 2072 6574 3b0a 0909 ) return ret;... │ │ │ +000609e0: 0909 6966 2028 696e 7428 6261 636b 7570 ..if (int(backup │ │ │ +000609f0: 5f62 6c6f 636b 732e 7369 7a65 2829 2920 _blocks.size()) │ │ │ +00060a00: 2667 743b 3d20 6e75 6d5f 626c 6f63 6b73 >= num_blocks │ │ │ +00060a10: 290a 0909 0909 0962 7265 616b 3b0a 0909 )......break;... │ │ │ +00060a20: 097d 0a0a 0909 096e 756d 5f62 6c6f 636b .}.....num_block │ │ │ +00060a30: 7320 3d20 6170 7065 6e64 5f62 6c6f 636b s = append_block │ │ │ +00060a40: 7328 696e 7465 7265 7374 696e 675f 626c s(interesting_bl │ │ │ +00060a50: 6f63 6b73 2c20 6261 636b 7570 5f62 6c6f ocks, backup_blo │ │ │ +00060a60: 636b 730a 0909 0909 2c20 6e75 6d5f 626c cks....., num_bl │ │ │ +00060a70: 6f63 6b73 293b 0a09 0909 6966 2028 6e75 ocks);....if (nu │ │ │ +00060a80: 6d5f 626c 6f63 6b73 2026 6c74 3b3d 2030 m_blocks <= 0 │ │ │ +00060a90: 2920 7265 7475 726e 2072 6574 3b0a 0909 ) return ret;... │ │ │ +00060aa0: 7d0a 0a09 0969 6620 2821 7375 6767 6573 }....if (!sugges │ │ │ +00060ab0: 7465 645f 7069 6563 6573 2e65 6d70 7479 ted_pieces.empty │ │ │ +00060ac0: 2829 290a 0909 7b0a 0909 0966 6f72 2028 ())...{....for ( │ │ │ +00060ad0: 7069 6563 655f 696e 6465 785f 7420 6920 piece_index_t i │ │ │ +00060ae0: 3a20 7375 6767 6573 7465 645f 7069 6563 : suggested_piec │ │ │ +00060af0: 6573 290a 0909 097b 0a09 0909 0970 632e es)....{.....pc. │ │ │ +00060b00: 696e 635f 7374 6174 735f 636f 756e 7465 inc_stats_counte │ │ │ +00060b10: 7228 636f 756e 7465 7273 3a3a 7069 6563 r(counters::piec │ │ │ +00060b20: 655f 7069 636b 6572 5f73 7567 6765 7374 e_picker_suggest │ │ │ +00060b30: 5f6c 6f6f 7073 293b 0a09 0909 0969 6620 _loops);.....if │ │ │ +00060b40: 2821 6973 5f70 6965 6365 5f66 7265 6528 (!is_piece_free( │ │ │ +00060b50: 692c 2070 6965 6365 7329 2920 636f 6e74 i, pieces)) cont │ │ │ +00060b60: 696e 7565 3b0a 0a09 0909 0972 6574 207c inue;......ret | │ │ │ +00060b70: 3d20 7069 636b 6572 5f6c 6f67 5f61 6c65 = picker_log_ale │ │ │ +00060b80: 7274 3a3a 7375 6767 6573 7465 645f 7069 rt::suggested_pi │ │ │ +00060b90: 6563 6573 3b0a 0a3c 2f70 7265 3e3c 2f74 eces;..
    relevanc │ │ │ +00060bd0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/piece_p │ │ │ +00060c10: 6963 6b65 722e 6370 703a 3231 3935 3c2f icker.cpp:2195Is it │ │ │ +00060c30: 2061 2067 6f6f 6420 6964 6561 2074 6861 a good idea tha │ │ │ +00060c40: 7420 7468 6973 2061 6666 696e 6974 7920 t this affinity │ │ │ +00060c50: 7461 6b65 7320 7072 6563 6564 656e 6365 takes precedence │ │ │ +00060c60: 206f 7665 7220 7069 6563 6520 7072 696f over piece prio │ │ │ +00060c70: 7269 7479 3f3c 2f74 643e 3c2f 7472 3e3c rity?< │ │ │ +00060c80: 7472 2069 643d 2232 3234 2220 7374 796c tr id="224" styl │ │ │ +00060c90: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00060ca0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00060cb0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00060cc0: 6832 3e49 7320 6974 2061 2067 6f6f 6420 h2>Is it a good │ │ │ +00060cd0: 6964 6561 2074 6861 7420 7468 6973 2061 idea that this a │ │ │ +00060ce0: 6666 696e 6974 7920 7461 6b65 7320 7072 ffinity takes pr │ │ │ +00060cf0: 6563 6564 656e 6365 206f 7665 720a 7069 ecedence over.pi │ │ │ +00060d00: 6563 6520 7072 696f 7269 7479 3f3c 2f68 ece priority?

    ../src/pie │ │ │ +00060d20: 6365 5f70 6963 6b65 722e 6370 703a 3231 ce_picker.cpp:21 │ │ │ +00060d30: 3935 3c2f 6834 3e3c 7072 6520 7374 796c 95

    ......pc.inc_st
    │ │ │ +00060d80: 6174 735f 636f 756e 7465 7228 636f 756e  ats_counter(coun
    │ │ │ +00060d90: 7465 7273 3a3a 7069 6563 655f 7069 636b  ters::piece_pick
    │ │ │ +00060da0: 6572 5f72 6576 6572 7365 5f72 6172 655f  er_reverse_rare_
    │ │ │ +00060db0: 6c6f 6f70 7329 3b0a 0a09 0909 0909 0969  loops);........i
    │ │ │ +00060dc0: 6620 2821 6973 5f70 6965 6365 5f66 7265  f (!is_piece_fre
    │ │ │ +00060dd0: 6528 6d5f 7069 6563 6573 5b70 5d2c 2070  e(m_pieces[p], p
    │ │ │ +00060de0: 6965 6365 7329 2920 636f 6e74 696e 7565  ieces)) continue
    │ │ │ +00060df0: 3b0a 0909 0909 0909 2f2f 2063 7572 736f  ;.......// curso
    │ │ │ +00060e00: 7273 2061 7265 206e 6f74 206d 7574 6174  rs are not mutat
    │ │ │ +00060e10: 6564 2064 7572 696e 6720 7069 636b 696e  ed during pickin
    │ │ │ +00060e20: 673b 206d 616b 6520 7375 7265 2077 6520  g; make sure we 
    │ │ │ +00060e30: 646f 6e27 7420 7069 636b 2070 6965 6365  don't pick piece
    │ │ │ +00060e40: 7320 7769 7468 696e 2074 6865 0a09 0909  s within the....
    │ │ │ +00060e50: 0909 092f 2f20 7365 7175 656e 7469 616c  ...// sequential
    │ │ │ +00060e60: 2072 616e 6765 2069 6620 696e 2073 6571   range if in seq
    │ │ │ +00060e70: 7565 6e74 6961 6c20 646f 776e 6c6f 6164  uential download
    │ │ │ +00060e80: 206d 6f64 6520 736f 2074 6861 7420 7765   mode so that we
    │ │ │ +00060e90: 2064 6f6e 2774 2070 6963 6b20 6475 706c   don't pick dupl
    │ │ │ +00060ea0: 6963 6174 6520 7069 6563 6573 0a09 0909  icate pieces....
    │ │ │ +00060eb0: 0909 0969 6620 2828 6f70 7469 6f6e 7320  ...if ((options 
    │ │ │ +00060ec0: 2661 6d70 3b20 7365 7175 656e 7469 616c  & sequential
    │ │ │ +00060ed0: 2920 2661 6d70 3b26 616d 703b 206d 5f70  ) && m_p
    │ │ │ +00060ee0: 6965 6365 735b 705d 2026 6774 3b3d 206d  ieces[p] >= m
    │ │ │ +00060ef0: 5f63 7572 736f 7220 2661 6d70 3b26 616d  _cursor &&am
    │ │ │ +00060f00: 703b 206d 5f70 6965 6365 735b 705d 2026  p; m_pieces[p] &
    │ │ │ +00060f10: 6c74 3b20 6d5f 7265 7665 7273 655f 6375  lt; m_reverse_cu
    │ │ │ +00060f20: 7273 6f72 2920 636f 6e74 696e 7565 3b0a  rsor) continue;.
    │ │ │ +00060f30: 0a09 0909 0909 0972 6574 207c 3d20 7069  .......ret |= pi
    │ │ │ +00060f40: 636b 6572 5f6c 6f67 5f61 6c65 7274 3a3a  cker_log_alert::
    │ │ │ +00060f50: 7265 7665 7273 655f 7261 7265 7374 5f66  reverse_rarest_f
    │ │ │ +00060f60: 6972 7374 3b0a 0a09 0909 0909 096e 756d  irst;........num
    │ │ │ +00060f70: 5f62 6c6f 636b 7320 3d20 6164 645f 626c  _blocks = add_bl
    │ │ │ +00060f80: 6f63 6b73 286d 5f70 6965 6365 735b 705d  ocks(m_pieces[p]
    │ │ │ +00060f90: 2c20 7069 6563 6573 0a09 0909 0909 0909  , pieces........
    │ │ │ +00060fa0: 2c20 696e 7465 7265 7374 696e 675f 626c  , interesting_bl
    │ │ │ +00060fb0: 6f63 6b73 0a09 0909 0909 0909 2c20 6261  ocks........, ba
    │ │ │ +00060fc0: 636b 7570 5f62 6c6f 636b 732c 206e 756d  ckup_blocks, num
    │ │ │ +00060fd0: 5f62 6c6f 636b 730a 0909 0909 0909 092c  _blocks........,
    │ │ │ +00060fe0: 2070 7265 6665 725f 636f 6e74 6967 756f   prefer_contiguo
    │ │ │ +00060ff0: 7573 5f62 6c6f 636b 732c 2070 6565 722c  us_blocks, peer,
    │ │ │ +00061000: 2069 676e 6f72 6564 5f70 6965 6365 730a   ignored_pieces.
    │ │ │ +00061010: 0909 0909 0909 092c 206f 7074 696f 6e73  ......., options
    │ │ │ +00061020: 293b 0a09 0909 0909 0969 6620 286e 756d  );.......if (num
    │ │ │ +00061030: 5f62 6c6f 636b 7320 266c 743b 3d20 3029  _blocks <= 0)
    │ │ │ +00061040: 2072 6574 7572 6e20 7265 743b 0a09 0909   return ret;....
    │ │ │ +00061050: 0909 7d0a 0909 0909 7d0a 0909 097d 0a09  ..}.....}....}..
    │ │ │ +00061060: 0909 656c 7365 0a09 0909 7b0a 3c64 6976  ..else....{.
    ....if │ │ │ +000610a0: 2028 6f70 7469 6f6e 7320 2661 6d70 3b20 (options & │ │ │ +000610b0: 7069 6563 655f 6578 7465 6e74 5f61 6666 piece_extent_aff │ │ │ +000610c0: 696e 6974 7929 0a3c 2f64 6976 3e09 0909 inity).
    ... │ │ │ +000610d0: 097b 0a09 0909 0909 696e 7420 746f 5f65 .{......int to_e │ │ │ +000610e0: 7261 7365 203d 202d 313b 0a09 0909 0909 rase = -1;...... │ │ │ +000610f0: 696e 7420 6964 7820 3d20 2d31 3b0a 0909 int idx = -1;... │ │ │ +00061100: 0909 0966 6f72 2028 7069 6563 655f 6578 ...for (piece_ex │ │ │ +00061110: 7465 6e74 5f74 2063 6f6e 7374 2065 203a tent_t const e : │ │ │ +00061120: 206d 5f72 6563 656e 745f 6578 7465 6e74 m_recent_extent │ │ │ +00061130: 7329 0a09 0909 0909 7b0a 0909 0909 0909 s)......{....... │ │ │ +00061140: 2b2b 6964 783b 0a09 0909 0909 0962 6f6f ++idx;.......boo │ │ │ +00061150: 6c20 6861 7665 5f61 6c6c 203d 2074 7275 l have_all = tru │ │ │ +00061160: 653b 0a09 0909 0909 0966 6f72 2028 7069 e;.......for (pi │ │ │ +00061170: 6563 655f 696e 6465 785f 7420 636f 6e73 ece_index_t cons │ │ │ +00061180: 7420 7020 3a20 6578 7465 6e74 5f66 6f72 t p : extent_for │ │ │ +00061190: 2865 2929 0a09 0909 0909 097b 0a09 0909 (e)).......{.... │ │ │ +000611a0: 0909 0909 6966 2028 216d 5f70 6965 6365 ....if (!m_piece │ │ │ +000611b0: 5f6d 6170 5b70 5d2e 666c 7573 6865 6428 _map[p].flushed( │ │ │ +000611c0: 2929 2068 6176 655f 616c 6c20 3d20 6661 )) have_all = fa │ │ │ +000611d0: 6c73 653b 0a09 0909 0909 0909 6966 2028 lse;........if ( │ │ │ +000611e0: 2169 735f 7069 6563 655f 6672 6565 2870 !is_piece_free(p │ │ │ +000611f0: 2c20 7069 6563 6573 2929 2063 6f6e 7469 , pieces)) conti │ │ │ +00061200: 6e75 653b 0a09 0909 0909 0909 6966 2028 nue;........if ( │ │ │ +00061210: 286f 7074 696f 6e73 2026 616d 703b 2073 (options & s │ │ │ +00061220: 6571 7565 6e74 6961 6c29 2026 616d 703b equential) & │ │ │ +00061230: 2661 6d70 3b20 7020 2667 743b 3d20 6d5f & p >= m_ │ │ │ +00061240: 6375 7273 6f72 2026 616d 703b 2661 6d70 cursor && │ │ │ +00061250: 3b20 7020 266c 743b 206d 5f72 6576 6572 ; p < m_rever │ │ │ +00061260: 7365 5f63 7572 736f 7229 2063 6f6e 7469 se_cursor) conti │ │ │ +00061270: 6e75 653b 0a0a 0909 0909 0909 0972 6574 nue;.........ret │ │ │ +00061280: 207c 3d20 7069 636b 6572 5f6c 6f67 5f61 |= picker_log_a │ │ │ +00061290: 6c65 7274 3a3a 6578 7465 6e74 5f61 6666 lert::extent_aff │ │ │ +000612a0: 696e 6974 793b 0a0a 0909 0909 0909 096e inity;.........n │ │ │ +000612b0: 756d 5f62 6c6f 636b 7320 3d20 6164 645f um_blocks = add_ │ │ │ +000612c0: 626c 6f63 6b73 2870 2c20 7069 6563 6573 blocks(p, pieces │ │ │ +000612d0: 0a09 0909 0909 0909 092c 2069 6e74 6572 ........., inter │ │ │ +000612e0: 6573 7469 6e67 5f62 6c6f 636b 730a 0909 esting_blocks... │ │ │ +000612f0: 0909 0909 0909 2c20 6261 636b 7570 5f62 ......, backup_b │ │ │ +00061300: 6c6f 636b 732c 206e 756d 5f62 6c6f 636b locks, num_block │ │ │ +00061310: 730a 0909 0909 0909 0909 2c20 7072 6566 s........., pref │ │ │ +00061320: 6572 5f63 6f6e 7469 6775 6f75 735f 626c er_contiguous_bl │ │ │ +00061330: 6f63 6b73 2c20 7065 6572 2c20 6967 6e6f ocks, peer, igno │ │ │ +00061340: 7265 645f 7069 6563 6573 0a09 0909 0909 red_pieces...... │ │ │ +00061350: 0909 092c 206f 7074 696f 6e73 293b 0a09 ..., options);.. │ │ │ +00061360: 0909 0909 0909 6966 2028 6e75 6d5f 626c ......if (num_bl │ │ │ +00061370: 6f63 6b73 2026 6c74 3b3d 2030 290a 0909 ocks <= 0)... │ │ │ +00061380: 0909 0909 097b 0a09 0909 0909 0909 092f .....{........./ │ │ │ +00061390: 2f20 6966 2077 6520 6861 7665 2061 6c6c / if we have all │ │ │ +000613a0: 2070 6965 6365 7320 6265 6c6f 6e67 696e pieces belongin │ │ │ +000613b0: 6720 746f 2074 6869 7320 6578 7465 6e74 g to this extent │ │ │ +000613c0: 2c20 7265 6d6f 7665 2069 740a 0909 0909 , remove it..... │ │ │ +000613d0: 0909 0909 6966 2028 746f 5f65 7261 7365 ....if (to_erase │ │ │ +000613e0: 2021 3d20 2d31 2920 6d5f 7265 6365 6e74 != -1) m_recent │ │ │ +000613f0: 5f65 7874 656e 7473 2e65 7261 7365 286d _extents.erase(m │ │ │ +00061400: 5f72 6563 656e 745f 6578 7465 6e74 732e _recent_extents. │ │ │ +00061410: 6265 6769 6e28 2920 2b20 746f 5f65 7261 begin() + to_era │ │ │ +00061420: 7365 293b 0a09 0909 0909 0909 0972 6574 se);.........ret │ │ │ +00061430: 7572 6e20 7265 743b 0a09 0909 0909 0909 urn ret;........ │ │ │ +00061440: 7d0a 0909 0909 0909 7d0a 0909 0909 0909 }.......}....... │ │ │ +00061450: 2f2f 2069 6620 7765 2068 6176 6520 616c // if we have al │ │ │ +00061460: 6c20 7069 6563 6573 2062 656c 6f6e 6769 l pieces belongi │ │ │ +00061470: 6e67 2074 6f20 7468 6973 2065 7874 656e ng to this exten │ │ │ +00061480: 742c 2072 656d 6f76 6520 6974 0a09 0909 t, remove it.... │ │ │ +00061490: 0909 0969 6620 2868 6176 655f 616c 6c29 ...if (have_all) │ │ │ +000614a0: 2074 6f5f 6572 6173 6520 3d20 6964 783b to_erase = idx; │ │ │ +000614b0: 0a09 0909 0909 7d0a 3c2f 7072 653e 3c2f ......}.
    relevan │ │ │ +000614f0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/piece_ │ │ │ +00061530: 7069 636b 6572 2e63 7070 3a32 3534 373c picker.cpp:2547< │ │ │ +00061540: 2f61 3e3c 2f74 643e 3c74 643e 7768 656e /a>when │ │ │ +00061550: 2065 7870 616e 6469 6e67 2070 6965 6365 expanding piece │ │ │ +00061560: 7320 666f 7220 6361 6368 6520 7374 7269 s for cache stri │ │ │ +00061570: 7065 2072 6561 736f 6e73 2c20 7468 6520 pe reasons, the │ │ │ +00061580: 2164 6f77 6e6c 6f61 6469 6e67 2063 6f6e !downloading con │ │ │ +00061590: 6469 7469 6f6e 2064 6f65 736e 2774 206d dition doesn't m │ │ │ +000615a0: 616b 6520 6d75 6368 2073 656e 7365 3c2f ake much sense

    when │ │ │ +00061600: 2065 7870 616e 6469 6e67 2070 6965 6365 expanding piece │ │ │ +00061610: 7320 666f 7220 6361 6368 6520 7374 7269 s for cache stri │ │ │ +00061620: 7065 2072 6561 736f 6e73 2c0a 7468 6520 pe reasons,.the │ │ │ +00061630: 2164 6f77 6e6c 6f61 6469 6e67 2063 6f6e !downloading con │ │ │ +00061640: 6469 7469 6f6e 2064 6f65 736e 2774 206d dition doesn't m │ │ │ +00061650: 616b 6520 6d75 6368 2073 656e 7365 3c2f ake much sense

    ../src/pi │ │ │ +00061670: 6563 655f 7069 636b 6572 2e63 7070 3a32 ece_picker.cpp:2 │ │ │ +00061680: 3534 373c 2f68 343e 3c70 7265 2073 7479 547

    ..TORRENT_ASSE
    │ │ │ +000616d0: 5254 2869 6e64 6578 2026 6c74 3b20 6d5f  RT(index < m_
    │ │ │ +000616e0: 7069 6563 655f 6d61 702e 656e 645f 696e  piece_map.end_in
    │ │ │ +000616f0: 6465 7828 2929 3b0a 0909 6966 2028 6e65  dex());...if (ne
    │ │ │ +00061700: 7874 2869 6e64 6578 2920 3d3d 206d 5f70  xt(index) == m_p
    │ │ │ +00061710: 6965 6365 5f6d 6170 2e65 6e64 5f69 6e64  iece_map.end_ind
    │ │ │ +00061720: 6578 2829 290a 0909 0972 6574 7572 6e20  ex())....return 
    │ │ │ +00061730: 6d5f 626c 6f63 6b73 5f69 6e5f 6c61 7374  m_blocks_in_last
    │ │ │ +00061740: 5f70 6965 6365 3b0a 0909 656c 7365 0a09  _piece;...else..
    │ │ │ +00061750: 0909 7265 7475 726e 2062 6c6f 636b 735f  ..return blocks_
    │ │ │ +00061760: 7065 725f 7069 6563 6528 293b 0a09 7d0a  per_piece();..}.
    │ │ │ +00061770: 0a09 626f 6f6c 2070 6965 6365 5f70 6963  ..bool piece_pic
    │ │ │ +00061780: 6b65 723a 3a69 735f 7069 6563 655f 6672  ker::is_piece_fr
    │ │ │ +00061790: 6565 2870 6965 6365 5f69 6e64 6578 5f74  ee(piece_index_t
    │ │ │ +000617a0: 2063 6f6e 7374 2070 6965 6365 0a09 092c   const piece...,
    │ │ │ +000617b0: 2074 7970 6564 5f62 6974 6669 656c 6426   typed_bitfield&
    │ │ │ +000617c0: 6c74 3b70 6965 6365 5f69 6e64 6578 5f74  lt;piece_index_t
    │ │ │ +000617d0: 2667 743b 2063 6f6e 7374 2661 6d70 3b20  > const& 
    │ │ │ +000617e0: 6269 746d 6173 6b29 2063 6f6e 7374 0a09  bitmask) const..
    │ │ │ +000617f0: 7b0a 0909 7265 7475 726e 2062 6974 6d61  {...return bitma
    │ │ │ +00061800: 736b 5b70 6965 6365 5d0a 0909 0926 616d  sk[piece]....&am
    │ │ │ +00061810: 703b 2661 6d70 3b20 216d 5f70 6965 6365  p;& !m_piece
    │ │ │ +00061820: 5f6d 6170 5b70 6965 6365 5d2e 666c 7573  _map[piece].flus
    │ │ │ +00061830: 6865 6428 290a 0909 0926 616d 703b 2661  hed()....&&a
    │ │ │ +00061840: 6d70 3b20 216d 5f70 6965 6365 5f6d 6170  mp; !m_piece_map
    │ │ │ +00061850: 5b70 6965 6365 5d2e 6669 6c74 6572 6564  [piece].filtered
    │ │ │ +00061860: 2829 3b0a 097d 0a0a 0962 6f6f 6c20 7069  ();..}...bool pi
    │ │ │ +00061870: 6563 655f 7069 636b 6572 3a3a 6361 6e5f  ece_picker::can_
    │ │ │ +00061880: 7069 636b 2870 6965 6365 5f69 6e64 6578  pick(piece_index
    │ │ │ +00061890: 5f74 2063 6f6e 7374 2070 6965 6365 0a09  _t const piece..
    │ │ │ +000618a0: 092c 2074 7970 6564 5f62 6974 6669 656c  ., typed_bitfiel
    │ │ │ +000618b0: 6426 6c74 3b70 6965 6365 5f69 6e64 6578  d<piece_index
    │ │ │ +000618c0: 5f74 2667 743b 2063 6f6e 7374 2661 6d70  _t> const&
    │ │ │ +000618d0: 3b20 6269 746d 6173 6b29 2063 6f6e 7374  ; bitmask) const
    │ │ │ +000618e0: 0a09 7b0a 0909 7265 7475 726e 2062 6974  ..{...return bit
    │ │ │ +000618f0: 6d61 736b 5b70 6965 6365 5d0a 0909 0926  mask[piece]....&
    │ │ │ +00061900: 616d 703b 2661 6d70 3b20 216d 5f70 6965  amp;& !m_pie
    │ │ │ +00061910: 6365 5f6d 6170 5b70 6965 6365 5d2e 666c  ce_map[piece].fl
    │ │ │ +00061920: 7573 6865 6428 290a 3c64 6976 2073 7479  ushed().
    ...&&a │ │ │ +00061960: 6d70 3b20 216d 5f70 6965 6365 5f6d 6170 mp; !m_piece_map │ │ │ +00061970: 5b70 6965 6365 5d2e 646f 776e 6c6f 6164 [piece].download │ │ │ +00061980: 696e 6728 290a 3c2f 6469 763e 0909 0926 ing().
    ...& │ │ │ +00061990: 616d 703b 2661 6d70 3b20 216d 5f70 6965 amp;& !m_pie │ │ │ +000619a0: 6365 5f6d 6170 5b70 6965 6365 5d2e 6669 ce_map[piece].fi │ │ │ +000619b0: 6c74 6572 6564 2829 3b0a 097d 0a0a 2369 ltered();..}..#i │ │ │ +000619c0: 6620 544f 5252 454e 545f 5553 455f 494e f TORRENT_USE_IN │ │ │ +000619d0: 5641 5249 414e 545f 4348 4543 4b53 0a09 VARIANT_CHECKS.. │ │ │ +000619e0: 766f 6964 2070 6965 6365 5f70 6963 6b65 void piece_picke │ │ │ +000619f0: 723a 3a63 6865 636b 5f70 6565 7273 2829 r::check_peers() │ │ │ +00061a00: 0a09 7b0a 0909 666f 7220 2861 7574 6f20 ..{...for (auto │ │ │ +00061a10: 636f 6e73 7426 616d 703b 2062 203a 206d const& b : m │ │ │ +00061a20: 5f62 6c6f 636b 5f69 6e66 6f29 0a09 097b _block_info)...{ │ │ │ +00061a30: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +00061a40: 5254 2862 2e70 6565 7220 3d3d 206e 756c RT(b.peer == nul │ │ │ +00061a50: 6c70 7472 207c 7c20 7374 6174 6963 5f63 lptr || static_c │ │ │ +00061a60: 6173 7426 6c74 3b61 7578 3a3a 746f 7272 ast<aux::torr │ │ │ +00061a70: 656e 745f 7065 6572 2a26 6774 3b28 622e ent_peer*>(b. │ │ │ +00061a80: 7065 6572 292d 2667 743b 696e 5f75 7365 peer)->in_use │ │ │ +00061a90: 293b 0a09 097d 0a09 7d0a 2365 6e64 6966 );...}..}.#endif │ │ │ +00061aa0: 0a0a 0976 6f69 6420 7069 6563 655f 7069 ...void piece_pi │ │ │ +00061ab0: 636b 6572 3a3a 636c 6561 725f 7065 6572 cker::clear_peer │ │ │ +00061ac0: 2861 7578 3a3a 746f 7272 656e 745f 7065 (aux::torrent_pe │ │ │ +00061ad0: 6572 2a20 7065 6572 290a 097b 0a09 0966 er* peer)..{...f │ │ │ +00061ae0: 6f72 2028 6175 746f 2661 6d70 3b20 6220 or (auto& b │ │ │ +00061af0: 3a20 6d5f 626c 6f63 6b5f 696e 666f 290a : m_block_info). │ │ │ +00061b00: 0909 7b0a 0909 0969 6620 2862 2e70 6565 ..{....if (b.pee │ │ │ +00061b10: 7220 3d3d 2070 6565 7229 2062 2e70 6565 r == peer) b.pee │ │ │ +00061b20: 7220 3d20 6e75 6c6c 7074 723b 0a09 097d r = nullptr;...} │ │ │ +00061b30: 0a09 7d0a 0a09 2f2f 2074 6865 2066 6972 ..}...// the fir │ │ │ +00061b40: 7374 2062 6f6f 6c20 6973 2074 7275 6520 st bool is true │ │ │ +00061b50: 6966 2074 6869 7320 6973 2074 6865 206f if this is the o │ │ │ +00061b60: 6e6c 7920 7065 6572 2074 6861 7420 6861 nly peer that ha │ │ │ +00061b70: 7320 7265 7175 6573 7465 6420 616e 6420 s requested and │ │ │ +00061b80: 646f 776e 6c6f 6164 6564 0a09 2f2f 2062 downloaded..// b │ │ │ +00061b90: 6c6f 636b 7320 6672 6f6d 2074 6869 7320 locks from this │ │ │ +00061ba0: 7069 6563 652e 0a09 2f2f 2074 6865 2073 piece...// the s │ │ │ +00061bb0: 6563 6f6e 6420 626f 6f6c 2069 7320 7472 econd bool is tr │ │ │ +00061bc0: 7565 2069 6620 7468 6973 2069 7320 7468 ue if this is th │ │ │ +00061bd0: 6520 6f6e 6c79 2061 6374 6976 6520 7065 e only active pe │ │ │ +00061be0: 6572 2074 6861 7420 6973 2072 6571 7565 er that is reque │ │ │ +00061bf0: 7374 696e 670a 092f 2f20 616e 6420 646f sting..// and do │ │ │ +00061c00: 776e 6c6f 6164 696e 6720 626c 6f63 6b73 wnloading blocks │ │ │ +00061c10: 2066 726f 6d20 7468 6973 2070 6965 6365 from this piece │ │ │ +00061c20: 2e20 4163 7469 7665 206d 6561 6e73 2068 . Active means h │ │ │ +00061c30: 6176 696e 6720 6120 636f 6e6e 6563 7469 aving a connecti │ │ │ +00061c40: 6f6e 2e0a 3c2f 7072 653e 3c2f 7464 3e3c on..
    < │ │ │ +00061c50: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr> TRUNCATED DUE TO SIZE LIMIT: 10485760 bytes