If seed_mode is set, libtorrent will assume that all files
│ │ │ ├── html2text {}
│ │ │ │ @@ -1,42 +1,143 @@
│ │ │ │ >
│ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
│ │ │ │ VVeerrssiioonn:: 2.0.12
│ │ │ │ _h_o_m_e
│ │ │ │ Table of contents
│ │ │ │ - * _p_e_e_r___i_n_f_o
│ │ │ │ - o _i_2_p___d_e_s_t_i_n_a_t_i_o_n_(_)
│ │ │ │ + * _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_(_)_ _h_a_s___v_2_(_)_ _h_a_s___v_1_(_)
│ │ │ │ + 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_(_)
│ │ │ │ o _f_o_r___e_a_c_h_(_)
│ │ │ │ - * _p_i_e_c_e___b_l_o_c_k
│ │ │ │ * _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 _i_2_p___d_e_s_t_i_n_a_t_i_o_n_(_)
│ │ │ │ + * _l_o_a_d___t_o_r_r_e_n_t___p_a_r_s_e_d_(_)_ _l_o_a_d___t_o_r_r_e_n_t___b_u_f_f_e_r_(_)_ _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_o_r_r_e_n_t___p_e_e_r___e_q_u_a_l_(_)
│ │ │ │ - * _t_r_u_n_c_a_t_e___f_i_l_e_s_(_)
│ │ │ │ * _v_e_r_s_i_o_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_ _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_ _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]
│ │ │ │ +************ 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"
│ │ │ │ +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]
│ │ │ │ +************ iinnffoo__hhaasshh__tt ************
│ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p"
│ │ │ │ +class holding the info-hash of a torrent. It can hold a v1 info-hash (SHA-1) or
│ │ │ │ +a v2 info-hash (SHA-256) or both.
│ │ │ │ +Note
│ │ │ │ +If has_v2() is false then the v1 hash might actually be a truncated v2 hash
│ │ │ │ +struct info_hash_t
│ │ │ │ +{
│ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept;
│ │ │ │ + iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept;
│ │ │ │ + iinnffoo__hhaasshh__tt () noexcept = default;
│ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept;
│ │ │ │ + bool hhaass__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;
│ │ │ │ + template void ffoorr__eeaacchh (F f) const;
│ │ │ │ + bool ooppeerraattoorr<< (info_hash_t const& o) const;
│ │ │ │ + friend std::ostream& ooppeerraattoorr<<<< (std::ostream& os, info_hash_t const& ih);
│ │ │ │ +
│ │ │ │ + sha1_hash v1;
│ │ │ │ + sha256_hash v2;
│ │ │ │ +};
│ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ +********** iinnffoo__hhaasshh__tt(()) **********
│ │ │ │ +explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept;
│ │ │ │ +iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept;
│ │ │ │ +iinnffoo__hhaasshh__tt () noexcept = default;
│ │ │ │ +explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept;
│ │ │ │ +The default constructor creates an object that has neither a v1 or v2 hash.
│ │ │ │ +For backwards compatibility, make it possible to construct directly from a v1
│ │ │ │ +hash. This constructor allows iimmpplliicciitt conversion from a v1 hash, but the
│ │ │ │ +implicitness is deprecated.
│ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ +********** hhaass__vv22(()) hhaass(()) hhaass__vv11(()) **********
│ │ │ │ +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]
│ │ │ │ +********** 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]
│ │ │ │ +********** ffoorr__eeaacchh(()) **********
│ │ │ │ +template void ffoorr__eeaacchh (F f) const;
│ │ │ │ +calls the function object f for each hash that is available. starting with v1.
│ │ │ │ +The signature of F is:
│ │ │ │ +void(sha1_hash const&, protocol_version);
│ │ │ │ +[_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
│ │ │ │ {
│ │ │ │ sha256_hash ii22pp__ddeessttiinnaattiioonn () const;
│ │ │ │
│ │ │ │ @@ -405,141 +506,47 @@
│ │ │ │ to disk before downloading more.
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ read_state write_state
│ │ │ │ bitmasks indicating what state this peer is in with regards to sending
│ │ │ │ and receiving data. The states are defined as independent flags of type
│ │ │ │ bandwidth_state_flags_t, in this class.
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -************ iinnffoo__hhaasshh__tt ************
│ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p"
│ │ │ │ -class holding the info-hash of a torrent. It can hold a v1 info-hash (SHA-1) or
│ │ │ │ -a v2 info-hash (SHA-256) or both.
│ │ │ │ -Note
│ │ │ │ -If has_v2() is false then the v1 hash might actually be a truncated v2 hash
│ │ │ │ -struct info_hash_t
│ │ │ │ -{
│ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept;
│ │ │ │ - iinnffoo__hhaasshh__tt () noexcept = default;
│ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept;
│ │ │ │ - iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept;
│ │ │ │ - bool hhaass__vv11 () const;
│ │ │ │ - bool hhaass__vv22 () 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;
│ │ │ │ - template void ffoorr__eeaacchh (F f) const;
│ │ │ │ - bool ooppeerraattoorr<< (info_hash_t const& o) const;
│ │ │ │ - friend std::ostream& ooppeerraattoorr<<<< (std::ostream& os, info_hash_t const& ih);
│ │ │ │ -
│ │ │ │ - sha1_hash v1;
│ │ │ │ - sha256_hash v2;
│ │ │ │ -};
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -********** iinnffoo__hhaasshh__tt(()) **********
│ │ │ │ -explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept;
│ │ │ │ -iinnffoo__hhaasshh__tt () noexcept = default;
│ │ │ │ -explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept;
│ │ │ │ -iinnffoo__hhaasshh__tt (sha1_hash h1, 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__vv22(()) hhaass__vv11(()) **********
│ │ │ │ -bool hhaass__vv11 () const;
│ │ │ │ -bool hhaass__vv22 () 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]
│ │ │ │ -********** ffoorr__eeaacchh(()) **********
│ │ │ │ -template void ffoorr__eeaacchh (F f) const;
│ │ │ │ -calls the function object f for each hash that is available. starting with v1.
│ │ │ │ -The signature of F is:
│ │ │ │ -void(sha1_hash const&, protocol_version);
│ │ │ │ -[_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"
│ │ │ │ -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]
│ │ │ │ -************ ppeeeerr__rreeqquueesstt ************
│ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___r_e_q_u_e_s_t_._h_p_p"
│ │ │ │ -represents a byte range within a piece. Internally this is is used for incoming
│ │ │ │ -piece requests.
│ │ │ │ -struct peer_request
│ │ │ │ -{
│ │ │ │ - bool ooppeerraattoorr==== (peer_request const& r) const;
│ │ │ │ -
│ │ │ │ - piece_index_t piece;
│ │ │ │ - int start;
│ │ │ │ - int length;
│ │ │ │ -};
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -********** ooppeerraattoorr====(()) **********
│ │ │ │ -bool ooppeerraattoorr==== (peer_request const& r) const;
│ │ │ │ -returns true if the right hand side _p_e_e_r___r_e_q_u_e_s_t refers to the same range as
│ │ │ │ -this does.
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ - piece
│ │ │ │ - The index of the piece in which the range starts.
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ - start
│ │ │ │ - The byte offset within that piece where the range starts.
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ - length
│ │ │ │ - The size of the range, in bytes.
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -************ llooaadd__ttoorrrreenntt__ffiillee(()) llooaadd__ttoorrrreenntt__ppaarrsseedd(()) llooaadd__ttoorrrreenntt__bbuuffffeerr(()) ************
│ │ │ │ +************ llooaadd__ttoorrrreenntt__ppaarrsseedd(()) llooaadd__ttoorrrreenntt__bbuuffffeerr(()) 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__ppaarrsseedd (
│ │ │ │ bdecode_node const& torrent_file);
│ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr (
│ │ │ │ - span buffer, load_torrent_limits const& cfg);
│ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr (
│ │ │ │ - span buffer);
│ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ffiillee (
│ │ │ │ std::string const& filename, 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, load_torrent_limits const& cfg);
│ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ffiillee (
│ │ │ │ + std::string const& filename);
│ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr (
│ │ │ │ + span buffer, load_torrent_limits const& cfg);
│ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr (
│ │ │ │ + span buffer);
│ │ │ │ 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_(_)
│ │ │ │ [_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 (torrent_info const& info);
│ │ │ │ std::string mmaakkee__mmaaggnneett__uurrii (torrent_handle const& handle);
│ │ │ │ +std::string mmaakkee__mmaaggnneett__uurrii (torrent_info const& info);
│ │ │ │ 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:
│ │ │ │ ti, info_hashes, url_seeds, dht_nodes, file_priorities, trackers,
│ │ │ │ name, peers.
│ │ │ │ @@ -555,78 +562,42 @@
│ │ │ │ The overload that takes a _t_o_r_r_e_n_t___h_a_n_d_l_e will make blocking calls to query
│ │ │ │ information about the torrent. If the torrent handle is invalid, an empty
│ │ │ │ string is returned.
│ │ │ │ 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);
│ │ │ │ +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]
│ │ │ │ ************ ttoorrrreenntt__ppeeeerr__eeqquuaall(()) ************
│ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___p_e_e_r_._h_p_p"
│ │ │ │ inline bool ttoorrrreenntt__ppeeeerr__eeqquuaall (torrent_peer const* lhs, torrent_peer const*
│ │ │ │ rhs);
│ │ │ │ [_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]
│ │ │ │ ************ vveerrssiioonn(()) ************
│ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p"
│ │ │ │ char const* vveerrssiioonn ();
│ │ │ │ returns the libtorrent version as string form in this format:
│ │ │ │ "..."
│ │ │ │ [_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_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -|_t_c_p___s_s_l_ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -|_s_o_c_k_s_5___s_s_l_|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -|_h_t_t_p___s_s_l_ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -|_u_t_p___s_s_l_ _ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -[_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_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -************ eennuumm ppoorrttmmaapp__ttrraannssppoorrtt ************
│ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_r_t_m_a_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_a_t_p_m_p_|_0_ _ _ _ _|_n_a_t_p_m_p_ _c_a_n_ _b_e_ _N_A_T_-_P_M_P_ _o_r_ _P_C_P|
│ │ │ │ -|_u_p_n_p_ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -************ eennuumm ppoorrttmmaapp__pprroottooccooll ************
│ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_r_t_m_a_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_n_e_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -|_t_c_p_ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -|_u_d_p_ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ ************ eennuumm eevveenntt__tt ************
│ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_r_a_c_k_e_r___m_a_n_a_g_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|
│ │ │ │ |_n_o_n_e_ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ |_c_o_m_p_l_e_t_e_d_|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ |_s_t_a_r_t_e_d_ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ @@ -637,45 +608,64 @@
│ │ │ │ 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_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_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ |_u_r_l___s_e_e_d_ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ |_h_t_t_p___s_e_e_d_ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ +************ eennuumm ppoorrttmmaapp__ttrraannssppoorrtt ************
│ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_r_t_m_a_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_a_t_p_m_p_|_0_ _ _ _ _|_n_a_t_p_m_p_ _c_a_n_ _b_e_ _N_A_T_-_P_M_P_ _o_r_ _P_C_P|
│ │ │ │ +|_u_p_n_p_ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ +************ eennuumm ppoorrttmmaapp__pprroottooccooll ************
│ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_r_t_m_a_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_n_e_|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +|_t_c_p_ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +|_u_d_p_ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +[_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_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +|_t_c_p___s_s_l_ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +|_s_o_c_k_s_5___s_s_l_|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +|_h_t_t_p___s_s_l_ _ _|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +|_u_t_p___s_s_l_ _ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ |
│ │ │ │ +[_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
│ │ │ │ @@ -683,14 +673,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
│ │ │ @@ -30,26 +30,26 @@
│ │ │
│ │ │ home
│ │ │
│ │ │
Table of contents
│ │ │
│ │ │ - create_torrent
│ │ │ struct create_torrent
│ │ │ {
│ │ │ explicit create_torrent (torrent_info const& ti);
│ │ │ explicit create_torrent (file_storage& fs, int piece_size = 0
│ │ │ , create_flags_t flags = {});
│ │ │ - std::vector<char> generate_buf () const;
│ │ │ entry generate () const;
│ │ │ + std::vector<char> generate_buf () const;
│ │ │ file_storage const& files () 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_http_seed (string_view url);
│ │ │ 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 is_v2_only () const;
│ │ │ + 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;
│ │ │ 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;
│ │ │ + int piece_length () const;
│ │ │ void add_similar_torrent (sha1_hash ih);
│ │ │ void add_collection (string_view c);
│ │ │
│ │ │ static constexpr create_flags_t modification_time = 2_bit;
│ │ │ static constexpr create_flags_t symlinks = 3_bit;
│ │ │ static constexpr create_flags_t v2_only = 5_bit;
│ │ │ static constexpr create_flags_t v1_only = 6_bit;
│ │ │ @@ -175,21 +175,21 @@
│ │ │ have any affect. Instead of using this overload, consider using
│ │ │ write_torrent_file() instead.
│ │ │
│ │ │ -
│ │ │ -[report issue]
│ │ │ -
│ │ │ -
generate() generate_buf()
│ │ │ +
│ │ │ +
[report issue]
│ │ │ +
│ │ │ +
generate_buf() generate()
│ │ │
│ │ │ -std::vector<char> generate_buf () const;
│ │ │ 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
│ │ │ @@ -272,18 +272,18 @@
│ │ │ 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_http_seed() add_url_seed()
│ │ │ +
│ │ │ +
[report issue]
│ │ │ +
│ │ │ +
add_url_seed() add_http_seed()
│ │ │
│ │ │ void add_http_seed (string_view url);
│ │ │ 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
│ │ │ @@ -320,21 +320,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()
│ │ │
│ │ │ -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]
│ │ │
│ │ │ @@ -374,16 +374,16 @@
│ │ │
│ │ │
the total number of bytes of all files and pad files
│ │ │
│ │ │
[report issue]
│ │ │
│ │ │
piece_length() piece_size()
│ │ │
│ │ │ -int piece_length () const;
│ │ │ int piece_size (piece_index_t i) const;
│ │ │ +int piece_length () 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]
│ │ │
│ │ │ @@ -482,28 +482,28 @@
│ │ │
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);
│ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p, error_code& ec);
│ │ │ void set_piece_hashes (create_torrent& t, std::string const& p
│ │ │ - , settings_interface const& settings
│ │ │ , 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
│ │ │ , std::function<void(piece_index_t)> const& f);
│ │ │ -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_interface const& settings
│ │ │ , std::function<void(piece_index_t)> const& f);
│ │ │ void set_piece_hashes (create_torrent& t, std::string const& p
│ │ │ + , settings_interface const& settings, disk_io_constructor_type disk_io
│ │ │ , std::function<void(piece_index_t)> const& f, error_code& ec);
│ │ │ void set_piece_hashes (create_torrent& t, std::string const& p
│ │ │ - , settings_interface const& settings, disk_io_constructor_type disk_io
│ │ │ + , settings_interface 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:
│ │ │
│ │ │ ├── html2text {}
│ │ │ │ @@ -1,26 +1,26 @@
│ │ │ │ >
│ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
│ │ │ │ VVeerrssiioonn:: 2.0.12
│ │ │ │ _h_o_m_e
│ │ │ │ Table of contents
│ │ │ │ * _c_r_e_a_t_e___t_o_r_r_e_n_t
│ │ │ │ o _c_r_e_a_t_e___t_o_r_r_e_n_t_(_)
│ │ │ │ - o _g_e_n_e_r_a_t_e_(_)_ _g_e_n_e_r_a_t_e___b_u_f_(_)
│ │ │ │ + o _g_e_n_e_r_a_t_e___b_u_f_(_)_ _g_e_n_e_r_a_t_e_(_)
│ │ │ │ o _f_i_l_e_s_(_)
│ │ │ │ o _s_e_t___c_o_m_m_e_n_t_(_)
│ │ │ │ o _s_e_t___c_r_e_a_t_o_r_(_)
│ │ │ │ o _s_e_t___c_r_e_a_t_i_o_n___d_a_t_e_(_)
│ │ │ │ o _s_e_t___h_a_s_h_(_)
│ │ │ │ o _s_e_t___h_a_s_h_2_(_)
│ │ │ │ - o _a_d_d___h_t_t_p___s_e_e_d_(_)_ _a_d_d___u_r_l___s_e_e_d_(_)
│ │ │ │ + o _a_d_d___u_r_l___s_e_e_d_(_)_ _a_d_d___h_t_t_p___s_e_e_d_(_)
│ │ │ │ o _a_d_d___n_o_d_e_(_)
│ │ │ │ o _a_d_d___t_r_a_c_k_e_r_(_)
│ │ │ │ o _s_e_t___r_o_o_t___c_e_r_t_(_)
│ │ │ │ - o _p_r_i_v_(_)_ _s_e_t___p_r_i_v_(_)
│ │ │ │ + o _s_e_t___p_r_i_v_(_)_ _p_r_i_v_(_)
│ │ │ │ o _n_u_m___p_i_e_c_e_s_(_)
│ │ │ │ o _p_i_e_c_e___r_a_n_g_e_(_)
│ │ │ │ o _f_i_l_e___r_a_n_g_e_(_)
│ │ │ │ o _f_i_l_e___p_i_e_c_e___r_a_n_g_e_(_)
│ │ │ │ o _t_o_t_a_l___s_i_z_e_(_)
│ │ │ │ o _p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___s_i_z_e_(_)
│ │ │ │ o _a_d_d___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_(_)
│ │ │ │ @@ -69,41 +69,41 @@
│ │ │ │ _e_n_t_r_y that's returned can then be bencoded into a .torrent file using _b_e_n_c_o_d_e
│ │ │ │ _(_).
│ │ │ │ struct create_torrent
│ │ │ │ {
│ │ │ │ explicit ccrreeaattee__ttoorrrreenntt (torrent_info const& ti);
│ │ │ │ explicit ccrreeaattee__ttoorrrreenntt (file_storage& fs, int piece_size = 0
│ │ │ │ , create_flags_t flags = {});
│ │ │ │ - std::vector ggeenneerraattee__bbuuff () const;
│ │ │ │ entry ggeenneerraattee () const;
│ │ │ │ + std::vector ggeenneerraattee__bbuuff () const;
│ │ │ │ file_storage const& ffiilleess () const;
│ │ │ │ void sseett__ccoommmmeenntt (char const* str);
│ │ │ │ void sseett__ccrreeaattoorr (char const* str);
│ │ │ │ void sseett__ccrreeaattiioonn__ddaattee (std::time_t timestamp);
│ │ │ │ void sseett__hhaasshh (piece_index_t index, sha1_hash const& h);
│ │ │ │ void sseett__hhaasshh22 (file_index_t file, piece_index_t::diff_type piece,
│ │ │ │ sha256_hash const& h);
│ │ │ │ void aadddd__hhttttpp__sseeeedd (string_view url);
│ │ │ │ void aadddd__uurrll__sseeeedd (string_view url);
│ │ │ │ void aadddd__nnooddee (std::pair node);
│ │ │ │ void aadddd__ttrraacckkeerr (string_view url, int tier = 0);
│ │ │ │ void sseett__rroooott__cceerrtt (string_view cert);
│ │ │ │ - bool pprriivv () const;
│ │ │ │ void sseett__pprriivv (bool p);
│ │ │ │ - bool iiss__vv22__oonnllyy () const;
│ │ │ │ + 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;
│ │ │ │ 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;
│ │ │ │ + int ppiieeccee__lleennggtthh () const;
│ │ │ │ void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
│ │ │ │ void aadddd__ccoolllleeccttiioonn (string_view c);
│ │ │ │
│ │ │ │ static constexpr create_flags_t mmooddiiffiiccaattiioonn__ttiimmee = 2_bit;
│ │ │ │ static constexpr create_flags_t ssyymmlliinnkkss = 3_bit;
│ │ │ │ static constexpr create_flags_t vv22__oonnllyy = 5_bit;
│ │ │ │ static constexpr create_flags_t vv11__oonnllyy = 6_bit;
│ │ │ │ @@ -131,17 +131,17 @@
│ │ │ │ functions of _c_r_e_a_t_e___t_o_r_r_e_n_t that affects the content of the info dictionary
│ │ │ │ (such as _s_e_t___h_a_s_h_(_)), will have any affect. Instead of using this overload,
│ │ │ │ consider using _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) instead.
│ │ │ │ Warning
│ │ │ │ The _f_i_l_e___s_t_o_r_a_g_e and _t_o_r_r_e_n_t___i_n_f_o objects must stay alive for the entire
│ │ │ │ duration of the _c_r_e_a_t_e___t_o_r_r_e_n_t object.
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -********** ggeenneerraattee(()) ggeenneerraattee__bbuuff(()) **********
│ │ │ │ -std::vector ggeenneerraattee__bbuuff () const;
│ │ │ │ +********** ggeenneerraattee__bbuuff(()) ggeenneerraattee(()) **********
│ │ │ │ entry ggeenneerraattee () const;
│ │ │ │ +std::vector ggeenneerraattee__bbuuff () const;
│ │ │ │ This function will generate the .torrent file as a bencode tree, or a bencoded
│ │ │ │ into a buffer. In order to encode the _e_n_t_r_y into a flat file, use the _b_e_n_c_o_d_e_(_)
│ │ │ │ function.
│ │ │ │ The function returning an _e_n_t_r_y may be useful to add custom entries to the
│ │ │ │ torrent file before bencoding it and saving it to disk.
│ │ │ │ Whether the resulting torrent object is v1, v2 or hybrid depends on whether any
│ │ │ │ of the v1_only or v2_only flags were set on the constructor. If neither were
│ │ │ │ @@ -198,15 +198,15 @@
│ │ │ │ the merkle tree formed by the piece's 16 kiB blocks. Note that piece sizes must
│ │ │ │ be powers-of-2, so all per-piece merkle trees are complete. A SHA-256 hash of
│ │ │ │ all zeros is internally used to indicate a hash that has not been set. Setting
│ │ │ │ such hash will not be considered set when calling _g_e_n_e_r_a_t_e_(_). This function
│ │ │ │ will throw std::system_error if it is called on an object constructed with the
│ │ │ │ v1_only flag.
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ -********** aadddd__hhttttpp__sseeeedd(()) aadddd__uurrll__sseeeedd(()) **********
│ │ │ │ +********** aadddd__uurrll__sseeeedd(()) aadddd__hhttttpp__sseeeedd(()) **********
│ │ │ │ void aadddd__hhttttpp__sseeeedd (string_view url);
│ │ │ │ void aadddd__uurrll__sseeeedd (string_view url);
│ │ │ │ This adds a url seed to the torrent. You can have any number of url seeds. For
│ │ │ │ a single file torrent, this should be an HTTP url, pointing to a file with
│ │ │ │ identical content as the file of the torrent. For a multi-file torrent, it
│ │ │ │ should point to a directory containing a directory with the same name as this
│ │ │ │ torrent, and all the files of the torrent in it.
│ │ │ │ @@ -235,17 +235,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]
│ │ │ │ -********** pprriivv(()) sseett__pprriivv(()) **********
│ │ │ │ -bool pprriivv () const;
│ │ │ │ +********** 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]
│ │ │ │ ********** 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.
│ │ │ │ @@ -264,16 +264,16 @@
│ │ │ │ delta from the first piece in the file. i.e. the first index is 0.
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ ********** ttoottaall__ssiizzee(()) **********
│ │ │ │ std::int64_t ttoottaall__ssiizzee () const;
│ │ │ │ the total number of bytes of all files and pad files
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ ********** ppiieeccee__lleennggtthh(()) ppiieeccee__ssiizzee(()) **********
│ │ │ │ -int ppiieeccee__lleennggtthh () const;
│ │ │ │ int ppiieeccee__ssiizzee (piece_index_t i) const;
│ │ │ │ +int ppiieeccee__lleennggtthh () const;
│ │ │ │ piece_length() returns the piece size of all pieces but the last one.
│ │ │ │ piece_size() returns the size of the specified piece. these functions are just
│ │ │ │ forwarding to the associated _f_i_l_e___s_t_o_r_a_g_e.
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ ********** aadddd__ccoolllleeccttiioonn(()) aadddd__ssiimmiillaarr__ttoorrrreenntt(()) **********
│ │ │ │ void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
│ │ │ │ void aadddd__ccoolllleeccttiioonn (string_view c);
│ │ │ │ @@ -348,29 +348,29 @@
│ │ │ │ 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
│ │ │ │ - , settings_interface const& settings
│ │ │ │ - , 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,
│ │ │ │ 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
│ │ │ │ , std::function const& f);
│ │ │ │ -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_interface const& settings
│ │ │ │ , std::function const& f);
│ │ │ │ void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
│ │ │ │ + , settings_interface const& settings, disk_io_constructor_type disk_io
│ │ │ │ , std::function const& f, error_code& ec);
│ │ │ │ void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
│ │ │ │ - , settings_interface const& settings, disk_io_constructor_type disk_io
│ │ │ │ + , settings_interface 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
│ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html
│ │ │ @@ -28,69 +28,345 @@
│ │ │ | 2.0.12 |
│ │ │
│ │ │
│ │ │ 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())
│ │ │ + {
│ │ │ + 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
│ │ │ + {
│ │ │ + 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()), int(b.size())), 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::status_t::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::no_error, 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); });
│ │ │ + }
│ │ │ +
│ │ │ + void free_disk_buffer(char*) override
│ │ │ + {
│ │ │ + }
│ │ │ +
│ │ │ + 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;
│ │ │ +
│ │ │ + std::vector<lt::storage_index_t> m_free_slots;
│ │ │ +
│ │ │ + lt::io_context& m_ioc;
│ │ │ +};
│ │ │ +
│ │ │ +std::unique_ptr<lt::disk_interface> temp_disk_constructor(
│ │ │ + lt::io_context& ioc, lt::settings_interface const&, lt::counters&)
│ │ │ +{
│ │ │ + return std::make_unique<temp_disk_io>(ioc);
│ │ │ +}
│ │ │ +
│ │ │ +
[report issue]
│ │ │ +
settings_interface
│ │ │ +
Declared in "libtorrent/settings_pack.hpp"
│ │ │ +
the common interface to settings_pack and the internal representation of
│ │ │ +settings.
│ │ │ +
│ │ │ +struct settings_interface
│ │ │ +{
│ │ │ + virtual void set_str (int name, std::string val) = 0;
│ │ │ + virtual void set_int (int name, int val) = 0;
│ │ │ + virtual bool has_val (int name) const = 0;
│ │ │ + virtual void set_bool (int name, bool val) = 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;
│ │ │ +};
│ │ │ +
│ │ │ +
[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
│ │ │ {
│ │ │ @@ -133,21 +409,21 @@
│ │ │ the constructor. The callbacks will be run in the network thread.
│ │ │
│ │ │ struct disk_interface
│ │ │ {
│ │ │ virtual storage_holder new_torrent (storage_params const& p
│ │ │ , std::shared_ptr<void> const& torrent) = 0;
│ │ │ virtual void remove_torrent (storage_index_t) = 0;
│ │ │ - virtual void async_read (storage_index_t storage, peer_request const& r
│ │ │ - , std::function<void(disk_buffer_holder, storage_error const&)> handler
│ │ │ - , disk_job_flags_t flags = {}) = 0;
│ │ │ virtual bool async_write (storage_index_t storage, peer_request const& r
│ │ │ , char const* buf, std::shared_ptr<disk_observer> o
│ │ │ , std::function<void(storage_error const&)> handler
│ │ │ , disk_job_flags_t flags = {}) = 0;
│ │ │ + virtual void async_read (storage_index_t storage, peer_request const& r
│ │ │ + , std::function<void(disk_buffer_holder, storage_error const&)> handler
│ │ │ + , disk_job_flags_t flags = {}) = 0;
│ │ │ virtual void async_hash (storage_index_t storage, piece_index_t piece, span<sha256_hash> v2
│ │ │ , disk_job_flags_t flags
│ │ │ , std::function<void(piece_index_t, sha1_hash const&, storage_error const&)> handler) = 0;
│ │ │ virtual void async_hash2 (storage_index_t storage, piece_index_t piece, int offset, disk_job_flags_t flags
│ │ │ , std::function<void(piece_index_t, sha256_hash const&, storage_error const&)> handler) = 0;
│ │ │ virtual void async_move_storage (storage_index_t storage, std::string p, move_flags_t flags
│ │ │ , std::function<void(status_t, std::string const&, storage_error const&)> handler) = 0;
│ │ │ @@ -204,21 +480,21 @@
│ │ │ delete any files from disk, just to clean up any resources associated
│ │ │ with the specified storage.
│ │ │
│ │ │ [report issue]
│ │ │
│ │ │
async_read() async_write()
│ │ │
│ │ │ -virtual void async_read (storage_index_t storage, peer_request const& r
│ │ │ - , std::function<void(disk_buffer_holder, storage_error const&)> handler
│ │ │ - , disk_job_flags_t flags = {}) = 0;
│ │ │ virtual bool async_write (storage_index_t storage, peer_request const& r
│ │ │ , char const* buf, std::shared_ptr<disk_observer> o
│ │ │ , std::function<void(storage_error const&)> handler
│ │ │ , disk_job_flags_t flags = {}) = 0;
│ │ │ +virtual void async_read (storage_index_t storage, peer_request const& r
│ │ │ + , std::function<void(disk_buffer_holder, storage_error const&)> handler
│ │ │ + , disk_job_flags_t flags = {}) = 0;
│ │ │
│ │ │
perform a read or write operation from/to the specified storage
│ │ │ index and the specified request. When the operation completes, call
│ │ │ handler possibly with a disk_buffer_holder, holding the buffer with
│ │ │ the result. Flags may be set to affect the read operation. See
│ │ │ disk_job_flags_t.
│ │ │
The disk_observer is a callback to indicate that
│ │ │ @@ -470,21 +746,21 @@
│ │ │ 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& operator= (storage_holder const&) = delete;
│ │ │ 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;
│ │ │ };
│ │ │
│ │ │
[report issue]
│ │ │
│ │ │
disk_observer
│ │ │ @@ -526,16 +802,16 @@
│ │ │
If this buffer holder is moved-from, default constructed or reset,
│ │ │ data() will return nullptr.
│ │ │
│ │ │ struct disk_buffer_holder
│ │ │ {
│ │ │ disk_buffer_holder& operator= (disk_buffer_holder&&) & noexcept;
│ │ │ disk_buffer_holder (disk_buffer_holder&&) noexcept;
│ │ │ - disk_buffer_holder& operator= (disk_buffer_holder const&) = delete;
│ │ │ 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, int sz) noexcept;
│ │ │ disk_buffer_holder () noexcept = default;
│ │ │ ~disk_buffer_holder ();
│ │ │ char* data () const noexcept;
│ │ │ void reset ();
│ │ │ void swap (disk_buffer_holder& h) noexcept;
│ │ │ @@ -600,34 +876,16 @@
│ │ │
│ │ │
bool()
│ │ │
│ │ │ explicit operator bool () const noexcept;
│ │ │
│ │ │
implicitly convertible to true if the object is currently holding a
│ │ │ buffer
│ │ │ -
[report issue]
│ │ │ -
│ │ │ -
│ │ │ -
settings_interface
│ │ │ -
Declared in "libtorrent/settings_pack.hpp"
│ │ │ -
the common interface to settings_pack and the internal representation of
│ │ │ -settings.
│ │ │ -
│ │ │ -struct settings_interface
│ │ │ -{
│ │ │ - virtual void set_str (int name, std::string val) = 0;
│ │ │ - virtual void set_bool (int name, bool val) = 0;
│ │ │ - virtual void set_int (int name, int 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]
│ │ │ +
│ │ │
│ │ │
file_open_mode_t
│ │ │
Declared in "libtorrent/disk_interface.hpp"
│ │ │
│ │ │ - read_only
│ │ │ - open the file for reading only
│ │ │
│ │ │ ├── html2text {}
│ │ │ │ @@ -1,12 +1,13 @@
│ │ │ │ >
│ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
│ │ │ │ VVeerrssiioonn:: 2.0.12
│ │ │ │ _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_p_e_n___f_i_l_e___s_t_a_t_e
│ │ │ │ * _d_i_s_k___i_n_t_e_r_f_a_c_e
│ │ │ │ o _n_e_w___t_o_r_r_e_n_t_(_)
│ │ │ │ o _r_e_m_o_v_e___t_o_r_r_e_n_t_(_)
│ │ │ │ o _a_s_y_n_c___r_e_a_d_(_)_ _a_s_y_n_c___w_r_i_t_e_(_)
│ │ │ │ o _a_s_y_n_c___h_a_s_h_(_)
│ │ │ │ o _a_s_y_n_c___h_a_s_h_2_(_)
│ │ │ │ @@ -32,28 +33,322 @@
│ │ │ │ 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_(_)
│ │ │ │ - * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e
│ │ │ │ * _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()), int
│ │ │ │ +(b.size())), 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::status_t::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::no_error, 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 update_stats_counters(lt::counters&) const override {}
│ │ │ │ +
│ │ │ │ + std::vector get_status(lt::storage_index_t) const
│ │ │ │ +override
│ │ │ │ + { return {}; }
│ │ │ │ +
│ │ │ │ + void submit_jobs() override {}
│ │ │ │ +
│ │ │ │ +private:
│ │ │ │ +
│ │ │ │ + lt::aux::vector, lt::storage_index_t>
│ │ │ │ +m_torrents;
│ │ │ │ +
│ │ │ │ + // slots that are unused in the m_torrents vector
│ │ │ │ + std::vector m_free_slots;
│ │ │ │ +
│ │ │ │ + // callbacks are posted on this
│ │ │ │ + lt::io_context& m_ioc;
│ │ │ │ +};
│ │ │ │ +
│ │ │ │ +std::unique_ptr temp_disk_constructor(
│ │ │ │ + lt::io_context& ioc, lt::settings_interface const&, lt::counters&)
│ │ │ │ +{
│ │ │ │ + return std::make_unique(ioc);
│ │ │ │ +}
│ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ +************ sseettttiinnggss__iinntteerrffaaccee ************
│ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p"
│ │ │ │ +the common interface to _s_e_t_t_i_n_g_s___p_a_c_k and the internal representation of
│ │ │ │ +settings.
│ │ │ │ +struct settings_interface
│ │ │ │ +{
│ │ │ │ + virtual void sseett__ssttrr (int name, std::string val) = 0;
│ │ │ │ + virtual void sseett__iinntt (int name, int val) = 0;
│ │ │ │ + virtual bool hhaass__vvaall (int name) const = 0;
│ │ │ │ + virtual void sseett__bbooooll (int name, bool val) = 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]
│ │ │ │ ************ 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
│ │ │ │ {
│ │ │ │ @@ -90,21 +385,21 @@
│ │ │ │ thread via the io_context object passed into the constructor. The callbacks
│ │ │ │ will be run in the network thread.
│ │ │ │ struct disk_interface
│ │ │ │ {
│ │ │ │ virtual storage_holder nneeww__ttoorrrreenntt (storage_params const& p
│ │ │ │ , std::shared_ptr const& torrent) = 0;
│ │ │ │ virtual void rreemmoovvee__ttoorrrreenntt (storage_index_t) = 0;
│ │ │ │ - virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
│ │ │ │ - , std::function handler
│ │ │ │ - , disk_job_flags_t flags = {}) = 0;
│ │ │ │ virtual bool aassyynncc__wwrriittee (storage_index_t storage, peer_request const& r
│ │ │ │ , char const* buf, std::shared_ptr o
│ │ │ │ , std::function handler
│ │ │ │ , disk_job_flags_t flags = {}) = 0;
│ │ │ │ + virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
│ │ │ │ + , std::function handler
│ │ │ │ + , disk_job_flags_t flags = {}) = 0;
│ │ │ │ virtual void aassyynncc__hhaasshh (storage_index_t storage, piece_index_t piece,
│ │ │ │ span v2
│ │ │ │ , disk_job_flags_t flags
│ │ │ │ , std::function handler) = 0;
│ │ │ │ virtual void aassyynncc__hhaasshh22 (storage_index_t storage, piece_index_t piece, int
│ │ │ │ offset, disk_job_flags_t flags
│ │ │ │ @@ -160,21 +455,21 @@
│ │ │ │ ********** rreemmoovvee__ttoorrrreenntt(()) **********
│ │ │ │ virtual void rreemmoovvee__ttoorrrreenntt (storage_index_t) = 0;
│ │ │ │ remove the storage with the specified index. This is not expected to delete any
│ │ │ │ files from disk, just to clean up any resources associated with the specified
│ │ │ │ storage.
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ ********** aassyynncc__rreeaadd(()) aassyynncc__wwrriittee(()) **********
│ │ │ │ -virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
│ │ │ │ - , std::function handler
│ │ │ │ - , disk_job_flags_t flags = {}) = 0;
│ │ │ │ virtual bool aassyynncc__wwrriittee (storage_index_t storage, peer_request const& r
│ │ │ │ , char const* buf, std::shared_ptr o
│ │ │ │ , std::function handler
│ │ │ │ , disk_job_flags_t flags = {}) = 0;
│ │ │ │ +virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
│ │ │ │ + , std::function handler
│ │ │ │ + , disk_job_flags_t flags = {}) = 0;
│ │ │ │ perform a read or write operation from/to the specified storage index and the
│ │ │ │ specified request. When the operation completes, call handler possibly with a
│ │ │ │ _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r, holding the buffer with the result. Flags may be set to
│ │ │ │ affect the read operation. See disk_job_flags_t.
│ │ │ │ The _d_i_s_k___o_b_s_e_r_v_e_r is a callback to indicate that the store buffer/disk write
│ │ │ │ queue is below the watermark to let peers start writing buffers to disk again.
│ │ │ │ When async_write() returns true, indicating the write queue is full, the peer
│ │ │ │ @@ -362,21 +657,21 @@
│ │ │ │ (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 ();
│ │ │ │ - storage_holder& ooppeerraattoorr== (storage_holder const&) = delete;
│ │ │ │ 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;
│ │ │ │ };
│ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e]
│ │ │ │ ************ ddiisskk__oobbsseerrvveerr ************
│ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___o_b_s_e_r_v_e_r_._h_p_p"
│ │ │ │ struct disk_observer
│ │ │ │ @@ -405,16 +700,16 @@
│ │ │ │ it's destructed
│ │ │ │ If this buffer holder is moved-from, default constructed or reset, data() will
│ │ │ │ return nullptr.
│ │ │ │ struct disk_buffer_holder
│ │ │ │ {
│ │ │ │ disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder&&) & noexcept;
│ │ │ │ ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder&&) noexcept;
│ │ │ │ - disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder const&) = delete;
│ │ │ │ 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, int sz) noexcept;
│ │ │ │ ddiisskk__bbuuffffeerr__hhoollddeerr () noexcept = default;
│ │ │ │ ~~ddiisskk__bbuuffffeerr__hhoollddeerr ();
│ │ │ │ char* ddaattaa () const noexcept;
│ │ │ │ void rreesseett ();
│ │ │ │ void sswwaapp (disk_buffer_holder& h) noexcept;
│ │ │ │ @@ -454,29 +749,14 @@
│ │ │ │ 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]
│ │ │ │ -************ 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 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]
│ │ │ │ ************ 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
│ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html
│ │ │ @@ -47,16 +47,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]
│ │ │
│ │ │
counters()
│ │ │
│ │ │ virtual dht_storage_counters counters () const = 0;
│ │ │
│ │ │
return stats counters for the store
│ │ │ -
[report issue]
│ │ │ +[report issue]
│ │ │